| | |
| | | /** |
| | | * 获取子部门ID集合 |
| | | * |
| | | * @param deptId 主键 |
| | | * @param deptIds 主键 |
| | | * @return 子部门ID |
| | | */ |
| | | public static List<Long> getDeptChildIds(Long deptId) { |
| | | if (deptId == null) { |
| | | public static List<Long> getDeptChildIds(String deptIds) { |
| | | if (Strings.isBlank(deptIds)) { |
| | | return null; |
| | | } |
| | | List<Long> deptIdList = CacheUtil.get(SYS_CACHE, DEPT_CHILDIDS_ID, deptId, List.class); |
| | | if (deptIdList == null) { |
| | | deptIdList = new ArrayList<>(); |
| | | List<Dept> deptChild = getDeptChild(deptId); |
| | | if (deptChild != null) { |
| | | List<Long> collect = deptChild.stream().map(Dept::getId).collect(Collectors.toList()); |
| | | deptIdList.addAll(collect); |
| | | List<Long> list = new ArrayList<>(); |
| | | List<String> deptIdList = new ArrayList<>(Arrays.asList(deptIds.split(","))); |
| | | for (String deptId : deptIdList) { |
| | | List<Long> deptIdLists = CacheUtil.get(SYS_CACHE, DEPT_CHILDIDS_ID, deptId, List.class); |
| | | if (deptIdLists == null) { |
| | | deptIdLists = new ArrayList<>(); |
| | | List<Dept> deptChild = getDeptChild(Long.parseLong(deptId)); |
| | | if (deptChild != null) { |
| | | List<Long> collect = deptChild.stream().map(Dept::getId).collect(Collectors.toList()); |
| | | deptIdLists.addAll(collect); |
| | | } |
| | | deptIdLists.add(Long.parseLong(deptId)); |
| | | CacheUtil.put(SYS_CACHE, DEPT_CHILDIDS_ID, deptId, deptIdLists); |
| | | } |
| | | deptIdList.add(deptId); |
| | | CacheUtil.put(SYS_CACHE, DEPT_CHILDIDS_ID, deptId, deptIdList); |
| | | list.addAll(deptIdLists); |
| | | } |
| | | return deptIdList; |
| | | // 去重 |
| | | List<Long> collect = list.stream().distinct().collect(Collectors.toList()); |
| | | // 返回 |
| | | return collect; |
| | | } |
| | | |
| | | /** |
| | |
| | | //所有行政区划code |
| | | List<String> allRegionList = new ArrayList<>(); |
| | | deptIdList.forEach(id->{ |
| | | |
| | | List<String> list = new ArrayList<>(); |
| | | // 查询对应的区域编号code |
| | | Dept dept = deptService.getById(id); |
| | | if (null!=dept && !Strings.isBlank(dept.getRegionCode()) && !AuthUtil.isAdministrator()){ |
| | | list = getRegionChildCodes(dept.getRegionCode()); |
| | | |
| | | //行政区划不为空添加进集合 |
| | | if (list.size()>0){ |
| | | allRegionList.addAll(list); |