|
|
@@ -149,14 +149,14 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public List<SysOrgVO> selectBusinessTreeList(String excludeOrgCode) {
|
|
|
+ public List<SysOrgVO> selectBusinessTreeList(SysOrgTreeRequestDto request) {
|
|
|
SysOrg sysOrg = null;
|
|
|
SysOrgVO excludeOrg = null;
|
|
|
sysOrg = getLoginUserOrg();
|
|
|
List<SysOrgVO> cacheList = getOrgCache();
|
|
|
List<SysOrgVO> orgs = new ArrayList<>();
|
|
|
- if(StringUtils.isNotEmpty(excludeOrgCode)){
|
|
|
- final Optional<SysOrgVO> first = cacheList.stream().filter(x -> ObjectUtil.equal(x.getCode(), excludeOrgCode)).findFirst();
|
|
|
+ if(StringUtils.isNotEmpty(request.getExcludeOrgCode())){
|
|
|
+ final Optional<SysOrgVO> first = cacheList.stream().filter(x -> ObjectUtil.equal(x.getCode(), request.getExcludeOrgCode())).findFirst();
|
|
|
if(first.isPresent())
|
|
|
{
|
|
|
excludeOrg=first.get();
|
|
|
@@ -181,10 +181,40 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
|
|
}
|
|
|
orgs.add(org);
|
|
|
}
|
|
|
+ if(!StringUtils.isEmpty(request.getExcludeOrgName()))
|
|
|
+ {
|
|
|
+ orgs= excludeOrgByOrgName(orgs,request.getExcludeOrgName());
|
|
|
+ }
|
|
|
+
|
|
|
return generateTree(orgs, sysOrg);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
+ * 排除指定机构名称的机构以及该机构的下级机构
|
|
|
+ * @param orgs 待排出机构列表
|
|
|
+ * @param excludeOrgName 需排出机构的名称
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private List<SysOrgVO> excludeOrgByOrgName(List<SysOrgVO> orgs,String excludeOrgName)
|
|
|
+ {
|
|
|
+ List<SysOrgVO> result = new ArrayList<>();
|
|
|
+
|
|
|
+ final List<SysOrgVO> excludeOrgList = orgs.stream().filter(x -> ObjectUtil.equal(x.getName(), excludeOrgName)).collect(Collectors.toList());
|
|
|
+ if(ObjectUtil.isEmpty(excludeOrgList))
|
|
|
+ {
|
|
|
+ return orgs;
|
|
|
+ }
|
|
|
+ for (SysOrgVO org : orgs) {
|
|
|
+ if(excludeOrgList.stream().anyMatch(e-> org.getPath().startsWith(e.getPath())))
|
|
|
+ {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ result.add(org);
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
* 获取缓存的行社及行社上级机构
|
|
|
*
|
|
|
* @param path
|
|
|
@@ -265,7 +295,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
|
|
|
- final List<SysOrgVO> orgList = getWholePathTreeOrgFromCache(sysOrg, cacheList,request.getIncludeSub());
|
|
|
+ final List<SysOrgVO> orgList = getWholePathTreeOrgFromCache(sysOrg, cacheList,request.getIncludeSub(),request.getExcludeOrgName());
|
|
|
|
|
|
return generateTree(orgList,null);
|
|
|
}
|
|
|
@@ -276,7 +306,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
|
|
* @param cacheList
|
|
|
* @return
|
|
|
*/
|
|
|
- public List<SysOrgVO> getWholePathTreeOrgFromCache(SysOrgVO orgVO,List<SysOrgVO> cacheList,Boolean includeSub) {
|
|
|
+ public List<SysOrgVO> getWholePathTreeOrgFromCache(SysOrgVO orgVO,List<SysOrgVO> cacheList,Boolean includeSub,String excludeOrgName) {
|
|
|
List<SysOrgVO> selfAndAllChildOrglist =null;
|
|
|
if(includeSub)
|
|
|
{
|
|
|
@@ -286,6 +316,8 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
|
|
selfAndAllChildOrglist=cacheList.stream().filter(c ->ObjectUtil.equal(orgVO.getId(),c.getId())).collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
Set<Long> parentIds = new HashSet<>();
|
|
|
Arrays.stream(orgVO.getPath().split("-")).map(p -> Long.parseLong(p))
|
|
|
.collect(Collectors.toList())
|
|
|
@@ -298,6 +330,13 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
|
|
|
.filter(o -> parentIds.contains(o.getId()))
|
|
|
.collect(Collectors.toList()));
|
|
|
|
|
|
+ // 排除指定机构名称的机构以及该机构的下级机构
|
|
|
+ if(StringUtils.isNotEmpty(excludeOrgName))
|
|
|
+ {
|
|
|
+ selfAndAllChildOrglist= excludeOrgByOrgName(selfAndAllChildOrglist,excludeOrgName);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
return selfAndAllChildOrglist;
|
|
|
}
|
|
|
|