From e56de5c2263a887631382b96e8ee35fe03257cc4 Mon Sep 17 00:00:00 2001
From: xuhy <3313886187@qq.com>
Date: 星期日, 01 三月 2026 00:25:19 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/service/impl/XpClockInServiceImpl.java |   42 +++++++++++++++++++++++++-----------------
 1 files changed, 25 insertions(+), 17 deletions(-)

diff --git a/xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/service/impl/XpClockInServiceImpl.java b/xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/service/impl/XpClockInServiceImpl.java
index 7b3ba86..fed04e9 100644
--- a/xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/service/impl/XpClockInServiceImpl.java
+++ b/xp-robotaxi-maintenance-boot/src/main/java/com/xiaopeng/maintenance/service/impl/XpClockInServiceImpl.java
@@ -1,8 +1,10 @@
 package com.xiaopeng.maintenance.service.impl;
 
+import cn.hutool.core.collection.CollUtil;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.xiaopeng.api.feignClient.account.XpOperationUserClient;
+import com.xiaopeng.api.model.account.SysRole;
 import com.xiaopeng.api.model.account.XpOperationsRole;import com.xiaopeng.api.model.account.XpOperationsUser;import com.xiaopeng.api.model.maintenance.XpCheckLocation;
 import com.xiaopeng.api.model.maintenance.XpClockIn;
 import com.xiaopeng.api.model.maintenance.XpShift;
