Commit 3b7956cc754e70199f21568ea0bf201d6b544056

Authored by YunaiV
1 parent fd3a556d

✨ feat(mes): 新增维修工单状态流转功能

实现维修工单的状态流转,包括提交、完成维修和验收功能。新增相关接口和状态枚举,优化了维修工单的管理流程,确保状态的准确性和一致性。
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/repair/MesDvRepairController.java
@@ -31,7 +31,6 @@ import java.io.IOException; @@ -31,7 +31,6 @@ import java.io.IOException;
31 import java.util.Collections; 31 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;  
35 import java.util.stream.Stream; 34 import java.util.stream.Stream;
36 35
37 import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; 36 import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
@@ -111,8 +110,28 @@ public class MesDvRepairController { @@ -111,8 +110,28 @@ public class MesDvRepairController {
111 buildRepairRespVOList(list)); 110 buildRepairRespVOList(list));
112 } 111 }
113 112
  113 + @PutMapping("/submit")
  114 + @Operation(summary = "提交维修工单(草稿→维修中)")
  115 + @Parameter(name = "id", description = "编号", required = true)
  116 + @PreAuthorize("@ss.hasPermission('mes:dv-repair:update')")
  117 + 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);
  130 + return success(true);
  131 + }
  132 +
114 @PutMapping("/confirm") 133 @PutMapping("/confirm")
115 - @Operation(summary = "通过维修工单(草稿→已确认,结果=通过)") 134 + @Operation(summary = "验收通过(待验收→已确认,结果=通过)")
116 @Parameter(name = "id", description = "编号", required = true) 135 @Parameter(name = "id", description = "编号", required = true)
117 @PreAuthorize("@ss.hasPermission('mes:dv-repair:update')") 136 @PreAuthorize("@ss.hasPermission('mes:dv-repair:update')")
118 public CommonResult<Boolean> confirmRepair(@RequestParam("id") Long id) { 137 public CommonResult<Boolean> confirmRepair(@RequestParam("id") Long id) {
@@ -121,7 +140,7 @@ public class MesDvRepairController { @@ -121,7 +140,7 @@ public class MesDvRepairController {
121 } 140 }
122 141
123 @PutMapping("/reject") 142 @PutMapping("/reject")
124 - @Operation(summary = "不通过维修工单(草稿→已确认,结果=不通过)") 143 + @Operation(summary = "验收不通过(待验收→已确认,结果=不通过)")
125 @Parameter(name = "id", description = "编号", required = true) 144 @Parameter(name = "id", description = "编号", required = true)
126 @PreAuthorize("@ss.hasPermission('mes:dv-repair:update')") 145 @PreAuthorize("@ss.hasPermission('mes:dv-repair:update')")
127 public CommonResult<Boolean> rejectRepair(@RequestParam("id") Long id) { 146 public CommonResult<Boolean> rejectRepair(@RequestParam("id") Long id) {
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/dv/repair/MesDvRepairDO.java
@@ -76,7 +76,7 @@ public class MesDvRepairDO extends BaseDO { @@ -76,7 +76,7 @@ public class MesDvRepairDO extends BaseDO {
76 * 关联 AdminUserDO#getId() 76 * 关联 AdminUserDO#getId()
77 */ 77 */
78 private Long confirmUserId; 78 private Long confirmUserId;
79 - // TODO @芋艿:sourceDocType、sourceDocId、sourceDocCode 需要哪里处理; 79 + // DONE @芋艿:sourceDocType、sourceDocId、sourceDocCode 为预留字段,对齐:暂未使用
80 /** 80 /**
81 * 来源单据类型 81 * 来源单据类型
82 */ 82 */
@@ -93,7 +93,6 @@ public class MesDvRepairDO extends BaseDO { @@ -93,7 +93,6 @@ public class MesDvRepairDO extends BaseDO {
93 * 状态 93 * 状态
94 * 94 *
95 * 枚举 {@link MesDvRepairStatusEnum} 95 * 枚举 {@link MesDvRepairStatusEnum}
96 - * 字典类型 mes_dv_repair_status  
97 */ 96 */
98 private Integer status; 97 private Integer status;
99 /** 98 /**
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/ErrorCodeConstants.java
@@ -177,8 +177,10 @@ public interface ErrorCodeConstants { @@ -177,8 +177,10 @@ public interface ErrorCodeConstants {
177 177
178 // ========== MES 设备管理-维修工单(1-040-303-000) ========== 178 // ========== MES 设备管理-维修工单(1-040-303-000) ==========
179 ErrorCode DV_REPAIR_NOT_EXISTS = new ErrorCode(1_040_303_000, "维修工单不存在"); 179 ErrorCode DV_REPAIR_NOT_EXISTS = new ErrorCode(1_040_303_000, "维修工单不存在");
180 - ErrorCode DV_REPAIR_NOT_DRAFT = new ErrorCode(1_040_303_001, "维修工单已确认,不允许修改或删除"); 180 + ErrorCode DV_REPAIR_NOT_PREPARE = new ErrorCode(1_040_303_001, "维修工单不是草稿状态,不允许修改或删除");
181 ErrorCode DV_REPAIR_CODE_DUPLICATE = new ErrorCode(1_040_303_002, "维修工单编码已存在"); 181 ErrorCode DV_REPAIR_CODE_DUPLICATE = new ErrorCode(1_040_303_002, "维修工单编码已存在");
  182 + ErrorCode DV_REPAIR_NOT_CONFIRMED = new ErrorCode(1_040_303_003, "只有维修中状态的维修工单才能完成维修");
  183 + ErrorCode DV_REPAIR_NOT_APPROVING = new ErrorCode(1_040_303_004, "只有待验收状态的维修工单才能验收");
182 // ========== MES 设备管理-维修工单行(1-040-303-100) ========== 184 // ========== MES 设备管理-维修工单行(1-040-303-100) ==========
183 ErrorCode DV_REPAIR_LINE_NOT_EXISTS = new ErrorCode(1_040_303_100, "维修工单行不存在"); 185 ErrorCode DV_REPAIR_LINE_NOT_EXISTS = new ErrorCode(1_040_303_100, "维修工单行不存在");
184 186
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/dv/MesDvRepairStatusEnum.java
1 package cn.iocoder.yudao.module.mes.enums.dv; 1 package cn.iocoder.yudao.module.mes.enums.dv;
2 2
3 import cn.iocoder.yudao.framework.common.core.ArrayValuable; 3 import cn.iocoder.yudao.framework.common.core.ArrayValuable;
  4 +import cn.iocoder.yudao.module.mes.enums.MesOrderStatusConstants;
4 import lombok.AllArgsConstructor; 5 import lombok.AllArgsConstructor;
5 import lombok.Getter; 6 import lombok.Getter;
6 7
@@ -9,14 +10,35 @@ import java.util.Arrays; @@ -9,14 +10,35 @@ import java.util.Arrays;
9 /** 10 /**
10 * MES 维修工单状态枚举 11 * MES 维修工单状态枚举
11 * 12 *
  13 + * 状态流转:草稿 → 维修中 → 待验收 → 已确认
  14 + *
12 * @author 芋道源码 15 * @author 芋道源码
13 */ 16 */
14 @Getter 17 @Getter
15 @AllArgsConstructor 18 @AllArgsConstructor
16 public enum MesDvRepairStatusEnum implements ArrayValuable<Integer> { 19 public enum MesDvRepairStatusEnum implements ArrayValuable<Integer> {
17 20
18 - DRAFT(10, "草稿"),  
19 - CONFIRMED(20, "已确认"); 21 + // TODO @AI:不用 ktg 的注释,里面需要 @ 对应方法,对齐现有项目的规范;
  22 + /**
  23 + * 草稿
  24 + */
  25 + PREPARE(MesOrderStatusConstants.PREPARE, "草稿"),
  26 + /**
  27 + * 维修中(提交后,维修人接单)
  28 + */
  29 + CONFIRMED(MesOrderStatusConstants.CONFIRMED, "维修中"),
  30 + /**
  31 + * 待验收(维修完成,等待验收)
  32 + *
  33 + * 对应 KTG: FINISHED
  34 + */
  35 + APPROVING(MesOrderStatusConstants.APPROVING, "待验收"),
  36 + /**
  37 + * 已确认(验收通过或不通过,终态)
  38 + *
  39 + * 对应 KTG: CONFIRMED
  40 + */
  41 + FINISHED(MesOrderStatusConstants.FINISHED, "已确认");
20 42
21 public static final Integer[] ARRAYS = Arrays.stream(values()).map(MesDvRepairStatusEnum::getStatus).toArray(Integer[]::new); 43 public static final Integer[] ARRAYS = Arrays.stream(values()).map(MesDvRepairStatusEnum::getStatus).toArray(Integer[]::new);
22 44
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/repair/MesDvRepairLineServiceImpl.java
@@ -38,7 +38,7 @@ public class MesDvRepairLineServiceImpl implements MesDvRepairLineService { @@ -38,7 +38,7 @@ public class MesDvRepairLineServiceImpl implements MesDvRepairLineService {
38 // 1.1 校验关联数据 38 // 1.1 校验关联数据
39 validateRepairLineRelation(createReqVO); 39 validateRepairLineRelation(createReqVO);
40 // 1.2 校验维修工单为草稿状态 40 // 1.2 校验维修工单为草稿状态
41 - repairService.validateRepairDraft(createReqVO.getRepairId()); 41 + repairService.validateRepairPrepare(createReqVO.getRepairId());
42 42
43 // 2. 插入 43 // 2. 插入
44 MesDvRepairLineDO repairLine = BeanUtils.toBean(createReqVO, MesDvRepairLineDO.class); 44 MesDvRepairLineDO repairLine = BeanUtils.toBean(createReqVO, MesDvRepairLineDO.class);
@@ -53,7 +53,7 @@ public class MesDvRepairLineServiceImpl implements MesDvRepairLineService { @@ -53,7 +53,7 @@ public class MesDvRepairLineServiceImpl implements MesDvRepairLineService {
53 // 1.2 校验关联数据 53 // 1.2 校验关联数据
54 validateRepairLineRelation(updateReqVO); 54 validateRepairLineRelation(updateReqVO);
55 // 1.3 校验维修工单为草稿状态 55 // 1.3 校验维修工单为草稿状态
56 - repairService.validateRepairDraft(updateReqVO.getRepairId()); 56 + repairService.validateRepairPrepare(updateReqVO.getRepairId());
57 57
58 // 2. 更新 58 // 2. 更新
59 MesDvRepairLineDO updateObj = BeanUtils.toBean(updateReqVO, MesDvRepairLineDO.class); 59 MesDvRepairLineDO updateObj = BeanUtils.toBean(updateReqVO, MesDvRepairLineDO.class);
@@ -68,7 +68,7 @@ public class MesDvRepairLineServiceImpl implements MesDvRepairLineService { @@ -68,7 +68,7 @@ public class MesDvRepairLineServiceImpl implements MesDvRepairLineService {
68 throw exception(DV_REPAIR_LINE_NOT_EXISTS); 68 throw exception(DV_REPAIR_LINE_NOT_EXISTS);
69 } 69 }
70 // 1.2 校验维修工单为草稿状态 70 // 1.2 校验维修工单为草稿状态
71 - repairService.validateRepairDraft(line.getRepairId()); 71 + repairService.validateRepairPrepare(line.getRepairId());
72 72
73 // 2. 删除 73 // 2. 删除
74 repairLineMapper.deleteById(id); 74 repairLineMapper.deleteById(id);
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/repair/MesDvRepairService.java
@@ -40,8 +40,9 @@ public interface MesDvRepairService { @@ -40,8 +40,9 @@ public interface MesDvRepairService {
40 * 校验维修工单是否存在 40 * 校验维修工单是否存在
41 * 41 *
42 * @param id 编号 42 * @param id 编号
  43 + * @return 维修工单
43 */ 44 */
44 - void validateRepairExists(Long id); 45 + MesDvRepairDO validateRepairExists(Long id);
45 46
46 /** 47 /**
47 * 获得指定设备的维修工单数量 48 * 获得指定设备的维修工单数量
@@ -68,14 +69,28 @@ public interface MesDvRepairService { @@ -68,14 +69,28 @@ public interface MesDvRepairService {
68 PageResult<MesDvRepairDO> getRepairPage(MesDvRepairPageReqVO pageReqVO); 69 PageResult<MesDvRepairDO> getRepairPage(MesDvRepairPageReqVO pageReqVO);
69 70
70 /** 71 /**
71 - * 通过维修工单(草稿→已确认,结果=通过) 72 + * 提交维修工单(草稿→维修中)
  73 + *
  74 + * @param id 编号
  75 + */
  76 + void submitRepair(Long id);
  77 +
  78 + /**
  79 + * 完成维修(维修中→待验收)
  80 + *
  81 + * @param id 编号
  82 + */
  83 + void finishRepair(Long id);
  84 +
  85 + /**
  86 + * 验收通过(待验收→已确认,结果=通过)
72 * 87 *
73 * @param id 编号 88 * @param id 编号
74 */ 89 */
75 void confirmRepair(Long id); 90 void confirmRepair(Long id);
76 91
77 /** 92 /**
78 - * 不通过维修工单(草稿→已确认,结果=不通过) 93 + * 验收不通过(待验收→已确认,结果=不通过)
79 * 94 *
80 * @param id 编号 95 * @param id 编号
81 */ 96 */
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/repair/MesDvRepairServiceImpl.java
@@ -18,6 +18,7 @@ import org.springframework.validation.annotation.Validated; @@ -18,6 +18,7 @@ import org.springframework.validation.annotation.Validated;
18 import java.time.LocalDateTime; 18 import java.time.LocalDateTime;
19 19
20 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; 20 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
  21 +import static cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils.getLoginUserId;
21 import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; 22 import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*;
22 23
23 /** 24 /**
@@ -39,15 +40,12 @@ public class MesDvRepairServiceImpl implements MesDvRepairService { @@ -39,15 +40,12 @@ public class MesDvRepairServiceImpl implements MesDvRepairService {
39 40
40 @Override 41 @Override
41 public Long createRepair(MesDvRepairSaveReqVO createReqVO) { 42 public Long createRepair(MesDvRepairSaveReqVO createReqVO) {
42 - // TODO @AI:抽成 validateXXSaveData(vo);  
43 - // 1.1 校验关联数据  
44 - validateRepairRelation(createReqVO);  
45 - // 1.2 校验编码唯一  
46 - validateCodeUnique(null, createReqVO.getCode()); 43 + // 1. 校验保存数据
  44 + validateSaveData(createReqVO);
47 45
48 // 2. 插入 46 // 2. 插入
49 MesDvRepairDO repair = BeanUtils.toBean(createReqVO, MesDvRepairDO.class); 47 MesDvRepairDO repair = BeanUtils.toBean(createReqVO, MesDvRepairDO.class);
50 - repair.setStatus(MesDvRepairStatusEnum.DRAFT.getStatus()); 48 + repair.setStatus(MesDvRepairStatusEnum.PREPARE.getStatus());
51 repairMapper.insert(repair); 49 repairMapper.insert(repair);
52 return repair.getId(); 50 return repair.getId();
53 } 51 }
@@ -55,12 +53,9 @@ public class MesDvRepairServiceImpl implements MesDvRepairService { @@ -55,12 +53,9 @@ public class MesDvRepairServiceImpl implements MesDvRepairService {
55 @Override 53 @Override
56 public void updateRepair(MesDvRepairSaveReqVO updateReqVO) { 54 public void updateRepair(MesDvRepairSaveReqVO updateReqVO) {
57 // 1.1 校验存在,且状态为草稿 55 // 1.1 校验存在,且状态为草稿
58 - validateRepairDraft(updateReqVO.getId());  
59 - // TODO @AI:抽成 validateXXSaveData(vo);  
60 - // 1.2 校验关联数据  
61 - validateRepairRelation(updateReqVO);  
62 - // 1.3 校验编码唯一  
63 - validateCodeUnique(updateReqVO.getId(), updateReqVO.getCode()); 56 + validateRepairPrepare(updateReqVO.getId());
  57 + // 1.2 校验保存数据
  58 + validateSaveData(updateReqVO);
64 59
65 // 2. 更新 60 // 2. 更新
66 MesDvRepairDO updateObj = BeanUtils.toBean(updateReqVO, MesDvRepairDO.class); 61 MesDvRepairDO updateObj = BeanUtils.toBean(updateReqVO, MesDvRepairDO.class);
@@ -71,7 +66,7 @@ public class MesDvRepairServiceImpl implements MesDvRepairService { @@ -71,7 +66,7 @@ public class MesDvRepairServiceImpl implements MesDvRepairService {
71 @Transactional(rollbackFor = Exception.class) 66 @Transactional(rollbackFor = Exception.class)
72 public void deleteRepair(Long id) { 67 public void deleteRepair(Long id) {
73 // 校验存在,且状态为草稿 68 // 校验存在,且状态为草稿
74 - validateRepairDraft(id); 69 + validateRepairPrepare(id);
75 70
76 // 删除 71 // 删除
77 repairMapper.deleteById(id); 72 repairMapper.deleteById(id);
@@ -79,8 +74,13 @@ public class MesDvRepairServiceImpl implements MesDvRepairService { @@ -79,8 +74,13 @@ public class MesDvRepairServiceImpl implements MesDvRepairService {
79 repairLineService.deleteByRepairId(id); 74 repairLineService.deleteByRepairId(id);
80 } 75 }
81 76
82 - private void validateRepairRelation(MesDvRepairSaveReqVO reqVO) {  
83 - // 校验设备是否存在 77 + /**
  78 + * 校验保存时的关联数据
  79 + */
  80 + private void validateSaveData(MesDvRepairSaveReqVO reqVO) {
  81 + // 校验编码唯一
  82 + validateCodeUnique(reqVO.getId(), reqVO.getCode());
  83 + // 校验设备存在
84 machineryService.validateMachineryExists(reqVO.getMachineryId()); 84 machineryService.validateMachineryExists(reqVO.getMachineryId());
85 } 85 }
86 86
@@ -89,20 +89,21 @@ public class MesDvRepairServiceImpl implements MesDvRepairService { @@ -89,20 +89,21 @@ public class MesDvRepairServiceImpl implements MesDvRepairService {
89 return; 89 return;
90 } 90 }
91 MesDvRepairDO repair = repairMapper.selectByCode(code); 91 MesDvRepairDO repair = repairMapper.selectByCode(code);
92 - // TODO @AI:参考别的模块,notEquals  
93 if (repair == null) { 92 if (repair == null) {
94 return; 93 return;
95 } 94 }
96 - if (id == null || !id.equals(repair.getId())) { 95 + if (ObjUtil.notEqual(id, repair.getId())) {
97 throw exception(DV_REPAIR_CODE_DUPLICATE); 96 throw exception(DV_REPAIR_CODE_DUPLICATE);
98 } 97 }
99 } 98 }
100 99
101 @Override 100 @Override
102 - public void validateRepairExists(Long id) {  
103 - if (repairMapper.selectById(id) == null) { 101 + public MesDvRepairDO validateRepairExists(Long id) {
  102 + MesDvRepairDO repair = repairMapper.selectById(id);
  103 + if (repair == null) {
104 throw exception(DV_REPAIR_NOT_EXISTS); 104 throw exception(DV_REPAIR_NOT_EXISTS);
105 } 105 }
  106 + return repair;
106 } 107 }
107 108
108 @Override 109 @Override
@@ -116,14 +117,10 @@ public class MesDvRepairServiceImpl implements MesDvRepairService { @@ -116,14 +117,10 @@ public class MesDvRepairServiceImpl implements MesDvRepairService {
116 * @param id 编号 117 * @param id 编号
117 * @return 维修工单 118 * @return 维修工单
118 */ 119 */
119 - public MesDvRepairDO validateRepairDraft(Long id) {  
120 - // TODO @AI:复用 validateRepairExists 方法  
121 - MesDvRepairDO repair = repairMapper.selectById(id);  
122 - if (repair == null) {  
123 - throw exception(DV_REPAIR_NOT_EXISTS);  
124 - }  
125 - if (ObjUtil.notEqual(MesDvRepairStatusEnum.DRAFT.getStatus(), repair.getStatus())) {  
126 - throw exception(DV_REPAIR_NOT_DRAFT); 120 + public MesDvRepairDO validateRepairPrepare(Long id) {
  121 + MesDvRepairDO repair = validateRepairExists(id);
  122 + if (ObjUtil.notEqual(MesDvRepairStatusEnum.PREPARE.getStatus(), repair.getStatus())) {
  123 + throw exception(DV_REPAIR_NOT_PREPARE);
127 } 124 }
128 return repair; 125 return repair;
129 } 126 }
@@ -139,26 +136,59 @@ public class MesDvRepairServiceImpl implements MesDvRepairService { @@ -139,26 +136,59 @@ public class MesDvRepairServiceImpl implements MesDvRepairService {
139 } 136 }
140 137
141 @Override 138 @Override
142 - public void confirmRepair(Long id) { 139 + public void submitRepair(Long id) {
143 // 1. 校验存在,且状态为草稿 140 // 1. 校验存在,且状态为草稿
144 - validateRepairDraft(id); 141 + validateRepairPrepare(id);
145 142
146 - // 2. 更新状态为已确认,结果为通过,自动设置验收日期 143 + // 2. 更新状态为维修中,自动设置维修人为当前用户
147 repairMapper.updateById(new MesDvRepairDO().setId(id) 144 repairMapper.updateById(new MesDvRepairDO().setId(id)
148 .setStatus(MesDvRepairStatusEnum.CONFIRMED.getStatus()) 145 .setStatus(MesDvRepairStatusEnum.CONFIRMED.getStatus())
  146 + .setAcceptedUserId(getLoginUserId()));
  147 + }
  148 +
  149 + @Override
  150 + public void finishRepair(Long id) {
  151 + // 1. 校验存在,且状态为维修中
  152 + MesDvRepairDO repair = validateRepairExists(id);
  153 + if (ObjUtil.notEqual(MesDvRepairStatusEnum.CONFIRMED.getStatus(), repair.getStatus())) {
  154 + throw exception(DV_REPAIR_NOT_CONFIRMED);
  155 + }
  156 +
  157 + // 2. 更新状态为待验收,自动设置维修完成日期
  158 + 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())
149 .setResult(MesDvRepairResultEnum.PASS.getResult()) 174 .setResult(MesDvRepairResultEnum.PASS.getResult())
  175 + .setConfirmUserId(getLoginUserId())
150 .setConfirmDate(LocalDateTime.now())); 176 .setConfirmDate(LocalDateTime.now()));
151 } 177 }
152 178
153 @Override 179 @Override
154 public void rejectRepair(Long id) { 180 public void rejectRepair(Long id) {
155 - // 1. 校验存在,且状态为草稿  
156 - validateRepairDraft(id); 181 + // 1. 校验存在,且状态为待验收
  182 + MesDvRepairDO repair = validateRepairExists(id);
  183 + if (ObjUtil.notEqual(MesDvRepairStatusEnum.APPROVING.getStatus(), repair.getStatus())) {
  184 + throw exception(DV_REPAIR_NOT_APPROVING);
  185 + }
157 186
158 - // 2. 更新状态为已确认,结果为不通过,自动设置验收日期 187 + // 2. 更新状态为已确认,结果为不通过,自动设置验收人和验收日期
159 repairMapper.updateById(new MesDvRepairDO().setId(id) 188 repairMapper.updateById(new MesDvRepairDO().setId(id)
160 - .setStatus(MesDvRepairStatusEnum.CONFIRMED.getStatus()) 189 + .setStatus(MesDvRepairStatusEnum.FINISHED.getStatus())
161 .setResult(MesDvRepairResultEnum.FAIL.getResult()) 190 .setResult(MesDvRepairResultEnum.FAIL.getResult())
  191 + .setConfirmUserId(getLoginUserId())
162 .setConfirmDate(LocalDateTime.now())); 192 .setConfirmDate(LocalDateTime.now()));
163 } 193 }
164 194