| | |
| | | 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)){ |
| | | 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(); |
| | | // 通过车队id和已过期的班次获取排班明细 |
| | | List<XpSchedulingDetail> clockOutPlanExpiredList = clockOutPlanList.stream() |
| | | .filter(xpSchedulingDetail -> xpSchedulingDetail.getFleetId().equals(fleetId) |
| | | && ids.contains(xpSchedulingDetail.getShiftId())).collect(Collectors.toList()); |
| | | if(!CollectionUtils.isEmpty(clockOutPlanExpiredList)){ |
| | | && ids.contains(xpSchedulingDetail.getShiftId())) |
| | | .collect(Collectors.toList()); |
| | | if(CollectionUtils.isEmpty(clockOutPlanExpiredList)){ |
| | | continue; |
| | | } |
| | | 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); |
| | | boolean created = xpClockInService.createMissingClockInIfAbsent(operationsUserId, shiftId, LocalDate.now()); |
| | | if (created) { |
| | | createdCount++; |
| | | } |
| | | } |
| | | } |
| | | if (!CollectionUtils.isEmpty(noClockInList)){ |
| | | log.info("添加上班缺卡信息:{}", noClockInList); |
| | | xpClockInService.saveBatch(noClockInList); |
| | | } |
| | | log.info("========== 新增上班缺卡记录{}条 ==========", createdCount); |
| | | } |
| | | } |
| | | |
| | |
| | | for (XpClockIn xpClockIn : clockInListFive) { |
| | | xpClockIn.setClockOutTime(LocalDateTime.now()); |
| | | xpClockIn.setClockOutResult(3); |
| | | xpClockIn.setAppUserId(null); |
| | | } |
| | | xpClockInService.updateBatchById(clockInListFive); |
| | | log.info("========== 修改为下班缺卡 =========="); |
| | |
| | | log.info("========== 获取到{}个人员没有下班打卡信息 ==========", clockInListFive.size()); |
| | | if(!CollectionUtils.isEmpty(clockInListFive)){ |
| | | for (XpClockIn xpClockIn : clockInListFive) { |
| | | xpClockIn.setAppUserId(null); |
| | | xpClockIn.setClockOutTime(LocalDateTime.now()); |
| | | xpClockIn.setClockOutResult(3); |
| | | } |