From 215f58813401103cdf6a6bfa0c27e68815fa8e8b Mon Sep 17 00:00:00 2001 From: YunaiV Date: Tue, 17 Feb 2026 09:52:34 +0800 Subject: [PATCH] feat(mes-cal): 新增排班计划(cal_plan)、计划班次(cal_shift)、计划班组(cal_plan_team)模块 --- yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/MesCalPlanController.java | 93 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/MesCalPlanTeamController.java | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 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/MesCalPlanPageReqVO.java | 27 +++++++++++++++++++++++++++ yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/MesCalPlanRespVO.java | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/MesCalPlanSaveReqVO.java | 63 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 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/controller/admin/cal/plan/vo/team/MesCalPlanTeamRespVO.java | 47 +++++++++++++++++++++++++++++++++++++++++++++++ yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/team/MesCalPlanTeamSaveReqVO.java | 37 +++++++++++++++++++++++++++++++++++++ yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/cal/MesCalPlanDO.java | 100 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/cal/MesCalPlanTeamDO.java | 62 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 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/enums/cal/CalConstants.java | 18 ++++++++++++++++++ yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalPlanService.java | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalPlanServiceImpl.java | 136 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalPlanTeamService.java | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalPlanTeamServiceImpl.java | 75 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 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 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 21 files changed, 1437 insertions(+), 0 deletions(-) create mode 100644 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/MesCalPlanController.java create mode 100644 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/MesCalPlanTeamController.java create 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/MesCalPlanPageReqVO.java create mode 100644 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/MesCalPlanRespVO.java create mode 100644 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/MesCalPlanSaveReqVO.java create mode 100644 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/shift/MesCalShiftPageReqVO.java create mode 100644 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/shift/MesCalShiftRespVO.java create 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/controller/admin/cal/plan/vo/team/MesCalPlanTeamRespVO.java create mode 100644 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/team/MesCalPlanTeamSaveReqVO.java create mode 100644 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/cal/MesCalPlanDO.java create mode 100644 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/cal/MesCalPlanTeamDO.java create 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/enums/cal/CalConstants.java create mode 100644 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalPlanService.java create mode 100644 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalPlanServiceImpl.java create mode 100644 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalPlanTeamService.java create mode 100644 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalPlanTeamServiceImpl.java create mode 100644 yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalShiftService.java create 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/MesCalPlanController.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/MesCalPlanController.java new file mode 100644 index 0000000..5081f6c --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/MesCalPlanController.java @@ -0,0 +1,93 @@ +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.MesCalPlanPageReqVO; +import cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.MesCalPlanRespVO; +import cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.MesCalPlanSaveReqVO; +import cn.iocoder.yudao.module.mes.dal.dataobject.cal.MesCalPlanDO; +import cn.iocoder.yudao.module.mes.service.cal.plan.MesCalPlanService; +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") +@Validated +public class MesCalPlanController { + + @Resource + private MesCalPlanService planService; + + @PostMapping("/create") + @Operation(summary = "创建排班计划") + @PreAuthorize("@ss.hasPermission('mes:cal-plan:create')") + public CommonResult createPlan(@Valid @RequestBody MesCalPlanSaveReqVO createReqVO) { + return success(planService.createPlan(createReqVO)); + } + + @PutMapping("/update") + @Operation(summary = "更新排班计划") + @PreAuthorize("@ss.hasPermission('mes:cal-plan:update')") + public CommonResult updatePlan(@Valid @RequestBody MesCalPlanSaveReqVO updateReqVO) { + planService.updatePlan(updateReqVO); + return success(true); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除排班计划") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('mes:cal-plan:delete')") + public CommonResult deletePlan(@RequestParam("id") Long id) { + planService.deletePlan(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 getPlan(@RequestParam("id") Long id) { + MesCalPlanDO plan = planService.getPlan(id); + return success(BeanUtils.toBean(plan, MesCalPlanRespVO.class)); + } + + @GetMapping("/page") + @Operation(summary = "获得排班计划分页") + @PreAuthorize("@ss.hasPermission('mes:cal-plan:query')") + public CommonResult> getPlanPage(@Valid MesCalPlanPageReqVO pageReqVO) { + PageResult pageResult = planService.getPlanPage(pageReqVO); + return success(BeanUtils.toBean(pageResult, MesCalPlanRespVO.class)); + } + + @GetMapping("/export-excel") + @Operation(summary = "导出排班计划 Excel") + @PreAuthorize("@ss.hasPermission('mes:cal-plan:export')") + @ApiAccessLog(operateType = EXPORT) + public void exportPlanExcel(@Valid MesCalPlanPageReqVO pageReqVO, + HttpServletResponse response) throws IOException { + pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); + List list = planService.getPlanPage(pageReqVO).getList(); + // 导出 Excel + ExcelUtils.write(response, "排班计划.xls", "数据", MesCalPlanRespVO.class, + BeanUtils.toBean(list, MesCalPlanRespVO.class)); + } + +} diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/MesCalPlanTeamController.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/MesCalPlanTeamController.java new file mode 100644 index 0000000..5544ac6 --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/MesCalPlanTeamController.java @@ -0,0 +1,57 @@ +package cn.iocoder.yudao.module.mes.controller.admin.cal.plan; + +import cn.iocoder.yudao.framework.common.pojo.CommonResult; +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.team.MesCalPlanTeamRespVO; +import cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.team.MesCalPlanTeamSaveReqVO; +import cn.iocoder.yudao.module.mes.dal.dataobject.cal.MesCalPlanTeamDO; +import cn.iocoder.yudao.module.mes.service.cal.plan.MesCalPlanTeamService; +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 static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; + +@Tag(name = "管理后台 - MES 计划班组关联") +@RestController +@RequestMapping("/mes/cal/plan-team") +@Validated +public class MesCalPlanTeamController { + + @Resource + private MesCalPlanTeamService planTeamService; + + @PostMapping("/create") + @Operation(summary = "创建计划班组关联") + @PreAuthorize("@ss.hasPermission('mes:cal-plan:update')") + public CommonResult createPlanTeam(@Valid @RequestBody MesCalPlanTeamSaveReqVO createReqVO) { + return success(planTeamService.createPlanTeam(createReqVO)); + } + + @DeleteMapping("/delete") + @Operation(summary = "删除计划班组关联") + @Parameter(name = "id", description = "编号", required = true) + @PreAuthorize("@ss.hasPermission('mes:cal-plan:update')") + public CommonResult deletePlanTeam(@RequestParam("id") Long id) { + planTeamService.deletePlanTeam(id); + return success(true); + } + + @GetMapping("/list-by-plan") + @Operation(summary = "获得指定排班计划的班组列表") + @Parameter(name = "planId", description = "排班计划编号", required = true) + @PreAuthorize("@ss.hasPermission('mes:cal-plan:query')") + public CommonResult> getPlanTeamListByPlan(@RequestParam("planId") Long planId) { + List list = planTeamService.getPlanTeamListByPlanId(planId); + // TODO @芋艿:拼装班组编码/名称,等 cal_team 迁移后对接 + return success(BeanUtils.toBean(list, MesCalPlanTeamRespVO.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 new file mode 100644 index 0000000..f17660e --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/MesCalShiftController.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.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/MesCalPlanPageReqVO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/MesCalPlanPageReqVO.java new file mode 100644 index 0000000..d387f35 --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/MesCalPlanPageReqVO.java @@ -0,0 +1,27 @@ +package cn.iocoder.yudao.module.mes.controller.admin.cal.plan.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; + +@Schema(description = "管理后台 - MES 排班计划分页 Request VO") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +public class MesCalPlanPageReqVO extends PageParam { + + @Schema(description = "计划编码", example = "PLAN001") + private String code; + + @Schema(description = "计划名称", example = "2024年排班") + private String name; + + @Schema(description = "轮班方式", example = "1") + private Integer shiftType; + + @Schema(description = "状态", example = "0") + private Integer status; + +} diff --git a/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/MesCalPlanRespVO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/MesCalPlanRespVO.java new file mode 100644 index 0000000..00ca9e4 --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/MesCalPlanRespVO.java @@ -0,0 +1,75 @@ +package cn.iocoder.yudao.module.mes.controller.admin.cal.plan.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 MesCalPlanRespVO { + + @Schema(description = "计划编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024") + @ExcelProperty("计划编号") + private Long id; + + @Schema(description = "计划编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "PLAN001") + @ExcelProperty("计划编码") + private String code; + + @Schema(description = "计划名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "2024年排班计划") + @ExcelProperty("计划名称") + private String name; + + @Schema(description = "班组类型", example = "1") + @ExcelProperty("班组类型") + private Integer calendarType; + + @Schema(description = "开始日期", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("开始日期") + private LocalDateTime startDate; + + @Schema(description = "结束日期", requiredMode = Schema.RequiredMode.REQUIRED) + @ExcelProperty("结束日期") + private LocalDateTime endDate; + + @Schema(description = "轮班方式", example = "1") + @ExcelProperty("轮班方式") + private Integer shiftType; + + @Schema(description = "倒班方式", example = "1") + @ExcelProperty("倒班方式") + private Integer shiftMethod; + + @Schema(description = "倒班天数", example = "7") + @ExcelProperty("倒班天数") + private Integer shiftCount; + + @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/cal/plan/vo/MesCalPlanSaveReqVO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/MesCalPlanSaveReqVO.java new file mode 100644 index 0000000..e320bdf --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/MesCalPlanSaveReqVO.java @@ -0,0 +1,63 @@ +package cn.iocoder.yudao.module.mes.controller.admin.cal.plan.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 MesCalPlanSaveReqVO { + + @Schema(description = "计划编号", example = "1024") + private Long id; + + @Schema(description = "计划编码", requiredMode = Schema.RequiredMode.REQUIRED, example = "PLAN001") + @NotEmpty(message = "计划编码不能为空") + private String code; + + @Schema(description = "计划名称", requiredMode = Schema.RequiredMode.REQUIRED, example = "2024年排班计划") + @NotEmpty(message = "计划名称不能为空") + private String name; + + @Schema(description = "班组类型", example = "1") + private Integer calendarType; + + @Schema(description = "开始日期", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "开始日期不能为空") + private LocalDateTime startDate; + + @Schema(description = "结束日期", requiredMode = Schema.RequiredMode.REQUIRED) + @NotNull(message = "结束日期不能为空") + private LocalDateTime endDate; + + @Schema(description = "轮班方式", example = "1") + private Integer shiftType; + + @Schema(description = "倒班方式", example = "1") + private Integer shiftMethod; + + @Schema(description = "倒班天数", example = "7") + private Integer shiftCount; + + @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/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 new file mode 100644 index 0000000..d37a934 --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/shift/MesCalShiftPageReqVO.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 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 new file mode 100644 index 0000000..d8abf28 --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/shift/MesCalShiftRespVO.java @@ -0,0 +1,59 @@ +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 new file mode 100644 index 0000000..1ed9abb --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/shift/MesCalShiftSaveReqVO.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 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/controller/admin/cal/plan/vo/team/MesCalPlanTeamRespVO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/team/MesCalPlanTeamRespVO.java new file mode 100644 index 0000000..789daff --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/team/MesCalPlanTeamRespVO.java @@ -0,0 +1,47 @@ +package cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.team; + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +import java.time.LocalDateTime; + +@Schema(description = "管理后台 - MES 计划班组关联 Response VO") +@Data +public class MesCalPlanTeamRespVO { + + @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 teamId; + + // TODO @芋艿:等 cal_team 迁移后,通过 teamId 关联查询填充 + @Schema(description = "班组编码", example = "T001") + private String teamCode; + + // TODO @芋艿:等 cal_team 迁移后,通过 teamId 关联查询填充 + @Schema(description = "班组名称", example = "A组") + private String teamName; + + @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/cal/plan/vo/team/MesCalPlanTeamSaveReqVO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/team/MesCalPlanTeamSaveReqVO.java new file mode 100644 index 0000000..d29de0b --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/team/MesCalPlanTeamSaveReqVO.java @@ -0,0 +1,37 @@ +package cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.team; + +import io.swagger.v3.oas.annotations.media.Schema; +import jakarta.validation.constraints.NotNull; +import lombok.Data; + +@Schema(description = "管理后台 - MES 计划班组关联新增 Request VO") +@Data +public class MesCalPlanTeamSaveReqVO { + + @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 teamId; + + @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 new file mode 100644 index 0000000..fb0c2f6 --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/cal/MesCalPlanDO.java @@ -0,0 +1,100 @@ +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.MesCalPlanStatusEnum; +import cn.iocoder.yudao.module.mes.enums.cal.MesCalShiftMethodEnum; +import cn.iocoder.yudao.module.mes.enums.cal.MesCalShiftTypeEnum; +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_cal_plan") +@KeySequence("mes_cal_plan_seq") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class MesCalPlanDO extends BaseDO { + + /** + * 计划编号 + */ + @TableId + private Long id; + /** + * 计划编码 + */ + private String code; + /** + * 计划名称 + */ + private String name; + // TODO @AI:增加一个枚举值(类),好一点; + /** + * 班组类型 + * + * 枚举 mes_cal_calendar_type(1=分组轮班, 2=固定班组) + */ + private Integer calendarType; + /** + * 开始日期 + */ + private LocalDateTime startDate; + /** + * 结束日期 + */ + private LocalDateTime endDate; + /** + * 轮班方式 + * + * 枚举 {@link MesCalShiftTypeEnum} + */ + private Integer shiftType; + /** + * 倒班方式 + * + * 枚举 {@link MesCalShiftMethodEnum} + */ + private Integer shiftMethod; + /** + * 倒班天数 + */ + private Integer shiftCount; + /** + * 状态 + * + * 枚举 {@link MesCalPlanStatusEnum} + */ + 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/cal/MesCalPlanTeamDO.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/cal/MesCalPlanTeamDO.java new file mode 100644 index 0000000..784724c --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/cal/MesCalPlanTeamDO.java @@ -0,0 +1,62 @@ +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_team") +@KeySequence("mes_cal_plan_team_seq") +@Data +@EqualsAndHashCode(callSuper = true) +@ToString(callSuper = true) +@Builder +@NoArgsConstructor +@AllArgsConstructor +public class MesCalPlanTeamDO extends BaseDO { + + /** + * 编号 + */ + @TableId + private Long id; + /** + * 排班计划编号 + * + * 关联 {@link MesCalPlanDO#getId()} + */ + private Long planId; + /** + * 班组编号 + * + * TODO @芋艿:关联 cal_team 表,等 cal_team 迁移后补充 + */ + private Long teamId; + /** + * 备注 + */ + 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 new file mode 100644 index 0000000..dc028df --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/cal/MesCalShiftDO.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_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/enums/cal/CalConstants.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/cal/CalConstants.java new file mode 100644 index 0000000..02cd03a --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/cal/CalConstants.java @@ -0,0 +1,18 @@ +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/service/cal/plan/MesCalPlanService.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalPlanService.java new file mode 100644 index 0000000..a0ff629 --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalPlanService.java @@ -0,0 +1,54 @@ +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.MesCalPlanPageReqVO; +import cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.MesCalPlanSaveReqVO; +import cn.iocoder.yudao.module.mes.dal.dataobject.cal.MesCalPlanDO; +import jakarta.validation.Valid; + +/** + * MES 排班计划 Service 接口 + * + * @author 芋道源码 + */ +public interface MesCalPlanService { + + /** + * 创建排班计划 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createPlan(@Valid MesCalPlanSaveReqVO createReqVO); + + /** + * 更新排班计划 + * + * @param updateReqVO 更新信息 + */ + void updatePlan(@Valid MesCalPlanSaveReqVO updateReqVO); + + /** + * 删除排班计划 + * + * @param id 编号 + */ + void deletePlan(Long id); + + /** + * 获得排班计划 + * + * @param id 编号 + * @return 排班计划 + */ + MesCalPlanDO getPlan(Long id); + + /** + * 获得排班计划分页 + * + * @param pageReqVO 分页查询 + * @return 排班计划分页 + */ + PageResult getPlanPage(MesCalPlanPageReqVO pageReqVO); + +} 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 new file mode 100644 index 0000000..cd81180 --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalPlanServiceImpl.java @@ -0,0 +1,136 @@ +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.MesCalPlanPageReqVO; +import cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.MesCalPlanSaveReqVO; +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 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 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 MesCalPlanServiceImpl implements MesCalPlanService { + + @Resource + private MesCalPlanMapper planMapper; + @Resource + @Lazy + private MesCalShiftService shiftService; + @Resource + @Lazy + private MesCalPlanTeamService planTeamService; + + @Override + @Transactional(rollbackFor = Exception.class) + public Long createPlan(MesCalPlanSaveReqVO createReqVO) { + // 1. 校验编码唯一 + validatePlanCodeUnique(null, createReqVO.getCode()); + + // 2. 插入计划 + MesCalPlanDO plan = BeanUtils.toBean(createReqVO, MesCalPlanDO.class); + plan.setStatus(MesCalPlanStatusEnum.PREPARE.getStatus()); // 默认草稿 + planMapper.insert(plan); + + // 3. 自动生成默认班次 + if (plan.getShiftType() != null) { + shiftService.addDefaultShift(plan.getId(), plan.getShiftType()); + } + return plan.getId(); + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void updatePlan(MesCalPlanSaveReqVO updateReqVO) { + // 1.1 校验存在 + MesCalPlanDO existPlan = validatePlanExists(updateReqVO.getId()); + // 1.2 校验编码唯一 + validatePlanCodeUnique(updateReqVO.getId(), updateReqVO.getCode()); + // 1.3 若 status 变为 CONFIRMED,校验班组数量 + if (MesCalPlanStatusEnum.CONFIRMED.getStatus().equals(updateReqVO.getStatus()) + && !MesCalPlanStatusEnum.CONFIRMED.getStatus().equals(existPlan.getStatus())) { + validateTeamCountForConfirm(updateReqVO.getId(), updateReqVO.getShiftType()); + } + + // 2. 更新 + MesCalPlanDO updateObj = BeanUtils.toBean(updateReqVO, MesCalPlanDO.class); + planMapper.updateById(updateObj); + + // TODO @芋艿:确认时调用 calTeamshiftService.genRecords(planId) 生成排班记录,等 cal_team_shift 迁移后 + } + + @Override + @Transactional(rollbackFor = Exception.class) + public void deletePlan(Long id) { + // 1.1 校验存在 + MesCalPlanDO plan = validatePlanExists(id); + // 1.2 校验状态为草稿 + // TODO @AI:notEquals 更好一点; + if (!MesCalPlanStatusEnum.PREPARE.getStatus().equals(plan.getStatus())) { + throw exception(CAL_PLAN_NOT_PREPARE); + } + + // 2.1 级联删除班次 + 班组关联 + shiftService.deleteShiftByPlanId(id); + planTeamService.deleteByPlanId(id); + // 2.2 删除计划 + planMapper.deleteById(id); + } + + @Override + public MesCalPlanDO getPlan(Long id) { + return planMapper.selectById(id); + } + + @Override + public PageResult getPlanPage(MesCalPlanPageReqVO pageReqVO) { + return planMapper.selectPage(pageReqVO); + } + + private MesCalPlanDO validatePlanExists(Long id) { + MesCalPlanDO plan = planMapper.selectById(id); + if (plan == null) { + throw exception(CAL_PLAN_NOT_EXISTS); + } + return plan; + } + + private void validatePlanCodeUnique(Long id, String code) { + MesCalPlanDO plan = planMapper.selectByCode(code); + if (plan == null) { + return; + } + if (id == null || !id.equals(plan.getId())) { + throw exception(CAL_PLAN_CODE_DUPLICATE); + } + } + + /** + * 确认排班计划时,校验班组数量是否与轮班方式匹配 + */ + 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) { + 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/MesCalPlanTeamService.java b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalPlanTeamService.java new file mode 100644 index 0000000..4d6cbf6 --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalPlanTeamService.java @@ -0,0 +1,54 @@ +package cn.iocoder.yudao.module.mes.service.cal.plan; + +import cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.team.MesCalPlanTeamSaveReqVO; +import cn.iocoder.yudao.module.mes.dal.dataobject.cal.MesCalPlanTeamDO; +import jakarta.validation.Valid; + +import java.util.List; + +/** + * MES 计划班组关联 Service 接口 + * + * @author 芋道源码 + */ +public interface MesCalPlanTeamService { + + /** + * 创建计划班组关联 + * + * @param createReqVO 创建信息 + * @return 编号 + */ + Long createPlanTeam(@Valid MesCalPlanTeamSaveReqVO createReqVO); + + /** + * 删除计划班组关联 + * + * @param id 编号 + */ + void deletePlanTeam(Long id); + + /** + * 获得指定排班计划的班组列表 + * + * @param planId 排班计划编号 + * @return 班组关联列表 + */ + List getPlanTeamListByPlanId(Long planId); + + /** + * 获得指定排班计划的班组数量 + * + * @param planId 排班计划编号 + * @return 班组数量 + */ + Long getPlanTeamCountByPlanId(Long planId); + + /** + * 根据排班计划编号删除所有班组关联 + * + * @param planId 排班计划编号 + */ + void deleteByPlanId(Long 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 new file mode 100644 index 0000000..3a20842 --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalPlanTeamServiceImpl.java @@ -0,0 +1,75 @@ +package cn.iocoder.yudao.module.mes.service.cal.plan; + +import cn.iocoder.yudao.framework.common.util.object.BeanUtils; +import cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.team.MesCalPlanTeamSaveReqVO; +import cn.iocoder.yudao.module.mes.dal.dataobject.cal.MesCalPlanTeamDO; +import cn.iocoder.yudao.module.mes.dal.mysql.cal.plan.MesCalPlanTeamMapper; +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 MesCalPlanTeamServiceImpl implements MesCalPlanTeamService { + + @Resource + private MesCalPlanTeamMapper planTeamMapper; + + @Override + public Long createPlanTeam(MesCalPlanTeamSaveReqVO createReqVO) { + // 校验排班计划存在 + validatePlanTeamDuplicate(createReqVO.getPlanId(), createReqVO.getTeamId()); + + // 插入 + MesCalPlanTeamDO planTeam = BeanUtils.toBean(createReqVO, MesCalPlanTeamDO.class); + planTeamMapper.insert(planTeam); + return planTeam.getId(); + } + + @Override + public void deletePlanTeam(Long id) { + // 校验存在 + validatePlanTeamExists(id); + // 删除 + planTeamMapper.deleteById(id); + } + + private void validatePlanTeamExists(Long id) { + if (planTeamMapper.selectById(id) == null) { + throw exception(CAL_PLAN_TEAM_NOT_EXISTS); + } + } + + private void validatePlanTeamDuplicate(Long planId, Long teamId) { + MesCalPlanTeamDO planTeam = planTeamMapper.selectByPlanIdAndTeamId(planId, teamId); + if (planTeam != null) { + throw exception(CAL_PLAN_TEAM_DUPLICATE); + } + } + + @Override + public List getPlanTeamListByPlanId(Long planId) { + return planTeamMapper.selectListByPlanId(planId); + } + + @Override + public Long getPlanTeamCountByPlanId(Long planId) { + return planTeamMapper.selectCountByPlanId(planId); + } + + @Override + public void deleteByPlanId(Long planId) { + planTeamMapper.deleteByPlanId(planId); + } + +} 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 new file mode 100644 index 0000000..046220e --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalShiftService.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.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 new file mode 100644 index 0000000..1135282 --- /dev/null +++ b/yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalShiftServiceImpl.java @@ -0,0 +1,147 @@ +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