---
title: "4.根据所有上级列表按照全路径排序"
docId: "207677624703516672"
source: "https://weapp.eteams.cn/build/techdoc/wdoc/index.html#/public/repository/91f5067f-775e-48f4-93a2-ce84ca0b9c2e/doc/207677624703516672"
---
```java
com.weaver.common.hrm.util.browsercondition.HrmBrowserUtil#orderOrgPath
```

- 入参说明

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| infoCacheCacheList | List<T> | 所有上级列表 |
| orginList | List<T> | 原数据列表 |
| config | HrmOrgBrowserLevelConfig<T> | 规则 |

- T 可以任意bean，必须有 getter & parentGetter function
- HrmOrgBrowserLevelConfig说明

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| idGetter | Function<T, Long> | id的getter方法 |
| parentGetter | Function<T, Long> | 上级的getter方法 |
| orderType | FullPathOrderTypeEnum | 全路径排序规则；DESC，从顶级到叶子；ASC 从叶子到顶级 |

- 返回Map<Long,List<T>>

| 参数 | 类型 | 说明 |
| --- | --- | --- |
| key | Long | 原数据的id |
| value | ,List<T> | 全路径列表 |

- 调用示例

```java
-- 查询所有上级，返回结果，待排序
		List<Long> list = new ArrayList<>();
        list.add(deptId);
        HrmOrgRelationCodition codition  = new HrmOrgRelationCodition();
        codition.setQueryType(HrmOrgRelationQueryType.org_allSuper_org);
        codition.setIds(list);
        codition.setTenantKey(tenantKey);
        List<HrmDepartmentComInfo> orgRelationByCondtion = hrmCommonDepartmentService.findOrgRelationByCondtion(codition);
        
        if(CollectionUtils.isEmpty(orgRelationByCondtion)) return Lists.newArrayList() ;

        HrmDepartmentComInfo cacheById = comInfoCache.getCacheById(HrmDepartmentComInfo.class, deptId);
        if(cacheById == null) return Lists.newArrayList() ;

        Map<Long, List<HrmDepartmentComInfo>> idAndAllSuperMap = HrmBrowserUtil.orderOrgPath(orgRelationByCondtion, Lists.newArrayList(cacheById),
                new HrmOrgBrowserLevelConfig<HrmDepartmentComInfo>()
                        .setIdGetter(HrmDepartmentComInfo::getId)
                        .setParentGetter(HrmDepartmentComInfo::getParent)
        );

        List<HrmDepartmentComInfo> orderedAllSuperList = idAndAllSuperMap.get(deptId); // 这个就是有顺序的
```
