|
@@ -31,10 +31,10 @@ public class MatchLogic {
|
|
*/
|
|
*/
|
|
public static boolean matchCondition(String type, String condition, String threshold, String value, JSONObject obj) {
|
|
public static boolean matchCondition(String type, String condition, String threshold, String value, JSONObject obj) {
|
|
try {
|
|
try {
|
|
- if (Check.isNull(threshold)) {
|
|
|
|
|
|
+ if (Check.isNull(threshold) || "[]".equals(threshold)) {
|
|
return false;
|
|
return false;
|
|
}
|
|
}
|
|
- if (Check.isNull(value)) {
|
|
|
|
|
|
+ if (Check.isNull(value) || "[]".equals(value)) {
|
|
obj.put("isNull", true);
|
|
obj.put("isNull", true);
|
|
return true;
|
|
return true;
|
|
}
|
|
}
|
|
@@ -60,18 +60,40 @@ public class MatchLogic {
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
} else if ("string".equals(type)) {
|
|
} else if ("string".equals(type)) {
|
|
- switch (condition) {
|
|
|
|
- case "equal":
|
|
|
|
- return value.equals(threshold);
|
|
|
|
- case "not_equal":
|
|
|
|
- return !value.equals(threshold);
|
|
|
|
- case "contain":
|
|
|
|
- return threshold.contains(value);
|
|
|
|
- case "no_contain":
|
|
|
|
- return !threshold.contains(value);
|
|
|
|
- default:
|
|
|
|
- log.warn("关系不匹配 type={},condition={},threshold={},value={},", type, condition, threshold, value);
|
|
|
|
- break;
|
|
|
|
|
|
+ if (threshold.contains("[")) {
|
|
|
|
+ boolean flag = false;
|
|
|
|
+ List<String> thresholds = strToList(threshold);
|
|
|
|
+ if ("equal".equals(condition)) {
|
|
|
|
+ return value.equals(thresholds.get(0));
|
|
|
|
+ } else if ("not_equal".equals(condition)) {
|
|
|
|
+ return !value.equals(thresholds.get(0));
|
|
|
|
+ }
|
|
|
|
+ for (String thro : thresholds) {
|
|
|
|
+ if ("contain".equals(condition)) {
|
|
|
|
+ if (value.contains(thro)) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ } else if ("no_contain".equals(condition)) {
|
|
|
|
+ if (!value.contains(thro)) {
|
|
|
|
+ return true;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return flag;
|
|
|
|
+ } else {
|
|
|
|
+ switch (condition) {
|
|
|
|
+ case "equal":
|
|
|
|
+ return value.equals(threshold);
|
|
|
|
+ case "not_equal":
|
|
|
|
+ return !value.equals(threshold);
|
|
|
|
+ case "contain":
|
|
|
|
+ return value.contains(threshold);
|
|
|
|
+ case "no_contain":
|
|
|
|
+ return !value.contains(threshold);
|
|
|
|
+ default:
|
|
|
|
+ log.warn("关系不匹配 type={},condition={},threshold={},value={},", type, condition, threshold, value);
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
if (value.contains("[") && threshold.contains("[")) {
|
|
if (value.contains("[") && threshold.contains("[")) {
|
|
@@ -228,9 +250,5 @@ public class MatchLogic {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return sendData;
|
|
return sendData;
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
}
|
|
}
|