Commit af59a5ee218a8442b9f1244939a2940cf5199171

Authored by guzijian
1 parent e791214e

fix: 新增排班

Showing 54 changed files with 2014 additions and 170 deletions
ruoyi-admin/src/main/java/com/ruoyi/common/RuleSchedulingProperties.java
@@ -5,11 +5,11 @@ package com.ruoyi.common; @@ -5,11 +5,11 @@ package com.ruoyi.common;
5 */ 5 */
6 public interface RuleSchedulingProperties { 6 public interface RuleSchedulingProperties {
7 /** 7 /**
8 - * 分段 8 + * 分段
9 */ 9 */
10 Integer HAVE_SEGMENTATION = 2; 10 Integer HAVE_SEGMENTATION = 2;
11 /** 11 /**
12 - * 分段 12 + * 分段
13 */ 13 */
14 Integer NO_SEGMENTATION = 1; 14 Integer NO_SEGMENTATION = 1;
15 15
@@ -47,4 +47,22 @@ public interface RuleSchedulingProperties { @@ -47,4 +47,22 @@ public interface RuleSchedulingProperties {
47 Integer WORK_HOUR_TYPE_ELASTIC = 0; 47 Integer WORK_HOUR_TYPE_ELASTIC = 0;
48 Integer WORK_HOUR_TYPE_FIXED = 1; 48 Integer WORK_HOUR_TYPE_FIXED = 1;
49 49
  50 + /**
  51 + * 班次类型 按照星期翻班
  52 + */
  53 + Integer RULE_TYPE_WEEK = 2;
  54 + /**
  55 + * 按照固定规则
  56 + */
  57 + Integer RULE_TYPE_FIXED = 1;
  58 +
  59 + /**
  60 + * 上班
  61 + */
  62 + Integer WORK_FLAG = 1;
  63 + /**
  64 + * 休息
  65 + */
  66 + Integer FREE_FLAG = 0;
  67 +
50 } 68 }
ruoyi-admin/src/main/java/com/ruoyi/common/WeekEnum.java 0 → 100644
  1 +package com.ruoyi.common;
  2 +
  3 +/**
  4 + * 星期枚举
  5 + * @author 20412
  6 + */
  7 +
  8 +public enum WeekEnum {
  9 + MONDAY(1,"MONDAY","星期一"),
  10 + TUESDAY(2,"TUESDAY","星期二"),
  11 + WEDNESDAY(3,"WEDNESDAY","星期三"),
  12 + THURSDAY(4,"THURSDAY","星期四"),
  13 + FRIDAY(5,"FRIDAY","星期五"),
  14 + SATURDAY(6,"SATURDAY","星期六"),
  15 + SUNDAY(7,"SUNDAY","星期天"),
  16 + FREE(0,"休息","休息");
  17 +
  18 + private String description;
  19 + private Integer value;
  20 + private String valueString;
  21 +
  22 + WeekEnum(Integer value,String valueString,String description){
  23 + this.value = value;
  24 + this.description = description;
  25 + this.valueString = valueString;
  26 + }
  27 + public Integer getValue(){
  28 + return this.value;
  29 + }
  30 + public String getDescription() {
  31 + return this.description;
  32 + }
  33 + public String getValueString(){
  34 + return this.valueString;
  35 + }
  36 +}
ruoyi-admin/src/main/java/com/ruoyi/controller/AttendanceController.java
1 package com.ruoyi.controller; 1 package com.ruoyi.controller;
2 2
  3 +import com.ruoyi.common.core.controller.BaseController;
  4 +import com.ruoyi.common.core.page.TableDataInfo;
3 import com.ruoyi.common.global.Result; 5 import com.ruoyi.common.global.Result;
  6 +import com.ruoyi.domain.RuleAttendanceMain;
  7 +import com.ruoyi.pojo.dto.SchedulingDto;
  8 +import com.ruoyi.pojo.dto.SchedulingSettingDto;
  9 +import com.ruoyi.pojo.vo.RuleAttendanceMainRequestVo;
4 import com.ruoyi.pojo.vo.SchedulingRequestVo; 10 import com.ruoyi.pojo.vo.SchedulingRequestVo;
  11 +import com.ruoyi.pojo.vo.SchedulingResponseVo;
  12 +import com.ruoyi.pojo.vo.UpdateAttendanceVo;
5 import com.ruoyi.service.AttendanceService; 13 import com.ruoyi.service.AttendanceService;
6 import io.swagger.annotations.Api; 14 import io.swagger.annotations.Api;
7 import io.swagger.annotations.ApiOperation; 15 import io.swagger.annotations.ApiOperation;
8 import org.springframework.beans.factory.annotation.Autowired; 16 import org.springframework.beans.factory.annotation.Autowired;
  17 +import org.springframework.validation.annotation.Validated;
9 import org.springframework.web.bind.annotation.*; 18 import org.springframework.web.bind.annotation.*;
10 19
  20 +import java.util.List;
  21 +
11 /** 22 /**
12 * 考勤表controller 23 * 考勤表controller
13 * @author 20412 24 * @author 20412
@@ -15,7 +26,7 @@ import org.springframework.web.bind.annotation.*; @@ -15,7 +26,7 @@ import org.springframework.web.bind.annotation.*;
15 @RestController 26 @RestController
16 @RequestMapping("/attendance") 27 @RequestMapping("/attendance")
17 @Api(tags = "考勤管理") 28 @Api(tags = "考勤管理")
18 -public class AttendanceController { 29 +public class AttendanceController extends BaseController {
19 30
20 @Autowired 31 @Autowired
21 private AttendanceService attendanceService; 32 private AttendanceService attendanceService;
@@ -35,7 +46,66 @@ public class AttendanceController { @@ -35,7 +46,66 @@ public class AttendanceController {
35 */ 46 */
36 @ApiOperation("获取排班") 47 @ApiOperation("获取排班")
37 @GetMapping("/scheduling/list") 48 @GetMapping("/scheduling/list")
38 - public Result<?> getSchedulingList(@ModelAttribute SchedulingRequestVo vo){  
39 - return Result.OK(attendanceService.getSchedulingList(vo)); 49 + public TableDataInfo getSchedulingList(@ModelAttribute SchedulingRequestVo vo){
  50 + List<SchedulingResponseVo> list = attendanceService.getSchedulingList(vo);
  51 + return getDataTable(list);
  52 + }
  53 +
  54 + /**
  55 + * 根据班次获取模板
  56 + */
  57 + @ApiOperation("根据班次获取模板")
  58 + @GetMapping("/template/{id}")
  59 + public Result<?> getTemplate(@PathVariable("id") Long id){
  60 + return Result.OK(attendanceService.getTemplate(id));
  61 + }
  62 +
  63 +
  64 + /**
  65 + * 新增排班设置
  66 + */
  67 + @ApiOperation("排班设置")
  68 + @PostMapping("/saveSchedulingSetting")
  69 + public Result<?> saveSchedulingSetting(@RequestBody @Validated SchedulingSettingDto dto){
  70 + attendanceService.saveSchedulingSetting(dto);
  71 + return Result.OK("新增成功");
  72 + }
  73 +
  74 + /**
  75 + * 修改排班设置
  76 + */
  77 + @ApiOperation("排班设置")
  78 + @PutMapping("/updateSchedulingSetting")
  79 + public Result<?> updateSchedulingSetting(@RequestBody @Validated SchedulingDto dto){
  80 + attendanceService.updateSchedulingSetting(dto);
  81 + return Result.OK("新增成功");
  82 + }
  83 +
  84 + /**
  85 + * 删除排班设置
  86 + */
  87 + @ApiOperation("排班设置")
  88 + @DeleteMapping("/deleteSchedulingSetting/{settingId}")
  89 + public Result<?> deleteSchedulingSetting(@PathVariable("settingId") Integer settingId){
  90 + attendanceService.deleteSchedulingSetting(settingId);
  91 + return Result.OK("删除成功");
  92 + }
  93 +
  94 +
  95 + /**
  96 + * 获取考情表
  97 + */
  98 + @ApiOperation("获取考情表")
  99 + @GetMapping("/list/attendance")
  100 + public TableDataInfo getAttendance(@ModelAttribute RuleAttendanceMainRequestVo vo){
  101 + List<RuleAttendanceMain> list = attendanceService.queryAttendanceMain(vo);
  102 + return getDataTable(list);
  103 + }
  104 +
  105 + @ApiOperation("修改考情表")
  106 + @PutMapping("/update/attendance")
  107 + public Result<?> updateAttendance(@RequestBody @Validated UpdateAttendanceVo vo){
  108 + attendanceService.updateAttendance(vo);
  109 + return Result.OK("规则修改成功");
40 } 110 }
41 } 111 }
ruoyi-admin/src/main/java/com/ruoyi/domain/RuleAttendanceMain.java 0 → 100644
  1 +package com.ruoyi.domain;
  2 +
  3 +import com.baomidou.mybatisplus.annotation.IdType;
  4 +import com.baomidou.mybatisplus.annotation.TableField;
  5 +import com.baomidou.mybatisplus.annotation.TableId;
  6 +import com.baomidou.mybatisplus.annotation.TableName;
  7 +import java.io.Serializable;
  8 +import java.util.Date;
  9 +import lombok.Data;
  10 +import org.springframework.format.annotation.DateTimeFormat;
  11 +
  12 +/**
  13 + * 考勤表
  14 + * @author 20412
  15 + * @TableName rule_attendance_main
  16 + */
  17 +@TableName(value ="rule_attendance_main")
  18 +@Data
  19 +public class RuleAttendanceMain implements Serializable {
  20 + /**
  21 + * 主键
  22 + */
  23 + @TableId(type = IdType.AUTO)
  24 + private Integer id;
  25 +
  26 + /**
  27 + * 姓名
  28 + */
  29 + private String name;
  30 +
  31 + /**
  32 + * 工号
  33 + */
  34 + private String jobCode;
  35 +
  36 + /**
  37 + * 工时制
  38 + */
  39 + private Integer workingHourPlan;
  40 +
  41 + /**
  42 + * 工时类型
  43 + */
  44 + private Integer workingHourType;
  45 +
  46 + /**
  47 + * 第一段上班签到时间
  48 + */
  49 + private Date firstWorkSignInTime;
  50 +
  51 + /**
  52 + * 第一段上班打卡签到范围
  53 + */
  54 + private Integer firstSignInWorkingRange;
  55 +
  56 + /**
  57 + * 第一段下班签退时间
  58 + */
  59 + private Date firstQuittingSignInTime;
  60 +
  61 + /**
  62 + * 第一段下班签退签到范围
  63 + */
  64 + private Integer firstSignInQuittingRange;
  65 +
  66 + /**
  67 + * 超时范围允许
  68 + */
  69 + private Integer signInTimeOutRange;
  70 +
  71 + /**
  72 + * 第二段上班签到时间
  73 + */
  74 + private Date secondWorkSignInTime;
  75 +
  76 + /**
  77 + * 第二段上班打卡范围
  78 + */
  79 + private Integer secondSignInWorkingRange;
  80 +
  81 + /**
  82 + * 第二段下班签到签退
  83 + */
  84 + private Date secondQuittingSignInTime;
  85 +
  86 + /**
  87 + * 第二段下班打卡范围
  88 + */
  89 + private Integer secondSignInQuittingRange;
  90 +
  91 + /**
  92 + * 值班日期
  93 + */
  94 + @DateTimeFormat(pattern = "yyyy-MM-dd")
  95 + private Date schedulingDate;
  96 +
  97 + /**
  98 + * 工作还是休息
  99 + */
  100 + private Integer workFlag;
  101 +
  102 + /**
  103 + * 工种
  104 + */
  105 + private String posts;
  106 +
  107 + /**
  108 + * 班型名称
  109 + */
  110 + private String ruleDictName;
  111 +
  112 + @TableField(exist = false)
  113 + private static final long serialVersionUID = 1L;
  114 +}
0 \ No newline at end of file 115 \ No newline at end of file
ruoyi-admin/src/main/java/com/ruoyi/domain/RuleNumSetting.java
1 package com.ruoyi.domain; 1 package com.ruoyi.domain;
2 2
  3 +
  4 +import com.baomidou.mybatisplus.annotation.IdType;
  5 +import com.baomidou.mybatisplus.annotation.TableField;
  6 +import com.baomidou.mybatisplus.annotation.TableId;
  7 +import com.baomidou.mybatisplus.annotation.TableName;
  8 +import java.io.Serializable;
  9 +import java.util.Date;
3 import lombok.Data; 10 import lombok.Data;
4 11
5 /** 12 /**
6 - * 排班设置 13 + * 排班设置
7 * @author 20412 14 * @author 20412
  15 + * @TableName rule_num_setting
8 */ 16 */
  17 +@TableName(value ="rule_num_setting")
9 @Data 18 @Data
10 -public class RuleNumSetting {  
11 -} 19 +public class RuleNumSetting implements Serializable {
  20 + /**
  21 + * 主键
  22 + */
  23 + @TableId(type = IdType.AUTO)
  24 + private Integer id;
  25 +
  26 + /**
  27 + * 班次id
  28 + */
  29 + private Integer ruleNumId;
  30 +
  31 + /**
  32 + * 排班名称
  33 + */
  34 + private String ruleDictName;
  35 +
  36 + /**
  37 + * 创建时间
  38 + */
  39 + private Date createTime;
  40 +
  41 + /**
  42 + * 修改时间
  43 + */
  44 + private Date updateTime;
  45 +
  46 + /**
  47 + * 备注
  48 + */
  49 + private String remark;
  50 +
  51 + /**
  52 + * 创建人
  53 + */
  54 + private String createBy;
  55 +
  56 + /**
  57 + * 修改人
  58 + */
  59 + private String updateBy;
  60 +
  61 + @TableField(exist = false)
  62 + private static final long serialVersionUID = 1L;
  63 +}
12 \ No newline at end of file 64 \ No newline at end of file
ruoyi-admin/src/main/java/com/ruoyi/domain/RuleSettingDriver.java 0 → 100644
  1 +package com.ruoyi.domain;
  2 +
  3 +
  4 +import com.baomidou.mybatisplus.annotation.IdType;
  5 +import com.baomidou.mybatisplus.annotation.TableField;
  6 +import com.baomidou.mybatisplus.annotation.TableId;
  7 +import com.baomidou.mybatisplus.annotation.TableName;
  8 +import java.io.Serializable;
  9 +import java.util.Date;
  10 +
  11 +import com.fasterxml.jackson.annotation.JsonFormat;
  12 +import lombok.Data;
  13 +import org.springframework.format.annotation.DateTimeFormat;
  14 +
  15 +import javax.validation.constraints.NotNull;
  16 +
  17 +/**
  18 + * 人员信息表与排班设置绑定表
  19 + * @author 20412
  20 + * @TableName rule_setting_driver
  21 + */
  22 +@TableName(value ="rule_setting_driver")
  23 +@Data
  24 +public class RuleSettingDriver implements Serializable {
  25 + /**
  26 + *
  27 + */
  28 + @TableId(type = IdType.AUTO)
  29 + private Integer id;
  30 +
  31 + /**
  32 + *
  33 + */
  34 + private Integer settingId;
  35 +
  36 + /**
  37 + * 工号
  38 + */
  39 + private String jobCode;
  40 +
  41 + /**
  42 + * 开始时间
  43 + */
  44 + @DateTimeFormat(pattern = "yyyy-MM-dd")
  45 + @JsonFormat(pattern = "yyyy-MM-dd")
  46 + private Date startDate;
  47 +
  48 + @TableField(exist = false)
  49 + private static final long serialVersionUID = 1L;
  50 +}
0 \ No newline at end of file 51 \ No newline at end of file
ruoyi-admin/src/main/java/com/ruoyi/domain/RuleSettingScheduling.java 0 → 100644
  1 +package com.ruoyi.domain;
  2 +
  3 +
  4 +import com.baomidou.mybatisplus.annotation.IdType;
  5 +import com.baomidou.mybatisplus.annotation.TableField;
  6 +import com.baomidou.mybatisplus.annotation.TableId;
  7 +import com.baomidou.mybatisplus.annotation.TableName;
  8 +import java.io.Serializable;
  9 +import lombok.Data;
  10 +
  11 +import javax.validation.constraints.NotNull;
  12 +
  13 +/**
  14 + * 考勤规则表
  15 + * @author 20412
  16 + * @TableName rule_setting_scheduling
  17 + */
  18 +@TableName(value ="rule_setting_scheduling")
  19 +@Data
  20 +public class RuleSettingScheduling implements Serializable {
  21 + /**
  22 + *
  23 + */
  24 + @TableId(type = IdType.AUTO)
  25 + private Integer id;
  26 +
  27 + /**
  28 + * 设置表id
  29 + */
  30 + @NotNull(message = "设置表id不能为空")
  31 + private Integer settingId;
  32 +
  33 + /**
  34 + * 规则id
  35 + */
  36 + private Integer ruleSchedulingId;
  37 + /**
  38 + * 规则名称
  39 + */
  40 + private String ruleName;
  41 + /**
  42 + * 时间范围
  43 + */
  44 + private String rangeTime;
  45 +
  46 + /**
  47 + * 序号
  48 + */
  49 + @NotNull(message = "序号不能为空")
  50 + private Integer sort;
  51 +
  52 + @TableField(exist = false)
  53 + private static final long serialVersionUID = 1L;
  54 +}
