Commit 0b8834cdffcbea50201a2d730fc70872a0789fff
1 parent
2d8f3857
✨ feat(mes): 添加过程检验单编码,更新工作站校验方法返回类型
Showing
4 changed files
with
56 additions
and
15 deletions
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/md/autocode/MesMdAutoCodeRuleCodeEnum.java
| @@ -16,7 +16,8 @@ public enum MesMdAutoCodeRuleCodeEnum { | @@ -16,7 +16,8 @@ public enum MesMdAutoCodeRuleCodeEnum { | ||
| 16 | PACKAGE_CODE("WM_PACKAGE_CODE", "装箱单编码"), | 16 | PACKAGE_CODE("WM_PACKAGE_CODE", "装箱单编码"), |
| 17 | BATCH_CODE("WM_BATCH_CODE", "批次编码"), | 17 | BATCH_CODE("WM_BATCH_CODE", "批次编码"), |
| 18 | TASK_CODE("PRO_TASK_CODE", "生产任务编码"), | 18 | TASK_CODE("PRO_TASK_CODE", "生产任务编码"), |
| 19 | - QC_IQC_CODE("QC_IQC_CODE", "来料检验单编码"); | 19 | + QC_IQC_CODE("QC_IQC_CODE", "来料检验单编码"), |
| 20 | + QC_IPQC_CODE("QC_IPQC_CODE", "过程检验单编码"); | ||
| 20 | 21 | ||
| 21 | /** | 22 | /** |
| 22 | * 规则代码 | 23 | * 规则代码 |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/workstation/MesMdWorkstationService.java
| @@ -45,8 +45,9 @@ public interface MesMdWorkstationService { | @@ -45,8 +45,9 @@ public interface MesMdWorkstationService { | ||
| 45 | * 校验工作站存在 | 45 | * 校验工作站存在 |
| 46 | * | 46 | * |
| 47 | * @param id 编号 | 47 | * @param id 编号 |
| 48 | + * @return 工作站 | ||
| 48 | */ | 49 | */ |
| 49 | - void validateWorkstationExists(Long id); | 50 | + MesMdWorkstationDO validateWorkstationExists(Long id); |
| 50 | 51 | ||
| 51 | /** | 52 | /** |
| 52 | * 获得工作站 | 53 | * 获得工作站 |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/workstation/MesMdWorkstationServiceImpl.java
| @@ -121,10 +121,12 @@ public class MesMdWorkstationServiceImpl implements MesMdWorkstationService { | @@ -121,10 +121,12 @@ public class MesMdWorkstationServiceImpl implements MesMdWorkstationService { | ||
| 121 | } | 121 | } |
| 122 | 122 | ||
| 123 | @Override | 123 | @Override |
| 124 | - public void validateWorkstationExists(Long id) { | ||
| 125 | - if (workstationMapper.selectById(id) == null) { | 124 | + public MesMdWorkstationDO validateWorkstationExists(Long id) { |
| 125 | + MesMdWorkstationDO workstation = workstationMapper.selectById(id); | ||
| 126 | + if (workstation == null) { | ||
| 126 | throw exception(MD_WORKSTATION_NOT_EXISTS); | 127 | throw exception(MD_WORKSTATION_NOT_EXISTS); |
| 127 | } | 128 | } |
| 129 | + return workstation; | ||
| 128 | } | 130 | } |
| 129 | 131 | ||
| 130 | private void validateWorkshopExists(Long workshopId) { | 132 | private void validateWorkshopExists(Long workshopId) { |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/qc/ipqc/MesQcIpqcServiceImpl.java
| @@ -6,6 +6,8 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; | @@ -6,6 +6,8 @@ import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 6 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 6 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 7 | import cn.iocoder.yudao.module.mes.controller.admin.qc.ipqc.vo.MesQcIpqcPageReqVO; | 7 | import cn.iocoder.yudao.module.mes.controller.admin.qc.ipqc.vo.MesQcIpqcPageReqVO; |
| 8 | import cn.iocoder.yudao.module.mes.controller.admin.qc.ipqc.vo.MesQcIpqcSaveReqVO; | 8 | import cn.iocoder.yudao.module.mes.controller.admin.qc.ipqc.vo.MesQcIpqcSaveReqVO; |
| 9 | +import cn.iocoder.yudao.module.mes.dal.dataobject.md.workstation.MesMdWorkstationDO; | ||
| 10 | +import cn.iocoder.yudao.module.mes.dal.dataobject.pro.route.MesProRouteProductDO; | ||
| 9 | import cn.iocoder.yudao.module.mes.dal.dataobject.pro.workorder.MesProWorkOrderDO; | 11 | import cn.iocoder.yudao.module.mes.dal.dataobject.pro.workorder.MesProWorkOrderDO; |
| 10 | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.defectrecord.MesQcDefectRecordDO; | 12 | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.defectrecord.MesQcDefectRecordDO; |
| 11 | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.ipqc.MesQcIpqcDO; | 13 | import cn.iocoder.yudao.module.mes.dal.dataobject.qc.ipqc.MesQcIpqcDO; |
| @@ -18,6 +20,8 @@ import cn.iocoder.yudao.module.mes.enums.MesBizTypeConstants; | @@ -18,6 +20,8 @@ import cn.iocoder.yudao.module.mes.enums.MesBizTypeConstants; | ||
| 18 | import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService; | 20 | import cn.iocoder.yudao.module.mes.service.md.item.MesMdItemService; |
| 19 | import cn.iocoder.yudao.module.mes.service.md.workstation.MesMdWorkstationService; | 21 | import cn.iocoder.yudao.module.mes.service.md.workstation.MesMdWorkstationService; |
| 20 | import cn.iocoder.yudao.module.mes.service.pro.feedback.MesProFeedbackService; | 22 | import cn.iocoder.yudao.module.mes.service.pro.feedback.MesProFeedbackService; |
| 23 | +import cn.iocoder.yudao.module.mes.service.pro.route.MesProRouteProcessService; | ||
| 24 | +import cn.iocoder.yudao.module.mes.service.pro.route.MesProRouteProductService; | ||
| 21 | import cn.iocoder.yudao.module.mes.service.pro.workorder.MesProWorkOrderService; | 25 | import cn.iocoder.yudao.module.mes.service.pro.workorder.MesProWorkOrderService; |
| 22 | import cn.iocoder.yudao.module.mes.service.qc.defectrecord.MesQcDefectRecordService; | 26 | import cn.iocoder.yudao.module.mes.service.qc.defectrecord.MesQcDefectRecordService; |
| 23 | import cn.iocoder.yudao.module.mes.service.qc.template.MesQcTemplateDetailService; | 27 | import cn.iocoder.yudao.module.mes.service.qc.template.MesQcTemplateDetailService; |
| @@ -65,6 +69,12 @@ public class MesQcIpqcServiceImpl implements MesQcIpqcService { | @@ -65,6 +69,12 @@ public class MesQcIpqcServiceImpl implements MesQcIpqcService { | ||
| 65 | @Resource | 69 | @Resource |
| 66 | @Lazy | 70 | @Lazy |
| 67 | private MesQcDefectRecordService defectRecordService; | 71 | private MesQcDefectRecordService defectRecordService; |
| 72 | + @Resource | ||
| 73 | + @Lazy | ||
| 74 | + private MesProRouteProductService routeProductService; | ||
| 75 | + @Resource | ||
| 76 | + @Lazy | ||
| 77 | + private MesProRouteProcessService routeProcessService; | ||
| 68 | 78 | ||
| 69 | @Resource | 79 | @Resource |
| 70 | private AdminUserApi adminUserApi; | 80 | private AdminUserApi adminUserApi; |
| @@ -77,21 +87,21 @@ public class MesQcIpqcServiceImpl implements MesQcIpqcService { | @@ -77,21 +87,21 @@ public class MesQcIpqcServiceImpl implements MesQcIpqcService { | ||
| 77 | public Long createIpqc(MesQcIpqcSaveReqVO createReqVO) { | 87 | public Long createIpqc(MesQcIpqcSaveReqVO createReqVO) { |
| 78 | // 1.1 校验编号唯一 | 88 | // 1.1 校验编号唯一 |
| 79 | validateIpqcCodeUnique(null, createReqVO.getCode()); | 89 | validateIpqcCodeUnique(null, createReqVO.getCode()); |
| 80 | - // 1.2 校验工单、工位、检测人员、物料存在 | 90 | + // 1.2 校验工单、工位、检测人员存在 |
| 81 | MesProWorkOrderDO workOrder = workOrderService.validateWorkOrderExists(createReqVO.getWorkOrderId()); | 91 | MesProWorkOrderDO workOrder = workOrderService.validateWorkOrderExists(createReqVO.getWorkOrderId()); |
| 82 | - workstationService.validateWorkstationExists(createReqVO.getWorkstationId()); | 92 | + MesMdWorkstationDO workstation = workstationService.validateWorkstationExists(createReqVO.getWorkstationId()); |
| 83 | adminUserApi.validateUser(createReqVO.getInspectorUserId()); | 93 | adminUserApi.validateUser(createReqVO.getInspectorUserId()); |
| 84 | - itemService.validateItemExists(createReqVO.getItemId()); | ||
| 85 | // 1.3 根据产品 + 检验类型自动匹配模板 | 94 | // 1.3 根据产品 + 检验类型自动匹配模板 |
| 86 | MesQcTemplateItemDO templateItem = templateDetailService.getRequiredTemplateByItemIdAndType( | 95 | MesQcTemplateItemDO templateItem = templateDetailService.getRequiredTemplateByItemIdAndType( |
| 87 | workOrder.getProductId(), MesQcTypeEnum.IPQC.getType()); | 96 | workOrder.getProductId(), MesQcTypeEnum.IPQC.getType()); |
| 88 | Long templateId = templateItem.getTemplateId(); | 97 | Long templateId = templateItem.getTemplateId(); |
| 89 | - // TODO @AI:processId 不应该是前端传递,而是通过 workstation + work order + route 表,联合查询出来的; | ||
| 90 | 98 | ||
| 91 | // 2. 插入主表 | 99 | // 2. 插入主表 |
| 92 | - MesQcIpqcDO ipqc = BeanUtils.toBean(createReqVO, MesQcIpqcDO.class); | ||
| 93 | - ipqc.setItemId(workOrder.getProductId()); | ||
| 94 | - ipqc.setTemplateId(templateId).setStatus(MesQcStatusEnum.DRAFT.getStatus()); | 100 | + MesQcIpqcDO ipqc = BeanUtils.toBean(createReqVO, MesQcIpqcDO.class) |
| 101 | + .setItemId(workOrder.getProductId()) | ||
| 102 | + .setProcessId(getProcessId(workOrder.getProductId(), workstation.getProcessId())) | ||
| 103 | + .setTemplateId(templateId) | ||
| 104 | + .setStatus(MesQcStatusEnum.DRAFT.getStatus()); | ||
| 95 | ipqcMapper.insert(ipqc); | 105 | ipqcMapper.insert(ipqc); |
| 96 | 106 | ||
| 97 | // 3. 从模板指标自动生成检验行 | 107 | // 3. 从模板指标自动生成检验行 |
| @@ -105,18 +115,18 @@ public class MesQcIpqcServiceImpl implements MesQcIpqcService { | @@ -105,18 +115,18 @@ public class MesQcIpqcServiceImpl implements MesQcIpqcService { | ||
| 105 | validateIpqcStatusPrepare(updateReqVO.getId()); | 115 | validateIpqcStatusPrepare(updateReqVO.getId()); |
| 106 | // 1.2 校验编号唯一 | 116 | // 1.2 校验编号唯一 |
| 107 | validateIpqcCodeUnique(updateReqVO.getId(), updateReqVO.getCode()); | 117 | validateIpqcCodeUnique(updateReqVO.getId(), updateReqVO.getCode()); |
| 108 | - // 1.3 校验工单、工位、检测人员、物料存在 | ||
| 109 | - workOrderService.validateWorkOrderExists(updateReqVO.getWorkOrderId()); | ||
| 110 | - workstationService.validateWorkstationExists(updateReqVO.getWorkstationId()); | 118 | + // 1.3 校验工位、检测人员存在 |
| 119 | + MesMdWorkstationDO workstation = workstationService.validateWorkstationExists(updateReqVO.getWorkstationId()); | ||
| 111 | adminUserApi.validateUser(updateReqVO.getInspectorUserId()); | 120 | adminUserApi.validateUser(updateReqVO.getInspectorUserId()); |
| 112 | - itemService.validateItemExists(updateReqVO.getItemId()); | ||
| 113 | 121 | ||
| 114 | // 2. 更新主表 | 122 | // 2. 更新主表 |
| 123 | + MesQcIpqcDO existIpqc = validateIpqcExists(updateReqVO.getId()); | ||
| 115 | MesQcIpqcDO updateObj = BeanUtils.toBean(updateReqVO, MesQcIpqcDO.class); | 124 | MesQcIpqcDO updateObj = BeanUtils.toBean(updateReqVO, MesQcIpqcDO.class); |
| 116 | updateObj.setSourceDocType(null).setSourceDocId(null).setSourceLineId(null); // 不允许修改来源单据 | 125 | updateObj.setSourceDocType(null).setSourceDocId(null).setSourceLineId(null); // 不允许修改来源单据 |
| 117 | updateObj.setTemplateId(null); // 不允许修改模板 | 126 | updateObj.setTemplateId(null); // 不允许修改模板 |
| 118 | updateObj.setItemId(null); // 不允许修改物料 | 127 | updateObj.setItemId(null); // 不允许修改物料 |
| 119 | updateObj.setWorkOrderId(null); // 不允许修改工单 | 128 | updateObj.setWorkOrderId(null); // 不允许修改工单 |
| 129 | + updateObj.setProcessId(getProcessId(existIpqc.getItemId(), workstation.getProcessId())); | ||
| 120 | ipqcMapper.updateById(updateObj); | 130 | ipqcMapper.updateById(updateObj); |
| 121 | } | 131 | } |
| 122 | 132 | ||
| @@ -214,6 +224,33 @@ public class MesQcIpqcServiceImpl implements MesQcIpqcService { | @@ -214,6 +224,33 @@ public class MesQcIpqcServiceImpl implements MesQcIpqcService { | ||
| 214 | } | 224 | } |
| 215 | } | 225 | } |
| 216 | 226 | ||
| 227 | + /** | ||
| 228 | + * 推导工序 ID:对齐 KTG getProcessInfo() 逻辑 | ||
| 229 | + * | ||
| 230 | + * <p>通过产品 → 工艺路线产品 → 工艺路线 → 校验工位工序是否在该路线中 | ||
| 231 | + * <p>如果工位的工序在路线中,则返回该 processId;否则返回 null | ||
| 232 | + * | ||
| 233 | + * @param productId 产品 ID(工单产品) | ||
| 234 | + * @param workstationProcessId 工位关联的工序 ID | ||
| 235 | + * @return 推导出的工序 ID,无法推导时返回 null | ||
| 236 | + */ | ||
| 237 | + private Long getProcessId(Long productId, Long workstationProcessId) { | ||
| 238 | + if (productId == null || workstationProcessId == null) { | ||
| 239 | + return null; | ||
| 240 | + } | ||
| 241 | + // 1. 产品 → 工艺路线 | ||
| 242 | + MesProRouteProductDO routeProduct = routeProductService.getRouteProductByItemId(productId); | ||
| 243 | + if (routeProduct == null) { | ||
| 244 | + return null; | ||
| 245 | + } | ||
| 246 | + // 2. 校验工位的工序是否在该路线中 | ||
| 247 | + if (routeProcessService.getRouteProcessByRouteIdAndProcessId( | ||
| 248 | + routeProduct.getRouteId(), workstationProcessId) == null) { | ||
| 249 | + return null; | ||
| 250 | + } | ||
| 251 | + return workstationProcessId; | ||
| 252 | + } | ||
| 253 | + | ||
| 217 | @Override | 254 | @Override |
| 218 | public MesQcIpqcDO getIpqc(Long id) { | 255 | public MesQcIpqcDO getIpqc(Long id) { |
| 219 | return ipqcMapper.selectById(id); | 256 | return ipqcMapper.selectById(id); |