Commit 582c84b648d0316dd176d07edf375afc60a86292

Authored by YunaiV
1 parent d7b33f00

✨ feat(mes): 更新保养记录相关字段及新增功能

调整保养记录请求对象,新增保养计划编号、设备编号和保养人编号字段。更新查询逻辑以支持新字段,并新增获取保养记录明细列表和根据记录编号删除明细的功能。优化表单组件以支持详情模式。
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/maintenrecord/vo/MesDvMaintenRecordPageReqVO.java
@@ -17,17 +17,14 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_ @@ -17,17 +17,14 @@ import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_
17 @ToString(callSuper = true) 17 @ToString(callSuper = true)
18 public class MesDvMaintenRecordPageReqVO extends PageParam { 18 public class MesDvMaintenRecordPageReqVO extends PageParam {
19 19
20 - @Schema(description = "计划名称", example = "计划1")  
21 - private String planName; 20 + @Schema(description = "保养计划编号", example = "1")
  21 + private Long planId;
22 22
23 - @Schema(description = "设备编码", example = "M1")  
24 - private String machineryCode; 23 + @Schema(description = "设备编号", example = "1")
  24 + private Long machineryId;
25 25
26 - @Schema(description = "设备名称", example = "设备1")  
27 - private String machineryName;  
28 -  
29 - @Schema(description = "保养人名称", example = "张三")  
30 - private String nickname; 26 + @Schema(description = "保养人编号", example = "1")
  27 + private Long userId;
31 28
32 @Schema(description = "保养时间") 29 @Schema(description = "保养时间")
33 @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) 30 @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/dv/maintenrecord/MesDvMaintenRecordMapper.java
@@ -17,19 +17,9 @@ public interface MesDvMaintenRecordMapper extends BaseMapperX<MesDvMaintenRecord @@ -17,19 +17,9 @@ public interface MesDvMaintenRecordMapper extends BaseMapperX<MesDvMaintenRecord
17 17
18 default PageResult<MesDvMaintenRecordDO> selectPage(MesDvMaintenRecordPageReqVO reqVO) { 18 default PageResult<MesDvMaintenRecordDO> selectPage(MesDvMaintenRecordPageReqVO reqVO) {
19 return selectPage(reqVO, new LambdaQueryWrapperX<MesDvMaintenRecordDO>() 19 return selectPage(reqVO, new LambdaQueryWrapperX<MesDvMaintenRecordDO>()
20 - // TODO @AI:对齐分析下,哪里有问题!  
21 -// .apply(StrUtil.isNotBlank(reqVO.getPlanName()),  
22 -// "plan_id IN (SELECT id FROM mes_dv_check_plan WHERE name LIKE CONCAT('%', {0}, '%') AND deleted = 0)",  
23 -// reqVO.getPlanName())  
24 -// .apply(StrUtil.isNotBlank(reqVO.getMachineryCode()),  
25 -// "machinery_id IN (SELECT id FROM mes_dv_machinery WHERE code LIKE CONCAT('%', {0}, '%') AND deleted = 0)",  
26 -// reqVO.getMachineryCode())  
27 -// .apply(StrUtil.isNotBlank(reqVO.getMachineryName()),  
28 -// "machinery_id IN (SELECT id FROM mes_dv_machinery WHERE name LIKE CONCAT('%', {0}, '%') AND deleted = 0)",  
29 -// reqVO.getMachineryName())  
30 -// .apply(StrUtil.isNotBlank(reqVO.getNickname()),  
31 -// "user_id IN (SELECT id FROM system_users WHERE nickname LIKE CONCAT('%', {0}, '%') AND deleted = 0)",  
32 -// reqVO.getNickname()) 20 + .eqIfPresent(MesDvMaintenRecordDO::getPlanId, reqVO.getPlanId())
  21 + .eqIfPresent(MesDvMaintenRecordDO::getMachineryId, reqVO.getMachineryId())
  22 + .eqIfPresent(MesDvMaintenRecordDO::getUserId, reqVO.getUserId())
33 .betweenIfPresent(MesDvMaintenRecordDO::getMaintenTime, reqVO.getMaintenTime()) 23 .betweenIfPresent(MesDvMaintenRecordDO::getMaintenTime, reqVO.getMaintenTime())
34 .orderByDesc(MesDvMaintenRecordDO::getId)); 24 .orderByDesc(MesDvMaintenRecordDO::getId));
35 } 25 }
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/maintenrecord/MesDvMaintenRecordLineService.java
@@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.mes.controller.admin.dv.maintenrecord.vo.line.Mes @@ -6,6 +6,7 @@ import cn.iocoder.yudao.module.mes.controller.admin.dv.maintenrecord.vo.line.Mes
6 import cn.iocoder.yudao.module.mes.dal.dataobject.dv.maintenrecord.MesDvMaintenRecordLineDO; 6 import cn.iocoder.yudao.module.mes.dal.dataobject.dv.maintenrecord.MesDvMaintenRecordLineDO;
7 7
8 import jakarta.validation.Valid; 8 import jakarta.validation.Valid;
  9 +import java.util.List;
9 10
10 /** 11 /**
11 * 设备保养记录明细 Service 接口 12 * 设备保养记录明细 Service 接口
@@ -52,4 +53,19 @@ public interface MesDvMaintenRecordLineService { @@ -52,4 +53,19 @@ public interface MesDvMaintenRecordLineService {
52 */ 53 */
53 PageResult<MesDvMaintenRecordLineDO> getMaintenRecordLinePage(MesDvMaintenRecordLinePageReqVO pageReqVO); 54 PageResult<MesDvMaintenRecordLineDO> getMaintenRecordLinePage(MesDvMaintenRecordLinePageReqVO pageReqVO);
54 55
  56 + /**
  57 + * 获得指定保养记录的明细列表
  58 + *
  59 + * @param recordId 保养记录编号
  60 + * @return 明细列表
  61 + */
  62 + List<MesDvMaintenRecordLineDO> getMaintenRecordLineListByRecordId(Long recordId);
  63 +
  64 + /**
  65 + * 根据保养记录编号删除所有明细
  66 + *
  67 + * @param recordId 保养记录编号
  68 + */
  69 + void deleteMaintenRecordLineByRecordId(Long recordId);
  70 +
55 } 71 }
56 \ No newline at end of file 72 \ No newline at end of file
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/maintenrecord/MesDvMaintenRecordLineServiceImpl.java
@@ -12,6 +12,8 @@ import org.springframework.context.annotation.Lazy; @@ -12,6 +12,8 @@ import org.springframework.context.annotation.Lazy;
12 import org.springframework.stereotype.Service; 12 import org.springframework.stereotype.Service;
13 import org.springframework.validation.annotation.Validated; 13 import org.springframework.validation.annotation.Validated;
14 14
  15 +import java.util.List;
  16 +
15 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; 17 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
16 import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; 18 import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*;
17 19
@@ -29,7 +31,7 @@ public class MesDvMaintenRecordLineServiceImpl implements MesDvMaintenRecordLine @@ -29,7 +31,7 @@ public class MesDvMaintenRecordLineServiceImpl implements MesDvMaintenRecordLine
29 31
30 @Resource 32 @Resource
31 @Lazy 33 @Lazy
32 - private MesDvMaintenRecordServiceImpl maintenRecordService; 34 + private MesDvMaintenRecordService maintenRecordService;
33 @Resource 35 @Resource
34 private MesDvSubjectService subjectService; 36 private MesDvSubjectService subjectService;
35 37
@@ -76,7 +78,7 @@ public class MesDvMaintenRecordLineServiceImpl implements MesDvMaintenRecordLine @@ -76,7 +78,7 @@ public class MesDvMaintenRecordLineServiceImpl implements MesDvMaintenRecordLine
76 78
77 private MesDvMaintenRecordLineDO validateMaintenRecordLineExists(Long id) { 79 private MesDvMaintenRecordLineDO validateMaintenRecordLineExists(Long id) {
78 MesDvMaintenRecordLineDO maintenRecordLine = maintenRecordLineMapper.selectById(id); 80 MesDvMaintenRecordLineDO maintenRecordLine = maintenRecordLineMapper.selectById(id);
79 - if (maintenRecordLineMapper.selectById(id) == null) { 81 + if (maintenRecordLine == null) {
80 throw exception(MAINTEN_RECORD_LINE_NOT_EXISTS); 82 throw exception(MAINTEN_RECORD_LINE_NOT_EXISTS);
81 } 83 }
82 return maintenRecordLine; 84 return maintenRecordLine;
@@ -92,4 +94,14 @@ public class MesDvMaintenRecordLineServiceImpl implements MesDvMaintenRecordLine @@ -92,4 +94,14 @@ public class MesDvMaintenRecordLineServiceImpl implements MesDvMaintenRecordLine
92 return maintenRecordLineMapper.selectPage(pageReqVO); 94 return maintenRecordLineMapper.selectPage(pageReqVO);
93 } 95 }
94 96
  97 + @Override
  98 + public List<MesDvMaintenRecordLineDO> getMaintenRecordLineListByRecordId(Long recordId) {
  99 + return maintenRecordLineMapper.selectListByRecordId(recordId);
  100 + }
  101 +
  102 + @Override
  103 + public void deleteMaintenRecordLineByRecordId(Long recordId) {
  104 + maintenRecordLineMapper.deleteByRecordId(recordId);
  105 + }
  106 +
