Commit e3af5b248eac9e8cd27de851a2de460d05b1a0bc

Authored by guzijian
1 parent 0c728fa5

feat: 新增灵活跟班设置。

Bsth-admin/src/main/java/com/ruoyi/domain/DriverSchedulingExpandSmart.java 0 → 100644
  1 +package com.ruoyi.domain;
  2 +
  3 +import com.baomidou.mybatisplus.annotation.*;
  4 +
  5 +import java.io.Serializable;
  6 +import java.util.Date;
  7 +import lombok.Data;
  8 +
  9 +/**
  10 + * 灵活跟班表
  11 + * @TableName driver_scheduling_expand_smart
  12 + */
  13 +@TableName(value ="driver_scheduling_expand_smart")
  14 +@Data
  15 +public class DriverSchedulingExpandSmart implements Serializable {
  16 + /**
  17 + * 主键
  18 + */
  19 + @TableId
  20 + private String id;
  21 +
  22 + /**
  23 + * 姓名
  24 + */
  25 + private String name;
  26 +
  27 + /**
  28 + * 驾驶员工号
  29 + */
  30 + private String masterJobCode;
  31 +
  32 + /**
  33 + * 跟班人员工号
  34 + */
  35 + private String slaveJobCode;
  36 +
  37 + /**
  38 + * 开始日期
  39 + */
  40 + private Date startDate;
  41 +
  42 + /**
  43 + * 结束日期
  44 + */
  45 + private Date endDate;
  46 +
  47 + /**
  48 + * 创建人
  49 + */
  50 + @TableField(fill= FieldFill.INSERT)
  51 + private String createBy;
  52 +
  53 + /**
  54 + * 修改人
  55 + */
  56 + @TableField(fill= FieldFill.INSERT_UPDATE)
  57 + private String updateBy;
  58 +
  59 + /**
  60 + * 创建时间
  61 + */
  62 + @TableField(fill= FieldFill.INSERT)
  63 + private Date createTime;
  64 +
  65 + /**
  66 + * 修改时间
  67 + */
  68 + @TableField(fill= FieldFill.INSERT_UPDATE)
  69 + private Date updateTime;
  70 +
  71 + /** 跟班id */
  72 + private String expandId;
  73 +
  74 + private String remark;
  75 +
  76 + @TableField(exist = false)
  77 + private static final long serialVersionUID = 1L;
  78 +}
0 \ No newline at end of file 79 \ No newline at end of file
Bsth-admin/src/main/java/com/ruoyi/expand/controller/DriverSchedulingExpandController.java
@@ -3,18 +3,15 @@ package com.ruoyi.expand.controller; @@ -3,18 +3,15 @@ package com.ruoyi.expand.controller;
3 import java.util.List; 3 import java.util.List;
4 import javax.servlet.http.HttpServletResponse; 4 import javax.servlet.http.HttpServletResponse;
5 5
  6 +import com.ruoyi.common.global.Result;
  7 +import com.ruoyi.pojo.dto.SmartExpandDto;
6 import com.ruoyi.pojo.vo.ExpandResponseViewVo; 8 import com.ruoyi.pojo.vo.ExpandResponseViewVo;
  9 +import com.ruoyi.pojo.vo.SmartExpandVo;
  10 +import com.ruoyi.service.DriverSchedulingExpandSmartService;
7 import org.springframework.security.access.prepost.PreAuthorize; 11 import org.springframework.security.access.prepost.PreAuthorize;
8 import org.springframework.beans.factory.annotation.Autowired; 12 import org.springframework.beans.factory.annotation.Autowired;
9 import org.springframework.validation.annotation.Validated; 13 import org.springframework.validation.annotation.Validated;
10 -import org.springframework.web.bind.annotation.GetMapping;  
11 -import org.springframework.web.bind.annotation.PostMapping;  
12 -import org.springframework.web.bind.annotation.PutMapping;  
13 -import org.springframework.web.bind.annotation.DeleteMapping;  
14 -import org.springframework.web.bind.annotation.PathVariable;  
15 -import org.springframework.web.bind.annotation.RequestBody;  
16 -import org.springframework.web.bind.annotation.RequestMapping;  
17 -import org.springframework.web.bind.annotation.RestController; 14 +import org.springframework.web.bind.annotation.*;
18 import com.ruoyi.common.annotation.Log; 15 import com.ruoyi.common.annotation.Log;
19 import com.ruoyi.common.core.controller.BaseController; 16 import com.ruoyi.common.core.controller.BaseController;
20 import com.ruoyi.common.core.domain.AjaxResult; 17 import com.ruoyi.common.core.domain.AjaxResult;
@@ -37,6 +34,9 @@ public class DriverSchedulingExpandController extends BaseController @@ -37,6 +34,9 @@ public class DriverSchedulingExpandController extends BaseController
37 @Autowired 34 @Autowired
38 private IDriverSchedulingExpandService driverSchedulingExpandService; 35 private IDriverSchedulingExpandService driverSchedulingExpandService;
39 36
  37 + @Autowired
  38 + private DriverSchedulingExpandSmartService smartService;
  39 +
