Commit 7e0b9ec4adf9443f6cc6197c2aa2acbcfa10adee

Authored by liujun001
1 parent 0628166f

1、正常签退时间由原先的60分钟延长至80分钟,超出时间属于异常签退。

2、酒精测试2次异常后,不得再次操作。
Bsth-admin/src/main/java/com/ruoyi/common/ConstDriverProperties.java
@@ -22,5 +22,12 @@ public interface ConstDriverProperties { @@ -22,5 +22,12 @@ public interface ConstDriverProperties {
22 Integer STATUS_NORMAL = 0; 22 Integer STATUS_NORMAL = 0;
23 23
24 Integer STATUS_DEACTIVATE = 1; 24 Integer STATUS_DEACTIVATE = 1;
  25 + /***
  26 + * 正常签退时间由原先的60分钟延长至80分钟
  27 + *
  28 + * @author liujun
  29 + * @date 2024/6/11 15:19
  30 + */
  31 + public Integer SIGN_OUT_TIME = 80;
25 32
26 } 33 }
Bsth-admin/src/main/java/com/ruoyi/common/cache/NowSchedulingCache.java
1 package com.ruoyi.common.cache; 1 package com.ruoyi.common.cache;
2 2
3 import cn.hutool.core.collection.CollectionUtil; 3 import cn.hutool.core.collection.CollectionUtil;
  4 +import cn.hutool.core.map.MapUtil;
  5 +import com.ruoyi.common.utils.StringUtils;
4 import com.ruoyi.driver.mapper.DriverSchedulingMapper; 6 import com.ruoyi.driver.mapper.DriverSchedulingMapper;
5 import com.ruoyi.errorScheduling.domain.ErrorJobcode; 7 import com.ruoyi.errorScheduling.domain.ErrorJobcode;
6 import com.ruoyi.errorScheduling.service.IErrorJobcodeService; 8 import com.ruoyi.errorScheduling.service.IErrorJobcodeService;
@@ -8,9 +10,12 @@ import com.ruoyi.in.domain.SignIn; @@ -8,9 +10,12 @@ import com.ruoyi.in.domain.SignIn;
8 import com.ruoyi.domain.DriverScheduling; 10 import com.ruoyi.domain.DriverScheduling;
9 import com.ruoyi.service.ThreadJobService; 11 import com.ruoyi.service.ThreadJobService;
10 import com.ruoyi.utils.ConstDateUtil; 12 import com.ruoyi.utils.ConstDateUtil;
  13 +import lombok.extern.slf4j.Slf4j;
  14 +import org.apache.commons.collections4.CollectionUtils;
11 import org.slf4j.Logger; 15 import org.slf4j.Logger;
12 import org.slf4j.LoggerFactory; 16 import org.slf4j.LoggerFactory;
13 import org.springframework.stereotype.Component; 17 import org.springframework.stereotype.Component;
  18 +import org.springframework.stereotype.Service;
