|
@@ -25,6 +25,7 @@ import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
import cn.com.ctop.common.module.service.IRuleDataAccountService;
|
|
import cn.com.ctop.common.module.service.IRuleDataAccountService;
|
|
import cn.com.ctop.common.module.service.ISendMessageService;
|
|
import cn.com.ctop.common.module.service.ISendMessageService;
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
import cn.com.ctop.common.module.utils.Check;
|
|
|
|
+import cn.com.ctop.common.module.utils.SendMailUtil;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouUpdateService;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouUpdateService;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
@@ -35,6 +36,7 @@ import lombok.extern.slf4j.Slf4j;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
@@ -82,8 +84,10 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
private AlarmEventSendMapper alarmEventSendMapper;
|
|
private AlarmEventSendMapper alarmEventSendMapper;
|
|
@Autowired
|
|
@Autowired
|
|
private UserAllocationMapper userAllocationMapper;
|
|
private UserAllocationMapper userAllocationMapper;
|
|
- ;
|
|
|
|
private JSONObject userObj = null;
|
|
private JSONObject userObj = null;
|
|
|
|
+ private final static String ACCOUNT = "account";
|
|
|
|
+ private final static String PLAN = "plan";
|
|
|
|
+ private final static String CREATIVE = "creative";
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void checkRules() {
|
|
public void checkRules() {
|
|
@@ -92,24 +96,23 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
//查询账户绑定过的规则模板
|
|
//查询账户绑定过的规则模板
|
|
List<RuleAccountTemplate> ruleAccountTemplates = ruleAccountTemplateMapper.selectByMap(null);
|
|
List<RuleAccountTemplate> ruleAccountTemplates = ruleAccountTemplateMapper.selectByMap(null);
|
|
if (Check.isNull(ruleAccountTemplates)) {
|
|
if (Check.isNull(ruleAccountTemplates)) {
|
|
- log.warn("查询账户绑定过的规则模板失败");
|
|
|
|
|
|
+ log.error("查询账户绑定过的规则模板失败");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
//获取规则集
|
|
//获取规则集
|
|
Map<Long, Object> ruleGroupMap = getRuleGroupMap();
|
|
Map<Long, Object> ruleGroupMap = getRuleGroupMap();
|
|
if (Check.isNull(ruleGroupMap)) {
|
|
if (Check.isNull(ruleGroupMap)) {
|
|
- log.warn("获取规则集失败");
|
|
|
|
|
|
+ log.error("获取规则集失败");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
//获取指标内容
|
|
//获取指标内容
|
|
JSONObject indicators = getRuleIndicator();
|
|
JSONObject indicators = getRuleIndicator();
|
|
if (Check.isNull(indicators)) {
|
|
if (Check.isNull(indicators)) {
|
|
- log.warn("获取指标内容失败");
|
|
|
|
|
|
+ log.error("获取指标内容失败");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
for (RuleAccountTemplate templates : ruleAccountTemplates) {
|
|
for (RuleAccountTemplate templates : ruleAccountTemplates) {
|
|
- if (templates.getAccountId() == 1681223758914574l)
|
|
|
|
- matchAlarmRules(ruleGroupMap, indicators, templates);
|
|
|
|
|
|
+ matchAlarmRules(ruleGroupMap, indicators, templates);
|
|
}
|
|
}
|
|
Long endTime = System.currentTimeMillis();
|
|
Long endTime = System.currentTimeMillis();
|
|
log.info("------end------共耗时: {} ms", endTime - startTime);
|
|
log.info("------end------共耗时: {} ms", endTime - startTime);
|
|
@@ -192,17 +195,20 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
for (Map.Entry<String, Object> entry : batchNo.entrySet()) {
|
|
for (Map.Entry<String, Object> entry : batchNo.entrySet()) {
|
|
JSONObject thresholdJn = (JSONObject) entry.getValue();
|
|
JSONObject thresholdJn = (JSONObject) entry.getValue();
|
|
if (!Check.isNull(thresholdJn)) {
|
|
if (!Check.isNull(thresholdJn)) {
|
|
- CombinationRule(ruleGroup, ruleBaseList, thresholdJn, indicators, matchData, type, accountName, complianceList);
|
|
|
|
|
|
+ CombinationRule(ruleBaseList, thresholdJn, indicators, matchData, complianceList);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
boolean isGroup = "group".equals(ruleGroup.getRuleType());
|
|
boolean isGroup = "group".equals(ruleGroup.getRuleType());
|
|
//匹配组合规则
|
|
//匹配组合规则
|
|
if (isGroup) {
|
|
if (isGroup) {
|
|
- CombinationRule(ruleGroup, ruleBaseList, thresholdObj, indicators, matchData, type, accountName, complianceList);
|
|
|
|
|
|
+ CombinationRule(ruleBaseList, thresholdObj, indicators, matchData, complianceList);
|
|
//匹配单规则
|
|
//匹配单规则
|
|
} else {
|
|
} else {
|
|
RuleBase ruleBase = ruleBaseList.get(0);
|
|
RuleBase ruleBase = ruleBaseList.get(0);
|
|
|
|
+ if (Check.isNull(ruleBase)) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
//指标对象
|
|
//指标对象
|
|
JSONObject indicator = indicators.getJSONObject(ruleBase.getIndicatorCode());
|
|
JSONObject indicator = indicators.getJSONObject(ruleBase.getIndicatorCode());
|
|
//指标阈值
|
|
//指标阈值
|
|
@@ -219,14 +225,14 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
String value = obj.getString(ruleBase.getIndicatorCode());
|
|
String value = obj.getString(ruleBase.getIndicatorCode());
|
|
if (MatchLogic.matchCondition(indicator.getString("dataType"), ruleBase.getRuleCondition(), threshold, value, obj)) {
|
|
if (MatchLogic.matchCondition(indicator.getString("dataType"), ruleBase.getRuleCondition(), threshold, value, obj)) {
|
|
complianceList.add(obj);
|
|
complianceList.add(obj);
|
|
-// sendMsg(ruleGroup, obj, type, accountName);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
|
|
+ if (!Check.isNull(complianceList)) {
|
|
|
|
+ getAndSendMessag(complianceList, ruleGroup, accountName);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -244,7 +250,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
* @throws
|
|
* @throws
|
|
* @author ZHAOXA
|
|
* @author ZHAOXA
|
|
*/
|
|
*/
|
|
- private void CombinationRule(RuleGroup ruleGroup, List<RuleBase> ruleBaseList, JSONObject thresholdObj, JSONObject indicators, JSONObject matchData, Integer type, String accountName, JSONArray complianceList) {
|
|
|
|
|
|
+ private void CombinationRule(List<RuleBase> ruleBaseList, JSONObject thresholdObj, JSONObject indicators, JSONObject matchData, JSONArray complianceList) {
|
|
//符合规则的数据集
|
|
//符合规则的数据集
|
|
JSONArray targetDatas = new JSONArray();
|
|
JSONArray targetDatas = new JSONArray();
|
|
JSONArray planDatas = new JSONArray();
|
|
JSONArray planDatas = new JSONArray();
|
|
@@ -259,50 +265,113 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
String threshold = thresholdObj.getString(ruleBase.getId().toString());
|
|
String threshold = thresholdObj.getString(ruleBase.getId().toString());
|
|
//阈值为空时,或者阈值为“unlimited”(不限),不执行该规则
|
|
//阈值为空时,或者阈值为“unlimited”(不限),不执行该规则
|
|
if (Check.isNull(threshold) || "unlimited".equals(threshold)) {
|
|
if (Check.isNull(threshold) || "unlimited".equals(threshold)) {
|
|
- continue;
|
|
|
|
|
|
+ if (!Check.isNull(accountDatas)) {
|
|
|
|
+ accountDatas = null;
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(planDatas)) {
|
|
|
|
+ planDatas = null;
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(creativeDatas)) {
|
|
|
|
+ creativeDatas = null;
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(targetDatas)) {
|
|
|
|
+ targetDatas = null;
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
}
|
|
}
|
|
JSONArray dimensionData = matchData.getJSONArray(ruleBase.getRuleDimension());
|
|
JSONArray dimensionData = matchData.getJSONArray(ruleBase.getRuleDimension());
|
|
if (Check.isNull(dimensionData)) {
|
|
if (Check.isNull(dimensionData)) {
|
|
|
|
+ if (!Check.isNull(accountDatas)) {
|
|
|
|
+ accountDatas = null;
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(planDatas)) {
|
|
|
|
+ planDatas = null;
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(creativeDatas)) {
|
|
|
|
+ creativeDatas = null;
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(targetDatas)) {
|
|
|
|
+ targetDatas = null;
|
|
|
|
+ }
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
//账户维度数据
|
|
//账户维度数据
|
|
- if ("account".equals(ruleBase.getRuleDimension())) {
|
|
|
|
|
|
+ if (ACCOUNT.equals(ruleBase.getRuleDimension())) {
|
|
JSONObject accountEntity = dimensionData.getJSONObject(0);
|
|
JSONObject accountEntity = dimensionData.getJSONObject(0);
|
|
if (MatchLogic.matchCondition(dataType, ruleBase.getRuleCondition(), threshold, accountEntity.getString(ruleBase.getIndicatorCode()), accountEntity)) {
|
|
if (MatchLogic.matchCondition(dataType, ruleBase.getRuleCondition(), threshold, accountEntity.getString(ruleBase.getIndicatorCode()), accountEntity)) {
|
|
accountDatas.add(accountEntity);
|
|
accountDatas.add(accountEntity);
|
|
} else {
|
|
} else {
|
|
- log.warn("匹配规则组({}),账户维度数据不符合直接跳过", ruleGroup.getId());
|
|
|
|
- break;
|
|
|
|
- }
|
|
|
|
- if (Check.isNull(accountDatas)) {
|
|
|
|
|
|
+ if (!Check.isNull(accountDatas)) {
|
|
|
|
+ accountDatas = null;
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(planDatas)) {
|
|
|
|
+ planDatas = null;
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(creativeDatas)) {
|
|
|
|
+ creativeDatas = null;
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(targetDatas)) {
|
|
|
|
+ targetDatas = null;
|
|
|
|
+ }
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- } else if ("plan".equals(ruleBase.getRuleDimension())) {
|
|
|
|
|
|
+ } else if (PLAN.equals(ruleBase.getRuleDimension())) {
|
|
planDatas = getOKData(planDatas, dimensionData, ruleBase, dataType, threshold);
|
|
planDatas = getOKData(planDatas, dimensionData, ruleBase, dataType, threshold);
|
|
if (Check.isNull(planDatas)) {
|
|
if (Check.isNull(planDatas)) {
|
|
|
|
+ if (!Check.isNull(accountDatas)) {
|
|
|
|
+ accountDatas = null;
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(planDatas)) {
|
|
|
|
+ planDatas = null;
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(creativeDatas)) {
|
|
|
|
+ creativeDatas = null;
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(targetDatas)) {
|
|
|
|
+ targetDatas = null;
|
|
|
|
+ }
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- } else if ("creative".equals(ruleBase.getRuleDimension())) {
|
|
|
|
|
|
+ } else if (CREATIVE.equals(ruleBase.getRuleDimension())) {
|
|
creativeDatas = getOKData(creativeDatas, dimensionData, ruleBase, dataType, threshold);
|
|
creativeDatas = getOKData(creativeDatas, dimensionData, ruleBase, dataType, threshold);
|
|
if (Check.isNull(creativeDatas)) {
|
|
if (Check.isNull(creativeDatas)) {
|
|
|
|
+ if (!Check.isNull(accountDatas)) {
|
|
|
|
+ accountDatas = null;
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(planDatas)) {
|
|
|
|
+ planDatas = null;
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(creativeDatas)) {
|
|
|
|
+ creativeDatas = null;
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(targetDatas)) {
|
|
|
|
+ targetDatas = null;
|
|
|
|
+ }
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
} else if ("target".equals(ruleBase.getRuleDimension())) {
|
|
} else if ("target".equals(ruleBase.getRuleDimension())) {
|
|
targetDatas = getOKData(targetDatas, dimensionData, ruleBase, dataType, threshold);
|
|
targetDatas = getOKData(targetDatas, dimensionData, ruleBase, dataType, threshold);
|
|
if (Check.isNull(targetDatas)) {
|
|
if (Check.isNull(targetDatas)) {
|
|
|
|
+ if (!Check.isNull(accountDatas)) {
|
|
|
|
+ accountDatas = null;
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(planDatas)) {
|
|
|
|
+ planDatas = null;
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(creativeDatas)) {
|
|
|
|
+ creativeDatas = null;
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(targetDatas)) {
|
|
|
|
+ targetDatas = null;
|
|
|
|
+ }
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
}
|
|
}
|
|
//获取达标可发送的数据
|
|
//获取达标可发送的数据
|
|
JSONArray sendData = MatchLogic.getSendData(accountDatas, planDatas, creativeDatas, targetDatas);
|
|
JSONArray sendData = MatchLogic.getSendData(accountDatas, planDatas, creativeDatas, targetDatas);
|
|
if (!Check.isNull(sendData)) {
|
|
if (!Check.isNull(sendData)) {
|
|
complianceList.addAll(sendData);
|
|
complianceList.addAll(sendData);
|
|
-// //执行发送
|
|
|
|
-//// for (int i = 0; i < sendData.size(); i++) {
|
|
|
|
-//// sendMsg(ruleGroup, , type, accountName);
|
|
|
|
-//// }
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -338,7 +407,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
return ruleDatas;
|
|
return ruleDatas;
|
|
}
|
|
}
|
|
|
|
|
|
- private void sendMag2(JSONArray complianceList, RuleGroup ruleGroup, String accountName) {
|
|
|
|
|
|
+ private void getAndSendMessag(JSONArray complianceList, RuleGroup ruleGroup, String accountName) {
|
|
Long accountId = complianceList.getJSONObject(0).getLong("accountId");
|
|
Long accountId = complianceList.getJSONObject(0).getLong("accountId");
|
|
if (Check.isNull(accountId)) {
|
|
if (Check.isNull(accountId)) {
|
|
return;
|
|
return;
|
|
@@ -353,65 +422,69 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
boolean isNull = obj.getBoolean("isNull");
|
|
boolean isNull = obj.getBoolean("isNull");
|
|
if (isNull) {
|
|
if (isNull) {
|
|
if (!Check.isNull(obj.getString("creativeId"))) {
|
|
if (!Check.isNull(obj.getString("creativeId"))) {
|
|
- //字节小于1900时
|
|
|
|
- if (isNullCreativeJoiner.toString().getBytes().length <= 1900) {
|
|
|
|
|
|
+ //字节小于1800时
|
|
|
|
+ if (isNullCreativeJoiner.toString().getBytes().length <= 1800) {
|
|
isNullCreativeJoiner.add(obj.getString("creativeId"));
|
|
isNullCreativeJoiner.add(obj.getString("creativeId"));
|
|
} else {
|
|
} else {
|
|
- String message = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, "creative", isNullCreativeJoiner.toString(), false);
|
|
|
|
- sendMsg(message, ruleGroup, user);
|
|
|
|
|
|
+ String message = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, CREATIVE, isNullCreativeJoiner.toString(), isNull);
|
|
|
|
+ sendMsg(message, ruleGroup, user, CREATIVE);
|
|
isNullCreativeJoiner = new StringJoiner(",");
|
|
isNullCreativeJoiner = new StringJoiner(",");
|
|
|
|
+ isNullCreativeJoiner.add(obj.getString("creativeId"));
|
|
}
|
|
}
|
|
} else if (!Check.isNull(obj.getLong("planId"))) {
|
|
} else if (!Check.isNull(obj.getLong("planId"))) {
|
|
- if (isNullPlanJoiner.toString().getBytes().length <= 1900) {
|
|
|
|
|
|
+ if (isNullPlanJoiner.toString().getBytes().length <= 1800) {
|
|
isNullPlanJoiner.add(obj.getString("planId"));
|
|
isNullPlanJoiner.add(obj.getString("planId"));
|
|
} else {
|
|
} else {
|
|
- String msg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, "plan", isNullPlanJoiner.toString(), false);
|
|
|
|
- sendMsg(msg, ruleGroup, user);
|
|
|
|
|
|
+ String msg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, PLAN, isNullPlanJoiner.toString(), isNull);
|
|
|
|
+ sendMsg(msg, ruleGroup, user, PLAN);
|
|
isNullPlanJoiner = new StringJoiner(",");
|
|
isNullPlanJoiner = new StringJoiner(",");
|
|
|
|
+ isNullPlanJoiner.add(obj.getString("planId"));
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- String msg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, null, null, false);
|
|
|
|
- sendMsg(msg, ruleGroup, user);
|
|
|
|
|
|
+ String msg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, null, null, isNull);
|
|
|
|
+ sendMsg(msg, ruleGroup, user, ACCOUNT);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
if (!Check.isNull(obj.getString("creativeId"))) {
|
|
if (!Check.isNull(obj.getString("creativeId"))) {
|
|
- //字节小于1900时
|
|
|
|
- if (creativeJoiner.toString().getBytes().length <= 1900) {
|
|
|
|
|
|
+ //字节小于1800时(消息支持最大2048字节)
|
|
|
|
+ if (creativeJoiner.toString().getBytes().length <= 1800) {
|
|
creativeJoiner.add(obj.getString("creativeId"));
|
|
creativeJoiner.add(obj.getString("creativeId"));
|
|
} else {
|
|
} else {
|
|
- String message = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, "creative", creativeJoiner.toString(), false);
|
|
|
|
- sendMsg(message, ruleGroup, user);
|
|
|
|
|
|
+ String message = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, CREATIVE, creativeJoiner.toString(), isNull);
|
|
|
|
+ sendMsg(message, ruleGroup, user, CREATIVE);
|
|
creativeJoiner = new StringJoiner(",");
|
|
creativeJoiner = new StringJoiner(",");
|
|
|
|
+ creativeJoiner.add(obj.getString("creativeId"));
|
|
}
|
|
}
|
|
} else if (!Check.isNull(obj.getLong("planId"))) {
|
|
} else if (!Check.isNull(obj.getLong("planId"))) {
|
|
- if (planJoiner.toString().getBytes().length <= 1900) {
|
|
|
|
|
|
+ if (planJoiner.toString().getBytes().length <= 1800) {
|
|
planJoiner.add(obj.getString("planId"));
|
|
planJoiner.add(obj.getString("planId"));
|
|
} else {
|
|
} else {
|
|
- String msg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, "plan", planJoiner.toString(), false);
|
|
|
|
- sendMsg(msg, ruleGroup, user);
|
|
|
|
|
|
+ String msg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, PLAN, planJoiner.toString(), isNull);
|
|
|
|
+ sendMsg(msg, ruleGroup, user, PLAN);
|
|
planJoiner = new StringJoiner(",");
|
|
planJoiner = new StringJoiner(",");
|
|
|
|
+ planJoiner.add(obj.getString("planId"));
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- String msg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, null, null, false);
|
|
|
|
- sendMsg(msg, ruleGroup, user);
|
|
|
|
|
|
+ String msg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, null, null, isNull);
|
|
|
|
+ sendMsg(msg, ruleGroup, user, ACCOUNT);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- String creativeMsg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, "creative", creativeJoiner.toString(), accountName, false);
|
|
|
|
- if (!Check.isNull(creativeMsg)) {
|
|
|
|
- sendMsg(creativeMsg, ruleGroup, user);
|
|
|
|
|
|
+ if (!Check.isNull(creativeJoiner.toString())) {
|
|
|
|
+ String creativeMsg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, CREATIVE, creativeJoiner.toString(), false);
|
|
|
|
+ sendMsg(creativeMsg, ruleGroup, user, CREATIVE);
|
|
}
|
|
}
|
|
- String planMsg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, "creative", planJoiner.toString(), accountName, false);
|
|
|
|
- if (!Check.isNull(planMsg)) {
|
|
|
|
- sendMsg(planMsg, ruleGroup, user);
|
|
|
|
|
|
+ if (!Check.isNull(planJoiner.toString())) {
|
|
|
|
+ String planMsg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, PLAN, planJoiner.toString(), false);
|
|
|
|
+ sendMsg(planMsg, ruleGroup, user, PLAN);
|
|
}
|
|
}
|
|
- String isNullCreativeMsg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, "creative", isNullCreativeJoiner.toString(), accountName, false);
|
|
|
|
- if (!Check.isNull(isNullCreativeMsg)) {
|
|
|
|
- sendMsg(isNullCreativeMsg, ruleGroup, user);
|
|
|
|
|
|
+ if (!Check.isNull(isNullCreativeJoiner.toString())) {
|
|
|
|
+ String isNullCreativeMsg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, CREATIVE, isNullCreativeJoiner.toString(), true);
|
|
|
|
+ sendMsg(isNullCreativeMsg, ruleGroup, user, CREATIVE);
|
|
}
|
|
}
|
|
- String isNullPlanMsg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, "creative", isNullPlanJoiner.toString(), accountName, false);
|
|
|
|
- if (!Check.isNull(isNullPlanMsg)) {
|
|
|
|
- sendMsg(isNullPlanMsg, ruleGroup, user);
|
|
|
|
|
|
+ if (!Check.isNull(isNullPlanJoiner.toString())) {
|
|
|
|
+ String isNullPlanMsg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, PLAN, isNullPlanJoiner.toString(), true);
|
|
|
|
+ sendMsg(isNullPlanMsg, ruleGroup, user, PLAN);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -426,9 +499,10 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
* @throws
|
|
* @throws
|
|
* @author ZHAOXA
|
|
* @author ZHAOXA
|
|
*/
|
|
*/
|
|
- private void sendMsg(String msg, RuleGroup ruleGroup, JSONObject user) {
|
|
|
|
- //TODO 关停操作
|
|
|
|
- boolean isPause = false;
|
|
|
|
|
|
+ private void sendMsg(String msg, RuleGroup ruleGroup, JSONObject user, String type) {
|
|
|
|
+ try {
|
|
|
|
+ //TODO 关停操作
|
|
|
|
+ boolean isPause = false;
|
|
/* "PAUSE".equals(ruleGroup.getOperate());
|
|
/* "PAUSE".equals(ruleGroup.getOperate());
|
|
if (isPause) {
|
|
if (isPause) {
|
|
if (shutDown(accountId, planId, creativeId, user.getString("id"))) {
|
|
if (shutDown(accountId, planId, creativeId, user.getString("id"))) {
|
|
@@ -437,42 +511,46 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
type 1:头条2:快手
|
|
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)) {
|
|
|
|
-
|
|
|
|
- } else if ("EMAIL".equals(sendType)) {
|
|
|
|
|
|
+ if (isPause) {
|
|
|
|
+ msg += "现已被关停,请您及时查看并调整!";
|
|
|
|
+ } else {
|
|
|
|
+ msg += "请您及时查看并调整!";
|
|
|
|
+ }
|
|
|
|
+ String sendType = ruleGroup.getSendType();
|
|
|
|
+ if ("SMS".equals(sendType)) {
|
|
|
|
|
|
- } else if ("TEL".equals(sendType)) {
|
|
|
|
|
|
+ } else if ("EMAIL".equals(sendType)) {
|
|
|
|
+ List<String> mailList = new ArrayList<>();
|
|
|
|
+ mailList.add(user.getString("email"));
|
|
|
|
+ SendMailUtil.sendMail(mailList, ruleGroup.getGroupName() + "预警", msg);
|
|
|
|
+ } else if ("TEL".equals(sendType)) {
|
|
|
|
|
|
- } else {
|
|
|
|
- //TODO
|
|
|
|
- ISendMessageService sendMessageService = this.sendMessageService;
|
|
|
|
-// sendMessageService.sendMessage(user.getString("id"), msg);
|
|
|
|
- sendMessageService.sendMessage("1b3deb8258e84df994f1371a51cfc14a", msg);
|
|
|
|
- //113dee46c7df464da78c07a985e92cd1 于蒙
|
|
|
|
- }
|
|
|
|
- if (!Check.isNull(msg)) {
|
|
|
|
- AlarmEventSend send = new AlarmEventSend();
|
|
|
|
- send.setAlarmDetail(msg);
|
|
|
|
- send.setAlarmStatus(NoEn.NO1.valueStr());
|
|
|
|
- send.setEventRuleId(ruleGroup.getId());
|
|
|
|
- if (msg.contains("预警账户")) {
|
|
|
|
- send.setMetricValueCode("account");
|
|
|
|
- if (msg.contains("预警计划")) {
|
|
|
|
- send.setMetricValueCode("plan");
|
|
|
|
- if (msg.contains("预警创意")) {
|
|
|
|
- send.setMetricValueCode("creative");
|
|
|
|
- }
|
|
|
|
|
|
+ } else {
|
|
|
|
+// for (int i = 0; i < 10000000; i++) {
|
|
|
|
+// sendMessageService.sendMessage("1b3deb8258e84df994f1371a51cfc14a", msg + i);
|
|
|
|
+// Thread.sleep(2000);
|
|
|
|
+// }
|
|
|
|
+ sendMessageService.sendMessage("1b3deb8258e84df994f1371a51cfc14a", msg);
|
|
|
|
+ Thread.sleep(200);
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(msg)) {
|
|
|
|
+ AlarmEventSend send = new AlarmEventSend();
|
|
|
|
+ send.setUserId(user.getString("id"));
|
|
|
|
+ send.setAlarmDetail(msg.replace("<br/>", ""));
|
|
|
|
+ send.setAlarmStatus(NoEn.NO1.valueStr());
|
|
|
|
+ send.setGroupId(ruleGroup.getId());
|
|
|
|
+ send.setGroupName(ruleGroup.getGroupName());
|
|
|
|
+ if (CREATIVE.equals(type)) {
|
|
|
|
+ send.setRuleDimension(CREATIVE);
|
|
|
|
+ } else if (PLAN.equals(type)) {
|
|
|
|
+ send.setRuleDimension(PLAN);
|
|
|
|
+ } else {
|
|
|
|
+ send.setRuleDimension(ACCOUNT);
|
|
}
|
|
}
|
|
|
|
+ alarmEventSendMapper.insert(send);
|
|
}
|
|
}
|
|
- send.setAlarmCondition(ruleGroup.getGroupName());
|
|
|
|
- send.setUserId(user.getString("id"));
|
|
|
|
- alarmEventSendMapper.insert(send);
|
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("发送消息异常", e);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -713,6 +791,9 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
RuleAccountThreshold threshold = new RuleAccountThreshold();
|
|
RuleAccountThreshold threshold = new RuleAccountThreshold();
|
|
|
|
+ if (ruleBase.getVariableType() == 0) {
|
|
|
|
+ threshold.setThreshold(ruleBase.getThreshold());
|
|
|
|
+ }
|
|
threshold.setAccountId(accountId);
|
|
threshold.setAccountId(accountId);
|
|
if (isCopy == 1) {
|
|
if (isCopy == 1) {
|
|
threshold.setBatchNo(batchId);
|
|
threshold.setBatchNo(batchId);
|