|  | @@ -30,6 +30,7 @@ import com.xunmei.system.mapper.SysOrgMapper;
 | 
	
		
			
				|  |  |  import com.xunmei.system.mapper.SysRoleMapper;
 | 
	
		
			
				|  |  |  import com.xunmei.system.service.ISysDeptService;
 | 
	
		
			
				|  |  |  import com.xunmei.system.service.ISysOrgService;
 | 
	
		
			
				|  |  | +import org.apache.commons.lang3.ObjectUtils;
 | 
	
		
			
				|  |  |  import org.springframework.beans.factory.annotation.Autowired;
 | 
	
		
			
				|  |  |  import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -148,7 +149,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
 | 
	
		
			
				|  |  |       * @return
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  | -    public List<SysOrgVO> selectTreeByOrgType(Boolean includeUp,Boolean includeBangshichu, OrgTypeEnum orgType) {
 | 
	
		
			
				|  |  | +    public List<SysOrgVO> selectTreeByOrgType(Boolean includeUp, Boolean includeBangshichu, OrgTypeEnum orgType) {
 | 
	
		
			
				|  |  |          String path = "";
 | 
	
		
			
				|  |  |          SysOrg sysOrg = getLoginUserOrg();
 | 
	
		
			
				|  |  |          path = sysOrg.getPath();
 | 
	
	
		
			
				|  | @@ -157,8 +158,8 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          List<SysOrgVO> orglist = getWholePathInCache(includeUp, path, orgType);
 | 
	
		
			
				|  |  | -        if(!includeBangshichu){
 | 
	
		
			
				|  |  | -            orglist=orglist.stream().filter(o->ObjectUtil.notEqual(o.getType(),OrgTypeEnum.BAN_SHI_CHU.getCode()))
 | 
	
		
			
				|  |  | +        if (!includeBangshichu) {
 | 
	
		
			
				|  |  | +            orglist = orglist.stream().filter(o -> ObjectUtil.notEqual(o.getType(), OrgTypeEnum.BAN_SHI_CHU.getCode()))
 | 
	
		
			
				|  |  |                      .collect(Collectors.toList());
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          List<SysOrgVO> r = generateTree(orglist, sysOrg);
 | 
	
	
		
			
				|  | @@ -167,18 +168,19 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 获取本机构及下级机构,且上级机构若与本机构同类型,也获取
 | 
	
		
			
				|  |  | +     *
 | 
	
		
			
				|  |  |       * @return
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  | -    public List<SysOrgVO> deptTreeWithSametypeUp(){
 | 
	
		
			
				|  |  | -        Map<Long,SysOrgVO> cacheList = getOrgCache().stream().collect(Collectors.toMap(SysOrgVO::getId,vo->vo));
 | 
	
		
			
				|  |  | -        Long orgId= SecurityUtils.getLoginUser().getOrgId();
 | 
	
		
			
				|  |  | -        if(!cacheList.containsKey(orgId)){
 | 
	
		
			
				|  |  | -            return  new ArrayList<>();
 | 
	
		
			
				|  |  | +    public List<SysOrgVO> deptTreeWithSametypeUp() {
 | 
	
		
			
				|  |  | +        Map<Long, SysOrgVO> cacheList = getOrgCache().stream().collect(Collectors.toMap(SysOrgVO::getId, vo -> vo));
 | 
	
		
			
				|  |  | +        Long orgId = SecurityUtils.getLoginUser().getOrgId();
 | 
	
		
			
				|  |  | +        if (!cacheList.containsKey(orgId)) {
 | 
	
		
			
				|  |  | +            return new ArrayList<>();
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        SysOrgVO sysOrgVO =cacheList.get(orgId);
 | 
	
		
			
				|  |  | -        List<SysOrgVO> orgs=new ArrayList<>();
 | 
	
		
			
				|  |  | +        SysOrgVO sysOrgVO = cacheList.get(orgId);
 | 
	
		
			
				|  |  | +        List<SysOrgVO> orgs = new ArrayList<>();
 | 
	
		
			
				|  |  |          for (SysOrgVO org : cacheList.values()) {
 | 
	
		
			
				|  |  |              String path = org.getPath();
 | 
	
		
			
				|  |  |              if (StringUtils.isEmpty(path) || !path.startsWith(sysOrgVO.getPath())) {
 | 
	
	
		
			
				|  | @@ -194,12 +196,12 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
 | 
	
		
			
				|  |  |              orgs.add(org);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        SysOrgVO parentVo=cacheList.get(sysOrgVO.getParentId());
 | 
	
		
			
				|  |  | -        while(ObjectUtil.isNotNull(parentVo) && ObjectUtil.equal(parentVo.getType(), sysOrgVO.getType())){
 | 
	
		
			
				|  |  | +        SysOrgVO parentVo = cacheList.get(sysOrgVO.getParentId());
 | 
	
		
			
				|  |  | +        while (ObjectUtil.isNotNull(parentVo) && ObjectUtil.equal(parentVo.getType(), sysOrgVO.getType())) {
 | 
	
		
			
				|  |  |              orgs.add(parentVo);
 | 
	
		
			
				|  |  | -            sysOrgVO=parentVo;
 | 
	
		
			
				|  |  | +            sysOrgVO = parentVo;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -            parentVo=cacheList.get(sysOrgVO.getParentId());
 | 
	
		
			
				|  |  | +            parentVo = cacheList.get(sysOrgVO.getParentId());
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          SysOrg sysOrg = orgMapper.selectById(sysOrgVO.getId());
 | 
	
	
		
			
				|  | @@ -219,7 +221,7 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
 | 
	
		
			
				|  |  |                  excludeOrg = first.get();
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        if(excludeOrg == null){
 | 
	
		
			
				|  |  | +        if (excludeOrg == null) {
 | 
	
		
			
				|  |  |              return null;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -309,8 +311,8 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public List<SysOrgVO> hangsheWholePath(Long orgId) {
 | 
	
		
			
				|  |  | -        SysOrg org= orgService.getById(orgId);
 | 
	
		
			
				|  |  | -        List<SysOrgVO> orgs = getWholePathInCache(true,org.getPath(), OrgTypeEnum.HANG_SHE);
 | 
	
		
			
				|  |  | +        SysOrg org = orgService.getById(orgId);
 | 
	
		
			
				|  |  | +        List<SysOrgVO> orgs = getWholePathInCache(true, org.getPath(), OrgTypeEnum.HANG_SHE);
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          return orgs;
 | 
	
		
			
				|  |  |      }
 | 
	
	
		
			
				|  | @@ -496,7 +498,11 @@ public class SysDeptServiceImpl extends ServiceImpl<SysDeptMapper, SysDept> impl
 | 
	
		
			
				|  |  |      public List<SysOrg> buildDeptTree(List<SysOrg> depts) {
 | 
	
		
			
				|  |  |          List<SysOrg> returnList = new ArrayList<SysOrg>();
 | 
	
		
			
				|  |  |          List<Long> tempList = depts.stream().map(SysOrg::getId).collect(Collectors.toList());
 | 
	
		
			
				|  |  | -        Set<Long> sts = new HashSet<>(tempList);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        Set<Long> sts = new HashSet<>();
 | 
	
		
			
				|  |  | +        if (ObjectUtils.isNotEmpty(tempList)) {
 | 
	
		
			
				|  |  | +            sts.addAll(tempList);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |          for (SysOrg dept : depts) {
 | 
	
		
			
				|  |  |              // 如果是顶级节点, 遍历该父节点的所有子节点
 | 
	
		
			
				|  |  |              if (!sts.contains(dept.getParentId())) {
 |