liujie
2026-06-09 c96fbe6b0aeb413a17c429133ee6d81d138144b9
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);
                            }