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 d67e6a2..cbb04c5 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 @@ -329,6 +329,7 @@ public class BaseKnifeController extends BaseController operLog.setOperParam(json); operLog.setStatus(1); operLog.setOperTime(new Date()); + // 接口返回信息 String msg = "生产准备验证成功!"; // 记录所需物料数量的map @@ -351,6 +352,7 @@ public class BaseKnifeController extends BaseController return AjaxResult.error("物料台账查询错误", techBom.getKnifeCode()); } + // 查询复合条件的台账 baseKnifeWrapper.setMbbBdMrlId(mdItemTemp.getItemId()); baseKnifeWrapper.setIsLocked(0); List tempList = this.baseKnifeService.selectBaseKnifeList(baseKnifeWrapper); @@ -573,6 +575,7 @@ public class BaseKnifeController extends BaseController BomRoute bomRoute = bomRouteService.selectBomRouteByBomRouteId(zdTask.getAttr1()); BaseKnife baseKnifeWrapper = new BaseKnife(); List baseKnifeList = new ArrayList<>(); + // 遍历组装整刀需要的bom物料 for (MbbProduBom mbbProduBom : bomRoute.getMbbProduBomList()) { baseKnifeWrapper.setMbbBdMrlId(mbbProduBom.getMdItemId()); baseKnifeWrapper.setIsLocked(0); @@ -588,6 +591,7 @@ public class BaseKnifeController extends BaseController // 查询工艺bom BaseTechnologyBom technologyBom = new BaseTechnologyBom(); Boolean lockedFlag = false; + // attr4 组装任务所属计划单, 如果为空则是手动组装任务不需要锁定 if (zdTask.getAttr4() != null){ lockedFlag = true; technologyBom = baseTechnologyBomService.selectBaseTechnologyBomByTechnologyBomId(zdTask.getAttr4()); @@ -595,15 +599,19 @@ public class BaseKnifeController extends BaseController technologyBom.setFigureCode(zdTask.getCode()); } - // 出库基础物料 - WmsOutPlan outPlan = new WmsOutPlan(); - outPlan.setPlanCode(technologyBom.getFigureCode()); - outPlan.setWmsBusinessTypeId(12L); - outPlan.setPlanState("1"); - outPlan.setPlanType("ZDCK"); - outPlan.setCreateBy(getUsername()); - outPlan.setCreateTime(DateUtils.getNowDate()); - wmsOutPlanMapper.insertWmsOutPlan(outPlan); + // 出库基础物料, 根据图号查询出库计划,如果不存在生成计划,存在则往计划中添加任务 + WmsOutPlan outPlan = wmsOutPlanMapper.selectWmsOutPlanByPlanCode(technologyBom.getFigureCode()); + if (outPlan == null){ + WmsOutPlan outPlanTemp = new WmsOutPlan(); + outPlanTemp.setPlanCode(technologyBom.getFigureCode()); + outPlanTemp.setWmsBusinessTypeId(12L); + outPlanTemp.setPlanState("1"); + outPlanTemp.setPlanType("ZDCK"); + outPlanTemp.setCreateBy(getUsername()); + outPlanTemp.setCreateTime(DateUtils.getNowDate()); + wmsOutPlanMapper.insertWmsOutPlan(outPlanTemp); + outPlan = outPlanTemp; + } // 锁定物料 Boolean outPlanFlag = true; @@ -621,6 +629,7 @@ public class BaseKnifeController extends BaseController baseKnife.setStandardQuantity("1"); baseKnife.setKnifeLife(100); baseKnife.setKnifeFineState(0); + // 判断是否需要锁定整刀 if (lockedFlag) { baseKnife.setIsLocked(1); baseKnife.setLockedStartTime(technologyBom.getLockedStartTime()); @@ -661,7 +670,7 @@ public class BaseKnifeController extends BaseController wmsOutPlanDetailList.add(outPlanDetail); } - // 锁定物料 + // 锁定基础 物料 int bomCount = mbbProduBom.getStandardDosage(); for (BaseKnife wmsBaseKnife : baseKnifeList){ if (bomCount > 0){ @@ -673,6 +682,7 @@ public class BaseKnifeController extends BaseController baseKnifeListOutPlan.add(wmsBaseKnife); baseKnifeService.updateBaseKnife(wmsBaseKnife); bomCount--; + // 记录刀片重置次数 resetCount += wmsBaseKnife.getResetCount(); } } @@ -699,11 +709,12 @@ public class BaseKnifeController extends BaseController wmsOutPlanDetailEntityMapper.insertWmsOutPlanDetailEntity(wmsOutPlanDetailEntity); } - // 出库任务 + // 生成出库任务 WmsOutTask wmsOutTask = new WmsOutTask(); wmsOutTask.setWmsOutPlanId(outPlan.getWmsOutPlanId()); - wmsOutTask.setWmsOutPlanCode(outPlan.getPlanCode()); + wmsOutTask.setWmsOutPlanCode(generateTaskCode(outPlan.getPlanCode())); wmsOutTask.setWmsOutPlanDetailId(outPlanDetail.getWmsOutPlanDetailId()); + // 出库类型 12组刀出库 wmsOutTask.setWmsBusinessTypeId(12L); wmsOutTask.setTaskCode(outPlan.getPlanCode()); wmsOutTask.setTaskNumber(outPlanDetail.getPlannedQuantity()); @@ -726,29 +737,46 @@ public class BaseKnifeController extends BaseController mdItemService.updateMdItem(mdItem); } - // 整刀入库计划 - WmsInPlan wmsInPlan = new WmsInPlan(); - wmsInPlan.setState("1"); - wmsInPlan.setSourceType("SGLR"); - wmsInPlan.setCellCode(zdTask.getAttr3()); - wmsInPlan.setPlanCode(technologyBom.getFigureCode()); - wmsInPlan.setRelBillCode("组装单据"); - wmsInPlan.setPlanTypeId("13"); - wmsInPlan.setCreateBy(getUsername()); - wmsInPlan.setCreateTime(DateUtils.getNowDate()); + // 整刀入库计划, 根据图号查询入库计划,如果不存在生成计划,存在则往计划中添加任务 + WmsInPlan wmsInPlan = wmsInPlanService.selectWmsInPlanByPlanCode(technologyBom.getFigureCode()); + if (wmsInPlan == null){ + WmsInPlan wmsInPlanTemp = new WmsInPlan(); + wmsInPlanTemp.setState("1"); + wmsInPlanTemp.setSourceType("SGLR"); + wmsInPlanTemp.setCellCode(zdTask.getAttr3()); + wmsInPlanTemp.setPlanCode(technologyBom.getFigureCode()); + 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("1"); - wmsInPlanDetails.setQuantity(zdTask.getProductIdQty().toString()); - wmsInPlanDetails.setQuantityIn(zdTask.getProductIdQty().toString()); - wmsInPlanDetails.setPlanInStatus("0"); - wmsInPlanDetailsList.add(wmsInPlanDetails); - wmsInPlan.setWmsInPlanDetailsList(wmsInPlanDetailsList); - wmsInPlanService.insertWmsInPlan(wmsInPlan); + // 入库任务明细 + List wmsInPlanDetailsList = new ArrayList<>(); + WmsInPlanDetails wmsInPlanDetails = new WmsInPlanDetails(); + wmsInPlanDetails.setMaterialId(zdTask.getmProductId().toString()); + wmsInPlanDetails.setBatch(batchNum); + wmsInPlanDetails.setCellId("1"); + 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("1"); + 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()); diff --git a/ktg-mes/src/main/java/com/ktg/mes/md/mapper/WmsOutPlanMapper.java b/ktg-mes/src/main/java/com/ktg/mes/md/mapper/WmsOutPlanMapper.java index 15cd215..03562d8 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/md/mapper/WmsOutPlanMapper.java +++ b/ktg-mes/src/main/java/com/ktg/mes/md/mapper/WmsOutPlanMapper.java @@ -101,4 +101,6 @@ public interface WmsOutPlanMapper { ); WmsOutPlanDetail selectWmsOutPlanDetailById(Long wmsOutPlanDetailId); + + WmsOutPlan selectWmsOutPlanByPlanCode(String figureCode); } diff --git a/ktg-mes/src/main/java/com/ktg/mes/wm/mapper/WmsInPlanMapper.java b/ktg-mes/src/main/java/com/ktg/mes/wm/mapper/WmsInPlanMapper.java index 6b226a2..04fe90c 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/wm/mapper/WmsInPlanMapper.java +++ b/ktg-mes/src/main/java/com/ktg/mes/wm/mapper/WmsInPlanMapper.java @@ -84,4 +84,6 @@ public interface WmsInPlanMapper * @return 结果 */ public int deleteWmsInPlanDetailsByPlanId(String planId); + + WmsInPlan selectWmsInPlanByPlanCode(String planCode); } 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 d9bde35..ca39920 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 @@ -19,6 +19,8 @@ public interface IWmsInPlanService */ public WmsInPlan selectWmsInPlanByPlanId(String planId); + WmsInPlan selectWmsInPlanByPlanCode(String planCode); + /** * 查询入库计划列表 * @@ -58,4 +60,5 @@ public interface IWmsInPlanService * @return 结果 */ public int deleteWmsInPlanByPlanId(String 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 cf06451..7029a3a 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 @@ -42,6 +42,11 @@ public class WmsInPlanServiceImpl implements IWmsInPlanService { return wmsInPlanMapper.selectWmsInPlanByPlanId(planId); } + @Override + public WmsInPlan selectWmsInPlanByPlanCode(String planCode) { + return wmsInPlanMapper.selectWmsInPlanByPlanCode(planCode); + } + /** * 查询入库计划列表 * diff --git a/ktg-mes/src/main/resources/mapper/md/WmsOutPlanMapper.xml b/ktg-mes/src/main/resources/mapper/md/WmsOutPlanMapper.xml index 85e0494..9f2c617 100644 --- a/ktg-mes/src/main/resources/mapper/md/WmsOutPlanMapper.xml +++ b/ktg-mes/src/main/resources/mapper/md/WmsOutPlanMapper.xml @@ -390,4 +390,47 @@ FROM WMS_OUT_PLAN_DETAIL WHERE WMS_OUT_PLAN_DETAIL_ID = #{wmsOutPlanDetailId}; + + \ No newline at end of file diff --git a/ktg-mes/src/main/resources/mapper/wm/WmsInPlanMapper.xml b/ktg-mes/src/main/resources/mapper/wm/WmsInPlanMapper.xml index c5e3695..e18c73a 100644 --- a/ktg-mes/src/main/resources/mapper/wm/WmsInPlanMapper.xml +++ b/ktg-mes/src/main/resources/mapper/wm/WmsInPlanMapper.xml @@ -175,6 +175,55 @@ where a.PLAN_ID = #{planId} + + insert into WMS_IN_PLAN