From 370e8ab17c12930647e75f513c24272a621a4407 Mon Sep 17 00:00:00 2001 From: WangXu10 Date: Tue, 7 Mar 2023 14:44:01 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=B5=8B=E8=AF=95=E8=B7=9F=E8=B8=AA)?= =?UTF-8?q?=EF=BC=9A=E7=BC=BA=E9=99=B7=E7=AE=A1=E7=90=86-=E9=AB=98?= =?UTF-8?q?=E7=BA=A7=E6=90=9C=E7=B4=A2-=E7=A6=85=E9=81=93=E5=BD=B1?= =?UTF-8?q?=E5=93=8D=E7=89=88=E6=9C=AC=E6=9F=A5=E8=AF=A2=E6=9D=A1=E4=BB=B6?= =?UTF-8?q?=E4=B8=8D=E7=94=9F=E6=95=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --bug=1021230 --user=王旭 【测试跟踪】缺陷管理-高级搜索-禅道影响版本-不属于-筛选数据不对 https://www.tapd.cn/55049933/s/1345956 --- .../commons/constants/OperatorTypeConstants.java | 5 +++++ .../java/io/metersphere/service/ServiceUtils.java | 12 ++++++++++-- 2 files changed, 15 insertions(+), 2 deletions(-) create mode 100644 framework/sdk-parent/sdk/src/main/java/io/metersphere/commons/constants/OperatorTypeConstants.java diff --git a/framework/sdk-parent/sdk/src/main/java/io/metersphere/commons/constants/OperatorTypeConstants.java b/framework/sdk-parent/sdk/src/main/java/io/metersphere/commons/constants/OperatorTypeConstants.java new file mode 100644 index 0000000000..6c9c679305 --- /dev/null +++ b/framework/sdk-parent/sdk/src/main/java/io/metersphere/commons/constants/OperatorTypeConstants.java @@ -0,0 +1,5 @@ +package io.metersphere.commons.constants; + +public class OperatorTypeConstants { + public static final String NOT_IN = "not in"; +} diff --git a/framework/sdk-parent/sdk/src/main/java/io/metersphere/service/ServiceUtils.java b/framework/sdk-parent/sdk/src/main/java/io/metersphere/service/ServiceUtils.java index c0a3b567f0..421c1ac296 100644 --- a/framework/sdk-parent/sdk/src/main/java/io/metersphere/service/ServiceUtils.java +++ b/framework/sdk-parent/sdk/src/main/java/io/metersphere/service/ServiceUtils.java @@ -4,6 +4,7 @@ import io.metersphere.base.domain.Project; import io.metersphere.base.domain.User; import io.metersphere.base.domain.Workspace; import io.metersphere.commons.constants.CustomFieldType; +import io.metersphere.commons.constants.OperatorTypeConstants; import io.metersphere.commons.exception.MSException; import io.metersphere.commons.utils.CommonBeanFactory; import io.metersphere.commons.utils.JSON; @@ -384,8 +385,15 @@ public class ServiceUtils { CustomFieldType.CHECKBOX.getValue(), CustomFieldType.MULTIPLE_SELECT.getValue()) && StringUtils.isNotEmpty(custom.get("value").toString())) { List customValues = JSON.parseArray(custom.get("value").toString(), String.class); - List jsonValues = customValues.stream().map(item -> "JSON_CONTAINS(`value`, '[\"".concat(item).concat("\"]')")).collect(Collectors.toList()); - custom.put("value", "(".concat(StringUtils.join(jsonValues, " OR ")).concat(")")); + List jsonValues; + if (StringUtils.equalsIgnoreCase(custom.get("operator").toString(), OperatorTypeConstants.NOT_IN)) { + jsonValues = customValues.stream().map(item -> "locate('"+item+"',`value`) = 0").collect(Collectors.toList()); + custom.put("value", "(".concat(StringUtils.join(jsonValues, " and ")).concat(")")); + } else { + jsonValues = customValues.stream().map(item -> "JSON_CONTAINS(`value`, '[\"".concat(item).concat("\"]')")).collect(Collectors.toList()); + custom.put("value", "(".concat(StringUtils.join(jsonValues, " OR ")).concat(")")); + } + } }); }