Commit 4c4885e2d93334410c07c760a670ffebdc50a76d
1 parent
1dc7bf7f
feat(mes): 更新点检结果字段类型为整数,重构相关枚举和状态描述
Showing
11 changed files
with
73 additions
and
54 deletions
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/checkrecord/MesDvCheckRecordController.java
| ... | ... | @@ -72,7 +72,7 @@ public class MesDvCheckRecordController { |
| 72 | 72 | } |
| 73 | 73 | |
| 74 | 74 | @PutMapping("/submit") |
| 75 | - @Operation(summary = "提交设备点检记录(待点检→已完成)") | |
| 75 | + @Operation(summary = "提交设备点检记录(草稿→已完成)") | |
| 76 | 76 | @Parameter(name = "id", description = "编号", required = true) |
| 77 | 77 | @PreAuthorize("@ss.hasPermission('mes:dv-check-record:update')") |
| 78 | 78 | public CommonResult<Boolean> submitCheckRecord(@RequestParam("id") Long id) { | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/checkrecord/vo/MesDvCheckRecordRespVO.java
| ... | ... | @@ -26,9 +26,6 @@ public class MesDvCheckRecordRespVO { |
| 26 | 26 | @ExcelProperty("计划名称") |
| 27 | 27 | private String planName; |
| 28 | 28 | |
| 29 | - @Schema(description = "计划类型", example = "1") | |
| 30 | - private Integer planType; | |
| 31 | - | |
| 32 | 29 | @Schema(description = "设备编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| 33 | 30 | private Long machineryId; |
| 34 | 31 | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/checkrecord/vo/MesDvCheckRecordSaveReqVO.java
| ... | ... | @@ -16,9 +16,6 @@ public class MesDvCheckRecordSaveReqVO { |
| 16 | 16 | @Schema(description = "点检计划编号", example = "1") |
| 17 | 17 | private Long planId; |
| 18 | 18 | |
| 19 | - @Schema(description = "计划类型", example = "1") | |
| 20 | - private Integer planType; | |
| 21 | - | |
| 22 | 19 | @Schema(description = "设备编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") |
| 23 | 20 | @NotNull(message = "设备不能为空") |
| 24 | 21 | private Long machineryId; | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/checkrecord/vo/line/MesDvCheckRecordLineRespVO.java
| ... | ... | @@ -41,10 +41,10 @@ public class MesDvCheckRecordLineRespVO { |
| 41 | 41 | @ExcelProperty("检查标准") |
| 42 | 42 | private String subjectStandard; |
| 43 | 43 | |
| 44 | - @Schema(description = "点检结果(Y=正常,N=异常)", requiredMode = Schema.RequiredMode.REQUIRED, example = "Y") | |
| 44 | + @Schema(description = "点检结果", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 45 | 45 | @ExcelProperty(value = "点检结果", converter = DictConvert.class) |
| 46 | 46 | @DictFormat(DictTypeConstants.MES_DV_CHECK_RESULT) |
| 47 | - private String checkStatus; | |
| 47 | + private Integer checkStatus; | |
| 48 | 48 | |
| 49 | 49 | @Schema(description = "异常描述", example = "设备异响") |
| 50 | 50 | @ExcelProperty("异常描述") | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/checkrecord/vo/line/MesDvCheckRecordLineSaveReqVO.java
| ... | ... | @@ -20,9 +20,9 @@ public class MesDvCheckRecordLineSaveReqVO { |
| 20 | 20 | @NotNull(message = "点检项目不能为空") |
| 21 | 21 | private Long subjectId; |
| 22 | 22 | |
| 23 | - @Schema(description = "点检结果(Y=正常,N=异常)", requiredMode = Schema.RequiredMode.REQUIRED, example = "Y") | |
| 23 | + @Schema(description = "点检结果", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | |
| 24 | 24 | @NotNull(message = "点检结果不能为空") |
| 25 | - private String checkStatus; | |
| 25 | + private Integer checkStatus; | |
| 26 | 26 | |
| 27 | 27 | @Schema(description = "异常描述", example = "设备异响") |
| 28 | 28 | private String checkResult; | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/dv/checkrecord/MesDvCheckRecordDO.java
| ... | ... | @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.mes.dal.dataobject.dv.checkrecord; |
| 3 | 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 4 | 4 | import cn.iocoder.yudao.module.mes.dal.dataobject.dv.checkplan.MesDvCheckPlanDO; |
| 5 | 5 | import cn.iocoder.yudao.module.mes.dal.dataobject.dv.machinery.MesDvMachineryDO; |
| 6 | +import cn.iocoder.yudao.module.mes.enums.dv.MesDvCheckRecordStatusEnum; | |
| 6 | 7 | import com.baomidou.mybatisplus.annotation.KeySequence; |
| 7 | 8 | import com.baomidou.mybatisplus.annotation.TableId; |
| 8 | 9 | import com.baomidou.mybatisplus.annotation.TableName; |
| ... | ... | @@ -36,13 +37,6 @@ public class MesDvCheckRecordDO extends BaseDO { |
| 36 | 37 | * 关联 {@link MesDvCheckPlanDO#getId()} |
| 37 | 38 | */ |
| 38 | 39 | private Long planId; |
| 39 | - // TODO @AI:这个字段可以移除; | |
| 40 | - /** | |
| 41 | - * 计划类型 | |
| 42 | - * | |
| 43 | - * 字典类型 mes_dv_check_plan_type(与计划保持冗余,避免 JOIN) | |
| 44 | - */ | |
| 45 | - private Integer planType; | |
| 46 | 40 | /** |
| 47 | 41 | * 设备编号 |
| 48 | 42 | * |
| ... | ... | @@ -59,11 +53,10 @@ public class MesDvCheckRecordDO extends BaseDO { |
| 59 | 53 | * 关联 AdminUserDO#getId() |
| 60 | 54 | */ |
| 61 | 55 | private Long userId; |
| 62 | - // TODO @AI:枚举、字典; | |
| 63 | 56 | /** |
| 64 | 57 | * 状态 |
| 65 | 58 | * |
| 66 | - * 字典类型 mes_dv_check_record_status(10=待点检,20=已完成) | |
| 59 | + * 枚举 {@link MesDvCheckRecordStatusEnum} | |
| 67 | 60 | */ |
| 68 | 61 | private Integer status; |
| 69 | 62 | /** | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/dv/checkrecord/MesDvCheckRecordLineDO.java
| ... | ... | @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.mes.dal.dataobject.dv.checkrecord; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 4 | 4 | import cn.iocoder.yudao.module.mes.dal.dataobject.dv.subject.MesDvSubjectDO; |
| 5 | +import cn.iocoder.yudao.module.mes.enums.dv.MesDvCheckResultEnum; | |
| 5 | 6 | import com.baomidou.mybatisplus.annotation.KeySequence; |
| 6 | 7 | import com.baomidou.mybatisplus.annotation.TableId; |
| 7 | 8 | import com.baomidou.mybatisplus.annotation.TableName; |
| ... | ... | @@ -39,16 +40,16 @@ public class MesDvCheckRecordLineDO extends BaseDO { |
| 39 | 40 | * 关联 {@link MesDvSubjectDO#getId()} |
| 40 | 41 | */ |
| 41 | 42 | private Long subjectId; |
| 42 | - // TODO @AI:应该使用 int; | |
| 43 | 43 | /** |
| 44 | 44 | * 点检结果 |
| 45 | 45 | * |
| 46 | - * 字典类型 mes_dv_check_result(Y=正常,N=异常) | |
| 46 | + * 枚举 {@link MesDvCheckResultEnum} | |
| 47 | 47 | */ |
| 48 | - private String checkStatus; | |
| 49 | - // TODO @AI:需要标注下,checkStatus 才有使用; | |
| 48 | + private Integer checkStatus; | |
| 50 | 49 | /** |
| 51 | 50 | * 异常描述 |
| 51 | + * | |
| 52 | + * 仅 {@link #checkStatus} 为异常时使用 | |
| 52 | 53 | */ |
| 53 | 54 | private String checkResult; |
| 54 | 55 | /** | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/ErrorCodeConstants.java
| ... | ... | @@ -147,7 +147,7 @@ public interface ErrorCodeConstants { |
| 147 | 147 | |
| 148 | 148 | // ========== MES 设备管理-点检记录(1-040-306-000) ========== |
| 149 | 149 | ErrorCode DV_CHECK_RECORD_NOT_EXISTS = new ErrorCode(1_040_306_000, "设备点检记录不存在"); |
| 150 | - ErrorCode DV_CHECK_RECORD_NOT_PREPARE = new ErrorCode(1_040_306_001, "设备点检记录已完成,不允许修改或删除"); | |
| 150 | + ErrorCode DV_CHECK_RECORD_NOT_DRAFT = new ErrorCode(1_040_306_001, "设备点检记录已完成,不允许修改或删除"); | |
| 151 | 151 | ErrorCode DV_CHECK_RECORD_NO_LINE = new ErrorCode(1_040_306_002, "提交点检记录时,至少需要一条点检项目"); |
| 152 | 152 | // ========== MES 设备管理-点检记录明细(1-040-306-100) ========== |
| 153 | 153 | ErrorCode DV_CHECK_RECORD_LINE_NOT_EXISTS = new ErrorCode(1_040_306_100, "设备点检记录明细不存在"); | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/dv/MesDvCheckResultEnum.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.enums.dv; | |
| 2 | + | |
| 3 | +import cn.iocoder.yudao.framework.common.core.ArrayValuable; | |
| 4 | +import lombok.AllArgsConstructor; | |
| 5 | +import lombok.Getter; | |
| 6 | + | |
| 7 | +import java.util.Arrays; | |
| 8 | + | |
| 9 | +/** | |
| 10 | + * MES 设备点检结果枚举 | |
| 11 | + * | |
| 12 | + * @author 芋道源码 | |
| 13 | + */ | |
| 14 | +@Getter | |
| 15 | +@AllArgsConstructor | |
| 16 | +public enum MesDvCheckResultEnum implements ArrayValuable<Integer> { | |
| 17 | + | |
| 18 | + NORMAL(1, "正常"), | |
| 19 | + ABNORMAL(2, "异常"); | |
| 20 | + | |
| 21 | + public static final Integer[] ARRAYS = Arrays.stream(values()).map(MesDvCheckResultEnum::getResult).toArray(Integer[]::new); | |
| 22 | + | |
| 23 | + /** | |
| 24 | + * 结果值 | |
| 25 | + */ | |
| 26 | + private final Integer result; | |
| 27 | + /** | |
| 28 | + * 结果名 | |
| 29 | + */ | |
| 30 | + private final String name; | |
| 31 | + | |
| 32 | + @Override | |
| 33 | + public Integer[] array() { | |
| 34 | + return ARRAYS; | |
| 35 | + } | |
| 36 | + | |
| 37 | +} | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/checkrecord/MesDvCheckRecordService.java
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/checkrecord/MesDvCheckRecordServiceImpl.java
| 1 | 1 | package cn.iocoder.yudao.module.mes.service.dv.checkrecord; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | +import cn.hutool.core.util.ObjUtil; | |
| 4 | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 5 | 6 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 6 | 7 | import cn.iocoder.yudao.module.mes.controller.admin.dv.checkrecord.vo.MesDvCheckRecordPageReqVO; |
| ... | ... | @@ -8,6 +9,8 @@ import cn.iocoder.yudao.module.mes.controller.admin.dv.checkrecord.vo.MesDvCheck |
| 8 | 9 | import cn.iocoder.yudao.module.mes.dal.dataobject.dv.checkplan.MesDvCheckPlanSubjectDO; |
| 9 | 10 | import cn.iocoder.yudao.module.mes.dal.dataobject.dv.checkrecord.MesDvCheckRecordDO; |
| 10 | 11 | import cn.iocoder.yudao.module.mes.dal.dataobject.dv.checkrecord.MesDvCheckRecordLineDO; |
| 12 | +import cn.iocoder.yudao.module.mes.enums.dv.MesDvCheckRecordStatusEnum; | |
| 13 | +import cn.iocoder.yudao.module.mes.enums.dv.MesDvCheckResultEnum; | |
| 11 | 14 | import cn.iocoder.yudao.module.mes.dal.mysql.dv.checkrecord.MesDvCheckRecordLineMapper; |
| 12 | 15 | import cn.iocoder.yudao.module.mes.dal.mysql.dv.checkrecord.MesDvCheckRecordMapper; |
| 13 | 16 | import cn.iocoder.yudao.module.mes.service.dv.checkplan.MesDvCheckPlanService; |
| ... | ... | @@ -18,6 +21,7 @@ import org.springframework.stereotype.Service; |
| 18 | 21 | import org.springframework.transaction.annotation.Transactional; |
| 19 | 22 | import org.springframework.validation.annotation.Validated; |
| 20 | 23 | |
| 24 | +import java.util.ArrayList; | |
| 21 | 25 | import java.util.List; |
| 22 | 26 | |
| 23 | 27 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| ... | ... | @@ -32,16 +36,6 @@ import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; |
| 32 | 36 | @Validated |
| 33 | 37 | public class MesDvCheckRecordServiceImpl implements MesDvCheckRecordService { |
| 34 | 38 | |
| 35 | - // TODO @AI:枚举类; | |
| 36 | - /** | |
| 37 | - * 待点检状态 | |
| 38 | - */ | |
| 39 | - private static final int STATUS_PREPARE = 10; | |
| 40 | - /** | |
| 41 | - * 已完成状态 | |
| 42 | - */ | |
| 43 | - private static final int STATUS_FINISHED = 20; | |
| 44 | - | |
| 45 | 39 | @Resource |
| 46 | 40 | private MesDvCheckRecordMapper checkRecordMapper; |
| 47 | 41 | @Resource |
| ... | ... | @@ -59,9 +53,9 @@ public class MesDvCheckRecordServiceImpl implements MesDvCheckRecordService { |
| 59 | 53 | // 1. 校验关联数据 |
| 60 | 54 | validateCheckRecordRelation(createReqVO); |
| 61 | 55 | |
| 62 | - // 2. 插入主记录,状态默认为待点检 | |
| 56 | + // 2. 插入主记录,状态默认为草稿 | |
| 63 | 57 | MesDvCheckRecordDO checkRecord = BeanUtils.toBean(createReqVO, MesDvCheckRecordDO.class) |
| 64 | - .setStatus(STATUS_PREPARE); | |
| 58 | + .setStatus(MesDvCheckRecordStatusEnum.DRAFT.getStatus()); | |
| 65 | 59 | checkRecordMapper.insert(checkRecord); |
| 66 | 60 | |
| 67 | 61 | // 3. 如果指定了点检计划,自动生成明细行 |
| ... | ... | @@ -74,8 +68,8 @@ public class MesDvCheckRecordServiceImpl implements MesDvCheckRecordService { |
| 74 | 68 | @Override |
| 75 | 69 | @Transactional(rollbackFor = Exception.class) |
| 76 | 70 | public void updateCheckRecord(MesDvCheckRecordSaveReqVO updateReqVO) { |
| 77 | - // 1.1 校验存在 + 状态为待点检 | |
| 78 | - MesDvCheckRecordDO existRecord = validateCheckRecordPrepare(updateReqVO.getId()); | |
| 71 | + // 1.1 校验存在 + 状态为草稿 | |
| 72 | + MesDvCheckRecordDO existRecord = validateCheckRecordDraft(updateReqVO.getId()); | |
| 79 | 73 | // 1.2 校验关联数据 |
| 80 | 74 | validateCheckRecordRelation(updateReqVO); |
| 81 | 75 | |
| ... | ... | @@ -97,8 +91,8 @@ public class MesDvCheckRecordServiceImpl implements MesDvCheckRecordService { |
| 97 | 91 | |
| 98 | 92 | @Override |
| 99 | 93 | public void submitCheckRecord(Long id) { |
| 100 | - // 1.1 校验状态为待点检 | |
| 101 | - validateCheckRecordPrepare(id); | |
| 94 | + // 1.1 校验状态为草稿 | |
| 95 | + validateCheckRecordDraft(id); | |
| 102 | 96 | // 1.2 校验至少有一条明细 |
| 103 | 97 | List<MesDvCheckRecordLineDO> lines = checkRecordLineMapper.selectListByRecordId(id); |
| 104 | 98 | if (CollUtil.isEmpty(lines)) { |
| ... | ... | @@ -107,15 +101,15 @@ public class MesDvCheckRecordServiceImpl implements MesDvCheckRecordService { |
| 107 | 101 | |
| 108 | 102 | // 2. 状态改为已完成 |
| 109 | 103 | MesDvCheckRecordDO updateObj = new MesDvCheckRecordDO() |
| 110 | - .setId(id).setStatus(STATUS_FINISHED); | |
| 104 | + .setId(id).setStatus(MesDvCheckRecordStatusEnum.FINISHED.getStatus()); | |
| 111 | 105 | checkRecordMapper.updateById(updateObj); |
| 112 | 106 | } |
| 113 | 107 | |
| 114 | 108 | @Override |
| 115 | 109 | @Transactional(rollbackFor = Exception.class) |
| 116 | 110 | public void deleteCheckRecord(Long id) { |
| 117 | - // 1. 校验状态为待点检(已完成不可删除) | |
| 118 | - validateCheckRecordPrepare(id); | |
| 111 | + // 1. 校验状态为草稿(已完成不可删除) | |
| 112 | + validateCheckRecordDraft(id); | |
| 119 | 113 | |
| 120 | 114 | // 2.1 删除主记录 |
| 121 | 115 | checkRecordMapper.deleteById(id); |
| ... | ... | @@ -143,16 +137,15 @@ public class MesDvCheckRecordServiceImpl implements MesDvCheckRecordService { |
| 143 | 137 | // ==================== 私有方法 ==================== |
| 144 | 138 | |
| 145 | 139 | /** |
| 146 | - * 校验点检记录为待点检状态 | |
| 140 | + * 校验点检记录为草稿状态 | |
| 147 | 141 | */ |
| 148 | - private MesDvCheckRecordDO validateCheckRecordPrepare(Long id) { | |
| 142 | + private MesDvCheckRecordDO validateCheckRecordDraft(Long id) { | |
| 149 | 143 | MesDvCheckRecordDO record = checkRecordMapper.selectById(id); |
| 150 | 144 | if (record == null) { |
| 151 | 145 | throw exception(DV_CHECK_RECORD_NOT_EXISTS); |
| 152 | 146 | } |
| 153 | - // TODO @AI:ObjUtil notEquals | |
| 154 | - if (!STATUS_PREPARE.equals(record.getStatus())) { | |
| 155 | - throw exception(DV_CHECK_RECORD_NOT_PREPARE); | |
| 147 | + if (ObjUtil.notEqual(MesDvCheckRecordStatusEnum.DRAFT.getStatus(), record.getStatus())) { | |
| 148 | + throw exception(DV_CHECK_RECORD_NOT_DRAFT); | |
| 156 | 149 | } |
| 157 | 150 | return record; |
| 158 | 151 | } |
| ... | ... | @@ -174,12 +167,13 @@ public class MesDvCheckRecordServiceImpl implements MesDvCheckRecordService { |
| 174 | 167 | if (CollUtil.isEmpty(planSubjects)) { |
| 175 | 168 | return; |
| 176 | 169 | } |
| 177 | - // TODO @AI:批量插入; | |
| 170 | + List<MesDvCheckRecordLineDO> lines = new ArrayList<>(planSubjects.size()); | |
| 178 | 171 | for (MesDvCheckPlanSubjectDO planSubject : planSubjects) { |
| 179 | - MesDvCheckRecordLineDO line = new MesDvCheckRecordLineDO() | |
| 180 | - .setRecordId(recordId).setSubjectId(planSubject.getSubjectId()).setCheckStatus("Y"); | |
| 181 | - checkRecordLineMapper.insert(line); | |
| 172 | + lines.add(new MesDvCheckRecordLineDO() | |
| 173 | + .setRecordId(recordId).setSubjectId(planSubject.getSubjectId()) | |
| 174 | + .setCheckStatus(MesDvCheckResultEnum.NORMAL.getResult())); | |
| 182 | 175 | } |
| 176 | + checkRecordLineMapper.insertBatch(lines); | |
| 183 | 177 | } |
| 184 | 178 | |
| 185 | 179 | } | ... | ... |