| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -26,6 +26,7 @@ import org.apache.commons.lang3.StringUtils; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.springframework.beans.factory.annotation.Autowired; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.springframework.stereotype.Service; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.util.Arrays; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.util.List; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.util.Map; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.util.stream.Collectors; | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -147,6 +148,42 @@ public class OptSysDeptServiceImpl extends BaseServiceImpl<OptSysDeptDao, OptSys | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        return deptScope; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    @Override | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    public List<Long> listParentDeptIds(String[] typeKeys, Long deptId) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        List<Long> result = Lists.newArrayList(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if (ArrayUtil.isNotEmpty(typeKeys)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            String deptIdsKey = OptimizeRedisKeys.getParentDeptIdsKey(deptId, StringUtils.join(escapeDeptTypeKey(typeKeys), StrConstant.HYPHEN)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            Object obj = redisUtils.get(deptIdsKey); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (null != obj) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                return (List<Long>) obj; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            // 查询部门信息
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            OptSysDeptEntity optSysDeptEntity = baseDao.selectById(deptId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (!optSysDeptEntity.getPid().equals(NumConstant.ONE_L)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                // 获取所有上级部门id
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                String[] pids = optSysDeptEntity.getPids().split(StrConstant.COMMA); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                List<OptSysDeptEntity> sysDeptEntityList = baseDao.selectBatchIds(Arrays.asList(pids)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                if (CollUtil.isNotEmpty(sysDeptEntityList)) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    // 按顺序循环查询条件中所有部门类别,确保结果按顺序返回
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    for (int i = 0; i < typeKeys.length; i++) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        String typeKey = typeKeys[i]; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        // 声明上级机构id为 -1,如果未匹配到,以-1站位
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        Long parentId = NumConstant.ZERO_L - NumConstant.ONE_L; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        for (OptSysDeptEntity sysDeptEntity : sysDeptEntityList) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                            if (typeKey.equals(sysDeptEntity.getTypeKey())) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                                parentId = sysDeptEntity.getId(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                                // 只取关系最近的上级机构
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                                break; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                        result.add(parentId); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                redisUtils.set(deptIdsKey, result, RedisUtils.MINUTE_TEN_EXPIRE); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        return result; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    /** | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * 根据部门数据权限组装部门层级结构 | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |