Commit c599198eff37a95292bef939ef34423b485c5b62
1 parent
3b7956cc
✨ feat(mes): 更新维修工单流程及状态管理
新增维修工单提交、确认和完成验收功能,优化状态流转逻辑。 - 提交维修工单时记录当前用户 - 完成维修后更新状态为待验收 - 完成验收时支持通过与不通过的结果记录 确保维修工单的状态管理更加清晰,提升用户体验
Showing
7 changed files
with
44 additions
and
66 deletions
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/repair/MesDvRepairController.java
| ... | ... | @@ -19,6 +19,7 @@ import cn.iocoder.yudao.module.system.api.user.AdminUserApi; |
| 19 | 19 | import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; |
| 20 | 20 | import io.swagger.v3.oas.annotations.Operation; |
| 21 | 21 | import io.swagger.v3.oas.annotations.Parameter; |
| 22 | +import io.swagger.v3.oas.annotations.Parameters; | |
| 22 | 23 | import io.swagger.v3.oas.annotations.tags.Tag; |
| 23 | 24 | import jakarta.annotation.Resource; |
| 24 | 25 | import jakarta.servlet.http.HttpServletResponse; |
| ... | ... | @@ -37,6 +38,7 @@ import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPOR |
| 37 | 38 | import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; |
| 38 | 39 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; |
| 39 | 40 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSetByFlatMap; |
| 41 | +import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | |
| 40 | 42 | |
| 41 | 43 | @Tag(name = "管理后台 - MES 维修工单") |
| 42 | 44 | @RestController |
| ... | ... | @@ -110,28 +112,19 @@ public class MesDvRepairController { |
| 110 | 112 | buildRepairRespVOList(list)); |
| 111 | 113 | } |
| 112 | 114 | |
| 115 | + // DONE @AI:submit=>confirm=>finish(然后里面有是 resultstatus 这样的字段【对齐实体?】) | |
| 116 | + | |
| 113 | 117 | @PutMapping("/submit") |
| 114 | 118 | @Operation(summary = "提交维修工单(草稿→维修中)") |
| 115 | 119 | @Parameter(name = "id", description = "编号", required = true) |
| 116 | 120 | @PreAuthorize("@ss.hasPermission('mes:dv-repair:update')") |
| 117 | 121 | public CommonResult<Boolean> submitRepair(@RequestParam("id") Long id) { |
| 118 | - repairService.submitRepair(id); | |
| 119 | - return success(true); | |
| 120 | - } | |
| 121 | - | |
| 122 | - // TODO @AI:submit=>confirm=>finish(然后里面有是 resultstatus 这样的字段【对齐实体?】) | |
| 123 | - | |
| 124 | - @PutMapping("/finish") | |
| 125 | - @Operation(summary = "完成维修(维修中→待验收)") | |
| 126 | - @Parameter(name = "id", description = "编号", required = true) | |
| 127 | - @PreAuthorize("@ss.hasPermission('mes:dv-repair:update')") | |
| 128 | - public CommonResult<Boolean> finishRepair(@RequestParam("id") Long id) { | |
| 129 | - repairService.finishRepair(id); | |
| 122 | + repairService.submitRepair(id, getLoginUserId()); | |
| 130 | 123 | return success(true); |
| 131 | 124 | } |
| 132 | 125 | |
| 133 | 126 | @PutMapping("/confirm") |
| 134 | - @Operation(summary = "验收通过(待验收→已确认,结果=通过)") | |
| 127 | + @Operation(summary = "确认维修完成(维修中→待验收)") | |
| 135 | 128 | @Parameter(name = "id", description = "编号", required = true) |
| 136 | 129 | @PreAuthorize("@ss.hasPermission('mes:dv-repair:update')") |
| 137 | 130 | public CommonResult<Boolean> confirmRepair(@RequestParam("id") Long id) { |
| ... | ... | @@ -139,12 +132,16 @@ public class MesDvRepairController { |
| 139 | 132 | return success(true); |
| 140 | 133 | } |
| 141 | 134 | |
| 142 | - @PutMapping("/reject") | |
| 143 | - @Operation(summary = "验收不通过(待验收→已确认,结果=不通过)") | |
| 144 | - @Parameter(name = "id", description = "编号", required = true) | |
| 135 | + @PutMapping("/finish") | |
| 136 | + @Operation(summary = "完成验收(待验收→已确认)") | |
| 137 | + @Parameters({ | |
| 138 | + @Parameter(name = "id", description = "编号", required = true), | |
| 139 | + @Parameter(name = "result", description = "验收结果", required = true) | |
| 140 | + }) | |
| 145 | 141 | @PreAuthorize("@ss.hasPermission('mes:dv-repair:update')") |
| 146 | - public CommonResult<Boolean> rejectRepair(@RequestParam("id") Long id) { | |
| 147 | - repairService.rejectRepair(id); | |
| 142 | + public CommonResult<Boolean> finishRepair(@RequestParam("id") Long id, | |
| 143 | + @RequestParam("result") Integer result) { | |
| 144 | + repairService.finishRepair(id, result, getLoginUserId()); | |
| 148 | 145 | return success(true); |
| 149 | 146 | } |
| 150 | 147 | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/repair/vo/MesDvRepairSaveReqVO.java
| ... | ... | @@ -25,7 +25,8 @@ public class MesDvRepairSaveReqVO { |
| 25 | 25 | @NotNull(message = "设备不能为空") |
| 26 | 26 | private Long machineryId; |
| 27 | 27 | |
| 28 | - @Schema(description = "报修日期") | |
| 28 | + @Schema(description = "报修日期", requiredMode = Schema.RequiredMode.REQUIRED) | |
| 29 | + @NotNull(message = "报修日期不能为空") | |
| 29 | 30 | private LocalDateTime requireDate; |
| 30 | 31 | |
| 31 | 32 | @Schema(description = "维修完成日期") | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/dv/repair/MesDvRepairDO.java
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/dv/MesDvRepairStatusEnum.java
| ... | ... | @@ -2,6 +2,7 @@ package cn.iocoder.yudao.module.mes.enums.dv; |
| 2 | 2 | |
| 3 | 3 | import cn.iocoder.yudao.framework.common.core.ArrayValuable; |
| 4 | 4 | import cn.iocoder.yudao.module.mes.enums.MesOrderStatusConstants; |
| 5 | +import cn.iocoder.yudao.module.mes.service.dv.repair.MesDvRepairService; | |
| 5 | 6 | import lombok.AllArgsConstructor; |
| 6 | 7 | import lombok.Getter; |
| 7 | 8 | |
| ... | ... | @@ -18,25 +19,28 @@ import java.util.Arrays; |
| 18 | 19 | @AllArgsConstructor |
| 19 | 20 | public enum MesDvRepairStatusEnum implements ArrayValuable<Integer> { |
| 20 | 21 | |
| 21 | - // TODO @AI:不用 ktg 的注释,里面需要 @ 对应方法,对齐现有项目的规范; | |
| 22 | 22 | /** |
| 23 | 23 | * 草稿 |
| 24 | + * | |
| 25 | + * 对应方法:{@link MesDvRepairService#createRepair} | |
| 24 | 26 | */ |
| 25 | 27 | PREPARE(MesOrderStatusConstants.PREPARE, "草稿"), |
| 26 | 28 | /** |
| 27 | 29 | * 维修中(提交后,维修人接单) |
| 30 | + * | |
| 31 | + * 对应方法:{@link MesDvRepairService#submitRepair(Long, Long)} | |
| 28 | 32 | */ |
| 29 | 33 | CONFIRMED(MesOrderStatusConstants.CONFIRMED, "维修中"), |
| 30 | 34 | /** |
| 31 | 35 | * 待验收(维修完成,等待验收) |
| 32 | 36 | * |
| 33 | - * 对应 KTG: FINISHED | |
| 37 | + * 对应方法:{@link MesDvRepairService#confirmRepair(Long)} | |
| 34 | 38 | */ |
| 35 | 39 | APPROVING(MesOrderStatusConstants.APPROVING, "待验收"), |
| 36 | 40 | /** |
| 37 | 41 | * 已确认(验收通过或不通过,终态) |
| 38 | 42 | * |
| 39 | - * 对应 KTG: CONFIRMED | |
| 43 | + * 对应方法:{@link MesDvRepairService#finishRepair(Long, Integer, Long)} | |
| 40 | 44 | */ |
| 41 | 45 | FINISHED(MesOrderStatusConstants.FINISHED, "已确认"); |
| 42 | 46 | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/md/autocode/MesMdAutoCodeRuleCodeEnum.java
| ... | ... | @@ -40,7 +40,11 @@ public enum MesMdAutoCodeRuleCodeEnum { |
| 40 | 40 | WM_OUTSOURCE_ISSUE_CODE("WM_OUTSOURCE_ISSUE_CODE", "外协发料单编码"), |
| 41 | 41 | DV_MACHINERY_CODE("DV_MACHINERY_CODE", "设备编码"), |
| 42 | 42 | DV_MACHINERY_TYPE_CODE("DV_MACHINERY_TYPE_CODE", "设备类型编码"), |
| 43 | - DV_SUBJECT_CODE("DV_SUBJECT_CODE", "点检保养项目编码"); | |
| 43 | + DV_SUBJECT_CODE("DV_SUBJECT_CODE", "点检保养项目编码"), | |
| 44 | + DV_REPAIR_CODE("DV_REPAIR_CODE", "维修单编码"), | |
| 45 | + WM_SALES_NOTICE_CODE("WM_SALES_NOTICE_CODE", "发货通知单编码"), | |
| 46 | + WM_RETURN_SALES_CODE("WM_RETURN_SALES_CODE", "销售退货单编码"), | |
| 47 | + WM_MISC_ISSUE_CODE("WM_MISC_ISSUE_CODE", "杂项出库单编码"); | |
| 44 | 48 | |
| 45 | 49 | /** |
| 46 | 50 | * 规则代码 | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/repair/MesDvRepairService.java
| ... | ... | @@ -73,27 +73,22 @@ public interface MesDvRepairService { |
| 73 | 73 | * |
| 74 | 74 | * @param id 编号 |
| 75 | 75 | */ |
| 76 | - void submitRepair(Long id); | |
| 76 | + void submitRepair(Long id, Long userId); | |
| 77 | 77 | |
| 78 | 78 | /** |
| 79 | - * 完成维修(维修中→待验收) | |
| 80 | - * | |
| 81 | - * @param id 编号 | |
| 82 | - */ | |
| 83 | - void finishRepair(Long id); | |
| 84 | - | |
| 85 | - /** | |
| 86 | - * 验收通过(待验收→已确认,结果=通过) | |
| 79 | + * 确认维修完成(维修中→待验收) | |
| 87 | 80 | * |
| 88 | 81 | * @param id 编号 |
| 89 | 82 | */ |
| 90 | 83 | void confirmRepair(Long id); |
| 91 | 84 | |
| 92 | 85 | /** |
| 93 | - * 验收不通过(待验收→已确认,结果=不通过) | |
| 86 | + * 完成验收(待验收→已确认) | |
| 94 | 87 | * |
| 95 | 88 | * @param id 编号 |
| 89 | + * @param result 验收结果 | |
| 90 | + * @param userId 当前登录用户编号 | |
| 96 | 91 | */ |
| 97 | - void rejectRepair(Long id); | |
| 92 | + void finishRepair(Long id, Integer result, Long userId); | |
| 98 | 93 | |
| 99 | 94 | } | ... | ... |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/repair/MesDvRepairServiceImpl.java
| ... | ... | @@ -7,7 +7,6 @@ import cn.iocoder.yudao.module.mes.controller.admin.dv.repair.vo.MesDvRepairPage |
| 7 | 7 | import cn.iocoder.yudao.module.mes.controller.admin.dv.repair.vo.MesDvRepairSaveReqVO; |
| 8 | 8 | import cn.iocoder.yudao.module.mes.dal.dataobject.dv.repair.MesDvRepairDO; |
| 9 | 9 | import cn.iocoder.yudao.module.mes.dal.mysql.dv.repair.MesDvRepairMapper; |
| 10 | -import cn.iocoder.yudao.module.mes.enums.dv.MesDvRepairResultEnum; | |
| 11 | 10 | import cn.iocoder.yudao.module.mes.enums.dv.MesDvRepairStatusEnum; |
| 12 | 11 | import cn.iocoder.yudao.module.mes.service.dv.machinery.MesDvMachineryService; |
| 13 | 12 | import jakarta.annotation.Resource; |
| ... | ... | @@ -18,7 +17,6 @@ import org.springframework.validation.annotation.Validated; |
| 18 | 17 | import java.time.LocalDateTime; |
| 19 | 18 | |
| 20 | 19 | import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; |
| 21 | -import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId; | |
| 22 | 20 | import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; |
| 23 | 21 | |
| 24 | 22 | /** |
| ... | ... | @@ -136,18 +134,17 @@ public class MesDvRepairServiceImpl implements MesDvRepairService { |
| 136 | 134 | } |
| 137 | 135 | |
| 138 | 136 | @Override |
| 139 | - public void submitRepair(Long id) { | |
| 137 | + public void submitRepair(Long id, Long userId) { | |
| 140 | 138 | // 1. 校验存在,且状态为草稿 |
| 141 | 139 | validateRepairPrepare(id); |
| 142 | 140 | |
| 143 | - // 2. 更新状态为维修中,自动设置维修人为当前用户 | |
| 141 | + // 2. 更新状态为维修中,设置维修人 | |
| 144 | 142 | repairMapper.updateById(new MesDvRepairDO().setId(id) |
| 145 | - .setStatus(MesDvRepairStatusEnum.CONFIRMED.getStatus()) | |
| 146 | - .setAcceptedUserId(getLoginUserId())); | |
| 143 | + .setStatus(MesDvRepairStatusEnum.CONFIRMED.getStatus()).setAcceptedUserId(userId)); | |
| 147 | 144 | } |
| 148 | 145 | |
| 149 | 146 | @Override |
| 150 | - public void finishRepair(Long id) { | |
| 147 | + public void confirmRepair(Long id) { | |
| 151 | 148 | // 1. 校验存在,且状态为维修中 |
| 152 | 149 | MesDvRepairDO repair = validateRepairExists(id); |
| 153 | 150 | if (ObjUtil.notEqual(MesDvRepairStatusEnum.CONFIRMED.getStatus(), repair.getStatus())) { |
| ... | ... | @@ -156,40 +153,21 @@ public class MesDvRepairServiceImpl implements MesDvRepairService { |
| 156 | 153 | |
| 157 | 154 | // 2. 更新状态为待验收,自动设置维修完成日期 |
| 158 | 155 | repairMapper.updateById(new MesDvRepairDO().setId(id) |
| 159 | - .setStatus(MesDvRepairStatusEnum.APPROVING.getStatus()) | |
| 160 | - .setFinishDate(LocalDateTime.now())); | |
| 161 | - } | |
| 162 | - | |
| 163 | - @Override | |
| 164 | - public void confirmRepair(Long id) { | |
| 165 | - // 1. 校验存在,且状态为待验收 | |
| 166 | - MesDvRepairDO repair = validateRepairExists(id); | |
| 167 | - if (ObjUtil.notEqual(MesDvRepairStatusEnum.APPROVING.getStatus(), repair.getStatus())) { | |
| 168 | - throw exception(DV_REPAIR_NOT_APPROVING); | |
| 169 | - } | |
| 170 | - | |
| 171 | - // 2. 更新状态为已确认,结果为通过,自动设置验收人和验收日期 | |
| 172 | - repairMapper.updateById(new MesDvRepairDO().setId(id) | |
| 173 | - .setStatus(MesDvRepairStatusEnum.FINISHED.getStatus()) | |
| 174 | - .setResult(MesDvRepairResultEnum.PASS.getResult()) | |
| 175 | - .setConfirmUserId(getLoginUserId()) | |
| 176 | - .setConfirmDate(LocalDateTime.now())); | |
| 156 | + .setStatus(MesDvRepairStatusEnum.APPROVING.getStatus()).setFinishDate(LocalDateTime.now())); | |
| 177 | 157 | } |
| 178 | 158 | |
| 179 | 159 | @Override |
| 180 | - public void rejectRepair(Long id) { | |
| 160 | + public void finishRepair(Long id, Integer result, Long userId) { | |
| 181 | 161 | // 1. 校验存在,且状态为待验收 |
| 182 | 162 | MesDvRepairDO repair = validateRepairExists(id); |
| 183 | 163 | if (ObjUtil.notEqual(MesDvRepairStatusEnum.APPROVING.getStatus(), repair.getStatus())) { |
| 184 | 164 | throw exception(DV_REPAIR_NOT_APPROVING); |
| 185 | 165 | } |
| 186 | 166 | |
| 187 | - // 2. 更新状态为已确认,结果为不通过,自动设置验收人和验收日期 | |
| 167 | + // 2. 更新状态为已确认,设置验收结果、验收人和验收日期 | |
| 188 | 168 | repairMapper.updateById(new MesDvRepairDO().setId(id) |
| 189 | - .setStatus(MesDvRepairStatusEnum.FINISHED.getStatus()) | |
| 190 | - .setResult(MesDvRepairResultEnum.FAIL.getResult()) | |
| 191 | - .setConfirmUserId(getLoginUserId()) | |
| 192 | - .setConfirmDate(LocalDateTime.now())); | |
| 169 | + .setStatus(MesDvRepairStatusEnum.FINISHED.getStatus()).setResult(result) | |
| 170 | + .setConfirmUserId(userId).setConfirmDate(LocalDateTime.now())); | |
| 193 | 171 | } |
| 194 | 172 | |
| 195 | 173 | } | ... | ... |