Commit 09143f6bc160bed789a04aea2955d6f75ba57c5c

Authored by guzijian
1 parent eff53cd9

feat: 新增驾驶员无排班也许酒测,新增驾驶员酒精不通过后必须通过后才能不酒测 解决跟班bug,解决备注无酒精异常备注bug

Bsth-admin/src/main/java/com/ruoyi/common/cache/NowSchedulingCache.java
... ... @@ -32,6 +32,9 @@ public class NowSchedulingCache {
32 32 cacheNowDaySchedulingInit();
33 33 }
34 34  
  35 + /**
  36 + * 初始化签到报表数据并存入缓存
  37 + */
35 38 private void cacheNowDaySchedulingInit() {
36 39 // 查询今天和昨天
37 40 for (int i = 0; i > -2; i--) {
... ...
Bsth-admin/src/main/java/com/ruoyi/common/cache/SchedulingCache.java
... ... @@ -46,6 +46,9 @@ public class SchedulingCache {
46 46 }
47 47  
48 48  
  49 + /**
  50 + * 初始化排班数据 并存入缓存
  51 + */
49 52 private void schedulingInit() {
50 53 String formatNowDate = ConstDateUtil.formatDate(new Date());
51 54 String url = getUrl(formatNowDate);
... ...
Bsth-admin/src/main/java/com/ruoyi/driver/service/impl/DriverServiceImpl.java
... ... @@ -62,6 +62,7 @@ import static com.ruoyi.common.ApiProperties.PERSONNEL_API_KEY;
62 62 import static com.ruoyi.common.ConstDriverProperties.*;
63 63 import static com.ruoyi.common.ConstSignInConstSignInProperties.*;
64 64 import static com.ruoyi.common.redispre.GlobalRedisPreName.DRIVER_SCHEDULING_PRE;
  65 +import static com.ruoyi.common.redispre.GlobalRedisPreName.REDIS_SIGN_IN_DRIVER_ALCOHOL_OVERFLOW;
65 66  
66 67 /**
67 68 * 驾驶员信息Service业务层处理
... ... @@ -360,9 +361,9 @@ public class DriverServiceImpl implements IDriverService {
360 361 vos.add(DriverResponseVo.createDriverResponseVo(null, item, SIGN_IN_STRING, needCheckAlcoholDevice, true, "测试", "测试", "测试"));
361 362 }
362 363 } else {
363   - // 无排班
  364 + // 无排班 工种是驾驶员需要酒测
364 365 if (Objects.isNull(vo)) {
365   - vos.add(DriverResponseVo.createDriverResponseVo(null, item, null, false, false, "", "", ""));
  366 + vos.add(DriverResponseVo.createDriverResponseVo(null, item, null, "驾驶员".equals(item.getPosts()),false, "", "", ""));
366 367 } else {
367 368 // 特定设备是无需酒精测试的
368 369 vo.setCheckAlcohol(needCheckAlcoholDevice ? vo.getCheckAlcohol() : false);
... ... @@ -404,6 +405,16 @@ public class DriverServiceImpl implements IDriverService {
404 405 } else if (BC_TYPE_IN.equals(recommendation.getBcType())) {
405 406 vo = DriverResponseVo.createDriverResponseVo(recommendation.getTimestamps(), driver, SIGN_IN_OUT_STRING, !alcoholFlag, schedulingFlag, recommendation.getNbbm(), recommendation.getLpName(), recommendation.getLineName());
406 407 }
  408 +
  409 + // 如果驾驶员酒精测试在之前不合格 必须重测
  410 + if ("驾驶员".equals(driver.getPosts())) {
  411 + String key = REDIS_SIGN_IN_DRIVER_ALCOHOL_OVERFLOW + ConstDateUtil.formatDate("yyyyMMdd") + ":" + driver.getJobCode();
  412 + Integer count = redisCache.getCacheObject(key);
  413 + if (!Objects.isNull(count) && !Objects.isNull(vo)) {
  414 + vo.setCheckAlcohol(alcoholFlag);
  415 + }
  416 + }
  417 +
407 418 }
408 419 return vo;
409 420 }
... ... @@ -543,7 +554,7 @@ public class DriverServiceImpl implements IDriverService {
543 554 nowTimerList.add(timeMap.get(index));
544 555 }
545 556 // 处理当前时间段未签人员
546   - nowTimerList = handleTimeOutPerson(nowTimerList,now);
  557 + nowTimerList = handleTimeOutPerson(nowTimerList, now);
547 558 sendNotice(nowTimerList);
548 559 }
549 560  
... ... @@ -581,7 +592,7 @@ public class DriverServiceImpl implements IDriverService {
581 592 private List<DriverSignInRecommendation> handleTimeOutPerson(List<DriverSignInRecommendation> nowTimerList, Long now) {
582 593 return nowTimerList.stream()
583 594 // 只需要签到
584   - .filter(item-> BC_TYPE_OUT.equals(item.getBcType()) && checkPosts(item))
  595 + .filter(item -> BC_TYPE_OUT.equals(item.getBcType()) && checkPosts(item))
585 596 // 给出范围界限 不能未到具体时间的也发送通知
586 597 .filter(item -> now - item.getTimestamps() >= 0)
587 598 // 筛选应签未签人员
... ... @@ -590,7 +601,7 @@ public class DriverServiceImpl implements IDriverService {
590 601 }
591 602  
592 603 private boolean checkPosts(DriverSignInRecommendation item) {
593   - switch (item.getPosts()){
  604 + switch (item.getPosts()) {
594 605 case "驾驶员":
595 606 case "售票员":
596 607 case "采集员":
... ...
Bsth-admin/src/main/java/com/ruoyi/in/service/impl/SignInServiceImpl.java
... ... @@ -201,6 +201,8 @@ public class SignInServiceImpl implements ISignInService {
201 201 return result;
202 202 }
203 203 }
  204 + // 酒精测试后续恢复的需要删除异常的酒测缓存
  205 +
204 206 if (SIGN_IN_SUCCESS.equals(signIn.getStatus())) {
205 207 String prompt = signIn.getRemark().replace("正常", "");
206 208 if (signIn.getType().equals(SIGN_OUT)) {
... ... @@ -430,6 +432,13 @@ public class SignInServiceImpl implements ISignInService {
430 432 signIn.setRemark(signIn.getRemark() + ALCOHOL_SIGN_IN_ERROR + signIn.getAlcoholIntake().toString() + "mg/100ml。");
431 433 signIn.setExType(SIGN_ALCOHOL_EX_NUM);
432 434 result = false;
  435 + } else {
  436 + // 如果驾驶员酒精测试在之前不合格 必须重测
  437 + String key = REDIS_SIGN_IN_DRIVER_ALCOHOL_OVERFLOW + ConstDateUtil.formatDate("yyyyMMdd") + ":" + driver.getJobCode();
  438 + Integer count = redisCache.getCacheObject(key);
  439 + if (!Objects.isNull(count)) {
  440 + redisCache.deleteObject(key);
  441 + }
433 442 }
434 443 }
435 444 return result;
... ... @@ -559,9 +568,18 @@ public class SignInServiceImpl implements ISignInService {
559 568 }
560 569 // 签退|签到 当前有记录
561 570 if (!Objects.isNull(currentScheduling.getSignInId())) {
562   - String prompt = getPrompt(currentScheduling);
  571 + String prompt;
  572 + // 超时了就到下一次签到报表记录
  573 + boolean timeOut = handleTimeOut(currentScheduling.getBcType(), nowBetween, globalIndex, currentScheduling);
  574 + if (timeOut) {
  575 + DriverSignInRecommendation nextScheduling = schedulingService.computedTheCurrentClosestTimestamp(dto, now, 1);
  576 + globalIndex.setIndex(nextScheduling.getIndex());
  577 + prompt = getPrompt(nextScheduling);
  578 + } else {
  579 + globalIndex.setIndex(currentScheduling.getIndex());
  580 + prompt = getPrompt(currentScheduling);
  581 + }
563 582 signIn.setRemark((currentScheduling.getBcType().equals(BC_TYPE_IN) ? SIGN_OUT_TIMEOUT : SIGN_IN_TIMEOUT) + prompt);
564   - globalIndex.setIndex(currentScheduling.getIndex());
565 583 result = false;
566 584 }
567 585 } else {
... ... @@ -575,12 +593,20 @@ public class SignInServiceImpl implements ISignInService {
575 593 }
576 594 }
577 595  
  596 + private boolean handleTimeOut(String bcType, long nowBetween, GlobalIndex globalIndex, DriverSignInRecommendation currentScheduling) {
  597 + if (BC_TYPE_OUT.equals(bcType) && nowBetween > 60L || BC_TYPE_IN.equals(bcType) && nowBetween <= 120L) {
  598 + return true;
  599 + } else {
  600 + return false;
  601 + }
  602 + }
  603 +
578 604 private String getPrompt(DriverSignInRecommendation currentScheduling) {
579 605 if (BC_TYPE_OUT.equals(currentScheduling.getBcType())) {
580 606 return "请在" + ConstDateUtil.formatDate("HH:mm", new Date(currentScheduling.getTimestamps())) + "前后一小时内打卡。";
581 607 } else {
582 608 // 正两小时 负 1小时
583   - LocalDateTime time = ConstDateUtil.stringTransformLocalDateTime(ConstDateUtil.formatDate("yyyy-MM-dd HH:mm:ss", new Date(currentScheduling.getTimestamps())),"yyyy-MM-dd HH:mm:ss");
  609 + LocalDateTime time = ConstDateUtil.stringTransformLocalDateTime(ConstDateUtil.formatDate("yyyy-MM-dd HH:mm:ss", new Date(currentScheduling.getTimestamps())), "yyyy-MM-dd HH:mm:ss");
584 610 LocalDateTime addHours = time.plusHours(2);
585 611 LocalDateTime hours = time.plusHours(-1);
586 612 return "请在" + ConstDateUtil.formatDate("HH:mm", hours) + "到"
... ... @@ -589,7 +615,6 @@ public class SignInServiceImpl implements ISignInService {
589 615 }
590 616  
591 617  
592   -
593 618 private static boolean checkTimerSign(long nowBetween, String bcType) {
594 619 // 如果是签到就是正负一小时内有效
595 620 if (BC_TYPE_OUT.equals(bcType)) {
... ...
Bsth-admin/src/main/java/com/ruoyi/job/DriverJob.java
... ... @@ -376,7 +376,7 @@ public class DriverJob implements InitializingBean {
376 376 }
377 377 }
378 378 } catch (Exception e) {
379   - log.info("创建班失败原因:{}", e.getMessage());
  379 + log.info("创建班失败原因:{}", e.getMessage());
380 380 }
381 381 }
382 382  
... ...
Bsth-admin/src/main/java/com/ruoyi/service/SchedulingService.java
... ... @@ -27,8 +27,7 @@ import java.util.*;
27 27 import static com.ruoyi.common.ConstDriverProperties.BC_TYPE_IN;
28 28 import static com.ruoyi.common.ConstDriverProperties.BC_TYPE_OUT;
29 29 import static com.ruoyi.common.ConstSignInConstSignInProperties.*;
30   -import static com.ruoyi.common.ErrorTypeProperties.SIGN_IN_TIMEOUT;
31   -import static com.ruoyi.common.ErrorTypeProperties.SIGN_OUT_TIMEOUT;
  30 +import static com.ruoyi.common.ErrorTypeProperties.*;
32 31 import static com.ruoyi.common.ReportProperties.NOW;
33 32  
34 33 /**
... ... @@ -127,7 +126,7 @@ public class SchedulingService {
127 126 nowSchedulingCache.updateCacheByJobCode(ConstDateUtil.formatDate(dto.get(0).getScheduleDate()), globalIndex.getIndex(), signIn);
128 127 }
129 128 // 之前的无效
130   - else if (!dto.get(globalIndex.getIndex()).getExType().equals(SIGN_NO_EX_NUM)) {
  129 + else if (!SIGN_NO_EX_NUM.equals(dto.get(globalIndex.getIndex()).getExType())) {
131 130 schedulingMapper.updateRoster(dto.get(globalIndex.getIndex()), signIn.getId(), signIn.getExType(), signIn.getCreateTime(), remark, signIn.getType(), signIn.getAlcoholFlag(), signIn.getAlcoholIntake());
132 131 nowSchedulingCache.updateCacheByJobCode(ConstDateUtil.formatDate(dto.get(0).getScheduleDate()), globalIndex.getIndex(), signIn);
133 132 }
... ... @@ -139,17 +138,21 @@ public class SchedulingService {
139 138 }
140 139  
141 140 private String getRemark(List<DriverScheduling> dto, SignIn signIn, Integer globalIndex) {
  141 + StringBuilder sb = new StringBuilder();
142 142 DriverScheduling scheduling = dto.get(globalIndex);
143 143 long date = scheduling.getBcType().equals(BC_TYPE_IN) ? scheduling.getZdsjT() : scheduling.getFcsjT();
144 144 long nowBetween = ChronoUnit.MINUTES.between(ConstDateUtil.getLocalDateTimeByLongTime(date), ConstDateUtil.getLocalDateTimeByLongTime(signIn.getCreateTime().getTime()));
145 145 if (checkTimerSign(nowBetween, scheduling.getBcType())) {
146 146 if (nowBetween < -60L) {
147   - return "早签";
  147 + sb.append("早签");
148 148 } else {
149   - return "迟到";
  149 + sb.append("迟到");
150 150 }
151 151 }
152   - return signIn.getRemark();
  152 + if (SIGN_ALCOHOL_EX_NUM.equals(signIn.getExType())) {
  153 + sb.append("," + signIn.getRemark().substring(signIn.getRemark().indexOf(ALCOHOL_SIGN_IN_ERROR)));
  154 + }
  155 + return sb.toString();
153 156 }
154 157  
155 158 private static boolean checkTimerSign(long nowBetween, String bcType) {
... ... @@ -196,7 +199,7 @@ public class SchedulingService {
196 199 return "请在" + ConstDateUtil.formatDate("HH:mm", date) + "前后一小时内打卡。";
197 200 } else {
198 201 // 正两小时 负 1小时
199   - LocalDateTime time = ConstDateUtil.stringTransformLocalDateTime(ConstDateUtil.formatDate("yyyy-MM-dd HH:mm:ss", date),"yyyy-MM-dd HH:mm:ss");
  202 + LocalDateTime time = ConstDateUtil.stringTransformLocalDateTime(ConstDateUtil.formatDate("yyyy-MM-dd HH:mm:ss", date), "yyyy-MM-dd HH:mm:ss");
200 203 LocalDateTime addHours = time.plusHours(2);
201 204 LocalDateTime hours = time.plusHours(-1);
202 205 return "请在" + ConstDateUtil.formatDate("HH:mm", hours) + "到"
... ...
Bsth-admin/src/main/resources/mapper/expand/DriverSchedulingExpandMapper.xml
... ... @@ -54,7 +54,8 @@ PUBLIC &quot;-//mybatis.org//DTD Mapper 3.0//EN&quot;
54 54 driver.fleet_name slaveFleetName,
55 55 driver.posts slavePosts,expand.*
56 56 from driver_scheduling_expand expand,driver
57   - where driver.job_code = expand.slave_job_code
  57 + where driver.job_code = expand.slave_job_code
  58 + and start_date &lt;= NOW()
58 59 <if test="status != null">
59 60 and expand.`status` = #{status}
60 61 </if>
... ...