Commit c2d93bafba0d1f63ba80e9e536c65ac846c4b034
1 parent
391d2531
feat(mes): 添加设备保养记录提交功能,新增状态枚举及相关校验
Showing
18 changed files
with
239 additions
and
52 deletions
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/maintenrecord/MesDvMaintenRecordController.java
| @@ -113,7 +113,14 @@ public class MesDvMaintenRecordController { | @@ -113,7 +113,14 @@ public class MesDvMaintenRecordController { | ||
| 113 | buildMaintenRecordRespVOList(list)); | 113 | buildMaintenRecordRespVOList(list)); |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | - // TODO @AI:submitMaintenRecord 缺少; | 116 | + @PutMapping("/submit") |
| 117 | + @Operation(summary = "提交设备保养记录(草稿→已提交)") | ||
| 118 | + @Parameter(name = "id", description = "编号", required = true) | ||
| 119 | + @PreAuthorize("@ss.hasPermission('mes:dv-mainten-record:update')") | ||
| 120 | + public CommonResult<Boolean> submitMaintenRecord(@RequestParam("id") Long id) { | ||
| 121 | + maintenRecordService.submitMaintenRecord(id); | ||
| 122 | + return success(true); | ||
| 123 | + } | ||
| 117 | 124 | ||
| 118 | // ==================== 拼接 VO ==================== | 125 | // ==================== 拼接 VO ==================== |
| 119 | 126 |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/maintenrecord/vo/MesDvMaintenRecordSaveReqVO.java
| @@ -27,10 +27,6 @@ public class MesDvMaintenRecordSaveReqVO { | @@ -27,10 +27,6 @@ public class MesDvMaintenRecordSaveReqVO { | ||
| 27 | @Schema(description = "用户编号", example = "1") | 27 | @Schema(description = "用户编号", example = "1") |
| 28 | private Long userId; | 28 | private Long userId; |
| 29 | 29 | ||
| 30 | - // TODO @AI:这个字段,不允许提交 | ||
| 31 | - @Schema(description = "状态", example = "10") | ||
| 32 | - private Integer status; | ||
| 33 | - | ||
| 34 | @Schema(description = "备注", example = "测试备注") | 30 | @Schema(description = "备注", example = "测试备注") |
| 35 | private String remark; | 31 | private String remark; |
| 36 | 32 |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/repair/MesDvRepairController.java
| @@ -32,10 +32,12 @@ import java.util.Collections; | @@ -32,10 +32,12 @@ import java.util.Collections; | ||
| 32 | import java.util.List; | 32 | import java.util.List; |
| 33 | import java.util.Map; | 33 | import java.util.Map; |
| 34 | import java.util.Set; | 34 | import java.util.Set; |
| 35 | +import java.util.stream.Stream; | ||
| 35 | 36 | ||
| 36 | import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; | 37 | import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; |
| 37 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | 38 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 38 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | 39 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| 40 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSetByFlatMap; | ||
| 39 | 41 | ||
| 40 | @Tag(name = "管理后台 - MES 维修工单") | 42 | @Tag(name = "管理后台 - MES 维修工单") |
| 41 | @RestController | 43 | @RestController |
| @@ -119,10 +121,8 @@ public class MesDvRepairController { | @@ -119,10 +121,8 @@ public class MesDvRepairController { | ||
| 119 | Map<Long, MesDvMachineryDO> machineryMap = machineryService.getMachineryMap( | 121 | Map<Long, MesDvMachineryDO> machineryMap = machineryService.getMachineryMap( |
| 120 | convertSet(list, MesDvRepairDO::getMachineryId)); | 122 | convertSet(list, MesDvRepairDO::getMachineryId)); |
| 121 | // 1.2 收集所有用户 ID(维修人 + 验收人) | 123 | // 1.2 收集所有用户 ID(维修人 + 验收人) |
| 122 | - // TODO @AI:CollUtils 里面,有多字段的处理,你研究下; | ||
| 123 | - Set<Long> userIds = convertSet(list, MesDvRepairDO::getAcceptedUserId); | ||
| 124 | - userIds.addAll(convertSet(list, MesDvRepairDO::getConfirmUserId)); | ||
| 125 | - Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(userIds); | 124 | + Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertSetByFlatMap(list, |
| 125 | + repair -> Stream.of(repair.getAcceptedUserId(), repair.getConfirmUserId()))); | ||
| 126 | // 2. 拼接 VO | 126 | // 2. 拼接 VO |
| 127 | return BeanUtils.toBean(list, MesDvRepairRespVO.class, vo -> { | 127 | return BeanUtils.toBean(list, MesDvRepairRespVO.class, vo -> { |
| 128 | MapUtils.findAndThen(machineryMap, vo.getMachineryId(), machinery -> vo | 128 | MapUtils.findAndThen(machineryMap, vo.getMachineryId(), machinery -> vo |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/repair/vo/MesDvRepairPageReqVO.java
| @@ -23,6 +23,9 @@ public class MesDvRepairPageReqVO extends PageParam { | @@ -23,6 +23,9 @@ public class MesDvRepairPageReqVO extends PageParam { | ||
| 23 | @Schema(description = "维修工单名称", example = "注塑机维修") | 23 | @Schema(description = "维修工单名称", example = "注塑机维修") |
| 24 | private String name; | 24 | private String name; |
| 25 | 25 | ||
| 26 | + @Schema(description = "维修结果", example = "1") | ||
| 27 | + private Integer result; | ||
| 28 | + | ||
| 26 | @Schema(description = "状态", example = "10") | 29 | @Schema(description = "状态", example = "10") |
| 27 | private Integer status; | 30 | private Integer status; |
| 28 | 31 |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/repair/vo/MesDvRepairSaveReqVO.java
| @@ -52,10 +52,6 @@ public class MesDvRepairSaveReqVO { | @@ -52,10 +52,6 @@ public class MesDvRepairSaveReqVO { | ||
| 52 | @Schema(description = "来源单据编码", example = "DOC001") | 52 | @Schema(description = "来源单据编码", example = "DOC001") |
| 53 | private String sourceDocCode; | 53 | private String sourceDocCode; |
| 54 | 54 | ||
| 55 | - // TODO @AI:这个字段,不允许提交 | ||
| 56 | - @Schema(description = "状态", example = "10") | ||
| 57 | - private Integer status; | ||
| 58 | - | ||
| 59 | @Schema(description = "备注", example = "测试备注") | 55 | @Schema(description = "备注", example = "测试备注") |
| 60 | private String remark; | 56 | private String remark; |
| 61 | 57 |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/dv/maintenrecord/MesDvMaintenRecordDO.java
| @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.mes.dal.dataobject.dv.maintenrecord; | @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.mes.dal.dataobject.dv.maintenrecord; | ||
| 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 4 | import cn.iocoder.yudao.module.mes.dal.dataobject.dv.checkplan.MesDvCheckPlanDO; | 4 | import cn.iocoder.yudao.module.mes.dal.dataobject.dv.checkplan.MesDvCheckPlanDO; |
| 5 | import cn.iocoder.yudao.module.mes.dal.dataobject.dv.machinery.MesDvMachineryDO; | 5 | import cn.iocoder.yudao.module.mes.dal.dataobject.dv.machinery.MesDvMachineryDO; |
| 6 | +import cn.iocoder.yudao.module.mes.enums.dv.MesDvMaintenRecordStatusEnum; | ||
| 6 | import com.baomidou.mybatisplus.annotation.KeySequence; | 7 | import com.baomidou.mybatisplus.annotation.KeySequence; |
| 7 | import com.baomidou.mybatisplus.annotation.TableId; | 8 | import com.baomidou.mybatisplus.annotation.TableId; |
| 8 | import com.baomidou.mybatisplus.annotation.TableName; | 9 | import com.baomidou.mybatisplus.annotation.TableName; |
| @@ -52,11 +53,10 @@ public class MesDvMaintenRecordDO extends BaseDO { | @@ -52,11 +53,10 @@ public class MesDvMaintenRecordDO extends BaseDO { | ||
| 52 | * 关联 AdminUserDO#getId() | 53 | * 关联 AdminUserDO#getId() |
| 53 | */ | 54 | */ |
| 54 | private Long userId; | 55 | private Long userId; |
| 55 | - // TODO @AI:搞个枚举类,关联下; | ||
| 56 | - // TODO @AI:mes_mainten_record_status,需要在 dict contants 美剧侠,然后 @关联下; | ||
| 57 | /** | 56 | /** |
| 58 | * 状态 | 57 | * 状态 |
| 59 | * | 58 | * |
| 59 | + * 枚举 {@link MesDvMaintenRecordStatusEnum} | ||
| 60 | * 字典类型 mes_mainten_record_status | 60 | * 字典类型 mes_mainten_record_status |
| 61 | */ | 61 | */ |
| 62 | private Integer status; | 62 | private Integer status; |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/dv/maintenrecord/MesDvMaintenRecordLineDO.java
| @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.mes.dal.dataobject.dv.maintenrecord; | @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.mes.dal.dataobject.dv.maintenrecord; | ||
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 4 | import cn.iocoder.yudao.module.mes.dal.dataobject.dv.subject.MesDvSubjectDO; | 4 | import cn.iocoder.yudao.module.mes.dal.dataobject.dv.subject.MesDvSubjectDO; |
| 5 | +import cn.iocoder.yudao.module.mes.enums.dv.MesDvMaintenStatusEnum; | ||
| 5 | import com.baomidou.mybatisplus.annotation.KeySequence; | 6 | import com.baomidou.mybatisplus.annotation.KeySequence; |
| 6 | import com.baomidou.mybatisplus.annotation.TableId; | 7 | import com.baomidou.mybatisplus.annotation.TableId; |
| 7 | import com.baomidou.mybatisplus.annotation.TableName; | 8 | import com.baomidou.mybatisplus.annotation.TableName; |
| @@ -39,11 +40,10 @@ public class MesDvMaintenRecordLineDO extends BaseDO { | @@ -39,11 +40,10 @@ public class MesDvMaintenRecordLineDO extends BaseDO { | ||
| 39 | * 关联 {@link MesDvSubjectDO#getId()} | 40 | * 关联 {@link MesDvSubjectDO#getId()} |
| 40 | */ | 41 | */ |
| 41 | private Long subjectId; | 42 | private Long subjectId; |
| 42 | - // TODO @AI:搞个枚举类,关联下; | ||
| 43 | - // TODO @AI:mes_mainten_status,需要在 dict contants 美剧侠,然后 @关联下; | ||
| 44 | /** | 43 | /** |
| 45 | * 保养结果 | 44 | * 保养结果 |
| 46 | * | 45 | * |
| 46 | + * 枚举 {@link MesDvMaintenStatusEnum} | ||
| 47 | * 字典类型 mes_mainten_status | 47 | * 字典类型 mes_mainten_status |
| 48 | */ | 48 | */ |
| 49 | private Integer status; | 49 | private Integer status; |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/dv/repair/MesDvRepairDO.java
| @@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.mes.dal.dataobject.dv.repair; | @@ -2,6 +2,8 @@ package cn.iocoder.yudao.module.mes.dal.dataobject.dv.repair; | ||
| 2 | 2 | ||
| 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | 3 | import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; |
| 4 | import cn.iocoder.yudao.module.mes.dal.dataobject.dv.machinery.MesDvMachineryDO; | 4 | import cn.iocoder.yudao.module.mes.dal.dataobject.dv.machinery.MesDvMachineryDO; |
| 5 | +import cn.iocoder.yudao.module.mes.enums.dv.MesDvRepairResultEnum; | ||
| 6 | +import cn.iocoder.yudao.module.mes.enums.dv.MesDvRepairStatusEnum; | ||
| 5 | import com.baomidou.mybatisplus.annotation.KeySequence; | 7 | import com.baomidou.mybatisplus.annotation.KeySequence; |
| 6 | import com.baomidou.mybatisplus.annotation.TableId; | 8 | import com.baomidou.mybatisplus.annotation.TableId; |
| 7 | import com.baomidou.mybatisplus.annotation.TableName; | 9 | import com.baomidou.mybatisplus.annotation.TableName; |
| @@ -55,11 +57,10 @@ public class MesDvRepairDO extends BaseDO { | @@ -55,11 +57,10 @@ public class MesDvRepairDO extends BaseDO { | ||
| 55 | * 验收日期 | 57 | * 验收日期 |
| 56 | */ | 58 | */ |
| 57 | private LocalDateTime confirmDate; | 59 | private LocalDateTime confirmDate; |
| 58 | - // TODO @AI:枚举类; | ||
| 59 | - // TODO @AI:字典,需要在 dict constants; | ||
| 60 | /** | 60 | /** |
| 61 | * 维修结果 | 61 | * 维修结果 |
| 62 | * | 62 | * |
| 63 | + * 枚举 {@link MesDvRepairResultEnum} | ||
| 63 | * 字典类型 mes_dv_repair_result | 64 | * 字典类型 mes_dv_repair_result |
| 64 | */ | 65 | */ |
| 65 | private Integer result; | 66 | private Integer result; |
| @@ -88,11 +89,10 @@ public class MesDvRepairDO extends BaseDO { | @@ -88,11 +89,10 @@ public class MesDvRepairDO extends BaseDO { | ||
| 88 | * 来源单据编码 | 89 | * 来源单据编码 |
| 89 | */ | 90 | */ |
| 90 | private String sourceDocCode; | 91 | private String sourceDocCode; |
| 91 | - // TODO @AI:枚举类; | ||
| 92 | - // TODO @AI:字典,需要在 dict constants; | ||
| 93 | /** | 92 | /** |
| 94 | * 状态 | 93 | * 状态 |
| 95 | * | 94 | * |
| 95 | + * 枚举 {@link MesDvRepairStatusEnum} | ||
| 96 | * 字典类型 mes_dv_repair_status | 96 | * 字典类型 mes_dv_repair_status |
| 97 | */ | 97 | */ |
| 98 | private Integer status; | 98 | private Integer status; |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/dv/repair/MesDvRepairMapper.java
| @@ -19,6 +19,7 @@ public interface MesDvRepairMapper extends BaseMapperX<MesDvRepairDO> { | @@ -19,6 +19,7 @@ public interface MesDvRepairMapper extends BaseMapperX<MesDvRepairDO> { | ||
| 19 | return selectPage(reqVO, new LambdaQueryWrapperX<MesDvRepairDO>() | 19 | return selectPage(reqVO, new LambdaQueryWrapperX<MesDvRepairDO>() |
| 20 | .likeIfPresent(MesDvRepairDO::getCode, reqVO.getCode()) | 20 | .likeIfPresent(MesDvRepairDO::getCode, reqVO.getCode()) |
| 21 | .likeIfPresent(MesDvRepairDO::getName, reqVO.getName()) | 21 | .likeIfPresent(MesDvRepairDO::getName, reqVO.getName()) |
| 22 | + .eqIfPresent(MesDvRepairDO::getResult, reqVO.getResult()) | ||
| 22 | .eqIfPresent(MesDvRepairDO::getStatus, reqVO.getStatus()) | 23 | .eqIfPresent(MesDvRepairDO::getStatus, reqVO.getStatus()) |
| 23 | .betweenIfPresent(MesDvRepairDO::getRequireDate, reqVO.getRequireDate()) | 24 | .betweenIfPresent(MesDvRepairDO::getRequireDate, reqVO.getRequireDate()) |
| 24 | .orderByDesc(MesDvRepairDO::getId)); | 25 | .orderByDesc(MesDvRepairDO::getId)); |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/ErrorCodeConstants.java
| @@ -137,11 +137,14 @@ public interface ErrorCodeConstants { | @@ -137,11 +137,14 @@ public interface ErrorCodeConstants { | ||
| 137 | 137 | ||
| 138 | // ========== MES 设备管理-维修工单(1-040-303-000) ========== | 138 | // ========== MES 设备管理-维修工单(1-040-303-000) ========== |
| 139 | ErrorCode DV_REPAIR_NOT_EXISTS = new ErrorCode(1_040_303_000, "维修工单不存在"); | 139 | ErrorCode DV_REPAIR_NOT_EXISTS = new ErrorCode(1_040_303_000, "维修工单不存在"); |
| 140 | + ErrorCode DV_REPAIR_NOT_DRAFT = new ErrorCode(1_040_303_001, "维修工单已确认,不允许修改或删除"); | ||
| 140 | // ========== MES 设备管理-维修工单行(1-040-303-100) ========== | 141 | // ========== MES 设备管理-维修工单行(1-040-303-100) ========== |
| 141 | ErrorCode DV_REPAIR_LINE_NOT_EXISTS = new ErrorCode(1_040_303_100, "维修工单行不存在"); | 142 | ErrorCode DV_REPAIR_LINE_NOT_EXISTS = new ErrorCode(1_040_303_100, "维修工单行不存在"); |
| 142 | 143 | ||
| 143 | // ========== MES 设备管理-保养记录(1-040-305-000) ========== | 144 | // ========== MES 设备管理-保养记录(1-040-305-000) ========== |
| 144 | ErrorCode MAINTEN_RECORD_NOT_EXISTS = new ErrorCode(1_040_305_000, "设备保养记录不存在"); | 145 | ErrorCode MAINTEN_RECORD_NOT_EXISTS = new ErrorCode(1_040_305_000, "设备保养记录不存在"); |
| 146 | + ErrorCode MAINTEN_RECORD_NOT_DRAFT = new ErrorCode(1_040_305_001, "设备保养记录已提交,不允许修改或删除"); | ||
| 147 | + ErrorCode MAINTEN_RECORD_NO_LINE = new ErrorCode(1_040_305_002, "提交保养记录时,至少需要一条保养项目"); | ||
| 145 | // ========== MES 设备管理-保养记录明细(1-040-305-100) ========== | 148 | // ========== MES 设备管理-保养记录明细(1-040-305-100) ========== |
| 146 | ErrorCode MAINTEN_RECORD_LINE_NOT_EXISTS = new ErrorCode(1_040_305_100, "设备保养记录明细不存在"); | 149 | ErrorCode MAINTEN_RECORD_LINE_NOT_EXISTS = new ErrorCode(1_040_305_100, "设备保养记录明细不存在"); |
| 147 | 150 |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/dv/MesDvMaintenStatusEnum.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 MesDvMaintenStatusEnum implements ArrayValuable<Integer> { | ||
| 17 | + | ||
| 18 | + NORMAL(1, "正常"), | ||
| 19 | + ABNORMAL(2, "异常"); | ||
| 20 | + | ||
| 21 | + public static final Integer[] ARRAYS = Arrays.stream(values()).map(MesDvMaintenStatusEnum::getStatus).toArray(Integer[]::new); | ||
| 22 | + | ||
| 23 | + /** | ||
| 24 | + * 状态值 | ||
| 25 | + */ | ||
| 26 | + private final Integer status; | ||
| 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/enums/dv/MesDvRepairResultEnum.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 MesDvRepairResultEnum implements ArrayValuable<Integer> { | ||
| 17 | + | ||
| 18 | + PASS(1, "通过"), | ||
| 19 | + FAIL(2, "不通过"); | ||
| 20 | + | ||
| 21 | + public static final Integer[] ARRAYS = Arrays.stream(values()).map(MesDvRepairResultEnum::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/enums/dv/MesDvRepairStatusEnum.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 MesDvRepairStatusEnum implements ArrayValuable<Integer> { | ||
| 17 | + | ||
| 18 | + DRAFT(10, "草稿"), | ||
| 19 | + CONFIRMED(20, "已确认"); | ||
| 20 | + | ||
| 21 | + public static final Integer[] ARRAYS = Arrays.stream(values()).map(MesDvRepairStatusEnum::getStatus).toArray(Integer[]::new); | ||
| 22 | + | ||
| 23 | + /** | ||
| 24 | + * 状态值 | ||
| 25 | + */ | ||
| 26 | + private final Integer status; | ||
| 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/maintenrecord/MesDvMaintenRecordLineServiceImpl.java
| @@ -29,7 +29,7 @@ public class MesDvMaintenRecordLineServiceImpl implements MesDvMaintenRecordLine | @@ -29,7 +29,7 @@ public class MesDvMaintenRecordLineServiceImpl implements MesDvMaintenRecordLine | ||
| 29 | 29 | ||
| 30 | @Resource | 30 | @Resource |
| 31 | @Lazy | 31 | @Lazy |
| 32 | - private MesDvMaintenRecordService maintenRecordService; | 32 | + private MesDvMaintenRecordServiceImpl maintenRecordService; |
| 33 | @Resource | 33 | @Resource |
| 34 | private MesDvSubjectService subjectService; | 34 | private MesDvSubjectService subjectService; |
| 35 | 35 | ||
| @@ -37,7 +37,6 @@ public class MesDvMaintenRecordLineServiceImpl implements MesDvMaintenRecordLine | @@ -37,7 +37,6 @@ public class MesDvMaintenRecordLineServiceImpl implements MesDvMaintenRecordLine | ||
| 37 | public Long createMaintenRecordLine(MesDvMaintenRecordLineSaveReqVO createReqVO) { | 37 | public Long createMaintenRecordLine(MesDvMaintenRecordLineSaveReqVO createReqVO) { |
| 38 | // 1. 校验关联数据 | 38 | // 1. 校验关联数据 |
| 39 | validateMaintenRecordLineRelation(createReqVO); | 39 | validateMaintenRecordLineRelation(createReqVO); |
| 40 | - // TODO @AI:已提交时,不允许编辑(最好对方提供一个通用方法) | ||
| 41 | 40 | ||
| 42 | // 2. 插入 | 41 | // 2. 插入 |
| 43 | MesDvMaintenRecordLineDO maintenRecordLine = BeanUtils.toBean(createReqVO, MesDvMaintenRecordLineDO.class); | 42 | MesDvMaintenRecordLineDO maintenRecordLine = BeanUtils.toBean(createReqVO, MesDvMaintenRecordLineDO.class); |
| @@ -59,25 +58,28 @@ public class MesDvMaintenRecordLineServiceImpl implements MesDvMaintenRecordLine | @@ -59,25 +58,28 @@ public class MesDvMaintenRecordLineServiceImpl implements MesDvMaintenRecordLine | ||
| 59 | 58 | ||
| 60 | @Override | 59 | @Override |
| 61 | public void deleteMaintenRecordLine(Long id) { | 60 | public void deleteMaintenRecordLine(Long id) { |
| 62 | - // 1. 校验存在 | ||
| 63 | - validateMaintenRecordLineExists(id); | ||
| 64 | - // TODO @AI:已提交时,不允许删除;(最好对方提供一个通用方法) | 61 | + // 1.1 校验存在 |
| 62 | + MesDvMaintenRecordLineDO line = validateMaintenRecordLineExists(id); | ||
| 63 | + // 1.2 校验保养记录为草稿状态 | ||
| 64 | + maintenRecordService.validateMaintenRecordDraft(line.getRecordId()); | ||
| 65 | 65 | ||
| 66 | // 2. 删除 | 66 | // 2. 删除 |
| 67 | maintenRecordLineMapper.deleteById(id); | 67 | maintenRecordLineMapper.deleteById(id); |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | private void validateMaintenRecordLineRelation(MesDvMaintenRecordLineSaveReqVO reqVO) { | 70 | private void validateMaintenRecordLineRelation(MesDvMaintenRecordLineSaveReqVO reqVO) { |
| 71 | - // 校验设备保养记录是否存在 | ||
| 72 | - maintenRecordService.validateMaintenRecordExists(reqVO.getRecordId()); | 71 | + // 校验保养记录为草稿状态 |
| 72 | + maintenRecordService.validateMaintenRecordDraft(reqVO.getRecordId()); | ||
| 73 | // 校验保养项目是否存在 | 73 | // 校验保养项目是否存在 |
| 74 | subjectService.validateSubjectExists(reqVO.getSubjectId()); | 74 | subjectService.validateSubjectExists(reqVO.getSubjectId()); |
| 75 | } | 75 | } |
| 76 | 76 | ||
| 77 | - private void validateMaintenRecordLineExists(Long id) { | 77 | + private MesDvMaintenRecordLineDO validateMaintenRecordLineExists(Long id) { |
| 78 | + MesDvMaintenRecordLineDO maintenRecordLine = maintenRecordLineMapper.selectById(id); | ||
| 78 | if (maintenRecordLineMapper.selectById(id) == null) { | 79 | if (maintenRecordLineMapper.selectById(id) == null) { |
| 79 | throw exception(MAINTEN_RECORD_LINE_NOT_EXISTS); | 80 | throw exception(MAINTEN_RECORD_LINE_NOT_EXISTS); |
| 80 | } | 81 | } |
| 82 | + return maintenRecordLine; | ||
| 81 | } | 83 | } |
| 82 | 84 | ||
| 83 | @Override | 85 | @Override |
| @@ -90,4 +92,4 @@ public class MesDvMaintenRecordLineServiceImpl implements MesDvMaintenRecordLine | @@ -90,4 +92,4 @@ public class MesDvMaintenRecordLineServiceImpl implements MesDvMaintenRecordLine | ||
| 90 | return maintenRecordLineMapper.selectPage(pageReqVO); | 92 | return maintenRecordLineMapper.selectPage(pageReqVO); |
| 91 | } | 93 | } |
| 92 | 94 | ||
| 93 | -} | ||
| 94 | \ No newline at end of file | 95 | \ No newline at end of file |
| 96 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/maintenrecord/MesDvMaintenRecordService.java
| @@ -30,6 +30,13 @@ public interface MesDvMaintenRecordService { | @@ -30,6 +30,13 @@ public interface MesDvMaintenRecordService { | ||
| 30 | void updateMaintenRecord(@Valid MesDvMaintenRecordSaveReqVO updateReqVO); | 30 | void updateMaintenRecord(@Valid MesDvMaintenRecordSaveReqVO updateReqVO); |
| 31 | 31 | ||
| 32 | /** | 32 | /** |
| 33 | + * 提交设备保养记录(草稿→已提交) | ||
| 34 | + * | ||
| 35 | + * @param id 编号 | ||
| 36 | + */ | ||
| 37 | + void submitMaintenRecord(Long id); | ||
| 38 | + | ||
| 39 | + /** | ||
| 33 | * 删除设备保养记录 | 40 | * 删除设备保养记录 |
| 34 | * | 41 | * |
| 35 | * @param id 编号 | 42 | * @param id 编号 |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/maintenrecord/MesDvMaintenRecordServiceImpl.java
| 1 | package cn.iocoder.yudao.module.mes.service.dv.maintenrecord; | 1 | package cn.iocoder.yudao.module.mes.service.dv.maintenrecord; |
| 2 | 2 | ||
| 3 | +import cn.hutool.core.collection.CollUtil; | ||
| 4 | +import cn.hutool.core.util.ObjUtil; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 5 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 6 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 5 | import cn.iocoder.yudao.module.mes.controller.admin.dv.maintenrecord.vo.MesDvMaintenRecordPageReqVO; | 7 | import cn.iocoder.yudao.module.mes.controller.admin.dv.maintenrecord.vo.MesDvMaintenRecordPageReqVO; |
| 6 | import cn.iocoder.yudao.module.mes.controller.admin.dv.maintenrecord.vo.MesDvMaintenRecordSaveReqVO; | 8 | import cn.iocoder.yudao.module.mes.controller.admin.dv.maintenrecord.vo.MesDvMaintenRecordSaveReqVO; |
| 7 | import cn.iocoder.yudao.module.mes.dal.dataobject.dv.maintenrecord.MesDvMaintenRecordDO; | 9 | import cn.iocoder.yudao.module.mes.dal.dataobject.dv.maintenrecord.MesDvMaintenRecordDO; |
| 10 | +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.maintenrecord.MesDvMaintenRecordLineDO; | ||
| 8 | import cn.iocoder.yudao.module.mes.dal.mysql.dv.maintenrecord.MesDvMaintenRecordLineMapper; | 11 | import cn.iocoder.yudao.module.mes.dal.mysql.dv.maintenrecord.MesDvMaintenRecordLineMapper; |
| 9 | import cn.iocoder.yudao.module.mes.dal.mysql.dv.maintenrecord.MesDvMaintenRecordMapper; | 12 | import cn.iocoder.yudao.module.mes.dal.mysql.dv.maintenrecord.MesDvMaintenRecordMapper; |
| 13 | +import cn.iocoder.yudao.module.mes.enums.dv.MesDvMaintenRecordStatusEnum; | ||
| 10 | import cn.iocoder.yudao.module.mes.service.dv.checkplan.MesDvCheckPlanService; | 14 | import cn.iocoder.yudao.module.mes.service.dv.checkplan.MesDvCheckPlanService; |
| 11 | import cn.iocoder.yudao.module.mes.service.dv.machinery.MesDvMachineryService; | 15 | import cn.iocoder.yudao.module.mes.service.dv.machinery.MesDvMachineryService; |
| 12 | import jakarta.annotation.Resource; | 16 | import jakarta.annotation.Resource; |
| @@ -14,6 +18,8 @@ import org.springframework.stereotype.Service; | @@ -14,6 +18,8 @@ import org.springframework.stereotype.Service; | ||
| 14 | import org.springframework.transaction.annotation.Transactional; | 18 | import org.springframework.transaction.annotation.Transactional; |
| 15 | import org.springframework.validation.annotation.Validated; | 19 | import org.springframework.validation.annotation.Validated; |
| 16 | 20 | ||
| 21 | +import java.util.List; | ||
| 22 | + | ||
| 17 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | 23 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 18 | import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; | 24 | import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; |
| 19 | 25 | ||
| @@ -42,31 +48,45 @@ public class MesDvMaintenRecordServiceImpl implements MesDvMaintenRecordService | @@ -42,31 +48,45 @@ public class MesDvMaintenRecordServiceImpl implements MesDvMaintenRecordService | ||
| 42 | 48 | ||
| 43 | // 2. 插入 | 49 | // 2. 插入 |
| 44 | MesDvMaintenRecordDO maintenRecord = BeanUtils.toBean(createReqVO, MesDvMaintenRecordDO.class); | 50 | MesDvMaintenRecordDO maintenRecord = BeanUtils.toBean(createReqVO, MesDvMaintenRecordDO.class); |
| 45 | - // TODO @AI:设置下默认状态; | 51 | + maintenRecord.setStatus(MesDvMaintenRecordStatusEnum.PREPARE.getStatus()); |
| 46 | maintenRecordMapper.insert(maintenRecord); | 52 | maintenRecordMapper.insert(maintenRecord); |
| 47 | return maintenRecord.getId(); | 53 | return maintenRecord.getId(); |
| 48 | } | 54 | } |
| 49 | 55 | ||
| 50 | @Override | 56 | @Override |
| 51 | public void updateMaintenRecord(MesDvMaintenRecordSaveReqVO updateReqVO) { | 57 | public void updateMaintenRecord(MesDvMaintenRecordSaveReqVO updateReqVO) { |
| 52 | - // 1.1 校验存在 | ||
| 53 | - validateMaintenRecordExists(updateReqVO.getId()); | 58 | + // 1.1 校验存在,且状态为草稿 |
| 59 | + validateMaintenRecordDraft(updateReqVO.getId()); | ||
| 54 | // 1.2 校验关联数据 | 60 | // 1.2 校验关联数据 |
| 55 | validateMaintenRecordRelation(updateReqVO); | 61 | validateMaintenRecordRelation(updateReqVO); |
| 56 | - // TODO @AI:已提交时,不允许编辑 | ||
| 57 | 62 | ||
| 58 | // 2. 更新 | 63 | // 2. 更新 |
| 59 | MesDvMaintenRecordDO updateObj = BeanUtils.toBean(updateReqVO, MesDvMaintenRecordDO.class); | 64 | MesDvMaintenRecordDO updateObj = BeanUtils.toBean(updateReqVO, MesDvMaintenRecordDO.class); |
| 60 | - // TODO 设置为空,避免更新; | 65 | + maintenRecordMapper.updateById(updateObj); |
| 66 | + } | ||
| 67 | + | ||
| 68 | + @Override | ||
| 69 | + public void submitMaintenRecord(Long id) { | ||
| 70 | + // 1.1 校验状态为草稿 | ||
| 71 | + validateMaintenRecordDraft(id); | ||
| 72 | + // 1.2 校验至少有一条明细 | ||
| 73 | + List<MesDvMaintenRecordLineDO> lines = maintenRecordLineMapper.selectListByRecordId(id); | ||
| 74 | + if (CollUtil.isEmpty(lines)) { | ||
| 75 | + throw exception(MAINTEN_RECORD_NO_LINE); | ||
| 76 | + } | ||
| 77 | + | ||
| 78 | + // 2. 状态改为已提交 | ||
| 79 | + MesDvMaintenRecordDO updateObj = new MesDvMaintenRecordDO(); | ||
| 80 | + updateObj.setId(id); | ||
| 81 | + updateObj.setStatus(MesDvMaintenRecordStatusEnum.SUBMITTED.getStatus()); | ||
| 61 | maintenRecordMapper.updateById(updateObj); | 82 | maintenRecordMapper.updateById(updateObj); |
| 62 | } | 83 | } |
| 63 | 84 | ||
| 64 | @Override | 85 | @Override |
| 65 | @Transactional(rollbackFor = Exception.class) | 86 | @Transactional(rollbackFor = Exception.class) |
| 66 | public void deleteMaintenRecord(Long id) { | 87 | public void deleteMaintenRecord(Long id) { |
| 67 | - // 校验存在 | ||
| 68 | - validateMaintenRecordExists(id); | ||
| 69 | - // TODO @AI:已提交时,不允许删除 | 88 | + // 校验存在,且状态为草稿 |
| 89 | + validateMaintenRecordDraft(id); | ||
| 70 | 90 | ||
| 71 | // 删除 | 91 | // 删除 |
| 72 | maintenRecordMapper.deleteById(id); | 92 | maintenRecordMapper.deleteById(id); |
| @@ -90,6 +110,23 @@ public class MesDvMaintenRecordServiceImpl implements MesDvMaintenRecordService | @@ -90,6 +110,23 @@ public class MesDvMaintenRecordServiceImpl implements MesDvMaintenRecordService | ||
| 90 | } | 110 | } |
| 91 | } | 111 | } |
| 92 | 112 | ||
| 113 | + /** | ||
| 114 | + * 校验设备保养记录是否为草稿状态 | ||
| 115 | + * | ||
| 116 | + * @param id 编号 | ||
| 117 | + * @return 保养记录 | ||
| 118 | + */ | ||
| 119 | + public MesDvMaintenRecordDO validateMaintenRecordDraft(Long id) { | ||
| 120 | + MesDvMaintenRecordDO record = maintenRecordMapper.selectById(id); | ||
| 121 | + if (record == null) { | ||
| 122 | + throw exception(MAINTEN_RECORD_NOT_EXISTS); | ||
| 123 | + } | ||
| 124 | + if (ObjUtil.notEqual(MesDvMaintenRecordStatusEnum.PREPARE.getStatus(), record.getStatus())) { | ||
| 125 | + throw exception(MAINTEN_RECORD_NOT_DRAFT); | ||
| 126 | + } | ||
| 127 | + return record; | ||
| 128 | + } | ||
| 129 | + | ||
| 93 | @Override | 130 | @Override |
| 94 | public MesDvMaintenRecordDO getMaintenRecord(Long id) { | 131 | public MesDvMaintenRecordDO getMaintenRecord(Long id) { |
| 95 | return maintenRecordMapper.selectById(id); | 132 | return maintenRecordMapper.selectById(id); |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/repair/MesDvRepairLineServiceImpl.java
| @@ -29,15 +29,16 @@ public class MesDvRepairLineServiceImpl implements MesDvRepairLineService { | @@ -29,15 +29,16 @@ public class MesDvRepairLineServiceImpl implements MesDvRepairLineService { | ||
| 29 | 29 | ||
| 30 | @Resource | 30 | @Resource |
| 31 | @Lazy | 31 | @Lazy |
| 32 | - private MesDvRepairService repairService; | 32 | + private MesDvRepairServiceImpl repairService; |
| 33 | @Resource | 33 | @Resource |
| 34 | private MesDvSubjectService subjectService; | 34 | private MesDvSubjectService subjectService; |
| 35 | 35 | ||
| 36 | @Override | 36 | @Override |
| 37 | public Long createRepairLine(MesDvRepairLineSaveReqVO createReqVO) { | 37 | public Long createRepairLine(MesDvRepairLineSaveReqVO createReqVO) { |
| 38 | - // 1. 校验关联数据 | 38 | + // 1.1 校验关联数据 |
| 39 | validateRepairLineRelation(createReqVO); | 39 | validateRepairLineRelation(createReqVO); |
| 40 | - // TODO @AI:关联数据的状态的校验(最好对方提供的方法) | 40 | + // 1.2 校验维修工单为草稿状态 |
| 41 | + repairService.validateRepairDraft(createReqVO.getRepairId()); | ||
| 41 | 42 | ||
| 42 | // 2. 插入 | 43 | // 2. 插入 |
| 43 | MesDvRepairLineDO repairLine = BeanUtils.toBean(createReqVO, MesDvRepairLineDO.class); | 44 | MesDvRepairLineDO repairLine = BeanUtils.toBean(createReqVO, MesDvRepairLineDO.class); |
| @@ -51,7 +52,8 @@ public class MesDvRepairLineServiceImpl implements MesDvRepairLineService { | @@ -51,7 +52,8 @@ public class MesDvRepairLineServiceImpl implements MesDvRepairLineService { | ||
| 51 | validateRepairLineExists(updateReqVO.getId()); | 52 | validateRepairLineExists(updateReqVO.getId()); |
| 52 | // 1.2 校验关联数据 | 53 | // 1.2 校验关联数据 |
| 53 | validateRepairLineRelation(updateReqVO); | 54 | validateRepairLineRelation(updateReqVO); |
| 54 | - // TODO @AI:关联数据的状态的校验(最好对方提供的方法) | 55 | + // 1.3 校验维修工单为草稿状态 |
| 56 | + repairService.validateRepairDraft(updateReqVO.getRepairId()); | ||
| 55 | 57 | ||
| 56 | // 2. 更新 | 58 | // 2. 更新 |
| 57 | MesDvRepairLineDO updateObj = BeanUtils.toBean(updateReqVO, MesDvRepairLineDO.class); | 59 | MesDvRepairLineDO updateObj = BeanUtils.toBean(updateReqVO, MesDvRepairLineDO.class); |
| @@ -60,11 +62,15 @@ public class MesDvRepairLineServiceImpl implements MesDvRepairLineService { | @@ -60,11 +62,15 @@ public class MesDvRepairLineServiceImpl implements MesDvRepairLineService { | ||
| 60 | 62 | ||
| 61 | @Override | 63 | @Override |
| 62 | public void deleteRepairLine(Long id) { | 64 | public void deleteRepairLine(Long id) { |
| 63 | - // 校验存在 | ||
| 64 | - validateRepairLineExists(id); | ||
| 65 | - // TODO @AI:关联数据的状态的校验(最好对方提供的方法) | 65 | + // 1.1 校验存在 |
| 66 | + MesDvRepairLineDO line = repairLineMapper.selectById(id); | ||
| 67 | + if (line == null) { | ||
| 68 | + throw exception(DV_REPAIR_LINE_NOT_EXISTS); | ||
| 69 | + } | ||
| 70 | + // 1.2 校验维修工单为草稿状态 | ||
| 71 | + repairService.validateRepairDraft(line.getRepairId()); | ||
| 66 | 72 | ||
| 67 | - // 删除 | 73 | + // 2. 删除 |
| 68 | repairLineMapper.deleteById(id); | 74 | repairLineMapper.deleteById(id); |
| 69 | } | 75 | } |
| 70 | 76 |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/repair/MesDvRepairServiceImpl.java
| 1 | package cn.iocoder.yudao.module.mes.service.dv.repair; | 1 | package cn.iocoder.yudao.module.mes.service.dv.repair; |
| 2 | 2 | ||
| 3 | +import cn.hutool.core.util.ObjUtil; | ||
| 3 | import cn.iocoder.yudao.framework.common.pojo.PageResult; | 4 | import cn.iocoder.yudao.framework.common.pojo.PageResult; |
| 4 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | 5 | import cn.iocoder.yudao.framework.common.util.object.BeanUtils; |
| 5 | import cn.iocoder.yudao.module.mes.controller.admin.dv.repair.vo.MesDvRepairPageReqVO; | 6 | import cn.iocoder.yudao.module.mes.controller.admin.dv.repair.vo.MesDvRepairPageReqVO; |
| @@ -7,6 +8,7 @@ import cn.iocoder.yudao.module.mes.controller.admin.dv.repair.vo.MesDvRepairSave | @@ -7,6 +8,7 @@ import cn.iocoder.yudao.module.mes.controller.admin.dv.repair.vo.MesDvRepairSave | ||
| 7 | import cn.iocoder.yudao.module.mes.dal.dataobject.dv.repair.MesDvRepairDO; | 8 | import cn.iocoder.yudao.module.mes.dal.dataobject.dv.repair.MesDvRepairDO; |
| 8 | import cn.iocoder.yudao.module.mes.dal.mysql.dv.repair.MesDvRepairLineMapper; | 9 | import cn.iocoder.yudao.module.mes.dal.mysql.dv.repair.MesDvRepairLineMapper; |
| 9 | import cn.iocoder.yudao.module.mes.dal.mysql.dv.repair.MesDvRepairMapper; | 10 | import cn.iocoder.yudao.module.mes.dal.mysql.dv.repair.MesDvRepairMapper; |
| 11 | +import cn.iocoder.yudao.module.mes.enums.dv.MesDvRepairStatusEnum; | ||
| 10 | import cn.iocoder.yudao.module.mes.service.dv.machinery.MesDvMachineryService; | 12 | import cn.iocoder.yudao.module.mes.service.dv.machinery.MesDvMachineryService; |
| 11 | import jakarta.annotation.Resource; | 13 | import jakarta.annotation.Resource; |
| 12 | import org.springframework.stereotype.Service; | 14 | import org.springframework.stereotype.Service; |
| @@ -39,29 +41,28 @@ public class MesDvRepairServiceImpl implements MesDvRepairService { | @@ -39,29 +41,28 @@ public class MesDvRepairServiceImpl implements MesDvRepairService { | ||
| 39 | 41 | ||
| 40 | // 2. 插入 | 42 | // 2. 插入 |
| 41 | MesDvRepairDO repair = BeanUtils.toBean(createReqVO, MesDvRepairDO.class); | 43 | MesDvRepairDO repair = BeanUtils.toBean(createReqVO, MesDvRepairDO.class); |
| 42 | - // TODO @AI:status | 44 | + repair.setStatus(MesDvRepairStatusEnum.DRAFT.getStatus()); |
| 43 | repairMapper.insert(repair); | 45 | repairMapper.insert(repair); |
| 44 | return repair.getId(); | 46 | return repair.getId(); |
| 45 | } | 47 | } |
| 46 | 48 | ||
| 47 | @Override | 49 | @Override |
| 48 | public void updateRepair(MesDvRepairSaveReqVO updateReqVO) { | 50 | public void updateRepair(MesDvRepairSaveReqVO updateReqVO) { |
| 49 | - // 1.1 校验存在 | ||
| 50 | - validateRepairExists(updateReqVO.getId()); | 51 | + // 1.1 校验存在,且状态为草稿 |
| 52 | + validateRepairDraft(updateReqVO.getId()); | ||
| 51 | // 1.2 校验关联数据 | 53 | // 1.2 校验关联数据 |
| 52 | validateRepairRelation(updateReqVO); | 54 | validateRepairRelation(updateReqVO); |
| 53 | 55 | ||
| 54 | // 2. 更新 | 56 | // 2. 更新 |
| 55 | MesDvRepairDO updateObj = BeanUtils.toBean(updateReqVO, MesDvRepairDO.class); | 57 | MesDvRepairDO updateObj = BeanUtils.toBean(updateReqVO, MesDvRepairDO.class); |
| 56 | - // TODO @AI:status | ||
| 57 | repairMapper.updateById(updateObj); | 58 | repairMapper.updateById(updateObj); |
| 58 | } | 59 | } |
| 59 | 60 | ||
| 60 | @Override | 61 | @Override |
| 61 | @Transactional(rollbackFor = Exception.class) | 62 | @Transactional(rollbackFor = Exception.class) |
| 62 | public void deleteRepair(Long id) { | 63 | public void deleteRepair(Long id) { |
| 63 | - // 校验存在 | ||
| 64 | - validateRepairExists(id); | 64 | + // 校验存在,且状态为草稿 |
| 65 | + validateRepairDraft(id); | ||
| 65 | 66 | ||
| 66 | // 删除 | 67 | // 删除 |
| 67 | repairMapper.deleteById(id); | 68 | repairMapper.deleteById(id); |
| @@ -81,6 +82,23 @@ public class MesDvRepairServiceImpl implements MesDvRepairService { | @@ -81,6 +82,23 @@ public class MesDvRepairServiceImpl implements MesDvRepairService { | ||
| 81 | } | 82 | } |
| 82 | } | 83 | } |
| 83 | 84 | ||
| 85 | + /** | ||
| 86 | + * 校验维修工单是否为草稿状态 | ||
| 87 | + * | ||
| 88 | + * @param id 编号 | ||
| 89 | + * @return 维修工单 | ||
| 90 | + */ | ||
| 91 | + public MesDvRepairDO validateRepairDraft(Long id) { | ||
| 92 | + MesDvRepairDO repair = repairMapper.selectById(id); | ||
| 93 | + if (repair == null) { | ||
| 94 | + throw exception(DV_REPAIR_NOT_EXISTS); | ||
| 95 | + } | ||
| 96 | + if (ObjUtil.notEqual(MesDvRepairStatusEnum.DRAFT.getStatus(), repair.getStatus())) { | ||
| 97 | + throw exception(DV_REPAIR_NOT_DRAFT); | ||
| 98 | + } | ||
| 99 | + return repair; | ||
| 100 | + } | ||
| 101 | + | ||
| 84 | @Override | 102 | @Override |
| 85 | public MesDvRepairDO getRepair(Long id) { | 103 | public MesDvRepairDO getRepair(Long id) { |
| 86 | return repairMapper.selectById(id); | 104 | return repairMapper.selectById(id); |