Commit 69ee026d3f4a4cba0ca59e1ff04923a1cc831c70

Authored by liujun001
1 parent 072d50b2

修改打卡信息

Bsth-admin/src/main/java/com/ruoyi/common/cache/NowSchedulingCache.java
@@ -8,6 +8,7 @@ import com.ruoyi.driver.mapper.DriverSchedulingMapper; @@ -8,6 +8,7 @@ import com.ruoyi.driver.mapper.DriverSchedulingMapper;
8 import com.ruoyi.errorScheduling.domain.ErrorJobcode; 8 import com.ruoyi.errorScheduling.domain.ErrorJobcode;
9 import com.ruoyi.errorScheduling.service.IErrorJobcodeService; 9 import com.ruoyi.errorScheduling.service.IErrorJobcodeService;
10 import com.ruoyi.in.domain.SignIn; 10 import com.ruoyi.in.domain.SignIn;
  11 +import com.ruoyi.service.BigViewServiceV1;
11 import com.ruoyi.service.ThreadJobService; 12 import com.ruoyi.service.ThreadJobService;
12 import com.ruoyi.utils.ConstDateUtil; 13 import com.ruoyi.utils.ConstDateUtil;
13 import com.ruoyi.utils.DateUtil; 14 import com.ruoyi.utils.DateUtil;
@@ -15,6 +16,7 @@ import org.apache.commons.collections4.CollectionUtils; @@ -15,6 +16,7 @@ import org.apache.commons.collections4.CollectionUtils;
15 import org.apache.commons.lang3.time.DateUtils; 16 import org.apache.commons.lang3.time.DateUtils;
16 import org.slf4j.Logger; 17 import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory; 18 import org.slf4j.LoggerFactory;
  19 +import org.springframework.beans.factory.annotation.Autowired;
