diff --git a/src/main/java/neatlogic/module/cmdb/dao/mapper/resourcecenter/ResourceMapper.xml b/src/main/java/neatlogic/module/cmdb/dao/mapper/resourcecenter/ResourceMapper.xml index 81ca068620fc1c6dc5714a21decfabf17925ae16..fce7ea66800b5ce00a47d2826663f4149cda33f2 100644 --- a/src/main/java/neatlogic/module/cmdb/dao/mapper/resourcecenter/ResourceMapper.xml +++ b/src/main/java/neatlogic/module/cmdb/dao/mapper/resourcecenter/ResourceMapper.xml @@ -309,7 +309,8 @@ along with this program. If not, see .--> COUNT(DISTINCT a.`id`) - FROM `cmdb_cientity` a + FROM @{DATA_SCHEMA}.`${viewName}` b + JOIN `cmdb_cientity` a on a.`id` = b.`cientity_id` LEFT JOIN `cmdb_cientity_expiredtime` `ex` ON `ex`.`cientity_id` = `a`.`id` LEFT JOIN cmdb_cientity_group ccg ON ccg.cientity_id = a.id diff --git a/src/main/java/neatlogic/module/cmdb/resourcecenter/datasource/handler/DefaultResourceCenterDataSourceImpl.java b/src/main/java/neatlogic/module/cmdb/resourcecenter/datasource/handler/DefaultResourceCenterDataSourceImpl.java index dbd642242d64621cd0f84825012028228834364a..4a39a869957eb6a159eb1ae1d5ddbf65b2f38220 100644 --- a/src/main/java/neatlogic/module/cmdb/resourcecenter/datasource/handler/DefaultResourceCenterDataSourceImpl.java +++ b/src/main/java/neatlogic/module/cmdb/resourcecenter/datasource/handler/DefaultResourceCenterDataSourceImpl.java @@ -28,6 +28,7 @@ import neatlogic.framework.cmdb.dto.resourcecenter.config.ResourceEntityConfigVo import neatlogic.framework.cmdb.dto.resourcecenter.config.ResourceEntityFieldMappingVo; import neatlogic.framework.cmdb.dto.resourcecenter.config.ResourceEntityVo; import neatlogic.framework.cmdb.dto.resourcecenter.config.SceneEntityVo; +import neatlogic.framework.cmdb.exception.ci.CiNotFoundException; import neatlogic.framework.cmdb.exception.resourcecenter.AppModuleNotFoundException; import neatlogic.framework.cmdb.exception.resourcecenter.AppSystemNotFoundException; import neatlogic.framework.cmdb.resourcecenter.datasource.core.IResourceCenterDataSource; @@ -652,7 +653,17 @@ public class DefaultResourceCenterDataSourceImpl implements IResourceCenterDataS if (Objects.equals(searchVo.getRowNum(), 0)) { int rowNum = 0; if (noFilterCondition(searchVo)) { - rowNum = resourceMapper.getAllResourceCount(searchVo); + ResourceEntityVo resourceEntityVo = resourceEntityMapper.getResourceEntityByName("scence_ipobject_detail"); + if (resourceEntityVo != null) { + ResourceEntityConfigVo config = resourceEntityVo.getConfig(); + if (config != null) { + CiVo ciVo = ciMapper.getCiByName(config.getMainCi()); + if (ciVo != null) { + searchVo.setViewName(ciVo.getCiTableName(false)); + rowNum = resourceMapper.getAllResourceCount(searchVo); + } + } + } } else { rowNum = resourceMapper.getResourceCount(searchVo); } @@ -670,10 +681,23 @@ public class DefaultResourceCenterDataSourceImpl implements IResourceCenterDataS keyword = keyword.toLowerCase(); } List resultList = new ArrayList<>(); - List ciIdList = resourceEntityMapper.getAllResourceTypeCiIdList(); - if (CollectionUtils.isEmpty(ciIdList)) { +// List ciIdList = resourceEntityMapper.getAllResourceTypeCiIdList(); +// if (CollectionUtils.isEmpty(ciIdList)) { +// return resultList; +// } + AssetListDisplayVo assetListDisplayVo = resourceEntityMapper.getAssetListDisplay(); + if (assetListDisplayVo == null) { return resultList; } + String rootCiName = assetListDisplayVo.getRootCiName(); + if (StringUtils.isBlank(rootCiName)) { + return resultList; + } + CiVo rootCiVo = ciMapper.getCiByName(rootCiName); + if (rootCiVo == null) { + throw new CiNotFoundException(rootCiName); + } + List ciIdList = Collections.singletonList(rootCiVo.getId()); List authCiVoList = new ArrayList<>(); ResourceSearchVo searchVo = new ResourceSearchVo(); searchVo.setTypeIdList(ciIdList);