Commit 2742bd4fb8ee1d1f23aebe771005f618741af415
1 parent
c82e0937
fix(mes-cal): 计划班次增删改前校验排班计划未确认
MesCalPlanShiftServiceImpl 的 create/update/delete 方法调用 planService.validatePlanPrepare(),确认后的排班计划禁止修改班次 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Showing
1 changed file
with
16 additions
and
7 deletions
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalPlanShiftServiceImpl.java
| ... | ... | @@ -11,6 +11,7 @@ import cn.iocoder.yudao.module.mes.dal.mysql.cal.plan.MesCalPlanMapper; |
| 11 | 11 | import cn.iocoder.yudao.module.mes.dal.mysql.cal.plan.MesCalPlanShiftMapper; |
| 12 | 12 | import cn.iocoder.yudao.module.mes.enums.cal.MesCalShiftTypeEnum; |
| 13 | 13 | import jakarta.annotation.Resource; |
| 14 | +import org.springframework.context.annotation.Lazy; | |
| 14 | 15 | import org.springframework.stereotype.Service; |
| 15 | 16 | import org.springframework.validation.annotation.Validated; |
| 16 | 17 | |
| ... | ... | @@ -32,10 +33,14 @@ public class MesCalPlanShiftServiceImpl implements MesCalPlanShiftService { |
| 32 | 33 | private MesCalPlanShiftMapper planShiftMapper; |
| 33 | 34 | @Resource |
| 34 | 35 | private MesCalPlanMapper planMapper; |
| 36 | + @Resource | |
| 37 | + @Lazy | |
| 38 | + private MesCalPlanService planService; | |
| 35 | 39 | |
| 36 | 40 | @Override |
| 37 | 41 | public Long createPlanShift(MesCalPlanShiftSaveReqVO createReqVO) { |
| 38 | - // TODO @AI:需要校验下,plan 未确定;(确认后,不允许编辑) | |
| 42 | + // 校验计划未确认 | |
| 43 | + planService.validatePlanPrepare(createReqVO.getPlanId()); | |
| 39 | 44 | // 校验班次数量限制 |
| 40 | 45 | validatePlanShiftCount(createReqVO.getPlanId()); |
| 41 | 46 | |
| ... | ... | @@ -47,9 +52,10 @@ public class MesCalPlanShiftServiceImpl implements MesCalPlanShiftService { |
| 47 | 52 | |
| 48 | 53 | @Override |
| 49 | 54 | public void updatePlanShift(MesCalPlanShiftSaveReqVO updateReqVO) { |
| 50 | - // TODO @AI:需要校验下,plan 未确定;(确认后,不允许编辑) | |
| 51 | 55 | // 校验存在 |
| 52 | - validatePlanShiftExists(updateReqVO.getId()); | |
| 56 | + MesCalPlanShiftDO existShift = validatePlanShiftExists(updateReqVO.getId()); | |
| 57 | + // 校验计划未确认 | |
| 58 | + planService.validatePlanPrepare(existShift.getPlanId()); | |
| 53 | 59 | // 更新 |
| 54 | 60 | MesCalPlanShiftDO updateObj = BeanUtils.toBean(updateReqVO, MesCalPlanShiftDO.class); |
| 55 | 61 | planShiftMapper.updateById(updateObj); |
| ... | ... | @@ -57,17 +63,20 @@ public class MesCalPlanShiftServiceImpl implements MesCalPlanShiftService { |
| 57 | 63 | |
| 58 | 64 | @Override |
| 59 | 65 | public void deletePlanShift(Long id) { |
| 60 | - // TODO @AI:需要校验下,plan 未确定;(确认后,不允许编辑) | |
| 61 | 66 | // 校验存在 |
| 62 | - validatePlanShiftExists(id); | |
| 67 | + MesCalPlanShiftDO existShift = validatePlanShiftExists(id); | |
| 68 | + // 校验计划未确认 | |
| 69 | + planService.validatePlanPrepare(existShift.getPlanId()); | |
| 63 | 70 | // 删除 |
| 64 | 71 | planShiftMapper.deleteById(id); |
| 65 | 72 | } |
| 66 | 73 | |
| 67 | - private void validatePlanShiftExists(Long id) { | |
| 68 | - if (planShiftMapper.selectById(id) == null) { | |
| 74 | + private MesCalPlanShiftDO validatePlanShiftExists(Long id) { | |
| 75 | + MesCalPlanShiftDO shift = planShiftMapper.selectById(id); | |
| 76 | + if (shift == null) { | |
| 69 | 77 | throw exception(CAL_PLAN_SHIFT_NOT_EXISTS); |
| 70 | 78 | } |
| 79 | + return shift; | |
| 71 | 80 | } |
| 72 | 81 | |
| 73 | 82 | /** | ... | ... |