Browse Source

[feat]采购管理

修改采购计划添加采购订单,采购计划刚开始和子表没有不含税单价和含税单价,添加采购订单的时候,把从后端查询的最新审核通过的采购报价的数据添加到采购计划子表和主表中,主表是子表的合计;并且如果不含税单价、含税单价、最新报价没有值不能提交,提示:无物料报价,请先通过采购报价审核
dev
liuxiaoxu 2 days ago
parent
commit
b2657ffcc4
  1. 35
      ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderServiceImpl.java

35
ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchaseOrderServiceImpl.java

@ -351,6 +351,21 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
throw new BusinessException("请填写本次采购数量");
}
// 判断价格是否为空,如果为空,提示,无物料报价,需要通过采购报价审核
boolean anyNullLatestQuoteRmb = purchasePlanSelectMaterialVoList.stream().anyMatch(item -> item.getLatestQuoteRmb() == null);
if (anyNullLatestQuoteRmb) {
throw new BusinessException("无物料报价,请先通过采购报价审核");
}
boolean anyNullRmbSum = purchasePlanSelectMaterialVoList.stream().anyMatch(item -> item.getMaterialRmbSum() == null);
if (anyNullRmbSum) {
throw new BusinessException("无物料报价,请先通过采购报价审核");
}
boolean anyNullNoRmbSum = purchasePlanSelectMaterialVoList.stream().anyMatch(item -> item.getMaterialNoRmbSum() == null);
if (anyNullNoRmbSum) {
throw new BusinessException("无物料报价,请先通过采购报价审核");
}
purchaseOrder.setPurchaseOrderCode(redisCache.generateBillNo("CG"));
purchaseOrder.setPurchasePlanCode(purchasePlanOne.getPurchasePlanCodes());
purchaseOrder.setPaymentStatus("0");
@ -467,6 +482,10 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
oldChild.setUpdateTime(new Date());
oldChild.setUpdateBy(ShiroUtils.getLoginName());
oldChild.setThisPurchaseNum(thisPurchaseNum);
oldChild.setMaterialNoRmbSum(purchasePlanSelectMaterialVo.getMaterialNoRmbSum());
oldChild.setMaterialRmbSum(purchasePlanSelectMaterialVo.getMaterialRmbSum());
oldChild.setLatestQuoteRmb(purchasePlanSelectMaterialVo.getLatestQuoteRmb());
//收集更新后的子表数据
purchasePlanChildren.add(oldChild);
int result = purchasePlanChildMapper.updatePurchasePlanChild(oldChild);
@ -489,6 +508,10 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
.collect(Collectors.groupingBy(PurchasePlanChild::getPurchasePlanCode));
List<PurchasePlanSelectMaterialVo> purchasePlanSelectMaterialVoList = addPurchaseOrder.getPurchasePlanSelectMaterialVoList();
PurchasePlanOne purchasePlanOne = addPurchaseOrder.getPurchasePlanOne();
String purchasePlanCodes = purchasePlanOne.getPurchasePlanCodes();
//得到本次采购的所有采购计划单号
@ -530,6 +553,18 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService
int currentPurchaseSum = purchasePlan.getPurchaseSum();
purchasePlan.setPurchaseSum(currentPurchaseSum - thisPurchaseSum);
// 计算合计值
double totalNoRmbSum = children.stream().mapToDouble(vo -> vo.getMaterialNoRmbSum().doubleValue()).sum();
double totalRmbSum = children.stream().mapToDouble(vo -> vo.getMaterialRmbSum().doubleValue()).sum();
// 将结果转换回 BigDecimal
BigDecimal totalBigDecimalNoRmbSum = BigDecimal.valueOf(totalNoRmbSum);
BigDecimal totalBigDecimalRmbSum = BigDecimal.valueOf(totalRmbSum);
purchasePlan.setRmbSum(totalBigDecimalRmbSum.add(purchasePlan.getRmbSum()));
purchasePlan.setNoRmbSum(totalBigDecimalNoRmbSum.add(purchasePlan.getNoRmbSum()));
// 更新采购计划状态
if (purchasePlan.getActualPurchaseSum() < purchasePlan.getPlanPurchaseSum()) {
purchasePlan.setPurchasePlanStatus("1");

Loading…
Cancel
Save