18 import org.springframework.stereotype.Component; 20 import org.springframework.stereotype.Component;
19 21
20 import java.util.*; 22 import java.util.*;
@@ -22,6 +24,9 @@ import java.util.concurrent.ConcurrentHashMap; @@ -22,6 +24,9 @@ import java.util.concurrent.ConcurrentHashMap;
22 24
23 @Component 25 @Component
24 public class NowSchedulingCache { 26 public class NowSchedulingCache {
  27 +
  28 + @Autowired
  29 + private BigViewServiceV1 bigViewServiceV1;
25 private final DriverSchedulingMapper schedulingMapper; 30 private final DriverSchedulingMapper schedulingMapper;
26 static Logger log = LoggerFactory.getLogger(SchedulingCache.class); 31 static Logger log = LoggerFactory.getLogger(SchedulingCache.class);
27 /** 32 /**
@@ -172,4 +177,54 @@ public class NowSchedulingCache { @@ -172,4 +177,54 @@ public class NowSchedulingCache {
172 scheduling.setAlcoholIntake(signIn.getAlcoholIntake()); 177 scheduling.setAlcoholIntake(signIn.getAlcoholIntake());
173 } 178 }
174 } 179 }
  180 +
  181 + /**
  182 + * 更新缓存
  183 + *
  184 + * @param remark
  185 + * @param key
  186 + * @param index
  187 + * @param signIn
  188 + */
  189 + public void updateCacheByJobCode(String remark, String key, Integer index, SignIn signIn, boolean isNew, DriverScheduling sourceScheduling) {
  190 + if (isNew && Objects.nonNull(sourceScheduling)) {
  191 + if (Objects.isNull(cacheNowDayScheduling.get(key))) {
  192 + return;
  193 + }
  194 +
  195 + int size = CollectionUtils.size(cacheNowDayScheduling.get(key).get(signIn.getJobCode()));
  196 + for (int i = 0; i < size; i++) {
  197 + if (Objects.equals(cacheNowDayScheduling.get(key).get(signIn.getJobCode()).get(i).getId(), sourceScheduling.getId())) {
  198 + index = i;
  199 + break;
  200 + }
  201 + }
  202 + }
  203 + if (key.equals(ConstDateUtil.formatDate(ConstDateUtil.getTheSpecifiedNumberOfDaysOfTime(0)))
  204 + || key.equals(ConstDateUtil.formatDate(ConstDateUtil.getTheSpecifiedNumberOfDaysOfTime(-1)))) {
  205 + if (Objects.isNull(cacheNowDayScheduling.get(key)) || Objects.isNull(cacheNowDayScheduling.get(key).get(signIn.getJobCode()))) {
  206 + return;
  207 + }
  208 + int size = CollectionUtils.size(cacheNowDayScheduling.get(key).get(signIn.getJobCode()));
  209 + if (size <= index) {
  210 + return;
  211 + }
  212 + DriverScheduling scheduling = cacheNowDayScheduling.get(key).get(signIn.getJobCode()).get(index);
  213 + scheduling.setSignInId(signIn.getId());
  214 + scheduling.setRemark(remark);
  215 +
  216 + Integer exType = signIn.getExType();
  217 + if (isNew) {
  218 + exType = bigViewServiceV1.isSignStatusWineEnum(signIn) ? 3 : bigViewServiceV1.isSignStatusDelayEnum(signIn) ? 1 : Objects.equals(2, signIn.getExType()) ? 2 : 0;
  219 + }
  220 + scheduling.setExType(exType);
  221 + scheduling.setSignTime(signIn.getCreateTime());
  222 + scheduling.setSignType(signIn.getType());
  223 + scheduling.setAlcoholFlag(signIn.getAlcoholFlag());
  224 + scheduling.setAlcoholIntake(signIn.getAlcoholIntake());
  225 +
  226 +
  227 + cacheNowDayScheduling.get(key).get(signIn.getJobCode()).set(index, scheduling);
  228 + }
  229 + }
175 } 230 }
Bsth-admin/src/main/java/com/ruoyi/controller/app/AppSignExceptionController.java
@@ -61,7 +61,7 @@ public class AppSignExceptionController extends BaseController { @@ -61,7 +61,7 @@ public class AppSignExceptionController extends BaseController {
61 signIn.setStartCreateTime(DateUtil.shortDate(dto.getSignTime())); 61 signIn.setStartCreateTime(DateUtil.shortDate(dto.getSignTime()));
62 signIn.setEndCreateTime(DateUtils.addDays(signIn.getStartCreateTime(), 1)); 62 signIn.setEndCreateTime(DateUtils.addDays(signIn.getStartCreateTime(), 1));
63 } else { 63 } else {
64 - signIn.setEndCreateTime(DateUtil.shortDate(DateUtils.addDays(new Date(),1))); 64 + signIn.setEndCreateTime(DateUtil.shortDate(DateUtils.addDays(new Date(), 1)));
65 signIn.setStartCreateTime(DateUtils.addMonths(signIn.getEndCreateTime(), -2)); 65 signIn.setStartCreateTime(DateUtils.addMonths(signIn.getEndCreateTime(), -2));
66 66
67 } 67 }
@@ -103,7 +103,7 @@ public class AppSignExceptionController extends BaseController { @@ -103,7 +103,7 @@ public class AppSignExceptionController extends BaseController {
103 Set<String> jobCodes = reportList.stream().map(EquipmentExceptionReport::getJobCode).collect(Collectors.toSet()); 103 Set<String> jobCodes = reportList.stream().map(EquipmentExceptionReport::getJobCode).collect(Collectors.toSet());
104 List<NewDriver> drivers = driverService.list(jobCodes); 104 List<NewDriver> drivers = driverService.list(jobCodes);
105 105
106 - List<SignExceptionVo> vos = convertSignExceptionVo(reportList,drivers,signIns,schedulings); 106 + List<SignExceptionVo> vos = convertSignExceptionVo(reportList, drivers, signIns, schedulings);
107 return ResponseResult.success(vos); 107 return ResponseResult.success(vos);
108 } 108 }
109 109
@@ -127,7 +127,7 @@ public class AppSignExceptionController extends BaseController { @@ -127,7 +127,7 @@ public class AppSignExceptionController extends BaseController {
127 Optional<SignIn> optSign = signIns.stream().filter(s -> Objects.equals(s.getId(), r.getSignId())).findFirst(); 127 Optional<SignIn> optSign = signIns.stream().filter(s -> Objects.equals(s.getId(), r.getSignId())).findFirst();
128 if (optSign.isPresent()) { 128 if (optSign.isPresent()) {
129 vo.setSignTime(optSign.get().getCreateTime()); 129 vo.setSignTime(optSign.get().getCreateTime());
130 - vo.setSignStatus(optSign.get().getStatus()); 130 + vo.setSignStatus(optSign.get().getExType());
131 vo.setAlcoholIntake(optSign.get().getAlcoholIntake()); 131 vo.setAlcoholIntake(optSign.get().getAlcoholIntake());
132 132
133 if (schedulingSize > 0) { 133 if (schedulingSize > 0) {
Bsth-admin/src/main/java/com/ruoyi/controller/dss/DssDriverController.java
@@ -10,7 +10,6 @@ import com.ruoyi.common.core.domain.AjaxResult; @@ -10,7 +10,6 @@ import com.ruoyi.common.core.domain.AjaxResult;
10 import com.ruoyi.common.core.domain.ResponseResult; 10 import com.ruoyi.common.core.domain.ResponseResult;
11 import com.ruoyi.common.core.domain.entity.SysDictData; 11 import com.ruoyi.common.core.domain.entity.SysDictData;
12 import com.ruoyi.common.core.redis.RedisCache; 12 import com.ruoyi.common.core.redis.RedisCache;
13 -import com.ruoyi.common.exception.file.FileUploadException;  
14 import com.ruoyi.domain.OrderEntity; 13 import com.ruoyi.domain.OrderEntity;
15 import com.ruoyi.domain.caiinfo.CarInfo; 14 import com.ruoyi.domain.caiinfo.CarInfo;
16 import com.ruoyi.domain.driver.NewDriver; 15 import com.ruoyi.domain.driver.NewDriver;
@@ -38,8 +37,11 @@ import com.ruoyi.equipment.service.IEquipmentService; @@ -38,8 +37,11 @@ import com.ruoyi.equipment.service.IEquipmentService;
38 import com.ruoyi.exception.InterruptException; 37 import com.ruoyi.exception.InterruptException;
39 import com.ruoyi.framework.security.filter.JwtAuthenticationTokenFilter; 38 import com.ruoyi.framework.security.filter.JwtAuthenticationTokenFilter;
40 import com.ruoyi.in.domain.SignIn; 39 import com.ruoyi.in.domain.SignIn;
  40 +import com.ruoyi.in.domain.SignInV1;
41 import com.ruoyi.in.service.ISignInService; 41 import com.ruoyi.in.service.ISignInService;
  42 +import com.ruoyi.in.service.SignInServiceV1;
42 import com.ruoyi.pojo.response.SignInResponseVo; 43 import com.ruoyi.pojo.response.SignInResponseVo;
  44 +import com.ruoyi.service.BigViewServiceV1;
43 import com.ruoyi.service.carinfo.CarInfoService; 45 import com.ruoyi.service.carinfo.CarInfoService;
44 import com.ruoyi.service.driver.NewDriverService; 46 import com.ruoyi.service.driver.NewDriverService;
45 import com.ruoyi.service.dss.FaceService; 47 import com.ruoyi.service.dss.FaceService;
@@ -54,6 +56,7 @@ import lombok.extern.slf4j.Slf4j; @@ -54,6 +56,7 @@ import lombok.extern.slf4j.Slf4j;
54 import org.apache.commons.collections4.CollectionUtils; 56 import org.apache.commons.collections4.CollectionUtils;
55 import org.apache.commons.lang3.StringUtils; 57 import org.apache.commons.lang3.StringUtils;
56 import org.apache.commons.lang3.time.DateUtils; 58 import org.apache.commons.lang3.time.DateUtils;
  59 +import org.springframework.beans.BeanUtils;
57 import org.springframework.beans.factory.annotation.Autowired; 60 import org.springframework.beans.factory.annotation.Autowired;
58 import org.springframework.validation.BindingResult; 61 import org.springframework.validation.BindingResult;
59 import org.springframework.web.bind.annotation.PostMapping; 62 import org.springframework.web.bind.annotation.PostMapping;
@@ -63,6 +66,7 @@ import org.springframework.web.bind.annotation.RestController; @@ -63,6 +66,7 @@ import org.springframework.web.bind.annotation.RestController;
63 66
64 import javax.validation.Valid; 67 import javax.validation.Valid;
65 import java.io.IOException; 68 import java.io.IOException;
  69 +import java.text.ParseException;
66 import java.util.*; 70 import java.util.*;
67 import java.util.stream.Collectors; 71 import java.util.stream.Collectors;
68 72
@@ -97,6 +101,10 @@ public class DssDriverController extends BaseController { @@ -97,6 +101,10 @@ public class DssDriverController extends BaseController {
97 private LinggangSignInResourceService signInResourceService; 101 private LinggangSignInResourceService signInResourceService;
98 @Autowired 102 @Autowired
99 private RedisCache redisCache; 103 private RedisCache redisCache;
  104 + @Autowired
  105 + private SignInServiceV1 signInServiceV1;
  106 + @Autowired
  107 + private BigViewServiceV1 bigViewServiceV1;
100 108
101 @PostMapping(value = "/Driver/Login") 109 @PostMapping(value = "/Driver/Login")
102 @ApiOperation("人员登录设备") 110 @ApiOperation("人员登录设备")
@@ -141,7 +149,9 @@ public class DssDriverController extends BaseController { @@ -141,7 +149,9 @@ public class DssDriverController extends BaseController {
141 149
142 SignIn signIn = convertSignIn(dto); 150 SignIn signIn = convertSignIn(dto);
143 try { 151 try {
144 - AjaxResult ajaxResult = signInService.addSignIn(signIn); 152 + signIn.setType(1);
  153 + AjaxResult ajaxResult = signInServiceV1.addsignInV1(signIn);
  154 +// AjaxResult ajaxResult = signInService.addSignIn(signIn);
145 if (Objects.nonNull(ajaxResult) && ajaxResult.isSuccess()) { 155 if (Objects.nonNull(ajaxResult) && ajaxResult.isSuccess()) {
146 // if(Objects.nonNull(ajaxResult.get(AjaxResult.MSG_TAG))){ 156 // if(Objects.nonNull(ajaxResult.get(AjaxResult.MSG_TAG))){
147 // String msg = ajaxResult.get(AjaxResult.MSG_TAG).toString(); 157 // String msg = ajaxResult.get(AjaxResult.MSG_TAG).toString();
@@ -153,16 +163,24 @@ public class DssDriverController extends BaseController { @@ -153,16 +163,24 @@ public class DssDriverController extends BaseController {
153 sysDictData.setDictType("drinking"); 163 sysDictData.setDictType("drinking");
154 SysDictData dictData = sysDictDataService.getOne(sysDictData); 164 SysDictData dictData = sysDictDataService.getOne(sysDictData);
155 165
156 - SignInResponseVo responseVo = (SignInResponseVo) ajaxResult.get(AjaxResult.DATA_TAG);  
157 - if (Objects.nonNull(responseVo)) {  
158 - ResponseResult<DssSignVo> responseResult = ResponseResult.success(convertSignInVo(responseVo, dto, dictData)); 166 + SignInV1 signInV1 = (SignInV1) ajaxResult.get(AjaxResult.DATA_TAG);
  167 +
  168 + SignInResponseVo vo = new SignInResponseVo();
  169 + if (Objects.nonNull(signInV1)) {
  170 + BeanUtils.copyProperties(signInV1,vo);
  171 +
  172 + vo.setDeviceId(signIn.getDeviceId());
  173 + vo.setSiteName(signInV1.getEquipment().getName());
  174 + vo.setName(signInV1.getDriver().getPersonnelName());
  175 + vo.setPosts(signInV1.getPosts());
  176 + ResponseResult<DssSignVo> responseResult = ResponseResult.success(convertSignInVo(vo, dto, dictData,signInV1));
159 responseResult.setMsg(Convert.toStr(ajaxResult.get(AjaxResult.MSG_TAG))); 177 responseResult.setMsg(Convert.toStr(ajaxResult.get(AjaxResult.MSG_TAG)));
160 return responseResult; 178 return responseResult;
161 } 179 }
162 } 180 }
163 181
164 return ResponseResult.error(Convert.toInt(ajaxResult.get(AjaxResult.CODE_TAG)), Convert.toStr(ajaxResult.get(AjaxResult.MSG_TAG))); 182 return ResponseResult.error(Convert.toInt(ajaxResult.get(AjaxResult.CODE_TAG)), Convert.toStr(ajaxResult.get(AjaxResult.MSG_TAG)));
165 - } catch (FileUploadException | IOException e) { 183 + } catch ( IOException e) {
166 log.error("签到信息异常,传入的参数为:[{}]", dto, e); 184 log.error("签到信息异常,传入的参数为:[{}]", dto, e);
167 return ResponseResult.error(); 185 return ResponseResult.error();
168 } 186 }
@@ -184,18 +202,28 @@ public class DssDriverController extends BaseController { @@ -184,18 +202,28 @@ public class DssDriverController extends BaseController {
184 202
185 SignIn signIn = convertSignIn(dto); 203 SignIn signIn = convertSignIn(dto);
186 try { 204 try {
187 - AjaxResult ajaxResult = signInService.addSignIn(signIn); 205 + signIn.setType(2);
  206 +// AjaxResult ajaxResult = signInService.addSignIn(signIn);
  207 + AjaxResult ajaxResult = signInServiceV1.addsignInV1(signIn);
188 if (Objects.nonNull(ajaxResult) && ajaxResult.isSuccess()) { 208 if (Objects.nonNull(ajaxResult) && ajaxResult.isSuccess()) {
189 - SignInResponseVo responseVo = (SignInResponseVo) ajaxResult.get(AjaxResult.DATA_TAG);  
190 - if (Objects.nonNull(responseVo)) {  
191 - ResponseResult<SignOutVo> responseResult = ResponseResult.success(convertSignOutVo(dto, responseVo)); 209 + SignInV1 signInV1 = (SignInV1) ajaxResult.get(AjaxResult.DATA_TAG);
  210 +
  211 + SignInResponseVo vo = new SignInResponseVo();
  212 + if (Objects.nonNull(signInV1)) {
  213 + BeanUtils.copyProperties(signInV1,vo);
  214 +
  215 + vo.setDeviceId(signIn.getDeviceId());
  216 + vo.setSiteName(signInV1.getEquipment().getName());
  217 + vo.setName(signInV1.getDriver().getPersonnelName());
  218 + vo.setPosts(signInV1.getPosts());
  219 + ResponseResult<SignOutVo> responseResult = ResponseResult.success(convertSignOutVo(dto, vo));
192 responseResult.setMsg(Convert.toStr(ajaxResult.get(AjaxResult.MSG_TAG))); 220 responseResult.setMsg(Convert.toStr(ajaxResult.get(AjaxResult.MSG_TAG)));
193 return responseResult; 221 return responseResult;
194 } 222 }
195 } 223 }
196 224
197 return ResponseResult.error(Convert.toInt(ajaxResult.get(AjaxResult.CODE_TAG)), Convert.toStr(ajaxResult.get(AjaxResult.MSG_TAG))); 225 return ResponseResult.error(Convert.toInt(ajaxResult.get(AjaxResult.CODE_TAG)), Convert.toStr(ajaxResult.get(AjaxResult.MSG_TAG)));
198 - } catch (FileUploadException | IOException e) { 226 + } catch (IOException e) {
199 log.error("签到信息异常,传入的参数为:[{}]", dto, e); 227 log.error("签到信息异常,传入的参数为:[{}]", dto, e);
200 return ResponseResult.error(); 228 return ResponseResult.error();
201 } 229 }
@@ -482,7 +510,7 @@ public class DssDriverController extends BaseController { @@ -482,7 +510,7 @@ public class DssDriverController extends BaseController {
482 signIn.setCreateTime(dto.getSignTime()); 510 signIn.setCreateTime(dto.getSignTime());
483 signIn.setType(1); 511 signIn.setType(1);
484 512
485 - if(Objects.nonNull(dto.getTestValue())) { 513 + if (Objects.nonNull(dto.getTestValue())) {
486 signIn.setAlcoholFlag(ConstSignInConstSignInProperties.ALCOHOL_FLAG_YES); 514 signIn.setAlcoholFlag(ConstSignInConstSignInProperties.ALCOHOL_FLAG_YES);
487 signIn.setAlcoholIntake(Convert.toBigDecimal(dto.getTestValue())); 515 signIn.setAlcoholIntake(Convert.toBigDecimal(dto.getTestValue()));
488 } 516 }
@@ -572,17 +600,18 @@ public class DssDriverController extends BaseController { @@ -572,17 +600,18 @@ public class DssDriverController extends BaseController {
572 return resource; 600 return resource;
573 } 601 }
574 602
575 - private DssSignVo convertSignInVo(SignInResponseVo responseVo, DssSignDTO dto, SysDictData dictData) { 603 + private DssSignVo convertSignInVo(SignInResponseVo responseVo, DssSignDTO dto, SysDictData dictData,SignInV1 signInV1) {
576 DssSignVo vo = new DssSignVo(); 604 DssSignVo vo = new DssSignVo();
577 vo.setTestId(Convert.toStr(responseVo.getId())); 605 vo.setTestId(Convert.toStr(responseVo.getId()));
578 606
579 - Integer testResult = Objects.equals(responseVo.getExType(), 3) ? 2 : 0; 607 +
  608 + Integer testResult = bigViewServiceV1.isSignStatusZoneEnum(signInV1.getSignIn()) ? 2 : 0;
580 vo.setTestResult(testResult); 609 vo.setTestResult(testResult);
581 if (Objects.isNull(dictData) || Objects.equals(testResult, 0) && dto.getTestValue() > Convert.toLong(dictData.getDictValue())) { 610 if (Objects.isNull(dictData) || Objects.equals(testResult, 0) && dto.getTestValue() > Convert.toLong(dictData.getDictValue())) {
582 vo.setTestResult(1); 611 vo.setTestResult(1);
583 } 612 }
584 613
585 - Integer result = Objects.isNull(responseVo.getStatus()) ? 0 : responseVo.getStatus() - 1; 614 + Integer result = Objects.equals(1,signInV1.getSignIn().getStatus())?0:1;
586 vo.setResult(result); 615 vo.setResult(result);
587 616
588 return vo; 617 return vo;
@@ -593,7 +622,7 @@ public class DssDriverController extends BaseController { @@ -593,7 +622,7 @@ public class DssDriverController extends BaseController {
593 } 622 }
594 623
595 private GetWineRecordVo convertGetWineRecordVo(SignIn signIn) { 624 private GetWineRecordVo convertGetWineRecordVo(SignIn signIn) {
596 - if(Objects.isNull(signIn)){ 625 + if (Objects.isNull(signIn)) {
597 return null; 626 return null;
598 } 627 }
599 GetWineRecordVo vo = new GetWineRecordVo(); 628 GetWineRecordVo vo = new GetWineRecordVo();
@@ -611,14 +640,28 @@ public class DssDriverController extends BaseController { @@ -611,14 +640,28 @@ public class DssDriverController extends BaseController {
611 return vo; 640 return vo;
612 } 641 }
613 642
614 - private LinggangScheduling convertScheduling(GetBusPlanListDTO dto) { 643 + private LinggangScheduling convertScheduling(GetBusPlanListDTO dto) {
615 LinggangScheduling scheduling = new LinggangScheduling(); 644 LinggangScheduling scheduling = new LinggangScheduling();
616 if (Objects.equals(1, dto.getDateType())) { 645 if (Objects.equals(1, dto.getDateType())) {
617 scheduling.setStartScheduleDate(DateUtil.shortDate(DateUtils.addDays(new Date(), 1))); 646 scheduling.setStartScheduleDate(DateUtil.shortDate(DateUtils.addDays(new Date(), 1)));
618 scheduling.setEndScheduleDate(DateUtils.addDays(scheduling.getStartScheduleDate(), 1)); 647 scheduling.setEndScheduleDate(DateUtils.addDays(scheduling.getStartScheduleDate(), 1));
  648 +
  649 + String timeStr = DateUtil.YYYY_MM_DD_LINK.format(scheduling.getEndScheduleDate())+" 06:00:00";
  650 + try {
  651 + scheduling.setFcsjT(DateUtil.YYYY_MM_DD_LINK.parse(timeStr).getTime());
  652 + } catch (ParseException e) {
  653 + log.error("格式化时间错误",e);
  654 + }
619 } else if (Objects.equals(0, dto.getDateType())) { 655 } else if (Objects.equals(0, dto.getDateType())) {
620 scheduling.setStartScheduleDate(DateUtil.shortDate(new Date())); 656 scheduling.setStartScheduleDate(DateUtil.shortDate(new Date()));
621 scheduling.setEndScheduleDate(DateUtils.addDays(scheduling.getStartScheduleDate(), 1)); 657 scheduling.setEndScheduleDate(DateUtils.addDays(scheduling.getStartScheduleDate(), 1));
  658 +
  659 + String timeStr = DateUtil.YYYY_MM_DD_LINK.format(scheduling.getEndScheduleDate())+" 06:00:00";
  660 + try {
  661 + scheduling.setFcsjT(DateUtil.YYYY_MM_DD_LINK.parse(timeStr).getTime());
  662 + } catch (ParseException e) {
  663 + log.error("格式化时间错误",e);
  664 + }
622 } else { 665 } else {
623 scheduling.setStartScheduleDate(DateUtil.shortDate(new Date())); 666 scheduling.setStartScheduleDate(DateUtil.shortDate(new Date()));
624 scheduling.setEndScheduleDate(DateUtils.addDays(scheduling.getStartScheduleDate(), 3)); 667 scheduling.setEndScheduleDate(DateUtils.addDays(scheduling.getStartScheduleDate(), 3));
Bsth-admin/src/main/java/com/ruoyi/domain/DriverScheduling.java
1 package com.ruoyi.domain; 1 package com.ruoyi.domain;
2 2
  3 +import com.baomidou.mybatisplus.annotation.TableField;
3 import lombok.Data; 4 import lombok.Data;
4 5
5 import java.math.BigDecimal; 6 import java.math.BigDecimal;
@@ -25,22 +26,34 @@ public class DriverScheduling { @@ -25,22 +26,34 @@ public class DriverScheduling {
25 private Integer alcoholFlag; 26 private Integer alcoholFlag;
26 private BigDecimal alcoholIntake; 27 private BigDecimal alcoholIntake;
27 private String remark; 28 private String remark;
  29 + @TableField(exist = false)
28 private String siteName; 30 private String siteName;
29 /** 31 /**
30 * 不是当前表的属性 32 * 不是当前表的属性
31 */ 33 */
  34 + @TableField(exist = false)
32 private String fleetName; 35 private String fleetName;
33 /**上下行*/ 36 /**上下行*/
  37 + @TableField(value = "upDown")
34 private Integer upDown; 38 private Integer upDown;
35 /**起点站code*/ 39 /**起点站code*/
  40 + @TableField(value = "qdzCode")
36 private String qdzCode; 41 private String qdzCode;
37 /**起点站名字*/ 42 /**起点站名字*/
  43 + @TableField(value = "qdzName")
38 private String qdzName; 44 private String qdzName;
39 /**终点站code*/ 45 /**终点站code*/
  46 + @TableField(value = "zdzCode")
40 private String zdzCode; 47 private String zdzCode;
41 /**终点站名字*/ 48 /**终点站名字*/
  49 + @TableField(value = "zdzName")
42 private String zdzName; 50 private String zdzName;
43 51
44 /***1:实际排班表;100为计划排班表*/ 52 /***1:实际排班表;100为计划排班表*/
  53 + @TableField(value = "scheduling_type")
45 private java.lang.Integer type; 54 private java.lang.Integer type;
  55 +
  56 +
  57 + @TableField(exist = false)
  58 + private long minTime;
46 } 59 }
Bsth-admin/src/main/java/com/ruoyi/in/domain/CalDriverScheduling.java 0 → 100644
  1 +package com.ruoyi.in.domain;
  2 +
  3 +import com.ruoyi.domain.DriverScheduling;
  4 +import com.ruoyi.scheduling.domain.DriverSchedulingV1;
  5 +import lombok.Data;
  6 +
  7 +import java.util.Objects;
  8 +
  9 +/**
  10 + * @author liujun
  11 + * @date 2024年09月23日 11:29
  12 + */
  13 +@Data
  14 +public class CalDriverScheduling {
  15 +
  16 + private Integer index;
  17 + private DriverScheduling driverScheduling;
  18 +
  19 + public CalDriverScheduling(Integer index, DriverScheduling driverScheduling) {
  20 + this.index = index;
  21 + this.driverScheduling = driverScheduling;
  22 + }
  23 +
  24 + public CalDriverScheduling(DriverSchedulingV1 driverScheduling) {
  25 + this.index = Objects.isNull(driverScheduling) ? null : driverScheduling.getIndex();
  26 + this.driverScheduling = driverScheduling;
  27 + }
  28 +}
Bsth-admin/src/main/java/com/ruoyi/in/domain/SignInV1.java 0 → 100644
  1 +package com.ruoyi.in.domain;
  2 +
  3 +import com.alibaba.fastjson2.JSON;
  4 +import com.baomidou.mybatisplus.annotation.TableField;
  5 +import com.baomidou.mybatisplus.annotation.TableName;
  6 +import com.fasterxml.jackson.annotation.JsonFormat;
  7 +import com.ruoyi.common.annotation.Excel;
  8 +import com.ruoyi.domain.DriverScheduling;
  9 +import com.ruoyi.driver.domain.Driver;
  10 +import com.ruoyi.equipment.domain.Equipment;
  11 +import io.swagger.annotations.ApiModelProperty;
  12 +import lombok.Data;
  13 +
  14 +import javax.validation.constraints.NotBlank;
  15 +import javax.validation.constraints.NotNull;
  16 +import java.math.BigDecimal;
  17 +import java.util.Date;
  18 +
  19 +/**
  20 + * @author liujun
  21 + * @date 2024年09月23日 15:44
  22 + */
  23 +@Data
  24 +@TableName("sign_in")
  25 +public class SignInV1 {
  26 + private static final long serialVersionUID = 1L;
  27 +
  28 + /**
  29 + * 主键
  30 + */
  31 + @ApiModelProperty("主键")
  32 + private Long id;
  33 +
  34 + /**
  35 + * 工号
  36 + */
  37 + @Excel(name = "工号")
  38 + @ApiModelProperty("工号")
  39 + @NotBlank(message = "工号不能为空")
  40 + @TableField(value = "jobCode")
  41 + private String jobCode;
  42 +
  43 + @Excel(name = "设备号")
  44 + @ApiModelProperty("设备号")
  45 + @NotBlank(message = "设备号不能为空")
  46 + private String deviceId;
  47 + /**
  48 + * 设备地址
  49 + */
  50 + @Excel(name = "设备地址")
  51 + @ApiModelProperty("设备ip 不用填写")
  52 + private String ip;
  53 +
  54 + /**
  55 + * 图片
  56 + */
  57 + @Excel(name = "图片")
  58 + @ApiModelProperty("图片信息")
  59 + @NotBlank(message = "图片信息不能为空")
  60 + private String image;
  61 +
  62 + /**
  63 + * 签到结果
  64 + */
  65 + @Excel(name = "签到结果")
  66 + @ApiModelProperty("签到结果 1 成功 2 异常")
  67 + private Integer status;
  68 +
  69 + /**
  70 + * 签到类型
  71 + */
  72 + @Excel(name = "签到类型")
  73 + @ApiModelProperty("签到类型 1 人脸 2 刷卡 3 其他 4 酒精 用可以多选 用,拼接 如 1,2,3,4")
  74 + @NotBlank(message = "签到类型不能为空")
  75 + private String singnIn;
  76 +
  77 + /**
  78 + * 酒精测试
  79 + */
  80 + @Excel(name = "酒精测试")
  81 + @ApiModelProperty("酒精测试 1 已测试 2 未测试")
  82 + @NotNull(message = "酒精测试标识不能为空")
  83 + private Integer alcoholFlag;
  84 +
  85 + /**
  86 + * 签到签退
  87 + */
  88 + @Excel(name = "签到签退")
  89 + @ApiModelProperty("签到签退 1 签到成功 2 签退成功")
  90 + @NotNull(message = "签到类型不能为空")
  91 + private Integer type;
  92 +
  93 + /**
  94 + * 酒精摄入量
  95 + */
  96 + @Excel(name = "酒精摄入量")
  97 + @ApiModelProperty("酒精摄入量 52.12")
  98 + private BigDecimal alcoholIntake;
  99 + @Excel(name = "异常类型", readConverterExp = "0=无异常,1=超时异常,2=无排班异常,3=酒精超标异常,200=早签,300=迟到")
  100 + @ApiModelProperty("异常类型")
  101 + private Integer exType;
  102 +
  103 +
  104 + /**
  105 + * 创建时间
  106 + */
  107 + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
  108 + private Date createTime;
  109 +
  110 + /**
  111 + * 更新者
  112 + */
  113 + private String updateBy;
  114 +
  115 + /**
  116 + * 更新时间
  117 + */
  118 + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
  119 + private Date updateTime;
  120 +
  121 + /**
  122 + * 备注
  123 + */
  124 + private String remark;
  125 +
  126 + @TableField(exist = false)
  127 + private String name;
  128 + @TableField(exist = false)
  129 + private String posts;
  130 + @TableField(exist = false)
  131 + private String siteName;
  132 + @TableField(exist = false)
  133 + private String address;
  134 + @TableField(exist = false)
  135 + private Integer signStatus;
  136 +
  137 + @TableField(exist = false)
  138 + private Equipment equipment;
  139 +
  140 + @TableField(exist = false)
  141 + private Driver driver;
  142 + @TableField(exist = false)
  143 + private DriverScheduling driverScheduling;
  144 + @TableField(exist = false)
  145 + private SignIn signIn;
  146 +
  147 + @Override
  148 + public String toString() {
  149 + return JSON.toJSONString(this);
  150 + }
  151 +
  152 +}
Bsth-admin/src/main/java/com/ruoyi/in/mapper/SignInMapperV1.java 0 → 100644
  1 +package com.ruoyi.in.mapper;
  2 +
  3 +import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  4 +import com.ruoyi.in.domain.SignInV1;
  5 +
  6 +import javax.annotation.Resource;
  7 +
  8 +@Resource
  9 +public interface SignInMapperV1 extends BaseMapper<SignInV1> {
  10 +}
Bsth-admin/src/main/java/com/ruoyi/in/service/SignInServiceV1.java 0 → 100644
  1 +package com.ruoyi.in.service;
  2 +
  3 +import com.baomidou.mybatisplus.extension.service.IService;
  4 +import com.ruoyi.common.core.domain.AjaxResult;
  5 +import com.ruoyi.in.domain.SignIn;
  6 +import com.ruoyi.in.domain.SignInV1;
  7 +
  8 +import java.io.IOException;
  9 +
  10 +public interface SignInServiceV1 extends IService<SignInV1> {
  11 + AjaxResult addsignInV1(SignIn signIn) throws IOException;
  12 +}
Bsth-admin/src/main/java/com/ruoyi/in/service/impl/SignInServiceV1Impl.java 0 → 100644
  1 +package com.ruoyi.in.service.impl;
  2 +
  3 +import com.alibaba.fastjson2.JSON;
  4 +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  5 +import com.ruoyi.common.ConstDriverProperties;
  6 +import com.ruoyi.common.ConstSignInConstSignInProperties;
  7 +import com.ruoyi.common.ErrorTypeProperties;
  8 +import com.ruoyi.common.cache.TempCache;
  9 +import com.ruoyi.common.config.RuoYiConfig;
  10 +import com.ruoyi.common.constant.Constants;
  11 +import com.ruoyi.common.core.domain.AjaxResult;
  12 +import com.ruoyi.common.core.redis.RedisCache;
  13 +import com.ruoyi.common.redispre.GlobalRedisPreName;
  14 +import com.ruoyi.common.utils.DateUtils;
  15 +import com.ruoyi.common.utils.StringUtils;
  16 +import com.ruoyi.common.utils.ip.IpUtils;
  17 +import com.ruoyi.common.utils.uuid.Seq;
  18 +import com.ruoyi.common.utils.uuid.UUID;
  19 +import com.ruoyi.domain.DriverScheduling;
  20 +import com.ruoyi.driver.domain.Driver;
  21 +import com.ruoyi.driver.mapper.DriverMapper;
  22 +import com.ruoyi.equipment.domain.Equipment;
  23 +import com.ruoyi.equipment.mapper.EquipmentMapper;
  24 +import com.ruoyi.in.domain.CalDriverScheduling;
  25 +import com.ruoyi.in.domain.SignIn;
  26 +import com.ruoyi.in.domain.SignInV1;
  27 +import com.ruoyi.in.mapper.SignInMapper;
  28 +import com.ruoyi.in.mapper.SignInMapperV1;
  29 +import com.ruoyi.in.service.SignInServiceV1;
  30 +import com.ruoyi.scheduling.domain.DriverSchedulingV1;
  31 +import com.ruoyi.scheduling.service.SchedulingServiceV1;
  32 +import com.ruoyi.service.BigViewServiceV1;
  33 +import com.ruoyi.service.SchedulingService;
  34 +import com.ruoyi.service.ThreadJobService;
  35 +import com.ruoyi.utils.ConstDateUtil;
  36 +import lombok.extern.slf4j.Slf4j;
  37 +import org.apache.commons.collections4.CollectionUtils;
  38 +import org.apache.commons.io.FilenameUtils;
  39 +import org.apache.commons.lang3.time.FastDateFormat;
  40 +import org.springframework.beans.BeanUtils;
  41 +import org.springframework.beans.factory.annotation.Autowired;
  42 +import org.springframework.stereotype.Service;
  43 +import org.springframework.transaction.annotation.Transactional;
  44 +
  45 +import javax.annotation.Resource;
  46 +import java.io.File;
  47 +import java.io.IOException;
  48 +import java.math.BigDecimal;
  49 +import java.util.*;
  50 +
  51 +import static com.ruoyi.common.ConstSignInConstSignInProperties.*;
  52 +import static com.ruoyi.common.ErrorTypeProperties.SIGN_IN_ERROR;
  53 +import static com.ruoyi.common.ErrorTypeProperties.SIGN_OUT_ERROR;
  54 +
  55 +@Slf4j
  56 +@Service
  57 +public class SignInServiceV1Impl extends ServiceImpl<SignInMapperV1, SignInV1> implements SignInServiceV1 {
  58 +
  59 + @Autowired
  60 + private DriverMapper driverMapper;
  61 + @Autowired
  62 + private EquipmentMapper equipmentMapper;
  63 + @Autowired
  64 + private SchedulingServiceV1 schedulingServiceV1;
  65 +
  66 + @Resource
  67 + private ThreadJobService threadJobService;
  68 + @Resource
  69 + private SchedulingService schedulingService;
  70 + @Resource
  71 + private BigViewServiceV1 bigViewServiceV1;
  72 +
  73 + @Autowired
  74 + private SignInMapper signInMapper;
  75 +
  76 + @Autowired
  77 + private RedisCache redisCache;
  78 +
  79 + private static final FastDateFormat HHMM = FastDateFormat.getInstance("HH:mm");
  80 +
  81 + @Override
  82 + @Transactional(rollbackFor = Exception.class)
  83 + public AjaxResult addsignInV1(SignIn signIn) throws IOException {
  84 +
  85 + SignInV1 signInV1 = new SignInV1();
  86 + signInV1.setSignIn(signIn);
  87 +
  88 + // 查询员工信息
  89 + Driver driver = driverMapper.getDriverInfoByJobCode(signIn.getJobCode());
  90 + if (Objects.isNull(driver)) {
  91 + log.info("这个工号的员工不存在:[{}]", signIn);
  92 + return AjaxResult.warn("这个工号的员工不存在!");
  93 + }
  94 + signInV1.setDriver(driver);
  95 +
  96 + Equipment equipment = equipmentMapper.selectEquipmentByDeviceId(signIn.getDeviceId());
  97 + if (Objects.isNull(equipment)) {
  98 + log.info("这个设备号不存在:[{}]", signIn);
  99 + return AjaxResult.warn("这个设备号不存在");
  100 + }
  101 + signInV1.setEquipment(equipment);
  102 +
  103 + signInV1.setAddress(equipment.getAddress());
  104 + signInV1.setDeviceId(signIn.getDeviceId());
  105 + signInV1.setSiteName(equipment.getYardName());
  106 + signInV1.setName(driver.getPersonnelName());
  107 + signInV1.setPosts(driver.getPosts());
  108 +
  109 + if (Objects.isNull(signIn.getCreateTime())) {
  110 + signIn.setCreateTime(DateUtils.getNowDate());
  111 + }
  112 + long dateTime = signIn.getCreateTime().getTime();
  113 + Date date = DateUtils.shortDate(new Date(dateTime));
  114 + DriverScheduling scheduling = null;
  115 + CalDriverScheduling calDriverScheduling = null;
  116 +
  117 +
  118 + List<DriverSchedulingV1> schedulings = schedulingServiceV1.queryByJobCodeAndSchedulingDate(signIn.getJobCode(), date);
  119 + if (CollectionUtils.isEmpty(schedulings)) {
  120 + saveSignOfNoScheduling(signIn, ErrorTypeProperties.WORK_DAY_ERROR);
  121 + switchAndChooseAlcohol(signIn, driver, null);
  122 + return saveData(signIn, null, null, driver, signInV1);
  123 + } else if (Objects.equals(2, signIn.getType())) {
  124 + calDriverScheduling = findSchedulingByDateTime(schedulings, dateTime, ConstDriverProperties.BC_TYPE_IN);
  125 + } else {
  126 + if (checkAlcoholIntake(signIn.getAlcoholIntake())) {
  127 + AjaxResult ajaxResult = bigViewServiceV1.getAjaxResultByDriverSignInfo(signIn,signInV1);
  128 + if (Objects.nonNull(ajaxResult)) {
  129 + return ajaxResult;
  130 + }
  131 + }
  132 + calDriverScheduling = findSchedulingByDateTime(schedulings, dateTime, ConstDriverProperties.BC_TYPE_OUT);
  133 + }
  134 +
  135 + if (Objects.isNull(calDriverScheduling.getDriverScheduling())) {
  136 + log.info("当天没有满足要求的数据:dateTime:[{}],signIn:[{}],scheduling:[{}]", dateTime, signIn, JSON.toJSONString(scheduling));
  137 + saveSignOfNoScheduling(signIn, ErrorTypeProperties.WORK_DAY_ERROR);
  138 + return AjaxResult.success(ErrorTypeProperties.WORK_DAY_ERROR);
  139 + }
  140 +
  141 + scheduling = calDriverScheduling.getDriverScheduling();
  142 + signInV1.setDriverScheduling(calDriverScheduling.getDriverScheduling());
  143 +
  144 + if (Objects.isNull(scheduling.getSignInId())) {
  145 + switchAndChooseTime(signIn, scheduling, dateTime);
  146 + switchAndChooseAlcohol(signIn, driver, scheduling);
  147 +
  148 + } else {
  149 + log.info("签到的数据为:[{}]",scheduling);
  150 + SignInV1 sourceSign = getById(scheduling.getSignInId());
  151 + if (Objects.nonNull(sourceSign)) {
  152 + switchAndChooseTime(signIn, scheduling, dateTime);
  153 + switchAndChooseAlcohol(signIn, driver, scheduling);
  154 + }
  155 + }
  156 +
  157 + signInV1.setSignIn(signIn);
  158 +
  159 + return saveData(signIn, scheduling, calDriverScheduling, driver, signInV1);
  160 + }
  161 +
  162 + private AjaxResult saveData(SignIn signIn, DriverScheduling scheduling, CalDriverScheduling calDriverScheduling, Driver driver, SignInV1 signInV1) {
  163 +
  164 + signInMapper.insertSignIn(signIn);
  165 + signInV1.setId(signInV1.getId());
  166 + // 更新考勤
  167 + if (Objects.nonNull(calDriverScheduling)) {
  168 + schedulingService.computedSignInBySignIn(scheduling, calDriverScheduling.getIndex(), signIn,true);
  169 + }
  170 +
  171 + if (TempCache.checkJobCodeExist(signIn.getJobCode())) {
  172 + TempCache.updateSignStatus(signIn.getJobCode());
  173 + }
  174 +
  175 + // 异常保存到异常异常中
  176 + threadJobService.asyncInsertExceptionRecord(signIn, driver, scheduling);
  177 +
  178 + return handleAjaxResult(signIn, signInV1);
  179 + }
  180 +
  181 +
  182 + private AjaxResult handleAjaxResult(SignIn signIn, SignInV1 signInV1) {
  183 +
  184 + // 酒精测试后续恢复的需要删除异常的酒测缓存
  185 + BeanUtils.copyProperties(signIn, signInV1);
  186 + if (SIGN_IN_SUCCESS.equals(signIn.getStatus())) {
  187 + String prompt = "正常";
  188 + if (org.apache.commons.lang3.StringUtils.isNotEmpty(signIn.getRemark())) {
  189 + prompt = signIn.getRemark().replace("正常", "");
  190 + }
  191 +
  192 + if (signIn.getType().equals(SIGN_OUT)) {
  193 + return AjaxResult.success(SIGN_OUT_SUCCESS_STRING + "," + prompt, signInV1);
  194 + } else {
  195 + return AjaxResult.success(SIGN_IN_SUCCESS_STRING + "," + prompt, signInV1);
  196 + }
  197 + } else {
  198 + if (signIn.getType().equals(SIGN_OUT)) {
  199 + return AjaxResult.success(SIGN_OUT_ERROR + ":" + signIn.getRemark(), signInV1);
  200 + }
  201 + return AjaxResult.success(SIGN_IN_ERROR + ":" + signIn.getRemark(), signInV1);
  202 + }
  203 + }
  204 +
  205 +
  206 + /***
  207 + * 判断是否酒驾;范围 0 =未做酒测;1=酒测;2=酒测正常
  208 + * @author liujun
  209 + * @date 2024/9/23 10:56
  210 + *
  211 + * @param signIn
  212 + * @param driver
  213 + * @param scheduling
  214 + * @return java.lang.Integer
  215 + */
  216 + private Integer switchAndChooseAlcohol(SignIn signIn, Driver driver, DriverScheduling scheduling) {
  217 + // 酒精测试校验 确定 且员工工种是驾驶员
  218 + if (ConstSignInConstSignInProperties.ALCOHOL_FLAG_YES.equals(signIn.getAlcoholFlag()) && ConstDriverProperties.PERSONNEL_POSTS_DRIVER.equals(driver.getPosts())) {
  219 + if (org.apache.commons.lang3.StringUtils.isEmpty(signIn.getIp())) {
  220 + signIn.setIp(IpUtils.getIpAddr());
  221 + }
  222 + Integer extype = Objects.isNull(signIn.getExType()) ? 0 : signIn.getExType();
  223 + if (checkAlcoholIntake(signIn.getAlcoholIntake())) {
  224 + threadJobService.asyncSendEmail(scheduling, signIn, driver);
  225 + signIn.setRemark(join(signIn.getRemark(), org.apache.commons.lang3.StringUtils.join(ErrorTypeProperties.ALCOHOL_SIGN_IN_ERROR, signIn.getAlcoholIntake().toString(), "mg/100ml。")));
  226 + signIn.setExType(extype + ConstSignInConstSignInProperties.SIGN_ALCOHOL_EX_NUM);
  227 +
  228 + signIn.setStatus(ConstSignInConstSignInProperties.SIGN_IN_FAIL);
  229 + signIn.setRemark(signIn.getRemark().replaceFirst(",$", "。"));
  230 +
  231 + return 1;
  232 + } else {
  233 + // 如果驾驶员酒精测试在之前不合格 必须重测
  234 + String key = GlobalRedisPreName.REDIS_SIGN_IN_DRIVER_ALCOHOL_OVERFLOW + ConstDateUtil.formatDate("yyyyMMdd") + ":" + driver.getJobCode();
  235 + Integer count = redisCache.getCacheObject(key);
  236 + if (!Objects.isNull(count)) {
  237 + redisCache.deleteObject(key);
  238 + }
  239 + if (Objects.isNull(signIn.getStatus()) || Objects.equals(signIn.getStatus(), ConstSignInConstSignInProperties.SIGN_IN_SUCCESS)) {
  240 + signIn.setStatus(ConstSignInConstSignInProperties.SIGN_IN_SUCCESS);
  241 + }
  242 + extype = extype > 9 ? extype : extype + ConstSignInConstSignInProperties.SIGN_NO_EX_NUM;
  243 + signIn.setExType(extype);
  244 + if (Objects.equals(0, signIn.getExType())) {
  245 + signIn.setRemark("正常");
  246 + }
  247 +
  248 +
  249 + return 2;
  250 + }
  251 + }
  252 + log.info("未做酒测:alcoholFlag[{}];posts:[{}]", signIn.getAlcoholFlag(), driver.getPosts());
  253 + return 0;
  254 + }
  255 +
  256 + private boolean checkAlcoholIntake(BigDecimal alcoholIntake) {
  257 + return Objects.nonNull(alcoholIntake) ? new BigDecimal("20").compareTo(alcoholIntake) <= 0 : Boolean.FALSE;
  258 + }
  259 +
  260 + private int switchAndChooseTime(SignIn signIn, DriverScheduling scheduling, long dateTime) {
  261 + if (Objects.equals(2, signIn.getType())) {
  262 + Date zdsj = new Date(scheduling.getZdsjT());
  263 +
  264 + Date date1 = org.apache.commons.lang3.time.DateUtils.addMinutes(zdsj, 80);
  265 + String fcsjHHMM = HHMM.format(zdsj);
  266 + String dzsjHHMM = HHMM.format(date1);
  267 +
  268 + String remark = org.apache.commons.lang3.StringUtils.join(ErrorTypeProperties.SIGN_OUT_TIMEOUT, "请在", fcsjHHMM, "到", dzsjHHMM, "之间打卡");
  269 + return switchAndChooseTime(signIn, dateTime, zdsj, 80, remark);
  270 + } else {
  271 + Date fcsj = new Date(scheduling.getFcsjT());
  272 +
  273 + String fcsjHHMM = HHMM.format(org.apache.commons.lang3.time.DateUtils.addMinutes(fcsj, -60));
  274 + String dzsjHHMM = HHMM.format(fcsj);
  275 +
  276 + String remark = org.apache.commons.lang3.StringUtils.join(ErrorTypeProperties.SIGN_IN_TIMEOUT, "请在", fcsjHHMM, "到", dzsjHHMM, "之间打卡");
  277 + return switchAndChooseTime(signIn, dateTime, fcsj, -60, remark);
  278 + }
  279 + }
  280 +
  281 + private String join(String... strs) {
  282 + int length = strs.length;
  283 + StringBuilder builder = new StringBuilder();
  284 + for (int i = 0; i < length; i++) {
  285 + if (org.apache.commons.lang3.StringUtils.isNotEmpty(strs[i])) {
  286 + if (org.apache.commons.lang3.StringUtils.isNotEmpty(builder.toString())) {
  287 + builder.append(";");
  288 + }
  289 + builder.append(strs[i]);
  290 + }
  291 + }
  292 + return builder.toString();
  293 + }
  294 +
  295 + /**
  296 + * 判断时间是否是早签、正常、迟到
  297 + *
  298 + * @param signIn 签到数据
  299 + * @param dateTime 打卡时间
  300 + * @param date 发车或到站时间
  301 + * @param value 允许的最大范围值
  302 + * @param remark 提示信息模板
  303 + * @author liujun
  304 + * @date 2024/9/20 17:14
  305 + */
  306 + private int switchAndChooseTime(SignIn signIn, long dateTime, Date date, Integer value, String remark) {
  307 + long time1 = date.getTime();
  308 + date = org.apache.commons.lang3.time.DateUtils.addMinutes(date, value);
  309 + long time = date.getTime();
  310 +
  311 + if (value < 0) {
  312 + if (dateTime < time) {
  313 + signIn.setExType(20);
  314 + signIn.setRemark(remark);
  315 + signIn.setStatus(2);
  316 +
  317 + return 1;
  318 + } else if (dateTime > time1) {
  319 + signIn.setExType(30);
  320 + signIn.setRemark(remark);
  321 + signIn.setStatus(2);
  322 +
  323 + return 2;
  324 + }
  325 + } else if (value > 0) {
  326 + if (dateTime < time1) {
  327 + signIn.setExType(20);
  328 + signIn.setRemark(remark);
  329 + signIn.setStatus(2);
  330 +
  331 + return 1;
  332 + } else if (dateTime > time) {
  333 + signIn.setExType(30);
  334 + signIn.setRemark(remark);
  335 + signIn.setStatus(2);
  336 +
  337 + return 2;
  338 + }
  339 + }
  340 +
  341 + signIn.setExType(0);
  342 + signIn.setStatus(1);
  343 +
  344 + return 0;
  345 + }
  346 +
  347 + /***
  348 + * 在数据中找出最近一条的排班数据
  349 + * @author liujun
  350 + * @date 2024/9/20 17:08
  351 + * @param schedulings 排班数据集合
  352 + * @param dateTime 打开时间
  353 + * @param type 签到类型
  354 + * @return com.ruoyi.domain.DriverScheduling
  355 + */
  356 + private CalDriverScheduling findSchedulingByDateTime(List<DriverSchedulingV1> schedulings, long dateTime, String type) {
  357 + int size = CollectionUtils.size(schedulings);
  358 + for (int i = 0; i < size; i++) {
  359 + DriverSchedulingV1 s = schedulings.get(i);
  360 + s.setIndex(i);
  361 +
  362 + if (Objects.nonNull(s.getFcsjT()) && org.apache.commons.lang3.StringUtils.equalsAnyIgnoreCase(org.apache.commons.lang3.StringUtils.trim(s.getBcType()), type)) {
  363 + s.setMinTime(Math.abs(s.getFcsjT() - dateTime));
  364 + } else {
  365 + s.setMinTime(Long.MAX_VALUE);
  366 + }
  367 +
  368 + }
  369 +
  370 + Optional<DriverSchedulingV1> optional = schedulings.stream().min(Comparator.comparing(DriverScheduling::getMinTime));
  371 + return new CalDriverScheduling(optional.orElse(null));
  372 + }
  373 +
  374 + /**
  375 + * 没有排班数据
  376 + *
  377 + * @param signIn
  378 + * @param remark
  379 + * @author liujun
  380 + * @date 2024/9/20 16:41
  381 + */
  382 + private void saveSignOfNoScheduling(SignIn signIn, String remark) {
  383 + signIn.setRemark(remark);
  384 + signIn.setExType(2);
  385 + signIn.setStatus(2);
  386 + signIn.setType(1);
  387 +
  388 + }
  389 +
  390 + private void uploadImage(SignIn signIn) throws IOException {
  391 + String base64 = signIn.getImage();
  392 + // 图片路径
  393 + String filePath = RuoYiConfig.getUploadPath();
  394 + // 固定jpg文件
  395 + String fileName = "";
  396 + // 看是否带有base64前缀 有就判断文件类型 没有默认jpg
  397 + fileName = checkImageBase64Format(signIn.getImage());
  398 + fileName = extractFilename(fileName);
  399 + // 获取相对路径
  400 + String absPath = getAbsoluteFile(filePath, fileName).getAbsolutePath();
  401 +
  402 + // 获取文件上传路径
  403 + String pathFileName = getPathFileName(filePath, fileName);
  404 + signIn.setImage(pathFileName);
  405 + signIn.setImage(signIn.getImage());
  406 + log.info("开始异步上传签到图片");
  407 + // 异步上传文件
  408 + threadJobService.asyncStartUploadBase64Image(absPath, base64);
  409 + }
  410 +
  411 + /**
  412 + * 检查文件类型
  413 + *
  414 + * @param base64ImgData
  415 + * @return
  416 + */
  417 + public static String checkImageBase64Format(String base64ImgData) {
  418 + byte[] b = Base64.getDecoder().decode(base64ImgData);
  419 + String type = "";
  420 + if (0x424D == ((b[0] & 0xff) << 8 | (b[1] & 0xff))) {
  421 + type = "bmp";
  422 + } else if (0x8950 == ((b[0] & 0xff) << 8 | (b[1] & 0xff))) {
  423 + type = "png";
  424 + } else {
  425 + type = "jpg";
  426 + }
  427 +// else if (0xFFD8 == ((b[0] & 0xff) << 8 | (b[1] & 0xff))) {
  428 +// type = "jpg";
  429 +// }
  430 + return type;
  431 + }
  432 +
  433 + /**
  434 + * 获取扩展文件名
  435 + *
  436 + * @param extendFileName
  437 + * @return
  438 + */
  439 + private String extractFilename(String extendFileName) {
  440 + return StringUtils.format("{}/{}_{}.{}", DateUtils.datePath(),
  441 + FilenameUtils.getBaseName(UUID.randomUUID().toString().replace("-", "")), Seq.getId(Seq.uploadSeqType), extendFileName);
  442 + }
  443 +
  444 + /**
  445 + * 获取相对路径名
  446 + *
  447 + * @param uploadDir
  448 + * @param fileName
  449 + * @return
  450 + * @throws IOException
  451 + */
  452 + private File getAbsoluteFile(String uploadDir, String fileName) throws IOException {
  453 + File desc = new File(uploadDir + File.separator + fileName);
  454 +
  455 + if (!desc.exists()) {
  456 + if (!desc.getParentFile().exists()) {
  457 + desc.getParentFile().mkdirs();
  458 + }
  459 + }
  460 + return desc;
  461 + }
  462 +
  463 + /**
  464 + * @param uploadDir
  465 + * @param fileName
  466 + * @return
  467 + * @throws IOException
  468 + */
  469 + private String getPathFileName(String uploadDir, String fileName) throws IOException {
  470 + int dirLastIndex = RuoYiConfig.getProfile().length() + 1;
  471 + String currentDir = StringUtils.substring(uploadDir, dirLastIndex);
  472 + return Constants.RESOURCE_PREFIX + "/" + currentDir + "/" + fileName;
  473 + }
  474 +
  475 +
  476 +}
Bsth-admin/src/main/java/com/ruoyi/scheduling/domain/DriverSchedulingV1.java 0 → 100644
  1 +package com.ruoyi.scheduling.domain;
  2 +
  3 +import com.baomidou.mybatisplus.annotation.TableField;
  4 +import com.baomidou.mybatisplus.annotation.TableName;
  5 +import com.ruoyi.domain.DriverScheduling;
  6 +import lombok.Data;
  7 +
  8 +/**
  9 + * @author liujun
  10 + * @date 2024年09月23日 15:36
  11 + */
  12 +@TableName("scheduling")
  13 +@Data
  14 +public class DriverSchedulingV1 extends DriverScheduling {
  15 + @TableField(exist = false)
  16 + private Integer index;
  17 +}
Bsth-admin/src/main/java/com/ruoyi/scheduling/mapper/SchedulingMapperV1.java 0 → 100644
  1 +package com.ruoyi.scheduling.mapper;
  2 +
  3 +import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  4 +import com.ruoyi.scheduling.domain.DriverSchedulingV1;
  5 +
  6 +import javax.annotation.Resource;
  7 +
  8 +@Resource
  9 +public interface SchedulingMapperV1 extends BaseMapper<DriverSchedulingV1> {
  10 +}
Bsth-admin/src/main/java/com/ruoyi/scheduling/service/SchedulingServiceV1.java 0 → 100644
  1 +package com.ruoyi.scheduling.service;
  2 +
  3 +import com.baomidou.mybatisplus.extension.service.IService;
  4 +import com.ruoyi.scheduling.domain.DriverSchedulingV1;
  5 +
  6 +import java.util.Date;
  7 +import java.util.List;
  8 +
  9 +public interface SchedulingServiceV1 extends IService<DriverSchedulingV1> {
  10 +
  11 + List<DriverSchedulingV1> queryByJobCodeAndSchedulingDate(String jobCode, Date date);
  12 +
  13 + List<DriverSchedulingV1> queryByNbbmAndDate(String nbbm, Date date);
  14 +}
Bsth-admin/src/main/java/com/ruoyi/scheduling/service/impl/SchedulingServiceV1Impl.java 0 → 100644
  1 +package com.ruoyi.scheduling.service.impl;
  2 +
  3 +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
  4 +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
  5 +import com.ruoyi.common.utils.DateUtils;
  6 +import com.ruoyi.scheduling.domain.DriverSchedulingV1;
  7 +import com.ruoyi.scheduling.mapper.SchedulingMapperV1;
  8 +import com.ruoyi.scheduling.service.SchedulingServiceV1;
  9 +import org.apache.commons.lang3.StringUtils;
  10 +import org.springframework.stereotype.Service;
  11 +
  12 +import java.text.ParseException;
  13 +import java.util.Date;
  14 +import java.util.List;
  15 +
  16 +@Service
  17 +public class SchedulingServiceV1Impl extends ServiceImpl<SchedulingMapperV1, DriverSchedulingV1> implements SchedulingServiceV1 {
  18 +
  19 + @Override
  20 + public List<DriverSchedulingV1> queryByJobCodeAndSchedulingDate(String jobCode, Date date) {
  21 + String dateStr = DateUtils.FAST_YYYY_MM_DD.format(org.apache.commons.lang3.time.DateUtils.addDays(date, 1));
  22 + dateStr = StringUtils.join(dateStr, " 06:30:30");
  23 + LambdaQueryWrapper<DriverSchedulingV1> wrapper = new LambdaQueryWrapper<>();
  24 + try {
  25 + Date date1 = DateUtils.FAST_YYYY_MM_DDHHMMSS.parse(dateStr);
  26 +
  27 +// dateStr = DateUtils.FAST_YYYY_MM_DD.format(org.apache.commons.lang3.time.DateUtils.addDays(date, -1));
  28 + dateStr = DateUtils.FAST_YYYY_MM_DD.format(date);
  29 + dateStr = StringUtils.join(dateStr, " 00:00:00");
  30 + Date date2 = DateUtils.FAST_YYYY_MM_DDHHMMSS.parse(dateStr);
  31 +
  32 + wrapper.eq(DriverSchedulingV1::getJobCode, jobCode);
  33 + wrapper.and(wr -> {
  34 + wr.eq(DriverSchedulingV1::getScheduleDate, date).or().between(DriverSchedulingV1::getFcsjT, date2.getTime(), date1.getTime());
  35 + });
  36 + wrapper.orderByAsc(DriverSchedulingV1::getFcsjT);
  37 + } catch (ParseException e) {
  38 + throw new RuntimeException(e);
  39 + }
  40 + return list(wrapper);
  41 + }
  42 +
  43 + @Override
  44 + public List<DriverSchedulingV1> queryByNbbmAndDate(String nbbm, Date date) {
  45 + LambdaQueryWrapper<DriverSchedulingV1> wrapper = new LambdaQueryWrapper<>();
  46 + wrapper.eq(DriverSchedulingV1::getNbbm, nbbm).eq(DriverSchedulingV1::getScheduleDate, date);
  47 +
  48 + return list(wrapper);
  49 + }
  50 +}
Bsth-admin/src/main/java/com/ruoyi/service/BigViewServiceV1.java 0 → 100644
  1 +package com.ruoyi.service;
  2 +
  3 +import com.ruoyi.common.core.domain.AjaxResult;
  4 +import com.ruoyi.domain.DriverScheduling;
  5 +import com.ruoyi.driver.domain.Driver;
  6 +import com.ruoyi.in.domain.SignIn;
  7 +import com.ruoyi.in.domain.SignInV1;
  8 +import com.ruoyi.pojo.vo.bigViewVo.FleetState;
  9 +import com.ruoyi.pojo.vo.bigViewVo.LineInfo;
  10 +
  11 +import java.util.Date;
  12 +
  13 +public interface BigViewServiceV1 {
  14 +
  15 + void asyncRefreshRedisValue(SignIn signIn, Driver driver, DriverScheduling driverScheduling,String dateStr, Date date) throws InterruptedException;
  16 +
  17 + AjaxResult queryBigViewQueryLineInfo(Date date);
  18 +
  19 + LineInfo refreshRedisDriver(SignIn signIn, Driver driver, String dateStr, DriverScheduling driverScheduling, Date date);
  20 +
  21 + FleetState refreshRedisLine(SignIn signIn, DriverScheduling driverScheduling, String dateStr) throws InterruptedException;
  22 +
  23 + /***
  24 + * 判断酒测次数
  25 + * @author liujun
  26 + * @date 2024/9/25 14:54
  27 + *
  28 + * @param signIn
  29 + * @return com.ruoyi.common.core.domain.AjaxResult
  30 + */
  31 + AjaxResult getAjaxResultByDriverSignInfo(SignIn signIn,SignInV1 signInV1);
  32 +
  33 + /***
  34 + * 是否是早签
  35 + * @author liujun
  36 + * @date 2024/9/25 14:51
  37 + *
  38 + * @param signIn
  39 + * @return boolean
  40 + */
  41 + boolean isEarly(SignIn signIn);
  42 +
  43 + /***
  44 + * 是否是酒驾
  45 + * @author liujun
  46 + * @date 2024/9/25 14:33
  47 + *
  48 + * @param signIn
  49 + * @return boolean
  50 + */
  51 + boolean isSignStatusWineEnum(SignIn signIn);
  52 +
  53 +
  54 + /***
  55 + * 迟到
  56 + * @author liujun
  57 + * @date 2024/9/25 14:35
  58 + *
  59 + * @param signIn
  60 + * @return boolean
  61 + */
  62 + boolean isSignStatusDelayEnum(SignIn signIn);
  63 +
  64 + /***
  65 + * 酒测是否正常
  66 + * @author liujun
  67 + * @date 2024/9/25 15:15
  68 + *
  69 + * @param signIn
  70 + * @return boolean
  71 + */
  72 + boolean isSignStatusZoneEnum(SignIn signIn);
  73 + /***
  74 + * 是否是驾驶员
  75 + * @author liujun
  76 + * @date 2024/10/9 13:53
  77 + *
  78 + * @param driver
  79 + * @return boolean
  80 + */
  81 + boolean isDriver(Driver driver);
  82 +
  83 +}
Bsth-admin/src/main/java/com/ruoyi/service/SchedulingService.java
@@ -18,6 +18,7 @@ import com.ruoyi.utils.ConstDateUtil; @@ -18,6 +18,7 @@ import com.ruoyi.utils.ConstDateUtil;
18 import com.ruoyi.utils.DateUtil; 18 import com.ruoyi.utils.DateUtil;
19 import com.ruoyi.utils.ToolUtils; 19 import com.ruoyi.utils.ToolUtils;
20 import org.apache.commons.collections4.CollectionUtils; 20 import org.apache.commons.collections4.CollectionUtils;
  21 +import org.apache.commons.lang3.StringUtils;
21 import org.springframework.beans.BeanUtils; 22 import org.springframework.beans.BeanUtils;
22 import org.springframework.beans.factory.annotation.Autowired; 23 import org.springframework.beans.factory.annotation.Autowired;
23 import org.springframework.stereotype.Service; 24 import org.springframework.stereotype.Service;
@@ -50,6 +51,10 @@ public class SchedulingService { @@ -50,6 +51,10 @@ public class SchedulingService {
50 51
51 @Autowired 52 @Autowired
52 private SignInMapper signInMapper; 53 private SignInMapper signInMapper;
  54 +
  55 + @Resource
  56 + private BigViewServiceV1 bigViewServiceV1;
  57 +
53 @Autowired 58 @Autowired
54 private LinggangSchedulingService schedulingService; 59 private LinggangSchedulingService schedulingService;
55 60
@@ -131,6 +136,88 @@ public class SchedulingService { @@ -131,6 +136,88 @@ public class SchedulingService {
131 /** 136 /**
132 * 更具最新的签到记录判断是否需要更新考勤。 137 * 更具最新的签到记录判断是否需要更新考勤。
133 * 138 *
  139 + * @param signIn
  140 + */
  141 + public void computedSignInBySignIn(DriverScheduling driverScheduling, int index, SignIn signIn, boolean isNew) {
  142 + // 无排班不记录不在考勤表不更新
  143 + if (Objects.isNull(driverScheduling)) {
  144 + return;
  145 + }
  146 + String remark = getRemark(driverScheduling, signIn);
  147 + // 更新最新的签到记录判断是否需要更新考勤
  148 + // 记录为空直接插入记录
  149 + if (Objects.isNull(driverScheduling.getSignInId())) {
  150 + schedulingMapper.updateRoster(driverScheduling, signIn.getId(), signIn.getExType(), signIn.getCreateTime(), remark, signIn.getType(), signIn.getAlcoholFlag(), signIn.getAlcoholIntake());
  151 + // 更新缓存
  152 + nowSchedulingCache.updateCacheByJobCode(remark, ConstDateUtil.formatDate(driverScheduling.getScheduleDate()), index, signIn, isNew, driverScheduling);
  153 + }
  154 + // 之前的无效
  155 + else if (!SIGN_NO_EX_NUM.equals(driverScheduling.getExType())) {
  156 + schedulingMapper.updateRoster(driverScheduling, signIn.getId(), signIn.getExType(), signIn.getCreateTime(), remark, signIn.getType(), signIn.getAlcoholFlag(), signIn.getAlcoholIntake());
  157 + nowSchedulingCache.updateCacheByJobCode(remark, ConstDateUtil.formatDate(driverScheduling.getScheduleDate()), index, signIn, isNew, driverScheduling);
  158 + }
  159 + // 之前的有效
  160 + else {
  161 + handlerRecord(driverScheduling, signIn, index, isNew);
  162 + }
  163 +
  164 + }
  165 +
  166 + private String getRemark(DriverScheduling scheduling, SignIn signIn) {
  167 + StringBuilder sb = new StringBuilder();
  168 + if (bigViewServiceV1.isEarly(signIn)) {
  169 + sb.append(EARLY);
  170 + } else if (bigViewServiceV1.isSignStatusDelayEnum(signIn)) {
  171 + sb.append(SIGN_STATUS_DELAY_ENUM.getDescription(scheduling.getBcType()));
  172 + } else if (StringUtils.isNotEmpty(signIn.getRemark())) {
  173 + sb.append(signIn.getRemark());
  174 + }
  175 + if (bigViewServiceV1.isSignStatusWineEnum(signIn) && StringUtils.isNotEmpty(signIn.getRemark())) {
  176 + if (StringUtils.indexOf(scheduling.getRemark(), signIn.getRemark()) > -1) {
  177 + return scheduling.getRemark();
  178 + }
  179 +
  180 + if (StringUtils.indexOf(sb.toString(), signIn.getRemark()) > -1) {
  181 + return sb.toString();
  182 + }
  183 + int index = signIn.getRemark().indexOf(ALCOHOL_SIGN_IN_ERROR);
  184 + if (index != -1) {
  185 + sb.append("," + signIn.getRemark().substring(index));
  186 + }
  187 + }
  188 + return StringUtils.isEmpty(sb.toString()) ? "正常" : sb.toString();
  189 + }
  190 +
  191 + private void handlerRecord(DriverScheduling scheduling, SignIn signIn, Integer index, boolean isNew) {
  192 + if (Objects.isNull(scheduling)) {
  193 + return;
  194 + }
  195 + long timer = 1000 * 60 * 3;
  196 + // 有效的在三分钟内重复签到不做修改
  197 + if (signIn.getExType().equals(SIGN_NO_EX_NUM) && (DateUtils.getNowDate().getTime() - scheduling.getSignTime().getTime()) <= timer) {
  198 + signIn.setRemark("您已经打卡过了,请勿在3分钟内重复打卡");
  199 + return;
  200 + }
  201 + // 目前也有效 -》 无需更新 || 目前无效 -》往后更新
  202 + // TODO 判断时间 之前的有效 但是人员提前打卡且还在上次操作有效范围内需要往后偏移
  203 + // 但是操作一样时间还在有效范围内打卡的话会导致排班表数据不匹配
  204 +
  205 + if (signIn.getExType().equals(SIGN_NO_EX_NUM)) {
  206 + if (signIn.getType().equals(bcTypeTransform(scheduling.getBcType()))) {
  207 + return;
  208 + }
  209 + }
  210 +
  211 +
  212 + String remark = getRemark(scheduling, signIn);
  213 + signInMapper.updateSignIn(signIn);
  214 + schedulingMapper.updateRoster(scheduling, signIn.getId(), signIn.getExType(), signIn.getCreateTime(), remark, signIn.getType(), signIn.getAlcoholFlag(), signIn.getAlcoholIntake());
  215 + nowSchedulingCache.updateCacheByJobCode(remark, ConstDateUtil.formatDate(scheduling.getScheduleDate()), index, signIn, isNew, scheduling);
  216 + }
  217 +
  218 + /**
  219 + * 更具最新的签到记录判断是否需要更新考勤。
  220 + *
134 * @param dto 221 * @param dto
135 * @param signIn 222 * @param signIn
136 * @param globalIndex 223 * @param globalIndex
Bsth-admin/src/main/java/com/ruoyi/service/ThreadJobService.java
@@ -182,6 +182,31 @@ public class ThreadJobService { @@ -182,6 +182,31 @@ public class ThreadJobService {
182 } 182 }
183 183
184 @Async 184 @Async
  185 + public void asyncInsertExceptionRecord(SignIn signIn, Driver driver, DriverScheduling scheduling) {
  186 + if (!SIGN_NO_EX_NUM.equals(signIn.getExType())) {
  187 + EquipmentException exception = new EquipmentException();
  188 + exception.setExType(signIn.getExType());
  189 + exception.setDeviceId(signIn.getDeviceId());
  190 + exception.setJobCode(signIn.getJobCode());
  191 + exception.setStatus(EQUIPMENT_PROCESS_FLOW_COMMIT);
  192 + exception.setImage(signIn.getImage());
  193 + exception.setTitle("打卡异常");
  194 + exception.setRemark(signIn.getRemark());
  195 + exception.setCreateTime(signIn.getCreateTime());
  196 + exception.setFleetName(driver.getFleetName());
  197 + if (Objects.nonNull(scheduling)) {
  198 + exception.setNbbm(scheduling.getNbbm());
  199 + exception.setLineName(scheduling.getLineName());
  200 + exception.setPlanTime(scheduling.getBcType().equals(BC_TYPE_IN) ? new Date(scheduling.getZdsjT()) : new Date(scheduling.getFcsjT()));
  201 + }
  202 + exception.setSignType(signIn.getType());
  203 + exceptionMapper.insertEquipmentException(exception);
  204 + // 发送通知
  205 + sendNotice(signIn, driver, scheduling);
  206 + }
  207 + }
  208 +
  209 + @Async
185 public void asyncInsertExceptionRecord(SignIn signIn, Driver driver, List<DriverScheduling> dto, GlobalIndex globalIndex) { 210 public void asyncInsertExceptionRecord(SignIn signIn, Driver driver, List<DriverScheduling> dto, GlobalIndex globalIndex) {
186 if (!SIGN_NO_EX_NUM.equals(signIn.getExType())) { 211 if (!SIGN_NO_EX_NUM.equals(signIn.getExType())) {
187 EquipmentException exception = new EquipmentException(); 212 EquipmentException exception = new EquipmentException();
@@ -243,6 +268,34 @@ public class ThreadJobService { @@ -243,6 +268,34 @@ public class ThreadJobService {
243 } 268 }
244 } 269 }
245 270
  271 + private void sendNotice(SignIn signIn, Driver driver, DriverScheduling item) {
  272 + if (SIGN_ALCOHOL_EX_NUM.equals(signIn.getExType())) {
  273 + SysNotice notice = new SysNotice();
  274 + notice.setCreateBy("system");
  275 + notice.setUpdateBy("system");
  276 + notice.setNoticeTitle("酒精测试异常通知");
  277 +
  278 + if (Objects.isNull(item)) {
  279 + item = new DriverScheduling();
  280 + handlerNoScheduling(item, signIn, driver);
  281 + }
  282 + String jobCode = "工号:" + item.getJobCode() + "\n";
  283 + String name = "姓名:" + item.getName() + "\n";
  284 + String posts = "工种:" + item.getPosts() + "\n";
  285 + String fleetName = "车队:" + item.getFleetName() + "\n";
  286 + String scheduling = "排班:" + (Objects.isNull(item.getScheduleDate()) ? "无排班" : "有排班") + "\n";
  287 + String signDate = "打卡时间:" + ConstDateUtil.formatDate("yyyy-MM-dd HH:mm:ss", signIn.getCreateTime()) + "\n";
  288 + String cause = "原因:酒精测试超标,当前测试值达到" + signIn.getAlcoholIntake() + "mg/100ml。属于" + getResultString(signIn.getAlcoholIntake());
  289 + String content = jobCode + name + posts + fleetName + scheduling + signDate + cause;
  290 + notice.setNoticeContent(content);
  291 + notice.setNoticeType("1");
  292 + notice.setStatus("0");
  293 + notice.setCreateTime(DateUtils.getNowDate());
  294 + notice.setUpdateTime(DateUtils.getNowDate());
  295 + noticeService.insertNotice(notice);
  296 + }
  297 + }
  298 +
246 private String getResultString(BigDecimal alcoholIntake) { 299 private String getResultString(BigDecimal alcoholIntake) {
247 if (alcoholIntake.compareTo(new BigDecimal(20)) >= 0 && alcoholIntake.compareTo(new BigDecimal(80)) < 0) { 300 if (alcoholIntake.compareTo(new BigDecimal(20)) >= 0 && alcoholIntake.compareTo(new BigDecimal(80)) < 0) {
248 return "饮酒后驾驶机动车"; 301 return "饮酒后驾驶机动车";
@@ -293,6 +346,28 @@ public class ThreadJobService { @@ -293,6 +346,28 @@ public class ThreadJobService {
293 346
294 } 347 }
295 348
  349 + /**
  350 + * 异步发送邮件
  351 + *
  352 + * @param scheduling
  353 + * @param signIn
  354 + * @param driver
  355 + */
  356 + @Async
  357 + public void asyncSendEmail(DriverScheduling scheduling, SignIn signIn, Driver driver) {
  358 + DriverScheduling item = null;
  359 + if (Objects.isNull(scheduling)) {
  360 + item = new DriverScheduling();
  361 + handlerNoScheduling(item, signIn, driver);
  362 + // 无排班
  363 + emailService.sendWarningEmail(item, signIn.getCreateTime(), signIn.getAlcoholIntake());
  364 + } else {
  365 + // 有排班
  366 + emailService.sendWarningEmail(scheduling, signIn.getCreateTime(), signIn.getAlcoholIntake());
  367 + }
  368 +
  369 + }
  370 +
296 private void handlerNoScheduling(DriverScheduling item, SignIn signIn, Driver driver) { 371 private void handlerNoScheduling(DriverScheduling item, SignIn signIn, Driver driver) {
297 BeanUtils.copyProperties(signIn, item); 372 BeanUtils.copyProperties(signIn, item);
298 item.setName(driver.getPersonnelName()); 373 item.setName(driver.getPersonnelName());
Bsth-admin/src/main/java/com/ruoyi/service/impl/BigViewServiceV1Impl.java 0 → 100644
  1 +package com.ruoyi.service.impl;
  2 +
  3 +import com.alibaba.fastjson2.JSON;
  4 +import com.ruoyi.common.SignStatusEnum;
  5 +import com.ruoyi.common.core.domain.AjaxResult;
  6 +import com.ruoyi.common.core.redis.RedisCache;
  7 +import com.ruoyi.domain.DriverScheduling;
  8 +import com.ruoyi.driver.domain.Driver;
  9 +import com.ruoyi.driver.service.IDriverService;
  10 +import com.ruoyi.in.domain.SignIn;
  11 +import com.ruoyi.in.domain.SignInV1;
  12 +import com.ruoyi.in.service.SignInServiceV1;
  13 +import com.ruoyi.pojo.vo.bigViewVo.FleetInfoVo;
  14 +import com.ruoyi.pojo.vo.bigViewVo.FleetState;
  15 +import com.ruoyi.pojo.vo.bigViewVo.LineInfo;
  16 +import com.ruoyi.scheduling.service.SchedulingServiceV1;
  17 +import com.ruoyi.service.BigViewServiceV1;
  18 +import com.ruoyi.template.service.IFleetLineTemplateService;
  19 +import com.ruoyi.utils.ConstDateUtil;
  20 +import lombok.extern.slf4j.Slf4j;
  21 +import org.apache.commons.collections4.CollectionUtils;
  22 +import org.apache.commons.lang3.StringUtils;
  23 +import org.springframework.beans.factory.annotation.Autowired;
  24 +import org.springframework.scheduling.annotation.EnableAsync;
  25 +import org.springframework.stereotype.Service;
  26 +
  27 +import java.text.MessageFormat;
  28 +import java.util.Collections;
  29 +import java.util.Date;
  30 +import java.util.List;
  31 +import java.util.Objects;
  32 +import java.util.concurrent.TimeUnit;
  33 +import java.util.stream.Collectors;
  34 +
  35 +import static com.ruoyi.common.ConstSignInConstSignInProperties.SIGN_IN_ERROR_COUNT;
  36 +import static com.ruoyi.common.ErrorTypeProperties.SIGN_IN_ERROR;
  37 +import static com.ruoyi.common.redispre.GlobalRedisPreName.REDIS_SIGN_IN_DRIVER_ALCOHOL_OVERFLOW;
  38 +
  39 +/**
  40 + * @author liujun
  41 + * @date 2024年09月25日 14:38
  42 + */
  43 +@Slf4j
  44 +@Service
  45 +@EnableAsync
  46 +public class BigViewServiceV1Impl implements BigViewServiceV1 {
  47 + @Autowired
  48 + private IFleetLineTemplateService fleetLineTemplateService;
  49 + @Autowired
  50 + private SchedulingServiceV1 schedulingServiceV1;
  51 + @Autowired
  52 + private IDriverService driverService;
  53 + @Autowired
  54 + private SignInServiceV1 signInServiceV1;
  55 +
  56 + @Autowired
  57 + private RedisCache redisCache;
  58 +
  59 +
  60 + private static final String LINE_SIGN_NBBM_KEY = "sign:report:nbbm:{0}:{1}";
  61 + private static final String LINE_SIGN_NBBM_LOCK_KEY = "sign:report:lock:nbbm:{0}:{1}";
  62 +
  63 + private static final String LINE_SIGN_STATUS_KEY = "sign:report:status:{0}:{1}";
  64 + private static final String LINE_SIGN_STATUS_LOCK_KEY = "sign:report:lock:status:{0}:{1}";
  65 +
  66 + private static final String LINE_SIGN_REPORT_FLEET_KEY = "sign:report:fleet:{0}";
  67 +
  68 + private static final String BIG_VIEW_LINE_KEY = "big:view:line:{0}";
  69 +
  70 +
  71 + @Override
  72 + public void asyncRefreshRedisValue(SignIn signIn, Driver driver, DriverScheduling driverScheduling, String dateStr, Date date) throws InterruptedException {
  73 +
  74 + }
  75 +
  76 + @Override
  77 + public AjaxResult queryBigViewQueryLineInfo(Date date) {
  78 + return null;
  79 + }
  80 +
  81 +
  82 + @Override
  83 + public LineInfo refreshRedisDriver(SignIn signIn, Driver driver, String dateStr, DriverScheduling driverScheduling, Date date) {
  84 + return null;
  85 + }
  86 +
  87 +
  88 + @Override
  89 + public FleetState refreshRedisLine(SignIn signIn, DriverScheduling driverScheduling, String dateStr) throws InterruptedException {
  90 +
  91 + return null;
  92 + }
  93 +
  94 + @Override
  95 + public AjaxResult getAjaxResultByDriverSignInfo(SignIn signIn,SignInV1 signInV1) {
  96 + String key = StringUtils.join(REDIS_SIGN_IN_DRIVER_ALCOHOL_OVERFLOW, ConstDateUtil.FAST_YYYY_MM_DD.format(new Date()), ":", signIn.getJobCode());
  97 + // 驾驶员酒精测试连续超标两次则提示换人
  98 + Integer count = redisCache.getCacheObject(key);
  99 + if (Objects.isNull(count) || count.equals(0)) {
  100 + count = 1;
  101 + redisCache.setCacheObject(key, count, 1, TimeUnit.DAYS);
  102 + } else {
  103 + redisCache.setCacheObject(key, ++count, 1, TimeUnit.DAYS);
  104 + }
  105 + if (SIGN_IN_ERROR_COUNT.compareTo(count) <= 0) {
  106 +
  107 + return AjaxResult.success(SIGN_IN_ERROR + ": " + (StringUtils.isEmpty(signIn.getRemark()) ? "" : signIn.getRemark()) + "酒精测试不通过" + count + "次请更换车辆驾驶员。", signInV1);
  108 + }
  109 + return null;
  110 + }
  111 +
  112 +
  113 + @Override
  114 + public boolean isEarly(SignIn signIn) {
  115 + return Objects.nonNull(signIn) && signIn.getExType() >= 20 && signIn.getExType() < 30;
  116 + }
  117 +
  118 +
  119 + @Override
  120 + public boolean isSignStatusWineEnum(SignIn signIn) {
  121 + return Objects.nonNull(signIn) && (Objects.equals(3, signIn.getExType()) || Objects.equals(23, signIn.getExType()) || Objects.equals(33, signIn.getExType()));
  122 + }
  123 +
  124 +
  125 + @Override
  126 + public boolean isSignStatusDelayEnum(SignIn signIn) {
  127 + return Objects.nonNull(signIn) && Objects.nonNull(signIn.getExType()) && signIn.getExType() >= 30 && signIn.getExType() < 40;
  128 + }
  129 +
  130 + @Override
  131 + public boolean isSignStatusZoneEnum(SignIn signIn) {
  132 + return Objects.nonNull(signIn) && Objects.nonNull(signIn.getExType()) && signIn.getExType() % 10 == 3;
  133 + }
  134 +
  135 + @Override
  136 + public boolean isDriver(Driver driver) {
  137 + return Objects.nonNull(driver) && StringUtils.isNotEmpty(driver.getPosts()) && StringUtils.indexOf(driver.getPosts(), "驾驶员") > -1;
  138 + }
  139 +
  140 +
  141 + private List<FleetInfoVo> getFleetInfoVoOfRedis(String key) {
  142 + try {
  143 + String jsonStr = redisCache.getCacheObject(key);
  144 + if (StringUtils.isEmpty(jsonStr)) {
  145 +
  146 + log.info("redis中没有当天的数据[{}]", key);
  147 + return Collections.emptyList();
  148 + }
  149 + return JSON.parseArray(jsonStr, FleetInfoVo.class);
  150 + } catch (Exception e) {
  151 + log.error("从redis中获取数据异常,[{}]", key, e);
  152 + }
  153 + return null;
  154 + }
  155 +
  156 +
  157 + private LineInfo getLineInfoByRedis(String key) {
  158 + try {
  159 + String jsonStr = redisCache.getCacheObject(key);
  160 + if (StringUtils.isEmpty(jsonStr)) {
  161 + return null;
  162 + }
  163 + return JSON.parseObject(jsonStr, LineInfo.class);
  164 + } catch (Exception e) {
  165 + log.error("从redis中获取LineInfo 异常:[{}]", key, e);
  166 + }
  167 + return null;
  168 + }
  169 +
  170 +
  171 + private Integer switchSignStatus(SignIn signIn) {
  172 + if (Objects.isNull(signIn.getExType())) {
  173 + return null;
  174 + }
  175 + if (isSignStatusWineEnum(signIn)) {
  176 + return SignStatusEnum.SIGN_STATUS_WINE_ENUM.getStatus();
  177 + }
  178 +
  179 + if (isSignStatusDelayEnum(signIn)) {
  180 + return SignStatusEnum.SIGN_STATUS_DELAY_ENUM.getStatus();
  181 + }
  182 +
  183 + if (isSignStatusZoneEnum(signIn)) {
  184 + return SignStatusEnum.SIGN_STATUS_ZONE_ENUM.getStatus();
  185 + }
  186 + return SignStatusEnum.SIGN_STATUS_EMPTY_ENUM.getStatus();
  187 +
  188 + }
  189 +
  190 + private void setDriverByPost(Driver driver, LineInfo lineInfo, LineInfo.PersonInfoVo personInfoVo) {
  191 + if (isDriver(driver)) {
  192 + lineInfo.setDriverInfoVo(personInfoVo);
  193 + } else {
  194 + lineInfo.setDriverInfoVo(personInfoVo);
  195 + }
  196 + }
  197 +
  198 + private <T> List<T> getRedisData(String key, String dateStr, Class<T> calzz) {
  199 + key = MessageFormat.format(key, dateStr, "*");
  200 + List<String> jsonStrs = redisCache.getCacheList(key);
  201 + if (CollectionUtils.isEmpty(jsonStrs)) {
  202 + return Collections.emptyList();
  203 + }
  204 + return jsonStrs.stream().map(json -> {
  205 + T t = JSON.parseObject(json, calzz);
  206 + return t;
  207 + }).collect(Collectors.toList());
  208 + }
  209 +
  210 + private List<FleetInfoVo> getFleetInfoVoBtRedis(String key) {
  211 + try {
  212 + String json = redisCache.getCacheObject(key);
  213 + if (StringUtils.isEmpty(json)) {
  214 + return Collections.emptyList();
  215 + }
  216 + return JSON.parseArray(json, FleetInfoVo.class);
  217 + } catch (Exception e) {
  218 + log.error("[{}]从redis中获取页面数据异常", key, e);
  219 + }
  220 + return Collections.emptyList();
  221 + }
  222 +
  223 +
  224 +}
Bsth-common/src/main/java/com/ruoyi/common/utils/DateUtils.java
@@ -9,6 +9,7 @@ import java.text.ParseException; @@ -9,6 +9,7 @@ import java.text.ParseException;
9 import java.text.SimpleDateFormat; 9 import java.text.SimpleDateFormat;
10 import java.time.*; 10 import java.time.*;
11 import java.util.Date; 11 import java.util.Date;
  12 +import java.util.Objects;
12 13
13 /** 14 /**
14 * 时间工具类 15 * 时间工具类
@@ -37,6 +38,9 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils { @@ -37,6 +38,9 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
37 public static FastDateFormat YYYY_MM_DD_HH_MM_SPOT = FastDateFormat.getInstance("yyyy.MM.dd HH:mm"); 38 public static FastDateFormat YYYY_MM_DD_HH_MM_SPOT = FastDateFormat.getInstance("yyyy.MM.dd HH:mm");
38 public static FastDateFormat YYYY_MM_SPOT = FastDateFormat.getInstance("yyyy.MM"); 39 public static FastDateFormat YYYY_MM_SPOT = FastDateFormat.getInstance("yyyy.MM");
39 40
  41 + public static FastDateFormat FAST_YYYY_MM_DD = FastDateFormat.getInstance("yyyy-MM-dd");
  42 + public static FastDateFormat FAST_YYYY_MM_DDHHMMSS = FastDateFormat.getInstance("yyyy-MM-dd HH:mm:ss");
  43 +
40 44
41 private static String[] parsePatterns = { 45 private static String[] parsePatterns = {
42 "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM", 46 "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss", "yyyy-MM-dd HH:mm", "yyyy-MM",
@@ -52,6 +56,17 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils { @@ -52,6 +56,17 @@ public class DateUtils extends org.apache.commons.lang3.time.DateUtils {
52 return new Date(); 56 return new Date();
53 } 57 }
54 58
  59 + public static Date shortDate(Date date) {
  60 + if (Objects.isNull(date)) {
  61 + return null;
  62 + }
  63 + try {
  64 + return FAST_YYYY_MM_DD.parse(FAST_YYYY_MM_DD.format(date));
  65 + } catch (ParseException e) {
  66 + throw new RuntimeException(e);
  67 + }
  68 + }
  69 +
55 /** 70 /**
56 * 获取当前日期, 默认格式为yyyy-MM-dd 71 * 获取当前日期, 默认格式为yyyy-MM-dd
57 * 72 *