Commit de40b938af3672e56a3e383107c1a57ec975eb4e

Authored by YunaiV
1 parent 662194d1

✨ feat(mes): 增强工序管理功能,新增工序校验逻辑

新增工序创建和更新时的存在性校验,确保工序有效性。
同时,重构工艺路线服务,优化工序引用检查逻辑。
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/process/MesProProcessContentServiceImpl.java
@@ -5,6 +5,7 @@ import cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.content.MesPr @@ -5,6 +5,7 @@ import cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.content.MesPr
5 import cn.iocoder.yudao.module.mes.dal.dataobject.pro.process.MesProProcessContentDO; 5 import cn.iocoder.yudao.module.mes.dal.dataobject.pro.process.MesProProcessContentDO;
6 import cn.iocoder.yudao.module.mes.dal.mysql.pro.process.MesProProcessContentMapper; 6 import cn.iocoder.yudao.module.mes.dal.mysql.pro.process.MesProProcessContentMapper;
7 import jakarta.annotation.Resource; 7 import jakarta.annotation.Resource;
  8 +import org.springframework.context.annotation.Lazy;
8 import org.springframework.stereotype.Service; 9 import org.springframework.stereotype.Service;
9 import org.springframework.validation.annotation.Validated; 10 import org.springframework.validation.annotation.Validated;
10 11
@@ -25,8 +26,16 @@ public class MesProProcessContentServiceImpl implements MesProProcessContentServ @@ -25,8 +26,16 @@ public class MesProProcessContentServiceImpl implements MesProProcessContentServ
25 @Resource 26 @Resource
26 private MesProProcessContentMapper processContentMapper; 27 private MesProProcessContentMapper processContentMapper;
27 28
  29 + @Resource
  30 + @Lazy
  31 + private MesProProcessService processService;
  32 +