40 /** 40 /**
41 * 查询跟班设置列表 41 * 查询跟班设置列表
42 */ 42 */
@@ -70,6 +70,41 @@ public class DriverSchedulingExpandController extends BaseController @@ -70,6 +70,41 @@ public class DriverSchedulingExpandController extends BaseController
70 } 70 }
71 71
72 /** 72 /**
  73 + * 新增灵活跟班
  74 + */
  75 + @PreAuthorize("@ss.hasPermi('expand:expand:add')")
  76 + @Log(title = "新增灵活跟班", businessType = BusinessType.INSERT)
  77 + @PostMapping("addSmartExpand")
  78 + public Result<?> smartAdd(@Validated @RequestBody SmartExpandDto dto)
  79 + {
  80 + smartService.smartAdd(dto);
  81 + return Result.OK();
  82 + }
  83 +
  84 + /**
  85 + * 新增灵活跟班
  86 + */
  87 + @PreAuthorize("@ss.hasPermi('expand:expand:add')")
  88 + @Log(title = "新增灵活跟班", businessType = BusinessType.INSERT)
  89 + @GetMapping("querySmartExpand")
  90 + public Result<SmartExpandVo> querySmartExpand(@RequestParam("id") Long id )
  91 + {
  92 + return Result.OK(smartService.querySmartExpand(id));
  93 + }
  94 +
  95 + /**
  96 + * 新增灵活跟班
  97 + */
  98 + @PreAuthorize("@ss.hasPermi('expand:expand:add')")
  99 + @Log(title = "新增灵活跟班", businessType = BusinessType.INSERT)
  100 + @PutMapping("updateSmartExpand")
  101 + public Result<SmartExpandVo> updateSmartExpand(@RequestBody SmartExpandVo vo)
  102 + {
  103 + smartService.updateSmartExpand(vo);
  104 + return Result.OK();
  105 + }
  106 +
  107 + /**
73 * 修改跟班设置 108 * 修改跟班设置
74 */ 109 */
75 @PreAuthorize("@ss.hasPermi('expand:expand:edit')") 110 @PreAuthorize("@ss.hasPermi('expand:expand:edit')")
@@ -86,8 +121,9 @@ public class DriverSchedulingExpandController extends BaseController @@ -86,8 +121,9 @@ public class DriverSchedulingExpandController extends BaseController
86 @PreAuthorize("@ss.hasPermi('expand:expand:remove')") 121 @PreAuthorize("@ss.hasPermi('expand:expand:remove')")
87 @Log(title = "跟班设置", businessType = BusinessType.DELETE) 122 @Log(title = "跟班设置", businessType = BusinessType.DELETE)
88 @DeleteMapping("/{ids}") 123 @DeleteMapping("/{ids}")
89 - public AjaxResult remove(@PathVariable Long[] ids) 124 + public Result<?> remove(@PathVariable Long[] ids)
90 { 125 {
91 - return toAjax(driverSchedulingExpandService.deleteDriverSchedulingExpandByIds(ids)); 126 + smartService.deleteExpand(ids);
  127 + return Result.OK();
92 } 128 }
93 } 129 }
Bsth-admin/src/main/java/com/ruoyi/expand/domain/DriverSchedulingExpand.java
@@ -2,6 +2,7 @@ package com.ruoyi.expand.domain; @@ -2,6 +2,7 @@ package com.ruoyi.expand.domain;
2 2
3 import java.util.Date; 3 import java.util.Date;
4 import com.fasterxml.jackson.annotation.JsonFormat; 4 import com.fasterxml.jackson.annotation.JsonFormat;
  5 +import lombok.ToString;
5 import org.apache.commons.lang3.builder.ToStringBuilder; 6 import org.apache.commons.lang3.builder.ToStringBuilder;
6 import org.apache.commons.lang3.builder.ToStringStyle; 7 import org.apache.commons.lang3.builder.ToStringStyle;
7 import com.ruoyi.common.annotation.Excel; 8 import com.ruoyi.common.annotation.Excel;
@@ -16,6 +17,7 @@ import javax.validation.constraints.NotNull; @@ -16,6 +17,7 @@ import javax.validation.constraints.NotNull;
16 * @author guzijian 17 * @author guzijian
17 * @date 2023-09-12 18 * @date 2023-09-12
18 */ 19 */
  20 +@ToString
19 public class DriverSchedulingExpand extends BaseEntity 21 public class DriverSchedulingExpand extends BaseEntity
20 { 22 {
21 private static final long serialVersionUID = 1L; 23 private static final long serialVersionUID = 1L;
@@ -50,12 +52,22 @@ public class DriverSchedulingExpand extends BaseEntity @@ -50,12 +52,22 @@ public class DriverSchedulingExpand extends BaseEntity
50 @NotNull(message = "结束日期不能为空") 52 @NotNull(message = "结束日期不能为空")
51 private Date endDate; 53 private Date endDate;
52 54
53 - public void setId(Long id) 55 + private Integer type;
  56 +
  57 + public Integer getType() {
  58 + return type;
  59 + }
  60 +
  61 + public void setType(Integer type) {
  62 + this.type = type;
  63 + }
  64 +
  65 + public void setId(Long id)
54 { 66 {
55 this.id = id; 67 this.id = id;
56 } 68 }
57 69
58 - public Long getId() 70 + public Long getId()
59 { 71 {
60 return id; 72 return id;
61 } 73 }
@@ -105,20 +117,4 @@ public class DriverSchedulingExpand extends BaseEntity @@ -105,20 +117,4 @@ public class DriverSchedulingExpand extends BaseEntity
105 return endDate; 117 return endDate;
106 } 118 }
107 119
108 - @Override  
109 - public String toString() {  
110 - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)  
111 - .append("id", getId())  
112 - .append("status", getStatus())  
113 - .append("masterJobCode", getMasterJobCode())  
114 - .append("slaveJobCode", getSlaveJobCode())  
115 - .append("startDate", getStartDate())  
116 - .append("endDate", getEndDate())  
117 - .append("createTime", getCreateTime())  
118 - .append("updateTime", getUpdateTime())  
119 - .append("createBy", getCreateBy())  
120 - .append("updateBy", getUpdateBy())  
121 - .append("remark", getRemark())  
122 - .toString();  
123 - }  
124 } 120 }
Bsth-admin/src/main/java/com/ruoyi/expand/service/impl/DriverSchedulingExpandServiceImpl.java
@@ -35,6 +35,7 @@ public class DriverSchedulingExpandServiceImpl implements IDriverSchedulingExpan @@ -35,6 +35,7 @@ public class DriverSchedulingExpandServiceImpl implements IDriverSchedulingExpan
35 @Autowired 35 @Autowired
36 private DriverMapper driverMapper; 36 private DriverMapper driverMapper;
37 37
  38 +
