|
@@ -80,8 +80,6 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
@Autowired
|
|
@Autowired
|
|
private IKuaiShouUpdateService kuaiShouUpdateService;
|
|
private IKuaiShouUpdateService kuaiShouUpdateService;
|
|
@Autowired
|
|
@Autowired
|
|
- private ICtopOauthTokenService oauthTokenService;
|
|
|
|
- @Autowired
|
|
|
|
private IRuleDataAccountService ruleDataAccountService;
|
|
private IRuleDataAccountService ruleDataAccountService;
|
|
@Autowired
|
|
@Autowired
|
|
private AlarmEventSendMapper alarmEventSendMapper;
|
|
private AlarmEventSendMapper alarmEventSendMapper;
|
|
@@ -92,7 +90,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
@Autowired
|
|
@Autowired
|
|
private IByteDanceCreativeService byteDanceCreativeService;
|
|
private IByteDanceCreativeService byteDanceCreativeService;
|
|
@Autowired
|
|
@Autowired
|
|
- private ICtopOauthTokenService ctopOauthTokenService;
|
|
|
|
|
|
+ private ICtopOauthTokenService tokenService;
|
|
|
|
|
|
private JSONObject userObj = null;
|
|
private JSONObject userObj = null;
|
|
private final static String ACCOUNT = "account";
|
|
private final static String ACCOUNT = "account";
|
|
@@ -140,16 +138,21 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
*/
|
|
*/
|
|
private void matchAlarmRules(Map<Long, Object> ruleGroupMap, JSONObject indicators, RuleAccountTemplate templates) {
|
|
private void matchAlarmRules(Map<Long, Object> ruleGroupMap, JSONObject indicators, RuleAccountTemplate templates) {
|
|
userObj = new JSONObject();
|
|
userObj = new JSONObject();
|
|
- //查询匹配数据
|
|
|
|
- JSONObject matchData = getRuleData(templates.getAccountId());
|
|
|
|
- if (Check.isNull(matchData)) {
|
|
|
|
- log.warn("查询匹配数据失败");
|
|
|
|
- return;
|
|
|
|
- }
|
|
|
|
boolean isCopy = false;
|
|
boolean isCopy = false;
|
|
Map<Long, Object> map = (Map<Long, Object>) ruleGroupMap.get(templates.getTemplateId());
|
|
Map<Long, Object> map = (Map<Long, Object>) ruleGroupMap.get(templates.getTemplateId());
|
|
- //媒体类型 1:头条2:快手
|
|
|
|
Integer type = (Integer) map.get("type");
|
|
Integer type = (Integer) map.get("type");
|
|
|
|
+ JSONObject matchData = null;
|
|
|
|
+ //媒体类型 1:头条2:快手
|
|
|
|
+ if (NoEn.NO1.valueInt() == type || NoEn.NO3.valueInt() == type) {
|
|
|
|
+ //查询抖音匹配数据
|
|
|
|
+ matchData = getRuleData(templates.getAccountId());
|
|
|
|
+ } else {
|
|
|
|
+ //TODO 获取快手数据
|
|
|
|
+ }
|
|
|
|
+ if (Check.isNull(matchData)) {
|
|
|
|
+ log.warn("获取匹配数据失败");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
//常规规则+阈值
|
|
//常规规则+阈值
|
|
List<RuleGroup> notCopyGroups = (List<RuleGroup>) map.get("notCopy");
|
|
List<RuleGroup> notCopyGroups = (List<RuleGroup>) map.get("notCopy");
|
|
JSONObject notCopythreshold = getThreshold(templates.getAccountId(), isCopy);
|
|
JSONObject notCopythreshold = getThreshold(templates.getAccountId(), isCopy);
|
|
@@ -205,14 +208,14 @@ 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(ruleBaseList, thresholdJn, indicators, matchData, complianceList);
|
|
|
|
|
|
+ CombinationRule(ruleBaseList, thresholdJn, indicators, matchData, complianceList, type);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
boolean isGroup = "group".equals(ruleGroup.getRuleType());
|
|
boolean isGroup = "group".equals(ruleGroup.getRuleType());
|
|
//匹配组合规则
|
|
//匹配组合规则
|
|
if (isGroup) {
|
|
if (isGroup) {
|
|
- CombinationRule(ruleBaseList, thresholdObj, indicators, matchData, complianceList);
|
|
|
|
|
|
+ CombinationRule(ruleBaseList, thresholdObj, indicators, matchData, complianceList, type);
|
|
//匹配单规则
|
|
//匹配单规则
|
|
} else {
|
|
} else {
|
|
RuleBase ruleBase = ruleBaseList.get(0);
|
|
RuleBase ruleBase = ruleBaseList.get(0);
|
|
@@ -241,7 +244,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (!Check.isNull(complianceList)) {
|
|
if (!Check.isNull(complianceList)) {
|
|
- getAndSendMessag(complianceList, ruleGroup, accountName);
|
|
|
|
|
|
+ getAndSendMessag(complianceList, ruleGroup, accountName, type);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -260,8 +263,9 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
* @throws
|
|
* @throws
|
|
* @author ZHAOXA
|
|
* @author ZHAOXA
|
|
*/
|
|
*/
|
|
- private void CombinationRule(List<RuleBase> ruleBaseList, JSONObject thresholdObj, JSONObject indicators, JSONObject matchData, JSONArray complianceList) {
|
|
|
|
|
|
+ private void CombinationRule(List<RuleBase> ruleBaseList, JSONObject thresholdObj, JSONObject indicators, JSONObject matchData, JSONArray complianceList, Integer type) {
|
|
//符合规则的数据集
|
|
//符合规则的数据集
|
|
|
|
+ JSONArray groupDatas = new JSONArray();
|
|
JSONArray targetDatas = new JSONArray();
|
|
JSONArray targetDatas = new JSONArray();
|
|
JSONArray planDatas = new JSONArray();
|
|
JSONArray planDatas = new JSONArray();
|
|
JSONArray creativeDatas = new JSONArray();
|
|
JSONArray creativeDatas = new JSONArray();
|
|
@@ -272,7 +276,7 @@ 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) || threshold.contains("unlimited")) {
|
|
if (!Check.isNull(accountDatas)) {
|
|
if (!Check.isNull(accountDatas)) {
|
|
accountDatas = null;
|
|
accountDatas = null;
|
|
}
|
|
}
|
|
@@ -285,6 +289,9 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
if (!Check.isNull(targetDatas)) {
|
|
if (!Check.isNull(targetDatas)) {
|
|
targetDatas = null;
|
|
targetDatas = null;
|
|
}
|
|
}
|
|
|
|
+ if (!Check.isNull(groupDatas)) {
|
|
|
|
+ groupDatas = null;
|
|
|
|
+ }
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
JSONArray dimensionData = matchData.getJSONArray(ruleBase.getRuleDimension());
|
|
JSONArray dimensionData = matchData.getJSONArray(ruleBase.getRuleDimension());
|
|
@@ -301,6 +308,9 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
if (!Check.isNull(targetDatas)) {
|
|
if (!Check.isNull(targetDatas)) {
|
|
targetDatas = null;
|
|
targetDatas = null;
|
|
}
|
|
}
|
|
|
|
+ if (!Check.isNull(groupDatas)) {
|
|
|
|
+ groupDatas = null;
|
|
|
|
+ }
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
//账户维度数据
|
|
//账户维度数据
|
|
@@ -323,6 +333,9 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
if (!Check.isNull(targetDatas)) {
|
|
if (!Check.isNull(targetDatas)) {
|
|
targetDatas = null;
|
|
targetDatas = null;
|
|
}
|
|
}
|
|
|
|
+ if (!Check.isNull(groupDatas)) {
|
|
|
|
+ groupDatas = null;
|
|
|
|
+ }
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
} else if (PLAN.equals(ruleBase.getRuleDimension())) {
|
|
} else if (PLAN.equals(ruleBase.getRuleDimension())) {
|
|
@@ -340,6 +353,9 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
if (!Check.isNull(targetDatas)) {
|
|
if (!Check.isNull(targetDatas)) {
|
|
targetDatas = null;
|
|
targetDatas = null;
|
|
}
|
|
}
|
|
|
|
+ if (!Check.isNull(groupDatas)) {
|
|
|
|
+ groupDatas = null;
|
|
|
|
+ }
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
} else if (CREATIVE.equals(ruleBase.getRuleDimension())) {
|
|
} else if (CREATIVE.equals(ruleBase.getRuleDimension())) {
|
|
@@ -357,6 +373,9 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
if (!Check.isNull(targetDatas)) {
|
|
if (!Check.isNull(targetDatas)) {
|
|
targetDatas = null;
|
|
targetDatas = null;
|
|
}
|
|
}
|
|
|
|
+ if (!Check.isNull(groupDatas)) {
|
|
|
|
+ groupDatas = null;
|
|
|
|
+ }
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
} else if ("target".equals(ruleBase.getRuleDimension())) {
|
|
} else if ("target".equals(ruleBase.getRuleDimension())) {
|
|
@@ -374,12 +393,40 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
if (!Check.isNull(targetDatas)) {
|
|
if (!Check.isNull(targetDatas)) {
|
|
targetDatas = null;
|
|
targetDatas = null;
|
|
}
|
|
}
|
|
|
|
+ if (!Check.isNull(groupDatas)) {
|
|
|
|
+ groupDatas = null;
|
|
|
|
+ }
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ } else if ("group".equals(ruleBase.getRuleDimension())) {
|
|
|
|
+ groupDatas = getOKData(groupDatas, dimensionData, ruleBase, indicator, threshold);
|
|
|
|
+ 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;
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(groupDatas)) {
|
|
|
|
+ groupDatas = null;
|
|
|
|
+ }
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//获取达标可发送的数据
|
|
//获取达标可发送的数据
|
|
- JSONArray sendData = MatchLogic.getSendData(accountDatas, planDatas, creativeDatas, targetDatas);
|
|
|
|
|
|
+ JSONArray sendData = null;
|
|
|
|
+ if (NoEn.NO1.valueInt() == type || NoEn.NO3.valueInt() == type) {
|
|
|
|
+ sendData = MatchLogic.getSendData(accountDatas, planDatas, creativeDatas, targetDatas);
|
|
|
|
+ } else {
|
|
|
|
+ sendData = MatchLogic.getKuaiShouSendData(accountDatas, groupDatas, planDatas, creativeDatas, targetDatas);
|
|
|
|
+ }
|
|
if (!Check.isNull(sendData)) {
|
|
if (!Check.isNull(sendData)) {
|
|
complianceList.addAll(sendData);
|
|
complianceList.addAll(sendData);
|
|
}
|
|
}
|
|
@@ -417,7 +464,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
return ruleDatas;
|
|
return ruleDatas;
|
|
}
|
|
}
|
|
|
|
|
|
- private void getAndSendMessag(JSONArray complianceList, RuleGroup ruleGroup, String accountName) {
|
|
|
|
|
|
+ private void getAndSendMessag(JSONArray complianceList, RuleGroup ruleGroup, String accountName, Integer mediaType) {
|
|
Long accountId = complianceList.getJSONObject(0).getLong("accountId");
|
|
Long accountId = complianceList.getJSONObject(0).getLong("accountId");
|
|
if (Check.isNull(accountId)) {
|
|
if (Check.isNull(accountId)) {
|
|
return;
|
|
return;
|
|
@@ -437,7 +484,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
isNullCreativeJoiner.add(obj.getString("creativeId"));
|
|
isNullCreativeJoiner.add(obj.getString("creativeId"));
|
|
} else {
|
|
} else {
|
|
String message = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, CREATIVE, isNullCreativeJoiner.toString(), isNull);
|
|
String message = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, CREATIVE, isNullCreativeJoiner.toString(), isNull);
|
|
- sendMsg(message, ruleGroup, user, CREATIVE, isNullCreativeJoiner.toString(), accountId);
|
|
|
|
|
|
+ sendMsg(message, ruleGroup, user, CREATIVE, isNullCreativeJoiner.toString(), accountId, mediaType);
|
|
isNullCreativeJoiner = new StringJoiner(",");
|
|
isNullCreativeJoiner = new StringJoiner(",");
|
|
isNullCreativeJoiner.add(obj.getString("creativeId"));
|
|
isNullCreativeJoiner.add(obj.getString("creativeId"));
|
|
}
|
|
}
|
|
@@ -446,13 +493,13 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
isNullPlanJoiner.add(obj.getString("planId"));
|
|
isNullPlanJoiner.add(obj.getString("planId"));
|
|
} else {
|
|
} else {
|
|
String msg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, PLAN, isNullPlanJoiner.toString(), isNull);
|
|
String msg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, PLAN, isNullPlanJoiner.toString(), isNull);
|
|
- sendMsg(msg, ruleGroup, user, PLAN, isNullPlanJoiner.toString(), accountId);
|
|
|
|
|
|
+ sendMsg(msg, ruleGroup, user, PLAN, isNullPlanJoiner.toString(), accountId, mediaType);
|
|
isNullPlanJoiner = new StringJoiner(",");
|
|
isNullPlanJoiner = new StringJoiner(",");
|
|
isNullPlanJoiner.add(obj.getString("planId"));
|
|
isNullPlanJoiner.add(obj.getString("planId"));
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
String msg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, null, null, isNull);
|
|
String msg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, null, null, isNull);
|
|
- sendMsg(msg, ruleGroup, user, ACCOUNT, null, accountId);
|
|
|
|
|
|
+ sendMsg(msg, ruleGroup, user, ACCOUNT, null, accountId, mediaType);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
if (!Check.isNull(obj.getString("creativeId"))) {
|
|
if (!Check.isNull(obj.getString("creativeId"))) {
|
|
@@ -461,7 +508,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
creativeJoiner.add(obj.getString("creativeId"));
|
|
creativeJoiner.add(obj.getString("creativeId"));
|
|
} else {
|
|
} else {
|
|
String message = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, CREATIVE, creativeJoiner.toString(), isNull);
|
|
String message = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, CREATIVE, creativeJoiner.toString(), isNull);
|
|
- sendMsg(message, ruleGroup, user, CREATIVE, creativeJoiner.toString(), accountId);
|
|
|
|
|
|
+ sendMsg(message, ruleGroup, user, CREATIVE, creativeJoiner.toString(), accountId, mediaType);
|
|
creativeJoiner = new StringJoiner(",");
|
|
creativeJoiner = new StringJoiner(",");
|
|
creativeJoiner.add(obj.getString("creativeId"));
|
|
creativeJoiner.add(obj.getString("creativeId"));
|
|
}
|
|
}
|
|
@@ -470,31 +517,31 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
planJoiner.add(obj.getString("planId"));
|
|
planJoiner.add(obj.getString("planId"));
|
|
} else {
|
|
} else {
|
|
String msg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, PLAN, planJoiner.toString(), isNull);
|
|
String msg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, PLAN, planJoiner.toString(), isNull);
|
|
- sendMsg(msg, ruleGroup, user, PLAN, planJoiner.toString(), accountId);
|
|
|
|
|
|
+ sendMsg(msg, ruleGroup, user, PLAN, planJoiner.toString(), accountId, mediaType);
|
|
planJoiner = new StringJoiner(",");
|
|
planJoiner = new StringJoiner(",");
|
|
planJoiner.add(obj.getString("planId"));
|
|
planJoiner.add(obj.getString("planId"));
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
String msg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, null, null, isNull);
|
|
String msg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, null, null, isNull);
|
|
- sendMsg(msg, ruleGroup, user, ACCOUNT, null, accountId);
|
|
|
|
|
|
+ sendMsg(msg, ruleGroup, user, ACCOUNT, null, accountId, mediaType);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (!Check.isNull(creativeJoiner.toString())) {
|
|
if (!Check.isNull(creativeJoiner.toString())) {
|
|
String creativeMsg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, CREATIVE, creativeJoiner.toString(), false);
|
|
String creativeMsg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, CREATIVE, creativeJoiner.toString(), false);
|
|
- sendMsg(creativeMsg, ruleGroup, user, CREATIVE, creativeJoiner.toString(), accountId);
|
|
|
|
|
|
+ sendMsg(creativeMsg, ruleGroup, user, CREATIVE, creativeJoiner.toString(), accountId, mediaType);
|
|
}
|
|
}
|
|
if (!Check.isNull(planJoiner.toString())) {
|
|
if (!Check.isNull(planJoiner.toString())) {
|
|
String planMsg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, PLAN, planJoiner.toString(), false);
|
|
String planMsg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, PLAN, planJoiner.toString(), false);
|
|
- sendMsg(planMsg, ruleGroup, user, PLAN, planJoiner.toString(), accountId);
|
|
|
|
|
|
+ sendMsg(planMsg, ruleGroup, user, PLAN, planJoiner.toString(), accountId, mediaType);
|
|
}
|
|
}
|
|
if (!Check.isNull(isNullCreativeJoiner.toString())) {
|
|
if (!Check.isNull(isNullCreativeJoiner.toString())) {
|
|
String isNullCreativeMsg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, CREATIVE, isNullCreativeJoiner.toString(), true);
|
|
String isNullCreativeMsg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, CREATIVE, isNullCreativeJoiner.toString(), true);
|
|
- sendMsg(isNullCreativeMsg, ruleGroup, user, CREATIVE, isNullCreativeJoiner.toString(), accountId);
|
|
|
|
|
|
+ sendMsg(isNullCreativeMsg, ruleGroup, user, CREATIVE, isNullCreativeJoiner.toString(), accountId, mediaType);
|
|
}
|
|
}
|
|
if (!Check.isNull(isNullPlanJoiner.toString())) {
|
|
if (!Check.isNull(isNullPlanJoiner.toString())) {
|
|
String isNullPlanMsg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, PLAN, isNullPlanJoiner.toString(), true);
|
|
String isNullPlanMsg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, PLAN, isNullPlanJoiner.toString(), true);
|
|
- sendMsg(isNullPlanMsg, ruleGroup, user, PLAN, isNullPlanJoiner.toString(), accountId);
|
|
|
|
|
|
+ sendMsg(isNullPlanMsg, ruleGroup, user, PLAN, isNullPlanJoiner.toString(), accountId, mediaType);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -509,22 +556,24 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
* @throws
|
|
* @throws
|
|
* @author ZHAOXA
|
|
* @author ZHAOXA
|
|
*/
|
|
*/
|
|
- private void sendMsg(String msg, RuleGroup ruleGroup, JSONObject user, String type, String ids, Long accountId) {
|
|
|
|
|
|
+ private void sendMsg(String msg, RuleGroup ruleGroup, JSONObject user, String type, String ids, Long accountId, Integer mediaType) {
|
|
try {
|
|
try {
|
|
boolean isPause = "PAUSE".equals(ruleGroup.getOperate());
|
|
boolean isPause = "PAUSE".equals(ruleGroup.getOperate());
|
|
if (isPause) {
|
|
if (isPause) {
|
|
//type 1:头条2:快手
|
|
//type 1:头条2:快手
|
|
- if (NoEn.NO1.valueStr().equals(type)) {
|
|
|
|
- isPause = touTiaoshutDown(accountId, ids, type);
|
|
|
|
|
|
+ if (NoEn.NO1.valueInt() == mediaType || NoEn.NO3.valueInt() == mediaType) {
|
|
|
|
+ msg = touTiaoshutDown(accountId, ids, type, msg);
|
|
} else {
|
|
} else {
|
|
msg = kuaiShoushutDown(accountId, ids, type, user.getString("id"), msg);
|
|
msg = kuaiShoushutDown(accountId, ids, type, user.getString("id"), msg);
|
|
- if (msg.getBytes().length >= 2048) {
|
|
|
|
- msg = msg.replace(",", ",");
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
- }
|
|
|
|
- if (isPause) {
|
|
|
|
- msg += "现已被关停,请您及时查看并调整!";
|
|
|
|
|
|
+ if (msg.getBytes().length >= 2000) {
|
|
|
|
+ msg = msg.replace(",", ",");
|
|
|
|
+ }
|
|
|
|
+ if (ACCOUNT.equals(type)) {
|
|
|
|
+ msg += "请您及时查看并调整!";
|
|
|
|
+ } else {
|
|
|
|
+ msg += "现已被关停,请您及时查看并调整!";
|
|
|
|
+ }
|
|
} else {
|
|
} else {
|
|
msg += "请您及时查看并调整!";
|
|
msg += "请您及时查看并调整!";
|
|
}
|
|
}
|
|
@@ -538,13 +587,13 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
} else if ("TEL".equals(sendType)) {
|
|
} else if ("TEL".equals(sendType)) {
|
|
|
|
|
|
} else {
|
|
} else {
|
|
-// sendMessageService.sendMessage("1b3deb8258e84df994f1371a51cfc14a", msg);
|
|
|
|
- sendMessageService.sendMessage(user.getString("id"), msg);
|
|
|
|
|
|
+ sendMessageService.sendMessage("1b3deb8258e84df994f1371a51cfc14a", msg);
|
|
|
|
+// sendMessageService.sendMessage(user.getString("id"), msg);
|
|
Thread.sleep(200);
|
|
Thread.sleep(200);
|
|
}
|
|
}
|
|
if (!Check.isNull(msg)) {
|
|
if (!Check.isNull(msg)) {
|
|
AlarmEventSend send = new AlarmEventSend();
|
|
AlarmEventSend send = new AlarmEventSend();
|
|
- send.setUserId(user.getString("id"));
|
|
|
|
|
|
+ send.setUserId(user.getString("realname").concat("_").concat(user.getString("id")));
|
|
send.setAlarmDetail(msg.replace("<br/>", ","));
|
|
send.setAlarmDetail(msg.replace("<br/>", ","));
|
|
send.setAlarmStatus(NoEn.NO1.valueStr());
|
|
send.setAlarmStatus(NoEn.NO1.valueStr());
|
|
send.setGroupId(ruleGroup.getId());
|
|
send.setGroupId(ruleGroup.getId());
|
|
@@ -591,7 +640,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
* @author ZHAOXA
|
|
* @author ZHAOXA
|
|
*/
|
|
*/
|
|
private String kuaiShoushutDown(Long accountId, String ids, String type, String userId, String msg) {
|
|
private String kuaiShoushutDown(Long accountId, String ids, String type, String userId, String msg) {
|
|
- CtopOauthToken token = oauthTokenService.getTokenByAccountId(accountId);
|
|
|
|
|
|
+ CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
|
|
Map<String, Object> updateMap = new HashMap<>();
|
|
Map<String, Object> updateMap = new HashMap<>();
|
|
if (!Check.isNull(token) && !Check.isNull(ids)) {
|
|
if (!Check.isNull(token) && !Check.isNull(ids)) {
|
|
String[] idSplit = ids.split(",");
|
|
String[] idSplit = ids.split(",");
|
|
@@ -601,7 +650,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
if (!(boolean) updateMap.get("success")) {
|
|
if (!(boolean) updateMap.get("success")) {
|
|
msg = msg.replace(id, id + "(F)");
|
|
msg = msg.replace(id, id + "(F)");
|
|
}
|
|
}
|
|
- } else {
|
|
|
|
|
|
+ } else if (PLAN.equals(type)) {
|
|
updateMap = kuaiShouUpdateService.updateCampaignStatus(token.getAccessToken(), accountId, Long.valueOf(id), NoEn.NO2.valueInt(), userId);
|
|
updateMap = kuaiShouUpdateService.updateCampaignStatus(token.getAccessToken(), accountId, Long.valueOf(id), NoEn.NO2.valueInt(), userId);
|
|
if (!(boolean) updateMap.get("success")) {
|
|
if (!(boolean) updateMap.get("success")) {
|
|
msg = msg.replace(id, id + "(F)");
|
|
msg = msg.replace(id, id + "(F)");
|
|
@@ -620,57 +669,37 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
* @throws
|
|
* @throws
|
|
* @author ZHAOXA
|
|
* @author ZHAOXA
|
|
*/
|
|
*/
|
|
- private boolean touTiaoshutDown(Long accountId, String ids, String type) {
|
|
|
|
- Boolean flag = false;
|
|
|
|
|
|
+ private String touTiaoshutDown(Long accountId, String ids, String type, String msg) {
|
|
try {
|
|
try {
|
|
Map<String, Object> result = new HashMap<>();
|
|
Map<String, Object> result = new HashMap<>();
|
|
if (!Check.isNull(ids)) {
|
|
if (!Check.isNull(ids)) {
|
|
String[] split = ids.split(",");
|
|
String[] split = ids.split(",");
|
|
- JSONArray planId = new JSONArray();
|
|
|
|
- //最大更新100条数据,做拆分
|
|
|
|
- if (split.length > 100) {
|
|
|
|
- JSONArray planId2 = new JSONArray();
|
|
|
|
- StringJoiner str = new StringJoiner(",");
|
|
|
|
- StringJoiner str2 = new StringJoiner(",");
|
|
|
|
- for (int i = 0; i < split.length; i++) {
|
|
|
|
- if (i > 99) {
|
|
|
|
- str2.add(split[i]);
|
|
|
|
- planId2.add(split[i]);
|
|
|
|
- } else {
|
|
|
|
- str.add(split[i]);
|
|
|
|
- planId.add(split[i]);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ if (!Check.isNull(split)) {
|
|
if (PLAN.equals(type)) {
|
|
if (PLAN.equals(type)) {
|
|
- CtopOauthToken token = ctopOauthTokenService.getTokenByAccountId(accountId);
|
|
|
|
- result = byteDanceAdvertisePlanService.updateAdvertiserPlanStatus(token, planId, "AD_STATUS_DISABLE");
|
|
|
|
- if (planId2.size() > 0) {
|
|
|
|
- result = byteDanceAdvertisePlanService.updateAdvertiserPlanStatus(token, planId2, "AD_STATUS_DISABLE");
|
|
|
|
- }
|
|
|
|
- } else {
|
|
|
|
- result = byteDanceCreativeService.advertiserCreativeUpdateStatus(accountId, str.toString(), "disable");
|
|
|
|
- if (str2.length() > 0) {
|
|
|
|
- result = byteDanceCreativeService.advertiserCreativeUpdateStatus(accountId, str2.toString(), "disable");
|
|
|
|
|
|
+ CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
|
|
|
|
+ for (String id : split) {
|
|
|
|
+ JSONArray idArray = new JSONArray();
|
|
|
|
+ idArray.add(id);
|
|
|
|
+ result = byteDanceAdvertisePlanService.updateAdvertiserPlanStatus(token, idArray, "AD_STATUS_DISABLE");
|
|
|
|
+ if (Check.isNull(result.get("code")) || (int) result.get("code") != 0) {
|
|
|
|
+ msg = msg.replace(id, id + "(F)");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
- //低于100条数据,直接执行
|
|
|
|
- } else {
|
|
|
|
- if (PLAN.equals(type)) {
|
|
|
|
|
|
+ } else if (CREATIVE.equals(type)) {
|
|
|
|
+ CtopOauthToken creativeToken = tokenService.getOauthTokenByAccountId(accountId + "");
|
|
for (String id : split) {
|
|
for (String id : split) {
|
|
- planId.add(id);
|
|
|
|
|
|
+ result = byteDanceCreativeService.advertiserCreativeUpdateStatus(creativeToken, accountId, id, "disable");
|
|
|
|
+ if (Check.isNull(result.get("code")) || (int) result.get("code") != 0) {
|
|
|
|
+ msg = msg.replace(id, id + "(F)");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- CtopOauthToken token = ctopOauthTokenService.getTokenByAccountId(accountId);
|
|
|
|
- result = byteDanceAdvertisePlanService.updateAdvertiserPlanStatus(token, planId, "AD_STATUS_DISABLE");
|
|
|
|
- } else {
|
|
|
|
- result = byteDanceCreativeService.advertiserCreativeUpdateStatus(accountId, ids.replace(",", ","), "disable");
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- flag = !Check.isNull(result.get("code")) && (int) result.get("code") == 0;
|
|
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error("头条账户:{},关停{}失败", accountId, type, e);
|
|
log.error("头条账户:{},关停{}失败", accountId, type, e);
|
|
}
|
|
}
|
|
- return flag;
|
|
|
|
|
|
+ return msg;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|