@@ -41,6 +43,7 @@
 import java.time.LocalDateTime;
 import java.time.LocalTime;
 import java.util.List;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 
 /**
@@ -231,7 +234,7 @@
                 List<Long> collect = listR.getData().stream().map(XpOperationsUser::getId).collect(Collectors.toList());
                 appUserIds.addAll(collect);
             }
-
+            appUserIds.add(0L);
         }
         if(null != query.getRoleId()){
             R<List<XpOperationsRole>> roleByRoleId = xpOperationUserClient.getXpOperationsRoleByRoleId(query.getRoleId());
@@ -239,6 +242,7 @@
                 List<Long> collect = roleByRoleId.getData().stream().map(XpOperationsRole::getOperationsUserId).collect(Collectors.toList());
                 appUserIds.addAll(collect);
             }
+            appUserIds.add(0L);
         }
 
         String startTime = "";
@@ -253,17 +257,19 @@
         List<String> appUserIdList = clockInStatistics.stream().map(ClockInStatisticsDto::getAppUserId).collect(Collectors.toList());
         List<Long> ids = appUserIdList.stream().map(Long::parseLong).collect(Collectors.toList());
         List<XpOperationsUserWithRoleVO> data = xpOperationUserClient.listByIdsWithRole(ids).getData();
+        Map<Long, XpOperationsUserWithRoleVO> userMap = data.stream().collect(Collectors.toMap(XpOperationsUserWithRoleVO::getId, Function.identity()));
         //将查询结果组装成map对象,用于循环中提取数据
         for (ClockInStatisticsDto clockInStatistic : clockInStatistics) {
             String appUserId = clockInStatistic.getAppUserId();
             //运维账号可以拥有多个角色
-            List<XpOperationsUserWithRoleVO> collect = data.stream().filter(x->x.getId().equals(Long.parseLong(appUserId))).collect(Collectors.toList());
-            if(!collect.isEmpty()){
-                XpOperationsUserWithRoleVO xpOperationsUserWithRoleVO = collect.get(0);
-                clockInStatistic.setName(xpOperationsUserWithRoleVO.getNickName());
+            if(CollUtil.isNotEmpty(userMap)){
+                XpOperationsUserWithRoleVO vo = userMap.get(Long.parseLong(appUserId));
+                if (Objects.nonNull(vo)) {
+                    clockInStatistic.setName(vo.getNickName());
+                    String roleName = vo.getRoles().stream().map(SysRole::getRoleName).collect(Collectors.joining(";"));
+                    clockInStatistic.setRoleName(roleName);
+                }
             }
-            String roleName = collect.stream().map(XpOperationsUserWithRoleVO::getRoleName).collect(Collectors.joining(";"));
-            clockInStatistic.setRoleName(roleName);
             Integer shouldClockInDays = clockInStatistic.getShouldClockInDays();
             Integer clockInDays = clockInStatistic.getClockInDays();
             clockInStatistic.setNotClockInDays(shouldClockInDays - clockInDays);
@@ -289,7 +295,7 @@
                 List<Long> collect = listR.getData().stream().map(XpOperationsUser::getId).collect(Collectors.toList());
                 appUserIds.addAll(collect);
             }
-
+            appUserIds.add(0L);
         }
         if(null != query.getRoleId()){
             R<List<XpOperationsRole>> roleByRoleId = xpOperationUserClient.getXpOperationsRoleByRoleId(query.getRoleId());
@@ -297,8 +303,8 @@
                 List<Long> collect = roleByRoleId.getData().stream().map(XpOperationsRole::getOperationsUserId).collect(Collectors.toList());
                 appUserIds.addAll(collect);
             }
+            appUserIds.add(0L);
         }
-
         String startTime = "";
         String endTime = "";
         if(StringUtils.isNotEmpty(query.getStatisticDate())){
@@ -311,16 +317,18 @@
         List<String> appUserIdList = clockInStatistics.stream().map(ClockInStatisticsDto::getAppUserId).collect(Collectors.toList());
         List<Long> ids = appUserIdList.stream().map(Long::parseLong).collect(Collectors.toList());
         List<XpOperationsUserWithRoleVO> data = xpOperationUserClient.listByIdsWithRole(ids).getData();
+        Map<Long, XpOperationsUserWithRoleVO> userMap = data.stream().collect(Collectors.toMap(XpOperationsUserWithRoleVO::getId, Function.identity()));
         for (ClockInStatisticsDto clockInStatistic : clockInStatistics) {
             String appUserId = clockInStatistic.getAppUserId();
             //运维账号可以拥有多个角色
-            List<XpOperationsUserWithRoleVO> collect = data.stream().filter(x->x.getId().equals(Long.parseLong(appUserId))).collect(Collectors.toList());
-            if(!collect.isEmpty()){
-                XpOperationsUserWithRoleVO xpOperationsUserWithRoleVO = collect.get(0);
-                clockInStatistic.setName(xpOperationsUserWithRoleVO.getNickName());
+            if(CollUtil.isNotEmpty(userMap)){
+                XpOperationsUserWithRoleVO vo = userMap.get(Long.parseLong(appUserId));
+                if (Objects.nonNull(vo)) {
+                    clockInStatistic.setName(vo.getNickName());
+                    String roleName = vo.getRoles().stream().map(SysRole::getRoleName).collect(Collectors.joining(";"));
+                    clockInStatistic.setRoleName(roleName);
+                }
             }
-            String roleName = collect.stream().map(XpOperationsUserWithRoleVO::getRoleName).collect(Collectors.joining(";"));
-            clockInStatistic.setRoleName(roleName);
             Integer shouldClockInDays = clockInStatistic.getShouldClockInDays();
             Integer clockInDays = clockInStatistic.getClockInDays();
             clockInStatistic.setNotClockInDays(shouldClockInDays - clockInDays);
@@ -356,7 +364,7 @@
         //将查询结果组装成map对象,用于循环中提取数据
         for (ClockInStatisticsDetailsDto clockInStatistic : clockInStatisticsDetails) {
             clockInStatistic.setName(xpOperationsUserWithRoleVO.getNickName());
-            clockInStatistic.setRoleName(xpOperationsUserWithRoleVO.getRoleName());
+            clockInStatistic.setRoleName(xpOperationsUserWithRoleVO.getRoles().stream().map(SysRole::getRoleName).collect(Collectors.joining(";")));
         }
         pageInfo.setRecords(clockInStatisticsDetails);
         return pageInfo;
@@ -385,7 +393,7 @@
         //将查询结果组装成map对象,用于循环中提取数据
         for (ClockInStatisticsDetailsDto clockInStatistic : clockInStatisticsDetails) {
             clockInStatistic.setName(xpOperationsUserWithRoleVO.getNickName());
-            clockInStatistic.setRoleName(xpOperationsUserWithRoleVO.getRoleName());
+            clockInStatistic.setRoleName(xpOperationsUserWithRoleVO.getRoles().stream().map(SysRole::getRoleName).collect(Collectors.joining(";")));
         }
 
         ExcelUtil<ClockInStatisticsDetailsDto> excel = new ExcelUtil<ClockInStatisticsDetailsDto>(ClockInStatisticsDetailsDto.class);

--
Gitblit v1.7.1