95 } 107 }
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/maintenrecord/MesDvMaintenRecordService.java
@@ -51,6 +51,14 @@ public interface MesDvMaintenRecordService { @@ -51,6 +51,14 @@ public interface MesDvMaintenRecordService {
51 void validateMaintenRecordExists(Long id); 51 void validateMaintenRecordExists(Long id);
52 52
53 /** 53 /**
  54 + * 校验设备保养记录是否为草稿状态
  55 + *
  56 + * @param id 编号
  57 + * @return 保养记录
  58 + */
  59 + MesDvMaintenRecordDO validateMaintenRecordDraft(Long id);
  60 +
  61 + /**
54 * 获得指定设备的保养记录数量 62 * 获得指定设备的保养记录数量
55 * 63 *
56 * @param machineryId 设备编号 64 * @param machineryId 设备编号
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/maintenrecord/MesDvMaintenRecordServiceImpl.java
@@ -8,12 +8,12 @@ import cn.iocoder.yudao.module.mes.controller.admin.dv.maintenrecord.vo.MesDvMai @@ -8,12 +8,12 @@ import cn.iocoder.yudao.module.mes.controller.admin.dv.maintenrecord.vo.MesDvMai
8 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;
9 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; 10 import cn.iocoder.yudao.module.mes.dal.dataobject.dv.maintenrecord.MesDvMaintenRecordLineDO;
11 -import cn.iocoder.yudao.module.mes.dal.mysql.dv.maintenrecord.MesDvMaintenRecordLineMapper;  
12 import cn.iocoder.yudao.module.mes.dal.mysql.dv.maintenrecord.MesDvMaintenRecordMapper; 11 import cn.iocoder.yudao.module.mes.dal.mysql.dv.maintenrecord.MesDvMaintenRecordMapper;
13 import cn.iocoder.yudao.module.mes.enums.dv.MesDvMaintenRecordStatusEnum; 12 import cn.iocoder.yudao.module.mes.enums.dv.MesDvMaintenRecordStatusEnum;
14 import cn.iocoder.yudao.module.mes.service.dv.checkplan.MesDvCheckPlanService; 13 import cn.iocoder.yudao.module.mes.service.dv.checkplan.MesDvCheckPlanService;
15 import cn.iocoder.yudao.module.mes.service.dv.machinery.MesDvMachineryService; 14 import cn.iocoder.yudao.module.mes.service.dv.machinery.MesDvMachineryService;
16 import jakarta.annotation.Resource; 15 import jakarta.annotation.Resource;
  16 +import org.springframework.context.annotation.Lazy;
17 import org.springframework.stereotype.Service; 17 import org.springframework.stereotype.Service;
18 import org.springframework.transaction.annotation.Transactional; 18 import org.springframework.transaction.annotation.Transactional;
19 import org.springframework.validation.annotation.Validated; 19 import org.springframework.validation.annotation.Validated;
@@ -35,7 +35,8 @@ public class MesDvMaintenRecordServiceImpl implements MesDvMaintenRecordService @@ -35,7 +35,8 @@ public class MesDvMaintenRecordServiceImpl implements MesDvMaintenRecordService
35 @Resource 35 @Resource
36 private MesDvMaintenRecordMapper maintenRecordMapper; 36 private MesDvMaintenRecordMapper maintenRecordMapper;
37 @Resource 37 @Resource
38 - private MesDvMaintenRecordLineMapper maintenRecordLineMapper; 38 + @Lazy
  39 + private MesDvMaintenRecordLineService maintenRecordLineService;
39 @Resource 40 @Resource
40 private MesDvMachineryService machineryService; 41 private MesDvMachineryService machineryService;
41 @Resource 42 @Resource
@@ -70,7 +71,7 @@ public class MesDvMaintenRecordServiceImpl implements MesDvMaintenRecordService @@ -70,7 +71,7 @@ public class MesDvMaintenRecordServiceImpl implements MesDvMaintenRecordService
70 // 1.1 校验状态为草稿 71 // 1.1 校验状态为草稿
71 validateMaintenRecordDraft(id); 72 validateMaintenRecordDraft(id);
72 // 1.2 校验至少有一条明细 73 // 1.2 校验至少有一条明细
73 - List<MesDvMaintenRecordLineDO> lines = maintenRecordLineMapper.selectListByRecordId(id); 74 + List<MesDvMaintenRecordLineDO> lines = maintenRecordLineService.getMaintenRecordLineListByRecordId(id);
74 if (CollUtil.isEmpty(lines)) { 75 if (CollUtil.isEmpty(lines)) {
75 throw exception(MAINTEN_RECORD_NO_LINE); 76 throw exception(MAINTEN_RECORD_NO_LINE);
76 } 77 }
@@ -91,7 +92,7 @@ public class MesDvMaintenRecordServiceImpl implements MesDvMaintenRecordService @@ -91,7 +92,7 @@ public class MesDvMaintenRecordServiceImpl implements MesDvMaintenRecordService
91 // 删除 92 // 删除
92 maintenRecordMapper.deleteById(id); 93 maintenRecordMapper.deleteById(id);
93 // 级联删除子表 94 // 级联删除子表
94 - maintenRecordLineMapper.deleteByRecordId(id); 95 + maintenRecordLineService.deleteMaintenRecordLineByRecordId(id);
95 } 96 }
96 97
97 private void validateMaintenRecordRelation(MesDvMaintenRecordSaveReqVO reqVO) { 98 private void validateMaintenRecordRelation(MesDvMaintenRecordSaveReqVO reqVO) {
@@ -115,12 +116,7 @@ public class MesDvMaintenRecordServiceImpl implements MesDvMaintenRecordService @@ -115,12 +116,7 @@ public class MesDvMaintenRecordServiceImpl implements MesDvMaintenRecordService
115 return maintenRecordMapper.selectCountByMachineryId(machineryId); 116 return maintenRecordMapper.selectCountByMachineryId(machineryId);
116 } 117 }
117 118
118 - /**  
119 - * 校验设备保养记录是否为草稿状态  
120 - *  
121 - * @param id 编号  
122 - * @return 保养记录  
123 - */ 119 + @Override
124 public MesDvMaintenRecordDO validateMaintenRecordDraft(Long id) { 120 public MesDvMaintenRecordDO validateMaintenRecordDraft(Long id) {
125 MesDvMaintenRecordDO record = maintenRecordMapper.selectById(id); 121 MesDvMaintenRecordDO record = maintenRecordMapper.selectById(id);
126 if (record == null) { 122 if (record == null) {