diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/checkplan/MesDvCheckPlanController.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/checkplan/MesDvCheckPlanController.java new file mode 100644 index 0000000..55872f1 --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/checkplan/MesDvCheckPlanController.java @@ -0,0 +1,111 @@ +package cn.iocoder.yudao.module.mes.controller.admin.dv.checkplan; + +import cn.iocoder.yudao.framework.apilog.core.annotation.ApiAccessLog; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; +import cn.iocoder.yudao.module.mes.controller.admin.dv.checkplan.vo.MesDvCheckPlanPageReqVO; +import cn.iocoder.yudao.module.mes.controller.admin.dv.checkplan.vo.MesDvCheckPlanRespVO; +import cn.iocoder.yudao.module.mes.controller.admin.dv.checkplan.vo.MesDvCheckPlanSaveReqVO; +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.checkplan.MesDvCheckPlanDO; +import cn.iocoder.yudao.module.mes.service.dv.checkplan.MesDvCheckPlanService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.annotation.Resource; +import jakarta.servlet.http.HttpServletResponse; +import jakarta.validation.Valid; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.io.IOException; +import java.util.List; + +import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT; +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +@Tag(name = "管理后台 - MES 点检保养方案") +@RestController +@RequestMapping("/mes/dv/check-plan") +@Validated +public class MesDvCheckPlanController { + + @Resource + private MesDvCheckPlanService checkPlanService; + + @PostMapping("/create") + @Operation(summary = "创建点检保养方案") + @PreAuthorize("@ss.hasPermission('mes:dv-check-plan:create')") + public CommonResult createCheckPlan(@Valid @RequestBody MesDvCheckPlanSaveReqVO createReqVO) { + return success(checkPlanService.createCheckPlan(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新点检保养方案") + @PreAuthorize("@ss.hasPermission('mes:dv-check-plan:update')") + public CommonResult updateCheckPlan(@Valid @RequestBody MesDvCheckPlanSaveReqVO updateReqVO) { + checkPlanService.updateCheckPlan(updateReqVO); + return success(true); + } + + @PutMapping("/enable") + @Operation(summary = "启用点检保养方案") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('mes:dv-check-plan:update')") + public CommonResult enableCheckPlan(@RequestParam("id") Long id) { + checkPlanService.enableCheckPlan(id); + return success(true); + } + + @PutMapping("/disable") + @Operation(summary = "停用点检保养方案") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('mes:dv-check-plan:update')") + public CommonResult disableCheckPlan(@RequestParam("id") Long id) { + checkPlanService.disableCheckPlan(id); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除点检保养方案") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('mes:dv-check-plan:delete')") + public CommonResult deleteCheckPlan(@RequestParam("id") Long id) { + checkPlanService.deleteCheckPlan(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得点检保养方案") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('mes:dv-check-plan:query')") + public CommonResult getCheckPlan(@RequestParam("id") Long id) { + MesDvCheckPlanDO checkPlan = checkPlanService.getCheckPlan(id); + return success(BeanUtils.toBean(checkPlan, MesDvCheckPlanRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得点检保养方案分页") + @PreAuthorize("@ss.hasPermission('mes:dv-check-plan:query')") + public CommonResult> getCheckPlanPage(@Valid MesDvCheckPlanPageReqVO pageReqVO) { + PageResult pageResult = checkPlanService.getCheckPlanPage(pageReqVO); + return success(BeanUtils.toBean(pageResult, MesDvCheckPlanRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出点检保养方案 Excel") + @PreAuthorize("@ss.hasPermission('mes:dv-check-plan:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportCheckPlanExcel(@Valid MesDvCheckPlanPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = checkPlanService.getCheckPlanPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "点检保养方案.xls", "数据", MesDvCheckPlanRespVO.class, + BeanUtils.toBean(list, MesDvCheckPlanRespVO.class)); + } + +} diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/checkplan/MesDvCheckPlanMachineryController.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/checkplan/MesDvCheckPlanMachineryController.java new file mode 100644 index 0000000..ed01aaa --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/checkplan/MesDvCheckPlanMachineryController.java @@ -0,0 +1,84 @@ +package cn.iocoder.yudao.module.mes.controller.admin.dv.checkplan; + +import cn.hutool.core.collection.CollUtil; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.module.mes.controller.admin.dv.checkplan.vo.machinery.MesDvCheckPlanMachineryRespVO; +import cn.iocoder.yudao.module.mes.controller.admin.dv.checkplan.vo.machinery.MesDvCheckPlanMachinerySaveReqVO; +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.checkplan.MesDvCheckPlanMachineryDO; +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.machinery.MesDvMachineryDO; +import cn.iocoder.yudao.module.mes.service.dv.checkplan.MesDvCheckPlanMachineryService; +import cn.iocoder.yudao.module.mes.service.dv.machinery.MesDvMachineryService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.annotation.Resource; +import jakarta.validation.Valid; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +@Tag(name = "管理后台 - MES 点检保养方案设备") +@RestController +@RequestMapping("/mes/dv/check-plan-machinery") +@Validated +public class MesDvCheckPlanMachineryController { + + @Resource + private MesDvCheckPlanMachineryService checkPlanMachineryService; + @Resource + private MesDvMachineryService machineryService; + + @PostMapping("/create") + @Operation(summary = "创建方案设备关联") + @PreAuthorize("@ss.hasPermission('mes:dv-check-plan:update')") + public CommonResult createCheckPlanMachinery(@Valid @RequestBody MesDvCheckPlanMachinerySaveReqVO createReqVO) { + return success(checkPlanMachineryService.createCheckPlanMachinery(createReqVO)); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除方案设备关联") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('mes:dv-check-plan:update')") + public CommonResult deleteCheckPlanMachinery(@RequestParam("id") Long id) { + checkPlanMachineryService.deleteCheckPlanMachinery(id); + return success(true); + } + + @GetMapping("/list-by-plan") + @Operation(summary = "获得指定方案的设备列表") + @Parameter(name = "planId", description = "方案编号", required = true) + @PreAuthorize("@ss.hasPermission('mes:dv-check-plan:query')") + public CommonResult> getCheckPlanMachineryListByPlan( + @RequestParam("planId") Long planId) { + List list = checkPlanMachineryService.getCheckPlanMachineryListByPlanId(planId); + List respList = BeanUtils.toBean(list, MesDvCheckPlanMachineryRespVO.class); + // TODO @AI:为空,直接 return; + // 拼装设备编码/名称/品牌/规格 + // TODO @AI:拆出来,放在 buildVO 那; + if (CollUtil.isNotEmpty(respList)) { + // TODO @AI:convertMap; + List machineryIds = CollectionUtils.convertList(respList, MesDvCheckPlanMachineryRespVO::getMachineryId); + // TODO @AI:这里暂时没实现; + Map machineryMap = machineryService.getMachineryMap(machineryIds); + respList.forEach(resp -> { + MesDvMachineryDO machinery = machineryMap.get(resp.getMachineryId()); + if (machinery != null) { + // TODO @AI:链式调用; + resp.setMachineryCode(machinery.getCode()); + resp.setMachineryName(machinery.getName()); + resp.setMachineryBrand(machinery.getBrand()); + resp.setMachinerySpec(machinery.getSpec()); + } + }); + } + return success(respList); + } + +} diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/checkplan/MesDvCheckPlanSubjectController.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/checkplan/MesDvCheckPlanSubjectController.java new file mode 100644 index 0000000..ce0d56f --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/checkplan/MesDvCheckPlanSubjectController.java @@ -0,0 +1,81 @@ +package cn.iocoder.yudao.module.mes.controller.admin.dv.checkplan; + +import cn.hutool.core.collection.CollUtil; +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.module.mes.controller.admin.dv.checkplan.vo.subject.MesDvCheckPlanSubjectRespVO; +import cn.iocoder.yudao.module.mes.controller.admin.dv.checkplan.vo.subject.MesDvCheckPlanSubjectSaveReqVO; +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.checkplan.MesDvCheckPlanSubjectDO; +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.subject.MesDvSubjectDO; +import cn.iocoder.yudao.module.mes.service.dv.checkplan.MesDvCheckPlanSubjectService; +import cn.iocoder.yudao.module.mes.service.dv.subject.MesDvSubjectService; +import io.swagger.v3.oas.annotations.Operation; +import io.swagger.v3.oas.annotations.Parameter; +import io.swagger.v3.oas.annotations.tags.Tag; +import jakarta.annotation.Resource; +import jakarta.validation.Valid; +import org.springframework.security.access.prepost.PreAuthorize; +import org.springframework.validation.annotation.Validated; +import org.springframework.web.bind.annotation.*; + +import java.util.List; +import java.util.Map; + +import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +@Tag(name = "管理后台 - MES 点检保养方案项目") +@RestController +@RequestMapping("/mes/dv/check-plan-subject") +@Validated +public class MesDvCheckPlanSubjectController { + + @Resource + private MesDvCheckPlanSubjectService checkPlanSubjectService; + @Resource + private MesDvSubjectService subjectService; + + @PostMapping("/create") + @Operation(summary = "创建方案项目关联") + @PreAuthorize("@ss.hasPermission('mes:dv-check-plan:update')") + public CommonResult createCheckPlanSubject(@Valid @RequestBody MesDvCheckPlanSubjectSaveReqVO createReqVO) { + return success(checkPlanSubjectService.createCheckPlanSubject(createReqVO)); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除方案项目关联") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('mes:dv-check-plan:update')") + public CommonResult deleteCheckPlanSubject(@RequestParam("id") Long id) { + checkPlanSubjectService.deleteCheckPlanSubject(id); + return success(true); + } + + @GetMapping("/list-by-plan") + @Operation(summary = "获得指定方案的项目列表") + @Parameter(name = "planId", description = "方案编号", required = true) + @PreAuthorize("@ss.hasPermission('mes:dv-check-plan:query')") + public CommonResult> getCheckPlanSubjectListByPlan( + @RequestParam("planId") Long planId) { + List list = checkPlanSubjectService.getCheckPlanSubjectListByPlanId(planId); + List respList = BeanUtils.toBean(list, MesDvCheckPlanSubjectRespVO.class); + // 拼装项目编码/名称/类型/内容/标准 + // MesDvCheckPlanMachineryController.java 参考下里面的 todo; + if (CollUtil.isNotEmpty(respList)) { + List subjectIds = CollectionUtils.convertList(respList, MesDvCheckPlanSubjectRespVO::getSubjectId); + Map subjectMap = subjectService.getSubjectMap(subjectIds); + respList.forEach(resp -> { + MesDvSubjectDO subject = subjectMap.get(resp.getSubjectId()); + if (subject != null) { + resp.setSubjectCode(subject.getCode()); + resp.setSubjectName(subject.getName()); + resp.setSubjectType(subject.getType()); + resp.setSubjectContent(subject.getContent()); + resp.setSubjectStandard(subject.getStandard()); + } + }); + } + return success(respList); + } + +} diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/checkplan/vo/MesDvCheckPlanPageReqVO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/checkplan/vo/MesDvCheckPlanPageReqVO.java new file mode 100644 index 0000000..c7c1319 --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/checkplan/vo/MesDvCheckPlanPageReqVO.java @@ -0,0 +1,36 @@ +package cn.iocoder.yudao.module.mes.controller.admin.dv.checkplan.vo; + +import cn.iocoder.yudao.framework.common.pojo.PageParam; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.ToString; +import org.springframework.format.annotation.DateTimeFormat; + +import java.time.LocalDateTime; + +import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; + +@Schema(description = "管理后台 - MES 点检保养方案分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class MesDvCheckPlanPageReqVO extends PageParam { + + @Schema(description = "方案编码", example = "CHP001") + private String code; + + @Schema(description = "方案名称", example = "注塑机") + private String name; + + @Schema(description = "方案类型", example = "1") + private Integer type; + + @Schema(description = "状态", example = "0") + private Integer status; + + @Schema(description = "创建时间") + @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) + private LocalDateTime[] createTime; + +} diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/checkplan/vo/MesDvCheckPlanRespVO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/checkplan/vo/MesDvCheckPlanRespVO.java new file mode 100644 index 0000000..69d720c --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/checkplan/vo/MesDvCheckPlanRespVO.java @@ -0,0 +1,71 @@ +package cn.iocoder.yudao.module.mes.controller.admin.dv.checkplan.vo; + +import cn.idev.excel.annotation.ExcelIgnoreUnannotated; +import cn.idev.excel.annotation.ExcelProperty; +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - MES 点检保养方案 Response VO") +@Data +@ExcelIgnoreUnannotated +public class MesDvCheckPlanRespVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @ExcelProperty("编号") + private Long id; + + @Schema(description = "方案编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "CHP001") + @ExcelProperty("方案编码") + private String code; + + @Schema(description = "方案名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "注塑机日检方案") + @ExcelProperty("方案名称") + private String name; + + @Schema(description = "方案类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @ExcelProperty("方案类型") + private Integer type; + + @Schema(description = "开始日期") + @ExcelProperty("开始日期") + private LocalDateTime startDate; + + @Schema(description = "结束日期") + @ExcelProperty("结束日期") + private LocalDateTime endDate; + + @Schema(description = "周期类型", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @ExcelProperty("周期类型") + private Integer cycleType; + + @Schema(description = "周期数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @ExcelProperty("周期数量") + private Integer cycleCount; + + @Schema(description = "状态", requiredMode = Schema.RequiredMode.REQUIRED, example = "0") + @ExcelProperty("状态") + private Integer status; + + @Schema(description = "备注") + @ExcelProperty("备注") + private String remark; + + @Schema(description = "预留字段1") + private String attribute1; + + @Schema(description = "预留字段2") + private String attribute2; + + @Schema(description = "预留字段3") + private Integer attribute3; + + @Schema(description = "预留字段4") + private Integer attribute4; + + @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("创建时间") + private LocalDateTime createTime; + +} diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/checkplan/vo/MesDvCheckPlanSaveReqVO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/checkplan/vo/MesDvCheckPlanSaveReqVO.java new file mode 100644 index 0000000..d0db890 --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/checkplan/vo/MesDvCheckPlanSaveReqVO.java @@ -0,0 +1,61 @@ +package cn.iocoder.yudao.module.mes.controller.admin.dv.checkplan.vo; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - MES 点检保养方案新增/修改 Request VO") +@Data +public class MesDvCheckPlanSaveReqVO { + + @Schema(description = "编号", example = "1024") + private Long id; + + @Schema(description = "方案编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "CHP001") + @NotEmpty(message = "方案编码不能为空") + private String code; + + @Schema(description = "方案名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "注塑机日检方案") + @NotEmpty(message = "方案名称不能为空") + private String name; + + @Schema(description = "方案类型(1=设备点检,2=设备保养)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @NotNull(message = "方案类型不能为空") + private Integer type; + + @Schema(description = "开始日期") + private LocalDateTime startDate; + + @Schema(description = "结束日期") + private LocalDateTime endDate; + + @Schema(description = "周期类型(1=天,2=周,3=月,4=年)", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @NotNull(message = "周期类型不能为空") + private Integer cycleType; + + @Schema(description = "周期数量", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @NotNull(message = "周期数量不能为空") + private Integer cycleCount; + + @Schema(description = "状态", example = "0") + private Integer status; + + @Schema(description = "备注") + private String remark; + + @Schema(description = "预留字段1") + private String attribute1; + + @Schema(description = "预留字段2") + private String attribute2; + + @Schema(description = "预留字段3") + private Integer attribute3; + + @Schema(description = "预留字段4") + private Integer attribute4; + +} diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/checkplan/vo/machinery/MesDvCheckPlanMachineryRespVO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/checkplan/vo/machinery/MesDvCheckPlanMachineryRespVO.java new file mode 100644 index 0000000..4cdf768 --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/checkplan/vo/machinery/MesDvCheckPlanMachineryRespVO.java @@ -0,0 +1,51 @@ +package cn.iocoder.yudao.module.mes.controller.admin.dv.checkplan.vo.machinery; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - MES 点检保养方案设备 Response VO") +@Data +public class MesDvCheckPlanMachineryRespVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + private Long id; + + @Schema(description = "方案编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + private Long planId; + + @Schema(description = "设备编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + private Long machineryId; + + @Schema(description = "设备编码", example = "EQ001") + private String machineryCode; + + @Schema(description = "设备名称", example = "注塑机A") + private String machineryName; + + @Schema(description = "品牌", example = "海天") + private String machineryBrand; + + @Schema(description = "规格型号", example = "HTF120") + private String machinerySpec; + + @Schema(description = "备注") + private String remark; + + @Schema(description = "预留字段1") + private String attribute1; + + @Schema(description = "预留字段2") + private String attribute2; + + @Schema(description = "预留字段3") + private Integer attribute3; + + @Schema(description = "预留字段4") + private Integer attribute4; + + @Schema(description = "创建时间") + private LocalDateTime createTime; + +} diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/checkplan/vo/machinery/MesDvCheckPlanMachinerySaveReqVO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/checkplan/vo/machinery/MesDvCheckPlanMachinerySaveReqVO.java new file mode 100644 index 0000000..dff8252 --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/checkplan/vo/machinery/MesDvCheckPlanMachinerySaveReqVO.java @@ -0,0 +1,37 @@ +package cn.iocoder.yudao.module.mes.controller.admin.dv.checkplan.vo.machinery; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +@Schema(description = "管理后台 - MES 点检保养方案设备新增 Request VO") +@Data +public class MesDvCheckPlanMachinerySaveReqVO { + + @Schema(description = "编号", example = "1024") + private Long id; + + @Schema(description = "方案编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @NotNull(message = "方案编号不能为空") + private Long planId; + + @Schema(description = "设备编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @NotNull(message = "设备不能为空") + private Long machineryId; + + @Schema(description = "备注") + private String remark; + + @Schema(description = "预留字段1") + private String attribute1; + + @Schema(description = "预留字段2") + private String attribute2; + + @Schema(description = "预留字段3") + private Integer attribute3; + + @Schema(description = "预留字段4") + private Integer attribute4; + +} diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/checkplan/vo/subject/MesDvCheckPlanSubjectRespVO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/checkplan/vo/subject/MesDvCheckPlanSubjectRespVO.java new file mode 100644 index 0000000..e5af2f5 --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/checkplan/vo/subject/MesDvCheckPlanSubjectRespVO.java @@ -0,0 +1,54 @@ +package cn.iocoder.yudao.module.mes.controller.admin.dv.checkplan.vo.subject; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - MES 点检保养方案项目 Response VO") +@Data +public class MesDvCheckPlanSubjectRespVO { + + @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + private Long id; + + @Schema(description = "方案编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + private Long planId; + + @Schema(description = "项目编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + private Long subjectId; + + @Schema(description = "项目编码", example = "CHK001") + private String subjectCode; + + @Schema(description = "项目名称", example = "油温检查") + private String subjectName; + + @Schema(description = "项目类型", example = "1") + private Integer subjectType; + + @Schema(description = "项目内容", example = "检查油温是否正常") + private String subjectContent; + + @Schema(description = "标准", example = "40-60°C") + private String subjectStandard; + + @Schema(description = "备注") + private String remark; + + @Schema(description = "预留字段1") + private String attribute1; + + @Schema(description = "预留字段2") + private String attribute2; + + @Schema(description = "预留字段3") + private Integer attribute3; + + @Schema(description = "预留字段4") + private Integer attribute4; + + @Schema(description = "创建时间") + private LocalDateTime createTime; + +} diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/checkplan/vo/subject/MesDvCheckPlanSubjectSaveReqVO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/checkplan/vo/subject/MesDvCheckPlanSubjectSaveReqVO.java new file mode 100644 index 0000000..c77c7d8 --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/dv/checkplan/vo/subject/MesDvCheckPlanSubjectSaveReqVO.java @@ -0,0 +1,37 @@ +package cn.iocoder.yudao.module.mes.controller.admin.dv.checkplan.vo.subject; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +@Schema(description = "管理后台 - MES 点检保养方案项目新增 Request VO") +@Data +public class MesDvCheckPlanSubjectSaveReqVO { + + @Schema(description = "编号", example = "1024") + private Long id; + + @Schema(description = "方案编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @NotNull(message = "方案编号不能为空") + private Long planId; + + @Schema(description = "项目编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @NotNull(message = "点检保养项目不能为空") + private Long subjectId; + + @Schema(description = "备注") + private String remark; + + @Schema(description = "预留字段1") + private String attribute1; + + @Schema(description = "预留字段2") + private String attribute2; + + @Schema(description = "预留字段3") + private Integer attribute3; + + @Schema(description = "预留字段4") + private Integer attribute4; + +} diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/dv/checkplan/MesDvCheckPlanDO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/dv/checkplan/MesDvCheckPlanDO.java new file mode 100644 index 0000000..6c586c7 --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/dv/checkplan/MesDvCheckPlanDO.java @@ -0,0 +1,93 @@ +package cn.iocoder.yudao.module.mes.dal.dataobject.dv.checkplan; + +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import cn.iocoder.yudao.module.mes.enums.dv.MesDvCheckPlanStatusEnum; +import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.*; + +import java.time.LocalDateTime; + +/** + * MES 点检保养方案 DO + * + * @author 芋道源码 + */ +@TableName("mes_dv_check_plan") +@KeySequence("mes_dv_check_plan_seq") // 用于 Oracle、PostgreSQL、Kingbase、DB2、H2 数据库的主键自增。如果是 MySQL 等数据库,可不写。 +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class MesDvCheckPlanDO extends BaseDO { + + /** + * 编号 + */ + @TableId + private Long id; + /** + * 方案编码 + */ + private String code; + /** + * 方案名称 + */ + private String name; + // TODO @AI:需要在 dict constants 里枚举下,然后 @过去 + /** + * 方案类型 + * + * 字典类型 mes_dv_subject_type(1=设备点检,2=设备保养) + */ + private Integer type; + /** + * 开始日期 + */ + private LocalDateTime startDate; + /** + * 结束日期 + */ + private LocalDateTime endDate; + // TODO @AI:需要在 dict constants 里枚举下,然后 @过去 + /** + * 周期类型 + * + * 字典类型 mes_dv_cycle_type(1=天,2=周,3=月,4=年) + */ + private Integer cycleType; + /** + * 周期数量 + */ + private Integer cycleCount; + /** + * 状态 + * + * 枚举 {@link MesDvCheckPlanStatusEnum} + */ + private Integer status; + /** + * 备注 + */ + private String remark; + /** + * 预留字段1 + */ + private String attribute1; + /** + * 预留字段2 + */ + private String attribute2; + /** + * 预留字段3 + */ + private Integer attribute3; + /** + * 预留字段4 + */ + private Integer attribute4; + +} diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/dv/checkplan/MesDvCheckPlanMachineryDO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/dv/checkplan/MesDvCheckPlanMachineryDO.java new file mode 100644 index 0000000..ac92a78 --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/dv/checkplan/MesDvCheckPlanMachineryDO.java @@ -0,0 +1,63 @@ +package cn.iocoder.yudao.module.mes.dal.dataobject.dv.checkplan; + +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.machinery.MesDvMachineryDO; +import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.*; + +/** + * MES 点检保养方案设备 DO + * + * @author 芋道源码 + */ +@TableName("mes_dv_check_plan_machinery") +@KeySequence("mes_dv_check_plan_machinery_seq") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class MesDvCheckPlanMachineryDO extends BaseDO { + + /** + * 编号 + */ + @TableId + private Long id; + /** + * 方案编号 + * + * 关联 {@link MesDvCheckPlanDO#getId()} + */ + private Long planId; + /** + * 设备编号 + * + * 关联 {@link MesDvMachineryDO#getId()} + */ + private Long machineryId; + /** + * 备注 + */ + private String remark; + /** + * 预留字段1 + */ + private String attribute1; + /** + * 预留字段2 + */ + private String attribute2; + /** + * 预留字段3 + */ + private Integer attribute3; + /** + * 预留字段4 + */ + private Integer attribute4; + +} diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/dv/checkplan/MesDvCheckPlanSubjectDO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/dv/checkplan/MesDvCheckPlanSubjectDO.java new file mode 100644 index 0000000..90d5da2 --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/dv/checkplan/MesDvCheckPlanSubjectDO.java @@ -0,0 +1,63 @@ +package cn.iocoder.yudao.module.mes.dal.dataobject.dv.checkplan; + +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.subject.MesDvSubjectDO; +import com.baomidou.mybatisplus.annotation.KeySequence; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import lombok.*; + +/** + * MES 点检保养方案项目 DO + * + * @author 芋道源码 + */ +@TableName("mes_dv_check_plan_subject") +@KeySequence("mes_dv_check_plan_subject_seq") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class MesDvCheckPlanSubjectDO extends BaseDO { + + /** + * 编号 + */ + @TableId + private Long id; + /** + * 方案编号 + * + * 关联 {@link MesDvCheckPlanDO#getId()} + */ + private Long planId; + /** + * 项目编号 + * + * 关联 {@link MesDvSubjectDO#getId()} + */ + private Long subjectId; + /** + * 备注 + */ + private String remark; + /** + * 预留字段1 + */ + private String attribute1; + /** + * 预留字段2 + */ + private String attribute2; + /** + * 预留字段3 + */ + private Integer attribute3; + /** + * 预留字段4 + */ + private Integer attribute4; + +} diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/dv/checkplan/MesDvCheckPlanMachineryMapper.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/dv/checkplan/MesDvCheckPlanMachineryMapper.java new file mode 100644 index 0000000..fb2f1c0 --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/dv/checkplan/MesDvCheckPlanMachineryMapper.java @@ -0,0 +1,31 @@ +package cn.iocoder.yudao.module.mes.dal.mysql.dv.checkplan; + +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.checkplan.MesDvCheckPlanMachineryDO; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * MES 点检保养方案设备 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface MesDvCheckPlanMachineryMapper extends BaseMapperX { + + default List selectListByPlanId(Long planId) { + return selectList(MesDvCheckPlanMachineryDO::getPlanId, planId); + } + + default Long selectCountByPlanId(Long planId) { + return selectCount(MesDvCheckPlanMachineryDO::getPlanId, planId); + } + + default void deleteByPlanId(Long planId) { + delete(new LambdaQueryWrapperX() + .eq(MesDvCheckPlanMachineryDO::getPlanId, planId)); + } + +} diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/dv/checkplan/MesDvCheckPlanMapper.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/dv/checkplan/MesDvCheckPlanMapper.java new file mode 100644 index 0000000..eb2421c --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/dv/checkplan/MesDvCheckPlanMapper.java @@ -0,0 +1,32 @@ +package cn.iocoder.yudao.module.mes.dal.mysql.dv.checkplan; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.module.mes.controller.admin.dv.checkplan.vo.MesDvCheckPlanPageReqVO; +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.checkplan.MesDvCheckPlanDO; +import org.apache.ibatis.annotations.Mapper; + +/** + * MES 点检保养方案 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface MesDvCheckPlanMapper extends BaseMapperX { + + default PageResult selectPage(MesDvCheckPlanPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .likeIfPresent(MesDvCheckPlanDO::getCode, reqVO.getCode()) + .likeIfPresent(MesDvCheckPlanDO::getName, reqVO.getName()) + .eqIfPresent(MesDvCheckPlanDO::getType, reqVO.getType()) + .eqIfPresent(MesDvCheckPlanDO::getStatus, reqVO.getStatus()) + .betweenIfPresent(MesDvCheckPlanDO::getCreateTime, reqVO.getCreateTime()) + .orderByDesc(MesDvCheckPlanDO::getId)); + } + + default MesDvCheckPlanDO selectByCode(String code) { + return selectOne(MesDvCheckPlanDO::getCode, code); + } + +} diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/dv/checkplan/MesDvCheckPlanSubjectMapper.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/dv/checkplan/MesDvCheckPlanSubjectMapper.java new file mode 100644 index 0000000..3814ce1 --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/dv/checkplan/MesDvCheckPlanSubjectMapper.java @@ -0,0 +1,31 @@ +package cn.iocoder.yudao.module.mes.dal.mysql.dv.checkplan; + +import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; +import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.checkplan.MesDvCheckPlanSubjectDO; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * MES 点检保养方案项目 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface MesDvCheckPlanSubjectMapper extends BaseMapperX { + + default List selectListByPlanId(Long planId) { + return selectList(MesDvCheckPlanSubjectDO::getPlanId, planId); + } + + default Long selectCountByPlanId(Long planId) { + return selectCount(MesDvCheckPlanSubjectDO::getPlanId, planId); + } + + default void deleteByPlanId(Long planId) { + delete(new LambdaQueryWrapperX() + .eq(MesDvCheckPlanSubjectDO::getPlanId, planId)); + } + +} diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/ErrorCodeConstants.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/ErrorCodeConstants.java index 657f0e6..cf0a148 100644 --- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/ErrorCodeConstants.java +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/ErrorCodeConstants.java @@ -126,10 +126,23 @@ public interface ErrorCodeConstants { // ========== MES 设备管理-点检计划(1-040-302-000) ========== ErrorCode DV_CHECK_PLAN_NOT_EXISTS = new ErrorCode(1_040_302_000, "点检计划不存在"); + ErrorCode DV_CHECK_PLAN_CODE_DUPLICATE = new ErrorCode(1_040_302_001, "点检保养方案编码已存在"); + ErrorCode DV_CHECK_PLAN_NOT_PREPARE = new ErrorCode(1_040_302_002, "点检保养方案已启用,不允许修改或删除"); + ErrorCode DV_CHECK_PLAN_NO_MACHINERY = new ErrorCode(1_040_302_003, "启用方案时,至少需要关联一台设备"); + ErrorCode DV_CHECK_PLAN_NO_SUBJECT = new ErrorCode(1_040_302_004, "启用方案时,至少需要关联一个点检保养项目"); + // ========== MES 设备管理-点检方案设备(1-040-302-100) ========== + ErrorCode DV_CHECK_PLAN_MACHINERY_NOT_EXISTS = new ErrorCode(1_040_302_100, "点检保养方案设备不存在"); + // ========== MES 设备管理-点检方案项目(1-040-302-200) ========== + ErrorCode DV_CHECK_PLAN_SUBJECT_NOT_EXISTS = new ErrorCode(1_040_302_200, "点检保养方案项目不存在"); // ========== MES 设备管理-维修工单(1-040-303-000) ========== ErrorCode DV_REPAIR_NOT_EXISTS = new ErrorCode(1_040_303_000, "维修工单不存在"); + // ========== MES 设备管理-保养记录(1-040-305-000) ========== + ErrorCode MAINTEN_RECORD_NOT_EXISTS = new ErrorCode(1_040_305_000, "设备保养记录不存在"); + // ========== MES 设备管理-保养记录明细(1-040-305-100) ========== + ErrorCode MAINTEN_RECORD_LINE_NOT_EXISTS = new ErrorCode(1_040_305_100, "设备保养记录明细不存在"); + // ========== MES 工具管理-工具类型(1-040-400-000) ========== ErrorCode TM_TOOL_TYPE_NOT_EXISTS = new ErrorCode(1_040_400_000, "工具类型不存在"); ErrorCode TM_TOOL_TYPE_CODE_DUPLICATE = new ErrorCode(1_040_400_001, "工具类型编码已存在"); diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/dv/MesDvCheckPlanStatusEnum.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/dv/MesDvCheckPlanStatusEnum.java new file mode 100644 index 0000000..c378520 --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/dv/MesDvCheckPlanStatusEnum.java @@ -0,0 +1,37 @@ +package cn.iocoder.yudao.module.mes.enums.dv; + +import cn.iocoder.yudao.framework.common.core.ArrayValuable; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Arrays; + +/** + * MES 点检保养方案状态枚举 + * + * @author 芋道源码 + */ +@Getter +@AllArgsConstructor +public enum MesDvCheckPlanStatusEnum implements ArrayValuable { + + PREPARE(0, "草稿"), + ENABLED(1, "已启用"); + + public static final Integer[] ARRAYS = Arrays.stream(values()).map(MesDvCheckPlanStatusEnum::getStatus).toArray(Integer[]::new); + + /** + * 状态值 + */ + private final Integer status; + /** + * 状态名 + */ + private final String name; + + @Override + public Integer[] array() { + return ARRAYS; + } + +} diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/checkplan/MesDvCheckPlanMachineryService.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/checkplan/MesDvCheckPlanMachineryService.java new file mode 100644 index 0000000..7a7abc3 --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/checkplan/MesDvCheckPlanMachineryService.java @@ -0,0 +1,54 @@ +package cn.iocoder.yudao.module.mes.service.dv.checkplan; + +import cn.iocoder.yudao.module.mes.controller.admin.dv.checkplan.vo.machinery.MesDvCheckPlanMachinerySaveReqVO; +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.checkplan.MesDvCheckPlanMachineryDO; +import jakarta.validation.Valid; + +import java.util.List; + +/** + * MES 点检保养方案设备 Service 接口 + * + * @author 芋道源码 + */ +public interface MesDvCheckPlanMachineryService { + + /** + * 创建方案设备关联 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createCheckPlanMachinery(@Valid MesDvCheckPlanMachinerySaveReqVO createReqVO); + + /** + * 删除方案设备关联 + * + * @param id 编号 + */ + void deleteCheckPlanMachinery(Long id); + + /** + * 获得指定方案的设备列表 + * + * @param planId 方案编号 + * @return 设备关联列表 + */ + List getCheckPlanMachineryListByPlanId(Long planId); + + /** + * 获得指定方案的设备数量 + * + * @param planId 方案编号 + * @return 设备数量 + */ + Long getCheckPlanMachineryCountByPlanId(Long planId); + + /** + * 根据方案编号删除所有设备关联 + * + * @param planId 方案编号 + */ + void deleteByPlanId(Long planId); + +} diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/checkplan/MesDvCheckPlanMachineryServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/checkplan/MesDvCheckPlanMachineryServiceImpl.java new file mode 100644 index 0000000..2b6c886 --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/checkplan/MesDvCheckPlanMachineryServiceImpl.java @@ -0,0 +1,77 @@ +package cn.iocoder.yudao.module.mes.service.dv.checkplan; + +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.module.mes.controller.admin.dv.checkplan.vo.machinery.MesDvCheckPlanMachinerySaveReqVO; +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.checkplan.MesDvCheckPlanMachineryDO; +import cn.iocoder.yudao.module.mes.dal.mysql.dv.checkplan.MesDvCheckPlanMachineryMapper; +import cn.iocoder.yudao.module.mes.service.dv.machinery.MesDvMachineryService; +import jakarta.annotation.Resource; +import org.springframework.context.annotation.Lazy; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import java.util.List; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; + +/** + * MES 点检保养方案设备 Service 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +public class MesDvCheckPlanMachineryServiceImpl implements MesDvCheckPlanMachineryService { + + @Resource + private MesDvCheckPlanMachineryMapper checkPlanMachineryMapper; + @Resource + @Lazy + private MesDvCheckPlanService checkPlanService; + @Resource + private MesDvMachineryService machineryService; + + @Override + public Long createCheckPlanMachinery(MesDvCheckPlanMachinerySaveReqVO createReqVO) { + // 1.1 校验方案草稿状态 + checkPlanService.validateCheckPlanPrepare(createReqVO.getPlanId()); + // 1.2 校验设备存在 + machineryService.validateMachineryExists(createReqVO.getMachineryId()); + + // 2. 插入 + MesDvCheckPlanMachineryDO planMachinery = BeanUtils.toBean(createReqVO, MesDvCheckPlanMachineryDO.class); + checkPlanMachineryMapper.insert(planMachinery); + return planMachinery.getId(); + } + + @Override + public void deleteCheckPlanMachinery(Long id) { + // 1.1 校验存在 + MesDvCheckPlanMachineryDO existRecord = checkPlanMachineryMapper.selectById(id); + if (existRecord == null) { + throw exception(DV_CHECK_PLAN_MACHINERY_NOT_EXISTS); + } + // 1.2 校验方案草稿状态 + checkPlanService.validateCheckPlanPrepare(existRecord.getPlanId()); + + // 2. 删除 + checkPlanMachineryMapper.deleteById(id); + } + + @Override + public List getCheckPlanMachineryListByPlanId(Long planId) { + return checkPlanMachineryMapper.selectListByPlanId(planId); + } + + @Override + public Long getCheckPlanMachineryCountByPlanId(Long planId) { + return checkPlanMachineryMapper.selectCountByPlanId(planId); + } + + @Override + public void deleteByPlanId(Long planId) { + checkPlanMachineryMapper.deleteByPlanId(planId); + } + +} diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/checkplan/MesDvCheckPlanService.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/checkplan/MesDvCheckPlanService.java new file mode 100644 index 0000000..bfb1fe2 --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/checkplan/MesDvCheckPlanService.java @@ -0,0 +1,107 @@ +package cn.iocoder.yudao.module.mes.service.dv.checkplan; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.mes.controller.admin.dv.checkplan.vo.MesDvCheckPlanPageReqVO; +import cn.iocoder.yudao.module.mes.controller.admin.dv.checkplan.vo.MesDvCheckPlanSaveReqVO; +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.checkplan.MesDvCheckPlanDO; +import jakarta.validation.Valid; + +import java.util.Collection; +import java.util.List; +import java.util.Map; + +import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertMap; + +/** + * MES 点检保养方案 Service 接口 + * + * @author 芋道源码 + */ +public interface MesDvCheckPlanService { + + /** + * 创建点检保养方案 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createCheckPlan(@Valid MesDvCheckPlanSaveReqVO createReqVO); + + /** + * 更新点检保养方案 + * + * @param updateReqVO 更新信息 + */ + void updateCheckPlan(@Valid MesDvCheckPlanSaveReqVO updateReqVO); + + /** + * 启用点检保养方案 + * + * @param id 编号 + */ + void enableCheckPlan(Long id); + + /** + * 停用点检保养方案 + * + * @param id 编号 + */ + void disableCheckPlan(Long id); + + /** + * 删除点检保养方案 + * + * @param id 编号 + */ + void deleteCheckPlan(Long id); + + /** + * 校验点检保养方案存在 + * + * @param id 编号 + */ + void validateCheckPlanExists(Long id); + + /** + * 校验点检保养方案为草稿状态 + * + * @param planId 方案编号 + * @return 方案 + */ + MesDvCheckPlanDO validateCheckPlanPrepare(Long planId); + + /** + * 获得点检保养方案 + * + * @param id 编号 + * @return 方案 + */ + MesDvCheckPlanDO getCheckPlan(Long id); + + /** + * 获得点检保养方案分页 + * + * @param pageReqVO 分页查询 + * @return 方案分页 + */ + PageResult getCheckPlanPage(MesDvCheckPlanPageReqVO pageReqVO); + + /** + * 获得点检保养方案列表 + * + * @param ids 编号数组 + * @return 方案列表 + */ + List getCheckPlanList(Collection ids); + + /** + * 获得点检保养方案 Map + * + * @param ids 编号数组 + * @return 方案 Map + */ + default Map getCheckPlanMap(Collection ids) { + return convertMap(getCheckPlanList(ids), MesDvCheckPlanDO::getId); + } + +} diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/checkplan/MesDvCheckPlanServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/checkplan/MesDvCheckPlanServiceImpl.java new file mode 100644 index 0000000..868c8b8 --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/checkplan/MesDvCheckPlanServiceImpl.java @@ -0,0 +1,167 @@ +package cn.iocoder.yudao.module.mes.service.dv.checkplan; + +import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.util.ObjUtil; +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.module.mes.controller.admin.dv.checkplan.vo.MesDvCheckPlanPageReqVO; +import cn.iocoder.yudao.module.mes.controller.admin.dv.checkplan.vo.MesDvCheckPlanSaveReqVO; +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.checkplan.MesDvCheckPlanDO; +import cn.iocoder.yudao.module.mes.dal.mysql.dv.checkplan.MesDvCheckPlanMapper; +import cn.iocoder.yudao.module.mes.enums.dv.MesDvCheckPlanStatusEnum; +import jakarta.annotation.Resource; +import org.springframework.context.annotation.Lazy; +import org.springframework.stereotype.Service; +import org.springframework.transaction.annotation.Transactional; +import org.springframework.validation.annotation.Validated; + +import java.util.Collection; +import java.util.Collections; +import java.util.List; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; + +/** + * MES 点检保养方案 Service 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +public class MesDvCheckPlanServiceImpl implements MesDvCheckPlanService { + + @Resource + private MesDvCheckPlanMapper checkPlanMapper; + @Resource + @Lazy + private MesDvCheckPlanMachineryService checkPlanMachineryService; + @Resource + @Lazy + private MesDvCheckPlanSubjectService checkPlanSubjectService; + + @Override + public Long createCheckPlan(MesDvCheckPlanSaveReqVO createReqVO) { + // 1. 校验编码唯一 + validateCheckPlanCodeUnique(null, createReqVO.getCode()); + + // 2. 插入方案 + MesDvCheckPlanDO checkPlan = BeanUtils.toBean(createReqVO, MesDvCheckPlanDO.class); + checkPlan.setStatus(MesDvCheckPlanStatusEnum.PREPARE.getStatus()); // 默认草稿 + checkPlanMapper.insert(checkPlan); + return checkPlan.getId(); + } + + @Override + public void updateCheckPlan(MesDvCheckPlanSaveReqVO updateReqVO) { + // 1.1 校验存在 + MesDvCheckPlanDO existPlan = doValidateCheckPlanExists(updateReqVO.getId()); + // 1.2 校验草稿状态 + if (ObjUtil.notEqual(MesDvCheckPlanStatusEnum.PREPARE.getStatus(), existPlan.getStatus())) { + throw exception(DV_CHECK_PLAN_NOT_PREPARE); + } + // 1.3 校验编码唯一 + validateCheckPlanCodeUnique(updateReqVO.getId(), updateReqVO.getCode()); + + // 2. 更新 + updateReqVO.setStatus(null); // 不允许通过 update 修改状态 + MesDvCheckPlanDO updateObj = BeanUtils.toBean(updateReqVO, MesDvCheckPlanDO.class); + checkPlanMapper.updateById(updateObj); + } + + @Override + public void enableCheckPlan(Long id) { + // 1.1 校验存在 + 校验草稿状态 + validateCheckPlanPrepare(id); + // 1.2 校验至少关联一台设备 + Long machineryCount = checkPlanMachineryService.getCheckPlanMachineryCountByPlanId(id); + if (machineryCount <= 0) { + throw exception(DV_CHECK_PLAN_NO_MACHINERY); + } + // 1.3 校验至少关联一个项目 + Long subjectCount = checkPlanSubjectService.getCheckPlanSubjectCountByPlanId(id); + if (subjectCount <= 0) { + throw exception(DV_CHECK_PLAN_NO_SUBJECT); + } + + // 2. 更新状态为已启用 + checkPlanMapper.updateById(new MesDvCheckPlanDO().setId(id) + .setStatus(MesDvCheckPlanStatusEnum.ENABLED.getStatus())); + } + + @Override + public void disableCheckPlan(Long id) { + // 1. 校验存在 + validateCheckPlanExists(id); + + // 2. 更新状态为草稿 + checkPlanMapper.updateById(new MesDvCheckPlanDO().setId(id) + .setStatus(MesDvCheckPlanStatusEnum.PREPARE.getStatus())); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void deleteCheckPlan(Long id) { + // 1. 校验存在 + 校验草稿状态 + validateCheckPlanPrepare(id); + + // 2.1 级联删除设备关联 + 项目关联 + checkPlanMachineryService.deleteByPlanId(id); + checkPlanSubjectService.deleteByPlanId(id); + // 2.2 删除方案 + checkPlanMapper.deleteById(id); + } + + @Override + public MesDvCheckPlanDO validateCheckPlanPrepare(Long planId) { + MesDvCheckPlanDO plan = doValidateCheckPlanExists(planId); + if (ObjUtil.notEqual(MesDvCheckPlanStatusEnum.PREPARE.getStatus(), plan.getStatus())) { + throw exception(DV_CHECK_PLAN_NOT_PREPARE); + } + return plan; + } + + @Override + public MesDvCheckPlanDO getCheckPlan(Long id) { + return checkPlanMapper.selectById(id); + } + + @Override + public PageResult getCheckPlanPage(MesDvCheckPlanPageReqVO pageReqVO) { + return checkPlanMapper.selectPage(pageReqVO); + } + + @Override + public void validateCheckPlanExists(Long id) { + if (checkPlanMapper.selectById(id) == null) { + throw exception(DV_CHECK_PLAN_NOT_EXISTS); + } + } + + private MesDvCheckPlanDO doValidateCheckPlanExists(Long id) { + MesDvCheckPlanDO plan = checkPlanMapper.selectById(id); + if (plan == null) { + throw exception(DV_CHECK_PLAN_NOT_EXISTS); + } + return plan; + } + + private void validateCheckPlanCodeUnique(Long id, String code) { + MesDvCheckPlanDO plan = checkPlanMapper.selectByCode(code); + if (plan == null) { + return; + } + if (ObjUtil.notEqual(plan.getId(), id)) { + throw exception(DV_CHECK_PLAN_CODE_DUPLICATE); + } + } + + @Override + public List getCheckPlanList(Collection ids) { + if (CollUtil.isEmpty(ids)) { + return Collections.emptyList(); + } + return checkPlanMapper.selectByIds(ids); + } + +} diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/checkplan/MesDvCheckPlanSubjectService.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/checkplan/MesDvCheckPlanSubjectService.java new file mode 100644 index 0000000..e9f26a3 --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/checkplan/MesDvCheckPlanSubjectService.java @@ -0,0 +1,54 @@ +package cn.iocoder.yudao.module.mes.service.dv.checkplan; + +import cn.iocoder.yudao.module.mes.controller.admin.dv.checkplan.vo.subject.MesDvCheckPlanSubjectSaveReqVO; +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.checkplan.MesDvCheckPlanSubjectDO; +import jakarta.validation.Valid; + +import java.util.List; + +/** + * MES 点检保养方案项目 Service 接口 + * + * @author 芋道源码 + */ +public interface MesDvCheckPlanSubjectService { + + /** + * 创建方案项目关联 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createCheckPlanSubject(@Valid MesDvCheckPlanSubjectSaveReqVO createReqVO); + + /** + * 删除方案项目关联 + * + * @param id 编号 + */ + void deleteCheckPlanSubject(Long id); + + /** + * 获得指定方案的项目列表 + * + * @param planId 方案编号 + * @return 项目关联列表 + */ + List getCheckPlanSubjectListByPlanId(Long planId); + + /** + * 获得指定方案的项目数量 + * + * @param planId 方案编号 + * @return 项目数量 + */ + Long getCheckPlanSubjectCountByPlanId(Long planId); + + /** + * 根据方案编号删除所有项目关联 + * + * @param planId 方案编号 + */ + void deleteByPlanId(Long planId); + +} diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/checkplan/MesDvCheckPlanSubjectServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/checkplan/MesDvCheckPlanSubjectServiceImpl.java new file mode 100644 index 0000000..9e1488c --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/dv/checkplan/MesDvCheckPlanSubjectServiceImpl.java @@ -0,0 +1,77 @@ +package cn.iocoder.yudao.module.mes.service.dv.checkplan; + +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.module.mes.controller.admin.dv.checkplan.vo.subject.MesDvCheckPlanSubjectSaveReqVO; +import cn.iocoder.yudao.module.mes.dal.dataobject.dv.checkplan.MesDvCheckPlanSubjectDO; +import cn.iocoder.yudao.module.mes.dal.mysql.dv.checkplan.MesDvCheckPlanSubjectMapper; +import cn.iocoder.yudao.module.mes.service.dv.subject.MesDvSubjectService; +import jakarta.annotation.Resource; +import org.springframework.context.annotation.Lazy; +import org.springframework.stereotype.Service; +import org.springframework.validation.annotation.Validated; + +import java.util.List; + +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; +import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*; + +/** + * MES 点检保养方案项目 Service 实现类 + * + * @author 芋道源码 + */ +@Service +@Validated +public class MesDvCheckPlanSubjectServiceImpl implements MesDvCheckPlanSubjectService { + + @Resource + private MesDvCheckPlanSubjectMapper checkPlanSubjectMapper; + @Resource + @Lazy + private MesDvCheckPlanService checkPlanService; + @Resource + private MesDvSubjectService subjectService; + + @Override + public Long createCheckPlanSubject(MesDvCheckPlanSubjectSaveReqVO createReqVO) { + // 1.1 校验方案草稿状态 + checkPlanService.validateCheckPlanPrepare(createReqVO.getPlanId()); + // 1.2 校验项目存在 + subjectService.validateSubjectExists(createReqVO.getSubjectId()); + + // 2. 插入 + MesDvCheckPlanSubjectDO planSubject = BeanUtils.toBean(createReqVO, MesDvCheckPlanSubjectDO.class); + checkPlanSubjectMapper.insert(planSubject); + return planSubject.getId(); + } + + @Override + public void deleteCheckPlanSubject(Long id) { + // 1.1 校验存在 + MesDvCheckPlanSubjectDO existRecord = checkPlanSubjectMapper.selectById(id); + if (existRecord == null) { + throw exception(DV_CHECK_PLAN_SUBJECT_NOT_EXISTS); + } + // 1.2 校验方案草稿状态 + checkPlanService.validateCheckPlanPrepare(existRecord.getPlanId()); + + // 2. 删除 + checkPlanSubjectMapper.deleteById(id); + } + + @Override + public List getCheckPlanSubjectListByPlanId(Long planId) { + return checkPlanSubjectMapper.selectListByPlanId(planId); + } + + @Override + public Long getCheckPlanSubjectCountByPlanId(Long planId) { + return checkPlanSubjectMapper.selectCountByPlanId(planId); + } + + @Override + public void deleteByPlanId(Long planId) { + checkPlanSubjectMapper.deleteByPlanId(planId); + } + +}