From f343b6155463f55fea2c530472a8d04b022ad7f1 Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Thu, 20 Feb 2025 17:07:02 +0800 Subject: [PATCH] =?UTF-8?q?[=E4=BF=AE=E5=A4=8D]=20=E5=BA=94=E7=94=A8?= =?UTF-8?q?=E5=B7=A1=E6=A3=80-=E5=BA=94=E7=94=A8=E5=B7=A1=E6=A3=80?= =?UTF-8?q?=E5=BC=82=E5=B8=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1360903792984064]应用巡检-应用巡检异常 http://192.168.0.96:8090/demo/rdm.html#/bug-detail/939050947543040/939050947543057/1360903792984064 --- .../appenv/ListAppEnvForSelectApi.java | 12 ++++--- .../AppModuleResourceTypeListApi.java | 33 ++++++++++--------- 2 files changed, 26 insertions(+), 19 deletions(-) diff --git a/src/main/java/neatlogic/module/cmdb/api/resourcecenter/appenv/ListAppEnvForSelectApi.java b/src/main/java/neatlogic/module/cmdb/api/resourcecenter/appenv/ListAppEnvForSelectApi.java index 1fe3cc89..ffa53bb7 100644 --- a/src/main/java/neatlogic/module/cmdb/api/resourcecenter/appenv/ListAppEnvForSelectApi.java +++ b/src/main/java/neatlogic/module/cmdb/api/resourcecenter/appenv/ListAppEnvForSelectApi.java @@ -83,16 +83,20 @@ public class ListAppEnvForSelectApi extends PrivateApiComponentBase { searchVo.setRowNum(rowNum); if (searchVo.getNeedPage()) { List idList = resourceMapper.searchAppEnvIdList(searchVo); - List resourceList = resourceMapper.searchAppEnvListByIdList(idList); - return TableResultUtil.getResult(resourceList, searchVo); + if (CollectionUtils.isNotEmpty(idList)) { + List resourceList = resourceMapper.searchAppEnvListByIdList(idList); + return TableResultUtil.getResult(resourceList, searchVo); + } } else { List allResourceList = new ArrayList<>(); int pageCount = searchVo.getPageCount(); for (int currentPage = 1; currentPage <= pageCount; currentPage++) { searchVo.setCurrentPage(currentPage); List idList = resourceMapper.searchAppEnvIdList(searchVo); - List resourceList = resourceMapper.searchAppEnvListByIdList(idList); - allResourceList.addAll(resourceList); + if (CollectionUtils.isNotEmpty(idList)) { + List resourceList = resourceMapper.searchAppEnvListByIdList(idList); + allResourceList.addAll(resourceList); + } } return TableResultUtil.getResult(allResourceList, searchVo); } diff --git a/src/main/java/neatlogic/module/cmdb/api/resourcecenter/appmodule/AppModuleResourceTypeListApi.java b/src/main/java/neatlogic/module/cmdb/api/resourcecenter/appmodule/AppModuleResourceTypeListApi.java index 183f0a3c..fc995848 100644 --- a/src/main/java/neatlogic/module/cmdb/api/resourcecenter/appmodule/AppModuleResourceTypeListApi.java +++ b/src/main/java/neatlogic/module/cmdb/api/resourcecenter/appmodule/AppModuleResourceTypeListApi.java @@ -1,23 +1,22 @@ package neatlogic.module.cmdb.api.resourcecenter.appmodule; +import com.alibaba.fastjson.JSONArray; +import com.alibaba.fastjson.JSONObject; import neatlogic.framework.auth.core.AuthAction; import neatlogic.framework.cmdb.auth.label.CMDB; import neatlogic.framework.cmdb.dto.ci.CiVo; -import neatlogic.framework.cmdb.dto.cientity.CiEntityVo; import neatlogic.framework.cmdb.dto.resourcecenter.ResourceSearchVo; import neatlogic.framework.cmdb.dto.resourcecenter.ResourceVo; import neatlogic.framework.cmdb.enums.resourcecenter.AppModuleResourceType; import neatlogic.framework.cmdb.exception.ci.CiNotFoundException; import neatlogic.framework.common.constvalue.ApiParamType; +import neatlogic.framework.common.dto.BasePageVo; import neatlogic.framework.restful.annotation.*; import neatlogic.framework.restful.constvalue.OperationTypeEnum; import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; import neatlogic.module.cmdb.dao.mapper.ci.CiMapper; -import neatlogic.module.cmdb.dao.mapper.cientity.CiEntityMapper; import neatlogic.module.cmdb.dao.mapper.resourcecenter.ResourceMapper; import neatlogic.module.cmdb.service.resourcecenter.resource.IResourceCenterResourceService; -import com.alibaba.fastjson.JSONArray; -import com.alibaba.fastjson.JSONObject; import org.apache.commons.collections4.CollectionUtils; import org.springframework.stereotype.Service; @@ -36,9 +35,6 @@ public class AppModuleResourceTypeListApi extends PrivateApiComponentBase { @Resource private CiMapper ciMapper; - @Resource - private CiEntityMapper ciEntityMapper; - @Resource ResourceMapper resourceMapper; @@ -77,18 +73,25 @@ public class AppModuleResourceTypeListApi extends PrivateApiComponentBase { JSONArray returnArray = new JSONArray(); Long appModuleId = paramObj.getLong("appModuleId"); //获取应用环境模型 - CiVo envCiVo = ciMapper.getCiByName("APPEnv"); - if (envCiVo == null) { - throw new CiNotFoundException("APPEnv"); - } +// CiVo envCiVo = ciMapper.getCiByName("APPEnv"); +// if (envCiVo == null) { +// throw new CiNotFoundException("APPEnv"); +// } //获取需要采集的模型 List resourceTypeNameList = AppModuleResourceType.getNameList(); List resourceCiVoList = new ArrayList<>(); + List envResourceList = new ArrayList<>(); //获取应用环境实例list - CiEntityVo envCiEntityVo = new CiEntityVo(); - envCiEntityVo.setCiId(envCiVo.getId()); - List envIdList = ciEntityMapper.getCiEntityIdByCiId(envCiEntityVo); - List envResourceList = resourceMapper.searchAppEnvListByIdList(envIdList); +// CiEntityVo envCiEntityVo = new CiEntityVo(); +// envCiEntityVo.setCiId(envCiVo.getId()); +// List envIdList = ciEntityMapper.getCiEntityIdByCiId(envCiEntityVo); + BasePageVo search = new BasePageVo(); + search.setCurrentPage(1); + search.setPageSize(100); + List envIdList = resourceMapper.searchAppEnvIdList(search); + if (CollectionUtils.isNotEmpty(envIdList)) { + envResourceList = resourceMapper.searchAppEnvListByIdList(envIdList); + } //获取数据库所有的模型,用于通过id去获得对应的模型 Map allCiVoMap = new HashMap<>(); List allCiVoList = ciMapper.getAllCi(null); -- Gitee