28 @Override 33 @Override
29 public Long createProcessContent(MesProProcessContentSaveReqVO createReqVO) { 34 public Long createProcessContent(MesProProcessContentSaveReqVO createReqVO) {
  35 + // 校验工序存在
  36 + processService.validateProcessExists(createReqVO.getProcessId());
  37 +
  38 + // 插入
30 MesProProcessContentDO content = BeanUtils.toBean(createReqVO, MesProProcessContentDO.class); 39 MesProProcessContentDO content = BeanUtils.toBean(createReqVO, MesProProcessContentDO.class);
31 processContentMapper.insert(content); 40 processContentMapper.insert(content);
32 return content.getId(); 41 return content.getId();
@@ -36,6 +45,7 @@ public class MesProProcessContentServiceImpl implements MesProProcessContentServ @@ -36,6 +45,7 @@ public class MesProProcessContentServiceImpl implements MesProProcessContentServ
36 public void updateProcessContent(MesProProcessContentSaveReqVO updateReqVO) { 45 public void updateProcessContent(MesProProcessContentSaveReqVO updateReqVO) {
37 // 校验存在 46 // 校验存在
38 validateProcessContentExists(updateReqVO.getId()); 47 validateProcessContentExists(updateReqVO.getId());
  48 +
39 // 更新 49 // 更新
40 MesProProcessContentDO updateObj = BeanUtils.toBean(updateReqVO, MesProProcessContentDO.class); 50 MesProProcessContentDO updateObj = BeanUtils.toBean(updateReqVO, MesProProcessContentDO.class);
41 processContentMapper.updateById(updateObj); 51 processContentMapper.updateById(updateObj);
@@ -45,6 +55,7 @@ public class MesProProcessContentServiceImpl implements MesProProcessContentServ @@ -45,6 +55,7 @@ public class MesProProcessContentServiceImpl implements MesProProcessContentServ
45 public void deleteProcessContent(Long id) { 55 public void deleteProcessContent(Long id) {
46 // 校验存在 56 // 校验存在
47 validateProcessContentExists(id); 57 validateProcessContentExists(id);
  58 +
48 // 删除 59 // 删除
49 processContentMapper.deleteById(id); 60 processContentMapper.deleteById(id);
50 } 61 }
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/process/MesProProcessServiceImpl.java
@@ -7,8 +7,9 @@ import cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.MesProProcess @@ -7,8 +7,9 @@ import cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.MesProProcess
7 import cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.MesProProcessSaveReqVO; 7 import cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.MesProProcessSaveReqVO;
8 import cn.iocoder.yudao.module.mes.dal.dataobject.pro.process.MesProProcessDO; 8 import cn.iocoder.yudao.module.mes.dal.dataobject.pro.process.MesProProcessDO;
9 import cn.iocoder.yudao.module.mes.dal.mysql.pro.process.MesProProcessMapper; 9 import cn.iocoder.yudao.module.mes.dal.mysql.pro.process.MesProProcessMapper;
10 -import cn.iocoder.yudao.module.mes.dal.mysql.pro.route.MesProRouteProcessMapper; 10 +import cn.iocoder.yudao.module.mes.service.pro.route.MesProRouteProcessService;
11 import jakarta.annotation.Resource; 11 import jakarta.annotation.Resource;
  12 +import org.springframework.context.annotation.Lazy;
12 import org.springframework.stereotype.Service; 13 import org.springframework.stereotype.Service;
13 import org.springframework.transaction.annotation.Transactional; 14 import org.springframework.transaction.annotation.Transactional;
14 import org.springframework.validation.annotation.Validated; 15 import org.springframework.validation.annotation.Validated;
@@ -36,10 +37,12 @@ public class MesProProcessServiceImpl implements MesProProcessService { @@ -36,10 +37,12 @@ public class MesProProcessServiceImpl implements MesProProcessService {
36 private MesProProcessContentService processContentService; 37 private MesProProcessContentService processContentService;
37 38
38 @Resource 39 @Resource
39 - private MesProRouteProcessMapper routeProcessMapper; 40 + @Lazy
  41 + private MesProRouteProcessService routeProcessService;
40 42
41 @Override 43 @Override
42 public Long createProcess(MesProProcessSaveReqVO createReqVO) { 44 public Long createProcess(MesProProcessSaveReqVO createReqVO) {
  45 + // TODO @AI:validateXXXSaveData,传入 vo;
43 // 1.1 校验工序编码唯一性 46 // 1.1 校验工序编码唯一性
44 validateProcessCodeUnique(null, createReqVO.getCode()); 47 validateProcessCodeUnique(null, createReqVO.getCode());
45 // 1.2 校验工序名称唯一性 48 // 1.2 校验工序名称唯一性
@@ -55,6 +58,7 @@ public class MesProProcessServiceImpl implements MesProProcessService { @@ -55,6 +58,7 @@ public class MesProProcessServiceImpl implements MesProProcessService {
55 public void updateProcess(MesProProcessSaveReqVO updateReqVO) { 58 public void updateProcess(MesProProcessSaveReqVO updateReqVO) {
56 // 1.1 校验存在 59 // 1.1 校验存在
57 validateProcessExists(updateReqVO.getId()); 60 validateProcessExists(updateReqVO.getId());
  61 + // TODO @AI:validateXXXSaveData,传入 vo;
58 // 1.2 校验工序编码唯一性 62 // 1.2 校验工序编码唯一性
59 validateProcessCodeUnique(updateReqVO.getId(), updateReqVO.getCode()); 63 validateProcessCodeUnique(updateReqVO.getId(), updateReqVO.getCode());
60 // 1.3 校验工序名称唯一性 64 // 1.3 校验工序名称唯一性
@@ -71,7 +75,7 @@ public class MesProProcessServiceImpl implements MesProProcessService { @@ -71,7 +75,7 @@ public class MesProProcessServiceImpl implements MesProProcessService {
71 // 1.1 校验存在 75 // 1.1 校验存在
72 validateProcessExists(id); 76 validateProcessExists(id);
73 // 1.2 校验是否被工艺路线引用 77 // 1.2 校验是否被工艺路线引用
74 - if (CollUtil.isNotEmpty(routeProcessMapper.selectListByProcessId(id))) { 78 + if (CollUtil.isNotEmpty(routeProcessService.getRouteProcessListByProcessId(id))) {
75 throw exception(PRO_PROCESS_USED_BY_ROUTE); 79 throw exception(PRO_PROCESS_USED_BY_ROUTE);
76 } 80 }
77 81
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/route/MesProRouteProcessService.java
@@ -67,6 +67,14 @@ public interface MesProRouteProcessService { @@ -67,6 +67,14 @@ public interface MesProRouteProcessService {
67 List<MesProRouteProcessDO> getRouteProcessListByProductId(Long productId); 67 List<MesProRouteProcessDO> getRouteProcessListByProductId(Long productId);
68 68
69 /** 69 /**
  70 + * 按工序获得工艺路线工序列表
  71 + *
  72 + * @param processId 工序编号
  73 + * @return 工艺路线工序列表
  74 + */
  75 + List<MesProRouteProcessDO> getRouteProcessListByProcessId(Long processId);
  76 +
  77 + /**
70 * 按工艺路线删除工序(级联删除使用) 78 * 按工艺路线删除工序(级联删除使用)
71 * 79 *
72 * @param routeId 工艺路线编号 80 * @param routeId 工艺路线编号
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/route/MesProRouteProcessServiceImpl.java
@@ -192,6 +192,7 @@ public class MesProRouteProcessServiceImpl implements MesProRouteProcessService @@ -192,6 +192,7 @@ public class MesProRouteProcessServiceImpl implements MesProRouteProcessService
192 MesProRouteProductDO routeProduct = routeProductService.getRouteProductByItemId(productId); 192 MesProRouteProductDO routeProduct = routeProductService.getRouteProductByItemId(productId);
193 if (routeProduct == null) { 193 if (routeProduct == null) {
194 // TODO @芋艿:会不会存在配置了多个的情况??? 194 // TODO @芋艿:会不会存在配置了多个的情况???
  195 + // TODO @AI:会有这个情况么?
195 return Collections.emptyList(); 196 return Collections.emptyList();
196 } 197 }
197 // 2. 返回该工艺路线的工序列表 198 // 2. 返回该工艺路线的工序列表
@@ -199,6 +200,11 @@ public class MesProRouteProcessServiceImpl implements MesProRouteProcessService @@ -199,6 +200,11 @@ public class MesProRouteProcessServiceImpl implements MesProRouteProcessService
199 } 200 }
200 201
201 @Override 202 @Override
  203 + public List<MesProRouteProcessDO> getRouteProcessListByProcessId(Long processId) {
  204 + return routeProcessMapper.selectListByProcessId(processId);
  205 + }
  206 +
  207 + @Override
202 public void deleteRouteProcessByRouteId(Long routeId) { 208 public void deleteRouteProcessByRouteId(Long routeId) {
203 routeProcessMapper.deleteByRouteId(routeId); 209 routeProcessMapper.deleteByRouteId(routeId);
204 } 210 }