添加日志
parent
3ce3aec59d
commit
1f83038120
|
@ -207,6 +207,11 @@ public class InstanceServiceImpl implements InstanceService {
|
||||||
String table = CmdbUtils.CMDB_INSTANCE + moduleCode.toLowerCase();
|
String table = CmdbUtils.CMDB_INSTANCE + moduleCode.toLowerCase();
|
||||||
String valueTable = CmdbUtils.CMDB_INSTANCE_VALUE + moduleCode.toLowerCase();
|
String valueTable = CmdbUtils.CMDB_INSTANCE_VALUE + moduleCode.toLowerCase();
|
||||||
boolean hasAdminRole = checkAdminRole(userId);
|
boolean hasAdminRole = checkAdminRole(userId);
|
||||||
|
log.info("pager:{}",JSON.toJSONString(pager));
|
||||||
|
log.info("table:{}",JSON.toJSONString(table));
|
||||||
|
log.info("valueTable:{}",JSON.toJSONString(valueTable));
|
||||||
|
log.info("userId:{}",JSON.toJSONString(userId));
|
||||||
|
log.info("hasAdminRole:{}",JSON.toJSONString(hasAdminRole));
|
||||||
int total = instanceRepository.count(pager.getParams(), table, valueTable, userId, hasAdminRole);
|
int total = instanceRepository.count(pager.getParams(), table, valueTable, userId, hasAdminRole);
|
||||||
list = this.instanceRepository.list(pager, table, valueTable, userId, hasAdminRole);
|
list = this.instanceRepository.list(pager, table, valueTable, userId, hasAdminRole);
|
||||||
convertInstanceValue(list, moduleId, userId, hasAdminRole);
|
convertInstanceValue(list, moduleId, userId, hasAdminRole);
|
||||||
|
|
|
@ -10,6 +10,7 @@ import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
import java.util.concurrent.CountDownLatch;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
@ -430,17 +431,20 @@ public class ModuleServiceImpl implements ModuleService {
|
||||||
List<String> nameList = Arrays.asList("网络设备", "物理服务器", "安全设备");
|
List<String> nameList = Arrays.asList("网络设备", "物理服务器", "安全设备");
|
||||||
//查询根节点
|
//查询根节点
|
||||||
List<ModuleGroup> rootGroups = moduleGroupRepository.queryRootInName(nameList);
|
List<ModuleGroup> rootGroups = moduleGroupRepository.queryRootInName(nameList);
|
||||||
log.info("moduleGroups:{}", JSON.toJSONString(rootGroups));
|
log.info("rootGroups:{}", JSON.toJSONString(rootGroups));
|
||||||
|
log.info("context:{}", JSON.toJSONString(context));
|
||||||
|
|
||||||
//查询出所有根节点下的子节点
|
//用countDownLatch是为了加快速度
|
||||||
|
CountDownLatch countDownLatch = new CountDownLatch(rootGroups.size());
|
||||||
|
|
||||||
|
Map<String,Object> resultMap = new HashMap<>();
|
||||||
|
|
||||||
|
for (ModuleGroup rootGroup : rootGroups) {
|
||||||
|
//获取每个模型的所有实例总数
|
||||||
|
getInstaceCount(rootGroup,resultMap,countDownLatch);
|
||||||
|
}
|
||||||
|
countDownLatch.await();
|
||||||
|
|
||||||
List<Long> rootGroupIds = rootGroups.stream().map(ModuleGroup::getId).collect(Collectors.toList());
|
|
||||||
// 获取模型分组所有数据
|
|
||||||
List<ModuleGroup> moduleGroups = moduleGroupRepository.all();
|
|
||||||
// 获取根节点的子节点集合
|
|
||||||
List<ModuleGroup> children = moduleGroups.stream().filter(item -> rootGroupIds.contains(item.getParentId()))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
log.info("children:{}", JSON.toJSONString(children));
|
|
||||||
|
|
||||||
//查询云主机总数
|
//查询云主机总数
|
||||||
Pager pager = new Pager();
|
Pager pager = new Pager();
|
||||||
|
@ -458,7 +462,6 @@ public class ModuleServiceImpl implements ModuleService {
|
||||||
return new GeneralResult(false,"查询失败");
|
return new GeneralResult(false,"查询失败");
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<String,Object> resultMap = new HashMap<>();
|
|
||||||
resultMap.put("vm",result.getData().getInteger("total"));
|
resultMap.put("vm",result.getData().getInteger("total"));
|
||||||
|
|
||||||
return new GeneralResult<>(true, resultMap,"查询成功");
|
return new GeneralResult<>(true, resultMap,"查询成功");
|
||||||
|
@ -468,6 +471,29 @@ public class ModuleServiceImpl implements ModuleService {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void getInstaceCount(ModuleGroup rootGroup, Map<String, Object> resultMap, CountDownLatch countDownLatch) {
|
||||||
|
new Thread(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
//获取当前ModuleGroup下所有的modle
|
||||||
|
Pager pager = new Pager();
|
||||||
|
GeneralResult<GridBean<CiModule>> modelList = getModelList(pager);
|
||||||
|
if (modelList.isFailed()) {
|
||||||
|
log.info("modelList:{}", JSON.toJSONString(modelList));
|
||||||
|
countDownLatch.countDown();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (CiModule model : modelList.getData().getRows()) {
|
||||||
|
//获取每个模型下所有的实例总数
|
||||||
|
String table = CmdbUtils.CMDB_INSTANCE + model.getCode().toLowerCase();
|
||||||
|
String valueTable = CmdbUtils.CMDB_INSTANCE_VALUE + model.getCode().toLowerCase();
|
||||||
|
}
|
||||||
|
resultMap.put("","");
|
||||||
|
countDownLatch.countDown();
|
||||||
|
}
|
||||||
|
}).start();
|
||||||
|
}
|
||||||
|
|
||||||
private GeneralResult baseModifyProperty(Long moduleId, List<PropertyGroup> groups, List<Property> properties,
|
private GeneralResult baseModifyProperty(Long moduleId, List<PropertyGroup> groups, List<Property> properties,
|
||||||
Long userId) throws Exception {
|
Long userId) throws Exception {
|
||||||
CiModule module = moduleRepository.query(moduleId);
|
CiModule module = moduleRepository.query(moduleId);
|
||||||
|
|
Loading…
Reference in New Issue