diff --git a/src/main/java/neatlogic/module/cmdb/api/resourcecenter/config/SaveResourceEntityApi.java b/src/main/java/neatlogic/module/cmdb/api/resourcecenter/config/SaveResourceEntityApi.java index f6869d49e3ef4a0f9c85410c7b1f8e10477699ea..6b26d4a0e1dfb69bf2aa551a72c44e99f38f51a3 100644 --- a/src/main/java/neatlogic/module/cmdb/api/resourcecenter/config/SaveResourceEntityApi.java +++ b/src/main/java/neatlogic/module/cmdb/api/resourcecenter/config/SaveResourceEntityApi.java @@ -35,7 +35,7 @@ import neatlogic.framework.restful.core.IValid; import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; import neatlogic.module.cmdb.dao.mapper.ci.CiMapper; import neatlogic.module.cmdb.dao.mapper.resourcecenter.ResourceEntityMapper; -import neatlogic.module.cmdb.service.resourcecenter.resource.IResourceCenterResourceService; +import neatlogic.module.cmdb.service.resourcecenter.resource.ResourceBuildSqlService; import neatlogic.module.cmdb.utils.ResourceEntityFactory; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Service; @@ -56,8 +56,9 @@ public class SaveResourceEntityApi extends PrivateApiComponentBase { private CiMapper ciMapper; @Resource private ResourceEntityMapper resourceEntityMapper; + @Resource - private IResourceCenterResourceService resourceCenterResourceService; + private ResourceBuildSqlService resourceBuildSqlService; @Override public String getToken() { @@ -121,7 +122,7 @@ public class SaveResourceEntityApi extends PrivateApiComponentBase { } // if (!configEquals) { resourceEntityVo.setError(null); - String sql = resourceCenterResourceService.buildResourceView(resourceEntityVo); + String sql = resourceBuildSqlService.buildResourceView(resourceEntityVo); if (StringUtils.isNotBlank(resourceEntityVo.getError())) { resourceEntityVo.setStatus(Status.ERROR.getValue()); } else { diff --git a/src/main/java/neatlogic/module/cmdb/dao/mapper/resourcecenter/ResourceMapper.java b/src/main/java/neatlogic/module/cmdb/dao/mapper/resourcecenter/ResourceMapper.java index 47e12b72992b3e7aed05e805dee2363def69236d..9953a9998f1465b85477e7f602fd165a078a44a0 100644 --- a/src/main/java/neatlogic/module/cmdb/dao/mapper/resourcecenter/ResourceMapper.java +++ b/src/main/java/neatlogic/module/cmdb/dao/mapper/resourcecenter/ResourceMapper.java @@ -26,18 +26,35 @@ import org.apache.ibatis.annotations.Param; import java.util.List; import java.util.Map; -import java.util.Set; public interface ResourceMapper extends IResourceCrossoverMapper { - int getResourceCountByNameKeyword(ResourceSearchVo searchVo); + int getCountBySql(String sql); + + Long getIdBySql(String sql); + + List getIdListBySql(String sql); + + ResourceVo getResourceBySql(String sql); + + ResourceVo getResourceSimpleBySql(String sql); + + List getResourceListBySql(String sql); + + List getResourceSimpleListBySql(String sql); + + List searchAccountComponentListBySql(String sql); + List getAppEnvListBySql(String sql); + + List> getMapListBySql(String sql); + @Deprecated + int getResourceCountByNameKeyword(ResourceSearchVo searchVo); + @Deprecated int getResourceCountByIpKeyword(ResourceSearchVo searchVo); @Deprecated int getResourceCount(ResourceSearchVo searchVo); - int getResourceCountBySql(String sql); - int getAllResourceCount(ResourceSearchVo searchVo); int getResourceCountByDynamicCondition(@Param("searchVo") ResourceSearchVo searchVo, @Param("conditionSql") String conditionSql); @@ -45,14 +62,10 @@ public interface ResourceMapper extends IResourceCrossoverMapper { @Deprecated List getResourceIdList(ResourceSearchVo searchVo); - List getResourceIdListBySql(String sql); - List getResourceIdListByDynamicCondition(@Param("searchVo") ResourceSearchVo searchVo, @Param("conditionSql") String conditionSql); @Deprecated List getResourceListByIdList(List idList); - List getResourceListBySql(String sql); - int getAppResourceCount(ResourceSearchVo searchVo); List getAppResourceIdList(ResourceSearchVo searchVo); @@ -67,7 +80,7 @@ public interface ResourceMapper extends IResourceCrossoverMapper { List getResourceListByIpAndPortAndName(ResourceSearchVo searchVo); - Long getResourceIdByIpAndPortAndNameWithFilter(ResourceSearchVo searchVo); +// Long getResourceIdByIpAndPortAndNameWithFilter(ResourceSearchVo searchVo); List getResourceListByIpAndPortAndNameWithFilter(ResourceSearchVo searchVo); @@ -96,10 +109,10 @@ public interface ResourceMapper extends IResourceCrossoverMapper { List getAppModuleListByAppSystemIdList(ResourceSearchVo searchVo); List getAppModuleListByIdListSimple(@Param("idList") List idList, @Param("needOrder") boolean needOrder); - + // 该SQL语句可以使用 getResourceListByIpAndPortAndName 代替 List getResourceListByResourceVoList(@Param("resourceList") List resourceList,@Param("searchVo") ResourceSearchVo searchVo); - Set getResourceTypeIdListByAppSystemIdAndModuleIdAndEnvIdAndInspectStatusList(ResourceSearchVo searchVo); +// Set getResourceTypeIdListByAppSystemIdAndModuleIdAndEnvIdAndInspectStatusList(ResourceSearchVo searchVo); List getResourceIdListByAppSystemIdAndModuleIdAndEnvId(ResourceVo resourceVo); 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 0b1f7dbcfb5e2963a5ebcc9b90a7682be0c7f05a..26489062dfe3e5fae8499aeb762840b78a5191da 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 @@ -17,6 +17,46 @@ along with this program. If not, see .--> + + + + + + + + + + + + + + + + + + + + @@ -160,7 +200,7 @@ along with this program. If not, see .--> - + - + - - - - - - - SELECT a.`id`, a.`name`, a.`ip`, a.`port` + SELECT a.`id`, a.`name`, a.`ip`, a.`port`, a.`type_name` AS typeName FROM @{DATA_SCHEMA}.`scence_ipobject_detail` a LEFT JOIN cmdb_cientity_group ccg ON ccg.cientity_id = a.id @@ -880,7 +908,7 @@ along with this program. If not, see .--> #{id} - + - + - + --> - - + --> + SELECT - count(DISTINCT a.id) + count(DISTINCT c.resource_id, c.account_id) FROM `cmdb_resourcecenter_resource_account` c JOIN @{DATA_SCHEMA}.`scence_ipobject_detail` a ON a.id = c.resource_id JOIN `cmdb_resourcecenter_account` b ON b.id = c.account_id @@ -1902,6 +1934,7 @@ along with this program. If not, see .--> and os_id is not null +