From fd3d6ad8de4ed8f14c6b422deccab06006e8b12d Mon Sep 17 00:00:00 2001 From: YunaiV Date: Wed, 8 Apr 2026 08:44:16 +0800 Subject: [PATCH] ✨ feat(service): 添加点检保养方案未启用的错误码校验 --- yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/ErrorCodeConstants.java | 1 + yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/checkplan/MesDvCheckPlanService.java | 2 +- yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/checkplan/MesDvCheckPlanServiceImpl.java | 5 +++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/ErrorCodeConstants.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/ErrorCodeConstants.java index 6205166..3277331 100644 --- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/ErrorCodeConstants.java +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/ErrorCodeConstants.java @@ -169,6 +169,7 @@ public interface ErrorCodeConstants { ErrorCode DV_CHECK_PLAN_NO_SUBJECT = new ErrorCode(1_040_302_004, "启用方案时,至少需要关联一个点检保养项目"); ErrorCode DV_CHECK_PLAN_NOT_ENABLED = new ErrorCode(1_040_302_005, "点检保养方案未启用,不允许停用"); ErrorCode DV_CHECK_PLAN_TYPE_MISMATCH = new ErrorCode(1_040_302_006, "点检保养方案类型与当前业务不匹配"); + ErrorCode DV_CHECK_PLAN_NOT_ENABLED_FOR_RECORD = new ErrorCode(1_040_302_007, "点检保养方案未启用,不允许创建记录"); // ========== MES 设备管理-点检方案设备(1-040-302-100) ========== ErrorCode DV_CHECK_PLAN_MACHINERY_NOT_EXISTS = new ErrorCode(1_040_302_100, "点检保养方案设备不存在"); ErrorCode DV_CHECK_PLAN_MACHINERY_DUPLICATE = new ErrorCode(1_040_302_101, "该设备已关联到当前方案,请勿重复添加"); diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/checkplan/MesDvCheckPlanService.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/checkplan/MesDvCheckPlanService.java index 598afd7..c681d7e 100644 --- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/checkplan/MesDvCheckPlanService.java +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/checkplan/MesDvCheckPlanService.java @@ -63,7 +63,7 @@ public interface MesDvCheckPlanService { void validateCheckPlanExists(Long id); /** - * 校验点检保养方案存在,且类型匹配 + * 校验点检保养方案存在、类型匹配,且方案已启用 * * @param id 方案编号 * @param type 期望的方案类型 diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/checkplan/MesDvCheckPlanServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/checkplan/MesDvCheckPlanServiceImpl.java index eea3f1c..262f4b1 100644 --- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/checkplan/MesDvCheckPlanServiceImpl.java +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/checkplan/MesDvCheckPlanServiceImpl.java @@ -152,9 +152,14 @@ public class MesDvCheckPlanServiceImpl implements MesDvCheckPlanService { @Override public MesDvCheckPlanDO validateCheckPlanExistsAndType(Long id, Integer type) { MesDvCheckPlanDO plan = doValidateCheckPlanExists(id); + // 校验类型匹配 if (ObjUtil.notEqual(plan.getType(), type)) { throw exception(DV_CHECK_PLAN_TYPE_MISMATCH); } + // 校验方案已启用 + if (ObjUtil.notEqual(MesDvCheckPlanStatusEnum.ENABLED.getStatus(), plan.getStatus())) { + throw exception(DV_CHECK_PLAN_NOT_ENABLED_FOR_RECORD); + } return plan; } -- libgit2 0.21.4