This commit is contained in:
dinggang 2022-08-12 17:21:35 +08:00
parent 81e13e7824
commit ce07b0ea32
1 changed files with 9 additions and 15 deletions

View File

@ -1979,21 +1979,15 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
Map componentMap = new HashMap();
componentMap.put("title", "组件服务");
Map<String, List> map = new ConcurrentHashMap<>();
List<CompletableFuture> tasks = resourceTypeMap.get("组件服务").stream().map(it -> {
CompletableFuture task = CompletableFuture.runAsync(() -> {
selectAttrsByResourceId(Long.parseLong(it.get("id").toString())).stream().filter(temp -> "组件类型".equals(temp.getAttrType())).forEach(attr -> {
if (map.get(attr.getAttrValue()) != null) {
map.get(attr.getAttrValue()).add(it);
} else {
map.put(attr.getAttrValue(), Collections.synchronizedList(new ArrayList() {{
add(it);
}}));
}
});
}, executor);
return task;
}).collect(Collectors.toList());
CompletableFuture.allOf(tasks.toArray(new CompletableFuture[tasks.size()])).join();
CompletableFuture.allOf(resourceTypeMap.get("组件服务").stream().map(it -> CompletableFuture.runAsync(() -> selectAttrsByResourceId(Long.parseLong(it.get("id").toString())).stream().filter(temp -> "组件类型".equals(temp.getAttrType())).forEach(attr -> {
if (map.get(attr.getAttrValue()) != null) {
map.get(attr.getAttrValue()).add(it);
} else {
map.put(attr.getAttrValue(), (List) Collections.synchronizedList(new ArrayList() {{
add(it);
}}));
}
}), executor)).toArray(CompletableFuture[]::new)).join();
componentMap.put("children", map.entrySet().stream().map(it -> new HashMap() {{
put("title", it.getKey());
put("children", it.getValue());