14 19
15 import java.util.*; 20 import java.util.*;
16 import java.util.concurrent.ConcurrentHashMap; 21 import java.util.concurrent.ConcurrentHashMap;
@@ -18,14 +23,14 @@ import java.util.concurrent.ConcurrentHashMap; @@ -18,14 +23,14 @@ import java.util.concurrent.ConcurrentHashMap;
18 @Component 23 @Component
19 public class NowSchedulingCache { 24 public class NowSchedulingCache {
20 private final DriverSchedulingMapper schedulingMapper; 25 private final DriverSchedulingMapper schedulingMapper;
21 - Logger log = LoggerFactory.getLogger(SchedulingCache.class); 26 + static Logger log = LoggerFactory.getLogger(SchedulingCache.class);
22 /** 27 /**
23 * 当天初版排班 28 * 当天初版排班
24 */ 29 */
25 private static ConcurrentHashMap<String, Map<String, List<DriverScheduling>>> cacheNowDayScheduling = new ConcurrentHashMap<>(); 30 private static ConcurrentHashMap<String, Map<String, List<DriverScheduling>>> cacheNowDayScheduling = new ConcurrentHashMap<>();
26 private IErrorJobcodeService errorJobcodeService; 31 private IErrorJobcodeService errorJobcodeService;
27 32
28 - public NowSchedulingCache(DriverSchedulingMapper driverSchedulingMapper,IErrorJobcodeService errorJobcodeService) { 33 + public NowSchedulingCache(DriverSchedulingMapper driverSchedulingMapper, IErrorJobcodeService errorJobcodeService) {
29 this.schedulingMapper = driverSchedulingMapper; 34 this.schedulingMapper = driverSchedulingMapper;
30 this.errorJobcodeService = errorJobcodeService; 35 this.errorJobcodeService = errorJobcodeService;
31 log.info("项目启动加载中获取排班表并存入缓存-----"); 36 log.info("项目启动加载中获取排班表并存入缓存-----");
@@ -39,7 +44,7 @@ public class NowSchedulingCache { @@ -39,7 +44,7 @@ public class NowSchedulingCache {
39 // 查询今天和昨天 44 // 查询今天和昨天
40 for (int i = 0; i > -2; i--) { 45 for (int i = 0; i > -2; i--) {
41 Map<String, List<DriverScheduling>> resultMap = new HashMap<>(800); 46 Map<String, List<DriverScheduling>> resultMap = new HashMap<>(800);
42 - String date = ConstDateUtil.formatDate("yyyy-MM-dd",ConstDateUtil.getTheSpecifiedNumberOfDaysOfTime(i)); 47 + String date = ConstDateUtil.formatDate("yyyy-MM-dd", ConstDateUtil.getTheSpecifiedNumberOfDaysOfTime(i));
43 List<DriverScheduling> schedulingList = schedulingMapper.queryToDay(date, null, null, null); 48 List<DriverScheduling> schedulingList = schedulingMapper.queryToDay(date, null, null, null);
44 handlerResultMap(resultMap, schedulingList); 49 handlerResultMap(resultMap, schedulingList);
45 // 获取错误排班 50 // 获取错误排班
@@ -47,10 +52,48 @@ public class NowSchedulingCache { @@ -47,10 +52,48 @@ public class NowSchedulingCache {
47 // 插入错误排班 52 // 插入错误排班
48 errorJobcodeService.insertBatchErrorJobcode(errorScheduling); 53 errorJobcodeService.insertBatchErrorJobcode(errorScheduling);
49 // 更新缓存 54 // 更新缓存
50 - cacheNowDayScheduling.put(date.replaceAll("-",""), resultMap); 55 + cacheNowDayScheduling.put(date.replaceAll("-", ""), resultMap);
51 } 56 }
52 } 57 }
53 58
  59 + /***
  60 + *
  61 + * 刷新打卡缓本地存信息
  62 + * @author liujun
  63 + * @date 2024/6/12 10:37
  64 + * @param driverScheduling
  65 + * @param date
  66 + * @return int 0 为刷新成功、1为传入对象值为空或工号为空或传入的DriverScheduling的ID为空
  67 + */
  68 + public int refreshDriveScheDulingCacheByDateAndJobCode(DriverScheduling driverScheduling, Date date) {
  69 + if (Objects.isNull(driverScheduling) || Objects.isNull(date) || StringUtils.isEmpty(driverScheduling.getJobCode())
  70 + || Objects.isNull(driverScheduling.getId())) {
  71 + log.warn("刷新本地打卡缓存信息失败,传入的对象为空。传入的时间:{},传入的数据对象:{}", date, driverScheduling);
  72 + return 1;
  73 + }
  74 +
  75 + String dateStr = ConstDateUtil.FAST_YYYY_MM_DD.format(date);
  76 + Map<String, List<DriverScheduling>> resultMap = cacheNowDayScheduling.get(dateStr);
  77 + if (MapUtil.isEmpty(resultMap)) {
  78 + return 0;
  79 + }
  80 +
  81 + List<DriverScheduling> driverSchedulings = resultMap.get(driverScheduling.getJobCode());
  82 + int size = CollectionUtils.size(driverSchedulings);
  83 + if (0 == size) {
  84 + return 0;
  85 + }
  86 +
  87 + for (int i = 0; i < size; i++) {
  88 + DriverScheduling scheduling = driverSchedulings.get(i);
  89 + if (Objects.nonNull(scheduling) && Objects.equals(scheduling.getId(), driverScheduling.getId())) {
  90 + driverSchedulings.set(i, driverScheduling);
  91 + break;
  92 + }
  93 + }
  94 + return 0;
  95 + }
  96 +
54 97
55 public static void handlerResultMap(Map<String, List<DriverScheduling>> resultMap, List<DriverScheduling> schedulingList) { 98 public static void handlerResultMap(Map<String, List<DriverScheduling>> resultMap, List<DriverScheduling> schedulingList) {
56 for (DriverScheduling scheduling : schedulingList) { 99 for (DriverScheduling scheduling : schedulingList) {
@@ -110,7 +153,7 @@ public class NowSchedulingCache { @@ -110,7 +153,7 @@ public class NowSchedulingCache {
110 */ 153 */
111 public void updateCacheByJobCode(String remark, String key, Integer index, SignIn signIn) { 154 public void updateCacheByJobCode(String remark, String key, Integer index, SignIn signIn) {
112 if (key.equals(ConstDateUtil.formatDate(ConstDateUtil.getTheSpecifiedNumberOfDaysOfTime(0))) 155 if (key.equals(ConstDateUtil.formatDate(ConstDateUtil.getTheSpecifiedNumberOfDaysOfTime(0)))
113 - || key.equals(ConstDateUtil.formatDate(ConstDateUtil.getTheSpecifiedNumberOfDaysOfTime(-1)))){ 156 + || key.equals(ConstDateUtil.formatDate(ConstDateUtil.getTheSpecifiedNumberOfDaysOfTime(-1)))) {
114 DriverScheduling scheduling = cacheNowDayScheduling.get(key).get(signIn.getJobCode()).get(index); 157 DriverScheduling scheduling = cacheNowDayScheduling.get(key).get(signIn.getJobCode()).get(index);
115 scheduling.setSignInId(signIn.getId()); 158 scheduling.setSignInId(signIn.getId());
116 scheduling.setRemark(remark); 159 scheduling.setRemark(remark);
Bsth-admin/src/main/java/com/ruoyi/controller/ReportController.java
@@ -13,12 +13,14 @@ import com.ruoyi.system.domain.SysNotice; @@ -13,12 +13,14 @@ import com.ruoyi.system.domain.SysNotice;
13 import io.swagger.annotations.Api; 13 import io.swagger.annotations.Api;
14 import io.swagger.annotations.ApiOperation; 14 import io.swagger.annotations.ApiOperation;
15 import io.swagger.annotations.ApiParam; 15 import io.swagger.annotations.ApiParam;
  16 +import org.springframework.security.access.prepost.PreAuthorize;
16 import org.springframework.validation.annotation.Validated; 17 import org.springframework.validation.annotation.Validated;
17 import org.springframework.web.bind.annotation.*; 18 import org.springframework.web.bind.annotation.*;
18 19
19 import javax.annotation.Resource; 20 import javax.annotation.Resource;
20 import javax.servlet.http.HttpServletRequest; 21 import javax.servlet.http.HttpServletRequest;
21 import javax.servlet.http.HttpServletResponse; 22 import javax.servlet.http.HttpServletResponse;
  23 +import java.math.BigDecimal;
22 import java.util.List; 24 import java.util.List;
23 25
24 /** 26 /**
@@ -50,6 +52,38 @@ public class ReportController { @@ -50,6 +52,38 @@ public class ReportController {
50 return AjaxResult.success(reportService.getReportDetail(requestVo, response)); 52 return AjaxResult.success(reportService.getReportDetail(requestVo, response));
51 } 53 }
52 54
  55 + @ApiOperation("修改酒精打卡异常次数")
  56 + @PreAuthorize("@ss.hasPermi('system:report:signUpdateStatus')")
  57 + @GetMapping("/update/alcohol/exception/count/{id}/{alcoholIntake}")
  58 + public AjaxResult updateAlcoholExceptionCountById(@PathVariable Integer id, @PathVariable BigDecimal alcoholIntake) {
  59 + int result = reportService.updateAlcoholExceptionCountById(id, alcoholIntake);
  60 + AjaxResult ajaxResult;
  61 + switch (result) {
  62 + case 1:
  63 + ajaxResult = AjaxResult.error("再签到报表中没有找到数据,请核对数据后再操作");
  64 + break;
  65 + case 2:
  66 + ajaxResult = AjaxResult.error("没有找到签到数据,请核对数据后再操作");
  67 + break;
  68 + case 3:
  69 + ajaxResult = AjaxResult.error("不是酒驾数据,不能修改,请核对数据后再操作");
  70 + break;
  71 +
  72 + case 4:
  73 + ajaxResult = AjaxResult.error("不是签到数据,不能修改,请核对数据后再操作");
  74 + break;
  75 +
  76 + case 5:
  77 + ajaxResult = AjaxResult.error("不是司机的数据,不能修改,请核对数据后再操作");
  78 + break;
  79 +
  80 + default:
  81 + ajaxResult = AjaxResult.success();
  82 + break;
  83 + }
  84 + return ajaxResult;
  85 + }
  86 +
53 @ApiOperation("异常报表集合查询") 87 @ApiOperation("异常报表集合查询")
54 @GetMapping("/error/list") 88 @GetMapping("/error/list")
55 public AjaxResult getErrorList(@ApiParam @ModelAttribute ReportErrorRequestVo request) { 89 public AjaxResult getErrorList(@ApiParam @ModelAttribute ReportErrorRequestVo request) {
Bsth-admin/src/main/java/com/ruoyi/driver/mapper/DriverSchedulingMapper.java
@@ -21,8 +21,10 @@ public interface DriverSchedulingMapper { @@ -21,8 +21,10 @@ public interface DriverSchedulingMapper {
21 21
22 List<DriverScheduling> queryToDay(@Param("date") String date, @Param("name") String name,@Param("jobCode") String jobCode,@Param("lineName")String lineName ); 22 List<DriverScheduling> queryToDay(@Param("date") String date, @Param("name") String name,@Param("jobCode") String jobCode,@Param("lineName")String lineName );
23 23
24 - void updateRoster(@Param("scheduling") DriverScheduling scheduling, @Param("signInId") Long id, @Param("exType") Integer exType, @Param("signTime")Date signTime, @Param("remark") String remark, @Param("signType") Integer signType, @Param("alcoholFlag") Integer alcoholFlag, @Param("alcoholIntake")BigDecimal alcoholIntake);  
25 24
  25 +
  26 + void updateRoster(@Param("scheduling") DriverScheduling scheduling, @Param("signInId") Long id, @Param("exType") Integer exType, @Param("signTime")Date signTime, @Param("remark") String remark, @Param("signType") Integer signType, @Param("alcoholFlag") Integer alcoholFlag, @Param("alcoholIntake")BigDecimal alcoholIntake);
  27 + void updateRosterById(DriverScheduling scheduling);
26 /** 28 /**
27 * 查询设备数量 29 * 查询设备数量
28 * @return 30 * @return
@@ -32,4 +34,12 @@ public interface DriverSchedulingMapper { @@ -32,4 +34,12 @@ public interface DriverSchedulingMapper {
32 34
33 35
34 List<DriverScheduling> queryByMonth(@Param("startDate") String startDate,@Param("endDate") String endDate); 36 List<DriverScheduling> queryByMonth(@Param("startDate") String startDate,@Param("endDate") String endDate);
  37 + /***
  38 + * 根据ID查询对象的业务字段
  39 + * @author liujun
  40 + * @date 2024/6/12 9:38
  41 + * @param id
  42 + * @return com.ruoyi.domain.DriverScheduling
  43 + */
  44 + DriverScheduling querySelectColumnById(Integer id);
35 } 45 }
Bsth-admin/src/main/java/com/ruoyi/in/service/impl/SignInServiceImpl.java
@@ -159,6 +159,7 @@ public class SignInServiceImpl implements ISignInService { @@ -159,6 +159,7 @@ public class SignInServiceImpl implements ISignInService {
159 // 查询员工信息 159 // 查询员工信息
160 Driver driver = driverMapper.getDriverInfoByJobCode(signIn.getJobCode()); 160 Driver driver = driverMapper.getDriverInfoByJobCode(signIn.getJobCode());
161 if (Objects.isNull(driver)) return AjaxResult.warn("这个工号的员工不存在!"); 161 if (Objects.isNull(driver)) return AjaxResult.warn("这个工号的员工不存在!");
  162 +
162 // 查询地址 163 // 查询地址
163 Equipment equipment = equipmentMapper.selectEquipmentByDeviceId(signIn.getDeviceId()); 164 Equipment equipment = equipmentMapper.selectEquipmentByDeviceId(signIn.getDeviceId());
164 SignInResponseVo vo = getSignInResponseVo(driver, signIn, equipment); 165 SignInResponseVo vo = getSignInResponseVo(driver, signIn, equipment);
@@ -169,6 +170,15 @@ public class SignInServiceImpl implements ISignInService { @@ -169,6 +170,15 @@ public class SignInServiceImpl implements ISignInService {
169 List<DriverScheduling> dto = schedulingService.queryScheduling(signIn.getJobCode(), now); 170 List<DriverScheduling> dto = schedulingService.queryScheduling(signIn.getJobCode(), now);
170 handleSignBody(signIn, driver, globalIndex, now, dto); 171 handleSignBody(signIn, driver, globalIndex, now, dto);
171 172
  173 + if (PERSONNEL_POSTS_DRIVER.equals(driver.getPosts()) && Objects.equals(dto.get(globalIndex.getIndex()).getBcType(), BC_TYPE_OUT)) {
  174 + AjaxResult result = getAjaxResultByDriverSignInfo(signIn, vo);
  175 + if (!Objects.isNull(result)) {
  176 + String msg = "签到异常: 请使用手持式酒精测试棒进行酒测";
  177 + result.put(AjaxResult.MSG_TAG, msg);
  178 + return result;
  179 + }
  180 + }
  181 +
172 uploadImage(signIn, vo); 182 uploadImage(signIn, vo);
173 signInMapper.insertSignIn(signIn); 183 signInMapper.insertSignIn(signIn);
174 // 更新考勤 184 // 更新考勤
@@ -200,12 +210,7 @@ public class SignInServiceImpl implements ISignInService { @@ -200,12 +210,7 @@ public class SignInServiceImpl implements ISignInService {
200 } 210 }
201 211
202 private AjaxResult handleAjaxResult(SignIn signIn, Driver driver, SignInResponseVo vo) { 212 private AjaxResult handleAjaxResult(SignIn signIn, Driver driver, SignInResponseVo vo) {
203 - if (PERSONNEL_POSTS_DRIVER.equals(driver.getPosts()) && SIGN_IN_FAIL.equals(signIn.getStatus()) && signIn.getRemark().contains(ALCOHOL_SIGN_IN_ERROR)) {  
204 - AjaxResult result = getAjaxResultByDriverSignInfo(signIn, vo);  
205 - if (!Objects.isNull(result)) {  
206 - return result;  
207 - }  
208 - } 213 +
209 // 酒精测试后续恢复的需要删除异常的酒测缓存 214 // 酒精测试后续恢复的需要删除异常的酒测缓存
210 215
211 if (SIGN_IN_SUCCESS.equals(signIn.getStatus())) { 216 if (SIGN_IN_SUCCESS.equals(signIn.getStatus())) {
@@ -561,7 +566,7 @@ public class SignInServiceImpl implements ISignInService { @@ -561,7 +566,7 @@ public class SignInServiceImpl implements ISignInService {
561 DriverSignInRecommendation lastClosestTimestamp = schedulingService.computedTheCurrentClosestTimestamp(dto, now, -1); 566 DriverSignInRecommendation lastClosestTimestamp = schedulingService.computedTheCurrentClosestTimestamp(dto, now, -1);
562 // 给出签到范围 567 // 给出签到范围
563 // 上一次无记|签到,type:签退 当前时间小于最近签到时间 -> 超时签退 568 // 上一次无记|签到,type:签退 当前时间小于最近签到时间 -> 超时签退
564 - if (nowBetween < -60L && Objects.isNull(lastClosestTimestamp.getSignInId()) && signIn.getType().equals(SIGN_OUT) && lastClosestTimestamp.getBcType().equals(BC_TYPE_IN)) { 569 + if (nowBetween < -SIGN_OUT_TIME && Objects.isNull(lastClosestTimestamp.getSignInId()) && signIn.getType().equals(SIGN_OUT) && lastClosestTimestamp.getBcType().equals(BC_TYPE_IN)) {
565 signIn.setRemark(SIGN_OUT_TIMEOUT + getPrompt(lastClosestTimestamp)); 570 signIn.setRemark(SIGN_OUT_TIMEOUT + getPrompt(lastClosestTimestamp));
566 globalIndex.setIndex(lastClosestTimestamp.getIndex()); 571 globalIndex.setIndex(lastClosestTimestamp.getIndex());
567 result = false; 572 result = false;
@@ -578,7 +583,7 @@ public class SignInServiceImpl implements ISignInService { @@ -578,7 +583,7 @@ public class SignInServiceImpl implements ISignInService {
578 if (currentScheduling.getBcType().equals(BC_TYPE_IN) && Objects.isNull(currentScheduling.getSignInId())) { 583 if (currentScheduling.getBcType().equals(BC_TYPE_IN) && Objects.isNull(currentScheduling.getSignInId())) {
579 DriverSignInRecommendation lastClosestTimestamp = schedulingService.computedTheCurrentClosestTimestamp(dto, now, -1); 584 DriverSignInRecommendation lastClosestTimestamp = schedulingService.computedTheCurrentClosestTimestamp(dto, now, -1);
580 // 上一次无记|签退,type:签到 当前时间小于最近签退时间 -> 签到异常 585 // 上一次无记|签退,type:签到 当前时间小于最近签退时间 -> 签到异常
581 - if (nowBetween < -60L && Objects.isNull(lastClosestTimestamp.getSignInId()) && signIn.getType().equals(SIGN_IN)) { 586 + if (nowBetween < -SIGN_OUT_TIME && Objects.isNull(lastClosestTimestamp.getSignInId()) && signIn.getType().equals(SIGN_IN)) {
582 signIn.setRemark(SIGN_IN_TIMEOUT + getPrompt(lastClosestTimestamp)); 587 signIn.setRemark(SIGN_IN_TIMEOUT + getPrompt(lastClosestTimestamp));
583 globalIndex.setIndex(lastClosestTimestamp.getIndex()); 588 globalIndex.setIndex(lastClosestTimestamp.getIndex());
584 result = false; 589 result = false;
@@ -622,7 +627,7 @@ public class SignInServiceImpl implements ISignInService { @@ -622,7 +627,7 @@ public class SignInServiceImpl implements ISignInService {
622 627
623 private boolean handleTimeOut(String bcType, long nowBetween, GlobalIndex globalIndex, DriverSignInRecommendation currentScheduling) { 628 private boolean handleTimeOut(String bcType, long nowBetween, GlobalIndex globalIndex, DriverSignInRecommendation currentScheduling) {
624 if ((BC_TYPE_OUT.equals(bcType) && nowBetween > 0L) 629 if ((BC_TYPE_OUT.equals(bcType) && nowBetween > 0L)
625 - || (BC_TYPE_IN.equals(bcType) && nowBetween > 60L)) { 630 + || (BC_TYPE_IN.equals(bcType) && nowBetween > SIGN_OUT_TIME)) {
626 return true; 631 return true;
627 } else { 632 } else {
628 return false; 633 return false;
@@ -638,7 +643,7 @@ public class SignInServiceImpl implements ISignInService { @@ -638,7 +643,7 @@ public class SignInServiceImpl implements ISignInService {
638 } else { 643 } else {
639 // 延后一小时 644 // 延后一小时
640 LocalDateTime time = ConstDateUtil.stringTransformLocalDateTime(ConstDateUtil.formatDate("yyyy-MM-dd HH:mm:ss", new Date(currentScheduling.getTimestamps())), "yyyy-MM-dd HH:mm:ss"); 645 LocalDateTime time = ConstDateUtil.stringTransformLocalDateTime(ConstDateUtil.formatDate("yyyy-MM-dd HH:mm:ss", new Date(currentScheduling.getTimestamps())), "yyyy-MM-dd HH:mm:ss");
641 - LocalDateTime addHours = time.plusHours(1); 646 + LocalDateTime addHours = time.plusMinutes(80);
642 return "请在" + ConstDateUtil.formatDate("HH:mm", time) + "到" 647 return "请在" + ConstDateUtil.formatDate("HH:mm", time) + "到"
643 + ConstDateUtil.formatDate("HH:mm", addHours) + "之间打卡"; 648 + ConstDateUtil.formatDate("HH:mm", addHours) + "之间打卡";
644 } 649 }
@@ -650,8 +655,8 @@ public class SignInServiceImpl implements ISignInService { @@ -650,8 +655,8 @@ public class SignInServiceImpl implements ISignInService {
650 if (BC_TYPE_OUT.equals(bcType)) { 655 if (BC_TYPE_OUT.equals(bcType)) {
651 return !(nowBetween <= 0L && nowBetween >= -60L); 656 return !(nowBetween <= 0L && nowBetween >= -60L);
652 } else { 657 } else {
653 - // 如果是签退就是就是延后一小时内有效  
654 - return !(nowBetween <= 60 && nowBetween >= 0L); 658 + // 如果是签退就是就是延后80分钟内有效
  659 + return !(nowBetween <= SIGN_OUT_TIME && nowBetween >= 0L);
655 } 660 }
656 } 661 }
657 662
@@ -663,7 +668,7 @@ public class SignInServiceImpl implements ISignInService { @@ -663,7 +668,7 @@ public class SignInServiceImpl implements ISignInService {
663 globalIndex.setIndex(0); 668 globalIndex.setIndex(0);
664 // 单条数据 且不在范围内 669 // 单条数据 且不在范围内
665 if (BC_TYPE_IN.equals(dto.get(0).getBcType())) { 670 if (BC_TYPE_IN.equals(dto.get(0).getBcType())) {
666 - if (!(nowBetween < 0L && nowBetween >= -60L)) { 671 + if (!(nowBetween < 0L && nowBetween >= -SIGN_OUT_TIME)) {
667 signIn.setRemark(SIGN_OUT_TIMEOUT); 672 signIn.setRemark(SIGN_OUT_TIMEOUT);
668 return false; 673 return false;
669 } else { 674 } else {
@@ -765,4 +770,5 @@ public class SignInServiceImpl implements ISignInService { @@ -765,4 +770,5 @@ public class SignInServiceImpl implements ISignInService {
765 // } 770 // }
766 return type; 771 return type;
767 } 772 }
  773 +
768 } 774 }
Bsth-admin/src/main/java/com/ruoyi/pojo/response/ReportDetailResponseVo.java
@@ -3,6 +3,7 @@ package com.ruoyi.pojo.response; @@ -3,6 +3,7 @@ package com.ruoyi.pojo.response;
3 import io.swagger.annotations.ApiModel; 3 import io.swagger.annotations.ApiModel;
4 import lombok.Data; 4 import lombok.Data;
5 5
  6 +import java.math.BigDecimal;
6 import java.util.Date; 7 import java.util.Date;
7 8
8 /** 9 /**
@@ -11,6 +12,7 @@ import java.util.Date; @@ -11,6 +12,7 @@ import java.util.Date;
11 @Data 12 @Data
12 @ApiModel("签到报表查看详情vo") 13 @ApiModel("签到报表查看详情vo")
13 public class ReportDetailResponseVo { 14 public class ReportDetailResponseVo {
  15 + private Long id;
14 private String jobCode; 16 private String jobCode;
15 private String name; 17 private String name;
16 private String posts; 18 private String posts;
@@ -20,6 +22,9 @@ public class ReportDetailResponseVo { @@ -20,6 +22,9 @@ public class ReportDetailResponseVo {
20 private String nbbm; 22 private String nbbm;
21 private String exString; 23 private String exString;
22 private String siteName; 24 private String siteName;
  25 + private Integer exType;
  26 + private BigDecimal alcoholIntake;
  27 + private Date scheduleDate;
23 /** 28 /**
24 * 计划操作 29 * 计划操作
25 */ 30 */
Bsth-admin/src/main/java/com/ruoyi/service/ReportService.java
@@ -5,13 +5,19 @@ import com.alibaba.excel.EasyExcel; @@ -5,13 +5,19 @@ import com.alibaba.excel.EasyExcel;
5 import com.alibaba.excel.ExcelWriter; 5 import com.alibaba.excel.ExcelWriter;
6 import com.alibaba.excel.write.metadata.WriteSheet; 6 import com.alibaba.excel.write.metadata.WriteSheet;
7 import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy; 7 import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
  8 +import com.ruoyi.common.SignStatusEnum;
  9 +import com.ruoyi.common.cache.NowSchedulingCache;
  10 +import com.ruoyi.common.core.redis.RedisCache;
8 import com.ruoyi.common.global.Result; 11 import com.ruoyi.common.global.Result;
9 import com.ruoyi.common.global.ResultCode; 12 import com.ruoyi.common.global.ResultCode;
10 import com.ruoyi.common.utils.SecurityUtils; 13 import com.ruoyi.common.utils.SecurityUtils;
11 import com.ruoyi.common.utils.poi.ExcelUtil; 14 import com.ruoyi.common.utils.poi.ExcelUtil;
12 import com.ruoyi.domain.DriverScheduling; 15 import com.ruoyi.domain.DriverScheduling;
  16 +import com.ruoyi.driver.domain.Driver;
  17 +import com.ruoyi.driver.mapper.DriverMapper;
13 import com.ruoyi.driver.mapper.DriverSchedulingMapper; 18 import com.ruoyi.driver.mapper.DriverSchedulingMapper;
14 import com.ruoyi.eexception.mapper.EquipmentExceptionMapper; 19 import com.ruoyi.eexception.mapper.EquipmentExceptionMapper;
  20 +import com.ruoyi.in.domain.SignIn;
15 import com.ruoyi.in.mapper.SignInMapper; 21 import com.ruoyi.in.mapper.SignInMapper;
16 import com.ruoyi.pojo.request.ReportErrorRequestVo; 22 import com.ruoyi.pojo.request.ReportErrorRequestVo;
17 import com.ruoyi.pojo.request.ReportViewRequestVo; 23 import com.ruoyi.pojo.request.ReportViewRequestVo;
@@ -21,6 +27,8 @@ import com.ruoyi.system.domain.SysNotice; @@ -21,6 +27,8 @@ import com.ruoyi.system.domain.SysNotice;
21 import com.ruoyi.system.service.ISysNoticeService; 27 import com.ruoyi.system.service.ISysNoticeService;
22 import com.ruoyi.utils.ConstDateUtil; 28 import com.ruoyi.utils.ConstDateUtil;
23 import com.ruoyi.utils.ToolUtils; 29 import com.ruoyi.utils.ToolUtils;
  30 +import lombok.extern.slf4j.Slf4j;
  31 +import org.quartz.Scheduler;
24 import org.springframework.beans.BeanUtils; 32 import org.springframework.beans.BeanUtils;
25 import org.springframework.beans.factory.annotation.Autowired; 33 import org.springframework.beans.factory.annotation.Autowired;
26 import org.springframework.stereotype.Service; 34 import org.springframework.stereotype.Service;
@@ -30,6 +38,7 @@ import javax.servlet.http.HttpServletRequest; @@ -30,6 +38,7 @@ import javax.servlet.http.HttpServletRequest;
30 import javax.servlet.http.HttpServletResponse; 38 import javax.servlet.http.HttpServletResponse;
31 import javax.validation.constraints.NotBlank; 39 import javax.validation.constraints.NotBlank;
32 import java.io.OutputStream; 40 import java.io.OutputStream;
  41 +import java.math.BigDecimal;
33 import java.time.LocalDate; 42 import java.time.LocalDate;
34 import java.time.YearMonth; 43 import java.time.YearMonth;
35 import java.time.format.DateTimeFormatter; 44 import java.time.format.DateTimeFormatter;
@@ -44,17 +53,22 @@ import java.util.stream.Collectors; @@ -44,17 +53,22 @@ import java.util.stream.Collectors;
44 53
45 import static com.ruoyi.common.ApiProperties.PERSONNEL_API_KEY; 54 import static com.ruoyi.common.ApiProperties.PERSONNEL_API_KEY;
46 import static com.ruoyi.common.ConstDriverProperties.BC_TYPE_OUT; 55 import static com.ruoyi.common.ConstDriverProperties.BC_TYPE_OUT;
  56 +import static com.ruoyi.common.ConstDriverProperties.PERSONNEL_POSTS_DRIVER;
47 import static com.ruoyi.common.ConstSignInConstSignInProperties.*; 57 import static com.ruoyi.common.ConstSignInConstSignInProperties.*;
48 import static com.ruoyi.common.ReportProperties.*; 58 import static com.ruoyi.common.ReportProperties.*;
  59 +import static com.ruoyi.common.redispre.GlobalRedisPreName.REDIS_SIGN_IN_DRIVER_ALCOHOL_OVERFLOW;
49 60
50 /** 61 /**
51 * @author 20412 62 * @author 20412
52 */ 63 */
53 @Service 64 @Service
  65 +@Slf4j
54 public class ReportService { 66 public class ReportService {
55 67
56 @Autowired 68 @Autowired
57 private SignInMapper signInMapper; 69 private SignInMapper signInMapper;
  70 + @Autowired
  71 + private DriverMapper driverMapper;
58 72
59 @Autowired 73 @Autowired
60 private ISysNoticeService noticeService; 74 private ISysNoticeService noticeService;
@@ -68,6 +82,12 @@ public class ReportService { @@ -68,6 +82,12 @@ public class ReportService {
68 @Autowired 82 @Autowired
69 private DriverSchedulingMapper schedulingMapper; 83 private DriverSchedulingMapper schedulingMapper;
70 84
  85 +
  86 + @Autowired
  87 + private RedisCache redisCache;
  88 + @Autowired
  89 + private NowSchedulingCache nowSchedulingCache;
  90 +
71 /** 91 /**
72 * 查询报表信息 92 * 查询报表信息
73 */ 93 */
@@ -170,7 +190,7 @@ public class ReportService { @@ -170,7 +190,7 @@ public class ReportService {
170 data.add(ConstDateUtil.formatDate("yyyy-MM-dd HH:mm:ss", vo.getCreateTime())); 190 data.add(ConstDateUtil.formatDate("yyyy-MM-dd HH:mm:ss", vo.getCreateTime()));
171 if (vo.getSignType() == null) { 191 if (vo.getSignType() == null) {
172 data.add(""); 192 data.add("");
173 - }else { 193 + } else {
174 data.add(vo.getSignType().equals(SIGN_IN) ? "签到" : "签退"); 194 data.add(vo.getSignType().equals(SIGN_IN) ? "签到" : "签退");
175 } 195 }
176 } else { 196 } else {
@@ -349,6 +369,48 @@ public class ReportService { @@ -349,6 +369,48 @@ public class ReportService {
349 return responseVos; 369 return responseVos;
350 } 370 }
351 371
  372 + public Integer updateAlcoholExceptionCountById(Integer id, BigDecimal alcoholIntake) {
  373 + DriverScheduling driverScheduling = schedulingMapper.querySelectColumnById(id);
  374 + if (Objects.isNull(driverScheduling)) {
  375 + log.warn("{}没有签到数据", id);
  376 + return 1;
  377 + }
  378 +
  379 + SignIn signIn = signInMapper.selectSignInById(driverScheduling.getSignInId());
  380 + if (Objects.isNull(signIn)) {
  381 + log.warn("{}没有查到签到数据", id);
  382 + return 2;
  383 + }
  384 +
  385 + if (!Objects.equals(3, driverScheduling.getExType())) {
  386 + log.warn("{}不是酒驾数据,不能修改", id);
  387 + return 3;
  388 + }
  389 +
  390 + if (!Objects.equals(1, signIn.getType())) {
  391 + log.warn("{}不是签到数据,不能修改", id);
  392 + return 4;
  393 + }
  394 +
  395 + Driver driver = driverMapper.getDriverInfoByJobCode(signIn.getJobCode());
  396 + if (Objects.isNull(driver) || !Objects.equals(PERSONNEL_POSTS_DRIVER, driver.getPosts())) {
  397 + log.warn("{}只能修改司机的数据", id);
  398 + return 5;
  399 + }
  400 +
  401 +
  402 + schedulingMapper.updateRoster(driverScheduling, driverScheduling.getSignInId(), SignStatusEnum.SIGN_STATUS_ZONE_ENUM.getStatus(), driverScheduling.getSignTime(),
  403 + SignStatusEnum.SIGN_STATUS_ZONE_ENUM.getDescription(), driverScheduling.getSignType(), driverScheduling.getAlcoholFlag(), alcoholIntake);
  404 +
  405 + nowSchedulingCache.refreshDriveScheDulingCacheByDateAndJobCode(driverScheduling, driverScheduling.getScheduleDate());
  406 +
  407 +
  408 + String key = REDIS_SIGN_IN_DRIVER_ALCOHOL_OVERFLOW + ConstDateUtil.FAST_YYYY_MM_DD.format(driverScheduling.getScheduleDate()) + ":" + signIn.getJobCode();
  409 + redisCache.setCacheObject(key, 0, 1, TimeUnit.DAYS);
  410 +
  411 + return 0;
  412 + }
  413 +
352 private void handlerReportDetail(ReportDetailResponseVo reportDetailResponseVo, DriverScheduling scheduling) { 414 private void handlerReportDetail(ReportDetailResponseVo reportDetailResponseVo, DriverScheduling scheduling) {
353 BeanUtils.copyProperties(scheduling, reportDetailResponseVo); 415 BeanUtils.copyProperties(scheduling, reportDetailResponseVo);
354 reportDetailResponseVo.setPlanAction(scheduling.getBcType().equals(BC_TYPE_OUT) ? SIGN_IN_STRING : SIGN_IN_OUT_STRING); 416 reportDetailResponseVo.setPlanAction(scheduling.getBcType().equals(BC_TYPE_OUT) ? SIGN_IN_STRING : SIGN_IN_OUT_STRING);
Bsth-admin/src/main/java/com/ruoyi/service/SchedulingService.java
@@ -26,8 +26,7 @@ import java.time.YearMonth; @@ -26,8 +26,7 @@ import java.time.YearMonth;
26 import java.time.temporal.ChronoUnit; 26 import java.time.temporal.ChronoUnit;
27 import java.util.*; 27 import java.util.*;
28 28
29 -import static com.ruoyi.common.ConstDriverProperties.BC_TYPE_IN;  
30 -import static com.ruoyi.common.ConstDriverProperties.BC_TYPE_OUT; 29 +import static com.ruoyi.common.ConstDriverProperties.*;
31 import static com.ruoyi.common.ConstSignInConstSignInProperties.*; 30 import static com.ruoyi.common.ConstSignInConstSignInProperties.*;
32 import static com.ruoyi.common.ErrorTypeProperties.*; 31 import static com.ruoyi.common.ErrorTypeProperties.*;
33 import static com.ruoyi.common.ReportProperties.NOW; 32 import static com.ruoyi.common.ReportProperties.NOW;
@@ -145,7 +144,7 @@ public class SchedulingService { @@ -145,7 +144,7 @@ public class SchedulingService {
145 long date = scheduling.getBcType().equals(BC_TYPE_IN) ? scheduling.getZdsjT() : scheduling.getFcsjT(); 144 long date = scheduling.getBcType().equals(BC_TYPE_IN) ? scheduling.getZdsjT() : scheduling.getFcsjT();
146 long nowBetween = ChronoUnit.MINUTES.between(ConstDateUtil.getLocalDateTimeByLongTime(date), ConstDateUtil.getLocalDateTimeByLongTime(signIn.getCreateTime().getTime())); 145 long nowBetween = ChronoUnit.MINUTES.between(ConstDateUtil.getLocalDateTimeByLongTime(date), ConstDateUtil.getLocalDateTimeByLongTime(signIn.getCreateTime().getTime()));
147 if (SignInServiceImpl.checkTimerSign(nowBetween, scheduling.getBcType())) { 146 if (SignInServiceImpl.checkTimerSign(nowBetween, scheduling.getBcType())) {
148 - if (nowBetween < -60L || (BC_TYPE_IN.equals(scheduling.getBcType()) && nowBetween < 0L)) { 147 + if (nowBetween < -SIGN_OUT_TIME || (BC_TYPE_IN.equals(scheduling.getBcType()) && nowBetween < 0L)) {
149 sb.append(EARLY); 148 sb.append(EARLY);
150 } else { 149 } else {
151 sb.append(SIGN_STATUS_DELAY_ENUM.getDescription(scheduling.getBcType())); 150 sb.append(SIGN_STATUS_DELAY_ENUM.getDescription(scheduling.getBcType()));
@@ -220,7 +219,7 @@ public class SchedulingService { @@ -220,7 +219,7 @@ public class SchedulingService {
220 ConstDateUtil.formatDate("HH:mm", time) + "之间打卡"; 219 ConstDateUtil.formatDate("HH:mm", time) + "之间打卡";
221 } else { 220 } else {
222 LocalDateTime time = ConstDateUtil.stringTransformLocalDateTime(ConstDateUtil.formatDate("yyyy-MM-dd HH:mm:ss", date), "yyyy-MM-dd HH:mm:ss"); 221 LocalDateTime time = ConstDateUtil.stringTransformLocalDateTime(ConstDateUtil.formatDate("yyyy-MM-dd HH:mm:ss", date), "yyyy-MM-dd HH:mm:ss");
223 - LocalDateTime addHours = time.plusHours(1); 222 + LocalDateTime addHours = time.plusMinutes(80);
224 return "请在" + ConstDateUtil.formatDate("HH:mm", time) + "到" + 223 return "请在" + ConstDateUtil.formatDate("HH:mm", time) + "到" +
225 ConstDateUtil.formatDate("HH:mm", addHours) + "之间打卡"; 224 ConstDateUtil.formatDate("HH:mm", addHours) + "之间打卡";
226 } 225 }
Bsth-admin/src/main/java/com/ruoyi/utils/ConstDateUtil.java
1 package com.ruoyi.utils; 1 package com.ruoyi.utils;
2 2
  3 +import org.apache.commons.lang3.time.FastDateFormat;
  4 +
3 import java.text.ParseException; 5 import java.text.ParseException;
4 import java.text.SimpleDateFormat; 6 import java.text.SimpleDateFormat;
5 import java.time.*; 7 import java.time.*;
@@ -11,6 +13,9 @@ import java.util.List; @@ -11,6 +13,9 @@ import java.util.List;
11 13
12 public class ConstDateUtil { 14 public class ConstDateUtil {
13 15
  16 + public static final FastDateFormat FORMAT_YYYY_MM_DD_HORIZONTAIL_LINE = FastDateFormat.getInstance("yyyy-MM-dd");
  17 + public static final FastDateFormat FAST_YYYY_MM_DD = FastDateFormat.getInstance("yyyyMMdd");
  18 +
14 public static String getStringNowLocalDate(){ 19 public static String getStringNowLocalDate(){
15 // 指定当前日期和时间 20 // 指定当前日期和时间
16 LocalDate currentDate = LocalDate.now(); 21 LocalDate currentDate = LocalDate.now();
Bsth-admin/src/main/resources/mapper/driver_scheduling/DriverSchedulingMapper.xml
@@ -22,7 +22,15 @@ @@ -22,7 +22,15 @@
22 <result column="sign_time" property="signTime" jdbcType="DATETIMEOFFSET"/> 22 <result column="sign_time" property="signTime" jdbcType="DATETIMEOFFSET"/>
23 <result column="alcohol_flag" property="alcoholFlag" jdbcType="DATETIMEOFFSET"/> 23 <result column="alcohol_flag" property="alcoholFlag" jdbcType="DATETIMEOFFSET"/>
24 <result column="alcohol_intake" property="alcoholIntake"/> 24 <result column="alcohol_intake" property="alcoholIntake"/>
  25 + <result column="sign_type" property="signType"></result>
  26 + <result column="remark" property="remark"></result>
25 </resultMap> 27 </resultMap>
  28 +
  29 + <sql id="selectColumn">
  30 + id, job_code,name,posts,schedule_date,line_name,lp_name,nbbm,bc_type,fcsj_t,zdsj_t,sign_in_id,ex_type,sign_time,alcohol_flag,alcohol_intake,sign_type,remark
  31 + </sql>
  32 +
  33 +
26 <insert id="insertRoster" parameterType="java.util.List" useGeneratedKeys="true" keyColumn="id" keyProperty="id"> 34 <insert id="insertRoster" parameterType="java.util.List" useGeneratedKeys="true" keyColumn="id" keyProperty="id">
27 insert into scheduling (schedule_date,line_name,job_code,`name`,posts,lp_name,nbbm,bc_type,fcsj_t,zdsj_t) 35 insert into scheduling (schedule_date,line_name,job_code,`name`,posts,lp_name,nbbm,bc_type,fcsj_t,zdsj_t)
28 values 36 values
@@ -55,6 +63,10 @@ @@ -55,6 +63,10 @@
55 where id = #{scheduling.id} 63 where id = #{scheduling.id}
56 </update> 64 </update>
57 65
  66 + <update id="updateRosterById" parameterType="com.ruoyi.domain.DriverScheduling">
  67 +
  68 + </update>
  69 +
58 <select id="queryToDay" resultType="com.ruoyi.domain.DriverScheduling" resultMap="Scheduling"> 70 <select id="queryToDay" resultType="com.ruoyi.domain.DriverScheduling" resultMap="Scheduling">
59 select scheduling.*,driver.fleet_name fleetName,equipment.site_name siteName from 71 select scheduling.*,driver.fleet_name fleetName,equipment.site_name siteName from
60 scheduling left join driver on scheduling.job_code = driver.job_code 72 scheduling left join driver on scheduling.job_code = driver.job_code
@@ -86,4 +98,8 @@ @@ -86,4 +98,8 @@
86 where schedule_date &gt;= #{startDate} 98 where schedule_date &gt;= #{startDate}
87 and schedule_date &lt;= #{endDate} 99 and schedule_date &lt;= #{endDate}
88 </select> 100 </select>
  101 +
  102 + <select id="querySelectColumnById" parameterType="java.lang.Integer" resultMap="Scheduling">
  103 + select <include refid="selectColumn"></include> from scheduling where id=#{id}
  104 + </select>
89 </mapper> 105 </mapper>
90 \ No newline at end of file 106 \ No newline at end of file