Просмотр исходного кода

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

调整保养记录请求对象,新增保养计划编号、设备编号和保养人编号字段。更新查询逻辑以支持新字段,并新增获取保养记录明细列表和根据记录编号删除明细的功能。优化表单组件以支持详情模式。
YunaiV месяцев назад: 5
Родитель
Сommit
582c84b648

+ 6 - 9
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_
 @ToString(callSuper = true)
 public class MesDvMaintenRecordPageReqVO extends PageParam {
 
-    @Schema(description = "计划名称", example = "计划1")
-    private String planName;
+    @Schema(description = "保养计划编号", example = "1")
+    private Long planId;
 
-    @Schema(description = "设备编码", example = "M1")
-    private String machineryCode;
+    @Schema(description = "设备编号", example = "1")
+    private Long machineryId;
 
-    @Schema(description = "设备名称", example = "设备1")
-    private String machineryName;
-
-    @Schema(description = "保养人名称", example = "张三")
-    private String nickname;
+    @Schema(description = "保养人编号", example = "1")
+    private Long userId;
 
     @Schema(description = "保养时间")
     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)

+ 3 - 13
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
 
     default PageResult<MesDvMaintenRecordDO> selectPage(MesDvMaintenRecordPageReqVO reqVO) {
         return selectPage(reqVO, new LambdaQueryWrapperX<MesDvMaintenRecordDO>()
-                // TODO @AI:对齐分析下,哪里有问题!
-//                .apply(StrUtil.isNotBlank(reqVO.getPlanName()),
-//                        "plan_id IN (SELECT id FROM mes_dv_check_plan WHERE name LIKE CONCAT('%', {0}, '%') AND deleted = 0)",
-//                        reqVO.getPlanName())
-//                .apply(StrUtil.isNotBlank(reqVO.getMachineryCode()),
-//                        "machinery_id IN (SELECT id FROM mes_dv_machinery WHERE code LIKE CONCAT('%', {0}, '%') AND deleted = 0)",
-//                        reqVO.getMachineryCode())
-//                .apply(StrUtil.isNotBlank(reqVO.getMachineryName()),
-//                        "machinery_id IN (SELECT id FROM mes_dv_machinery WHERE name LIKE CONCAT('%', {0}, '%') AND deleted = 0)",
-//                        reqVO.getMachineryName())
-//                .apply(StrUtil.isNotBlank(reqVO.getNickname()),
-//                        "user_id IN (SELECT id FROM system_users WHERE nickname LIKE CONCAT('%', {0}, '%') AND deleted = 0)",
-//                        reqVO.getNickname())
+                .eqIfPresent(MesDvMaintenRecordDO::getPlanId, reqVO.getPlanId())
+                .eqIfPresent(MesDvMaintenRecordDO::getMachineryId, reqVO.getMachineryId())
+                .eqIfPresent(MesDvMaintenRecordDO::getUserId, reqVO.getUserId())
                 .betweenIfPresent(MesDvMaintenRecordDO::getMaintenTime, reqVO.getMaintenTime())
                 .orderByDesc(MesDvMaintenRecordDO::getId));
     }

+ 16 - 0
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
 import cn.iocoder.yudao.module.mes.dal.dataobject.dv.maintenrecord.MesDvMaintenRecordLineDO;
 
 import jakarta.validation.Valid;
+import java.util.List;
 
 /**
  * 设备保养记录明细 Service 接口
@@ -52,4 +53,19 @@ public interface MesDvMaintenRecordLineService {
      */
     PageResult<MesDvMaintenRecordLineDO> getMaintenRecordLinePage(MesDvMaintenRecordLinePageReqVO pageReqVO);
 
+    /**
+     * 获得指定保养记录的明细列表
+     *
+     * @param recordId 保养记录编号
+     * @return 明细列表
+     */
+    List<MesDvMaintenRecordLineDO> getMaintenRecordLineListByRecordId(Long recordId);
+
+    /**
+     * 根据保养记录编号删除所有明细
+     *
+     * @param recordId 保养记录编号
+     */
+    void deleteMaintenRecordLineByRecordId(Long recordId);
+
 }

+ 14 - 2
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;
 import org.springframework.stereotype.Service;
 import org.springframework.validation.annotation.Validated;
 
+import java.util.List;
+
 import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
 import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*;
 
@@ -29,7 +31,7 @@ public class MesDvMaintenRecordLineServiceImpl implements MesDvMaintenRecordLine
 
     @Resource
     @Lazy
-    private MesDvMaintenRecordServiceImpl maintenRecordService;
+    private MesDvMaintenRecordService maintenRecordService;
     @Resource
     private MesDvSubjectService subjectService;
 
