1.修复管理查看到员工今日建联数量空指针的问题
This commit is contained in:
@@ -185,16 +185,31 @@ public class EmployeeHostsServiceImpl implements EmployeeHostsService {
|
||||
|
||||
List<CompletedRateVO> dbList = employeeHostsMapper.selectEmployeeHostsCompleteBarChart(userIdList);
|
||||
|
||||
// 2. 转 Map,key 是 userId
|
||||
Map<Long, CompletedRateVO> dbMap = dbList.stream()
|
||||
.collect(Collectors.toMap(CompletedRateVO::getUserId, Function.identity()));
|
||||
|
||||
// 3. 组装结果
|
||||
List<CompletedRateVO> result = userIdList.stream()
|
||||
.map(userId -> dbMap.getOrDefault(userId, new CompletedRateVO(userId, 0))) // 缺数据补0
|
||||
.collect(Collectors.toList());
|
||||
try {
|
||||
// 2. 转 Map,key 是 userId
|
||||
Map<Long, CompletedRateVO> dbMap = dbList.stream()
|
||||
.collect(Collectors.toMap(
|
||||
CompletedRateVO::getUserId,
|
||||
Function.identity(),
|
||||
(oldVal, newVal) -> newVal)); // 重复时保留新的
|
||||
// 3. 组装结果
|
||||
List<CompletedRateVO> result = userIdList.stream()
|
||||
.map(userId -> dbMap.getOrDefault(userId, new CompletedRateVO(userId, 0))) // 缺数据补0
|
||||
.collect(Collectors.toList());
|
||||
return result;
|
||||
} catch (Exception e) {
|
||||
ArrayList<CompletedRateVO> nullData = new ArrayList<>();
|
||||
for (Long userId : userIdList) {
|
||||
nullData.add(new CompletedRateVO(userId, 0));
|
||||
}
|
||||
return nullData;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user