From e599a0cb5db6ebc5330ae8d8c61092e13073a977 Mon Sep 17 00:00:00 2001 From: Stang <32996823@qq.com> Date: Fri, 15 Nov 2024 15:04:06 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=BB=84=E8=A3=85=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../md/controller/BaseKnifeController.java | 133 +++++++++--------- .../md/service/impl/BaseKnifeServiceImpl.java | 7 + .../wm/controller/WmsZdTaskController.java | 5 + .../ktg/mes/wm/mapper/WmsInTaskMapper.java | 1 + .../ktg/mes/wm/mapper/WmsZdTaskMapper.java | 2 + .../ktg/mes/wm/service/IWmsZdTaskService.java | 2 + .../wm/service/impl/WmsZdTaskServiceImpl.java | 27 +++- .../resources/mapper/md/BaseKnifeMapper.xml | 3 + .../resources/mapper/wm/WmsZdTaskMapper.xml | 5 + 9 files changed, 110 insertions(+), 75 deletions(-) diff --git a/ktg-mes/src/main/java/com/ktg/mes/md/controller/BaseKnifeController.java b/ktg-mes/src/main/java/com/ktg/mes/md/controller/BaseKnifeController.java index aacefbc..c8a3ec5 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/md/controller/BaseKnifeController.java +++ b/ktg-mes/src/main/java/com/ktg/mes/md/controller/BaseKnifeController.java @@ -6,6 +6,7 @@ import javax.servlet.http.HttpServletResponse; import com.alibaba.fastjson.JSON; import com.ktg.common.utils.DateUtils; +import com.ktg.generator.util.MultiModuleCodeGenerator; import com.ktg.mes.md.domain.*; import com.ktg.mes.md.mapper.WmsOutPlanDetailEntityMapper; import com.ktg.mes.md.mapper.WmsOutPlanMapper; @@ -554,11 +555,11 @@ public class BaseKnifeController extends BaseController { // 生成组装任务 WmsZdTask wmsZdTask = new WmsZdTask(); wmsZdTask.setmProductId(mdItem.getItemId()); - wmsZdTask.setAttr4(planSheet); - wmsZdTask.setCode(techBom.getProcessCode()); + wmsZdTask.setPlanSheet(planSheet); + wmsZdTask.setCode(generateTaskCode(techBom.getProcessCode())); wmsZdTask.setName(techBom.getProcessName()); wmsZdTask.setProductIdQty(count); - wmsZdTask.setAttr1(bomRouteList.get(0).getBomRouteId()); + wmsZdTask.setBomId(bomRouteList.get(0).getBomRouteId()); wmsZdTask.setCreateTime(DateUtils.getNowDate()); zdTaskService.insertWmsZdTask(wmsZdTask); msg = "生产准备验证成功!缺少物料已生成组装任务!"; @@ -769,65 +770,65 @@ public class BaseKnifeController extends BaseController { mdItemService.updateMdItem(mdItem); } -// // 整刀入库计划, 根据图号查询入库计划,如果不存在生成计划,存在则往计划中添加任务 -// WmsInPlan wmsInPlan = wmsInPlanService.selectWmsInPlanByPlanCode(zdTask.getAttr4()); -// if (wmsInPlan == null) { -// WmsInPlan wmsInPlanTemp = new WmsInPlan(); -// wmsInPlanTemp.setState("1"); -// wmsInPlanTemp.setSourceType("SGLR"); -// wmsInPlanTemp.setCellCode(zdTask.getAttr3()); -// wmsInPlanTemp.setPlanCode(zdTask.getAttr4() == null ? zdTask.getCode() : zdTask.getAttr4()); -// wmsInPlanTemp.setRelBillCode("组装单据"); -// wmsInPlanTemp.setPlanTypeId("13"); -// wmsInPlanTemp.setCreateBy(getUsername()); -// wmsInPlanTemp.setCreateTime(DateUtils.getNowDate()); -// -// // 入库任务明细 -// List wmsInPlanDetailsList = new ArrayList<>(); -// WmsInPlanDetails wmsInPlanDetails = new WmsInPlanDetails(); -// wmsInPlanDetails.setMaterialId(zdTask.getmProductId().toString()); -// wmsInPlanDetails.setBatch(batchNum); -// wmsInPlanDetails.setCellId(1L); -// wmsInPlanDetails.setQuantity(zdTask.getProductIdQty().toString()); -// wmsInPlanDetails.setQuantityIn(zdTask.getProductIdQty().toString()); -// wmsInPlanDetails.setPlanInStatus("0"); -// wmsInPlanDetailsList.add(wmsInPlanDetails); -// wmsInPlanTemp.setWmsInPlanDetailsList(wmsInPlanDetailsList); -// wmsInPlanService.insertWmsInPlan(wmsInPlanTemp); -// wmsInPlan = wmsInPlanTemp; -// } else { -// // 入库任务明细 -// List wmsInPlanDetailsList = wmsInPlan.getWmsInPlanDetailsList(); -// WmsInPlanDetails wmsInPlanDetails = new WmsInPlanDetails(); -// wmsInPlanDetails.setMaterialId(zdTask.getmProductId().toString()); -// wmsInPlanDetails.setBatch(batchNum); -// wmsInPlanDetails.setCellId(1L); -// wmsInPlanDetails.setQuantity(zdTask.getProductIdQty().toString()); -// wmsInPlanDetails.setQuantityIn(zdTask.getProductIdQty().toString()); -// wmsInPlanDetails.setPlanInStatus("0"); -// wmsInPlanDetailsList.add(wmsInPlanDetails); -// wmsInPlan.setWmsInPlanDetailsList(wmsInPlanDetailsList); -// wmsInPlanService.updateWmsInPlan(wmsInPlan); -// } -// -// // 入库任务 -// MdItem mdItem = mdItemService.selectMdItemById(zdTask.getmProductId()); -// WmsInTask wmsInTask = new WmsInTask(); -// // 生成任务号 -// String taskInCode = MultiModuleCodeGenerator.generateTaskCode("RKT"); -// wmsInTask.setTaskInCode(taskInCode); -// wmsInTask.setPlanInId(wmsInPlan.getPlanId().toString()); -// wmsInTask.setPlanInCode(wmsInPlan.getPlanCode()); -// wmsInTask.setMaterialCode(mdItem.getItemCode()); -// wmsInTask.setTaskInQuantity(zdTask.getProductIdQty()); -// wmsInTask.setActualInQuantity(zdTask.getProductIdQty()); -// WmStorageArea wmStorageArea = wmStorageAreaService.selectWmStorageAreaByAreaCode(zdTask.getAttr3()); -// wmsInTask.setCellTgt(wmStorageArea.getAreaId()); -// wmsInTask.setBatch(batchNum); -// wmsInTask.setMaterialId(zdTask.getmProductId().toString()); -// wmsInTask.setPlanTypeId("9"); -// wmsInTask.setPlanInStatus("1"); -// wmsInTaskService.insertWmsInTask(wmsInTask); + // 整刀入库计划, 根据图号查询入库计划,如果不存在生成计划,存在则往计划中添加任务 + WmsInPlan wmsInPlan = wmsInPlanService.selectWmsInPlanByPlanCode(zdTask.getAttr4()); + if (wmsInPlan == null) { + WmsInPlan wmsInPlanTemp = new WmsInPlan(); + wmsInPlanTemp.setState("1"); + wmsInPlanTemp.setSourceType("SGLR"); + wmsInPlanTemp.setCellCode(zdTask.getAttr3()); + wmsInPlanTemp.setPlanCode(zdTask.getAttr4() == null ? zdTask.getCode() : zdTask.getAttr4()); + wmsInPlanTemp.setRelBillCode("组装单据"); + wmsInPlanTemp.setPlanTypeId("13"); + wmsInPlanTemp.setCreateBy(getUsername()); + wmsInPlanTemp.setCreateTime(DateUtils.getNowDate()); + + // 入库任务明细 + List wmsInPlanDetailsList = new ArrayList<>(); + WmsInPlanDetails wmsInPlanDetails = new WmsInPlanDetails(); + wmsInPlanDetails.setMaterialId(zdTask.getmProductId().toString()); + wmsInPlanDetails.setBatch(batchNum); + wmsInPlanDetails.setCellId(1L); + wmsInPlanDetails.setQuantity(zdTask.getProductIdQty().toString()); + wmsInPlanDetails.setQuantityIn(zdTask.getProductIdQty().toString()); + wmsInPlanDetails.setPlanInStatus("0"); + wmsInPlanDetailsList.add(wmsInPlanDetails); + wmsInPlanTemp.setWmsInPlanDetailsList(wmsInPlanDetailsList); + wmsInPlanService.insertWmsInPlan(wmsInPlanTemp); + wmsInPlan = wmsInPlanTemp; + } else { + // 入库任务明细 + List wmsInPlanDetailsList = wmsInPlan.getWmsInPlanDetailsList(); + WmsInPlanDetails wmsInPlanDetails = new WmsInPlanDetails(); + wmsInPlanDetails.setMaterialId(zdTask.getmProductId().toString()); + wmsInPlanDetails.setBatch(batchNum); + wmsInPlanDetails.setCellId(1L); + wmsInPlanDetails.setQuantity(zdTask.getProductIdQty().toString()); + wmsInPlanDetails.setQuantityIn(zdTask.getProductIdQty().toString()); + wmsInPlanDetails.setPlanInStatus("0"); + wmsInPlanDetailsList.add(wmsInPlanDetails); + wmsInPlan.setWmsInPlanDetailsList(wmsInPlanDetailsList); + wmsInPlanService.updateWmsInPlan(wmsInPlan); + } + + // 入库任务 + MdItem mdItem = mdItemService.selectMdItemById(zdTask.getmProductId()); + WmsInTask wmsInTask = new WmsInTask(); + // 生成任务号 + String taskInCode = MultiModuleCodeGenerator.generateTaskCode("RKT"); + wmsInTask.setTaskInCode(taskInCode); + wmsInTask.setPlanInId(wmsInPlan.getPlanId().toString()); + wmsInTask.setPlanInCode(wmsInPlan.getPlanCode()); + wmsInTask.setMaterialCode(mdItem.getItemCode()); + wmsInTask.setTaskInQuantity(zdTask.getProductIdQty()); + wmsInTask.setActualInQuantity(zdTask.getProductIdQty()); + WmStorageArea wmStorageArea = wmStorageAreaService.selectWmStorageAreaByAreaCode(zdTask.getAttr3()); + wmsInTask.setCellTgt(wmStorageArea.getAreaId()); + wmsInTask.setBatch(batchNum); + wmsInTask.setMaterialId(zdTask.getmProductId().toString()); + wmsInTask.setPlanTypeId("9"); + wmsInTask.setPlanInStatus("1"); + wmsInTaskService.insertWmsInTask(wmsInTask); // 更新组装任务 @@ -845,14 +846,6 @@ public class BaseKnifeController extends BaseController { public TableDataInfo list(BaseKnife baseKnife) { startPage(); List list = baseKnifeService.selectBaseKnifeList(baseKnife); - list.forEach(item -> { - // 查询基础物料 - if ("PRODUCT".equals(item.getItemOrProduct())) { - BaseKnife baseKnifeWrapper = new BaseKnife(); - baseKnifeWrapper.setAttr1(item.getBaseKnifeId()); - item.setBaseKnifeList(baseKnifeService.selectBaseKnifeList(baseKnifeWrapper)); - } - }); return getDataTable(list); } diff --git a/ktg-mes/src/main/java/com/ktg/mes/md/service/impl/BaseKnifeServiceImpl.java b/ktg-mes/src/main/java/com/ktg/mes/md/service/impl/BaseKnifeServiceImpl.java index bb56fdb..21a08e6 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/md/service/impl/BaseKnifeServiceImpl.java +++ b/ktg-mes/src/main/java/com/ktg/mes/md/service/impl/BaseKnifeServiceImpl.java @@ -119,6 +119,13 @@ public class BaseKnifeServiceImpl implements IBaseKnifeService { wmsInPlanDetailEntityQuery.setKnifeId(nowBaseKnife.getBaseKnifeId()); List wmsInPlanDetailEntityList = wmsInPlanDetailEntityService.selectWmsInPlanDetailEntityList(wmsInPlanDetailEntityQuery); nowBaseKnife.setInInfoList(wmsInPlanDetailEntityList); + + // 查询基础物料 + if ("PRODUCT".equals(nowBaseKnife.getItemOrProduct())) { + BaseKnife baseKnifeWrapper = new BaseKnife(); + baseKnifeWrapper.setParentId(nowBaseKnife.getBaseKnifeId()); + nowBaseKnife.setBaseKnifeList(baseKnifeMapper.selectBaseKnifeList(baseKnifeWrapper)); + } }); return baseKnifeList; diff --git a/ktg-mes/src/main/java/com/ktg/mes/wm/controller/WmsZdTaskController.java b/ktg-mes/src/main/java/com/ktg/mes/wm/controller/WmsZdTaskController.java index 7cf82a1..030d079 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/wm/controller/WmsZdTaskController.java +++ b/ktg-mes/src/main/java/com/ktg/mes/wm/controller/WmsZdTaskController.java @@ -2,6 +2,8 @@ package com.ktg.mes.wm.controller; import java.util.List; import javax.servlet.http.HttpServletResponse; + +import com.ktg.common.constant.UserConstants; import org.springframework.security.access.prepost.PreAuthorize; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.GetMapping; @@ -100,6 +102,9 @@ public class WmsZdTaskController extends BaseController @PostMapping public AjaxResult add(@RequestBody WmsZdTask wmsZdTask) { + if (UserConstants.NOT_UNIQUE.equals(wmsZdTaskService.checkTaskCodeUnique(wmsZdTask))) { + return AjaxResult.error("新增物料" + wmsZdTask.getCode() + "失败,任务编码已存在"); + } return toAjax(wmsZdTaskService.insertWmsZdTask(wmsZdTask)); } diff --git a/ktg-mes/src/main/java/com/ktg/mes/wm/mapper/WmsInTaskMapper.java b/ktg-mes/src/main/java/com/ktg/mes/wm/mapper/WmsInTaskMapper.java index 74bb03a..45d6f1c 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/wm/mapper/WmsInTaskMapper.java +++ b/ktg-mes/src/main/java/com/ktg/mes/wm/mapper/WmsInTaskMapper.java @@ -2,6 +2,7 @@ package com.ktg.mes.wm.mapper; import java.util.List; import com.ktg.mes.wm.domain.WmsInTask; +import com.ktg.mes.wm.domain.WmsZdTask; /** * 入库任务Mapper接口 diff --git a/ktg-mes/src/main/java/com/ktg/mes/wm/mapper/WmsZdTaskMapper.java b/ktg-mes/src/main/java/com/ktg/mes/wm/mapper/WmsZdTaskMapper.java index 76ebd16..9eb69cf 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/wm/mapper/WmsZdTaskMapper.java +++ b/ktg-mes/src/main/java/com/ktg/mes/wm/mapper/WmsZdTaskMapper.java @@ -58,4 +58,6 @@ public interface WmsZdTaskMapper * @return 结果 */ public int deleteWmsZdTaskByWmsZdTaskIds(String[] wmsZdTaskIds); + + WmsZdTask checkTaskCodeUnique(WmsZdTask wmsZdTask); } diff --git a/ktg-mes/src/main/java/com/ktg/mes/wm/service/IWmsZdTaskService.java b/ktg-mes/src/main/java/com/ktg/mes/wm/service/IWmsZdTaskService.java index d66cc6c..9b561e5 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/wm/service/IWmsZdTaskService.java +++ b/ktg-mes/src/main/java/com/ktg/mes/wm/service/IWmsZdTaskService.java @@ -64,4 +64,6 @@ public interface IWmsZdTaskService AjaxResult createOutTaskByWmsZdTask(WmsZdTask wmsZdTask); AjaxResult createInTaskByWmsZdTask(WmsZdTask wmsZdTask); + + String checkTaskCodeUnique(WmsZdTask wmsZdTask); } diff --git a/ktg-mes/src/main/java/com/ktg/mes/wm/service/impl/WmsZdTaskServiceImpl.java b/ktg-mes/src/main/java/com/ktg/mes/wm/service/impl/WmsZdTaskServiceImpl.java index 453fe5a..0a759e5 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/wm/service/impl/WmsZdTaskServiceImpl.java +++ b/ktg-mes/src/main/java/com/ktg/mes/wm/service/impl/WmsZdTaskServiceImpl.java @@ -3,8 +3,10 @@ package com.ktg.mes.wm.service.impl; import java.util.ArrayList; import java.util.List; +import com.ktg.common.constant.UserConstants; import com.ktg.common.core.domain.AjaxResult; import com.ktg.common.utils.DateUtils; +import com.ktg.common.utils.StringUtils; import com.ktg.generator.util.MultiModuleCodeGenerator; import com.ktg.mes.md.domain.*; import com.ktg.mes.md.mapper.*; @@ -180,6 +182,11 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService // attr4 组装任务所属计划单, 如果为空则是手动组装任务不需要锁定 if (zdTask.getPlanSheet() != null) { lockedFlag = true; + BaseTechnologyBom technologyBomWrapper = new BaseTechnologyBom(); + technologyBomWrapper.setProcessCode(zdTask.getProcessCode()); + MdItem mdItemTemp = mdItemMapper.selectMdItemById(zdTask.getmProductId()); + technologyBomWrapper.setKnifeCode(mdItemTemp.getItemCode()); + technologyBom = baseTechnologyBomMapper.selectBaseTechnologyBomList(technologyBomWrapper).get(0); } // 出库基础物料, 根据图号查询出库计划,如果不存在生成计划,存在则往计划中添加任务 @@ -216,7 +223,6 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService baseKnife.setKnifeLife(100); baseKnife.setKnifeFineState(1); baseKnife.setIsValid(1); - baseKnife.setZdTaskId(zdTask.getWmsZdTaskId()); // 判断是否需要锁定整刀 if (lockedFlag) { baseKnife.setIsLocked(1); @@ -227,6 +233,7 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService } // attr4 计划编码, 整刀 baseKnife.setPlanSheet(zdTask.getPlanSheet()); + baseKnife.setZdTaskId(zdTask.getWmsZdTaskId()); baseKnife.setItemOrProduct("PRODUCT"); baseKnife.setCreateBy(getUsername()); baseKnife.setCreateTime(DateUtils.getNowDate()); @@ -487,12 +494,12 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService String batchNum = "ZZPC001"; // 整刀入库计划, 根据图号查询入库计划,如果不存在生成计划,存在则往计划中添加任务 + WmStorageArea wmStorageArea = wmStorageAreaMapper.selectWmStorageAreaByAreaId(zdTask.getAreaId()); WmsInPlan wmsInPlan = wmsInPlanService.selectWmsInPlanByPlanCode(zdTask.getPlanSheet()); if (wmsInPlan == null) { WmsInPlan wmsInPlanTemp = new WmsInPlan(); wmsInPlanTemp.setState("1"); wmsInPlanTemp.setSourceType("SGLR"); - WmStorageArea wmStorageArea = wmStorageAreaMapper.selectWmStorageAreaByAreaId(zdTask.getAreaId()); wmsInPlanTemp.setCellCode(wmStorageArea.getAreaCode()); wmsInPlanTemp.setPlanCode(zdTask.getPlanSheet() == null ? zdTask.getCode() : zdTask.getPlanSheet()); wmsInPlanTemp.setRelBillCode("组装单据"); @@ -505,7 +512,7 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService WmsInPlanDetails wmsInPlanDetails = new WmsInPlanDetails(); wmsInPlanDetails.setMaterialId(zdTask.getmProductId().toString()); wmsInPlanDetails.setBatch(batchNum); - wmsInPlanDetails.setCellId(1L); + wmsInPlanDetails.setCellId(wmStorageArea.getAreaId()); wmsInPlanDetails.setQuantity(zdTask.getProductIdQty().toString()); wmsInPlanDetails.setQuantityIn(zdTask.getProductIdQty().toString()); wmsInPlanDetails.setPlanInStatus("0"); @@ -519,7 +526,7 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService WmsInPlanDetails wmsInPlanDetails = new WmsInPlanDetails(); wmsInPlanDetails.setMaterialId(zdTask.getmProductId().toString()); wmsInPlanDetails.setBatch(batchNum); - wmsInPlanDetails.setCellId(1L); + wmsInPlanDetails.setCellId(wmStorageArea.getAreaId()); wmsInPlanDetails.setQuantity(zdTask.getProductIdQty().toString()); wmsInPlanDetails.setQuantityIn(zdTask.getProductIdQty().toString()); wmsInPlanDetails.setPlanInStatus("0"); @@ -539,7 +546,6 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService wmsInTask.setMaterialCode(mdItem.getItemCode()); wmsInTask.setTaskInQuantity(zdTask.getProductIdQty()); wmsInTask.setActualInQuantity(zdTask.getProductIdQty()); - WmStorageArea wmStorageArea = wmStorageAreaMapper.selectWmStorageAreaByAreaId(zdTask.getAreaId()); wmsInTask.setCellTgt(wmStorageArea.getAreaId()); wmsInTask.setBatch(batchNum); wmsInTask.setMaterialId(zdTask.getmProductId().toString()); @@ -566,4 +572,15 @@ public class WmsZdTaskServiceImpl implements IWmsZdTaskService wmsZdTaskMapper.updateWmsZdTask(zdTask); return AjaxResult.success(); } + + @Override + public String checkTaskCodeUnique(WmsZdTask wmsZdTask) { + WmsZdTask zdTask = wmsZdTaskMapper.checkTaskCodeUnique(wmsZdTask); + Long zdTaskId = wmsZdTask.getWmsZdTaskId() == null ? -1L : wmsZdTask.getWmsZdTaskId(); + if (StringUtils.isNotNull(zdTask) && zdTask.getWmsZdTaskId().longValue() != zdTaskId.longValue()) { + return UserConstants.NOT_UNIQUE; + } else { + return UserConstants.UNIQUE; + } + } } diff --git a/ktg-mes/src/main/resources/mapper/md/BaseKnifeMapper.xml b/ktg-mes/src/main/resources/mapper/md/BaseKnifeMapper.xml index a14b6df..8e04ac6 100644 --- a/ktg-mes/src/main/resources/mapper/md/BaseKnifeMapper.xml +++ b/ktg-mes/src/main/resources/mapper/md/BaseKnifeMapper.xml @@ -152,6 +152,9 @@ and BK.plan_sheet = #{planSheet} + + and BK.parent_id = #{parentId} + and BK.zd_task_id = #{zdTaskId} diff --git a/ktg-mes/src/main/resources/mapper/wm/WmsZdTaskMapper.xml b/ktg-mes/src/main/resources/mapper/wm/WmsZdTaskMapper.xml index 3a1e6d3..6de191b 100644 --- a/ktg-mes/src/main/resources/mapper/wm/WmsZdTaskMapper.xml +++ b/ktg-mes/src/main/resources/mapper/wm/WmsZdTaskMapper.xml @@ -163,4 +163,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{wmsZdTaskId} + + \ No newline at end of file