|
@@ -18,7 +18,9 @@ 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.entity.UserAllocation;
|
|
|
import cn.com.ctop.common.module.mapper.SysUserMapper;
|
|
|
+import cn.com.ctop.common.module.mapper.UserAllocationMapper;
|
|
|
import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
|
import cn.com.ctop.common.module.service.IRuleDataAccountService;
|
|
|
import cn.com.ctop.common.module.service.ISendMessageService;
|
|
@@ -77,6 +79,9 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
|
private IRuleDataAccountService ruleDataAccountService;
|
|
|
@Autowired
|
|
|
private AlarmEventSendMapper alarmEventSendMapper;
|
|
|
+ @Autowired
|
|
|
+ private UserAllocationMapper userAllocationMapper;
|
|
|
+ ;
|
|
|
private JSONObject userObj = null;
|
|
|
|
|
|
@Override
|
|
@@ -137,12 +142,17 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
|
isCopythreshold = getThreshold(templates.getAccountId(), isCopy);
|
|
|
}
|
|
|
log.info("已获取账户({})的数据,开始匹配规则", templates.getAccountId());
|
|
|
+ UserAllocation userAllocations = userAllocationMapper.getUserAllocation(templates.getAccountId());
|
|
|
+ String accountName = "";
|
|
|
+ if (!Check.isNull(userAllocations)) {
|
|
|
+ accountName = userAllocations.getAuthName();
|
|
|
+ }
|
|
|
try {
|
|
|
if (!Check.isNull(notCopyGroups)) {
|
|
|
- checkRuleGroups(notCopyGroups, notCopythreshold, indicators, matchData, type, false);
|
|
|
+ checkRuleGroups(notCopyGroups, notCopythreshold, indicators, matchData, type, false, accountName);
|
|
|
}
|
|
|
if (isCopy && !Check.isNull(isCopythreshold)) {
|
|
|
- checkRuleGroups(isCopyGroups, isCopythreshold, indicators, matchData, type, isCopy);
|
|
|
+ checkRuleGroups(isCopyGroups, isCopythreshold, indicators, matchData, type, isCopy, accountName);
|
|
|
}
|
|
|
|
|
|
} catch (Exception e) {
|
|
@@ -163,7 +173,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) {
|
|
|
+ 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)) {
|
|
@@ -174,13 +184,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);
|
|
|
+ CombinationRule(ruleGroup, ruleBaseList, thresholdMap, indicators, matchData, type,accountName);
|
|
|
}
|
|
|
} else {
|
|
|
boolean isGroup = "group".equals(ruleGroup.getRuleType());
|
|
|
//匹配组合规则
|
|
|
if (isGroup) {
|
|
|
- CombinationRule(ruleGroup, ruleBaseList, thresholdObj, indicators, matchData, type);
|
|
|
+ CombinationRule(ruleGroup, ruleBaseList, thresholdObj, indicators, matchData, type,accountName);
|
|
|
//匹配单规则
|
|
|
} else {
|
|
|
RuleBase ruleBase = ruleBaseList.get(0);
|
|
@@ -200,7 +210,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);
|
|
|
+ sendMsg(ruleGroup, obj, type,accountName);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -222,7 +232,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) {
|
|
|
+ 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();
|
|
@@ -275,7 +285,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);
|
|
|
+ sendMsg(ruleGroup, sendData.getJSONObject(i), type,accountName);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -322,7 +332,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
|
* @throws
|
|
|
* @author ZHAOXA
|
|
|
*/
|
|
|
- private void sendMsg(RuleGroup ruleGroup, JSONObject obj, Integer type) {
|
|
|
+ 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");
|
|
@@ -336,7 +346,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
|
}
|
|
|
type 1:头条2:快手
|
|
|
}*/
|
|
|
- String msg = MatchLogic.getMsg(ruleGroup, user, accountId, planId, creativeId, isPause);
|
|
|
+ String msg = MatchLogic.getMsg(ruleGroup, user, accountId, planId, creativeId, isPause,accountName);
|
|
|
String sendType = ruleGroup.getSendType();
|
|
|
if ("SMS".equals(sendType)) {
|
|
|
|
|
@@ -346,7 +356,9 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
|
|
|
|
} else {
|
|
|
ISendMessageService sendMessageService = this.sendMessageService;
|
|
|
- sendMessageService.sendMessage(user.getString("id"), msg);
|
|
|
+// sendMessageService.sendMessage(user.getString("id"), msg);
|
|
|
+ sendMessageService.sendMessage("1b3deb8258e84df994f1371a51cfc14a", msg);
|
|
|
+ //113dee46c7df464da78c07a985e92cd1 于蒙
|
|
|
}
|
|
|
log.debug("账户{}的{}预警已发送", accountId, ruleGroup.getGroupName());
|
|
|
if (!Check.isNull(msg)) {
|