|
@@ -2237,7 +2237,8 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
|
if (obj != null) {
|
|
|
List<Long> resultPKeyId = new ArrayList<>();
|
|
|
List<WbsTreeContractLazyVO> nodeAll = this.getNodeAll(obj.getContractId());
|
|
|
- this.recursionGetChildNodesPkeyIds(nodeAll, Collections.singletonList(obj.getId()), resultPKeyId, lowestNodesPkeyIds);
|
|
|
+ Map<Long, List<WbsTreeContractLazyVO>> map = nodeAll.stream().collect(Collectors.groupingBy(WbsTreeContractLazyVO::getParentId));
|
|
|
+ this.recursionGetChildNodesPkeyIds(map, Collections.singletonList(obj.getId()), resultPKeyId, lowestNodesPkeyIds);
|
|
|
if (resultPKeyId.size() > 0) {
|
|
|
return resultPKeyId;
|
|
|
}
|
|
@@ -2246,19 +2247,21 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
|
}
|
|
|
|
|
|
private void recursionGetChildNodesPkeyIds
|
|
|
- (List<WbsTreeContractLazyVO> nodeAll, List<Long> ids, List<Long> resultPKeyId, List<Long> lowestNodesPkeyIds) {
|
|
|
+ (Map<Long, List<WbsTreeContractLazyVO>> nodeAll, List<Long> ids, List<Long> resultPKeyId, List<Long> lowestNodesPkeyIds) {
|
|
|
if (ids.size() > 0) {
|
|
|
- List<WbsTreeContractLazyVO> sortedFilteredNodes = nodeAll.stream()
|
|
|
- .filter(f -> ids.contains(f.getParentId()))
|
|
|
- .sorted(Comparator.comparing(WbsTreeContractLazyVO::getSort, Comparator.nullsFirst(Comparator.naturalOrder()))
|
|
|
- .thenComparing(new ComplexStringComparator<>(obj -> obj.getFullName() != null ? obj.getFullName() : ""))
|
|
|
- .thenComparing(WbsTreeContractLazyVO::getCreateTime, Comparator.nullsLast(Comparator.reverseOrder())))
|
|
|
- .collect(Collectors.toList());
|
|
|
-
|
|
|
Map<Long, List<WbsTreeContractLazyVO>> filteredNodesMap = new LinkedHashMap<>();
|
|
|
- sortedFilteredNodes.forEach(node -> {
|
|
|
- Long parentId = node.getParentId();
|
|
|
- filteredNodesMap.computeIfAbsent(parentId, k -> new ArrayList<>()).add(node);
|
|
|
+ ids.forEach(id -> {
|
|
|
+ List<WbsTreeContractLazyVO> list = nodeAll.get(id);
|
|
|
+ if (list != null && !list.isEmpty()) {
|
|
|
+ List<WbsTreeContractLazyVO> collect = list.stream().sorted(Comparator.comparing(WbsTreeContractLazyVO::getSort, Comparator.nullsFirst(Comparator.naturalOrder()))
|
|
|
+ .thenComparing(new ComplexStringComparator<>(obj -> obj.getFullName() != null ? obj.getFullName() : ""))
|
|
|
+ .thenComparing(WbsTreeContractLazyVO::getCreateTime, Comparator.nullsLast(Comparator.reverseOrder())))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ collect.forEach(node -> {
|
|
|
+ Long parentId = node.getParentId();
|
|
|
+ filteredNodesMap.computeIfAbsent(parentId, k -> new ArrayList<>()).add(node);
|
|
|
+ });
|
|
|
+ }
|
|
|
});
|
|
|
|
|
|
for (Long id : ids) {
|
|
@@ -2268,9 +2271,9 @@ public class UserServiceImpl extends BaseServiceImpl<UserMapper, User> implement
|
|
|
if (node.getHasChildren().equals(0)) {
|
|
|
lowestNodesPkeyIds.add(node.getPKeyId());
|
|
|
}
|
|
|
+ this.recursionGetChildNodesPkeyIds(nodeAll, Collections.singletonList(node.getId()), resultPKeyId, lowestNodesPkeyIds);
|
|
|
resultPKeyId.add(node.getPKeyId());
|
|
|
}
|
|
|
- this.recursionGetChildNodesPkeyIds(nodeAll, nodes.stream().map(WbsTreeContractLazyVO::getId).collect(Collectors.toList()), resultPKeyId, lowestNodesPkeyIds);
|
|
|
}
|
|
|
}
|
|
|
}
|