38 /** 39 /**
39 * 查询跟班设置 40 * 查询跟班设置
40 * 41 *
Bsth-admin/src/main/java/com/ruoyi/interceptor/MybatisPlusDAOInterceptor.java 0 → 100644
  1 +package com.ruoyi.interceptor;
  2 +
  3 +import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
  4 +import com.ruoyi.common.utils.SecurityUtils;
  5 +import org.apache.ibatis.reflection.MetaObject;
  6 +import org.springframework.stereotype.Component;
  7 +
  8 +import java.util.Date;
  9 +import java.util.Objects;
  10 +
  11 +/**
  12 + * @author 20412
  13 + */
  14 +@Component
  15 +public class MybatisPlusDAOInterceptor implements MetaObjectHandler {
  16 +
  17 + @Override
  18 + public void insertFill(MetaObject metaObject) {
  19 + if (metaObject.hasGetter("createTime")){
  20 + this.strictInsertFill(metaObject, "createTime", Date.class, new Date());
  21 + }
  22 +
  23 + if (metaObject.hasGetter("createBy")){
  24 + if (!Objects.isNull(SecurityUtils.getUsername())){
  25 + this.strictInsertFill(metaObject, "createBy", String.class, SecurityUtils.getUsername());
  26 + }
  27 + }
  28 +
  29 + if (metaObject.hasGetter("updateTime")){
  30 + this.strictInsertFill(metaObject, "updateTime", Date.class, new Date());
  31 + }
  32 + if (metaObject.hasGetter("updateBy")){
  33 + if (!Objects.isNull(SecurityUtils.getUsername())){
  34 + this.strictInsertFill(metaObject, "updateBy", String.class, SecurityUtils.getUsername());
  35 + }
  36 + }
  37 + }
  38 +
  39 + @Override
  40 + public void updateFill(MetaObject metaObject) {
  41 + if (metaObject.hasGetter("updateTime")){
  42 + this.strictUpdateFill(metaObject, "updateTime", Date.class, new Date());
  43 + }
  44 + if (metaObject.hasGetter("updateBy")){
  45 + this.strictUpdateFill(metaObject,"updateBy",String.class,SecurityUtils.getUsername());
  46 + }
  47 + }
  48 +}
0 \ No newline at end of file 49 \ No newline at end of file
Bsth-admin/src/main/java/com/ruoyi/job/DriverJob.java
@@ -19,6 +19,7 @@ import com.ruoyi.pojo.request.TokenRequestVo; @@ -19,6 +19,7 @@ import com.ruoyi.pojo.request.TokenRequestVo;
19 import com.ruoyi.pojo.response.ResponseSchedulingDto; 19 import com.ruoyi.pojo.response.ResponseSchedulingDto;
20 import com.ruoyi.pojo.response.personnel.*; 20 import com.ruoyi.pojo.response.personnel.*;
21 import com.ruoyi.pojo.vo.ExpandResponseVo; 21 import com.ruoyi.pojo.vo.ExpandResponseVo;
  22 +import com.ruoyi.service.DriverSchedulingExpandSmartService;
