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