From de37f12a8df8f692cfb4433257a99d1ad9bcafcf Mon Sep 17 00:00:00 2001 From: Kelvin Date: Thu, 28 Nov 2024 15:49:02 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E5=A2=9E=E5=8A=A0=20=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E5=85=A5=E5=BA=93=E8=AE=A1=E5=88=92?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ktg/mes/wm/service/IWmsInPlanService.java | 9 ++- .../wm/service/impl/WmsInPlanServiceImpl.java | 57 ++++++++++++++++++- 2 files changed, 63 insertions(+), 3 deletions(-) diff --git a/ktg-mes/src/main/java/com/ktg/mes/wm/service/IWmsInPlanService.java b/ktg-mes/src/main/java/com/ktg/mes/wm/service/IWmsInPlanService.java index cef7914..517db38 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/wm/service/IWmsInPlanService.java +++ b/ktg-mes/src/main/java/com/ktg/mes/wm/service/IWmsInPlanService.java @@ -17,7 +17,7 @@ public interface IWmsInPlanService * @param planId 入库计划主键 * @return 入库计划 */ - public WmsInPlan selectWmsInPlanByPlanId(String planId); + public WmsInPlan selectWmsInPlanByPlanId(Long planId); WmsInPlan selectWmsInPlanByPlanCode(String planCode); @@ -67,4 +67,11 @@ public interface IWmsInPlanService * @return 是否重复 */ public Boolean isDuplicatePlanCode(String planCode); + + /** + * 执行入库计划 + * @param planId 入库计划ID + * @return 结果 + */ + public int issueWmsInPlan(Long planId); } diff --git a/ktg-mes/src/main/java/com/ktg/mes/wm/service/impl/WmsInPlanServiceImpl.java b/ktg-mes/src/main/java/com/ktg/mes/wm/service/impl/WmsInPlanServiceImpl.java index 11a9180..fa86703 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/wm/service/impl/WmsInPlanServiceImpl.java +++ b/ktg-mes/src/main/java/com/ktg/mes/wm/service/impl/WmsInPlanServiceImpl.java @@ -1,14 +1,20 @@ package com.ktg.mes.wm.service.impl; +import java.util.Date; import java.util.List; import com.ktg.common.utils.DateUtils; +import com.ktg.mes.md.domain.MdItem; +import com.ktg.mes.md.service.IMdItemService; import com.ktg.mes.wm.domain.WmsInPlanDetailEntity; +import com.ktg.mes.wm.domain.WmsInTask; import com.ktg.mes.wm.mapper.WmsInPlanDetailEntityMapper; +import com.ktg.mes.wm.service.IWmsInTaskService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; +import java.util.concurrent.atomic.AtomicInteger; import com.ktg.common.utils.StringUtils; import org.springframework.transaction.annotation.Transactional; @@ -31,6 +37,12 @@ public class WmsInPlanServiceImpl implements IWmsInPlanService { @Autowired private WmsInPlanDetailEntityMapper wmsInPlanDetailEntityMapper; + @Autowired + private IWmsInTaskService wmsInTaskService; + + @Autowired + private IMdItemService mdItemService; + /** * 查询入库计划 * @@ -38,7 +50,7 @@ public class WmsInPlanServiceImpl implements IWmsInPlanService { * @return 入库计划 */ @Override - public WmsInPlan selectWmsInPlanByPlanId(String planId) { + public WmsInPlan selectWmsInPlanByPlanId(Long planId) { WmsInPlan wmsInPlan = wmsInPlanMapper.selectWmsInPlanByPlanId(planId); List wmsInPlanDetailsList = new ArrayList<>(); wmsInPlan.getWmsInPlanDetailsList().forEach(detail -> { @@ -140,7 +152,7 @@ public class WmsInPlanServiceImpl implements IWmsInPlanService { } if (!list.isEmpty()) { wmsInPlanMapper.batchWmsInPlanDetails(list); - WmsInPlan wmsInPlan1 = selectWmsInPlanByPlanId(planId.toString()); + WmsInPlan wmsInPlan1 = selectWmsInPlanByPlanId(planId); List wmsInPlanDetailsList1 = wmsInPlan1.getWmsInPlanDetailsList(); for (int i = 0; i < list.size(); i++) { List wmsInPlanDetailEntityList = list.get(i).getWmsInPlanDetailEntityList(); @@ -178,10 +190,51 @@ public class WmsInPlanServiceImpl implements IWmsInPlanService { /** * 入库计划ID是否重复 + * * @param planCode 入库计划ID * @return 是否重复 */ + @Override public Boolean isDuplicatePlanCode(String planCode) { return wmsInPlanMapper.isDuplicatePlanCode(planCode); } + + /** + * 执行入库计划 + * + * @param planId 入库计划ID + * @return 结果 + */ + @Override + public int issueWmsInPlan(Long planId) { + WmsInPlan wmsInPlan = selectWmsInPlanByPlanId(planId); + WmsInTask wmsInTask = new WmsInTask(); + + AtomicInteger atomicInteger = new AtomicInteger(); + wmsInPlan.getWmsInPlanDetailsList().forEach(detail -> { + int index = atomicInteger.getAndIncrement(); + + wmsInTask.setPlanInId(wmsInPlan.getPlanId()); + wmsInTask.setPlanInCode(wmsInPlan.getPlanCode()); + wmsInTask.setTaskInQuantity(Integer.parseInt(detail.getQuantity())); + wmsInTask.setActualInQuantity(Integer.parseInt(detail.getQuantityIn())); + wmsInTask.setCellTgt(detail.getCellId()); + wmsInTask.setCellOrig(new Date().toString() + index); + wmsInTask.setRemark(detail.getRemark()); + wmsInTask.setBatch(detail.getBatch()); + wmsInTask.setMaterialId(detail.getMaterialId()); + + MdItem mdItem = mdItemService.selectMdItemById(Long.parseLong(wmsInTask.getMaterialId())); + wmsInTask.setMaterialCode(mdItem.getItemCode()); + wmsInTask.setPlanTypeId(wmsInPlan.getPlanTypeId().toString()); + wmsInTask.setPlanTypeCode(wmsInPlan.getPlanTypeCode()); + wmsInTask.setPlanInStatus("0"); + wmsInTask.setDetailInId(detail.getDetailsId()); + + wmsInTaskService.insertWmsInTask(wmsInTask); + }); + + wmsInPlan.setState("1"); + return wmsInPlanMapper.updateWmsInPlan(wmsInPlan); + } }