|
@@ -85,8 +85,8 @@ public class AuthOrgTreeServiceImpl implements IAuthOrgTreeService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void updateTreeByCode(List<String> updateOrgCodes, boolean async) {
|
|
|
- Runnable runnable = () -> updateTask(updateOrgCodes);
|
|
|
+ public void updateTreeByCode(List<String> updateOrgCodes, List<AuthOrgInfo> delOrgInfos, boolean async) {
|
|
|
+ Runnable runnable = () -> updateTask(updateOrgCodes, delOrgInfos);
|
|
|
if (async) {
|
|
|
Thread thread = new Thread(runnable);
|
|
|
thread.start();
|
|
@@ -94,10 +94,14 @@ public class AuthOrgTreeServiceImpl implements IAuthOrgTreeService {
|
|
|
runnable.run();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- private void updateTask(List<String> updateOrgCodes) {
|
|
|
+ private void updateTask(List<String> updateOrgCodes, List<AuthOrgInfo> delOrgInfos) {
|
|
|
+ // 被删除的上机构(如果上级机构没有一起被删除的话)也需要加入更新的机构集合中
|
|
|
+ List<String> delUpOrgCodes = delOrgInfos.stream()
|
|
|
+ .map(AuthOrgInfo::getUpGovCode)
|
|
|
+ .distinct()
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ updateOrgCodes.addAll(delUpOrgCodes);
|
|
|
List<AuthOrgInfo> updateOrgInfos = authOrgInfoService.getOrgByCodes(updateOrgCodes);
|
|
|
- Set<String> existOrgCodes = updateOrgInfos.stream().map(AuthOrgInfo::getCode).collect(Collectors.toSet());
|
|
|
//构建需要更新的树节点
|
|
|
List<OrgTreeNodeDTO> treeNods = getTreeNods(updateOrgInfos);
|
|
|
|
|
@@ -121,10 +125,10 @@ public class AuthOrgTreeServiceImpl implements IAuthOrgTreeService {
|
|
|
}
|
|
|
});
|
|
|
//过滤删除的机构
|
|
|
- List<String> delCodes = updateOrgCodes.stream()
|
|
|
- .filter(e -> !existOrgCodes.contains(e))
|
|
|
+ List<String> delOrgCodes = delOrgInfos.stream()
|
|
|
+ .map(AuthOrgInfo::getCode)
|
|
|
.collect(Collectors.toList());
|
|
|
- holder.updateTreeNodes(treeNods, delCodes);
|
|
|
+ holder.updateTreeNodes(treeNods, delOrgCodes);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -375,6 +379,7 @@ public class AuthOrgTreeServiceImpl implements IAuthOrgTreeService {
|
|
|
List<OrgTreeNodeDTO> selfNodes = orgIds.stream().map(treeNodeMap::get).collect(Collectors.toList());
|
|
|
List<OrgTreeNodeDTO> collect = selfNodes
|
|
|
.stream()
|
|
|
+ .filter(Objects::nonNull)
|
|
|
.map(OrgTreeNodeDTO::getChildIds)
|
|
|
.flatMap(List::stream)
|
|
|
.distinct()
|