Bläddra i källkod

人群包、流量包逻辑修改

zhaoxian 4 år sedan
förälder
incheckning
c21ea2f8bb

+ 23 - 3
module-alarm/src/main/java/cn/com/ctop/alarm/modules/constant/MatchLogic.java

@@ -158,15 +158,35 @@ public class MatchLogic {
                             return flag;
                         }
                     }
+                } else if (threshold.contains("[")) {
+                    List<String> thresholds = strToList(threshold);
+                    if ("contain".equals(condition)) {
+                        for (String thr : thresholds) {
+                            if (value.toString().contains(thr)) {
+                                return true;
+                            }
+                        }
+                    } else {
+                        boolean flag = true;
+                        for (String thr : thresholds) {
+                            if (value.toString().contains(thr)) {
+                                flag = false;
+                            } else {
+                                return true;
+                            }
+                        }
+                        return flag;
+                    }
                 } else {
                     if ("contain".equals(condition)) {
-                        return value.contains(threshold);
+                        return value.toString().contains(threshold);
                     } else {
-                        return !value.contains(threshold);
+                        return !value.toString().contains(threshold);
                     }
                 }
             }
-        } catch (Exception e) {
+        } catch (
+                Exception e) {
             log.error("条件匹配异常,入参为:type={},condition={},threshold={},value={},", type, condition, threshold, value, e);
         }
         return false;