Commit 15e6c5d308f56bb07e704f6bf9c8eb4b80a525c3

Authored by YunaiV
1 parent 36660229

feat(mes):优化、实现 plan 的逻辑

Showing 17 changed files with 307 additions and 255 deletions
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/MesCalShiftController.java renamed to yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/MesCalPlanShiftController.java
... ... @@ -6,11 +6,11 @@ import cn.iocoder.yudao.framework.common.pojo.PageParam;
6 6 import cn.iocoder.yudao.framework.common.pojo.PageResult;
7 7 import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
8 8 import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils;
9   -import cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.shift.MesCalShiftPageReqVO;
10   -import cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.shift.MesCalShiftRespVO;
11   -import cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.shift.MesCalShiftSaveReqVO;
12   -import cn.iocoder.yudao.module.mes.dal.dataobject.cal.MesCalShiftDO;
13   -import cn.iocoder.yudao.module.mes.service.cal.plan.MesCalShiftService;
  9 +import cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.shift.MesCalPlanShiftPageReqVO;
  10 +import cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.shift.MesCalPlanShiftRespVO;
  11 +import cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.shift.MesCalPlanShiftSaveReqVO;
  12 +import cn.iocoder.yudao.module.mes.dal.dataobject.cal.MesCalPlanShiftDO;
  13 +import cn.iocoder.yudao.module.mes.service.cal.plan.MesCalPlanShiftService;
14 14 import io.swagger.v3.oas.annotations.Operation;
15 15 import io.swagger.v3.oas.annotations.Parameter;
16 16 import io.swagger.v3.oas.annotations.tags.Tag;
... ... @@ -27,77 +27,77 @@ import java.util.List;
27 27 import static cn.iocoder.yudao.framework.apilog.core.enums.OperateTypeEnum.EXPORT;
28 28 import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success;
29 29  
30   -// TODO @AI:它是不是改成 MesCalPlanShiftController 更好?毕竟它是排班计划的班次,而不是单纯的班次
31 30 @Tag(name = "管理后台 - MES 计划班次")
32 31 @RestController
33   -@RequestMapping("/mes/cal/shift")
  32 +@RequestMapping("/mes/cal/plan-shift")