0 \ No newline at end of file 55 \ No newline at end of file
ruoyi-admin/src/main/java/com/ruoyi/driver/mapper/DriverMapper.java
@@ -113,7 +113,7 @@ public interface DriverMapper @@ -113,7 +113,7 @@ public interface DriverMapper
113 * @param id 113 * @param id
114 * @return 114 * @return
115 */ 115 */
116 - List<PeopleResponseVo> queryAttendanceInfoById(Long id); 116 + List<PeopleResponseVo> queryAttendanceInfoById(@Param("id") Long id);
117 117
118 /** 118 /**
119 * 获取所有可添加的考勤人员 119 * 获取所有可添加的考勤人员
ruoyi-admin/src/main/java/com/ruoyi/job/DriverJob.java
1 package com.ruoyi.job; 1 package com.ruoyi.job;
2 2
3 -import cn.hutool.core.collection.CollectionUtil;  
4 import cn.hutool.http.HttpUtil; 3 import cn.hutool.http.HttpUtil;
5 import com.alibaba.fastjson2.JSON; 4 import com.alibaba.fastjson2.JSON;
6 import com.alibaba.fastjson2.JSONArray; 5 import com.alibaba.fastjson2.JSONArray;
@@ -16,6 +15,7 @@ import com.ruoyi.pojo.request.PersonnelRequestVo; @@ -16,6 +15,7 @@ import com.ruoyi.pojo.request.PersonnelRequestVo;
16 import com.ruoyi.pojo.request.TokenRequestVo; 15 import com.ruoyi.pojo.request.TokenRequestVo;
17 import com.ruoyi.pojo.response.ResponseSchedulingDto; 16 import com.ruoyi.pojo.response.ResponseSchedulingDto;
18 import com.ruoyi.pojo.response.personnel.*; 17 import com.ruoyi.pojo.response.personnel.*;
  18 +import com.ruoyi.service.RuleNumSettingService;
19 import com.ruoyi.service.ThreadJobService; 19 import com.ruoyi.service.ThreadJobService;
20 import com.ruoyi.utils.ConstDateUtil; 20 import com.ruoyi.utils.ConstDateUtil;
21 import com.ruoyi.utils.ListUtils; 21 import com.ruoyi.utils.ListUtils;
@@ -74,6 +74,9 @@ public class DriverJob implements InitializingBean { @@ -74,6 +74,9 @@ public class DriverJob implements InitializingBean {
74 private ThreadJobService threadJobService; 74 private ThreadJobService threadJobService;
75 75
76 @Autowired 76 @Autowired
  77 + private RuleNumSettingService ruleNumSettingService;
  78 +
  79 + @Autowired
77 private IDriverService driverService; 80 private IDriverService driverService;
78 81
79 @Value("${api.url.getDriverInfo}") 82 @Value("${api.url.getDriverInfo}")
@@ -98,6 +101,7 @@ public class DriverJob implements InitializingBean { @@ -98,6 +101,7 @@ public class DriverJob implements InitializingBean {
98 @Value("${api.config.nonce}") 101 @Value("${api.config.nonce}")
99 private String nonce; 102 private String nonce;
100 103
  104 + private static RuleNumSettingService RULE_NUM_SETTING_SERVICE;
101 private static NowSchedulingCache NOW_SCHEDULING_CACHE; 105 private static NowSchedulingCache NOW_SCHEDULING_CACHE;
102 private static ThreadJobService THREAD_JOB_SERVICE; 106 private static ThreadJobService THREAD_JOB_SERVICE;
103 private static SchedulingCache SCHEDULING_CACHE; 107 private static SchedulingCache SCHEDULING_CACHE;
@@ -204,7 +208,7 @@ public class DriverJob implements InitializingBean { @@ -204,7 +208,7 @@ public class DriverJob implements InitializingBean {
204 * 获取排班任务请求 208 * 获取排班任务请求
205 * 24小时执行一次 209 * 24小时执行一次
206 */ 210 */
207 - public void getSchedulingInfo() { 211 + public void getSchedulingInfo(String timeOut) {
208 // TODO 获取当天的签到表 212 // TODO 获取当天的签到表
209 long timestamp = System.currentTimeMillis(); 213 long timestamp = System.currentTimeMillis();
210 String formatDate = ConstDateUtil.formatDate(timestamp); 214 String formatDate = ConstDateUtil.formatDate(timestamp);
@@ -220,7 +224,7 @@ public class DriverJob implements InitializingBean { @@ -220,7 +224,7 @@ public class DriverJob implements InitializingBean {
220 throw new RuntimeException(e); 224 throw new RuntimeException(e);
221 } 225 }
222 // 获取排班信息并存入redis 226 // 获取排班信息并存入redis
223 - saveSchedulingToRedis(getSchedulingInfoUrl, formatDate); 227 + saveSchedulingToRedis(getSchedulingInfoUrl, formatDate,timeOut);
224 // 删除两天前排班信息 228 // 删除两天前排班信息
225 deleteScheduling(); 229 deleteScheduling();
226 log.info("获取{}的排班数据完毕", formatDate); 230 log.info("获取{}的排班数据完毕", formatDate);
@@ -261,6 +265,13 @@ public class DriverJob implements InitializingBean { @@ -261,6 +265,13 @@ public class DriverJob implements InitializingBean {
261 } 265 }
262 266
263 /** 267 /**
  268 + * 生成排班
  269 + */
  270 + public void createAttendance(){
  271 + RULE_NUM_SETTING_SERVICE.createAttendance();
  272 + }
  273 +
  274 + /**
264 * 计算设备在线状态 5 分钟一次 275 * 计算设备在线状态 5 分钟一次
265 */ 276 */
266 public void computedDeviceOnlineStatus(String date) throws IOException, ClassNotFoundException { 277 public void computedDeviceOnlineStatus(String date) throws IOException, ClassNotFoundException {
@@ -287,7 +298,7 @@ public class DriverJob implements InitializingBean { @@ -287,7 +298,7 @@ public class DriverJob implements InitializingBean {
287 } 298 }
288 299
289 300
290 - public Map<String, List<ResponseSchedulingDto>> saveSchedulingToRedis(String getSchedulingInfoUrl, String dateKey) { 301 + public Map<String, List<ResponseSchedulingDto>> saveSchedulingToRedis(String getSchedulingInfoUrl, String dateKey, String timeOut) {
291 log.info("开始拉取排班:{}", dateKey); 302 log.info("开始拉取排班:{}", dateKey);
292 List<ResponseSchedulingDto> originSchedulingList = RESTTEMPLATE.exchange( 303 List<ResponseSchedulingDto> originSchedulingList = RESTTEMPLATE.exchange(
293 getSchedulingInfoUrl, 304 getSchedulingInfoUrl,
@@ -314,7 +325,7 @@ public class DriverJob implements InitializingBean { @@ -314,7 +325,7 @@ public class DriverJob implements InitializingBean {
314 schedulingList.sort(Comparator.comparing(ResponseSchedulingDto::getFcsjT)); 325 schedulingList.sort(Comparator.comparing(ResponseSchedulingDto::getFcsjT));
315 } 326 }
316 // 存入签到报表 327 // 存入签到报表
317 - THREAD_JOB_SERVICE.asyncComputedScheduling(driverSchedulingMap); 328 + THREAD_JOB_SERVICE.asyncComputedScheduling(driverSchedulingMap,timeOut);
318 // 实时排班直接存入缓存 329 // 实时排班直接存入缓存
319 SCHEDULING_CACHE.setCacheScheduling(DRIVER_SCHEDULING_PRE + dateKey, driverSchedulingMap); 330 SCHEDULING_CACHE.setCacheScheduling(DRIVER_SCHEDULING_PRE + dateKey, driverSchedulingMap);
320 log.info("拉取排班完毕:{}", dateKey); 331 log.info("拉取排班完毕:{}", dateKey);
@@ -472,29 +483,8 @@ public class DriverJob implements InitializingBean { @@ -472,29 +483,8 @@ public class DriverJob implements InitializingBean {
472 throw e; 483 throw e;
473 } 484 }
474 485
475 -  
476 } 486 }
477 487
478 -// public static void main(String[] args) throws Exception {  
479 -// RestTemplate restTemplate1 = new RestTemplate();  
480 -//// String url = "http://101.95.136.206:9089/webservice/rest/person/company/%s";  
481 -// String url = "http://101.95.136.206:9089/webservice/rest/schedule_real/sch_jk/%s/%s?timestamp=%d&nonce=%s&password=%s&sign=%s";  
482 -//  
483 -// long timestamp = System.currentTimeMillis();  
484 -// Map<String, String> configMap = new HashMap<>(5);  
485 -// configMap.put("timestamp", String.valueOf(timestamp));  
486 -// configMap.put("nonce", "NONCE");  
487 -// configMap.put("password", "c4dd3d8cb9a82f6d6a625818618b28ca7bebb464");  
488 -// String format = String.format(url, "99", DateUtils.getDate("yyyyMMdd"), timestamp, "NONCE", "c4dd3d8cb9a82f6d6a625818618b28ca7bebb464", getSHA1(configMap));  
489 -//// String sign = getSHA1(configMap);  
490 -//// String httpUrl = format  
491 -//// + "?timestamp=" + timestamp  
492 -//// + "&nonce=" + "NONCE"  
493 -//// + "&password=" + "c4dd3d8cb9a82f6d6a625818618b28ca7bebb464"  
494 -//// + "&sign=" + sign;  
495 -// Object forObject = restTemplate1.getForObject(format, Object.class);  
496 -// }  
497 -  
498 @Override 488 @Override
499 public void afterPropertiesSet() throws Exception { 489 public void afterPropertiesSet() throws Exception {
500 GET_DRIVER_INFO_URL = getDriverInfoUrl; 490 GET_DRIVER_INFO_URL = getDriverInfoUrl;
@@ -511,5 +501,6 @@ public class DriverJob implements InitializingBean { @@ -511,5 +501,6 @@ public class DriverJob implements InitializingBean {
511 SCHEDULING_CACHE = schedulingCache; 501 SCHEDULING_CACHE = schedulingCache;
512 EQUIPMENT_MAPPER = equipmentMapper; 502 EQUIPMENT_MAPPER = equipmentMapper;
513 NOW_SCHEDULING_CACHE = nowSchedulingCache; 503 NOW_SCHEDULING_CACHE = nowSchedulingCache;
  504 + RULE_NUM_SETTING_SERVICE = ruleNumSettingService;
514 } 505 }
515 } 506 }
ruoyi-admin/src/main/java/com/ruoyi/mapper/RuleAttendanceMainMapper.java 0 → 100644
  1 +package com.ruoyi.mapper;
  2 +
  3 +import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  4 +import com.ruoyi.domain.RuleAttendanceMain;
  5 +
  6 +/**
  7 +* @author 20412
  8 +* @description 针对表【rule_attendance_main(考勤表)】的数据库操作Mapper
  9 +* @createDate 2023-09-03 12:15:39
  10 +* @Entity .domain.RuleAttendanceMain
  11 +*/
  12 +public interface RuleAttendanceMainMapper extends BaseMapper<RuleAttendanceMain> {
  13 +
  14 +}
  15 +
  16 +
  17 +
  18 +
ruoyi-admin/src/main/java/com/ruoyi/mapper/RuleNumSettingMapper.java 0 → 100644
  1 +package com.ruoyi.mapper;
  2 +
  3 +import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  4 +import com.ruoyi.domain.RuleNumSetting;
  5 +import com.ruoyi.driver.domain.Driver;
  6 +import com.ruoyi.pojo.dto.AttendanceDto;
  7 +import com.ruoyi.pojo.vo.SchedulingRequestVo;
  8 +import com.ruoyi.pojo.vo.SchedulingResponseVo;
  9 +
  10 +import java.util.List;
  11 +
  12 +/**
  13 +* @author 20412
  14 +* @description 针对表【rule_num_setting(排班设置表)】的数据库操作Mapper
  15 +* @createDate 2023-08-31 09:31:28
  16 +* @Entity .domain.RuleNumSetting
  17 +*/
  18 +public interface RuleNumSettingMapper extends BaseMapper<RuleNumSetting> {
  19 +
  20 + List<SchedulingResponseVo> getSchedulingList(SchedulingRequestVo vo);
  21 +
  22 + /**
  23 + * 获取需要生成排班人员
  24 + * @return
  25 + */
  26 + List<AttendanceDto> getPeopleList();
  27 +}
  28 +
  29 +
  30 +
  31 +
ruoyi-admin/src/main/java/com/ruoyi/mapper/RuleSettingDriverMapper.java 0 → 100644
  1 +package com.ruoyi.mapper;
  2 +
  3 +
  4 +import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  5 +import com.ruoyi.domain.RuleSettingDriver;
  6 +import com.ruoyi.driver.domain.Driver;
  7 +import com.ruoyi.pojo.dto.DriverDto;
  8 +
  9 +import java.util.List;
  10 +
  11 +/**
  12 +* @author 20412
  13 +* @description 针对表【rule_setting_driver(人员信息表与排班设置绑定表)】的数据库操作Mapper
  14 +* @createDate 2023-08-31 14:35:06
  15 +* @Entity .domain.RuleSettingDriver
  16 +*/
  17 +public interface RuleSettingDriverMapper extends BaseMapper<RuleSettingDriver> {
  18 +
  19 + List<DriverDto> queryDriverListBySettingId(List<Integer> list);
  20 +}
  21 +
  22 +
  23 +
  24 +
ruoyi-admin/src/main/java/com/ruoyi/mapper/RuleSettingSchedulingMapper.java 0 → 100644
  1 +package com.ruoyi.mapper;
  2 +
  3 +
  4 +import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  5 +import com.ruoyi.domain.RuleSettingScheduling;
  6 +import com.ruoyi.pojo.dto.RuleSchedulingDto;
  7 +import com.ruoyi.scheduling.domain.RuleScheduling;
  8 +
  9 +import java.util.List;
  10 +
  11 +/**
  12 +* @author 20412
  13 +* @description 针对表【rule_setting_scheduling(考勤规则表)】的数据库操作Mapper
  14 +* @createDate 2023-08-31 14:35:06
  15 +* @Entity .domain.RuleSettingScheduling
  16 +*/
  17 +public interface RuleSettingSchedulingMapper extends BaseMapper<RuleSettingScheduling> {
  18 +
  19 + List<RuleSchedulingDto> querySchedulingListBySettingId(List<Integer> list);
  20 +}
  21 +
  22 +
  23 +
  24 +
ruoyi-admin/src/main/java/com/ruoyi/num/controller/RuleNumController.java
@@ -56,6 +56,17 @@ public class RuleNumController extends BaseController @@ -56,6 +56,17 @@ public class RuleNumController extends BaseController
56 return AjaxResult.success(ruleNumService.selectRuleNumList(ruleNum)); 56 return AjaxResult.success(ruleNumService.selectRuleNumList(ruleNum));
57 } 57 }
58 58
  59 + /**
  60 + * 查询班次管理列表
  61 + */
  62 + @PreAuthorize("@ss.hasPermi('num:num:list')")
  63 + @GetMapping("/list/num/{settingId}")
  64 + public AjaxResult getRuleNumBySettingId(@PathVariable("settingId") Integer settingId)
  65 + {
  66 + return AjaxResult.success(ruleNumService.getRuleNumBySettingId(settingId));
  67 + }
  68 +
  69 +
59 70
60 /** 71 /**
61 * 导出班次管理列表 72 * 导出班次管理列表
ruoyi-admin/src/main/java/com/ruoyi/num/domain/RuleNum.java
1 package com.ruoyi.num.domain; 1 package com.ruoyi.num.domain;
2 2
  3 +import lombok.Data;
3 import org.apache.commons.lang3.builder.ToStringBuilder; 4 import org.apache.commons.lang3.builder.ToStringBuilder;
4 import org.apache.commons.lang3.builder.ToStringStyle; 5 import org.apache.commons.lang3.builder.ToStringStyle;
5 import com.ruoyi.common.annotation.Excel; 6 import com.ruoyi.common.annotation.Excel;
@@ -11,6 +12,7 @@ import com.ruoyi.common.core.domain.BaseEntity; @@ -11,6 +12,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
11 * @author guzijian 12 * @author guzijian
12 * @date 2023-08-03 13 * @date 2023-08-03
13 */ 14 */
  15 +@Data
14 public class RuleNum extends BaseEntity 16 public class RuleNum extends BaseEntity
15 { 17 {
16 private static final long serialVersionUID = 1L; 18 private static final long serialVersionUID = 1L;
@@ -24,84 +26,18 @@ public class RuleNum extends BaseEntity @@ -24,84 +26,18 @@ public class RuleNum extends BaseEntity
24 26
25 /** 班次类型 */ 27 /** 班次类型 */
26 @Excel(name = "班次类型") 28 @Excel(name = "班次类型")
27 - private Long ruleType; 29 + private Integer ruleType;
28 30
29 /** 工作天数 */ 31 /** 工作天数 */
30 @Excel(name = "工作天数") 32 @Excel(name = "工作天数")
31 - private Long workDay; 33 + private Integer workDay;
32 34
33 /** 休息天数 */ 35 /** 休息天数 */
34 @Excel(name = "休息天数") 36 @Excel(name = "休息天数")
35 - private Long freeDay; 37 + private Integer freeDay;
36 38
37 /** 星期翻班详情 */ 39 /** 星期翻班详情 */
38 @Excel(name = "星期翻班详情") 40 @Excel(name = "星期翻班详情")
39 private String ruleWeek; 41 private String ruleWeek;
40 42
41 - public void setId(Long id)  
42 - {  
43 - this.id = id;  
44 - }  
45 -  
46 - public Long getId()  
47 - {  
48 - return id;  
49 - }  
50 - public void setRuleDictName(String ruleDictName)  
51 - {  
52 - this.ruleDictName = ruleDictName;  
53 - }  
54 -  
55 - public String getRuleDictName()  
56 - {  
57 - return ruleDictName;  
58 - }  
59 - public void setRuleType(Long ruleType)  
60 - {  
61 - this.ruleType = ruleType;  
62 - }  
63 -  
64 - public Long getRuleType()  
65 - {  
66 - return ruleType;  
67 - }  
68 - public void setWorkDay(Long workDay)  
69 - {  
70 - this.workDay = workDay;  
71 - }  
72 -  
73 - public Long getWorkDay()  
74 - {  
75 - return workDay;  
76 - }  
77 - public void setFreeDay(Long freeDay)  
78 - {  
79 - this.freeDay = freeDay;  
80 - }  
81 -  
82 - public Long getFreeDay()  
83 - {  
84 - return freeDay;  
85 - }  
86 - public void setRuleWeek(String ruleWeek)  
87 - {  
88 - this.ruleWeek = ruleWeek;  
89 - }  
90 -  
91 - public String getRuleWeek()  
92 - {  
93 - return ruleWeek;  
94 - }  
95 -  
96 - @Override  
97 - public String toString() {  
98 - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)  
99 - .append("id", getId())  
100 - .append("ruleDictName", getRuleDictName())  
101 - .append("ruleType", getRuleType())  
102 - .append("workDay", getWorkDay())  
103 - .append("freeDay", getFreeDay())  
104 - .append("ruleWeek", getRuleWeek())  
105 - .toString();  
106 - }  
107 } 43 }
ruoyi-admin/src/main/java/com/ruoyi/num/mapper/RuleNumMapper.java
@@ -2,6 +2,8 @@ package com.ruoyi.num.mapper; @@ -2,6 +2,8 @@ package com.ruoyi.num.mapper;
2 2
3 import java.util.List; 3 import java.util.List;
4 import com.ruoyi.num.domain.RuleNum; 4 import com.ruoyi.num.domain.RuleNum;
  5 +import com.ruoyi.pojo.dto.RuleNumDto;
  6 +import org.apache.ibatis.annotations.Param;
5 7
6 /** 8 /**
7 * 班次管理Mapper接口 9 * 班次管理Mapper接口
@@ -58,4 +60,13 @@ public interface RuleNumMapper @@ -58,4 +60,13 @@ public interface RuleNumMapper
58 * @return 结果 60 * @return 结果
59 */ 61 */
60 public int deleteRuleNumByIds(Long[] ids); 62 public int deleteRuleNumByIds(Long[] ids);
  63 +
  64 + /**
  65 + * 根据排班设置id获取当前班次
  66 + * @param settingId
  67 + * @return
  68 + */
  69 + RuleNum listNumBySettingId(@Param("id") Integer settingId);
  70 +
  71 + List<RuleNumDto> selectRuleNumBySettingId(List<Integer> list);
61 } 72 }
ruoyi-admin/src/main/java/com/ruoyi/num/service/IRuleNumService.java
@@ -2,6 +2,9 @@ package com.ruoyi.num.service; @@ -2,6 +2,9 @@ package com.ruoyi.num.service;
2 2
3 import java.util.List; 3 import java.util.List;
4 import com.ruoyi.num.domain.RuleNum; 4 import com.ruoyi.num.domain.RuleNum;
  5 +import com.ruoyi.pojo.dto.RuleNumDto;
  6 +import com.ruoyi.pojo.vo.RuleNumTemplateVo;
  7 +import com.ruoyi.pojo.vo.RuleNumVo;
5 8
6 /** 9 /**
7 * 班次管理Service接口 10 * 班次管理Service接口
@@ -58,4 +61,13 @@ public interface IRuleNumService @@ -58,4 +61,13 @@ public interface IRuleNumService
58 * @return 结果 61 * @return 结果
59 */ 62 */
60 public int deleteRuleNumById(Long id); 63 public int deleteRuleNumById(Long id);
  64 +
  65 + RuleNumVo getRuleNumBySettingId(Integer settingId);
  66 +
  67 + /**
  68 + * 查询班次
  69 + * @param settingList
  70 + * @return
  71 + */
  72 + List<RuleNumDto> selectRuleNumBySettingId(List<Integer> settingList);
61 } 73 }
ruoyi-admin/src/main/java/com/ruoyi/num/service/impl/RuleNumServiceImpl.java
1 package com.ruoyi.num.service.impl; 1 package com.ruoyi.num.service.impl;
2 2
  3 +import java.util.ArrayList;
