|
|
@ -116,38 +116,42 @@ public class PurchaseOrderController extends BaseController |
|
|
|
@ResponseBody |
|
|
|
public AjaxResult addSave(@RequestBody PurchaseOrder purchaseOrder) throws Exception{ |
|
|
|
//获取采购订单子表中的供应商,核算供应商数量和采购物料合计以及采购数量合计,采购不含税报价合计,采购含税报价合计
|
|
|
|
List<PurchaseOrderChild> purchaseMaterials = purchaseOrder.getPurchaseOrderChildList(); |
|
|
|
purchaseOrder.setPurchaseOrderCode(redisCache.generateBillNo("CG")); |
|
|
|
BigDecimal materialNoRmb = BigDecimal.valueOf(0.0); |
|
|
|
BigDecimal materialRmb = BigDecimal.valueOf(0.0); |
|
|
|
BigDecimal materialNoRmbSum = BigDecimal.valueOf(0.0); |
|
|
|
BigDecimal materialRmbSum = BigDecimal.valueOf(0.0); |
|
|
|
BigDecimal materialSum = BigDecimal.valueOf(0.0); |
|
|
|
List<PurchaseOrderChild> purchaseMaterials = new ArrayList<>(); |
|
|
|
Long materialNum = 0L; |
|
|
|
int supplierNum = 0; |
|
|
|
for (PurchaseOrderChild purchaseOrderChild : purchaseMaterials) { |
|
|
|
purchaseOrderChild.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode()); |
|
|
|
for (PurchaseQuoteChild purchaseSupplierQuote : purchaseOrderChild.getPurchaseQuoteChildList()){ |
|
|
|
BigDecimal suplierMaterialNoRmb = purchaseSupplierQuote.getMaterialNoRmb(); |
|
|
|
BigDecimal suplierMaterialRmb = purchaseSupplierQuote.getMaterialRmb(); |
|
|
|
Long suplierMaterialNum = purchaseSupplierQuote.getMaterialNum(); |
|
|
|
BigDecimal suplierMaterialNoRmbSum = suplierMaterialNoRmb.multiply(BigDecimal.valueOf(suplierMaterialNum)); |
|
|
|
BigDecimal suplierMaterialRmbSum = suplierMaterialRmb.multiply(BigDecimal.valueOf(suplierMaterialNum)); |
|
|
|
materialNum = materialNum + suplierMaterialNum; |
|
|
|
materialNoRmb = materialNoRmb.add(purchaseSupplierQuote.getMaterialNoRmb()); |
|
|
|
materialRmb = materialRmb.add(purchaseSupplierQuote.getMaterialRmb()); |
|
|
|
materialRmbSum = materialRmbSum.add(suplierMaterialRmbSum); |
|
|
|
materialNoRmbSum = materialNoRmbSum.add(suplierMaterialNoRmbSum); |
|
|
|
purchaseSupplierQuote.setPurchaseQuoteCode(purchaseOrder.getPurchaseOrderCode()); |
|
|
|
if (purchaseSupplierQuote.getSupplierCode() != null){ |
|
|
|
supplierNum ++; |
|
|
|
} |
|
|
|
int purOdersize = purchaseOrder.getPurchaseOrderChildList().size(); |
|
|
|
if(purOdersize > 1){ |
|
|
|
purchaseMaterials = purchaseOrder.getPurchaseOrderChildList(); |
|
|
|
for (PurchaseOrderChild purchaseOrderChild : purchaseMaterials) { |
|
|
|
purchaseOrderChild.setPurchaseOrderCode(purchaseOrder.getPurchaseOrderCode()); |
|
|
|
for (PurchaseQuoteChild purchaseSupplierQuote : purchaseOrderChild.getPurchaseQuoteChildList()){ |
|
|
|
BigDecimal suplierMaterialNoRmb = purchaseSupplierQuote.getMaterialNoRmb(); |
|
|
|
BigDecimal suplierMaterialRmb = purchaseSupplierQuote.getMaterialRmb(); |
|
|
|
Long suplierMaterialNum = purchaseSupplierQuote.getMaterialNum(); |
|
|
|
BigDecimal suplierMaterialNoRmbSum = suplierMaterialNoRmb.multiply(BigDecimal.valueOf(suplierMaterialNum)); |
|
|
|
BigDecimal suplierMaterialRmbSum = suplierMaterialRmb.multiply(BigDecimal.valueOf(suplierMaterialNum)); |
|
|
|
materialNum = materialNum + suplierMaterialNum; |
|
|
|
materialNoRmb = materialNoRmb.add(purchaseSupplierQuote.getMaterialNoRmb()); |
|
|
|
materialRmb = materialRmb.add(purchaseSupplierQuote.getMaterialRmb()); |
|
|
|
materialRmbSum = materialRmbSum.add(suplierMaterialRmbSum); |
|
|
|
materialNoRmbSum = materialNoRmbSum.add(suplierMaterialNoRmbSum); |
|
|
|
purchaseSupplierQuote.setPurchaseQuoteCode(purchaseOrder.getPurchaseOrderCode()); |
|
|
|
if (purchaseSupplierQuote.getSupplierCode() != null){ |
|
|
|
supplierNum ++; |
|
|
|
} |
|
|
|
} |
|
|
|
purchaseOrderChild.setMaterialNormb(materialNoRmb); |
|
|
|
purchaseOrderChild.setMaterialRmb(materialRmb); |
|
|
|
purchaseOrderChild.setMaterialNum(materialNum); |
|
|
|
} |
|
|
|
purchaseOrderChild.setMaterialNormb(materialNoRmb); |
|
|
|
purchaseOrderChild.setMaterialRmb(materialRmb); |
|
|
|
purchaseOrderChild.setMaterialNum(materialNum); |
|
|
|
} |
|
|
|
purchaseOrder.setSupplierNum(supplierNum); |
|
|
|
purchaseOrder.setSupplierNum(supplierNum); |
|
|
|
} |
|
|
|
return toAjax(purchaseOrderService.insertPurchaseOrder(purchaseOrder)); |
|
|
|
} |
|
|
|
|
|
|
|