|
@@ -14,12 +14,11 @@ 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.entity.*;
|
|
|
-import cn.com.ctop.alarm.modules.mapper.*;
|
|
|
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;
|
|
@@ -70,7 +69,8 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
|
private IKuaiShouUpdateService kuaiShouUpdateService;
|
|
|
@Autowired
|
|
|
private ICtopOauthTokenService oauthTokenService;
|
|
|
-
|
|
|
+ @Autowired
|
|
|
+ private IRuleDataAccountService ruleDataAccountService;
|
|
|
|
|
|
@Override
|
|
|
public void checkRules() {
|
|
@@ -80,12 +80,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)) {
|
|
@@ -100,7 +94,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());
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -115,13 +109,13 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
|
* @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());
|
|
@@ -315,10 +309,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);
|
|
|
}
|
|
|
|
|
|
/**
|