Quellcode durchsuchen

Merge remote-tracking branch 'origin/master'

yumeng vor 4 Jahren
Ursprung
Commit
27711cf88b

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

@@ -108,8 +108,8 @@ public class MatchLogic {
                     List<String> thresholds = strToList(threshold);
                     //包含 任一存在则报警
                     if ("contain".equals(condition)) {
-                        for (String v : values) {
-                            if (threshold.contains(v)) {
+                        for (String thr : thresholds) {
+                            if (values.contains(thr)) {
                                 return true;
                             }
                         }
@@ -121,16 +121,16 @@ public class MatchLogic {
                             if (values.size() != thresholds.size()) {
                                 return true;
                             }
-                            for (String v : values) {
-                                if (!threshold.contains(v)) {
+                            for (String thr : thresholds) {
+                                if (!values.contains(thr)) {
                                     return true;
                                 }
                             }
                         } else {
                             boolean flag = true;
                             //不包含,阈值中,存在任一目标则不报警,都不存在时则报警,出现阈值之外的亦报警
-                            for (String v : values) {
-                                if (threshold.contains(v)) {
+                            for (String thr : thresholds) {
+                                if (values.contains(thr)) {
                                     flag = false;
                                 } else {
                                     return true;
@@ -141,9 +141,9 @@ public class MatchLogic {
                     }
                 } else {
                     if ("contain".equals(condition)) {
-                        return threshold.contains(value);
+                        return value.contains(threshold);
                     } else {
-                        return !threshold.contains(value);
+                        return !value.contains(threshold);
                     }
                 }
             }

+ 9 - 3
module-alarm/src/main/java/cn/com/ctop/alarm/modules/service/impl/RuleGroupServiceImpl.java

@@ -46,6 +46,8 @@ import java.util.List;
 import java.util.Map;
 import java.util.StringJoiner;
 import java.util.UUID;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Executors;
 
 /**
  * 规则组
@@ -101,6 +103,8 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
     private final static String PLAN = "plan";
     private final static String CREATIVE = "creative";
 
+    static ExecutorService executorService = Executors.newFixedThreadPool(5);
+
     @Override
     public void checkRules() {
         log.info("------start------");
@@ -126,9 +130,11 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
             log.error("获取指标内容失败");
             return;
         }
-        for (RuleAccountTemplate templates : ruleAccountTemplates) {
+
+        ruleAccountTemplates.forEach(templates -> executorService.submit(() -> {
             matchAlarmRules(ruleGroupMap, indicators, templates);
-        }
+        }));
+
         Long endTime = System.currentTimeMillis();
         log.info("------end------共耗时: {} ms", endTime - startTime);
     }
@@ -642,7 +648,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
      * @throws
      * @author ZHAOXA
      */
-    private JSONObject getUserByAccountId(Long accountId) {
+    private synchronized JSONObject getUserByAccountId(Long accountId) {
         JSONObject obj = userObj.getJSONObject(accountId.toString());
         if (Check.isNull(obj)) {
             JSONObject user = sysUserMapper.selectUserByAccount(accountId);

+ 1 - 2
module-common/src/main/java/cn/com/ctop/common/module/utils/CorpWexinUtils.java

@@ -50,8 +50,7 @@ public class CorpWexinUtils {
         }
     }
 
-
-    public static void sendMessageByWeChatId(String weChatId, String content) {
+    public synchronized static void sendMessageByWeChatId(String weChatId, String content) {
         if (wxCpService == null) {
             initService();
         }