Commit 391d253180905092e8bd13061e4662237d6ed7bd

Authored by YunaiV
1 parent 4c4885e2

feat(mes): 添加维修工单和维修工单行相关功能,包括请求和响应 VO 及控制器

Showing 24 changed files with 1184 additions and 0 deletions
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/checkrecord/vo/MesDvCheckRecordSaveReqVO.java
... ... @@ -27,6 +27,7 @@ public class MesDvCheckRecordSaveReqVO {
27 27 @Schema(description = "点检人编号", example = "1")
28 28 private Long userId;
29 29  
  30 + // TODO @AI:这个字段,不允许提交
30 31 @Schema(description = "状态", example = "10")
31 32 private Integer status;
32 33  
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/maintenrecord/MesDvMaintenRecordController.java
... ... @@ -113,6 +113,8 @@ public class MesDvMaintenRecordController {
113 113 buildMaintenRecordRespVOList(list));
114 114 }
115 115  
  116 + // TODO @AI:submitMaintenRecord 缺少;
  117 +
116 118 // ==================== 拼接 VO ====================
117 119  
118 120 private List<MesDvMaintenRecordRespVO> buildMaintenRecordRespVOList(List<MesDvMaintenRecordDO> list) {
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/maintenrecord/vo/MesDvMaintenRecordSaveReqVO.java
... ... @@ -27,6 +27,7 @@ public class MesDvMaintenRecordSaveReqVO {
27 27 @Schema(description = "用户编号", example = "1")
28 28 private Long userId;
29 29  
  30 + // TODO @AI:这个字段,不允许提交
30 31 @Schema(description = "状态", example = "10")
31 32 private Integer status;
32 33  
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/repair/MesDvRepairController.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.controller.admin.dv.repair;
  2 +
  3 +import cn.hutool.core.collection.CollUtil;
  4 +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
  5 +import cn.iocoder.yudao.framework.common.pojo.CommonResult;
  6 +import cn.iocoder.yudao.framework.common.pojo.PageParam;
  7 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  8 +import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
  9 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
  10 +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
  11 +import cn.iocoder.yudao.module.mes.controller.admin.dv.repair.vo.MesDvRepairPageReqVO;
  12 +import cn.iocoder.yudao.module.mes.controller.admin.dv.repair.vo.MesDvRepairRespVO;
  13 +import cn.iocoder.yudao.module.mes.controller.admin.dv.repair.vo.MesDvRepairSaveReqVO;
  14 +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.machinery.MesDvMachineryDO;
  15 +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.repair.MesDvRepairDO;
  16 +import cn.iocoder.yudao.module.mes.service.dv.machinery.MesDvMachineryService;
  17 +import cn.iocoder.yudao.module.mes.service.dv.repair.MesDvRepairService;
  18 +import cn.iocoder.yudao.module.system.api.user.AdminUserApi;
  19 +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO;
  20 +import io.swagger.v3.oas.annotations.Operation;
  21 +import io.swagger.v3.oas.annotations.Parameter;
  22 +import io.swagger.v3.oas.annotations.tags.Tag;
  23 +import jakarta.annotation.Resource;
  24 +import jakarta.servlet.http.HttpServletResponse;
  25 +import jakarta.validation.Valid;
  26 +import org.springframework.security.access.prepost.PreAuthorize;
  27 +import org.springframework.validation.annotation.Validated;
  28 +import org.springframework.web.bind.annotation.*;
  29 +
  30 +import java.io.IOException;
  31 +import java.util.Collections;
  32 +import java.util.List;
  33 +import java.util.Map;
  34 +import java.util.Set;
  35 +
  36 +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.util.collection.CollectionUtils.convertSet;
  39 +
  40 +@Tag(name = "管理后台 - MES 维修工单")
  41 +@RestController
  42 +@RequestMapping("/mes/dv/repair")
  43 +@Validated
  44 +public class MesDvRepairController {
  45 +
  46 + @Resource
  47 + private MesDvRepairService repairService;
  48 +
  49 + @Resource
  50 + private MesDvMachineryService machineryService;
  51 +
  52 + @Resource
  53 + private AdminUserApi adminUserApi;
  54 +
  55 + @PostMapping("/create")
  56 + @Operation(summary = "创建维修工单")
  57 + @PreAuthorize("@ss.hasPermission('mes:dv-repair:create')")
  58 + public CommonResult<Long> createRepair(@Valid @RequestBody MesDvRepairSaveReqVO createReqVO) {
  59 + return success(repairService.createRepair(createReqVO));
  60 + }
  61 +
  62 + @PutMapping("/update")
  63 + @Operation(summary = "更新维修工单")
  64 + @PreAuthorize("@ss.hasPermission('mes:dv-repair:update')")
  65 + public CommonResult<Boolean> updateRepair(@Valid @RequestBody MesDvRepairSaveReqVO updateReqVO) {
  66 + repairService.updateRepair(updateReqVO);
  67 + return success(true);
  68 + }
  69 +
  70 + @DeleteMapping("/delete")
  71 + @Operation(summary = "删除维修工单")
  72 + @Parameter(name = "id", description = "编号", required = true)
  73 + @PreAuthorize("@ss.hasPermission('mes:dv-repair:delete')")
  74 + public CommonResult<Boolean> deleteRepair(@RequestParam("id") Long id) {
  75 + repairService.deleteRepair(id);
  76 + return success(true);
  77 + }
  78 +
  79 + @GetMapping("/get")
  80 + @Operation(summary = "获得维修工单")
  81 + @Parameter(name = "id", description = "编号", required = true, example = "1024")
  82 + @PreAuthorize("@ss.hasPermission('mes:dv-repair:query')")
  83 + public CommonResult<MesDvRepairRespVO> getRepair(@RequestParam("id") Long id) {
  84 + MesDvRepairDO repair = repairService.getRepair(id);
  85 + if (repair == null) {
  86 + return success(null);
  87 + }
  88 + return success(buildRepairRespVOList(Collections.singletonList(repair)).get(0));
  89 + }
  90 +
  91 + @GetMapping("/page")
  92 + @Operation(summary = "获得维修工单分页")
  93 + @PreAuthorize("@ss.hasPermission('mes:dv-repair:query')")
  94 + public CommonResult<PageResult<MesDvRepairRespVO>> getRepairPage(@Valid MesDvRepairPageReqVO pageReqVO) {
  95 + PageResult<MesDvRepairDO> pageResult = repairService.getRepairPage(pageReqVO);
  96 + return success(new PageResult<>(buildRepairRespVOList(pageResult.getList()), pageResult.getTotal()));
  97 + }
  98 +
  99 + @GetMapping("/export-excel")
  100 + @Operation(summary = "导出维修工单 Excel")
  101 + @PreAuthorize("@ss.hasPermission('mes:dv-repair:export')")
  102 + @ApiAccessLog(operateType = EXPORT)
  103 + public void exportRepairExcel(@Valid MesDvRepairPageReqVO pageReqVO,
  104 + HttpServletResponse response) throws IOException {
  105 + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
  106 + List<MesDvRepairDO> list = repairService.getRepairPage(pageReqVO).getList();
  107 + // 导出 Excel
  108 + ExcelUtils.write(response, "维修工单.xls", "数据", MesDvRepairRespVO.class,
  109 + buildRepairRespVOList(list));
  110 + }
  111 +
  112 + // ==================== 拼接 VO ====================
  113 +
  114 + private List<MesDvRepairRespVO> buildRepairRespVOList(List<MesDvRepairDO> list) {
  115 + if (CollUtil.isEmpty(list)) {
  116 + return Collections.emptyList();
  117 + }
  118 + // 1.1 批量获取关联数据
  119 + Map<Long, MesDvMachineryDO> machineryMap = machineryService.getMachineryMap(
  120 + convertSet(list, MesDvRepairDO::getMachineryId));
  121 + // 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);
  126 + // 2. 拼接 VO
  127 + return BeanUtils.toBean(list, MesDvRepairRespVO.class, vo -> {
  128 + MapUtils.findAndThen(machineryMap, vo.getMachineryId(), machinery -> vo
  129 + .setMachineryCode(machinery.getCode()).setMachineryName(machinery.getName())
  130 + .setMachineryBrand(machinery.getBrand()).setMachinerySpec(machinery.getSpec()));
  131 + MapUtils.findAndThen(userMap, vo.getAcceptedUserId(),
  132 + user -> vo.setAcceptedUserNickname(user.getNickname()));
  133 + MapUtils.findAndThen(userMap, vo.getConfirmUserId(),
  134 + user -> vo.setConfirmUserNickname(user.getNickname()));
  135 + });
  136 + }
  137 +
  138 +}
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/repair/MesDvRepairLineController.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.controller.admin.dv.repair;
  2 +
  3 +import cn.hutool.core.collection.CollUtil;
  4 +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog;
  5 +import cn.iocoder.yudao.framework.common.pojo.CommonResult;
  6 +import cn.iocoder.yudao.framework.common.pojo.PageParam;
  7 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  8 +import cn.iocoder.yudao.framework.common.util.collection.MapUtils;
  9 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
  10 +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
  11 +import cn.iocoder.yudao.module.mes.controller.admin.dv.repair.vo.line.MesDvRepairLinePageReqVO;
  12 +import cn.iocoder.yudao.module.mes.controller.admin.dv.repair.vo.line.MesDvRepairLineRespVO;
  13 +import cn.iocoder.yudao.module.mes.controller.admin.dv.repair.vo.line.MesDvRepairLineSaveReqVO;
  14 +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.repair.MesDvRepairLineDO;
  15 +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.subject.MesDvSubjectDO;
  16 +import cn.iocoder.yudao.module.mes.service.dv.repair.MesDvRepairLineService;
  17 +import cn.iocoder.yudao.module.mes.service.dv.subject.MesDvSubjectService;
  18 +import io.swagger.v3.oas.annotations.Operation;
  19 +import io.swagger.v3.oas.annotations.Parameter;
  20 +import io.swagger.v3.oas.annotations.tags.Tag;
  21 +import jakarta.annotation.Resource;
  22 +import jakarta.servlet.http.HttpServletResponse;
  23 +import jakarta.validation.Valid;
  24 +import org.springframework.security.access.prepost.PreAuthorize;
  25 +import org.springframework.validation.annotation.Validated;
  26 +import org.springframework.web.bind.annotation.*;
  27 +
  28 +import java.io.IOException;
  29 +import java.util.Collections;
  30 +import java.util.List;
  31 +import java.util.Map;
  32 +
  33 +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
  34 +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
  35 +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet;
  36 +
  37 +@Tag(name = "管理后台 - MES 维修工单行")
  38 +@RestController
  39 +@RequestMapping("/mes/dv/repair-line")
  40 +@Validated
  41 +public class MesDvRepairLineController {
  42 +
  43 + @Resource
  44 + private MesDvRepairLineService repairLineService;
  45 +
  46 + @Resource
  47 + private MesDvSubjectService subjectService;
  48 +
  49 + @PostMapping("/create")
  50 + @Operation(summary = "创建维修工单行")
  51 + @PreAuthorize("@ss.hasPermission('mes:dv-repair:create')")
  52 + public CommonResult<Long> createRepairLine(@Valid @RequestBody MesDvRepairLineSaveReqVO createReqVO) {
  53 + return success(repairLineService.createRepairLine(createReqVO));
  54 + }
  55 +
  56 + @PutMapping("/update")
  57 + @Operation(summary = "更新维修工单行")
  58 + @PreAuthorize("@ss.hasPermission('mes:dv-repair:update')")
  59 + public CommonResult<Boolean> updateRepairLine(@Valid @RequestBody MesDvRepairLineSaveReqVO updateReqVO) {
  60 + repairLineService.updateRepairLine(updateReqVO);
  61 + return success(true);
  62 + }
  63 +
  64 + @DeleteMapping("/delete")
  65 + @Operation(summary = "删除维修工单行")
  66 + @Parameter(name = "id", description = "编号", required = true)
  67 + @PreAuthorize("@ss.hasPermission('mes:dv-repair:delete')")
  68 + public CommonResult<Boolean> deleteRepairLine(@RequestParam("id") Long id) {
  69 + repairLineService.deleteRepairLine(id);
  70 + return success(true);
  71 + }
  72 +
  73 + @GetMapping("/get")
  74 + @Operation(summary = "获得维修工单行")
  75 + @Parameter(name = "id", description = "编号", required = true, example = "1024")
  76 + @PreAuthorize("@ss.hasPermission('mes:dv-repair:query')")
  77 + public CommonResult<MesDvRepairLineRespVO> getRepairLine(@RequestParam("id") Long id) {
  78 + MesDvRepairLineDO repairLine = repairLineService.getRepairLine(id);
  79 + if (repairLine == null) {
  80 + return success(null);
  81 + }
  82 + return success(buildRepairLineRespVOList(Collections.singletonList(repairLine)).get(0));
  83 + }
  84 +
  85 + @GetMapping("/page")
  86 + @Operation(summary = "获得维修工单行分页")
  87 + @PreAuthorize("@ss.hasPermission('mes:dv-repair:query')")
  88 + public CommonResult<PageResult<MesDvRepairLineRespVO>> getRepairLinePage(@Valid MesDvRepairLinePageReqVO pageReqVO) {
  89 + PageResult<MesDvRepairLineDO> pageResult = repairLineService.getRepairLinePage(pageReqVO);
  90 + return success(new PageResult<>(buildRepairLineRespVOList(pageResult.getList()), pageResult.getTotal()));
  91 + }
  92 +
  93 + @GetMapping("/export-excel")
  94 + @Operation(summary = "导出维修工单行 Excel")
  95 + @PreAuthorize("@ss.hasPermission('mes:dv-repair:export')")
  96 + @ApiAccessLog(operateType = EXPORT)
  97 + public void exportRepairLineExcel(@Valid MesDvRepairLinePageReqVO pageReqVO,
  98 + HttpServletResponse response) throws IOException {
  99 + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
  100 + List<MesDvRepairLineDO> list = repairLineService.getRepairLinePage(pageReqVO).getList();
  101 + // 导出 Excel
  102 + ExcelUtils.write(response, "维修工单行.xls", "数据", MesDvRepairLineRespVO.class,
  103 + buildRepairLineRespVOList(list));
  104 + }
  105 +
  106 + // ==================== 拼接 VO ====================
  107 +
  108 + private List<MesDvRepairLineRespVO> buildRepairLineRespVOList(List<MesDvRepairLineDO> list) {
  109 + if (CollUtil.isEmpty(list)) {
  110 + return Collections.emptyList();
  111 + }
  112 + // 1. 批量获取关联数据
  113 + Map<Long, MesDvSubjectDO> subjectMap = subjectService.getSubjectMap(
  114 + convertSet(list, MesDvRepairLineDO::getSubjectId));
  115 + // 2. 拼接 VO
  116 + return BeanUtils.toBean(list, MesDvRepairLineRespVO.class, vo ->
  117 + MapUtils.findAndThen(subjectMap, vo.getSubjectId(), subject -> vo
  118 + .setSubjectName(subject.getName()).setSubjectContent(subject.getContent())
  119 + .setSubjectStandard(subject.getStandard())));
  120 + }
  121 +
  122 +}
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/repair/vo/MesDvRepairPageReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.controller.admin.dv.repair.vo;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageParam;
  4 +import io.swagger.v3.oas.annotations.media.Schema;
  5 +import lombok.Data;
  6 +import lombok.EqualsAndHashCode;
  7 +import lombok.ToString;
  8 +import org.springframework.format.annotation.DateTimeFormat;
  9 +
  10 +import java.time.LocalDateTime;
  11 +
  12 +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
  13 +
  14 +@Schema(description = "管理后台 - MES 维修工单分页 Request VO")
  15 +@Data
  16 +@EqualsAndHashCode(callSuper = true)
  17 +@ToString(callSuper = true)
  18 +public class MesDvRepairPageReqVO extends PageParam {
  19 +
  20 + @Schema(description = "维修工单编码", example = "REP2024001")
  21 + private String code;
  22 +
  23 + @Schema(description = "维修工单名称", example = "注塑机维修")
  24 + private String name;
  25 +
  26 + @Schema(description = "状态", example = "10")
  27 + private Integer status;
  28 +
  29 + @Schema(description = "报修日期")
  30 + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
  31 + private LocalDateTime[] requireDate;
  32 +
  33 +}
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/repair/vo/MesDvRepairRespVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.controller.admin.dv.repair.vo;
  2 +
  3 +import cn.iocoder.yudao.framework.excel.core.annotations.DictFormat;
  4 +import cn.iocoder.yudao.framework.excel.core.convert.DictConvert;
  5 +import cn.iocoder.yudao.module.mes.enums.DictTypeConstants;
  6 +import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
  7 +import cn.idev.excel.annotation.ExcelProperty;
  8 +import io.swagger.v3.oas.annotations.media.Schema;
  9 +import lombok.Data;
  10 +
  11 +import java.time.LocalDateTime;
  12 +
  13 +@Schema(description = "管理后台 - MES 维修工单 Response VO")
  14 +@Data
  15 +@ExcelIgnoreUnannotated
  16 +public class MesDvRepairRespVO {
  17 +
  18 + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
  19 + @ExcelProperty("编号")
  20 + private Long id;
  21 +
  22 + @Schema(description = "维修工单编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "REP2024001")
  23 + @ExcelProperty("维修工单编码")
  24 + private String code;
  25 +
  26 + @Schema(description = "维修工单名称", example = "注塑机液压系统维修")
  27 + @ExcelProperty("维修工单名称")
  28 + private String name;
  29 +
  30 + @Schema(description = "设备编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
  31 + private Long machineryId;
  32 +
  33 + @Schema(description = "设备编码", example = "M001")
  34 + @ExcelProperty("设备编码")
  35 + private String machineryCode;
  36 +
  37 + @Schema(description = "设备名称", example = "注塑机")
  38 + @ExcelProperty("设备名称")
  39 + private String machineryName;
  40 +
  41 + @Schema(description = "品牌", example = "西门子")
  42 + @ExcelProperty("品牌")
  43 + private String machineryBrand;
  44 +
  45 + @Schema(description = "规格型号", example = "X-100")
  46 + @ExcelProperty("规格型号")
  47 + private String machinerySpec;
  48 +
  49 + @Schema(description = "报修日期")
  50 + @ExcelProperty("报修日期")
  51 + private LocalDateTime requireDate;
  52 +
  53 + @Schema(description = "维修完成日期")
  54 + @ExcelProperty("维修完成日期")
  55 + private LocalDateTime finishDate;
  56 +
  57 + @Schema(description = "验收日期")
  58 + @ExcelProperty("验收日期")
  59 + private LocalDateTime confirmDate;
  60 +
  61 + @Schema(description = "维修结果", example = "1")
  62 + @ExcelProperty(value = "维修结果", converter = DictConvert.class)
  63 + @DictFormat(DictTypeConstants.MES_DV_REPAIR_RESULT)
  64 + private Integer result;
  65 +
  66 + @Schema(description = "维修人用户编号", example = "1")
  67 + private Long acceptedUserId;
  68 +
  69 + @Schema(description = "维修人名称", example = "张三")
  70 + @ExcelProperty("维修人")
  71 + private String acceptedUserNickname;
  72 +
  73 + @Schema(description = "验收人用户编号", example = "1")
  74 + private Long confirmUserId;
  75 +
  76 + @Schema(description = "验收人名称", example = "李四")
  77 + @ExcelProperty("验收人")
  78 + private String confirmUserNickname;
  79 +
  80 + @Schema(description = "来源单据类型", example = "1")
  81 + private Integer sourceDocType;
  82 +
  83 + @Schema(description = "来源单据编号", example = "1")
  84 + private Long sourceDocId;
  85 +
  86 + @Schema(description = "来源单据编码", example = "DOC001")
  87 + private String sourceDocCode;
  88 +
  89 + @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "10")
  90 + @ExcelProperty(value = "状态", converter = DictConvert.class)
  91 + @DictFormat(DictTypeConstants.MES_DV_REPAIR_STATUS)
  92 + private Integer status;
  93 +
  94 + @Schema(description = "备注", example = "测试备注")
  95 + @ExcelProperty("备注")
  96 + private String remark;
  97 +
  98 + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
  99 + @ExcelProperty("创建时间")
  100 + private LocalDateTime createTime;
  101 +
  102 +}
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/repair/vo/MesDvRepairSaveReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.controller.admin.dv.repair.vo;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import lombok.Data;
  5 +
  6 +import jakarta.validation.constraints.NotBlank;
  7 +import jakarta.validation.constraints.NotNull;
  8 +import java.time.LocalDateTime;
  9 +
  10 +@Schema(description = "管理后台 - MES 维修工单新增/修改 Request VO")
  11 +@Data
  12 +public class MesDvRepairSaveReqVO {
  13 +
  14 + @Schema(description = "编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "1024")
  15 + private Long id;
  16 +
  17 + @Schema(description = "维修工单编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "REP2024001")
  18 + @NotBlank(message = "维修工单编码不能为空")
  19 + private String code;
  20 +
  21 + @Schema(description = "维修工单名称", example = "注塑机液压系统维修")
  22 + private String name;
  23 +
  24 + @Schema(description = "设备编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
  25 + @NotNull(message = "设备不能为空")
  26 + private Long machineryId;
  27 +
  28 + @Schema(description = "报修日期")
  29 + private LocalDateTime requireDate;
  30 +
  31 + @Schema(description = "维修完成日期")
  32 + private LocalDateTime finishDate;
  33 +
  34 + @Schema(description = "验收日期")
  35 + private LocalDateTime confirmDate;
  36 +
  37 + @Schema(description = "维修结果", example = "1")
  38 + private Integer result;
  39 +
  40 + @Schema(description = "维修人用户编号", example = "1")
  41 + private Long acceptedUserId;
  42 +
  43 + @Schema(description = "验收人用户编号", example = "1")
  44 + private Long confirmUserId;
  45 +
  46 + @Schema(description = "来源单据类型", example = "1")
  47 + private Integer sourceDocType;
  48 +
  49 + @Schema(description = "来源单据编号", example = "1")
  50 + private Long sourceDocId;
  51 +
  52 + @Schema(description = "来源单据编码", example = "DOC001")
  53 + private String sourceDocCode;
  54 +
  55 + // TODO @AI:这个字段,不允许提交
  56 + @Schema(description = "状态", example = "10")
  57 + private Integer status;
  58 +
  59 + @Schema(description = "备注", example = "测试备注")
  60 + private String remark;
  61 +
  62 +}
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/repair/vo/line/MesDvRepairLinePageReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.controller.admin.dv.repair.vo.line;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageParam;
  4 +import io.swagger.v3.oas.annotations.media.Schema;
  5 +import lombok.Data;
  6 +import lombok.EqualsAndHashCode;
  7 +import lombok.ToString;
  8 +
  9 +@Schema(description = "管理后台 - MES 维修工单行分页 Request VO")
  10 +@Data
  11 +@EqualsAndHashCode(callSuper = true)
  12 +@ToString(callSuper = true)
  13 +public class MesDvRepairLinePageReqVO extends PageParam {
  14 +
  15 + @Schema(description = "维修工单编号", example = "1")
  16 + private Long repairId;
  17 +
  18 +}
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/repair/vo/line/MesDvRepairLineRespVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.controller.admin.dv.repair.vo.line;
  2 +
  3 +import cn.idev.excel.annotation.ExcelIgnoreUnannotated;
  4 +import cn.idev.excel.annotation.ExcelProperty;
  5 +import io.swagger.v3.oas.annotations.media.Schema;
  6 +import lombok.Data;
  7 +
  8 +import java.time.LocalDateTime;
  9 +
  10 +@Schema(description = "管理后台 - MES 维修工单行 Response VO")
  11 +@Data
  12 +@ExcelIgnoreUnannotated
  13 +public class MesDvRepairLineRespVO {
  14 +
  15 + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
  16 + @ExcelProperty("编号")
  17 + private Long id;
  18 +
  19 + @Schema(description = "维修工单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
  20 + private Long repairId;
  21 +
  22 + @Schema(description = "点检保养项目编号", example = "1")
  23 + private Long subjectId;
  24 +
  25 + @Schema(description = "项目名称", example = "检查机油")
  26 + @ExcelProperty("项目名称")
  27 + private String subjectName;
  28 +
  29 + @Schema(description = "项目内容", example = "检查机油是否充足")
  30 + @ExcelProperty("项目内容")
  31 + private String subjectContent;
  32 +
  33 + @Schema(description = "项目标准", example = "无漏油")
  34 + @ExcelProperty("标准")
  35 + private String subjectStandard;
  36 +
  37 + @Schema(description = "故障描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "液压系统漏油")
  38 + @ExcelProperty("故障描述")
  39 + private String malfunction;
  40 +
  41 + @Schema(description = "故障图片 URL", example = "https://example.com/image.png")
  42 + private String malfunctionUrl;
  43 +
  44 + @Schema(description = "维修描述", example = "更换密封圈")
  45 + @ExcelProperty("维修描述")
  46 + private String description;
  47 +
  48 + @Schema(description = "备注", example = "测试备注")
  49 + @ExcelProperty("备注")
  50 + private String remark;
  51 +
  52 + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED)
  53 + @ExcelProperty("创建时间")
  54 + private LocalDateTime createTime;
  55 +
  56 +}
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/repair/vo/line/MesDvRepairLineSaveReqVO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.controller.admin.dv.repair.vo.line;
  2 +
  3 +import io.swagger.v3.oas.annotations.media.Schema;
  4 +import lombok.Data;
  5 +
  6 +import jakarta.validation.constraints.NotBlank;
  7 +import jakarta.validation.constraints.NotNull;
  8 +
  9 +@Schema(description = "管理后台 - MES 维修工单行新增/修改 Request VO")
  10 +@Data
  11 +public class MesDvRepairLineSaveReqVO {
  12 +
  13 + @Schema(description = "编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "1024")
  14 + private Long id;
  15 +
  16 + @Schema(description = "维修工单编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1")
  17 + @NotNull(message = "维修工单不能为空")
  18 + private Long repairId;
  19 +
  20 + @Schema(description = "点检保养项目编号", example = "1")
  21 + private Long subjectId;
  22 +
  23 + @Schema(description = "故障描述", requiredMode = Schema.RequiredMode.REQUIRED, example = "液压系统漏油")
  24 + @NotBlank(message = "故障描述不能为空")
  25 + private String malfunction;
  26 +
  27 + @Schema(description = "故障图片 URL", example = "https://example.com/image.png")
  28 + private String malfunctionUrl;
  29 +
  30 + @Schema(description = "维修描述", example = "更换密封圈")
  31 + private String description;
  32 +
  33 + @Schema(description = "备注", example = "测试备注")
  34 + private String remark;
  35 +
  36 +}
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/dv/maintenrecord/MesDvMaintenRecordDO.java
... ... @@ -52,6 +52,8 @@ public class MesDvMaintenRecordDO extends BaseDO {
52 52 * 关联 AdminUserDO#getId()
53 53 */
54 54 private Long userId;
  55 + // TODO @AI:搞个枚举类,关联下;
  56 + // TODO @AI:mes_mainten_record_status,需要在 dict contants 美剧侠,然后 @关联下;
55 57 /**
56 58 * 状态
57 59 *
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/dv/maintenrecord/MesDvMaintenRecordLineDO.java
... ... @@ -39,6 +39,8 @@ public class MesDvMaintenRecordLineDO extends BaseDO {
39 39 * 关联 {@link MesDvSubjectDO#getId()}
40 40 */
41 41 private Long subjectId;
  42 + // TODO @AI:搞个枚举类,关联下;
  43 + // TODO @AI:mes_mainten_status,需要在 dict contants 美剧侠,然后 @关联下;
42 44 /**
43 45 * 保养结果
44 46 *
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/dv/repair/MesDvRepairDO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.dal.dataobject.dv.repair;
  2 +
  3 +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
  4 +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.machinery.MesDvMachineryDO;
  5 +import com.baomidou.mybatisplus.annotation.KeySequence;
  6 +import com.baomidou.mybatisplus.annotation.TableId;
  7 +import com.baomidou.mybatisplus.annotation.TableName;
  8 +import lombok.*;
  9 +
  10 +import java.time.LocalDateTime;
  11 +
  12 +/**
  13 + * MES 维修工单 DO
  14 + *
  15 + * @author 芋道源码
  16 + */
  17 +@TableName("mes_dv_repair")
  18 +@KeySequence("mes_dv_repair_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
  19 +@Data
  20 +@EqualsAndHashCode(callSuper = true)
  21 +@ToString(callSuper = true)
  22 +@Builder
  23 +@NoArgsConstructor
  24 +@AllArgsConstructor
  25 +public class MesDvRepairDO extends BaseDO {
  26 +
  27 + /**
  28 + * 编号
  29 + */
  30 + @TableId
  31 + private Long id;
  32 + /**
  33 + * 维修工单编码
  34 + */
  35 + private String code;
  36 + /**
  37 + * 维修工单名称
  38 + */
  39 + private String name;
  40 + /**
  41 + * 设备编号
  42 + *
  43 + * 关联 {@link MesDvMachineryDO#getId()}
  44 + */
  45 + private Long machineryId;
  46 + /**
  47 + * 报修日期
  48 + */
  49 + private LocalDateTime requireDate;
  50 + /**
  51 + * 维修完成日期
  52 + */
  53 + private LocalDateTime finishDate;
  54 + /**
  55 + * 验收日期
  56 + */
  57 + private LocalDateTime confirmDate;
  58 + // TODO @AI:枚举类;
  59 + // TODO @AI:字典,需要在 dict constants;
  60 + /**
  61 + * 维修结果
  62 + *
  63 + * 字典类型 mes_dv_repair_result
  64 + */
  65 + private Integer result;
  66 + /**
  67 + * 维修人用户编号
  68 + *
  69 + * 关联 AdminUserDO#getId()
  70 + */
  71 + private Long acceptedUserId;
  72 + /**
  73 + * 验收人用户编号
  74 + *
  75 + * 关联 AdminUserDO#getId()
  76 + */
  77 + private Long confirmUserId;
  78 + // TODO @芋艿:sourceDocType、sourceDocId、sourceDocCode 需要哪里处理;
  79 + /**
  80 + * 来源单据类型
  81 + */
  82 + private Integer sourceDocType;
  83 + /**
  84 + * 来源单据编号
  85 + */
  86 + private Long sourceDocId;
  87 + /**
  88 + * 来源单据编码
  89 + */
  90 + private String sourceDocCode;
  91 + // TODO @AI:枚举类;
  92 + // TODO @AI:字典,需要在 dict constants;
  93 + /**
  94 + * 状态
  95 + *
  96 + * 字典类型 mes_dv_repair_status
  97 + */
  98 + private Integer status;
  99 + /**
  100 + * 备注
  101 + */
  102 + private String remark;
  103 + /**
  104 + * 预留字段 1
  105 + */
  106 + private String attribute1;
  107 + /**
  108 + * 预留字段 2
  109 + */
  110 + private String attribute2;
  111 + /**
  112 + * 预留字段 3
  113 + */
  114 + private Integer attribute3;
  115 + /**
  116 + * 预留字段 4
  117 + */
  118 + private Integer attribute4;
  119 +
  120 +}
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/dv/repair/MesDvRepairLineDO.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.dal.dataobject.dv.repair;
  2 +
  3 +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
  4 +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.subject.MesDvSubjectDO;
  5 +import com.baomidou.mybatisplus.annotation.KeySequence;
  6 +import com.baomidou.mybatisplus.annotation.TableId;
  7 +import com.baomidou.mybatisplus.annotation.TableName;
  8 +import lombok.*;
  9 +
  10 +/**
  11 + * MES 维修工单行 DO
  12 + *
  13 + * @author 芋道源码
  14 + */
  15 +@TableName("mes_dv_repair_line")
  16 +@KeySequence("mes_dv_repair_line_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。
  17 +@Data
  18 +@EqualsAndHashCode(callSuper = true)
  19 +@ToString(callSuper = true)
  20 +@Builder
  21 +@NoArgsConstructor
  22 +@AllArgsConstructor
  23 +public class MesDvRepairLineDO extends BaseDO {
  24 +
  25 + /**
  26 + * 编号
  27 + */
  28 + @TableId
  29 + private Long id;
  30 + /**
  31 + * 维修工单编号
  32 + *
  33 + * 关联 {@link MesDvRepairDO#getId()}
  34 + */
  35 + private Long repairId;
  36 + /**
  37 + * 点检保养项目编号
  38 + *
  39 + * 关联 {@link MesDvSubjectDO#getId()}
  40 + */
  41 + private Long subjectId;
  42 + /**
  43 + * 故障描述
  44 + */
  45 + private String malfunction;
  46 + /**
  47 + * 故障图片 URL
  48 + */
  49 + private String malfunctionUrl;
  50 + /**
  51 + * 维修描述
  52 + */
  53 + private String description;
  54 + /**
  55 + * 备注
  56 + */
  57 + private String remark;
  58 + /**
  59 + * 预留字段 1
  60 + */
  61 + private String attribute1;
  62 + /**
  63 + * 预留字段 2
  64 + */
  65 + private String attribute2;
  66 + /**
  67 + * 预留字段 3
  68 + */
  69 + private Integer attribute3;
  70 + /**
  71 + * 预留字段 4
  72 + */
  73 + private Integer attribute4;
  74 +
  75 +}
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/dv/repair/MesDvRepairLineMapper.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.dal.mysql.dv.repair;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  4 +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
  5 +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
  6 +import cn.iocoder.yudao.module.mes.controller.admin.dv.repair.vo.line.MesDvRepairLinePageReqVO;
  7 +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.repair.MesDvRepairLineDO;
  8 +import org.apache.ibatis.annotations.Mapper;
  9 +
  10 +import java.util.List;
  11 +
  12 +/**
  13 + * MES 维修工单行 Mapper
  14 + *
  15 + * @author 芋道源码
  16 + */
  17 +@Mapper
  18 +public interface MesDvRepairLineMapper extends BaseMapperX<MesDvRepairLineDO> {
  19 +
  20 + default PageResult<MesDvRepairLineDO> selectPage(MesDvRepairLinePageReqVO reqVO) {
  21 + return selectPage(reqVO, new LambdaQueryWrapperX<MesDvRepairLineDO>()
  22 + .eqIfPresent(MesDvRepairLineDO::getRepairId, reqVO.getRepairId())
  23 + .orderByDesc(MesDvRepairLineDO::getId));
  24 + }
  25 +
  26 + default List<MesDvRepairLineDO> selectListByRepairId(Long repairId) {
  27 + return selectList(MesDvRepairLineDO::getRepairId, repairId);
  28 + }
  29 +
  30 + default int deleteByRepairId(Long repairId) {
  31 + return delete(MesDvRepairLineDO::getRepairId, repairId);
  32 + }
  33 +
  34 +}
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/dv/repair/MesDvRepairMapper.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.dal.mysql.dv.repair;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  4 +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
  5 +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
  6 +import cn.iocoder.yudao.module.mes.controller.admin.dv.repair.vo.MesDvRepairPageReqVO;
  7 +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.repair.MesDvRepairDO;
  8 +import org.apache.ibatis.annotations.Mapper;
  9 +
  10 +/**
  11 + * MES 维修工单 Mapper
  12 + *
  13 + * @author 芋道源码
  14 + */
  15 +@Mapper
  16 +public interface MesDvRepairMapper extends BaseMapperX<MesDvRepairDO> {
  17 +
  18 + default PageResult<MesDvRepairDO> selectPage(MesDvRepairPageReqVO reqVO) {
  19 + return selectPage(reqVO, new LambdaQueryWrapperX<MesDvRepairDO>()
  20 + .likeIfPresent(MesDvRepairDO::getCode, reqVO.getCode())
  21 + .likeIfPresent(MesDvRepairDO::getName, reqVO.getName())
  22 + .eqIfPresent(MesDvRepairDO::getStatus, reqVO.getStatus())
  23 + .betweenIfPresent(MesDvRepairDO::getRequireDate, reqVO.getRequireDate())
  24 + .orderByDesc(MesDvRepairDO::getId));
  25 + }
  26 +
  27 +}
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/dv/MesDvCheckRecordStatusEnum.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 MesDvCheckRecordStatusEnum implements ArrayValuable<Integer> {
  17 +
  18 + DRAFT(10, "草稿"),
  19 + FINISHED(20, "已完成");
  20 +
  21 + public static final Integer[] ARRAYS = Arrays.stream(values()).map(MesDvCheckRecordStatusEnum::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
... ... @@ -37,6 +37,7 @@ public class MesDvMaintenRecordLineServiceImpl implements MesDvMaintenRecordLine
37 37 public Long createMaintenRecordLine(MesDvMaintenRecordLineSaveReqVO createReqVO) {
38 38 // 1. 校验关联数据
39 39 validateMaintenRecordLineRelation(createReqVO);
  40 + // TODO @AI:已提交时,不允许编辑(最好对方提供一个通用方法)
40 41  
41 42 // 2. 插入
42 43 MesDvMaintenRecordLineDO maintenRecordLine = BeanUtils.toBean(createReqVO, MesDvMaintenRecordLineDO.class);
... ... @@ -58,7 +59,11 @@ public class MesDvMaintenRecordLineServiceImpl implements MesDvMaintenRecordLine
58 59  
59 60 @Override
60 61 public void deleteMaintenRecordLine(Long id) {
  62 + // 1. 校验存在
61 63 validateMaintenRecordLineExists(id);
  64 + // TODO @AI:已提交时,不允许删除;(最好对方提供一个通用方法)
  65 +
  66 + // 2. 删除
62 67 maintenRecordLineMapper.deleteById(id);
63 68 }
64 69  
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/maintenrecord/MesDvMaintenRecordServiceImpl.java
... ... @@ -42,6 +42,7 @@ public class MesDvMaintenRecordServiceImpl implements MesDvMaintenRecordService
42 42  
43 43 // 2. 插入
44 44 MesDvMaintenRecordDO maintenRecord = BeanUtils.toBean(createReqVO, MesDvMaintenRecordDO.class);
  45 + // TODO @AI:设置下默认状态;
45 46 maintenRecordMapper.insert(maintenRecord);
46 47 return maintenRecord.getId();
47 48 }
... ... @@ -52,9 +53,11 @@ public class MesDvMaintenRecordServiceImpl implements MesDvMaintenRecordService
52 53 validateMaintenRecordExists(updateReqVO.getId());
53 54 // 1.2 校验关联数据
54 55 validateMaintenRecordRelation(updateReqVO);
  56 + // TODO @AI:已提交时,不允许编辑
55 57  
56 58 // 2. 更新
57 59 MesDvMaintenRecordDO updateObj = BeanUtils.toBean(updateReqVO, MesDvMaintenRecordDO.class);
  60 + // TODO 设置为空,避免更新;
58 61 maintenRecordMapper.updateById(updateObj);
59 62 }
60 63  
... ... @@ -63,6 +66,7 @@ public class MesDvMaintenRecordServiceImpl implements MesDvMaintenRecordService
63 66 public void deleteMaintenRecord(Long id) {
64 67 // 校验存在
65 68 validateMaintenRecordExists(id);
  69 + // TODO @AI:已提交时,不允许删除
66 70  
67 71 // 删除
68 72 maintenRecordMapper.deleteById(id);
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/repair/MesDvRepairLineService.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.service.dv.repair;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  4 +import cn.iocoder.yudao.module.mes.controller.admin.dv.repair.vo.line.MesDvRepairLinePageReqVO;
  5 +import cn.iocoder.yudao.module.mes.controller.admin.dv.repair.vo.line.MesDvRepairLineSaveReqVO;
  6 +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.repair.MesDvRepairLineDO;
  7 +
  8 +import jakarta.validation.Valid;
  9 +
  10 +/**
  11 + * MES 维修工单行 Service 接口
  12 + *
  13 + * @author 芋道源码
  14 + */
  15 +public interface MesDvRepairLineService {
  16 +
  17 + /**
  18 + * 创建维修工单行
  19 + *
  20 + * @param createReqVO 创建信息
  21 + * @return 编号
  22 + */
  23 + Long createRepairLine(@Valid MesDvRepairLineSaveReqVO createReqVO);
  24 +
  25 + /**
  26 + * 更新维修工单行
  27 + *
  28 + * @param updateReqVO 更新信息
  29 + */
  30 + void updateRepairLine(@Valid MesDvRepairLineSaveReqVO updateReqVO);
  31 +
  32 + /**
  33 + * 删除维修工单行
  34 + *
  35 + * @param id 编号
  36 + */
  37 + void deleteRepairLine(Long id);
  38 +
  39 + /**
  40 + * 获得维修工单行
  41 + *
  42 + * @param id 编号
  43 + * @return 维修工单行
  44 + */
  45 + MesDvRepairLineDO getRepairLine(Long id);
  46 +
  47 + /**
  48 + * 获得维修工单行分页
  49 + *
  50 + * @param pageReqVO 分页查询
  51 + * @return 维修工单行分页
  52 + */
  53 + PageResult<MesDvRepairLineDO> getRepairLinePage(MesDvRepairLinePageReqVO pageReqVO);
  54 +
  55 +}
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/repair/MesDvRepairLineServiceImpl.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.service.dv.repair;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  4 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
  5 +import cn.iocoder.yudao.module.mes.controller.admin.dv.repair.vo.line.MesDvRepairLinePageReqVO;
  6 +import cn.iocoder.yudao.module.mes.controller.admin.dv.repair.vo.line.MesDvRepairLineSaveReqVO;
  7 +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.repair.MesDvRepairLineDO;
  8 +import cn.iocoder.yudao.module.mes.dal.mysql.dv.repair.MesDvRepairLineMapper;
  9 +import cn.iocoder.yudao.module.mes.service.dv.subject.MesDvSubjectService;
  10 +import jakarta.annotation.Resource;
  11 +import org.springframework.context.annotation.Lazy;
  12 +import org.springframework.stereotype.Service;
  13 +import org.springframework.validation.annotation.Validated;
  14 +
  15 +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
  16 +import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*;
  17 +
  18 +/**
  19 + * MES 维修工单行 Service 实现类
  20 + *
  21 + * @author 芋道源码
  22 + */
  23 +@Service
  24 +@Validated
  25 +public class MesDvRepairLineServiceImpl implements MesDvRepairLineService {
  26 +
  27 + @Resource
  28 + private MesDvRepairLineMapper repairLineMapper;
  29 +
  30 + @Resource
  31 + @Lazy
  32 + private MesDvRepairService repairService;
  33 + @Resource
  34 + private MesDvSubjectService subjectService;
  35 +
  36 + @Override
  37 + public Long createRepairLine(MesDvRepairLineSaveReqVO createReqVO) {
  38 + // 1. 校验关联数据
  39 + validateRepairLineRelation(createReqVO);
  40 + // TODO @AI:关联数据的状态的校验(最好对方提供的方法)
  41 +
  42 + // 2. 插入
  43 + MesDvRepairLineDO repairLine = BeanUtils.toBean(createReqVO, MesDvRepairLineDO.class);
  44 + repairLineMapper.insert(repairLine);
  45 + return repairLine.getId();
  46 + }
  47 +
  48 + @Override
  49 + public void updateRepairLine(MesDvRepairLineSaveReqVO updateReqVO) {
  50 + // 1.1 校验存在
  51 + validateRepairLineExists(updateReqVO.getId());
  52 + // 1.2 校验关联数据
  53 + validateRepairLineRelation(updateReqVO);
  54 + // TODO @AI:关联数据的状态的校验(最好对方提供的方法)
  55 +
  56 + // 2. 更新
  57 + MesDvRepairLineDO updateObj = BeanUtils.toBean(updateReqVO, MesDvRepairLineDO.class);
  58 + repairLineMapper.updateById(updateObj);
  59 + }
  60 +
  61 + @Override
  62 + public void deleteRepairLine(Long id) {
  63 + // 校验存在
  64 + validateRepairLineExists(id);
  65 + // TODO @AI:关联数据的状态的校验(最好对方提供的方法)
  66 +
  67 + // 删除
  68 + repairLineMapper.deleteById(id);
  69 + }
  70 +
  71 + private void validateRepairLineRelation(MesDvRepairLineSaveReqVO reqVO) {
  72 + // 校验维修工单是否存在
  73 + repairService.validateRepairExists(reqVO.getRepairId());
  74 + // 校验点检保养项目是否存在(可选)
  75 + if (reqVO.getSubjectId() != null) {
  76 + subjectService.validateSubjectExists(reqVO.getSubjectId());
  77 + }
  78 + }
  79 +
  80 + private void validateRepairLineExists(Long id) {
  81 + if (repairLineMapper.selectById(id) == null) {
  82 + throw exception(DV_REPAIR_LINE_NOT_EXISTS);
  83 + }
  84 + }
  85 +
  86 + @Override
  87 + public MesDvRepairLineDO getRepairLine(Long id) {
  88 + return repairLineMapper.selectById(id);
  89 + }
  90 +
  91 + @Override
  92 + public PageResult<MesDvRepairLineDO> getRepairLinePage(MesDvRepairLinePageReqVO pageReqVO) {
  93 + return repairLineMapper.selectPage(pageReqVO);
  94 + }
  95 +
  96 +}
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/repair/MesDvRepairService.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.service.dv.repair;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  4 +import cn.iocoder.yudao.module.mes.controller.admin.dv.repair.vo.MesDvRepairPageReqVO;
  5 +import cn.iocoder.yudao.module.mes.controller.admin.dv.repair.vo.MesDvRepairSaveReqVO;
  6 +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.repair.MesDvRepairDO;
  7 +
  8 +import jakarta.validation.Valid;
  9 +
  10 +/**
  11 + * MES 维修工单 Service 接口
  12 + *
  13 + * @author 芋道源码
  14 + */
  15 +public interface MesDvRepairService {
  16 +
  17 + /**
  18 + * 创建维修工单
  19 + *
  20 + * @param createReqVO 创建信息
  21 + * @return 编号
  22 + */
  23 + Long createRepair(@Valid MesDvRepairSaveReqVO createReqVO);
  24 +
  25 + /**
  26 + * 更新维修工单
  27 + *
  28 + * @param updateReqVO 更新信息
  29 + */
  30 + void updateRepair(@Valid MesDvRepairSaveReqVO updateReqVO);
  31 +
  32 + /**
  33 + * 删除维修工单
  34 + *
  35 + * @param id 编号
  36 + */
  37 + void deleteRepair(Long id);
  38 +
  39 + /**
  40 + * 校验维修工单是否存在
  41 + *
  42 + * @param id 编号
  43 + */
  44 + void validateRepairExists(Long id);
  45 +
  46 + /**
  47 + * 获得维修工单
  48 + *
  49 + * @param id 编号
  50 + * @return 维修工单
  51 + */
  52 + MesDvRepairDO getRepair(Long id);
  53 +
  54 + /**
  55 + * 获得维修工单分页
  56 + *
  57 + * @param pageReqVO 分页查询
  58 + * @return 维修工单分页
  59 + */
  60 + PageResult<MesDvRepairDO> getRepairPage(MesDvRepairPageReqVO pageReqVO);
  61 +
  62 +}
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/repair/MesDvRepairServiceImpl.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.service.dv.repair;
  2 +
  3 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  4 +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.MesDvRepairSaveReqVO;
  7 +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.MesDvRepairMapper;
  10 +import cn.iocoder.yudao.module.mes.service.dv.machinery.MesDvMachineryService;
  11 +import jakarta.annotation.Resource;
  12 +import org.springframework.stereotype.Service;
  13 +import org.springframework.transaction.annotation.Transactional;
  14 +import org.springframework.validation.annotation.Validated;
  15 +
  16 +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
  17 +import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*;
  18 +
  19 +/**
  20 + * MES 维修工单 Service 实现类
  21 + *
  22 + * @author 芋道源码
  23 + */
  24 +@Service
  25 +@Validated
  26 +public class MesDvRepairServiceImpl implements MesDvRepairService {
  27 +
  28 + @Resource
  29 + private MesDvRepairMapper repairMapper;
  30 + @Resource
  31 + private MesDvRepairLineMapper repairLineMapper;
  32 + @Resource
  33 + private MesDvMachineryService machineryService;
  34 +
  35 + @Override
  36 + public Long createRepair(MesDvRepairSaveReqVO createReqVO) {
  37 + // 1. 校验关联数据
  38 + validateRepairRelation(createReqVO);
  39 +
  40 + // 2. 插入
  41 + MesDvRepairDO repair = BeanUtils.toBean(createReqVO, MesDvRepairDO.class);
  42 + // TODO @AI:status
  43 + repairMapper.insert(repair);
  44 + return repair.getId();
  45 + }
  46 +
  47 + @Override
  48 + public void updateRepair(MesDvRepairSaveReqVO updateReqVO) {
  49 + // 1.1 校验存在
  50 + validateRepairExists(updateReqVO.getId());
  51 + // 1.2 校验关联数据
  52 + validateRepairRelation(updateReqVO);
  53 +
  54 + // 2. 更新
  55 + MesDvRepairDO updateObj = BeanUtils.toBean(updateReqVO, MesDvRepairDO.class);
  56 + // TODO @AI:status
  57 + repairMapper.updateById(updateObj);
  58 + }
  59 +
  60 + @Override
  61 + @Transactional(rollbackFor = Exception.class)
  62 + public void deleteRepair(Long id) {
  63 + // 校验存在
  64 + validateRepairExists(id);
  65 +
  66 + // 删除
  67 + repairMapper.deleteById(id);
  68 + // 级联删除子表
  69 + repairLineMapper.deleteByRepairId(id);
  70 + }
  71 +
  72 + private void validateRepairRelation(MesDvRepairSaveReqVO reqVO) {
  73 + // 校验设备是否存在
  74 + machineryService.validateMachineryExists(reqVO.getMachineryId());
  75 + }
  76 +
  77 + @Override
  78 + public void validateRepairExists(Long id) {
  79 + if (repairMapper.selectById(id) == null) {
  80 + throw exception(DV_REPAIR_NOT_EXISTS);
  81 + }
  82 + }
  83 +
  84 + @Override
  85 + public MesDvRepairDO getRepair(Long id) {
  86 + return repairMapper.selectById(id);
  87 + }
  88 +
  89 + @Override
  90 + public PageResult<MesDvRepairDO> getRepairPage(MesDvRepairPageReqVO pageReqVO) {
  91 + return repairMapper.selectPage(pageReqVO);
  92 + }
  93 +
  94 +}
... ...