| | |
| | | childrenMap = getChildrenDepartmentByOrgType(myDepartment, null); |
| | | } |
| | | SysDepartmentVO sysDepartmentVO = fillChildrenTreeModel(myDepartment, childrenMap); |
| | | switch (type) { |
| | | case 2: |
| | | case 3: |
| | | case 4: |
| | | filterEmptyChildren(sysDepartmentVO.getChildren()); |
| | | break; |
| | | } |
| | | root.add(sysDepartmentVO); |
| | | return root; |
| | | } |
| | | |
| | | /** |
| | | * 移除子节点为空的区域 |
| | | * |
| | | * @param departments |
| | | */ |
| | | private void filterEmptyChildren(List<SysDepartmentVO> departments) { |
| | | if (departments == null) { |
| | | return; |
| | | } |
| | | |
| | | Iterator<SysDepartmentVO> iterator = departments.iterator(); |
| | | while (iterator.hasNext()) { |
| | | SysDepartmentVO department = iterator.next(); |
| | | |
| | | // 递归过滤子节点 |
| | | filterEmptyChildren(department.getChildren()); |
| | | |
| | | // 如果 orgType == 1 且 children 为空,则移除当前节点 |
| | | if (department.getOrgType() == 1 && department.getChildren().isEmpty()) { |
| | | iterator.remove(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | |
| | | } |
| | | return root; |
| | | } |
| | | public List<SysDepartmentVO> getRegionTree2(String keyword) { |
| | | |
| | | List<SysDepartmentVO> root = new ArrayList<>(); |
| | | SysDepartment currentDepartment = this.baseMapper.selectById(-1); |
| | | if (Objects.isNull(currentDepartment)) { |
| | | return root; |
| | | } |
| | | if (!currentDepartment.getOrgType().equals(DepartmentEnum.REGION.getCode())) { |
| | | return root; |
| | | } |
| | | Map<Long, List<SysDepartment>> childrenMap = getChildrenDepartmentByOrgType(currentDepartment, Collections.singletonList(DepartmentEnum.REGION.getCode())); |
| | | SysDepartmentVO sysDepartmentVO = fillChildrenTreeModel(currentDepartment, childrenMap); |
| | | root.add(sysDepartmentVO); |
| | | if (StringUtils.isNotBlank(keyword)) { |
| | | treeMatch(root, keyword); |
| | | } |
| | | return root; |
| | | } |
| | | |
| | | /** |
| | | * 获取当前登录用户所属区域 |