From 7b122087b4100f14ece3d1c590c27c82f755f09b Mon Sep 17 00:00:00 2001 From: weizhiqiang <598748873@qq.com> Date: Sat, 2 Nov 2024 15:22:41 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E8=BD=A6=E9=97=B4=E4=BB=BB=E5=8A=A1?= =?UTF-8?q?=E8=BD=AC=E5=8A=A0=E5=B7=A5=E5=85=A5=E5=BA=93=E5=8D=95=E6=97=B6?= =?UTF-8?q?=EF=BC=8C=E5=95=86=E5=93=81=E8=BF=9B=E8=A1=8C=E5=9B=9E=E6=98=BE?= =?UTF-8?q?=E3=80=82https://gitee.com/dromara/skyeye/issues/IAUIWW?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/impl/MachinPutServiceImpl.java | 6 +++ .../service/MachinProcedureFarmService.java | 3 ++ .../impl/MachinProcedureFarmServiceImpl.java | 39 +++++++++++++++++++ 3 files changed, 48 insertions(+) diff --git a/skyeye-erp/erp-pro/src/main/java/com/skyeye/machin/service/impl/MachinPutServiceImpl.java b/skyeye-erp/erp-pro/src/main/java/com/skyeye/machin/service/impl/MachinPutServiceImpl.java index e4b1eb6b..c79160d7 100644 --- a/skyeye-erp/erp-pro/src/main/java/com/skyeye/machin/service/impl/MachinPutServiceImpl.java +++ b/skyeye-erp/erp-pro/src/main/java/com/skyeye/machin/service/impl/MachinPutServiceImpl.java @@ -24,6 +24,7 @@ import com.skyeye.machin.classenum.MachinPutFromType; import com.skyeye.machin.dao.MachinPutDao; import com.skyeye.machin.entity.MachinPut; import com.skyeye.machin.service.MachinPutService; +import com.skyeye.machinprocedure.service.MachinProcedureFarmService; import com.skyeye.material.classenum.MaterialInOrderType; import com.skyeye.organization.service.IDepmentService; import org.springframework.beans.factory.annotation.Autowired; @@ -51,6 +52,9 @@ public class MachinPutServiceImpl extends SkyeyeErpOrderServiceImpl getQueryWrapper(CommonPageInfo commonPageInfo) { return super.getQueryWrapper(commonPageInfo); @@ -63,6 +67,8 @@ public class MachinPutServiceImpl extends SkyeyeErpOrderServiceImpl queryAllMachinProcedureFarmByMachinProcedureId(String machinProcedureId); void queryMachinProcedureFarmToInOrOutList(InputObject inputObject, OutputObject outputObject); + + void setOrderMationByFromId(List> beans, String idKey, String mationKey); + } diff --git a/skyeye-erp/erp-pro/src/main/java/com/skyeye/machinprocedure/service/impl/MachinProcedureFarmServiceImpl.java b/skyeye-erp/erp-pro/src/main/java/com/skyeye/machinprocedure/service/impl/MachinProcedureFarmServiceImpl.java index d5acea58..6aadebba 100644 --- a/skyeye-erp/erp-pro/src/main/java/com/skyeye/machinprocedure/service/impl/MachinProcedureFarmServiceImpl.java +++ b/skyeye-erp/erp-pro/src/main/java/com/skyeye/machinprocedure/service/impl/MachinProcedureFarmServiceImpl.java @@ -6,6 +6,7 @@ package com.skyeye.machinprocedure.service.impl; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.map.MapUtil; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; @@ -20,6 +21,7 @@ import com.skyeye.common.util.mybatisplus.MybatisPlusUtil; import com.skyeye.exception.CustomException; import com.skyeye.farm.service.FarmService; import com.skyeye.machin.entity.MachinChild; +import com.skyeye.machin.service.MachinPutService; import com.skyeye.machin.service.MachinService; import com.skyeye.machinprocedure.classenum.MachinProcedureFarmState; import com.skyeye.machinprocedure.classenum.MachinProcedureState; @@ -31,6 +33,7 @@ import com.skyeye.machinprocedure.service.MachinProcedureFarmService; import com.skyeye.machinprocedure.service.MachinProcedureService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; import java.util.Arrays; import java.util.HashMap; @@ -62,6 +65,9 @@ public class MachinProcedureFarmServiceImpl extends SkyeyeBusinessServiceImpl getQueryWrapper(CommonPageInfo commonPageInfo) { if (StrUtil.isEmpty(commonPageInfo.getType())) { @@ -219,10 +225,43 @@ public class MachinProcedureFarmServiceImpl extends SkyeyeBusinessServiceImpl normsNumMap = machinPutService.calcMaterialNormsNumByFromId(id); + // 计算剩余数量:加工单子单据的数量 - 已经生成的加工入库单的数量 + Integer surplusNum = machinChild.getOperNumber() + - (normsNumMap.containsKey(machinChild.getNormsId()) ? normsNumMap.get(machinChild.getNormsId()) : 0); + surplusNum = surplusNum < 0 ? 0 : surplusNum; + machinChild.setOperNumber(surplusNum); + Map result = new HashMap<>(); result.put("erpOrderItemList", Arrays.asList(machinChild)); outputObject.setBean(result); outputObject.settotal(CommonNumConstants.NUM_ONE); } + @Override + public void setOrderMationByFromId(List> beans, String idKey, String mationKey) { + if (CollectionUtil.isEmpty(beans)) { + return; + } + List ids = beans.stream().filter(bean -> !com.skyeye.common.util.MapUtil.checkKeyIsNull(bean, idKey)) + .map(bean -> bean.get(idKey).toString()).distinct().collect(Collectors.toList()); + if (CollectionUtils.isEmpty(ids)) { + return; + } + QueryWrapper queryWrapper = new QueryWrapper<>(); + queryWrapper.in(CommonConstants.ID, ids); + List entityList = list(queryWrapper); + Map entityMap = entityList.stream().collect(Collectors.toMap(MachinProcedureFarm::getId, bean -> bean)); + for (Map bean : beans) { + if (!com.skyeye.common.util.MapUtil.checkKeyIsNull(bean, idKey)) { + MachinProcedureFarm entity = entityMap.get(bean.get(idKey).toString()); + if (ObjectUtil.isEmpty(entity)) { + continue; + } + bean.put(mationKey, entity); + } + } + } + }