From 15e6c5d308f56bb07e704f6bf9c8eb4b80a525c3 Mon Sep 17 00:00:00 2001 From: YunaiV Date: Tue, 17 Feb 2026 15:15:25 +0800 Subject: [PATCH] feat(mes):优化、实现 plan 的逻辑 --- yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/MesCalPlanShiftController.java | 103 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/MesCalShiftController.java | 103 ------------------------------------------------------------------------------------------------------- yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/shift/MesCalPlanShiftPageReqVO.java | 21 +++++++++++++++++++++ yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/shift/MesCalPlanShiftRespVO.java | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/shift/MesCalPlanShiftSaveReqVO.java | 50 ++++++++++++++++++++++++++++++++++++++++++++++++++ yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/shift/MesCalShiftPageReqVO.java | 21 --------------------- yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/shift/MesCalShiftRespVO.java | 59 ----------------------------------------------------------- yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/shift/MesCalShiftSaveReqVO.java | 50 -------------------------------------------------- yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/cal/MesCalPlanDO.java | 4 ++-- yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/cal/MesCalPlanShiftDO.java | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/cal/MesCalShiftDO.java | 72 ------------------------------------------------------------------------ yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/cal/plan/MesCalPlanShiftMapper.java | 42 ++++++++++++++++++++++++++++++++++++++++++ yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/cal/plan/MesCalShiftMapper.java | 42 ------------------------------------------ yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/DictTypeConstants.java | 3 +++ yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/ErrorCodeConstants.java | 11 ++++++----- yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/cal/CalConstants.java | 18 ------------------ yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/cal/MesCalCalendarTypeEnum.java | 37 +++++++++++++++++++++++++++++++++++++ yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/cal/MesCalShiftTypeEnum.java | 50 +++++++++++++++++++++++++++++++++++++++++++++++--- yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalPlanServiceImpl.java | 19 +++++++++---------- yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalPlanShiftService.java | 87 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalPlanShiftServiceImpl.java | 130 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalPlanTeamServiceImpl.java | 2 ++ yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalShiftService.java | 87 --------------------------------------------------------------------------------------- yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalShiftServiceImpl.java | 147 --------------------------------------------------------------------------------------------------------------------------------------------------- 24 files changed, 671 insertions(+), 619 deletions(-) create mode 100644 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/MesCalPlanShiftController.java delete mode 100644 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/MesCalShiftController.java create mode 100644 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/shift/MesCalPlanShiftPageReqVO.java create mode 100644 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/shift/MesCalPlanShiftRespVO.java create mode 100644 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/shift/MesCalPlanShiftSaveReqVO.java delete mode 100644 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/shift/MesCalShiftPageReqVO.java delete mode 100644 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/shift/MesCalShiftRespVO.java delete mode 100644 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/shift/MesCalShiftSaveReqVO.java create mode 100644 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/cal/MesCalPlanShiftDO.java delete mode 100644 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/cal/MesCalShiftDO.java create mode 100644 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/cal/plan/MesCalPlanShiftMapper.java delete mode 100644 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/cal/plan/MesCalShiftMapper.java delete mode 100644 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/cal/CalConstants.java create mode 100644 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/cal/MesCalCalendarTypeEnum.java create mode 100644 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalPlanShiftService.java create mode 100644 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalPlanShiftServiceImpl.java delete mode 100644 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalShiftService.java delete mode 100644 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalShiftServiceImpl.java diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/MesCalPlanShiftController.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/MesCalPlanShiftController.java new file mode 100644 index 0000000..4e0c905 --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/MesCalPlanShiftController.java @@ -0,0 +1,103 @@ +package cn.iocoder.yudao.module.mes.controller.admin.cal.plan; + +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.cal.plan.vo.shift.MesCalPlanShiftPageReqVO; +import cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.shift.MesCalPlanShiftRespVO; +import cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.shift.MesCalPlanShiftSaveReqVO; +import cn.iocoder.yudao.module.mes.dal.dataobject.cal.MesCalPlanShiftDO; +import cn.iocoder.yudao.module.mes.service.cal.plan.MesCalPlanShiftService; +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/cal/plan-shift") +@Validated +public class MesCalPlanShiftController { + + @Resource + private MesCalPlanShiftService planShiftService; + + @PostMapping("/create") + @Operation(summary = "创建计划班次") + @PreAuthorize("@ss.hasPermission('mes:cal-plan:update')") + public CommonResult createPlanShift(@Valid @RequestBody MesCalPlanShiftSaveReqVO createReqVO) { + return success(planShiftService.createPlanShift(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新计划班次") + @PreAuthorize("@ss.hasPermission('mes:cal-plan:update')") + public CommonResult updatePlanShift(@Valid @RequestBody MesCalPlanShiftSaveReqVO updateReqVO) { + planShiftService.updatePlanShift(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除计划班次") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('mes:cal-plan:update')") + public CommonResult deletePlanShift(@RequestParam("id") Long id) { + planShiftService.deletePlanShift(id); + return success(true); + } + + @GetMapping("/get") + @Operation(summary = "获得计划班次") + @Parameter(name = "id", description = "编号", required = true, example = "1024") + @PreAuthorize("@ss.hasPermission('mes:cal-plan:query')") + public CommonResult getPlanShift(@RequestParam("id") Long id) { + MesCalPlanShiftDO planShift = planShiftService.getPlanShift(id); + return success(BeanUtils.toBean(planShift, MesCalPlanShiftRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得计划班次分页") + @PreAuthorize("@ss.hasPermission('mes:cal-plan:query')") + public CommonResult> getPlanShiftPage(@Valid MesCalPlanShiftPageReqVO pageReqVO) { + PageResult pageResult = planShiftService.getPlanShiftPage(pageReqVO); + return success(BeanUtils.toBean(pageResult, MesCalPlanShiftRespVO.class)); + } + + @GetMapping("/list-by-plan") + @Operation(summary = "获得指定排班计划的班次列表") + @Parameter(name = "planId", description = "排班计划编号", required = true) + @PreAuthorize("@ss.hasPermission('mes:cal-plan:query')") + public CommonResult> getPlanShiftListByPlan(@RequestParam("planId") Long planId) { + List list = planShiftService.getPlanShiftListByPlanId(planId); + return success(BeanUtils.toBean(list, MesCalPlanShiftRespVO.class)); + } + +// TODO @AI:是不是不要导出 + @GetMapping("/export-excel") + @Operation(summary = "导出计划班次 Excel") + @PreAuthorize("@ss.hasPermission('mes:cal-plan:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportPlanShiftExcel(@Valid MesCalPlanShiftPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = planShiftService.getPlanShiftPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "计划班次.xls", "数据", MesCalPlanShiftRespVO.class, + BeanUtils.toBean(list, MesCalPlanShiftRespVO.class)); + } + +} diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/MesCalShiftController.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/MesCalShiftController.java deleted file mode 100644 index f17660e..0000000 --- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/MesCalShiftController.java +++ /dev/null @@ -1,103 +0,0 @@ -package cn.iocoder.yudao.module.mes.controller.admin.cal.plan; - -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.cal.plan.vo.shift.MesCalShiftPageReqVO; -import cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.shift.MesCalShiftRespVO; -import cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.shift.MesCalShiftSaveReqVO; -import cn.iocoder.yudao.module.mes.dal.dataobject.cal.MesCalShiftDO; -import cn.iocoder.yudao.module.mes.service.cal.plan.MesCalShiftService; -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; - -// TODO @AI:它是不是改成 MesCalPlanShiftController 更好?毕竟它是排班计划的班次,而不是单纯的班次 -@Tag(name = "管理后台 - MES 计划班次") -@RestController -@RequestMapping("/mes/cal/shift") -@Validated -public class MesCalShiftController { - - @Resource - private MesCalShiftService shiftService; - - @PostMapping("/create") - @Operation(summary = "创建计划班次") - @PreAuthorize("@ss.hasPermission('mes:cal-shift:create')") - public CommonResult createShift(@Valid @RequestBody MesCalShiftSaveReqVO createReqVO) { - return success(shiftService.createShift(createReqVO)); - } - - @PutMapping("/update") - @Operation(summary = "更新计划班次") - @PreAuthorize("@ss.hasPermission('mes:cal-shift:update')") - public CommonResult updateShift(@Valid @RequestBody MesCalShiftSaveReqVO updateReqVO) { - shiftService.updateShift(updateReqVO); - return success(true); - } - - @DeleteMapping("/delete") - @Operation(summary = "删除计划班次") - @Parameter(name = "id", description = "编号", required = true) - @PreAuthorize("@ss.hasPermission('mes:cal-shift:delete')") - public CommonResult deleteShift(@RequestParam("id") Long id) { - shiftService.deleteShift(id); - return success(true); - } - - @GetMapping("/get") - @Operation(summary = "获得计划班次") - @Parameter(name = "id", description = "编号", required = true, example = "1024") - @PreAuthorize("@ss.hasPermission('mes:cal-shift:query')") - public CommonResult getShift(@RequestParam("id") Long id) { - MesCalShiftDO shift = shiftService.getShift(id); - return success(BeanUtils.toBean(shift, MesCalShiftRespVO.class)); - } - - @GetMapping("/page") - @Operation(summary = "获得计划班次分页") - @PreAuthorize("@ss.hasPermission('mes:cal-shift:query')") - public CommonResult> getShiftPage(@Valid MesCalShiftPageReqVO pageReqVO) { - PageResult pageResult = shiftService.getShiftPage(pageReqVO); - return success(BeanUtils.toBean(pageResult, MesCalShiftRespVO.class)); - } - - @GetMapping("/list-by-plan") - @Operation(summary = "获得指定排班计划的班次列表") - @Parameter(name = "planId", description = "排班计划编号", required = true) - @PreAuthorize("@ss.hasPermission('mes:cal-shift:query')") - public CommonResult> getShiftListByPlan(@RequestParam("planId") Long planId) { - List list = shiftService.getShiftListByPlanId(planId); - return success(BeanUtils.toBean(list, MesCalShiftRespVO.class)); - } - - @GetMapping("/export-excel") - @Operation(summary = "导出计划班次 Excel") - @PreAuthorize("@ss.hasPermission('mes:cal-shift:export')") - @ApiAccessLog(operateType = EXPORT) - public void exportShiftExcel(@Valid MesCalShiftPageReqVO pageReqVO, - HttpServletResponse response) throws IOException { - pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); - List list = shiftService.getShiftPage(pageReqVO).getList(); - // 导出 Excel - ExcelUtils.write(response, "计划班次.xls", "数据", MesCalShiftRespVO.class, - BeanUtils.toBean(list, MesCalShiftRespVO.class)); - } - -} diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/shift/MesCalPlanShiftPageReqVO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/shift/MesCalPlanShiftPageReqVO.java new file mode 100644 index 0000000..525e168 --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/shift/MesCalPlanShiftPageReqVO.java @@ -0,0 +1,21 @@ +package cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.shift; + +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; + +@Schema(description = "管理后台 - MES 计划班次分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class MesCalPlanShiftPageReqVO extends PageParam { + + @Schema(description = "排班计划编号", example = "1") + private Long planId; + + @Schema(description = "班次名称", example = "白班") + private String name; + +} diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/shift/MesCalPlanShiftRespVO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/shift/MesCalPlanShiftRespVO.java new file mode 100644 index 0000000..5be873a --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/shift/MesCalPlanShiftRespVO.java @@ -0,0 +1,60 @@ +package cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.shift; + +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; + +// TODO @AI:是不是不要导出 +@Schema(description = "管理后台 - MES 计划班次 Response VO") +@Data +@ExcelIgnoreUnannotated +public class MesCalPlanShiftRespVO { + + @Schema(description = "班次编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @ExcelProperty("班次编号") + private Long id; + + @Schema(description = "排班计划编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @ExcelProperty("排班计划编号") + private Long planId; + + @Schema(description = "显示顺序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") + @ExcelProperty("显示顺序") + private Integer sort; + + @Schema(description = "班次名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "白班") + @ExcelProperty("班次名称") + private String name; + + @Schema(description = "开始时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "08:00") + @ExcelProperty("开始时间") + private String startTime; + + @Schema(description = "结束时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "17:00") + @ExcelProperty("结束时间") + private String endTime; + + @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/cal/plan/vo/shift/MesCalPlanShiftSaveReqVO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/shift/MesCalPlanShiftSaveReqVO.java new file mode 100644 index 0000000..fd60e99 --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/shift/MesCalPlanShiftSaveReqVO.java @@ -0,0 +1,50 @@ +package cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.shift; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotEmpty; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +@Schema(description = "管理后台 - MES 计划班次新增/修改 Request VO") +@Data +public class MesCalPlanShiftSaveReqVO { + + @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 Integer sort; + + @Schema(description = "班次名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "白班") + @NotEmpty(message = "班次名称不能为空") + private String name; + + @Schema(description = "开始时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "08:00") + @NotEmpty(message = "开始时间不能为空") + private String startTime; + + @Schema(description = "结束时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "17:00") + @NotEmpty(message = "结束时间不能为空") + private String endTime; + + @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/cal/plan/vo/shift/MesCalShiftPageReqVO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/shift/MesCalShiftPageReqVO.java deleted file mode 100644 index d37a934..0000000 --- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/shift/MesCalShiftPageReqVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.shift; - -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; - -@Schema(description = "管理后台 - MES 计划班次分页 Request VO") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -public class MesCalShiftPageReqVO extends PageParam { - - @Schema(description = "排班计划编号", example = "1") - private Long planId; - - @Schema(description = "班次名称", example = "白班") - private String name; - -} diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/shift/MesCalShiftRespVO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/shift/MesCalShiftRespVO.java deleted file mode 100644 index d8abf28..0000000 --- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/shift/MesCalShiftRespVO.java +++ /dev/null @@ -1,59 +0,0 @@ -package cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.shift; - -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 MesCalShiftRespVO { - - @Schema(description = "班次编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") - @ExcelProperty("班次编号") - private Long id; - - @Schema(description = "排班计划编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty("排班计划编号") - private Long planId; - - @Schema(description = "显示顺序", requiredMode = Schema.RequiredMode.REQUIRED, example = "1") - @ExcelProperty("显示顺序") - private Integer sort; - - @Schema(description = "班次名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "白班") - @ExcelProperty("班次名称") - private String name; - - @Schema(description = "开始时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "08:00") - @ExcelProperty("开始时间") - private String startTime; - - @Schema(description = "结束时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "17:00") - @ExcelProperty("结束时间") - private String endTime; - - @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/cal/plan/vo/shift/MesCalShiftSaveReqVO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/shift/MesCalShiftSaveReqVO.java deleted file mode 100644 index 1ed9abb..0000000 --- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/shift/MesCalShiftSaveReqVO.java +++ /dev/null @@ -1,50 +0,0 @@ -package cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.shift; - -import io.swagger.v3.oas.annotations.media.Schema; -import jakarta.validation.constraints.NotEmpty; -import jakarta.validation.constraints.NotNull; -import lombok.Data; - -@Schema(description = "管理后台 - MES 计划班次新增/修改 Request VO") -@Data -public class MesCalShiftSaveReqVO { - - @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 Integer sort; - - @Schema(description = "班次名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "白班") - @NotEmpty(message = "班次名称不能为空") - private String name; - - @Schema(description = "开始时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "08:00") - @NotEmpty(message = "开始时间不能为空") - private String startTime; - - @Schema(description = "结束时间", requiredMode = Schema.RequiredMode.REQUIRED, example = "17:00") - @NotEmpty(message = "结束时间不能为空") - private String endTime; - - @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/cal/MesCalPlanDO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/cal/MesCalPlanDO.java index fb0c2f6..6e88aab 100644 --- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/cal/MesCalPlanDO.java +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/cal/MesCalPlanDO.java @@ -1,6 +1,7 @@ package cn.iocoder.yudao.module.mes.dal.dataobject.cal; import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +import cn.iocoder.yudao.module.mes.enums.cal.MesCalCalendarTypeEnum; import cn.iocoder.yudao.module.mes.enums.cal.MesCalPlanStatusEnum; import cn.iocoder.yudao.module.mes.enums.cal.MesCalShiftMethodEnum; import cn.iocoder.yudao.module.mes.enums.cal.MesCalShiftTypeEnum; @@ -39,11 +40,10 @@ public class MesCalPlanDO extends BaseDO { * 计划名称 */ private String name; - // TODO @AI:增加一个枚举值(类),好一点; /** * 班组类型 * - * 枚举 mes_cal_calendar_type(1=分组轮班, 2=固定班组) + * 枚举 {@link MesCalCalendarTypeEnum} */ private Integer calendarType; /** diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/cal/MesCalPlanShiftDO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/cal/MesCalPlanShiftDO.java new file mode 100644 index 0000000..2165f9c --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/cal/MesCalPlanShiftDO.java @@ -0,0 +1,72 @@ +package cn.iocoder.yudao.module.mes.dal.dataobject.cal; + +import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; +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_cal_plan_shift") +@KeySequence("mes_cal_plan_shift_seq") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class MesCalPlanShiftDO extends BaseDO { + + /** + * 班次编号 + */ + @TableId + private Long id; + /** + * 排班计划编号 + * + * 关联 {@link MesCalPlanDO#getId()} + */ + private Long planId; + /** + * 显示顺序 + */ + private Integer sort; + /** + * 班次名称 + */ + private String name; + /** + * 开始时间(HH:mm 格式) + */ + private String startTime; + /** + * 结束时间(HH:mm 格式) + */ + private String endTime; + /** + * 备注 + */ + 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/cal/MesCalShiftDO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/cal/MesCalShiftDO.java deleted file mode 100644 index dc028df..0000000 --- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/cal/MesCalShiftDO.java +++ /dev/null @@ -1,72 +0,0 @@ -package cn.iocoder.yudao.module.mes.dal.dataobject.cal; - -import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO; -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_cal_shift") -@KeySequence("mes_cal_shift_seq") -@Data -@EqualsAndHashCode(callSuper = true) -@ToString(callSuper = true) -@Builder -@NoArgsConstructor -@AllArgsConstructor -public class MesCalShiftDO extends BaseDO { - - /** - * 班次编号 - */ - @TableId - private Long id; - /** - * 排班计划编号 - * - * 关联 {@link MesCalPlanDO#getId()} - */ - private Long planId; - /** - * 显示顺序 - */ - private Integer sort; - /** - * 班次名称 - */ - private String name; - /** - * 开始时间(HH:mm 格式) - */ - private String startTime; - /** - * 结束时间(HH:mm 格式) - */ - private String endTime; - /** - * 备注 - */ - 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/cal/plan/MesCalPlanShiftMapper.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/cal/plan/MesCalPlanShiftMapper.java new file mode 100644 index 0000000..ce87857 --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/cal/plan/MesCalPlanShiftMapper.java @@ -0,0 +1,42 @@ +package cn.iocoder.yudao.module.mes.dal.mysql.cal.plan; + +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.cal.plan.vo.shift.MesCalPlanShiftPageReqVO; +import cn.iocoder.yudao.module.mes.dal.dataobject.cal.MesCalPlanShiftDO; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** + * MES 计划班次 Mapper + * + * @author 芋道源码 + */ +@Mapper +public interface MesCalPlanShiftMapper extends BaseMapperX { + + default PageResult selectPage(MesCalPlanShiftPageReqVO reqVO) { + return selectPage(reqVO, new LambdaQueryWrapperX() + .eqIfPresent(MesCalPlanShiftDO::getPlanId, reqVO.getPlanId()) + .likeIfPresent(MesCalPlanShiftDO::getName, reqVO.getName()) + .orderByAsc(MesCalPlanShiftDO::getSort)); + } + + default List selectListByPlanId(Long planId) { + return selectList(new LambdaQueryWrapperX() + .eq(MesCalPlanShiftDO::getPlanId, planId) + .orderByAsc(MesCalPlanShiftDO::getSort)); + } + + default Long selectCountByPlanId(Long planId) { + return selectCount(MesCalPlanShiftDO::getPlanId, planId); + } + + default void deleteByPlanId(Long planId) { + delete(new LambdaQueryWrapperX() + .eq(MesCalPlanShiftDO::getPlanId, planId)); + } + +} diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/cal/plan/MesCalShiftMapper.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/cal/plan/MesCalShiftMapper.java deleted file mode 100644 index 41c0f84..0000000 --- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/cal/plan/MesCalShiftMapper.java +++ /dev/null @@ -1,42 +0,0 @@ -package cn.iocoder.yudao.module.mes.dal.mysql.cal.plan; - -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.cal.plan.vo.shift.MesCalShiftPageReqVO; -import cn.iocoder.yudao.module.mes.dal.dataobject.cal.MesCalShiftDO; -import org.apache.ibatis.annotations.Mapper; - -import java.util.List; - -/** - * MES 计划班次 Mapper - * - * @author 芋道源码 - */ -@Mapper -public interface MesCalShiftMapper extends BaseMapperX { - - default PageResult selectPage(MesCalShiftPageReqVO reqVO) { - return selectPage(reqVO, new LambdaQueryWrapperX() - .eqIfPresent(MesCalShiftDO::getPlanId, reqVO.getPlanId()) - .likeIfPresent(MesCalShiftDO::getName, reqVO.getName()) - .orderByAsc(MesCalShiftDO::getSort)); - } - - default List selectListByPlanId(Long planId) { - return selectList(new LambdaQueryWrapperX() - .eq(MesCalShiftDO::getPlanId, planId) - .orderByAsc(MesCalShiftDO::getSort)); - } - - default Long selectCountByPlanId(Long planId) { - return selectCount(MesCalShiftDO::getPlanId, planId); - } - - default void deleteByPlanId(Long planId) { - delete(new LambdaQueryWrapperX() - .eq(MesCalShiftDO::getPlanId, planId)); - } - -} diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/DictTypeConstants.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/DictTypeConstants.java index 64de731..456c08f 100644 --- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/DictTypeConstants.java +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/DictTypeConstants.java @@ -19,5 +19,8 @@ public interface DictTypeConstants { String MES_DV_MACHINERY_STATUS = "mes_dv_machinery_status"; // MES 设备状态 String MES_INDEX_TYPE = "mes_index_type"; // MES 检测项类型 String MES_DEFECT_LEVEL = "mes_defect_level"; // MES 缺陷等级 + String MES_PRO_WORKORDER_STATUS = "mes_pro_workorder_status"; // MES 生产工单状态 + String MES_PRO_WORKORDER_SOURCE_TYPE = "mes_pro_workorder_source_type"; // MES 工单来源类型 + String MES_PRO_WORKORDER_TYPE = "mes_pro_workorder_type"; // MES 工单类型 } 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 274ec06..ae99e75 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 @@ -81,11 +81,9 @@ public interface ErrorCodeConstants { ErrorCode MD_PRODUCT_SIP_NOT_EXISTS = new ErrorCode(1_040_109_000, "产品SIP不存在"); ErrorCode MD_PRODUCT_SIP_SORT_DUPLICATE = new ErrorCode(1_040_109_001, "该展示序号已存在"); - // ========== MES 日历排班-班次(1-040-200-000) ========== - ErrorCode CAL_SHIFT_NOT_EXISTS = new ErrorCode(1_040_200_000, "班次不存在"); - ErrorCode CAL_SHIFT_COUNT_EXCEED_SINGLE = new ErrorCode(1_040_200_001, "轮班方式为白班时只能有一个班次"); - ErrorCode CAL_SHIFT_COUNT_EXCEED_TWO = new ErrorCode(1_040_200_002, "轮班方式为两班倒时只能有两个班次"); - ErrorCode CAL_SHIFT_COUNT_EXCEED_THREE = new ErrorCode(1_040_200_003, "轮班方式为三班倒时只能有三个班次"); + // ========== MES 日历排班-计划班次(1-040-200-000) ========== + ErrorCode CAL_PLAN_SHIFT_NOT_EXISTS = new ErrorCode(1_040_200_000, "计划班次不存在"); + ErrorCode CAL_PLAN_SHIFT_COUNT_EXCEED = new ErrorCode(1_040_200_001, "班次数量已达到轮班方式的上限"); // ========== MES 日历排班-班组(1-040-201-000) ========== ErrorCode CAL_TEAM_NOT_EXISTS = new ErrorCode(1_040_201_000, "班组不存在"); @@ -140,6 +138,9 @@ public interface ErrorCodeConstants { // ========== MES 生产管理-生产工单(1-040-502-000) ========== ErrorCode PRO_WORKORDER_NOT_EXISTS = new ErrorCode(1_040_502_000, "生产工单不存在"); + ErrorCode PRO_WORKORDER_CODE_DUPLICATE = new ErrorCode(1_040_502_001, "生产工单编码已存在"); + ErrorCode PRO_WORKORDER_NOT_PREPARE = new ErrorCode(1_040_502_002, "只能删除草稿状态的工单"); + ErrorCode PRO_WORKORDER_BOM_NOT_EXISTS = new ErrorCode(1_040_502_100, "生产工单BOM不存在"); // ========== MES 生产管理-生产任务(1-040-503-000) ========== ErrorCode PRO_TASK_NOT_EXISTS = new ErrorCode(1_040_503_000, "生产任务不存在"); diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/cal/CalConstants.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/cal/CalConstants.java deleted file mode 100644 index 02cd03a..0000000 --- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/cal/CalConstants.java +++ /dev/null @@ -1,18 +0,0 @@ -package cn.iocoder.yudao.module.mes.enums.cal; - -// TODO @AI:参考别的类,生成枚举类 -/** - * MES 日历排班常量 - * - * @author 芋道源码 - */ -public interface CalConstants { - - /** 白班 */ - String SHIFT_NAME_DAY = "白班"; - /** 夜班 */ - String SHIFT_NAME_NIGHT = "夜班"; - /** 中班 */ - String SHIFT_NAME_MID = "中班"; - -} diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/cal/MesCalCalendarTypeEnum.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/cal/MesCalCalendarTypeEnum.java new file mode 100644 index 0000000..e9f6867 --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/cal/MesCalCalendarTypeEnum.java @@ -0,0 +1,37 @@ +package cn.iocoder.yudao.module.mes.enums.cal; + +import cn.iocoder.yudao.framework.common.core.ArrayValuable; +import lombok.AllArgsConstructor; +import lombok.Getter; + +import java.util.Arrays; + +/** + * MES 班组类型(日历类型)枚举 + * + * @author 芋道源码 + */ +@Getter +@AllArgsConstructor +public enum MesCalCalendarTypeEnum implements ArrayValuable { + + GROUP_ROTATION(1, "分组轮班"), + FIXED_TEAM(2, "固定班组"); + + public static final Integer[] ARRAYS = Arrays.stream(values()).map(MesCalCalendarTypeEnum::getType).toArray(Integer[]::new); + + /** + * 类型值 + */ + private final Integer type; + /** + * 类型名 + */ + private final String name; + + @Override + public Integer[] array() { + return ARRAYS; + } + +} diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/cal/MesCalShiftTypeEnum.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/cal/MesCalShiftTypeEnum.java index 9679cc3..f801e10 100644 --- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/cal/MesCalShiftTypeEnum.java +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/cal/MesCalShiftTypeEnum.java @@ -1,10 +1,12 @@ package cn.iocoder.yudao.module.mes.enums.cal; +import cn.hutool.core.lang.Pair; import cn.iocoder.yudao.framework.common.core.ArrayValuable; import lombok.AllArgsConstructor; import lombok.Getter; import java.util.Arrays; +import java.util.List; /** * MES 轮班方式枚举 @@ -15,9 +17,18 @@ import java.util.Arrays; @AllArgsConstructor public enum MesCalShiftTypeEnum implements ArrayValuable { - SINGLE(1, "单白班"), - TWO(2, "两班倒"), - THREE(3, "三班倒"); + SINGLE(1, "单白班", List.of( + Pair.of("白班", new String[]{"08:00", "17:00"}) + )), + TWO(2, "两班倒", List.of( + Pair.of("白班", new String[]{"08:00", "20:00"}), + Pair.of("夜班", new String[]{"20:00", "08:00"}) + )), + THREE(3, "三班倒", List.of( + Pair.of("白班", new String[]{"08:00", "16:00"}), + Pair.of("中班", new String[]{"16:00", "00:00"}), + Pair.of("夜班", new String[]{"00:00", "08:00"}) + )); public static final Integer[] ARRAYS = Arrays.stream(values()).map(MesCalShiftTypeEnum::getType).toArray(Integer[]::new); @@ -29,6 +40,39 @@ public enum MesCalShiftTypeEnum implements ArrayValuable { * 类型名 */ private final String name; + /** + * 班次配置列表 + * + * key: 班次名称(如 "白班", "夜班", "中班") + * value: [startTime, endTime](如 ["08:00", "17:00"]) + */ + private final List> shifts; + + /** + * 获取班次数量上限 + */ + public int getShiftCount() { + return shifts.size(); + } + + /** + * 获取所需的最少班组数量 + */ + public int getRequiredTeamCount() { + return shifts.size(); + } + + /** + * 根据类型值获取枚举 + */ + public static MesCalShiftTypeEnum valueOf(Integer type) { + for (MesCalShiftTypeEnum value : values()) { + if (value.getType().equals(type)) { + return value; + } + } + throw new IllegalArgumentException("不支持的轮班方式: " + type); + } @Override public Integer[] array() { diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalPlanServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalPlanServiceImpl.java index cd81180..5ce96b9 100644 --- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalPlanServiceImpl.java +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalPlanServiceImpl.java @@ -8,6 +8,7 @@ import cn.iocoder.yudao.module.mes.dal.dataobject.cal.MesCalPlanDO; import cn.iocoder.yudao.module.mes.dal.mysql.cal.plan.MesCalPlanMapper; import cn.iocoder.yudao.module.mes.enums.cal.MesCalPlanStatusEnum; import cn.iocoder.yudao.module.mes.enums.cal.MesCalShiftTypeEnum; +import cn.hutool.core.util.ObjUtil; import jakarta.annotation.Resource; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; @@ -30,7 +31,7 @@ public class MesCalPlanServiceImpl implements MesCalPlanService { private MesCalPlanMapper planMapper; @Resource @Lazy - private MesCalShiftService shiftService; + private MesCalPlanShiftService planShiftService; @Resource @Lazy private MesCalPlanTeamService planTeamService; @@ -48,7 +49,7 @@ public class MesCalPlanServiceImpl implements MesCalPlanService { // 3. 自动生成默认班次 if (plan.getShiftType() != null) { - shiftService.addDefaultShift(plan.getId(), plan.getShiftType()); + planShiftService.addDefaultPlanShift(plan.getId(), plan.getShiftType()); } return plan.getId(); } @@ -56,6 +57,7 @@ public class MesCalPlanServiceImpl implements MesCalPlanService { @Override @Transactional(rollbackFor = Exception.class) public void updatePlan(MesCalPlanSaveReqVO updateReqVO) { + // TODO @AI:需要校验下,plan 未确定;(确认后,不允许编辑) // 1.1 校验存在 MesCalPlanDO existPlan = validatePlanExists(updateReqVO.getId()); // 1.2 校验编码唯一 @@ -79,13 +81,13 @@ public class MesCalPlanServiceImpl implements MesCalPlanService { // 1.1 校验存在 MesCalPlanDO plan = validatePlanExists(id); // 1.2 校验状态为草稿 - // TODO @AI:notEquals 更好一点; - if (!MesCalPlanStatusEnum.PREPARE.getStatus().equals(plan.getStatus())) { + // TODO @AI:需要校验下,plan 未确定;(确认后,不允许编辑)【最好抽成一个方法,各个地方可以调用】 + if (ObjUtil.notEqual(MesCalPlanStatusEnum.PREPARE.getStatus(), plan.getStatus())) { throw exception(CAL_PLAN_NOT_PREPARE); } // 2.1 级联删除班次 + 班组关联 - shiftService.deleteShiftByPlanId(id); + planShiftService.deletePlanShiftByPlanId(id); planTeamService.deleteByPlanId(id); // 2.2 删除计划 planMapper.deleteById(id); @@ -124,13 +126,10 @@ public class MesCalPlanServiceImpl implements MesCalPlanService { */ private void validateTeamCountForConfirm(Long planId, Integer shiftType) { Long teamCount = planTeamService.getPlanTeamCountByPlanId(planId); - // TODO @AI:startTime、endTime 可以放到枚举类里么?List;这样就可以判断数量; - if (MesCalShiftTypeEnum.TWO.getType().equals(shiftType) && teamCount < 2) { - throw exception(CAL_PLAN_TEAM_COUNT_NOT_MATCH); - } else if (MesCalShiftTypeEnum.THREE.getType().equals(shiftType) && teamCount < 3) { + MesCalShiftTypeEnum shiftTypeEnum = MesCalShiftTypeEnum.valueOf(shiftType); + if (teamCount < shiftTypeEnum.getRequiredTeamCount()) { throw exception(CAL_PLAN_TEAM_COUNT_NOT_MATCH); } - // TODO @AI:兜底下,其它,则抛出异常参数 IllegalArgumentException,提示不支持的轮班方式; } } diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalPlanShiftService.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalPlanShiftService.java new file mode 100644 index 0000000..c014a48 --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalPlanShiftService.java @@ -0,0 +1,87 @@ +package cn.iocoder.yudao.module.mes.service.cal.plan; + +import cn.iocoder.yudao.framework.common.pojo.PageResult; +import cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.shift.MesCalPlanShiftPageReqVO; +import cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.shift.MesCalPlanShiftSaveReqVO; +import cn.iocoder.yudao.module.mes.dal.dataobject.cal.MesCalPlanShiftDO; +import jakarta.validation.Valid; + +import java.util.List; + +/** + * MES 计划班次 Service 接口 + * + * @author 芋道源码 + */ +public interface MesCalPlanShiftService { + + /** + * 创建计划班次 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createPlanShift(@Valid MesCalPlanShiftSaveReqVO createReqVO); + + /** + * 更新计划班次 + * + * @param updateReqVO 更新信息 + */ + void updatePlanShift(@Valid MesCalPlanShiftSaveReqVO updateReqVO); + + /** + * 删除计划班次 + * + * @param id 编号 + */ + void deletePlanShift(Long id); + + /** + * 获得计划班次 + * + * @param id 编号 + * @return 计划班次 + */ + MesCalPlanShiftDO getPlanShift(Long id); + + /** + * 获得计划班次分页 + * + * @param pageReqVO 分页查询 + * @return 计划班次分页 + */ + PageResult getPlanShiftPage(MesCalPlanShiftPageReqVO pageReqVO); + + /** + * 获得指定排班计划的班次列表 + * + * @param planId 排班计划编号 + * @return 班次列表 + */ + List getPlanShiftListByPlanId(Long planId); + + /** + * 获得指定排班计划的班次数量 + * + * @param planId 排班计划编号 + * @return 班次数量 + */ + Long getPlanShiftCountByPlanId(Long planId); + + /** + * 根据轮班方式添加默认班次 + * + * @param planId 排班计划编号 + * @param shiftType 轮班方式 + */ + void addDefaultPlanShift(Long planId, Integer shiftType); + + /** + * 根据排班计划编号删除所有班次 + * + * @param planId 排班计划编号 + */ + void deletePlanShiftByPlanId(Long planId); + +} diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalPlanShiftServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalPlanShiftServiceImpl.java new file mode 100644 index 0000000..a189026 --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalPlanShiftServiceImpl.java @@ -0,0 +1,130 @@ +package cn.iocoder.yudao.module.mes.service.cal.plan; + +import cn.hutool.core.lang.Pair; +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.cal.plan.vo.shift.MesCalPlanShiftPageReqVO; +import cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.shift.MesCalPlanShiftSaveReqVO; +import cn.iocoder.yudao.module.mes.dal.dataobject.cal.MesCalPlanDO; +import cn.iocoder.yudao.module.mes.dal.dataobject.cal.MesCalPlanShiftDO; +import cn.iocoder.yudao.module.mes.dal.mysql.cal.plan.MesCalPlanMapper; +import cn.iocoder.yudao.module.mes.dal.mysql.cal.plan.MesCalPlanShiftMapper; +import cn.iocoder.yudao.module.mes.enums.cal.MesCalShiftTypeEnum; +import jakarta.annotation.Resource; +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 MesCalPlanShiftServiceImpl implements MesCalPlanShiftService { + + @Resource + private MesCalPlanShiftMapper planShiftMapper; + @Resource + private MesCalPlanMapper planMapper; + + @Override + public Long createPlanShift(MesCalPlanShiftSaveReqVO createReqVO) { + // TODO @AI:需要校验下,plan 未确定;(确认后,不允许编辑) + // 校验班次数量限制 + validatePlanShiftCount(createReqVO.getPlanId()); + + // 插入 + MesCalPlanShiftDO planShift = BeanUtils.toBean(createReqVO, MesCalPlanShiftDO.class); + planShiftMapper.insert(planShift); + return planShift.getId(); + } + + @Override + public void updatePlanShift(MesCalPlanShiftSaveReqVO updateReqVO) { + // TODO @AI:需要校验下,plan 未确定;(确认后,不允许编辑) + // 校验存在 + validatePlanShiftExists(updateReqVO.getId()); + // 更新 + MesCalPlanShiftDO updateObj = BeanUtils.toBean(updateReqVO, MesCalPlanShiftDO.class); + planShiftMapper.updateById(updateObj); + } + + @Override + public void deletePlanShift(Long id) { + // TODO @AI:需要校验下,plan 未确定;(确认后,不允许编辑) + // 校验存在 + validatePlanShiftExists(id); + // 删除 + planShiftMapper.deleteById(id); + } + + private void validatePlanShiftExists(Long id) { + if (planShiftMapper.selectById(id) == null) { + throw exception(CAL_PLAN_SHIFT_NOT_EXISTS); + } + } + + /** + * 校验班次数量是否超限 + *

+ * 通过 planId 查询已有班次数量,根据排班计划的轮班方式校验 + */ + private void validatePlanShiftCount(Long planId) { + MesCalPlanDO plan = planMapper.selectById(planId); + if (plan == null) { + return; + } + Long count = planShiftMapper.selectCountByPlanId(planId); + MesCalShiftTypeEnum shiftTypeEnum = MesCalShiftTypeEnum.valueOf(plan.getShiftType()); + if (count >= shiftTypeEnum.getShiftCount()) { + throw exception(CAL_PLAN_SHIFT_COUNT_EXCEED); + } + } + + @Override + public MesCalPlanShiftDO getPlanShift(Long id) { + return planShiftMapper.selectById(id); + } + + @Override + public PageResult getPlanShiftPage(MesCalPlanShiftPageReqVO pageReqVO) { + return planShiftMapper.selectPage(pageReqVO); + } + + @Override + public List getPlanShiftListByPlanId(Long planId) { + return planShiftMapper.selectListByPlanId(planId); + } + + @Override + public Long getPlanShiftCountByPlanId(Long planId) { + return planShiftMapper.selectCountByPlanId(planId); + } + + @Override + public void addDefaultPlanShift(Long planId, Integer shiftType) { + // 根据轮班方式,通过枚举配置生成默认班次 + MesCalShiftTypeEnum shiftTypeEnum = MesCalShiftTypeEnum.valueOf(shiftType); + List> shifts = shiftTypeEnum.getShifts(); + for (int i = 0; i < shifts.size(); i++) { + Pair shift = shifts.get(i); + MesCalPlanShiftDO planShiftDO = MesCalPlanShiftDO.builder() + .planId(planId).sort(i + 1).name(shift.getKey()) + .startTime(shift.getValue()[0]).endTime(shift.getValue()[1]) + .build(); + planShiftMapper.insert(planShiftDO); + } + } + + @Override + public void deletePlanShiftByPlanId(Long planId) { + planShiftMapper.deleteByPlanId(planId); + } + +} diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalPlanTeamServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalPlanTeamServiceImpl.java index 3a20842..e7f66f1 100644 --- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalPlanTeamServiceImpl.java +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalPlanTeamServiceImpl.java @@ -27,6 +27,7 @@ public class MesCalPlanTeamServiceImpl implements MesCalPlanTeamService { @Override public Long createPlanTeam(MesCalPlanTeamSaveReqVO createReqVO) { + // TODO @AI:需要校验下,plan 未确定;(确认后,不允许编辑) // 校验排班计划存在 validatePlanTeamDuplicate(createReqVO.getPlanId(), createReqVO.getTeamId()); @@ -38,6 +39,7 @@ public class MesCalPlanTeamServiceImpl implements MesCalPlanTeamService { @Override public void deletePlanTeam(Long id) { + // TODO @AI:需要校验下,plan 未确定;(确认后,不允许编辑) // 校验存在 validatePlanTeamExists(id); // 删除 diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalShiftService.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalShiftService.java deleted file mode 100644 index 046220e..0000000 --- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalShiftService.java +++ /dev/null @@ -1,87 +0,0 @@ -package cn.iocoder.yudao.module.mes.service.cal.plan; - -import cn.iocoder.yudao.framework.common.pojo.PageResult; -import cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.shift.MesCalShiftPageReqVO; -import cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.shift.MesCalShiftSaveReqVO; -import cn.iocoder.yudao.module.mes.dal.dataobject.cal.MesCalShiftDO; -import jakarta.validation.Valid; - -import java.util.List; - -/** - * MES 计划班次 Service 接口 - * - * @author 芋道源码 - */ -public interface MesCalShiftService { - - /** - * 创建计划班次 - * - * @param createReqVO 创建信息 - * @return 编号 - */ - Long createShift(@Valid MesCalShiftSaveReqVO createReqVO); - - /** - * 更新计划班次 - * - * @param updateReqVO 更新信息 - */ - void updateShift(@Valid MesCalShiftSaveReqVO updateReqVO); - - /** - * 删除计划班次 - * - * @param id 编号 - */ - void deleteShift(Long id); - - /** - * 获得计划班次 - * - * @param id 编号 - * @return 计划班次 - */ - MesCalShiftDO getShift(Long id); - - /** - * 获得计划班次分页 - * - * @param pageReqVO 分页查询 - * @return 计划班次分页 - */ - PageResult getShiftPage(MesCalShiftPageReqVO pageReqVO); - - /** - * 获得指定排班计划的班次列表 - * - * @param planId 排班计划编号 - * @return 班次列表 - */ - List getShiftListByPlanId(Long planId); - - /** - * 获得指定排班计划的班次数量 - * - * @param planId 排班计划编号 - * @return 班次数量 - */ - Long getShiftCountByPlanId(Long planId); - - /** - * 根据轮班方式添加默认班次 - * - * @param planId 排班计划编号 - * @param shiftType 轮班方式 - */ - void addDefaultShift(Long planId, Integer shiftType); - - /** - * 根据排班计划编号删除所有班次 - * - * @param planId 排班计划编号 - */ - void deleteShiftByPlanId(Long planId); - -} diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalShiftServiceImpl.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalShiftServiceImpl.java deleted file mode 100644 index 1135282..0000000 --- a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalShiftServiceImpl.java +++ /dev/null @@ -1,147 +0,0 @@ -package cn.iocoder.yudao.module.mes.service.cal.plan; - -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.cal.plan.vo.shift.MesCalShiftPageReqVO; -import cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.shift.MesCalShiftSaveReqVO; -import cn.iocoder.yudao.module.mes.dal.dataobject.cal.MesCalPlanDO; -import cn.iocoder.yudao.module.mes.dal.dataobject.cal.MesCalShiftDO; -import cn.iocoder.yudao.module.mes.dal.mysql.cal.plan.MesCalPlanMapper; -import cn.iocoder.yudao.module.mes.dal.mysql.cal.plan.MesCalShiftMapper; -import cn.iocoder.yudao.module.mes.enums.cal.CalConstants; -import cn.iocoder.yudao.module.mes.enums.cal.MesCalShiftTypeEnum; -import jakarta.annotation.Resource; -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 MesCalShiftServiceImpl implements MesCalShiftService { - - @Resource - private MesCalShiftMapper shiftMapper; - @Resource - private MesCalPlanMapper planMapper; - - @Override - public Long createShift(MesCalShiftSaveReqVO createReqVO) { - // 校验班次数量限制 - validateShiftCount(createReqVO.getPlanId()); - - // 插入 - MesCalShiftDO shift = BeanUtils.toBean(createReqVO, MesCalShiftDO.class); - shiftMapper.insert(shift); - return shift.getId(); - } - - @Override - public void updateShift(MesCalShiftSaveReqVO updateReqVO) { - // 校验存在 - validateShiftExists(updateReqVO.getId()); - // 更新 - MesCalShiftDO updateObj = BeanUtils.toBean(updateReqVO, MesCalShiftDO.class); - shiftMapper.updateById(updateObj); - } - - @Override - public void deleteShift(Long id) { - // 校验存在 - validateShiftExists(id); - // 删除 - shiftMapper.deleteById(id); - } - - private void validateShiftExists(Long id) { - if (shiftMapper.selectById(id) == null) { - throw exception(CAL_SHIFT_NOT_EXISTS); - } - } - - /** - * 校验班次数量是否超限 - *

- * 通过 planId 查询已有班次数量,根据排班计划的轮班方式校验 - */ - private void validateShiftCount(Long planId) { - MesCalPlanDO plan = planMapper.selectById(planId); - if (plan == null) { - return; - } - Long count = shiftMapper.selectCountByPlanId(planId); - Integer shiftType = plan.getShiftType(); - // TODO @AI:startTime、endTime 可以放到枚举类里么?List;这样可以 count 来判断。更简洁; - if (MesCalShiftTypeEnum.SINGLE.getType().equals(shiftType) && count >= 1) { - throw exception(CAL_SHIFT_COUNT_EXCEED_SINGLE); - } else if (MesCalShiftTypeEnum.TWO.getType().equals(shiftType) && count >= 2) { - throw exception(CAL_SHIFT_COUNT_EXCEED_TWO); - } else if (MesCalShiftTypeEnum.THREE.getType().equals(shiftType) && count >= 3) { - throw exception(CAL_SHIFT_COUNT_EXCEED_THREE); - } - } - - @Override - public MesCalShiftDO getShift(Long id) { - return shiftMapper.selectById(id); - } - - @Override - public PageResult getShiftPage(MesCalShiftPageReqVO pageReqVO) { - return shiftMapper.selectPage(pageReqVO); - } - - @Override - public List getShiftListByPlanId(Long planId) { - return shiftMapper.selectListByPlanId(planId); - } - - @Override - public Long getShiftCountByPlanId(Long planId) { - return shiftMapper.selectCountByPlanId(planId); - } - - @Override - public void addDefaultShift(Long planId, Integer shiftType) { - // 根据轮班方式,添加默认班次 - // TODO @AI:startTime、endTime 可以放到枚举类里么?List;这样就可以 for 循环; - if (MesCalShiftTypeEnum.SINGLE.getType().equals(shiftType)) { - // 单白班:1 个班次 - insertShift(planId, 1, CalConstants.SHIFT_NAME_DAY, "08:00", "17:00"); - } else if (MesCalShiftTypeEnum.TWO.getType().equals(shiftType)) { - // 两班倒:2 个班次 - insertShift(planId, 1, CalConstants.SHIFT_NAME_DAY, "08:00", "20:00"); - insertShift(planId, 2, CalConstants.SHIFT_NAME_NIGHT, "20:00", "08:00"); - } else if (MesCalShiftTypeEnum.THREE.getType().equals(shiftType)) { - // 三班倒:3 个班次 - insertShift(planId, 1, CalConstants.SHIFT_NAME_DAY, "08:00", "16:00"); - insertShift(planId, 2, CalConstants.SHIFT_NAME_MID, "16:00", "00:00"); - insertShift(planId, 3, CalConstants.SHIFT_NAME_NIGHT, "00:00", "08:00"); - } - } - - private void insertShift(Long planId, Integer sort, String name, String startTime, String endTime) { - // TODO @AI:链式 set,想通放在一样; - MesCalShiftDO shift = new MesCalShiftDO(); - shift.setPlanId(planId); - shift.setSort(sort); - shift.setName(name); - shift.setStartTime(startTime); - shift.setEndTime(endTime); - shiftMapper.insert(shift); - } - - @Override - public void deleteShiftByPlanId(Long planId) { - shiftMapper.deleteByPlanId(planId); - } - -} -- libgit2 0.21.4