|
@ -232,276 +232,7 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public int insertPurchaseOrder(PurchaseOrder purchaseOrder) |
|
|
public int insertPurchaseOrder(PurchaseOrder purchaseOrder) |
|
|
{ |
|
|
{ |
|
|
// 生成采购订单编号
|
|
|
return 1; |
|
|
purchaseOrder.setPurchaseOrderCode(redisCache.generateBillNo("CG")); |
|
|
|
|
|
// 初始化累加变量
|
|
|
|
|
|
BigDecimal materialNoRmb = BigDecimal.ZERO; |
|
|
|
|
|
BigDecimal materialRmb = BigDecimal.ZERO; |
|
|
|
|
|
BigDecimal materialNoRmbSum = BigDecimal.ZERO; |
|
|
|
|
|
BigDecimal materialRmbSum = BigDecimal.ZERO; |
|
|
|
|
|
BigDecimal materialNum = BigDecimal.ZERO; |
|
|
|
|
|
int supplierNum = 0; |
|
|
|
|
|
//根据上传的物料信息做采购订单子项
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(purchaseOrder.getPurchaseOrderChildList())) { |
|
|
|
|
|
supplierNum = purchaseOrder.getPurchaseOrderChildList().size(); |
|
|
|
|
|
} |
|
|
|
|
|
if (purchaseOrder.getPurchaseOrderChildList() != null) { |
|
|
|
|
|
List<PurchaseOrderChild> purchaseOrderChildList = purchaseOrder.getPurchaseOrderChildList(); |
|
|
|
|
|
//订单子表去除实际物料数量位null或者0的物料信息
|
|
|
|
|
|
purchaseOrderChildList = purchaseOrderChildList.stream().filter(child -> child.getMaterialRealNum() != null).collect(Collectors.toList()); |
|
|
|
|
|
for (PurchaseOrderChild child : purchaseOrderChildList) { |
|
|
|
|
|
if (child.getCorrelationCode().contains(",")) |
|
|
|
|
|
{ |
|
|
|
|
|
String[] correlationCodes = child.getCorrelationCode().split(","); |
|
|
|
|
|
String[] planCodes = child.getPurchasePlanCode().split(","); |
|
|
|
|
|
String[] purchaseQuoteCodes = child.getPurchaseQuoteCode().split(","); |
|
|
|
|
|
for (int i = 0; i < planCodes.length - 1; i++) { |
|
|
|
|
|
String planCode = planCodes[i]; |
|
|
|
|
|
PurchasePlan purchasePlan = purchasePlanService.selectPurchasePlanByPlanCode(planCode); |
|
|
|
|
|
if (planCode != null) { |
|
|
|
|
|
PurchaseOrderChild material = new PurchaseOrderChild(); |
|
|
|
|
|
child.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode()); |
|
|
|
|
|
//获取物料供应商不含税采购价格
|
|
|
|
|
|
BigDecimal suplierMaterialNoRmb = child.getMaterialRealNoRmb(); |
|
|
|
|
|
// 获取物料供应商含税采购价格
|
|
|
|
|
|
BigDecimal suplierMaterialRmb = child.getMaterialRealRmb(); |
|
|
|
|
|
// 获取物料数量
|
|
|
|
|
|
BigDecimal suplierMaterialNum = child.getMaterialRealNum(); |
|
|
|
|
|
if(suplierMaterialNoRmb == null){suplierMaterialNoRmb = BigDecimal.ZERO;} |
|
|
|
|
|
if(suplierMaterialRmb == null){suplierMaterialRmb = BigDecimal.ZERO;} |
|
|
|
|
|
if(suplierMaterialNum == null){suplierMaterialNum = new BigDecimal(0);} |
|
|
|
|
|
//获取供应商不含税价格合计 = 物料数量 * 供应商采购不含税价格
|
|
|
|
|
|
BigDecimal suplierMaterialNoRmbSumLocal = suplierMaterialNoRmb.multiply(suplierMaterialNum); |
|
|
|
|
|
//获取供应商含税价格合计 = 物料数量 * 供应商采购含税价格
|
|
|
|
|
|
BigDecimal suplierMaterialRmbSumLocal = suplierMaterialRmb.multiply(suplierMaterialNum); |
|
|
|
|
|
// 累加物料数量
|
|
|
|
|
|
materialNum = materialNum.add(suplierMaterialNum); |
|
|
|
|
|
// 累加物料总价
|
|
|
|
|
|
materialNoRmbSum = materialNoRmbSum.add(suplierMaterialNoRmbSumLocal); |
|
|
|
|
|
// 累加物料含税总价
|
|
|
|
|
|
materialRmbSum = materialRmbSum.add(suplierMaterialRmbSumLocal); |
|
|
|
|
|
// 设置采购报价单编号和供应商信息到QuoteChild
|
|
|
|
|
|
material.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode()); |
|
|
|
|
|
material.setPurchasePlanCorrelationCode(correlationCodes[i]); |
|
|
|
|
|
material.setSupplierCode(child.getSupplierCode()); |
|
|
|
|
|
material.setMaterialUnit(child.getMaterialUnit()); |
|
|
|
|
|
material.setWarehouseDept(child.getWarehouseDept()); |
|
|
|
|
|
material.setSupplierName(child.getSupplierName()); |
|
|
|
|
|
material.setMaterialCode(child.getMaterialCode()); |
|
|
|
|
|
material.setMaterialName(child.getMaterialName()); |
|
|
|
|
|
material.setMaterialBrand(child.getMaterialBrand()); |
|
|
|
|
|
material.setMaterialDescribe(child.getMaterialDescribe()); |
|
|
|
|
|
material.setMaterialPhotoUrl(child.getMaterialPhotoUrl()); |
|
|
|
|
|
material.setMaterialProcessMethod(child.getMaterialProcessMethod()); |
|
|
|
|
|
material.setWarehouseDept(child.getWarehouseDept()); |
|
|
|
|
|
//计划采购数
|
|
|
|
|
|
material.setMaterialNum(child.getMaterialNum()); |
|
|
|
|
|
material.setMaterialNoRmb(child.getMaterialNoRmb()); |
|
|
|
|
|
material.setMaterialRmb(child.getMaterialRmb()); |
|
|
|
|
|
material.setMaterialNoRmbSum(child.getMaterialNoRmbSum()); |
|
|
|
|
|
material.setMaterialRmbSum(child.getMaterialRmbSum()); |
|
|
|
|
|
//实际采购数
|
|
|
|
|
|
material.setMaterialRealNum(child.getMaterialRealNum()); |
|
|
|
|
|
material.setMaterialRealNoRmb(child.getMaterialRealNoRmb()); |
|
|
|
|
|
material.setMaterialRealRmb(child.getMaterialRealRmb()); |
|
|
|
|
|
//实际采购单价合计
|
|
|
|
|
|
material.setMaterialRealRmbSum(suplierMaterialRmbSumLocal); |
|
|
|
|
|
material.setMaterialRealNoRmbSum(suplierMaterialNoRmbSumLocal); |
|
|
|
|
|
material.setCorrelationCode(correlationCodes[i]); |
|
|
|
|
|
material.setDeliveryTime(child.getDeliveryTime()); |
|
|
|
|
|
material.setPurchasePlanCode(planCode); |
|
|
|
|
|
material.setPurchaseQuoteCode(child.getPurchaseQuoteCode()); |
|
|
|
|
|
//收货状态,0:未收货,1:已收货 收款状态:0:待付款,1:已付款
|
|
|
|
|
|
material.setEceiptStatus("0"); |
|
|
|
|
|
material.setPaymentStatus("0"); |
|
|
|
|
|
// 执行子表插入操作
|
|
|
|
|
|
purchaseOrderChildService.insertPurchaseOrderChild(material); |
|
|
|
|
|
PurchasePlan plan = new PurchasePlan(); |
|
|
|
|
|
plan.setPurchasePlanCode(planCode); |
|
|
|
|
|
plan.setPurchasePlanStatus("1"); |
|
|
|
|
|
int result = purchasePlanService.updatePurchasePlan(plan); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
else if ((child.getPurchasePlanCode().contains(",") && !child.getCorrelationCode().contains(",") |
|
|
|
|
|
&& child.getCorrelationCode()!= null)) |
|
|
|
|
|
{ |
|
|
|
|
|
String[] planCodes = child.getPurchasePlanCode().split(","); |
|
|
|
|
|
for (int i = 0; i < planCodes.length - 1; i++) { |
|
|
|
|
|
String[] correlationCodes = child.getCorrelationCode().split(","); |
|
|
|
|
|
String[] planCode2 = child.getPurchasePlanCode().split(","); |
|
|
|
|
|
String[] purchaseQuoteCodes = child.getPurchaseQuoteCode().split(","); |
|
|
|
|
|
String planCode = planCode2[i]; |
|
|
|
|
|
PurchasePlan purchasePlan = purchasePlanService.selectPurchasePlanByPlanCode(planCode); |
|
|
|
|
|
if (planCode != null) { |
|
|
|
|
|
PurchaseOrderChild material = new PurchaseOrderChild(); |
|
|
|
|
|
child.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode()); |
|
|
|
|
|
//获取物料供应商不含税采购价格
|
|
|
|
|
|
BigDecimal suplierMaterialNoRmb = child.getMaterialRealNoRmb(); |
|
|
|
|
|
// 获取物料供应商含税采购价格
|
|
|
|
|
|
BigDecimal suplierMaterialRmb = child.getMaterialRealRmb(); |
|
|
|
|
|
// 获取物料数量
|
|
|
|
|
|
BigDecimal suplierMaterialNum = child.getMaterialRealNum(); |
|
|
|
|
|
if (suplierMaterialNoRmb == null) { |
|
|
|
|
|
suplierMaterialNoRmb = BigDecimal.ZERO; |
|
|
|
|
|
} |
|
|
|
|
|
if (suplierMaterialRmb == null) { |
|
|
|
|
|
suplierMaterialRmb = BigDecimal.ZERO; |
|
|
|
|
|
} |
|
|
|
|
|
if (suplierMaterialNum == null) { |
|
|
|
|
|
suplierMaterialNum = new BigDecimal(0); |
|
|
|
|
|
} |
|
|
|
|
|
//获取供应商不含税价格合计 = 物料数量 * 供应商采购不含税价格
|
|
|
|
|
|
BigDecimal suplierMaterialNoRmbSumLocal = suplierMaterialNoRmb.multiply(suplierMaterialNum); |
|
|
|
|
|
//获取供应商含税价格合计 = 物料数量 * 供应商采购含税价格
|
|
|
|
|
|
BigDecimal suplierMaterialRmbSumLocal = suplierMaterialRmb.multiply(suplierMaterialNum); |
|
|
|
|
|
// 累加物料数量
|
|
|
|
|
|
materialNum = materialNum.add(suplierMaterialNum); |
|
|
|
|
|
// 累加物料总价
|
|
|
|
|
|
materialNoRmbSum = materialNoRmbSum.add(suplierMaterialNoRmbSumLocal); |
|
|
|
|
|
// 累加物料含税总价
|
|
|
|
|
|
materialRmbSum = materialRmbSum.add(suplierMaterialRmbSumLocal); |
|
|
|
|
|
// 设置采购报价单编号和供应商信息到QuoteChild
|
|
|
|
|
|
material.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode()); |
|
|
|
|
|
material.setCorrelationCode(purchasePlan.getCorrelationCode()); |
|
|
|
|
|
material.setPurchasePlanCorrelationCode(correlationCodes[i]); |
|
|
|
|
|
material.setSupplierCode(child.getSupplierCode()); |
|
|
|
|
|
material.setMaterialUnit(child.getMaterialUnit()); |
|
|
|
|
|
material.setWarehouseDept(child.getWarehouseDept()); |
|
|
|
|
|
material.setSupplierName(child.getSupplierName()); |
|
|
|
|
|
material.setMaterialCode(child.getMaterialCode()); |
|
|
|
|
|
material.setMaterialName(child.getMaterialName()); |
|
|
|
|
|
material.setMaterialBrand(child.getMaterialBrand()); |
|
|
|
|
|
material.setMaterialDescribe(child.getMaterialDescribe()); |
|
|
|
|
|
material.setMaterialPhotoUrl(child.getMaterialPhotoUrl()); |
|
|
|
|
|
material.setMaterialProcessMethod(child.getMaterialProcessMethod()); |
|
|
|
|
|
material.setWarehouseDept(child.getWarehouseDept()); |
|
|
|
|
|
//计划采购数
|
|
|
|
|
|
material.setMaterialNum(child.getMaterialNum()); |
|
|
|
|
|
material.setMaterialNoRmb(child.getMaterialNoRmb()); |
|
|
|
|
|
material.setMaterialRmb(child.getMaterialRmb()); |
|
|
|
|
|
material.setMaterialNoRmbSum(child.getMaterialNoRmbSum()); |
|
|
|
|
|
material.setMaterialRmbSum(child.getMaterialRmbSum()); |
|
|
|
|
|
//实际采购数
|
|
|
|
|
|
material.setMaterialRealNum(child.getMaterialRealNum()); |
|
|
|
|
|
material.setMaterialRealNoRmb(child.getMaterialRealNoRmb()); |
|
|
|
|
|
material.setMaterialRealRmb(child.getMaterialRealRmb()); |
|
|
|
|
|
material.setDeliveryTime(child.getDeliveryTime()); |
|
|
|
|
|
//实际采购单价合计
|
|
|
|
|
|
material.setMaterialRealRmbSum(suplierMaterialRmbSumLocal); |
|
|
|
|
|
material.setMaterialRealNoRmbSum(suplierMaterialNoRmbSumLocal); |
|
|
|
|
|
material.setCorrelationCode(child.getCorrelationCode()); |
|
|
|
|
|
material.setPurchasePlanCode(planCode); |
|
|
|
|
|
material.setPurchaseQuoteCode(child.getPurchaseQuoteCode()); |
|
|
|
|
|
//收货状态,0:未收货,1:已收货 收款状态:0:待付款,1:已付款
|
|
|
|
|
|
material.setEceiptStatus("0"); |
|
|
|
|
|
material.setPaymentStatus("0"); |
|
|
|
|
|
// 执行子表插入操作
|
|
|
|
|
|
purchaseOrderChildService.insertPurchaseOrderChild(material); |
|
|
|
|
|
PurchasePlan plan = new PurchasePlan(); |
|
|
|
|
|
plan.setPurchasePlanCode(planCode); |
|
|
|
|
|
plan.setPurchasePlanStatus("1"); |
|
|
|
|
|
int result = purchasePlanService.updatePurchasePlan(plan); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
else if(child.getCorrelationCode().contains(",") && child.getCorrelationCode().contains(",") && |
|
|
|
|
|
child.getPurchasePlanCode()!=null && child.getCorrelationCode()!=null){ |
|
|
|
|
|
String planCode = child.getPurchasePlanCode(); |
|
|
|
|
|
PurchasePlan purchasePlan = purchasePlanService.selectPurchasePlanByPlanCode(planCode); |
|
|
|
|
|
if (planCode != null) { |
|
|
|
|
|
PurchaseOrderChild material = new PurchaseOrderChild(); |
|
|
|
|
|
child.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode()); |
|
|
|
|
|
//获取物料供应商不含税采购价格
|
|
|
|
|
|
BigDecimal suplierMaterialNoRmb = child.getMaterialRealNoRmb(); |
|
|
|
|
|
// 获取物料供应商含税采购价格
|
|
|
|
|
|
BigDecimal suplierMaterialRmb = child.getMaterialRealRmb(); |
|
|
|
|
|
// 获取物料数量
|
|
|
|
|
|
BigDecimal suplierMaterialNum = child.getMaterialRealNum(); |
|
|
|
|
|
if (suplierMaterialNoRmb == null) { |
|
|
|
|
|
suplierMaterialNoRmb = BigDecimal.ZERO; |
|
|
|
|
|
} |
|
|
|
|
|
if (suplierMaterialRmb == null) { |
|
|
|
|
|
suplierMaterialRmb = BigDecimal.ZERO; |
|
|
|
|
|
} |
|
|
|
|
|
if (suplierMaterialNum == null) { |
|
|
|
|
|
suplierMaterialNum = new BigDecimal(0); |
|
|
|
|
|
} |
|
|
|
|
|
//获取供应商不含税价格合计 = 物料数量 * 供应商采购不含税价格
|
|
|
|
|
|
BigDecimal suplierMaterialNoRmbSumLocal = suplierMaterialNoRmb.multiply(suplierMaterialNum); |
|
|
|
|
|
//获取供应商含税价格合计 = 物料数量 * 供应商采购含税价格
|
|
|
|
|
|
BigDecimal suplierMaterialRmbSumLocal = suplierMaterialRmb.multiply(suplierMaterialNum); |
|
|
|
|
|
// 累加物料数量
|
|
|
|
|
|
materialNum = materialNum.add(suplierMaterialNum); |
|
|
|
|
|
// 累加物料总价
|
|
|
|
|
|
materialNoRmbSum = materialNoRmbSum.add(suplierMaterialNoRmbSumLocal); |
|
|
|
|
|
// 累加物料含税总价
|
|
|
|
|
|
materialRmbSum = materialRmbSum.add(suplierMaterialRmbSumLocal); |
|
|
|
|
|
// 设置采购报价单编号和供应商信息到QuoteChild
|
|
|
|
|
|
material.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode()); |
|
|
|
|
|
material.setCorrelationCode(purchasePlan.getCorrelationCode()); |
|
|
|
|
|
material.setPurchasePlanCorrelationCode(child.getCorrelationCode()); |
|
|
|
|
|
material.setSupplierCode(child.getSupplierCode()); |
|
|
|
|
|
material.setMaterialUnit(child.getMaterialUnit()); |
|
|
|
|
|
material.setWarehouseDept(child.getWarehouseDept()); |
|
|
|
|
|
material.setSupplierName(child.getSupplierName()); |
|
|
|
|
|
material.setMaterialCode(child.getMaterialCode()); |
|
|
|
|
|
material.setMaterialName(child.getMaterialName()); |
|
|
|
|
|
material.setMaterialBrand(child.getMaterialBrand()); |
|
|
|
|
|
material.setMaterialDescribe(child.getMaterialDescribe()); |
|
|
|
|
|
material.setMaterialPhotoUrl(child.getMaterialPhotoUrl()); |
|
|
|
|
|
material.setMaterialProcessMethod(child.getMaterialProcessMethod()); |
|
|
|
|
|
material.setWarehouseDept(child.getWarehouseDept()); |
|
|
|
|
|
//计划采购数
|
|
|
|
|
|
material.setMaterialNum(child.getMaterialNum()); |
|
|
|
|
|
material.setMaterialNoRmb(child.getMaterialNoRmb()); |
|
|
|
|
|
material.setMaterialRmb(child.getMaterialRmb()); |
|
|
|
|
|
material.setMaterialNoRmbSum(child.getMaterialNoRmbSum()); |
|
|
|
|
|
material.setMaterialRmbSum(child.getMaterialRmbSum()); |
|
|
|
|
|
//实际采购数
|
|
|
|
|
|
material.setMaterialRealNum(child.getMaterialRealNum()); |
|
|
|
|
|
material.setMaterialRealNoRmb(child.getMaterialRealNoRmb()); |
|
|
|
|
|
material.setMaterialRealRmb(child.getMaterialRealRmb()); |
|
|
|
|
|
material.setDeliveryTime(child.getDeliveryTime()); |
|
|
|
|
|
//实际采购单价合计
|
|
|
|
|
|
material.setMaterialRealRmbSum(suplierMaterialRmbSumLocal); |
|
|
|
|
|
material.setMaterialRealNoRmbSum(suplierMaterialNoRmbSumLocal); |
|
|
|
|
|
material.setCorrelationCode(child.getCorrelationCode()); |
|
|
|
|
|
material.setPurchasePlanCode(child.getPurchasePlanCode()); |
|
|
|
|
|
material.setPurchaseQuoteCode(child.getPurchaseQuoteCode()); |
|
|
|
|
|
//收货状态,0:未收货,1:已收货 收款状态:0:待付款,1:已付款
|
|
|
|
|
|
material.setEceiptStatus("0"); |
|
|
|
|
|
material.setPaymentStatus("0"); |
|
|
|
|
|
// 执行子表插入操作
|
|
|
|
|
|
purchaseOrderChildService.insertPurchaseOrderChild(material); |
|
|
|
|
|
PurchasePlan plan = new PurchasePlan(); |
|
|
|
|
|
plan.setPurchasePlanCode(child.getPurchasePlanCode()); |
|
|
|
|
|
plan.setPurchasePlanStatus("1"); |
|
|
|
|
|
int result = purchasePlanService.updatePurchasePlan(plan); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
// 遍历处理采购订单子表
|
|
|
|
|
|
// 设置累加的物料信息到子表
|
|
|
|
|
|
|
|
|
|
|
|
// purchaseOrder.setMaterialSum(purchaseOrder.getMaterialSum());
|
|
|
|
|
|
// purchaseOrder.setNoRmbSum(purchaseOrder.getNoRmbSum());
|
|
|
|
|
|
// purchaseOrder.setRmbSum(purchaseOrder.getRmbSum());
|
|
|
|
|
|
// 设置主表的供应商数量
|
|
|
|
|
|
purchaseOrder.setSupplierNum(supplierNum); |
|
|
|
|
|
purchaseOrder.setNoRmbSum(materialNoRmbSum); |
|
|
|
|
|
purchaseOrder.setRmbSum(materialRmbSum); |
|
|
|
|
|
purchaseOrder.setDelFlag("0"); |
|
|
|
|
|
purchaseOrder.setEceiptStatus("0"); |
|
|
|
|
|
purchaseOrder.setPaymentStatus("0"); |
|
|
|
|
|
purchaseOrder.setPurchaseBuyer(purchaseOrder.getPurchaseBuyer()); |
|
|
|
|
|
purchaseOrder.setCreateTime(DateUtils.getNowDate()); |
|
|
|
|
|
purchaseOrder.setCreateBy(ShiroUtils.getLoginName()); |
|
|
|
|
|
Set<String> amountSet = purchaseOrder.getPurchaseOrderChildList().stream().map(PurchaseOrderChild::getMaterialCode).collect(Collectors.toSet()); |
|
|
|
|
|
Integer amount = amountSet.size(); |
|
|
|
|
|
purchaseOrder.setMaterialAmount(amount); |
|
|
|
|
|
return purchaseOrderMapper.insertPurchaseOrder(purchaseOrder); |
|
|
|
|
|
} |
|
|
} |
|
|
//生成应付账款,根据物料的供应商划分应付供应商,供应商的物料价格合计。
|
|
|
//生成应付账款,根据物料的供应商划分应付供应商,供应商的物料价格合计。
|
|
|
public int purchaseOrderPayment(PurchaseOrder purchaseOrder) { |
|
|
public int purchaseOrderPayment(PurchaseOrder purchaseOrder) { |
|
@ -531,270 +262,7 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService |
|
|
@Override |
|
|
@Override |
|
|
public int updatePurchaseOrderCode(PurchaseOrder purchaseOrder) |
|
|
public int updatePurchaseOrderCode(PurchaseOrder purchaseOrder) |
|
|
{ |
|
|
{ |
|
|
// 初始化累加变量
|
|
|
return 1; |
|
|
BigDecimal materialNoRmb = BigDecimal.ZERO; |
|
|
|
|
|
BigDecimal materialRmb = BigDecimal.ZERO; |
|
|
|
|
|
BigDecimal materialNoRmbSum = BigDecimal.ZERO; |
|
|
|
|
|
BigDecimal materialRmbSum = BigDecimal.ZERO; |
|
|
|
|
|
BigDecimal materialNum = BigDecimal.ZERO; |
|
|
|
|
|
int supplierNum = 0; |
|
|
|
|
|
//根据上传的物料信息做采购订单子项
|
|
|
|
|
|
if (!CollectionUtils.isEmpty(purchaseOrder.getPurchaseOrderChildList())) { |
|
|
|
|
|
supplierNum = purchaseOrder.getPurchaseOrderChildList().size(); |
|
|
|
|
|
} |
|
|
|
|
|
if (purchaseOrder.getPurchaseOrderChildList() != null) { |
|
|
|
|
|
List<PurchaseOrderChild> purchaseOrderChildList = purchaseOrder.getPurchaseOrderChildList(); |
|
|
|
|
|
//订单子表去除实际物料数量位null或者0的物料信息
|
|
|
|
|
|
purchaseOrderChildList = purchaseOrderChildList.stream().filter(child -> child.getMaterialRealNum() != null).collect(Collectors.toList()); |
|
|
|
|
|
for (PurchaseOrderChild child : purchaseOrderChildList) { |
|
|
|
|
|
purchaseOrderChildService.deletePurchaseOrderChildByPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode()); |
|
|
|
|
|
if (child.getCorrelationCode().contains(",")) |
|
|
|
|
|
{ |
|
|
|
|
|
String[] correlationCodes = child.getCorrelationCode().split(","); |
|
|
|
|
|
String[] planCodes = child.getPurchasePlanCode().split(","); |
|
|
|
|
|
String[] purchaseQuoteCodes = child.getPurchaseQuoteCode().split(","); |
|
|
|
|
|
for (int i = 0; i < planCodes.length - 1; i++) { |
|
|
|
|
|
String planCode = planCodes[i]; |
|
|
|
|
|
PurchasePlan purchasePlan = purchasePlanService.selectPurchasePlanByPlanCode(planCode); |
|
|
|
|
|
if (planCode != null) { |
|
|
|
|
|
PurchaseOrderChild material = new PurchaseOrderChild(); |
|
|
|
|
|
child.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode()); |
|
|
|
|
|
//获取物料供应商不含税采购价格
|
|
|
|
|
|
BigDecimal suplierMaterialNoRmb = child.getMaterialRealNoRmb(); |
|
|
|
|
|
// 获取物料供应商含税采购价格
|
|
|
|
|
|
BigDecimal suplierMaterialRmb = child.getMaterialRealRmb(); |
|
|
|
|
|
// 获取物料数量
|
|
|
|
|
|
BigDecimal suplierMaterialNum = child.getMaterialRealNum(); |
|
|
|
|
|
if(suplierMaterialNoRmb == null){suplierMaterialNoRmb = BigDecimal.ZERO;} |
|
|
|
|
|
if(suplierMaterialRmb == null){suplierMaterialRmb = BigDecimal.ZERO;} |
|
|
|
|
|
if(suplierMaterialNum == null){suplierMaterialNum = new BigDecimal(0);} |
|
|
|
|
|
//获取供应商不含税价格合计 = 物料数量 * 供应商采购不含税价格
|
|
|
|
|
|
BigDecimal suplierMaterialNoRmbSumLocal = suplierMaterialNoRmb.multiply(suplierMaterialNum); |
|
|
|
|
|
//获取供应商含税价格合计 = 物料数量 * 供应商采购含税价格
|
|
|
|
|
|
BigDecimal suplierMaterialRmbSumLocal = suplierMaterialRmb.multiply(suplierMaterialNum); |
|
|
|
|
|
// 累加物料数量
|
|
|
|
|
|
materialNum = materialNum.add(suplierMaterialNum); |
|
|
|
|
|
// 累加物料总价
|
|
|
|
|
|
materialNoRmbSum = materialNoRmbSum.add(suplierMaterialNoRmbSumLocal); |
|
|
|
|
|
// 累加物料含税总价
|
|
|
|
|
|
materialRmbSum = materialRmbSum.add(suplierMaterialRmbSumLocal); |
|
|
|
|
|
// 设置采购报价单编号和供应商信息到QuoteChild
|
|
|
|
|
|
material.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode()); |
|
|
|
|
|
material.setPurchasePlanCorrelationCode(correlationCodes[i]); |
|
|
|
|
|
material.setSupplierCode(child.getSupplierCode()); |
|
|
|
|
|
material.setMaterialUnit(child.getMaterialUnit()); |
|
|
|
|
|
material.setWarehouseDept(child.getWarehouseDept()); |
|
|
|
|
|
material.setSupplierName(child.getSupplierName()); |
|
|
|
|
|
material.setMaterialCode(child.getMaterialCode()); |
|
|
|
|
|
material.setMaterialName(child.getMaterialName()); |
|
|
|
|
|
material.setMaterialBrand(child.getMaterialBrand()); |
|
|
|
|
|
material.setMaterialDescribe(child.getMaterialDescribe()); |
|
|
|
|
|
material.setMaterialPhotoUrl(child.getMaterialPhotoUrl()); |
|
|
|
|
|
material.setMaterialProcessMethod(child.getMaterialProcessMethod()); |
|
|
|
|
|
material.setWarehouseDept(child.getWarehouseDept()); |
|
|
|
|
|
//计划采购数
|
|
|
|
|
|
material.setMaterialNum(child.getMaterialNum()); |
|
|
|
|
|
material.setMaterialNoRmb(child.getMaterialNoRmb()); |
|
|
|
|
|
material.setMaterialRmb(child.getMaterialRmb()); |
|
|
|
|
|
material.setMaterialNoRmbSum(child.getMaterialNoRmbSum()); |
|
|
|
|
|
material.setMaterialRmbSum(child.getMaterialRmbSum()); |
|
|
|
|
|
//实际采购数
|
|
|
|
|
|
material.setMaterialRealNum(child.getMaterialRealNum()); |
|
|
|
|
|
material.setMaterialRealNoRmb(child.getMaterialRealNoRmb()); |
|
|
|
|
|
material.setMaterialRealRmb(child.getMaterialRealRmb()); |
|
|
|
|
|
//实际采购单价合计
|
|
|
|
|
|
material.setMaterialRealRmbSum(suplierMaterialRmbSumLocal); |
|
|
|
|
|
material.setMaterialRealNoRmbSum(suplierMaterialNoRmbSumLocal); |
|
|
|
|
|
material.setCorrelationCode(correlationCodes[i]); |
|
|
|
|
|
material.setDeliveryTime(child.getDeliveryTime()); |
|
|
|
|
|
material.setPurchasePlanCode(planCode); |
|
|
|
|
|
material.setPurchaseQuoteCode(child.getPurchaseQuoteCode()); |
|
|
|
|
|
//收货状态,0:未收货,1:已收货 收款状态:0:待付款,1:已付款
|
|
|
|
|
|
material.setEceiptStatus("0"); |
|
|
|
|
|
material.setPaymentStatus("0"); |
|
|
|
|
|
// 执行子表插入操作
|
|
|
|
|
|
purchaseOrderChildService.insertPurchaseOrderChild(material); |
|
|
|
|
|
PurchasePlan plan = new PurchasePlan(); |
|
|
|
|
|
plan.setPurchasePlanCode(planCode); |
|
|
|
|
|
plan.setPurchasePlanStatus("1"); |
|
|
|
|
|
int result = purchasePlanService.updatePurchasePlan(plan); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
else if ((child.getPurchasePlanCode().contains(",") && !child.getCorrelationCode().contains(",") |
|
|
|
|
|
&& child.getCorrelationCode()!= null)) { |
|
|
|
|
|
String[] planCodes = child.getPurchasePlanCode().split(","); |
|
|
|
|
|
for (int i = 0; i < planCodes.length - 1; i++) { |
|
|
|
|
|
String[] correlationCodes = child.getCorrelationCode().split(","); |
|
|
|
|
|
String[] planCode2 = child.getPurchasePlanCode().split(","); |
|
|
|
|
|
String[] purchaseQuoteCodes = child.getPurchaseQuoteCode().split(","); |
|
|
|
|
|
String planCode = planCode2[i]; |
|
|
|
|
|
PurchasePlan purchasePlan = purchasePlanService.selectPurchasePlanByPlanCode(planCode); |
|
|
|
|
|
if (planCode != null) { |
|
|
|
|
|
PurchaseOrderChild material = new PurchaseOrderChild(); |
|
|
|
|
|
child.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode()); |
|
|
|
|
|
//获取物料供应商不含税采购价格
|
|
|
|
|
|
BigDecimal suplierMaterialNoRmb = child.getMaterialRealNoRmb(); |
|
|
|
|
|
// 获取物料供应商含税采购价格
|
|
|
|
|
|
BigDecimal suplierMaterialRmb = child.getMaterialRealRmb(); |
|
|
|
|
|
// 获取物料数量
|
|
|
|
|
|
BigDecimal suplierMaterialNum = child.getMaterialRealNum(); |
|
|
|
|
|
if (suplierMaterialNoRmb == null) { |
|
|
|
|
|
suplierMaterialNoRmb = BigDecimal.ZERO; |
|
|
|
|
|
} |
|
|
|
|
|
if (suplierMaterialRmb == null) { |
|
|
|
|
|
suplierMaterialRmb = BigDecimal.ZERO; |
|
|
|
|
|
} |
|
|
|
|
|
if (suplierMaterialNum == null) { |
|
|
|
|
|
suplierMaterialNum = new BigDecimal(0); |
|
|
|
|
|
} |
|
|
|
|
|
//获取供应商不含税价格合计 = 物料数量 * 供应商采购不含税价格
|
|
|
|
|
|
BigDecimal suplierMaterialNoRmbSumLocal = suplierMaterialNoRmb.multiply(suplierMaterialNum); |
|
|
|
|
|
//获取供应商含税价格合计 = 物料数量 * 供应商采购含税价格
|
|
|
|
|
|
BigDecimal suplierMaterialRmbSumLocal = suplierMaterialRmb.multiply(suplierMaterialNum); |
|
|
|
|
|
// 累加物料数量
|
|
|
|
|
|
materialNum = materialNum.add(suplierMaterialNum); |
|
|
|
|
|
// 累加物料总价
|
|
|
|
|
|
materialNoRmbSum = materialNoRmbSum.add(suplierMaterialNoRmbSumLocal); |
|
|
|
|
|
// 累加物料含税总价
|
|
|
|
|
|
materialRmbSum = materialRmbSum.add(suplierMaterialRmbSumLocal); |
|
|
|
|
|
// 设置采购报价单编号和供应商信息到QuoteChild
|
|
|
|
|
|
material.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode()); |
|
|
|
|
|
material.setCorrelationCode(purchasePlan.getCorrelationCode()); |
|
|
|
|
|
material.setPurchasePlanCorrelationCode(correlationCodes[i]); |
|
|
|
|
|
material.setSupplierCode(child.getSupplierCode()); |
|
|
|
|
|
material.setMaterialUnit(child.getMaterialUnit()); |
|
|
|
|
|
material.setWarehouseDept(child.getWarehouseDept()); |
|
|
|
|
|
material.setSupplierName(child.getSupplierName()); |
|
|
|
|
|
material.setMaterialCode(child.getMaterialCode()); |
|
|
|
|
|
material.setMaterialName(child.getMaterialName()); |
|
|
|
|
|
material.setMaterialBrand(child.getMaterialBrand()); |
|
|
|
|
|
material.setMaterialDescribe(child.getMaterialDescribe()); |
|
|
|
|
|
material.setMaterialPhotoUrl(child.getMaterialPhotoUrl()); |
|
|
|
|
|
material.setMaterialProcessMethod(child.getMaterialProcessMethod()); |
|
|
|
|
|
material.setWarehouseDept(child.getWarehouseDept()); |
|
|
|
|
|
//计划采购数
|
|
|
|
|
|
material.setMaterialNum(child.getMaterialNum()); |
|
|
|
|
|
material.setMaterialNoRmb(child.getMaterialNoRmb()); |
|
|
|
|
|
material.setMaterialRmb(child.getMaterialRmb()); |
|
|
|
|
|
material.setMaterialNoRmbSum(child.getMaterialNoRmbSum()); |
|
|
|
|
|
material.setMaterialRmbSum(child.getMaterialRmbSum()); |
|
|
|
|
|
//实际采购数
|
|
|
|
|
|
material.setMaterialRealNum(child.getMaterialRealNum()); |
|
|
|
|
|
material.setMaterialRealNoRmb(child.getMaterialRealNoRmb()); |
|
|
|
|
|
material.setMaterialRealRmb(child.getMaterialRealRmb()); |
|
|
|
|
|
material.setDeliveryTime(child.getDeliveryTime()); |
|
|
|
|
|
//实际采购单价合计
|
|
|
|
|
|
material.setMaterialRealRmbSum(suplierMaterialRmbSumLocal); |
|
|
|
|
|
material.setMaterialRealNoRmbSum(suplierMaterialNoRmbSumLocal); |
|
|
|
|
|
material.setCorrelationCode(child.getCorrelationCode()); |
|
|
|
|
|
material.setPurchasePlanCode(planCode); |
|
|
|
|
|
material.setPurchaseQuoteCode(child.getPurchaseQuoteCode()); |
|
|
|
|
|
//收货状态,0:未收货,1:已收货 收款状态:0:待付款,1:已付款
|
|
|
|
|
|
material.setEceiptStatus("0"); |
|
|
|
|
|
material.setPaymentStatus("0"); |
|
|
|
|
|
// 执行子表插入操作
|
|
|
|
|
|
purchaseOrderChildService.insertPurchaseOrderChild(material); |
|
|
|
|
|
PurchasePlan plan = new PurchasePlan(); |
|
|
|
|
|
plan.setPurchasePlanCode(planCode); |
|
|
|
|
|
plan.setPurchasePlanStatus("1"); |
|
|
|
|
|
int result = purchasePlanService.updatePurchasePlan(plan); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
else if(child.getCorrelationCode().contains(",") && child.getCorrelationCode().contains(",") && |
|
|
|
|
|
child.getPurchasePlanCode()!=null && child.getCorrelationCode()!=null){ |
|
|
|
|
|
String planCode = child.getPurchasePlanCode(); |
|
|
|
|
|
PurchasePlan purchasePlan = purchasePlanService.selectPurchasePlanByPlanCode(planCode); |
|
|
|
|
|
if (planCode != null) { |
|
|
|
|
|
PurchaseOrderChild material = new PurchaseOrderChild(); |
|
|
|
|
|
child.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode()); |
|
|
|
|
|
//获取物料供应商不含税采购价格
|
|
|
|
|
|
BigDecimal suplierMaterialNoRmb = child.getMaterialRealNoRmb(); |
|
|
|
|
|
// 获取物料供应商含税采购价格
|
|
|
|
|
|
BigDecimal suplierMaterialRmb = child.getMaterialRealRmb(); |
|
|
|
|
|
// 获取物料数量
|
|
|
|
|
|
BigDecimal suplierMaterialNum = child.getMaterialRealNum(); |
|
|
|
|
|
if (suplierMaterialNoRmb == null) { |
|
|
|
|
|
suplierMaterialNoRmb = BigDecimal.ZERO; |
|
|
|
|
|
} |
|
|
|
|
|
if (suplierMaterialRmb == null) { |
|
|
|
|
|
suplierMaterialRmb = BigDecimal.ZERO; |
|
|
|
|
|
} |
|
|
|
|
|
if (suplierMaterialNum == null) { |
|
|
|
|
|
suplierMaterialNum = new BigDecimal(0); |
|
|
|
|
|
} |
|
|
|
|
|
//获取供应商不含税价格合计 = 物料数量 * 供应商采购不含税价格
|
|
|
|
|
|
BigDecimal suplierMaterialNoRmbSumLocal = suplierMaterialNoRmb.multiply(suplierMaterialNum); |
|
|
|
|
|
//获取供应商含税价格合计 = 物料数量 * 供应商采购含税价格
|
|
|
|
|
|
BigDecimal suplierMaterialRmbSumLocal = suplierMaterialRmb.multiply(suplierMaterialNum); |
|
|
|
|
|
// 累加物料数量
|
|
|
|
|
|
materialNum = materialNum.add(suplierMaterialNum); |
|
|
|
|
|
// 累加物料总价
|
|
|
|
|
|
materialNoRmbSum = materialNoRmbSum.add(suplierMaterialNoRmbSumLocal); |
|
|
|
|
|
// 累加物料含税总价
|
|
|
|
|
|
materialRmbSum = materialRmbSum.add(suplierMaterialRmbSumLocal); |
|
|
|
|
|
// 设置采购报价单编号和供应商信息到QuoteChild
|
|
|
|
|
|
material.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode()); |
|
|
|
|
|
material.setCorrelationCode(purchasePlan.getCorrelationCode()); |
|
|
|
|
|
material.setPurchasePlanCorrelationCode(child.getCorrelationCode()); |
|
|
|
|
|
material.setSupplierCode(child.getSupplierCode()); |
|
|
|
|
|
material.setMaterialUnit(child.getMaterialUnit()); |
|
|
|
|
|
material.setWarehouseDept(child.getWarehouseDept()); |
|
|
|
|
|
material.setSupplierName(child.getSupplierName()); |
|
|
|
|
|
material.setMaterialCode(child.getMaterialCode()); |
|
|
|
|
|
material.setMaterialName(child.getMaterialName()); |
|
|
|
|
|
material.setMaterialBrand(child.getMaterialBrand()); |
|
|
|
|
|
material.setMaterialDescribe(child.getMaterialDescribe()); |
|
|
|
|
|
material.setMaterialPhotoUrl(child.getMaterialPhotoUrl()); |
|
|
|
|
|
material.setMaterialProcessMethod(child.getMaterialProcessMethod()); |
|
|
|
|
|
material.setWarehouseDept(child.getWarehouseDept()); |
|
|
|
|
|
//计划采购数
|
|
|
|
|
|
material.setMaterialNum(child.getMaterialNum()); |
|
|
|
|
|
material.setMaterialNoRmb(child.getMaterialNoRmb()); |
|
|
|
|
|
material.setMaterialRmb(child.getMaterialRmb()); |
|
|
|
|
|
material.setMaterialNoRmbSum(child.getMaterialNoRmbSum()); |
|
|
|
|
|
material.setMaterialRmbSum(child.getMaterialRmbSum()); |
|
|
|
|
|
//实际采购数
|
|
|
|
|
|
material.setMaterialRealNum(child.getMaterialRealNum()); |
|
|
|
|
|
material.setMaterialRealNoRmb(child.getMaterialRealNoRmb()); |
|
|
|
|
|
material.setMaterialRealRmb(child.getMaterialRealRmb()); |
|
|
|
|
|
material.setDeliveryTime(child.getDeliveryTime()); |
|
|
|
|
|
//实际采购单价合计
|
|
|
|
|
|
material.setMaterialRealRmbSum(suplierMaterialRmbSumLocal); |
|
|
|
|
|
material.setMaterialRealNoRmbSum(suplierMaterialNoRmbSumLocal); |
|
|
|
|
|
material.setCorrelationCode(child.getCorrelationCode()); |
|
|
|
|
|
material.setPurchasePlanCode(child.getPurchasePlanCode()); |
|
|
|
|
|
material.setPurchaseQuoteCode(child.getPurchaseQuoteCode()); |
|
|
|
|
|
//收货状态,0:未收货,1:已收货 收款状态:0:待付款,1:已付款
|
|
|
|
|
|
material.setEceiptStatus("0"); |
|
|
|
|
|
material.setPaymentStatus("0"); |
|
|
|
|
|
// 执行子表插入操作
|
|
|
|
|
|
purchaseOrderChildService.insertPurchaseOrderChild(material); |
|
|
|
|
|
PurchasePlan plan = new PurchasePlan(); |
|
|
|
|
|
plan.setPurchasePlanCode(child.getPurchasePlanCode()); |
|
|
|
|
|
plan.setPurchasePlanStatus("1"); |
|
|
|
|
|
int result = purchasePlanService.updatePurchasePlan(plan); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
// 遍历处理采购订单子表
|
|
|
|
|
|
// 设置累加的物料信息到子表
|
|
|
|
|
|
// 设置主表的供应商数量
|
|
|
|
|
|
purchaseOrder.setSupplierNum(supplierNum); |
|
|
|
|
|
purchaseOrder.setNoRmbSum(materialNoRmbSum); |
|
|
|
|
|
purchaseOrder.setRmbSum(materialRmbSum); |
|
|
|
|
|
purchaseOrder.setDelFlag("0"); |
|
|
|
|
|
purchaseOrder.setEceiptStatus("0"); |
|
|
|
|
|
purchaseOrder.setPaymentStatus("0"); |
|
|
|
|
|
purchaseOrder.setPurchaseBuyer(purchaseOrder.getPurchaseBuyer()); |
|
|
|
|
|
purchaseOrder.setCreateTime(DateUtils.getNowDate()); |
|
|
|
|
|
purchaseOrder.setCreateBy(ShiroUtils.getLoginName()); |
|
|
|
|
|
Set<String> amountSet = purchaseOrder.getPurchaseOrderChildList().stream().map(PurchaseOrderChild::getMaterialCode).collect(Collectors.toSet()); |
|
|
|
|
|
Integer amount = amountSet.size(); |
|
|
|
|
|
purchaseOrder.setMaterialAmount(amount); |
|
|
|
|
|
return purchaseOrderMapper.updatePurchaseOrder(purchaseOrder); |
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@ -927,72 +395,6 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService |
|
|
@Override |
|
|
@Override |
|
|
public Integer addPurchaseOrderPayable(PurchaseOrder purchaseOrder){ |
|
|
public Integer addPurchaseOrderPayable(PurchaseOrder purchaseOrder){ |
|
|
//根据供应商划分物料信息,合计物料不含税单价 ,含税单价,含税总价,不含税总价,实际采购数量
|
|
|
//根据供应商划分物料信息,合计物料不含税单价 ,含税单价,含税总价,不含税总价,实际采购数量
|
|
|
// 获取采购订单的子项列表
|
|
|
|
|
|
List<PurchaseOrderChild> children = purchaseOrderChildService.selectPurchaseOrderChildByOrderCode(purchaseOrder.getPurchaseOrderCode()); |
|
|
|
|
|
// 分组供应商的子订单,分组统计各供应商应付单供应商
|
|
|
|
|
|
List<PurchaseOrderChild> supplierGroup = (List<PurchaseOrderChild>) children.stream() |
|
|
|
|
|
// 分组依据为supplierCode
|
|
|
|
|
|
.collect(Collectors.groupingBy(PurchaseOrderChild::getSupplierCode)) |
|
|
|
|
|
// 把每个分组转为流,然后取第一个元素
|
|
|
|
|
|
.values().stream() |
|
|
|
|
|
.map(groupSupplier -> groupSupplier.stream().findFirst().orElse(null)) |
|
|
|
|
|
// 过滤掉null值,以防万一某些分组是空的
|
|
|
|
|
|
.filter(Objects::nonNull) |
|
|
|
|
|
.collect(Collectors.toList()); |
|
|
|
|
|
//根据物料中提出的供应商列表核对, 遍历每个相关的子订单,合计数据量
|
|
|
|
|
|
for (PurchaseOrderChild purchaseOrderChild : supplierGroup) { |
|
|
|
|
|
//初始化合计数
|
|
|
|
|
|
BigDecimal supplierNoRmbPrice = BigDecimal.ZERO; |
|
|
|
|
|
BigDecimal supplierRmbTaxPrice = BigDecimal.ZERO; |
|
|
|
|
|
List<PurchaseOrderChild> purchaseOrderChildList = purchaseOrder.getPurchaseOrderChildList(); |
|
|
|
|
|
//创建供应商应付单
|
|
|
|
|
|
FinancialAccountsPayable financialAccountsPayable = new FinancialAccountsPayable(); |
|
|
|
|
|
financialAccountsPayable.setAccountsPayableCode(redisCache.generateBillNo("YF")); |
|
|
|
|
|
financialAccountsPayable.setRelevanceCode(purchaseOrder.getPurchaseOrderCode()); |
|
|
|
|
|
for (PurchaseOrderChild purchaseOrderChild1 : children) { |
|
|
|
|
|
//如果是如上述的供应商,则进行统计
|
|
|
|
|
|
if (purchaseOrderChild1.getSupplierCode().equals(purchaseOrderChild.getSupplierCode())) { |
|
|
|
|
|
//供应商应付账款 不含税金额
|
|
|
|
|
|
supplierNoRmbPrice = supplierNoRmbPrice.add(purchaseOrderChild1.getMaterialRealNoRmbSum()); |
|
|
|
|
|
//供应商应付账款 含税金额
|
|
|
|
|
|
supplierRmbTaxPrice = supplierRmbTaxPrice.add(purchaseOrderChild1.getMaterialRealRmbSum()); |
|
|
|
|
|
}else{ |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
//每当当前供应商完成一次循环,生成一条供应商应付账款
|
|
|
|
|
|
SysSupplier sysSupplier = sysSupplierService.selectSysSupplierByCode(purchaseOrderChild.getSupplierCode()); |
|
|
|
|
|
if(ObjectUtils.isEmpty(sysSupplier)){ |
|
|
|
|
|
continue; |
|
|
|
|
|
}else{ |
|
|
|
|
|
//获取供应商开户银行
|
|
|
|
|
|
financialAccountsPayable.setOpenBank(sysSupplier.getDepositBank()); |
|
|
|
|
|
//供应商银行账号
|
|
|
|
|
|
financialAccountsPayable.setOpenAccount(sysSupplier.getBankAccount()); |
|
|
|
|
|
//供应商付款条件
|
|
|
|
|
|
financialAccountsPayable.setPaymentCondition(sysSupplier.getPaymentTerms()); |
|
|
|
|
|
} |
|
|
|
|
|
//供应商编号
|
|
|
|
|
|
financialAccountsPayable.setSupplierCode(purchaseOrderChild.getSupplierCode()); |
|
|
|
|
|
//供应商名称
|
|
|
|
|
|
financialAccountsPayable.setSupplierName(purchaseOrderChild.getSupplierName()); |
|
|
|
|
|
//创建单号人员
|
|
|
|
|
|
financialAccountsPayable.setCreateBy(ShiroUtils.getLoginName()); |
|
|
|
|
|
//创建时间
|
|
|
|
|
|
financialAccountsPayable.setCreateTime(DateUtils.getNowDate()); |
|
|
|
|
|
//采购订单的采购员
|
|
|
|
|
|
financialAccountsPayable.setPurchaseBuyer(purchaseOrder.getPurchaseBuyer()); |
|
|
|
|
|
//不含税金额
|
|
|
|
|
|
financialAccountsPayable.setPriceExcludingTax(supplierNoRmbPrice); |
|
|
|
|
|
//含税金额
|
|
|
|
|
|
financialAccountsPayable.setPriceIncludesTax(supplierRmbTaxPrice); |
|
|
|
|
|
financialAccountsPayable.setStorageStatus("0"); |
|
|
|
|
|
financialAccountsPayable.setAccountsPayableStatus("0"); |
|
|
|
|
|
financialAccountsPayable.setCreateTime(DateUtils.getNowDate()); |
|
|
|
|
|
financialAccountsPayable.setCreateBy(purchaseOrderChild.getCreateBy()); |
|
|
|
|
|
financialAccountsPayableMapper.insertFinancialAccountsPayable(financialAccountsPayable); |
|
|
|
|
|
} |
|
|
|
|
|
//根据供应商编分组,合计供应商总共合计了多少数,采购物采购,采购物料料
|
|
|
|
|
|
return 1; // 返回成功标识
|
|
|
return 1; // 返回成功标识
|
|
|
} |
|
|
} |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
@ -1105,36 +507,36 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService |
|
|
String orderDate = dateFormat.format(applyTime); |
|
|
String orderDate = dateFormat.format(applyTime); |
|
|
PurchaseOrderChild purchaseOrderChild = new PurchaseOrderChild(); |
|
|
PurchaseOrderChild purchaseOrderChild = new PurchaseOrderChild(); |
|
|
purchaseOrderChild.setPurchaseOrderCode(purchaseOrderCode); |
|
|
purchaseOrderChild.setPurchaseOrderCode(purchaseOrderCode); |
|
|
purchaseOrderChild.setSupplierCode(supplierCode); |
|
|
//purchaseOrderChild.setSupplierCode(supplierCode);
|
|
|
List<PurchaseOrderChild> purchaseOrderChildList = purchaseOrderChildService.selectChildListBySupplierCodeAndOrderCode(purchaseOrderChild); |
|
|
List<PurchaseOrderChild> purchaseOrderChildList = purchaseOrderChildService.selectChildListBySupplierCodeAndOrderCode(purchaseOrderChild); |
|
|
|
|
|
|
|
|
List<Map<String, Object>> detailList = new ArrayList<>(); |
|
|
List<Map<String, Object>> detailList = new ArrayList<>(); |
|
|
|
|
|
|
|
|
// 数字合计金额
|
|
|
// // 数字合计金额
|
|
|
BigDecimal totalAmount = purchaseOrderChildList.stream() |
|
|
// BigDecimal totalAmount = purchaseOrderChildList.stream()
|
|
|
.filter(item -> item.getMaterialRealRmbSum() != null) // 过滤掉值为空的字段
|
|
|
// .filter(item -> item.getMaterialRealRmbSum() != null) // 过滤掉值为空的字段
|
|
|
.map(item -> item.getMaterialRealRmbSum()) |
|
|
// .map(item -> item.getMaterialRealRmbSum())
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add); |
|
|
// .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
//转换成中文金额 //汉字大写合计金额
|
|
|
//转换成中文金额 //汉字大写合计金额
|
|
|
String ChineseCharacterAmount = MoneyUtils.amountConversion(totalAmount.toString()); |
|
|
// String ChineseCharacterAmount = MoneyUtils.amountConversion(totalAmount.toString());
|
|
|
AtomicInteger index = new AtomicInteger(1); |
|
|
AtomicInteger index = new AtomicInteger(1); |
|
|
for (PurchaseOrderChild item : purchaseOrderChildList) { |
|
|
// for (PurchaseOrderChild item : purchaseOrderChildList) {
|
|
|
Map<String, Object> detailMap = new HashMap<>(); |
|
|
// Map<String, Object> detailMap = new HashMap<>();
|
|
|
detailMap.put("index", index.getAndIncrement()); |
|
|
// detailMap.put("index", index.getAndIncrement());
|
|
|
detailMap.put("materialName", item.getMaterialName()); |
|
|
// detailMap.put("materialName", item.getMaterialName());
|
|
|
detailMap.put("materialDescribe", item.getMaterialDescribe()); |
|
|
// detailMap.put("materialDescribe", item.getMaterialDescribe());
|
|
|
detailMap.put("materialUnit", item.getMaterialUnit()); |
|
|
// detailMap.put("materialUnit", item.getMaterialUnit());
|
|
|
detailMap.put("materialRealNum", item.getMaterialRealNum()); |
|
|
// detailMap.put("materialRealNum", item.getMaterialRealNum());
|
|
|
detailMap.put("materialRealRmb", item.getMaterialRealRmb()); |
|
|
// detailMap.put("materialRealRmb", item.getMaterialRealRmb());
|
|
|
detailMap.put("materialRealRmbSum", item.getMaterialRealRmbSum()); |
|
|
// detailMap.put("materialRealRmbSum", item.getMaterialRealRmbSum());
|
|
|
|
|
|
//
|
|
|
// 使用 Optional 来安全地处理可能为 null 的值
|
|
|
// // 使用 Optional 来安全地处理可能为 null 的值
|
|
|
Optional<Date> optionalDeliveryTime = Optional.ofNullable(item.getDeliveryTime()); |
|
|
// Optional<Date> optionalDeliveryTime = Optional.ofNullable(item.getDeliveryTime());
|
|
|
String formattedDeliveryTime = optionalDeliveryTime.map(dateFormat::format).orElse("未提供"); |
|
|
// String formattedDeliveryTime = optionalDeliveryTime.map(dateFormat::format).orElse("未提供");
|
|
|
|
|
|
//
|
|
|
detailMap.put("deliveryTime", formattedDeliveryTime); |
|
|
// detailMap.put("deliveryTime", formattedDeliveryTime);
|
|
|
detailList.add(detailMap); |
|
|
// detailList.add(detailMap);
|
|
|
} |
|
|
// }
|
|
|
|
|
|
|
|
|
//查询仓库信息
|
|
|
//查询仓库信息
|
|
|
|
|
|
|
|
@ -1162,16 +564,16 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService |
|
|
put("depositBank", sysSupplier.getDepositBank()); |
|
|
put("depositBank", sysSupplier.getDepositBank()); |
|
|
put("bankAccount", sysSupplier.getBankAccount()); |
|
|
put("bankAccount", sysSupplier.getBankAccount()); |
|
|
put("exchangeSettlementAccount", sysSupplier.getExchangeSettlementAccount()); |
|
|
put("exchangeSettlementAccount", sysSupplier.getExchangeSettlementAccount()); |
|
|
put("totalAmount", totalAmount); |
|
|
// put("totalAmount", totalAmount);
|
|
|
put("ChineseCharacterAmount", ChineseCharacterAmount); |
|
|
// put("ChineseCharacterAmount", ChineseCharacterAmount);
|
|
|
put("taxRate", taxRate); |
|
|
// put("taxRate", taxRate);
|
|
|
put("enterpriseName", enterpriseName); |
|
|
// put("enterpriseName", enterpriseName);
|
|
|
put("bankAccountWC", bankAccountWC); |
|
|
// put("bankAccountWC", bankAccountWC);
|
|
|
put("depositBankWC", depositBankWC); |
|
|
// put("depositBankWC", depositBankWC);
|
|
|
put("contacts", contacts); |
|
|
// put("contacts", contacts);
|
|
|
put("stockAddress", purchaseOrder.getStockAddress()); |
|
|
// put("stockAddress", purchaseOrder.getStockAddress());
|
|
|
put("stockPhone", purchaseOrder.getStockPhone()); |
|
|
// put("stockPhone", purchaseOrder.getStockPhone());
|
|
|
put("stockContact", purchaseOrder.getStockContact()); |
|
|
// put("stockContact", purchaseOrder.getStockContact());
|
|
|
}} |
|
|
}} |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|