瀏覽代碼

预警规则判断优化

zhaoxian 4 年之前
父節點
當前提交
7f501da885

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

@@ -37,6 +37,7 @@ import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
+import java.util.Date;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -297,7 +298,9 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
             if (ACCOUNT.equals(ruleBase.getRuleDimension())) {
                 JSONObject accountEntity = dimensionData.getJSONObject(0);
                 if (MatchLogic.matchCondition(indicator, ruleBase.getRuleCondition(), threshold, accountEntity.getString(ruleBase.getIndicatorCode()), accountEntity)) {
-                    accountDatas.add(accountEntity);
+                    if (Check.isNull(accountDatas)) {
+                        accountDatas.add(accountEntity);
+                    }
                 } else {
                     if (!Check.isNull(accountDatas)) {
                         accountDatas = null;
@@ -524,17 +527,14 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
             } else if ("TEL".equals(sendType)) {
 
             } else {
-//                for (int i = 0; i < 10000000; i++) {
-//                    sendMessageService.sendMessage("1b3deb8258e84df994f1371a51cfc14a", msg + i);
-//                    Thread.sleep(2000);
-//                }
+//                sendMessageService.sendMessage("1b3deb8258e84df994f1371a51cfc14a", msg);
                 sendMessageService.sendMessage(user.getString("id"), msg);
                 Thread.sleep(200);
             }
             if (!Check.isNull(msg)) {
                 AlarmEventSend send = new AlarmEventSend();
                 send.setUserId(user.getString("id"));
-                send.setAlarmDetail(msg.replace("<br/>", ""));
+                send.setAlarmDetail(msg.replace("<br/>", ""));
                 send.setAlarmStatus(NoEn.NO1.valueStr());
                 send.setGroupId(ruleGroup.getId());
                 send.setGroupName(ruleGroup.getGroupName());
@@ -545,6 +545,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
                 } else {
                     send.setRuleDimension(ACCOUNT);
                 }
+                send.setCreateTime(new Date());
                 alarmEventSendMapper.insert(send);
             }
         } catch (Exception e) {