同步知识库的优化
This commit is contained in:
parent
30b5ee12f0
commit
70c706ba73
|
@ -1224,8 +1224,7 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
if (list.isEmpty() || list.size() < pageSize) {
|
||||
end.set(false);
|
||||
}
|
||||
customThreadPool.submit(() -> {
|
||||
list.parallelStream().filter(resource -> {
|
||||
customThreadPool.submit(() -> list.parallelStream().filter(resource -> {
|
||||
Map<String, Object> map = (Map<String, Object>) resource;
|
||||
return !knowledgeUUID.contains(map.get("uuid").toString());
|
||||
}).forEach(resource -> {
|
||||
|
@ -1272,16 +1271,18 @@ public class ResourceServiceImpl extends CrudServiceImpl<ResourceDao, ResourceEn
|
|||
dto.setInfoList(infoList);
|
||||
this.insertWithAttrs(dto);
|
||||
logger.info("插入:{}", dto.getName());
|
||||
});
|
||||
}).join();
|
||||
})).join();
|
||||
customThreadPool.shutdown();
|
||||
}, executor));
|
||||
|
||||
if (maxPage.get() == 100) {
|
||||
try {
|
||||
Thread.sleep(100L); // 防止任务运行过快,无法跳出循环
|
||||
Thread.sleep(new Random().nextInt(100)); // 防止任务运行过快,无法跳出循环
|
||||
} catch (InterruptedException e) {
|
||||
logger.info("知识库同步异常", e);
|
||||
// throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
} while (end.get() || pageIndex.get() < maxPage.get());
|
||||
return task;
|
||||
}).collect(Collectors.toList());
|
||||
|
|
Loading…
Reference in New Issue