From 5cdb04477b7614c4af1ccf00ede5491a0b6f1cca Mon Sep 17 00:00:00 2001 From: zhangsiqi <2825463979@qq.com> Date: Fri, 21 Jun 2024 13:34:48 +0800 Subject: [PATCH] =?UTF-8?q?[feat]=20=E9=87=87=E8=B4=AD=E7=AE=A1=E7=90=86?= =?UTF-8?q?=EF=BC=9A=E9=87=87=E8=B4=AD=E5=8D=95=E5=8A=A8=E6=80=81=E9=87=87?= =?UTF-8?q?=E8=B4=AD=E6=95=B0=E6=8D=AE=E3=80=82=E4=BF=AE=E6=94=B9=E5=88=86?= =?UTF-8?q?=E7=B1=BB=E4=BE=9B=E5=BA=94=E5=95=86=E6=96=B9=E6=B3=95=E3=80=82?= =?UTF-8?q?=E4=BE=9B=E5=BA=94=E5=95=86=E8=8E=B7=E5=8F=96=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=EF=BC=8C=E6=B7=BB=E5=8A=A0=E9=9D=9E=E7=A9=BA=E5=88=A4=E6=96=AD?= =?UTF-8?q?=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/PurchaseOrderController.java | 50 ++++++++++--------- .../purchasePlan/addPurchaseOrder.html | 15 +++--- 2 files changed, 35 insertions(+), 30 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java b/ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java index 2f042caa..0f4279eb 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/purchase/controller/PurchaseOrderController.java @@ -116,38 +116,42 @@ public class PurchaseOrderController extends BaseController @ResponseBody public AjaxResult addSave(@RequestBody PurchaseOrder purchaseOrder) throws Exception{ //获取采购订单子表中的供应商,核算供应商数量和采购物料合计以及采购数量合计,采购不含税报价合计,采购含税报价合计 - List 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 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)); } diff --git a/ruoyi-admin/src/main/resources/templates/purchase/purchasePlan/addPurchaseOrder.html b/ruoyi-admin/src/main/resources/templates/purchase/purchasePlan/addPurchaseOrder.html index 3e4f445b..eb28beeb 100644 --- a/ruoyi-admin/src/main/resources/templates/purchase/purchasePlan/addPurchaseOrder.html +++ b/ruoyi-admin/src/main/resources/templates/purchase/purchasePlan/addPurchaseOrder.html @@ -230,14 +230,15 @@ materialRmbSum: 0, purchaseOrderChildList: [] }; - // 遍历每个物料容器 $('.table-materialCode').each(function(index, tableElement) { console.log(tableElement); var tableId = tableIdList[index]; // 从table ID中提取tableId + var materialTable = "bootstrap-table_" + tableId; + var data = $('#' + materialTable).bootstrapTable('getData'); var materialData = { - materialCode: , // 确保能正确获取物料编码 - materialNum: 0, + materialCode:'' , // 假设'materialCode'是你要获取的字段名}) , // 确保能正确获取物料编码 + materialNum:10, materialNoRmbSum: 0, materialRmbSum: 0, purchaseQuoteChildList: [] @@ -246,8 +247,8 @@ var materialNoRmbTotal = $('#' + 'materialNoRmbSum_' + tableId).val(); var materialRmbTotal = $('#' + 'materialRmbSum_' + tableId).val(); materialData.materialNum = parseInt(materialActualNum); - materialData.materialNoRmbSum = materialNoRmbTotal; - materialData.materialRmbSum = materialRmbTotal; + materialData.materialNoRmbSum = parseFloat(materialNoRmbTotal); + materialData.materialRmbSum = parseFloat(materialRmbTotal); // 遍历该物料下的供应商信息 $('#' + 'material-' + tableId).find('.supplier-card').each(function(supplierIndex, supplierCard) { var supplierQuote = { @@ -261,8 +262,8 @@ materialData.purchaseQuoteChildList.push(supplierQuote); purchaseOrder.supplierNum += 1; // 累加供应商数量 }); - purchaseOrder.materialNoRmbSum += $("#" + 'material-'+ tableId ).find("supplierTotal_" + tableId).find("input[name='materialNoRmbSum']"); - purchaseOrder.materialRmbSum += $("#" + 'material-'+ tableId ).find("supplierTotal_" + tableId).find("input[name='materialNoRmbSum']"); // 累加含税总价 + purchaseOrder.materialNoRmbSum += parseFloat(materialNoRmbTotal) ; + purchaseOrder.materialRmbSum += parseFloat(materialRmbTotal); // 累加含税总价 purchaseOrder.purchaseOrderChildList.push(materialData); });