Browse Source

getBoundLevel接口完善

jwy
review512jwy@163.com 2 days ago
parent
commit
0372a359e2
  1. 21
      data-center-business-service/src/main/java/com/techsor/datacenter/business/service/impl/LevelRoleServiceImpl.java

21
data-center-business-service/src/main/java/com/techsor/datacenter/business/service/impl/LevelRoleServiceImpl.java

@ -360,7 +360,7 @@ public class LevelRoleServiceImpl implements LevelRoleService {
Map<Long, List<RefKey>> buildingMap = groupByParent(buildings);
// 用于去重,避免重复根节点
Set<String> visitedKeys = new HashSet<>();
// Set<String> visitedKeys = new HashSet<>();
// 组装树结构
List<TreeMenusDTO> result = new ArrayList<>();
@ -370,8 +370,8 @@ public class LevelRoleServiceImpl implements LevelRoleService {
TreeMenusDTO root = new TreeMenusDTO();
String rootKey = ref.getType() + "-" + ref.getId();
if (visitedKeys.contains(rootKey)) continue; // 已存在跳过
visitedKeys.add(rootKey);
// if (visitedKeys.contains(rootKey)) continue; // 已存在跳过
// visitedKeys.add(rootKey);
root.setKey(rootKey);
root.setLabel(ref.getName());
@ -380,7 +380,8 @@ public class LevelRoleServiceImpl implements LevelRoleService {
// 构建该节点下的子树
root.setChildren(buildTree(
ref.getType(), ref.getId(), rootKey,
storeMap, areaMap, siteMap, buildingMap, visitedKeys
storeMap, areaMap, siteMap, buildingMap
// , visitedKeys
));
result.add(root);
}
@ -446,8 +447,9 @@ public class LevelRoleServiceImpl implements LevelRoleService {
Map<Long, List<RefKey>> storeMap,
Map<Long, List<RefKey>> areaMap,
Map<Long, List<RefKey>> siteMap,
Map<Long, List<RefKey>> buildingMap,
Set<String> visitedKeys) {
Map<Long, List<RefKey>> buildingMap
// ,Set<String> visitedKeys
) {
Map<Long, List<RefKey>> childMap = switch (type) {
case "BRANCH" -> storeMap;
@ -467,8 +469,8 @@ public class LevelRoleServiceImpl implements LevelRoleService {
for (RefKey c : children) {
String key = c.getType() + "-" + c.getId();
if (visitedKeys.contains(key)) continue; // 已存在跳过
visitedKeys.add(key);
// if (visitedKeys.contains(key)) continue; // 已存在跳过
// visitedKeys.add(key);
TreeMenusDTO node = new TreeMenusDTO();
node.setKey(key);
@ -477,7 +479,8 @@ public class LevelRoleServiceImpl implements LevelRoleService {
node.setChildren(buildTree(
c.getType(), c.getId(), key,
storeMap, areaMap, siteMap, buildingMap, visitedKeys
storeMap, areaMap, siteMap, buildingMap
// , visitedKeys
));
list.add(node);

Loading…
Cancel
Save