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(")")); + } + } }); }