@@ -76,7 +78,7 @@ public class MesDvMaintenRecordLineServiceImpl implements MesDvMaintenRecordLine
 
     private MesDvMaintenRecordLineDO validateMaintenRecordLineExists(Long id) {
         MesDvMaintenRecordLineDO maintenRecordLine = maintenRecordLineMapper.selectById(id);
-        if (maintenRecordLineMapper.selectById(id) == null) {
+        if (maintenRecordLine == null) {
             throw exception(MAINTEN_RECORD_LINE_NOT_EXISTS);
         }
         return maintenRecordLine;
@@ -92,4 +94,14 @@ public class MesDvMaintenRecordLineServiceImpl implements MesDvMaintenRecordLine
         return maintenRecordLineMapper.selectPage(pageReqVO);
     }
 
+    @Override
+    public List<MesDvMaintenRecordLineDO> getMaintenRecordLineListByRecordId(Long recordId) {
+        return maintenRecordLineMapper.selectListByRecordId(recordId);
+    }
+
+    @Override
+    public void deleteMaintenRecordLineByRecordId(Long recordId) {
+        maintenRecordLineMapper.deleteByRecordId(recordId);
+    }
+
 }

+ 8 - 0
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/maintenrecord/MesDvMaintenRecordService.java

@@ -50,6 +50,14 @@ public interface MesDvMaintenRecordService {
      */
     void validateMaintenRecordExists(Long id);
 
+    /**
+     * 校验设备保养记录是否为草稿状态
+     *
+     * @param id 编号
+     * @return 保养记录
+     */
+    MesDvMaintenRecordDO validateMaintenRecordDraft(Long id);
+
     /**
      * 获得指定设备的保养记录数量
      *

+ 6 - 10
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
 import cn.iocoder.yudao.module.mes.controller.admin.dv.maintenrecord.vo.MesDvMaintenRecordSaveReqVO;
 import cn.iocoder.yudao.module.mes.dal.dataobject.dv.maintenrecord.MesDvMaintenRecordDO;
 import cn.iocoder.yudao.module.mes.dal.dataobject.dv.maintenrecord.MesDvMaintenRecordLineDO;
-import cn.iocoder.yudao.module.mes.dal.mysql.dv.maintenrecord.MesDvMaintenRecordLineMapper;
 import cn.iocoder.yudao.module.mes.dal.mysql.dv.maintenrecord.MesDvMaintenRecordMapper;
 import cn.iocoder.yudao.module.mes.enums.dv.MesDvMaintenRecordStatusEnum;
 import cn.iocoder.yudao.module.mes.service.dv.checkplan.MesDvCheckPlanService;
 import cn.iocoder.yudao.module.mes.service.dv.machinery.MesDvMachineryService;
 import jakarta.annotation.Resource;
+import org.springframework.context.annotation.Lazy;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.validation.annotation.Validated;
@@ -35,7 +35,8 @@ public class MesDvMaintenRecordServiceImpl implements MesDvMaintenRecordService
     @Resource
     private MesDvMaintenRecordMapper maintenRecordMapper;
     @Resource
-    private MesDvMaintenRecordLineMapper maintenRecordLineMapper;
+    @Lazy
+    private MesDvMaintenRecordLineService maintenRecordLineService;
     @Resource
     private MesDvMachineryService machineryService;
     @Resource
@@ -70,7 +71,7 @@ public class MesDvMaintenRecordServiceImpl implements MesDvMaintenRecordService
         // 1.1 校验状态为草稿
         validateMaintenRecordDraft(id);
         // 1.2 校验至少有一条明细
-        List<MesDvMaintenRecordLineDO> lines = maintenRecordLineMapper.selectListByRecordId(id);
+        List<MesDvMaintenRecordLineDO> lines = maintenRecordLineService.getMaintenRecordLineListByRecordId(id);
         if (CollUtil.isEmpty(lines)) {
             throw exception(MAINTEN_RECORD_NO_LINE);
         }
@@ -91,7 +92,7 @@ public class MesDvMaintenRecordServiceImpl implements MesDvMaintenRecordService
         // 删除
         maintenRecordMapper.deleteById(id);
         // 级联删除子表
-        maintenRecordLineMapper.deleteByRecordId(id);
+        maintenRecordLineService.deleteMaintenRecordLineByRecordId(id);
     }
 
     private void validateMaintenRecordRelation(MesDvMaintenRecordSaveReqVO reqVO) {
@@ -115,12 +116,7 @@ public class MesDvMaintenRecordServiceImpl implements MesDvMaintenRecordService
         return maintenRecordMapper.selectCountByMachineryId(machineryId);
     }
 
-    /**
-     * 校验设备保养记录是否为草稿状态
-     *
-     * @param id 编号
-     * @return 保养记录
-     */
+    @Override
     public MesDvMaintenRecordDO validateMaintenRecordDraft(Long id) {
         MesDvMaintenRecordDO record = maintenRecordMapper.selectById(id);
         if (record == null) {