From aacc83ac6473694c278de0d18de453774009d864 Mon Sep 17 00:00:00 2001
From: puzhibing <393733352@qq.com>
Date: 星期五, 10 四月 2026 17:58:04 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/schedule/ClockInScheduleTask.java |   55 ++++++++++++++++++++++---------------------------------
 1 files changed, 22 insertions(+), 33 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 72a8529..52368ac 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
@@ -90,39 +90,30 @@
                         List<Long> fleetIdIn = clockOutPlans.stream().map(XpSchedulingDetail::getFleetId).collect(Collectors.toList());
                         List<Long> operationsUserIds = xpFleetOperations.stream().filter(x -> fleetIdIn.contains(x.getFleetId()))
                                 .map(XpFleetOperations::getOperationsUserId).distinct().collect(Collectors.toList());
-                        // 批量查询人员打卡信息
-                        List<XpClockIn> clockInList = xpClockInService.list(Wrappers.lambdaQuery(XpClockIn.class)
-                                .in(XpClockIn::getAppUserId, operationsUserIds).in(XpClockIn::getShiftId, ids));
-                        // 判断有哪些人员没有打卡信息
-                        List<Long> noClockInUserIds = operationsUserIds.stream().filter(id -> clockInList.stream().noneMatch(clockIn -> clockIn.getAppUserId().equals(id))).collect(Collectors.toList());
-                        if(!CollectionUtils.isEmpty(noClockInUserIds)){
-                            log.info("========== 获取到{}个人员没有打卡信息 ==========", noClockInUserIds.size());
-                            // 添加上班缺卡信息
-                            List<XpClockIn> noClockInList = new ArrayList<>();
-                            for (Long noClockInUserId : noClockInUserIds) {
-                                // 通过用户id找到车队id
-                                List<XpFleetOperations> operations = xpFleetOperations.stream().filter(x -> x.getOperationsUserId().equals(noClockInUserId)).collect(Collectors.toList());
-                                if(!CollectionUtils.isEmpty(operations)){
-                                    Long fleetId = operations.get(0).getFleetId();
-                                    // 通过车队id和已过期的班次获取排班明细
-                                    List<XpSchedulingDetail> clockOutPlanExpiredList = clockOutPlanList.stream()
-                                            .filter(xpSchedulingDetail -> xpSchedulingDetail.getFleetId().equals(fleetId)
-                                                    && ids.contains(xpSchedulingDetail.getShiftId())).collect(Collectors.toList());
-                                    if(!CollectionUtils.isEmpty(clockOutPlanExpiredList)){
-                                        Long shiftId = clockOutPlanExpiredList.get(0).getShiftId();
-                                        XpClockIn xpClockIn = new XpClockIn();
-                                        xpClockIn.setAppUserId(noClockInUserId);
-                                        xpClockIn.setClockInTime(LocalDateTime.now());
-                                        xpClockIn.setClockInResult(3);
-                                        xpClockIn.setShiftId(shiftId);
-                                        noClockInList.add(xpClockIn);
-                                    }
+                        if(!CollectionUtils.isEmpty(operationsUserIds)){
+                            int createdCount = 0;
+                            for (Long operationsUserId : operationsUserIds) {
+                                List<XpFleetOperations> operations = xpFleetOperations.stream()
+                                        .filter(x -> x.getOperationsUserId().equals(operationsUserId))
+                                        .collect(Collectors.toList());
+                                if(CollectionUtils.isEmpty(operations)){
+                                    continue;
+                                }
+                                Long fleetId = operations.get(0).getFleetId();
+                                List<XpSchedulingDetail> clockOutPlanExpiredList = clockOutPlanList.stream()
+                                        .filter(xpSchedulingDetail -> xpSchedulingDetail.getFleetId().equals(fleetId)
+                                                && ids.contains(xpSchedulingDetail.getShiftId()))
+                                        .collect(Collectors.toList());
+                                if(CollectionUtils.isEmpty(clockOutPlanExpiredList)){
+                                    continue;
+                                }
+                                Long shiftId = clockOutPlanExpiredList.get(0).getShiftId();
+                                boolean created = xpClockInService.createMissingClockInIfAbsent(operationsUserId, shiftId, LocalDate.now());
+                                if (created) {
+                                    createdCount++;
                                 }
                             }
-                            if (!CollectionUtils.isEmpty(noClockInList)){
-                                log.info("添加上班缺卡信息:{}", noClockInList);
-                                xpClockInService.saveBatch(noClockInList);
-                            }
+                            log.info("========== 新增上班缺卡记录{}条 ==========", createdCount);
                         }
                     }
 
@@ -154,7 +145,6 @@
                                 for (XpClockIn xpClockIn : clockInListFive) {
                                     xpClockIn.setClockOutTime(LocalDateTime.now());
                                     xpClockIn.setClockOutResult(3);
-                                    xpClockIn.setAppUserId(null);
                                 }
                                 xpClockInService.updateBatchById(clockInListFive);
                                 log.info("========== 修改为下班缺卡 ==========");
@@ -198,7 +188,6 @@
                         log.info("========== 获取到{}个人员没有下班打卡信息 ==========", clockInListFive.size());
                         if(!CollectionUtils.isEmpty(clockInListFive)){
                             for (XpClockIn xpClockIn : clockInListFive) {
-                                xpClockIn.setAppUserId(null);
                                 xpClockIn.setClockOutTime(LocalDateTime.now());
                                 xpClockIn.setClockOutResult(3);
                             }

--
Gitblit v1.7.1