From fc0a84698b16024f26652227c15ace87bcc882a2 Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期日, 15 三月 2026 17:12:00 +0800
Subject: [PATCH] 缺卡处理

---
 xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/schedule/ClockInScheduleTask.java |   20 +++++++++++++-------
 1 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/schedule/ClockInScheduleTask.java b/xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/schedule/ClockInScheduleTask.java
index 96a4cf6..1527795 100644
--- a/xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/schedule/ClockInScheduleTask.java
+++ b/xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/schedule/ClockInScheduleTask.java
@@ -69,13 +69,13 @@
                     .likeRight(XpSchedulingDetail::getPlanTime, LocalDate.now().minusDays(1)));
 
             if(!CollectionUtils.isEmpty(clockOutPlanList)){
-                List<Long> fleetIds = clockOutPlanList.stream().map(XpSchedulingDetail::getFleetId).collect(Collectors.toList());
+                List<Long> fleetIds = clockOutPlanList.stream().map(XpSchedulingDetail::getFleetId).distinct().collect(Collectors.toList());
                 // 查询所有车队的绑定人员
                 List<XpFleetOperations> xpFleetOperations = xpFleetOperationsClient.getOperationsIdsByFleetIds(fleetIds).getData();
                 // 查询班次
                 List<Long> shiftIds = clockOutPlanList.stream().map(XpSchedulingDetail::getShiftId).collect(Collectors.toList());
                 List<XpShift> xpShifts = xpShiftService.list(Wrappers.lambdaQuery(XpShift.class)
-                        .eq(XpShift::getId, shiftIds));
+                        .in(XpShift::getId, shiftIds));
                 log.info("========== 查询到{}个车队 ==========", xpFleetOperations.size());
                 if(!CollectionUtils.isEmpty(xpShifts) && !CollectionUtils.isEmpty(xpFleetOperations)){
                     // 处理上班卡缺卡情况
@@ -92,7 +92,7 @@
                                 .map(XpFleetOperations::getOperationsUserId).distinct().collect(Collectors.toList());
                         // 批量查询人员打卡信息
                         List<XpClockIn> clockInList = xpClockInService.list(Wrappers.lambdaQuery(XpClockIn.class)
-                                .eq(XpClockIn::getAppUserId, operationsUserIds));
+                                .in(XpClockIn::getAppUserId, operationsUserIds));
                         // 判断有哪些人员没有打卡信息
                         List<Long> noClockInUserIds = operationsUserIds.stream().filter(id -> clockInList.stream().noneMatch(clockIn -> clockIn.getAppUserId().equals(id))).collect(Collectors.toList());
                         if(!CollectionUtils.isEmpty(noClockInUserIds)){
@@ -121,7 +121,7 @@
                             }
                             if (!CollectionUtils.isEmpty(noClockInList)){
                                 log.info("添加上班缺卡信息:{}", noClockInList);
-                                xpClockInService.saveOrUpdateBatch(noClockInList);
+                                xpClockInService.saveBatch(noClockInList);
                             }
                         }
                     }
@@ -133,22 +133,27 @@
                     List<Long> fiveIds = shiftListFive.stream().map(XpShift::getId).collect(Collectors.toList());
                     if(!CollectionUtils.isEmpty(fiveIds)){
                         log.info("========== 进入下班过期的班次 ==========");
+                        List<XpSchedulingDetail> clockOutPlans = clockOutPlanList.stream().filter(xpSchedulingDetail -> fiveIds.contains(xpSchedulingDetail.getShiftId())).collect(Collectors.toList());
+                        List<Long> fleetIdOut = clockOutPlans.stream().map(XpSchedulingDetail::getFleetId).collect(Collectors.toList());
+                        // 查询所有车队的绑定人员
+                        List<XpFleetOperations> xpFleetOperationsList = xpFleetOperationsClient.getOperationsIdsByFleetIds(fleetIdOut).getData();
                         // 获取过期当前班次的排班明细  覆盖
                         List<XpSchedulingDetail> fiveClockOutPlans = clockOutPlanList.stream().filter(xpSchedulingDetail -> fiveIds.contains(xpSchedulingDetail.getShiftId())).collect(Collectors.toList());
                         List<Long> fiveFleetIdIn = fiveClockOutPlans.stream().map(XpSchedulingDetail::getFleetId).collect(Collectors.toList());
                         // 查询所有车队的绑定人员
-                        if(!CollectionUtils.isEmpty(xpFleetOperations)){
-                            List<Long> operationsUserIdsFive = xpFleetOperations.stream().filter(x -> fiveFleetIdIn.contains(x.getFleetId()))
+                        if(!CollectionUtils.isEmpty(xpFleetOperationsList)){
+                            List<Long> operationsUserIdsFive = xpFleetOperationsList.stream().filter(x -> fiveFleetIdIn.contains(x.getFleetId()))
                                     .map(XpFleetOperations::getOperationsUserId).distinct().collect(Collectors.toList());
                             // 批量查询人员打卡信息
                             List<XpClockIn> clockInListFive = xpClockInService.list(Wrappers.lambdaQuery(XpClockIn.class)
-                                    .eq(XpClockIn::getAppUserId, operationsUserIdsFive)
+                                    .in(XpClockIn::getAppUserId, operationsUserIdsFive)
                                     .isNull(XpClockIn::getClockOutTime));
                             log.info("========== 获取到{}个人员没有下班打卡信息 ==========", clockInListFive.size());
                             if(!CollectionUtils.isEmpty(clockInListFive)){
                                 for (XpClockIn xpClockIn : clockInListFive) {
                                     xpClockIn.setClockOutTime(LocalDateTime.now());
                                     xpClockIn.setClockOutResult(3);
+                                    xpClockIn.setAppUserId(null);
                                 }
                                 xpClockInService.updateBatchById(clockInListFive);
                                 log.info("========== 修改为下班缺卡 ==========");
@@ -185,6 +190,7 @@
                         // 批量查询人员打卡信息
                         List<XpClockIn> clockInListFive = xpClockInService.list(Wrappers.lambdaQuery(XpClockIn.class)
                                 .in(XpClockIn::getAppUserId, operationsUserIdsFive)
+                                .likeRight(XpClockIn::getClockInTime,LocalDate.now().minusDays(1))
                                 .isNull(XpClockIn::getClockOutTime));
                         log.info("========== 获取到{}个人员没有下班打卡信息 ==========", clockInListFive.size());
                         if(!CollectionUtils.isEmpty(clockInListFive)){

--
Gitblit v1.7.1