Browse Source

规则引擎规则修改

zhaoxian 4 years ago
parent
commit
6490f5f536

+ 9 - 24
module-alarm/src/main/java/cn/com/ctop/alarm/modules/constant/MatchLogic.java

@@ -136,23 +136,12 @@ public class MatchLogic {
                         } else {
                             //不包含,阈值中,存在任一目标则不报警,都不存在时则报警,出现阈值之外的亦报警
                             boolean flag = true;
-                            if ("retargetingTagsInclude".equals(indicatorCode) || "population".equals(indicatorCode) || "region".equals(indicatorCode) || "district".equals(indicatorCode)) {
-                                //人群包判断是否存在该对象
-                                for (String thr : thresholds) {
-                                    if (values.contains(thr)) {
-                                        flag = false;
-                                    } else {
-                                        return true;
-                                    }
-                                }
-                            } else {
-                                //判断是否存在关键字。
-                                for (String thr : thresholds) {
-                                    if (values.toString().contains(thr)) {
-                                        flag = false;
-                                    } else {
-                                        return true;
-                                    }
+                            //人群包判断是否存在该对象
+                            for (String v : values) {
+                                if (threshold.contains(v)) {
+                                    flag = false;
+                                } else {
+                                    return true;
                                 }
                             }
                             return flag;
@@ -167,21 +156,17 @@ public class MatchLogic {
                             }
                         }
                     } else {
-                        boolean flag = true;
                         for (String thr : thresholds) {
-                            if (value.toString().contains(thr)) {
-                                flag = false;
-                            } else {
+                            if (!value.contains(thr)) {
                                 return true;
                             }
                         }
-                        return flag;
                     }
                 } else {
                     if ("contain".equals(condition)) {
-                        return value.toString().contains(threshold);
+                        return value.contains(threshold);
                     } else {
-                        return !value.toString().contains(threshold);
+                        return !value.contains(threshold);
                     }
                 }
             }