From d91ce26029b3d0a4d04dc1af9cf1b879b28f1317 Mon Sep 17 00:00:00 2001 From: yuemian Date: Sun, 27 Oct 2024 12:52:50 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../module/impl/ModuleGroupServiceImpl.java | 18 ++++++++++-------- .../service/module/impl/ModuleServiceImpl.java | 2 +- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/bocloud.ams.service/src/main/java/com/bocloud/ams/service/module/impl/ModuleGroupServiceImpl.java b/bocloud.ams.service/src/main/java/com/bocloud/ams/service/module/impl/ModuleGroupServiceImpl.java index 6dbf652..43b53af 100644 --- a/bocloud.ams.service/src/main/java/com/bocloud/ams/service/module/impl/ModuleGroupServiceImpl.java +++ b/bocloud.ams.service/src/main/java/com/bocloud/ams/service/module/impl/ModuleGroupServiceImpl.java @@ -301,7 +301,7 @@ public class ModuleGroupServiceImpl implements ModuleGroupService { // 资源目录中查询模型对应的实例数量 if ("resource".equalsIgnoreCase(menu)) { if (CollectionUtils.isNotEmpty(childModules)) { - countModuleInstanceNum(childModules, context); + countModuleInstanceNum(childModules, context, positionKey); } } group.setChildrenGroups(moduleGroups); @@ -318,7 +318,7 @@ public class ModuleGroupServiceImpl implements ModuleGroupService { } } - private void countModuleInstanceNum(List childModules, RequestContext context) { + private void countModuleInstanceNum(List childModules, RequestContext context, String positionKey) { log.info("--------------start count instance num---------"); try { @@ -326,7 +326,7 @@ public class ModuleGroupServiceImpl implements ModuleGroupService { List>> futureTasks = new ArrayList<>(); for (CiModule module : childModules) { FutureTask> task = - new FutureTask<>(new CountInstanceNumTask(module, context.getTarget(), hasAdminRole)); + new FutureTask<>(new CountInstanceNumTask(module, context.getTarget(), hasAdminRole, positionKey)); futureTasks.add(task); threadPoolTaskExecutor.submit(task); } @@ -348,22 +348,24 @@ public class ModuleGroupServiceImpl implements ModuleGroupService { private CiModule module; private Long userId; private boolean hasAdminRole; + private String positionKey; - public CountInstanceNumTask(CiModule module, Long userId, boolean hasAdminRole) { + public CountInstanceNumTask(CiModule module, Long userId, boolean hasAdminRole, String positionKey) { this.module = module; this.userId = userId; this.hasAdminRole = hasAdminRole; + this.positionKey = positionKey; } @Override public Map call() throws Exception { Map map = new HashMap<>(); - map.put(module.getId(), countInstanceNum(module, userId, hasAdminRole)); + map.put(module.getId(), countInstanceNum(module, userId, hasAdminRole, positionKey)); return map; } } - private int countInstanceNum(CiModule module, Long userId, boolean hasAdminRole) { + private int countInstanceNum(CiModule module, Long userId, boolean hasAdminRole, String positionKey) { int total = 0; try { String table = CmdbUtils.CMDB_INSTANCE + module.getCode().toLowerCase(); @@ -375,7 +377,7 @@ public class ModuleGroupServiceImpl implements ModuleGroupService { param.setParam(newMap); param.setSign(Sign.EQ); params.add(param); - total = instanceRepository.count(params, table, valueTable, userId, hasAdminRole); + total = instanceRepository.count(params, table, valueTable, userId, hasAdminRole, positionKey); } catch (Exception e) { log.error("查询模型实例数量出错", e); } @@ -514,7 +516,7 @@ public class ModuleGroupServiceImpl implements ModuleGroupService { //获取模型对应的实例数 if ("resource".equalsIgnoreCase(menu)) { if (CollectionUtils.isNotEmpty(newModules)) { - countModuleInstanceNum(newModules, context); + countModuleInstanceNum(newModules, context, positionKey); } } // 对模型根据groupId进行分组 diff --git a/bocloud.ams.service/src/main/java/com/bocloud/ams/service/module/impl/ModuleServiceImpl.java b/bocloud.ams.service/src/main/java/com/bocloud/ams/service/module/impl/ModuleServiceImpl.java index 4eb84b9..e09aaeb 100644 --- a/bocloud.ams.service/src/main/java/com/bocloud/ams/service/module/impl/ModuleServiceImpl.java +++ b/bocloud.ams.service/src/main/java/com/bocloud/ams/service/module/impl/ModuleServiceImpl.java @@ -495,7 +495,7 @@ public class ModuleServiceImpl implements ModuleService { param.setSign(Sign.EQ); paramList.add(param); boolean adminRole = instanceService.checkAdminRole(userId); - int count = instanceRepository.count(paramList, table, valueTable, userId, adminRole); + int count = instanceRepository.count(paramList, table, valueTable, userId, adminRole, positionKey); total += count; } resultMap.put(rootGroup.getCode(), total);