| | |
| | | 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(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * @param myDepartment |
| | | * @param orgTypes 查询区域类型列表 |
| | | * @return |