Commit 3cb4adf50678d060f0570845398a8242d8accfec
1 parent
620f432f
✨ feat(mes): 新增设备和点检项目启用状态校验
在设备管理和点检项目的相关服务中,新增了对设备和点检项目是否启用的校验逻辑。此变更确保在进行相关操作时,只有启用的设备和项目才能被使用,从而提高系统的稳定性和数据的准确性。
Showing
21 changed files
with
76 additions
and
15 deletions
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/ErrorCodeConstants.java
| @@ -158,6 +158,7 @@ public interface ErrorCodeConstants { | @@ -158,6 +158,7 @@ public interface ErrorCodeConstants { | ||
| 158 | // ========== MES 设备管理-设备台账(1-040-301-000) ========== | 158 | // ========== MES 设备管理-设备台账(1-040-301-000) ========== |
| 159 | ErrorCode DV_MACHINERY_NOT_EXISTS = new ErrorCode(1_040_301_000, "设备不存在"); | 159 | ErrorCode DV_MACHINERY_NOT_EXISTS = new ErrorCode(1_040_301_000, "设备不存在"); |
| 160 | ErrorCode DV_MACHINERY_CODE_DUPLICATE = new ErrorCode(1_040_301_001, "设备编码已存在"); | 160 | ErrorCode DV_MACHINERY_CODE_DUPLICATE = new ErrorCode(1_040_301_001, "设备编码已存在"); |
| 161 | + ErrorCode DV_MACHINERY_IS_DISABLE = new ErrorCode(1_040_301_007, "设备已禁用"); | ||
| 161 | ErrorCode DV_MACHINERY_IMPORT_LIST_IS_EMPTY = new ErrorCode(1_040_301_002, "导入设备数据不能为空"); | 162 | ErrorCode DV_MACHINERY_IMPORT_LIST_IS_EMPTY = new ErrorCode(1_040_301_002, "导入设备数据不能为空"); |
| 162 | ErrorCode DV_MACHINERY_HAS_CHECK_PLAN = new ErrorCode(1_040_301_003, "设备已关联点检计划,无法删除"); | 163 | ErrorCode DV_MACHINERY_HAS_CHECK_PLAN = new ErrorCode(1_040_301_003, "设备已关联点检计划,无法删除"); |
| 163 | ErrorCode DV_MACHINERY_HAS_CHECK_RECORD = new ErrorCode(1_040_301_004, "设备已关联点检记录,无法删除"); | 164 | ErrorCode DV_MACHINERY_HAS_CHECK_RECORD = new ErrorCode(1_040_301_004, "设备已关联点检记录,无法删除"); |
| @@ -168,6 +169,7 @@ public interface ErrorCodeConstants { | @@ -168,6 +169,7 @@ public interface ErrorCodeConstants { | ||
| 168 | ErrorCode DV_SUBJECT_NOT_EXISTS = new ErrorCode(1_040_304_000, "点检保养项目不存在"); | 169 | ErrorCode DV_SUBJECT_NOT_EXISTS = new ErrorCode(1_040_304_000, "点检保养项目不存在"); |
| 169 | ErrorCode DV_SUBJECT_CODE_DUPLICATE = new ErrorCode(1_040_304_001, "项目编码已存在"); | 170 | ErrorCode DV_SUBJECT_CODE_DUPLICATE = new ErrorCode(1_040_304_001, "项目编码已存在"); |
| 170 | ErrorCode DV_SUBJECT_USED_BY_CHECK_PLAN = new ErrorCode(1_040_304_002, "点检保养项目已被点检保养方案使用,无法删除"); | 171 | ErrorCode DV_SUBJECT_USED_BY_CHECK_PLAN = new ErrorCode(1_040_304_002, "点检保养项目已被点检保养方案使用,无法删除"); |
| 172 | + ErrorCode DV_SUBJECT_IS_DISABLE = new ErrorCode(1_040_304_003, "点检保养项目已禁用"); | ||
| 171 | 173 | ||
| 172 | // ========== MES 设备管理-点检计划(1-040-302-000) ========== | 174 | // ========== MES 设备管理-点检计划(1-040-302-000) ========== |
| 173 | ErrorCode DV_CHECK_PLAN_NOT_EXISTS = new ErrorCode(1_040_302_000, "点检计划不存在"); | 175 | ErrorCode DV_CHECK_PLAN_NOT_EXISTS = new ErrorCode(1_040_302_000, "点检计划不存在"); |
| @@ -224,6 +226,7 @@ public interface ErrorCodeConstants { | @@ -224,6 +226,7 @@ public interface ErrorCodeConstants { | ||
| 224 | ErrorCode PRO_PROCESS_CODE_EXISTS = new ErrorCode(1_040_500_001, "工序编码已存在"); | 226 | ErrorCode PRO_PROCESS_CODE_EXISTS = new ErrorCode(1_040_500_001, "工序编码已存在"); |
| 225 | ErrorCode PRO_PROCESS_NAME_EXISTS = new ErrorCode(1_040_500_002, "工序名称已存在"); | 227 | ErrorCode PRO_PROCESS_NAME_EXISTS = new ErrorCode(1_040_500_002, "工序名称已存在"); |
| 226 | ErrorCode PRO_PROCESS_USED_BY_ROUTE = new ErrorCode(1_040_500_003, "工序已被工艺路线引用,无法删除"); | 228 | ErrorCode PRO_PROCESS_USED_BY_ROUTE = new ErrorCode(1_040_500_003, "工序已被工艺路线引用,无法删除"); |
| 229 | + ErrorCode PRO_PROCESS_IS_DISABLE = new ErrorCode(1_040_500_004, "工序已禁用"); | ||
| 227 | // ========== MES 生产管理-工序内容(1-040-500-100) ========== | 230 | // ========== MES 生产管理-工序内容(1-040-500-100) ========== |
| 228 | ErrorCode PRO_PROCESS_CONTENT_NOT_EXISTS = new ErrorCode(1_040_500_100, "工序内容不存在"); | 231 | ErrorCode PRO_PROCESS_CONTENT_NOT_EXISTS = new ErrorCode(1_040_500_100, "工序内容不存在"); |
| 229 | 232 |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/checkplan/MesDvCheckPlanMachineryServiceImpl.java
| @@ -42,7 +42,7 @@ public class MesDvCheckPlanMachineryServiceImpl implements MesDvCheckPlanMachine | @@ -42,7 +42,7 @@ public class MesDvCheckPlanMachineryServiceImpl implements MesDvCheckPlanMachine | ||
| 42 | // 1.1 校验方案草稿状态 | 42 | // 1.1 校验方案草稿状态 |
| 43 | MesDvCheckPlanDO currentPlan = checkPlanService.validateCheckPlanPrepare(createReqVO.getPlanId()); | 43 | MesDvCheckPlanDO currentPlan = checkPlanService.validateCheckPlanPrepare(createReqVO.getPlanId()); |
| 44 | // 1.2 校验设备存在 | 44 | // 1.2 校验设备存在 |
| 45 | - machineryService.validateMachineryExists(createReqVO.getMachineryId()); | 45 | + machineryService.validateMachineryExistsAndEnable(createReqVO.getMachineryId()); |
| 46 | // 1.3 校验同一方案下设备不重复 | 46 | // 1.3 校验同一方案下设备不重复 |
| 47 | if (checkPlanMachineryMapper.selectByPlanIdAndMachineryId(createReqVO.getPlanId(), createReqVO.getMachineryId()) != null) { | 47 | if (checkPlanMachineryMapper.selectByPlanIdAndMachineryId(createReqVO.getPlanId(), createReqVO.getMachineryId()) != null) { |
| 48 | throw exception(DV_CHECK_PLAN_MACHINERY_DUPLICATE); | 48 | throw exception(DV_CHECK_PLAN_MACHINERY_DUPLICATE); |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/checkplan/MesDvCheckPlanSubjectServiceImpl.java
| @@ -37,7 +37,7 @@ public class MesDvCheckPlanSubjectServiceImpl implements MesDvCheckPlanSubjectSe | @@ -37,7 +37,7 @@ public class MesDvCheckPlanSubjectServiceImpl implements MesDvCheckPlanSubjectSe | ||
| 37 | // 1.1 校验方案草稿状态 | 37 | // 1.1 校验方案草稿状态 |
| 38 | checkPlanService.validateCheckPlanPrepare(createReqVO.getPlanId()); | 38 | checkPlanService.validateCheckPlanPrepare(createReqVO.getPlanId()); |
| 39 | // 1.2 校验项目存在 | 39 | // 1.2 校验项目存在 |
| 40 | - subjectService.validateSubjectExists(createReqVO.getSubjectId()); | 40 | + subjectService.validateSubjectExistsAndEnable(createReqVO.getSubjectId()); |
| 41 | // 1.3 校验同一方案下项目不重复 | 41 | // 1.3 校验同一方案下项目不重复 |
| 42 | if (checkPlanSubjectMapper.selectByPlanIdAndSubjectId(createReqVO.getPlanId(), createReqVO.getSubjectId()) != null) { | 42 | if (checkPlanSubjectMapper.selectByPlanIdAndSubjectId(createReqVO.getPlanId(), createReqVO.getSubjectId()) != null) { |
| 43 | throw exception(DV_CHECK_PLAN_SUBJECT_DUPLICATE); | 43 | throw exception(DV_CHECK_PLAN_SUBJECT_DUPLICATE); |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/checkrecord/MesDvCheckRecordServiceImpl.java
| @@ -161,7 +161,7 @@ public class MesDvCheckRecordServiceImpl implements MesDvCheckRecordService { | @@ -161,7 +161,7 @@ public class MesDvCheckRecordServiceImpl implements MesDvCheckRecordService { | ||
| 161 | 161 | ||
| 162 | private void validateCheckRecordSave(MesDvCheckRecordSaveReqVO reqVO) { | 162 | private void validateCheckRecordSave(MesDvCheckRecordSaveReqVO reqVO) { |
| 163 | // 校验设备是否存在 | 163 | // 校验设备是否存在 |
| 164 | - machineryService.validateMachineryExists(reqVO.getMachineryId()); | 164 | + machineryService.validateMachineryExistsAndEnable(reqVO.getMachineryId()); |
| 165 | // 校验点检计划是否存在 | 165 | // 校验点检计划是否存在 |
| 166 | if (reqVO.getPlanId() != null) { | 166 | if (reqVO.getPlanId() != null) { |
| 167 | checkPlanService.validateCheckPlanExistsAndType(reqVO.getPlanId(), MesDvCheckPlanTypeEnum.CHECK.getType()); | 167 | checkPlanService.validateCheckPlanExistsAndType(reqVO.getPlanId(), MesDvCheckPlanTypeEnum.CHECK.getType()); |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/machinery/MesDvMachineryService.java
| @@ -75,6 +75,13 @@ public interface MesDvMachineryService { | @@ -75,6 +75,13 @@ public interface MesDvMachineryService { | ||
| 75 | void validateMachineryExists(Long id); | 75 | void validateMachineryExists(Long id); |
| 76 | 76 | ||
| 77 | /** | 77 | /** |
| 78 | + * 校验设备存在且启用 | ||
| 79 | + * | ||
| 80 | + * @param id 编号 | ||
| 81 | + */ | ||
| 82 | + void validateMachineryExistsAndEnable(Long id); | ||
| 83 | + | ||
| 84 | + /** | ||
| 78 | * 获得设备列表 | 85 | * 获得设备列表 |
| 79 | * | 86 | * |
| 80 | * @return 设备列表 | 87 | * @return 设备列表 |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/machinery/MesDvMachineryServiceImpl.java
| @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.mes.service.dv.machinery; | @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.mes.service.dv.machinery; | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | import cn.hutool.core.util.ObjUtil; | 4 | import cn.hutool.core.util.ObjUtil; |
| 5 | import cn.hutool.core.util.StrUtil; | 5 | import cn.hutool.core.util.StrUtil; |
| 6 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 7 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 7 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 8 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 8 | import cn.iocoder.yudao.module.mes.controller.admin.dv.machinery.vo.MesDvMachineryImportExcelVO; | 9 | import cn.iocoder.yudao.module.mes.controller.admin.dv.machinery.vo.MesDvMachineryImportExcelVO; |
| @@ -136,6 +137,17 @@ public class MesDvMachineryServiceImpl implements MesDvMachineryService { | @@ -136,6 +137,17 @@ public class MesDvMachineryServiceImpl implements MesDvMachineryService { | ||
| 136 | } | 137 | } |
| 137 | } | 138 | } |
| 138 | 139 | ||
| 140 | + @Override | ||
| 141 | + public void validateMachineryExistsAndEnable(Long id) { | ||
| 142 | + MesDvMachineryDO machinery = machineryMapper.selectById(id); | ||
| 143 | + if (machinery == null) { | ||
| 144 | + throw exception(DV_MACHINERY_NOT_EXISTS); | ||
| 145 | + } | ||
| 146 | + if (ObjUtil.notEqual(CommonStatusEnum.ENABLE.getStatus(), machinery.getStatus())) { | ||
| 147 | + throw exception(DV_MACHINERY_IS_DISABLE); | ||
| 148 | + } | ||
| 149 | + } | ||
| 150 | + | ||
| 139 | private void validateMachineryCodeUnique(Long id, String code) { | 151 | private void validateMachineryCodeUnique(Long id, String code) { |
| 140 | if (code == null) { | 152 | if (code == null) { |
| 141 | return; | 153 | return; |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/maintenrecord/MesDvMaintenRecordLineServiceImpl.java
| @@ -73,7 +73,7 @@ public class MesDvMaintenRecordLineServiceImpl implements MesDvMaintenRecordLine | @@ -73,7 +73,7 @@ public class MesDvMaintenRecordLineServiceImpl implements MesDvMaintenRecordLine | ||
| 73 | // 校验保养记录为草稿状态 | 73 | // 校验保养记录为草稿状态 |
| 74 | maintenRecordService.validateMaintenRecordDraft(reqVO.getRecordId()); | 74 | maintenRecordService.validateMaintenRecordDraft(reqVO.getRecordId()); |
| 75 | // 校验保养项目是否存在 | 75 | // 校验保养项目是否存在 |
| 76 | - subjectService.validateSubjectExists(reqVO.getSubjectId()); | 76 | + subjectService.validateSubjectExistsAndEnable(reqVO.getSubjectId()); |
| 77 | } | 77 | } |
| 78 | 78 | ||
| 79 | private MesDvMaintenRecordLineDO validateMaintenRecordLineExists(Long id) { | 79 | private MesDvMaintenRecordLineDO validateMaintenRecordLineExists(Long id) { |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/maintenrecord/MesDvMaintenRecordServiceImpl.java
| @@ -98,7 +98,7 @@ public class MesDvMaintenRecordServiceImpl implements MesDvMaintenRecordService | @@ -98,7 +98,7 @@ public class MesDvMaintenRecordServiceImpl implements MesDvMaintenRecordService | ||
| 98 | 98 | ||
| 99 | private void validateMaintenRecordRelation(MesDvMaintenRecordSaveReqVO reqVO) { | 99 | private void validateMaintenRecordRelation(MesDvMaintenRecordSaveReqVO reqVO) { |
| 100 | // 校验设备是否存在 | 100 | // 校验设备是否存在 |
| 101 | - machineryService.validateMachineryExists(reqVO.getMachineryId()); | 101 | + machineryService.validateMachineryExistsAndEnable(reqVO.getMachineryId()); |
| 102 | // 校验保养计划是否存在 | 102 | // 校验保养计划是否存在 |
| 103 | if (reqVO.getPlanId() != null) { | 103 | if (reqVO.getPlanId() != null) { |
| 104 | checkPlanService.validateCheckPlanExistsAndType(reqVO.getPlanId(), MesDvCheckPlanTypeEnum.MAINTENANCE.getType()); | 104 | checkPlanService.validateCheckPlanExistsAndType(reqVO.getPlanId(), MesDvCheckPlanTypeEnum.MAINTENANCE.getType()); |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/repair/MesDvRepairLineServiceImpl.java
| @@ -79,7 +79,7 @@ public class MesDvRepairLineServiceImpl implements MesDvRepairLineService { | @@ -79,7 +79,7 @@ public class MesDvRepairLineServiceImpl implements MesDvRepairLineService { | ||
| 79 | repairService.validateRepairExists(reqVO.getRepairId()); | 79 | repairService.validateRepairExists(reqVO.getRepairId()); |
| 80 | // 校验点检保养项目是否存在(可选) | 80 | // 校验点检保养项目是否存在(可选) |
| 81 | if (reqVO.getSubjectId() != null) { | 81 | if (reqVO.getSubjectId() != null) { |
| 82 | - subjectService.validateSubjectExists(reqVO.getSubjectId()); | 82 | + subjectService.validateSubjectExistsAndEnable(reqVO.getSubjectId()); |
| 83 | } | 83 | } |
| 84 | } | 84 | } |
| 85 | 85 |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/repair/MesDvRepairServiceImpl.java
| @@ -79,7 +79,7 @@ public class MesDvRepairServiceImpl implements MesDvRepairService { | @@ -79,7 +79,7 @@ public class MesDvRepairServiceImpl implements MesDvRepairService { | ||
| 79 | // 校验编码唯一 | 79 | // 校验编码唯一 |
| 80 | validateCodeUnique(reqVO.getId(), reqVO.getCode()); | 80 | validateCodeUnique(reqVO.getId(), reqVO.getCode()); |
| 81 | // 校验设备存在 | 81 | // 校验设备存在 |
| 82 | - machineryService.validateMachineryExists(reqVO.getMachineryId()); | 82 | + machineryService.validateMachineryExistsAndEnable(reqVO.getMachineryId()); |
| 83 | } | 83 | } |
| 84 | 84 | ||
| 85 | private void validateCodeUnique(Long id, String code) { | 85 | private void validateCodeUnique(Long id, String code) { |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/subject/MesDvSubjectService.java
| @@ -65,6 +65,13 @@ public interface MesDvSubjectService { | @@ -65,6 +65,13 @@ public interface MesDvSubjectService { | ||
| 65 | void validateSubjectExists(Long id); | 65 | void validateSubjectExists(Long id); |
| 66 | 66 | ||
| 67 | /** | 67 | /** |
| 68 | + * 校验点检保养项目存在且启用 | ||
| 69 | + * | ||
| 70 | + * @param id 编号 | ||
| 71 | + */ | ||
| 72 | + void validateSubjectExistsAndEnable(Long id); | ||
| 73 | + | ||
| 74 | + /** | ||
| 68 | * 获得点检保养项目列表 | 75 | * 获得点检保养项目列表 |
| 69 | * | 76 | * |
| 70 | * @return 项目列表 | 77 | * @return 项目列表 |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/subject/MesDvSubjectServiceImpl.java
| @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.mes.service.dv.subject; | @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.mes.service.dv.subject; | ||
| 2 | 2 | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | import cn.hutool.core.util.ObjUtil; | 4 | import cn.hutool.core.util.ObjUtil; |
| 5 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 6 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 7 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 7 | import cn.iocoder.yudao.module.mes.controller.admin.dv.subject.vo.MesDvSubjectPageReqVO; | 8 | import cn.iocoder.yudao.module.mes.controller.admin.dv.subject.vo.MesDvSubjectPageReqVO; |
| @@ -80,6 +81,17 @@ public class MesDvSubjectServiceImpl implements MesDvSubjectService { | @@ -80,6 +81,17 @@ public class MesDvSubjectServiceImpl implements MesDvSubjectService { | ||
| 80 | } | 81 | } |
| 81 | } | 82 | } |
| 82 | 83 | ||
| 84 | + @Override | ||
| 85 | + public void validateSubjectExistsAndEnable(Long id) { | ||
| 86 | + MesDvSubjectDO subject = subjectMapper.selectById(id); | ||
| 87 | + if (subject == null) { | ||
| 88 | + throw exception(DV_SUBJECT_NOT_EXISTS); | ||
| 89 | + } | ||
| 90 | + if (ObjUtil.notEqual(CommonStatusEnum.ENABLE.getStatus(), subject.getStatus())) { | ||
| 91 | + throw exception(DV_SUBJECT_IS_DISABLE); | ||
| 92 | + } | ||
| 93 | + } | ||
| 94 | + | ||
| 83 | private void validateSubjectCodeUnique(Long id, String code) { | 95 | private void validateSubjectCodeUnique(Long id, String code) { |
| 84 | if (code == null) { | 96 | if (code == null) { |
| 85 | return; | 97 | return; |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/item/MesMdProductSipServiceImpl.java
| @@ -59,7 +59,7 @@ public class MesMdProductSipServiceImpl implements MesMdProductSipService { | @@ -59,7 +59,7 @@ public class MesMdProductSipServiceImpl implements MesMdProductSipService { | ||
| 59 | validateSortUnique(reqVO.getItemId(), reqVO.getSort(), excludeId); | 59 | validateSortUnique(reqVO.getItemId(), reqVO.getSort(), excludeId); |
| 60 | // 校验工序存在 | 60 | // 校验工序存在 |
| 61 | if (reqVO.getProcessId() != null) { | 61 | if (reqVO.getProcessId() != null) { |
| 62 | - processService.validateProcessExists(reqVO.getProcessId()); | 62 | + processService.validateProcessExistsAndEnable(reqVO.getProcessId()); |
| 63 | } | 63 | } |
| 64 | } | 64 | } |
| 65 | 65 |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/item/MesMdProductSopServiceImpl.java
| @@ -59,7 +59,7 @@ public class MesMdProductSopServiceImpl implements MesMdProductSopService { | @@ -59,7 +59,7 @@ public class MesMdProductSopServiceImpl implements MesMdProductSopService { | ||
| 59 | validateSortUnique(reqVO.getItemId(), reqVO.getSort(), excludeId); | 59 | validateSortUnique(reqVO.getItemId(), reqVO.getSort(), excludeId); |
| 60 | // 校验工序存在 | 60 | // 校验工序存在 |
| 61 | if (reqVO.getProcessId() != null) { | 61 | if (reqVO.getProcessId() != null) { |
| 62 | - processService.validateProcessExists(reqVO.getProcessId()); | 62 | + processService.validateProcessExistsAndEnable(reqVO.getProcessId()); |
| 63 | } | 63 | } |
| 64 | } | 64 | } |
| 65 | 65 |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/workstation/MesMdWorkstationMachineServiceImpl.java
| @@ -47,7 +47,7 @@ public class MesMdWorkstationMachineServiceImpl implements MesMdWorkstationMachi | @@ -47,7 +47,7 @@ public class MesMdWorkstationMachineServiceImpl implements MesMdWorkstationMachi | ||
| 47 | 47 | ||
| 48 | private void validateWorkstationMachineSaveData(MesMdWorkstationMachineSaveReqVO reqVO) { | 48 | private void validateWorkstationMachineSaveData(MesMdWorkstationMachineSaveReqVO reqVO) { |
| 49 | // 校验设备是否存在 | 49 | // 校验设备是否存在 |
| 50 | - machineryService.validateMachineryExists(reqVO.getMachineryId()); | 50 | + machineryService.validateMachineryExistsAndEnable(reqVO.getMachineryId()); |
| 51 | // 校验该设备是否已分配到其他工作站(一台设备只能分配到一个工作站) | 51 | // 校验该设备是否已分配到其他工作站(一台设备只能分配到一个工作站) |
| 52 | MesMdWorkstationMachineDO existing = workstationMachineMapper.selectByMachineryId(reqVO.getMachineryId()); | 52 | MesMdWorkstationMachineDO existing = workstationMachineMapper.selectByMachineryId(reqVO.getMachineryId()); |
| 53 | if (existing != null) { | 53 | if (existing != null) { |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/md/workstation/MesMdWorkstationServiceImpl.java
| @@ -98,7 +98,7 @@ public class MesMdWorkstationServiceImpl implements MesMdWorkstationService { | @@ -98,7 +98,7 @@ public class MesMdWorkstationServiceImpl implements MesMdWorkstationService { | ||
| 98 | // 校验车间存在 | 98 | // 校验车间存在 |
| 99 | validateWorkshopExists(reqVO.getWorkshopId()); | 99 | validateWorkshopExists(reqVO.getWorkshopId()); |
| 100 | // 校验工序存在 | 100 | // 校验工序存在 |
| 101 | - processService.validateProcessExists(reqVO.getProcessId()); | 101 | + processService.validateProcessExistsAndEnable(reqVO.getProcessId()); |
| 102 | // 处理仓库层级(未指定仓库时自动设置虚拟线边库) | 102 | // 处理仓库层级(未指定仓库时自动设置虚拟线边库) |
| 103 | handleWarehouseHierarchy(reqVO); | 103 | handleWarehouseHierarchy(reqVO); |
| 104 | } | 104 | } |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/andon/MesProAndonRecordServiceImpl.java
| @@ -53,7 +53,7 @@ public class MesProAndonRecordServiceImpl implements MesProAndonRecordService { | @@ -53,7 +53,7 @@ public class MesProAndonRecordServiceImpl implements MesProAndonRecordService { | ||
| 53 | workOrderService.validateWorkOrderConfirmed(createReqVO.getWorkOrderId()); | 53 | workOrderService.validateWorkOrderConfirmed(createReqVO.getWorkOrderId()); |
| 54 | } | 54 | } |
| 55 | if (createReqVO.getProcessId() != null) { | 55 | if (createReqVO.getProcessId() != null) { |
| 56 | - processService.validateProcessExists(createReqVO.getProcessId()); | 56 | + processService.validateProcessExistsAndEnable(createReqVO.getProcessId()); |
| 57 | } | 57 | } |
| 58 | 58 | ||
| 59 | // 2. 插入记录 | 59 | // 2. 插入记录 |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/card/MesProCardProcessServiceImpl.java
| @@ -89,7 +89,7 @@ public class MesProCardProcessServiceImpl implements MesProCardProcessService { | @@ -89,7 +89,7 @@ public class MesProCardProcessServiceImpl implements MesProCardProcessService { | ||
| 89 | cardService.validateCardExists(reqVO.getCardId()); | 89 | cardService.validateCardExists(reqVO.getCardId()); |
| 90 | // 校验工序存在 | 90 | // 校验工序存在 |
| 91 | if (reqVO.getProcessId() != null) { | 91 | if (reqVO.getProcessId() != null) { |
| 92 | - processService.validateProcessExists(reqVO.getProcessId()); | 92 | + processService.validateProcessExistsAndEnable(reqVO.getProcessId()); |
| 93 | } | 93 | } |
| 94 | } | 94 | } |
| 95 | 95 |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/process/MesProProcessService.java
| @@ -82,6 +82,13 @@ public interface MesProProcessService { | @@ -82,6 +82,13 @@ public interface MesProProcessService { | ||
| 82 | void validateProcessExists(Long id); | 82 | void validateProcessExists(Long id); |
| 83 | 83 | ||
| 84 | /** | 84 | /** |
| 85 | + * 校验工序存在且启用 | ||
| 86 | + * | ||
| 87 | + * @param id 编号 | ||
| 88 | + */ | ||
| 89 | + void validateProcessExistsAndEnable(Long id); | ||
| 90 | + | ||
| 91 | + /** | ||
| 85 | * 获得工序 Map | 92 | * 获得工序 Map |
| 86 | * | 93 | * |
| 87 | * @param ids 编号列表 | 94 | * @param ids 编号列表 |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/process/MesProProcessServiceImpl.java
| 1 | package cn.iocoder.yudao.module.mes.service.pro.process; | 1 | package cn.iocoder.yudao.module.mes.service.pro.process; |
| 2 | 2 | ||
| 3 | import cn.hutool.core.collection.CollUtil; | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | +import cn.hutool.core.util.ObjUtil; | ||
| 5 | +import cn.iocoder.yudao.framework.common.enums.CommonStatusEnum; | ||
| 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 6 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 7 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 6 | import cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.MesProProcessPageReqVO; | 8 | import cn.iocoder.yudao.module.mes.controller.admin.pro.process.vo.MesProProcessPageReqVO; |
| @@ -86,6 +88,17 @@ public class MesProProcessServiceImpl implements MesProProcessService { | @@ -86,6 +88,17 @@ public class MesProProcessServiceImpl implements MesProProcessService { | ||
| 86 | } | 88 | } |
| 87 | } | 89 | } |
| 88 | 90 | ||
| 91 | + @Override | ||
| 92 | + public void validateProcessExistsAndEnable(Long id) { | ||
| 93 | + MesProProcessDO process = processMapper.selectById(id); | ||
| 94 | + if (process == null) { | ||
| 95 | + throw exception(PRO_PROCESS_NOT_EXISTS); | ||
| 96 | + } | ||
| 97 | + if (ObjUtil.notEqual(CommonStatusEnum.ENABLE.getStatus(), process.getStatus())) { | ||
| 98 | + throw exception(PRO_PROCESS_IS_DISABLE); | ||
| 99 | + } | ||
| 100 | + } | ||
| 101 | + | ||
| 89 | private void validateProcessCodeUnique(Long id, String code) { | 102 | private void validateProcessCodeUnique(Long id, String code) { |
| 90 | MesProProcessDO process = processMapper.selectByCode(code); | 103 | MesProProcessDO process = processMapper.selectByCode(code); |
| 91 | if (process == null) { | 104 | if (process == null) { |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/pro/task/MesProTaskServiceImpl.java
| @@ -69,7 +69,7 @@ public class MesProTaskServiceImpl implements MesProTaskService { | @@ -69,7 +69,7 @@ public class MesProTaskServiceImpl implements MesProTaskService { | ||
| 69 | MesProWorkOrderDO workOrder = workOrderService.validateWorkOrderExists(createReqVO.getWorkOrderId()); | 69 | MesProWorkOrderDO workOrder = workOrderService.validateWorkOrderExists(createReqVO.getWorkOrderId()); |
| 70 | workstationService.validateWorkstationExists(createReqVO.getWorkstationId()); | 70 | workstationService.validateWorkstationExists(createReqVO.getWorkstationId()); |
| 71 | routeService.validateRouteExists(createReqVO.getRouteId()); | 71 | routeService.validateRouteExists(createReqVO.getRouteId()); |
| 72 | - processService.validateProcessExists(createReqVO.getProcessId()); | 72 | + processService.validateProcessExistsAndEnable(createReqVO.getProcessId()); |
| 73 | MesMdItemDO item = itemService.validateItemExists(createReqVO.getItemId()); | 73 | MesMdItemDO item = itemService.validateItemExists(createReqVO.getItemId()); |
| 74 | 74 | ||
| 75 | // 2.1 构建任务 DO:自动填充客户信息 | 75 | // 2.1 构建任务 DO:自动填充客户信息 |
| @@ -100,7 +100,7 @@ public class MesProTaskServiceImpl implements MesProTaskService { | @@ -100,7 +100,7 @@ public class MesProTaskServiceImpl implements MesProTaskService { | ||
| 100 | routeService.validateRouteExists(updateReqVO.getRouteId()); | 100 | routeService.validateRouteExists(updateReqVO.getRouteId()); |
| 101 | } | 101 | } |
| 102 | if (updateReqVO.getProcessId() != null) { | 102 | if (updateReqVO.getProcessId() != null) { |
| 103 | - processService.validateProcessExists(updateReqVO.getProcessId()); | 103 | + processService.validateProcessExistsAndEnable(updateReqVO.getProcessId()); |
| 104 | } | 104 | } |
| 105 | MesMdItemDO item; | 105 | MesMdItemDO item; |
| 106 | if (updateReqVO.getItemId() != null) { | 106 | if (updateReqVO.getItemId() != null) { |