diff --git a/src/main/java/neatlogic/module/cmdb/api/resourcecenter/resource/CheckResourceInputNodeListApi.java b/src/main/java/neatlogic/module/cmdb/api/resourcecenter/resource/CheckResourceInputNodeListApi.java index faa9865307f046f907a04ec80b402df1ab74c64e..b7f555b66636eb3a90171883a7feaa8319b8603e 100644 --- a/src/main/java/neatlogic/module/cmdb/api/resourcecenter/resource/CheckResourceInputNodeListApi.java +++ b/src/main/java/neatlogic/module/cmdb/api/resourcecenter/resource/CheckResourceInputNodeListApi.java @@ -23,19 +23,17 @@ import neatlogic.framework.cmdb.auth.label.CMDB; import neatlogic.framework.cmdb.dto.resourcecenter.ResourceSearchVo; import neatlogic.framework.cmdb.dto.resourcecenter.ResourceVo; import neatlogic.framework.common.constvalue.ApiParamType; -import neatlogic.framework.dto.condition.ConditionGroupRelVo; -import neatlogic.framework.dto.condition.ConditionGroupVo; import neatlogic.framework.restful.annotation.*; import neatlogic.framework.restful.constvalue.OperationTypeEnum; import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; import neatlogic.module.cmdb.dao.mapper.resourcecenter.ResourceMapper; import neatlogic.module.cmdb.service.resourcecenter.resource.IResourceCenterResourceService; import org.apache.commons.collections4.CollectionUtils; -import org.apache.commons.collections4.MapUtils; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.ArrayList; +import java.util.Arrays; import java.util.List; import java.util.Objects; @@ -61,7 +59,7 @@ public class CheckResourceInputNodeListApi extends PrivateApiComponentBase { } @Input({ - @Param(name = "filter", type = ApiParamType.JSONOBJECT, desc = "过滤条件", help="简单过滤条件和高级过滤条件都用这个字段"), + @Param(name = "preCondition", type = ApiParamType.JSONOBJECT, desc = "前置过滤器"), @Param(name = "cmdbGroupType", type = ApiParamType.STRING, desc = "通过团体过滤权限"), @Param(name = "inputNodeList", type = ApiParamType.JSONARRAY, isRequired = true, minSize = 1, desc = "输入节点列表"), }) @@ -75,92 +73,42 @@ public class CheckResourceInputNodeListApi extends PrivateApiComponentBase { JSONArray existList = new JSONArray(); JSONArray nonExistList = new JSONArray(); JSONArray inputNodeList = paramObj.getJSONArray("inputNodeList"); - JSONObject filter = paramObj.getJSONObject("filter"); + JSONObject preCondition = paramObj.getJSONObject("preCondition"); String cmdbGroupType = paramObj.getString("cmdbGroupType"); - if (MapUtils.isNotEmpty(filter)) { - // 判断过滤条件是简单模式还是高级模式 - if (filter.containsKey("conditionGroupList")) { - // 高级模式 - ResourceSearchVo searchVo = new ResourceSearchVo(); - JSONArray conditionGroupArray = filter.getJSONArray("conditionGroupList"); - if (CollectionUtils.isNotEmpty(conditionGroupArray)) { - List conditionGroupList = conditionGroupArray.toJavaList(ConditionGroupVo.class); - searchVo.setConditionGroupList(conditionGroupList); - } - JSONArray conditionGroupRelArray = filter.getJSONArray("conditionGroupRelList"); - if (CollectionUtils.isNotEmpty(conditionGroupRelArray)) { - List conditionGroupRelList = conditionGroupRelArray.toJavaList(ConditionGroupRelVo.class); - searchVo.setConditionGroupRelList(conditionGroupRelList); - } - StringBuilder sqlSb = new StringBuilder(); - searchVo.buildConditionWhereSql(sqlSb, searchVo); - searchVo.setPageSize(1); - for (int i = 0; i < inputNodeList.size(); i++) { - JSONObject inputNodeObj = inputNodeList.getJSONObject(i); - ResourceSearchVo node = JSON.toJavaObject(inputNodeObj, ResourceSearchVo.class); - searchVo.setCmdbGroupType(cmdbGroupType); - searchVo.setIp(node.getIp()); - searchVo.setPort(node.getPort()); - searchVo.setName(node.getName()); - searchVo.setCmdbGroupType(cmdbGroupType); - List idList = resourceMapper.getResourceIdListByDynamicCondition(searchVo, sqlSb.toString()); - if (CollectionUtils.isEmpty(idList)) { - if (!nonExistList.contains(inputNodeObj)) { - nonExistList.add(inputNodeObj); - } - - } else { - if (!existList.contains(inputNodeObj)) { - existList.add(inputNodeObj); - } - } - } - } else { - // 简单模式 - List nodeList = new ArrayList<>(); - ResourceSearchVo searchVo = resourceCenterResourceService.assembleResourceSearchVo(filter); - searchVo.setCmdbGroupType(cmdbGroupType); - for (int i = 0; i < inputNodeList.size(); i++) { - JSONObject inputNodeObj = inputNodeList.getJSONObject(i); - ResourceVo node = JSON.toJavaObject(inputNodeObj, ResourceVo.class); - nodeList.add(node); - if (nodeList.size() > 100) { - searchVo.setInputNodeList(nodeList); - List resourceList = resourceMapper.getResourceListByIpAndPortAndNameWithFilter(searchVo); - existsOrNot(nodeList, resourceList, existList, nonExistList); - nodeList.clear(); - } - } - if (CollectionUtils.isNotEmpty(nodeList)) { - searchVo.setInputNodeList(nodeList); - List resourceList = resourceMapper.getResourceListByIpAndPortAndNameWithFilter(searchVo); - existsOrNot(nodeList, resourceList, existList, nonExistList); - nodeList.clear(); - } - } - } else { - // 没有过滤条件 - List nodeList = new ArrayList<>(); - ResourceSearchVo searchVo = resourceCenterResourceService.assembleResourceSearchVo(new JSONObject()); - searchVo.setCmdbGroupType(cmdbGroupType); - for (int i = 0; i < inputNodeList.size(); i++) { - JSONObject inputNodeObj = inputNodeList.getJSONObject(i); - ResourceVo node = JSON.toJavaObject(inputNodeObj, ResourceVo.class); - nodeList.add(node); - if (nodeList.size() > 100) { - searchVo.setInputNodeList(nodeList); - List resourceList = resourceMapper.getResourceListByIpAndPortAndName(searchVo); - existsOrNot(nodeList, resourceList, existList, nonExistList); - nodeList.clear(); - } - } - if (CollectionUtils.isNotEmpty(nodeList)) { + List selectFieldNameList = Arrays.asList("id", "name", "ip", "port"); + List nodeList = new ArrayList<>(); + if (preCondition == null) { + preCondition = new JSONObject(); + } + ResourceSearchVo searchVo = resourceCenterResourceService.assembleResourceSearchVo(preCondition); + searchVo.setCmdbGroupType(cmdbGroupType); + for (int i = 0; i < inputNodeList.size(); i++) { + JSONObject inputNodeObj = inputNodeList.getJSONObject(i); + ResourceVo node = JSON.toJavaObject(inputNodeObj, ResourceVo.class); + nodeList.add(node); + if (nodeList.size() > 100) { searchVo.setInputNodeList(nodeList); - List resourceList = resourceMapper.getResourceListByIpAndPortAndName(searchVo); + searchVo.setPageSize(500); + List resourceList = new ArrayList<>(); + List idList = resourceCenterResourceService.getResourceIdList(searchVo); + if (CollectionUtils.isNotEmpty(idList)) { + resourceList = resourceCenterResourceService.getResourceListByIdList(idList, selectFieldNameList); + } existsOrNot(nodeList, resourceList, existList, nonExistList); nodeList.clear(); } } + if (CollectionUtils.isNotEmpty(nodeList)) { + searchVo.setInputNodeList(nodeList); + searchVo.setPageSize(500); + List resourceList = new ArrayList<>(); + List idList = resourceCenterResourceService.getResourceIdList(searchVo); + if (CollectionUtils.isNotEmpty(idList)) { + resourceList = resourceCenterResourceService.getResourceListByIdList(idList, selectFieldNameList); + } + existsOrNot(nodeList, resourceList, existList, nonExistList); + nodeList.clear(); + } JSONObject resultObj = new JSONObject(); resultObj.put("existList", existList); resultObj.put("nonExistList", nonExistList); diff --git a/src/main/java/neatlogic/module/cmdb/api/resourcecenter/resource/ExportResourceApi.java b/src/main/java/neatlogic/module/cmdb/api/resourcecenter/resource/ExportResourceApi.java index f1de6a864091b1e82e64cba95d8d4d828663e923..8faace56e2fca5972c78be5b3b62ad75ae4a00ee 100644 --- a/src/main/java/neatlogic/module/cmdb/api/resourcecenter/resource/ExportResourceApi.java +++ b/src/main/java/neatlogic/module/cmdb/api/resourcecenter/resource/ExportResourceApi.java @@ -133,7 +133,7 @@ public class ExportResourceApi extends PrivateBinaryStreamApiComponentBase { JSONArray defaultValue = paramObj.getJSONArray("defaultValue"); if (CollectionUtils.isNotEmpty(defaultValue)) { List idList = defaultValue.toJavaList(Long.class); - resourceList = resourceMapper.getResourceListByIdList(idList); + resourceList = resourceCenterResourceService.getResourceListByIdList(idList); resourceCenterResourceService.addTagAndAccountInformation(resourceList); for (ResourceVo resourceVo : resourceList) { Map dataMap = resourceConvertDataMap(resourceVo); @@ -141,18 +141,24 @@ public class ExportResourceApi extends PrivateBinaryStreamApiComponentBase { } } else { ResourceSearchVo searchVo = resourceCenterResourceService.assembleResourceSearchVo(paramObj); - resourceCenterResourceService.handleBatchSearchList(searchVo); - resourceCenterResourceService.setIpFieldAttrIdAndNameFieldAttrId(searchVo); - int rowNum = resourceMapper.getResourceCount(searchVo); +// resourceCenterResourceService.handleBatchSearchList(searchVo); +// resourceCenterResourceService.setIpFieldAttrIdAndNameFieldAttrId(searchVo); +// //是否存在前置条件 +// if (searchVo.getPreCondition() != null && searchVo.getPreCondition().isCustomCondition()) { +// StringBuilder preSqlSb = new StringBuilder(); +// searchVo.getPreCondition().buildConditionWhereSql(preSqlSb, searchVo.getPreCondition()); +// searchVo.getPreCondition().setConditionWhereSql(preSqlSb.toString()); +// } + int rowNum = resourceCenterResourceService.getResourceCount(searchVo); if (rowNum > 0) { searchVo.setPageSize(100); searchVo.setRowNum(rowNum); - resourceCenterResourceService.setIsIpFieldSortAndIsNameFieldSort(searchVo); +// resourceCenterResourceService.setIsIpFieldSortAndIsNameFieldSort(searchVo); for (int i = 1; i <= searchVo.getPageCount(); i++) { searchVo.setCurrentPage(i); - List idList = resourceMapper.getResourceIdList(searchVo); + List idList = resourceCenterResourceService.getResourceIdList(searchVo); if (CollectionUtils.isNotEmpty(idList)) { - resourceList = resourceMapper.getResourceListByIdList(idList); + resourceList = resourceCenterResourceService.getResourceListByIdList(idList); resourceCenterResourceService.addTagAndAccountInformation(resourceList); for (ResourceVo resourceVo : resourceList) { Map dataMap = resourceConvertDataMap(resourceVo); @@ -172,6 +178,7 @@ public class ExportResourceApi extends PrivateBinaryStreamApiComponentBase { /** * 表头信息 + * * @return */ private List getHeaderList() { @@ -198,6 +205,7 @@ public class ExportResourceApi extends PrivateBinaryStreamApiComponentBase { /** * 每列对应的key + * * @return */ private List getColumnList() { @@ -224,6 +232,7 @@ public class ExportResourceApi extends PrivateBinaryStreamApiComponentBase { /** * 资产对象转换成excel中一行数据dataMap + * * @param resourceVo 资产对象 */ private Map resourceConvertDataMap(ResourceVo resourceVo) { diff --git a/src/main/java/neatlogic/module/cmdb/api/resourcecenter/resource/ListResourceCustomApi.java b/src/main/java/neatlogic/module/cmdb/api/resourcecenter/resource/ListResourceCustomApi.java index cbb2518c937ecd498cd46aa86856a981c98988ac..45718a51b54910669f281781ba0aa3ecb54d1ecf 100644 --- a/src/main/java/neatlogic/module/cmdb/api/resourcecenter/resource/ListResourceCustomApi.java +++ b/src/main/java/neatlogic/module/cmdb/api/resourcecenter/resource/ListResourceCustomApi.java @@ -78,15 +78,24 @@ public class ListResourceCustomApi extends PrivateApiComponentBase { ResourceSearchVo resourceSearch = resourceCenterResourceService.assembleResourceSearchVo(paramObj); List resultList = new ArrayList<>(); StringBuilder sqlSb = new StringBuilder(); - resourceSearch.buildConditionWhereSql(sqlSb, resourceSearch); - int rowNum = resourceMapper.getResourceCountByDynamicCondition(resourceSearch, sqlSb.toString()); + //是否存在前置条件 +// if (resourceSearch.getPreCondition() != null && resourceSearch.getPreCondition().isCustomCondition()) { +// StringBuilder preSqlSb = new StringBuilder(); +// resourceSearch.getPreCondition().buildConditionWhereSql(preSqlSb, resourceSearch.getPreCondition()); +// resourceSearch.setConditionWhereSql(preSqlSb.toString()); +// } +// resourceSearch.buildConditionWhereSql(sqlSb, resourceSearch); +// resourceSearch.setConditionWhereSql(sqlSb.toString()); +// int rowNum = resourceMapper.getResourceCountByDynamicCondition(resourceSearch); + int rowNum = resourceCenterResourceService.getResourceCount(resourceSearch); if (rowNum == 0) { return TableResultUtil.getResult(resultList, resourceSearch); } resourceSearch.setRowNum(rowNum); - List idList = resourceMapper.getResourceIdListByDynamicCondition(resourceSearch, sqlSb.toString()); +// List idList = resourceMapper.getResourceIdListByDynamicCondition(resourceSearch); + List idList = resourceCenterResourceService.getResourceIdList(resourceSearch); if (CollectionUtils.isNotEmpty(idList)) { - List resourceList = resourceMapper.getResourceListByIdList(idList); + List resourceList = resourceCenterResourceService.getResourceListByIdList(idList); if (CollectionUtils.isNotEmpty(resourceList)) { resourceCenterResourceService.addTagAndAccountInformation(resourceList); } diff --git a/src/main/java/neatlogic/module/cmdb/api/resourcecenter/resource/ResourceAccountBatchAddApi.java b/src/main/java/neatlogic/module/cmdb/api/resourcecenter/resource/ResourceAccountBatchAddApi.java index 4e8eebe529a55c6c952000363497877792f5c740..7dae43b32efea8e70ac3ee380b273fd716ea0373 100644 --- a/src/main/java/neatlogic/module/cmdb/api/resourcecenter/resource/ResourceAccountBatchAddApi.java +++ b/src/main/java/neatlogic/module/cmdb/api/resourcecenter/resource/ResourceAccountBatchAddApi.java @@ -33,6 +33,7 @@ import neatlogic.framework.restful.constvalue.OperationTypeEnum; import neatlogic.framework.restful.core.privateapi.PrivateApiComponentBase; import neatlogic.module.cmdb.dao.mapper.resourcecenter.ResourceAccountMapper; import neatlogic.module.cmdb.dao.mapper.resourcecenter.ResourceMapper; +import neatlogic.module.cmdb.service.resourcecenter.resource.IResourceCenterResourceService; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.ListUtils; import org.springframework.stereotype.Service; @@ -52,7 +53,7 @@ import java.util.*; public class ResourceAccountBatchAddApi extends PrivateApiComponentBase { @Resource - private ResourceMapper resourceMapper; + private IResourceCenterResourceService resourceCenterResourceService; @Resource private ResourceAccountMapper resourceAccountMapper; @@ -87,7 +88,7 @@ public class ResourceAccountBatchAddApi extends PrivateApiComponentBase { List resourceIdList = resourceIdArray.toJavaList(Long.class); Map resourceVoMap = new HashMap<>(); List existResourceIdList = new ArrayList<>(); - List resourceVoList = resourceMapper.getResourceListByIdList(resourceIdList); + List resourceVoList = resourceCenterResourceService.getResourceListByIdList(resourceIdList); for (ResourceVo resourceVo : resourceVoList) { resourceVoMap.put(resourceVo.getId(), resourceVo); existResourceIdList.add(resourceVo.getId()); diff --git a/src/main/java/neatlogic/module/cmdb/api/resourcecenter/resource/ResourceListApi.java b/src/main/java/neatlogic/module/cmdb/api/resourcecenter/resource/ResourceListApi.java index 12cdf650d05899d4e2009154e0fde5907be94cc3..32983b63dc7f1b99c5b236ead905abf49fb8d496 100644 --- a/src/main/java/neatlogic/module/cmdb/api/resourcecenter/resource/ResourceListApi.java +++ b/src/main/java/neatlogic/module/cmdb/api/resourcecenter/resource/ResourceListApi.java @@ -105,15 +105,21 @@ public class ResourceListApi extends PrivateApiComponentBase { @Override public Object myDoService(JSONObject jsonObj) throws Exception { ResourceSearchVo searchVo; + ResourceSearchVo preCondition = null; JSONArray defaultValue = jsonObj.getJSONArray("defaultValue"); + //先处理前置过滤器 + if (jsonObj.containsKey("preCondition")) { + preCondition = resourceCenterResourceService.assembleResourceSearchVo(jsonObj.getJSONObject("preCondition")); + } if (CollectionUtils.isNotEmpty(defaultValue)) { searchVo = new ResourceSearchVo(); searchVo.setDefaultValue(defaultValue); } else { searchVo = resourceCenterResourceService.assembleResourceSearchVo(jsonObj); } - resourceCenterResourceService.handleBatchSearchList(searchVo); - resourceCenterResourceService.setIpFieldAttrIdAndNameFieldAttrId(searchVo); + searchVo.setPreCondition(preCondition); +// resourceCenterResourceService.handleBatchSearchList(searchVo); +// resourceCenterResourceService.setIpFieldAttrIdAndNameFieldAttrId(searchVo); IResourceCenterDataSource resourceCenterDataSource = ResourceCenterDataSourceFactory.getResourceCenterDataSource(); List resultList = resourceCenterDataSource.getResourceList(searchVo); if (CollectionUtils.isNotEmpty(resultList)) { 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 9953a9998f1465b85477e7f602fd165a078a44a0..5fcfd59158be33f49316c0cbc3bdb9445317008a 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 @@ -55,14 +55,9 @@ public interface ResourceMapper extends IResourceCrossoverMapper { @Deprecated int getResourceCount(ResourceSearchVo searchVo); - int getAllResourceCount(ResourceSearchVo searchVo); - - int getResourceCountByDynamicCondition(@Param("searchVo") ResourceSearchVo searchVo, @Param("conditionSql") String conditionSql); - @Deprecated List getResourceIdList(ResourceSearchVo searchVo); - List getResourceIdListByDynamicCondition(@Param("searchVo") ResourceSearchVo searchVo, @Param("conditionSql") String conditionSql); @Deprecated List getResourceListByIdList(List idList); @@ -74,16 +69,6 @@ public interface ResourceMapper extends IResourceCrossoverMapper { List getAppInstanceResourceListByIdListSimple(List idList); - Long getResourceIdByIpAndPortAndName(ResourceSearchVo searchVo); - - List getResourceIdListByIpAndPortAndName(ResourceSearchVo searchVo); - - List getResourceListByIpAndPortAndName(ResourceSearchVo searchVo); - -// Long getResourceIdByIpAndPortAndNameWithFilter(ResourceSearchVo searchVo); - - List getResourceListByIpAndPortAndNameWithFilter(ResourceSearchVo searchVo); - List getResourceByIdList(List idList); List getAuthResourceList(ResourceSearchVo searchVo); @@ -109,10 +94,6 @@ 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); 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 7947f1a2cdf78ddfce11222f4486bebd7768df58..d13fb31832c46bd7437fae5d8541a79192b3a1a2 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 @@ -29,7 +29,8 @@ along with this program. If not, see .--> ${sql} - ${sql} @@ -37,7 +38,8 @@ along with this program. If not, see .--> ${sql} - ${sql} @@ -45,7 +47,8 @@ along with this program. If not, see .--> ${sql} - ${sql} @@ -79,7 +82,7 @@ along with this program. If not, see .--> or ( - cg.id is not null and + cg.id is not null and a.`type_id` IN #{typeId} @@ -180,26 +183,105 @@ along with this program. If not, see .--> #{tagId} - + + AND fw.word IN + + #{item} + + + + AND fw2.word IN + + #{item} + + AND ajpn.status in #{status} + + and + + ( + a.`ip` = #{item.ip} + + + AND a.`port` = #{item.port} + + + AND a.`port` is null + + + + and a.`name` = #{item.name} + + ) + + + + + + + AND a.`type_id` IN + + #{typeId} + + + + AND a.`state_id` IN + + #{stateId} + + + + AND a.`vendor_id` IN + + #{vendorId} + + + + AND a.`env_id` IN + + #{envId} + + + + AND a.`env_id` is null + + + AND a.`app_system_id` IN + + #{appSystemId} + + + + AND a.`app_module_id` IN + + #{appModuleId} + + + + AND c.`protocol_id` IN + + #{protocolId} + + + + AND d.`tag_id` IN + + #{tagId} + + + + AND fw.word IN + + #{item} + + + - - + - - @@ -553,7 +512,8 @@ along with this program. If not, see .--> - + @@ -632,35 +592,37 @@ along with this program. If not, see .--> - SELECT COUNT(DISTINCT `id`) FROM @{DATA_SCHEMA}.`${viewName}` a - - AND a.`app_system_id` = #{appSystemId} - - - AND a.`app_module_id` = #{appModuleId} - - - AND a.`env_id` = #{envId} - - - AND a.`env_id` is null - - - AND a.`type_id` = #{typeId} - - - AND a.`inspect_status` IN - - #{inspectStatus} - - + + AND a.`app_system_id` = #{appSystemId} + + + AND a.`app_module_id` = #{appModuleId} + + + AND a.`env_id` = #{envId} + + + AND a.`env_id` is null + + + AND a.`type_id` = #{typeId} + + + AND a.`inspect_status` IN + + #{inspectStatus} + + - SELECT DISTINCT a.`id` FROM @{DATA_SCHEMA}.`${viewName}` a @@ -690,7 +652,8 @@ along with this program. If not, see .--> LIMIT #{startNum}, #{pageSize} - SELECT a.`id`, a.`name`, @@ -749,155 +712,40 @@ along with this program. If not, see .--> AND a.`env_id` = #{envId} - - AND a.`env_id` is null - - - - - - - - - - + + - - - - - - - - - + SELECT a.`id`, + a.`name`, + a.`ip`, + a.`type_id` AS typeId, + a.`type_name` AS typeName, + a.`type_label` AS typeLabel + FROM @{DATA_SCHEMA}.`scence_os` a WHERE a.`ip` = #{ip} LIMIT 1 @@ -1340,21 +1042,21 @@ along with this program. If not, see .--> @@ -1484,23 +1185,21 @@ along with this program. If not, see .--> @@ -1739,9 +1438,9 @@ along with this program. If not, see .--> - SELECT IFNULL(a.env_id, -2) as id, - IFNULL(a.env_name, '未配置') as name, - IFNULL(a.env_seq_no, 9999) as seqNo, - a.app_module_id as moduleId, - a.app_module_name as moduleName, - a.app_module_abbr_name as moduleAbbrName, - a.type_id as typeId, - a.type_name as typeName, - a.type_label as typeLabel + SELECT IFNULL(a.env_id, -2) as id, + IFNULL(a.env_name, '未配置') as name, + IFNULL(a.env_seq_no, 9999) as seqNo, + a.app_module_id as moduleId, + a.app_module_name as moduleName, + a.app_module_abbr_name as moduleAbbrName, + a.type_id as typeId, + a.type_name as typeName, + a.type_label as typeLabel FROM @{DATA_SCHEMA}.`${viewName}` a WHERE a.`app_system_id` = #{appSystemId} @@ -1818,123 +1517,29 @@ along with this program. If not, see .--> - + SELECT a.`app_module_id` AS appModuleId, + COUNT(DISTINCT a.`env_id`) AS count FROM @{DATA_SCHEMA}.`scence_ipobject_detail` a WHERE a.`app_system_id` = #{value} AND a.`env_id` IS NOT NULL GROUP BY a.`app_module_id` - - - AND sid.`id` IN - - #{id} - - - - - AND sid.`type_id` IN - - #{typeId} - - - - AND ( - - - sid.`type_id` IN - - #{authedTypeId} - - - - 1 = 0 - - - or ( - cg.id is not null and - sid.`type_id` IN - - #{typeId} - - and - ((cga.auth_type = 'common' AND cga.auth_uuid = 'alluser') - - OR ( - cga.auth_type = 'user' - AND - cga.auth_uuid = #{searchVo.authenticationInfo.userUuid} - ) - - - OR ( - cga.auth_type = 'team' - AND - cga.auth_uuid IN - - #{item} - - ) - - - OR ( - cga.auth_type = 'role' - AND - cga.auth_uuid IN - - #{item} - ) - - ) - ) - ) - - - - - diff --git a/src/main/java/neatlogic/module/cmdb/dependency/ResourceAccountDependencyHandler.java b/src/main/java/neatlogic/module/cmdb/dependency/ResourceAccountDependencyHandler.java index 2c5eed967a5f4904ae0e18bdb8d07676686e04e4..7ee5608372d1ba722da7062f64ab96d6c7e53ea2 100644 --- a/src/main/java/neatlogic/module/cmdb/dependency/ResourceAccountDependencyHandler.java +++ b/src/main/java/neatlogic/module/cmdb/dependency/ResourceAccountDependencyHandler.java @@ -9,6 +9,7 @@ import neatlogic.framework.dependency.core.IFromType; import neatlogic.framework.dependency.dto.DependencyInfoVo; import neatlogic.module.cmdb.dao.mapper.resourcecenter.ResourceAccountMapper; import neatlogic.module.cmdb.dao.mapper.resourcecenter.ResourceMapper; +import neatlogic.module.cmdb.service.resourcecenter.resource.IResourceCenterResourceService; import org.springframework.stereotype.Service; import javax.annotation.Resource; @@ -26,7 +27,7 @@ public class ResourceAccountDependencyHandler extends CustomDependencyHandlerBas ResourceAccountMapper resourceAccountMapper; @Resource - ResourceMapper resourceMapper; + private IResourceCenterResourceService resourceCenterResourceService; @Override protected String getTableName() { @@ -73,7 +74,7 @@ public class ResourceAccountDependencyHandler extends CustomDependencyHandlerBas List resultList = new ArrayList<>(); List resourceIdList = resourceAccountMapper.getResourceIdListByAccountIdWithPage((Long) from, startNum, pageSize); if (resourceIdList.size() > 0) { - List resourceList = resourceMapper.getResourceListByIdList(resourceIdList); + List resourceList = resourceCenterResourceService.getResourceListByIdList(resourceIdList); for (ResourceVo vo : resourceList) { DependencyInfoVo dependencyInfoVo = parse(vo); if (dependencyInfoVo != null) { diff --git a/src/main/java/neatlogic/module/cmdb/formattribute/handler/ResourcesHandler.java b/src/main/java/neatlogic/module/cmdb/formattribute/handler/ResourcesHandler.java index 4a1cdceba517ca76482a5ba96cfa477499a704b8..a8ae665ff1a4f5d40815628d198c3184de6c230a 100644 --- a/src/main/java/neatlogic/module/cmdb/formattribute/handler/ResourcesHandler.java +++ b/src/main/java/neatlogic/module/cmdb/formattribute/handler/ResourcesHandler.java @@ -33,18 +33,15 @@ import neatlogic.framework.form.exception.AttributeValidException; import neatlogic.module.cmdb.dao.mapper.ci.CiMapper; import neatlogic.module.cmdb.dao.mapper.cientity.CiEntityMapper; import neatlogic.module.cmdb.dao.mapper.resourcecenter.ResourceAccountMapper; -import neatlogic.module.cmdb.dao.mapper.resourcecenter.ResourceMapper; import neatlogic.module.cmdb.dao.mapper.resourcecenter.ResourceTagMapper; +import neatlogic.module.cmdb.service.resourcecenter.resource.IResourceCenterResourceService; import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; import org.springframework.stereotype.Component; import javax.annotation.Resource; -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.util.*; import java.util.stream.Collectors; /** @@ -55,7 +52,7 @@ import java.util.stream.Collectors; public class ResourcesHandler extends FormHandlerBase { @Resource - private ResourceMapper resourceMapper; + private IResourceCenterResourceService resourceCenterResourceService; @Resource private ResourceAccountMapper resourceAccountMapper; @Resource @@ -151,6 +148,7 @@ public class ResourcesHandler extends FormHandlerBase { if ("input".equals(type)) { JSONArray inputNodeArray = dataObj.getJSONArray("inputNodeList"); if (CollectionUtils.isNotEmpty(inputNodeArray)) { + List selectFieldNameList = Arrays.asList("id", "name", "ip", "port"); List resourceIsNotFoundList = new ArrayList<>(); ResourceSearchVo searchVo = new ResourceSearchVo(); searchVo.setIsHasAuth(true); @@ -161,7 +159,11 @@ public class ResourcesHandler extends FormHandlerBase { nodeList.add(node); if (nodeList.size() > 100) { searchVo.setInputNodeList(nodeList); - List resourceList = resourceMapper.getResourceListByIpAndPortAndName(searchVo); + List resourceList = new ArrayList<>(); + List idList = resourceCenterResourceService.getResourceIdList(searchVo); + if (CollectionUtils.isNotEmpty(idList)) { + resourceList = resourceCenterResourceService.getResourceListByIdList(idList, selectFieldNameList); + } List notExistsNodeList = notExistsNodeList(nodeList, resourceList); resourceIsNotFoundList.addAll(notExistsNodeList); nodeList.clear(); @@ -169,7 +171,11 @@ public class ResourcesHandler extends FormHandlerBase { } if (CollectionUtils.isNotEmpty(nodeList)) { searchVo.setInputNodeList(nodeList); - List resourceList = resourceMapper.getResourceListByIpAndPortAndName(searchVo); + List resourceList = new ArrayList<>(); + List idList = resourceCenterResourceService.getResourceIdList(searchVo); + if (CollectionUtils.isNotEmpty(idList)) { + resourceList = resourceCenterResourceService.getResourceListByIdList(idList, selectFieldNameList); + } List notExistsNodeList = notExistsNodeList(nodeList, resourceList); resourceIsNotFoundList.addAll(notExistsNodeList); nodeList.clear(); 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 dfde5ca6df66135f78e7f2a7b863173372e13b74..5dff3302ddbc7ae9191780a254f698039fa47b06 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,7 +28,6 @@ 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.enums.CmdbTenantConfig; import neatlogic.framework.cmdb.exception.ci.CiNotFoundException; import neatlogic.framework.cmdb.exception.resourcecenter.AppModuleNotFoundException; import neatlogic.framework.cmdb.exception.resourcecenter.AppSystemNotFoundException; @@ -37,7 +36,6 @@ import neatlogic.framework.cmdb.resourcecenter.datasource.core.Ordered; import neatlogic.framework.common.constvalue.InspectStatus; import neatlogic.framework.common.dto.BasePageVo; import neatlogic.framework.common.dto.ValueTextVo; -import neatlogic.framework.config.ConfigManager; import neatlogic.framework.util.TableResultUtil; import neatlogic.module.cmdb.dao.mapper.ci.CiMapper; import neatlogic.module.cmdb.dao.mapper.cientity.CiEntityCachedMapper; @@ -337,6 +335,7 @@ public class DefaultResourceCenterDataSourceImpl implements IResourceCenterDataS resultObj.put("isVirtual", ciEntityVo.getIsVirtual()); return resultObj; } + @Override public Ordered getOrdered() { return Ordered.LOWEST_PRECEDENCE; @@ -647,26 +646,10 @@ public class DefaultResourceCenterDataSourceImpl implements IResourceCenterDataS @Override public List getResourceList(ResourceSearchVo searchVo) { - String enable = ConfigManager.getConfig(CmdbTenantConfig.RESOURCECENTER_DATA_COMPARISON_MODE_ENABLE); List resultList = new ArrayList<>(); - String getResourceIdListSql = resourceBuildSqlService.buildGetResourceIdListSql(searchVo); - List idList = resourceMapper.getIdListBySql(getResourceIdListSql); - if (Objects.equals(enable, "1")) { - List oldIdList = resourceMapper.getResourceIdList(searchVo); - if (!Objects.equals(oldIdList, idList)) { - JSONObject errorObj = new JSONObject(); - errorObj.put("idList", idList); - errorObj.put("oldIdList", oldIdList); - logger.error("资产清单新旧SQL获取idList结果不一致:{}", errorObj); - } - } + List idList = resourceCenterResourceService.getResourceIdList(searchVo); if (CollectionUtils.isNotEmpty(idList)) { - String getResourceListSql = resourceBuildSqlService.buildGetResourceListSql(idList); - List resourceList = resourceMapper.getResourceListBySql(getResourceListSql); - if (Objects.equals(enable, "1")) { - List oldResourceList = resourceMapper.getResourceListByIdList(idList); - checkResourceListIsEquals(resourceList, oldResourceList); - } + List resourceList = resourceCenterResourceService.getResourceListByIdList(idList); //排序 for (Long id : idList) { for (ResourceVo resourceVo : resourceList) { @@ -677,32 +660,7 @@ public class DefaultResourceCenterDataSourceImpl implements IResourceCenterDataS } } if (Objects.equals(searchVo.getRowNum(), 0)) { - String getResourceCountSql = resourceBuildSqlService.buildGetResourceCountSql(searchVo); - int rowNum = resourceMapper.getCountBySql(getResourceCountSql); - if (Objects.equals(enable, "1")) { - int oldRowNum = 0; - if (noFilterCondition(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)); - oldRowNum = resourceMapper.getAllResourceCount(searchVo); - } - } - } - } else { - oldRowNum = resourceMapper.getResourceCount(searchVo); - } - if (oldRowNum != rowNum) { - JSONObject errorObj = new JSONObject(); - errorObj.put("rowNum", rowNum); - errorObj.put("oldRowNum", oldRowNum); - logger.error("资产清单新旧SQL获取rowNum结果不一致:{}", errorObj); - } - } + int rowNum = resourceCenterResourceService.getResourceCount(searchVo); searchVo.setRowNum(rowNum); } } else { @@ -1273,6 +1231,7 @@ public class DefaultResourceCenterDataSourceImpl implements IResourceCenterDataS /** * 判断是否有过滤条件 + * * @param searchVo * @return */ diff --git a/src/main/java/neatlogic/module/cmdb/service/resourcecenter/resource/IResourceCenterResourceService.java b/src/main/java/neatlogic/module/cmdb/service/resourcecenter/resource/IResourceCenterResourceService.java index 56ab8ab04234e9b653449f02c1b0cbdf9a10b4c8..86e49964d2b09c50e416f3864081d4617c652b1d 100644 --- a/src/main/java/neatlogic/module/cmdb/service/resourcecenter/resource/IResourceCenterResourceService.java +++ b/src/main/java/neatlogic/module/cmdb/service/resourcecenter/resource/IResourceCenterResourceService.java @@ -115,13 +115,13 @@ public interface IResourceCenterResourceService { List getAppResourceListByIdList(ResourceSearchVo searchVo); - Long getResourceIdByIpAndPortAndName(ResourceSearchVo searchVo); +// Long getResourceIdByIpAndPortAndName(ResourceSearchVo searchVo); - List getResourceIdListByIpAndPortAndName(ResourceSearchVo searchVo); +// List getResourceIdListByIpAndPortAndName(ResourceSearchVo searchVo); - List getResourceListByIpAndPortAndName(ResourceSearchVo searchVo); +// List getResourceListByIpAndPortAndName(ResourceSearchVo searchVo); - List getResourceListByIpAndPortAndNameWithFilter(ResourceSearchVo searchVo); +// List getResourceListByIpAndPortAndNameWithFilter(ResourceSearchVo searchVo); List getResourceByIdList(List idList); diff --git a/src/main/java/neatlogic/module/cmdb/service/resourcecenter/resource/ResourceBuildSqlServiceImpl.java b/src/main/java/neatlogic/module/cmdb/service/resourcecenter/resource/ResourceBuildSqlServiceImpl.java index 2a741f5a93efdb811898cbad3a522746f64838f2..b7669782e5f79ea10702d021736b2984c2346720 100644 --- a/src/main/java/neatlogic/module/cmdb/service/resourcecenter/resource/ResourceBuildSqlServiceImpl.java +++ b/src/main/java/neatlogic/module/cmdb/service/resourcecenter/resource/ResourceBuildSqlServiceImpl.java @@ -173,17 +173,27 @@ public class ResourceBuildSqlServiceImpl implements ResourceBuildSqlService, IRe try { ResourceEntityVo resourceEntityVo = resourceEntityMapper.getResourceEntityByName("scence_ipobject_detail"); ResourceEntityConfigVo config = getResourceEntityConfigVo(resourceEntityVo); + List filterItemFieldNameList = new ArrayList<>(); + ResourceQueryCriteriaVo preConditionQueryCriteriaVo = null; + ResourceSearchVo preCondition = searchVo.getPreCondition(); + if (preCondition != null) { + preConditionQueryCriteriaVo = new ResourceQueryCriteriaVo(preCondition); + filterItemFieldNameList.addAll(getFilterItemFieldNameList(preConditionQueryCriteriaVo)); + } ResourceQueryCriteriaVo queryCriteriaVo = new ResourceQueryCriteriaVo(searchVo); + filterItemFieldNameList.addAll(getFilterItemFieldNameList(queryCriteriaVo)); + filterItemFieldNameList.add("id"); + config.setFilterItemFieldNameList(filterItemFieldNameList); List selectItemFieldNameList = new ArrayList<>(); selectItemFieldNameList.add("id"); - List filterItemFieldNameList = getFilterItemFieldNameList(queryCriteriaVo); - filterItemFieldNameList.add("id"); config.setSelectItemFieldNameList(selectItemFieldNameList); - config.setFilterItemFieldNameList(filterItemFieldNameList); Map fieldName2ColumnMap = new HashMap<>(); PlainSelect plainSelect = getPlainSelect(config, fieldName2ColumnMap); - - SqlVo sqlVo = getSqlVoForResource(queryCriteriaVo, fieldName2ColumnMap); + SqlVo sqlVo = new SqlVo(); + if (preConditionQueryCriteriaVo != null) { + getSqlVoForResource(sqlVo, preConditionQueryCriteriaVo, fieldName2ColumnMap); + } + getSqlVoForResource(sqlVo, queryCriteriaVo, fieldName2ColumnMap); $sql.addSql(plainSelect, sqlVo); if (CollectionUtils.isNotEmpty(searchVo.getKeywordList()) && searchVo.getNameFieldAttrId() != null && searchVo.getIpFieldAttrId() != null) { $sql.addOrderBy(plainSelect, $sql.fun("COUNT", "fw.word").withDistinct(true), "desc"); @@ -206,16 +216,27 @@ public class ResourceBuildSqlServiceImpl implements ResourceBuildSqlService, IRe try { ResourceEntityVo resourceEntityVo = resourceEntityMapper.getResourceEntityByName("scence_ipobject_detail"); ResourceEntityConfigVo config = getResourceEntityConfigVo(resourceEntityVo); + List filterItemFieldNameList = new ArrayList<>(); + ResourceQueryCriteriaVo preConditionQueryCriteriaVo = null; + ResourceSearchVo preCondition = searchVo.getPreCondition(); + if (preCondition != null) { + preConditionQueryCriteriaVo = new ResourceQueryCriteriaVo(preCondition); + filterItemFieldNameList.addAll(getFilterItemFieldNameList(preConditionQueryCriteriaVo)); + } ResourceQueryCriteriaVo queryCriteriaVo = new ResourceQueryCriteriaVo(searchVo); + filterItemFieldNameList.addAll(getFilterItemFieldNameList(queryCriteriaVo)); + filterItemFieldNameList.add("id"); + config.setFilterItemFieldNameList(filterItemFieldNameList); List selectItemFieldNameList = new ArrayList<>(); selectItemFieldNameList.add("id"); - List filterItemFieldNameList = getFilterItemFieldNameList(queryCriteriaVo); - filterItemFieldNameList.add("id"); config.setSelectItemFieldNameList(selectItemFieldNameList); - config.setFilterItemFieldNameList(filterItemFieldNameList); Map fieldName2ColumnMap = new HashMap<>(); PlainSelect plainSelect = getPlainSelect(config, fieldName2ColumnMap); - SqlVo sqlVo = getSqlVoForResource(queryCriteriaVo, fieldName2ColumnMap); + SqlVo sqlVo = new SqlVo(); + if (preConditionQueryCriteriaVo != null) { + getSqlVoForResource(sqlVo, preConditionQueryCriteriaVo, fieldName2ColumnMap); + } + getSqlVoForResource(sqlVo, queryCriteriaVo, fieldName2ColumnMap); $sql.addSql(plainSelect, sqlVo); Column column = fieldName2ColumnMap.get("id"); $sql.setSelectColumn(plainSelect, $sql.fun("COUNT", column.toString()).withDistinct(true)); @@ -275,8 +296,6 @@ public class ResourceBuildSqlServiceImpl implements ResourceBuildSqlService, IRe ResourceEntityConfigVo config = getResourceEntityConfigVo(resourceEntityVo); ResourceQueryCriteriaVo queryCriteriaVo = new ResourceQueryCriteriaVo(searchVo); queryCriteriaVo.setInspectJobPhaseNodeStatusList(null); - queryCriteriaVo.setBatchSearchList(null); - queryCriteriaVo.setIpFieldAttrId(null); List selectItemFieldNameList = new ArrayList<>(); selectItemFieldNameList.add("id"); List filterItemFieldNameList = getFilterItemFieldNameList(queryCriteriaVo); @@ -303,8 +322,6 @@ public class ResourceBuildSqlServiceImpl implements ResourceBuildSqlService, IRe ResourceEntityConfigVo config = getResourceEntityConfigVo(resourceEntityVo); ResourceQueryCriteriaVo queryCriteriaVo = new ResourceQueryCriteriaVo(searchVo); queryCriteriaVo.setInspectJobPhaseNodeStatusList(null); - queryCriteriaVo.setBatchSearchList(null); - queryCriteriaVo.setNameFieldAttrId(null); List selectItemFieldNameList = new ArrayList<>(); selectItemFieldNameList.add("id"); List filterItemFieldNameList = getFilterItemFieldNameList(queryCriteriaVo); @@ -1016,33 +1033,18 @@ public class ResourceBuildSqlServiceImpl implements ResourceBuildSqlService, IRe filterItemFieldNameList.add("id"); ResourceQueryCriteriaVo queryCriteriaVo = new ResourceQueryCriteriaVo(searchVo); List filterItemFieldNameList1 = getFilterItemFieldNameList(queryCriteriaVo); - System.out.println("filterItemFieldNameList1 = " + filterItemFieldNameList1); filterItemFieldNameList.addAll(filterItemFieldNameList1); JSONObject conditionConfigObj = new JSONObject(); conditionConfigObj.put("conditionGroupList", searchVo.getConditionGroupList()); conditionConfigObj.put("conditionGroupRelList", searchVo.getConditionGroupRelList()); ResourceConditionConfigVo resourceConditionConfigVo = conditionConfigObj.toJavaObject(ResourceConditionConfigVo.class); List filterItemFieldNameList2 = resourceConditionConfigVo.getFilterItemFieldNameList(); - System.out.println("filterItemFieldNameList2 = " + filterItemFieldNameList2); filterItemFieldNameList.addAll(filterItemFieldNameList2); config.setSelectItemFieldNameList(selectItemFieldNameList); config.setFilterItemFieldNameList(filterItemFieldNameList); Map fieldName2ColumnMap = new HashMap<>(); PlainSelect plainSelect = getPlainSelect(config, fieldName2ColumnMap); $sql.addSelectColumn(plainSelect, $sql.fun("count", fieldName2ColumnMap.get("id").toString()).withDistinct(true)); - /* - - AND (a.`name` LIKE CONCAT('%', #{keyword}, '%') OR a.`ip` LIKE CONCAT('%', #{keyword}, '%')) - - */ - if (StringUtils.isNotBlank(queryCriteriaVo.getKeyword())) { - String keyword = "'%" + queryCriteriaVo.getKeyword() + "%'"; - $sql.addWhereExpression(plainSelect, $sql.exp("(", - $sql.exp(fieldName2ColumnMap.get("name").toString(), "like", keyword), - "or", $sql.exp(fieldName2ColumnMap.get("ip").toString(), "like", keyword), - ")") - ); - } SqlVo sqlVo = getSqlVoForResource(queryCriteriaVo, fieldName2ColumnMap); resourceConditionConfigVo.buildConditionSqlVo(sqlVo, fieldName2ColumnMap); $sql.addSql(plainSelect, sqlVo); @@ -1064,34 +1066,18 @@ public class ResourceBuildSqlServiceImpl implements ResourceBuildSqlService, IRe filterItemFieldNameList.add("id"); ResourceQueryCriteriaVo queryCriteriaVo = new ResourceQueryCriteriaVo(searchVo); List filterItemFieldNameList1 = getFilterItemFieldNameList(queryCriteriaVo); - System.out.println("filterItemFieldNameList1 = " + filterItemFieldNameList1); filterItemFieldNameList.addAll(filterItemFieldNameList1); JSONObject conditionConfigObj = new JSONObject(); conditionConfigObj.put("conditionGroupList", searchVo.getConditionGroupList()); conditionConfigObj.put("conditionGroupRelList", searchVo.getConditionGroupRelList()); ResourceConditionConfigVo resourceConditionConfigVo = conditionConfigObj.toJavaObject(ResourceConditionConfigVo.class); List filterItemFieldNameList2 = resourceConditionConfigVo.getFilterItemFieldNameList(); - System.out.println("filterItemFieldNameList2 = " + filterItemFieldNameList2); filterItemFieldNameList.addAll(filterItemFieldNameList2); config.setSelectItemFieldNameList(selectItemFieldNameList); config.setFilterItemFieldNameList(filterItemFieldNameList); Map fieldName2ColumnMap = new HashMap<>(); PlainSelect plainSelect = getPlainSelect(config, fieldName2ColumnMap); $sql.setDistinct(plainSelect, true); -// $sql.addSelectColumn(plainSelect, $sql.fun("count", fieldName2ColumnMap.get("id").toString()).withDistinct(true)); - /* - - AND (a.`name` LIKE CONCAT('%', #{keyword}, '%') OR a.`ip` LIKE CONCAT('%', #{keyword}, '%')) - - */ - if (StringUtils.isNotBlank(queryCriteriaVo.getKeyword())) { - String keyword = "'%" + queryCriteriaVo.getKeyword() + "%'"; - $sql.addWhereExpression(plainSelect, $sql.exp("(", - $sql.exp(fieldName2ColumnMap.get("name").toString(), "like", keyword), - "or", $sql.exp(fieldName2ColumnMap.get("ip").toString(), "like", keyword), - ")") - ); - } SqlVo sqlVo = getSqlVoForResource(queryCriteriaVo, fieldName2ColumnMap); resourceConditionConfigVo.buildConditionSqlVo(sqlVo, fieldName2ColumnMap); $sql.addSql(plainSelect, sqlVo); @@ -2578,11 +2564,25 @@ public class ResourceBuildSqlServiceImpl implements ResourceBuildSqlService, IRe if (CollectionUtils.isNotEmpty(queryCriteriaVo.getInspectStatusList())) { filterItemFieldNameSet.add("inspect_status"); } + if (CollectionUtils.isNotEmpty(queryCriteriaVo.getInputNodeList())) { + filterItemFieldNameSet.add("name"); + filterItemFieldNameSet.add("ip"); + filterItemFieldNameSet.add("port"); + } + if (queryCriteriaVo.getConditionConfig() != null) { + filterItemFieldNameSet.addAll(queryCriteriaVo.getConditionConfig().getFilterItemFieldNameList()); + } return new ArrayList<>(filterItemFieldNameSet); } private SqlVo getSqlVoForResource(ResourceQueryCriteriaVo queryCriteriaVo, Map fieldName2ColumnMap) { SqlVo sqlVo = new SqlVo(); + getSqlVoForResource(sqlVo, queryCriteriaVo, fieldName2ColumnMap); + return sqlVo; + } + + private void getSqlVoForResource(SqlVo sqlVo, ResourceQueryCriteriaVo queryCriteriaVo, Map fieldName2ColumnMap) { +// SqlVo sqlVo = new SqlVo(); List joinList = new ArrayList<>(); List whereExpressionList = new ArrayList<>(); /* @@ -2606,11 +2606,12 @@ public class ResourceBuildSqlServiceImpl implements ResourceBuildSqlService, IRe joinList.add($sql.join("join", "fulltextindex_field_cmdb", "ffc").withOn(expressionVo)); } { - ExpressionVo expressionVo = $sql.exp( - $sql.exp("fw.id", "=", "ffc.word_id"), - "and", - $sql.exp("fw.word", "in", queryCriteriaVo.getKeywordList())); - joinList.add($sql.join("join", "fulltextindex_word", "fw").withOn(expressionVo)); +// ExpressionVo expressionVo = $sql.exp( +// $sql.exp("fw.id", "=", "ffc.word_id"), +// "and", +// $sql.exp("fw.word", "in", queryCriteriaVo.getKeywordList())); + joinList.add($sql.join("join", "fulltextindex_word", "fw").withOn($sql.exp("fw.id", "=", "ffc.word_id"))); + whereExpressionList.add($sql.exp("fw.word", "in", queryCriteriaVo.getKeywordList())); } } /* @@ -2649,11 +2650,12 @@ public class ResourceBuildSqlServiceImpl implements ResourceBuildSqlService, IRe joinList.add($sql.join("join", "fulltextindex_field_cmdb", "ffc2").withOn(expressionVo)); } { - ExpressionVo expressionVo = $sql.exp( - $sql.exp("fw2.id", "=", "ffc2.word_id"), - "and", - $sql.exp("fw2.word", "in", queryCriteriaVo.getBatchSearchList())); - joinList.add($sql.join("join", "fulltextindex_word", "fw2").withOn(expressionVo)); +// ExpressionVo expressionVo = $sql.exp( +// $sql.exp("fw2.id", "=", "ffc2.word_id"), +// "and", +// $sql.exp("fw2.word", "in", queryCriteriaVo.getBatchSearchList())); + joinList.add($sql.join("join", "fulltextindex_word", "fw2").withOn($sql.exp("fw2.id", "=", "ffc2.word_id"))); + whereExpressionList.add($sql.exp("fw2.word", "in", queryCriteriaVo.getBatchSearchList())); } } /* @@ -2947,9 +2949,37 @@ public class ResourceBuildSqlServiceImpl implements ResourceBuildSqlService, IRe // System.out.println("x"); whereExpressionList.add($sql.exp(fieldName2ColumnMap.get("inspect_status").toString(), "in", queryCriteriaVo.getInspectStatusList())); } - sqlVo.withJoinList(joinList); - sqlVo.withWhereExpressionList(whereExpressionList); - return sqlVo; + if (CollectionUtils.isNotEmpty(queryCriteriaVo.getInputNodeList())) { + ExpressionVo orExp = null; + for (ResourceVo inputNode : queryCriteriaVo.getInputNodeList()) { + Column ipColumn = fieldName2ColumnMap.get("ip"); + ExpressionVo andExp = $sql.exp(ipColumn.toString(), "=", $sql.value(inputNode.getIp())); + Column portColumn = fieldName2ColumnMap.get("port"); + if (inputNode.getPort() != null) { + andExp = $sql.exp(andExp, "and", $sql.exp(portColumn.toString(), "=", inputNode.getPort())); + } else { + andExp = $sql.exp(andExp, "and", $sql.exp(portColumn.toString(), "is null")); + } + if (StringUtils.isNotBlank(inputNode.getName())) { + Column nameColumn = fieldName2ColumnMap.get("name"); + andExp = $sql.exp(andExp, "and", $sql.exp(nameColumn.toString(), "=", $sql.value(inputNode.getName()))); + } + andExp = $sql.exp("(", andExp, ")"); + if (orExp == null) { + orExp = andExp; + } else { + orExp = $sql.exp(orExp, "or", andExp); + } + } + orExp = $sql.exp("(", orExp, ")"); + whereExpressionList.add(orExp); + } + sqlVo.withAddJoinList(joinList); + sqlVo.withAddWhereExpressionList(whereExpressionList); + if (queryCriteriaVo.getConditionConfig() != null) { + queryCriteriaVo.getConditionConfig().buildConditionSqlVo(sqlVo, fieldName2ColumnMap); + } +// return sqlVo; } private SqlVo getSqlVoForInspect(ResourceQueryCriteriaVo queryCriteriaVo, Map fieldName2ColumnMap) { diff --git a/src/main/java/neatlogic/module/cmdb/service/resourcecenter/resource/ResourceCenterResourceServiceImpl.java b/src/main/java/neatlogic/module/cmdb/service/resourcecenter/resource/ResourceCenterResourceServiceImpl.java index dc8c757aba8821c2212e6be3c3545026b6f7bb82..79904cf8b216a4a03d0fde38b61a30bd683460d9 100644 --- a/src/main/java/neatlogic/module/cmdb/service/resourcecenter/resource/ResourceCenterResourceServiceImpl.java +++ b/src/main/java/neatlogic/module/cmdb/service/resourcecenter/resource/ResourceCenterResourceServiceImpl.java @@ -95,7 +95,7 @@ public class ResourceCenterResourceServiceImpl implements IResourceCenterResourc @Override public ResourceSearchVo assembleResourceSearchVo(JSONObject jsonObj) { - if(!jsonObj.containsKey("typeId") && !jsonObj.containsKey("typeIdList")){ + if (!jsonObj.containsKey("typeId") && !jsonObj.containsKey("typeIdList")) { List ciIdList = resourceEntityMapper.getAllResourceTypeCiIdList(); jsonObj.put("typeIdList", ciIdList); } @@ -591,25 +591,23 @@ public class ResourceCenterResourceServiceImpl implements IResourceCenterResourc int oldRowNum = 0; int newRowNum = 0; if (Objects.equals(mode, JSQLPARSER_MODE) || Objects.equals(enable, COMPARISON_ENABLED)) { + if (searchVo.getPreCondition() != null) { + if (searchVo.getPreCondition().getIpFieldAttrId() == null && searchVo.getPreCondition().getNameFieldAttrId() == null) { + handleBatchSearchList(searchVo.getPreCondition()); + setIpFieldAttrIdAndNameFieldAttrId(searchVo.getPreCondition()); + } + } + if (searchVo.getIpFieldAttrId() == null && searchVo.getNameFieldAttrId() == null) { + handleBatchSearchList(searchVo); + setIpFieldAttrIdAndNameFieldAttrId(searchVo); + } String sql = resourceBuildSqlService.buildGetResourceCountSql(searchVo); newRowNum = resourceMapper.getCountBySql(sql); } if (Objects.equals(mode, MYBATIS_MODE) || Objects.equals(enable, COMPARISON_ENABLED)) { - if (noFilterCondition(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)); - oldRowNum = resourceMapper.getAllResourceCount(searchVo); - } - } - } - } else { - oldRowNum = resourceMapper.getResourceCount(searchVo); - } + //是否存在前置条件 + initConditionOld(searchVo); + oldRowNum = resourceMapper.getResourceCount(searchVo); } if (Objects.equals(enable, COMPARISON_ENABLED)) { if (oldRowNum != newRowNum) { @@ -627,6 +625,36 @@ public class ResourceCenterResourceServiceImpl implements IResourceCenterResourc return 0; } + /** + * 初始化前置条件 + * + * @param searchVo 条件 + */ + private void initConditionOld(ResourceSearchVo searchVo) { + if (searchVo.getPreCondition() != null) { + if(searchVo.getPreCondition().isCustomCondition()) { + if (StringUtils.isBlank(searchVo.getPreCondition().getConditionWhereSql())) { + StringBuilder preSqlSb = new StringBuilder(); + searchVo.getPreCondition().buildConditionWhereSql(preSqlSb, searchVo.getPreCondition()); + searchVo.getPreCondition().setConditionWhereSql(preSqlSb.toString()); + } + } + if (searchVo.getPreCondition().getIpFieldAttrId() == null && searchVo.getPreCondition().getNameFieldAttrId() == null) { + handleBatchSearchList(searchVo.getPreCondition()); + setIpFieldAttrIdAndNameFieldAttrId(searchVo.getPreCondition()); + } + } + if (StringUtils.isBlank(searchVo.getConditionWhereSql()) && searchVo.isCustomCondition()) { + StringBuilder sqlSb = new StringBuilder(); + searchVo.buildConditionWhereSql(sqlSb, searchVo); + searchVo.setConditionWhereSql(sqlSb.toString()); + } + if (searchVo.getIpFieldAttrId() == null && searchVo.getNameFieldAttrId() == null) { + handleBatchSearchList(searchVo); + setIpFieldAttrIdAndNameFieldAttrId(searchVo); + } + } + @Override public List getResourceIdList(ResourceSearchVo searchVo) { String enable = ConfigManager.getConfig(CmdbTenantConfig.RESOURCECENTER_DATA_COMPARISON_MODE_ENABLE); @@ -634,10 +662,22 @@ public class ResourceCenterResourceServiceImpl implements IResourceCenterResourc List newIdList = new ArrayList<>(); List oldIdList = new ArrayList<>(); if (Objects.equals(mode, JSQLPARSER_MODE) || Objects.equals(enable, COMPARISON_ENABLED)) { + if (searchVo.getPreCondition() != null) { + if (searchVo.getPreCondition().getIpFieldAttrId() == null && searchVo.getPreCondition().getNameFieldAttrId() == null) { + handleBatchSearchList(searchVo.getPreCondition()); + setIpFieldAttrIdAndNameFieldAttrId(searchVo.getPreCondition()); + } + } + if (searchVo.getIpFieldAttrId() == null && searchVo.getNameFieldAttrId() == null) { + handleBatchSearchList(searchVo); + setIpFieldAttrIdAndNameFieldAttrId(searchVo); + } String sql = resourceBuildSqlService.buildGetResourceIdListSql(searchVo); newIdList = resourceMapper.getIdListBySql(sql); } if (Objects.equals(mode, MYBATIS_MODE) || Objects.equals(enable, COMPARISON_ENABLED)) { + //是否存在前置条件 + initConditionOld(searchVo); oldIdList = resourceMapper.getResourceIdList(searchVo); } if (Objects.equals(enable, COMPARISON_ENABLED)) { @@ -682,26 +722,8 @@ public class ResourceCenterResourceServiceImpl implements IResourceCenterResourc @Override public List getResourceListByIdList(List idList, List selectFieldNameList) { - String enable = ConfigManager.getConfig(CmdbTenantConfig.RESOURCECENTER_DATA_COMPARISON_MODE_ENABLE); - String mode = ConfigManager.getConfig(CmdbTenantConfig.RESOURCECENTER_SQL_MODE); - List newResourceList = new ArrayList<>(); - List oldResourceList = new ArrayList<>(); - if (Objects.equals(mode, JSQLPARSER_MODE) || Objects.equals(enable, COMPARISON_ENABLED)) { - String sql = resourceBuildSqlService.buildGetResourceListSql(idList, selectFieldNameList); - newResourceList = resourceMapper.getResourceListBySql(sql); - } - if (Objects.equals(mode, MYBATIS_MODE) || Objects.equals(enable, COMPARISON_ENABLED)) { - oldResourceList = resourceMapper.getResourceListByIdList(idList); - } - if (Objects.equals(enable, COMPARISON_ENABLED)) { - checkResourceListIsEquals(newResourceList, oldResourceList); - } - if (Objects.equals(mode, JSQLPARSER_MODE)) { - return newResourceList; - } else if (Objects.equals(mode, MYBATIS_MODE)) { - return oldResourceList; - } - return new ArrayList<>(); + String sql = resourceBuildSqlService.buildGetResourceListSql(idList, selectFieldNameList); + return resourceMapper.getResourceListBySql(sql); } @Override @@ -844,111 +866,111 @@ public class ResourceCenterResourceServiceImpl implements IResourceCenterResourc return new ArrayList<>(); } - @Override - public Long getResourceIdByIpAndPortAndName(ResourceSearchVo searchVo) { - String enable = ConfigManager.getConfig(CmdbTenantConfig.RESOURCECENTER_DATA_COMPARISON_MODE_ENABLE); - String mode = ConfigManager.getConfig(CmdbTenantConfig.RESOURCECENTER_SQL_MODE); - Long newId = null; - Long oldId = null; - if (Objects.equals(mode, JSQLPARSER_MODE) || Objects.equals(enable, COMPARISON_ENABLED)) { - String sql = resourceBuildSqlService.buildGetResourceIdByIpAndPortAndNameSql(searchVo); - newId = resourceMapper.getIdBySql(sql); - } - if (Objects.equals(mode, MYBATIS_MODE) || Objects.equals(enable, COMPARISON_ENABLED)) { - oldId = resourceMapper.getResourceIdByIpAndPortAndName(searchVo); - } - if (Objects.equals(enable, COMPARISON_ENABLED)) { - if (!Objects.equals(newId, oldId)) { - JSONObject resultObj = new JSONObject(); - resultObj.put("newId", newId); - resultObj.put("oldId", oldId); - logger.error("资产清单新旧SQL获取结果不一致:{}", resultObj); - } - } - if (Objects.equals(mode, JSQLPARSER_MODE)) { - return newId; - } else if (Objects.equals(mode, MYBATIS_MODE)) { - return oldId; - } - return null; - } +// @Override +// public Long getResourceIdByIpAndPortAndName(ResourceSearchVo searchVo) { +// String enable = ConfigManager.getConfig(CmdbTenantConfig.RESOURCECENTER_DATA_COMPARISON_MODE_ENABLE); +// String mode = ConfigManager.getConfig(CmdbTenantConfig.RESOURCECENTER_SQL_MODE); +// Long newId = null; +// Long oldId = null; +// if (Objects.equals(mode, JSQLPARSER_MODE) || Objects.equals(enable, COMPARISON_ENABLED)) { +// String sql = resourceBuildSqlService.buildGetResourceIdByIpAndPortAndNameSql(searchVo); +// newId = resourceMapper.getIdBySql(sql); +// } +// if (Objects.equals(mode, MYBATIS_MODE) || Objects.equals(enable, COMPARISON_ENABLED)) { +// oldId = resourceMapper.getResourceIdByIpAndPortAndName(searchVo); +// } +// if (Objects.equals(enable, COMPARISON_ENABLED)) { +// if (!Objects.equals(newId, oldId)) { +// JSONObject resultObj = new JSONObject(); +// resultObj.put("newId", newId); +// resultObj.put("oldId", oldId); +// logger.error("资产清单新旧SQL获取结果不一致:{}", resultObj); +// } +// } +// if (Objects.equals(mode, JSQLPARSER_MODE)) { +// return newId; +// } else if (Objects.equals(mode, MYBATIS_MODE)) { +// return oldId; +// } +// return null; +// } - @Override - public List getResourceIdListByIpAndPortAndName(ResourceSearchVo searchVo) { - String enable = ConfigManager.getConfig(CmdbTenantConfig.RESOURCECENTER_DATA_COMPARISON_MODE_ENABLE); - String mode = ConfigManager.getConfig(CmdbTenantConfig.RESOURCECENTER_SQL_MODE); - List newIdList = new ArrayList<>(); - List oldIdList = new ArrayList<>(); - if (Objects.equals(mode, JSQLPARSER_MODE) || Objects.equals(enable, COMPARISON_ENABLED)) { - String sql = resourceBuildSqlService.buildGetResourceIdListByIpAndPortAndNameSql(searchVo); - newIdList = resourceMapper.getIdListBySql(sql); - } - if (Objects.equals(mode, MYBATIS_MODE) || Objects.equals(enable, COMPARISON_ENABLED)) { - oldIdList = resourceMapper.getResourceIdListByIpAndPortAndName(searchVo); - } - if (Objects.equals(enable, COMPARISON_ENABLED)) { - if (!Objects.equals(oldIdList, newIdList)) { - JSONObject resultObj = new JSONObject(); - resultObj.put("idList", newIdList); - resultObj.put("oldIdList", oldIdList); - logger.error("资产清单新旧SQL获取结果不一致:{}", resultObj); - } - } - if (Objects.equals(mode, JSQLPARSER_MODE)) { - return newIdList; - } else if (Objects.equals(mode, MYBATIS_MODE)) { - return oldIdList; - } - return new ArrayList<>(); - } +// @Override +// public List getResourceIdListByIpAndPortAndName(ResourceSearchVo searchVo) { +// String enable = ConfigManager.getConfig(CmdbTenantConfig.RESOURCECENTER_DATA_COMPARISON_MODE_ENABLE); +// String mode = ConfigManager.getConfig(CmdbTenantConfig.RESOURCECENTER_SQL_MODE); +// List newIdList = new ArrayList<>(); +// List oldIdList = new ArrayList<>(); +// if (Objects.equals(mode, JSQLPARSER_MODE) || Objects.equals(enable, COMPARISON_ENABLED)) { +// String sql = resourceBuildSqlService.buildGetResourceIdListByIpAndPortAndNameSql(searchVo); +// newIdList = resourceMapper.getIdListBySql(sql); +// } +// if (Objects.equals(mode, MYBATIS_MODE) || Objects.equals(enable, COMPARISON_ENABLED)) { +// oldIdList = resourceMapper.getResourceIdListByIpAndPortAndName(searchVo); +// } +// if (Objects.equals(enable, COMPARISON_ENABLED)) { +// if (!Objects.equals(oldIdList, newIdList)) { +// JSONObject resultObj = new JSONObject(); +// resultObj.put("idList", newIdList); +// resultObj.put("oldIdList", oldIdList); +// logger.error("资产清单新旧SQL获取结果不一致:{}", resultObj); +// } +// } +// if (Objects.equals(mode, JSQLPARSER_MODE)) { +// return newIdList; +// } else if (Objects.equals(mode, MYBATIS_MODE)) { +// return oldIdList; +// } +// return new ArrayList<>(); +// } - @Override - public List getResourceListByIpAndPortAndName(ResourceSearchVo searchVo) { - String enable = ConfigManager.getConfig(CmdbTenantConfig.RESOURCECENTER_DATA_COMPARISON_MODE_ENABLE); - String mode = ConfigManager.getConfig(CmdbTenantConfig.RESOURCECENTER_SQL_MODE); - List newResourceList = new ArrayList<>(); - List oldResourceList = new ArrayList<>(); - if (Objects.equals(mode, JSQLPARSER_MODE) || Objects.equals(enable, COMPARISON_ENABLED)) { - String sql = resourceBuildSqlService.buildGetResourceListByIpAndPortAndNameSql(searchVo); - newResourceList = resourceMapper.getResourceSimpleListBySql(sql); - } - if (Objects.equals(mode, MYBATIS_MODE) || Objects.equals(enable, COMPARISON_ENABLED)) { - oldResourceList = resourceMapper.getResourceListByIpAndPortAndName(searchVo); - } - if (Objects.equals(enable, COMPARISON_ENABLED)) { - checkResourceListIsEquals(newResourceList, oldResourceList); - } - if (Objects.equals(mode, JSQLPARSER_MODE)) { - return newResourceList; - } else if (Objects.equals(mode, MYBATIS_MODE)) { - return oldResourceList; - } - return new ArrayList<>(); - } +// @Override +// public List getResourceListByIpAndPortAndName(ResourceSearchVo searchVo) { +// String enable = ConfigManager.getConfig(CmdbTenantConfig.RESOURCECENTER_DATA_COMPARISON_MODE_ENABLE); +// String mode = ConfigManager.getConfig(CmdbTenantConfig.RESOURCECENTER_SQL_MODE); +// List newResourceList = new ArrayList<>(); +// List oldResourceList = new ArrayList<>(); +// if (Objects.equals(mode, JSQLPARSER_MODE) || Objects.equals(enable, COMPARISON_ENABLED)) { +// String sql = resourceBuildSqlService.buildGetResourceListByIpAndPortAndNameSql(searchVo); +// newResourceList = resourceMapper.getResourceSimpleListBySql(sql); +// } +// if (Objects.equals(mode, MYBATIS_MODE) || Objects.equals(enable, COMPARISON_ENABLED)) { +// oldResourceList = resourceMapper.getResourceListByIpAndPortAndName(searchVo); +// } +// if (Objects.equals(enable, COMPARISON_ENABLED)) { +// checkResourceListIsEquals(newResourceList, oldResourceList); +// } +// if (Objects.equals(mode, JSQLPARSER_MODE)) { +// return newResourceList; +// } else if (Objects.equals(mode, MYBATIS_MODE)) { +// return oldResourceList; +// } +// return new ArrayList<>(); +// } - @Override - public List getResourceListByIpAndPortAndNameWithFilter(ResourceSearchVo searchVo) { - String enable = ConfigManager.getConfig(CmdbTenantConfig.RESOURCECENTER_DATA_COMPARISON_MODE_ENABLE); - String mode = ConfigManager.getConfig(CmdbTenantConfig.RESOURCECENTER_SQL_MODE); - List newResourceList = new ArrayList<>(); - List oldResourceList = new ArrayList<>(); - if (Objects.equals(mode, JSQLPARSER_MODE) || Objects.equals(enable, COMPARISON_ENABLED)) { - String sql = resourceBuildSqlService.buildGetResourceListByIpAndPortAndNameWithFilterSql(searchVo); - newResourceList = resourceMapper.getResourceSimpleListBySql(sql); - } - if (Objects.equals(mode, MYBATIS_MODE) || Objects.equals(enable, COMPARISON_ENABLED)) { - oldResourceList = resourceMapper.getResourceListByIpAndPortAndNameWithFilter(searchVo); - } - if (Objects.equals(enable, COMPARISON_ENABLED)) { - checkResourceListIsEquals(newResourceList, oldResourceList); - } - if (Objects.equals(mode, JSQLPARSER_MODE)) { - return newResourceList; - } else if (Objects.equals(mode, MYBATIS_MODE)) { - return oldResourceList; - } - return new ArrayList<>(); - } +// @Override +// public List getResourceListByIpAndPortAndNameWithFilter(ResourceSearchVo searchVo) { +// String enable = ConfigManager.getConfig(CmdbTenantConfig.RESOURCECENTER_DATA_COMPARISON_MODE_ENABLE); +// String mode = ConfigManager.getConfig(CmdbTenantConfig.RESOURCECENTER_SQL_MODE); +// List newResourceList = new ArrayList<>(); +// List oldResourceList = new ArrayList<>(); +// if (Objects.equals(mode, JSQLPARSER_MODE) || Objects.equals(enable, COMPARISON_ENABLED)) { +// String sql = resourceBuildSqlService.buildGetResourceListByIpAndPortAndNameWithFilterSql(searchVo); +// newResourceList = resourceMapper.getResourceSimpleListBySql(sql); +// } +// if (Objects.equals(mode, MYBATIS_MODE) || Objects.equals(enable, COMPARISON_ENABLED)) { +// oldResourceList = resourceMapper.getResourceListByIpAndPortAndNameWithFilter(searchVo); +// } +// if (Objects.equals(enable, COMPARISON_ENABLED)) { +// checkResourceListIsEquals(newResourceList, oldResourceList); +// } +// if (Objects.equals(mode, JSQLPARSER_MODE)) { +// return newResourceList; +// } else if (Objects.equals(mode, MYBATIS_MODE)) { +// return oldResourceList; +// } +// return new ArrayList<>(); +// } @Override public List getResourceByIdList(List idList) { @@ -1616,50 +1638,4 @@ public class ResourceCenterResourceServiceImpl implements IResourceCenterResourc } return flag; } - - private boolean noFilterCondition(ResourceSearchVo searchVo) { - if (StringUtils.isNotBlank(searchVo.getKeyword())) { - return false; - } - if (CollectionUtils.isNotEmpty(searchVo.getBatchSearchList())) { - return false; - } - if (CollectionUtils.isNotEmpty(searchVo.getStateIdList())) { - return false; - } - if (CollectionUtils.isNotEmpty(searchVo.getVendorIdList())) { - return false; - } - if (CollectionUtils.isNotEmpty(searchVo.getEnvIdList())) { - return false; - } - if (searchVo.getExistNoEnv()) { - return false; - } - if (CollectionUtils.isNotEmpty(searchVo.getAppSystemIdList())) { - return false; - } - if (CollectionUtils.isNotEmpty(searchVo.getAppModuleIdList())) { - return false; - } - if (CollectionUtils.isNotEmpty(searchVo.getDefaultValue())) { - return false; - } - if (CollectionUtils.isNotEmpty(searchVo.getIdList())) { - return false; - } - if (CollectionUtils.isNotEmpty(searchVo.getInspectStatusList())) { - return false; - } - if (CollectionUtils.isNotEmpty(searchVo.getProtocolIdList())) { - return false; - } - if (CollectionUtils.isNotEmpty(searchVo.getTagIdList())) { - return false; - } - if (CollectionUtils.isNotEmpty(searchVo.getInspectJobPhaseNodeStatusList())) { - return false; - } - return true; - } }