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 d13fb31832c46bd7437fae5d8541a79192b3a1a2..bb1dac6f306684723ed6f07df4e4b5b6e1a65b65 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 @@ -183,11 +183,14 @@ along with this program. If not, see .--> #{tagId} - + + + AND (a.`name` LIKE CONCAT(#{keyword}, '%') OR a.`ip` LIKE CONCAT(#{keyword}, '%')) AND fw2.word IN @@ -274,11 +277,14 @@ along with this program. If not, see .--> #{tagId} - + + + AND (a.`name` LIKE CONCAT(#{preCondition.keyword}, '%') OR a.`ip` LIKE CONCAT(#{preCondition.keyword}, '%')) @@ -307,10 +313,10 @@ along with this program. If not, see .--> - + JOIN fulltextindex_field_cmdb ffc2 ON ffc2.target_id = a.id @@ -352,10 +358,10 @@ along with this program. If not, see .--> - + JOIN fulltextindex_field_cmdb ffc2 ON ffc2.target_id = a.id @@ -394,11 +400,11 @@ along with this program. If not, see .--> - + JOIN fulltextindex_field_cmdb ffc2 ON ffc2.target_id = a.id @@ -430,9 +436,9 @@ along with this program. If not, see .--> resultType="java.lang.Long"> SELECT m.`id` FROM ( SELECT DISTINCT a.`id` - + FROM @{DATA_SCHEMA}.`scence_ipobject_detail` a LEFT JOIN `cmdb_resourcecenter_resource_account` b ON b.`resource_id` = a.`id` LEFT JOIN `cmdb_resourcecenter_account` c ON c.`id` = b.`account_id` @@ -451,11 +457,11 @@ along with this program. If not, see .--> - + JOIN fulltextindex_field_cmdb ffc2 ON ffc2.target_id = a.id @@ -480,13 +486,13 @@ along with this program. If not, see .--> - + - + a.`id` DESC LIMIT #{startNum}, #{pageSize} @@ -1568,10 +1574,10 @@ along with this program. If not, see .--> - + 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 01a3cdbad92263c2a97cf024bd770a4f8f13c11d..848f2b2a4d8b4b8461e95e98f03919bad3a75611 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 @@ -198,9 +198,9 @@ public class ResourceBuildSqlServiceImpl implements ResourceBuildSqlService, IRe } 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"); - } +// if (CollectionUtils.isNotEmpty(searchVo.getKeywordList()) && searchVo.getNameFieldAttrId() != null && searchVo.getIpFieldAttrId() != null) { +// $sql.addOrderBy(plainSelect, $sql.fun("COUNT", "fw.word").withDistinct(true), "desc"); +// } Column idColumn = fieldName2ColumnMap.get("id"); // 分组 $sql.addGroupBy(plainSelect, idColumn.toString()); @@ -2805,23 +2805,33 @@ public class ResourceBuildSqlServiceImpl implements ResourceBuildSqlService, IRe ) */ - if (CollectionUtils.isNotEmpty(queryCriteriaVo.getKeywordList()) && (queryCriteriaVo.getNameFieldAttrId() != null || queryCriteriaVo.getIpFieldAttrId() != null)) { -// System.out.println("a"); - { - ExpressionVo expressionVo = $sql.exp( - $sql.exp("ffc.target_id", "=", fieldName2ColumnMap.get("id").toString()), - "and", - $sql.exp("ffc.target_field", "in", Arrays.asList(queryCriteriaVo.getNameFieldAttrId(), queryCriteriaVo.getIpFieldAttrId()))); - joinList.add($sql.join("join", "fulltextindex_field_cmdb", "ffc").withOn(expressionVo)); - } - { +// if (CollectionUtils.isNotEmpty(queryCriteriaVo.getKeywordList()) && (queryCriteriaVo.getNameFieldAttrId() != null || queryCriteriaVo.getIpFieldAttrId() != null)) { +//// System.out.println("a"); +// { // ExpressionVo expressionVo = $sql.exp( -// $sql.exp("fw.id", "=", "ffc.word_id"), +// $sql.exp("ffc.target_id", "=", fieldName2ColumnMap.get("id").toString()), // "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())); - } +// $sql.exp("ffc.target_field", "in", Arrays.asList(queryCriteriaVo.getNameFieldAttrId(), queryCriteriaVo.getIpFieldAttrId()))); +// joinList.add($sql.join("join", "fulltextindex_field_cmdb", "ffc").withOn(expressionVo)); +// } +// { +// 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())); +// } +// } + /* + + AND (a.`name` LIKE CONCAT(#{keyword}, '%') OR a.`ip` LIKE CONCAT(#{keyword}, '%')) + + */ + if (StringUtils.isNotBlank(queryCriteriaVo.getKeyword())) { + String keyword = queryCriteriaVo.getKeyword() + "%"; + whereExpressionList.add($sql.exp( + "(", + $sql.exp(fieldName2ColumnMap.get("name").toString(), "like", $sql.value(keyword)), + "OR", + $sql.exp(fieldName2ColumnMap.get("ip").toString(), "like", $sql.value(keyword)), + ")")); } /*