|
@@ -86,6 +86,8 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
|
|
|
|
@Override
|
|
|
public void checkRules() {
|
|
|
+ log.info("------start------");
|
|
|
+ Long startTime = System.currentTimeMillis();
|
|
|
//查询账户绑定过的规则模板
|
|
|
List<RuleAccountTemplate> ruleAccountTemplates = ruleAccountTemplateMapper.selectByMap(null);
|
|
|
if (Check.isNull(ruleAccountTemplates)) {
|
|
@@ -107,6 +109,8 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
|
for (RuleAccountTemplate templates : ruleAccountTemplates) {
|
|
|
matchAlarmRules(ruleGroupMap, indicators, templates);
|
|
|
}
|
|
|
+ Long endTime = System.currentTimeMillis();
|
|
|
+ log.info("------end------共耗时: {} ms", endTime - startTime);
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -173,7 +177,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
|
* @throws
|
|
|
* @author ZHAOXA
|
|
|
*/
|
|
|
- private void checkRuleGroups(List<RuleGroup> ruleGroups, JSONObject thresholdObj, JSONObject indicators, JSONObject matchData, Integer type, boolean isCopy,String accountName) {
|
|
|
+ private void checkRuleGroups(List<RuleGroup> ruleGroups, JSONObject thresholdObj, JSONObject indicators, JSONObject matchData, Integer type, boolean isCopy, String accountName) {
|
|
|
for (RuleGroup ruleGroup : ruleGroups) {
|
|
|
List<RuleBase> ruleBaseList = ruleGroup.getRuleBaseList();
|
|
|
if (Check.isNull(ruleBaseList)) {
|
|
@@ -184,13 +188,13 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
|
JSONObject batchNo = thresholdObj.getJSONObject(ruleGroup.getId().toString());
|
|
|
for (Map.Entry<String, Object> entry : batchNo.entrySet()) {
|
|
|
JSONObject thresholdMap = (JSONObject) entry.getValue();
|
|
|
- CombinationRule(ruleGroup, ruleBaseList, thresholdMap, indicators, matchData, type,accountName);
|
|
|
+ CombinationRule(ruleGroup, ruleBaseList, thresholdMap, indicators, matchData, type, accountName);
|
|
|
}
|
|
|
} 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);
|
|
|
//匹配单规则
|
|
|
} else {
|
|
|
RuleBase ruleBase = ruleBaseList.get(0);
|
|
@@ -210,7 +214,7 @@ 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)) {
|
|
|
- sendMsg(ruleGroup, obj, type,accountName);
|
|
|
+ sendMsg(ruleGroup, obj, type, accountName);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -232,7 +236,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 targetDatas = new JSONArray();
|
|
|
JSONArray planDatas = new JSONArray();
|
|
@@ -252,11 +256,14 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
|
JSONArray dimensionData = matchData.getJSONArray(ruleBase.getRuleDimension());
|
|
|
//账户维度数据
|
|
|
if ("account".equals(ruleBase.getRuleDimension())) {
|
|
|
+ if (Check.isNull(dimensionData)) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
JSONObject accountEntity = dimensionData.getJSONObject(0);
|
|
|
if (MatchLogic.matchCondition(dataType, ruleBase.getRuleCondition(), threshold, accountEntity.getString(ruleBase.getIndicatorCode()))) {
|
|
|
accountDatas.add(accountEntity);
|
|
|
} else {
|
|
|
- log.warn("判断规则组({}),账户规则不符合", ruleGroup.getId());
|
|
|
+ log.warn("匹配规则组({}),账户维度数据不符合直接跳过", ruleGroup.getId());
|
|
|
break;
|
|
|
}
|
|
|
if (Check.isNull(accountDatas)) {
|
|
@@ -285,7 +292,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
|
if (!Check.isNull(sendData)) {
|
|
|
//执行发送
|
|
|
for (int i = 0; i < sendData.size(); i++) {
|
|
|
- sendMsg(ruleGroup, sendData.getJSONObject(i), type,accountName);
|
|
|
+ sendMsg(ruleGroup, sendData.getJSONObject(i), type, accountName);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -332,7 +339,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
|
* @throws
|
|
|
* @author ZHAOXA
|
|
|
*/
|
|
|
- private void sendMsg(RuleGroup ruleGroup, JSONObject obj, Integer type,String accountName) {
|
|
|
+ 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");
|
|
@@ -346,7 +353,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
|
}
|
|
|
type 1:头条2:快手
|
|
|
}*/
|
|
|
- String msg = MatchLogic.getMsg(ruleGroup, user, accountId, planId, creativeId, isPause,accountName);
|
|
|
+ String msg = MatchLogic.getMsg(ruleGroup, user, accountId, planId, creativeId, isPause, accountName);
|
|
|
String sendType = ruleGroup.getSendType();
|
|
|
if ("SMS".equals(sendType)) {
|
|
|
|
|
@@ -355,6 +362,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
|
} else if ("TEL".equals(sendType)) {
|
|
|
|
|
|
} else {
|
|
|
+ //TODO
|
|
|
ISendMessageService sendMessageService = this.sendMessageService;
|
|
|
// sendMessageService.sendMessage(user.getString("id"), msg);
|
|
|
sendMessageService.sendMessage("1b3deb8258e84df994f1371a51cfc14a", msg);
|