|
@@ -3,10 +3,24 @@ package cn.com.ctop.alarm.modules.service.impl;
|
|
|
import cn.com.ctop.alarm.modules.constant.MatchLogic;
|
|
|
import cn.com.ctop.alarm.modules.entity.*;
|
|
|
import cn.com.ctop.alarm.modules.mapper.*;
|
|
|
+import cn.com.ctop.alarm.modules.entity.AlarmEventRule;
|
|
|
+import cn.com.ctop.alarm.modules.entity.RuleAccountTemplate;
|
|
|
+import cn.com.ctop.alarm.modules.entity.RuleAccountThreshold;
|
|
|
+import cn.com.ctop.alarm.modules.entity.RuleBase;
|
|
|
+import cn.com.ctop.alarm.modules.entity.RuleGroup;
|
|
|
+import cn.com.ctop.alarm.modules.entity.RuleIndicator;
|
|
|
+import cn.com.ctop.alarm.modules.entity.RuleTemplate;
|
|
|
+import cn.com.ctop.alarm.modules.mapper.RuleAccountTemplateMapper;
|
|
|
+import cn.com.ctop.alarm.modules.mapper.RuleAccountThresholdMapper;
|
|
|
+import cn.com.ctop.alarm.modules.mapper.RuleBaseMapper;
|
|
|
+import cn.com.ctop.alarm.modules.mapper.RuleGroupMapper;
|
|
|
+import cn.com.ctop.alarm.modules.mapper.RuleIndicatorMapper;
|
|
|
+import cn.com.ctop.alarm.modules.mapper.RuleTemplateMapper;
|
|
|
import cn.com.ctop.alarm.modules.service.IRuleAccountTemplateService;
|
|
|
import cn.com.ctop.alarm.modules.service.IRuleGroupService;
|
|
|
import cn.com.ctop.common.module.entity.CtopOauthToken;
|
|
|
import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
|
+import cn.com.ctop.common.module.service.IRuleDataAccountService;
|
|
|
import cn.com.ctop.common.module.service.ISendMessageService;
|
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouUpdateService;
|
|
@@ -57,7 +71,8 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
|
private IKuaiShouUpdateService kuaiShouUpdateService;
|
|
|
@Autowired
|
|
|
private ICtopOauthTokenService oauthTokenService;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private IRuleDataAccountService ruleDataAccountService;
|
|
|
|
|
|
@Override
|
|
|
public void checkRules() {
|
|
@@ -67,12 +82,6 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
|
log.warn("查询账户绑定过的规则模板失败");
|
|
|
return;
|
|
|
}
|
|
|
- //查询匹配数据
|
|
|
- JSONObject dataList = getData();
|
|
|
- if (Check.isNull(dataList)) {
|
|
|
- log.warn("查询匹配数据失败");
|
|
|
- return;
|
|
|
- }
|
|
|
//获取规则集
|
|
|
Map<Long, List<RuleGroup>> ruleGroupMap = getRuleGroupMap();
|
|
|
if (Check.isNull(ruleGroupMap)) {
|
|
@@ -87,7 +96,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
|
}
|
|
|
for (RuleAccountTemplate templates : ruleAccountTemplates) {
|
|
|
List<RuleGroup> ruleGroups = ruleGroupMap.get(templates.getTemplateId());
|
|
|
- matchAlarmRules(ruleGroups, getThreshold(ruleAccountThresholdMapper.selectByAccountId(templates.getAccountId())), dataList, indicators, templates.getAccountId());
|
|
|
+ matchAlarmRules(ruleGroups, getThreshold(ruleAccountThresholdMapper.selectByAccountId(templates.getAccountId())), indicators, templates.getAccountId());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -96,19 +105,18 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
|
*
|
|
|
* @param ruleGroups 规则集
|
|
|
* @param thresholdObj 规则id阈值
|
|
|
- * @param matchData 匹配数据
|
|
|
* @param indicators 指标码
|
|
|
* @return void
|
|
|
* @throws
|
|
|
* @author ZHAOXA
|
|
|
*/
|
|
|
- private void matchAlarmRules(List<RuleGroup> ruleGroups, JSONObject thresholdObj, JSONObject matchData, JSONObject indicators, Long accountId) {
|
|
|
- //TODO 获取数据
|
|
|
- JSONArray targetData = matchData.getJSONArray("target");
|
|
|
- JSONArray planData = matchData.getJSONArray("plan");
|
|
|
- JSONArray accountData = matchData.getJSONArray("account");
|
|
|
- JSONArray creativeData = matchData.getJSONArray("creative");
|
|
|
- JSONArray lostCostData = matchData.getJSONArray("lostCost");
|
|
|
+ private void matchAlarmRules(List<RuleGroup> ruleGroups, JSONObject thresholdObj, JSONObject indicators, Long accountId) {
|
|
|
+ //查询匹配数据
|
|
|
+ JSONObject matchData = getRuleData(accountId);
|
|
|
+ if (Check.isNull(matchData)) {
|
|
|
+ log.warn("查询匹配数据失败");
|
|
|
+ return;
|
|
|
+ }
|
|
|
for (RuleGroup ruleGroup : ruleGroups) {
|
|
|
List<RuleBase> ruleBaseList = ruleGroup.getRuleBaseList();
|
|
|
boolean isBase = "base".equals(ruleGroup.getRuleType());
|
|
@@ -302,10 +310,8 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
|
* @throws
|
|
|
* @author ZHAOXA
|
|
|
*/
|
|
|
- private JSONObject getData() {
|
|
|
-
|
|
|
-
|
|
|
- return null;
|
|
|
+ private JSONObject getRuleData(Long accountId) {
|
|
|
+ return ruleDataAccountService.getRuleDataByAccountId(accountId);
|
|
|
}
|
|
|
|
|
|
/**
|