| 
					
				 | 
			
			
				@@ -10,9 +10,12 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.xunmei.common.core.constant.CacheConstants; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.xunmei.common.core.constant.Constants; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.xunmei.common.core.constant.ErrorMsgConstants; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.xunmei.common.core.domain.OrgTreeReq; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.xunmei.common.core.domain.OrgTreeResp; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.xunmei.common.core.enums.OrgTypeEnum; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.xunmei.common.core.exception.ServiceException; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.xunmei.common.core.util.BeanHelper; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.xunmei.common.core.utils.DateUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.xunmei.common.core.web.page.TableDataInfo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.xunmei.common.redis.utils.RedisUtils; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -30,7 +33,6 @@ import org.springframework.transaction.annotation.Transactional; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import javax.annotation.PostConstruct; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.*; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.stream.Collectors; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.stream.Stream; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  * 【请填写功能名称】Service业务层处理 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -461,17 +463,17 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         String queryOrgPath = idPathMap.get(queryOrgId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (req.getCheckSub()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             //1.如果当前机构是查询机构的上级机构,那么应查询当前机构到 查询机构之间的所有机构id,与当前机构的所有下级 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (curOrgPath.startsWith(queryOrgPath) && ObjectUtil.notEqual(curOrgPath,queryOrgPath)){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (curOrgPath.startsWith(queryOrgPath) && ObjectUtil.notEqual(curOrgPath, queryOrgPath)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 List<Long> list = Arrays.stream(curOrgPath.split("-")).map(Long::valueOf).collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 int queryOrgIdIdx = list.indexOf(queryOrgId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 int curOrgIdIdx = list.indexOf(curOrgId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 //移除list中queryOrgId元素 之前的数据 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                list = ListUtil.sub(list,queryOrgIdIdx, curOrgIdIdx+1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                list = ListUtil.sub(list, queryOrgIdIdx, curOrgIdIdx + 1); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 //移除当前机构id,当前机构的数据以path字段查询 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 list.remove(curOrgId); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 resp.setOrgIdList(list); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 resp.setOrgPath(curOrgPath); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            }else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 resp.setOrgPath(queryOrgPath); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             return resp; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -488,4 +490,47 @@ public class SysOrgServiceImpl extends ServiceImpl<SysOrgMapper, SysOrg> impleme 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         return resp; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Override 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public List<SysOrg> selectOrgTreeListByCurOrgId(Long id) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        SysOrg org = getById(id); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (ObjectUtil.hasEmpty(org, org.getType())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            throw new ServiceException(ErrorMsgConstants.CUR_USER_ORT_TYPE_ERROR); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<SysOrgVO> sysOrgList = RedisUtils.getCacheList(CacheConstants.ORG_CACHE_LIST_KEY); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        sysOrgList.forEach(sysOrg -> { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (ObjectUtil.isNull(sysOrg.getSort())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                sysOrg.setSort(0); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (ObjectUtil.isNotEmpty(sysOrg.getShortName())){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                sysOrg.setName(sysOrg.getShortName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        }); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        sysOrgList.removeIf(sysOrg -> ObjectUtil.isEmpty(sysOrg.getPath()) || sysOrg.getName().contains("各部门")); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        OrgTypeEnum orgTypeEnum = OrgTypeEnum.getOrgTypeEnum(org.getType()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<SysOrgVO> result = new ArrayList<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        switch (orgTypeEnum) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            case SHEGN_LIAN_SHE: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                result = sysOrgList.stream() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        .filter(sysOrg -> ObjectUtil.equal(sysOrg.getType(), OrgTypeEnum.DIQU_HANG_SHE.getCode())) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        .filter(sysOrg -> sysOrg.getName().contains("地区行社")) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        .sorted(Comparator.comparing(SysOrgVO::getSort)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        .collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            case BAN_SHI_CHU: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                result = sysOrgList.stream() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        .filter(sysOrg -> sysOrg.getPath().startsWith(org.getPath())) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        .filter(sysOrg -> ObjectUtil.equal(sysOrg.getType(), OrgTypeEnum.HANG_SHE.getCode())) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        .sorted(Comparator.comparing(SysOrgVO::getSort)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        .collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                break; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            default: 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                result = sysOrgList.stream() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        .filter(sysOrg -> ObjectUtil.equal(sysOrg.getParentId(), org.getId())) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        //.filter(sysOrg -> sysOrg.getPath().startsWith(org.getPath())) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        .sorted(Comparator.comparing(SysOrgVO::getSort)) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        .collect(Collectors.toList()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        return BeanHelper.copyProperties(result, SysOrg.class); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |