Commit 41a7284a733a0bef263c18af6ae5c51d18bd8ddf

Authored by guzijian
1 parent b0681714

fix: 更新文件

Showing 70 changed files with 2246 additions and 675 deletions
ruoyi-admin/pom.xml
... ... @@ -16,6 +16,12 @@
16 16 </description>
17 17  
18 18 <dependencies>
  19 + <!-- 邮箱starter依赖-->
  20 + <dependency>
  21 + <groupId>org.springframework.boot</groupId>
  22 + <artifactId>spring-boot-starter-mail</artifactId>
  23 + </dependency>
  24 + <!-- hutool工具包 -->
19 25 <dependency>
20 26 <groupId>cn.hutool</groupId>
21 27 <artifactId>hutool-all</artifactId>
... ...
ruoyi-admin/src/main/java/com/ruoyi/common/ConstEquipmentProperties.java
... ... @@ -29,10 +29,12 @@ public interface ConstEquipmentProperties {
29 29 * 设备脱机
30 30 */
31 31 String DEVICE_OFFLINE = "脱机";
  32 + Integer DEVICE_OFFLINE_NUM = 2;
32 33 /**
33 34 * 设备在线
34 35 */
35 36 String DEVICE_ONLINE = "在线";
  37 + Integer DEVICE_ONLINE_NUM = 1;
36 38 /**
37 39 * 脱机判断5分钟
38 40 */
... ...
ruoyi-admin/src/main/java/com/ruoyi/common/RuleSchedulingProperties.java 0 → 100644
  1 +package com.ruoyi.common;
  2 +
  3 +/**
  4 + * @author 20412
  5 + */
  6 +public interface RuleSchedulingProperties {
  7 + /**
  8 + * 无分段
  9 + */
  10 + Integer HAVE_SEGMENTATION = 2;
  11 + /**
  12 + * 有分段
  13 + */
  14 + Integer NO_SEGMENTATION = 1;
  15 +
  16 + /**
  17 + * 有隔天
  18 + */
  19 + Integer TOMORROW_YES = 2;
  20 + /**
  21 + * 有隔天
  22 + */
  23 + String TOMORROW_YES_STRING = "-隔天";
  24 + /**
  25 + * 无隔天
  26 + */
  27 + Integer TOMORROW_NO = 1;
  28 + String TOMORROW_NO_STRING = "-";
  29 +
  30 + /**
  31 + * 工时制
  32 + */
  33 + String WORK_HOUR_PLAN_NORMAL_STRING = "标准工时制";
  34 + String WORK_HOUR_PLAN_COMPREHENSIVE_STRING = "综合工时制";
  35 + String WORK_HOUR_PLAN_DYNAMIC_STRING = "不定时工时制";
  36 +
  37 + Integer WORK_HOUR_PLAN_NORMAL = 0;
  38 + Integer WORK_HOUR_PLAN_COMPREHENSIVE = 1;
  39 + Integer WORK_HOUR_PLAN_DYNAMIC = 2;
  40 +
  41 + /**
  42 + * 工时类型
  43 + */
  44 + String WORK_HOUR_TYPE_ELASTIC_STRING = "弹性工时";
  45 + String WORK_HOUR_TYPE_FIXED_STRING = "固定工时";
  46 +
  47 + Integer WORK_HOUR_TYPE_ELASTIC = 0;
  48 + Integer WORK_HOUR_TYPE_FIXED = 1;
  49 +
  50 +}
... ...
ruoyi-admin/src/main/java/com/ruoyi/common/cache/NowSchedulingCache.java
... ... @@ -2,8 +2,11 @@ package com.ruoyi.common.cache;
2 2  
3 3 import cn.hutool.core.collection.CollectionUtil;
4 4 import com.ruoyi.driver.mapper.DriverSchedulingMapper;
  5 +import com.ruoyi.errorScheduling.domain.ErrorJobcode;
  6 +import com.ruoyi.errorScheduling.service.IErrorJobcodeService;
5 7 import com.ruoyi.in.domain.SignIn;
6   -import com.ruoyi.pojo.entity.DriverScheduling;
  8 +import com.ruoyi.domain.DriverScheduling;
  9 +import com.ruoyi.service.ThreadJobService;
7 10 import com.ruoyi.utils.ConstDateUtil;
8 11 import org.slf4j.Logger;
9 12 import org.slf4j.LoggerFactory;
... ... @@ -20,10 +23,11 @@ public class NowSchedulingCache {
20 23 * 当天初版排班
21 24 */
22 25 private static ConcurrentHashMap<String, Map<String, List<DriverScheduling>>> cacheNowDayScheduling = new ConcurrentHashMap<>();
  26 + private IErrorJobcodeService errorJobcodeService;
23 27  
24   -
25   - public NowSchedulingCache(DriverSchedulingMapper driverSchedulingMapper) {
  28 + public NowSchedulingCache(DriverSchedulingMapper driverSchedulingMapper,IErrorJobcodeService errorJobcodeService) {
26 29 this.schedulingMapper = driverSchedulingMapper;
  30 + this.errorJobcodeService = errorJobcodeService;
27 31 log.info("项目启动加载中获取排班表-----");
28 32 cacheNowDaySchedulingInit();
29 33 }
... ... @@ -34,12 +38,18 @@ public class NowSchedulingCache {
34 38 Map<String, List<DriverScheduling>> resultMap = new HashMap<>(800);
35 39 String date = ConstDateUtil.formatDate(ConstDateUtil.getTheSpecifiedNumberOfDaysOfTime(i));
36 40 List<DriverScheduling> schedulingList = schedulingMapper.queryToDay(date, null, null, null);
37   - handleResultMap(resultMap, schedulingList);
  41 + handlerResultMap(resultMap, schedulingList);
  42 + // 获取错误排班
  43 + List<ErrorJobcode> errorScheduling = ThreadJobService.getErrorScheduling(resultMap);
  44 + // 插入错误排班
  45 + errorJobcodeService.insertBatchErrorJobcode(errorScheduling);
  46 + // 更新缓存
38 47 cacheNowDayScheduling.put(date, resultMap);
39 48 }
40 49 }
41 50  
42   - private void handleResultMap(Map<String, List<DriverScheduling>> resultMap, List<DriverScheduling> schedulingList) {
  51 +
  52 + public static void handlerResultMap(Map<String, List<DriverScheduling>> resultMap, List<DriverScheduling> schedulingList) {
43 53 for (DriverScheduling scheduling : schedulingList) {
44 54 List<DriverScheduling> list = resultMap.get(scheduling.getJobCode());
45 55 if (CollectionUtil.isEmpty(list)) {
... ... @@ -94,13 +104,16 @@ public class NowSchedulingCache {
94 104 * @param signIn
95 105 */
96 106 public void updateCacheByJobCode(String key, Integer index, SignIn signIn) {
97   - DriverScheduling scheduling = cacheNowDayScheduling.get(key).get(signIn.getJobCode()).get(index);
98   - scheduling.setSignInId(signIn.getId());
99   - scheduling.setRemark(signIn.getRemark());
100   - scheduling.setExType(signIn.getExType());
101   - scheduling.setSignTime(signIn.getCreateTime());
102   - scheduling.setSignType(signIn.getType());
103   - scheduling.setAlcoholFlag(signIn.getAlcoholFlag());
104   - scheduling.setAlcoholIntake(signIn.getAlcoholIntake());
  107 + if (key.equals(ConstDateUtil.formatDate(ConstDateUtil.getTheSpecifiedNumberOfDaysOfTime(0)))
  108 + || key.equals(ConstDateUtil.formatDate(ConstDateUtil.getTheSpecifiedNumberOfDaysOfTime(-1)))){
  109 + DriverScheduling scheduling = cacheNowDayScheduling.get(key).get(signIn.getJobCode()).get(index);
  110 + scheduling.setSignInId(signIn.getId());
  111 + scheduling.setRemark(signIn.getRemark());
  112 + scheduling.setExType(signIn.getExType());
  113 + scheduling.setSignTime(signIn.getCreateTime());
  114 + scheduling.setSignType(signIn.getType());
  115 + scheduling.setAlcoholFlag(signIn.getAlcoholFlag());
  116 + scheduling.setAlcoholIntake(signIn.getAlcoholIntake());
  117 + }
105 118 }
106 119 }
... ...
ruoyi-admin/src/main/java/com/ruoyi/common/cache/SchedulingCache.java
1 1 package com.ruoyi.common.cache;
2 2  
3   -import cn.hutool.core.collection.CollectionUtil;
4   -import com.ruoyi.pojo.entity.DriverScheduling;
5 3 import com.ruoyi.pojo.response.ResponseSchedulingDto;
6   -import com.ruoyi.service.SchedulingService;
7 4 import com.ruoyi.utils.ConstDateUtil;
8 5 import org.slf4j.Logger;
9 6 import org.slf4j.LoggerFactory;
... ... @@ -44,8 +41,8 @@ public class SchedulingCache {
44 41  
45 42  
46 43 public SchedulingCache() {
47   - log.info("项目启动加载中-----");
48   - schedulingInit();
  44 + log.info("项目启动加载中获取实时班次-----");
  45 +// schedulingInit();
49 46 }
50 47  
51 48  
... ...
ruoyi-admin/src/main/java/com/ruoyi/common/global/GlobalDriverInfoCache.java deleted 100644 → 0
1   -package com.ruoyi.common.global;
2   -
3   -import com.ruoyi.in.domain.SignIn;
4   -import com.ruoyi.pojo.domain.SignInExpand;
5   -import org.springframework.stereotype.Component;
6   -
7   -import java.util.*;
8   -import java.util.concurrent.ConcurrentHashMap;
9   -
10   -/**
11   - * @author 20412
12   - */
13   -@Component
14   -public class GlobalDriverInfoCache {
15   - /**
16   - * 签到次数汇总
17   - */
18   - private final ConcurrentHashMap<String, List<SignInExpand>> userCurrentMap = new ConcurrentHashMap<>();
19   -
20   - /**
21   - * 驾驶员签到成功
22   - *
23   - * @param signIn
24   - */
25   - public void putDriverSignInSuccess(SignIn signIn) {
26   - ConcurrentHashMap<String, List<SignInExpand>> userCurrentMap = null;
27   - if (Objects.isNull(userCurrentMap.get(signIn.getJobCode()))) {
28   - SignInExpand signInExpand = new SignInExpand();
29   - signInExpand.setJobCode(signIn.getJobCode());
30   - signInExpand.setSignCount(signIn.getId() + ",");
31   - userCurrentMap.put(signIn.getJobCode(), new ArrayList<>(Arrays.asList(signInExpand)));
32   - } else {
33   - SignInExpand signInExpand = new SignInExpand();
34   - signInExpand.setJobCode(signIn.getJobCode());
35   - signInExpand.setSignCount(signInExpand.getSignCount() + signIn.getId() + ",");
36   - userCurrentMap.get(signIn.getJobCode()).add(signInExpand);
37   - }
38   - }
39   -
40   - }
41   -
42   -
ruoyi-admin/src/main/java/com/ruoyi/controller/AttendanceController.java 0 → 100644
  1 +package com.ruoyi.controller;
  2 +
  3 +import com.ruoyi.common.global.Result;
  4 +import com.ruoyi.pojo.vo.SchedulingRequestVo;
  5 +import com.ruoyi.service.AttendanceService;
  6 +import io.swagger.annotations.Api;
  7 +import io.swagger.annotations.ApiOperation;
  8 +import org.springframework.beans.factory.annotation.Autowired;
  9 +import org.springframework.web.bind.annotation.*;
  10 +
  11 +/**
  12 + * 考勤表controller
  13 + * @author 20412
  14 + */
  15 +@RestController
  16 +@RequestMapping("/attendance")
  17 +@Api(tags = "考勤管理")
  18 +public class AttendanceController {
  19 +
  20 + @Autowired
  21 + private AttendanceService attendanceService;
  22 +
  23 +
  24 + /**
  25 + * 获取指定人员信息
  26 + */
  27 + @ApiOperation("获取人员信息")
  28 + @GetMapping("/peoples")
  29 + public Result<?> getPeopleInfo(@RequestParam(value = "id",required = false) Long id){
  30 + return Result.OK(attendanceService.getDriverInfo(id));
  31 + }
  32 +
  33 + /**
  34 + * 获取排班
  35 + */
  36 + @ApiOperation("获取排班")
  37 + @GetMapping("/scheduling/list")
  38 + public Result<?> getSchedulingList(@ModelAttribute SchedulingRequestVo vo){
  39 + return Result.OK(attendanceService.getSchedulingList(vo));
  40 + }
  41 +}
... ...
ruoyi-admin/src/main/java/com/ruoyi/controller/ReportController.java
... ... @@ -50,7 +50,6 @@ public class ReportController {
50 50 return AjaxResult.success(reportService.getReportDetail(requestVo, response));
51 51 }
52 52  
53   -
54 53 @ApiOperation("异常报表集合查询")
55 54 @GetMapping("/error/list")
56 55 public AjaxResult getErrorList(@ApiParam @ModelAttribute ReportErrorRequestVo request) {
... ...
ruoyi-admin/src/main/java/com/ruoyi/pojo/entity/DriverScheduling.java renamed to ruoyi-admin/src/main/java/com/ruoyi/domain/DriverScheduling.java
1   -package com.ruoyi.pojo.entity;
  1 +package com.ruoyi.domain;
2 2  
3 3 import lombok.Data;
4 4 import org.apache.poi.hpsf.Decimal;
... ...
ruoyi-admin/src/main/java/com/ruoyi/pojo/domain/EquipmentDriverExpand.java renamed to ruoyi-admin/src/main/java/com/ruoyi/domain/EquipmentDriverExpand.java
1   -package com.ruoyi.pojo.domain;
  1 +package com.ruoyi.domain;
2 2  
3 3 import lombok.Data;
4 4  
... ...
ruoyi-admin/src/main/java/com/ruoyi/domain/RuleNumSetting.java 0 → 100644
  1 +package com.ruoyi.domain;
  2 +
  3 +import lombok.Data;
  4 +
  5 +/**
  6 + * 排班设置
  7 + * @author 20412
  8 + */
  9 +@Data
  10 +public class RuleNumSetting {
  11 +}
... ...
ruoyi-admin/src/main/java/com/ruoyi/pojo/domain/SignInExpand.java renamed to ruoyi-admin/src/main/java/com/ruoyi/domain/SignInExpand.java
1   -package com.ruoyi.pojo.domain;
  1 +package com.ruoyi.domain;
2 2  
3 3 import lombok.Data;
4 4 import org.springframework.format.annotation.DateTimeFormat;
... ...
ruoyi-admin/src/main/java/com/ruoyi/driver/mapper/DriverMapper.java
... ... @@ -7,6 +7,7 @@ import com.ruoyi.driver.domain.Driver;
7 7 import com.ruoyi.pojo.request.DriverRequestVo;
8 8 import com.ruoyi.pojo.response.DriverResponseVo;
9 9 import com.ruoyi.pojo.response.ResponseSchedulingDto;
  10 +import com.ruoyi.pojo.vo.PeopleResponseVo;
10 11 import org.apache.ibatis.annotations.Param;
11 12  
12 13 /**
... ... @@ -106,4 +107,17 @@ public interface DriverMapper
106 107 void updateDriverInfoByJobCodes(@Param("drivers") List<Driver> drivers);
107 108  
108 109 void saveScheduling(@Param("responseSchedulingDto") List<ResponseSchedulingDto> responseSchedulingDto);
  110 +
  111 + /**
  112 + * 获取已添加的考勤人员
  113 + * @param id
  114 + * @return
  115 + */
  116 + List<PeopleResponseVo> queryAttendanceInfoById(Long id);
  117 +
  118 + /**
  119 + * 获取所有可添加的考勤人员
  120 + * @return
  121 + */
  122 + List<PeopleResponseVo> queryAttendanceInfoAll();
109 123 }
... ...
ruoyi-admin/src/main/java/com/ruoyi/driver/mapper/DriverSchedulingMapper.java
1 1 package com.ruoyi.driver.mapper;
2 2  
3   -import com.ruoyi.pojo.entity.DriverScheduling;
4   -import com.ruoyi.pojo.request.ReportViewRequestVo;
5   -import com.ruoyi.pojo.response.ReportViewResponseVo;
6   -import com.ruoyi.pojo.response.ResponseSchedulingDto;
  3 +import com.ruoyi.domain.DriverScheduling;
7 4 import org.apache.ibatis.annotations.Param;
8 5  
9 6 import java.math.BigDecimal;
... ... @@ -16,7 +13,7 @@ import java.util.List;
16 13 public interface DriverSchedulingMapper {
17 14  
18 15  
19   - void insertRoster(@Param("list") List<DriverScheduling> list);
  16 + void insertRoster(List<DriverScheduling> list);
20 17  
21 18  
22 19 List<DriverScheduling> queryToDay(@Param("date") String date, @Param("name") String name,@Param("jobCode") String jobCode,@Param("lineName")String lineName );
... ...
ruoyi-admin/src/main/java/com/ruoyi/driver/service/impl/DriverServiceImpl.java
... ... @@ -25,8 +25,8 @@ import com.ruoyi.equipment.mapper.EquipmentMapper;
25 25 import com.ruoyi.framework.config.ServerConfig;
26 26 import com.ruoyi.job.DriverJob;
27 27 import com.ruoyi.pojo.DriverSignRecommendation;
28   -import com.ruoyi.pojo.domain.EquipmentDriverExpand;
29   -import com.ruoyi.pojo.entity.DriverScheduling;
  28 +import com.ruoyi.domain.EquipmentDriverExpand;
  29 +import com.ruoyi.domain.DriverScheduling;
30 30 import com.ruoyi.pojo.request.DriverRequestVo;
31 31 import com.ruoyi.pojo.request.DriverSignInRequestVo;
32 32 import com.ruoyi.pojo.request.FaceUpdateReqVo;
... ... @@ -150,16 +150,17 @@ public class DriverServiceImpl implements IDriverService {
150 150 LocalDateTime signTime = ConstDateUtil.getLocalDateTimeByLongTime(timeMap.get(index).getTimestamps());
151 151 long range = ChronoUnit.MINUTES.between(signTime, nowTime);
152 152 // 如果当前记录靠近签退,但是未到签退小于合法范围 上一次记录未签到,则返回签到记录
153   - if (BC_TYPE_IN.equals(timeMap.get(index).getBcType())
154   - && range < -60L
155   - && Objects.isNull(timeMap.get(index).getSignInId())
156   - && Objects.isNull(timeMap.get(index - 1).getSignInId())) {
157   - // 定位上次操作
158   - index = index - 1;
159   - }
  153 + if ( dto.size() > 1
  154 + && BC_TYPE_IN.equals(timeMap.get(index).getBcType())
  155 + && range < -60L
  156 + && Objects.isNull(timeMap.get(index).getSignInId())
  157 + && Objects.isNull(timeMap.get(index - 1).getSignInId())) {
  158 + // 定位上次操作
  159 + index = index - 1;
  160 + }
160 161  
161 162 // 如果当前记录是异常的记录且还在目前还在签到范围内
162   - if (!Objects.isNull(timeMap.get(index).getSignInId())) {
  163 + if (!Objects.isNull(timeMap.get(index).getSignInId()) && dto.size() > 1) {
163 164 LocalDateTime endTime = ConstDateUtil.getLocalDateTimeByLongTime(timeMap.get(index).getTimestamps());
164 165 long nowBetween = ChronoUnit.MINUTES.between(endTime, nowTime);
165 166 // 如果当前有效范围内签到记录无效如酒精测试异常则重复当前操作
... ... @@ -328,7 +329,7 @@ public class DriverServiceImpl implements IDriverService {
328 329 // 更新信息
329 330 for (Driver item : drivers) {
330 331 dto = schedulingService.queryScheduling(item.getJobCode(), now);
331   - DriverResponseVo vo = handleRecommendation(item, now, dto, schedulingFlag, alcoholFlag);
  332 + DriverResponseVo vo = handlerRecommendation(item, now, dto, schedulingFlag, alcoholFlag);
332 333 // 无排班
333 334 if (Objects.isNull(vo)) {
334 335 vos.add(DriverResponseVo.createDriverResponseVo(null, item, null, false, false, "", "", ""));
... ... @@ -339,7 +340,7 @@ public class DriverServiceImpl implements IDriverService {
339 340 return vos;
340 341 }
341 342  
342   - private DriverResponseVo handleRecommendation(Driver driver, Long now, List<DriverScheduling> dto, Boolean schedulingFlag, Boolean alcoholFlag) {
  343 + private DriverResponseVo handlerRecommendation(Driver driver, Long now, List<DriverScheduling> dto, Boolean schedulingFlag, Boolean alcoholFlag) {
343 344 DriverResponseVo vo = null;
344 345 // 给出计划操作
345 346 if (!CollectionUtil.isEmpty(dto)) {
... ...
ruoyi-admin/src/main/java/com/ruoyi/schedulingAssociateNum/controller/RuleNumSchedulingController.java renamed to ruoyi-admin/src/main/java/com/ruoyi/email/controller/EmailConfigController.java
1   -package com.ruoyi.schedulingAssociateNum.controller;
  1 +package com.ruoyi.email.controller;
2 2  
3 3 import java.util.List;
4 4 import javax.servlet.http.HttpServletResponse;
5 5 import org.springframework.security.access.prepost.PreAuthorize;
6 6 import org.springframework.beans.factory.annotation.Autowired;
  7 +import org.springframework.validation.annotation.Validated;
7 8 import org.springframework.web.bind.annotation.GetMapping;
8 9 import org.springframework.web.bind.annotation.PostMapping;
9 10 import org.springframework.web.bind.annotation.PutMapping;
... ... @@ -16,89 +17,94 @@ import com.ruoyi.common.annotation.Log;
16 17 import com.ruoyi.common.core.controller.BaseController;
17 18 import com.ruoyi.common.core.domain.AjaxResult;
18 19 import com.ruoyi.common.enums.BusinessType;
19   -import com.ruoyi.schedulingAssociateNum.domain.RuleNumScheduling;
20   -import com.ruoyi.schedulingAssociateNum.service.IRuleNumSchedulingService;
  20 +import com.ruoyi.email.domain.EmailConfig;
  21 +import com.ruoyi.email.service.IEmailConfigService;
21 22 import com.ruoyi.common.utils.poi.ExcelUtil;
22 23 import com.ruoyi.common.core.page.TableDataInfo;
23 24  
24 25 /**
25   - * 排班规则和班次关联Controller
  26 + * 邮箱配置Controller
26 27 *
27   - * @author 古自健
28   - * @date 2023-08-07
  28 + * @author guzijian
  29 + * @date 2023-08-24
29 30 */
30 31 @RestController
31   -@RequestMapping("/schedulingAssociateNum/schedulingAssociateNum")
32   -public class RuleNumSchedulingController extends BaseController
  32 +@RequestMapping("/email/email")
  33 +public class EmailConfigController extends BaseController
33 34 {
34 35 @Autowired
35   - private IRuleNumSchedulingService ruleNumSchedulingService;
  36 + private IEmailConfigService emailConfigService;
36 37  
37 38 /**
38   - * 查询排班规则和班次关联列表
  39 + * 查询邮箱配置列表
39 40 */
40   - @PreAuthorize("@ss.hasPermi('schedulingAssociateNum:schedulingAssociateNum:list')")
  41 + @PreAuthorize("@ss.hasPermi('email:email:list')")
41 42 @GetMapping("/list")
42   - public TableDataInfo list(RuleNumScheduling ruleNumScheduling)
  43 + public TableDataInfo list(EmailConfig emailConfig)
43 44 {
44 45 startPage();
45   - List<RuleNumScheduling> list = ruleNumSchedulingService.selectRuleNumSchedulingList(ruleNumScheduling);
  46 + List<EmailConfig> list = emailConfigService.selectEmailConfigList(emailConfig);
46 47 return getDataTable(list);
47 48 }
48 49  
49 50 /**
50   - * 导出排班规则和班次关联列表
  51 + * 导出邮箱配置列表
51 52 */
52   - @PreAuthorize("@ss.hasPermi('schedulingAssociateNum:schedulingAssociateNum:export')")
53   - @Log(title = "排班规则和班次关联", businessType = BusinessType.EXPORT)
  53 + @PreAuthorize("@ss.hasPermi('email:email:export')")
  54 + @Log(title = "邮箱配置", businessType = BusinessType.EXPORT)
54 55 @PostMapping("/export")
55   - public void export(HttpServletResponse response, RuleNumScheduling ruleNumScheduling)
  56 + public void export(HttpServletResponse response, EmailConfig emailConfig)
56 57 {
57   - List<RuleNumScheduling> list = ruleNumSchedulingService.selectRuleNumSchedulingList(ruleNumScheduling);
58   - ExcelUtil<RuleNumScheduling> util = new ExcelUtil<RuleNumScheduling>(RuleNumScheduling.class);
59   - util.exportExcel(response, list, "排班规则和班次关联数据");
  58 + List<EmailConfig> list = emailConfigService.selectEmailConfigList(emailConfig);
  59 + ExcelUtil<EmailConfig> util = new ExcelUtil<EmailConfig>(EmailConfig.class);
  60 + util.exportExcel(response, list, "邮箱配置数据");
  61 + }
  62 +
  63 + @GetMapping("/getAllEmail")
  64 + public AjaxResult getAllEmail(){
  65 + return AjaxResult.success(emailConfigService.selectEmailConfigList(new EmailConfig()));
60 66 }
61 67  
62 68 /**
63   - * 获取排班规则和班次关联详细信息
  69 + * 获取邮箱配置详细信息
64 70 */
65   - @PreAuthorize("@ss.hasPermi('schedulingAssociateNum:schedulingAssociateNum:query')")
  71 + @PreAuthorize("@ss.hasPermi('email:email:query')")
66 72 @GetMapping(value = "/{id}")
67 73 public AjaxResult getInfo(@PathVariable("id") Long id)
68 74 {
69   - return success(ruleNumSchedulingService.selectRuleNumSchedulingById(id));
  75 + return success(emailConfigService.selectEmailConfigById(id));
70 76 }
71 77  
72 78 /**
73   - * 新增排班规则和班次关联
  79 + * 新增邮箱配置
74 80 */
75   - @PreAuthorize("@ss.hasPermi('schedulingAssociateNum:schedulingAssociateNum:add')")
76   - @Log(title = "排班规则和班次关联", businessType = BusinessType.INSERT)
  81 + @PreAuthorize("@ss.hasPermi('email:email:add')")
  82 + @Log(title = "邮箱配置", businessType = BusinessType.INSERT)
77 83 @PostMapping
78   - public AjaxResult add(@RequestBody RuleNumScheduling ruleNumScheduling)
  84 + public AjaxResult add(@RequestBody @Validated EmailConfig emailConfig)
79 85 {
80   - return toAjax(ruleNumSchedulingService.insertRuleNumScheduling(ruleNumScheduling));
  86 + return toAjax(emailConfigService.insertEmailConfig(emailConfig));
81 87 }
82 88  
83 89 /**
84   - * 修改排班规则和班次关联
  90 + * 修改邮箱配置
85 91 */
86   - @PreAuthorize("@ss.hasPermi('schedulingAssociateNum:schedulingAssociateNum:edit')")
87   - @Log(title = "排班规则和班次关联", businessType = BusinessType.UPDATE)
  92 + @PreAuthorize("@ss.hasPermi('email:email:edit')")
  93 + @Log(title = "邮箱配置", businessType = BusinessType.UPDATE)
88 94 @PutMapping
89   - public AjaxResult edit(@RequestBody RuleNumScheduling ruleNumScheduling)
  95 + public AjaxResult edit(@RequestBody EmailConfig emailConfig)
90 96 {
91   - return toAjax(ruleNumSchedulingService.updateRuleNumScheduling(ruleNumScheduling));
  97 + return toAjax(emailConfigService.updateEmailConfig(emailConfig));
92 98 }
93 99  
94 100 /**
95   - * 删除排班规则和班次关联
  101 + * 删除邮箱配置
96 102 */
97   - @PreAuthorize("@ss.hasPermi('schedulingAssociateNum:schedulingAssociateNum:remove')")
98   - @Log(title = "排班规则和班次关联", businessType = BusinessType.DELETE)
99   - @DeleteMapping("/{ids}")
100   - public AjaxResult remove(@PathVariable Long[] ids)
  103 + @PreAuthorize("@ss.hasPermi('email:email:remove')")
  104 + @Log(title = "邮箱配置", businessType = BusinessType.DELETE)
  105 + @DeleteMapping("/{id}")
  106 + public AjaxResult remove(@PathVariable Long id)
101 107 {
102   - return toAjax(ruleNumSchedulingService.deleteRuleNumSchedulingByIds(ids));
  108 + return toAjax(emailConfigService.deleteEmailConfigById(id));
103 109 }
104 110 }
... ...
ruoyi-admin/src/main/java/com/ruoyi/email/domain/EmailConfig.java 0 → 100644
  1 +package com.ruoyi.email.domain;
  2 +
  3 +import lombok.Data;
  4 +import org.apache.commons.lang3.builder.ToStringBuilder;
  5 +import org.apache.commons.lang3.builder.ToStringStyle;
  6 +import com.ruoyi.common.annotation.Excel;
  7 +import com.ruoyi.common.core.domain.BaseEntity;
  8 +
  9 +import javax.validation.constraints.Email;
  10 +
  11 +/**
  12 + * 邮箱配置对象 email_config
  13 + *
  14 + * @author guzijian
  15 + * @date 2023-08-24
  16 + */
  17 +@Data
  18 +public class EmailConfig extends BaseEntity
  19 +{
  20 + private static final long serialVersionUID = 1L;
  21 +
  22 + /** 主键 */
  23 + private Long id;
  24 +
  25 + /** 姓名 */
  26 + @Excel(name = "姓名")
  27 + private String name;
  28 +
  29 + /** 邮箱 */
  30 + @Excel(name = "邮箱")
  31 + @Email(message = "请输入正确的邮箱")
  32 + private String email;
  33 +
  34 + /** 排序 */
  35 + @Excel(name = "排序")
  36 + private Long sort;
  37 + /**
  38 + * 类型 0 收件人 1 抄送人 2 未启用
  39 + */
  40 + private Integer type;
  41 +
  42 + /**
  43 + * 抄送人
  44 + */
  45 + private String parentId;
  46 +
  47 +}
... ...
ruoyi-admin/src/main/java/com/ruoyi/schedulingAssociateNum/mapper/RuleNumSchedulingMapper.java renamed to ruoyi-admin/src/main/java/com/ruoyi/email/mapper/EmailConfigMapper.java
1   -package com.ruoyi.schedulingAssociateNum.mapper;
  1 +package com.ruoyi.email.mapper;
2 2  
3 3 import java.util.List;
4   -import com.ruoyi.schedulingAssociateNum.domain.RuleNumScheduling;
  4 +import com.ruoyi.email.domain.EmailConfig;
  5 +import org.apache.ibatis.annotations.Param;
5 6  
6 7 /**
7   - * 排班规则和班次关联Mapper接口
  8 + * 邮箱配置Mapper接口
8 9 *
9   - * @author 古自健
10   - * @date 2023-08-07
  10 + * @author guzijian
  11 + * @date 2023-08-24
11 12 */
12   -public interface RuleNumSchedulingMapper
  13 +public interface EmailConfigMapper
13 14 {
14 15 /**
15   - * 查询排班规则和班次关联
  16 + * 查询邮箱配置
16 17 *
17   - * @param id 排班规则和班次关联主键
18   - * @return 排班规则和班次关联
  18 + * @param id 邮箱配置主键
  19 + * @return 邮箱配置
19 20 */
20   - public RuleNumScheduling selectRuleNumSchedulingById(Long id);
  21 + public EmailConfig selectEmailConfigById(Long id);
21 22  
22 23 /**
23   - * 查询排班规则和班次关联列表
  24 + * 查询邮箱配置列表
24 25 *
25   - * @param ruleNumScheduling 排班规则和班次关联
26   - * @return 排班规则和班次关联集合
  26 + * @param emailConfig 邮箱配置
  27 + * @return 邮箱配置集合
27 28 */
28   - public List<RuleNumScheduling> selectRuleNumSchedulingList(RuleNumScheduling ruleNumScheduling);
  29 + public List<EmailConfig> selectEmailConfigList(EmailConfig emailConfig);
29 30  
30 31 /**
31   - * 新增排班规则和班次关联
  32 + * 新增邮箱配置
32 33 *
33   - * @param ruleNumScheduling 排班规则和班次关联
  34 + * @param emailConfig 邮箱配置
34 35 * @return 结果
35 36 */
36   - public int insertRuleNumScheduling(RuleNumScheduling ruleNumScheduling);
  37 + public int insertEmailConfig(EmailConfig emailConfig);
37 38  
38 39 /**
39   - * 修改排班规则和班次关联
  40 + * 修改邮箱配置
40 41 *
41   - * @param ruleNumScheduling 排班规则和班次关联
  42 + * @param emailConfig 邮箱配置
42 43 * @return 结果
43 44 */
44   - public int updateRuleNumScheduling(RuleNumScheduling ruleNumScheduling);
  45 + public int updateEmailConfig(EmailConfig emailConfig);
45 46  
46 47 /**
47   - * 删除排班规则和班次关联
  48 + * 删除邮箱配置
48 49 *
49   - * @param id 排班规则和班次关联主键
  50 + * @param id 邮箱配置主键
50 51 * @return 结果
51 52 */
52   - public int deleteRuleNumSchedulingById(Long id);
  53 + public int deleteEmailConfigById(Long id);
53 54  
54 55 /**
55   - * 批量删除排班规则和班次关联
  56 + * 批量删除邮箱配置
56 57 *
57 58 * @param ids 需要删除的数据主键集合
58 59 * @return 结果
59 60 */
60   - public int deleteRuleNumSchedulingByIds(Long[] ids);
  61 + public int deleteEmailConfigByIds(Long[] ids);
  62 +
  63 + void updateEmailConfigByEmails(@Param("ids") List<String> ids, @Param("config") EmailConfig emailConfig);
  64 +
  65 + void resetEmailConfigByEmails(@Param("ids") List<String> emails,@Param("config") EmailConfig config);
  66 +
  67 + List<EmailConfig> selectRecipientsEmailConfigList();
  68 +
  69 + List<EmailConfig> selectEmailConfigListByIds(@Param("ids") List<Long> ids);
61 70 }
... ...
ruoyi-admin/src/main/java/com/ruoyi/schedulingAssociateNum/service/IRuleNumSchedulingService.java renamed to ruoyi-admin/src/main/java/com/ruoyi/email/service/IEmailConfigService.java
1   -package com.ruoyi.schedulingAssociateNum.service;
  1 +package com.ruoyi.email.service;
2 2  
3 3 import java.util.List;
4   -import com.ruoyi.schedulingAssociateNum.domain.RuleNumScheduling;
  4 +import com.ruoyi.email.domain.EmailConfig;
5 5  
6 6 /**
7   - * 排班规则和班次关联Service接口
  7 + * 邮箱配置Service接口
8 8 *
9   - * @author 古自健
10   - * @date 2023-08-07
  9 + * @author guzijian
  10 + * @date 2023-08-24
11 11 */
12   -public interface IRuleNumSchedulingService
  12 +public interface IEmailConfigService
13 13 {
14 14 /**
15   - * 查询排班规则和班次关联
  15 + * 查询邮箱配置
16 16 *
17   - * @param id 排班规则和班次关联主键
18   - * @return 排班规则和班次关联
  17 + * @param id 邮箱配置主键
  18 + * @return 邮箱配置
19 19 */
20   - public RuleNumScheduling selectRuleNumSchedulingById(Long id);
  20 + public EmailConfig selectEmailConfigById(Long id);
21 21  
22 22 /**
23   - * 查询排班规则和班次关联列表
  23 + * 查询邮箱配置列表
24 24 *
25   - * @param ruleNumScheduling 排班规则和班次关联
26   - * @return 排班规则和班次关联集合
  25 + * @param emailConfig 邮箱配置
  26 + * @return 邮箱配置集合
27 27 */
28   - public List<RuleNumScheduling> selectRuleNumSchedulingList(RuleNumScheduling ruleNumScheduling);
  28 + public List<EmailConfig> selectEmailConfigList(EmailConfig emailConfig);
29 29  
30 30 /**
31   - * 新增排班规则和班次关联
  31 + * 新增邮箱配置
32 32 *
33   - * @param ruleNumScheduling 排班规则和班次关联
  33 + * @param emailConfig 邮箱配置
34 34 * @return 结果
35 35 */
36   - public int insertRuleNumScheduling(RuleNumScheduling ruleNumScheduling);
  36 + public int insertEmailConfig(EmailConfig emailConfig);
37 37  
38 38 /**
39   - * 修改排班规则和班次关联
  39 + * 修改邮箱配置
40 40 *
41   - * @param ruleNumScheduling 排班规则和班次关联
  41 + * @param emailConfig 邮箱配置
42 42 * @return 结果
43 43 */
44   - public int updateRuleNumScheduling(RuleNumScheduling ruleNumScheduling);
  44 + public int updateEmailConfig(EmailConfig emailConfig);
45 45  
46 46 /**
47   - * 批量删除排班规则和班次关联
  47 + * 批量删除邮箱配置
48 48 *
49   - * @param ids 需要删除的排班规则和班次关联主键集合
  49 + * @param ids 需要删除的邮箱配置主键集合
50 50 * @return 结果
51 51 */
52   - public int deleteRuleNumSchedulingByIds(Long[] ids);
  52 + public int deleteEmailConfigByIds(Long[] ids);
53 53  
54 54 /**
55   - * 删除排班规则和班次关联信息
  55 + * 删除邮箱配置信息
56 56 *
57   - * @param id 排班规则和班次关联主键
  57 + * @param id 邮箱配置主键
58 58 * @return 结果
59 59 */
60   - public int deleteRuleNumSchedulingById(Long id);
  60 + public int deleteEmailConfigById(Long id);
  61 +
  62 + List<EmailConfig> selectRecipientsEmailConfigList();
  63 +
  64 + List<EmailConfig> selectEmailConfigListByIds(List<Long> collect);
61 65 }
... ...
ruoyi-admin/src/main/java/com/ruoyi/email/service/impl/EmailConfigServiceImpl.java 0 → 100644
  1 +package com.ruoyi.email.service.impl;
  2 +
  3 +import java.util.ArrayList;
  4 +import java.util.Arrays;
  5 +import java.util.List;
  6 +import java.util.stream.Collectors;
  7 +
  8 +import cn.hutool.core.collection.CollectionUtil;
  9 +import org.apache.tomcat.util.buf.StringUtils;
  10 +import org.slf4j.Logger;
  11 +import org.slf4j.LoggerFactory;
  12 +import org.springframework.beans.factory.annotation.Autowired;
  13 +import org.springframework.stereotype.Service;
  14 +import com.ruoyi.email.mapper.EmailConfigMapper;
  15 +import com.ruoyi.email.domain.EmailConfig;
  16 +import com.ruoyi.email.service.IEmailConfigService;
  17 +
  18 +/**
  19 + * 邮箱配置Service业务层处理
  20 + *
  21 + * @author guzijian
  22 + * @date 2023-08-24
  23 + */
  24 +@Service
  25 +public class EmailConfigServiceImpl implements IEmailConfigService {
  26 +
  27 + private static final Logger log = LoggerFactory.getLogger(EmailConfigServiceImpl.class);
  28 + @Autowired
  29 + private EmailConfigMapper emailConfigMapper;
  30 +
  31 + /**
  32 + * 查询邮箱配置
  33 + *
  34 + * @param id 邮箱配置主键
  35 + * @return 邮箱配置
  36 + */
  37 + @Override
  38 + public EmailConfig selectEmailConfigById(Long id) {
  39 + return emailConfigMapper.selectEmailConfigById(id);
  40 + }
  41 +
  42 + /**
  43 + * 查询邮箱配置列表
  44 + *
  45 + * @param emailConfig 邮箱配置
  46 + * @return 邮箱配置
  47 + */
  48 + @Override
  49 + public List<EmailConfig> selectEmailConfigList(EmailConfig emailConfig) {
  50 + return emailConfigMapper.selectEmailConfigList(emailConfig);
  51 + }
  52 +
  53 + /**
  54 + * 新增邮箱配置
  55 + *
  56 + * @param emailConfig 邮箱配置
  57 + * @return 结果
  58 + */
  59 + @Override
  60 + public int insertEmailConfig(EmailConfig emailConfig) {
  61 + if (!emailConfig.getType().equals(2)) {
  62 + throw new RuntimeException("新增邮件只能设置为未启用!");
  63 + }
  64 + return emailConfigMapper.insertEmailConfig(emailConfig);
  65 + }
  66 +
  67 + /**
  68 + * 修改邮箱配置
  69 + *
  70 + * @param emailConfig 邮箱配置
  71 + * @return 结果
  72 + */
  73 + @Override
  74 + public int updateEmailConfig(EmailConfig emailConfig) {
  75 + // 类型为收件人
  76 + try {
  77 + if (emailConfig.getType().equals(0)) {
  78 + List<String> ids = handlerEmail(emailConfig);
  79 + updateEmailConfigByEmails(ids, emailConfig);
  80 + } else {
  81 + EmailConfig config = emailConfigMapper.selectEmailConfigById(emailConfig.getId());
  82 + if (config.getType().equals(0)) {
  83 + List<String> ids = handlerEmail(config);
  84 + resetEmailConfigByEmails(ids, emailConfig);
  85 + } else {
  86 + emailConfig.setType(config.getType());
  87 + emailConfigMapper.updateEmailConfig(emailConfig);
  88 + }
  89 + }
  90 + return 1;
  91 + } catch (Exception e) {
  92 + log.error(e.getMessage());
  93 + return 0;
  94 + }
  95 + }
  96 +
  97 + private void resetEmailConfigByEmails(List<String> ids, EmailConfig config) {
  98 + emailConfigMapper.resetEmailConfigByEmails(ids, config);
  99 + }
  100 +
  101 + private void updateEmailConfigByEmails(List<String> ids, EmailConfig emailConfig) {
  102 + emailConfigMapper.updateEmailConfigByEmails(ids, emailConfig);
  103 + }
  104 +
  105 + private List<String> handlerEmail(EmailConfig emailConfig) {
  106 + if (emailConfig.getParentId() != null) {
  107 + List<String> ids = Arrays.stream(emailConfig.getParentId().split(",")).distinct().collect(Collectors.toList());
  108 + emailConfig.setParentId(StringUtils.join(ids));
  109 + return ids;
  110 + }
  111 + return null;
  112 + }
  113 +
  114 + /**
  115 + * 批量删除邮箱配置
  116 + *
  117 + * @param ids 需要删除的邮箱配置主键
  118 + * @return 结果
  119 + */
  120 + @Override
  121 + public int deleteEmailConfigByIds(Long[] ids) {
  122 + throw new RuntimeException("禁止批量删除!!!!");
  123 + }
  124 +
  125 + /**
  126 + * 删除邮箱配置信息
  127 + *
  128 + * @param id 邮箱配置主键
  129 + * @return 结果
  130 + */
  131 + @Override
  132 + public int deleteEmailConfigById(Long id) {
  133 + EmailConfig emailConfig = selectEmailConfigById(id);
  134 + if (!emailConfig.getType().equals(2)) {
  135 + throw new RuntimeException("除了未启用不允许被删除");
  136 + }
  137 + return emailConfigMapper.deleteEmailConfigById(id);
  138 + }
  139 +
  140 + @Override
  141 + public List<EmailConfig> selectRecipientsEmailConfigList() {
  142 + return emailConfigMapper.selectRecipientsEmailConfigList();
  143 + }
  144 +
  145 + @Override
  146 + public List<EmailConfig> selectEmailConfigListByIds(List<Long> ids) {
  147 + return emailConfigMapper.selectEmailConfigListByIds(ids);
  148 + }
  149 +}
... ...
ruoyi-admin/src/main/java/com/ruoyi/equipment/controller/EquipmentController.java
... ... @@ -3,18 +3,12 @@ package com.ruoyi.equipment.controller;
3 3 import java.util.List;
4 4 import javax.servlet.http.HttpServletResponse;
5 5  
  6 +import com.ruoyi.equipment.domain.EquipmentLog;
6 7 import io.swagger.annotations.Api;
7 8 import io.swagger.annotations.ApiOperation;
8 9 import org.springframework.security.access.prepost.PreAuthorize;
9 10 import org.springframework.beans.factory.annotation.Autowired;
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;
  11 +import org.springframework.web.bind.annotation.*;
18 12 import com.ruoyi.common.annotation.Log;
19 13 import com.ruoyi.common.core.controller.BaseController;
20 14 import com.ruoyi.common.core.domain.AjaxResult;
... ... @@ -63,6 +57,17 @@ public class EquipmentController extends BaseController {
63 57 }
64 58  
65 59 /**
  60 + * 查看日志
  61 + */
  62 + @GetMapping("/log")
  63 + @ApiOperation("设备日志")
  64 + public TableDataInfo log(@ModelAttribute EquipmentLog log){
  65 + startPage();
  66 + List<EquipmentLog> list = equipmentService.queryLog(log);
  67 + return getDataTable(list);
  68 + }
  69 +
  70 + /**
66 71 * 获取设备信息详细信息
67 72 */
68 73 // @PreAuthorize("@ss.hasPermi('equipment:equipment:query')")
... ...
ruoyi-admin/src/main/java/com/ruoyi/equipment/domain/EquipmentLog.java 0 → 100644
  1 +package com.ruoyi.equipment.domain;
  2 +
  3 +import com.ruoyi.common.annotation.Excel;
  4 +import lombok.Data;
  5 +
  6 +import java.util.Date;
  7 +
  8 +/**
  9 + * @author 20412
  10 + */
  11 +@Data
  12 +public class EquipmentLog {
  13 + private Long id;
  14 + @Excel(name = "设备号")
  15 + private String deviceId;
  16 + /**
  17 + * 掉线时间
  18 + */
  19 + @Excel(name = "掉线时间")
  20 + private Date offLineTime;
  21 + /**
  22 + * 恢复时间
  23 + */
  24 + @Excel(name = "恢复时间")
  25 + private Date recoveryTime;
  26 + @Excel(name = "是否恢复")
  27 + private Integer recoveryFlag;
  28 + @Excel(name = "备注")
  29 + private String remark;
  30 +}
... ...
ruoyi-admin/src/main/java/com/ruoyi/equipment/mapper/EquipmentMapper.java
... ... @@ -4,7 +4,8 @@ import java.util.List;
4 4  
5 5 import com.ruoyi.driver.domain.Driver;
6 6 import com.ruoyi.equipment.domain.Equipment;
7   -import com.ruoyi.pojo.domain.EquipmentDriverExpand;
  7 +import com.ruoyi.equipment.domain.EquipmentLog;
  8 +import com.ruoyi.domain.EquipmentDriverExpand;
8 9 import org.apache.ibatis.annotations.Param;
9 10  
10 11 /**
... ... @@ -75,4 +76,11 @@ public interface EquipmentMapper
75 76  
76 77 void updateEquipmentByDeviceId(Equipment equipment);
77 78  
  79 + void deleteExRecord();
  80 +
  81 + void insertEquipmentOffLineLog(List<Equipment> list);
  82 +
  83 + void updateEquipmentLog(@Param("recoveryList") List<EquipmentLog> recoveryList);
  84 +
  85 + List<EquipmentLog> queryLog(EquipmentLog log);
78 86 }
... ...
ruoyi-admin/src/main/java/com/ruoyi/equipment/service/IEquipmentService.java
... ... @@ -2,6 +2,7 @@ package com.ruoyi.equipment.service;
2 2  
3 3 import java.util.List;
4 4 import com.ruoyi.equipment.domain.Equipment;
  5 +import com.ruoyi.equipment.domain.EquipmentLog;
5 6  
6 7 /**
7 8 * 设备信息Service接口
... ... @@ -58,4 +59,6 @@ public interface IEquipmentService
58 59 * @return 结果
59 60 */
60 61 public int deleteEquipmentById(Long id);
  62 +
  63 + List<EquipmentLog> queryLog(EquipmentLog log);
61 64 }
... ...
ruoyi-admin/src/main/java/com/ruoyi/equipment/service/impl/EquipmentServiceImpl.java
... ... @@ -4,6 +4,7 @@ import java.util.List;
4 4 import com.ruoyi.common.utils.DateUtils;
5 5 import com.ruoyi.common.utils.SecurityUtils;
6 6 import com.ruoyi.common.utils.StringUtils;
  7 +import com.ruoyi.equipment.domain.EquipmentLog;
7 8 import com.ruoyi.pojo.equipment.EquipmentOnline;
8 9 import org.springframework.beans.factory.annotation.Autowired;
9 10 import org.springframework.stereotype.Service;
... ... @@ -106,4 +107,9 @@ public class EquipmentServiceImpl implements IEquipmentService
106 107 {
107 108 return equipmentMapper.deleteEquipmentById(id);
108 109 }
  110 +
  111 + @Override
  112 + public List<EquipmentLog> queryLog(EquipmentLog log) {
  113 + return equipmentMapper.queryLog(log);
  114 + }
109 115 }
... ...
ruoyi-admin/src/main/java/com/ruoyi/errorScheduling/controller/ErrorJobcodeController.java 0 → 100644
  1 +package com.ruoyi.errorScheduling.controller;
  2 +
  3 +import java.util.List;
  4 +import javax.servlet.http.HttpServletResponse;
  5 +
  6 +import com.ruoyi.pojo.vo.ErrorJobcodeVo;
  7 +import org.springframework.security.access.prepost.PreAuthorize;
  8 +import org.springframework.beans.factory.annotation.Autowired;
  9 +import org.springframework.web.bind.annotation.GetMapping;
  10 +import org.springframework.web.bind.annotation.PostMapping;
  11 +import org.springframework.web.bind.annotation.PutMapping;
  12 +import org.springframework.web.bind.annotation.DeleteMapping;
  13 +import org.springframework.web.bind.annotation.PathVariable;
  14 +import org.springframework.web.bind.annotation.RequestBody;
  15 +import org.springframework.web.bind.annotation.RequestMapping;
  16 +import org.springframework.web.bind.annotation.RestController;
  17 +import com.ruoyi.common.annotation.Log;
  18 +import com.ruoyi.common.core.controller.BaseController;
  19 +import com.ruoyi.common.core.domain.AjaxResult;
  20 +import com.ruoyi.common.enums.BusinessType;
  21 +import com.ruoyi.errorScheduling.domain.ErrorJobcode;
  22 +import com.ruoyi.errorScheduling.service.IErrorJobcodeService;
  23 +import com.ruoyi.common.utils.poi.ExcelUtil;
  24 +import com.ruoyi.common.core.page.TableDataInfo;
  25 +
  26 +/**
  27 + * 问题排班Controller
  28 + *
  29 + * @author guzijian
  30 + * @date 2023-08-24
  31 + */
  32 +@RestController
  33 +@RequestMapping("/errorScheduling/errorScheduling")
  34 +public class ErrorJobcodeController extends BaseController
  35 +{
  36 + @Autowired
  37 + private IErrorJobcodeService errorJobcodeService;
  38 +
  39 + /**
  40 + * 查询问题排班列表
  41 + */
  42 + @PreAuthorize("@ss.hasPermi('errorScheduling:errorScheduling:list')")
  43 + @GetMapping("/list")
  44 + public TableDataInfo list(ErrorJobcodeVo errorJobcode)
  45 + {
  46 + startPage();
  47 + List<ErrorJobcodeVo> list = errorJobcodeService.selectErrorJobcodeList(errorJobcode);
  48 + return getDataTable(list);
  49 + }
  50 +
  51 + /**
  52 + * 导出问题排班列表
  53 + */
  54 + @PreAuthorize("@ss.hasPermi('errorScheduling:errorScheduling:export')")
  55 + @Log(title = "问题排班", businessType = BusinessType.EXPORT)
  56 + @PostMapping("/export")
  57 + public void export(HttpServletResponse response, ErrorJobcodeVo errorJobcode)
  58 + {
  59 + List<ErrorJobcodeVo> list = errorJobcodeService.selectErrorJobcodeList(errorJobcode);
  60 + ExcelUtil<ErrorJobcodeVo> util = new ExcelUtil<ErrorJobcodeVo>(ErrorJobcodeVo.class);
  61 + util.exportExcel(response, list, "问题排班数据");
  62 + }
  63 +
  64 + /**
  65 + * 获取问题排班详细信息
  66 + */
  67 + @PreAuthorize("@ss.hasPermi('errorScheduling:errorScheduling:query')")
  68 + @GetMapping(value = "/{id}")
  69 + public AjaxResult getInfo(@PathVariable("id") Long id)
  70 + {
  71 + return success(errorJobcodeService.selectErrorJobcodeById(id));
  72 + }
  73 +
  74 +// /**
  75 +// * 新增问题排班
  76 +// */
  77 +// @PreAuthorize("@ss.hasPermi('errorScheduling:errorScheduling:add')")
  78 +// @Log(title = "问题排班", businessType = BusinessType.INSERT)
  79 +// @PostMapping
  80 +// public AjaxResult add(@RequestBody ErrorJobcode errorJobcode)
  81 +// {
  82 +// return toAjax(errorJobcodeService.insertErrorJobcode(errorJobcode));
  83 +// }
  84 +
  85 + /**
  86 + * 修改问题排班
  87 + */
  88 + @PreAuthorize("@ss.hasPermi('errorScheduling:errorScheduling:edit')")
  89 + @Log(title = "问题排班", businessType = BusinessType.UPDATE)
  90 + @PutMapping
  91 + public AjaxResult edit(@RequestBody ErrorJobcode errorJobcode)
  92 + {
  93 + return toAjax(errorJobcodeService.updateErrorJobcode(errorJobcode));
  94 + }
  95 +
  96 + /**
  97 + * 删除问题排班
  98 + */
  99 + @PreAuthorize("@ss.hasPermi('errorScheduling:errorScheduling:remove')")
  100 + @Log(title = "问题排班", businessType = BusinessType.DELETE)
  101 + @DeleteMapping("/{ids}")
  102 + public AjaxResult remove(@PathVariable Long[] ids)
  103 + {
  104 + return toAjax(errorJobcodeService.deleteErrorJobcodeByIds(ids));
  105 + }
  106 +}
... ...
ruoyi-admin/src/main/java/com/ruoyi/errorScheduling/domain/ErrorJobcode.java 0 → 100644
  1 +package com.ruoyi.errorScheduling.domain;
  2 +
  3 +import com.fasterxml.jackson.annotation.JsonFormat;
  4 +import lombok.Data;
  5 +import org.apache.commons.lang3.builder.ToStringBuilder;
  6 +import org.apache.commons.lang3.builder.ToStringStyle;
  7 +import com.ruoyi.common.annotation.Excel;
  8 +import com.ruoyi.common.core.domain.BaseEntity;
  9 +import org.springframework.format.annotation.DateTimeFormat;
  10 +
  11 +import java.util.Date;
  12 +
  13 +/**
  14 + * 问题排班对象 error_jobcode
  15 + *
  16 + * @author guzijian
  17 + * @date 2023-08-24
  18 + */
  19 +@Data
  20 +public class ErrorJobcode extends BaseEntity
  21 +{
  22 + private static final long serialVersionUID = 1L;
  23 +
  24 + /** 主键 */
  25 + private Long id;
  26 +
  27 + /** 工号 */
  28 + @Excel(name = "工号")
  29 + private String jobCode;
  30 +
  31 + /** 姓名 */
  32 + @Excel(name = "姓名")
  33 + private String name;
  34 +
  35 + /**工种 */
  36 + @Excel(name = "工种")
  37 + private String posts;
  38 +
  39 + /** 部门 */
  40 + @Excel(name = "部门")
  41 + private String fleetName;
  42 +
  43 + /** 线路 */
  44 + @Excel(name = "线路")
  45 + private String lineName;
  46 +
  47 + /** 车辆自编号 */
  48 + @Excel(name = "车辆自编号")
  49 + private String nbbm;
  50 +
  51 + /** 路牌 */
  52 + @Excel(name = "路牌")
  53 + private String lpName;
  54 +
  55 + @Excel(name = "触发日期")
  56 + @DateTimeFormat(pattern = "yyyy-MM-dd")
  57 + @JsonFormat(pattern = "yyyy-MM-dd")
  58 + private Date createTime;
  59 +
  60 +}
... ...
ruoyi-admin/src/main/java/com/ruoyi/errorScheduling/mapper/ErrorJobcodeMapper.java 0 → 100644
  1 +package com.ruoyi.errorScheduling.mapper;
  2 +
  3 +import java.util.List;
  4 +import com.ruoyi.errorScheduling.domain.ErrorJobcode;
  5 +import com.ruoyi.pojo.vo.ErrorJobcodeVo;
  6 +import org.apache.ibatis.annotations.Param;
  7 +
  8 +/**
  9 + * 问题排班Mapper接口
  10 + *
  11 + * @author guzijian
  12 + * @date 2023-08-24
  13 + */
  14 +public interface ErrorJobcodeMapper
  15 +{
  16 + /**
  17 + * 查询问题排班
  18 + *
  19 + * @param id 问题排班主键
  20 + * @return 问题排班
  21 + */
  22 + public ErrorJobcode selectErrorJobcodeById(Long id);
  23 +
  24 + /**
  25 + * 查询问题排班列表
  26 + *
  27 + * @param errorJobcode 问题排班
  28 + * @return 问题排班集合
  29 + */
  30 + public List<ErrorJobcodeVo> selectErrorJobcodeList(ErrorJobcodeVo errorJobcode);
  31 +
  32 + /**
  33 + * 新增问题排班
  34 + *
  35 + * @param errorJobcode 问题排班
  36 + * @return 结果
  37 + */
  38 + public int insertErrorJobcode(ErrorJobcode errorJobcode);
  39 +
  40 + /**
  41 + * 修改问题排班
  42 + *
  43 + * @param errorJobcode 问题排班
  44 + * @return 结果
  45 + */
  46 + public int updateErrorJobcode(ErrorJobcode errorJobcode);
  47 +
  48 + /**
  49 + * 删除问题排班
  50 + *
  51 + * @param id 问题排班主键
  52 + * @return 结果
  53 + */
  54 + public int deleteErrorJobcodeById(Long id);
  55 +
  56 + /**
  57 + * 批量删除问题排班
  58 + *
  59 + * @param ids 需要删除的数据主键集合
  60 + * @return 结果
  61 + */
  62 + public int deleteErrorJobcodeByIds(Long[] ids);
  63 +
  64 + void insertBatchErrorJobcode(@Param("errorScheduling") List<ErrorJobcode> errorScheduling);
  65 +}
... ...
ruoyi-admin/src/main/java/com/ruoyi/errorScheduling/service/IErrorJobcodeService.java 0 → 100644
  1 +package com.ruoyi.errorScheduling.service;
  2 +
  3 +import java.util.List;
  4 +import com.ruoyi.errorScheduling.domain.ErrorJobcode;
  5 +import com.ruoyi.pojo.vo.ErrorJobcodeVo;
  6 +
  7 +/**
  8 + * 问题排班Service接口
  9 + *
  10 + * @author guzijian
  11 + * @date 2023-08-24
  12 + */
  13 +public interface IErrorJobcodeService
  14 +{
  15 + /**
  16 + * 查询问题排班
  17 + *
  18 + * @param id 问题排班主键
  19 + * @return 问题排班
  20 + */
  21 + public ErrorJobcode selectErrorJobcodeById(Long id);
  22 +
  23 + /**
  24 + * 查询问题排班列表
  25 + *
  26 + * @param errorJobcode 问题排班
  27 + * @return 问题排班集合
  28 + */
  29 + public List<ErrorJobcodeVo> selectErrorJobcodeList(ErrorJobcodeVo errorJobcode);
  30 +
  31 + /**
  32 + * 新增问题排班
  33 + *
  34 + * @param errorJobcode 问题排班
  35 + * @return 结果
  36 + */
  37 + public int insertErrorJobcode(ErrorJobcode errorJobcode);
  38 +
  39 + /**
  40 + * 修改问题排班
  41 + *
  42 + * @param errorJobcode 问题排班
  43 + * @return 结果
  44 + */
  45 + public int updateErrorJobcode(ErrorJobcode errorJobcode);
  46 +
  47 + /**
  48 + * 批量删除问题排班
  49 + *
  50 + * @param ids 需要删除的问题排班主键集合
  51 + * @return 结果
  52 + */
  53 + public int deleteErrorJobcodeByIds(Long[] ids);
  54 +
  55 + /**
  56 + * 删除问题排班信息
  57 + *
  58 + * @param id 问题排班主键
  59 + * @return 结果
  60 + */
  61 + public int deleteErrorJobcodeById(Long id);
  62 +
  63 + void insertBatchErrorJobcode(List<ErrorJobcode> errorScheduling);
  64 +}
... ...
ruoyi-admin/src/main/java/com/ruoyi/schedulingAssociateNum/service/impl/RuleNumSchedulingServiceImpl.java renamed to ruoyi-admin/src/main/java/com/ruoyi/errorScheduling/service/impl/ErrorJobcodeServiceImpl.java
1   -package com.ruoyi.schedulingAssociateNum.service.impl;
  1 +package com.ruoyi.errorScheduling.service.impl;
2 2  
3 3 import java.util.List;
  4 +
  5 +import cn.hutool.core.collection.CollectionUtil;
  6 +import com.ruoyi.common.utils.DateUtils;
4 7 import com.ruoyi.common.utils.SecurityUtils;
  8 +import com.ruoyi.pojo.vo.ErrorJobcodeVo;
5 9 import org.springframework.beans.factory.annotation.Autowired;
6 10 import org.springframework.stereotype.Service;
7   -import com.ruoyi.schedulingAssociateNum.mapper.RuleNumSchedulingMapper;
8   -import com.ruoyi.schedulingAssociateNum.domain.RuleNumScheduling;
9   -import com.ruoyi.schedulingAssociateNum.service.IRuleNumSchedulingService;
  11 +import com.ruoyi.errorScheduling.mapper.ErrorJobcodeMapper;
  12 +import com.ruoyi.errorScheduling.domain.ErrorJobcode;
  13 +import com.ruoyi.errorScheduling.service.IErrorJobcodeService;
10 14  
11 15 /**
12   - * 排班规则和班次关联Service业务层处理
  16 + * 问题排班Service业务层处理
13 17 *
14   - * @author 古自健
15   - * @date 2023-08-07
  18 + * @author guzijian
  19 + * @date 2023-08-24
16 20 */
17 21 @Service
18   -public class RuleNumSchedulingServiceImpl implements IRuleNumSchedulingService
  22 +public class ErrorJobcodeServiceImpl implements IErrorJobcodeService
19 23 {
20 24 @Autowired
21   - private RuleNumSchedulingMapper ruleNumSchedulingMapper;
  25 + private ErrorJobcodeMapper errorJobcodeMapper;
22 26  
23 27 /**
24   - * 查询排班规则和班次关联
  28 + * 查询问题排班
25 29 *
26   - * @param id 排班规则和班次关联主键
27   - * @return 排班规则和班次关联
  30 + * @param id 问题排班主键
  31 + * @return 问题排班
28 32 */
29 33 @Override
30   - public RuleNumScheduling selectRuleNumSchedulingById(Long id)
  34 + public ErrorJobcode selectErrorJobcodeById(Long id)
31 35 {
32   - return ruleNumSchedulingMapper.selectRuleNumSchedulingById(id);
  36 + return errorJobcodeMapper.selectErrorJobcodeById(id);
33 37 }
34 38  
35 39 /**
36   - * 查询排班规则和班次关联列表
  40 + * 查询问题排班列表
37 41 *
38   - * @param ruleNumScheduling 排班规则和班次关联
39   - * @return 排班规则和班次关联
  42 + * @param errorJobcode 问题排班
  43 + * @return 问题排班
40 44 */
41 45 @Override
42   - public List<RuleNumScheduling> selectRuleNumSchedulingList(RuleNumScheduling ruleNumScheduling)
  46 + public List<ErrorJobcodeVo> selectErrorJobcodeList(ErrorJobcodeVo errorJobcode)
43 47 {
44   - return ruleNumSchedulingMapper.selectRuleNumSchedulingList(ruleNumScheduling);
  48 + return errorJobcodeMapper.selectErrorJobcodeList(errorJobcode);
45 49 }
46 50  
47 51 /**
48   - * 新增排班规则和班次关联
  52 + * 新增问题排班
49 53 *
50   - * @param ruleNumScheduling 排班规则和班次关联
  54 + * @param errorJobcode 问题排班
51 55 * @return 结果
52 56 */
53 57 @Override
54   - public int insertRuleNumScheduling(RuleNumScheduling ruleNumScheduling)
  58 + public int insertErrorJobcode(ErrorJobcode errorJobcode)
55 59 {
56   - return ruleNumSchedulingMapper.insertRuleNumScheduling(ruleNumScheduling);
  60 + errorJobcode.setCreateTime(DateUtils.getNowDate());
  61 + return errorJobcodeMapper.insertErrorJobcode(errorJobcode);
57 62 }
58 63  
59 64 /**
60   - * 修改排班规则和班次关联
  65 + * 修改问题排班
61 66 *
62   - * @param ruleNumScheduling 排班规则和班次关联
  67 + * @param errorJobcode 问题排班
63 68 * @return 结果
64 69 */
65 70 @Override
66   - public int updateRuleNumScheduling(RuleNumScheduling ruleNumScheduling)
  71 + public int updateErrorJobcode(ErrorJobcode errorJobcode)
67 72 {
68   - return ruleNumSchedulingMapper.updateRuleNumScheduling(ruleNumScheduling);
  73 + return errorJobcodeMapper.updateErrorJobcode(errorJobcode);
69 74 }
70 75  
71 76 /**
72   - * 批量删除排班规则和班次关联
  77 + * 批量删除问题排班
73 78 *
74   - * @param ids 需要删除的排班规则和班次关联主键
  79 + * @param ids 需要删除的问题排班主键
75 80 * @return 结果
76 81 */
77 82 @Override
78   - public int deleteRuleNumSchedulingByIds(Long[] ids)
  83 + public int deleteErrorJobcodeByIds(Long[] ids)
79 84 {
80   - return ruleNumSchedulingMapper.deleteRuleNumSchedulingByIds(ids);
  85 + return errorJobcodeMapper.deleteErrorJobcodeByIds(ids);
81 86 }
82 87  
83 88 /**
84   - * 删除排班规则和班次关联信息
  89 + * 删除问题排班信息
85 90 *
86   - * @param id 排班规则和班次关联主键
  91 + * @param id 问题排班主键
87 92 * @return 结果
88 93 */
89 94 @Override
90   - public int deleteRuleNumSchedulingById(Long id)
  95 + public int deleteErrorJobcodeById(Long id)
91 96 {
92   - return ruleNumSchedulingMapper.deleteRuleNumSchedulingById(id);
  97 + return errorJobcodeMapper.deleteErrorJobcodeById(id);
  98 + }
  99 +
  100 + @Override
  101 + public void insertBatchErrorJobcode(List<ErrorJobcode> errorScheduling) {
  102 + if (!CollectionUtil.isEmpty(errorScheduling)){
  103 + errorJobcodeMapper.insertBatchErrorJobcode(errorScheduling);
  104 + }
93 105 }
94 106 }
... ...
ruoyi-admin/src/main/java/com/ruoyi/in/controller/SignInController.java
... ... @@ -2,15 +2,14 @@ package com.ruoyi.in.controller;
2 2  
3 3 import java.io.IOException;
4 4 import java.util.List;
  5 +import javax.servlet.http.HttpServletRequest;
5 6 import javax.servlet.http.HttpServletResponse;
6 7  
7 8 import com.ruoyi.common.exception.file.FileUploadException;
8   -import com.ruoyi.pojo.request.FaceUpdateReqVo;
9 9 import com.ruoyi.pojo.response.SignInResponseVo;
10 10 import io.swagger.annotations.Api;
11 11 import io.swagger.annotations.ApiOperation;
12 12 import io.swagger.annotations.ApiParam;
13   -import org.springframework.security.access.prepost.PreAuthorize;
14 13 import org.springframework.beans.factory.annotation.Autowired;
15 14 import org.springframework.validation.annotation.Validated;
16 15 import org.springframework.web.bind.annotation.GetMapping;
... ... @@ -59,7 +58,7 @@ public class SignInController extends BaseController {
59 58 * 导出签到列表
60 59 */
61 60 // @PreAuthorize("@ss.hasPermi('in:in:export')")
62   - @Log(title = "签到", businessType = BusinessType.EXPORT)
  61 +// @Log(title = "签到", businessType = BusinessType.EXPORT)
63 62 @PostMapping("/export")
64 63 @ApiOperation("导出签到列表")
65 64 public void export(HttpServletResponse response, SignInResponseVo signIn) {
... ... @@ -78,16 +77,16 @@ public class SignInController extends BaseController {
78 77 return success(signInService.selectSignInById(id));
79 78 }
80 79  
81   - /**
82   - * 新增签到
83   - */
84   -// @PreAuthorize("@ss.hasPermi('in:in:add')")
85   - @Log(title = "签到", businessType = BusinessType.INSERT)
86   - @PostMapping
87   - @ApiOperation("新增签到(通过后台管理页面)")
88   - public AjaxResult add(@ApiParam @RequestBody SignIn signIn) {
89   - return signInService.insertSignIn(signIn);
90   - }
  80 +// /**
  81 +// * 新增签到
  82 +// */
  83 +//// @PreAuthorize("@ss.hasPermi('in:in:add')")
  84 +// @Log(title = "签到", businessType = BusinessType.INSERT)
  85 +// @PostMapping
  86 +// @ApiOperation("新增签到(通过后台管理页面)")
  87 +// public AjaxResult add(@ApiParam @RequestBody SignIn signIn) {
  88 +// return signInService.insertSignIn(signIn);
  89 +// }
91 90  
92 91  
93 92 /**
... ... @@ -103,25 +102,35 @@ public class SignInController extends BaseController {
103 102 return signInService.addSignIn(signIn);
104 103 }
105 104  
106   - /**
107   - * 修改签到
108   - */
109   -// @PreAuthorize("@ss.hasPermi('in:in:edit')")
110   - @Log(title = "签到", businessType = BusinessType.UPDATE)
111   - @PutMapping
112   - @ApiOperation("修改签到")
113   - public AjaxResult edit(@RequestBody SignIn signIn) {
114   - return toAjax(signInService.updateSignIn(signIn));
115   - }
  105 +// /**
  106 +// * 修改签到
  107 +// */
  108 +//// @PreAuthorize("@ss.hasPermi('in:in:edit')")
  109 +// @Log(title = "签到", businessType = BusinessType.UPDATE)
  110 +// @PutMapping
  111 +// @ApiOperation("修改签到")
  112 +// public AjaxResult edit(@RequestBody SignIn signIn) {
  113 +// return toAjax(signInService.updateSignIn(signIn));
  114 +// }
116 115  
117 116 /**
118 117 * 删除签到
119 118 */
120 119 // @PreAuthorize("@ss.hasPermi('in:in:remove')")
121   - @Log(title = "签到", businessType = BusinessType.DELETE)
122   - @DeleteMapping("/{ids}")
123   - @ApiOperation("删除签到")
124   - public AjaxResult remove(@PathVariable Long[] ids) {
125   - return toAjax(signInService.deleteSignInByIds(ids));
  120 +// @Log(title = "签到", businessType = BusinessType.DELETE)
  121 +// @DeleteMapping("/{ids}")
  122 +// @ApiOperation("删除签到")
  123 +// public AjaxResult remove(@PathVariable Long[] ids) {
  124 +// return toAjax(signInService.deleteSignInByIds(ids));
  125 +// }
  126 +
  127 + @GetMapping("/repair")
  128 + public AjaxResult repairSignRecord(HttpServletRequest request){
  129 + return AjaxResult.success(signInService.repairSignRecord(request));
  130 + }
  131 +
  132 + @GetMapping("/repairAll/{date}")
  133 + public AjaxResult repairAllSignRecord(HttpServletRequest request,@PathVariable("date") String date){
  134 + return AjaxResult.success(signInService.repairAllSignRecord(request,date));
126 135 }
127 136 }
... ...
ruoyi-admin/src/main/java/com/ruoyi/in/mapper/SignInMapper.java
... ... @@ -2,6 +2,7 @@ package com.ruoyi.in.mapper;
2 2  
3 3 import java.util.List;
4 4 import com.ruoyi.in.domain.SignIn;
  5 +import com.ruoyi.domain.DriverScheduling;
5 6 import com.ruoyi.pojo.request.ReportViewRequestVo;
6 7 import com.ruoyi.pojo.request.ReportErrorRequestVo;
7 8 import com.ruoyi.pojo.response.ReportViewResponseVo;
... ... @@ -71,4 +72,8 @@ public interface SignInMapper
71 72 List<ReportViewResponseVo> getReportScrollViewTable(ReportViewRequestVo requestVo);
72 73  
73 74 List<SignIn> getSignErrorList(ReportErrorRequestVo request);
  75 +
  76 + List<DriverScheduling> queryOutBcType();
  77 +
  78 + List<SignIn> querySignInData();
74 79 }
... ...
ruoyi-admin/src/main/java/com/ruoyi/in/service/ISignInService.java
... ... @@ -6,10 +6,10 @@ import java.util.List;
6 6 import com.ruoyi.common.core.domain.AjaxResult;
7 7 import com.ruoyi.common.exception.file.FileUploadException;
8 8 import com.ruoyi.in.domain.SignIn;
9   -import com.ruoyi.pojo.request.ReportViewRequestVo;
10   -import com.ruoyi.pojo.response.ReportViewResponseVo;
11 9 import com.ruoyi.pojo.response.SignInResponseVo;
12 10  
  11 +import javax.servlet.http.HttpServletRequest;
  12 +
13 13 /**
14 14 * 签到Service接口
15 15 *
... ... @@ -73,4 +73,7 @@ public interface ISignInService
73 73 */
74 74 AjaxResult addSignIn(SignIn signIn) throws FileUploadException, IOException;
75 75  
  76 + String repairSignRecord(HttpServletRequest request);
  77 +
  78 + String repairAllSignRecord(HttpServletRequest request,String date);
76 79 }
... ...
ruoyi-admin/src/main/java/com/ruoyi/in/service/impl/SignInServiceImpl.java
... ... @@ -3,11 +3,15 @@ package com.ruoyi.in.service.impl;
3 3 import java.io.File;
4 4 import java.io.IOException;
5 5 import java.math.BigDecimal;
  6 +import java.time.LocalDate;
6 7 import java.time.LocalDateTime;
  8 +import java.time.format.DateTimeFormatter;
7 9 import java.time.temporal.ChronoUnit;
8 10 import java.util.*;
  11 +import java.util.stream.Collectors;
9 12  
10 13 import cn.hutool.core.collection.CollectionUtil;
  14 +import com.ruoyi.common.cache.NowSchedulingCache;
11 15 import com.ruoyi.common.cache.SchedulingCache;
12 16 import com.ruoyi.common.config.RuoYiConfig;
13 17 import com.ruoyi.common.constant.Constants;
... ... @@ -22,9 +26,10 @@ import com.ruoyi.driver.domain.Driver;
22 26 import com.ruoyi.driver.mapper.DriverMapper;
23 27 import com.ruoyi.equipment.domain.Equipment;
24 28 import com.ruoyi.equipment.mapper.EquipmentMapper;
  29 +import com.ruoyi.errorScheduling.service.IErrorJobcodeService;
25 30 import com.ruoyi.pojo.DriverSignRecommendation;
26 31 import com.ruoyi.pojo.GlobalIndex;
27   -import com.ruoyi.pojo.entity.DriverScheduling;
  32 +import com.ruoyi.domain.DriverScheduling;
28 33 import com.ruoyi.pojo.response.SignInResponseVo;
29 34 import com.ruoyi.service.SchedulingService;
30 35 import com.ruoyi.service.ThreadJobService;
... ... @@ -37,8 +42,10 @@ import org.springframework.stereotype.Service;
37 42 import com.ruoyi.in.mapper.SignInMapper;
38 43 import com.ruoyi.in.domain.SignIn;
39 44 import com.ruoyi.in.service.ISignInService;
  45 +import org.springframework.transaction.annotation.Transactional;
40 46  
41 47 import javax.annotation.Resource;
  48 +import javax.servlet.http.HttpServletRequest;
42 49  
43 50 import static com.ruoyi.common.ConstDriverProperties.*;
44 51 import static com.ruoyi.common.ErrorTypeProperties.*;
... ... @@ -57,8 +64,13 @@ public class SignInServiceImpl implements ISignInService {
57 64 private Logger log = LoggerFactory.getLogger(SignInServiceImpl.class);
58 65  
59 66 @Resource
  67 + private NowSchedulingCache nowSchedulingCache;
  68 + @Resource
60 69 private SchedulingService schedulingService;
61 70  
  71 + @Autowired
  72 + private IErrorJobcodeService errorJobcodeService;
  73 +
62 74 @Resource
63 75 private SchedulingCache schedulingCache;
64 76 @Autowired
... ... @@ -223,6 +235,152 @@ public class SignInServiceImpl implements ISignInService {
223 235 return SIGN_IN_SUCCESS.equals(signIn.getStatus()) ? AjaxResult.success(SIGN_IN_SUCCESS_STRING, vo) : AjaxResult.success(SIGN_IN_ERROR + ":" + signIn.getRemark(), vo);
224 236 }
225 237  
  238 + @Override
  239 + @Transactional(rollbackFor = Exception.class)
  240 + public String repairSignRecord(HttpServletRequest request) {
  241 + String header = request.getHeader("X-TOKEN-AUTH");
  242 + if (!"gzjUse".equals(header)) {
  243 + throw new RuntimeException("错误的认证");
  244 + }
  245 + // 获取发车班次
  246 + List<DriverScheduling> list = signInMapper.queryOutBcType();
  247 + // 获取签到数据
  248 + List<SignIn> signIns = signInMapper.querySignInData();
  249 + Map<String, DriverScheduling> transformMap = list.stream().collect(Collectors.toMap(DriverScheduling::getJobCode, item -> item));
  250 + // 更新签到数据
  251 + List<SignIn> signInList = handlerHaveScheduling(transformMap, signIns);
  252 + startRepairSignRecord(transformMap, signInList);
  253 + equipmentMapper.deleteExRecord();
  254 + return null;
  255 + }
  256 +
  257 + @Override
  258 + public String repairAllSignRecord(HttpServletRequest request, String date) {
  259 + String header = request.getHeader("X-TOKEN-AUTH");
  260 + if (!"gzjUse".equals(header)) {
  261 + throw new RuntimeException("错误的认证");
  262 + }
  263 + // 恢复当天的所有签到数据
  264 + // 获取排班
  265 + List<DriverScheduling> dto = schedulingService.queryToDay(date);
  266 + Map<String, List<DriverScheduling>> resultMap = new HashMap<>(500);
  267 + NowSchedulingCache.handlerResultMap(resultMap, dto);
  268 +
  269 + // 获取当天的签到数据
  270 + SignInResponseVo vo = new SignInResponseVo();
  271 + vo.setDate(transFormDate(date));
  272 + List<SignInResponseVo> inList = signInMapper.selectSignInList(vo);
  273 + vo.setDate(transFormDate(handleDate(date)));
  274 + inList.addAll(signInMapper.selectSignInList(vo));
  275 +
  276 + handleAllRecord(resultMap, inList);
  277 +
  278 + return null;
  279 + }
  280 +
  281 + private String handleDate(String dateString) {
  282 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
  283 + // 解析字符串日期为 LocalDate 对象
  284 + LocalDate parse = LocalDate.parse(dateString, formatter);
  285 + // 给日期加上一天
  286 + LocalDate nextDay = parse.plusDays(1);
  287 + // 将结果日期格式化为字符串(可选)
  288 + return nextDay.format(formatter);
  289 + }
  290 +
  291 + private String transFormDate(String dateString){
  292 + DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
  293 + LocalDate parse = LocalDate.parse(dateString, formatter);
  294 + DateTimeFormatter formatter1 = DateTimeFormatter.ofPattern("yyyy-MM-dd");
  295 + return parse.format(formatter1);
  296 + }
  297 +
  298 + private void handleAllRecord(Map<String, List<DriverScheduling>> resultMap, List<SignInResponseVo> inList) {
  299 + inList = inList.stream().filter(item -> !Objects.isNull(resultMap.get(item.getJobCode()))).collect(Collectors.toList());
  300 + Map<String, List<SignInResponseVo>> recordMap = new HashMap<>(500);
  301 + handleSignIn(recordMap, inList);
  302 + // 恢复数据
  303 + repairRecord(resultMap, recordMap);
  304 + errorJobcodeService.insertBatchErrorJobcode(ThreadJobService.getErrorScheduling(resultMap));
  305 + }
  306 +
  307 + private void repairRecord(Map<String, List<DriverScheduling>> resultMap, Map<String, List<SignInResponseVo>> recordMap) {
  308 + Map<String, Driver> drivers = driverMapper.getDrivers(new Driver()).stream().collect(Collectors.toMap(Driver::getJobCode, driver -> driver));
  309 + for (Map.Entry<String, List<SignInResponseVo>> entry : recordMap.entrySet()) {
  310 + List<SignInResponseVo> value = entry.getValue();
  311 + for (SignInResponseVo sign : value) {
  312 + GlobalIndex globalIndex = new GlobalIndex();
  313 + checkSignIn(sign.getCreateTime().getTime(), resultMap.get(sign.getJobCode()), globalIndex, sign, drivers.get(sign.getJobCode()));
  314 + schedulingService.computedSignInBySignIn(resultMap.get(sign.getJobCode()),sign,globalIndex);
  315 + }
  316 + }
  317 + }
  318 +
  319 +
  320 + private void handleSignIn(Map<String, List<SignInResponseVo>> recordMap, List<SignInResponseVo> inList) {
  321 + for (SignInResponseVo vo : inList) {
  322 + List<SignInResponseVo> voList = recordMap.get(vo.getJobCode());
  323 + if (CollectionUtil.isEmpty(voList)) {
  324 + recordMap.put(vo.getJobCode(), new ArrayList<>(Arrays.asList(vo)));
  325 + } else {
  326 + voList.add(vo);
  327 + }
  328 + }
  329 + // 排序
  330 + for (Map.Entry<String, List<SignInResponseVo>> stringListEntry : recordMap.entrySet()) {
  331 + stringListEntry.getValue().sort(Comparator.comparing(SignInResponseVo::getCreateTime));
  332 + }
  333 + }
  334 +
  335 + private void startRepairSignRecord(Map<String, DriverScheduling> transformMap, List<SignIn> signInList) {
  336 + for (SignIn signIn : signInList) {
  337 + handlerExOutData(transformMap.get(signIn.getJobCode()), signIn);
  338 +
  339 + schedulingService.computedSignInBySignIn(new ArrayList<>(Arrays.asList(transformMap.get(signIn.getJobCode()))), signIn, new GlobalIndex());
  340 +// // 更新缓存
  341 + nowSchedulingCache.updateCacheByJobCode(ConstDateUtil.formatDate(transformMap.get(signIn.getJobCode()).getScheduleDate()), 0, signIn);
  342 + signInMapper.updateSignIn(signIn);
  343 +
  344 + }
  345 +
  346 + }
  347 +
  348 + private void handlerExOutData(DriverScheduling driverScheduling, SignIn signIn) {
  349 + LocalDateTime endTime = ConstDateUtil.getLocalDateTimeByLongTime(driverScheduling.getFcsjT());
  350 + LocalDateTime nowTime = ConstDateUtil.getLocalDateTimeByLongTime(signIn.getCreateTime().getTime());
  351 + long nowBetween = ChronoUnit.MINUTES.between(endTime, nowTime);
  352 + if (Math.abs(nowBetween) <= 60) {
  353 + handlerNoExData(signIn, driverScheduling);
  354 + return;
  355 + }
  356 + handlerHaveExData(signIn, driverScheduling);
  357 + }
  358 +
  359 + private void handlerHaveExData(SignIn signIn, DriverScheduling driverScheduling) {
  360 + signIn.setExType(SIGN_TIME_OUT_EX_NUM);
  361 + signIn.setStatus(SIGN_IN_FAIL);
  362 + signIn.setUpdateTime(new Date());
  363 + signIn.setRemark(SIGN_IN_TIMEOUT);
  364 + }
  365 +
  366 + private void handlerNoExData(SignIn signIn, DriverScheduling driverScheduling) {
  367 + signIn.setExType(SIGN_NO_EX_NUM);
  368 + signIn.setStatus(SIGN_IN_SUCCESS);
  369 + signIn.setUpdateTime(new Date());
  370 + signIn.setRemark("正常");
  371 + }
  372 +
  373 + private List<SignIn> handlerHaveScheduling(Map<String, DriverScheduling> transformMap, List<SignIn> signIns) {
  374 + List<SignIn> signList = new ArrayList<>(500);
  375 +
  376 + for (SignIn signIn : signIns) {
  377 + if (!Objects.isNull(transformMap.get(signIn.getJobCode()))) {
  378 + signList.add(signIn);
  379 + }
  380 + }
  381 + return signList;
  382 + }
  383 +
226 384 private SignInResponseVo getSignInResponseVo(Driver driver, SignIn signIn, Equipment equipment) {
227 385 SignInResponseVo vo = new SignInResponseVo(signIn);
228 386 if (Objects.isNull(equipment)) {
... ... @@ -264,6 +422,7 @@ public class SignInServiceImpl implements ISignInService {
264 422 // 酒精测试校验 确定 且员工工种是驾驶员
265 423 if (ALCOHOL_FLAG_YES.equals(signIn.getAlcoholFlag()) && PERSONNEL_POSTS_DRIVER.equals(driver.getPosts())) {
266 424 if (new BigDecimal(20).compareTo(signIn.getAlcoholIntake()) <= 0) {
  425 + threadJobService.asyncSendEmail(dto, globalIndex.getIndex(), signIn, driver);
267 426 signIn.setRemark(signIn.getRemark() + ALCOHOL_SIGN_IN_ERROR + signIn.getAlcoholIntake().toString() + "mg/100ml。");
268 427 signIn.setExType(SIGN_ALCOHOL_EX_NUM);
269 428 result = false;
... ... @@ -296,6 +455,11 @@ public class SignInServiceImpl implements ISignInService {
296 455 }
297 456 break;
298 457 default:
  458 + if (CollectionUtil.isEmpty(dto)) {
  459 + signIn.setRemark(signIn.getRemark() + WORK_DAY_ERROR);
  460 + signIn.setExType(SIGN_NO_SCHEDULING_EX_NUM);
  461 + result = false;
  462 + }
299 463 break;
300 464 }
301 465  
... ... @@ -347,6 +511,10 @@ public class SignInServiceImpl implements ISignInService {
347 511 LocalDateTime endTime = ConstDateUtil.getLocalDateTimeByLongTime(currentScheduling.getTimestamps());
348 512 LocalDateTime nowTime = ConstDateUtil.getLocalDateTimeByLongTime(now);
349 513 long nowBetween = ChronoUnit.MINUTES.between(endTime, nowTime);
  514 + // 异常数据当进出场为单记录时
  515 + if (dto.size() == 1) {
  516 + return handlerExceptionRecord(dto, now, globalIndex, signIn);
  517 + }
350 518 // 不在有效时间范围内,判断当前是否有签到记录 当前应签到还是签退
351 519 if (!(Math.abs(nowBetween) <= 60)) {
352 520 // 签到一个逻辑 当前无记录
... ... @@ -403,6 +571,32 @@ public class SignInServiceImpl implements ISignInService {
403 571 }
404 572 }
405 573  
  574 + private Boolean handlerExceptionRecord(List<DriverScheduling> dto, long now, GlobalIndex globalIndex, SignIn signIn) {
  575 + DriverSignRecommendation currentScheduling = schedulingService.computedTheCurrentClosestTimestamp(dto, now, 0);
  576 + LocalDateTime endTime = ConstDateUtil.getLocalDateTimeByLongTime(currentScheduling.getTimestamps());
  577 + LocalDateTime nowTime = ConstDateUtil.getLocalDateTimeByLongTime(now);
  578 + long nowBetween = ChronoUnit.MINUTES.between(endTime, nowTime);
  579 + globalIndex.setIndex(0);
  580 + // 单挑数据 且不在范围内
  581 + if (BC_TYPE_IN.equals(dto.get(0).getBcType())) {
  582 + if (!(Math.abs(nowBetween) <= 60)) {
  583 + signIn.setRemark(SIGN_OUT_TIMEOUT);
  584 + return false;
  585 + } else {
  586 + return true;
  587 + }
  588 + }
  589 + if (BC_TYPE_OUT.equals(dto.get(0).getBcType())) {
  590 + if (!(Math.abs(nowBetween) <= 60)) {
  591 + signIn.setRemark(SIGN_IN_TIMEOUT);
  592 + return false;
  593 + } else {
  594 + return true;
  595 + }
  596 + }
  597 + return true;
  598 + }
  599 +
406 600 private void uploadImage(SignIn signIn, SignInResponseVo vo) throws IOException {
407 601 String base64 = signIn.getImage();
408 602 // 图片路径
... ...
ruoyi-admin/src/main/java/com/ruoyi/job/DriverJob.java
1 1 package com.ruoyi.job;
2 2  
  3 +import cn.hutool.core.collection.CollectionUtil;
3 4 import cn.hutool.http.HttpUtil;
4 5 import com.alibaba.fastjson2.JSON;
5 6 import com.alibaba.fastjson2.JSONArray;
... ... @@ -17,6 +18,7 @@ import com.ruoyi.pojo.response.ResponseSchedulingDto;
17 18 import com.ruoyi.pojo.response.personnel.*;
18 19 import com.ruoyi.service.ThreadJobService;
19 20 import com.ruoyi.utils.ConstDateUtil;
  21 +import com.ruoyi.utils.ListUtils;
20 22 import lombok.extern.slf4j.Slf4j;
21 23 import org.springframework.beans.BeanUtils;
22 24 import org.springframework.beans.factory.InitializingBean;
... ... @@ -28,6 +30,7 @@ import org.springframework.stereotype.Component;
28 30 import org.springframework.web.client.RestTemplate;
29 31  
30 32 import javax.annotation.Resource;
  33 +import java.io.IOException;
31 34 import java.io.UnsupportedEncodingException;
32 35 import java.net.URLEncoder;
33 36 import java.nio.charset.StandardCharsets;
... ... @@ -260,8 +263,9 @@ public class DriverJob implements InitializingBean {
260 263 /**
261 264 * 计算设备在线状态 5 分钟一次
262 265 */
263   - public void computedDeviceOnlineStatus(String date) {
  266 + public void computedDeviceOnlineStatus(String date) throws IOException, ClassNotFoundException {
264 267 List<Equipment> list = EQUIPMENT_MAPPER.selectEquipmentList(null);
  268 + List<Equipment> original = ListUtils.deepCopy(list);
265 269 Long checkTime = StringUtils.isEmpty(date) ? DEVICE_OFFLINE_TIME : Long.parseLong(date);
266 270 for (Equipment equipment : list) {
267 271 if (Objects.isNull(equipment.getLastHeartRes())) {
... ... @@ -277,9 +281,12 @@ public class DriverJob implements InitializingBean {
277 281 }
278 282 }
279 283 }
  284 + // 更新日志
  285 + THREAD_JOB_SERVICE.asyncInsertEquipmentLog(list,original);
280 286 EQUIPMENT_MAPPER.updateEquipments(list);
281 287 }
282 288  
  289 +
283 290 public Map<String, List<ResponseSchedulingDto>> saveSchedulingToRedis(String getSchedulingInfoUrl, String dateKey) {
284 291 log.info("开始拉取排班:{}", dateKey);
285 292 List<ResponseSchedulingDto> originSchedulingList = RESTTEMPLATE.exchange(
... ...
ruoyi-admin/src/main/java/com/ruoyi/num/controller/RuleNumController.java
... ... @@ -47,6 +47,17 @@ public class RuleNumController extends BaseController
47 47 }
48 48  
49 49 /**
  50 + * 查询班次管理列表
  51 + */
  52 + @PreAuthorize("@ss.hasPermi('num:num:list')")
  53 + @GetMapping("/list/all")
  54 + public AjaxResult listAll(RuleNum ruleNum)
  55 + {
  56 + return AjaxResult.success(ruleNumService.selectRuleNumList(ruleNum));
  57 + }
  58 +
  59 +
  60 + /**
50 61 * 导出班次管理列表
51 62 */
52 63 @PreAuthorize("@ss.hasPermi('num:num:export')")
... ...
ruoyi-admin/src/main/java/com/ruoyi/pojo/DriverSignRecommendation.java
1 1 package com.ruoyi.pojo;
2 2  
3   -import com.ruoyi.pojo.entity.DriverScheduling;
  3 +import com.ruoyi.domain.DriverScheduling;
4 4 import lombok.Data;
5 5  
6 6 import static com.ruoyi.common.ConstDriverProperties.BC_TYPE_OUT;
... ...
ruoyi-admin/src/main/java/com/ruoyi/pojo/equipment/EquipmentOnline.java
... ... @@ -26,12 +26,12 @@ public class EquipmentOnline {
26 26  
27 27 Logger log = LoggerFactory.getLogger(EquipmentOnline.class);
28 28  
29   - @Autowired
30   - private EquipmentOnline(EquipmentMapper mapper) {
31   - log.info("初始化设备信息");
32   - initClient(mapper);
33   - log.info("设备信息初始化完毕");
34   - }
  29 +// @Autowired
  30 +// private EquipmentOnline(EquipmentMapper mapper) {
  31 +// log.info("初始化设备信息");
  32 +// initClient(mapper);
  33 +// log.info("设备信息初始化完毕");
  34 +// }
35 35  
36 36 private void initClient(EquipmentMapper mapper) {
37 37 List<Equipment> list = mapper.selectEquipmentList(null);
... ...
ruoyi-admin/src/main/java/com/ruoyi/pojo/response/ExportReportViewResponseVo.java
... ... @@ -5,7 +5,7 @@ import com.alibaba.excel.annotation.write.style.ColumnWidth;
5 5 import com.alibaba.excel.annotation.write.style.HeadFontStyle;
6 6 import com.alibaba.excel.annotation.write.style.HeadRowHeight;
7 7 import com.ruoyi.common.utils.bean.BeanUtils;
8   -import com.ruoyi.pojo.entity.DriverScheduling;
  8 +import com.ruoyi.domain.DriverScheduling;
9 9 import io.swagger.annotations.ApiModel;
10 10 import io.swagger.annotations.ApiModelProperty;
11 11 import lombok.Data;
... ... @@ -119,17 +119,17 @@ public class ExportReportViewResponseVo {
119 119 int size = driverSchedulings.size();
120 120 this.setHaveSecondFlagString(size >= 4 ? "有分班":"无分班");
121 121 if (size <= 3) {
122   - handleFirst(driverSchedulings, size);
  122 + handlerFirst(driverSchedulings, size);
123 123 }
124 124 // 有分班
125 125 else {
126 126 // 签到
127   - handleFirst(driverSchedulings, 2);
128   - handelSecond(driverSchedulings, size);
  127 + handlerFirst(driverSchedulings, 2);
  128 + handlerSecond(driverSchedulings, size);
129 129 }
130 130 }
131 131  
132   - private void handelSecond(List<DriverScheduling> driverSchedulingList, int size) {
  132 + private void handlerSecond(List<DriverScheduling> driverSchedulingList, int size) {
133 133 // 签到
134 134 this.setSecondPlanSignInTime(new Date(driverSchedulingList.get(2).getFcsjT()));
135 135 this.setSecondActualSignInTime(driverSchedulingList.get(2).getSignTime());
... ... @@ -144,7 +144,7 @@ public class ExportReportViewResponseVo {
144 144 this.setSecondSignOutResultString(Objects.isNull(driverSchedulingList.get(size -1).getSignInId()) ? "未签退" : driverSchedulingList.get(size -1).getRemark());
145 145 }
146 146  
147   - private void handleFirst(List<DriverScheduling> driverSchedulingList, int size) {
  147 + private void handlerFirst(List<DriverScheduling> driverSchedulingList, int size) {
148 148 // 签到
149 149 this.setPlanSignInTime(new Date(driverSchedulingList.get(0).getFcsjT()));
150 150 this.setActualSignInTime(driverSchedulingList.get(0).getSignTime());
... ...
ruoyi-admin/src/main/java/com/ruoyi/pojo/vo/ErrorJobcodeVo.java 0 → 100644
  1 +package com.ruoyi.pojo.vo;
  2 +
  3 +import com.ruoyi.errorScheduling.domain.ErrorJobcode;
  4 +import lombok.Data;
  5 +
  6 +@Data
  7 +public class ErrorJobcodeVo extends ErrorJobcode {
  8 + /**
  9 + * date
  10 + */
  11 + String date;
  12 +}
... ...
ruoyi-admin/src/main/java/com/ruoyi/pojo/vo/PeopleResponseVo.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 + * @author 20412
  9 + */
  10 +@Data
  11 +@ApiModel("人员信息对象")
  12 +public class PeopleResponseVo {
  13 + @ApiModelProperty("工号")
  14 + private String jobCode;
  15 + @ApiModelProperty("姓名")
  16 + private String name;
  17 + @ApiModelProperty("工种")
  18 + private String posts;
  19 + @ApiModelProperty("部门")
  20 + private String fleetName;
  21 +}
... ...
ruoyi-admin/src/main/java/com/ruoyi/pojo/vo/RuleSchedulingResponseVo.java 0 → 100644
  1 +package com.ruoyi.pojo.vo;
  2 +
  3 +import com.ruoyi.common.annotation.Excel;
  4 +import com.ruoyi.scheduling.domain.RuleScheduling;
  5 +import lombok.Data;
  6 +
  7 +/**
  8 + * @author 20412
  9 + */
  10 +@Data
  11 +public class RuleSchedulingResponseVo extends RuleScheduling {
  12 + private String rangeTime;
  13 +
  14 +}
... ...
ruoyi-admin/src/main/java/com/ruoyi/pojo/vo/RuleSchedulingVo.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 RuleSchedulingVo {
  10 +
  11 + private Long id;
  12 + /**
  13 + * 规则名称
  14 + */
  15 + private String ruleName;
  16 + /**
  17 + * 时间范围
  18 + */
  19 + private String rangeTime;
  20 +}
... ...
ruoyi-admin/src/main/java/com/ruoyi/pojo/vo/SchedulingRequestVo.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 +import java.util.List;
  8 +
  9 +/**
  10 + * @author 20412
  11 + */
  12 +@Data
  13 +@ApiModel("排班规则请求vo")
  14 +public class SchedulingRequestVo {
  15 + @ApiModelProperty("id")
  16 + private Long id;
  17 + @ApiModelProperty("规则名字")
  18 + private String matchName;
  19 + @ApiModelProperty("班次名称")
  20 + private String ruleDictName;
  21 + @ApiModelProperty("班次类型")
  22 + private Integer ruleType;
  23 +
  24 + private Integer pageNum;
  25 + private Integer pageSize;
  26 +}
... ...
ruoyi-admin/src/main/java/com/ruoyi/pojo/vo/SchedulingResponseVo.java 0 → 100644
  1 +package com.ruoyi.pojo.vo;
  2 +
  3 +import io.swagger.annotations.ApiModelProperty;
  4 +import lombok.Data;
  5 +
  6 +import java.util.List;
  7 +
  8 +/**
  9 + * @author 20412
  10 + */
  11 +@Data
  12 +public class SchedulingResponseVo {
  13 +
  14 + @ApiModelProperty("规则名字")
  15 + private String matchName;
  16 + @ApiModelProperty("班次名称")
  17 + private String ruleDictName;
  18 + @ApiModelProperty("班次类型")
  19 + private Integer ruleType;
  20 + @ApiModelProperty("考勤规则列表")
  21 + private List<String> ruleList;
  22 + @ApiModelProperty("适用人员")
  23 + private List<String> peopleList;
  24 +}
... ...
ruoyi-admin/src/main/java/com/ruoyi/scheduling/controller/RuleSchedulingController.java
... ... @@ -2,6 +2,8 @@ package com.ruoyi.scheduling.controller;
2 2  
3 3 import java.util.List;
4 4 import javax.servlet.http.HttpServletResponse;
  5 +
  6 +import com.ruoyi.pojo.vo.RuleSchedulingResponseVo;
5 7 import org.springframework.security.access.prepost.PreAuthorize;
6 8 import org.springframework.beans.factory.annotation.Autowired;
7 9 import org.springframework.web.bind.annotation.GetMapping;
... ... @@ -43,7 +45,18 @@ public class RuleSchedulingController extends BaseController
43 45 {
44 46 startPage();
45 47 List<RuleScheduling> list = ruleSchedulingService.selectRuleSchedulingList(ruleScheduling);
46   - return getDataTable(list);
  48 + List<RuleSchedulingResponseVo> vos = ruleSchedulingService.handleResponseRuleSchedulingList(list);
  49 + return getDataTable(vos);
  50 + }
  51 +
  52 + /**
  53 + * 查询排版规则列表
  54 + */
  55 + @PreAuthorize("@ss.hasPermi('scheduling:scheduling:list')")
  56 + @GetMapping("/list/all")
  57 + public AjaxResult listAll(RuleScheduling ruleScheduling)
  58 + {
  59 + return AjaxResult.success(ruleSchedulingService.selectRuleSchedulingListVo(ruleScheduling));
47 60 }
48 61  
49 62 /**
... ...
ruoyi-admin/src/main/java/com/ruoyi/scheduling/domain/RuleScheduling.java
... ... @@ -2,10 +2,12 @@ package com.ruoyi.scheduling.domain;
2 2  
3 3 import java.util.Date;
4 4 import com.fasterxml.jackson.annotation.JsonFormat;
  5 +import lombok.Data;
5 6 import org.apache.commons.lang3.builder.ToStringBuilder;
6 7 import org.apache.commons.lang3.builder.ToStringStyle;
7 8 import com.ruoyi.common.annotation.Excel;
8 9 import com.ruoyi.common.core.domain.BaseEntity;
  10 +import org.springframework.format.annotation.DateTimeFormat;
9 11  
10 12 /**
11 13 * 排版规则对象 rule_scheduling
... ... @@ -13,6 +15,7 @@ import com.ruoyi.common.core.domain.BaseEntity;
13 15 * @author guzijian
14 16 * @date 2023-08-07
15 17 */
  18 +@Data
16 19 public class RuleScheduling extends BaseEntity
17 20 {
18 21 private static final long serialVersionUID = 1L;
... ... @@ -26,228 +29,66 @@ public class RuleScheduling extends BaseEntity
26 29  
27 30 /** 工时制 */
28 31 @Excel(name = "工时制")
29   - private Long workingHourPlan;
  32 + private Integer workingHourPlan;
30 33  
31 34 /** 工时类型 */
32 35 @Excel(name = "工时类型")
33   - private Long workingHourType;
  36 + private Integer workingHourType;
34 37  
35 38 /** 第一段上班签到时间 */
36   - @JsonFormat(pattern = "yyyy-MM-dd")
37   - @Excel(name = "第一段上班签到时间", width = 30, dateFormat = "yyyy-MM-dd")
  39 + @JsonFormat(pattern = "HH:mm")
  40 + @Excel(name = "第一段上班签到时间", width = 30, dateFormat = "HH:mm")
  41 + @DateTimeFormat(pattern = "HH:mm")
38 42 private Date firstWorkSignInTime;
39 43  
40 44 /** 第一段上班打卡签到范围 */
41 45 @Excel(name = "第一段上班打卡签到范围")
42   - private Long firstSignInWorkingRange;
  46 + private Integer firstSignInWorkingRange;
43 47  
44 48 /** 第一段下班签退时间 */
45   - @JsonFormat(pattern = "yyyy-MM-dd")
46   - @Excel(name = "第一段下班签退时间", width = 30, dateFormat = "yyyy-MM-dd")
  49 + @JsonFormat(pattern = "HH:mm")
  50 + @Excel(name = "第一段下班签退时间", width = 30, dateFormat = "HH:mm")
  51 + @DateTimeFormat(pattern = "HH:mm")
47 52 private Date firstQuittingSignInTime;
48 53  
49 54 /** 第一段上下班标识,今天时间还是隔天 */
50 55 @Excel(name = "第一段上下班标识,今天时间还是隔天")
51   - private Long firstSignInDayTomorrow;
  56 + private Integer firstSignInDayTomorrow;
52 57  
53 58 /** 第一段下班签退签到范围 */
54 59 @Excel(name = "第一段下班签退签到范围")
55   - private Long firstSignInQuittingRange;
  60 + private Integer firstSignInQuittingRange;
56 61  
57 62 /** 超时范围允许 */
58 63 @Excel(name = "超时范围允许")
59   - private Long signInTimeOutRange;
  64 + private Integer signInTimeOutRange;
60 65  
61 66 /** 第二段开启标识 1默认1 未开启 2 开启 */
62 67 @Excel(name = "第二段开启标识 1默认1 未开启 2 开启")
63   - private Long secondFlag;
  68 + private Integer secondFlag;
64 69  
65 70 /** 第二段上班签到时间 */
66   - @JsonFormat(pattern = "yyyy-MM-dd")
67   - @Excel(name = "第二段上班签到时间", width = 30, dateFormat = "yyyy-MM-dd")
  71 + @JsonFormat(pattern = "HH:mm")
  72 + @Excel(name = "第二段上班签到时间", width = 30, dateFormat = "HH:mm")
  73 + @DateTimeFormat(pattern = "HH:mm")
68 74 private Date secondWorkSignInTime;
69 75  
70 76 /** 第二段上班打卡范围 */
71 77 @Excel(name = "第二段上班打卡范围")
72   - private Long secondSignInWorkingRange;
  78 + private Integer secondSignInWorkingRange;
73 79  
74 80 /** 第二段下班签到签退 */
75   - @JsonFormat(pattern = "yyyy-MM-dd")
76   - @Excel(name = "第二段下班签到签退", width = 30, dateFormat = "yyyy-MM-dd")
  81 + @JsonFormat(pattern = "HH:mm")
  82 + @Excel(name = "第二段下班签到签退", width = 30, dateFormat = "HH:mm")
  83 + @DateTimeFormat(pattern = "HH:mm")
77 84 private Date secondQuittingSignInTime;
78 85  
79 86 /** 第二段下班打卡范围 */
80 87 @Excel(name = "第二段下班打卡范围")
81   - private Long secondSignInQuittingRange;
  88 + private Integer secondSignInQuittingRange;
82 89  
83 90 /** 第二段上下班标识,今天时间还是隔天 */
84 91 @Excel(name = "第二段上下班标识,今天时间还是隔天")
85   - private Long secondSignDayTomorrow;
86   -
87   - public void setId(Long id)
88   - {
89   - this.id = id;
90   - }
91   -
92   - public Long getId()
93   - {
94   - return id;
95   - }
96   - public void setRuleName(String ruleName)
97   - {
98   - this.ruleName = ruleName;
99   - }
100   -
101   - public String getRuleName()
102   - {
103   - return ruleName;
104   - }
105   - public void setWorkingHourPlan(Long workingHourPlan)
106   - {
107   - this.workingHourPlan = workingHourPlan;
108   - }
109   -
110   - public Long getWorkingHourPlan()
111   - {
112   - return workingHourPlan;
113   - }
114   - public void setWorkingHourType(Long workingHourType)
115   - {
116   - this.workingHourType = workingHourType;
117   - }
118   -
119   - public Long getWorkingHourType()
120   - {
121   - return workingHourType;
122   - }
123   - public void setFirstWorkSignInTime(Date firstWorkSignInTime)
124   - {
125   - this.firstWorkSignInTime = firstWorkSignInTime;
126   - }
127   -
128   - public Date getFirstWorkSignInTime()
129   - {
130   - return firstWorkSignInTime;
131   - }
132   - public void setFirstSignInWorkingRange(Long firstSignInWorkingRange)
133   - {
134   - this.firstSignInWorkingRange = firstSignInWorkingRange;
135   - }
136   -
137   - public Long getFirstSignInWorkingRange()
138   - {
139   - return firstSignInWorkingRange;
140   - }
141   - public void setFirstQuittingSignInTime(Date firstQuittingSignInTime)
142   - {
143   - this.firstQuittingSignInTime = firstQuittingSignInTime;
144   - }
145   -
146   - public Date getFirstQuittingSignInTime()
147   - {
148   - return firstQuittingSignInTime;
149   - }
150   - public void setFirstSignInDayTomorrow(Long firstSignInDayTomorrow)
151   - {
152   - this.firstSignInDayTomorrow = firstSignInDayTomorrow;
153   - }
154   -
155   - public Long getFirstSignInDayTomorrow()
156   - {
157   - return firstSignInDayTomorrow;
158   - }
159   - public void setFirstSignInQuittingRange(Long firstSignInQuittingRange)
160   - {
161   - this.firstSignInQuittingRange = firstSignInQuittingRange;
162   - }
163   -
164   - public Long getFirstSignInQuittingRange()
165   - {
166   - return firstSignInQuittingRange;
167   - }
168   - public void setSignInTimeOutRange(Long signInTimeOutRange)
169   - {
170   - this.signInTimeOutRange = signInTimeOutRange;
171   - }
172   -
173   - public Long getSignInTimeOutRange()
174   - {
175   - return signInTimeOutRange;
176   - }
177   - public void setSecondFlag(Long secondFlag)
178   - {
179   - this.secondFlag = secondFlag;
180   - }
181   -
182   - public Long getSecondFlag()
183   - {
184   - return secondFlag;
185   - }
186   - public void setSecondWorkSignInTime(Date secondWorkSignInTime)
187   - {
188   - this.secondWorkSignInTime = secondWorkSignInTime;
189   - }
190   -
191   - public Date getSecondWorkSignInTime()
192   - {
193   - return secondWorkSignInTime;
194   - }
195   - public void setSecondSignInWorkingRange(Long secondSignInWorkingRange)
196   - {
197   - this.secondSignInWorkingRange = secondSignInWorkingRange;
198   - }
199   -
200   - public Long getSecondSignInWorkingRange()
201   - {
202   - return secondSignInWorkingRange;
203   - }
204   - public void setSecondQuittingSignInTime(Date secondQuittingSignInTime)
205   - {
206   - this.secondQuittingSignInTime = secondQuittingSignInTime;
207   - }
208   -
209   - public Date getSecondQuittingSignInTime()
210   - {
211   - return secondQuittingSignInTime;
212   - }
213   - public void setSecondSignInQuittingRange(Long secondSignInQuittingRange)
214   - {
215   - this.secondSignInQuittingRange = secondSignInQuittingRange;
216   - }
217   -
218   - public Long getSecondSignInQuittingRange()
219   - {
220   - return secondSignInQuittingRange;
221   - }
222   - public void setSecondSignDayTomorrow(Long secondSignDayTomorrow)
223   - {
224   - this.secondSignDayTomorrow = secondSignDayTomorrow;
225   - }
226   -
227   - public Long getSecondSignDayTomorrow()
228   - {
229   - return secondSignDayTomorrow;
230   - }
231   -
232   - @Override
233   - public String toString() {
234   - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
235   - .append("id", getId())
236   - .append("ruleName", getRuleName())
237   - .append("workingHourPlan", getWorkingHourPlan())
238   - .append("workingHourType", getWorkingHourType())
239   - .append("firstWorkSignInTime", getFirstWorkSignInTime())
240   - .append("firstSignInWorkingRange", getFirstSignInWorkingRange())
241   - .append("firstQuittingSignInTime", getFirstQuittingSignInTime())
242   - .append("firstSignInDayTomorrow", getFirstSignInDayTomorrow())
243   - .append("firstSignInQuittingRange", getFirstSignInQuittingRange())
244   - .append("signInTimeOutRange", getSignInTimeOutRange())
245   - .append("secondFlag", getSecondFlag())
246   - .append("secondWorkSignInTime", getSecondWorkSignInTime())
247   - .append("secondSignInWorkingRange", getSecondSignInWorkingRange())
248   - .append("secondQuittingSignInTime", getSecondQuittingSignInTime())
249   - .append("secondSignInQuittingRange", getSecondSignInQuittingRange())
250   - .append("secondSignDayTomorrow", getSecondSignDayTomorrow())
251   - .toString();
252   - }
  92 + private Integer secondSignDayTomorrow;
  93 +
253 94 }
... ...
ruoyi-admin/src/main/java/com/ruoyi/scheduling/service/IRuleSchedulingService.java
1 1 package com.ruoyi.scheduling.service;
2 2  
3 3 import java.util.List;
  4 +
  5 +import com.ruoyi.pojo.vo.RuleSchedulingResponseVo;
  6 +import com.ruoyi.pojo.vo.RuleSchedulingVo;
4 7 import com.ruoyi.scheduling.domain.RuleScheduling;
5 8  
6 9 /**
... ... @@ -58,4 +61,8 @@ public interface IRuleSchedulingService
58 61 * @return 结果
59 62 */
60 63 public int deleteRuleSchedulingById(Long id);
  64 +
  65 + List<RuleSchedulingVo> selectRuleSchedulingListVo(RuleScheduling ruleScheduling);
  66 +
  67 + List<RuleSchedulingResponseVo> handleResponseRuleSchedulingList(List<RuleScheduling> list);
61 68 }
... ...
ruoyi-admin/src/main/java/com/ruoyi/scheduling/service/impl/RuleSchedulingServiceImpl.java
1 1 package com.ruoyi.scheduling.service.impl;
2 2  
  3 +import java.text.SimpleDateFormat;
  4 +import java.util.Date;
3 5 import java.util.List;
4   -import com.ruoyi.common.utils.SecurityUtils;
  6 +import java.util.stream.Collectors;
  7 +
  8 +import cn.hutool.core.collection.CollectionUtil;
  9 +import com.ruoyi.pojo.vo.RuleSchedulingResponseVo;
  10 +import com.ruoyi.pojo.vo.RuleSchedulingVo;
  11 +import org.springframework.beans.BeanUtils;
5 12 import org.springframework.beans.factory.annotation.Autowired;
6 13 import org.springframework.stereotype.Service;
7 14 import com.ruoyi.scheduling.mapper.RuleSchedulingMapper;
8 15 import com.ruoyi.scheduling.domain.RuleScheduling;
9 16 import com.ruoyi.scheduling.service.IRuleSchedulingService;
10 17  
  18 +import static com.ruoyi.common.RuleSchedulingProperties.*;
  19 +
11 20 /**
12 21 * 排版规则Service业务层处理
13   - *
  22 + *
14 23 * @author guzijian
15 24 * @date 2023-08-04
16 25 */
17 26 @Service
18   -public class RuleSchedulingServiceImpl implements IRuleSchedulingService
19   -{
  27 +public class RuleSchedulingServiceImpl implements IRuleSchedulingService {
20 28 @Autowired
21 29 private RuleSchedulingMapper ruleSchedulingMapper;
22 30  
23 31 /**
24 32 * 查询排版规则
25   - *
  33 + *
26 34 * @param id 排版规则主键
27 35 * @return 排版规则
28 36 */
29 37 @Override
30   - public RuleScheduling selectRuleSchedulingById(Long id)
31   - {
  38 + public RuleScheduling selectRuleSchedulingById(Long id) {
32 39 return ruleSchedulingMapper.selectRuleSchedulingById(id);
33 40 }
34 41  
35 42 /**
36 43 * 查询排版规则列表
37   - *
  44 + *
38 45 * @param ruleScheduling 排版规则
39 46 * @return 排版规则
40 47 */
41 48 @Override
42   - public List<RuleScheduling> selectRuleSchedulingList(RuleScheduling ruleScheduling)
43   - {
  49 + public List<RuleScheduling> selectRuleSchedulingList(RuleScheduling ruleScheduling) {
44 50 return ruleSchedulingMapper.selectRuleSchedulingList(ruleScheduling);
45 51 }
46 52  
47 53 /**
48 54 * 新增排版规则
49   - *
  55 + *
50 56 * @param ruleScheduling 排版规则
51 57 * @return 结果
52 58 */
53 59 @Override
54   - public int insertRuleScheduling(RuleScheduling ruleScheduling)
55   - {
  60 + public int insertRuleScheduling(RuleScheduling ruleScheduling) {
56 61 return ruleSchedulingMapper.insertRuleScheduling(ruleScheduling);
57 62 }
58 63  
59 64 /**
60 65 * 修改排版规则
61   - *
  66 + *
62 67 * @param ruleScheduling 排版规则
63 68 * @return 结果
64 69 */
65 70 @Override
66   - public int updateRuleScheduling(RuleScheduling ruleScheduling)
67   - {
  71 + public int updateRuleScheduling(RuleScheduling ruleScheduling) {
68 72 return ruleSchedulingMapper.updateRuleScheduling(ruleScheduling);
69 73 }
70 74  
71 75 /**
72 76 * 批量删除排版规则
73   - *
  77 + *
74 78 * @param ids 需要删除的排版规则主键
75 79 * @return 结果
76 80 */
77 81 @Override
78   - public int deleteRuleSchedulingByIds(Long[] ids)
79   - {
  82 + public int deleteRuleSchedulingByIds(Long[] ids) {
80 83 return ruleSchedulingMapper.deleteRuleSchedulingByIds(ids);
81 84 }
82 85  
83 86 /**
84 87 * 删除排版规则信息
85   - *
  88 + *
86 89 * @param id 排版规则主键
87 90 * @return 结果
88 91 */
89 92 @Override
90   - public int deleteRuleSchedulingById(Long id)
91   - {
  93 + public int deleteRuleSchedulingById(Long id) {
92 94 return ruleSchedulingMapper.deleteRuleSchedulingById(id);
93 95 }
  96 +
  97 + @Override
  98 + public List<RuleSchedulingVo> selectRuleSchedulingListVo(RuleScheduling ruleScheduling) {
  99 + List<RuleScheduling> list = ruleSchedulingMapper.selectRuleSchedulingList(ruleScheduling);
  100 + return handleRuleScheduling(list);
  101 + }
  102 +
  103 + @Override
  104 + public List<RuleSchedulingResponseVo> handleResponseRuleSchedulingList(List<RuleScheduling> list) {
  105 + return list.stream()
  106 + .map(item ->{
  107 + RuleSchedulingResponseVo vo = new RuleSchedulingResponseVo();
  108 + BeanUtils.copyProperties(item,vo);
  109 + vo.setRangeTime(handleRuleSchedulingRangeTime(item));
  110 + return vo;
  111 + })
  112 + .collect(Collectors.toList());
  113 + }
  114 +
  115 + private List<RuleSchedulingVo> handleRuleScheduling(List<RuleScheduling> list) {
  116 + if (CollectionUtil.isEmpty(list)) {
  117 + return null;
  118 + }
  119 +
  120 + // 处理返回数据
  121 + return list
  122 + .stream()
  123 + .map(item -> {
  124 + RuleSchedulingVo vo = new RuleSchedulingVo();
  125 + vo.setRuleName(item.getRuleName());
  126 + vo.setId(item.getId());
  127 + vo.setRangeTime(handleRuleSchedulingRangeTime(item));
  128 + return vo;
  129 + })
  130 + .collect(Collectors.toList());
  131 +
  132 + }
  133 +
  134 + private String handleRuleSchedulingRangeTime(RuleScheduling item) {
  135 + // 处理存在分段的数据
  136 + if (HAVE_SEGMENTATION.equals(item.getSecondFlag())) {
  137 + return handleSegmentation(item);
  138 + }
  139 + // 处理不存在分段的数据
  140 + else {
  141 + return handleNoSegmentation(item);
  142 + }
  143 + }
  144 +
  145 + private String handleNoSegmentation(RuleScheduling item) {
  146 + // 处理不隔天的情况
  147 + if (TOMORROW_NO.equals(item.getFirstSignInDayTomorrow())) {
  148 + return transformTimeType(item.getFirstWorkSignInTime()) + TOMORROW_NO_STRING + transformTimeType(item.getFirstQuittingSignInTime());
  149 + }
  150 + // 隔天
  151 + else {
  152 + return transformTimeType(item.getFirstWorkSignInTime()) + TOMORROW_YES_STRING + transformTimeType(item.getFirstQuittingSignInTime());
  153 + }
  154 + }
  155 +
  156 + private String handleSegmentation(RuleScheduling item) {
  157 + // 隔天
  158 + String firstRangeTimeString = handleNoSegmentation(item);
  159 + String secondRangeTimeString = handleHaveSegmentation(item);
  160 + return firstRangeTimeString + ";" + secondRangeTimeString;
  161 + }
  162 +
  163 + private String handleHaveSegmentation(RuleScheduling item) {
  164 + // 处理不隔天的情况
  165 + if (TOMORROW_NO.equals(item.getSecondSignDayTomorrow())) {
  166 + return transformTimeType(item.getSecondWorkSignInTime()) + TOMORROW_NO_STRING + transformTimeType(item.getSecondQuittingSignInTime());
  167 + }
  168 + // 隔天
  169 + else {
  170 + return transformTimeType(item.getSecondWorkSignInTime()) + TOMORROW_YES_STRING + transformTimeType(item.getSecondQuittingSignInTime());
  171 + }
  172 + }
  173 +
  174 + private String transformTimeType(Date time) {
  175 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat("HH:mm");
  176 + return simpleDateFormat.format(time);
  177 + }
94 178 }
... ...
ruoyi-admin/src/main/java/com/ruoyi/schedulingAssociateNum/domain/RuleNumScheduling.java deleted 100644 → 0
1   -package com.ruoyi.schedulingAssociateNum.domain;
2   -
3   -import org.apache.commons.lang3.builder.ToStringBuilder;
4   -import org.apache.commons.lang3.builder.ToStringStyle;
5   -import com.ruoyi.common.annotation.Excel;
6   -import com.ruoyi.common.core.domain.BaseEntity;
7   -
8   -/**
9   - * 排班规则和班次关联对象 rule_num_scheduling
10   - *
11   - * @author 古自健
12   - * @date 2023-08-07
13   - */
14   -public class RuleNumScheduling extends BaseEntity
15   -{
16   - private static final long serialVersionUID = 1L;
17   -
18   - /** 主键 */
19   - private Long id;
20   -
21   - /** 班次id */
22   - @Excel(name = "班次id")
23   - private Long ruleNumId;
24   -
25   - /** 规则id集合 */
26   - @Excel(name = "规则id集合")
27   - private String ruleSchedulingId;
28   -
29   - /** 排班名称 */
30   - @Excel(name = "排班名称")
31   - private String matchName;
32   -
33   - public void setId(Long id)
34   - {
35   - this.id = id;
36   - }
37   -
38   - public Long getId()
39   - {
40   - return id;
41   - }
42   - public void setRuleNumId(Long ruleNumId)
43   - {
44   - this.ruleNumId = ruleNumId;
45   - }
46   -
47   - public Long getRuleNumId()
48   - {
49   - return ruleNumId;
50   - }
51   - public void setRuleSchedulingId(String ruleSchedulingId)
52   - {
53   - this.ruleSchedulingId = ruleSchedulingId;
54   - }
55   -
56   - public String getRuleSchedulingId()
57   - {
58   - return ruleSchedulingId;
59   - }
60   - public void setMatchName(String matchName)
61   - {
62   - this.matchName = matchName;
63   - }
64   -
65   - public String getMatchName()
66   - {
67   - return matchName;
68   - }
69   -
70   - @Override
71   - public String toString() {
72   - return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)
73   - .append("id", getId())
74   - .append("ruleNumId", getRuleNumId())
75   - .append("ruleSchedulingId", getRuleSchedulingId())
76   - .append("matchName", getMatchName())
77   - .toString();
78   - }
79   -}
ruoyi-admin/src/main/java/com/ruoyi/service/AppService.java
... ... @@ -96,7 +96,6 @@ public class AppService {
96 96  
97 97 public void checkAppHeart(HeartPackageVo vo) {
98 98 Equipment equipment = new Equipment();
99   - equipment.setOnlineClient(DEVICE_ONLINE);
100 99 equipment.setLastHeartRes(new Date());
101 100 equipment.setDeviceId(vo.getDeviceId());
102 101 equipment.setRemark("版本号:" + vo.getVersionNum());
... ...
ruoyi-admin/src/main/java/com/ruoyi/service/AttendanceService.java 0 → 100644
  1 +package com.ruoyi.service;
  2 +
  3 +import com.ruoyi.pojo.vo.PeopleResponseVo;
  4 +import com.ruoyi.pojo.vo.SchedulingRequestVo;
  5 +
  6 +import java.util.List;
  7 +
  8 +/**
  9 + * @author 20412
  10 + */
  11 +public interface AttendanceService {
  12 + /**
  13 + * 获取人员信息
  14 + * @param id
  15 + * @return
  16 + */
  17 + List<PeopleResponseVo> getDriverInfo(Long id);
  18 +
  19 + List<SchedulingRequestVo> getSchedulingList(SchedulingRequestVo vo);
  20 +}
... ...
ruoyi-admin/src/main/java/com/ruoyi/service/EmailService.java 0 → 100644
  1 +package com.ruoyi.service;
  2 +
  3 +import com.ruoyi.email.domain.EmailConfig;
  4 +import com.ruoyi.email.service.IEmailConfigService;
  5 +import com.ruoyi.domain.DriverScheduling;
  6 +import com.ruoyi.utils.ConstDateUtil;
  7 +import org.slf4j.Logger;
  8 +import org.slf4j.LoggerFactory;
  9 +import org.springframework.beans.factory.annotation.Autowired;
  10 +import org.springframework.beans.factory.annotation.Value;
  11 +import org.springframework.mail.javamail.JavaMailSender;
  12 +import org.springframework.mail.javamail.MimeMessageHelper;
  13 +import org.springframework.stereotype.Service;
  14 +
  15 +import javax.mail.internet.MimeMessage;
  16 +import java.math.BigDecimal;
  17 +import java.util.Arrays;
  18 +import java.util.Date;
  19 +import java.util.List;
  20 +import java.util.Objects;
  21 +import java.util.stream.Collectors;
  22 +
  23 +/**
  24 + * 发送邮箱服务
  25 + *
  26 + * @author 20412
  27 + */
  28 +@Service
  29 +public class EmailService {
  30 + @Autowired
  31 + private JavaMailSender javaMailSender;
  32 +
  33 + @Autowired
  34 + private IEmailConfigService emailConfigService;
  35 +
  36 + private static final Logger log = LoggerFactory.getLogger(EmailService.class);
  37 +
  38 + @Value("${spring.mail.form}")
  39 + private String from;
  40 +
  41 + @Value("${spring.mail.nickname}")
  42 + private String name;
  43 +
  44 + public void sendWarningEmail(DriverScheduling item, Date signTime, BigDecimal alcoholIntake) {
  45 +
  46 + // TODO 支持发送多人 读取配置文件选着发送对象
  47 + List<EmailConfig> emailConfigs = emailConfigService.selectRecipientsEmailConfigList();
  48 + for (EmailConfig config : emailConfigs) {
  49 + String recipientEmail = config.getEmail().trim();
  50 + List<String> emails = getRecipientsEmailIds(config);
  51 + MimeMessage mimeMessage = javaMailSender.createMimeMessage();
  52 + try {
  53 + MimeMessageHelper mimeMessageHelper = new MimeMessageHelper(mimeMessage, true);
  54 + mimeMessageHelper.setFrom(from,name);
  55 + mimeMessageHelper.setTo(recipientEmail);
  56 + mimeMessageHelper.setSubject("重要警示:酒精测试通知");
  57 + if (!Objects.isNull(emails)) mimeMessageHelper.setCc(emails.toArray(new String[0]));
  58 + String jobCode = "工号:" + item.getJobCode() + "\n";
  59 + String name = "姓名:" + item.getName() + "\n";
  60 + String posts = "工种:" + item.getPosts() + "\n";
  61 + String fleetName = "车队:" + item.getFleetName() + "\n";
  62 + String scheduling = "排班:" + (Objects.isNull(item.getScheduleDate()) ? "无排班" : "有排班") + "\n";
  63 + String signDate = "打卡时间:" + ConstDateUtil.formatDate("yyyy-MM-dd HH:mm:ss", signTime) + "\n";
  64 + String cause = "原因:酒精测试超标,当前测试值达到" + alcoholIntake.toString() + "mg/100ml。属于" + getResultString(alcoholIntake);
  65 +
  66 + String content = jobCode + name + posts + fleetName + scheduling + signDate + cause;
  67 + mimeMessageHelper.setText(content);
  68 + javaMailSender.send(mimeMessage);
  69 + log.info("发送给:" + recipientEmail + "邮件发送成功");
  70 + } catch (Exception e) {
  71 + log.info("发送给:" + recipientEmail + "邮件发送失败");
  72 + log.error(e.getMessage());
  73 + }
  74 + }
  75 +
  76 + }
  77 +
  78 + private List<String> getRecipientsEmailIds(EmailConfig config) {
  79 + if (!Objects.isNull(config.getParentId())){
  80 + return emailConfigService
  81 + .selectEmailConfigListByIds(Arrays.stream(config.getParentId()
  82 + .split(","))
  83 + .map(Long::parseLong)
  84 + .collect(Collectors.toList()))
  85 + .stream()
  86 + .map(EmailConfig::getEmail)
  87 + .collect(Collectors.toList());
  88 + }
  89 + return null;
  90 + }
  91 +
  92 + private String getResultString(BigDecimal alcoholIntake) {
  93 + if (alcoholIntake.compareTo(new BigDecimal(20)) >= 0 && alcoholIntake.compareTo(new BigDecimal(80)) < 0)
  94 + return "饮酒后驾驶机动车";
  95 + else
  96 + return "醉酒后驾驶机动车";
  97 + }
  98 +}
... ...
ruoyi-admin/src/main/java/com/ruoyi/service/ReportService.java
1 1 package com.ruoyi.service;
2 2  
3   -import com.ruoyi.driver.domain.Driver;
4 3 import com.ruoyi.driver.mapper.DriverMapper;
5 4 import com.ruoyi.driver.mapper.DriverSchedulingMapper;
6   -import com.ruoyi.eexception.domain.EquipmentException;
7 5 import com.ruoyi.eexception.mapper.EquipmentExceptionMapper;
8   -import com.ruoyi.in.domain.SignIn;
9 6 import com.ruoyi.in.mapper.SignInMapper;
10   -import com.ruoyi.pojo.entity.DriverScheduling;
  7 +import com.ruoyi.domain.DriverScheduling;
11 8 import com.ruoyi.pojo.request.ReportViewRequestVo;
12 9 import com.ruoyi.pojo.request.ReportErrorRequestVo;
13 10 import com.ruoyi.pojo.response.*;
14   -import com.ruoyi.utils.ConstDateUtil;
15 11 import org.springframework.beans.BeanUtils;
16 12 import org.springframework.beans.factory.annotation.Autowired;
17 13 import org.springframework.stereotype.Service;
... ... @@ -19,7 +15,6 @@ import org.springframework.stereotype.Service;
19 15 import javax.annotation.Resource;
20 16 import javax.servlet.http.HttpServletResponse;
21 17 import javax.validation.constraints.NotBlank;
22   -import java.text.SimpleDateFormat;
23 18 import java.time.LocalDate;
24 19 import java.time.YearMonth;
25 20 import java.time.format.DateTimeFormatter;
... ... @@ -28,8 +23,6 @@ import java.util.stream.Collectors;
28 23  
29 24 import static com.ruoyi.common.ConstDriverProperties.BC_TYPE_OUT;
30 25 import static com.ruoyi.common.ConstSignInConstSignInProperties.*;
31   -import static com.ruoyi.common.ErrorTypeProperties.EQUIPMENT_ERROR;
32   -import static com.ruoyi.common.ErrorTypeProperties.SIGN_IN_ERROR;
33 26 import static com.ruoyi.common.ReportProperties.DAY;
34 27 import static com.ruoyi.common.ReportProperties.MONTH;
35 28  
... ... @@ -96,7 +89,7 @@ public class ReportService {
96 89 List<DriverScheduling> schedulingList = schedulingMapper.queryToDay(date, null, null, null);
97 90 Map<String, List<DriverScheduling>> resultMap = new HashMap<>(800);
98 91 List<ExportReportViewResponseVo> vo = new ArrayList<>(800);
99   - handleResultMap(date, resultMap, schedulingList);
  92 + handlerResultMap(date, resultMap, schedulingList);
100 93 handleResultList(vo, resultMap);
101 94 return vo;
102 95 }
... ... @@ -108,7 +101,7 @@ public class ReportService {
108 101 }
109 102 }
110 103  
111   - private void handleResultMap(@NotBlank String date, Map<String, List<DriverScheduling>> resultMap, List<DriverScheduling> schedulingList) {
  104 + private void handlerResultMap(@NotBlank String date, Map<String, List<DriverScheduling>> resultMap, List<DriverScheduling> schedulingList) {
112 105 for (DriverScheduling item : schedulingList) {
113 106 String key = date + item.getJobCode();
114 107 if (Objects.isNull(resultMap.get(key))) {
... ... @@ -156,14 +149,14 @@ public class ReportService {
156 149 List<DriverScheduling> toDay = schedulingMapper.queryToDay(vo.getDate(), vo.getName(), vo.getJobCode(), vo.getLineName());
157 150 for (DriverScheduling scheduling : toDay) {
158 151 ReportDetailResponseVo reportDetailResponseVo = new ReportDetailResponseVo();
159   - handleReportDetail(reportDetailResponseVo, scheduling);
  152 + handlerReportDetail(reportDetailResponseVo, scheduling);
160 153 responseVos.add(reportDetailResponseVo);
161 154 }
162 155 responseVos.sort(Comparator.comparing(ReportDetailResponseVo::getPlanTime));
163 156 return responseVos;
164 157 }
165 158  
166   - private void handleReportDetail(ReportDetailResponseVo reportDetailResponseVo, DriverScheduling scheduling) {
  159 + private void handlerReportDetail(ReportDetailResponseVo reportDetailResponseVo, DriverScheduling scheduling) {
167 160 BeanUtils.copyProperties(scheduling, reportDetailResponseVo);
168 161 reportDetailResponseVo.setPlanAction(scheduling.getBcType().equals(BC_TYPE_OUT) ? SIGN_IN_STRING : SIGN_IN_OUT_STRING);
169 162 reportDetailResponseVo.setPlanTime(scheduling.getBcType().equals(BC_TYPE_OUT) ? new Date(scheduling.getFcsjT()) : new Date(scheduling.getZdsjT()));
... ...
ruoyi-admin/src/main/java/com/ruoyi/service/SchedulingService.java
... ... @@ -7,7 +7,7 @@ import com.ruoyi.in.domain.SignIn;
7 7 import com.ruoyi.in.mapper.SignInMapper;
8 8 import com.ruoyi.pojo.DriverSignRecommendation;
9 9 import com.ruoyi.pojo.GlobalIndex;
10   -import com.ruoyi.pojo.entity.DriverScheduling;
  10 +import com.ruoyi.domain.DriverScheduling;
11 11 import com.ruoyi.pojo.request.ReportViewRequestVo;
12 12 import com.ruoyi.pojo.response.ReportViewResponseVo;
13 13 import com.ruoyi.utils.ConstDateUtil;
... ... @@ -118,7 +118,7 @@ public class SchedulingService {
118 118  
119 119 // 更新最新的签到记录判断是否需要更新考勤
120 120 // 记录为空直接插入记录
121   - if (Objects.isNull(dto.get(globalIndex.getIndex()).getSignInId())) {
  121 + if (Objects.isNull(dto.get(globalIndex.getIndex()).getSignInId()) || dto.size() == 1) {
122 122 schedulingMapper.updateRoster(dto.get(globalIndex.getIndex()), signIn.getId(), signIn.getExType(), signIn.getCreateTime(), signIn.getRemark(), signIn.getType(), signIn.getAlcoholFlag(), signIn.getAlcoholIntake());
123 123 // 更新缓存
124 124 nowSchedulingCache.updateCacheByJobCode(ConstDateUtil.formatDate(dto.get(0).getScheduleDate()), globalIndex.getIndex(), signIn);
... ... @@ -130,12 +130,12 @@ public class SchedulingService {
130 130 }
131 131 // 之前的有效
132 132 else {
133   - handleRecord(dto, signIn, globalIndex);
  133 + handlerRecord(dto, signIn, globalIndex);
134 134 }
135 135  
136 136 }
137 137  
138   - private void handleRecord(List<DriverScheduling> dto, SignIn signIn, GlobalIndex globalIndex) {
  138 + private void handlerRecord(List<DriverScheduling> dto, SignIn signIn, GlobalIndex globalIndex) {
139 139 if (globalIndex.getIndex() == dto.size() - 1) {
140 140 return;
141 141 }
... ... @@ -210,13 +210,13 @@ public class SchedulingService {
210 210 for (String key : orangeMap.keySet()) {
211 211 List<DriverScheduling> list = orangeMap.get(key);
212 212 ReportViewResponseVo vo1 = new ReportViewResponseVo();
213   - handleScheduling(list, vo1);
  213 + handlerScheduling(list, vo1);
214 214 resultMap.put(key, vo1);
215 215 }
216 216 return new ArrayList<>(resultMap.values());
217 217 }
218 218  
219   - private static void handleScheduling(List<DriverScheduling> list, ReportViewResponseVo vo) {
  219 + private static void handlerScheduling(List<DriverScheduling> list, ReportViewResponseVo vo) {
220 220 int planSignInCount = 0;
221 221 int actualSignInCount = 0;
222 222 int planSignOutCount = 0;
... ... @@ -249,4 +249,8 @@ public class SchedulingService {
249 249 vo.setActualSignInCount(actualSignInCount);
250 250 vo.setActualSignOutCount(actualSignOutCount);
251 251 }
  252 +
  253 + public List<DriverScheduling> queryToDay(String date) {
  254 + return schedulingMapper.queryToDay(date,null,null,null);
  255 + }
252 256 }
... ...
ruoyi-admin/src/main/java/com/ruoyi/service/ThreadJobService.java
... ... @@ -13,12 +13,16 @@ import com.ruoyi.driver.mapper.DriverMapper;
13 13 import com.ruoyi.driver.mapper.DriverSchedulingMapper;
14 14 import com.ruoyi.eexception.domain.EquipmentException;
15 15 import com.ruoyi.eexception.mapper.EquipmentExceptionMapper;
  16 +import com.ruoyi.equipment.domain.Equipment;
  17 +import com.ruoyi.equipment.domain.EquipmentLog;
  18 +import com.ruoyi.equipment.mapper.EquipmentMapper;
  19 +import com.ruoyi.errorScheduling.domain.ErrorJobcode;
  20 +import com.ruoyi.errorScheduling.service.IErrorJobcodeService;
16 21 import com.ruoyi.in.domain.SignIn;
17 22 import com.ruoyi.job.DriverJob;
18   -import com.ruoyi.pojo.entity.DriverScheduling;
  23 +import com.ruoyi.domain.DriverScheduling;
19 24 import com.ruoyi.pojo.response.ResponseSchedulingDto;
20 25 import com.ruoyi.utils.ConstDateUtil;
21   -import com.ruoyi.utils.ToolUtils;
22 26 import lombok.extern.slf4j.Slf4j;
23 27 import org.springframework.beans.BeanUtils;
24 28 import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -55,6 +59,12 @@ import static com.ruoyi.common.ConstSignInConstSignInProperties.SIGN_NO_EX_NUM;
55 59 public class ThreadJobService {
56 60  
57 61 @Autowired
  62 + private IErrorJobcodeService errorJobcodeService;
  63 +
  64 + @Resource
  65 + private EmailService emailService;
  66 +
  67 + @Autowired
58 68 private DriverMapper driverMapper;
59 69  
60 70 @Autowired
... ... @@ -70,6 +80,9 @@ public class ThreadJobService {
70 80 @Autowired
71 81 private EquipmentExceptionMapper exceptionMapper;
72 82  
  83 + @Autowired
  84 + private EquipmentMapper equipmentMapper;
  85 +
73 86 @Value("${api.headImage}")
74 87 private String headImagePre;
75 88  
... ... @@ -128,8 +141,8 @@ public class ThreadJobService {
128 141 }
129 142  
130 143 @Async
131   - public void asyncInsertExceptionRecord(SignIn signIn){
132   - if (!SIGN_NO_EX_NUM.equals(signIn.getExType())){
  144 + public void asyncInsertExceptionRecord(SignIn signIn) {
  145 + if (!SIGN_NO_EX_NUM.equals(signIn.getExType())) {
133 146 EquipmentException exception = new EquipmentException();
134 147 exception.setExType(signIn.getExType());
135 148 exception.setDeviceId(signIn.getDeviceId());
... ... @@ -160,8 +173,35 @@ public class ThreadJobService {
160 173 log.error("保存数据是出现了异常:{}", e.getMessage());
161 174 }
162 175 }
  176 + }
  177 +
  178 + /**
  179 + * 异步发送邮件
  180 + *
  181 + * @param dto
  182 + * @param signIn
  183 + * @param driver
  184 + */
  185 + @Async
  186 + public void asyncSendEmail(List<DriverScheduling> dto, Integer index, SignIn signIn, Driver driver) {
  187 + DriverScheduling item = null;
  188 + if (CollectionUtil.isEmpty(dto)) {
  189 + item = new DriverScheduling();
  190 + handlerNoScheduling(item, signIn, driver);
  191 + // 无排班
  192 + emailService.sendWarningEmail(item, signIn.getCreateTime(), signIn.getAlcoholIntake());
  193 + } else {
  194 + // 有排班
  195 + emailService.sendWarningEmail(dto.get(index), signIn.getCreateTime(), signIn.getAlcoholIntake());
  196 + }
163 197  
  198 + }
164 199  
  200 + private void handlerNoScheduling(DriverScheduling item, SignIn signIn, Driver driver) {
  201 + BeanUtils.copyProperties(signIn, item);
  202 + item.setName(driver.getPersonnelName());
  203 + item.setFleetName(driver.getFleetName());
  204 + item.setPosts(driver.getPosts());
165 205 }
166 206  
167 207 private void insertDriverInfo(String token, Driver driver) {
... ... @@ -281,20 +321,31 @@ public class ThreadJobService {
281 321 @Async
282 322 @Transactional(rollbackFor = {Exception.class})
283 323 public void asyncComputedScheduling(Map<String, List<ResponseSchedulingDto>> originSchedulingMap) {
284   - //查询当天是否保存过考情表 如果存在则保存
285   - List<DriverScheduling> dto = schedulingMapper.queryToDay(ConstDateUtil.formatDate("yyyy-MM-dd"), null,null,null);
286   - // 存入缓存
  324 + //查询当天是否保存过考情表 如果不存在则保存
  325 + Map<String, List<DriverScheduling>> dto = nowSchedulingCache.getCacheScheduling(ConstDateUtil.formatDate(new Date()));
287 326 if (!CollectionUtil.isEmpty(dto) || originSchedulingMap.size() == 0) {
288   - String date = ConstDateUtil.formatDate(new Date());
289   - if (CollectionUtil.isEmpty(nowSchedulingCache.getCacheScheduling(date))){
290   - Map<String, List<DriverScheduling>> resultMap =new HashMap<>(800);
291   - handleResultMap(resultMap,dto);
292   - nowSchedulingCache.setCacheScheduling(date,resultMap);
293   - }
294 327 return;
295 328 }
  329 + List<DriverScheduling> bcList = getBcList(originSchedulingMap);
  330 + // 插入排班
  331 + schedulingMapper.insertRoster(bcList);
  332 + // 异常数据过多,不通过自增获取id再次查询获取
  333 + bcList = schedulingMapper.queryToDay(ConstDateUtil.formatDate("yyyy-MM-dd"), null, null, null);
  334 + // 处理缓存和错误排班
  335 + String date = ConstDateUtil.formatDate(new Date());
  336 + if (!CollectionUtil.isEmpty(bcList)) {
  337 + Map<String, List<DriverScheduling>> resultMap = new HashMap<>(800);
  338 + NowSchedulingCache.handlerResultMap(resultMap, bcList);
  339 + // 更新缓存
  340 + nowSchedulingCache.setCacheScheduling(date, resultMap);
  341 + // 获取错误排班
  342 + List<ErrorJobcode> errorScheduling = getErrorScheduling(resultMap);
  343 + // 插入错误排班
  344 + errorJobcodeService.insertBatchErrorJobcode(errorScheduling);
  345 + }
  346 + }
296 347  
297   -
  348 + private List<DriverScheduling> getBcList(Map<String, List<ResponseSchedulingDto>> originSchedulingMap) {
298 349 List<DriverScheduling> bcList = new ArrayList<>(1000);
299 350 for (String key : originSchedulingMap.keySet()) {
300 351 List<ResponseSchedulingDto> schedulingList = originSchedulingMap.get(key);
... ... @@ -302,29 +353,148 @@ public class ThreadJobService {
302 353 .filter(item -> BC_TYPE_IN.equals(item.getBcType()) || BC_TYPE_OUT.equals(item.getBcType()))
303 354 .map(item -> {
304 355 DriverScheduling scheduling = new DriverScheduling();
305   - BeanUtils.copyProperties(item, scheduling);
  356 + BeanUtils.copyProperties(item, scheduling, "id");
306 357 return scheduling;
307 358 }).collect(Collectors.toList());
308   - if (nowScheduling.size() > 4){
309   - System.out.println("问题工号:" + key);
310   - }
311   - if (nowScheduling.size() % 2 == 1){
312   - System.out.println("问题工号:" + key);
  359 + if (nowScheduling.size() % 2 == 1 && nowScheduling.size() > 2) {
  360 + // 处理错误班次
  361 + nowScheduling = handleErrorBc(schedulingList);
313 362 }
314 363 bcList.addAll(nowScheduling);
315 364 }
316   - schedulingMapper.insertRoster(bcList);
  365 + return bcList;
  366 + }
  367 +
  368 + public static List<ErrorJobcode> getErrorScheduling(Map<String, List<DriverScheduling>> resultMap) {
  369 + List<ErrorJobcode> errorList = new ArrayList<>();
  370 + // 循环处理
  371 + for (String key : resultMap.keySet()) {
  372 + List<DriverScheduling> schedulingList = resultMap.get(key);
  373 + schedulingList.sort(Comparator.comparing(DriverScheduling::getFcsjT));
  374 + // 处理单进|出场
  375 + if (resultMap.get(key).size() == 1) {
  376 + errorList.add(handlerSingleBc(schedulingList));
  377 + } else {
  378 + // 处理进出场不匹配
  379 + ErrorJobcode errorJobcode = handlerBcNoMatch(schedulingList);
  380 + if (errorJobcode != null) errorList.add(errorJobcode);
  381 + }
  382 + }
  383 + return errorList;
  384 + }
  385 +
  386 + public static ErrorJobcode handlerBcNoMatch(List<DriverScheduling> driverSchedulingList) {
  387 +
  388 + ErrorJobcode er = new ErrorJobcode();
  389 + BeanUtils.copyProperties(driverSchedulingList.get(0), er);
  390 + er.setCreateTime(driverSchedulingList.get(0).getScheduleDate());
  391 + // 出场次数
  392 + int bcOutCount = 0;
  393 + // 进场次数
  394 + int bcInCount = 0;
  395 + // 连续进场场次
  396 + boolean inContinuousFlag = false;
  397 + // 连续出场场次
  398 + boolean outContinuousFlag = false;
  399 + int length = driverSchedulingList.size();
  400 + for (int i = 0; i < length; i++) {
  401 + if (i < length - 1) {
  402 + // 判断是否出现连续
  403 + if (driverSchedulingList.get(i) == driverSchedulingList.get(i + 1)) {
  404 + if (BC_TYPE_IN.equals(driverSchedulingList.get(i).getBcType())) inContinuousFlag = true;
  405 + else outContinuousFlag = true;
  406 + }
  407 + }
  408 + if (BC_TYPE_IN.equals(driverSchedulingList.get(i).getBcType())) bcInCount++;
  409 + else bcOutCount++;
  410 + }
  411 + // 匹配进出场顺序
  412 + if (bcOutCount == bcInCount) {
  413 + if (inContinuousFlag || outContinuousFlag) {
  414 + er.setRemark(inContinuousFlag ? "连续进场" : "连续出场");
  415 + return er;
  416 + }
  417 + } else {
  418 + er.setRemark(bcOutCount > bcInCount ? "出场次数与进场次数不匹配,多于进场" : "进场次数与进场次数不匹配,多于出场");
  419 + return er;
  420 + }
  421 +
  422 + return null;
  423 +
  424 + }
  425 +
  426 + public static ErrorJobcode handlerSingleBc(List<DriverScheduling> driverSchedulingList) {
  427 + ErrorJobcode errorJobcode = new ErrorJobcode();
  428 + BeanUtils.copyProperties(driverSchedulingList.get(0), errorJobcode);
  429 + errorJobcode.setCreateTime(driverSchedulingList.get(0).getScheduleDate());
  430 + errorJobcode.setRemark(BC_TYPE_IN.equals(driverSchedulingList.get(0).getBcType()) ? "单个场次,没有出场" : "单个场次,没有进场");
  431 + return errorJobcode;
  432 + }
  433 +
  434 + private List<DriverScheduling> handleErrorBc(List<ResponseSchedulingDto> nowScheduling) {
  435 + // 处理两个进场
  436 + return handlerTowIn(nowScheduling);
  437 + }
  438 +
  439 + private List<DriverScheduling> handlerTowIn(List<ResponseSchedulingDto> nowScheduling) {
  440 + nowScheduling = nowScheduling.stream().filter(item -> BC_TYPE_IN.equals(item.getBcType()) || BC_TYPE_OUT.equals(item.getBcType())).collect(Collectors.toList());
  441 + if (nowScheduling.get(nowScheduling.size() - 1).getBcType().equals(BC_TYPE_IN)) {
  442 + // 连续的进场 判断哪个适配
  443 + ResponseSchedulingDto scheduling1 = nowScheduling.get(nowScheduling.size() - 1);
  444 + ResponseSchedulingDto scheduling2 = nowScheduling.get(nowScheduling.size() - 2);
  445 + // 判断后移除
  446 + if ("秀沁路汽车站".equals(scheduling1.getZdzName())) {
  447 + nowScheduling.remove(nowScheduling.size() - 2);
  448 + }
  449 + if ("秀沁路汽车站".equals(scheduling2.getZdzName())) {
  450 + nowScheduling.remove(nowScheduling.size() - 1);
  451 + }
  452 + }
  453 +
  454 + return nowScheduling.stream().map(item -> {
  455 + DriverScheduling scheduling = new DriverScheduling();
  456 + BeanUtils.copyProperties(item, scheduling);
  457 + return scheduling;
  458 + }).collect(Collectors.toList());
  459 + }
  460 +
  461 + @Async
  462 + public void asyncInsertEquipmentLog(List<Equipment> list, List<Equipment> original) {
  463 + // 插入离线日志
  464 + List<Equipment> offline = handleOffLine(list);
  465 + if (CollectionUtil.isNotEmpty(offline)) {
  466 + equipmentMapper.insertEquipmentOffLineLog(offline);
  467 + }
  468 +
  469 + // 更新恢复日志
  470 + List<EquipmentLog> recoveryList = handlerEquipmentRecovery(list, original);
  471 + if (CollectionUtil.isNotEmpty(recoveryList)) {
  472 + equipmentMapper.updateEquipmentLog(recoveryList);
  473 + }
317 474 }
318 475  
319   - private void handleResultMap(Map<String, List<DriverScheduling>> resultMap, List<DriverScheduling> schedulingList) {
320   - for (DriverScheduling scheduling : schedulingList) {
321   - List<DriverScheduling> list = resultMap.get(scheduling.getJobCode());
322   - if (CollectionUtil.isEmpty(list)){
323   - resultMap.put(scheduling.getJobCode(),new ArrayList<>(Arrays.asList(scheduling)));
324   - }else {
325   - list.add(scheduling);
  476 + private List<Equipment> handleOffLine(List<Equipment> list) {
  477 + return list.stream().filter(item -> "脱机".equals(item.getOnlineClient())).collect(Collectors.toList());
  478 + }
  479 +
  480 + private List<EquipmentLog> handlerEquipmentRecovery(List<Equipment> list, List<Equipment> original) {
  481 + if (CollectionUtil.isEmpty(original)) {
  482 + return new ArrayList<>();
  483 + }
  484 + List<EquipmentLog> recoveryList = new ArrayList<>(12);
  485 + Map<String, Equipment> originalMap = original.stream().collect(Collectors.toMap(Equipment::getDeviceId, equipment -> equipment));
  486 + for (Equipment nowItem : list) {
  487 + Equipment eqOr = originalMap.get(nowItem.getDeviceId());
  488 + if (!nowItem.getOnlineClient().equals(eqOr.getOnlineClient()) && DEVICE_OFFLINE.equals(eqOr.getOnlineClient())) {
  489 + EquipmentLog eqLog = new EquipmentLog();
  490 + eqLog.setRecoveryFlag(DEVICE_ONLINE_NUM);
  491 + eqLog.setRecoveryTime(nowItem.getLastHeartRes());
  492 + eqLog.setDeviceId(eqOr.getDeviceId());
  493 + recoveryList.add(eqLog);
326 494 }
327 495 }
  496 + return recoveryList;
328 497 }
329 498  
  499 +
330 500 }
... ...
ruoyi-admin/src/main/java/com/ruoyi/service/impl/AttendanceServiceImpl.java 0 → 100644
  1 +package com.ruoyi.service.impl;
  2 +
  3 +import com.github.pagehelper.PageHelper;
  4 +import com.github.pagehelper.PageInfo;
  5 +import com.ruoyi.common.utils.PageUtils;
  6 +import com.ruoyi.driver.mapper.DriverMapper;
  7 +import com.ruoyi.mapper.RuleAttendanceMapper;
  8 +import com.ruoyi.pojo.vo.PeopleResponseVo;
  9 +import com.ruoyi.pojo.vo.SchedulingRequestVo;
  10 +import com.ruoyi.service.AttendanceService;
  11 +import org.springframework.beans.factory.annotation.Autowired;
  12 +import org.springframework.stereotype.Service;
  13 +
  14 +import java.util.List;
  15 +
  16 +/**
  17 + * @author 20412
  18 + */
  19 +@Service
  20 +public class AttendanceServiceImpl implements AttendanceService {
  21 +
  22 + @Autowired
  23 + private DriverMapper driverMapper;
  24 +
  25 +
  26 + @Autowired
  27 + private RuleAttendanceMapper ruleAttendanceMapper;
  28 +
  29 + @Override
  30 + public List<PeopleResponseVo> getDriverInfo(Long id) {
  31 + List<PeopleResponseVo> vos ;
  32 + // TODO 待完成
  33 + if (id != null) {
  34 + vos = driverMapper.queryAttendanceInfoById(id);
  35 + } else {
  36 + // 获取所有为设置考勤的人员
  37 + vos = driverMapper.queryAttendanceInfoAll();
  38 + }
  39 + return vos;
  40 + }
  41 +
  42 + @Override
  43 + public List<SchedulingRequestVo> getSchedulingList(SchedulingRequestVo vo) {
  44 + PageUtils.startPage();
  45 +// ruleAttendanceMapper.getSchedulingList(vo);
  46 + return null;
  47 + }
  48 +}
... ...
ruoyi-admin/src/main/java/com/ruoyi/utils/ConstDateUtil.java
1 1 package com.ruoyi.utils;
2 2  
3   -import java.text.ParseException;
4 3 import java.text.SimpleDateFormat;
5 4 import java.time.Instant;
6 5 import java.time.LocalDateTime;
... ... @@ -9,10 +8,14 @@ import java.util.Calendar;
9 8 import java.util.Date;
10 9  
11 10 public class ConstDateUtil {
12   - public static String formatDate(String str){
13   - SimpleDateFormat simpleDateFormat = new SimpleDateFormat(str);
  11 + public static String formatDate(String pattern){
  12 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
14 13 return simpleDateFormat.format(new Date());
15 14 }
  15 + public static String formatDate(String pattern,Date date){
  16 + SimpleDateFormat simpleDateFormat = new SimpleDateFormat(pattern);
  17 + return simpleDateFormat.format(date);
  18 + }
16 19 public static String formatDate(long time){
17 20 SimpleDateFormat simpleDateFormat = new SimpleDateFormat("yyyyMMdd");
18 21 return simpleDateFormat.format(new Date(time));
... ... @@ -38,4 +41,6 @@ public class ConstDateUtil {
38 41 LocalDateTime localDateTime = instant.atZone(ZoneId.systemDefault()).toLocalDateTime();
39 42 return localDateTime;
40 43 }
  44 +
  45 +
41 46 }
... ...
ruoyi-admin/src/main/java/com/ruoyi/utils/ListUtils.java
1 1 package com.ruoyi.utils;
2 2  
  3 +import cn.hutool.core.collection.CollectionUtil;
  4 +
  5 +import java.io.*;
3 6 import java.util.ArrayList;
4 7 import java.util.List;
5 8  
... ... @@ -17,4 +20,26 @@ public class ListUtils&lt;T&gt;{
17 20 }
18 21 return batchList;
19 22 }
  23 +
  24 + /**
  25 + * 深度备份
  26 + * @param sourceList
  27 + * @return
  28 + * @param <T>
  29 + * @throws IOException
  30 + * @throws ClassNotFoundException
  31 + */
  32 + public static <T> List<T> deepCopy(List<T> sourceList) throws IOException, ClassNotFoundException{
  33 + if (CollectionUtil.isEmpty(sourceList)){
  34 + return new ArrayList<>();
  35 + }
  36 + ByteArrayOutputStream bo= new ByteArrayOutputStream();
  37 + ObjectOutputStream oos= new ObjectOutputStream(bo);
  38 + oos.writeObject(sourceList);
  39 + ByteArrayInputStream bi= new ByteArrayInputStream(bo.toByteArray());
  40 + ObjectInputStream ois=new ObjectInputStream(bi);
  41 + @SuppressWarnings("unchecked")
  42 + List<T> dest = (List<T>)ois.readObject();
  43 + return dest;
  44 + }
20 45 }
... ...
ruoyi-admin/src/main/resources/application-druid-dev.yml
1 1 # 数据源配置
2 2 spring:
  3 + # 邮箱配置
  4 + mail:
  5 + # 只发送不接收
  6 + host: smtp.163.com
  7 + # 自己的邮箱
  8 + username: m18980249160@163.com
  9 + # 提供的密码 不是自己的登录密码
  10 + password: RZHJXWXPCALIAOCG
  11 + # 占用端口号
  12 + port: 465
  13 + nickname: 酒精测试异常通知
  14 + form: m18980249160@163.com
  15 + protocol: smtp
  16 + properties:
  17 + mail:
  18 + smtp:
  19 + ssl:
  20 + enable: true
  21 + socketFactory:
  22 + class: javax.net.ssl.SSLSocketFactory
  23 +
  24 +
  25 +
  26 +
3 27 datasource:
4 28 type: com.alibaba.druid.pool.DruidDataSource
5 29 driverClassName: com.mysql.cj.jdbc.Driver
... ... @@ -7,7 +31,7 @@ spring:
7 31 # 主库数据源
8 32 master:
9 33 # 测试地址
10   - url: jdbc:mysql://1.14.107.94:3306/all-in-one?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&useAffectedRows=true&allowMultiQueries=true
  34 + url: jdbc:mysql://localhost:3306/all-in-one?useUnicode=true&characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=true&serverTimezone=GMT%2B8&useAffectedRows=true&allowMultiQueries=true
11 35 username: root
12 36 password: guzijian
13 37 # 从库数据源
... ...
ruoyi-admin/src/main/resources/application-druid-prd.yml
1 1 # 数据源配置
2 2 spring:
  3 + # 邮箱配置
  4 + mail:
  5 + # 只发送不接收
  6 + host: smtp.163.com
  7 + # 自己的邮箱
  8 + username: m18980249160@163.com
  9 + # 提供的密码 不是自己的登录密码
  10 + password: RZHJXWXPCALIAOCG
  11 + # 占用端口号
  12 + port: 465
  13 + nickname: 酒精测试异常通知
  14 + form: m18980249160@163.com
  15 + protocol: smtp
  16 + properties:
  17 + mail:
  18 + smtp:
  19 + ssl:
  20 + enable: true
  21 + socketFactory:
  22 + class: javax.net.ssl.SSLSocketFactory
  23 +
3 24 datasource:
4 25 type: com.alibaba.druid.pool.DruidDataSource
5 26 driverClassName: com.mysql.cj.jdbc.Driver
... ...
ruoyi-admin/src/main/resources/application-druid-uat.yml
1 1 # 数据源配置
2 2 spring:
  3 + # 邮箱配置
  4 + mail:
  5 + # 只发送不接收
  6 + host: smtp.163.com
  7 + # 自己的邮箱
  8 + username: m18980249160@163.com
  9 + # 提供的密码 不是自己的登录密码
  10 + password: RZHJXWXPCALIAOCG
  11 + # 占用端口号
  12 + port: 465
  13 + nickname: 酒精测试异常通知
  14 + form: m18980249160@163.com
  15 + protocol: smtp
  16 + properties:
  17 + mail:
  18 + smtp:
  19 + ssl:
  20 + enable: true
  21 + socketFactory:
  22 + class: javax.net.ssl.SSLSocketFactory
  23 +
3 24 datasource:
4 25 type: com.alibaba.druid.pool.DruidDataSource
5 26 driverClassName: com.mysql.cj.jdbc.Driver
... ...
ruoyi-admin/src/main/resources/mapper/driver/DriverMapper.xml
... ... @@ -25,7 +25,13 @@
25 25 <result property="updateTime" column="update_time"/>
26 26 <result property="fleetName" column="fleet_name"/>
27 27 </resultMap>
  28 + <resultMap id="PeopleResult" type="com.ruoyi.pojo.vo.PeopleResponseVo">
28 29  
  30 + <result property="jobCode" column="job_code"/>
  31 + <result property="fleetName" column="fleet_name"/>
  32 + <result property="posts" column="posts"/>
  33 + <result property="name" column="personnel_name"/>
  34 + </resultMap>
29 35 <sql id="selectDriverVo">
30 36 select id,
31 37 job_code,
... ... @@ -172,6 +178,25 @@
172 178 #{item}
173 179 </foreach>
174 180 </select>
  181 + <select id="queryAttendanceInfoById" resultType="com.ruoyi.pojo.vo.PeopleResponseVo" resultMap="PeopleResult">
  182 +
  183 + </select>
  184 + <select id="queryAttendanceInfoAll" resultType="com.ruoyi.pojo.vo.PeopleResponseVo" resultMap="PeopleResult">
  185 + SELECT
  186 + job_code,
  187 + personnel_name,
  188 + posts,
  189 + fleet_name
  190 + FROM
  191 + 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 != "售票员"
  199 + </select>
175 200  
176 201 <insert id="insertDriver" parameterType="Driver" useGeneratedKeys="true" keyProperty="id">
177 202 insert into driver
... ...
ruoyi-admin/src/main/resources/mapper/driver_scheduling/DriverSchedulingMapper.xml
... ... @@ -5,7 +5,7 @@
5 5 <mapper namespace="com.ruoyi.driver.mapper.DriverSchedulingMapper">
6 6  
7 7  
8   - <resultMap id="Scheduling" type="com.ruoyi.pojo.entity.DriverScheduling">
  8 + <resultMap id="Scheduling" type="com.ruoyi.domain.DriverScheduling">
9 9 <id column="id" jdbcType="BIGINT" property="id"/>
10 10 <result column="job_code" property="jobCode"/>
11 11 <result column="name" property="name"/>
... ... @@ -23,10 +23,10 @@
23 23 <result column="alcohol_flag" property="alcoholFlag" jdbcType="DATETIMEOFFSET"/>
24 24 <result column="alcohol_intake" property="alcoholIntake"/>
25 25 </resultMap>
26   - <insert id="insertRoster" useGeneratedKeys="true" keyProperty="id">
  26 + <insert id="insertRoster" parameterType="java.util.List" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
27 27 insert into scheduling (schedule_date,line_name,job_code,`name`,posts,lp_name,nbbm,bc_type,fcsj_t,zdsj_t)
28 28 values
29   - <foreach collection="list" item="item" index="index" separator=",">
  29 + <foreach collection="list" item="item" separator=",">
30 30 (
31 31 #{item.scheduleDate},
32 32 #{item.lineName},
... ... @@ -39,7 +39,6 @@
39 39 #{item.fcsjT},
40 40 #{item.zdsjT}
41 41 )
42   -
43 42 </foreach>
44 43 on duplicate key update
45 44 job_code = values(job_code)
... ... @@ -56,7 +55,7 @@
56 55 where id = #{scheduling.id}
57 56 </update>
58 57  
59   - <select id="queryToDay" resultType="com.ruoyi.pojo.entity.DriverScheduling" resultMap="Scheduling">
  58 + <select id="queryToDay" resultType="com.ruoyi.domain.DriverScheduling" resultMap="Scheduling">
60 59 select scheduling.*,driver.fleet_name fleetName from
61 60 scheduling join driver on driver.job_code = scheduling.job_code
62 61 where schedule_date = #{date}
... ...
ruoyi-admin/src/main/resources/mapper/email/EmailConfigMapper.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.email.mapper.EmailConfigMapper">
  6 +
  7 + <resultMap type="EmailConfig" id="EmailConfigResult">
  8 + <result property="id" column="id" />
  9 + <result property="name" column="name" />
  10 + <result property="email" column="email" />
  11 + <result property="sort" column="sort" />
  12 + <result property="type" column="type" />
  13 + <result property="parentId" column="parent_id" />
  14 + </resultMap>
  15 +
  16 + <sql id="selectEmailConfigVo">
  17 + select id, `name`, email, sort,`type`,parent_id from email_config
  18 + </sql>
  19 +
  20 + <select id="selectEmailConfigList" parameterType="EmailConfig" resultMap="EmailConfigResult">
  21 + <include refid="selectEmailConfigVo"/>
  22 + <where>
  23 + <if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
  24 + <if test="email != null and email != ''"> and email = #{email}</if>
  25 + <if test="sort != null "> and sort = #{sort}</if>
  26 + <if test="type != null "> and type = #{type}</if>
  27 + <if test="parentId != null "> and parent_id = #{parentId}</if>
  28 + </where>
  29 + order by sort
  30 + </select>
  31 +
  32 + <select id="selectEmailConfigById" parameterType="Long" resultMap="EmailConfigResult">
  33 + <include refid="selectEmailConfigVo"/>
  34 + where id = #{id}
  35 + </select>
  36 + <select id="selectRecipientsEmailConfigList" resultType="com.ruoyi.email.domain.EmailConfig">
  37 + <include refid="selectEmailConfigVo"/>
  38 + where `type` = 0
  39 + </select>
  40 + <select id="selectEmailConfigListByIds" resultType="com.ruoyi.email.domain.EmailConfig">
  41 + select * from email_config
  42 + where id in
  43 + <foreach collection="ids" item="item" open="(" close=")" separator=",">
  44 + #{item}
  45 + </foreach>
  46 + </select>
  47 +
  48 +
  49 + <insert id="insertEmailConfig" parameterType="EmailConfig">
  50 + insert into email_config
  51 + <trim prefix="(" suffix=")" suffixOverrides=",">
  52 + <if test="id != null">id,</if>
  53 + <if test="name != null">`name`,</if>
  54 + <if test="email != null">email,</if>
  55 + <if test="type != null">`type`,</if>
  56 + <if test="sort != null">sort,</if>
  57 + <if test="parentId != null">parentId,</if>
  58 + </trim>
  59 + <trim prefix="values (" suffix=")" suffixOverrides=",">
  60 + <if test="id != null">#{id},</if>
  61 + <if test="name != null">#{name},</if>
  62 + <if test="email != null">#{email},</if>
  63 + <if test="type != null">#{type},</if>
  64 + <if test="sort != null">#{sort},</if>
  65 + <if test="parentId != null">#{parentId},</if>
  66 + </trim>
  67 + </insert>
  68 +
  69 + <update id="updateEmailConfig" parameterType="EmailConfig">
  70 + update email_config
  71 + <trim prefix="SET" suffixOverrides=",">
  72 + <if test="name != null">name = #{name},</if>
  73 + <if test="email != null">email = #{email},</if>
  74 + <if test="type != null">`type` = #{type},</if>
  75 + <if test="sort != null">sort = #{sort},</if>
  76 + <if test="parentId != null">parent_id = #{parentId},</if>
  77 + </trim>
  78 + where id = #{id}
  79 + </update>
  80 + <update id="updateEmailConfigByEmails">
  81 + <if test="ids != null and ids.size() > 0">
  82 + update email_config set type = 1 where id in
  83 + <foreach collection="ids" item="item" open="(" close=")" separator=",">
  84 + #{item}
  85 + </foreach>;
  86 + update email_config set type = 2 where id not in
  87 + <foreach collection="ids" item="item" open="(" close=")" separator=",">
  88 + #{item}
  89 + </foreach>;
  90 + </if>
  91 +
  92 + update email_config set type = #{config.type}, email = #{config.email}, `name` = #{config.name} , sort = #{config.sort}, parent_id = #{config.parentId} where id = #{config.id};
  93 + </update>
  94 + <update id="resetEmailConfigByEmails">
  95 + <if test="ids != null and ids.size() > 0">
  96 + update email_config set type = 2 where id in
  97 + <foreach collection="ids" item="item" open="(" close=")" separator=",">
  98 + #{item}
  99 + </foreach>;
  100 + </if>
  101 + update email_config set `type` = #{config.type}, email = #{config.email} , sort = #{config.sort} , `name` = #{config.name} ,parent_id = null where id = #{config.id};
  102 + </update>
  103 +
  104 + <delete id="deleteEmailConfigById" parameterType="Long">
  105 + delete from email_config where id = #{id}
  106 + </delete>
  107 +
  108 + <delete id="deleteEmailConfigByIds" parameterType="String">
  109 + delete from email_config where id in
  110 + <foreach item="id" collection="array" open="(" separator="," close=")">
  111 + #{id}
  112 + </foreach>
  113 + </delete>
  114 +</mapper>
0 115 \ No newline at end of file
... ...
ruoyi-admin/src/main/resources/mapper/equipment/EquipmentMapper.xml
... ... @@ -55,7 +55,7 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
55 55 select count(*) from equipment
56 56 where status = 1
57 57 </select>
58   - <select id="querySignListByJobCode" resultType="com.ruoyi.pojo.domain.EquipmentDriverExpand">
  58 + <select id="querySignListByJobCode" resultType="com.ruoyi.domain.EquipmentDriverExpand">
59 59 select driver_face_device_id.* from driver_face_device_id,equipment
60 60 where driver_face_device_id.device_id = equipment.device_id
61 61 <if test="drivers != null and drivers.size() > 0">
... ... @@ -70,8 +70,11 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
70 70 select * from equipment
71 71 where device_id = #{deviceId}
72 72 </select>
73   -
74   -
  73 + <select id="queryLog" resultType="com.ruoyi.equipment.domain.EquipmentLog">
  74 + select * from equipment_log
  75 + where device_id = #{deviceId}
  76 + order by off_line_time desc
  77 + </select>
75 78 <insert id="insertEquipment" parameterType="Equipment" useGeneratedKeys="true" keyProperty="id">
76 79 insert into equipment
77 80 <trim prefix="(" suffix=")" suffixOverrides=",">
... ... @@ -107,6 +110,20 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
107 110 <if test="onlineClient != null">#{online_client},</if>
108 111 </trim>
109 112 </insert>
  113 + <insert id="insertEquipmentOffLineLog">
  114 + insert into equipment_log (device_id,off_line_time,recovery_flag)
  115 + values
  116 + <foreach collection="list" item="item" separator=",">
  117 + (
  118 + #{item.deviceId},
  119 + #{item.lastHeartRes},
  120 + 2
  121 + )
  122 + </foreach>
  123 + on duplicate key update
  124 + device_id = values(device_id)
  125 +
  126 + </insert>
110 127  
111 128 <update id="updateEquipment" parameterType="Equipment">
112 129 update equipment
... ... @@ -117,7 +134,6 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
117 134 <if test="status != null">status = #{status},</if>
118 135 <if test="promise != null and promise != ''">promise = #{promise},</if>
119 136 <if test="image != null">image = #{image},</if>
120   - <if test="deviceId != null">device_id = #{deviceId},</if>
121 137 <if test="createTime != null">create_time = #{createTime},</if>
122 138 <if test="updateTime != null">update_time = #{updateTime},</if>
123 139 <if test="createBy != null">create_by = #{createBy},</if>
... ... @@ -160,6 +176,12 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
160 176 </trim>
161 177 where device_id = #{deviceId}
162 178 </update>
  179 + <update id="updateEquipmentLog">
  180 + <foreach collection="recoveryList" item="item" separator=";" index="index">
  181 + update equipment_log set recovery_time = #{item.recoveryTime},recovery_flag = #{item.recoveryFlag}
  182 + where device_id = #{item.deviceId} and recovery_flag = 2
  183 + </foreach>
  184 + </update>
163 185  
164 186 <delete id="deleteEquipmentById" parameterType="Long">
165 187 delete from equipment where id = #{id}
... ... @@ -171,4 +193,45 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
171 193 #{id}
172 194 </foreach>
173 195 </delete>
  196 + <delete id="deleteExRecord">
  197 + DELETE
  198 + FROM
  199 + equipment_exception
  200 + WHERE
  201 + id IN (
  202 + SELECT
  203 + ee.id
  204 + FROM
  205 + (
  206 + SELECT
  207 + id
  208 + FROM
  209 + equipment_exception
  210 + WHERE
  211 + create_time LIKE CONCAT( DATE_FORMAT( NOW(), "%Y-%m-%d" ), "%" )
  212 + AND job_code IN (
  213 + SELECT
  214 + s1.job_code
  215 + FROM
  216 + scheduling s1
  217 + INNER JOIN (
  218 + SELECT
  219 + job_code,
  220 + schedule_date,
  221 + MIN( fcsj_t ) AS min_fcsj_t
  222 + FROM
  223 + scheduling
  224 + WHERE
  225 + bc_type = 'out'
  226 + AND schedule_date = DATE_FORMAT( NOW(), '%Y-%m-%d' )
  227 + GROUP BY
  228 + job_code,
  229 + schedule_date
  230 + ) s2 ON s1.job_code = s2.job_code
  231 + AND s1.schedule_date = s2.schedule_date
  232 + AND s1.fcsj_t = s2.min_fcsj_t
  233 + )
  234 + ) as ee
  235 + )
  236 + </delete>
174 237 </mapper>
175 238 \ No newline at end of file
... ...
ruoyi-admin/src/main/resources/mapper/errorScheduling/ErrorJobcodeMapper.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.errorScheduling.mapper.ErrorJobcodeMapper">
  6 +
  7 + <resultMap type="ErrorJobcode" id="ErrorJobcodeResult">
  8 + <result property="id" column="id" />
  9 + <result property="jobCode" column="job_code" />
  10 + <result property="name" column="name" />
  11 + <result property="posts" column="posts" />
  12 + <result property="fleetName" column="fleet_name" />
  13 + <result property="lineName" column="line_name" />
  14 + <result property="nbbm" column="nbbm" />
  15 + <result property="lpName" column="lp_name" />
  16 + <result property="remark" column="remark" />
  17 + <result property="createTime" column="create_time" />
  18 + </resultMap>
  19 +
  20 + <sql id="selectErrorJobcodeVo">
  21 + select id, job_code, `name`, posts,fleet_name, line_name, nbbm, lp_name, remark, create_time from error_jobcode
  22 + </sql>
  23 +
  24 + <select id="selectErrorJobcodeList" parameterType="com.ruoyi.pojo.vo.ErrorJobcodeVo" resultMap="ErrorJobcodeResult">
  25 + <include refid="selectErrorJobcodeVo"/>
  26 + <where>
  27 + <if test="jobCode != null and jobCode != ''"> and job_code = #{jobCode}</if>
  28 + <if test="name != null and name != ''"> and name like concat('%', #{name}, '%')</if>
  29 + <if test="fleetName != null and fleetName != ''"> and fleet_name like concat('%', #{fleetName}, '%')</if>
  30 + <if test="lineName != null and lineName != ''"> and line_name like concat('%', #{lineName}, '%')</if>
  31 + <if test="nbbm != null and nbbm != ''"> and nbbm = #{nbbm}</if>
  32 + <if test="lpName != null and lpName != ''"> and lp_name like concat('%', #{lpName}, '%')</if>
  33 + <if test="date != null and date != ''"> and create_time like concat(#{date}, '%')</if>
  34 + </where>
  35 + </select>
  36 +
  37 + <select id="selectErrorJobcodeById" parameterType="Long" resultMap="ErrorJobcodeResult">
  38 + <include refid="selectErrorJobcodeVo"/>
  39 + where id = #{id}
  40 + </select>
  41 +
  42 + <insert id="insertErrorJobcode" parameterType="ErrorJobcode" useGeneratedKeys="true" keyProperty="id">
  43 + insert into error_jobcode
  44 + <trim prefix="(" suffix=")" suffixOverrides=",">
  45 + <if test="jobCode != null">job_code,</if>
  46 + <if test="name != null">`name`,</if>
  47 + <if test="posts != null">`posts`,</if>
  48 + <if test="fleetName != null">fleet_name,</if>
  49 + <if test="lineName != null">line_name,</if>
  50 + <if test="nbbm != null">nbbm,</if>
  51 + <if test="lpName != null">lp_name,</if>
  52 + <if test="remark != null">remark,</if>
  53 + <if test="createTime != null">create_time,</if>
  54 + </trim>
  55 + <trim prefix="values (" suffix=")" suffixOverrides=",">
  56 + <if test="jobCode != null">#{jobCode},</if>
  57 + <if test="name != null">#{name},</if>
  58 + <if test="posts != null">#{posts},</if>
  59 + <if test="fleetName != null">#{fleetName},</if>
  60 + <if test="lineName != null">#{lineName},</if>
  61 + <if test="nbbm != null">#{nbbm},</if>
  62 + <if test="lpName != null">#{lpName},</if>
  63 + <if test="remark != null">#{remark},</if>
  64 + <if test="createTime != null">#{createTime},</if>
  65 + </trim>
  66 + </insert>
  67 + <insert id="insertBatchErrorJobcode" useGeneratedKeys="true" keyProperty="id">
  68 + insert into error_jobcode (
  69 + job_code, `name`,posts ,fleet_name, line_name, nbbm, lp_name, remark, create_time
  70 + ) values
  71 + <foreach collection="errorScheduling" item="item" index="index" separator=",">
  72 + (
  73 + #{item.jobCode},
  74 + #{item.name},
  75 + #{item.posts},
  76 + #{item.fleetName},
  77 + #{item.lineName},
  78 + #{item.nbbm},
  79 + #{item.lpName},
  80 + #{item.remark},
  81 + #{item.createTime}
  82 + )
  83 + </foreach>
  84 + on duplicate key UPDATE
  85 + job_code = values(job_code)
  86 + </insert>
  87 +
  88 + <update id="updateErrorJobcode" parameterType="ErrorJobcode">
  89 + update error_jobcode
  90 + <trim prefix="SET" suffixOverrides=",">
  91 + <if test="jobCode != null">job_code = #{jobCode},</if>
  92 + <if test="name != null">name = #{name},</if>
  93 + <if test="fleetName != null">fleet_name = #{fleetName},</if>
  94 + <if test="lineName != null">line_name = #{lineName},</if>
  95 + <if test="nbbm != null">nbbm = #{nbbm},</if>
  96 + <if test="lpName != null">lp_name = #{lpName},</if>
  97 + <if test="remark != null">remark = #{remark},</if>
  98 + <if test="createTime != null">create_time = #{createTime},</if>
  99 + </trim>
  100 + where id = #{id}
  101 + </update>
  102 +
  103 + <delete id="deleteErrorJobcodeById" parameterType="Long">
  104 + delete from error_jobcode where id = #{id}
  105 + </delete>
  106 +
  107 + <delete id="deleteErrorJobcodeByIds" parameterType="String">
  108 + delete from error_jobcode where id in
  109 + <foreach item="id" collection="array" open="(" separator="," close=")">
  110 + #{id}
  111 + </foreach>
  112 + </delete>
  113 +</mapper>
0 114 \ No newline at end of file
... ...
ruoyi-admin/src/main/resources/mapper/in/SignInMapper.xml
... ... @@ -99,6 +99,25 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
99 99 </if>
100 100  
101 101 </select>
  102 + <select id="queryOutBcType" resultType="com.ruoyi.domain.DriverScheduling">
  103 + SELECT s1.*
  104 + FROM scheduling s1
  105 + INNER JOIN (
  106 + SELECT job_code, schedule_date, MIN(fcsj_t) AS min_fcsj_t
  107 + FROM scheduling
  108 + WHERE bc_type = 'out' AND schedule_date = DATE_FORMAT(NOW(), '%Y-%m-%d')
  109 + GROUP BY job_code, schedule_date
  110 + ) s2 ON s1.job_code = s2.job_code AND s1.schedule_date = s2.schedule_date AND s1.fcsj_t = s2.min_fcsj_t;
  111 +
  112 + </select>
  113 + <select id="querySignInData" resultType="com.ruoyi.in.domain.SignIn">
  114 + SELECT * FROM sign_in s1 JOIN (
  115 + SELECT jobCode AS job_code, MIN(create_time) AS min_create_time
  116 + FROM sign_in
  117 + WHERE create_time LIKE CONCAT(DATE_FORMAT(NOW(), "%Y-%m-%d"), "%")
  118 + GROUP BY job_code, DATE(create_time)
  119 + ) s2 on s1.jobCode = s2.job_code and s1.create_time = s2.min_create_time
  120 + </select>
102 121  
103 122 <insert id="insertSignIn" parameterType="SignIn" useGeneratedKeys="true" keyProperty="id">
104 123 insert into sign_in
... ... @@ -144,7 +163,7 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
144 163 <if test="ip != null">ip = #{ip},</if>
145 164 <if test="deviceId != null">device_id = #{deviceId},</if>
146 165 <if test="image != null">image = #{image},</if>
147   - <if test="status != null">status = #{status},</if>
  166 + <if test="status != null">`status` = #{status},</if>
148 167 <if test="updateBy != null">update_by = #{updateBy},</if>
149 168 <if test="singnIn != null">singn_in = #{singnIn},</if>
150 169 <if test="alcoholFlag != null">alcohol_flag = #{alcoholFlag},</if>
... ... @@ -152,6 +171,7 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
152 171 <if test="updateTime != null">update_time = #{updateTime},</if>
153 172 <if test="alcoholIntake != null">alcohol_intake = #{alcoholIntake},</if>
154 173 <if test="remark != null">remark = #{remark},</if>
  174 + <if test="exType != null">ex_type = #{exType},</if>
155 175 </trim>
156 176 where id = #{id}
157 177 </update>
... ...
ruoyi-admin/src/main/resources/mapper/schedulingAssociateNum/RuleNumSchedulingMapper.xml deleted 100644 → 0
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.schedulingAssociateNum.mapper.RuleNumSchedulingMapper">
6   -
7   - <resultMap type="RuleNumScheduling" id="RuleNumSchedulingResult">
8   - <result property="id" column="id" />
9   - <result property="ruleNumId" column="rule_num_id" />
10   - <result property="ruleSchedulingId" column="rule_scheduling_id" />
11   - <result property="matchName" column="match_name" />
12   - </resultMap>
13   -
14   - <sql id="selectRuleNumSchedulingVo">
15   - select id, rule_num_id, rule_scheduling_id, match_name from rule_num_scheduling
16   - </sql>
17   -
18   - <select id="selectRuleNumSchedulingList" parameterType="RuleNumScheduling" resultMap="RuleNumSchedulingResult">
19   - <include refid="selectRuleNumSchedulingVo"/>
20   - <where>
21   - <if test="ruleNumId != null "> and rule_num_id = #{ruleNumId}</if>
22   - <if test="ruleSchedulingId != null and ruleSchedulingId != ''"> and rule_scheduling_id = #{ruleSchedulingId}</if>
23   - <if test="matchName != null and matchName != ''"> and match_name like concat('%', #{matchName}, '%')</if>
24   - </where>
25   - </select>
26   -
27   - <select id="selectRuleNumSchedulingById" parameterType="Long" resultMap="RuleNumSchedulingResult">
28   - <include refid="selectRuleNumSchedulingVo"/>
29   - where id = #{id}
30   - </select>
31   -
32   - <insert id="insertRuleNumScheduling" parameterType="RuleNumScheduling" useGeneratedKeys="true" keyProperty="id">
33   - insert into rule_num_scheduling
34   - <trim prefix="(" suffix=")" suffixOverrides=",">
35   - <if test="ruleNumId != null">rule_num_id,</if>
36   - <if test="ruleSchedulingId != null">rule_scheduling_id,</if>
37   - <if test="matchName != null">match_name,</if>
38   - </trim>
39   - <trim prefix="values (" suffix=")" suffixOverrides=",">
40   - <if test="ruleNumId != null">#{ruleNumId},</if>
41   - <if test="ruleSchedulingId != null">#{ruleSchedulingId},</if>
42   - <if test="matchName != null">#{matchName},</if>
43   - </trim>
44   - </insert>
45   -
46   - <update id="updateRuleNumScheduling" parameterType="RuleNumScheduling">
47   - update rule_num_scheduling
48   - <trim prefix="SET" suffixOverrides=",">
49   - <if test="ruleNumId != null">rule_num_id = #{ruleNumId},</if>
50   - <if test="ruleSchedulingId != null">rule_scheduling_id = #{ruleSchedulingId},</if>
51   - <if test="matchName != null">match_name = #{matchName},</if>
52   - </trim>
53   - where id = #{id}
54   - </update>
55   -
56   - <delete id="deleteRuleNumSchedulingById" parameterType="Long">
57   - delete from rule_num_scheduling where id = #{id}
58   - </delete>
59   -
60   - <delete id="deleteRuleNumSchedulingByIds" parameterType="String">
61   - delete from rule_num_scheduling where id in
62   - <foreach item="id" collection="array" open="(" separator="," close=")">
63   - #{id}
64   - </foreach>
65   - </delete>
66   -</mapper>
67 0 \ No newline at end of file
ruoyi-framework/src/main/java/com/ruoyi/framework/config/SecurityConfig.java
... ... @@ -111,7 +111,7 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter
111 111 // 过滤请求
112 112 .authorizeRequests()
113 113 // 对于登录login 注册register 验证码captchaImage 允许匿名访问
114   - .antMatchers("/app/version/check/**","/app/checkDeviceHeart","/app/download","/driver/**","/in/**","/eexception/**","/equipment/**","/report/**","/login", "/register", "/captchaImage").permitAll()
  114 + .antMatchers("/system/dict/data/**","/app/version/check/**","/app/checkDeviceHeart","/app/download","/driver/**","/in/**","/eexception/**","/equipment/**","/report/**","/login", "/register", "/captchaImage").permitAll()
115 115 // 静态资源,可匿名访问
116 116 .antMatchers(HttpMethod.GET, "/", "/*.html", "/**/*.html", "/**/*.css", "/**/*.js", "/profile/**").permitAll()
117 117 .antMatchers("/swagger-ui.html", "/swagger-resources/**", "/webjars/**", "/*/api-docs", "/druid/**").permitAll()
... ...