融合服务-数据资源bug修复

This commit is contained in:
Koi-tsk 2022-08-29 10:08:10 +08:00
parent 0f20088c46
commit 13934c1da9
1 changed files with 31 additions and 17 deletions

View File

@ -168,10 +168,11 @@ public class TbFuseServiceImpl extends CrudServiceImpl<TbFuseDao, TbFuseEntity,
AtomicInteger pageIndex = new AtomicInteger(1);
AtomicBoolean end = new AtomicBoolean(true);
List<CompletableFuture> completableFutures=new CopyOnWriteArrayList<>();
while(end.get()){
do {
completableFutures.add(CompletableFuture.supplyAsync(()->{
Optional<AbstractDataResourceService> factory = DataResourceFactory.build();
if (factory.isPresent()) {
try {
GetDataResourceListDto dto=new GetDataResourceListDto().setPageNum(pageIndex.get()).setPageSize(pageSize);
Map<String, Object> dataResource = (Map<String, Object>) factory.get().getDataResource(dto);
if(!dataResource.isEmpty()){
@ -185,14 +186,27 @@ public class TbFuseServiceImpl extends CrudServiceImpl<TbFuseDao, TbFuseEntity,
}
}), list);}};
}
} catch (Exception e) {
logger.info("获取数据资源异常:", e);
end.set(false);
}
return null;
}
return new HashMap<>();
}).thenAcceptAsync(map->{
if(map != null){
if(!map.isEmpty()){
result.putAll(map);
}else{
end.set(false);
}
}));
try {
Thread.sleep(300); // 防止任务运行过快无法跳出循环
} catch (InterruptedException e) {
logger.info("获取数据资源异常", e);
}
} while(end.get());
return result;
}
@ -204,7 +218,7 @@ public class TbFuseServiceImpl extends CrudServiceImpl<TbFuseDao, TbFuseEntity,
List<TbFuseResourceEntity> list = fuseResourceDao.selectList(wrapper);
Map<String, List<TbFuseResourceEntity>> resourceMap = list.stream().filter(index -> index.getType() != null).collect(Collectors.groupingBy(TbFuseResourceEntity::getType));
if (resourceMap.containsKey("数据资源")) {
//dataResourceMap.putAll(getDataResource());
dataResourceMap.putAll(getDataResource());
}
resourceMap.forEach((type, value) -> {
if ("组件服务".equals(type)) {