|
@@ -22,6 +22,7 @@ import cn.com.ctop.common.module.entity.UserAllocation;
|
|
import cn.com.ctop.common.module.mapper.SysUserMapper;
|
|
import cn.com.ctop.common.module.mapper.SysUserMapper;
|
|
import cn.com.ctop.common.module.mapper.UserAllocationMapper;
|
|
import cn.com.ctop.common.module.mapper.UserAllocationMapper;
|
|
import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
import cn.com.ctop.common.module.service.ICtopOauthTokenService;
|
|
|
|
+import cn.com.ctop.common.module.service.IRuleDataAccountKuaishouService;
|
|
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;
|
|
@@ -82,6 +83,8 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
@Autowired
|
|
@Autowired
|
|
private IRuleDataAccountService ruleDataAccountService;
|
|
private IRuleDataAccountService ruleDataAccountService;
|
|
@Autowired
|
|
@Autowired
|
|
|
|
+ private IRuleDataAccountKuaishouService ruleDataAccountKuaishouService;
|
|
|
|
+ @Autowired
|
|
private AlarmEventSendMapper alarmEventSendMapper;
|
|
private AlarmEventSendMapper alarmEventSendMapper;
|
|
@Autowired
|
|
@Autowired
|
|
private UserAllocationMapper userAllocationMapper;
|
|
private UserAllocationMapper userAllocationMapper;
|
|
@@ -94,6 +97,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
|
|
|
|
private JSONObject userObj = null;
|
|
private JSONObject userObj = null;
|
|
private final static String ACCOUNT = "account";
|
|
private final static String ACCOUNT = "account";
|
|
|
|
+ private final static String UNIT = "unit";
|
|
private final static String PLAN = "plan";
|
|
private final static String PLAN = "plan";
|
|
private final static String CREATIVE = "creative";
|
|
private final static String CREATIVE = "creative";
|
|
|
|
|
|
@@ -102,7 +106,10 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
log.info("------start------");
|
|
log.info("------start------");
|
|
Long startTime = System.currentTimeMillis();
|
|
Long startTime = System.currentTimeMillis();
|
|
//查询账户绑定过的规则模板
|
|
//查询账户绑定过的规则模板
|
|
- List<RuleAccountTemplate> ruleAccountTemplates = ruleAccountTemplateMapper.selectByMap(null);
|
|
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
+ //0状态为启动
|
|
|
|
+ map.put("template_status", 0);
|
|
|
|
+ List<RuleAccountTemplate> ruleAccountTemplates = ruleAccountTemplateMapper.selectByMap(map);
|
|
if (Check.isNull(ruleAccountTemplates)) {
|
|
if (Check.isNull(ruleAccountTemplates)) {
|
|
log.error("查询账户绑定过的规则模板失败");
|
|
log.error("查询账户绑定过的规则模板失败");
|
|
return;
|
|
return;
|
|
@@ -142,12 +149,12 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
Map<Long, Object> map = (Map<Long, Object>) ruleGroupMap.get(templates.getTemplateId());
|
|
Map<Long, Object> map = (Map<Long, Object>) ruleGroupMap.get(templates.getTemplateId());
|
|
Integer type = (Integer) map.get("type");
|
|
Integer type = (Integer) map.get("type");
|
|
JSONObject matchData = null;
|
|
JSONObject matchData = null;
|
|
- //媒体类型 1:头条2:快手
|
|
|
|
|
|
+ //媒体类型 1,3:头条2:快手
|
|
if (NoEn.NO1.valueInt() == type || NoEn.NO3.valueInt() == type) {
|
|
if (NoEn.NO1.valueInt() == type || NoEn.NO3.valueInt() == type) {
|
|
- //查询抖音匹配数据
|
|
|
|
- matchData = getRuleData(templates.getAccountId());
|
|
|
|
|
|
+ //查询头条匹配数据
|
|
|
|
+ matchData = getRuleData(templates.getAccountId(), "TT");
|
|
} else {
|
|
} else {
|
|
- //TODO 获取快手数据
|
|
|
|
|
|
+ matchData = getRuleData(templates.getAccountId(), "KS");
|
|
}
|
|
}
|
|
if (Check.isNull(matchData)) {
|
|
if (Check.isNull(matchData)) {
|
|
log.warn("获取匹配数据失败");
|
|
log.warn("获取匹配数据失败");
|
|
@@ -398,9 +405,9 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- } else if ("group".equals(ruleBase.getRuleDimension())) {
|
|
|
|
|
|
+ } else if (UNIT.equals(ruleBase.getRuleDimension())) {
|
|
groupDatas = getOKData(groupDatas, dimensionData, ruleBase, indicator, threshold);
|
|
groupDatas = getOKData(groupDatas, dimensionData, ruleBase, indicator, threshold);
|
|
- if (Check.isNull(targetDatas)) {
|
|
|
|
|
|
+ if (Check.isNull(groupDatas)) {
|
|
if (!Check.isNull(accountDatas)) {
|
|
if (!Check.isNull(accountDatas)) {
|
|
accountDatas = null;
|
|
accountDatas = null;
|
|
}
|
|
}
|
|
@@ -471,6 +478,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
}
|
|
}
|
|
JSONObject user = getUserByAccountId(accountId);
|
|
JSONObject user = getUserByAccountId(accountId);
|
|
StringJoiner creativeJoiner = new StringJoiner(",");
|
|
StringJoiner creativeJoiner = new StringJoiner(",");
|
|
|
|
+ StringJoiner unitJoiner = new StringJoiner(",");
|
|
StringJoiner planJoiner = new StringJoiner(",");
|
|
StringJoiner planJoiner = new StringJoiner(",");
|
|
StringJoiner isNullCreativeJoiner = new StringJoiner(",");
|
|
StringJoiner isNullCreativeJoiner = new StringJoiner(",");
|
|
StringJoiner isNullPlanJoiner = new StringJoiner(",");
|
|
StringJoiner isNullPlanJoiner = new StringJoiner(",");
|
|
@@ -512,6 +520,15 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
creativeJoiner = new StringJoiner(",");
|
|
creativeJoiner = new StringJoiner(",");
|
|
creativeJoiner.add(obj.getString("creativeId"));
|
|
creativeJoiner.add(obj.getString("creativeId"));
|
|
}
|
|
}
|
|
|
|
+ } else if (!Check.isNull(obj.getLong("unitId"))) {
|
|
|
|
+ if (unitJoiner.toString().getBytes().length <= 1800) {
|
|
|
|
+ unitJoiner.add(obj.getString("unitId"));
|
|
|
|
+ } else {
|
|
|
|
+ String msg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, UNIT, unitJoiner.toString(), isNull);
|
|
|
|
+ sendMsg(msg, ruleGroup, user, UNIT, unitJoiner.toString(), accountId, mediaType);
|
|
|
|
+ unitJoiner = new StringJoiner(",");
|
|
|
|
+ unitJoiner.add(obj.getString("unitId"));
|
|
|
|
+ }
|
|
} else if (!Check.isNull(obj.getLong("planId"))) {
|
|
} else if (!Check.isNull(obj.getLong("planId"))) {
|
|
if (planJoiner.toString().getBytes().length <= 1800) {
|
|
if (planJoiner.toString().getBytes().length <= 1800) {
|
|
planJoiner.add(obj.getString("planId"));
|
|
planJoiner.add(obj.getString("planId"));
|
|
@@ -531,6 +548,10 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
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, mediaType);
|
|
sendMsg(creativeMsg, ruleGroup, user, CREATIVE, creativeJoiner.toString(), accountId, mediaType);
|
|
}
|
|
}
|
|
|
|
+ if (!Check.isNull(unitJoiner.toString())) {
|
|
|
|
+ String creativeMsg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, UNIT, unitJoiner.toString(), false);
|
|
|
|
+ sendMsg(creativeMsg, ruleGroup, user, UNIT, unitJoiner.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, mediaType);
|
|
sendMsg(planMsg, ruleGroup, user, PLAN, planJoiner.toString(), accountId, mediaType);
|
|
@@ -595,11 +616,14 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
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());
|
|
|
|
+ send.setMediaType((NoEn.NO1.valueInt() == mediaType || NoEn.NO3.valueInt() == mediaType) ? "头条" : "快手");
|
|
send.setGroupName(ruleGroup.getGroupName());
|
|
send.setGroupName(ruleGroup.getGroupName());
|
|
if (CREATIVE.equals(type)) {
|
|
if (CREATIVE.equals(type)) {
|
|
- send.setRuleDimension(CREATIVE);
|
|
|
|
|
|
+ send.setRuleDimension(type);
|
|
} else if (PLAN.equals(type)) {
|
|
} else if (PLAN.equals(type)) {
|
|
- send.setRuleDimension(PLAN);
|
|
|
|
|
|
+ send.setRuleDimension(type);
|
|
|
|
+ } else if (UNIT.equals(type)) {
|
|
|
|
+ send.setRuleDimension(type);
|
|
} else {
|
|
} else {
|
|
send.setRuleDimension(ACCOUNT);
|
|
send.setRuleDimension(ACCOUNT);
|
|
}
|
|
}
|
|
@@ -648,6 +672,11 @@ 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 if (UNIT.equals(type)) {
|
|
|
|
+ updateMap = kuaiShouUpdateService.updateUnitStatus(token.getAccessToken(), accountId, Long.valueOf(id), NoEn.NO2.valueInt(), userId);
|
|
|
|
+ if (!(boolean) updateMap.get("success")) {
|
|
|
|
+ msg = msg.replace(id, id + "(F)");
|
|
|
|
+ }
|
|
} else if (PLAN.equals(type)) {
|
|
} 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")) {
|
|
@@ -818,9 +847,14 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
* @throws
|
|
* @throws
|
|
* @author ZHAOXA
|
|
* @author ZHAOXA
|
|
*/
|
|
*/
|
|
- private JSONObject getRuleData(Long accountId) {
|
|
|
|
|
|
+ private JSONObject getRuleData(Long accountId, String type) {
|
|
try {
|
|
try {
|
|
- return ruleDataAccountService.getRuleDataByAccountId(accountId);
|
|
|
|
|
|
+ if ("TT".equals(type)) {
|
|
|
|
+ return ruleDataAccountService.getRuleDataByAccountId(accountId);
|
|
|
|
+ }
|
|
|
|
+ if ("KS".equals(type)) {
|
|
|
|
+ return ruleDataAccountKuaishouService.getKuaiShouRuleDataByAccountId(accountId);
|
|
|
|
+ }
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error("获取匹配数据集异常", e);
|
|
log.error("获取匹配数据集异常", e);
|
|
}
|
|
}
|