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 cbb04c5..5b43e4f 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 @@ -127,13 +127,11 @@ public class BaseKnifeController extends BaseController @PostMapping("/open/checkForAlignment") @ResponseBody - public AjaxResult checkForAlignment(@RequestBody String json) { - // 检查请求json是否正确 - List technologyBomList = JSON.parseArray(json, BaseTechnologyBom.class); + public AjaxResult checkForAlignment(@RequestBody List processCodeList) { + // 获取工艺bom + List technologyBomList = baseTechnologyBomService.selectBaseTechnologyBomListByProcessCodeList(processCodeList); if (technologyBomList.isEmpty() || technologyBomList.size() == 1 && technologyBomList.get(0).getKnifeCode() == null) return AjaxResult.error("未检测到工艺bom项"); - // 记录请求数据 - technologyBomList.forEach(baseTechnologyBom -> baseTechnologyBomService.insertBaseTechnologyBom(baseTechnologyBom)); // 构建日志 SysOperLog operLog = new SysOperLog(); @@ -145,7 +143,7 @@ public class BaseKnifeController extends BaseController operLog.setOperLocation("上游系统"); operLog.setOperUrl("/mes/md/baseKnife/open/checkForAlignment"); operLog.setMethod("com.ktg.mes.md.controller.BaseKnifeController.checkForAlignment()"); - operLog.setOperParam(json); + operLog.setOperParam(JSON.toJSONString(processCodeList)); operLog.setStatus(1); operLog.setOperTime(new Date()); @@ -304,18 +302,28 @@ public class BaseKnifeController extends BaseController } - @PostMapping("/open/productionArrangements") + @PostMapping("/open/productionArrangements/{planCode}") @ResponseBody - public AjaxResult productionArrangements(@RequestBody String json) { - // 验证请求数据 - List technologyBomList = JSON.parseArray(json, BaseTechnologyBom.class); + public AjaxResult productionArrangements(@PathVariable String planCode, @RequestBody List processCodeList) { + // 检查计划单是否已存在 + BaseKnife baseKnifePlan = new BaseKnife(); + baseKnifePlan.setPlanSheet(planCode); + if (!baseKnifeService.selectBaseKnifeList(baseKnifePlan).isEmpty()) + return AjaxResult.error("该计划单已存在,请更换重试"); + + // 验证bom工艺 + List technologyBomList = baseTechnologyBomService.selectBaseTechnologyBomListByProcessCodeList(processCodeList); if (technologyBomList.isEmpty() || technologyBomList.size() == 1 && technologyBomList.get(0).getKnifeCode() == null) return AjaxResult.error("未检测到工艺bom项"); - technologyBomList.forEach(baseTechnologyBom -> baseTechnologyBomService.insertBaseTechnologyBom(baseTechnologyBom)); // 记录数据修改 List baseKnifeOriginList = new ArrayList<>(); + // 参数列表 + Map params = new HashMap<>(); + params.put("planCode", planCode); + params.put("processCodeList", processCodeList); + // 构建日志 SysOperLog operLog = new SysOperLog(); operLog.setTitle("生产准备"); @@ -326,7 +334,7 @@ public class BaseKnifeController extends BaseController operLog.setOperLocation("上游系统"); operLog.setOperUrl("/mes/md/baseKnife/open/productionArrangements"); operLog.setMethod("com.ktg.mes.md.controller.BaseKnifeController.productionArrangements()"); - operLog.setOperParam(json); + operLog.setOperParam(JSON.toJSONString(params)); operLog.setStatus(1); operLog.setOperTime(new Date()); // 接口返回信息 @@ -429,7 +437,7 @@ public class BaseKnifeController extends BaseController countMap.put(item.getKnifeCode(), countMap.get(item.getKnifeCode()) + 1); // 记录源数据然后锁定 baseKnifeOriginList.add(item); - item.setPlanSheet(techBom.getTechnologyBomId()); + item.setPlanSheet(planCode); item.setIsLocked(1); item.setLockedStartTime(techBom.getLockedStartTime()); item.setLockedEndTime(techBom.getLockedEndTime()); @@ -535,9 +543,10 @@ public class BaseKnifeController extends BaseController return AjaxResult.error("Bom头查询错误", techBom.getKnifeCode()); } + // 生成组装任务 WmsZdTask wmsZdTask = new WmsZdTask(); wmsZdTask.setmProductId(mdItem.getItemId()); - wmsZdTask.setAttr4(techBom.getTechnologyBomId()); + wmsZdTask.setAttr4(planCode); wmsZdTask.setCode(techBom.getProcessCode()); wmsZdTask.setName(techBom.getProcessName()); wmsZdTask.setProductIdQty(count); @@ -594,16 +603,13 @@ public class BaseKnifeController extends BaseController // attr4 组装任务所属计划单, 如果为空则是手动组装任务不需要锁定 if (zdTask.getAttr4() != null){ lockedFlag = true; - technologyBom = baseTechnologyBomService.selectBaseTechnologyBomByTechnologyBomId(zdTask.getAttr4()); - } else { - technologyBom.setFigureCode(zdTask.getCode()); } // 出库基础物料, 根据图号查询出库计划,如果不存在生成计划,存在则往计划中添加任务 - WmsOutPlan outPlan = wmsOutPlanMapper.selectWmsOutPlanByPlanCode(technologyBom.getFigureCode()); + WmsOutPlan outPlan = wmsOutPlanMapper.selectWmsOutPlanByPlanCode(zdTask.getAttr4()); if (outPlan == null){ WmsOutPlan outPlanTemp = new WmsOutPlan(); - outPlanTemp.setPlanCode(technologyBom.getFigureCode()); + outPlanTemp.setPlanCode(zdTask.getAttr4()); outPlanTemp.setWmsBusinessTypeId(12L); outPlanTemp.setPlanState("1"); outPlanTemp.setPlanType("ZDCK"); @@ -679,6 +685,7 @@ public class BaseKnifeController extends BaseController wmsBaseKnife.setLockedStartTime(technologyBom.getLockedStartTime()); wmsBaseKnife.setLockedEndTime(technologyBom.getLockedEndTime()); wmsBaseKnife.setAttr1(baseKnife.getBaseKnifeId()); + wmsBaseKnife.setPlanSheet(zdTask.getAttr4()); baseKnifeListOutPlan.add(wmsBaseKnife); baseKnifeService.updateBaseKnife(wmsBaseKnife); bomCount--; @@ -738,13 +745,13 @@ public class BaseKnifeController extends BaseController } // 整刀入库计划, 根据图号查询入库计划,如果不存在生成计划,存在则往计划中添加任务 - WmsInPlan wmsInPlan = wmsInPlanService.selectWmsInPlanByPlanCode(technologyBom.getFigureCode()); + 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(technologyBom.getFigureCode()); + wmsInPlanTemp.setPlanCode(zdTask.getAttr4()); wmsInPlanTemp.setRelBillCode("组装单据"); wmsInPlanTemp.setPlanTypeId("13"); wmsInPlanTemp.setCreateBy(getUsername()); @@ -782,7 +789,7 @@ public class BaseKnifeController extends BaseController MdItem mdItem = mdItemService.selectMdItemById(zdTask.getmProductId()); WmsInTask wmsInTask = new WmsInTask(); wmsInTask.setPlanInId(wmsInPlan.getPlanId().toString()); - wmsInTask.setPlanInCode(generateTaskCode(wmsInPlan.getPlanCode())); + wmsInTask.setPlanInCode(wmsInPlan.getPlanCode()); wmsInTask.setMaterialCode(mdItem.getItemCode()); wmsInTask.setTaskInQuantity(zdTask.getProductIdQty()); wmsInTask.setActualInQuantity(zdTask.getProductIdQty()); diff --git a/ktg-mes/src/main/java/com/ktg/mes/md/mapper/BaseTechnologyBomMapper.java b/ktg-mes/src/main/java/com/ktg/mes/md/mapper/BaseTechnologyBomMapper.java index 3fc06a8..889bf53 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/md/mapper/BaseTechnologyBomMapper.java +++ b/ktg-mes/src/main/java/com/ktg/mes/md/mapper/BaseTechnologyBomMapper.java @@ -58,4 +58,6 @@ public interface BaseTechnologyBomMapper * @return 结果 */ public int deleteBaseTechnologyBomByTechnologyBomIds(String[] technologyBomIds); + + List selectBaseTechnologyBomListByProcessCodeList(List processCodeList); } diff --git a/ktg-mes/src/main/java/com/ktg/mes/md/service/IBaseTechnologyBomService.java b/ktg-mes/src/main/java/com/ktg/mes/md/service/IBaseTechnologyBomService.java index 6287e89..aead0c8 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/md/service/IBaseTechnologyBomService.java +++ b/ktg-mes/src/main/java/com/ktg/mes/md/service/IBaseTechnologyBomService.java @@ -58,4 +58,6 @@ public interface IBaseTechnologyBomService * @return 结果 */ public int deleteBaseTechnologyBomByTechnologyBomId(String technologyBomId); + + List selectBaseTechnologyBomListByProcessCodeList(List processCodeList); } diff --git a/ktg-mes/src/main/java/com/ktg/mes/md/service/impl/BaseTechnologyBomServiceImpl.java b/ktg-mes/src/main/java/com/ktg/mes/md/service/impl/BaseTechnologyBomServiceImpl.java index cbd7236..9d440c1 100644 --- a/ktg-mes/src/main/java/com/ktg/mes/md/service/impl/BaseTechnologyBomServiceImpl.java +++ b/ktg-mes/src/main/java/com/ktg/mes/md/service/impl/BaseTechnologyBomServiceImpl.java @@ -1,5 +1,6 @@ package com.ktg.mes.md.service.impl; +import java.util.Collections; import java.util.List; import com.ktg.common.utils.DateUtils; import org.springframework.beans.factory.annotation.Autowired; @@ -93,4 +94,9 @@ public class BaseTechnologyBomServiceImpl implements IBaseTechnologyBomService { return baseTechnologyBomMapper.deleteBaseTechnologyBomByTechnologyBomId(technologyBomId); } + + @Override + public List selectBaseTechnologyBomListByProcessCodeList(List processCodeList) { + return baseTechnologyBomMapper.selectBaseTechnologyBomListByProcessCodeList(processCodeList); + } } diff --git a/ktg-mes/src/main/resources/mapper/md/BaseKnifeMapper.xml b/ktg-mes/src/main/resources/mapper/md/BaseKnifeMapper.xml index f47a0d6..4e3ee92 100644 --- a/ktg-mes/src/main/resources/mapper/md/BaseKnifeMapper.xml +++ b/ktg-mes/src/main/resources/mapper/md/BaseKnifeMapper.xml @@ -93,12 +93,10 @@ BK.CREATE_BY, BK.CREATE_TIME, BK.UPDATE_BY, - BK.UPDATE_TIME, - BTB.FIGURE_CODE PLAN_SHEET + BK.UPDATE_TIME from BASE_KNIFE BK LEFT JOIN MD_ITEM MI on BK.MBB_BD_MRL_ID = MI.ITEM_ID LEFT JOIN MD_ITEM_TYPE MIT ON MI.ITEM_TYPE_ID = MIT.ITEM_TYPE_ID - LEFT JOIN BASE_TECHNOLOGY_BOM BTB ON BTB.TECHNOLOGY_BOM_ID = BK.PLAN_SHEET + + where process_code in + + #{processCode} + + \ No newline at end of file diff --git a/ktg-mes/src/main/resources/mapper/wm/WmsZdTaskMapper.xml b/ktg-mes/src/main/resources/mapper/wm/WmsZdTaskMapper.xml index ab10022..13563c9 100644 --- a/ktg-mes/src/main/resources/mapper/wm/WmsZdTaskMapper.xml +++ b/ktg-mes/src/main/resources/mapper/wm/WmsZdTaskMapper.xml @@ -31,10 +31,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select wzt.WMS_ZD_TASK_ID, wzt.CODE, wzt."name", wzt.M_PRODUCT_ID, wzt."product_id_qty", wzt.QTY, wzt.PLAN_OUT_ID, wzt.PLAN_OUT_TYPE, wzt.QTY_OK, wzt.REMARK, wzt.ATTR1, wzt.ATTR3, wzt.ATTR4, wzt.CREATE_BY, wzt.CREATE_TIME, - wzt.UPDATE_BY, wzt.UPDATE_TIME, wzt.STATUS, mi.item_name attr2, btb.figure_code plan_sheet + wzt.UPDATE_BY, wzt.UPDATE_TIME, wzt.STATUS, mi.item_name attr2 from WMS_ZD_TASK wzt left join md_item mi on wzt.m_product_id = mi.item_id - left join base_technology_bom btb on btb.technology_bom_id = wzt.attr4