|
|
@ -332,7 +332,8 @@ public class LevelRoleServiceImpl implements LevelRoleService { |
|
|
Map<String, Object> levelMap = new HashMap<>(); |
|
|
Map<String, Object> levelMap = new HashMap<>(); |
|
|
levelMap.put("companyId", companyId); |
|
|
levelMap.put("companyId", companyId); |
|
|
List<RefKey> branches = levelRoleMapperExt.selectAllBranches(levelMap); |
|
|
List<RefKey> branches = levelRoleMapperExt.selectAllBranches(levelMap); |
|
|
List<RefKey> storeAreas = levelRoleMapperExt.selectAllStoreAreas(levelMap); |
|
|
List<RefKey> stores = levelRoleMapperExt.selectAllStores(levelMap); |
|
|
|
|
|
List<RefKey> areas = levelRoleMapperExt.selectAllAreas(levelMap); |
|
|
List<RefKey> sites = levelRoleMapperExt.selectAllSites(levelMap); |
|
|
List<RefKey> sites = levelRoleMapperExt.selectAllSites(levelMap); |
|
|
List<RefKey> buildings = levelRoleMapperExt.selectAllBuildings(levelMap); |
|
|
List<RefKey> buildings = levelRoleMapperExt.selectAllBuildings(levelMap); |
|
|
|
|
|
|
|
|
@ -340,7 +341,8 @@ public class LevelRoleServiceImpl implements LevelRoleService { |
|
|
List<RefKey> userRefs = new ArrayList<>(); |
|
|
List<RefKey> userRefs = new ArrayList<>(); |
|
|
if (levelRoleMapperExt.checkLevelManager(userId) > 0){ |
|
|
if (levelRoleMapperExt.checkLevelManager(userId) > 0){ |
|
|
userRefs.addAll(branches); |
|
|
userRefs.addAll(branches); |
|
|
userRefs.addAll(storeAreas); |
|
|
userRefs.addAll(stores); |
|
|
|
|
|
userRefs.addAll(areas); |
|
|
userRefs.addAll(sites); |
|
|
userRefs.addAll(sites); |
|
|
userRefs.addAll(buildings); |
|
|
userRefs.addAll(buildings); |
|
|
} else { |
|
|
} else { |
|
|
@ -348,11 +350,12 @@ public class LevelRoleServiceImpl implements LevelRoleService { |
|
|
paramMap.put("userId", userId); |
|
|
paramMap.put("userId", userId); |
|
|
userRefs = levelRoleMapperExt.selectUserRefs(paramMap); |
|
|
userRefs = levelRoleMapperExt.selectUserRefs(paramMap); |
|
|
// 名称填充
|
|
|
// 名称填充
|
|
|
fillNames(userRefs, branches, storeAreas, sites, buildings); |
|
|
fillNames(userRefs, branches, stores, areas, sites, buildings); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 构建 parentId → List<RefKey> 的多值 Map
|
|
|
// 构建 parentId → List<RefKey> 的多值 Map
|
|
|
Map<Long, List<RefKey>> storeAreaMap = groupByParent(storeAreas); |
|
|
Map<Long, List<RefKey>> storeMap = groupByParent(stores); |
|
|
|
|
|
Map<Long, List<RefKey>> areaMap = groupByParent(areas); |
|
|
Map<Long, List<RefKey>> siteMap = groupByParent(sites); |
|
|
Map<Long, List<RefKey>> siteMap = groupByParent(sites); |
|
|
Map<Long, List<RefKey>> buildingMap = groupByParent(buildings); |
|
|
Map<Long, List<RefKey>> buildingMap = groupByParent(buildings); |
|
|
|
|
|
|
|
|
@ -377,7 +380,7 @@ public class LevelRoleServiceImpl implements LevelRoleService { |
|
|
// 构建该节点下的子树
|
|
|
// 构建该节点下的子树
|
|
|
root.setChildren(buildTree( |
|
|
root.setChildren(buildTree( |
|
|
ref.getType(), ref.getId(), rootKey, |
|
|
ref.getType(), ref.getId(), rootKey, |
|
|
storeAreaMap, siteMap, buildingMap, visitedKeys |
|
|
storeMap, areaMap, siteMap, buildingMap, visitedKeys |
|
|
)); |
|
|
)); |
|
|
result.add(root); |
|
|
result.add(root); |
|
|
} |
|
|
} |
|
|
@ -395,19 +398,22 @@ public class LevelRoleServiceImpl implements LevelRoleService { |
|
|
|
|
|
|
|
|
private void fillNames(List<RefKey> userRefs, |
|
|
private void fillNames(List<RefKey> userRefs, |
|
|
List<RefKey> branches, |
|
|
List<RefKey> branches, |
|
|
List<RefKey> storeAreas, |
|
|
List<RefKey> stores, |
|
|
|
|
|
List<RefKey> areas, |
|
|
List<RefKey> sites, |
|
|
List<RefKey> sites, |
|
|
List<RefKey> buildings) { |
|
|
List<RefKey> buildings) { |
|
|
|
|
|
|
|
|
Map<Long, String> branchName = toNameMap(branches); |
|
|
Map<Long, String> branchName = toNameMap(branches); |
|
|
Map<Long, String> storeAreaName = toNameMap(storeAreas); |
|
|
Map<Long, String> storeName = toNameMap(stores); |
|
|
|
|
|
Map<Long, String> areaName = toNameMap(areas); |
|
|
Map<Long, String> siteName = toNameMap(sites); |
|
|
Map<Long, String> siteName = toNameMap(sites); |
|
|
Map<Long, String> buildingName = toNameMap(buildings); |
|
|
Map<Long, String> buildingName = toNameMap(buildings); |
|
|
|
|
|
|
|
|
userRefs.removeIf(r -> { |
|
|
userRefs.removeIf(r -> { |
|
|
String name = switch (r.getType()) { |
|
|
String name = switch (r.getType()) { |
|
|
case "BRANCH" -> branchName.get(r.getId()); |
|
|
case "BRANCH" -> branchName.get(r.getId()); |
|
|
case "STORE_AREA" -> storeAreaName.get(r.getId()); |
|
|
case "STORE" -> storeName.get(r.getId()); |
|
|
|
|
|
case "AREA" -> areaName.get(r.getId()); |
|
|
case "SITE" -> siteName.get(r.getId()); |
|
|
case "SITE" -> siteName.get(r.getId()); |
|
|
case "BUILDING" -> buildingName.get(r.getId()); |
|
|
case "BUILDING" -> buildingName.get(r.getId()); |
|
|
default -> null; |
|
|
default -> null; |
|
|
@ -437,18 +443,19 @@ public class LevelRoleServiceImpl implements LevelRoleService { |
|
|
private List<TreeMenusDTO> buildTree(String type, |
|
|
private List<TreeMenusDTO> buildTree(String type, |
|
|
Long parentId, |
|
|
Long parentId, |
|
|
String parentKey, |
|
|
String parentKey, |
|
|
Map<Long, List<RefKey>> storeAreaMap, |
|
|
Map<Long, List<RefKey>> storeMap, |
|
|
|
|
|
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" -> storeAreaMap; |
|
|
case "BRANCH" -> storeMap; |
|
|
case "STORE_AREA" -> siteMap; |
|
|
case "STORE" -> areaMap; |
|
|
|
|
|
case "AREA" -> siteMap; |
|
|
case "SITE" -> buildingMap; |
|
|
case "SITE" -> buildingMap; |
|
|
default -> null; |
|
|
default -> null; |
|
|
}; |
|
|
}; |
|
|
|
|
|
|
|
|
if (childMap == null) return Collections.emptyList(); |
|
|
if (childMap == null) return Collections.emptyList(); |
|
|
|
|
|
|
|
|
// 直接取 parentId 的子节点
|
|
|
// 直接取 parentId 的子节点
|
|
|
@ -470,7 +477,7 @@ public class LevelRoleServiceImpl implements LevelRoleService { |
|
|
|
|
|
|
|
|
node.setChildren(buildTree( |
|
|
node.setChildren(buildTree( |
|
|
c.getType(), c.getId(), key, |
|
|
c.getType(), c.getId(), key, |
|
|
storeAreaMap, siteMap, buildingMap, visitedKeys |
|
|
storeMap, areaMap, siteMap, buildingMap, visitedKeys |
|
|
)); |
|
|
)); |
|
|
|
|
|
|
|
|
list.add(node); |
|
|
list.add(node); |
|
|
|