From c9ff97747e88c9503eabe998507dbd20e0adda9b Mon Sep 17 00:00:00 2001 From: liuxiaoxu <1793812695@qq.com> Date: Wed, 3 Jul 2024 14:33:56 +0800 Subject: [PATCH] =?UTF-8?q?[fix]=20=E7=94=9F=E4=BA=A7=E7=AE=A1=E7=90=86=20?= =?UTF-8?q?=E4=BB=93=E5=BA=93=E7=AE=A1=E7=90=86=20=E6=96=B0=E5=A2=9E=20?= =?UTF-8?q?=E7=94=9F=E4=BA=A7=E9=A2=86=E6=96=99=E5=8D=95=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E5=B7=B2=E9=A2=86=E6=96=99=E6=95=B0=E5=AD=97=E6=AE=B5=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=20=E7=94=9F=E4=BA=A7=E9=A2=86=E6=96=99?= =?UTF-8?q?=E5=8D=95=E5=89=8D=E7=AB=AF=E6=96=B0=E5=A2=9E=E5=B7=B2=E9=A2=86?= =?UTF-8?q?=E6=96=99=E6=95=B0=E5=AD=97=E6=AE=B5=20=E6=96=B0=E5=A2=9E=20?= =?UTF-8?q?=E5=93=81=E8=B4=A8=E5=AE=8C=E6=9B=B4=E6=96=B0=E4=BB=93=E5=BA=93?= =?UTF-8?q?=E5=85=A5=E5=BA=93=E5=8D=95=E7=9A=84=E5=93=81=E8=B4=A8=E7=8A=B6?= =?UTF-8?q?=E6=80=81=20=E6=96=B0=E5=A2=9E=20=E7=94=9F=E4=BA=A7=E9=A2=86?= =?UTF-8?q?=E6=96=99=E5=8D=95=E8=AF=A6=E6=83=85=E5=89=8D=E7=AB=AF=E6=96=B0?= =?UTF-8?q?=E5=A2=9E=E5=B7=B2=E9=A2=86=E6=96=99=E6=95=B0=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=20=E4=BF=AE=E6=94=B9=20=E7=94=9F=E4=BA=A7=E5=8D=95BOM=E7=9A=84?= =?UTF-8?q?=E6=8D=9F=E8=80=97=E7=8E=87=E5=AD=97=E6=AE=B5=E7=9A=84=E7=B1=BB?= =?UTF-8?q?=E5=9E=8BBigDecimal->=20String=20=E7=94=9F=E4=BA=A7=E9=A2=86?= =?UTF-8?q?=E6=96=99=E5=8D=95=E8=AF=A6=E6=83=85=E6=96=B0=E5=A2=9E=20?= =?UTF-8?q?=E6=A0=B9=E6=8D=AE=E7=94=9F=E4=BA=A7=E5=8D=95=E5=8F=B7=E5=92=8C?= =?UTF-8?q?=E9=A2=86=E6=96=99=E5=8D=95=E5=8F=B7=E4=BB=A5=E5=8F=8A=E7=89=A9?= =?UTF-8?q?=E6=96=99=E5=8F=B7=E6=9F=A5=E8=AF=A2=E9=A2=86=E6=96=99=E5=8D=95?= =?UTF-8?q?=E8=AF=A6=E6=83=85=E4=BF=A1=E6=81=AF=20=E4=BF=AE=E6=94=B9=20?= =?UTF-8?q?=E6=96=B0=E5=A2=9E=E7=94=9F=E4=BA=A7=E8=AE=A2=E5=8D=95=E9=A2=86?= =?UTF-8?q?=E6=96=99=E6=98=8E=E7=BB=86=E7=9A=84=E6=96=B0=E5=A2=9E=E6=96=B9?= =?UTF-8?q?=E6=B3=95=EF=BC=8C=E5=8A=A0=E5=85=A5=E5=AF=B9=E5=B7=B2=E9=A2=86?= =?UTF-8?q?=E6=96=99=E6=95=B0=E5=AD=97=E6=AE=B5=E7=9A=84=E5=A4=84=E7=90=86?= =?UTF-8?q?=20=E4=BF=AE=E6=94=B9=20=E6=96=B0=E5=A2=9E=E7=94=9F=E4=BA=A7?= =?UTF-8?q?=E9=A2=86=E6=96=99=E5=8D=95=E7=9A=84=E6=96=B0=E5=A2=9E=E6=96=B9?= =?UTF-8?q?=E6=B3=95=E5=8A=A0=E5=85=A5=E5=AF=B9=20=E9=A2=86=E6=96=99?= =?UTF-8?q?=E5=8D=95=E4=B8=BA=E7=A9=BA=E7=9A=84=E6=95=B0=E6=8D=AE=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E8=BF=87=E6=BB=A4=20=E6=96=B0=E5=A2=9E=20=E9=83=A8?= =?U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=95=E5=AD=90?= =?UTF-8?q?=E8=A1=A8=E7=9A=84=E5=87=BA=E5=BA=93=E6=95=B0=E9=87=8F=E4=B8=BA?= =?UTF-8?q?=E7=94=9F=E4=BA=A7=E9=A2=86=E6=96=99=E5=8D=95=E8=AF=A6=E6=83=85?= =?UTF-8?q?=E7=9A=84=E9=A2=86=E6=96=99=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ruoyi/system/domain/SysMakeorderBom.java | 16 +-- .../system/domain/SysMakeorderPickDetail.java | 13 +++ .../mapper/SysMakeorderPickDetailMapper.java | 6 + .../service/impl/SysMakeOrderServiceImpl.java | 6 +- .../SysMakeorderPickDetailServiceImpl.java | 22 ++++ .../impl/SysMakeorderPickServiceImpl.java | 19 ++- .../impl/WarehouseOutOrderServiceImpl.java | 110 +++++++++++++++--- .../system/SysMakeorderPickDetailMapper.xml | 13 ++- .../templates/system/makeorder/addpick.html | 9 ++ .../system/makeorderpick/detail.html | 6 + 10 files changed, 188 insertions(+), 32 deletions(-) diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysMakeorderBom.java b/ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysMakeorderBom.java index f1c56077..435f932d 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysMakeorderBom.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysMakeorderBom.java @@ -78,7 +78,7 @@ public class SysMakeorderBom extends BaseEntity /** 损耗率 */ @Excel(name = "损耗率") - private BigDecimal lossRate; + private String lossRate; /** 层级 */ @Excel(name = "层级") @@ -223,16 +223,16 @@ public class SysMakeorderBom extends BaseEntity { return useNum; } - public void setLossRate(BigDecimal lossRate) - { - this.lossRate = lossRate; - } - public BigDecimal getLossRate() - { + public String getLossRate() { return lossRate; } - public void setLevel(Long level) + + public void setLossRate(String lossRate) { + this.lossRate = lossRate; + } + + public void setLevel(Long level) { this.level = level; } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysMakeorderPickDetail.java b/ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysMakeorderPickDetail.java index cb644469..6fafaaf2 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysMakeorderPickDetail.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/domain/SysMakeorderPickDetail.java @@ -43,6 +43,10 @@ public class SysMakeorderPickDetail extends BaseEntity @Excel(name = "领料数量") private Long pickNum; + /** 已领料数量 */ + @Excel(name = "已领料数量") + private Long hasPickNum; + /** bom号 */ private String bomNo; /** bom的图片地址 */ @@ -132,6 +136,14 @@ public class SysMakeorderPickDetail extends BaseEntity return pickNum; } + public Long getHasPickNum() { + return hasPickNum; + } + + public void setHasPickNum(Long hasPickNum) { + this.hasPickNum = hasPickNum; + } + public String getBomNo() { return bomNo; } @@ -243,6 +255,7 @@ public class SysMakeorderPickDetail extends BaseEntity .append("materialNo", getMaterialNo()) .append("makeorderBomId", getMakeorderBomId()) .append("pickNum", getPickNum()) + .append("hasPickNum", getHasPickNum()) .toString(); } } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/mapper/SysMakeorderPickDetailMapper.java b/ruoyi-admin/src/main/java/com/ruoyi/system/mapper/SysMakeorderPickDetailMapper.java index b234c08f..4a600d76 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/mapper/SysMakeorderPickDetailMapper.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/mapper/SysMakeorderPickDetailMapper.java @@ -80,4 +80,10 @@ public interface SysMakeorderPickDetailMapper * 根据生产单号和领料单号查询 领料单详情信息 * */ List selectSysMakeorderPickDetailByNo(SysMakeorderPickDetail sysMakeorderPickDetail); + + /* + * 根据生产单号和领料单号以及物料号查询领料单详情信息 + * */ + public SysMakeorderPickDetail selectSysMakeorderPickDetailByThreeNo(SysMakeorderPickDetail sysMakeorderPickDetail); + } 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 89a274a6..edd751f8 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 @@ -30,6 +30,7 @@ import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; import org.springframework.util.CollectionUtils; +import java.math.BigDecimal; import java.util.ArrayList; import java.util.Date; import java.util.List; @@ -271,6 +272,7 @@ public class SysMakeOrderServiceImpl implements ISysMakeOrderService orderBom.setMakeNo(makeNo); orderBom.setSalesOrderCode(saleNo); orderBom.setSalesOrderMaterialNo(materialCode); + orderBom.setLossRate(subBom.getLossRate()); //如果sys_makeorder_bom数据表里面没有入库部门.这里给他加入 //orderBom.setWarehouseDept(subBom.getWarehouseDept()); sortNo++; @@ -288,6 +290,7 @@ public class SysMakeOrderServiceImpl implements ISysMakeOrderService orderBom.setMakeNo(makeNo); orderBom.setSalesOrderCode(saleNo); orderBom.setSalesOrderMaterialNo(materialCode); + orderBom.setLossRate(subBom.getLossRate()); sortNo++; orderBom.setSortNo(sortNo); makeorderBomService.insertSysMakeorderBom(orderBom); @@ -347,7 +350,8 @@ public class SysMakeOrderServiceImpl implements ISysMakeOrderService } sysMakeOrder.setMakeNo(makeNo); - sysMakeOrder.setEceiptNum((long) warehouseStorageOrder.getStorageNum()); + //只有生产入库才能更新生产订单的已入库数 + //sysMakeOrder.setEceiptNum((long) warehouseStorageOrder.getStorageNum()); //更新生产订单的数据 int updateResult = sysMakeOrderMapper.updateByMakeNo(sysMakeOrder); if (updateResult <= 0){ diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysMakeorderPickDetailServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysMakeorderPickDetailServiceImpl.java index 2c5c251b..b1feae62 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysMakeorderPickDetailServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysMakeorderPickDetailServiceImpl.java @@ -58,6 +58,28 @@ public class SysMakeorderPickDetailServiceImpl implements ISysMakeorderPickDetai String loginName = ShiroUtils.getLoginName(); sysMakeorderPickDetail.setCreateBy(loginName); sysMakeorderPickDetail.setCreateTime(DateUtils.getNowDate()); + + SysMakeorderPickDetail tempMakeorderPickDetail = sysMakeorderPickDetailMapper.selectSysMakeorderPickDetailByThreeNo(sysMakeorderPickDetail); + if (tempMakeorderPickDetail != null){ + + if (tempMakeorderPickDetail.getHasPickNum() != null ){ + // 如果刚开始 领料详细数据不为空,并且已经有已领料数了,说明也有领料数,再领料,已领料数会累加 本次领料数; + Long hasPickNum = tempMakeorderPickDetail.getHasPickNum() + sysMakeorderPickDetail.getPickNum(); + sysMakeorderPickDetail.setHasPickNum(hasPickNum); + } + + }else { + // 如果刚开始 领料详细数据为空,已领料数等于领料数 + sysMakeorderPickDetail.setHasPickNum(sysMakeorderPickDetail.getPickNum()); + } + + // 缓存sysMakeorderPickDetail的领料数,避免多次调用 下面代码等同于上面的逻辑 +// Long pickNum = sysMakeorderPickDetail.getPickNum(); +// Long hasPickNum = (tempMakeorderPickDetail != null && tempMakeorderPickDetail.getHasPickNum() != null) +// ? tempMakeorderPickDetail.getHasPickNum() + pickNum +// : pickNum; +// sysMakeorderPickDetail.setHasPickNum(hasPickNum); + return sysMakeorderPickDetailMapper.insertSysMakeorderPickDetail(sysMakeorderPickDetail); } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysMakeorderPickServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysMakeorderPickServiceImpl.java index 9562dcdb..048b9fd0 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysMakeorderPickServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/system/service/impl/SysMakeorderPickServiceImpl.java @@ -7,6 +7,7 @@ import com.ruoyi.common.core.page.PageDomain; import com.ruoyi.common.core.page.TableSupport; import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.core.text.Convert; +import com.ruoyi.common.exception.BusinessException; import com.ruoyi.common.utils.DateUtils; import com.ruoyi.common.utils.ShiroUtils; import com.ruoyi.common.utils.StringUtils; @@ -20,6 +21,7 @@ import com.ruoyi.system.mapper.SysUserMapper; import com.ruoyi.system.service.ISysMakeorderPickDetailService; import com.ruoyi.system.service.ISysMakeorderPickService; import com.ruoyi.system.service.ISysRoleService; +import com.ruoyi.warehouse.service.IWarehouseOutOrderService; import org.activiti.engine.TaskService; import org.activiti.engine.impl.persistence.entity.TaskEntityImpl; import org.activiti.engine.runtime.ProcessInstance; @@ -33,6 +35,7 @@ import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.stream.Collectors; /** * 生产领料单Service业务层处理 @@ -172,13 +175,23 @@ public class SysMakeorderPickServiceImpl implements ISysMakeorderPickService String billNo = redisCache.generateBillNo("SCLL"); sysMakeorderPick.setPickNo(billNo); int id = sysMakeorderPickMapper.insertSysMakeorderPick(sysMakeorderPick); + //保留领料单数不为空的数据 + List filterPickDetails = pickDetails.stream().filter(details -> details.getPickNum() != null).collect(Collectors.toList()); + // 插入子表 - for (int i = 0; i < pickDetails.size(); i++) { - SysMakeorderPickDetail pickDetail = pickDetails.get(i); + for (int i = 0; i < filterPickDetails.size(); i++) { + //获取过滤后的领料单详情 + SysMakeorderPickDetail pickDetail = filterPickDetails.get(i); pickDetail.setPickNo(billNo); pickDetail.setMakeNo(makeNo); - makeorderPickDetailService.insertSysMakeorderPickDetail(pickDetail); + int insertMakeorderPickDetailResult = makeorderPickDetailService.insertSysMakeorderPickDetail(pickDetail); + if (insertMakeorderPickDetailResult <= 0){ + throw new BusinessException("新增生产领料单详情失败"); + } } + + + return id; } diff --git a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseOutOrderServiceImpl.java b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseOutOrderServiceImpl.java index 7d97fdb8..e6f31336 100644 --- a/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseOutOrderServiceImpl.java +++ b/ruoyi-admin/src/main/java/com/ruoyi/warehouse/service/impl/WarehouseOutOrderServiceImpl.java @@ -1,7 +1,7 @@ package com.ruoyi.warehouse.service.impl; -import java.util.Date; -import java.util.List; +import java.util.*; +import java.util.stream.Collectors; import com.ruoyi.common.core.redis.RedisCache; import com.ruoyi.common.exception.BusinessException; @@ -17,6 +17,7 @@ import com.ruoyi.system.mapper.SysMakeorderPickDetailMapper; import com.ruoyi.system.mapper.SysMakeorderPickMapper; import com.ruoyi.system.mapper.SysSalesOrderMapper; import com.ruoyi.warehouse.domain.WarehouseOutOrderDetail; +import com.ruoyi.warehouse.domain.WarehouseStorageOrderDetail; import com.ruoyi.warehouse.mapper.WarehouseOutOrderDetailMapper; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; @@ -260,13 +261,41 @@ public class WarehouseOutOrderServiceImpl implements IWarehouseOutOrderService warehouseOutOrder.setMakeNo(tempSysMakeorderPickVo.getMakeNo()); //标明来源是生产订单 warehouseOutOrder.setWarehouseOrderType("1"); + //标明是生产领料 warehouseOutOrder.setWarehouseOutType("1"); - warehouseOutOrder.setMaterialSum(tempSysMakeorderPickVo.getMaterialSum()); - warehouseOutOrder.setEnterpriseSum(tempSysMakeorderPickVo.getEnterpriseSum()); - - warehouseOutOrder.setCreateBy(sysMakeorderPickVo.getApplyUser()); + warehouseOutOrder.setBusinessName(ShiroUtils.getLoginName()); + warehouseOutOrder.setCreateBy(ShiroUtils.getLoginName()); warehouseOutOrder.setCreateTime(new Date()); warehouseOutOrder.setApplyName(sysMakeorderPickVo.getApplyUser()); + List sysMakeorderPickDetails = getSysMakeorderPickDetails(sysMakeorderPickVo); + //对物料相同的数据进行合并操作,并合计领料数 + List mergeMakeorderPickDetails = mergeMakeorderPickDetails(sysMakeorderPickDetails); + + //物料合计 + Integer materialSum = 0; + + //数量合计 + Integer enterpriseSum = 0; + + materialSum = mergeMakeorderPickDetails.size(); + + // 检查storageNum是否含有null值 + boolean hasThisStorageNumNull = mergeMakeorderPickDetails.stream() + .anyMatch(item -> item.getPickNum() == null); + + if (hasThisStorageNumNull) { + throw new BusinessException("存在入库数为空,请检查!"); + } + // 计算各个字段的总和 + long enterpriseSumLong = mergeMakeorderPickDetails.stream() + .mapToLong(SysMakeorderPickDetail::getPickNum) + .sum(); + + // 确保转换前不会造成数据溢出 + enterpriseSum = (int)enterpriseSumLong; + + warehouseOutOrder.setMaterialSum(materialSum); + warehouseOutOrder.setEnterpriseSum(enterpriseSum); //生成出库单数据 int insertResult = warehouseOutOrderMapper.insertWarehouseOutOrder(warehouseOutOrder); if (insertResult <= 0){ @@ -274,18 +303,41 @@ public class WarehouseOutOrderServiceImpl implements IWarehouseOutOrderService throw new BusinessException("添加出库单信息失败"); } //生成出库单详情相关信息 - generateWarehouseOutOrder(sysMakeorderPickVo, tempSysMakeorderPickVo, outOrderCode); + generateWarehouseOutOrder(sysMakeorderPickVo, tempSysMakeorderPickVo, outOrderCode,mergeMakeorderPickDetails); return insertResult; } + /* + * 对物料相同的数据进行合并操作,并合计领料数 + * */ + public List mergeMakeorderPickDetails(List sysMakeorderPickDetails) { + Map materialMap = new HashMap<>(); + for (SysMakeorderPickDetail detail : sysMakeorderPickDetails) { + String materialNo = detail.getMaterialNo(); + Long pickNum = detail.getPickNum(); + if (materialMap.containsKey(materialNo)) { + materialMap.put(materialNo, materialMap.get(materialNo) + pickNum); + } else { + materialMap.put(materialNo, pickNum); + } + } + + List mergedDetails = new ArrayList<>(); + for (Map.Entry entry : materialMap.entrySet()) { + SysMakeorderPickDetail mergedDetail = new SysMakeorderPickDetail(); + mergedDetail.setMaterialNo(entry.getKey()); + mergedDetail.setPickNum(entry.getValue()); + mergedDetails.add(mergedDetail); + } + + return mergedDetails; + } + + //生成出库单详情相关信息 - private void generateWarehouseOutOrder(SysMakeorderPickVo sysMakeorderPickVo, SysMakeorderPickVo tempSysMakeorderPickVo, String outOrderCode) { - SysMakeorderPickDetail tempMakeorderPickDetail = new SysMakeorderPickDetail(); - tempMakeorderPickDetail.setPickNo(tempSysMakeorderPickVo.getPickNo()); - tempMakeorderPickDetail.setMakeNo(tempSysMakeorderPickVo.getMakeNo()); - //查询生产物料领料单详情 - List sysMakeorderPickDetails = makeorderPickDetailMapper.selectSysMakeorderPickDetailByNo(tempMakeorderPickDetail); - for (SysMakeorderPickDetail sysMakeorderPickDetail : sysMakeorderPickDetails) { + private void generateWarehouseOutOrder(SysMakeorderPickVo sysMakeorderPickVo, SysMakeorderPickVo tempSysMakeorderPickVo, String outOrderCode,List mergeMakeorderPickDetails) { + + for (SysMakeorderPickDetail sysMakeorderPickDetail : mergeMakeorderPickDetails) { WarehouseOutOrderDetail warehouseOutOrderDetail = new WarehouseOutOrderDetail(); warehouseOutOrderDetail.setOutOrderCode(outOrderCode); warehouseOutOrderDetail.setWarehouseOutStatus("4"); @@ -297,7 +349,7 @@ public class WarehouseOutOrderServiceImpl implements IWarehouseOutOrderService warehouseOutOrderDetail.setMaterialSum(tempSysMakeorderPickVo.getMaterialSum()); warehouseOutOrderDetail.setEnterpriseSum(tempSysMakeorderPickVo.getEnterpriseSum()); - warehouseOutOrderDetail.setCreateBy(sysMakeorderPickVo.getApplyUser()); + warehouseOutOrderDetail.setCreateBy(ShiroUtils.getLoginName()); warehouseOutOrderDetail.setCreateTime(new Date()); warehouseOutOrderDetail.setApplyName(sysMakeorderPickVo.getApplyUser()); //物料相关信息 @@ -308,15 +360,35 @@ public class WarehouseOutOrderServiceImpl implements IWarehouseOutOrderService warehouseOutOrderDetail.setMaterialBrand(sysMakeorderPickDetail.getBrand()); warehouseOutOrderDetail.setMaterialProcessMethod(sysMakeorderPickDetail.getProcessMethod()); warehouseOutOrderDetail.setMakeNum(tempSysMakeorderPickVo.getMaterialSum()); - if (StringUtils.isNotEmpty(sysMakeorderPickDetail.getDescribe())){ + //添加申请出库数量 + warehouseOutOrderDetail.setApplyOutOrderSum(Math.toIntExact(sysMakeorderPickDetail.getPickNum())); + + if (StringUtils.isNotEmpty(sysMakeorderPickDetail.getDescribe())) { String[] splitDescribe = sysMakeorderPickDetail.getDescribe().split(","); - warehouseOutOrderDetail.setMaterialModel(splitDescribe[0]); - warehouseOutOrderDetail.setMaterialSpecification(splitDescribe[1]); + if (splitDescribe.length >= 2) { + warehouseOutOrderDetail.setMaterialModel(splitDescribe[0]); + warehouseOutOrderDetail.setMaterialSpecification(splitDescribe[1]); + } + } + int insertOutOrderDetailResult = outOrderDetailMapper.insertWarehouseOutOrderDetail(warehouseOutOrderDetail); + if (insertOutOrderDetailResult <= 0){ + throw new BusinessException("新增出库单详情数据失败"); } - outOrderDetailMapper.insertWarehouseOutOrderDetail(warehouseOutOrderDetail); } } + private List getSysMakeorderPickDetails(SysMakeorderPickVo tempSysMakeorderPickVo) { + SysMakeorderPickDetail tempMakeorderPickDetail = new SysMakeorderPickDetail(); + tempMakeorderPickDetail.setPickNo(tempSysMakeorderPickVo.getPickNo()); + tempMakeorderPickDetail.setMakeNo(tempSysMakeorderPickVo.getMakeNo()); + + //查询生产物料领料单详情 + List sysMakeorderPickDetails = makeorderPickDetailMapper.selectSysMakeorderPickDetailByNo(tempMakeorderPickDetail); + //保留领料单数不为空的数据 + List filterPickDetails = sysMakeorderPickDetails.stream().filter(details -> details.getPickNum() != null).collect(Collectors.toList()); + return filterPickDetails; + } + /* * 生产单-出库 * */ diff --git a/ruoyi-admin/src/main/resources/mapper/system/SysMakeorderPickDetailMapper.xml b/ruoyi-admin/src/main/resources/mapper/system/SysMakeorderPickDetailMapper.xml index 5ee983b3..c9675145 100644 --- a/ruoyi-admin/src/main/resources/mapper/system/SysMakeorderPickDetailMapper.xml +++ b/ruoyi-admin/src/main/resources/mapper/system/SysMakeorderPickDetailMapper.xml @@ -17,6 +17,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -33,7 +34,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select a.id, a.del_flag, a.create_by, a.create_time, a.update_by, a.update_time, a.remark - , a.make_no, a.pick_no, a.material_no, a.makeorder_bom_id, a.pick_num + , a.make_no, a.pick_no, a.material_no, a.makeorder_bom_id, a.pick_num, a.has_pick_num ,b.bom_no,b.photoUrl,b.material_name,b.material_type,b.process_method,b.unit,b.brand ,b.describe,b.use_num,b.loss_rate,b.level,b.sort_no from sys_makeorder_pick_detail a @@ -66,6 +67,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + + insert into sys_makeorder_pick_detail @@ -80,6 +88,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" material_no, makeorder_bom_id, pick_num, + has_pick_num, #{delFlag}, @@ -93,6 +102,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{materialNo}, #{makeorderBomId}, #{pickNum}, + #{hasPickNum}, @@ -110,6 +120,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" material_no = #{materialNo}, makeorder_bom_id = #{makeorderBomId}, pick_num = #{pickNum}, + has_pick_num = #{hasPickNum}, where id = #{id} diff --git a/ruoyi-admin/src/main/resources/templates/system/makeorder/addpick.html b/ruoyi-admin/src/main/resources/templates/system/makeorder/addpick.html index e2afe31d..6f165ced 100644 --- a/ruoyi-admin/src/main/resources/templates/system/makeorder/addpick.html +++ b/ruoyi-admin/src/main/resources/templates/system/makeorder/addpick.html @@ -151,6 +151,11 @@ field: 'materialNum', align: 'center', title: '订单数量' + }, + { + field: 'finishNum', + align: 'center', + title: '已完成数' } ] }; @@ -302,6 +307,10 @@ return parentRow.materialNum * row.useNum; } }, + { + field: 'hasPickNum', + title: '已领料数量', + }, { field: 'pickNum', title: '本次领料数量', diff --git a/ruoyi-admin/src/main/resources/templates/system/makeorderpick/detail.html b/ruoyi-admin/src/main/resources/templates/system/makeorderpick/detail.html index 7e4dcce1..4c7ec2b7 100644 --- a/ruoyi-admin/src/main/resources/templates/system/makeorderpick/detail.html +++ b/ruoyi-admin/src/main/resources/templates/system/makeorderpick/detail.html @@ -293,6 +293,12 @@ return parentRow.materialNum * row.useNum; } }, + + { + field: 'hasPickNum', + title: '已领料数', + }, + { field: 'pickNum', title: '本次领料数量',