22 import com.ruoyi.service.RuleAttendanceMainService; 23 import com.ruoyi.service.RuleAttendanceMainService;
23 import com.ruoyi.service.RuleNumSettingService; 24 import com.ruoyi.service.RuleNumSettingService;
24 import com.ruoyi.service.ThreadJobService; 25 import com.ruoyi.service.ThreadJobService;
@@ -85,6 +86,9 @@ public class DriverJob implements InitializingBean { @@ -85,6 +86,9 @@ public class DriverJob implements InitializingBean {
85 private RuleNumSettingService ruleNumSettingService; 86 private RuleNumSettingService ruleNumSettingService;
86 87
87 @Autowired 88 @Autowired
  89 + private DriverSchedulingExpandSmartService driverSchedulingExpandSmartService;
  90 +
  91 + @Autowired
88 private IDriverService driverService; 92 private IDriverService driverService;
89 93
90 @Autowired 94 @Autowired
@@ -114,6 +118,7 @@ public class DriverJob implements InitializingBean { @@ -114,6 +118,7 @@ public class DriverJob implements InitializingBean {
114 118
115 119
116 private static DriverSchedulingExpandMapper EXPAND_MAPPER; 120 private static DriverSchedulingExpandMapper EXPAND_MAPPER;
  121 + private static DriverSchedulingExpandSmartService EXPAND_SMART_SERVICE;
117 private static RuleNumSettingService RULE_NUM_SETTING_SERVICE; 122 private static RuleNumSettingService RULE_NUM_SETTING_SERVICE;
118 private static RuleAttendanceMainService ATTENDANCE_MAIN_SERVICE; 123 private static RuleAttendanceMainService ATTENDANCE_MAIN_SERVICE;
119 private static NowSchedulingCache NOW_SCHEDULING_CACHE; 124 private static NowSchedulingCache NOW_SCHEDULING_CACHE;
@@ -287,6 +292,13 @@ public class DriverJob implements InitializingBean { @@ -287,6 +292,13 @@ public class DriverJob implements InitializingBean {
287 } 292 }
288 293
289 /** 294 /**
  295 + * 计算灵活跟班
  296 + */
  297 + public void computedExpandSmart() {
  298 + EXPAND_SMART_SERVICE.computedExpand();
  299 + }
  300 +
  301 + /**
290 * 生成排班 每天早上在获取调度排班前生成 302 * 生成排班 每天早上在获取调度排班前生成
291 */ 303 */
292 public void createAttendance() { 304 public void createAttendance() {
@@ -601,5 +613,6 @@ public class DriverJob implements InitializingBean { @@ -601,5 +613,6 @@ public class DriverJob implements InitializingBean {
601 RULE_NUM_SETTING_SERVICE = ruleNumSettingService; 613 RULE_NUM_SETTING_SERVICE = ruleNumSettingService;
602 EXPAND_MAPPER = expandMapper; 614 EXPAND_MAPPER = expandMapper;
603 ATTENDANCE_MAIN_SERVICE = attendanceMainService; 615 ATTENDANCE_MAIN_SERVICE = attendanceMainService;
  616 + EXPAND_SMART_SERVICE = driverSchedulingExpandSmartService;
604 } 617 }
605 } 618 }
Bsth-admin/src/main/java/com/ruoyi/mapper/DriverSchedulingExpandSmartMapper.java 0 → 100644
  1 +package com.ruoyi.mapper;
  2 +
  3 +import com.ruoyi.domain.DriverSchedulingExpandSmart;
  4 +import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  5 +import com.ruoyi.pojo.vo.SmartExpandVo;
  6 +import org.apache.ibatis.annotations.Param;
  7 +
  8 +import java.util.List;
  9 +
  10 +/**
  11 +* @author 20412
  12 +* @description 针对表【driver_scheduling_expand_smart(灵活跟班表)】的数据库操作Mapper
  13 +* @createDate 2024-03-07 16:49:40
  14 +* @Entity .domain.DriverSchedulingExpandSmart
  15 +*/
  16 +public interface DriverSchedulingExpandSmartMapper extends BaseMapper<DriverSchedulingExpandSmart> {
  17 +
  18 + SmartExpandVo querySmartExpand(@Param("id") Long id);
  19 +
  20 + List<SmartExpandVo> querySmartExpandAll();
  21 +}
  22 +
  23 +
  24 +
  25 +
Bsth-admin/src/main/java/com/ruoyi/pojo/dto/SmartExpandDto.java 0 → 100644
  1 +package com.ruoyi.pojo.dto;
  2 +
  3 +import lombok.Data;
  4 +
  5 +import java.util.Date;
  6 +import java.util.List;
  7 +
  8 +/**
  9 + * @author 20412
  10 + */
  11 +@Data
  12 +public class SmartExpandDto {
  13 + private String slaveJobCode;
  14 + private Integer type;
  15 + private String remark;
  16 + private List<Activity> activities;
  17 +
  18 + @Data
  19 + public static class Activity {
  20 + private String name;
  21 + private String masterJobCode;
  22 + private Date startDate;
  23 + private Date endDate;
  24 + }
  25 +}
Bsth-admin/src/main/java/com/ruoyi/pojo/vo/ExpandResponseVo.java
@@ -18,6 +18,7 @@ public class ExpandResponseVo { @@ -18,6 +18,7 @@ public class ExpandResponseVo {
18 private Integer status; 18 private Integer status;
19 private Date startDate; 19 private Date startDate;
20 private Date endDate; 20 private Date endDate;
  21 + private Integer type;
21 22
22 23
23 } 24 }
Bsth-admin/src/main/java/com/ruoyi/pojo/vo/SmartExpandVo.java 0 → 100644
  1 +package com.ruoyi.pojo.vo;
  2 +
  3 +import com.ruoyi.pojo.dto.SmartExpandDto;
  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 SmartExpandVo {
  14 + private Long id;
  15 + private String slaveJobCode;
  16 + private Integer type;
  17 + private String remark;
  18 + private List<Activity> activities;
  19 +
  20 + @Data
  21 + public static class Activity {
  22 + private String uuId;
  23 + private String name;
  24 + private String masterJobCode;
  25 + private Date startDate;
  26 + private Date endDate;
  27 + }
  28 +}
Bsth-admin/src/main/java/com/ruoyi/service/DriverSchedulingExpandSmartService.java 0 → 100644
  1 +package com.ruoyi.service;
  2 +
  3 +import com.ruoyi.domain.DriverSchedulingExpandSmart;
  4 +import com.baomidou.mybatisplus.extension.service.IService;
  5 +import com.ruoyi.pojo.dto.SmartExpandDto;
  6 +import com.ruoyi.pojo.vo.SmartExpandVo;
  7 +
  8 +/**
  9 +* @author 20412
  10 +* @description 针对表【driver_scheduling_expand_smart(灵活跟班表)】的数据库操作Service
  11 +* @createDate 2024-03-07 16:49:40
  12 +*/
  13 +public interface DriverSchedulingExpandSmartService extends IService<DriverSchedulingExpandSmart> {
  14 +
  15 + void smartAdd(SmartExpandDto dto);
  16 +
  17 + void computedExpand();
  18 +
  19 + SmartExpandVo querySmartExpand(Long id);
  20 +
  21 + void updateSmartExpand(SmartExpandVo vo);
  22 +
  23 + void deleteExpand(Long[] ids);
  24 +}
Bsth-admin/src/main/java/com/ruoyi/service/impl/DriverSchedulingExpandSmartServiceImpl.java 0 → 100644
  1 +package com.ruoyi.service.impl;
  2 +
  3 +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  4 +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
  5 +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  6 +import com.ruoyi.common.exception.ServiceException;
  7 +import com.ruoyi.common.global.ResultCode;
  8 +import com.ruoyi.common.utils.StringUtils;
  9 +import com.ruoyi.common.utils.bean.BeanUtils;
  10 +import com.ruoyi.domain.DriverSchedulingExpandSmart;
  11 +import com.ruoyi.expand.domain.DriverSchedulingExpand;
  12 +import com.ruoyi.expand.mapper.DriverSchedulingExpandMapper;
  13 +import com.ruoyi.expand.service.IDriverSchedulingExpandService;
  14 +import com.ruoyi.pojo.dto.SmartExpandDto;
  15 +import com.ruoyi.pojo.vo.SmartExpandVo;
  16 +import com.ruoyi.service.DriverSchedulingExpandSmartService;
  17 +import com.ruoyi.mapper.DriverSchedulingExpandSmartMapper;
  18 +import com.ruoyi.utils.ConstDateUtil;
  19 +import com.ruoyi.utils.ToolUtils;
  20 +import lombok.extern.slf4j.Slf4j;
  21 +import org.springframework.beans.BeansException;
  22 +import org.springframework.beans.factory.annotation.Autowired;
  23 +import org.springframework.stereotype.Service;
  24 +import org.springframework.transaction.annotation.Transactional;
  25 +
  26 +import java.util.ArrayList;
  27 +import java.util.Comparator;
  28 +import java.util.Date;
  29 +import java.util.List;
  30 +
  31 +/**
  32 + * @author 20412
  33 + * @description 针对表【driver_scheduling_expand_smart(灵活跟班表)】的数据库操作Service实现
  34 + * @createDate 2024-03-07 16:49:40
  35 + */
  36 +@Service
  37 +@Slf4j
  38 +public class DriverSchedulingExpandSmartServiceImpl extends ServiceImpl<DriverSchedulingExpandSmartMapper, DriverSchedulingExpandSmart>
  39 + implements DriverSchedulingExpandSmartService {
  40 +
  41 + @Autowired
  42 + private IDriverSchedulingExpandService expandService;
  43 +
  44 + @Autowired
  45 + private DriverSchedulingExpandMapper expandMapper;
  46 +
  47 + @Override
  48 + @Transactional(rollbackFor = Exception.class)
  49 + public void smartAdd(SmartExpandDto dto) {
  50 + List<DriverSchedulingExpandSmart> list = new ArrayList<>(dto.getActivities().size());
  51 + for (SmartExpandDto.Activity activity : dto.getActivities()) {
  52 + DriverSchedulingExpandSmart smart = new DriverSchedulingExpandSmart();
  53 + BeanUtils.copyProperties(activity, smart, "id");
  54 + smart.setSlaveJobCode(dto.getSlaveJobCode());
  55 + list.add(smart);
  56 + }
  57 + list.sort(Comparator.comparing(DriverSchedulingExpandSmart::getStartDate));
  58 + // 校验跟班时间正确
  59 + isExpandCorrect(list);
  60 + // 保存记录
  61 + DriverSchedulingExpand expand = new DriverSchedulingExpand();
  62 + BeanUtils.copyProperties(list.get(0), expand);
  63 + expand.setType(dto.getType());
  64 + expand.setRemark(dto.getRemark());
  65 + expandService.insertDriverSchedulingExpand(expand);
  66 + for (DriverSchedulingExpandSmart item : list) {
  67 + item.setExpandId(expand.getId().toString());
  68 + }
  69 + this.saveBatch(list);
  70 + }
  71 +
  72 + @Override
  73 + public void computedExpand() {
  74 + try {
  75 + List<SmartExpandVo> vos = baseMapper.querySmartExpandAll();
  76 + int sum = 0;
  77 + for (SmartExpandVo vo : vos) {
  78 + SmartExpandVo.Activity activity = handlerSmartExpand(vo);
  79 + DriverSchedulingExpand expand = new DriverSchedulingExpand();
  80 + BeanUtils.copyProperties(activity, expand);
  81 + expand.setId(vo.getId());
  82 + expand.setType(1);
  83 + expand.setSlaveJobCode(vo.getSlaveJobCode());
  84 + int result = expandMapper.updateDriverSchedulingExpand(expand);
  85 + sum += result;
  86 + }
  87 + log.info("跟班计算完毕,共修改{}数据", sum);
  88 +
  89 + } catch (Exception e) {
  90 + log.info("跟班计算出现问题:{}", e.getMessage());
  91 + }
  92 + }
  93 +
  94 + private SmartExpandVo.Activity handlerSmartExpand(SmartExpandVo vo) {
  95 + vo.getActivities().sort(Comparator.comparing(SmartExpandVo.Activity::getStartDate));
  96 + Date date = new Date();
  97 + for (int i = 0; i < vo.getActivities().size(); i++) {
  98 + int compare = StringUtils.compare(ConstDateUtil.formatDate(date), ConstDateUtil.formatDate(vo.getActivities().get(i).getEndDate()));
  99 + if (compare > 0 && i < vo.getActivities().size() - 1) {
  100 + continue;
  101 + }
  102 + return vo.getActivities().get(i);
  103 + }
  104 + log.error("没有找到跟班对象:{}", vo);
  105 + throw new ServiceException("未知错误", ResultCode.CODE_500.getCode());
  106 + }
  107 +
  108 + @Override
  109 + public SmartExpandVo querySmartExpand(Long id) {
  110 + return baseMapper.querySmartExpand(id);
  111 + }
  112 +
  113 + @Override
  114 + @Transactional(rollbackFor = Exception.class)
  115 + public void updateSmartExpand(SmartExpandVo vo) {
  116 + List<DriverSchedulingExpandSmart> list = new ArrayList<>(vo.getActivities().size());
  117 + // 删除老数据
  118 + LambdaQueryWrapper<DriverSchedulingExpandSmart> qw = new LambdaQueryWrapper<>();
  119 + qw.eq(DriverSchedulingExpandSmart::getExpandId, vo.getId());
  120 + remove(qw);
  121 + // COPY
  122 + for (SmartExpandVo.Activity activity : vo.getActivities()) {
  123 + DriverSchedulingExpandSmart smart = new DriverSchedulingExpandSmart();
  124 + BeanUtils.copyProperties(activity, smart, "id");
  125 + smart.setSlaveJobCode(vo.getSlaveJobCode());
  126 + list.add(smart);
  127 + }
  128 + list.sort(Comparator.comparing(DriverSchedulingExpandSmart::getStartDate));
  129 + for (DriverSchedulingExpandSmart item : list) {
  130 + item.setExpandId(vo.getId().toString());
  131 + }
  132 + this.saveBatch(list);
  133 + // 更新当前跟班显示
  134 + DriverSchedulingExpandSmart smart = ToolUtils.computedShowSmart(list);
  135 + DriverSchedulingExpand expand = new DriverSchedulingExpand();
  136 + BeanUtils.copyProperties(expand, smart, "id");
  137 + expand.setRemark(vo.getRemark());
  138 + expand.setType(vo.getType());
  139 + expand.setId(vo.getId());
  140 + expandService.updateDriverSchedulingExpand(expand);
  141 + }
  142 +
  143 + @Override
  144 + @Transactional(rollbackFor = Exception.class)
  145 + public void deleteExpand(Long[] ids) {
  146 + expandService.deleteDriverSchedulingExpandByIds(ids);
  147 + LambdaQueryWrapper<DriverSchedulingExpandSmart> qw = new LambdaQueryWrapper<>();
  148 + qw.eq(DriverSchedulingExpandSmart::getExpandId, ids[0]);
  149 + remove(qw);
  150 + }
  151 +
  152 + private void isExpandCorrect(List<DriverSchedulingExpandSmart> list) {
  153 + // 校验跟班人选中的时间日期是否合法
  154 + long day = 1000 * 60 * 60 * 24;
  155 + for (int i = 0; i < list.size() - 1; i++) {
  156 + if (list.get(i + 1).getStartDate().getTime() - list.get(i).getEndDate().getTime() < day) {
  157 + String errMsg = "时间区间设置不正确,请确保时间是递增的" + ConstDateUtil.formatDate("yyyy-MM-dd", list.get(i).getEndDate()) + "->" + ConstDateUtil.formatDate("yyyy-MM-dd", list.get(i + 1).getStartDate());
  158 + throw new ServiceException(errMsg, ResultCode.CODE_400.getCode());
  159 + }
  160 + }
  161 + }
  162 +}
  163 +
  164 +
  165 +
  166 +
Bsth-admin/src/main/java/com/ruoyi/utils/ToolUtils.java
1 package com.ruoyi.utils; 1 package com.ruoyi.utils;
2 2
  3 +import com.ruoyi.common.exception.ServiceException;
  4 +import com.ruoyi.common.global.Result;
  5 +import com.ruoyi.common.global.ResultCode;
  6 +import com.ruoyi.common.utils.StringUtils;
3 import com.ruoyi.common.utils.uuid.UUID; 7 import com.ruoyi.common.utils.uuid.UUID;
4 import com.ruoyi.domain.DriverScheduling; 8 import com.ruoyi.domain.DriverScheduling;
  9 +import com.ruoyi.domain.DriverSchedulingExpandSmart;
5 import com.ruoyi.domain.RuleAttendanceMain; 10 import com.ruoyi.domain.RuleAttendanceMain;
6 import com.ruoyi.num.domain.RuleNum; 11 import com.ruoyi.num.domain.RuleNum;
7 import com.ruoyi.pojo.dto.RuleSchedulingDto; 12 import com.ruoyi.pojo.dto.RuleSchedulingDto;
8 import com.ruoyi.scheduling.domain.RuleScheduling; 13 import com.ruoyi.scheduling.domain.RuleScheduling;
  14 +import org.slf4j.Logger;
  15 +import org.slf4j.LoggerFactory;
9 import org.springframework.beans.BeanUtils; 16 import org.springframework.beans.BeanUtils;
10 17
  18 +import java.util.Comparator;
11 import java.util.Date; 19 import java.util.Date;
  20 +import java.util.List;
12 import java.util.Objects; 21 import java.util.Objects;
13 22
14 import static com.ruoyi.common.ConstDriverProperties.BC_TYPE_IN; 23 import static com.ruoyi.common.ConstDriverProperties.BC_TYPE_IN;
@@ -20,6 +29,8 @@ import static com.ruoyi.common.SignStatusEnum.SIGN_STATUS_ZONE_ENUM; @@ -20,6 +29,8 @@ import static com.ruoyi.common.SignStatusEnum.SIGN_STATUS_ZONE_ENUM;
20 29
21 public class ToolUtils { 30 public class ToolUtils {
22 31
  32 + private static final Logger log = LoggerFactory.getLogger(ToolUtils.class);
  33 +
23 public static String getUUID() { 34 public static String getUUID() {
24 return UUID.randomUUID().toString().replaceAll("-", ""); 35 return UUID.randomUUID().toString().replaceAll("-", "");
25 } 36 }
@@ -95,4 +106,20 @@ public class ToolUtils { @@ -95,4 +106,20 @@ public class ToolUtils {
95 } 106 }
96 107
97 108
  109 + public static DriverSchedulingExpandSmart computedShowSmart(List<DriverSchedulingExpandSmart> list) {
  110 + // 遍历 规则 范围内-》 范围外 往后显示
  111 + list.sort(Comparator.comparing(DriverSchedulingExpandSmart::getStartDate));
  112 + Date date = new Date();
  113 + for (int i = 0; i < list.size(); i++) {
  114 + int compare = StringUtils.compare(ConstDateUtil.formatDate(date), ConstDateUtil.formatDate(list.get(i).getEndDate()));
  115 + if (compare > 0 && i < list.size() - 1) {
  116 + continue;
  117 + }
  118 + return list.get(i);
  119 + }
  120 +
  121 + log.error("没有找到跟班对象:{}", list);
  122 + throw new ServiceException("未知错误", ResultCode.CODE_500.getCode());
  123 + }
  124 +
98 } 125 }
Bsth-admin/src/main/resources/mapper/DriverSchedulingExpandSmartMapper.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.DriverSchedulingExpandSmartMapper">
  6 +
  7 + <resultMap id="BaseResultMap" type="com.ruoyi.domain.DriverSchedulingExpandSmart">
  8 + <id property="id" column="id" jdbcType="VARCHAR"/>
  9 + <result property="name" column="name" jdbcType="VARCHAR"/>
  10 + <result property="expandId" column="expand_id" jdbcType="VARCHAR"/>
  11 + <result property="masterJobCode" column="master_job_code" jdbcType="VARCHAR"/>
  12 + <result property="slaveJobCode" column="slave_job_code" jdbcType="VARCHAR"/>
  13 + <result property="startDate" column="start_date" jdbcType="DATE"/>
  14 + <result property="endDate" column="end_date" jdbcType="DATE"/>
  15 + <result property="createBy" column="create_by" jdbcType="VARCHAR"/>
  16 + <result property="updateBy" column="update_by" jdbcType="VARCHAR"/>
  17 + <result property="createTime" column="create_time" jdbcType="TIMESTAMP"/>
  18 + <result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/>
  19 + <result property="remark" column="remark" jdbcType="VARCHAR"/>
  20 + </resultMap>
  21 + <resultMap id="SmartExpandVo" type="com.ruoyi.pojo.vo.SmartExpandVo">
  22 + <id property="id" column="id" jdbcType="VARCHAR"/>
  23 + <result property="slaveJobCode" column="slave_job_code" jdbcType="VARCHAR"/>
  24 + <result property="type" column="type" jdbcType="TINYINT"/>
  25 + <result property="remark" column="remark" jdbcType="VARCHAR"/>
  26 + <collection property="activities" ofType="com.ruoyi.pojo.vo.SmartExpandVo$Activity">
  27 + <result column="name" property="name" jdbcType="VARCHAR"/>
  28 + <result column="smart_id" property="uuId" jdbcType="VARCHAR"/>
  29 + <result column="master_job_code" property="masterJobCode" jdbcType="VARCHAR"/>
  30 + <result column="start_date" property="startDate" jdbcType="DATE"/>
  31 + <result column="end_date" property="endDate" jdbcType="DATE"/>
  32 + </collection>
  33 + </resultMap>
  34 +
  35 + <sql id="Base_Column_List">
  36 + id,expand_id,`name`,master_job_code,
  37 + slave_job_code,start_date,end_date,
  38 + create_by,update_by,create_time,
  39 + update_time,remark
  40 + </sql>
  41 + <select id="querySmartExpand" resultMap="SmartExpandVo" resultType="com.ruoyi.pojo.vo.SmartExpandVo">
  42 + SELECT
  43 + expand.id,
  44 + expand.slave_job_code,
  45 + expand.type,
  46 + expand.remark,
  47 + smart.id smart_id,
  48 + smart.start_date,
  49 + smart.end_date,
  50 + smart.master_job_code,
  51 + smart.`name`
  52 + FROM
  53 + driver_scheduling_expand expand,
  54 + driver_scheduling_expand_smart smart
  55 + WHERE
  56 + expand.id = smart.expand_id
  57 + AND expand.id = #{id}
  58 + </select>
  59 + <select id="querySmartExpandAll" resultMap="SmartExpandVo" resultType="com.ruoyi.pojo.vo.SmartExpandVo">
  60 + SELECT
  61 + expand.id,
  62 + expand.slave_job_code,
  63 + expand.type,
  64 + expand.remark,
  65 + smart.id smart_id,
  66 + smart.start_date,
  67 + smart.end_date,
  68 + smart.master_job_code,
  69 + smart.`name`
  70 + FROM
  71 + driver_scheduling_expand expand,
  72 + driver_scheduling_expand_smart smart
  73 + WHERE
  74 + expand.id = smart.expand_id
  75 + </select>
  76 +</mapper>
Bsth-admin/src/main/resources/mapper/expand/DriverSchedulingExpandMapper.xml
@@ -16,6 +16,7 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot; @@ -16,6 +16,7 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
16 <result property="createBy" column="create_by" /> 16 <result property="createBy" column="create_by" />
17 <result property="updateBy" column="update_by" /> 17 <result property="updateBy" column="update_by" />
18 <result property="remark" column="remark" /> 18 <result property="remark" column="remark" />
  19 + <result property="type" column="type" />
19 </resultMap> 20 </resultMap>
20 21
21 <resultMap id="DriverSchedulingExpandDto" type="com.ruoyi.pojo.vo.ExpandResponseVo"> 22 <resultMap id="DriverSchedulingExpandDto" type="com.ruoyi.pojo.vo.ExpandResponseVo">
@@ -28,10 +29,11 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot; @@ -28,10 +29,11 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
28 <result property="slaveName" column="slaveName" /> 29 <result property="slaveName" column="slaveName" />
29 <result property="slaveFleetName" column="slaveFleetName" /> 30 <result property="slaveFleetName" column="slaveFleetName" />
30 <result property="slavePosts" column="slavePosts" /> 31 <result property="slavePosts" column="slavePosts" />
  32 + <result property="type" column="type" />
31 </resultMap> 33 </resultMap>
32 34
33 <sql id="selectDriverSchedulingExpandVo"> 35 <sql id="selectDriverSchedulingExpandVo">
34 - select id, status, master_job_code, slave_job_code, start_date, end_date, create_time, update_time, create_by, update_by, remark from driver_scheduling_expand 36 + select id, status, master_job_code, slave_job_code, start_date, end_date, create_time, update_time, create_by, update_by, remark,type from driver_scheduling_expand
35 </sql> 37 </sql>
36 38
37 <select id="selectDriverSchedulingExpandList" parameterType="DriverSchedulingExpand" resultMap="DriverSchedulingExpandResult"> 39 <select id="selectDriverSchedulingExpandList" parameterType="DriverSchedulingExpand" resultMap="DriverSchedulingExpandResult">
@@ -80,6 +82,7 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot; @@ -80,6 +82,7 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
80 <if test="createBy != null">create_by,</if> 82 <if test="createBy != null">create_by,</if>
81 <if test="updateBy != null">update_by,</if> 83 <if test="updateBy != null">update_by,</if>
82 <if test="remark != null">remark,</if> 84 <if test="remark != null">remark,</if>
  85 + <if test="type != null">type,</if>
83 </trim> 86 </trim>
84 <trim prefix="values (" suffix=")" suffixOverrides=","> 87 <trim prefix="values (" suffix=")" suffixOverrides=",">
85 <if test="status != null">#{status},</if> 88 <if test="status != null">#{status},</if>
@@ -92,6 +95,7 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot; @@ -92,6 +95,7 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
92 <if test="createBy != null">#{createBy},</if> 95 <if test="createBy != null">#{createBy},</if>
93 <if test="updateBy != null">#{updateBy},</if> 96 <if test="updateBy != null">#{updateBy},</if>
94 <if test="remark != null">#{remark},</if> 97 <if test="remark != null">#{remark},</if>
  98 + <if test="type != null">#{type},</if>
95 </trim> 99 </trim>
96 </insert> 100 </insert>
97 101
@@ -108,6 +112,7 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot; @@ -108,6 +112,7 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
108 <if test="createBy != null">create_by = #{createBy},</if> 112 <if test="createBy != null">create_by = #{createBy},</if>
109 <if test="updateBy != null">update_by = #{updateBy},</if> 113 <if test="updateBy != null">update_by = #{updateBy},</if>
110 <if test="remark != null">remark = #{remark},</if> 114 <if test="remark != null">remark = #{remark},</if>
  115 + <if test="type != null">`type` = #{type},</if>
111 </trim> 116 </trim>
112 where id = #{id} 117 where id = #{id}
113 </update> 118 </update>
Bsth-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
@@ -111,7 +111,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter @@ -111,7 +111,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
111 // 过滤请求 111 // 过滤请求
112 .authorizeRequests() 112 .authorizeRequests()
113 // 对于登录login 注册register 验证码captchaImage 允许匿名访问 113 // 对于登录login 注册register 验证码captchaImage 允许匿名访问
114 - .antMatchers("/big/view/**","/report/list/**","/system/dict/data/**","/app/version/check/**","/app/checkDeviceHeart","/app/download","/driver/**","/in/**","/eexception/**","/equipment/**","/report/**","/login", "/register", "/captchaImage").permitAll() 114 + .antMatchers("/big/view/queryNumberByType","/big/view/queryLineInfo/*","/big/view/querySignDetails","/report/list/**","/system/dict/data/**","/app/version/check/**","/app/checkDeviceHeart","/app/download","/driver/**","/in/**","/eexception/**","/equipment/**","/report/**","/login", "/register", "/captchaImage").permitAll()
115 // 静态资源,可匿名访问 115 // 静态资源,可匿名访问
116 .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll() 116 .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
117 .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll() 117 .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()