|
@@ -1552,7 +1552,7 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
* @param lowestNodeParentIds 最底层节点ParentIds
|
|
|
* @param nodesAll 所有节点
|
|
|
*/
|
|
|
- public void recursiveGetParentNodes(List<WbsTreeContractLazyVO> result, List<Long> lowestNodeParentIds, List<WbsTreeContractLazyVO> nodesAll) {
|
|
|
+ /*public void recursiveGetParentNodes(List<WbsTreeContractLazyVO> result, List<Long> lowestNodeParentIds, List<WbsTreeContractLazyVO> nodesAll) {
|
|
|
if (lowestNodeParentIds.isEmpty()) {
|
|
|
return;
|
|
|
}
|
|
@@ -1587,52 +1587,40 @@ public class WbsTreeContractServiceImpl extends BaseServiceImpl<WbsTreeContractM
|
|
|
result.addAll(multipleParentNodes);
|
|
|
this.recursiveGetParentNodes(result, collect, nodesAll);
|
|
|
}
|
|
|
- }
|
|
|
-
|
|
|
- /*public void recursiveGetParentNodes(List<WbsTreeContractLazyVO> result, List<Long> lowestNodeParentIds, List<WbsTreeContractLazyVO> nodesAll) {
|
|
|
+ }*/
|
|
|
+ public void recursiveGetParentNodes(List<WbsTreeContractLazyVO> result, List<Long> lowestNodeParentIds, List<WbsTreeContractLazyVO> nodesAll) {
|
|
|
if (lowestNodeParentIds.isEmpty()) {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- //并行粒度
|
|
|
- ForkJoinPool customThreadPool = new ForkJoinPool(4);
|
|
|
-
|
|
|
- //父级Id与出现的次数Map
|
|
|
- Map<Long, Long> parentIdGroup = lowestNodeParentIds.parallelStream()
|
|
|
+ Map<Long, Long> parentIdGroup = lowestNodeParentIds.stream()
|
|
|
.collect(Collectors.groupingByConcurrent(Function.identity(), Collectors.counting()));
|
|
|
|
|
|
- //批量查询单次节点
|
|
|
- CompletableFuture<List<WbsTreeContractLazyVO>> parentNodesFuture = CompletableFuture.supplyAsync(() ->
|
|
|
- parentIdGroup.entrySet().parallelStream()
|
|
|
- .filter(entry -> entry.getValue() == 1L)
|
|
|
- .flatMap(entry -> nodesAll.parallelStream()
|
|
|
- .filter(f -> entry.getKey().equals(f.getId())))
|
|
|
- .collect(Collectors.toList()), customThreadPool);
|
|
|
+ List<WbsTreeContractLazyVO> collectedNodes = parentIdGroup.entrySet().parallelStream()
|
|
|
+ .flatMap(entry -> {
|
|
|
+ List<WbsTreeContractLazyVO> nodes = nodesAll.stream()
|
|
|
+ .filter(f -> entry.getKey().equals(f.getId()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
|
- //批量查询多次节点
|
|
|
- CompletableFuture<List<WbsTreeContractLazyVO>> multipleParentNodesFuture = CompletableFuture.supplyAsync(() ->
|
|
|
- parentIdGroup.entrySet().parallelStream()
|
|
|
- .filter(entry -> entry.getValue() > 1L)
|
|
|
- .flatMap(entry -> nodesAll.parallelStream()
|
|
|
- .filter(f -> entry.getKey().equals(f.getId()))
|
|
|
- .limit(1)
|
|
|
- .flatMap(node -> Collections.nCopies(entry.getValue().intValue(), node).parallelStream()))
|
|
|
- .collect(Collectors.toList()), customThreadPool);
|
|
|
+ if (entry.getValue() > 1L) {
|
|
|
+ nodes = nodes.stream().limit(1)
|
|
|
+ .flatMap(node -> Collections.nCopies(entry.getValue().intValue(), node).stream())
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
|
|
|
- //结果集
|
|
|
- CompletableFuture<List<Long>> collectFuture = parentNodesFuture.thenCombine(multipleParentNodesFuture, (parentNodes, multipleParentNodes) ->
|
|
|
- Stream.concat(parentNodes.parallelStream(), multipleParentNodes.parallelStream())
|
|
|
- .map(WbsTreeContractLazyVO::getParentId)
|
|
|
- .collect(Collectors.toList()));
|
|
|
+ return nodes.stream();
|
|
|
+ })
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
|
- List<Long> collect = collectFuture.join();
|
|
|
+ List<Long> collect = collectedNodes.stream()
|
|
|
+ .map(WbsTreeContractLazyVO::getParentId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
|
|
|
if (!collect.isEmpty()) {
|
|
|
- result.addAll(parentNodesFuture.join());
|
|
|
- result.addAll(multipleParentNodesFuture.join());
|
|
|
+ result.addAll(collectedNodes);
|
|
|
this.recursiveGetParentNodes(result, collect, nodesAll);
|
|
|
}
|
|
|
- }*/
|
|
|
+ }
|
|
|
|
|
|
@Override
|
|
|
public boolean syncTabData(String pKeyId) throws Exception {
|