3 import java.util.List; 4 import java.util.List;
  5 +import java.util.Map;
  6 +import java.util.Objects;
  7 +import java.util.stream.Collectors;
  8 +import java.util.stream.Stream;
  9 +
  10 +import cn.hutool.core.bean.BeanUtil;
4 import com.ruoyi.common.utils.SecurityUtils; 11 import com.ruoyi.common.utils.SecurityUtils;
  12 +import com.ruoyi.pojo.dto.RuleNumDto;
  13 +import com.ruoyi.pojo.vo.RuleNumTemplateVo;
  14 +import com.ruoyi.pojo.vo.RuleNumVo;
5 import org.springframework.beans.factory.annotation.Autowired; 15 import org.springframework.beans.factory.annotation.Autowired;
6 import org.springframework.stereotype.Service; 16 import org.springframework.stereotype.Service;
7 import com.ruoyi.num.mapper.RuleNumMapper; 17 import com.ruoyi.num.mapper.RuleNumMapper;
8 import com.ruoyi.num.domain.RuleNum; 18 import com.ruoyi.num.domain.RuleNum;
9 import com.ruoyi.num.service.IRuleNumService; 19 import com.ruoyi.num.service.IRuleNumService;
10 20
  21 +import static com.ruoyi.common.RuleSchedulingProperties.*;
  22 +
11 /** 23 /**
12 * 班次管理Service业务层处理 24 * 班次管理Service业务层处理
13 * 25 *
@@ -91,4 +103,58 @@ public class RuleNumServiceImpl implements IRuleNumService @@ -91,4 +103,58 @@ public class RuleNumServiceImpl implements IRuleNumService
91 { 103 {
92 return ruleNumMapper.deleteRuleNumById(id); 104 return ruleNumMapper.deleteRuleNumById(id);
93 } 105 }
  106 +
  107 + @Override
  108 + public RuleNumVo getRuleNumBySettingId(Integer settingId) {
  109 + RuleNum ruleNum = ruleNumMapper.listNumBySettingId(settingId);
  110 + RuleNumVo vo = new RuleNumVo();
  111 + BeanUtil.copyProperties(ruleNum,vo);
  112 + // 当为固定规则时
  113 + if (RULE_TYPE_FIXED.equals(ruleNum.getRuleType())) {
  114 + vo.setTemplateVos(handleFixedTemplate(ruleNum));
  115 + }
  116 + // 处理按星期
  117 + else {
  118 + vo.setTemplateVos(handleWeekTemplate(ruleNum));
  119 + }
  120 + // 模板
  121 + return vo;
  122 + }
  123 +
  124 + @Override
  125 + public List<RuleNumDto> selectRuleNumBySettingId(List<Integer> settingList) {
  126 + return ruleNumMapper.selectRuleNumBySettingId(settingList);
  127 + }
  128 +
  129 + private List<RuleNumTemplateVo> handleWeekTemplate(RuleNum ruleNum) {
  130 + String[] strings = ruleNum.getRuleWeek().split(",");
  131 + Map<Integer, Integer> weeks = Stream.of(strings).collect(Collectors.toMap(s -> Integer.parseInt(s), s -> Integer.parseInt(s)));
  132 + List<RuleNumTemplateVo> vos = new ArrayList<>(7);
  133 + for (int i = 1; i <= 7; i++) {
  134 + Integer integer = weeks.get(i);
  135 + if (Objects.isNull(integer)) {
  136 + vos.add(getRuleNumTemplateVo(i, false));
  137 + } else {
  138 + vos.add(getRuleNumTemplateVo(integer, true));
  139 + }
  140 + }
  141 + return vos;
  142 + }
  143 +
  144 + private RuleNumTemplateVo getRuleNumTemplateVo(Integer serialNumber, Boolean workFlag) {
  145 + RuleNumTemplateVo vo = new RuleNumTemplateVo();
  146 + vo.setSerialNumber(serialNumber);
  147 + vo.setType(workFlag ? WORK_FLAG : FREE_FLAG);
  148 + return vo;
  149 + }
  150 +
  151 +
  152 + private List<RuleNumTemplateVo> handleFixedTemplate(RuleNum ruleNum) {
  153 + int countDay = ruleNum.getWorkDay() + ruleNum.getFreeDay();
  154 + List<RuleNumTemplateVo> vos = new ArrayList<>(countDay);
  155 + for (int i = 1; i <= countDay; i++) {
  156 + vos.add(getRuleNumTemplateVo(i, i <= ruleNum.getWorkDay()));
  157 + }
  158 + return vos;
  159 + }
94 } 160 }
ruoyi-admin/src/main/java/com/ruoyi/pojo/dto/AttendanceDto.java 0 → 100644
  1 +package com.ruoyi.pojo.dto;
  2 +
  3 +import com.ruoyi.scheduling.domain.RuleScheduling;
  4 +import lombok.Data;
  5 +
  6 +import java.util.Date;
  7 +import java.util.List;
  8 +
  9 +/**
  10 + * @author 20412
  11 + */
  12 +@Data
  13 +public class AttendanceDto {
  14 + private String name;
  15 + private String jobCode;
  16 + private List<RuleScheduling> ruleList;
  17 + private Integer settingId;
  18 + private Date startDate;
  19 + private String posts;
  20 +}
ruoyi-admin/src/main/java/com/ruoyi/pojo/dto/DriverDto.java 0 → 100644
  1 +package com.ruoyi.pojo.dto;
  2 +
  3 +import com.ruoyi.driver.domain.Driver;
  4 +import lombok.Data;
  5 +
  6 +/**
  7 + * @author 20412
  8 + */
  9 +@Data
  10 +public class DriverDto extends Driver {
  11 + private Integer settingId;
  12 +}
ruoyi-admin/src/main/java/com/ruoyi/pojo/dto/RuleNumDto.java 0 → 100644
  1 +package com.ruoyi.pojo.dto;
  2 +
  3 +import com.ruoyi.num.domain.RuleNum;
  4 +import lombok.Data;
  5 +
  6 +/**
  7 + *
  8 + * @author 20412
  9 + */
  10 +@Data
  11 +public class RuleNumDto extends RuleNum {
  12 + private Integer settingId;
  13 +}
ruoyi-admin/src/main/java/com/ruoyi/pojo/dto/RuleSchedulingDto.java 0 → 100644
  1 +package com.ruoyi.pojo.dto;
  2 +
  3 +import com.ruoyi.scheduling.domain.RuleScheduling;
  4 +import lombok.Data;
  5 +
  6 +/**
  7 + * @author 20412
  8 + */
  9 +@Data
  10 +public class RuleSchedulingDto extends RuleScheduling {
  11 + private Integer settingId;
  12 + private Integer sort;
  13 +}
ruoyi-admin/src/main/java/com/ruoyi/pojo/dto/SchedulingDto.java 0 → 100644
  1 +package com.ruoyi.pojo.dto;
  2 +
  3 +import com.ruoyi.domain.RuleSettingDriver;
  4 +import com.ruoyi.domain.RuleSettingScheduling;
  5 +import lombok.Data;
  6 +
  7 +import javax.validation.constraints.NotBlank;
  8 +import javax.validation.constraints.NotEmpty;
  9 +import javax.validation.constraints.NotNull;
  10 +import java.util.List;
  11 +
  12 +/**
  13 + * 修改排班设置表dto
  14 + * @author 20412
  15 + */
  16 +@Data
  17 +public class SchedulingDto {
  18 +
  19 + @NotNull(message = "设置表id不能为空")
  20 + private Integer id;
  21 +
  22 + @NotNull(message = "班次id不能为空")
  23 + private Integer ruleNumId;
  24 +
  25 + @NotBlank(message = "班次名称不能为空")
  26 + private String ruleDictName;
  27 +
  28 + @NotEmpty(message = "规则集合不能为空")
  29 + private List<RuleSettingScheduling> ruleSchedulingList;
  30 +
  31 + private List<RuleSettingDriver> peopleList;
  32 +}
ruoyi-admin/src/main/java/com/ruoyi/pojo/dto/SchedulingSettingDto.java 0 → 100644
  1 +package com.ruoyi.pojo.dto;
  2 +
  3 +import com.ruoyi.domain.RuleSettingDriver;
  4 +import com.ruoyi.domain.RuleSettingScheduling;
  5 +import com.ruoyi.scheduling.domain.RuleScheduling;
  6 +import lombok.Data;
  7 +
  8 +import javax.validation.constraints.NotBlank;
  9 +import javax.validation.constraints.NotEmpty;
  10 +import javax.validation.constraints.NotNull;
  11 +import java.util.List;
  12 +
  13 +/**
  14 + * @author 20412
  15 + */
  16 +@Data
  17 +public class SchedulingSettingDto {
  18 + /**
  19 + * 班次
  20 + */
  21 + @NotNull
  22 + private Integer ruleNumId;
  23 + /**
  24 + * 班次名称
  25 + */
  26 + @NotBlank
  27 + private String ruleDictName;
  28 + /**
  29 + * 规则集合
  30 + */
  31 + @NotEmpty
  32 + private List<RuleSettingScheduling> ruleSchedulingList;
  33 + /**
  34 + * 绑定人员集合
  35 + */
  36 + private List<RuleSettingDriver> peopleList;
  37 +}
ruoyi-admin/src/main/java/com/ruoyi/pojo/vo/PeopleResponseVo.java
@@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModel; @@ -4,6 +4,8 @@ import io.swagger.annotations.ApiModel;
4 import io.swagger.annotations.ApiModelProperty; 4 import io.swagger.annotations.ApiModelProperty;
5 import lombok.Data; 5 import lombok.Data;
6 6
  7 +import java.util.Date;
  8 +
7 /** 9 /**
8 * @author 20412 10 * @author 20412
9 */ 11 */
@@ -18,4 +20,6 @@ public class PeopleResponseVo { @@ -18,4 +20,6 @@ public class PeopleResponseVo {
18 private String posts; 20 private String posts;
19 @ApiModelProperty("部门") 21 @ApiModelProperty("部门")
20 private String fleetName; 22 private String fleetName;
  23 + @ApiModelProperty("开始时间")
  24 + private Date startDate;
21 } 25 }
ruoyi-admin/src/main/java/com/ruoyi/pojo/vo/RuleAttendanceMainRequestVo.java 0 → 100644
  1 +package com.ruoyi.pojo.vo;
  2 +
  3 +import lombok.Data;
  4 +
  5 +/**
  6 + * @author 20412
  7 + */
  8 +@Data
  9 +public class RuleAttendanceMainRequestVo {
  10 + private String jocCode;
  11 + private String date;
  12 + private String name;
  13 +}
ruoyi-admin/src/main/java/com/ruoyi/pojo/vo/RuleNumTemplateVo.java 0 → 100644
  1 +package com.ruoyi.pojo.vo;
  2 +
  3 +import io.swagger.annotations.ApiModel;
  4 +import io.swagger.annotations.ApiModelProperty;
  5 +import lombok.Data;
  6 +
  7 +/**
  8 + * 班次模板
  9 + * @author 20412
  10 + */
  11 +@Data
  12 +@ApiModel("班次模板")
  13 +public class RuleNumTemplateVo {
  14 + /**
  15 + * 休息还是上班 0 休息 1 上班
  16 + */
  17 + @ApiModelProperty("休息还是上班 (0 休息 1 上班)")
  18 + private Integer type;
  19 +
  20 + @ApiModelProperty("序号")
  21 + private Integer serialNumber;
  22 +}
ruoyi-admin/src/main/java/com/ruoyi/pojo/vo/RuleNumVo.java 0 → 100644
  1 +package com.ruoyi.pojo.vo;
  2 +
  3 +import com.ruoyi.num.domain.RuleNum;
  4 +import lombok.Data;
  5 +
  6 +import java.util.List;
  7 +
  8 +/**
  9 + * @author 20412
  10 + */
  11 +@Data
  12 +public class RuleNumVo extends RuleNum {
  13 + /**
  14 + * 模板
  15 + */
  16 + private List<RuleNumTemplateVo> templateVos;
  17 +}
ruoyi-admin/src/main/java/com/ruoyi/pojo/vo/SchedulingRequestVo.java
@@ -12,15 +12,19 @@ import java.util.List; @@ -12,15 +12,19 @@ import java.util.List;
12 @Data 12 @Data
13 @ApiModel("排班规则请求vo") 13 @ApiModel("排班规则请求vo")
14 public class SchedulingRequestVo { 14 public class SchedulingRequestVo {
  15 + /**
  16 + * 主键
  17 + */
15 @ApiModelProperty("id") 18 @ApiModelProperty("id")
16 private Long id; 19 private Long id;
17 - @ApiModelProperty("规则名字")  
18 - private String matchName; 20 + /**
  21 + * 班次名称
  22 + */
19 @ApiModelProperty("班次名称") 23 @ApiModelProperty("班次名称")
20 private String ruleDictName; 24 private String ruleDictName;
21 - @ApiModelProperty("班次类型")  
22 - private Integer ruleType;  
23 -  
24 - private Integer pageNum;  
25 - private Integer pageSize; 25 + /**
  26 + * 工号
  27 + */
  28 + @ApiModelProperty("工号")
  29 + private String jobCode;
26 } 30 }
ruoyi-admin/src/main/java/com/ruoyi/pojo/vo/SchedulingResponseVo.java
1 package com.ruoyi.pojo.vo; 1 package com.ruoyi.pojo.vo;
2 2
  3 +import com.ruoyi.domain.RuleNumSetting;
