|
@ -255,7 +255,8 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService |
|
|
//订单子表去除实际物料数量位null或者0的物料信息
|
|
|
//订单子表去除实际物料数量位null或者0的物料信息
|
|
|
purchaseOrderChildList = purchaseOrderChildList.stream().filter(child -> child.getMaterialRealNum() != null).collect(Collectors.toList()); |
|
|
purchaseOrderChildList = purchaseOrderChildList.stream().filter(child -> child.getMaterialRealNum() != null).collect(Collectors.toList()); |
|
|
for (PurchaseOrderChild child : purchaseOrderChildList) { |
|
|
for (PurchaseOrderChild child : purchaseOrderChildList) { |
|
|
if (child.getCorrelationCode().contains(",")) { |
|
|
if (child.getCorrelationCode().contains(",")) |
|
|
|
|
|
{ |
|
|
String[] correlationCodes = child.getCorrelationCode().split(","); |
|
|
String[] correlationCodes = child.getCorrelationCode().split(","); |
|
|
String[] planCodes = child.getPurchasePlanCode().split(","); |
|
|
String[] planCodes = child.getPurchasePlanCode().split(","); |
|
|
String[] purchaseQuoteCodes = child.getPurchaseQuoteCode().split(","); |
|
|
String[] purchaseQuoteCodes = child.getPurchaseQuoteCode().split(","); |
|
@ -286,7 +287,7 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService |
|
|
materialRmbSum = materialRmbSum.add(suplierMaterialRmbSumLocal); |
|
|
materialRmbSum = materialRmbSum.add(suplierMaterialRmbSumLocal); |
|
|
// 设置采购报价单编号和供应商信息到QuoteChild
|
|
|
// 设置采购报价单编号和供应商信息到QuoteChild
|
|
|
material.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode()); |
|
|
material.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode()); |
|
|
material.setPurchasePlanCorrelationCode(child.getCorrelationCode()); |
|
|
material.setPurchasePlanCorrelationCode(correlationCodes[i]); |
|
|
material.setSupplierCode(child.getSupplierCode()); |
|
|
material.setSupplierCode(child.getSupplierCode()); |
|
|
material.setMaterialUnit(child.getMaterialUnit()); |
|
|
material.setMaterialUnit(child.getMaterialUnit()); |
|
|
material.setWarehouseDept(child.getWarehouseDept()); |
|
|
material.setWarehouseDept(child.getWarehouseDept()); |
|
@ -311,9 +312,91 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService |
|
|
//实际采购单价合计
|
|
|
//实际采购单价合计
|
|
|
material.setMaterialRealRmbSum(suplierMaterialRmbSumLocal); |
|
|
material.setMaterialRealRmbSum(suplierMaterialRmbSumLocal); |
|
|
material.setMaterialRealNoRmbSum(suplierMaterialNoRmbSumLocal); |
|
|
material.setMaterialRealNoRmbSum(suplierMaterialNoRmbSumLocal); |
|
|
material.setCorrelationCode(child.getCorrelationCode()); |
|
|
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.setDeliveryTime(child.getDeliveryTime()); |
|
|
material.setPurchasePlanCode(child.getPurchasePlanCode()); |
|
|
//实际采购单价合计
|
|
|
|
|
|
material.setMaterialRealRmbSum(suplierMaterialRmbSumLocal); |
|
|
|
|
|
material.setMaterialRealNoRmbSum(suplierMaterialNoRmbSumLocal); |
|
|
|
|
|
material.setCorrelationCode(child.getCorrelationCode()); |
|
|
|
|
|
material.setPurchasePlanCode(planCode); |
|
|
material.setPurchaseQuoteCode(child.getPurchaseQuoteCode()); |
|
|
material.setPurchaseQuoteCode(child.getPurchaseQuoteCode()); |
|
|
//收货状态,0:未收货,1:已收货 收款状态:0:待付款,1:已付款
|
|
|
//收货状态,0:未收货,1:已收货 收款状态:0:待付款,1:已付款
|
|
|
material.setEceiptStatus("0"); |
|
|
material.setEceiptStatus("0"); |
|
@ -321,77 +404,86 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService |
|
|
// 执行子表插入操作
|
|
|
// 执行子表插入操作
|
|
|
purchaseOrderChildService.insertPurchaseOrderChild(material); |
|
|
purchaseOrderChildService.insertPurchaseOrderChild(material); |
|
|
PurchasePlan plan = new PurchasePlan(); |
|
|
PurchasePlan plan = new PurchasePlan(); |
|
|
plan.setPurchasePlanCode(child.getPurchasePlanCode()); |
|
|
plan.setPurchasePlanCode(planCode); |
|
|
plan.setPurchasePlanStatus("1"); |
|
|
plan.setPurchasePlanStatus("1"); |
|
|
int result = purchasePlanService.updatePurchasePlan(plan); |
|
|
int result = purchasePlanService.updatePurchasePlan(plan); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
else if ((!child.getCorrelationCode().contains(",")) |
|
|
else if(child.getCorrelationCode().contains(",") && child.getCorrelationCode().contains(",") && |
|
|
&& child.getPurchasePlanCode() != null) { |
|
|
child.getPurchasePlanCode()!=null && child.getCorrelationCode()!=null){ |
|
|
PurchasePlan purchasePlan = purchasePlanService.selectPurchasePlanByPlanCode(child.getPurchasePlanCode()); |
|
|
String planCode = child.getPurchasePlanCode(); |
|
|
PurchaseOrderChild material = new PurchaseOrderChild(); |
|
|
PurchasePlan purchasePlan = purchasePlanService.selectPurchasePlanByPlanCode(planCode); |
|
|
child.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode()); |
|
|
if (planCode != null) { |
|
|
//获取物料供应商不含税采购价格
|
|
|
PurchaseOrderChild material = new PurchaseOrderChild(); |
|
|
BigDecimal suplierMaterialNoRmb = child.getMaterialRealNoRmb(); |
|
|
child.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode()); |
|
|
// 获取物料供应商含税采购价格
|
|
|
//获取物料供应商不含税采购价格
|
|
|
BigDecimal suplierMaterialRmb = child.getMaterialRealRmb(); |
|
|
BigDecimal suplierMaterialNoRmb = child.getMaterialRealNoRmb(); |
|
|
// 获取物料数量
|
|
|
// 获取物料供应商含税采购价格
|
|
|
BigDecimal suplierMaterialNum = child.getMaterialRealNum(); |
|
|
BigDecimal suplierMaterialRmb = child.getMaterialRealRmb(); |
|
|
if(suplierMaterialNoRmb == null){suplierMaterialNoRmb = BigDecimal.ZERO;} |
|
|
// 获取物料数量
|
|
|
if(suplierMaterialRmb == null){suplierMaterialRmb = BigDecimal.ZERO;} |
|
|
BigDecimal suplierMaterialNum = child.getMaterialRealNum(); |
|
|
if(suplierMaterialNum == null){suplierMaterialNum = new BigDecimal(0);} |
|
|
if (suplierMaterialNoRmb == null) { |
|
|
//获取供应商不含税价格合计 = 物料数量 * 供应商采购不含税价格
|
|
|
suplierMaterialNoRmb = BigDecimal.ZERO; |
|
|
BigDecimal suplierMaterialNoRmbSumLocal = suplierMaterialNoRmb.multiply(suplierMaterialNum); |
|
|
} |
|
|
//获取供应商含税价格合计 = 物料数量 * 供应商采购含税价格
|
|
|
if (suplierMaterialRmb == null) { |
|
|
BigDecimal suplierMaterialRmbSumLocal = suplierMaterialRmb.multiply(suplierMaterialNum); |
|
|
suplierMaterialRmb = BigDecimal.ZERO; |
|
|
// 累加物料数量
|
|
|
} |
|
|
materialNum = materialNum.add(suplierMaterialNum); |
|
|
if (suplierMaterialNum == null) { |
|
|
// 累加物料总价
|
|
|
suplierMaterialNum = new BigDecimal(0); |
|
|
materialNoRmbSum = materialNoRmbSum.add(suplierMaterialNoRmbSumLocal); |
|
|
} |
|
|
// 累加物料含税总价
|
|
|
//获取供应商不含税价格合计 = 物料数量 * 供应商采购不含税价格
|
|
|
materialRmbSum = materialRmbSum.add(suplierMaterialRmbSumLocal); |
|
|
BigDecimal suplierMaterialNoRmbSumLocal = suplierMaterialNoRmb.multiply(suplierMaterialNum); |
|
|
// 设置采购报价单编号和供应商信息到QuoteChild
|
|
|
//获取供应商含税价格合计 = 物料数量 * 供应商采购含税价格
|
|
|
material.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode()); |
|
|
BigDecimal suplierMaterialRmbSumLocal = suplierMaterialRmb.multiply(suplierMaterialNum); |
|
|
material.setCorrelationCode(purchasePlan.getCorrelationCode()); |
|
|
// 累加物料数量
|
|
|
material.setPurchasePlanCorrelationCode(child.getCorrelationCode()); |
|
|
materialNum = materialNum.add(suplierMaterialNum); |
|
|
material.setSupplierCode(child.getSupplierCode()); |
|
|
// 累加物料总价
|
|
|
material.setMaterialUnit(child.getMaterialUnit()); |
|
|
materialNoRmbSum = materialNoRmbSum.add(suplierMaterialNoRmbSumLocal); |
|
|
material.setWarehouseDept(child.getWarehouseDept()); |
|
|
// 累加物料含税总价
|
|
|
material.setSupplierName(child.getSupplierName()); |
|
|
materialRmbSum = materialRmbSum.add(suplierMaterialRmbSumLocal); |
|
|
material.setMaterialCode(child.getMaterialCode()); |
|
|
// 设置采购报价单编号和供应商信息到QuoteChild
|
|
|
material.setMaterialName(child.getMaterialName()); |
|
|
material.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode()); |
|
|
material.setMaterialBrand(child.getMaterialBrand()); |
|
|
material.setCorrelationCode(purchasePlan.getCorrelationCode()); |
|
|
material.setMaterialDescribe(child.getMaterialDescribe()); |
|
|
material.setPurchasePlanCorrelationCode(child.getCorrelationCode()); |
|
|
material.setMaterialPhotoUrl(child.getMaterialPhotoUrl()); |
|
|
material.setSupplierCode(child.getSupplierCode()); |
|
|
material.setMaterialProcessMethod(child.getMaterialProcessMethod()); |
|
|
material.setMaterialUnit(child.getMaterialUnit()); |
|
|
material.setWarehouseDept(child.getWarehouseDept()); |
|
|
material.setWarehouseDept(child.getWarehouseDept()); |
|
|
//计划采购数
|
|
|
material.setSupplierName(child.getSupplierName()); |
|
|
material.setMaterialNum(child.getMaterialNum()); |
|
|
material.setMaterialCode(child.getMaterialCode()); |
|
|
material.setMaterialNoRmb(child.getMaterialNoRmb()); |
|
|
material.setMaterialName(child.getMaterialName()); |
|
|
material.setMaterialRmb(child.getMaterialRmb()); |
|
|
material.setMaterialBrand(child.getMaterialBrand()); |
|
|
material.setMaterialNoRmbSum(child.getMaterialNoRmbSum()); |
|
|
material.setMaterialDescribe(child.getMaterialDescribe()); |
|
|
material.setMaterialRmbSum(child.getMaterialRmbSum()); |
|
|
material.setMaterialPhotoUrl(child.getMaterialPhotoUrl()); |
|
|
//实际采购数
|
|
|
material.setMaterialProcessMethod(child.getMaterialProcessMethod()); |
|
|
material.setMaterialRealNum(child.getMaterialRealNum()); |
|
|
material.setWarehouseDept(child.getWarehouseDept()); |
|
|
material.setMaterialRealNoRmb(child.getMaterialRealNoRmb()); |
|
|
//计划采购数
|
|
|
material.setMaterialRealRmb(child.getMaterialRealRmb()); |
|
|
material.setMaterialNum(child.getMaterialNum()); |
|
|
material.setDeliveryTime(child.getDeliveryTime()); |
|
|
material.setMaterialNoRmb(child.getMaterialNoRmb()); |
|
|
//实际采购单价合计
|
|
|
material.setMaterialRmb(child.getMaterialRmb()); |
|
|
material.setMaterialRealRmbSum(suplierMaterialRmbSumLocal); |
|
|
material.setMaterialNoRmbSum(child.getMaterialNoRmbSum()); |
|
|
material.setMaterialRealNoRmbSum(suplierMaterialNoRmbSumLocal); |
|
|
material.setMaterialRmbSum(child.getMaterialRmbSum()); |
|
|
material.setCorrelationCode(child.getCorrelationCode()); |
|
|
//实际采购数
|
|
|
material.setPurchasePlanCode(child.getPurchasePlanCode()); |
|
|
material.setMaterialRealNum(child.getMaterialRealNum()); |
|
|
material.setPurchaseQuoteCode(child.getPurchaseQuoteCode()); |
|
|
material.setMaterialRealNoRmb(child.getMaterialRealNoRmb()); |
|
|
//收货状态,0:未收货,1:已收货 收款状态:0:待付款,1:已付款
|
|
|
material.setMaterialRealRmb(child.getMaterialRealRmb()); |
|
|
material.setEceiptStatus("0"); |
|
|
material.setDeliveryTime(child.getDeliveryTime()); |
|
|
material.setPaymentStatus("0"); |
|
|
//实际采购单价合计
|
|
|
// 执行子表插入操作
|
|
|
material.setMaterialRealRmbSum(suplierMaterialRmbSumLocal); |
|
|
purchaseOrderChildService.insertPurchaseOrderChild(material); |
|
|
material.setMaterialRealNoRmbSum(suplierMaterialNoRmbSumLocal); |
|
|
PurchasePlan plan = new PurchasePlan(); |
|
|
material.setCorrelationCode(child.getCorrelationCode()); |
|
|
plan.setPurchasePlanCode(child.getPurchasePlanCode()); |
|
|
material.setPurchasePlanCode(child.getPurchasePlanCode()); |
|
|
plan.setPurchasePlanStatus("1"); |
|
|
material.setPurchaseQuoteCode(child.getPurchaseQuoteCode()); |
|
|
int result = purchasePlanService.updatePurchasePlan(plan); |
|
|
//收货状态,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); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -430,6 +522,178 @@ public class PurchaseOrderServiceImpl implements IPurchaseOrderService |
|
|
@Override |
|
|
@Override |
|
|
public int updatePurchaseOrder(PurchaseOrder purchaseOrder) |
|
|
public int updatePurchaseOrder(PurchaseOrder purchaseOrder) |
|
|
{ |
|
|
{ |
|
|
|
|
|
// 初始化累加变量
|
|
|
|
|
|
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()); |
|
|
|
|
|
if (!CollectionUtils.isEmpty(purchaseOrderChildList)) { |
|
|
|
|
|
purchaseOrderChildService.deletePurchaseOrderChildByPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode()); |
|
|
|
|
|
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(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.setMaterialRealRmbSum(suplierMaterialRmbSumLocal); |
|
|
|
|
|
material.setMaterialRealNoRmbSum(suplierMaterialNoRmbSumLocal); |
|
|
|
|
|
material.setCorrelationCode(child.getCorrelationCode()); |
|
|
|
|
|
material.setDeliveryTime(child.getDeliveryTime()); |
|
|
|
|
|
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); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
else if ((!child.getCorrelationCode().contains(",")) |
|
|
|
|
|
&& child.getPurchasePlanCode() != null) { |
|
|
|
|
|
PurchasePlan purchasePlan = purchasePlanService.selectPurchasePlanByPlanCode(child.getPurchasePlanCode()); |
|
|
|
|
|
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); |
|
|
purchaseOrder.setCreateTime(DateUtils.getNowDate()); |
|
|
purchaseOrder.setCreateTime(DateUtils.getNowDate()); |
|
|
purchaseOrder.setCreateBy(ShiroUtils.getLoginName()); |
|
|
purchaseOrder.setCreateBy(ShiroUtils.getLoginName()); |
|
|
return purchaseOrderMapper.updatePurchaseOrder(purchaseOrder); |
|
|
return purchaseOrderMapper.updatePurchaseOrder(purchaseOrder); |
|
|