fix: 分润,讨论后,发现问题统一修复。
This commit is contained in:
@@ -304,7 +304,7 @@ public class ProfitTask {
|
||||
|
||||
Map<String, List<SharingUserTaskVo>> result = new HashMap<>();
|
||||
collect.forEach((k, v) -> {
|
||||
List<SharingUserTaskVo> distinctList = v.stream().distinct().collect(Collectors.toList());
|
||||
List<SharingUserTaskVo> distinctList = distinctByUserId(v);
|
||||
List<SharingUserTaskVo> newList = new ArrayList<>();
|
||||
for (SharingUserTaskVo e : distinctList) {
|
||||
if (e != null && e.getParentId() != null) {
|
||||
@@ -313,7 +313,7 @@ public class ProfitTask {
|
||||
newList.add(e);
|
||||
}
|
||||
}
|
||||
result.put(k, newList.stream().distinct().collect(Collectors.toList()));
|
||||
result.put(k, distinctByUserId(newList));
|
||||
});
|
||||
|
||||
return result;
|
||||
@@ -325,8 +325,8 @@ public class ProfitTask {
|
||||
|
||||
// 预处理数据,提高查找效率
|
||||
Map<Long, SharingUserTaskVo> userTaskMap = sharingUserTaskVos.stream()
|
||||
.filter(f -> f != null && f.getDeptId() != null)
|
||||
.collect(Collectors.toMap(SharingUserTaskVo::getDeptId, f -> f, (existing, replacement) -> existing));
|
||||
.filter(f -> f != null && f.getUserId() != null)
|
||||
.collect(Collectors.toMap(SharingUserTaskVo::getUserId, f -> f, (existing, replacement) -> existing));
|
||||
|
||||
Set<Long> visited = new HashSet<>(); // 防止循环引用导致的无限循环
|
||||
|
||||
@@ -354,4 +354,19 @@ public class ProfitTask {
|
||||
|
||||
return resultList;
|
||||
}
|
||||
|
||||
private List<SharingUserTaskVo> distinctByUserId(List<SharingUserTaskVo> list) {
|
||||
Map<Long, SharingUserTaskVo> map = new LinkedHashMap<>();
|
||||
for (SharingUserTaskVo item : list) {
|
||||
if (item == null) {
|
||||
continue;
|
||||
}
|
||||
Long userId = item.getUserId();
|
||||
if (userId == null) {
|
||||
continue;
|
||||
}
|
||||
map.putIfAbsent(userId, item);
|
||||
}
|
||||
return new ArrayList<>(map.values());
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user