Commit 17fedca9d5e50c01f047a448f481360bdba2501f
1 parent
9b22a9cf
feat(mes): 新增设备保养记录及明细相关功能,包括请求和响应 VO、Controller、Service 及 API 接口
Showing
16 changed files
with
968 additions
and
0 deletions
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/maintenrecord/MesDvMaintenRecordController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.dv.maintenrecord; | ||
| 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.maintenrecord.vo.MesDvMaintenRecordPageReqVO; | ||
| 12 | +import cn.iocoder.yudao.module.mes.controller.admin.dv.maintenrecord.vo.MesDvMaintenRecordRespVO; | ||
| 13 | +import cn.iocoder.yudao.module.mes.controller.admin.dv.maintenrecord.vo.MesDvMaintenRecordSaveReqVO; | ||
| 14 | +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.checkplan.MesDvCheckPlanDO; | ||
| 15 | +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.machinery.MesDvMachineryDO; | ||
| 16 | +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.maintenrecord.MesDvMaintenRecordDO; | ||
| 17 | +import cn.iocoder.yudao.module.mes.service.dv.checkplan.MesDvCheckPlanService; | ||
| 18 | +import cn.iocoder.yudao.module.mes.service.dv.machinery.MesDvMachineryService; | ||
| 19 | +import cn.iocoder.yudao.module.mes.service.dv.maintenrecord.MesDvMaintenRecordService; | ||
| 20 | +import cn.iocoder.yudao.module.system.api.user.AdminUserApi; | ||
| 21 | +import cn.iocoder.yudao.module.system.api.user.dto.AdminUserRespDTO; | ||
| 22 | +import io.swagger.v3.oas.annotations.Operation; | ||
| 23 | +import io.swagger.v3.oas.annotations.Parameter; | ||
| 24 | +import io.swagger.v3.oas.annotations.tags.Tag; | ||
| 25 | +import jakarta.annotation.Resource; | ||
| 26 | +import jakarta.servlet.http.HttpServletResponse; | ||
| 27 | +import jakarta.validation.Valid; | ||
| 28 | +import org.springframework.security.access.prepost.PreAuthorize; | ||
| 29 | +import org.springframework.validation.annotation.Validated; | ||
| 30 | +import org.springframework.web.bind.annotation.*; | ||
| 31 | + | ||
| 32 | +import java.io.IOException; | ||
| 33 | +import java.util.Collections; | ||
| 34 | +import java.util.List; | ||
| 35 | +import java.util.Map; | ||
| 36 | + | ||
| 37 | +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; | ||
| 38 | +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||
| 39 | +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertSet; | ||
| 40 | + | ||
| 41 | +@Tag(name = "管理后台 - MES 设备保养记录") | ||
| 42 | +@RestController | ||
| 43 | +@RequestMapping("/mes/dv/mainten-record") | ||
| 44 | +@Validated | ||
| 45 | +public class MesDvMaintenRecordController { | ||
| 46 | + | ||
| 47 | + @Resource | ||
| 48 | + private MesDvMaintenRecordService maintenRecordService; | ||
| 49 | + | ||
| 50 | + @Resource | ||
| 51 | + private MesDvCheckPlanService checkPlanService; | ||
| 52 | + | ||
| 53 | + @Resource | ||
| 54 | + private MesDvMachineryService machineryService; | ||
| 55 | + | ||
| 56 | + @Resource | ||
| 57 | + private AdminUserApi adminUserApi; | ||
| 58 | + | ||
| 59 | + @PostMapping("/create") | ||
| 60 | + @Operation(summary = "创建设备保养记录") | ||
| 61 | + @PreAuthorize("@ss.hasPermission('mes:dv-mainten-record:create')") | ||
| 62 | + public CommonResult<Long> createMaintenRecord(@Valid @RequestBody MesDvMaintenRecordSaveReqVO createReqVO) { | ||
| 63 | + return success(maintenRecordService.createMaintenRecord(createReqVO)); | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + @PutMapping("/update") | ||
| 67 | + @Operation(summary = "更新设备保养记录") | ||
| 68 | + @PreAuthorize("@ss.hasPermission('mes:dv-mainten-record:update')") | ||
| 69 | + public CommonResult<Boolean> updateMaintenRecord(@Valid @RequestBody MesDvMaintenRecordSaveReqVO updateReqVO) { | ||
| 70 | + maintenRecordService.updateMaintenRecord(updateReqVO); | ||
| 71 | + return success(true); | ||
| 72 | + } | ||
| 73 | + | ||
| 74 | + @DeleteMapping("/delete") | ||
| 75 | + @Operation(summary = "删除设备保养记录") | ||
| 76 | + @Parameter(name = "id", description = "编号", required = true) | ||
| 77 | + @PreAuthorize("@ss.hasPermission('mes:dv-mainten-record:delete')") | ||
| 78 | + public CommonResult<Boolean> deleteMaintenRecord(@RequestParam("id") Long id) { | ||
| 79 | + maintenRecordService.deleteMaintenRecord(id); | ||
| 80 | + return success(true); | ||
| 81 | + } | ||
| 82 | + | ||
| 83 | + @GetMapping("/get") | ||
| 84 | + @Operation(summary = "获得设备保养记录") | ||
| 85 | + @Parameter(name = "id", description = "编号", required = true, example = "1024") | ||
| 86 | + @PreAuthorize("@ss.hasPermission('mes:dv-mainten-record:query')") | ||
| 87 | + public CommonResult<MesDvMaintenRecordRespVO> getMaintenRecord(@RequestParam("id") Long id) { | ||
| 88 | + MesDvMaintenRecordDO maintenRecord = maintenRecordService.getMaintenRecord(id); | ||
| 89 | + if (maintenRecord == null) { | ||
| 90 | + return success(null); | ||
| 91 | + } | ||
| 92 | + return success(buildMaintenRecordRespVOList(Collections.singletonList(maintenRecord)).get(0)); | ||
| 93 | + } | ||
| 94 | + | ||
| 95 | + @GetMapping("/page") | ||
| 96 | + @Operation(summary = "获得设备保养记录分页") | ||
| 97 | + @PreAuthorize("@ss.hasPermission('mes:dv-mainten-record:query')") | ||
| 98 | + public CommonResult<PageResult<MesDvMaintenRecordRespVO>> getMaintenRecordPage(@Valid MesDvMaintenRecordPageReqVO pageReqVO) { | ||
| 99 | + PageResult<MesDvMaintenRecordDO> pageResult = maintenRecordService.getMaintenRecordPage(pageReqVO); | ||
| 100 | + return success(new PageResult<>(buildMaintenRecordRespVOList(pageResult.getList()), pageResult.getTotal())); | ||
| 101 | + } | ||
| 102 | + | ||
| 103 | + @GetMapping("/export-excel") | ||
| 104 | + @Operation(summary = "导出设备保养记录 Excel") | ||
| 105 | + @PreAuthorize("@ss.hasPermission('mes:dv-mainten-record:export')") | ||
| 106 | + @ApiAccessLog(operateType = EXPORT) | ||
| 107 | + public void exportMaintenRecordExcel(@Valid MesDvMaintenRecordPageReqVO pageReqVO, | ||
| 108 | + HttpServletResponse response) throws IOException { | ||
| 109 | + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | ||
| 110 | + List<MesDvMaintenRecordDO> list = maintenRecordService.getMaintenRecordPage(pageReqVO).getList(); | ||
| 111 | + // 导出 Excel | ||
| 112 | + ExcelUtils.write(response, "设备保养记录.xls", "数据", MesDvMaintenRecordRespVO.class, | ||
| 113 | + buildMaintenRecordRespVOList(list)); | ||
| 114 | + } | ||
| 115 | + | ||
| 116 | + // ==================== 拼接 VO ==================== | ||
| 117 | + | ||
| 118 | + private List<MesDvMaintenRecordRespVO> buildMaintenRecordRespVOList(List<MesDvMaintenRecordDO> list) { | ||
| 119 | + if (CollUtil.isEmpty(list)) { | ||
| 120 | + return Collections.emptyList(); | ||
| 121 | + } | ||
| 122 | + // 1. 批量获取关联数据 | ||
| 123 | + Map<Long, MesDvCheckPlanDO> planMap = checkPlanService.getCheckPlanMap( | ||
| 124 | + convertSet(list, MesDvMaintenRecordDO::getPlanId)); | ||
| 125 | + Map<Long, MesDvMachineryDO> machineryMap = machineryService.getMachineryMap( | ||
| 126 | + convertSet(list, MesDvMaintenRecordDO::getMachineryId)); | ||
| 127 | + Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap( | ||
| 128 | + convertSet(list, MesDvMaintenRecordDO::getUserId)); | ||
| 129 | + // 2. 拼接 VO | ||
| 130 | + return BeanUtils.toBean(list, MesDvMaintenRecordRespVO.class, vo -> { | ||
| 131 | + MapUtils.findAndThen(planMap, vo.getPlanId(), | ||
| 132 | + plan -> vo.setPlanName(plan.getName())); | ||
| 133 | + MapUtils.findAndThen(machineryMap, vo.getMachineryId(), machinery -> vo | ||
| 134 | + .setMachineryCode(machinery.getCode()).setMachineryName(machinery.getName()) | ||
| 135 | + .setMachineryBrand(machinery.getBrand()).setMachinerySpec(machinery.getSpec())); | ||
| 136 | + MapUtils.findAndThen(userMap, vo.getUserId(), | ||
| 137 | + user -> vo.setNickname(user.getNickname())); | ||
| 138 | + }); | ||
| 139 | + } | ||
| 140 | + | ||
| 141 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/maintenrecord/MesDvMaintenRecordLineController.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.dv.maintenrecord; | ||
| 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.maintenrecord.vo.line.MesDvMaintenRecordLinePageReqVO; | ||
| 12 | +import cn.iocoder.yudao.module.mes.controller.admin.dv.maintenrecord.vo.line.MesDvMaintenRecordLineRespVO; | ||
| 13 | +import cn.iocoder.yudao.module.mes.controller.admin.dv.maintenrecord.vo.line.MesDvMaintenRecordLineSaveReqVO; | ||
| 14 | +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.maintenrecord.MesDvMaintenRecordLineDO; | ||
| 15 | +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.subject.MesDvSubjectDO; | ||
| 16 | +import cn.iocoder.yudao.module.mes.service.dv.maintenrecord.MesDvMaintenRecordLineService; | ||
| 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/mainten-record-line") | ||
| 40 | +@Validated | ||
| 41 | +public class MesDvMaintenRecordLineController { | ||
| 42 | + | ||
| 43 | + @Resource | ||
| 44 | + private MesDvMaintenRecordLineService maintenRecordLineService; | ||
| 45 | + | ||
| 46 | + @Resource | ||
| 47 | + private MesDvSubjectService subjectService; | ||
| 48 | + | ||
| 49 | + @PostMapping("/create") | ||
| 50 | + @Operation(summary = "创建设备保养记录明细") | ||
| 51 | + @PreAuthorize("@ss.hasPermission('mes:dv-mainten-record:create')") | ||
| 52 | + public CommonResult<Long> createMaintenRecordLine(@Valid @RequestBody MesDvMaintenRecordLineSaveReqVO createReqVO) { | ||
| 53 | + return success(maintenRecordLineService.createMaintenRecordLine(createReqVO)); | ||
| 54 | + } | ||
| 55 | + | ||
| 56 | + @PutMapping("/update") | ||
| 57 | + @Operation(summary = "更新设备保养记录明细") | ||
| 58 | + @PreAuthorize("@ss.hasPermission('mes:dv-mainten-record:update')") | ||
| 59 | + public CommonResult<Boolean> updateMaintenRecordLine(@Valid @RequestBody MesDvMaintenRecordLineSaveReqVO updateReqVO) { | ||
| 60 | + maintenRecordLineService.updateMaintenRecordLine(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-mainten-record:delete')") | ||
| 68 | + public CommonResult<Boolean> deleteMaintenRecordLine(@RequestParam("id") Long id) { | ||
| 69 | + maintenRecordLineService.deleteMaintenRecordLine(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-mainten-record:query')") | ||
| 77 | + public CommonResult<MesDvMaintenRecordLineRespVO> getMaintenRecordLine(@RequestParam("id") Long id) { | ||
| 78 | + MesDvMaintenRecordLineDO maintenRecordLine = maintenRecordLineService.getMaintenRecordLine(id); | ||
| 79 | + if (maintenRecordLine == null) { | ||
| 80 | + return success(null); | ||
| 81 | + } | ||
| 82 | + return success(buildMaintenRecordLineRespVOList(Collections.singletonList(maintenRecordLine)).get(0)); | ||
| 83 | + } | ||
| 84 | + | ||
| 85 | + @GetMapping("/page") | ||
| 86 | + @Operation(summary = "获得设备保养记录明细分页") | ||
| 87 | + @PreAuthorize("@ss.hasPermission('mes:dv-mainten-record:query')") | ||
| 88 | + public CommonResult<PageResult<MesDvMaintenRecordLineRespVO>> getMaintenRecordLinePage(@Valid MesDvMaintenRecordLinePageReqVO pageReqVO) { | ||
| 89 | + PageResult<MesDvMaintenRecordLineDO> pageResult = maintenRecordLineService.getMaintenRecordLinePage(pageReqVO); | ||
| 90 | + return success(new PageResult<>(buildMaintenRecordLineRespVOList(pageResult.getList()), pageResult.getTotal())); | ||
| 91 | + } | ||
| 92 | + | ||
| 93 | + @GetMapping("/export-excel") | ||
| 94 | + @Operation(summary = "导出设备保养记录明细 Excel") | ||
| 95 | + @PreAuthorize("@ss.hasPermission('mes:dv-mainten-record:export')") | ||
| 96 | + @ApiAccessLog(operateType = EXPORT) | ||
| 97 | + public void exportMaintenRecordLineExcel(@Valid MesDvMaintenRecordLinePageReqVO pageReqVO, | ||
| 98 | + HttpServletResponse response) throws IOException { | ||
| 99 | + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | ||
| 100 | + List<MesDvMaintenRecordLineDO> list = maintenRecordLineService.getMaintenRecordLinePage(pageReqVO).getList(); | ||
| 101 | + // 导出 Excel | ||
| 102 | + ExcelUtils.write(response, "设备保养记录明细.xls", "数据", MesDvMaintenRecordLineRespVO.class, | ||
| 103 | + buildMaintenRecordLineRespVOList(list)); | ||
| 104 | + } | ||
| 105 | + | ||
| 106 | + // ==================== 拼接 VO ==================== | ||
| 107 | + | ||
| 108 | + private List<MesDvMaintenRecordLineRespVO> buildMaintenRecordLineRespVOList(List<MesDvMaintenRecordLineDO> list) { | ||
| 109 | + if (CollUtil.isEmpty(list)) { | ||
| 110 | + return Collections.emptyList(); | ||
| 111 | + } | ||
| 112 | + // 1. 批量获取关联数据 | ||
| 113 | + Map<Long, MesDvSubjectDO> subjectMap = subjectService.getSubjectMap( | ||
| 114 | + convertSet(list, MesDvMaintenRecordLineDO::getSubjectId)); | ||
| 115 | + // 2. 拼接 VO | ||
| 116 | + return BeanUtils.toBean(list, MesDvMaintenRecordLineRespVO.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/maintenrecord/vo/MesDvMaintenRecordPageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.dv.maintenrecord.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 MesDvMaintenRecordPageReqVO extends PageParam { | ||
| 19 | + | ||
| 20 | + @Schema(description = "计划名称", example = "计划1") | ||
| 21 | + private String planName; | ||
| 22 | + | ||
| 23 | + @Schema(description = "设备编码", example = "M1") | ||
| 24 | + private String machineryCode; | ||
| 25 | + | ||
| 26 | + @Schema(description = "设备名称", example = "设备1") | ||
| 27 | + private String machineryName; | ||
| 28 | + | ||
| 29 | + @Schema(description = "保养人名称", example = "张三") | ||
| 30 | + private String nickname; | ||
| 31 | + | ||
| 32 | + @Schema(description = "保养时间") | ||
| 33 | + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||
| 34 | + private LocalDateTime[] maintenTime; | ||
| 35 | + | ||
| 36 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/maintenrecord/vo/MesDvMaintenRecordRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.dv.maintenrecord.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 MesDvMaintenRecordRespVO { | ||
| 17 | + | ||
| 18 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") | ||
| 19 | + @ExcelProperty("编号") | ||
| 20 | + private Long id; | ||
| 21 | + | ||
| 22 | + @Schema(description = "计划编号", example = "1") | ||
| 23 | + private Long planId; | ||
| 24 | + | ||
| 25 | + @Schema(description = "计划名称", example = "保养计划1") | ||
| 26 | + @ExcelProperty("计划名称") | ||
| 27 | + private String planName; | ||
| 28 | + | ||
| 29 | + @Schema(description = "设备编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 30 | + private Long machineryId; | ||
| 31 | + | ||
| 32 | + @Schema(description = "设备编码", example = "M001") | ||
| 33 | + @ExcelProperty("设备编码") | ||
| 34 | + private String machineryCode; | ||
| 35 | + | ||
| 36 | + @Schema(description = "设备名称", example = "机床A") | ||
| 37 | + @ExcelProperty("设备名称") | ||
| 38 | + private String machineryName; | ||
| 39 | + | ||
| 40 | + @Schema(description = "品牌", example = "西门子") | ||
| 41 | + @ExcelProperty("品牌") | ||
| 42 | + private String machineryBrand; | ||
| 43 | + | ||
| 44 | + @Schema(description = "规格型号", example = "X-100") | ||
| 45 | + @ExcelProperty("规格型号") | ||
| 46 | + private String machinerySpec; | ||
| 47 | + | ||
| 48 | + @Schema(description = "保养时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 49 | + @ExcelProperty("保养时间") | ||
| 50 | + private LocalDateTime maintenTime; | ||
| 51 | + | ||
| 52 | + @Schema(description = "用户编号", example = "1") | ||
| 53 | + private Long userId; | ||
| 54 | + | ||
| 55 | + @Schema(description = "保养人名称", example = "张三") | ||
| 56 | + @ExcelProperty("保养人") | ||
| 57 | + private String nickname; | ||
| 58 | + | ||
| 59 | + @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "10") | ||
| 60 | + @ExcelProperty(value = "状态", converter = DictConvert.class) | ||
| 61 | + @DictFormat(DictTypeConstants.MES_MAINTEN_RECORD_STATUS) | ||
| 62 | + private Integer status; | ||
| 63 | + | ||
| 64 | + @Schema(description = "备注", example = "测试备注") | ||
| 65 | + @ExcelProperty("备注") | ||
| 66 | + private String remark; | ||
| 67 | + | ||
| 68 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 69 | + @ExcelProperty("创建时间") | ||
| 70 | + private LocalDateTime createTime; | ||
| 71 | + | ||
| 72 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/maintenrecord/vo/MesDvMaintenRecordSaveReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.dv.maintenrecord.vo; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.Data; | ||
| 5 | + | ||
| 6 | +import jakarta.validation.constraints.NotNull; | ||
| 7 | +import java.time.LocalDateTime; | ||
| 8 | + | ||
| 9 | +@Schema(description = "管理后台 - MES 设备保养记录新增/修改 Request VO") | ||
| 10 | +@Data | ||
| 11 | +public class MesDvMaintenRecordSaveReqVO { | ||
| 12 | + | ||
| 13 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "1024") | ||
| 14 | + private Long id; | ||
| 15 | + | ||
| 16 | + @Schema(description = "计划编号", example = "1") | ||
| 17 | + private Long planId; | ||
| 18 | + | ||
| 19 | + @Schema(description = "设备编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 20 | + @NotNull(message = "设备不能为空") | ||
| 21 | + private Long machineryId; | ||
| 22 | + | ||
| 23 | + @Schema(description = "保养时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 24 | + @NotNull(message = "保养时间不能为空") | ||
| 25 | + private LocalDateTime maintenTime; | ||
| 26 | + | ||
| 27 | + @Schema(description = "用户编号", example = "1") | ||
| 28 | + private Long userId; | ||
| 29 | + | ||
| 30 | + @Schema(description = "状态", example = "10") | ||
| 31 | + private Integer status; | ||
| 32 | + | ||
| 33 | + @Schema(description = "备注", example = "测试备注") | ||
| 34 | + private String remark; | ||
| 35 | + | ||
| 36 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/maintenrecord/vo/line/MesDvMaintenRecordLinePageReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.dv.maintenrecord.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 MesDvMaintenRecordLinePageReqVO extends PageParam { | ||
| 14 | + | ||
| 15 | + @Schema(description = "保养记录ID", example = "1") | ||
| 16 | + private Long recordId; | ||
| 17 | + | ||
| 18 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/maintenrecord/vo/line/MesDvMaintenRecordLineRespVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.dv.maintenrecord.vo.line; | ||
| 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 MesDvMaintenRecordLineRespVO { | ||
| 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 = "1") | ||
| 23 | + private Long recordId; | ||
| 24 | + | ||
| 25 | + @Schema(description = "项目编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 26 | + private Long subjectId; | ||
| 27 | + | ||
| 28 | + @Schema(description = "项目名称", example = "检查机油") | ||
| 29 | + @ExcelProperty("项目名称") | ||
| 30 | + private String subjectName; | ||
| 31 | + | ||
| 32 | + @Schema(description = "项目内容", example = "检查机油是否充足") | ||
| 33 | + @ExcelProperty("项目内容") | ||
| 34 | + private String subjectContent; | ||
| 35 | + | ||
| 36 | + @Schema(description = "项目标准", example = "无漏油") | ||
| 37 | + @ExcelProperty("标准") | ||
| 38 | + private String subjectStandard; | ||
| 39 | + | ||
| 40 | + @Schema(description = "保养结果", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 41 | + @ExcelProperty(value = "保养结果", converter = DictConvert.class) | ||
| 42 | + @DictFormat(DictTypeConstants.MES_MAINTEN_STATUS) | ||
| 43 | + private Integer status; | ||
| 44 | + | ||
| 45 | + @Schema(description = "异常描述", example = "发现损坏") | ||
| 46 | + @ExcelProperty("异常描述") | ||
| 47 | + private String result; | ||
| 48 | + | ||
| 49 | + @Schema(description = "备注", example = "测试备注") | ||
| 50 | + @ExcelProperty("备注") | ||
| 51 | + private String remark; | ||
| 52 | + | ||
| 53 | + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||
| 54 | + @ExcelProperty("创建时间") | ||
| 55 | + private LocalDateTime createTime; | ||
| 56 | + | ||
| 57 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/maintenrecord/vo/line/MesDvMaintenRecordLineSaveReqVO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.controller.admin.dv.maintenrecord.vo.line; | ||
| 2 | + | ||
| 3 | +import io.swagger.v3.oas.annotations.media.Schema; | ||
| 4 | +import lombok.Data; | ||
| 5 | + | ||
| 6 | +import jakarta.validation.constraints.NotNull; | ||
| 7 | + | ||
| 8 | +@Schema(description = "管理后台 - MES 设备保养记录明细新增/修改 Request VO") | ||
| 9 | +@Data | ||
| 10 | +public class MesDvMaintenRecordLineSaveReqVO { | ||
| 11 | + | ||
| 12 | + @Schema(description = "编号", requiredMode = Schema.RequiredMode.NOT_REQUIRED, example = "1024") | ||
| 13 | + private Long id; | ||
| 14 | + | ||
| 15 | + @Schema(description = "保养记录编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 16 | + @NotNull(message = "保养记录不能为空") | ||
| 17 | + private Long recordId; | ||
| 18 | + | ||
| 19 | + @Schema(description = "项目编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 20 | + @NotNull(message = "项目不能为空") | ||
| 21 | + private Long subjectId; | ||
| 22 | + | ||
| 23 | + @Schema(description = "保养结果", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") | ||
| 24 | + @NotNull(message = "保养结果不能为空") | ||
| 25 | + private Integer status; | ||
| 26 | + | ||
| 27 | + @Schema(description = "异常描述", example = "发现损坏") | ||
| 28 | + private String result; | ||
| 29 | + | ||
| 30 | + @Schema(description = "备注", example = "测试备注") | ||
| 31 | + private String remark; | ||
| 32 | + | ||
| 33 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/dv/maintenrecord/MesDvMaintenRecordDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.dal.dataobject.dv.maintenrecord; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; | ||
| 4 | +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.checkplan.MesDvCheckPlanDO; | ||
| 5 | +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.machinery.MesDvMachineryDO; | ||
| 6 | +import com.baomidou.mybatisplus.annotation.KeySequence; | ||
| 7 | +import com.baomidou.mybatisplus.annotation.TableId; | ||
| 8 | +import com.baomidou.mybatisplus.annotation.TableName; | ||
| 9 | +import lombok.*; | ||
| 10 | + | ||
| 11 | +import java.time.LocalDateTime; | ||
| 12 | + | ||
| 13 | +/** | ||
| 14 | + * MES 设备保养记录 DO | ||
| 15 | + * | ||
| 16 | + * @author 芋道源码 | ||
| 17 | + */ | ||
| 18 | +@TableName("mes_dv_mainten_record") | ||
| 19 | +@KeySequence("mes_dv_mainten_record_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 | ||
| 20 | +@Data | ||
| 21 | +@EqualsAndHashCode(callSuper = true) | ||
| 22 | +@ToString(callSuper = true) | ||
| 23 | +@Builder | ||
| 24 | +@NoArgsConstructor | ||
| 25 | +@AllArgsConstructor | ||
| 26 | +public class MesDvMaintenRecordDO extends BaseDO { | ||
| 27 | + | ||
| 28 | + /** | ||
| 29 | + * 编号 | ||
| 30 | + */ | ||
| 31 | + @TableId | ||
| 32 | + private Long id; | ||
| 33 | + /** | ||
| 34 | + * 计划编号 | ||
| 35 | + * | ||
| 36 | + * 关联 {@link MesDvCheckPlanDO#getId()} | ||
| 37 | + */ | ||
| 38 | + private Long planId; | ||
| 39 | + /** | ||
| 40 | + * 设备编号 | ||
| 41 | + * | ||
| 42 | + * 关联 {@link MesDvMachineryDO#getId()} | ||
| 43 | + */ | ||
| 44 | + private Long machineryId; | ||
| 45 | + /** | ||
| 46 | + * 保养时间 | ||
| 47 | + */ | ||
| 48 | + private LocalDateTime maintenTime; | ||
| 49 | + /** | ||
| 50 | + * 用户编号 | ||
| 51 | + * | ||
| 52 | + * 关联 AdminUserDO#getId() | ||
| 53 | + */ | ||
| 54 | + private Long userId; | ||
| 55 | + /** | ||
| 56 | + * 状态 | ||
| 57 | + * | ||
| 58 | + * 字典类型 mes_mainten_record_status | ||
| 59 | + */ | ||
| 60 | + private Integer status; | ||
| 61 | + /** | ||
| 62 | + * 备注 | ||
| 63 | + */ | ||
| 64 | + private String remark; | ||
| 65 | + | ||
| 66 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/dv/maintenrecord/MesDvMaintenRecordLineDO.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.dal.dataobject.dv.maintenrecord; | ||
| 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_mainten_record_line") | ||
| 16 | +@KeySequence("mes_dv_mainten_record_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 MesDvMaintenRecordLineDO extends BaseDO { | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 编号 | ||
| 27 | + */ | ||
| 28 | + @TableId | ||
| 29 | + private Long id; | ||
| 30 | + /** | ||
| 31 | + * 保养记录编号 | ||
| 32 | + * | ||
| 33 | + * 关联 {@link MesDvMaintenRecordDO#getId()} | ||
| 34 | + */ | ||
| 35 | + private Long recordId; | ||
| 36 | + /** | ||
| 37 | + * 项目编号 | ||
| 38 | + * | ||
| 39 | + * 关联 {@link MesDvSubjectDO#getId()} | ||
| 40 | + */ | ||
| 41 | + private Long subjectId; | ||
| 42 | + /** | ||
| 43 | + * 保养结果 | ||
| 44 | + * | ||
| 45 | + * 字典类型 mes_mainten_status | ||
| 46 | + */ | ||
| 47 | + private Integer status; | ||
| 48 | + /** | ||
| 49 | + * 异常描述 | ||
| 50 | + */ | ||
| 51 | + private String result; | ||
| 52 | + /** | ||
| 53 | + * 备注 | ||
| 54 | + */ | ||
| 55 | + private String remark; | ||
| 56 | + | ||
| 57 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/dv/maintenrecord/MesDvMaintenRecordLineMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.dal.mysql.dv.maintenrecord; | ||
| 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.maintenrecord.vo.line.MesDvMaintenRecordLinePageReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.maintenrecord.MesDvMaintenRecordLineDO; | ||
| 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 MesDvMaintenRecordLineMapper extends BaseMapperX<MesDvMaintenRecordLineDO> { | ||
| 19 | + | ||
| 20 | + default PageResult<MesDvMaintenRecordLineDO> selectPage(MesDvMaintenRecordLinePageReqVO reqVO) { | ||
| 21 | + return selectPage(reqVO, new LambdaQueryWrapperX<MesDvMaintenRecordLineDO>() | ||
| 22 | + .eqIfPresent(MesDvMaintenRecordLineDO::getRecordId, reqVO.getRecordId()) | ||
| 23 | + .orderByDesc(MesDvMaintenRecordLineDO::getId)); | ||
| 24 | + } | ||
| 25 | + | ||
| 26 | + default List<MesDvMaintenRecordLineDO> selectListByRecordId(Long recordId) { | ||
| 27 | + return selectList(MesDvMaintenRecordLineDO::getRecordId, recordId); | ||
| 28 | + } | ||
| 29 | + | ||
| 30 | + default int deleteByRecordId(Long recordId) { | ||
| 31 | + return delete(MesDvMaintenRecordLineDO::getRecordId, recordId); | ||
| 32 | + } | ||
| 33 | + | ||
| 34 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/dv/maintenrecord/MesDvMaintenRecordMapper.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.dal.mysql.dv.maintenrecord; | ||
| 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.maintenrecord.vo.MesDvMaintenRecordPageReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.maintenrecord.MesDvMaintenRecordDO; | ||
| 8 | +import cn.hutool.core.util.StrUtil; | ||
| 9 | +import org.apache.ibatis.annotations.Mapper; | ||
| 10 | + | ||
| 11 | +/** | ||
| 12 | + * MES 设备保养记录 Mapper | ||
| 13 | + * | ||
| 14 | + * @author 芋道源码 | ||
| 15 | + */ | ||
| 16 | +@Mapper | ||
| 17 | +public interface MesDvMaintenRecordMapper extends BaseMapperX<MesDvMaintenRecordDO> { | ||
| 18 | + | ||
| 19 | + default PageResult<MesDvMaintenRecordDO> selectPage(MesDvMaintenRecordPageReqVO reqVO) { | ||
| 20 | + return selectPage(reqVO, new LambdaQueryWrapperX<MesDvMaintenRecordDO>() | ||
| 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()) | ||
| 33 | + .betweenIfPresent(MesDvMaintenRecordDO::getMaintenTime, reqVO.getMaintenTime()) | ||
| 34 | + .orderByDesc(MesDvMaintenRecordDO::getId)); | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/maintenrecord/MesDvMaintenRecordLineService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.service.dv.maintenrecord; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.module.mes.controller.admin.dv.maintenrecord.vo.line.MesDvMaintenRecordLinePageReqVO; | ||
| 5 | +import cn.iocoder.yudao.module.mes.controller.admin.dv.maintenrecord.vo.line.MesDvMaintenRecordLineSaveReqVO; | ||
| 6 | +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.maintenrecord.MesDvMaintenRecordLineDO; | ||
| 7 | + | ||
| 8 | +import jakarta.validation.Valid; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * 设备保养记录明细 Service 接口 | ||
| 12 | + * | ||
| 13 | + * @author 芋道源码 | ||
| 14 | + */ | ||
| 15 | +public interface MesDvMaintenRecordLineService { | ||
| 16 | + | ||
| 17 | + /** | ||
| 18 | + * 创建设备保养记录明细 | ||
| 19 | + * | ||
| 20 | + * @param createReqVO 创建信息 | ||
| 21 | + * @return 编号 | ||
| 22 | + */ | ||
| 23 | + Long createMaintenRecordLine(@Valid MesDvMaintenRecordLineSaveReqVO createReqVO); | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 更新设备保养记录明细 | ||
| 27 | + * | ||
| 28 | + * @param updateReqVO 更新信息 | ||
| 29 | + */ | ||
| 30 | + void updateMaintenRecordLine(@Valid MesDvMaintenRecordLineSaveReqVO updateReqVO); | ||
| 31 | + | ||
| 32 | + /** | ||
| 33 | + * 删除设备保养记录明细 | ||
| 34 | + * | ||
| 35 | + * @param id 编号 | ||
| 36 | + */ | ||
| 37 | + void deleteMaintenRecordLine(Long id); | ||
| 38 | + | ||
| 39 | + /** | ||
| 40 | + * 获得设备保养记录明细 | ||
| 41 | + * | ||
| 42 | + * @param id 编号 | ||
| 43 | + * @return 设备保养记录明细 | ||
| 44 | + */ | ||
| 45 | + MesDvMaintenRecordLineDO getMaintenRecordLine(Long id); | ||
| 46 | + | ||
| 47 | + /** | ||
| 48 | + * 获得设备保养记录明细分页 | ||
| 49 | + * | ||
| 50 | + * @param pageReqVO 分页查询 | ||
| 51 | + * @return 设备保养记录明细分页 | ||
| 52 | + */ | ||
| 53 | + PageResult<MesDvMaintenRecordLineDO> getMaintenRecordLinePage(MesDvMaintenRecordLinePageReqVO pageReqVO); | ||
| 54 | + | ||
| 55 | +} | ||
| 0 | \ No newline at end of file | 56 | \ No newline at end of file |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/maintenrecord/MesDvMaintenRecordLineServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.service.dv.maintenrecord; | ||
| 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.maintenrecord.vo.line.MesDvMaintenRecordLinePageReqVO; | ||
| 6 | +import cn.iocoder.yudao.module.mes.controller.admin.dv.maintenrecord.vo.line.MesDvMaintenRecordLineSaveReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.maintenrecord.MesDvMaintenRecordLineDO; | ||
| 8 | +import cn.iocoder.yudao.module.mes.dal.mysql.dv.maintenrecord.MesDvMaintenRecordLineMapper; | ||
| 9 | +import org.springframework.stereotype.Service; | ||
| 10 | +import org.springframework.validation.annotation.Validated; | ||
| 11 | +import jakarta.annotation.Resource; | ||
| 12 | + | ||
| 13 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 14 | +import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.MAINTEN_RECORD_LINE_NOT_EXISTS; | ||
| 15 | + | ||
| 16 | +// TODO @AI:注释风格; | ||
| 17 | +/** | ||
| 18 | + * 设备保养记录明细 Service 实现类 | ||
| 19 | + * | ||
| 20 | + * @author 芋道源码 | ||
| 21 | + */ | ||
| 22 | +@Service | ||
| 23 | +@Validated | ||
| 24 | +public class MesDvMaintenRecordLineServiceImpl implements MesDvMaintenRecordLineService { | ||
| 25 | + | ||
| 26 | + @Resource | ||
| 27 | + private MesDvMaintenRecordLineMapper maintenRecordLineMapper; | ||
| 28 | + | ||
| 29 | + @Override | ||
| 30 | + public Long createMaintenRecordLine(MesDvMaintenRecordLineSaveReqVO createReqVO) { | ||
| 31 | + // TODO @AI:必要的校验 | ||
| 32 | + MesDvMaintenRecordLineDO maintenRecordLine = BeanUtils.toBean(createReqVO, MesDvMaintenRecordLineDO.class); | ||
| 33 | + maintenRecordLineMapper.insert(maintenRecordLine); | ||
| 34 | + return maintenRecordLine.getId(); | ||
| 35 | + } | ||
| 36 | + | ||
| 37 | + @Override | ||
| 38 | + public void updateMaintenRecordLine(MesDvMaintenRecordLineSaveReqVO updateReqVO) { | ||
| 39 | + // TODO @AI:必要的校验 | ||
| 40 | + validateMaintenRecordLineExists(updateReqVO.getId()); | ||
| 41 | + MesDvMaintenRecordLineDO updateObj = BeanUtils.toBean(updateReqVO, MesDvMaintenRecordLineDO.class); | ||
| 42 | + maintenRecordLineMapper.updateById(updateObj); | ||
| 43 | + } | ||
| 44 | + | ||
| 45 | + @Override | ||
| 46 | + public void deleteMaintenRecordLine(Long id) { | ||
| 47 | + validateMaintenRecordLineExists(id); | ||
| 48 | + maintenRecordLineMapper.deleteById(id); | ||
| 49 | + } | ||
| 50 | + | ||
| 51 | + private void validateMaintenRecordLineExists(Long id) { | ||
| 52 | + if (maintenRecordLineMapper.selectById(id) == null) { | ||
| 53 | + throw exception(MAINTEN_RECORD_LINE_NOT_EXISTS); | ||
| 54 | + } | ||
| 55 | + } | ||
| 56 | + | ||
| 57 | + @Override | ||
| 58 | + public MesDvMaintenRecordLineDO getMaintenRecordLine(Long id) { | ||
| 59 | + return maintenRecordLineMapper.selectById(id); | ||
| 60 | + } | ||
| 61 | + | ||
| 62 | + @Override | ||
| 63 | + public PageResult<MesDvMaintenRecordLineDO> getMaintenRecordLinePage(MesDvMaintenRecordLinePageReqVO pageReqVO) { | ||
| 64 | + return maintenRecordLineMapper.selectPage(pageReqVO); | ||
| 65 | + } | ||
| 66 | + | ||
| 67 | +} | ||
| 0 | \ No newline at end of file | 68 | \ No newline at end of file |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/maintenrecord/MesDvMaintenRecordService.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.service.dv.maintenrecord; | ||
| 2 | + | ||
| 3 | +import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||
| 4 | +import cn.iocoder.yudao.module.mes.controller.admin.dv.maintenrecord.vo.MesDvMaintenRecordPageReqVO; | ||
| 5 | +import cn.iocoder.yudao.module.mes.controller.admin.dv.maintenrecord.vo.MesDvMaintenRecordSaveReqVO; | ||
| 6 | +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.maintenrecord.MesDvMaintenRecordDO; | ||
| 7 | + | ||
| 8 | +import jakarta.validation.Valid; | ||
| 9 | + | ||
| 10 | +/** | ||
| 11 | + * 设备保养记录 Service 接口 | ||
| 12 | + * | ||
| 13 | + * @author 芋道源码 | ||
| 14 | + */ | ||
| 15 | +public interface MesDvMaintenRecordService { | ||
| 16 | + | ||
| 17 | + /** | ||
| 18 | + * 创建设备保养记录 | ||
| 19 | + * | ||
| 20 | + * @param createReqVO 创建信息 | ||
| 21 | + * @return 编号 | ||
| 22 | + */ | ||
| 23 | + Long createMaintenRecord(@Valid MesDvMaintenRecordSaveReqVO createReqVO); | ||
| 24 | + | ||
| 25 | + /** | ||
| 26 | + * 更新设备保养记录 | ||
| 27 | + * | ||
| 28 | + * @param updateReqVO 更新信息 | ||
| 29 | + */ | ||
| 30 | + void updateMaintenRecord(@Valid MesDvMaintenRecordSaveReqVO updateReqVO); | ||
| 31 | + | ||
| 32 | + /** | ||
| 33 | + * 删除设备保养记录 | ||
| 34 | + * | ||
| 35 | + * @param id 编号 | ||
| 36 | + */ | ||
| 37 | + void deleteMaintenRecord(Long id); | ||
| 38 | + | ||
| 39 | + /** | ||
| 40 | + * 获得设备保养记录 | ||
| 41 | + * | ||
| 42 | + * @param id 编号 | ||
| 43 | + * @return 设备保养记录 | ||
| 44 | + */ | ||
| 45 | + MesDvMaintenRecordDO getMaintenRecord(Long id); | ||
| 46 | + | ||
| 47 | + /** | ||
| 48 | + * 获得设备保养记录分页 | ||
| 49 | + * | ||
| 50 | + * @param pageReqVO 分页查询 | ||
| 51 | + * @return 设备保养记录分页 | ||
| 52 | + */ | ||
| 53 | + PageResult<MesDvMaintenRecordDO> getMaintenRecordPage(MesDvMaintenRecordPageReqVO pageReqVO); | ||
| 54 | + | ||
| 55 | +} |
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/maintenrecord/MesDvMaintenRecordServiceImpl.java
0 → 100644
| 1 | +package cn.iocoder.yudao.module.mes.service.dv.maintenrecord; | ||
| 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.maintenrecord.vo.MesDvMaintenRecordPageReqVO; | ||
| 6 | +import cn.iocoder.yudao.module.mes.controller.admin.dv.maintenrecord.vo.MesDvMaintenRecordSaveReqVO; | ||
| 7 | +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.maintenrecord.MesDvMaintenRecordDO; | ||
| 8 | +import cn.iocoder.yudao.module.mes.dal.mysql.dv.maintenrecord.MesDvMaintenRecordMapper; | ||
| 9 | +import cn.iocoder.yudao.module.mes.dal.mysql.dv.maintenrecord.MesDvMaintenRecordLineMapper; | ||
| 10 | +import org.springframework.stereotype.Service; | ||
| 11 | +import org.springframework.transaction.annotation.Transactional; | ||
| 12 | +import org.springframework.validation.annotation.Validated; | ||
| 13 | +import jakarta.annotation.Resource; | ||
| 14 | + | ||
| 15 | +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||
| 16 | +import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.MAINTEN_RECORD_NOT_EXISTS; | ||
| 17 | + | ||
| 18 | +// TODO @AI:注释风格; | ||
| 19 | +/** | ||
| 20 | + * 设备保养记录 Service 实现类 | ||
| 21 | + * | ||
| 22 | + * @author 芋道源码 | ||
| 23 | + */ | ||
| 24 | +@Service | ||
| 25 | +@Validated | ||
| 26 | +public class MesDvMaintenRecordServiceImpl implements MesDvMaintenRecordService { | ||
| 27 | + | ||
| 28 | + @Resource | ||
| 29 | + private MesDvMaintenRecordMapper maintenRecordMapper; | ||
| 30 | + | ||
| 31 | + @Resource | ||
| 32 | + private MesDvMaintenRecordLineMapper maintenRecordLineMapper; | ||
| 33 | + | ||
| 34 | + @Override | ||
| 35 | + public Long createMaintenRecord(MesDvMaintenRecordSaveReqVO createReqVO) { | ||
| 36 | + // TODO @AI:必要的校验 | ||
| 37 | + // 插入 | ||
| 38 | + MesDvMaintenRecordDO maintenRecord = BeanUtils.toBean(createReqVO, MesDvMaintenRecordDO.class); | ||
| 39 | + maintenRecordMapper.insert(maintenRecord); | ||
| 40 | + return maintenRecord.getId(); | ||
| 41 | + } | ||
| 42 | + | ||
| 43 | + @Override | ||
| 44 | + public void updateMaintenRecord(MesDvMaintenRecordSaveReqVO updateReqVO) { | ||
| 45 | + // TODO @AI:必要的校验 | ||
| 46 | + // 校验存在 | ||
| 47 | + validateMaintenRecordExists(updateReqVO.getId()); | ||
| 48 | + | ||
| 49 | + // 更新 | ||
| 50 | + MesDvMaintenRecordDO updateObj = BeanUtils.toBean(updateReqVO, MesDvMaintenRecordDO.class); | ||
| 51 | + maintenRecordMapper.updateById(updateObj); | ||
| 52 | + } | ||
| 53 | + | ||
| 54 | + @Override | ||
| 55 | + @Transactional(rollbackFor = Exception.class) | ||
| 56 | + public void deleteMaintenRecord(Long id) { | ||
| 57 | + // 校验存在 | ||
| 58 | + validateMaintenRecordExists(id); | ||
| 59 | + | ||
| 60 | + // 删除 | ||
| 61 | + maintenRecordMapper.deleteById(id); | ||
| 62 | + // 级联删除子表 | ||
| 63 | + maintenRecordLineMapper.deleteByRecordId(id); | ||
| 64 | + } | ||
| 65 | + | ||
| 66 | + private void validateMaintenRecordExists(Long id) { | ||
| 67 | + if (maintenRecordMapper.selectById(id) == null) { | ||
| 68 | + throw exception(MAINTEN_RECORD_NOT_EXISTS); | ||
| 69 | + } | ||
| 70 | + } | ||
| 71 | + | ||
| 72 | + @Override | ||
| 73 | + public MesDvMaintenRecordDO getMaintenRecord(Long id) { | ||
| 74 | + return maintenRecordMapper.selectById(id); | ||
| 75 | + } | ||
| 76 | + | ||
| 77 | + @Override | ||
| 78 | + public PageResult<MesDvMaintenRecordDO> getMaintenRecordPage(MesDvMaintenRecordPageReqVO pageReqVO) { | ||
| 79 | + return maintenRecordMapper.selectPage(pageReqVO); | ||
| 80 | + } | ||
| 81 | + | ||
| 82 | +} |