34 33 @Validated
35   -public class MesCalShiftController {
  34 +public class MesCalPlanShiftController {
36 35  
37 36 @Resource
38   - private MesCalShiftService shiftService;
  37 + private MesCalPlanShiftService planShiftService;
39 38  
40 39 @PostMapping("/create")
41 40 @Operation(summary = "创建计划班次")
42   - @PreAuthorize("@ss.hasPermission('mes:cal-shift:create')")
43   - public CommonResult<Long> createShift(@Valid @RequestBody MesCalShiftSaveReqVO createReqVO) {
44   - return success(shiftService.createShift(createReqVO));
  41 + @PreAuthorize("@ss.hasPermission('mes:cal-plan:update')")
  42 + public CommonResult<Long> createPlanShift(@Valid @RequestBody MesCalPlanShiftSaveReqVO createReqVO) {
  43 + return success(planShiftService.createPlanShift(createReqVO));
45 44 }
46 45  
47 46 @PutMapping("/update")
48 47 @Operation(summary = "更新计划班次")
49   - @PreAuthorize("@ss.hasPermission('mes:cal-shift:update')")
50   - public CommonResult<Boolean> updateShift(@Valid @RequestBody MesCalShiftSaveReqVO updateReqVO) {
51   - shiftService.updateShift(updateReqVO);
  48 + @PreAuthorize("@ss.hasPermission('mes:cal-plan:update')")
  49 + public CommonResult<Boolean> updatePlanShift(@Valid @RequestBody MesCalPlanShiftSaveReqVO updateReqVO) {
  50 + planShiftService.updatePlanShift(updateReqVO);
52 51 return success(true);
53 52 }
54 53  
55 54 @DeleteMapping("/delete")
56 55 @Operation(summary = "删除计划班次")
57 56 @Parameter(name = "id", description = "编号", required = true)
58   - @PreAuthorize("@ss.hasPermission('mes:cal-shift:delete')")
59   - public CommonResult<Boolean> deleteShift(@RequestParam("id") Long id) {
60   - shiftService.deleteShift(id);
  57 + @PreAuthorize("@ss.hasPermission('mes:cal-plan:update')")
  58 + public CommonResult<Boolean> deletePlanShift(@RequestParam("id") Long id) {
  59 + planShiftService.deletePlanShift(id);
61 60 return success(true);
62 61 }
63 62  
64 63 @GetMapping("/get")
65 64 @Operation(summary = "获得计划班次")
66 65 @Parameter(name = "id", description = "编号", required = true, example = "1024")
67   - @PreAuthorize("@ss.hasPermission('mes:cal-shift:query')")
68   - public CommonResult<MesCalShiftRespVO> getShift(@RequestParam("id") Long id) {
69   - MesCalShiftDO shift = shiftService.getShift(id);
70   - return success(BeanUtils.toBean(shift, MesCalShiftRespVO.class));
  66 + @PreAuthorize("@ss.hasPermission('mes:cal-plan:query')")
  67 + public CommonResult<MesCalPlanShiftRespVO> getPlanShift(@RequestParam("id") Long id) {
  68 + MesCalPlanShiftDO planShift = planShiftService.getPlanShift(id);
  69 + return success(BeanUtils.toBean(planShift, MesCalPlanShiftRespVO.class));
71 70 }
72 71  
73 72 @GetMapping("/page")
74 73 @Operation(summary = "获得计划班次分页")
75   - @PreAuthorize("@ss.hasPermission('mes:cal-shift:query')")
76   - public CommonResult<PageResult<MesCalShiftRespVO>> getShiftPage(@Valid MesCalShiftPageReqVO pageReqVO) {
77   - PageResult<MesCalShiftDO> pageResult = shiftService.getShiftPage(pageReqVO);
78   - return success(BeanUtils.toBean(pageResult, MesCalShiftRespVO.class));
  74 + @PreAuthorize("@ss.hasPermission('mes:cal-plan:query')")
  75 + public CommonResult<PageResult<MesCalPlanShiftRespVO>> getPlanShiftPage(@Valid MesCalPlanShiftPageReqVO pageReqVO) {
  76 + PageResult<MesCalPlanShiftDO> pageResult = planShiftService.getPlanShiftPage(pageReqVO);
  77 + return success(BeanUtils.toBean(pageResult, MesCalPlanShiftRespVO.class));
79 78 }
80 79  
81 80 @GetMapping("/list-by-plan")
82 81 @Operation(summary = "获得指定排班计划的班次列表")
83 82 @Parameter(name = "planId", description = "排班计划编号", required = true)
84   - @PreAuthorize("@ss.hasPermission('mes:cal-shift:query')")
85   - public CommonResult<List<MesCalShiftRespVO>> getShiftListByPlan(@RequestParam("planId") Long planId) {
86   - List<MesCalShiftDO> list = shiftService.getShiftListByPlanId(planId);
87   - return success(BeanUtils.toBean(list, MesCalShiftRespVO.class));
  83 + @PreAuthorize("@ss.hasPermission('mes:cal-plan:query')")
  84 + public CommonResult<List<MesCalPlanShiftRespVO>> getPlanShiftListByPlan(@RequestParam("planId") Long planId) {
  85 + List<MesCalPlanShiftDO> list = planShiftService.getPlanShiftListByPlanId(planId);
  86 + return success(BeanUtils.toBean(list, MesCalPlanShiftRespVO.class));
88 87 }
89 88  
  89 +// TODO @AI:是不是不要导出
90 90 @GetMapping("/export-excel")
91 91 @Operation(summary = "导出计划班次 Excel")
92   - @PreAuthorize("@ss.hasPermission('mes:cal-shift:export')")
  92 + @PreAuthorize("@ss.hasPermission('mes:cal-plan:export')")
93 93 @ApiAccessLog(operateType = EXPORT)
94   - public void exportShiftExcel(@Valid MesCalShiftPageReqVO pageReqVO,
95   - HttpServletResponse response) throws IOException {
  94 + public void exportPlanShiftExcel(@Valid MesCalPlanShiftPageReqVO pageReqVO,
  95 + HttpServletResponse response) throws IOException {
96 96 pageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE);
97   - List<MesCalShiftDO> list = shiftService.getShiftPage(pageReqVO).getList();
  97 + List<MesCalPlanShiftDO> list = planShiftService.getPlanShiftPage(pageReqVO).getList();
98 98 // 导出 Excel
99   - ExcelUtils.write(response, "计划班次.xls", "数据", MesCalShiftRespVO.class,
100   - BeanUtils.toBean(list, MesCalShiftRespVO.class));
  99 + ExcelUtils.write(response, "计划班次.xls", "数据", MesCalPlanShiftRespVO.class,
  100 + BeanUtils.toBean(list, MesCalPlanShiftRespVO.class));
101 101 }
102 102  
103 103 }
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/shift/MesCalShiftPageReqVO.java renamed to yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/shift/MesCalPlanShiftPageReqVO.java
... ... @@ -10,7 +10,7 @@ import lombok.ToString;
10 10 @Data
11 11 @EqualsAndHashCode(callSuper = true)
12 12 @ToString(callSuper = true)
13   -public class MesCalShiftPageReqVO extends PageParam {
  13 +public class MesCalPlanShiftPageReqVO extends PageParam {
14 14  
15 15 @Schema(description = "排班计划编号", example = "1")
16 16 private Long planId;
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/shift/MesCalShiftRespVO.java renamed to yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/shift/MesCalPlanShiftRespVO.java
... ... @@ -7,10 +7,11 @@ import lombok.Data;
7 7  
8 8 import java.time.LocalDateTime;
9 9  
  10 +// TODO @AI:是不是不要导出
10 11 @Schema(description = "管理后台 - MES 计划班次 Response VO")
11 12 @Data
12 13 @ExcelIgnoreUnannotated
13   -public class MesCalShiftRespVO {
  14 +public class MesCalPlanShiftRespVO {
14 15  
15 16 @Schema(description = "班次编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "1024")
16 17 @ExcelProperty("班次编号")
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/shift/MesCalShiftSaveReqVO.java renamed to yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/controller/admin/cal/plan/vo/shift/MesCalPlanShiftSaveReqVO.java
... ... @@ -7,7 +7,7 @@ import lombok.Data;
7 7  
8 8 @Schema(description = "管理后台 - MES 计划班次新增/修改 Request VO")
9 9 @Data
10   -public class MesCalShiftSaveReqVO {
  10 +public class MesCalPlanShiftSaveReqVO {
11 11  
12 12 @Schema(description = "班次编号", example = "1024")
13 13 private Long id;
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/cal/MesCalPlanDO.java
1 1 package cn.iocoder.yudao.module.mes.dal.dataobject.cal;
2 2  
3 3 import cn.iocoder.yudao.framework.mybatis.core.dataobject.BaseDO;
  4 +import cn.iocoder.yudao.module.mes.enums.cal.MesCalCalendarTypeEnum;
4 5 import cn.iocoder.yudao.module.mes.enums.cal.MesCalPlanStatusEnum;
5 6 import cn.iocoder.yudao.module.mes.enums.cal.MesCalShiftMethodEnum;
6 7 import cn.iocoder.yudao.module.mes.enums.cal.MesCalShiftTypeEnum;
... ... @@ -39,11 +40,10 @@ public class MesCalPlanDO extends BaseDO {
39 40 * 计划名称
40 41 */
41 42 private String name;
42   - // TODO @AI:增加一个枚举值(类),好一点;
43 43 /**
44 44 * 班组类型
45 45 *
46   - * 枚举 mes_cal_calendar_type(1=分组轮班, 2=固定班组)
  46 + * 枚举 {@link MesCalCalendarTypeEnum}
47 47 */
48 48 private Integer calendarType;
49 49 /**
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/cal/MesCalShiftDO.java renamed to yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/dataobject/cal/MesCalPlanShiftDO.java
... ... @@ -11,15 +11,15 @@ import lombok.*;
11 11 *
12 12 * @author 芋道源码
13 13 */
14   -@TableName("mes_cal_shift")
15   -@KeySequence("mes_cal_shift_seq")
  14 +@TableName("mes_cal_plan_shift")
  15 +@KeySequence("mes_cal_plan_shift_seq")
16 16 @Data
17 17 @EqualsAndHashCode(callSuper = true)
18 18 @ToString(callSuper = true)
19 19 @Builder
20 20 @NoArgsConstructor
21 21 @AllArgsConstructor
22   -public class MesCalShiftDO extends BaseDO {
  22 +public class MesCalPlanShiftDO extends BaseDO {
23 23  
24 24 /**
25 25 * 班次编号
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/cal/plan/MesCalShiftMapper.java renamed to yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/dal/mysql/cal/plan/MesCalPlanShiftMapper.java
... ... @@ -3,8 +3,8 @@ package cn.iocoder.yudao.module.mes.dal.mysql.cal.plan;
3 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4 4 import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
5 5 import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
6   -import cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.shift.MesCalShiftPageReqVO;
7   -import cn.iocoder.yudao.module.mes.dal.dataobject.cal.MesCalShiftDO;
  6 +import cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.shift.MesCalPlanShiftPageReqVO;
  7 +import cn.iocoder.yudao.module.mes.dal.dataobject.cal.MesCalPlanShiftDO;
8 8 import org.apache.ibatis.annotations.Mapper;
9 9  
10 10 import java.util.List;
... ... @@ -15,28 +15,28 @@ import java.util.List;
15 15 * @author 芋道源码
16 16 */
17 17 @Mapper
18   -public interface MesCalShiftMapper extends BaseMapperX<MesCalShiftDO> {
  18 +public interface MesCalPlanShiftMapper extends BaseMapperX<MesCalPlanShiftDO> {
19 19  
20   - default PageResult<MesCalShiftDO> selectPage(MesCalShiftPageReqVO reqVO) {
21   - return selectPage(reqVO, new LambdaQueryWrapperX<MesCalShiftDO>()
22   - .eqIfPresent(MesCalShiftDO::getPlanId, reqVO.getPlanId())
23   - .likeIfPresent(MesCalShiftDO::getName, reqVO.getName())
24   - .orderByAsc(MesCalShiftDO::getSort));
  20 + default PageResult<MesCalPlanShiftDO> selectPage(MesCalPlanShiftPageReqVO reqVO) {
  21 + return selectPage(reqVO, new LambdaQueryWrapperX<MesCalPlanShiftDO>()
  22 + .eqIfPresent(MesCalPlanShiftDO::getPlanId, reqVO.getPlanId())
  23 + .likeIfPresent(MesCalPlanShiftDO::getName, reqVO.getName())
  24 + .orderByAsc(MesCalPlanShiftDO::getSort));
25 25 }
26 26  
27   - default List<MesCalShiftDO> selectListByPlanId(Long planId) {
28   - return selectList(new LambdaQueryWrapperX<MesCalShiftDO>()
29   - .eq(MesCalShiftDO::getPlanId, planId)
30   - .orderByAsc(MesCalShiftDO::getSort));
  27 + default List<MesCalPlanShiftDO> selectListByPlanId(Long planId) {
  28 + return selectList(new LambdaQueryWrapperX<MesCalPlanShiftDO>()
  29 + .eq(MesCalPlanShiftDO::getPlanId, planId)
  30 + .orderByAsc(MesCalPlanShiftDO::getSort));
31 31 }
32 32  
33 33 default Long selectCountByPlanId(Long planId) {
34   - return selectCount(MesCalShiftDO::getPlanId, planId);
  34 + return selectCount(MesCalPlanShiftDO::getPlanId, planId);
35 35 }
36 36  
37 37 default void deleteByPlanId(Long planId) {
38   - delete(new LambdaQueryWrapperX<MesCalShiftDO>()
39   - .eq(MesCalShiftDO::getPlanId, planId));
  38 + delete(new LambdaQueryWrapperX<MesCalPlanShiftDO>()
  39 + .eq(MesCalPlanShiftDO::getPlanId, planId));
40 40 }
41 41  
42 42 }
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/DictTypeConstants.java
... ... @@ -19,5 +19,8 @@ public interface DictTypeConstants {
19 19 String MES_DV_MACHINERY_STATUS = "mes_dv_machinery_status"; // MES 设备状态
20 20 String MES_INDEX_TYPE = "mes_index_type"; // MES 检测项类型
21 21 String MES_DEFECT_LEVEL = "mes_defect_level"; // MES 缺陷等级
  22 + String MES_PRO_WORKORDER_STATUS = "mes_pro_workorder_status"; // MES 生产工单状态
  23 + String MES_PRO_WORKORDER_SOURCE_TYPE = "mes_pro_workorder_source_type"; // MES 工单来源类型
  24 + String MES_PRO_WORKORDER_TYPE = "mes_pro_workorder_type"; // MES 工单类型
22 25  
23 26 }
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/ErrorCodeConstants.java
... ... @@ -81,11 +81,9 @@ public interface ErrorCodeConstants {
81 81 ErrorCode MD_PRODUCT_SIP_NOT_EXISTS = new ErrorCode(1_040_109_000, "产品SIP不存在");
82 82 ErrorCode MD_PRODUCT_SIP_SORT_DUPLICATE = new ErrorCode(1_040_109_001, "该展示序号已存在");
83 83  
84   - // ========== MES 日历排班-班次(1-040-200-000) ==========
85   - ErrorCode CAL_SHIFT_NOT_EXISTS = new ErrorCode(1_040_200_000, "班次不存在");
86   - ErrorCode CAL_SHIFT_COUNT_EXCEED_SINGLE = new ErrorCode(1_040_200_001, "轮班方式为白班时只能有一个班次");
87   - ErrorCode CAL_SHIFT_COUNT_EXCEED_TWO = new ErrorCode(1_040_200_002, "轮班方式为两班倒时只能有两个班次");
88   - ErrorCode CAL_SHIFT_COUNT_EXCEED_THREE = new ErrorCode(1_040_200_003, "轮班方式为三班倒时只能有三个班次");
  84 + // ========== MES 日历排班-计划班次(1-040-200-000) ==========
  85 + ErrorCode CAL_PLAN_SHIFT_NOT_EXISTS = new ErrorCode(1_040_200_000, "计划班次不存在");
  86 + ErrorCode CAL_PLAN_SHIFT_COUNT_EXCEED = new ErrorCode(1_040_200_001, "班次数量已达到轮班方式的上限");
89 87  
90 88 // ========== MES 日历排班-班组(1-040-201-000) ==========
91 89 ErrorCode CAL_TEAM_NOT_EXISTS = new ErrorCode(1_040_201_000, "班组不存在");
... ... @@ -140,6 +138,9 @@ public interface ErrorCodeConstants {
140 138  
141 139 // ========== MES 生产管理-生产工单(1-040-502-000) ==========
142 140 ErrorCode PRO_WORKORDER_NOT_EXISTS = new ErrorCode(1_040_502_000, "生产工单不存在");
  141 + ErrorCode PRO_WORKORDER_CODE_DUPLICATE = new ErrorCode(1_040_502_001, "生产工单编码已存在");
  142 + ErrorCode PRO_WORKORDER_NOT_PREPARE = new ErrorCode(1_040_502_002, "只能删除草稿状态的工单");
  143 + ErrorCode PRO_WORKORDER_BOM_NOT_EXISTS = new ErrorCode(1_040_502_100, "生产工单BOM不存在");
143 144  
144 145 // ========== MES 生产管理-生产任务(1-040-503-000) ==========
145 146 ErrorCode PRO_TASK_NOT_EXISTS = new ErrorCode(1_040_503_000, "生产任务不存在");
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/cal/CalConstants.java deleted
1   -package cn.iocoder.yudao.module.mes.enums.cal;
2   -
3   -// TODO @AI:参考别的类,生成枚举类
4   -/**
5   - * MES 日历排班常量
6   - *
7   - * @author 芋道源码
8   - */
9   -public interface CalConstants {
10   -
11   - /** 白班 */
12   - String SHIFT_NAME_DAY = "白班";
13   - /** 夜班 */
14   - String SHIFT_NAME_NIGHT = "夜班";
15   - /** 中班 */
16   - String SHIFT_NAME_MID = "中班";
17   -
18   -}
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/cal/MesCalCalendarTypeEnum.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.enums.cal;
  2 +
  3 +import cn.iocoder.yudao.framework.common.core.ArrayValuable;
  4 +import lombok.AllArgsConstructor;
  5 +import lombok.Getter;
  6 +
  7 +import java.util.Arrays;
  8 +
  9 +/**
  10 + * MES 班组类型(日历类型)枚举
  11 + *
  12 + * @author 芋道源码
  13 + */
  14 +@Getter
  15 +@AllArgsConstructor
  16 +public enum MesCalCalendarTypeEnum implements ArrayValuable<Integer> {
  17 +
  18 + GROUP_ROTATION(1, "分组轮班"),
  19 + FIXED_TEAM(2, "固定班组");
  20 +
  21 + public static final Integer[] ARRAYS = Arrays.stream(values()).map(MesCalCalendarTypeEnum::getType).toArray(Integer[]::new);
  22 +
  23 + /**
  24 + * 类型值
  25 + */
  26 + private final Integer type;
  27 + /**
  28 + * 类型名
  29 + */
  30 + private final String name;
  31 +
  32 + @Override
  33 + public Integer[] array() {
  34 + return ARRAYS;
  35 + }
  36 +
  37 +}
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/enums/cal/MesCalShiftTypeEnum.java
1 1 package cn.iocoder.yudao.module.mes.enums.cal;
2 2  
  3 +import cn.hutool.core.lang.Pair;
3 4 import cn.iocoder.yudao.framework.common.core.ArrayValuable;
4 5 import lombok.AllArgsConstructor;
5 6 import lombok.Getter;
6 7  
7 8 import java.util.Arrays;
  9 +import java.util.List;
8 10  
9 11 /**
10 12 * MES 轮班方式枚举
... ... @@ -15,9 +17,18 @@ import java.util.Arrays;
15 17 @AllArgsConstructor
16 18 public enum MesCalShiftTypeEnum implements ArrayValuable<Integer> {
17 19  
18   - SINGLE(1, "单白班"),
19   - TWO(2, "两班倒"),
20   - THREE(3, "三班倒");
  20 + SINGLE(1, "单白班", List.of(
  21 + Pair.of("白班", new String[]{"08:00", "17:00"})
  22 + )),
  23 + TWO(2, "两班倒", List.of(
  24 + Pair.of("白班", new String[]{"08:00", "20:00"}),
  25 + Pair.of("夜班", new String[]{"20:00", "08:00"})
  26 + )),
  27 + THREE(3, "三班倒", List.of(
  28 + Pair.of("白班", new String[]{"08:00", "16:00"}),
  29 + Pair.of("中班", new String[]{"16:00", "00:00"}),
  30 + Pair.of("夜班", new String[]{"00:00", "08:00"})
  31 + ));
21 32  
22 33 public static final Integer[] ARRAYS = Arrays.stream(values()).map(MesCalShiftTypeEnum::getType).toArray(Integer[]::new);
23 34  
... ... @@ -29,6 +40,39 @@ public enum MesCalShiftTypeEnum implements ArrayValuable&lt;Integer&gt; {
29 40 * 类型名
30 41 */
31 42 private final String name;
  43 + /**
  44 + * 班次配置列表
  45 + *
  46 + * key: 班次名称(如 "白班", "夜班", "中班")
  47 + * value: [startTime, endTime](如 ["08:00", "17:00"])
  48 + */
  49 + private final List<Pair<String, String[]>> shifts;
  50 +
  51 + /**
  52 + * 获取班次数量上限
  53 + */
  54 + public int getShiftCount() {
  55 + return shifts.size();
  56 + }
  57 +
  58 + /**
  59 + * 获取所需的最少班组数量
  60 + */
  61 + public int getRequiredTeamCount() {
  62 + return shifts.size();
  63 + }
  64 +
  65 + /**
  66 + * 根据类型值获取枚举
  67 + */
  68 + public static MesCalShiftTypeEnum valueOf(Integer type) {
  69 + for (MesCalShiftTypeEnum value : values()) {
  70 + if (value.getType().equals(type)) {
  71 + return value;
  72 + }
  73 + }
  74 + throw new IllegalArgumentException("不支持的轮班方式: " + type);
  75 + }
32 76  
33 77 @Override
34 78 public Integer[] array() {
... ...
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;
8 8 import cn.iocoder.yudao.module.mes.dal.mysql.cal.plan.MesCalPlanMapper;
9 9 import cn.iocoder.yudao.module.mes.enums.cal.MesCalPlanStatusEnum;
10 10 import cn.iocoder.yudao.module.mes.enums.cal.MesCalShiftTypeEnum;
  11 +import cn.hutool.core.util.ObjUtil;
11 12 import jakarta.annotation.Resource;
12 13 import org.springframework.context.annotation.Lazy;
13 14 import org.springframework.stereotype.Service;
... ... @@ -30,7 +31,7 @@ public class MesCalPlanServiceImpl implements MesCalPlanService {
30 31 private MesCalPlanMapper planMapper;
31 32 @Resource
32 33 @Lazy
33   - private MesCalShiftService shiftService;
  34 + private MesCalPlanShiftService planShiftService;
34 35 @Resource
35 36 @Lazy
36 37 private MesCalPlanTeamService planTeamService;
... ... @@ -48,7 +49,7 @@ public class MesCalPlanServiceImpl implements MesCalPlanService {
48 49  
49 50 // 3. 自动生成默认班次
50 51 if (plan.getShiftType() != null) {
51   - shiftService.addDefaultShift(plan.getId(), plan.getShiftType());
  52 + planShiftService.addDefaultPlanShift(plan.getId(), plan.getShiftType());
52 53 }
53 54 return plan.getId();
54 55 }
... ... @@ -56,6 +57,7 @@ public class MesCalPlanServiceImpl implements MesCalPlanService {
56 57 @Override
57 58 @Transactional(rollbackFor = Exception.class)
58 59 public void updatePlan(MesCalPlanSaveReqVO updateReqVO) {
  60 + // TODO @AI:需要校验下,plan 未确定;(确认后,不允许编辑)
59 61 // 1.1 校验存在
60 62 MesCalPlanDO existPlan = validatePlanExists(updateReqVO.getId());
61 63 // 1.2 校验编码唯一
... ... @@ -79,13 +81,13 @@ public class MesCalPlanServiceImpl implements MesCalPlanService {
79 81 // 1.1 校验存在
80 82 MesCalPlanDO plan = validatePlanExists(id);
81 83 // 1.2 校验状态为草稿
82   - // TODO @AI:notEquals 更好一点;
83   - if (!MesCalPlanStatusEnum.PREPARE.getStatus().equals(plan.getStatus())) {
  84 + // TODO @AI:需要校验下,plan 未确定;(确认后,不允许编辑)【最好抽成一个方法,各个地方可以调用】
  85 + if (ObjUtil.notEqual(MesCalPlanStatusEnum.PREPARE.getStatus(), plan.getStatus())) {
84 86 throw exception(CAL_PLAN_NOT_PREPARE);
85 87 }
86 88  
87 89 // 2.1 级联删除班次 + 班组关联
88   - shiftService.deleteShiftByPlanId(id);
  90 + planShiftService.deletePlanShiftByPlanId(id);
89 91 planTeamService.deleteByPlanId(id);
90 92 // 2.2 删除计划
91 93 planMapper.deleteById(id);
... ... @@ -124,13 +126,10 @@ public class MesCalPlanServiceImpl implements MesCalPlanService {
124 126 */
125 127 private void validateTeamCountForConfirm(Long planId, Integer shiftType) {
126 128 Long teamCount = planTeamService.getPlanTeamCountByPlanId(planId);
127   - // TODO @AI:startTime、endTime 可以放到枚举类里么?List<hutool Pair>;这样就可以判断数量;
128   - if (MesCalShiftTypeEnum.TWO.getType().equals(shiftType) && teamCount < 2) {
129   - throw exception(CAL_PLAN_TEAM_COUNT_NOT_MATCH);
130   - } else if (MesCalShiftTypeEnum.THREE.getType().equals(shiftType) && teamCount < 3) {
  129 + MesCalShiftTypeEnum shiftTypeEnum = MesCalShiftTypeEnum.valueOf(shiftType);
  130 + if (teamCount < shiftTypeEnum.getRequiredTeamCount()) {
131 131 throw exception(CAL_PLAN_TEAM_COUNT_NOT_MATCH);
132 132 }
133   - // TODO @AI:兜底下,其它,则抛出异常参数 IllegalArgumentException,提示不支持的轮班方式;
134 133 }
135 134  
136 135 }
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalShiftService.java renamed to yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalPlanShiftService.java
1 1 package cn.iocoder.yudao.module.mes.service.cal.plan;
2 2  
3 3 import cn.iocoder.yudao.framework.common.pojo.PageResult;
4   -import cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.shift.MesCalShiftPageReqVO;
5   -import cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.shift.MesCalShiftSaveReqVO;
6   -import cn.iocoder.yudao.module.mes.dal.dataobject.cal.MesCalShiftDO;
  4 +import cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.shift.MesCalPlanShiftPageReqVO;
  5 +import cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.shift.MesCalPlanShiftSaveReqVO;
  6 +import cn.iocoder.yudao.module.mes.dal.dataobject.cal.MesCalPlanShiftDO;
7 7 import jakarta.validation.Valid;
8 8  
9 9 import java.util.List;
... ... @@ -13,7 +13,7 @@ import java.util.List;
13 13 *
14 14 * @author 芋道源码
15 15 */
16   -public interface MesCalShiftService {
  16 +public interface MesCalPlanShiftService {
17 17  
18 18 /**
19 19 * 创建计划班次
... ... @@ -21,21 +21,21 @@ public interface MesCalShiftService {
21 21 * @param createReqVO 创建信息
22 22 * @return 编号
23 23 */
24   - Long createShift(@Valid MesCalShiftSaveReqVO createReqVO);
  24 + Long createPlanShift(@Valid MesCalPlanShiftSaveReqVO createReqVO);
25 25  
26 26 /**
27 27 * 更新计划班次
28 28 *
29 29 * @param updateReqVO 更新信息
30 30 */
31   - void updateShift(@Valid MesCalShiftSaveReqVO updateReqVO);
  31 + void updatePlanShift(@Valid MesCalPlanShiftSaveReqVO updateReqVO);
32 32  
33 33 /**
34 34 * 删除计划班次
35 35 *
36 36 * @param id 编号
37 37 */
38   - void deleteShift(Long id);
  38 + void deletePlanShift(Long id);
39 39  
40 40 /**
41 41 * 获得计划班次
... ... @@ -43,7 +43,7 @@ public interface MesCalShiftService {
43 43 * @param id 编号
44 44 * @return 计划班次
45 45 */
46   - MesCalShiftDO getShift(Long id);
  46 + MesCalPlanShiftDO getPlanShift(Long id);
47 47  
48 48 /**
49 49 * 获得计划班次分页
... ... @@ -51,7 +51,7 @@ public interface MesCalShiftService {
51 51 * @param pageReqVO 分页查询
52 52 * @return 计划班次分页
53 53 */
54   - PageResult<MesCalShiftDO> getShiftPage(MesCalShiftPageReqVO pageReqVO);
  54 + PageResult<MesCalPlanShiftDO> getPlanShiftPage(MesCalPlanShiftPageReqVO pageReqVO);
55 55  
56 56 /**
57 57 * 获得指定排班计划的班次列表
... ... @@ -59,7 +59,7 @@ public interface MesCalShiftService {
59 59 * @param planId 排班计划编号
60 60 * @return 班次列表
61 61 */
62   - List<MesCalShiftDO> getShiftListByPlanId(Long planId);
  62 + List<MesCalPlanShiftDO> getPlanShiftListByPlanId(Long planId);
63 63  
64 64 /**
65 65 * 获得指定排班计划的班次数量
... ... @@ -67,7 +67,7 @@ public interface MesCalShiftService {
67 67 * @param planId 排班计划编号
68 68 * @return 班次数量
69 69 */
70   - Long getShiftCountByPlanId(Long planId);
  70 + Long getPlanShiftCountByPlanId(Long planId);
71 71  
72 72 /**
73 73 * 根据轮班方式添加默认班次
... ... @@ -75,13 +75,13 @@ public interface MesCalShiftService {
75 75 * @param planId 排班计划编号
76 76 * @param shiftType 轮班方式
77 77 */
78   - void addDefaultShift(Long planId, Integer shiftType);
  78 + void addDefaultPlanShift(Long planId, Integer shiftType);
79 79  
80 80 /**
81 81 * 根据排班计划编号删除所有班次
82 82 *
83 83 * @param planId 排班计划编号
84 84 */
85   - void deleteShiftByPlanId(Long planId);
  85 + void deletePlanShiftByPlanId(Long planId);
86 86  
87 87 }
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalPlanShiftServiceImpl.java 0 → 100644
  1 +package cn.iocoder.yudao.module.mes.service.cal.plan;
  2 +
  3 +import cn.hutool.core.lang.Pair;
  4 +import cn.iocoder.yudao.framework.common.pojo.PageResult;
  5 +import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
  6 +import cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.shift.MesCalPlanShiftPageReqVO;
  7 +import cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.shift.MesCalPlanShiftSaveReqVO;
  8 +import cn.iocoder.yudao.module.mes.dal.dataobject.cal.MesCalPlanDO;
  9 +import cn.iocoder.yudao.module.mes.dal.dataobject.cal.MesCalPlanShiftDO;
  10 +import cn.iocoder.yudao.module.mes.dal.mysql.cal.plan.MesCalPlanMapper;
  11 +import cn.iocoder.yudao.module.mes.dal.mysql.cal.plan.MesCalPlanShiftMapper;
  12 +import cn.iocoder.yudao.module.mes.enums.cal.MesCalShiftTypeEnum;
  13 +import jakarta.annotation.Resource;
  14 +import org.springframework.stereotype.Service;
  15 +import org.springframework.validation.annotation.Validated;
  16 +
  17 +import java.util.List;
  18 +
  19 +import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
  20 +import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*;
  21 +
  22 +/**
  23 + * MES 计划班次 Service 实现类
  24 + *
  25 + * @author 芋道源码
  26 + */
  27 +@Service
  28 +@Validated
  29 +public class MesCalPlanShiftServiceImpl implements MesCalPlanShiftService {
  30 +
  31 + @Resource
  32 + private MesCalPlanShiftMapper planShiftMapper;
  33 + @Resource
  34 + private MesCalPlanMapper planMapper;
  35 +
  36 + @Override
  37 + public Long createPlanShift(MesCalPlanShiftSaveReqVO createReqVO) {
  38 + // TODO @AI:需要校验下,plan 未确定;(确认后,不允许编辑)
  39 + // 校验班次数量限制
  40 + validatePlanShiftCount(createReqVO.getPlanId());
  41 +
  42 + // 插入
  43 + MesCalPlanShiftDO planShift = BeanUtils.toBean(createReqVO, MesCalPlanShiftDO.class);
  44 + planShiftMapper.insert(planShift);
  45 + return planShift.getId();
  46 + }
  47 +
  48 + @Override
  49 + public void updatePlanShift(MesCalPlanShiftSaveReqVO updateReqVO) {
  50 + // TODO @AI:需要校验下,plan 未确定;(确认后,不允许编辑)
  51 + // 校验存在
  52 + validatePlanShiftExists(updateReqVO.getId());
  53 + // 更新
  54 + MesCalPlanShiftDO updateObj = BeanUtils.toBean(updateReqVO, MesCalPlanShiftDO.class);
  55 + planShiftMapper.updateById(updateObj);
  56 + }
  57 +
  58 + @Override
  59 + public void deletePlanShift(Long id) {
  60 + // TODO @AI:需要校验下,plan 未确定;(确认后,不允许编辑)
  61 + // 校验存在
  62 + validatePlanShiftExists(id);
  63 + // 删除
  64 + planShiftMapper.deleteById(id);
  65 + }
  66 +
  67 + private void validatePlanShiftExists(Long id) {
  68 + if (planShiftMapper.selectById(id) == null) {
  69 + throw exception(CAL_PLAN_SHIFT_NOT_EXISTS);
  70 + }
  71 + }
  72 +
  73 + /**
  74 + * 校验班次数量是否超限
  75 + * <p>
  76 + * 通过 planId 查询已有班次数量,根据排班计划的轮班方式校验
  77 + */
  78 + private void validatePlanShiftCount(Long planId) {
  79 + MesCalPlanDO plan = planMapper.selectById(planId);
  80 + if (plan == null) {
  81 + return;
  82 + }
  83 + Long count = planShiftMapper.selectCountByPlanId(planId);
  84 + MesCalShiftTypeEnum shiftTypeEnum = MesCalShiftTypeEnum.valueOf(plan.getShiftType());
  85 + if (count >= shiftTypeEnum.getShiftCount()) {
  86 + throw exception(CAL_PLAN_SHIFT_COUNT_EXCEED);
  87 + }
  88 + }
  89 +
  90 + @Override
  91 + public MesCalPlanShiftDO getPlanShift(Long id) {
  92 + return planShiftMapper.selectById(id);
  93 + }
  94 +
  95 + @Override
  96 + public PageResult<MesCalPlanShiftDO> getPlanShiftPage(MesCalPlanShiftPageReqVO pageReqVO) {
  97 + return planShiftMapper.selectPage(pageReqVO);
  98 + }
  99 +
  100 + @Override
  101 + public List<MesCalPlanShiftDO> getPlanShiftListByPlanId(Long planId) {
  102 + return planShiftMapper.selectListByPlanId(planId);
  103 + }
  104 +
  105 + @Override
  106 + public Long getPlanShiftCountByPlanId(Long planId) {
  107 + return planShiftMapper.selectCountByPlanId(planId);
  108 + }
  109 +
  110 + @Override
  111 + public void addDefaultPlanShift(Long planId, Integer shiftType) {
  112 + // 根据轮班方式,通过枚举配置生成默认班次
  113 + MesCalShiftTypeEnum shiftTypeEnum = MesCalShiftTypeEnum.valueOf(shiftType);
  114 + List<Pair<String, String[]>> shifts = shiftTypeEnum.getShifts();
  115 + for (int i = 0; i < shifts.size(); i++) {
  116 + Pair<String, String[]> shift = shifts.get(i);
  117 + MesCalPlanShiftDO planShiftDO = MesCalPlanShiftDO.builder()
  118 + .planId(planId).sort(i + 1).name(shift.getKey())
  119 + .startTime(shift.getValue()[0]).endTime(shift.getValue()[1])
  120 + .build();
  121 + planShiftMapper.insert(planShiftDO);
  122 + }
  123 + }
  124 +
  125 + @Override
  126 + public void deletePlanShiftByPlanId(Long planId) {
  127 + planShiftMapper.deleteByPlanId(planId);
  128 + }
  129 +
  130 +}
... ...
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 {
27 27  
28 28 @Override
29 29 public Long createPlanTeam(MesCalPlanTeamSaveReqVO createReqVO) {
  30 + // TODO @AI:需要校验下,plan 未确定;(确认后,不允许编辑)
30 31 // 校验排班计划存在
31 32 validatePlanTeamDuplicate(createReqVO.getPlanId(), createReqVO.getTeamId());
32 33  
... ... @@ -38,6 +39,7 @@ public class MesCalPlanTeamServiceImpl implements MesCalPlanTeamService {
38 39  
39 40 @Override
40 41 public void deletePlanTeam(Long id) {
  42 + // TODO @AI:需要校验下,plan 未确定;(确认后,不允许编辑)
41 43 // 校验存在
42 44 validatePlanTeamExists(id);
43 45 // 删除
... ...
yudao-module-mes/src/main/java/cn/iocoder/yudao/module/mes/service/cal/plan/MesCalShiftServiceImpl.java deleted
1   -package cn.iocoder.yudao.module.mes.service.cal.plan;
2   -
3   -import cn.iocoder.yudao.framework.common.pojo.PageResult;
4   -import cn.iocoder.yudao.framework.common.util.object.BeanUtils;
5   -import cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.shift.MesCalShiftPageReqVO;
6   -import cn.iocoder.yudao.module.mes.controller.admin.cal.plan.vo.shift.MesCalShiftSaveReqVO;
7   -import cn.iocoder.yudao.module.mes.dal.dataobject.cal.MesCalPlanDO;
8   -import cn.iocoder.yudao.module.mes.dal.dataobject.cal.MesCalShiftDO;
9   -import cn.iocoder.yudao.module.mes.dal.mysql.cal.plan.MesCalPlanMapper;
10   -import cn.iocoder.yudao.module.mes.dal.mysql.cal.plan.MesCalShiftMapper;
11   -import cn.iocoder.yudao.module.mes.enums.cal.CalConstants;
12   -import cn.iocoder.yudao.module.mes.enums.cal.MesCalShiftTypeEnum;
13   -import jakarta.annotation.Resource;
14   -import org.springframework.stereotype.Service;
15   -import org.springframework.validation.annotation.Validated;
16   -
17   -import java.util.List;
18   -
19   -import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
20   -import static cn.iocoder.yudao.module.mes.enums.ErrorCodeConstants.*;
21   -
22   -/**
23   - * MES 计划班次 Service 实现类
24   - *
25   - * @author 芋道源码
26   - */
27   -@Service
28   -@Validated
29   -public class MesCalShiftServiceImpl implements MesCalShiftService {
30   -
31   - @Resource
32   - private MesCalShiftMapper shiftMapper;
33   - @Resource
34   - private MesCalPlanMapper planMapper;
35   -
36   - @Override
37   - public Long createShift(MesCalShiftSaveReqVO createReqVO) {
38   - // 校验班次数量限制
39   - validateShiftCount(createReqVO.getPlanId());
40   -
41   - // 插入
42   - MesCalShiftDO shift = BeanUtils.toBean(createReqVO, MesCalShiftDO.class);
43   - shiftMapper.insert(shift);
44   - return shift.getId();
45   - }
46   -
47   - @Override
48   - public void updateShift(MesCalShiftSaveReqVO updateReqVO) {
49   - // 校验存在
50   - validateShiftExists(updateReqVO.getId());
51   - // 更新
52   - MesCalShiftDO updateObj = BeanUtils.toBean(updateReqVO, MesCalShiftDO.class);
53   - shiftMapper.updateById(updateObj);
54   - }
55   -
56   - @Override
57   - public void deleteShift(Long id) {
58   - // 校验存在
59   - validateShiftExists(id);
60   - // 删除
61   - shiftMapper.deleteById(id);
62   - }
63   -
64   - private void validateShiftExists(Long id) {
65   - if (shiftMapper.selectById(id) == null) {
66   - throw exception(CAL_SHIFT_NOT_EXISTS);
67   - }
68   - }
69   -
70   - /**
71   - * 校验班次数量是否超限
72   - * <p>
73   - * 通过 planId 查询已有班次数量,根据排班计划的轮班方式校验
74   - */
75   - private void validateShiftCount(Long planId) {
76   - MesCalPlanDO plan = planMapper.selectById(planId);
77   - if (plan == null) {
78   - return;
79   - }
80   - Long count = shiftMapper.selectCountByPlanId(planId);
81   - Integer shiftType = plan.getShiftType();
82   - // TODO @AI:startTime、endTime 可以放到枚举类里么?List<hutool Pair>;这样可以 count 来判断。更简洁;
83   - if (MesCalShiftTypeEnum.SINGLE.getType().equals(shiftType) && count >= 1) {
84   - throw exception(CAL_SHIFT_COUNT_EXCEED_SINGLE);
85   - } else if (MesCalShiftTypeEnum.TWO.getType().equals(shiftType) && count >= 2) {
86   - throw exception(CAL_SHIFT_COUNT_EXCEED_TWO);
87   - } else if (MesCalShiftTypeEnum.THREE.getType().equals(shiftType) && count >= 3) {
88   - throw exception(CAL_SHIFT_COUNT_EXCEED_THREE);
89   - }
90   - }
91   -
92   - @Override
93   - public MesCalShiftDO getShift(Long id) {
94   - return shiftMapper.selectById(id);
95   - }
96   -
97   - @Override
98   - public PageResult<MesCalShiftDO> getShiftPage(MesCalShiftPageReqVO pageReqVO) {
99   - return shiftMapper.selectPage(pageReqVO);
100   - }
101   -
102   - @Override
103   - public List<MesCalShiftDO> getShiftListByPlanId(Long planId) {
104   - return shiftMapper.selectListByPlanId(planId);
105   - }
106   -
107   - @Override
108   - public Long getShiftCountByPlanId(Long planId) {
109   - return shiftMapper.selectCountByPlanId(planId);
110   - }
111   -
112   - @Override
113   - public void addDefaultShift(Long planId, Integer shiftType) {
114   - // 根据轮班方式,添加默认班次
115   - // TODO @AI:startTime、endTime 可以放到枚举类里么?List<hutool Pair>;这样就可以 for 循环;
116   - if (MesCalShiftTypeEnum.SINGLE.getType().equals(shiftType)) {
117   - // 单白班:1 个班次
118   - insertShift(planId, 1, CalConstants.SHIFT_NAME_DAY, "08:00", "17:00");
119   - } else if (MesCalShiftTypeEnum.TWO.getType().equals(shiftType)) {
120   - // 两班倒:2 个班次
121   - insertShift(planId, 1, CalConstants.SHIFT_NAME_DAY, "08:00", "20:00");
122   - insertShift(planId, 2, CalConstants.SHIFT_NAME_NIGHT, "20:00", "08:00");
123   - } else if (MesCalShiftTypeEnum.THREE.getType().equals(shiftType)) {
124   - // 三班倒:3 个班次
125   - insertShift(planId, 1, CalConstants.SHIFT_NAME_DAY, "08:00", "16:00");
126   - insertShift(planId, 2, CalConstants.SHIFT_NAME_MID, "16:00", "00:00");
127   - insertShift(planId, 3, CalConstants.SHIFT_NAME_NIGHT, "00:00", "08:00");
128   - }
129   - }
130   -
131   - private void insertShift(Long planId, Integer sort, String name, String startTime, String endTime) {
132   - // TODO @AI:链式 set,想通放在一样;
133   - MesCalShiftDO shift = new MesCalShiftDO();
134   - shift.setPlanId(planId);
135   - shift.setSort(sort);
136   - shift.setName(name);
137   - shift.setStartTime(startTime);
138   - shift.setEndTime(endTime);
139   - shiftMapper.insert(shift);
140   - }
141   -
142   - @Override
143   - public void deleteShiftByPlanId(Long planId) {
144   - shiftMapper.deleteByPlanId(planId);
145   - }
146   -
147   -}