3 import io.swagger.annotations.ApiModelProperty; 4 import io.swagger.annotations.ApiModelProperty;
4 import lombok.Data; 5 import lombok.Data;
5 6
@@ -9,10 +10,8 @@ import java.util.List; @@ -9,10 +10,8 @@ import java.util.List;
9 * @author 20412 10 * @author 20412
10 */ 11 */
11 @Data 12 @Data
12 -public class SchedulingResponseVo { 13 +public class SchedulingResponseVo extends RuleNumSetting {
13 14
14 - @ApiModelProperty("规则名字")  
15 - private String matchName;  
16 @ApiModelProperty("班次名称") 15 @ApiModelProperty("班次名称")
17 private String ruleDictName; 16 private String ruleDictName;
18 @ApiModelProperty("班次类型") 17 @ApiModelProperty("班次类型")
ruoyi-admin/src/main/java/com/ruoyi/pojo/vo/UpdateAttendanceVo.java 0 → 100644
  1 +package com.ruoyi.pojo.vo;
  2 +
  3 +import com.ruoyi.scheduling.domain.RuleScheduling;
  4 +import lombok.Data;
  5 +
  6 +import javax.validation.constraints.NotNull;
  7 +import java.util.List;
  8 +
  9 +/**
  10 + * @author 20412
  11 + */
  12 +@Data
  13 +public class UpdateAttendanceVo {
  14 + @NotNull
  15 + private Integer id;
  16 + @NotNull
  17 + private Integer ruleId;
  18 +}
ruoyi-admin/src/main/java/com/ruoyi/scheduling/controller/RuleSchedulingController.java
@@ -60,6 +60,17 @@ public class RuleSchedulingController extends BaseController @@ -60,6 +60,17 @@ public class RuleSchedulingController extends BaseController
60 } 60 }
61 61
62 /** 62 /**
  63 + * 查询排版规则列表
  64 + */
  65 + @PreAuthorize("@ss.hasPermi('scheduling:scheduling:list')")
  66 + @GetMapping("/list/scheduling/{settingId}")
  67 + public AjaxResult getRuleSchedulingListVoBySettingId(@PathVariable("settingId") Integer settingId)
  68 + {
  69 + return AjaxResult.success(ruleSchedulingService.selectRuleSchedulingListVoBySettingId(settingId));
  70 + }
  71 +
  72 +
  73 + /**
63 * 导出排版规则列表 74 * 导出排版规则列表
64 */ 75 */
65 @PreAuthorize("@ss.hasPermi('scheduling:scheduling:export')") 76 @PreAuthorize("@ss.hasPermi('scheduling:scheduling:export')")
ruoyi-admin/src/main/java/com/ruoyi/scheduling/mapper/RuleSchedulingMapper.java
1 package com.ruoyi.scheduling.mapper; 1 package com.ruoyi.scheduling.mapper;
2 2
3 import java.util.List; 3 import java.util.List;
  4 +
  5 +import com.ruoyi.pojo.dto.RuleSchedulingDto;
4 import com.ruoyi.scheduling.domain.RuleScheduling; 6 import com.ruoyi.scheduling.domain.RuleScheduling;
  7 +import org.apache.ibatis.annotations.Param;
5 8
6 /** 9 /**
7 * 排版规则Mapper接口 10 * 排版规则Mapper接口
@@ -58,4 +61,13 @@ public interface RuleSchedulingMapper @@ -58,4 +61,13 @@ public interface RuleSchedulingMapper
58 * @return 结果 61 * @return 结果
59 */ 62 */
60 public int deleteRuleSchedulingByIds(Long[] ids); 63 public int deleteRuleSchedulingByIds(Long[] ids);
  64 +
  65 + /**
  66 + * 根据设置表id返回排班规则
  67 + * @param settingId
  68 + * @return
  69 + */
  70 + List<RuleScheduling> selectRuleSchedulingListVoBySettingId(@Param("settingId") Integer settingId);
  71 +
  72 + List<RuleSchedulingDto> selectRuleSchedulingListVoBySettingIds(List<Integer> list);
61 } 73 }
ruoyi-admin/src/main/java/com/ruoyi/scheduling/service/IRuleSchedulingService.java
@@ -2,6 +2,7 @@ package com.ruoyi.scheduling.service; @@ -2,6 +2,7 @@ package com.ruoyi.scheduling.service;
2 2
3 import java.util.List; 3 import java.util.List;
4 4
  5 +import com.ruoyi.pojo.dto.RuleSchedulingDto;
5 import com.ruoyi.pojo.vo.RuleSchedulingResponseVo; 6 import com.ruoyi.pojo.vo.RuleSchedulingResponseVo;
6 import com.ruoyi.pojo.vo.RuleSchedulingVo; 7 import com.ruoyi.pojo.vo.RuleSchedulingVo;
7 import com.ruoyi.scheduling.domain.RuleScheduling; 8 import com.ruoyi.scheduling.domain.RuleScheduling;
@@ -65,4 +66,8 @@ public interface IRuleSchedulingService @@ -65,4 +66,8 @@ public interface IRuleSchedulingService
65 List<RuleSchedulingVo> selectRuleSchedulingListVo(RuleScheduling ruleScheduling); 66 List<RuleSchedulingVo> selectRuleSchedulingListVo(RuleScheduling ruleScheduling);
66 67
67 List<RuleSchedulingResponseVo> handleResponseRuleSchedulingList(List<RuleScheduling> list); 68 List<RuleSchedulingResponseVo> handleResponseRuleSchedulingList(List<RuleScheduling> list);
  69 +
  70 + List<RuleSchedulingVo> selectRuleSchedulingListVoBySettingId(Integer settingId);
  71 +
  72 + List<RuleSchedulingDto> selectRuleSchedulingListVoBySettingIds(List<Integer> settingList);
68 } 73 }
ruoyi-admin/src/main/java/com/ruoyi/scheduling/service/impl/RuleSchedulingServiceImpl.java
1 package com.ruoyi.scheduling.service.impl; 1 package com.ruoyi.scheduling.service.impl;
2 2
3 import java.text.SimpleDateFormat; 3 import java.text.SimpleDateFormat;
  4 +import java.util.ArrayList;
4 import java.util.Date; 5 import java.util.Date;
5 import java.util.List; 6 import java.util.List;
6 import java.util.stream.Collectors; 7 import java.util.stream.Collectors;
7 8
8 import cn.hutool.core.collection.CollectionUtil; 9 import cn.hutool.core.collection.CollectionUtil;
  10 +import com.ruoyi.pojo.dto.RuleSchedulingDto;
9 import com.ruoyi.pojo.vo.RuleSchedulingResponseVo; 11 import com.ruoyi.pojo.vo.RuleSchedulingResponseVo;
10 import com.ruoyi.pojo.vo.RuleSchedulingVo; 12 import com.ruoyi.pojo.vo.RuleSchedulingVo;
11 import org.springframework.beans.BeanUtils; 13 import org.springframework.beans.BeanUtils;
@@ -16,6 +18,7 @@ import com.ruoyi.scheduling.domain.RuleScheduling; @@ -16,6 +18,7 @@ import com.ruoyi.scheduling.domain.RuleScheduling;
16 import com.ruoyi.scheduling.service.IRuleSchedulingService; 18 import com.ruoyi.scheduling.service.IRuleSchedulingService;
17 19
18 import static com.ruoyi.common.RuleSchedulingProperties.*; 20 import static com.ruoyi.common.RuleSchedulingProperties.*;
  21 +import static com.ruoyi.common.WeekEnum.FREE;
19 22
20 /** 23 /**
21 * 排版规则Service业务层处理 24 * 排版规则Service业务层处理
@@ -58,9 +61,21 @@ public class RuleSchedulingServiceImpl implements IRuleSchedulingService { @@ -58,9 +61,21 @@ public class RuleSchedulingServiceImpl implements IRuleSchedulingService {
58 */ 61 */
59 @Override 62 @Override
60 public int insertRuleScheduling(RuleScheduling ruleScheduling) { 63 public int insertRuleScheduling(RuleScheduling ruleScheduling) {
  64 + handleNewAddScheduling(ruleScheduling);
61 return ruleSchedulingMapper.insertRuleScheduling(ruleScheduling); 65 return ruleSchedulingMapper.insertRuleScheduling(ruleScheduling);
62 } 66 }
63 67
  68 + private void handleNewAddScheduling(RuleScheduling ruleScheduling) {
  69 + // 如果没有分班则重置第一段后的规则
  70 + if (NO_SEGMENTATION.equals(ruleScheduling.getSecondFlag())){
  71 + ruleScheduling.setSecondSignDayTomorrow(null);
  72 + ruleScheduling.setSecondSignInWorkingRange(null);
  73 + ruleScheduling.setSecondWorkSignInTime(null);
  74 + ruleScheduling.setSecondQuittingSignInTime(null);
  75 + ruleScheduling.setSecondSignInQuittingRange(null);
  76 + }
  77 + }
  78 +
