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