|  | @@ -38,6 +38,7 @@ import org.springframework.stereotype.Service;
 | 
	
		
			
				|  |  |  import java.util.HashMap;
 | 
	
		
			
				|  |  |  import java.util.List;
 | 
	
		
			
				|  |  |  import java.util.Map;
 | 
	
		
			
				|  |  | +import java.util.StringJoiner;
 | 
	
		
			
				|  |  |  import java.util.UUID;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |  /**
 | 
	
	
		
			
				|  | @@ -107,7 +108,8 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
 | 
	
		
			
				|  |  |              return;
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          for (RuleAccountTemplate templates : ruleAccountTemplates) {
 | 
	
		
			
				|  |  | -            matchAlarmRules(ruleGroupMap, indicators, templates);
 | 
	
		
			
				|  |  | +            if (templates.getAccountId() == 1681223758914574l)
 | 
	
		
			
				|  |  | +                matchAlarmRules(ruleGroupMap, indicators, templates);
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          Long endTime = System.currentTimeMillis();
 | 
	
		
			
				|  |  |          log.info("------end------共耗时: {} ms", endTime - startTime);
 | 
	
	
		
			
				|  | @@ -179,6 +181,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  |      private void checkRuleGroups(List<RuleGroup> ruleGroups, JSONObject thresholdObj, JSONObject indicators, JSONObject matchData, Integer type, boolean isCopy, String accountName) {
 | 
	
		
			
				|  |  |          for (RuleGroup ruleGroup : ruleGroups) {
 | 
	
		
			
				|  |  | +            JSONArray complianceList = new JSONArray();
 | 
	
		
			
				|  |  |              List<RuleBase> ruleBaseList = ruleGroup.getRuleBaseList();
 | 
	
		
			
				|  |  |              if (Check.isNull(ruleBaseList)) {
 | 
	
		
			
				|  |  |                  continue;
 | 
	
	
		
			
				|  | @@ -189,14 +192,14 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
 | 
	
		
			
				|  |  |                  for (Map.Entry<String, Object> entry : batchNo.entrySet()) {
 | 
	
		
			
				|  |  |                      JSONObject thresholdJn = (JSONObject) entry.getValue();
 | 
	
		
			
				|  |  |                      if (!Check.isNull(thresholdJn)) {
 | 
	
		
			
				|  |  | -                        CombinationRule(ruleGroup, ruleBaseList, thresholdJn, indicators, matchData, type, accountName);
 | 
	
		
			
				|  |  | +                        CombinationRule(ruleGroup, ruleBaseList, thresholdJn, indicators, matchData, type, accountName, complianceList);
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              } else {
 | 
	
		
			
				|  |  |                  boolean isGroup = "group".equals(ruleGroup.getRuleType());
 | 
	
		
			
				|  |  |                  //匹配组合规则
 | 
	
		
			
				|  |  |                  if (isGroup) {
 | 
	
		
			
				|  |  | -                    CombinationRule(ruleGroup, ruleBaseList, thresholdObj, indicators, matchData, type, accountName);
 | 
	
		
			
				|  |  | +                    CombinationRule(ruleGroup, ruleBaseList, thresholdObj, indicators, matchData, type, accountName, complianceList);
 | 
	
		
			
				|  |  |                      //匹配单规则
 | 
	
		
			
				|  |  |                  } else {
 | 
	
		
			
				|  |  |                      RuleBase ruleBase = ruleBaseList.get(0);
 | 
	
	
		
			
				|  | @@ -215,12 +218,15 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
 | 
	
		
			
				|  |  |                              JSONObject obj = dimensionData.getJSONObject(i);
 | 
	
		
			
				|  |  |                              String value = obj.getString(ruleBase.getIndicatorCode());
 | 
	
		
			
				|  |  |                              if (MatchLogic.matchCondition(indicator.getString("dataType"), ruleBase.getRuleCondition(), threshold, value, obj)) {
 | 
	
		
			
				|  |  | -                                sendMsg(ruleGroup, obj, type, accountName);
 | 
	
		
			
				|  |  | +                                complianceList.add(obj);
 | 
	
		
			
				|  |  | +//                                sendMsg(ruleGroup, obj, type, accountName);
 | 
	
		
			
				|  |  |                              }
 | 
	
		
			
				|  |  |                          }
 | 
	
		
			
				|  |  |                      }
 | 
	
		
			
				|  |  |                  }
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -238,7 +244,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
 | 
	
		
			
				|  |  |       * @throws
 | 
	
		
			
				|  |  |       * @author ZHAOXA
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  | -    private void CombinationRule(RuleGroup ruleGroup, List<RuleBase> ruleBaseList, JSONObject thresholdObj, JSONObject indicators, JSONObject matchData, Integer type, String accountName) {
 | 
	
		
			
				|  |  | +    private void CombinationRule(RuleGroup ruleGroup, List<RuleBase> ruleBaseList, JSONObject thresholdObj, JSONObject indicators, JSONObject matchData, Integer type, String accountName, JSONArray complianceList) {
 | 
	
		
			
				|  |  |          //符合规则的数据集
 | 
	
		
			
				|  |  |          JSONArray targetDatas = new JSONArray();
 | 
	
		
			
				|  |  |          JSONArray planDatas = new JSONArray();
 | 
	
	
		
			
				|  | @@ -292,10 +298,11 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
 | 
	
		
			
				|  |  |          //获取达标可发送的数据
 | 
	
		
			
				|  |  |          JSONArray sendData = MatchLogic.getSendData(accountDatas, planDatas, creativeDatas, targetDatas);
 | 
	
		
			
				|  |  |          if (!Check.isNull(sendData)) {
 | 
	
		
			
				|  |  | -            //执行发送
 | 
	
		
			
				|  |  | -            for (int i = 0; i < sendData.size(); i++) {
 | 
	
		
			
				|  |  | -                sendMsg(ruleGroup, sendData.getJSONObject(i), type, accountName);
 | 
	
		
			
				|  |  | -            }
 | 
	
		
			
				|  |  | +            complianceList.addAll(sendData);
 | 
	
		
			
				|  |  | +//            //执行发送
 | 
	
		
			
				|  |  | +////            for (int i = 0; i < sendData.size(); i++) {
 | 
	
		
			
				|  |  | +////                sendMsg(ruleGroup, , type, accountName);
 | 
	
		
			
				|  |  | +////            }
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -331,6 +338,83 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
 | 
	
		
			
				|  |  |          return ruleDatas;
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    private void sendMag2(JSONArray complianceList, RuleGroup ruleGroup, String accountName) {
 | 
	
		
			
				|  |  | +        Long accountId = complianceList.getJSONObject(0).getLong("accountId");
 | 
	
		
			
				|  |  | +        if (Check.isNull(accountId)) {
 | 
	
		
			
				|  |  | +            return;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        JSONObject user = getUserByAccountId(accountId);
 | 
	
		
			
				|  |  | +        StringJoiner creativeJoiner = new StringJoiner(",");
 | 
	
		
			
				|  |  | +        StringJoiner planJoiner = new StringJoiner(",");
 | 
	
		
			
				|  |  | +        StringJoiner isNullCreativeJoiner = new StringJoiner(",");
 | 
	
		
			
				|  |  | +        StringJoiner isNullPlanJoiner = new StringJoiner(",");
 | 
	
		
			
				|  |  | +        for (int i = 0; i < complianceList.size(); i++) {
 | 
	
		
			
				|  |  | +            JSONObject obj = complianceList.getJSONObject(i);
 | 
	
		
			
				|  |  | +            boolean isNull = obj.getBoolean("isNull");
 | 
	
		
			
				|  |  | +            if (isNull) {
 | 
	
		
			
				|  |  | +                if (!Check.isNull(obj.getString("creativeId"))) {
 | 
	
		
			
				|  |  | +                    //字节小于1900时
 | 
	
		
			
				|  |  | +                    if (isNullCreativeJoiner.toString().getBytes().length <= 1900) {
 | 
	
		
			
				|  |  | +                        isNullCreativeJoiner.add(obj.getString("creativeId"));
 | 
	
		
			
				|  |  | +                    } else {
 | 
	
		
			
				|  |  | +                        String message = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, "creative", isNullCreativeJoiner.toString(), false);
 | 
	
		
			
				|  |  | +                        sendMsg(message, ruleGroup, user);
 | 
	
		
			
				|  |  | +                        isNullCreativeJoiner = new StringJoiner(",");
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                } else if (!Check.isNull(obj.getLong("planId"))) {
 | 
	
		
			
				|  |  | +                    if (isNullPlanJoiner.toString().getBytes().length <= 1900) {
 | 
	
		
			
				|  |  | +                        isNullPlanJoiner.add(obj.getString("planId"));
 | 
	
		
			
				|  |  | +                    } else {
 | 
	
		
			
				|  |  | +                        String msg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, "plan", isNullPlanJoiner.toString(), false);
 | 
	
		
			
				|  |  | +                        sendMsg(msg, ruleGroup, user);
 | 
	
		
			
				|  |  | +                        isNullPlanJoiner = new StringJoiner(",");
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                } else {
 | 
	
		
			
				|  |  | +                    String msg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, null, null, false);
 | 
	
		
			
				|  |  | +                    sendMsg(msg, ruleGroup, user);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            } else {
 | 
	
		
			
				|  |  | +                if (!Check.isNull(obj.getString("creativeId"))) {
 | 
	
		
			
				|  |  | +                    //字节小于1900时
 | 
	
		
			
				|  |  | +                    if (creativeJoiner.toString().getBytes().length <= 1900) {
 | 
	
		
			
				|  |  | +                        creativeJoiner.add(obj.getString("creativeId"));
 | 
	
		
			
				|  |  | +                    } else {
 | 
	
		
			
				|  |  | +                        String message = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, "creative", creativeJoiner.toString(), false);
 | 
	
		
			
				|  |  | +                        sendMsg(message, ruleGroup, user);
 | 
	
		
			
				|  |  | +                        creativeJoiner = new StringJoiner(",");
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                } else if (!Check.isNull(obj.getLong("planId"))) {
 | 
	
		
			
				|  |  | +                    if (planJoiner.toString().getBytes().length <= 1900) {
 | 
	
		
			
				|  |  | +                        planJoiner.add(obj.getString("planId"));
 | 
	
		
			
				|  |  | +                    } else {
 | 
	
		
			
				|  |  | +                        String msg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, "plan", planJoiner.toString(), false);
 | 
	
		
			
				|  |  | +                        sendMsg(msg, ruleGroup, user);
 | 
	
		
			
				|  |  | +                        planJoiner = new StringJoiner(",");
 | 
	
		
			
				|  |  | +                    }
 | 
	
		
			
				|  |  | +                } else {
 | 
	
		
			
				|  |  | +                    String msg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, null, null, false);
 | 
	
		
			
				|  |  | +                    sendMsg(msg, ruleGroup, user);
 | 
	
		
			
				|  |  | +                }
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        String creativeMsg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, "creative", creativeJoiner.toString(), accountName, false);
 | 
	
		
			
				|  |  | +        if (!Check.isNull(creativeMsg)) {
 | 
	
		
			
				|  |  | +            sendMsg(creativeMsg, ruleGroup, user);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        String planMsg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, "creative", planJoiner.toString(), accountName, false);
 | 
	
		
			
				|  |  | +        if (!Check.isNull(planMsg)) {
 | 
	
		
			
				|  |  | +            sendMsg(planMsg, ruleGroup, user);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        String isNullCreativeMsg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, "creative", isNullCreativeJoiner.toString(), accountName, false);
 | 
	
		
			
				|  |  | +        if (!Check.isNull(isNullCreativeMsg)) {
 | 
	
		
			
				|  |  | +            sendMsg(isNullCreativeMsg, ruleGroup, user);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        String isNullPlanMsg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, "creative", isNullPlanJoiner.toString(), accountName, false);
 | 
	
		
			
				|  |  | +        if (!Check.isNull(isNullPlanMsg)) {
 | 
	
		
			
				|  |  | +            sendMsg(isNullPlanMsg, ruleGroup, user);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +    }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      /**
 | 
	
		
			
				|  |  |       * 发送消息
 | 
	
		
			
				|  |  |       *
 | 
	
	
		
			
				|  | @@ -342,11 +426,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
 | 
	
		
			
				|  |  |       * @throws
 | 
	
		
			
				|  |  |       * @author ZHAOXA
 | 
	
		
			
				|  |  |       */
 | 
	
		
			
				|  |  | -    private void sendMsg(RuleGroup ruleGroup, JSONObject obj, Integer type, String accountName) {
 | 
	
		
			
				|  |  | -        Long creativeId = obj.getLong("creativeId");
 | 
	
		
			
				|  |  | -        Long planId = obj.getLong("planId");
 | 
	
		
			
				|  |  | -        Long accountId = obj.getLong("accountId");
 | 
	
		
			
				|  |  | -        JSONObject user = getUserByAccountId(accountId);
 | 
	
		
			
				|  |  | +    private void sendMsg(String msg, RuleGroup ruleGroup, JSONObject user) {
 | 
	
		
			
				|  |  |          //TODO 关停操作
 | 
	
		
			
				|  |  |          boolean isPause = false;
 | 
	
		
			
				|  |  |            /*      "PAUSE".equals(ruleGroup.getOperate());
 | 
	
	
		
			
				|  | @@ -356,7 +436,12 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  |              type 1:头条2:快手
 | 
	
		
			
				|  |  |          }*/
 | 
	
		
			
				|  |  | -        String msg = MatchLogic.getMsg(ruleGroup, user, obj, isPause, accountName);
 | 
	
		
			
				|  |  | +//        String msg = MatchLogic.getMsg(ruleGroup, user, obj, isPause, accountName);
 | 
	
		
			
				|  |  | +        if (isPause) {
 | 
	
		
			
				|  |  | +            msg += "现已被关停,请您及时查看并调整!";
 | 
	
		
			
				|  |  | +        } else {
 | 
	
		
			
				|  |  | +            msg += "请您及时查看并调整!";
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  |          String sendType = ruleGroup.getSendType();
 | 
	
		
			
				|  |  |          if ("SMS".equals(sendType)) {
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -367,11 +452,10 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
 | 
	
		
			
				|  |  |          } else {
 | 
	
		
			
				|  |  |              //TODO
 | 
	
		
			
				|  |  |              ISendMessageService sendMessageService = this.sendMessageService;
 | 
	
		
			
				|  |  | -            sendMessageService.sendMessage(user.getString("id"), msg);
 | 
	
		
			
				|  |  | -//            sendMessageService.sendMessage("1b3deb8258e84df994f1371a51cfc14a", msg);
 | 
	
		
			
				|  |  | +//            sendMessageService.sendMessage(user.getString("id"), msg);
 | 
	
		
			
				|  |  | +            sendMessageService.sendMessage("1b3deb8258e84df994f1371a51cfc14a", msg);
 | 
	
		
			
				|  |  |              //113dee46c7df464da78c07a985e92cd1 于蒙
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -        log.debug("账户{}的{}预警已发送", accountId, ruleGroup.getGroupName());
 | 
	
		
			
				|  |  |          if (!Check.isNull(msg)) {
 | 
	
		
			
				|  |  |              AlarmEventSend send = new AlarmEventSend();
 | 
	
		
			
				|  |  |              send.setAlarmDetail(msg);
 |