64 /** 79 /**
65 * 修改排版规则 80 * 修改排版规则
66 * 81 *
@@ -69,6 +84,7 @@ public class RuleSchedulingServiceImpl implements IRuleSchedulingService { @@ -69,6 +84,7 @@ public class RuleSchedulingServiceImpl implements IRuleSchedulingService {
69 */ 84 */
70 @Override 85 @Override
71 public int updateRuleScheduling(RuleScheduling ruleScheduling) { 86 public int updateRuleScheduling(RuleScheduling ruleScheduling) {
  87 + handleNewAddScheduling(ruleScheduling);
72 return ruleSchedulingMapper.updateRuleScheduling(ruleScheduling); 88 return ruleSchedulingMapper.updateRuleScheduling(ruleScheduling);
73 } 89 }
74 90
@@ -103,16 +119,30 @@ public class RuleSchedulingServiceImpl implements IRuleSchedulingService { @@ -103,16 +119,30 @@ public class RuleSchedulingServiceImpl implements IRuleSchedulingService {
103 @Override 119 @Override
104 public List<RuleSchedulingResponseVo> handleResponseRuleSchedulingList(List<RuleScheduling> list) { 120 public List<RuleSchedulingResponseVo> handleResponseRuleSchedulingList(List<RuleScheduling> list) {
105 return list.stream() 121 return list.stream()
106 - .map(item ->{ 122 + .map(item -> {
107 RuleSchedulingResponseVo vo = new RuleSchedulingResponseVo(); 123 RuleSchedulingResponseVo vo = new RuleSchedulingResponseVo();
108 - BeanUtils.copyProperties(item,vo); 124 + BeanUtils.copyProperties(item, vo);
109 vo.setRangeTime(handleRuleSchedulingRangeTime(item)); 125 vo.setRangeTime(handleRuleSchedulingRangeTime(item));
110 return vo; 126 return vo;
111 }) 127 })
112 .collect(Collectors.toList()); 128 .collect(Collectors.toList());
113 } 129 }
114 130
115 - private List<RuleSchedulingVo> handleRuleScheduling(List<RuleScheduling> list) { 131 + @Override
  132 + public List<RuleSchedulingVo> selectRuleSchedulingListVoBySettingId(Integer settingId) {
  133 + List<RuleScheduling> list = ruleSchedulingMapper.selectRuleSchedulingListVoBySettingId(settingId);
  134 + return handleRuleScheduling(list);
  135 + }
  136 +
  137 + @Override
  138 + public List<RuleSchedulingDto> selectRuleSchedulingListVoBySettingIds(List<Integer> settingList) {
  139 + if (CollectionUtil.isEmpty(settingList)){
  140 + return new ArrayList<>();
  141 + }
  142 + return ruleSchedulingMapper.selectRuleSchedulingListVoBySettingIds(settingList);
  143 + }
  144 +
  145 + public static List<RuleSchedulingVo> handleRuleScheduling(List<RuleScheduling> list) {
116 if (CollectionUtil.isEmpty(list)) { 146 if (CollectionUtil.isEmpty(list)) {
117 return null; 147 return null;
118 } 148 }
@@ -124,6 +154,9 @@ public class RuleSchedulingServiceImpl implements IRuleSchedulingService { @@ -124,6 +154,9 @@ public class RuleSchedulingServiceImpl implements IRuleSchedulingService {
124 RuleSchedulingVo vo = new RuleSchedulingVo(); 154 RuleSchedulingVo vo = new RuleSchedulingVo();
125 vo.setRuleName(item.getRuleName()); 155 vo.setRuleName(item.getRuleName());
126 vo.setId(item.getId()); 156 vo.setId(item.getId());
  157 + if (item.getRuleName().equals(FREE.getDescription())){
  158 + return vo;
  159 + }
127 vo.setRangeTime(handleRuleSchedulingRangeTime(item)); 160 vo.setRangeTime(handleRuleSchedulingRangeTime(item));
128 return vo; 161 return vo;
129 }) 162 })
@@ -131,7 +164,7 @@ public class RuleSchedulingServiceImpl implements IRuleSchedulingService { @@ -131,7 +164,7 @@ public class RuleSchedulingServiceImpl implements IRuleSchedulingService {
131 164
132 } 165 }
133 166
134 - private String handleRuleSchedulingRangeTime(RuleScheduling item) { 167 + public static String handleRuleSchedulingRangeTime(RuleScheduling item) {
135 // 处理存在分段的数据 168 // 处理存在分段的数据
136 if (HAVE_SEGMENTATION.equals(item.getSecondFlag())) { 169 if (HAVE_SEGMENTATION.equals(item.getSecondFlag())) {
137 return handleSegmentation(item); 170 return handleSegmentation(item);
@@ -142,7 +175,7 @@ public class RuleSchedulingServiceImpl implements IRuleSchedulingService { @@ -142,7 +175,7 @@ public class RuleSchedulingServiceImpl implements IRuleSchedulingService {
142 } 175 }
143 } 176 }
144 177
145 - private String handleNoSegmentation(RuleScheduling item) { 178 + private static String handleNoSegmentation(RuleScheduling item) {
146 // 处理不隔天的情况 179 // 处理不隔天的情况
147 if (TOMORROW_NO.equals(item.getFirstSignInDayTomorrow())) { 180 if (TOMORROW_NO.equals(item.getFirstSignInDayTomorrow())) {
148 return transformTimeType(item.getFirstWorkSignInTime()) + TOMORROW_NO_STRING + transformTimeType(item.getFirstQuittingSignInTime()); 181 return transformTimeType(item.getFirstWorkSignInTime()) + TOMORROW_NO_STRING + transformTimeType(item.getFirstQuittingSignInTime());
@@ -153,14 +186,14 @@ public class RuleSchedulingServiceImpl implements IRuleSchedulingService { @@ -153,14 +186,14 @@ public class RuleSchedulingServiceImpl implements IRuleSchedulingService {
153 } 186 }
154 } 187 }
155 188
156 - private String handleSegmentation(RuleScheduling item) { 189 + private static String handleSegmentation(RuleScheduling item) {
157 // 隔天 190 // 隔天
158 String firstRangeTimeString = handleNoSegmentation(item); 191 String firstRangeTimeString = handleNoSegmentation(item);
159 String secondRangeTimeString = handleHaveSegmentation(item); 192 String secondRangeTimeString = handleHaveSegmentation(item);
160 return firstRangeTimeString + ";" + secondRangeTimeString; 193 return firstRangeTimeString + ";" + secondRangeTimeString;
161 } 194 }
162 195
163 - private String handleHaveSegmentation(RuleScheduling item) { 196 + private static String handleHaveSegmentation(RuleScheduling item) {
164 // 处理不隔天的情况 197 // 处理不隔天的情况
165 if (TOMORROW_NO.equals(item.getSecondSignDayTomorrow())) { 198 if (TOMORROW_NO.equals(item.getSecondSignDayTomorrow())) {
166 return transformTimeType(item.getSecondWorkSignInTime()) + TOMORROW_NO_STRING + transformTimeType(item.getSecondQuittingSignInTime()); 199 return transformTimeType(item.getSecondWorkSignInTime()) + TOMORROW_NO_STRING + transformTimeType(item.getSecondQuittingSignInTime());
@@ -171,7 +204,7 @@ public class RuleSchedulingServiceImpl implements IRuleSchedulingService { @@ -171,7 +204,7 @@ public class RuleSchedulingServiceImpl implements IRuleSchedulingService {
171 } 204 }
172 } 205 }
173 206
174 - private String transformTimeType(Date time) { 207 + private static String transformTimeType(Date time) {
175 SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm"); 208 SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm");
176 return simpleDateFormat.format(time); 209 return simpleDateFormat.format(time);
177 } 210 }
ruoyi-admin/src/main/java/com/ruoyi/service/AttendanceService.java
1 package com.ruoyi.service; 1 package com.ruoyi.service;
2 2
3 -import com.ruoyi.pojo.vo.PeopleResponseVo;  
4 -import com.ruoyi.pojo.vo.SchedulingRequestVo; 3 +import com.ruoyi.domain.RuleAttendanceMain;
  4 +import com.ruoyi.pojo.dto.SchedulingDto;
  5 +import com.ruoyi.pojo.dto.SchedulingSettingDto;
  6 +import com.ruoyi.pojo.vo.*;
5 7
6 import java.util.List; 8 import java.util.List;
7 9
@@ -16,5 +18,39 @@ public interface AttendanceService { @@ -16,5 +18,39 @@ public interface AttendanceService {
16 */ 18 */
17 List<PeopleResponseVo> getDriverInfo(Long id); 19 List<PeopleResponseVo> getDriverInfo(Long id);
18 20
19 - List<SchedulingRequestVo> getSchedulingList(SchedulingRequestVo vo); 21 + /**
  22 + * 获取排班列表
  23 + * @param vo
  24 + * @return
  25 + */
  26 + List<SchedulingResponseVo> getSchedulingList(SchedulingRequestVo vo);
  27 +
  28 + /**
  29 + * 获取班次模板
  30 + * @param id
  31 + * @return
  32 + */
  33 + List<RuleNumTemplateVo> getTemplate(Long id);
  34 +
  35 + /**
  36 + * 新增排班
  37 + * @param dto
  38 + */
  39 + void saveSchedulingSetting(SchedulingSettingDto dto);
  40 +
  41 + /**
  42 + * 修改排班
  43 + * @param dto
  44 + */
  45 + void updateSchedulingSetting(SchedulingDto dto);
  46 +
  47 + /**
  48 + * 删除排班
  49 + * @param settingId
  50 + */
  51 + void deleteSchedulingSetting(Integer settingId);
  52 +
  53 + List<RuleAttendanceMain> queryAttendanceMain(RuleAttendanceMainRequestVo vo);
  54 +
  55 + void updateAttendance(UpdateAttendanceVo vo);
20 } 56 }
ruoyi-admin/src/main/java/com/ruoyi/service/RuleAttendanceMainService.java 0 → 100644
  1 +package com.ruoyi.service;
  2 +
  3 +import com.baomidou.mybatisplus.extension.service.IService;
  4 +import com.ruoyi.domain.RuleAttendanceMain;
  5 +
  6 +/**
  7 +* @author 20412
  8 +* @description 针对表【rule_attendance_main(考勤表)】的数据库操作Service
  9 +* @createDate 2023-09-03 12:15:39
  10 +*/
  11 +public interface RuleAttendanceMainService extends IService<RuleAttendanceMain> {
  12 +
  13 +}
ruoyi-admin/src/main/java/com/ruoyi/service/RuleNumSettingService.java 0 → 100644
  1 +package com.ruoyi.service;
  2 +
  3 +import com.baomidou.mybatisplus.extension.service.IService;
  4 +import com.ruoyi.domain.RuleNumSetting;
  5 +import com.ruoyi.pojo.dto.RuleNumDto;
  6 +import com.ruoyi.pojo.vo.SchedulingRequestVo;
  7 +import com.ruoyi.pojo.vo.SchedulingResponseVo;
  8 +
  9 +import java.util.List;
  10 +
  11 +/**
  12 +* @author 20412
  13 +* @description 针对表【rule_num_setting(排班设置表)】的数据库操作Service
  14 +* @createDate 2023-08-31 09:31:28
  15 +*/
  16 +public interface RuleNumSettingService extends IService<RuleNumSetting> {
  17 +
  18 + /**
  19 + * 查询排班设置表
  20 + * @param vo
  21 + * @return
  22 + */
  23 + List<SchedulingResponseVo> getSchedulingList(SchedulingRequestVo vo);
  24 +
  25 + /**
  26 + * 生成考情表
  27 + */
  28 + void createAttendance();
  29 +
  30 + /**
  31 + * 获取班次根据设置表
  32 + * @param settingList
  33 + * @return
  34 + */
  35 + List<RuleNumDto> selectRuleNumBySettingId(List<Integer> settingList);
  36 +}
ruoyi-admin/src/main/java/com/ruoyi/service/RuleSettingDriverService.java 0 → 100644
  1 +package com.ruoyi.service;
  2 +
  3 +import com.baomidou.mybatisplus.extension.service.IService;
  4 +import com.ruoyi.domain.RuleSettingDriver;
  5 +import com.ruoyi.driver.domain.Driver;
  6 +import com.ruoyi.pojo.dto.DriverDto;
  7 +
  8 +import java.util.List;
  9 +
  10 +/**
  11 +* @author 20412
  12 +* @description 针对表【rule_setting_driver(人员信息表与排班设置绑定表)】的数据库操作Service
  13 +* @createDate 2023-08-31 14:35:06
  14 +*/
  15 +public interface RuleSettingDriverService extends IService<RuleSettingDriver> {
  16 +
  17 + List<DriverDto> queryDriverListBySettingId(List<Integer> settingIdList);
  18 +}
ruoyi-admin/src/main/java/com/ruoyi/service/RuleSettingSchedulingService.java 0 → 100644
  1 +package com.ruoyi.service;
  2 +
  3 +
  4 +import com.baomidou.mybatisplus.extension.service.IService;
  5 +import com.ruoyi.domain.RuleSettingScheduling;
  6 +import com.ruoyi.pojo.dto.RuleSchedulingDto;
  7 +import com.ruoyi.scheduling.domain.RuleScheduling;
  8 +
  9 +import java.util.List;
  10 +
  11 +/**
  12 +* @author 20412
  13 +* @description 针对表【rule_setting_scheduling(考勤规则表)】的数据库操作Service
  14 +* @createDate 2023-08-31 14:35:06
  15 +*/
  16 +public interface RuleSettingSchedulingService extends IService<RuleSettingScheduling> {
  17 +
  18 + List<RuleSchedulingDto> querySchedulingListBySettingId(List<Integer> settingIdList);
  19 +}
ruoyi-admin/src/main/java/com/ruoyi/service/ThreadJobService.java
@@ -39,6 +39,7 @@ import sun.misc.BASE64Decoder; @@ -39,6 +39,7 @@ import sun.misc.BASE64Decoder;
39 39
40 import javax.annotation.Resource; 40 import javax.annotation.Resource;
41 import java.io.*; 41 import java.io.*;
  42 +import java.time.LocalDate;
42 import java.util.*; 43 import java.util.*;
43 import java.util.stream.Collectors; 44 import java.util.stream.Collectors;
44 45
@@ -317,10 +318,20 @@ public class ThreadJobService { @@ -317,10 +318,20 @@ public class ThreadJobService {
317 * 保存当天的调度信息 318 * 保存当天的调度信息
318 * 319 *
319 * @param originSchedulingMap 320 * @param originSchedulingMap
  321 + * @param timeOut
320 */ 322 */
321 @Async 323 @Async
322 @Transactional(rollbackFor = {Exception.class}) 324 @Transactional(rollbackFor = {Exception.class})
323 - public void asyncComputedScheduling(Map<String, List<ResponseSchedulingDto>> originSchedulingMap) { 325 + public void asyncComputedScheduling(Map<String, List<ResponseSchedulingDto>> originSchedulingMap, String timeOut) {
  326 + if (StringUtils.isNotEmpty(timeOut)){
  327 + LocalDate date = LocalDate.now();
  328 + Date date2 = ConstDateUtil.dateAddition(date.toString(), timeOut);
  329 + Date date1 = new Date();
  330 + // 如果当前日期小于设定时间就不获取固定排班
  331 + if (date1.compareTo(date2) < 0){
  332 + return;
  333 + }
  334 + }
324 //查询当天是否保存过考情表 如果不存在则保存 335 //查询当天是否保存过考情表 如果不存在则保存
325 Map<String, List<DriverScheduling>> dto = nowSchedulingCache.getCacheScheduling(ConstDateUtil.formatDate(new Date())); 336 Map<String, List<DriverScheduling>> dto = nowSchedulingCache.getCacheScheduling(ConstDateUtil.formatDate(new Date()));
326 if (!CollectionUtil.isEmpty(dto) || originSchedulingMap.size() == 0) { 337 if (!CollectionUtil.isEmpty(dto) || originSchedulingMap.size() == 0) {
ruoyi-admin/src/main/java/com/ruoyi/service/impl/AttendanceServiceImpl.java
1 package com.ruoyi.service.impl; 1 package com.ruoyi.service.impl;
2 2
3 -import com.github.pagehelper.PageHelper;  
4 -import com.github.pagehelper.PageInfo; 3 +import cn.hutool.core.collection.CollectionUtil;
  4 +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
  5 +import com.ruoyi.common.utils.DateUtils;
5 import com.ruoyi.common.utils.PageUtils; 6 import com.ruoyi.common.utils.PageUtils;
  7 +import com.ruoyi.common.utils.SecurityUtils;
  8 +import com.ruoyi.domain.RuleAttendanceMain;
  9 +import com.ruoyi.domain.RuleNumSetting;
  10 +import com.ruoyi.domain.RuleSettingDriver;
  11 +import com.ruoyi.domain.RuleSettingScheduling;
6 import com.ruoyi.driver.mapper.DriverMapper; 12 import com.ruoyi.driver.mapper.DriverMapper;
7 -import com.ruoyi.pojo.vo.PeopleResponseVo;  
8 -import com.ruoyi.pojo.vo.SchedulingRequestVo;  
9 -import com.ruoyi.service.AttendanceService; 13 +import com.ruoyi.num.domain.RuleNum;
  14 +import com.ruoyi.num.service.IRuleNumService;
  15 +import com.ruoyi.pojo.dto.DriverDto;
  16 +import com.ruoyi.pojo.dto.RuleSchedulingDto;
  17 +import com.ruoyi.pojo.dto.SchedulingDto;
  18 +import com.ruoyi.pojo.dto.SchedulingSettingDto;
  19 +import com.ruoyi.pojo.vo.*;
  20 +import com.ruoyi.scheduling.domain.RuleScheduling;
  21 +import com.ruoyi.scheduling.service.IRuleSchedulingService;
  22 +import com.ruoyi.scheduling.service.impl.RuleSchedulingServiceImpl;
  23 +import com.ruoyi.service.*;
  24 +import com.ruoyi.utils.ConstDateUtil;
  25 +import org.springframework.beans.BeanUtils;
10 import org.springframework.beans.factory.annotation.Autowired; 26 import org.springframework.beans.factory.annotation.Autowired;
  27 +import org.springframework.security.core.parameters.P;
11 import org.springframework.stereotype.Service; 28 import org.springframework.stereotype.Service;
  29 +import org.springframework.transaction.annotation.Transactional;
12 30
13 -import java.util.List; 31 +import java.time.LocalDate;
  32 +import java.util.*;
  33 +import java.util.stream.Collectors;
  34 +import java.util.stream.Stream;
  35 +
  36 +import static com.ruoyi.common.RuleSchedulingProperties.*;
  37 +import static com.ruoyi.common.WeekEnum.FREE;
14 38
15 /** 39 /**
16 * @author 20412 40 * @author 20412
@@ -21,12 +45,28 @@ public class AttendanceServiceImpl implements AttendanceService { @@ -21,12 +45,28 @@ public class AttendanceServiceImpl implements AttendanceService {
21 @Autowired 45 @Autowired
22 private DriverMapper driverMapper; 46 private DriverMapper driverMapper;
23 47
  48 + @Autowired
  49 + private IRuleSchedulingService ruleSchedulingService;
  50 +
  51 + @Autowired
  52 + private RuleNumSettingService ruleNumSettingService;
  53 +
  54 + @Autowired
  55 + private RuleSettingDriverService settingDriverService;
  56 +
  57 + @Autowired
  58 + private RuleSettingSchedulingService settingSchedulingService;
  59 +
  60 + @Autowired
  61 + private RuleAttendanceMainService attendanceMainService;
  62 +
  63 + @Autowired
  64 + private IRuleNumService ruleNumService;
24 65
25 66
26 @Override 67 @Override
27 public List<PeopleResponseVo> getDriverInfo(Long id) { 68 public List<PeopleResponseVo> getDriverInfo(Long id) {
28 - List<PeopleResponseVo> vos ;  
29 - // TODO 待完成 69 + List<PeopleResponseVo> vos;
30 if (id != null) { 70 if (id != null) {
31 vos = driverMapper.queryAttendanceInfoById(id); 71 vos = driverMapper.queryAttendanceInfoById(id);
32 } else { 72 } else {
@@ -37,9 +77,236 @@ public class AttendanceServiceImpl implements AttendanceService { @@ -37,9 +77,236 @@ public class AttendanceServiceImpl implements AttendanceService {
37 } 77 }
38 78
39 @Override 79 @Override
40 - public List<SchedulingRequestVo> getSchedulingList(SchedulingRequestVo vo) { 80 + public List<SchedulingResponseVo> getSchedulingList(SchedulingRequestVo vo) {
  81 + // 查询排班设置表
  82 + PageUtils.startPage();
  83 + List<SchedulingResponseVo> vos = ruleNumSettingService.getSchedulingList(vo);
  84 + if (CollectionUtil.isEmpty(vos)) {
  85 + return vos;
  86 + }
  87 + List<Integer> settingIdList = vos.stream().map(SchedulingResponseVo::getId).collect(Collectors.toList());
  88 + // 查询对应的规则
  89 + List<DriverDto> driverList = settingDriverService.queryDriverListBySettingId(settingIdList);
  90 + List<RuleSchedulingDto> schedulingList = settingSchedulingService.querySchedulingListBySettingId(settingIdList);
  91 + handleSchedulingResponse(vos, driverList, schedulingList);
  92 + return vos;
  93 + }
  94 +
  95 + @Override
  96 + public List<RuleNumTemplateVo> getTemplate(Long id) {
  97 + RuleNum ruleNum = ruleNumService.selectRuleNumById(id);
  98 + if (Objects.isNull(ruleNum)) {
  99 + return null;
  100 + }
  101 + // 当为固定规则时
  102 + if (RULE_TYPE_FIXED.equals(ruleNum.getRuleType())) {
  103 + return handleFixedTemplate(ruleNum);
  104 + }
  105 + // 处理按星期
  106 + else {
  107 + return handleWeekTemplate(ruleNum);
  108 + }
  109 + }
  110 +
  111 + @Override
  112 + @Transactional(rollbackFor = Exception.class)
  113 + public void saveSchedulingSetting(SchedulingSettingDto dto) {
  114 + RuleNumSetting setting = getRuleNumSetting(dto);
  115 + ruleNumSettingService.save(setting);
  116 + List<RuleSettingScheduling> schedulingList = getSettingSchedulingList(dto, setting.getId());
  117 + settingSchedulingService.saveBatch(schedulingList);
  118 + if (CollectionUtil.isNotEmpty(dto.getPeopleList())) {
  119 + List<RuleSettingDriver> peopleList = getSettingDriverList(dto, setting.getId());
  120 + settingDriverService.remove(new QueryWrapper<RuleSettingDriver>().lambda().in(RuleSettingDriver::getJobCode, peopleList.stream().map(RuleSettingDriver::getJobCode).collect(Collectors.toList())));
  121 + settingDriverService.saveBatch(peopleList);
  122 + }
  123 + }
  124 +
  125 + @Override
  126 + @Transactional(rollbackFor = Exception.class)
  127 + public void updateSchedulingSetting(SchedulingDto dto) {
  128 + RuleNumSetting setting = new RuleNumSetting();
  129 + getRumSettingByDto(dto, setting);
  130 + ruleNumSettingService.updateById(setting);
  131 + // 更新规则
  132 + settingSchedulingService.remove(new QueryWrapper<RuleSettingScheduling>().lambda().eq(RuleSettingScheduling::getSettingId, dto.getId()));
  133 + settingSchedulingService.saveBatch(dto.getRuleSchedulingList());
  134 + // 更新人员
  135 + settingDriverService.remove(new QueryWrapper<RuleSettingDriver>()
  136 + .lambda()
  137 + .eq(RuleSettingDriver::getSettingId, dto.getId()));
  138 + settingDriverService.saveBatch(dto.getPeopleList());
  139 + }
  140 +
  141 + @Override
  142 + public void deleteSchedulingSetting(Integer settingId) {
  143 + ruleNumSettingService.removeById(settingId);
  144 + // 更新规则
  145 + settingSchedulingService.remove(new QueryWrapper<RuleSettingScheduling>().lambda().eq(RuleSettingScheduling::getSettingId, settingId));
  146 + // 更新人员
  147 + settingDriverService.remove(new QueryWrapper<RuleSettingDriver>()
  148 + .lambda()
  149 + .eq(RuleSettingDriver::getSettingId, settingId));
  150 + }
  151 +
  152 + @Override
  153 + public List<RuleAttendanceMain> queryAttendanceMain(RuleAttendanceMainRequestVo vo) {
41 PageUtils.startPage(); 154 PageUtils.startPage();
42 -// ruleAttendanceMapper.getSchedulingList(vo);  
43 - return null; 155 + List<RuleAttendanceMain> list = attendanceMainService.list(new QueryWrapper<RuleAttendanceMain>()
  156 + .lambda()
  157 + .eq(RuleAttendanceMain::getSchedulingDate, vo.getDate()));
  158 + return list;
  159 + }
  160 +
  161 + @Override
  162 + public void updateAttendance(UpdateAttendanceVo vo) {
  163 + RuleAttendanceMain main = attendanceMainService.getById(vo.getId());
  164 + RuleScheduling ruleScheduling = ruleSchedulingService.selectRuleSchedulingById(vo.getId().longValue());
  165 + BeanUtils.copyProperties(ruleScheduling,main);
  166 + main.setFirstWorkSignInTime(ConstDateUtil.dateAddition(LocalDate.now().toString(), ConstDateUtil.formatDate("HH:mm:ss", main.getFirstWorkSignInTime())));
  167 + if (HAVE_SEGMENTATION.equals(ruleScheduling.getSecondFlag())){
  168 + main.setFirstQuittingSignInTime(ConstDateUtil.dateAddition(LocalDate.now().toString(), ConstDateUtil.formatDate("HH:mm:ss", main.getFirstQuittingSignInTime())));
  169 + main.setSecondWorkSignInTime(ConstDateUtil.dateAddition(LocalDate.now().toString(), ConstDateUtil.formatDate("HH:mm:ss", main.getSecondWorkSignInTime())));
  170 + // 处理隔天
  171 + if (TOMORROW_YES.equals(ruleScheduling.getFirstSignInDayTomorrow())){
  172 + main.setSecondQuittingSignInTime( ConstDateUtil.dateAddition(LocalDate.now().plusDays(1).toString(), ConstDateUtil.formatDate("HH:mm:ss", main.getFirstQuittingSignInTime())));
  173 + }
  174 + }else {
  175 +
  176 + // 处理隔天
  177 + if (TOMORROW_YES.equals(ruleScheduling.getFirstSignInDayTomorrow())){
  178 + main.setFirstQuittingSignInTime( ConstDateUtil.dateAddition(LocalDate.now().plusDays(1).toString(), ConstDateUtil.formatDate("HH:mm:ss", main.getFirstQuittingSignInTime())));
  179 + }
  180 + }
  181 + }
  182 +
  183 + private static void getRumSettingByDto(SchedulingDto dto, RuleNumSetting setting) {
  184 + setting.setId(dto.getId());
  185 + setting.setUpdateTime(DateUtils.getNowDate());
  186 + setting.setUpdateBy(SecurityUtils.getUsername());
  187 + setting.setRuleNumId(dto.getRuleNumId());
  188 + setting.setRuleDictName(dto.getRuleDictName());
  189 + }
  190 +
  191 + private List<RuleSettingDriver> getSettingDriverList(SchedulingSettingDto dto, Integer id) {
  192 + return dto
  193 + .getPeopleList()
  194 + .stream()
  195 + .map(item -> {
  196 + RuleSettingDriver driver = new RuleSettingDriver();
  197 + driver.setSettingId(id);
  198 + driver.setJobCode(item.getJobCode());
  199 + if (item.getStartDate() == null) {
  200 + throw new RuntimeException("非法开始时间");
  201 + }
  202 + driver.setStartDate(item.getStartDate());
  203 + return driver;
  204 + })
  205 + .collect(Collectors.toList());
  206 + }
  207 +
  208 + private List<RuleSettingScheduling> getSettingSchedulingList(SchedulingSettingDto dto, Integer id) {
  209 + // TODO 规则校验
  210 + return dto.getRuleSchedulingList().stream().peek(item -> {
  211 + item.setSettingId(id);
  212 + }).collect(Collectors.toList());
  213 + }
  214 +
  215 + private static RuleNumSetting getRuleNumSetting(SchedulingSettingDto dto) {
  216 + RuleNumSetting setting = new RuleNumSetting();
  217 + setting.setCreateTime(DateUtils.getNowDate());
  218 + setting.setUpdateTime(DateUtils.getNowDate());
  219 + String username = SecurityUtils.getUsername();
  220 + setting.setCreateBy(username);
  221 + setting.setUpdateBy(username);
  222 + setting.setRuleDictName(dto.getRuleDictName());
  223 + setting.setRuleNumId(dto.getRuleNumId());
  224 + return setting;
  225 + }
  226 +
  227 + private List<RuleNumTemplateVo> handleWeekTemplate(RuleNum ruleNum) {
  228 + String[] strings = ruleNum.getRuleWeek().split(",");
  229 + Map<Integer, Integer> weeks = Stream.of(strings).collect(Collectors.toMap(s -> Integer.parseInt(s), s -> Integer.parseInt(s)));
  230 + List<RuleNumTemplateVo> vos = new ArrayList<>(7);
  231 + for (int i = 1; i <= 7; i++) {
  232 + Integer integer = weeks.get(i);
  233 + if (Objects.isNull(integer)) {
  234 + vos.add(getRuleNumTemplateVo(i, false));
  235 + } else {
  236 + vos.add(getRuleNumTemplateVo(integer, true));
  237 + }
  238 + }
  239 + return vos;
  240 + }
  241 +
  242 + private List<RuleNumTemplateVo> handleFixedTemplate(RuleNum ruleNum) {
  243 + int countDay = ruleNum.getWorkDay() + ruleNum.getFreeDay();
  244 + List<RuleNumTemplateVo> vos = new ArrayList<>(countDay);
  245 + for (int i = 1; i <= countDay; i++) {
  246 + vos.add(getRuleNumTemplateVo(i, i <= ruleNum.getWorkDay()));
  247 + }
  248 + return vos;
  249 + }
  250 +
  251 + private RuleNumTemplateVo getRuleNumTemplateVo(Integer serialNumber, Boolean workFlag) {
  252 + RuleNumTemplateVo vo = new RuleNumTemplateVo();
  253 + vo.setSerialNumber(serialNumber);
  254 + vo.setType(workFlag ? WORK_FLAG : FREE_FLAG);
  255 + return vo;
  256 + }
  257 +
  258 + private void handleSchedulingResponse(List<SchedulingResponseVo> vos, List<DriverDto> driverList, List<RuleSchedulingDto> schedulingList) {
  259 + Map<Integer, List<DriverDto>> driverMap = transFromMapByDriver(driverList);
  260 + Map<Integer, List<RuleScheduling>> schedulingMap = transFromMapByScheduling(schedulingList);
  261 + for (SchedulingResponseVo vo : vos) {
  262 + vo.setPeopleList(handlePeopleList(vo.getId(), driverMap.get(vo.getId())));
  263 + vo.setRuleList(handleRuleList(vo.getId(), schedulingMap.get(vo.getId())));
  264 + }
  265 + }
  266 +
  267 + private Map<Integer, List<RuleScheduling>> transFromMapByScheduling(List<RuleSchedulingDto> schedulingList) {
  268 + Map<Integer, List<RuleScheduling>> map = new HashMap<>(16);
  269 + for (RuleSchedulingDto scheduling : schedulingList) {
  270 + List<RuleScheduling> list = map.get(scheduling.getSettingId());
  271 + if (CollectionUtil.isEmpty(list)) {
  272 + map.put(scheduling.getSettingId(), new ArrayList<>(Arrays.asList(scheduling)));
  273 + } else {
  274 + list.add(scheduling);
  275 + }
  276 + }
  277 + return map;
  278 + }
  279 +
  280 + private Map<Integer, List<DriverDto>> transFromMapByDriver(List<DriverDto> driverList) {
  281 + Map<Integer, List<DriverDto>> map = new HashMap<>(16);
  282 + for (DriverDto driver : driverList) {
  283 + List<DriverDto> list = map.get(driver.getSettingId());
  284 + if (CollectionUtil.isEmpty(list)) {
  285 + map.put(driver.getSettingId(), new ArrayList<>(Arrays.asList(driver)));
  286 + } else {
  287 + list.add(driver);
  288 + }
  289 + }
  290 + return map;
  291 + }
  292 +
  293 + private List<String> handleRuleList(Integer id, List<RuleScheduling> schedulingList) {
  294 + List<RuleSchedulingVo> list = RuleSchedulingServiceImpl.handleRuleScheduling(schedulingList);
  295 + if (CollectionUtil.isEmpty(list)) {
  296 + return new ArrayList<>();
  297 + }
  298 + return list.stream().map(item -> {
  299 + if (item.getRuleName().equals(FREE.getDescription())) {
  300 + return item.getRuleName();
  301 + }
  302 + return item.getRuleName() + "(" + item.getRangeTime() + ")";
  303 + }).collect(Collectors.toList());
  304 + }
  305 +
  306 + private List<String> handlePeopleList(Integer id, List<DriverDto> driverList) {
  307 + if (CollectionUtil.isEmpty(driverList)) {
  308 + return new ArrayList<>();
  309 + }
  310 + return driverList.stream().map(item -> item.getPersonnelName() + "(" + item.getJobCode() + ")").collect(Collectors.toList());
44 } 311 }
45 } 312 }
ruoyi-admin/src/main/java/com/ruoyi/service/impl/RuleAttendanceMainServiceImpl.java 0 → 100644
  1 +package com.ruoyi.service.impl;
  2 +
  3 +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  4 +import com.ruoyi.domain.RuleAttendanceMain;
  5 +import com.ruoyi.mapper.RuleAttendanceMainMapper;
  6 +import com.ruoyi.service.RuleAttendanceMainService;
  7 +import org.springframework.stereotype.Service;
  8 +
  9 +/**
  10 +* @author 20412
  11 +* @description 针对表【rule_attendance_main(考勤表)】的数据库操作Service实现
  12 +* @createDate 2023-09-03 12:15:39
  13 +*/
  14 +@Service
  15 +public class RuleAttendanceMainServiceImpl extends ServiceImpl<RuleAttendanceMainMapper, RuleAttendanceMain>
  16 + implements RuleAttendanceMainService {
  17 +
  18 +}
  19 +
  20 +
  21 +
  22 +
ruoyi-admin/src/main/java/com/ruoyi/service/impl/RuleNumSettingServiceImpl.java 0 → 100644
  1 +package com.ruoyi.service.impl;
  2 +
  3 +import cn.hutool.core.collection.CollectionUtil;
  4 +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  5 +import com.ruoyi.domain.RuleAttendanceMain;
  6 +import com.ruoyi.domain.RuleNumSetting;
  7 +import com.ruoyi.mapper.RuleNumSettingMapper;
  8 +import com.ruoyi.num.service.IRuleNumService;
  9 +import com.ruoyi.pojo.dto.AttendanceDto;
  10 +import com.ruoyi.pojo.dto.RuleNumDto;
  11 +import com.ruoyi.pojo.dto.RuleSchedulingDto;
  12 +import com.ruoyi.pojo.vo.SchedulingRequestVo;
  13 +import com.ruoyi.pojo.vo.SchedulingResponseVo;
  14 +import com.ruoyi.scheduling.service.IRuleSchedulingService;
  15 +import com.ruoyi.service.RuleAttendanceMainService;
  16 +import com.ruoyi.service.RuleNumSettingService;
  17 +import com.ruoyi.utils.ConstDateUtil;
  18 +import org.springframework.beans.BeanUtils;
  19 +import org.springframework.beans.factory.annotation.Autowired;
  20 +import org.springframework.stereotype.Service;
  21 +
  22 +import java.time.LocalDate;
  23 +import java.time.ZoneId;
  24 +import java.time.temporal.ChronoUnit;
  25 +import java.util.*;
  26 +import java.util.stream.Collectors;
  27 +
  28 +import static com.ruoyi.common.RuleSchedulingProperties.*;
  29 +
  30 +/**
  31 + * @author 20412
  32 + * @description 针对表【rule_num_setting(排班设置表)】的数据库操作Service实现
  33 + * @createDate 2023-08-31 09:31:28
  34 + */
  35 +@Service
  36 +public class RuleNumSettingServiceImpl extends ServiceImpl<RuleNumSettingMapper, RuleNumSetting>
  37 + implements RuleNumSettingService {
  38 +
  39 + @Autowired
  40 + private IRuleSchedulingService schedulingService;
  41 +
  42 + @Autowired
  43 + private RuleNumSettingService ruleNumSettingService;
  44 +
  45 + @Autowired
  46 + private IRuleNumService ruleNumService;
  47 +
  48 + @Autowired
  49 + private RuleAttendanceMainService attendanceMainService;
  50 +
  51 + @Override
  52 + public List<SchedulingResponseVo> getSchedulingList(SchedulingRequestVo vo) {
  53 + return baseMapper.getSchedulingList(vo);
  54 + }
  55 +
  56 + @Override
  57 + public void createAttendance() {
  58 +
  59 + // 临时表根据工号生成一个月的模板,固定下来,每天生成一次,如果当前月内的工号已经生成了一次排班,则跳过生成
  60 + // 用户可以修改临时排班表的数据,只能修改未来一个月内的数据 过一天后把数据存储到考勤表,
  61 + // 获取需要生成的人员工号
  62 + List<AttendanceDto> peopleList = baseMapper.getPeopleList();
  63 + List<Integer> settingList = peopleList.stream().map(AttendanceDto::getSettingId).distinct().collect(Collectors.toList());
  64 + // 获取规则集合
  65 + List<RuleSchedulingDto> ruleList = schedulingService.selectRuleSchedulingListVoBySettingIds(settingList);
  66 + // 获取班次
  67 + List<RuleNumDto> ruleNumDtoList = ruleNumSettingService.selectRuleNumBySettingId(settingList);
  68 + // 处理规则
  69 + List<RuleAttendanceMain> attendanceMains = handleAttendanceMain(peopleList, ruleList, ruleNumDtoList);
  70 + attendanceMainService.saveBatch(attendanceMains);
  71 + }
  72 +
  73 + private List<RuleAttendanceMain> handleAttendanceMain(List<AttendanceDto> peopleList, List<RuleSchedulingDto> ruleList, List<RuleNumDto> ruleNumDtoList) {
  74 + if (CollectionUtil.isEmpty(peopleList)) {
  75 + return null;
  76 + }
  77 + Map<Integer, List<AttendanceDto>> peopleMap = transformMapByPeople(peopleList);
  78 + Map<Integer, RuleNumDto> ruleNumMap = transformMapByRuleNum(ruleNumDtoList);
  79 + Map<Integer, List<RuleSchedulingDto>> ruleMap = transformMapByRule(ruleList);
  80 + List<RuleAttendanceMain> ruleAttendanceMainList = new ArrayList<>();
  81 + List<LocalDate> dateList = ConstDateUtil.getDateSetFromTheCurrentDayToTheEndOfTheMonth();
  82 + for (Map.Entry<Integer, List<AttendanceDto>> entry : peopleMap.entrySet()) {
  83 + Integer settingId = entry.getKey();
  84 + List<AttendanceDto> attendanceDtoList = entry.getValue();
  85 + RuleNumDto dto = ruleNumMap.get(settingId);
  86 + List<RuleAttendanceMain> mainList = new ArrayList<>(entry.getValue().size() * dateList.size());
  87 + for (AttendanceDto attendanceDto : attendanceDtoList) {
  88 + for (LocalDate date : dateList) {
  89 + // 处理固定规则翻班
  90 + if (RULE_TYPE_FIXED.equals(dto.getRuleType())) {
  91 + handleFixed(date, mainList, ruleMap.get(settingId), attendanceDto,dto.getRuleDictName());
  92 + }
  93 + // 处理星期翻班
  94 + else {
  95 + handleWeek(date, mainList, ruleMap.get(settingId), attendanceDto,dto.getRuleDictName());
  96 + }
  97 + }
  98 + }
  99 + ruleAttendanceMainList.addAll(mainList);
  100 + }
  101 + return ruleAttendanceMainList;
  102 + }
  103 +
  104 + private void handleWeek(LocalDate date, List<RuleAttendanceMain> mainList, List<RuleSchedulingDto> ruleSchedulingDtoList, AttendanceDto attendanceDto, String ruleDictName) {
  105 + RuleAttendanceMain main = new RuleAttendanceMain();
  106 + main.setSchedulingDate(Date.from(date.atStartOfDay(ZoneId.systemDefault()).toInstant()));
  107 + main.setPosts(attendanceDto.getPosts());
  108 + main.setRuleDictName(ruleDictName);
  109 + RuleSchedulingDto dto = null;
  110 + dto = getRuleByWeek(main,ruleSchedulingDtoList, date,attendanceDto.getStartDate());
  111 + BeanUtils.copyProperties(dto, main);
  112 + main.setName(attendanceDto.getName());
  113 + main.setJobCode(attendanceDto.getJobCode());
  114 + handleSegmentationByDate(date, main, dto);
  115 + mainList.add(main);
  116 + }
  117 +
  118 + private void handleSegmentationByDate(LocalDate date, RuleAttendanceMain main, RuleSchedulingDto dto) {
  119 + main.setFirstWorkSignInTime(ConstDateUtil.dateAddition(date.toString(), ConstDateUtil.formatDate("HH:mm:ss", main.getFirstWorkSignInTime())));
  120 + // 不存在分段
  121 + if (NO_SEGMENTATION.equals(dto.getSecondFlag())) {
  122 + if (TOMORROW_YES.equals(dto.getFirstSignInDayTomorrow())) {
  123 + main.setFirstQuittingSignInTime(handleTimeTomorrowByRule(date, main.getFirstQuittingSignInTime()));
  124 + } else {
  125 + main.setFirstQuittingSignInTime(ConstDateUtil.dateAddition(date.toString(), ConstDateUtil.formatDate("HH:mm:ss", main.getFirstQuittingSignInTime())));
  126 + }
  127 + }
  128 + // 存在分段
  129 + else {
  130 + main.setSecondWorkSignInTime(ConstDateUtil.dateAddition(date.toString(), ConstDateUtil.formatDate("HH:mm:ss", main.getSecondWorkSignInTime())));
  131 + if (TOMORROW_YES.equals(dto.getFirstSignInDayTomorrow())) {
  132 + main.setSecondQuittingSignInTime(handleTimeTomorrowByRule(date, main.getSecondQuittingSignInTime()));
  133 + } else {
  134 + main.setSecondWorkSignInTime(ConstDateUtil.dateAddition(date.toString(), ConstDateUtil.formatDate("HH:mm:ss", main.getSecondQuittingSignInTime())));
  135 + }
  136 + }
  137 + }
  138 +
  139 + private static RuleSchedulingDto getRuleByWeek(RuleAttendanceMain main, List<RuleSchedulingDto> ruleSchedulingDtoList, LocalDate nowDate, Date startDate) {
  140 + RuleSchedulingDto dto = null;
  141 + switch (nowDate.getDayOfWeek().toString()) {
  142 + case "MONDAY":
  143 + dto = ruleSchedulingDtoList.get(0);
  144 + break;
  145 + case "TUESDAY":
  146 + dto = ruleSchedulingDtoList.get(1);
  147 + break;
  148 + case "WEDNESDAY":
  149 + dto = ruleSchedulingDtoList.get(2);
  150 + break;
  151 + case "THURSDAY":
  152 + dto = ruleSchedulingDtoList.get(3);
  153 + break;
  154 + case "FRIDAY":
  155 + dto = ruleSchedulingDtoList.get(4);
  156 + break;
  157 + case "SATURDAY":
  158 + dto = ruleSchedulingDtoList.get(5);
  159 + break;
  160 + case "SUNDAY":
  161 + dto = ruleSchedulingDtoList.get(6);
  162 + break;
  163 + }
  164 + LocalDate start = startDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
  165 + int daysDifference = new Long(ChronoUnit.DAYS.between(start, nowDate)).intValue();
  166 + if (daysDifference < 0) {
  167 + return getFreeRuleSchedulingDto(startDate);
  168 + }
  169 + main.setWorkFlag(dto.getId() == 0 ? FREE_FLAG : WORK_FLAG);
  170 + return dto;
  171 + }
  172 +
  173 + private void handleFixed(LocalDate nowDate, List<RuleAttendanceMain> mainList, List<RuleSchedulingDto> ruleSchedulingDtoList, AttendanceDto attendanceDto, String ruleDictName) {
  174 + RuleAttendanceMain main = new RuleAttendanceMain();
  175 + main.setPosts(attendanceDto.getPosts());
  176 + main.setRuleDictName(ruleDictName);
  177 + main.setSchedulingDate(Date.from(nowDate.atStartOfDay(ZoneId.systemDefault()).toInstant()));
  178 + Date startDate = attendanceDto.getStartDate();
  179 + // 匹配当天应设置的规则
  180 + RuleSchedulingDto dto = getNowRuleByFixed(nowDate, startDate, ruleSchedulingDtoList);
  181 + main.setWorkFlag(dto.getId() == 0 ? FREE_FLAG : WORK_FLAG);
  182 + BeanUtils.copyProperties(dto, main);
  183 + main.setName(attendanceDto.getName());
  184 + main.setJobCode(attendanceDto.getJobCode());
  185 + // 处理是否分段
  186 + handleSegmentationByDate(nowDate, main, dto);
  187 + mainList.add(main);
  188 + }
  189 +
  190 +
  191 + private RuleSchedulingDto getNowRuleByFixed(LocalDate nowDate, Date startDate, List<RuleSchedulingDto> ruleSchedulingDtoList) {
  192 + LocalDate start = startDate.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
  193 + int daysDifference = new Long(ChronoUnit.DAYS.between(start, nowDate)).intValue();
  194 + if (daysDifference < 0) {
  195 + return getFreeRuleSchedulingDto(startDate);
  196 + }
  197 + int length = ruleSchedulingDtoList.size();
  198 + return ruleSchedulingDtoList.get(daysDifference % length);
  199 + }
  200 +
  201 + private static RuleSchedulingDto getFreeRuleSchedulingDto(Date startDate) {
  202 + RuleSchedulingDto dto = new RuleSchedulingDto();
  203 + dto.setId(0L);
  204 + dto.setRuleName("休息");
  205 + dto.setWorkingHourPlan(WORK_HOUR_PLAN_NORMAL);
  206 + dto.setWorkingHourType(WORK_HOUR_TYPE_ELASTIC);
  207 + dto.setFirstQuittingSignInTime(startDate);
  208 + dto.setFirstWorkSignInTime(startDate);
  209 + dto.setSecondFlag(NO_SEGMENTATION);
  210 + dto.setFirstSignInQuittingRange(0);
  211 + dto.setFirstSignInWorkingRange(0);
  212 + dto.setSignInTimeOutRange(0);
  213 + return dto;
  214 + }
  215 +
  216 +
  217 + private Date handleTimeTomorrowByRule(LocalDate date, Date time) {
  218 + // 隔天日期需要加1
  219 + return ConstDateUtil.dateAddition(date.plusDays(1).toString(), ConstDateUtil.formatDate("HH:mm:ss", time));
  220 + }
  221 +
  222 +
  223 + private Map<Integer, RuleNumDto> transformMapByRuleNum(List<RuleNumDto> ruleNumDtoList) {
  224 + Map<Integer, RuleNumDto> map = new HashMap<>(16);
  225 + for (RuleNumDto ruleNumDto : ruleNumDtoList) {
  226 + map.put(ruleNumDto.getSettingId(), ruleNumDto);
  227 + }
  228 + return map;
  229 + }
  230 +
  231 + private Map<Integer, List<RuleSchedulingDto>> transformMapByRule(List<RuleSchedulingDto> ruleList) {
  232 + Map<Integer, List<RuleSchedulingDto>> map = new HashMap<>(16);
  233 + for (RuleSchedulingDto dto : ruleList) {
  234 + List<RuleSchedulingDto> dtoList = map.get(dto.getSettingId());
  235 + if (CollectionUtil.isEmpty(dtoList)) {
  236 + map.put(dto.getSettingId(), new ArrayList<>(Arrays.asList(dto)));
  237 + } else {
  238 + dtoList.add(dto);
  239 + }
  240 + }
  241 + for (Map.Entry<Integer, List<RuleSchedulingDto>> entry : map.entrySet()) {
  242 + entry.getValue().sort(Comparator.comparing(RuleSchedulingDto::getSort));
  243 + }
  244 + return map;
  245 + }
  246 +
  247 + private Map<Integer, List<AttendanceDto>> transformMapByPeople(List<AttendanceDto> peopleList) {
  248 + Map<Integer, List<AttendanceDto>> map = new HashMap<>(16);
  249 + for (AttendanceDto dto : peopleList) {
  250 + List<AttendanceDto> dtoList = map.get(dto.getSettingId());
  251 + if (CollectionUtil.isEmpty(dtoList)) {
  252 + map.put(dto.getSettingId(), new ArrayList<>(Arrays.asList(dto)));
  253 + } else {
  254 + dtoList.add(dto);
  255 + }
  256 + }
  257 + return map;
  258 + }
  259 +
  260 + @Override
  261 + public List<RuleNumDto> selectRuleNumBySettingId(List<Integer> settingList) {
  262 + if (CollectionUtil.isEmpty(settingList)) {
  263 + return new ArrayList<>();
  264 + }
  265 + return ruleNumService.selectRuleNumBySettingId(settingList);
  266 + }
  267 +
  268 +
  269 +}
  270 +
  271 +
  272 +
  273 +
ruoyi-admin/src/main/java/com/ruoyi/service/impl/RuleSettingDriverServiceImpl.java 0 → 100644
  1 +package com.ruoyi.service.impl;
  2 +
  3 +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  4 +import com.ruoyi.domain.RuleSettingDriver;
  5 +import com.ruoyi.driver.domain.Driver;
  6 +import com.ruoyi.mapper.RuleSettingDriverMapper;
  7 +import com.ruoyi.pojo.dto.DriverDto;
  8 +import com.ruoyi.service.RuleSettingDriverService;
  9 +import org.springframework.stereotype.Service;
  10 +
  11 +import java.util.List;
  12 +
  13 +/**
  14 +* @author 20412
  15 +* @description 针对表【rule_setting_driver(人员信息表与排班设置绑定表)】的数据库操作Service实现
  16 +* @createDate 2023-08-31 14:35:06
  17 +*/
  18 +@Service
  19 +public class RuleSettingDriverServiceImpl extends ServiceImpl<RuleSettingDriverMapper, RuleSettingDriver>
  20 + implements RuleSettingDriverService {
  21 +
  22 + @Override
  23 + public List<DriverDto> queryDriverListBySettingId(List<Integer> settingIdList) {
  24 + return getBaseMapper().queryDriverListBySettingId(settingIdList);
  25 + }
  26 +}
  27 +
  28 +
  29 +
  30 +
ruoyi-admin/src/main/java/com/ruoyi/service/impl/RuleSettingSchedulingServiceImpl.java 0 → 100644
  1 +package com.ruoyi.service.impl;
  2 +
  3 +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  4 +import com.ruoyi.domain.RuleSettingScheduling;
  5 +import com.ruoyi.mapper.RuleSettingSchedulingMapper;
  6 +import com.ruoyi.pojo.dto.RuleSchedulingDto;
  7 +import com.ruoyi.scheduling.domain.RuleScheduling;
  8 +import com.ruoyi.scheduling.mapper.RuleSchedulingMapper;
  9 +import com.ruoyi.service.RuleSettingSchedulingService;
  10 +import org.springframework.beans.factory.annotation.Autowired;
  11 +import org.springframework.stereotype.Service;
  12 +
  13 +import java.util.ArrayList;
  14 +import java.util.List;
  15 +
  16 +/**
  17 +* @author 20412
  18 +* @description 针对表【rule_setting_scheduling(考勤规则表)】的数据库操作Service实现
  19 +* @createDate 2023-08-31 14:35:06
  20 +*/
  21 +@Service
  22 +public class RuleSettingSchedulingServiceImpl extends ServiceImpl<RuleSettingSchedulingMapper, RuleSettingScheduling>
  23 + implements RuleSettingSchedulingService {
  24 +
  25 +
  26 + @Override
  27 + public List<RuleSchedulingDto> querySchedulingListBySettingId(List<Integer> settingIdList) {
  28 + return getBaseMapper().querySchedulingListBySettingId(settingIdList);
  29 + }
  30 +}
  31 +
  32 +
  33 +
  34 +
ruoyi-admin/src/main/java/com/ruoyi/utils/ConstDateUtil.java
1 package com.ruoyi.utils; 1 package com.ruoyi.utils;
2 2
3 import java.text.SimpleDateFormat; 3 import java.text.SimpleDateFormat;
4 -import java.time.Instant;  
5 -import java.time.LocalDateTime;  
6 -import java.time.ZoneId; 4 +import java.time.*;
  5 +import java.time.format.DateTimeFormatter;
  6 +import java.util.ArrayList;
7 import java.util.Calendar; 7 import java.util.Calendar;
8 import java.util.Date; 8 import java.util.Date;
  9 +import java.util.List;
9 10
10 public class ConstDateUtil { 11 public class ConstDateUtil {
11 public static String formatDate(String pattern){ 12 public static String formatDate(String pattern){
12 SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern); 13 SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
13 return simpleDateFormat.format(new Date()); 14 return simpleDateFormat.format(new Date());
14 } 15 }
  16 +
15 public static String formatDate(String pattern,Date date){ 17 public static String formatDate(String pattern,Date date){
16 SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern); 18 SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
17 return simpleDateFormat.format(date); 19 return simpleDateFormat.format(date);
@@ -25,6 +27,15 @@ public class ConstDateUtil { @@ -25,6 +27,15 @@ public class ConstDateUtil {
25 return simpleDateFormat.format(date); 27 return simpleDateFormat.format(date);
26 } 28 }
27 29
  30 + public static Date dateAddition(String dateString,String timeString){
  31 + LocalDate date = LocalDate.parse(dateString);
  32 + LocalTime time = LocalTime.parse(timeString);
  33 +
  34 + // 将日期和时间相加
  35 + LocalDateTime dateTime = date.atTime(time);
  36 +
  37 + return Date.from(dateTime.atZone(ZoneId.systemDefault()).toInstant());
  38 + }
28 39
29 public static Date getTheSpecifiedNumberOfDaysOfTime(Integer amount) { 40 public static Date getTheSpecifiedNumberOfDaysOfTime(Integer amount) {
30 // 获取当前日期时间 41 // 获取当前日期时间
@@ -42,5 +53,29 @@ public class ConstDateUtil { @@ -42,5 +53,29 @@ public class ConstDateUtil {
42 return localDateTime; 53 return localDateTime;
43 } 54 }
44 55
  56 + public static List<LocalDate> getDateSetFromTheCurrentDayToTheEndOfTheMonth(){
  57 + LocalDate today = LocalDate.now();
  58 + int year = today.getYear();
  59 + int month = today.getMonthValue();
  60 +
  61 + // 获取本月的最后一天
  62 + LocalDate endDay;
  63 + if (month == 12) {
  64 + endDay = LocalDate.of(year, month, 31);
  65 + } else {
  66 + endDay = LocalDate.of(year, month + 1, 1).minusDays(1);
  67 + }
  68 +
  69 + // 生成日期列表
  70 + List<LocalDate> dateList = new ArrayList<>();
  71 + LocalDate currentDay = today;
  72 + while (!currentDay.isAfter(endDay)) {
  73 + dateList.add(currentDay);
  74 + currentDay = currentDay.plusDays(1);
  75 + }
  76 +
  77 + return dateList;
  78 + }
  79 +
45 80
46 } 81 }
ruoyi-admin/src/main/resources/mapper/RuleAttendanceMainMapper.xml 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE mapper
  3 + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4 + "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5 +<mapper namespace="com.ruoyi.mapper.RuleAttendanceMainMapper">
  6 +
  7 + <resultMap id="BaseResultMap" type="com.ruoyi.domain.RuleAttendanceMain">
  8 + <id property="id" column="id" jdbcType="INTEGER"/>
  9 + <result property="name" column="name" jdbcType="VARCHAR"/>
  10 + <result property="jobCode" column="job_code" jdbcType="VARCHAR"/>
  11 + <result property="workingHourPlan" column="working_hour_plan" jdbcType="INTEGER"/>
  12 + <result property="workingHourType" column="working_hour_type" jdbcType="TINYINT"/>
  13 + <result property="firstWorkSignInTime" column="first_work_sign_in_time" jdbcType="TIMESTAMP"/>
  14 + <result property="firstSignInWorkingRange" column="first_sign_in_working_range" jdbcType="INTEGER"/>
  15 + <result property="firstQuittingSignInTime" column="first_quitting_sign_in_time" jdbcType="TIMESTAMP"/>
  16 + <result property="firstSignInQuittingRange" column="first_sign_in_quitting_range" jdbcType="INTEGER"/>
  17 + <result property="signInTimeOutRange" column="sign_in_time_out_range" jdbcType="INTEGER"/>
  18 + <result property="secondWorkSignInTime" column="second_work_sign_in_time" jdbcType="TIMESTAMP"/>
  19 + <result property="secondSignInWorkingRange" column="second_sign_in_working_range" jdbcType="INTEGER"/>
  20 + <result property="secondQuittingSignInTime" column="second_quitting_sign_in_time" jdbcType="TIMESTAMP"/>
  21 + <result property="secondSignInQuittingRange" column="second_sign_in_quitting_range" jdbcType="INTEGER"/>
  22 + <result property="schedulingDate" column="scheduling_date" jdbcType="DATE"/>
  23 + <result property="posts" column="posts" jdbcType="VARCHAR"/>
  24 + <result property="ruleDictName" column="rule_dict_name" jdbcType="VARCHAR"/>
  25 + <result property="workFlag" column="work_flag" jdbcType="INTEGER"/>
  26 + </resultMap>
  27 +
  28 + <sql id="Base_Column_List">
  29 + id,name,job_code,
  30 + working_hour_plan,working_hour_type,first_work_sign_in_time,
  31 + first_sign_in_working_range,first_quitting_sign_in_time,first_sign_in_quitting_range,
  32 + sign_in_time_out_range,second_work_sign_in_time,second_sign_in_working_range,
  33 + second_quitting_sign_in_time,second_sign_in_quitting_range,scheduling_date,work_flag
  34 + </sql>
  35 +</mapper>
ruoyi-admin/src/main/resources/mapper/RuleNumSettingMapper.xml 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE mapper
  3 + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4 + "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5 +<mapper namespace="com.ruoyi.mapper.RuleNumSettingMapper">
  6 +
  7 + <resultMap id="BaseResultMap" type="com.ruoyi.domain.RuleNumSetting">
  8 + <id property="id" column="id" jdbcType="INTEGER"/>
  9 + <result property="ruleNumId" column="rule_num_id" jdbcType="INTEGER"/>
  10 + <result property="ruleDictName" column="rule_dict_name" jdbcType="VARCHAR"/>
  11 + <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
  12 + <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
  13 + <result property="remark" column="remark" jdbcType="VARCHAR"/>
  14 + <result property="createBy" column="create_by" jdbcType="VARCHAR"/>
  15 + <result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
  16 + </resultMap>
  17 +
  18 + <resultMap id="AttendanceResult" type="com.ruoyi.pojo.dto.AttendanceDto">
  19 + <result property="jobCode" column="job_code" jdbcType="VARCHAR"/>
  20 + <result property="name" column="personnel_name" jdbcType="VARCHAR"/>
  21 + <result property="posts" column="posts" jdbcType="VARCHAR"/>
  22 + <result property="name" column="personnel_name" jdbcType="VARCHAR"/>
  23 + <result property="settingId" column="setting_id" jdbcType="INTEGER"/>
  24 + <result property="startDate" column="start_date" jdbcType="DATE"/>
  25 +<!-- <collection property="ruleList" ofType="com.ruoyi.scheduling.domain.RuleScheduling">-->
  26 +<!-- <result column="working_hour_plan" property="workingHourPlan" jdbcType="INTEGER"/>-->
  27 +<!-- <result column="working_hour_type" property="workingHourType" jdbcType="INTEGER"/>-->
  28 +<!-- <result column="first_work_sign_in_time" property="firstWorkSignInTime" jdbcType="DATE"/>-->
  29 +<!-- <result column="first_sign_in_working_range" property="firstSignInWorkingRange" jdbcType="INTEGER"/>-->
  30 +<!-- <result column="first_quitting_sign_in_time" property="firstQuittingSignInTime" jdbcType="DATE"/>-->
  31 +<!-- <result column="first_sign_in_day_tomorrow" property="firstSignInDayTomorrow" jdbcType="INTEGER"/>-->
  32 +<!-- <result column="first_sign_in_quitting_range" property="firstSignInQuittingRange" jdbcType="INTEGER"/>-->
  33 +<!-- <result column="sign_in_time_out_range" property="signInTimeOutRange" jdbcType="INTEGER"/>-->
  34 +<!-- <result column="second_flag" property="secondFlag" jdbcType="INTEGER"/>-->
  35 +<!-- <result column="second_work_sign_in_time" property="secondWorkSignInTime" jdbcType="DATE"/>-->
  36 +<!-- <result column="second_sign_in_working_range" property="secondSignInWorkingRange" jdbcType="INTEGER"/>-->
  37 +<!-- <result column="second_quitting_sign_in_time" property="secondQuittingSignInTime" jdbcType="DATE"/>-->
  38 +<!-- <result column="second_sign_in_quitting_range" property="secondSignInQuittingRange" jdbcType="INTEGER"/>-->
  39 +<!-- <result column="second_sign_day_tomorrow" property="secondSignDayTomorrow" jdbcType="INTEGER"/>-->
  40 +<!-- </collection>-->
  41 + </resultMap>
  42 +
  43 + <sql id="Base_Column_List">
  44 + id,rule_num_id,match_name,
  45 + create_time,update_time,remart,
  46 + create_by,update_by
  47 + </sql>
  48 + <select id="getSchedulingList" resultType="com.ruoyi.pojo.vo.SchedulingResponseVo">
  49 + SELECT
  50 + setting.*,
  51 + num.rule_dict_name,
  52 + num.rule_type
  53 + FROM
  54 + `rule_num_setting` setting,rule_num num
  55 + WHERE setting.rule_num_id = num.id
  56 + <if test="jobCode != null and jobCode != ''">
  57 + and setting.id = (
  58 + SELECT
  59 + setting_id
  60 + FROM
  61 + rule_setting_driver
  62 + WHERE
  63 + job_code = #{jocCode}
  64 + LIMIT 1)
  65 + </if>
  66 + <if test="ruleDictName != null and ruleDictName != ''">
  67 + and rule_dict_name = #{ruleDictName}
  68 + </if>
  69 + </select>
  70 + <select id="getPeopleList" resultType="com.ruoyi.pojo.dto.AttendanceDto" resultMap="AttendanceResult">
  71 + SELECT
  72 + driver.job_code,
  73 + driver.personnel_name,
  74 + driver.posts,
  75 + rule_setting_driver.setting_id,
  76 + rule_setting_driver.start_date
  77 + FROM
  78 + driver,
  79 + rule_setting_driver
  80 + WHERE
  81 + driver.job_code = rule_setting_driver.job_code
  82 + AND rule_setting_driver.job_code NOT IN (
  83 + SELECT DISTINCT
  84 + job_code
  85 + FROM
  86 + rule_attendance_main
  87 + WHERE
  88 + DATE_FORMAT( scheduling_date, '%y-%m' ) = DATE_FORMAT( NOW(), '%y-%m' )
  89 + )
  90 + </select>
  91 +
  92 +</mapper>
ruoyi-admin/src/main/resources/mapper/RuleSettingDriverMapper.xml 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE mapper
  3 + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4 + "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5 +<mapper namespace="com.ruoyi.mapper.RuleSettingDriverMapper">
  6 +
  7 + <resultMap id="BaseResultMap" type="com.ruoyi.domain.RuleSettingDriver">
  8 + <id property="id" column="id" jdbcType="INTEGER"/>
  9 + <result property="settingId" column="setting_id" jdbcType="INTEGER"/>
  10 + <result property="jobCode" column="job_code" jdbcType="VARCHAR"/>
  11 + <result property="startDate" column="start_date" jdbcType="DATE"/>
  12 + </resultMap>
  13 +
  14 + <sql id="Base_Column_List">
  15 + id,setting_id,job_code
  16 + </sql>
  17 + <select id="queryDriverListBySettingId" resultType="com.ruoyi.pojo.dto.DriverDto">
  18 + SELECT
  19 + driver.*,
  20 + rule_setting_driver.setting_id
  21 + FROM
  22 + `driver`,
  23 + rule_setting_driver
  24 + WHERE
  25 + driver.job_code = rule_setting_driver.job_code
  26 + <if test="list != null and list.size() > 0">
  27 + AND rule_setting_driver.setting_id IN
  28 + <foreach collection="list" index="index" item="item" open="(" close=")" separator=",">
  29 + #{item}
  30 + </foreach>
  31 + </if>
  32 + </select>
  33 +</mapper>
ruoyi-admin/src/main/resources/mapper/RuleSettingSchedulingMapper.xml 0 → 100644
  1 +<?xml version="1.0" encoding="UTF-8"?>
  2 +<!DOCTYPE mapper
  3 + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4 + "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
  5 +<mapper namespace="com.ruoyi.mapper.RuleSettingSchedulingMapper">
  6 +
  7 + <resultMap id="BaseResultMap" type="com.ruoyi.domain.RuleSettingScheduling">
  8 + <id property="id" column="id" jdbcType="INTEGER"/>
  9 + <result property="settingId" column="setting_id" jdbcType="INTEGER"/>
  10 + <result property="ruleSchedulingId" column="rule_scheduling_id" jdbcType="INTEGER"/>
  11 + <result property="rangeTime" column="rangeTime" jdbcType="VARCHAR"/>
  12 + <result property="ruleName" column="rule_name" jdbcType="VARCHAR"/>
  13 + </resultMap>
  14 +
  15 + <sql id="Base_Column_List">
  16 + id,setting_id,rule_scheduling_id
  17 + </sql>
  18 + <select id="querySchedulingListBySettingId" resultType="com.ruoyi.pojo.dto.RuleSchedulingDto">
  19 + SELECT
  20 + rule_scheduling.*,
  21 + rule_setting_scheduling.setting_id
  22 + FROM
  23 + `rule_scheduling`,
  24 + rule_setting_scheduling
  25 + WHERE
  26 + rule_scheduling.id = rule_setting_scheduling.rule_scheduling_id
  27 + <if test="list != null and list.size() > 0">
  28 + AND rule_setting_scheduling.setting_id IN
  29 + <foreach collection="list" index="index" item="item" open="(" close=")" separator=",">
  30 + #{item}
  31 + </foreach>
  32 + </if>
  33 + </select>
  34 +</mapper>
ruoyi-admin/src/main/resources/mapper/driver/DriverMapper.xml
@@ -31,6 +31,7 @@ @@ -31,6 +31,7 @@
31 <result property="fleetName" column="fleet_name"/> 31 <result property="fleetName" column="fleet_name"/>
32 <result property="posts" column="posts"/> 32 <result property="posts" column="posts"/>
33 <result property="name" column="personnel_name"/> 33 <result property="name" column="personnel_name"/>
  34 + <result property="startDate" column="start_date"/>
34 </resultMap> 35 </resultMap>
35 <sql id="selectDriverVo"> 36 <sql id="selectDriverVo">
36 select id, 37 select id,
@@ -179,7 +180,15 @@ @@ -179,7 +180,15 @@
179 </foreach> 180 </foreach>
180 </select> 181 </select>
181 <select id="queryAttendanceInfoById" resultType="com.ruoyi.pojo.vo.PeopleResponseVo" resultMap="PeopleResult"> 182 <select id="queryAttendanceInfoById" resultType="com.ruoyi.pojo.vo.PeopleResponseVo" resultMap="PeopleResult">
182 - 183 + SELECT
  184 + driver.job_code,
  185 + driver.personnel_name,
  186 + driver.posts,
  187 + driver.fleet_name,
  188 + rule_setting_driver.start_date
  189 + FROM
  190 + driver,rule_setting_driver
  191 + WHERE driver.job_code = rule_setting_driver.job_code and rule_setting_driver.setting_id = #{id}
183 </select> 192 </select>
184 <select id="queryAttendanceInfoAll" resultType="com.ruoyi.pojo.vo.PeopleResponseVo" resultMap="PeopleResult"> 193 <select id="queryAttendanceInfoAll" resultType="com.ruoyi.pojo.vo.PeopleResponseVo" resultMap="PeopleResult">
185 SELECT 194 SELECT
@@ -189,13 +198,7 @@ @@ -189,13 +198,7 @@
189 fleet_name 198 fleet_name
190 FROM 199 FROM
191 driver 200 driver
192 - WHERE  
193 - job_code NOT IN (  
194 - SELECT  
195 - job_code  
196 - FROM  
197 - rule_num_driver  
198 - ) and driver.posts != "驾驶员" and driver.posts != "售票员" 201 + WHERE driver.posts != "驾驶员" and driver.posts != "售票员"
199 </select> 202 </select>
200 203
201 <insert id="insertDriver" parameterType="Driver" useGeneratedKeys="true" keyProperty="id"> 204 <insert id="insertDriver" parameterType="Driver" useGeneratedKeys="true" keyProperty="id">
ruoyi-admin/src/main/resources/mapper/num/RuleNumMapper.xml
1 <?xml version="1.0" encoding="UTF-8" ?> 1 <?xml version="1.0" encoding="UTF-8" ?>
2 <!DOCTYPE mapper 2 <!DOCTYPE mapper
3 -PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"  
4 -"http://mybatis.org/dtd/mybatis-3-mapper.dtd"> 3 + PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
  4 + "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
5 <mapper namespace="com.ruoyi.num.mapper.RuleNumMapper"> 5 <mapper namespace="com.ruoyi.num.mapper.RuleNumMapper">
6 - 6 +
7 <resultMap type="RuleNum" id="RuleNumResult"> 7 <resultMap type="RuleNum" id="RuleNumResult">
8 - <result property="id" column="id" />  
9 - <result property="ruleDictName" column="rule_dict_name" />  
10 - <result property="ruleType" column="rule_type" />  
11 - <result property="workDay" column="work_day" />  
12 - <result property="freeDay" column="free_day" />  
13 - <result property="ruleWeek" column="rule_week" /> 8 + <result property="id" column="id"/>
  9 + <result property="ruleDictName" column="rule_dict_name"/>
  10 + <result property="ruleType" column="rule_type"/>
  11 + <result property="workDay" column="work_day"/>
  12 + <result property="freeDay" column="free_day"/>
  13 + <result property="ruleWeek" column="rule_week"/>
  14 + </resultMap>
  15 +
  16 + <resultMap type="com.ruoyi.pojo.dto.RuleNumDto" id="RuleNumDtoResult">
  17 + <result property="id" column="id"/>
  18 + <result property="ruleDictName" column="rule_dict_name"/>
  19 + <result property="ruleType" column="rule_type"/>
  20 + <result property="workDay" column="work_day"/>
  21 + <result property="freeDay" column="free_day"/>
  22 + <result property="ruleWeek" column="rule_week"/>
  23 + <result property="settingId" column="setting_id"/>
14 </resultMap> 24 </resultMap>
15 25
16 <sql id="selectRuleNumVo"> 26 <sql id="selectRuleNumVo">
17 - select id, rule_dict_name, rule_type, work_day, free_day, rule_week from rule_num 27 + select id, rule_dict_name, rule_type, work_day, free_day, rule_week
  28 + from rule_num
18 </sql> 29 </sql>
19 30
20 <select id="selectRuleNumList" parameterType="RuleNum" resultMap="RuleNumResult"> 31 <select id="selectRuleNumList" parameterType="RuleNum" resultMap="RuleNumResult">
21 <include refid="selectRuleNumVo"/> 32 <include refid="selectRuleNumVo"/>
22 - <where>  
23 - <if test="ruleDictName != null "> and rule_dict_name like concat('%', #{ruleDictName}, '%')</if>  
24 - <if test="ruleType != null "> and rule_type = #{ruleType}</if>  
25 - <if test="workDay != null "> and work_day = #{workDay}</if>  
26 - <if test="freeDay != null "> and free_day = #{freeDay}</if>  
27 - <if test="ruleWeek != null and ruleWeek != ''"> and rule_week = #{ruleWeek}</if> 33 + <where>
  34 + <if test="ruleDictName != null ">and rule_dict_name like concat('%', #{ruleDictName}, '%')</if>
  35 + <if test="ruleType != null ">and rule_type = #{ruleType}</if>
  36 + <if test="workDay != null ">and work_day = #{workDay}</if>
  37 + <if test="freeDay != null ">and free_day = #{freeDay}</if>
  38 + <if test="ruleWeek != null and ruleWeek != ''">and rule_week = #{ruleWeek}</if>
28 </where> 39 </where>
29 </select> 40 </select>
30 - 41 +
31 <select id="selectRuleNumById" parameterType="Long" resultMap="RuleNumResult"> 42 <select id="selectRuleNumById" parameterType="Long" resultMap="RuleNumResult">
32 <include refid="selectRuleNumVo"/> 43 <include refid="selectRuleNumVo"/>
33 where id = #{id} 44 where id = #{id}
34 </select> 45 </select>
35 - 46 + <select id="listNumBySettingId" resultType="com.ruoyi.num.domain.RuleNum" resultMap="RuleNumResult">
  47 + select *
  48 + from rule_num,
  49 + rule_num_setting
  50 + where rule_num.id = rule_num_setting.rule_num_id
  51 + and rule_num_setting.id = #{id}
  52 + </select>
  53 + <select id="selectRuleNumBySettingId" resultType="com.ruoyi.pojo.dto.RuleNumDto" resultMap="RuleNumDtoResult">
  54 + select
  55 + rule_num.*,
  56 + rule_num_setting.id setting_id
  57 + from rule_num,rule_num_setting
  58 + where rule_num.id = rule_num_setting.rule_num_id
  59 + and rule_num_setting.id in
  60 + <foreach collection="list" item="item" index="index" open="(" close=")" separator=",">
  61 + #{item}
  62 + </foreach>
  63 + </select>
  64 +
36 <insert id="insertRuleNum" parameterType="RuleNum" useGeneratedKeys="true" keyProperty="id"> 65 <insert id="insertRuleNum" parameterType="RuleNum" useGeneratedKeys="true" keyProperty="id">
37 insert into rule_num 66 insert into rule_num
38 <trim prefix="(" suffix=")" suffixOverrides=","> 67 <trim prefix="(" suffix=")" suffixOverrides=",">
@@ -41,14 +70,14 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot; @@ -41,14 +70,14 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
41 <if test="workDay != null">work_day,</if> 70 <if test="workDay != null">work_day,</if>
42 <if test="freeDay != null">free_day,</if> 71 <if test="freeDay != null">free_day,</if>
43 <if test="ruleWeek != null">rule_week,</if> 72 <if test="ruleWeek != null">rule_week,</if>
44 - </trim> 73 + </trim>
45 <trim prefix="values (" suffix=")" suffixOverrides=","> 74 <trim prefix="values (" suffix=")" suffixOverrides=",">
46 <if test="ruleDictName != null">#{ruleDictName},</if> 75 <if test="ruleDictName != null">#{ruleDictName},</if>
47 <if test="ruleType != null">#{ruleType},</if> 76 <if test="ruleType != null">#{ruleType},</if>
48 <if test="workDay != null">#{workDay},</if> 77 <if test="workDay != null">#{workDay},</if>
49 <if test="freeDay != null">#{freeDay},</if> 78 <if test="freeDay != null">#{freeDay},</if>
50 <if test="ruleWeek != null">#{ruleWeek},</if> 79 <if test="ruleWeek != null">#{ruleWeek},</if>
51 - </trim> 80 + </trim>
52 </insert> 81 </insert>
53 82
54 <update id="updateRuleNum" parameterType="RuleNum"> 83 <update id="updateRuleNum" parameterType="RuleNum">
@@ -64,11 +93,13 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot; @@ -64,11 +93,13 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
64 </update> 93 </update>
65 94
66 <delete id="deleteRuleNumById" parameterType="Long"> 95 <delete id="deleteRuleNumById" parameterType="Long">
67 - delete from rule_num where id = #{id} 96 + delete
  97 + from rule_num
  98 + where id = #{id}
68 </delete> 99 </delete>
69 100
70 <delete id="deleteRuleNumByIds" parameterType="String"> 101 <delete id="deleteRuleNumByIds" parameterType="String">
71 - delete from rule_num where id in 102 + delete from rule_num where id in
72 <foreach item="id" collection="array" open="(" separator="," close=")"> 103 <foreach item="id" collection="array" open="(" separator="," close=")">
73 #{id} 104 #{id}
74 </foreach> 105 </foreach>
ruoyi-admin/src/main/resources/mapper/scheduling/RuleSchedulingMapper.xml
@@ -4,6 +4,27 @@ @@ -4,6 +4,27 @@
4 "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> 4 "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
5 <mapper namespace="com.ruoyi.scheduling.mapper.RuleSchedulingMapper"> 5 <mapper namespace="com.ruoyi.scheduling.mapper.RuleSchedulingMapper">
6 6
  7 + <resultMap type="com.ruoyi.pojo.dto.RuleSchedulingDto" id="RuleSchedulingDtoResult">
  8 + <result property="id" column="id" />
  9 + <result property="ruleName" column="rule_name" />
  10 + <result property="workingHourPlan" column="working_hour_plan" />
  11 + <result property="workingHourType" column="working_hour_type" />
  12 + <result property="firstWorkSignInTime" column="first_work_sign_in_time" />
  13 + <result property="firstSignInWorkingRange" column="first_sign_in_working_range" />
  14 + <result property="firstQuittingSignInTime" column="first_quitting_sign_in_time" />
  15 + <result property="firstSignInDayTomorrow" column="first_sign_in_day_tomorrow" />
  16 + <result property="firstSignInQuittingRange" column="first_sign_in_quitting_range" />
  17 + <result property="signInTimeOutRange" column="sign_in_time_out_range" />
  18 + <result property="secondFlag" column="second_flag" />
  19 + <result property="secondWorkSignInTime" column="second_work_sign_in_time" />
  20 + <result property="secondSignInWorkingRange" column="second_sign_in_working_range" />
  21 + <result property="secondQuittingSignInTime" column="second_quitting_sign_in_time" />
  22 + <result property="secondSignInQuittingRange" column="second_sign_in_quitting_range" />
  23 + <result property="secondSignDayTomorrow" column="second_sign_day_tomorrow" />
  24 + <result property="settingId" column="setting_id" />
  25 + <result property="sort" column="sort" />
  26 + </resultMap>
  27 +
7 <resultMap type="RuleScheduling" id="RuleSchedulingResult"> 28 <resultMap type="RuleScheduling" id="RuleSchedulingResult">
8 <result property="id" column="id" /> 29 <result property="id" column="id" />
9 <result property="ruleName" column="rule_name" /> 30 <result property="ruleName" column="rule_name" />
@@ -52,6 +73,24 @@ @@ -52,6 +73,24 @@
52 <include refid="selectRuleSchedulingVo"/> 73 <include refid="selectRuleSchedulingVo"/>
53 where id = #{id} 74 where id = #{id}
54 </select> 75 </select>
  76 + <select id="selectRuleSchedulingListVoBySettingId" resultType="com.ruoyi.scheduling.domain.RuleScheduling">
  77 + select rule_scheduling.*
  78 + from rule_scheduling,rule_setting_scheduling
  79 + where rule_scheduling.id = rule_setting_scheduling.rule_scheduling_id and
  80 + rule_setting_scheduling.setting_id = #{settingId}
  81 + </select>
  82 + <select id="selectRuleSchedulingListVoBySettingIds"
  83 + resultType="com.ruoyi.pojo.dto.RuleSchedulingDto" resultMap="RuleSchedulingDtoResult">
  84 + select rule_scheduling.*,
  85 + rule_setting_scheduling.setting_id,
  86 + rule_setting_scheduling.sort
  87 + from rule_scheduling,rule_setting_scheduling
  88 + where rule_scheduling.id = rule_setting_scheduling.rule_scheduling_id
  89 + and rule_setting_scheduling.setting_id in
  90 + <foreach collection="list" item="item" index="index" separator="," open="(" close=")">
  91 + #{item}
  92 + </foreach>
  93 + </select>
55 94
56 <insert id="insertRuleScheduling" parameterType="RuleScheduling" useGeneratedKeys="true" keyProperty="id"> 95 <insert id="insertRuleScheduling" parameterType="RuleScheduling" useGeneratedKeys="true" keyProperty="id">
57 insert into rule_scheduling 96 insert into rule_scheduling