Commit 7e0b9ec4adf9443f6cc6197c2aa2acbcfa10adee
1 parent
0628166f
1、正常签退时间由原先的60分钟延长至80分钟,超出时间属于异常签退。
2、酒精测试2次异常后,不得再次操作。
Showing
10 changed files
with
211 additions
and
24 deletions
Bsth-admin/src/main/java/com/ruoyi/common/ConstDriverProperties.java
| ... | ... | @@ -22,5 +22,12 @@ public interface ConstDriverProperties { |
| 22 | 22 | Integer STATUS_NORMAL = 0; |
| 23 | 23 | |
| 24 | 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 | 1 | package com.ruoyi.common.cache; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.collection.CollectionUtil; |
| 4 | +import cn.hutool.core.map.MapUtil; | |
| 5 | +import com.ruoyi.common.utils.StringUtils; | |
| 4 | 6 | import com.ruoyi.driver.mapper.DriverSchedulingMapper; |
| 5 | 7 | import com.ruoyi.errorScheduling.domain.ErrorJobcode; |
| 6 | 8 | import com.ruoyi.errorScheduling.service.IErrorJobcodeService; |
| ... | ... | @@ -8,9 +10,12 @@ import com.ruoyi.in.domain.SignIn; |
| 8 | 10 | import com.ruoyi.domain.DriverScheduling; |
| 9 | 11 | import com.ruoyi.service.ThreadJobService; |
| 10 | 12 | import com.ruoyi.utils.ConstDateUtil; |
| 13 | +import lombok.extern.slf4j.Slf4j; | |
| 14 | +import org.apache.commons.collections4.CollectionUtils; | |
| 11 | 15 | import org.slf4j.Logger; |
| 12 | 16 | import org.slf4j.LoggerFactory; |
| 13 | 17 | import org.springframework.stereotype.Component; |
| 18 | +import org.springframework.stereotype.Service; | |
| 14 | 19 | |
| 15 | 20 | import java.util.*; |
| 16 | 21 | import java.util.concurrent.ConcurrentHashMap; |
| ... | ... | @@ -18,14 +23,14 @@ import java.util.concurrent.ConcurrentHashMap; |
| 18 | 23 | @Component |
| 19 | 24 | public class NowSchedulingCache { |
| 20 | 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 | 30 | private static ConcurrentHashMap<String, Map<String, List<DriverScheduling>>> cacheNowDayScheduling = new ConcurrentHashMap<>(); |
| 26 | 31 | private IErrorJobcodeService errorJobcodeService; |
| 27 | 32 | |
| 28 | - public NowSchedulingCache(DriverSchedulingMapper driverSchedulingMapper,IErrorJobcodeService errorJobcodeService) { | |
| 33 | + public NowSchedulingCache(DriverSchedulingMapper driverSchedulingMapper, IErrorJobcodeService errorJobcodeService) { | |
| 29 | 34 | this.schedulingMapper = driverSchedulingMapper; |
| 30 | 35 | this.errorJobcodeService = errorJobcodeService; |
| 31 | 36 | log.info("项目启动加载中获取排班表并存入缓存-----"); |
| ... | ... | @@ -39,7 +44,7 @@ public class NowSchedulingCache { |
| 39 | 44 | // 查询今天和昨天 |
| 40 | 45 | for (int i = 0; i > -2; i--) { |
| 41 | 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 | 48 | List<DriverScheduling> schedulingList = schedulingMapper.queryToDay(date, null, null, null); |
| 44 | 49 | handlerResultMap(resultMap, schedulingList); |
| 45 | 50 | // 获取错误排班 |
| ... | ... | @@ -47,10 +52,48 @@ public class NowSchedulingCache { |
| 47 | 52 | // 插入错误排班 |
| 48 | 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 | 98 | public static void handlerResultMap(Map<String, List<DriverScheduling>> resultMap, List<DriverScheduling> schedulingList) { |
| 56 | 99 | for (DriverScheduling scheduling : schedulingList) { |
| ... | ... | @@ -110,7 +153,7 @@ public class NowSchedulingCache { |
| 110 | 153 | */ |
| 111 | 154 | public void updateCacheByJobCode(String remark, String key, Integer index, SignIn signIn) { |
| 112 | 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 | 157 | DriverScheduling scheduling = cacheNowDayScheduling.get(key).get(signIn.getJobCode()).get(index); |
| 115 | 158 | scheduling.setSignInId(signIn.getId()); |
| 116 | 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 | 13 | import io.swagger.annotations.Api; |
| 14 | 14 | import io.swagger.annotations.ApiOperation; |
| 15 | 15 | import io.swagger.annotations.ApiParam; |
| 16 | +import org.springframework.security.access.prepost.PreAuthorize; | |
| 16 | 17 | import org.springframework.validation.annotation.Validated; |
| 17 | 18 | import org.springframework.web.bind.annotation.*; |
| 18 | 19 | |
| 19 | 20 | import javax.annotation.Resource; |
| 20 | 21 | import javax.servlet.http.HttpServletRequest; |
| 21 | 22 | import javax.servlet.http.HttpServletResponse; |
| 23 | +import java.math.BigDecimal; | |
| 22 | 24 | import java.util.List; |
| 23 | 25 | |
| 24 | 26 | /** |
| ... | ... | @@ -50,6 +52,38 @@ public class ReportController { |
| 50 | 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 | 87 | @ApiOperation("异常报表集合查询") |
| 54 | 88 | @GetMapping("/error/list") |
| 55 | 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 | 21 | |
| 22 | 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 | 30 | * @return |
| ... | ... | @@ -32,4 +34,12 @@ public interface DriverSchedulingMapper { |
| 32 | 34 | |
| 33 | 35 | |
| 34 | 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 | 159 | // 查询员工信息 |
| 160 | 160 | Driver driver = driverMapper.getDriverInfoByJobCode(signIn.getJobCode()); |
| 161 | 161 | if (Objects.isNull(driver)) return AjaxResult.warn("这个工号的员工不存在!"); |
| 162 | + | |
| 162 | 163 | // 查询地址 |
| 163 | 164 | Equipment equipment = equipmentMapper.selectEquipmentByDeviceId(signIn.getDeviceId()); |
| 164 | 165 | SignInResponseVo vo = getSignInResponseVo(driver, signIn, equipment); |
| ... | ... | @@ -169,6 +170,15 @@ public class SignInServiceImpl implements ISignInService { |
| 169 | 170 | List<DriverScheduling> dto = schedulingService.queryScheduling(signIn.getJobCode(), now); |
| 170 | 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 | 182 | uploadImage(signIn, vo); |
| 173 | 183 | signInMapper.insertSignIn(signIn); |
| 174 | 184 | // 更新考勤 |
| ... | ... | @@ -200,12 +210,7 @@ public class SignInServiceImpl implements ISignInService { |
| 200 | 210 | } |
| 201 | 211 | |
| 202 | 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 | 216 | if (SIGN_IN_SUCCESS.equals(signIn.getStatus())) { |
| ... | ... | @@ -561,7 +566,7 @@ public class SignInServiceImpl implements ISignInService { |
| 561 | 566 | DriverSignInRecommendation lastClosestTimestamp = schedulingService.computedTheCurrentClosestTimestamp(dto, now, -1); |
| 562 | 567 | // 给出签到范围 |
| 563 | 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 | 570 | signIn.setRemark(SIGN_OUT_TIMEOUT + getPrompt(lastClosestTimestamp)); |
| 566 | 571 | globalIndex.setIndex(lastClosestTimestamp.getIndex()); |
| 567 | 572 | result = false; |
| ... | ... | @@ -578,7 +583,7 @@ public class SignInServiceImpl implements ISignInService { |
| 578 | 583 | if (currentScheduling.getBcType().equals(BC_TYPE_IN) && Objects.isNull(currentScheduling.getSignInId())) { |
| 579 | 584 | DriverSignInRecommendation lastClosestTimestamp = schedulingService.computedTheCurrentClosestTimestamp(dto, now, -1); |
| 580 | 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 | 587 | signIn.setRemark(SIGN_IN_TIMEOUT + getPrompt(lastClosestTimestamp)); |
| 583 | 588 | globalIndex.setIndex(lastClosestTimestamp.getIndex()); |
| 584 | 589 | result = false; |
| ... | ... | @@ -622,7 +627,7 @@ public class SignInServiceImpl implements ISignInService { |
| 622 | 627 | |
| 623 | 628 | private boolean handleTimeOut(String bcType, long nowBetween, GlobalIndex globalIndex, DriverSignInRecommendation currentScheduling) { |
| 624 | 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 | 631 | return true; |
| 627 | 632 | } else { |
| 628 | 633 | return false; |
| ... | ... | @@ -638,7 +643,7 @@ public class SignInServiceImpl implements ISignInService { |
| 638 | 643 | } else { |
| 639 | 644 | // 延后一小时 |
| 640 | 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 | 647 | return "请在" + ConstDateUtil.formatDate("HH:mm", time) + "到" |
| 643 | 648 | + ConstDateUtil.formatDate("HH:mm", addHours) + "之间打卡"; |
| 644 | 649 | } |
| ... | ... | @@ -650,8 +655,8 @@ public class SignInServiceImpl implements ISignInService { |
| 650 | 655 | if (BC_TYPE_OUT.equals(bcType)) { |
| 651 | 656 | return !(nowBetween <= 0L && nowBetween >= -60L); |
| 652 | 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 | 668 | globalIndex.setIndex(0); |
| 664 | 669 | // 单条数据 且不在范围内 |
| 665 | 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 | 672 | signIn.setRemark(SIGN_OUT_TIMEOUT); |
| 668 | 673 | return false; |
| 669 | 674 | } else { |
| ... | ... | @@ -765,4 +770,5 @@ public class SignInServiceImpl implements ISignInService { |
| 765 | 770 | // } |
| 766 | 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 | 3 | import io.swagger.annotations.ApiModel; |
| 4 | 4 | import lombok.Data; |
| 5 | 5 | |
| 6 | +import java.math.BigDecimal; | |
| 6 | 7 | import java.util.Date; |
| 7 | 8 | |
| 8 | 9 | /** |
| ... | ... | @@ -11,6 +12,7 @@ import java.util.Date; |
| 11 | 12 | @Data |
| 12 | 13 | @ApiModel("签到报表查看详情vo") |
| 13 | 14 | public class ReportDetailResponseVo { |
| 15 | + private Long id; | |
| 14 | 16 | private String jobCode; |
| 15 | 17 | private String name; |
| 16 | 18 | private String posts; |
| ... | ... | @@ -20,6 +22,9 @@ public class ReportDetailResponseVo { |
| 20 | 22 | private String nbbm; |
| 21 | 23 | private String exString; |
| 22 | 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 | 5 | import com.alibaba.excel.ExcelWriter; |
| 6 | 6 | import com.alibaba.excel.write.metadata.WriteSheet; |
| 7 | 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 | 11 | import com.ruoyi.common.global.Result; |
| 9 | 12 | import com.ruoyi.common.global.ResultCode; |
| 10 | 13 | import com.ruoyi.common.utils.SecurityUtils; |
| 11 | 14 | import com.ruoyi.common.utils.poi.ExcelUtil; |
| 12 | 15 | import com.ruoyi.domain.DriverScheduling; |
| 16 | +import com.ruoyi.driver.domain.Driver; | |
| 17 | +import com.ruoyi.driver.mapper.DriverMapper; | |
| 13 | 18 | import com.ruoyi.driver.mapper.DriverSchedulingMapper; |
| 14 | 19 | import com.ruoyi.eexception.mapper.EquipmentExceptionMapper; |
| 20 | +import com.ruoyi.in.domain.SignIn; | |
| 15 | 21 | import com.ruoyi.in.mapper.SignInMapper; |
| 16 | 22 | import com.ruoyi.pojo.request.ReportErrorRequestVo; |
| 17 | 23 | import com.ruoyi.pojo.request.ReportViewRequestVo; |
| ... | ... | @@ -21,6 +27,8 @@ import com.ruoyi.system.domain.SysNotice; |
| 21 | 27 | import com.ruoyi.system.service.ISysNoticeService; |
| 22 | 28 | import com.ruoyi.utils.ConstDateUtil; |
| 23 | 29 | import com.ruoyi.utils.ToolUtils; |
| 30 | +import lombok.extern.slf4j.Slf4j; | |
| 31 | +import org.quartz.Scheduler; | |
| 24 | 32 | import org.springframework.beans.BeanUtils; |
| 25 | 33 | import org.springframework.beans.factory.annotation.Autowired; |
| 26 | 34 | import org.springframework.stereotype.Service; |
| ... | ... | @@ -30,6 +38,7 @@ import javax.servlet.http.HttpServletRequest; |
| 30 | 38 | import javax.servlet.http.HttpServletResponse; |
| 31 | 39 | import javax.validation.constraints.NotBlank; |
| 32 | 40 | import java.io.OutputStream; |
| 41 | +import java.math.BigDecimal; | |
| 33 | 42 | import java.time.LocalDate; |
| 34 | 43 | import java.time.YearMonth; |
| 35 | 44 | import java.time.format.DateTimeFormatter; |
| ... | ... | @@ -44,17 +53,22 @@ import java.util.stream.Collectors; |
| 44 | 53 | |
| 45 | 54 | import static com.ruoyi.common.ApiProperties.PERSONNEL_API_KEY; |
| 46 | 55 | import static com.ruoyi.common.ConstDriverProperties.BC_TYPE_OUT; |
| 56 | +import static com.ruoyi.common.ConstDriverProperties.PERSONNEL_POSTS_DRIVER; | |
| 47 | 57 | import static com.ruoyi.common.ConstSignInConstSignInProperties.*; |
| 48 | 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 | 62 | * @author 20412 |
| 52 | 63 | */ |
| 53 | 64 | @Service |
| 65 | +@Slf4j | |
| 54 | 66 | public class ReportService { |
| 55 | 67 | |
| 56 | 68 | @Autowired |
| 57 | 69 | private SignInMapper signInMapper; |
| 70 | + @Autowired | |
| 71 | + private DriverMapper driverMapper; | |
| 58 | 72 | |
| 59 | 73 | @Autowired |
| 60 | 74 | private ISysNoticeService noticeService; |
| ... | ... | @@ -68,6 +82,12 @@ public class ReportService { |
| 68 | 82 | @Autowired |
| 69 | 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 | 190 | data.add(ConstDateUtil.formatDate("yyyy-MM-dd HH:mm:ss", vo.getCreateTime())); |
| 171 | 191 | if (vo.getSignType() == null) { |
| 172 | 192 | data.add(""); |
| 173 | - }else { | |
| 193 | + } else { | |
| 174 | 194 | data.add(vo.getSignType().equals(SIGN_IN) ? "签到" : "签退"); |
| 175 | 195 | } |
| 176 | 196 | } else { |
| ... | ... | @@ -349,6 +369,48 @@ public class ReportService { |
| 349 | 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 | 414 | private void handlerReportDetail(ReportDetailResponseVo reportDetailResponseVo, DriverScheduling scheduling) { |
| 353 | 415 | BeanUtils.copyProperties(scheduling, reportDetailResponseVo); |
| 354 | 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 | 26 | import java.time.temporal.ChronoUnit; |
| 27 | 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 | 30 | import static com.ruoyi.common.ConstSignInConstSignInProperties.*; |
| 32 | 31 | import static com.ruoyi.common.ErrorTypeProperties.*; |
| 33 | 32 | import static com.ruoyi.common.ReportProperties.NOW; |
| ... | ... | @@ -145,7 +144,7 @@ public class SchedulingService { |
| 145 | 144 | long date = scheduling.getBcType().equals(BC_TYPE_IN) ? scheduling.getZdsjT() : scheduling.getFcsjT(); |
| 146 | 145 | long nowBetween = ChronoUnit.MINUTES.between(ConstDateUtil.getLocalDateTimeByLongTime(date), ConstDateUtil.getLocalDateTimeByLongTime(signIn.getCreateTime().getTime())); |
| 147 | 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 | 148 | sb.append(EARLY); |
| 150 | 149 | } else { |
| 151 | 150 | sb.append(SIGN_STATUS_DELAY_ENUM.getDescription(scheduling.getBcType())); |
| ... | ... | @@ -220,7 +219,7 @@ public class SchedulingService { |
| 220 | 219 | ConstDateUtil.formatDate("HH:mm", time) + "之间打卡"; |
| 221 | 220 | } else { |
| 222 | 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 | 223 | return "请在" + ConstDateUtil.formatDate("HH:mm", time) + "到" + |
| 225 | 224 | ConstDateUtil.formatDate("HH:mm", addHours) + "之间打卡"; |
| 226 | 225 | } | ... | ... |
Bsth-admin/src/main/java/com/ruoyi/utils/ConstDateUtil.java
| 1 | 1 | package com.ruoyi.utils; |
| 2 | 2 | |
| 3 | +import org.apache.commons.lang3.time.FastDateFormat; | |
| 4 | + | |
| 3 | 5 | import java.text.ParseException; |
| 4 | 6 | import java.text.SimpleDateFormat; |
| 5 | 7 | import java.time.*; |
| ... | ... | @@ -11,6 +13,9 @@ import java.util.List; |
| 11 | 13 | |
| 12 | 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 | 19 | public static String getStringNowLocalDate(){ |
| 15 | 20 | // 指定当前日期和时间 |
| 16 | 21 | LocalDate currentDate = LocalDate.now(); | ... | ... |
Bsth-admin/src/main/resources/mapper/driver_scheduling/DriverSchedulingMapper.xml
| ... | ... | @@ -22,7 +22,15 @@ |
| 22 | 22 | <result column="sign_time" property="signTime" jdbcType="DATETIMEOFFSET"/> |
| 23 | 23 | <result column="alcohol_flag" property="alcoholFlag" jdbcType="DATETIMEOFFSET"/> |
| 24 | 24 | <result column="alcohol_intake" property="alcoholIntake"/> |
| 25 | + <result column="sign_type" property="signType"></result> | |
| 26 | + <result column="remark" property="remark"></result> | |
| 25 | 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 | 34 | <insert id="insertRoster" parameterType="java.util.List" useGeneratedKeys="true" keyColumn="id" keyProperty="id"> |
| 27 | 35 | insert into scheduling (schedule_date,line_name,job_code,`name`,posts,lp_name,nbbm,bc_type,fcsj_t,zdsj_t) |
| 28 | 36 | values |
| ... | ... | @@ -55,6 +63,10 @@ |
| 55 | 63 | where id = #{scheduling.id} |
| 56 | 64 | </update> |
| 57 | 65 | |
| 66 | + <update id="updateRosterById" parameterType="com.ruoyi.domain.DriverScheduling"> | |
| 67 | + | |
| 68 | + </update> | |
| 69 | + | |
| 58 | 70 | <select id="queryToDay" resultType="com.ruoyi.domain.DriverScheduling" resultMap="Scheduling"> |
| 59 | 71 | select scheduling.*,driver.fleet_name fleetName,equipment.site_name siteName from |
| 60 | 72 | scheduling left join driver on scheduling.job_code = driver.job_code |
| ... | ... | @@ -86,4 +98,8 @@ |
| 86 | 98 | where schedule_date >= #{startDate} |
| 87 | 99 | and schedule_date <= #{endDate} |
| 88 | 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 | 105 | </mapper> |
| 90 | 106 | \ No newline at end of file | ... | ... |