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 1fe3cc8985861970f58523085769dc5d35f42a31..ffa53bb78a70a83d8414878178db89da0398d86e 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 183f0a3c34083d491adbfc385f29b2ad3bd21e0e..fc995848eda76a7779c6672d35764bb3de8fdc69 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);