Commit 8aafc43472a3804f2542380730bbc8d4acb4f2d1

Authored by 2c
1 parent 4fa8a048

优化管理员代领钥匙逻辑

Bsth-admin/src/main/java/com/ruoyi/controller/dss/KeyBoxController.java
@@ -336,18 +336,36 @@ public class KeyBoxController extends BaseController { @@ -336,18 +336,36 @@ public class KeyBoxController extends BaseController {
336 String date = DateFormatUtils.format(DateUtils.getNowDate(),"yyyy-MM-dd"); 336 String date = DateFormatUtils.format(DateUtils.getNowDate(),"yyyy-MM-dd");
337 LambdaQueryWrapper<LinggangScheduling> wrapper = new LambdaQueryWrapper<>(); 337 LambdaQueryWrapper<LinggangScheduling> wrapper = new LambdaQueryWrapper<>();
338 wrapper.eq(LinggangScheduling::getNbbm,dto.getKeyItem().get(0).getPlate()).and(i -> i.and(j -> j.apply("DATE_FORMAT(schedule_date, '%Y-%m-%d') LIKE {0}", date+"%"))) 338 wrapper.eq(LinggangScheduling::getNbbm,dto.getKeyItem().get(0).getPlate()).and(i -> i.and(j -> j.apply("DATE_FORMAT(schedule_date, '%Y-%m-%d') LIKE {0}", date+"%")))
339 - .and(i -> i.eq(LinggangScheduling::getBcType,"out")).and(i -> i.eq(LinggangScheduling::getPosts,"驾驶员"))  
340 - .last("ORDER BY ABS(fcsj_t - UNIX_TIMESTAMP() * 1000) LIMIT 1"); 339 + .and(i -> i.eq(LinggangScheduling::getBcType,"out")).and(i -> i.eq(LinggangScheduling::getPosts,"驾驶员"));
341 //sql 语句: 340 //sql 语句:
342 // SELECT * FROM `linggang_scheduling` 341 // SELECT * FROM `linggang_scheduling`
343 // WHERE nbbm = 'A01' AND DATE_FORMAT(schedule_date, '%Y-%m-%d') LIKE '2023-07-08%' AND bc_type = 'out' AND posts = '驾驶员' 342 // WHERE nbbm = 'A01' AND DATE_FORMAT(schedule_date, '%Y-%m-%d') LIKE '2023-07-08%' AND bc_type = 'out' AND posts = '驾驶员'
344 - // ORDER BY ABS(fcsj_t - UNIX_TIMESTAMP() * 100)  
345 - // LIMIT 1 343 +
  344 + // 查询符合条件的调度信息列表
346 List<LinggangScheduling> scheduling = schedulingService.list(wrapper); 345 List<LinggangScheduling> scheduling = schedulingService.list(wrapper);
  346 + // 初始化调度信息索引
  347 + int schedulingIndex = 0;
  348 + // 检查调度信息列表是否不为空
347 if(!scheduling.isEmpty()){ 349 if(!scheduling.isEmpty()){
348 - scheduling.get(0).setExType(4);  
349 - scheduling.get(0).setRemark("管理员代领钥匙");  
350 - schedulingService.updateById(scheduling.get(0)); 350 + // 初始化一个数组,用于存储每个调度信息与当前时间的毫秒差
  351 + long[] timing = new long[scheduling.size()];
  352 + // 获取当前系统时间的毫秒值
  353 + long time = System.currentTimeMillis();
  354 + // 遍历调度信息列表,计算每个调度信息的时间与当前时间的差值
  355 + for(int i=0;i<scheduling.size();i++){
  356 + timing[i] = Math.abs(time - scheduling.get(i).getFcsjT());
  357 + }
  358 + // 遍历时间差数组,找到与当前时间最接近的调度信息索引
  359 + for (int i = 0; i < timing.length; i++){
  360 + if (timing[i] < timing[schedulingIndex]) {
  361 + schedulingIndex = i;
  362 + }
  363 + }
  364 + // 更新与当前时间最接近的调度信息,设置其事件类型为4,并备注管理员代领钥匙
  365 + scheduling.get(schedulingIndex).setExType(4);
  366 + scheduling.get(schedulingIndex).setRemark("管理员代领钥匙");
  367 + // 调用服务方法更新数据库中的相应调度信息
  368 + schedulingService.updateById(scheduling.get(schedulingIndex));
351 } 369 }
352 } 370 }
353 371
Bsth-admin/src/main/java/com/ruoyi/service/impl/BigViewServiceImpl.java
@@ -472,7 +472,7 @@ public class BigViewServiceImpl implements BigViewService { @@ -472,7 +472,7 @@ public class BigViewServiceImpl implements BigViewService {
472 return; 472 return;
473 } 473 }
474 // 如有多异常覆盖策略 异常等级排 未签 -》 迟到 -》 酒驾 474 // 如有多异常覆盖策略 异常等级排 未签 -》 迟到 -》 酒驾
475 - if (driverInfoVo.getSignStatus().compareTo(personInfoVo.getSignStatus()) > 0) { 475 + if (driverInfoVo.getSignStatus().compareTo(personInfoVo.getSignStatus()) > 0 && personInfoVo.getSignStatus()!=4) {
476 return; 476 return;
477 } 477 }
478 } 478 }