From d6fed8a2797e8b571e2bd59f7441394fb5210690 Mon Sep 17 00:00:00 2001 From: liuxiaoxu <1793812695@qq.com> Date: Sun, 30 Jun 2024 15:12:17 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=20=E9=87=87=E8=B4=AD=E7=AE=A1=E7=90=86=20?= =?UTF-8?q?=E5=B7=A5=E7=A8=8B=E7=AE=A1=E7=90=86=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E9=87=87=E8=B4=AD=E8=AE=A1=E5=88=92=E8=AF=A6=E6=83=85=E5=89=8D?= =?UTF-8?q?=E7=AB=AF=E9=A1=B5=E9=9D=A2=E5=AD=97=E6=AE=B5=20=E4=BF=AE?= =?UTF-8?q?=E6=94=B9=E9=87=87=E8=B4=AD=E8=AE=A1=E5=88=92=E5=89=8D=E7=AB=AF?= =?UTF-8?q?=E9=A1=B5=E9=9D=A2=E5=AD=97=E6=AE=B5=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E7=94=9F=E4=BA=A7=E8=AE=A2=E5=8D=95=E8=BD=AC=E9=87=87=E8=B4=AD?= =?UTF-8?q?=E8=AE=A1=E5=88=92=EF=BC=8C=E6=B7=BB=E5=8A=A0=E9=87=87=E8=B4=AD?= =?UTF-8?q?=E8=AE=A1=E5=88=92=E7=9A=84=E6=96=B9=E6=B3=95=EF=BC=9A=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E7=89=A9=E6=96=99=E5=90=88=E8=AE=A1=E5=92=8C=E6=95=B0?= =?UTF-8?q?=E9=87=8F=E5=90=88=E8=AE=A1=E7=9A=84=E8=AE=A1=E7=AE=97=20?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=94=9F=E4=BA=A7=E8=AE=A2=E5=8D=95=E8=BD=AC?= =?UTF-8?q?=E9=87=87=E8=B4=AD=E8=AE=A1=E5=88=92=E8=AF=A6=E6=83=85=EF=BC=8C?= =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=87=87=E8=B4=AD=E8=AE=A1=E5=88=92=E8=AF=A6?= =?UTF-8?q?=E6=83=85=E7=9A=84=E6=96=B9=E6=B3=95=EF=BC=9A=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E8=AE=A1=E5=88=92=E9=87=87=E8=B4=AD=E6=95=B0=E7=9A=84=E8=AE=A1?= =?UTF-8?q?=E7=AE=97=20=E4=BF=AE=E6=94=B9bom=20=E6=A0=B9=E6=8D=AEbom?= =?UTF-8?q?=E5=8F=B7=E6=9F=A5=E8=AF=A2=E6=8A=A5=E9=94=99=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/PurchasePlanServiceImpl.java | 42 ++++++++++++---- .../service/impl/SysMakeOrderServiceImpl.java | 50 +++++++++++++------ .../resources/mapper/erp/ErpBomMapper.xml | 2 +- .../purchase/purchasePlan/detail.html | 8 ++- .../purchase/purchasePlan/purchasePlan.html | 6 +-- 5 files changed, 71 insertions(+), 37 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchasePlanServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchasePlanServiceImpl.java index b9782463..8aa6a405 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchasePlanServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/purchase/service/impl/PurchasePlanServiceImpl.java @@ -4,6 +4,7 @@ import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.util.Date; import java.util.List; +import java.util.stream.Collectors; import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.utils.DateUtils; @@ -163,8 +164,22 @@ public class PurchasePlanServiceImpl implements IPurchasePlanService // 仅查询一次,因为所有SysMakeorderBom都关联同一生产单号 SysMakeOrder sysMakeOrder = sysMakeOrderMapper.selectMakeOrderByMakeNo(insertedSysMakeorderBoms.get(0).getMakeNo()); + //保存所有加工方式为采购的物料 + List filterSysMakeorderBoms = insertedSysMakeorderBoms.stream().filter(bom -> "0".equals(bom.getProcessMethod())).collect(Collectors.toList()); + //统计物料种类的数量 + Integer materialAmount = filterSysMakeorderBoms.size(); + + //统计数量合计 + //生产订单中的订单数量 + Long makeOrderMaterialSum = sysMakeOrder.getMaterialSum(); + //加工方式为采购的所有物料用量合计 + Long sum = filterSysMakeorderBoms.stream().mapToLong(SysMakeorderBom::getUseNum).sum(); + + Long purchasePlanMaterialSum = makeOrderMaterialSum * sum; // 创建采购计划主记录 - PurchasePlan purchasePlan = buildPurchasePlan(sysMakeOrder, purchasePlanCode); + PurchasePlan purchasePlan = buildPurchasePlan(sysMakeOrder, purchasePlanCode,materialAmount,purchasePlanMaterialSum); + + purchasePlanMapper.insertPurchasePlan(purchasePlan); // 批量创建采购计划子项 @@ -178,18 +193,16 @@ public class PurchasePlanServiceImpl implements IPurchasePlanService return redisCache.generateBillNo("CGJH"); } - private PurchasePlan buildPurchasePlan(SysMakeOrder sysMakeOrder, String purchasePlanCode) { + private PurchasePlan buildPurchasePlan(SysMakeOrder sysMakeOrder, String purchasePlanCode,Integer materialAmount,Long purchasePlanMaterialSum) { PurchasePlan purchasePlan = new PurchasePlan(); purchasePlan.setCorrelationCode(sysMakeOrder.getMakeNo()); purchasePlan.setPurchasePlanCode(purchasePlanCode); purchasePlan.setPurchasePlanType("1"); - if (StringUtils.isNotBlank(sysMakeOrder.getMaterial())) { - purchasePlan.setMaterialAmount(Long.parseLong(sysMakeOrder.getMaterial())); - } else { - // 如果该字段允许为NULL或有默认值,可以这样设置 - purchasePlan.setMaterialAmount(0L); // 或者设定一个默认值,例如:0L - } - purchasePlan.setMaterialSum(sysMakeOrder.getMaterialSum()); + //添加物料合计 + purchasePlan.setMaterialAmount((long) materialAmount); + + //添加数量合计 + purchasePlan.setMaterialSum(purchasePlanMaterialSum); purchasePlan.setNoRmbSum(sysMakeOrder.getNoRate()); purchasePlan.setRmbSum(sysMakeOrder.getRate()); purchasePlan.setApplyUser(sysMakeOrder.getSalesman()); @@ -202,6 +215,9 @@ public class PurchasePlanServiceImpl implements IPurchasePlanService } private void insertPurchasePlanChildren(List insertedSysMakeorderBoms, String purchasePlanCode, SysMakeOrder sysMakeOrder) { + + //生产订单中的订单数量 + Long makeOrderMaterialSum = sysMakeOrder.getMaterialSum(); for (SysMakeorderBom bom : insertedSysMakeorderBoms) { if ("0".equals(bom.getProcessMethod())) { PurchasePlanChild purchasePlanChild = new PurchasePlanChild(); @@ -211,12 +227,16 @@ public class PurchasePlanServiceImpl implements IPurchasePlanService purchasePlanChild.setMaterialType(bom.getMaterialType()); //新增物料入库部门 purchasePlanChild.setWarehouseDept(bom.getWarehouseDept()); - purchasePlanChild.setProcessMethod("采购"); + purchasePlanChild.setProcessMethod("0"); purchasePlanChild.setBrand(bom.getBrand()); purchasePlanChild.setDescribe(bom.getDescribe()); - purchasePlanChild.setMaterialNum(bom.getUseNum()); + //物料用量 + Long useNum = bom.getUseNum(); + //物料的计划采购数 + purchasePlanChild.setMaterialNum(useNum * makeOrderMaterialSum); purchasePlanChild.setCreateBy(ShiroUtils.getLoginName()); purchasePlanChild.setCreateTime(new Date()); + purchasePlanChild.setUnit(bom.getUnit()); purchasePlanChildMapper.insertPurchasePlanChild(purchasePlanChild); } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysMakeOrderServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysMakeOrderServiceImpl.java index 5495e766..5db56e28 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysMakeOrderServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysMakeOrderServiceImpl.java @@ -258,23 +258,41 @@ public class SysMakeOrderServiceImpl implements ISysMakeOrderService String materialCode = sysSalesOrderChild.getMaterialCode(); // 0阶 ErpBom erpBom = erpBomService.selectErpBomByOneMaterialNo(materialCode); - Long id = erpBom.getId(); - // 查询1阶及以下 - ErpBom oneLevelBom = new ErpBom(); - oneLevelBom.setParentId(id); - List subBomList = erpBomService.selectErpBomAllLevelList(oneLevelBom); - for (int j = 0; j < subBomList.size(); j++) { - ErpBom subBom = subBomList.get(j); - SysMakeorderBom orderBom = new SysMakeorderBom(); - BeanUtils.copyProperties(subBom,orderBom, "id","delFlag","createBy","createTime","updateBy","updateTime","remark"); - orderBom.setMakeNo(makeNo); - orderBom.setSalesOrderCode(saleNo); - orderBom.setSalesOrderMaterialNo(materialCode); - sortNo++; - orderBom.setSortNo(sortNo); - makeorderBomService.insertSysMakeorderBom(orderBom); - insertedSysMakeorderBoms.add(orderBom); + if (erpBom != null){ + Long id = erpBom.getId(); + // 查询1阶及以下 + ErpBom oneLevelBom = new ErpBom(); + oneLevelBom.setParentId(id); + List subBomList = erpBomService.selectErpBomAllLevelList(oneLevelBom); + for (int j = 0; j < subBomList.size(); j++) { + ErpBom subBom = subBomList.get(j); + SysMakeorderBom orderBom = new SysMakeorderBom(); + BeanUtils.copyProperties(subBom,orderBom, "id","delFlag","createBy","createTime","updateBy","updateTime","remark"); + orderBom.setMakeNo(makeNo); + orderBom.setSalesOrderCode(saleNo); + orderBom.setSalesOrderMaterialNo(materialCode); + sortNo++; + orderBom.setSortNo(sortNo); + makeorderBomService.insertSysMakeorderBom(orderBom); + insertedSysMakeorderBoms.add(orderBom); + } + }else { + ErpBom oneLevelBom = new ErpBom(); + List subBomList = erpBomService.selectErpBomAllLevelList(oneLevelBom); + for (int j = 0; j < subBomList.size(); j++) { + ErpBom subBom = subBomList.get(j); + SysMakeorderBom orderBom = new SysMakeorderBom(); + BeanUtils.copyProperties(subBom,orderBom, "id","delFlag","createBy","createTime","updateBy","updateTime","remark"); + orderBom.setMakeNo(makeNo); + orderBom.setSalesOrderCode(saleNo); + orderBom.setSalesOrderMaterialNo(materialCode); + sortNo++; + orderBom.setSortNo(sortNo); + makeorderBomService.insertSysMakeorderBom(orderBom); + insertedSysMakeorderBoms.add(orderBom); + } } + } } // todo 加工方式“采购”的物料生成采购计划 diff --git a/ruoyi-admin/src/main/resources/mapper/erp/ErpBomMapper.xml b/ruoyi-admin/src/main/resources/mapper/erp/ErpBomMapper.xml index 869e14a6..4d61fe05 100644 --- a/ruoyi-admin/src/main/resources/mapper/erp/ErpBomMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/erp/ErpBomMapper.xml @@ -115,7 +115,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" and erp.create_time between #{params.beginCreateTime} and #{params.endCreateTime} and erp.material_no like concat('%', #{params.materialNo}, '%') and erp.material_no = #{materialNo} - and erp.bomNo = #{bomNo} + and erp.bom_no = #{bomNo} and erp.material_name like concat('%', #{materialName}, '%') and erp.audit_status = #{auditStatus} and erp.use_status = #{useStatus} diff --git a/ruoyi-admin/src/main/resources/templates/purchase/purchasePlan/detail.html b/ruoyi-admin/src/main/resources/templates/purchase/purchasePlan/detail.html index ba9d8bb1..aa78314f 100644 --- a/ruoyi-admin/src/main/resources/templates/purchase/purchasePlan/detail.html +++ b/ruoyi-admin/src/main/resources/templates/purchase/purchasePlan/detail.html @@ -107,7 +107,7 @@ }, columns: [ {field: 'purchasePlanId',title: '主键id',visible: false}, - {field: 'materialNo',title: '料号',}, + {field: 'materialCode',title: '料号',}, {field: 'photoUrl',title: '图片', formatter: function(value, row, index) {return $.table.imageView(value);} }, @@ -117,14 +117,12 @@ }, {field: 'describe',title: '描述',}, {field: 'brand',title: '品牌',}, - {field: 'processMethod',title: '半成品类型', + {field: 'processMethod',title: '加工方式', formatter: function(value, row, index) {return $.table.selectDictLabel(processMethodDatas, value);} }, {field: 'unit',title: '单位', - formatter: function(value, row, index) {return $.table.selectDictLabel(sysUnitClassDatas, value);} }, - {field: 'planNum',title: '计划采购数', - formatter: function(value, row, index) {return $.table.selectDictLabel(sysUnitClassDatas, value);} + {field: 'materialNum',title: '计划采购数', }, ]} $.table.init(option); diff --git a/ruoyi-admin/src/main/resources/templates/purchase/purchasePlan/purchasePlan.html b/ruoyi-admin/src/main/resources/templates/purchase/purchasePlan/purchasePlan.html index 33c03ab2..66e45649 100644 --- a/ruoyi-admin/src/main/resources/templates/purchase/purchasePlan/purchasePlan.html +++ b/ruoyi-admin/src/main/resources/templates/purchase/purchasePlan/purchasePlan.html @@ -144,12 +144,10 @@ }, {field: 'describe',title: '描述',}, {field: 'brand',title: '品牌',}, - {field: 'processMethod',title: '加工类型', + {field: 'processMethod',title: '加工方式', formatter: function(value, row, index) {return $.table.selectDictLabel(processMethodDatas, value);} }, - {field: 'unit',title: '单位', - formatter: function(value, row, index) {return $.table.selectDictLabel(sysUnitClassDatas, value);} - }, + {field: 'unit',title: '单位', }, {field: 'warehouseDept',title: '入库部门',visible: false}, {field: 'materialNum',title: '计划采购数',}, ]