From b69478780d0e8dacd06ea29ef239f64038db05ea Mon Sep 17 00:00:00 2001 From: "1437892690@qq.com" <1437892690@qq.com> Date: Thu, 20 Nov 2025 14:25:08 +0800 Subject: [PATCH] =?UTF-8?q?[=E4=BF=AE=E5=A4=8D]=20=E8=87=AA=E5=8A=A8?= =?UTF-8?q?=E5=8C=96=E6=89=A7=E8=A1=8C=E7=9B=AE=E6=A0=87=E4=B8=8D=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E5=90=8D=E7=A7=B0=E8=A7=84=E5=88=99=E6=90=9C=E7=B4=A2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 关联 #[1556385160986624]自动化执行目标不支持名称规则搜索 http://192.168.0.96:8090/demo/rdm.html#/bug-detail/939050947543040/939050947543057/1556385160986624 --- .../mapper/resourcecenter/ResourceMapper.xml | 42 +++++++++-------- .../resource/ResourceBuildSqlServiceImpl.java | 46 +++++++++++-------- 2 files changed, 52 insertions(+), 36 deletions(-) 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 d13fb318..bb1dac6f 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 01a3cdba..848f2b2a 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)), + ")")); } /* -- Gitee