|
@@ -2,6 +2,7 @@ package cn.com.ctop.alarm.modules.service.impl;
|
|
|
|
|
|
import cn.com.ctop.alarm.modules.constant.MatchLogic;
|
|
import cn.com.ctop.alarm.modules.constant.MatchLogic;
|
|
import cn.com.ctop.alarm.modules.entity.AlarmEventSend;
|
|
import cn.com.ctop.alarm.modules.entity.AlarmEventSend;
|
|
|
|
+import cn.com.ctop.alarm.modules.entity.AlarmRuleOperationRecord;
|
|
import cn.com.ctop.alarm.modules.entity.AlarmRuleRecord;
|
|
import cn.com.ctop.alarm.modules.entity.AlarmRuleRecord;
|
|
import cn.com.ctop.alarm.modules.entity.RuleAccountTemplate;
|
|
import cn.com.ctop.alarm.modules.entity.RuleAccountTemplate;
|
|
import cn.com.ctop.alarm.modules.entity.RuleAccountThreshold;
|
|
import cn.com.ctop.alarm.modules.entity.RuleAccountThreshold;
|
|
@@ -11,12 +12,14 @@ import cn.com.ctop.alarm.modules.entity.RuleIndicator;
|
|
import cn.com.ctop.alarm.modules.entity.RuleTemplate;
|
|
import cn.com.ctop.alarm.modules.entity.RuleTemplate;
|
|
import cn.com.ctop.alarm.modules.enums.ConditEnum;
|
|
import cn.com.ctop.alarm.modules.enums.ConditEnum;
|
|
import cn.com.ctop.alarm.modules.mapper.AlarmEventSendMapper;
|
|
import cn.com.ctop.alarm.modules.mapper.AlarmEventSendMapper;
|
|
|
|
+import cn.com.ctop.alarm.modules.mapper.AlarmRuleOperationRecordMapper;
|
|
import cn.com.ctop.alarm.modules.mapper.RuleAccountTemplateMapper;
|
|
import cn.com.ctop.alarm.modules.mapper.RuleAccountTemplateMapper;
|
|
import cn.com.ctop.alarm.modules.mapper.RuleAccountThresholdMapper;
|
|
import cn.com.ctop.alarm.modules.mapper.RuleAccountThresholdMapper;
|
|
import cn.com.ctop.alarm.modules.mapper.RuleBaseMapper;
|
|
import cn.com.ctop.alarm.modules.mapper.RuleBaseMapper;
|
|
import cn.com.ctop.alarm.modules.mapper.RuleGroupMapper;
|
|
import cn.com.ctop.alarm.modules.mapper.RuleGroupMapper;
|
|
import cn.com.ctop.alarm.modules.mapper.RuleIndicatorMapper;
|
|
import cn.com.ctop.alarm.modules.mapper.RuleIndicatorMapper;
|
|
import cn.com.ctop.alarm.modules.mapper.RuleTemplateMapper;
|
|
import cn.com.ctop.alarm.modules.mapper.RuleTemplateMapper;
|
|
|
|
+import cn.com.ctop.alarm.modules.service.ExternalLinkService;
|
|
import cn.com.ctop.alarm.modules.service.IAlarmRuleRecordService;
|
|
import cn.com.ctop.alarm.modules.service.IAlarmRuleRecordService;
|
|
import cn.com.ctop.alarm.modules.service.IRuleAccountTemplateService;
|
|
import cn.com.ctop.alarm.modules.service.IRuleAccountTemplateService;
|
|
import cn.com.ctop.alarm.modules.service.IRuleGroupService;
|
|
import cn.com.ctop.alarm.modules.service.IRuleGroupService;
|
|
@@ -30,7 +33,12 @@ 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.common.module.utils.SendMailUtil;
|
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroup;
|
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.entity.KuaiShouGroupBid;
|
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.mapper.KuaiShouGroupBidMapper;
|
|
|
|
+import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouGroupService;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouUpdateService;
|
|
import cn.com.ctop.kuaishou.modules.batch.service.IKuaiShouUpdateService;
|
|
|
|
+import cn.com.ctop.toutiao.modules.material.entity.ByteDanceAdvertisePlan;
|
|
import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertisePlanService;
|
|
import cn.com.ctop.toutiao.modules.material.service.IByteDanceAdvertisePlanService;
|
|
import cn.com.ctop.toutiao.modules.material.service.IByteDanceCreativeService;
|
|
import cn.com.ctop.toutiao.modules.material.service.IByteDanceCreativeService;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
@@ -39,9 +47,13 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.xxl.job.core.enums.NoEn;
|
|
import com.xxl.job.core.enums.NoEn;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
+import org.jeecg.common.util.DateUtils;
|
|
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 javax.annotation.Resource;
|
|
|
|
+import java.math.BigDecimal;
|
|
|
|
+import java.text.ParseException;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
@@ -63,6 +75,11 @@ import java.util.concurrent.Executors;
|
|
@Service
|
|
@Service
|
|
public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup> implements IRuleGroupService {
|
|
public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup> implements IRuleGroupService {
|
|
|
|
|
|
|
|
+ //修改头条CPABID出价,投放时间
|
|
|
|
+ private static final String URL_UPDATE_CPABID = "";
|
|
|
|
+ //修改头条预算
|
|
|
|
+ private static final String URL_UPDATE_BUDGET = "";
|
|
|
|
+
|
|
@Autowired
|
|
@Autowired
|
|
private RuleBaseMapper ruleBaseMapper;
|
|
private RuleBaseMapper ruleBaseMapper;
|
|
@Autowired
|
|
@Autowired
|
|
@@ -101,6 +118,14 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
private IAlarmRuleRecordService alarmRuleRecordService;
|
|
private IAlarmRuleRecordService alarmRuleRecordService;
|
|
@Autowired
|
|
@Autowired
|
|
private ICtopOauthTokenService tokenService;
|
|
private ICtopOauthTokenService tokenService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private IKuaiShouGroupService kuaiShouGroupService;
|
|
|
|
+ @Resource
|
|
|
|
+ private KuaiShouGroupBidMapper groupBidMapper;
|
|
|
|
+ @Resource
|
|
|
|
+ private AlarmRuleOperationRecordMapper ruleOperationRecordMapper;
|
|
|
|
+ @Resource
|
|
|
|
+ private ExternalLinkService externalLinkService;
|
|
|
|
|
|
private JSONObject userObj = null;
|
|
private JSONObject userObj = null;
|
|
private final static String ACCOUNT = "account";
|
|
private final static String ACCOUNT = "account";
|
|
@@ -197,7 +222,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
} else {
|
|
} else {
|
|
matchData = getRuleData(templates.getAccountId(), "KS");
|
|
matchData = getRuleData(templates.getAccountId(), "KS");
|
|
}
|
|
}
|
|
- if (Check.isNull(matchData)) {
|
|
|
|
|
|
+ if (Check.isNull(matchData) || matchData.isEmpty()) {
|
|
log.warn("获取匹配数据失败");
|
|
log.warn("获取匹配数据失败");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -247,64 +272,516 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
for (RuleGroup ruleGroup : ruleGroups) {
|
|
for (RuleGroup ruleGroup : ruleGroups) {
|
|
JSONArray complianceList = new JSONArray();
|
|
JSONArray complianceList = new JSONArray();
|
|
List<RuleBase> ruleBaseList = ruleGroup.getRuleBaseList();
|
|
List<RuleBase> ruleBaseList = ruleGroup.getRuleBaseList();
|
|
|
|
+ if (Check.isNull(ruleBaseList)) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
//存储触发预警的数据
|
|
//存储触发预警的数据
|
|
List<AlarmRuleRecord> recordList = new ArrayList<>();
|
|
List<AlarmRuleRecord> recordList = new ArrayList<>();
|
|
- if (Check.isNull(ruleBaseList)) {
|
|
|
|
|
|
+ //是否有后续操作
|
|
|
|
+ Integer operation = ruleGroup.getOperation();
|
|
|
|
+ if (!Check.isNull(operation) && operation == 1) {
|
|
|
|
+ //有后续操作
|
|
|
|
+ checkRuleGroupsForOperation(isCopy, thresholdObj, ruleGroup, indicators, matchData, complianceList, type, ruleBaseList, accountName);
|
|
|
|
+ } else {
|
|
|
|
+ //复制逻辑
|
|
|
|
+ if (isCopy) {
|
|
|
|
+ JSONObject batchNo = thresholdObj.getJSONObject(ruleGroup.getId().toString());
|
|
|
|
+ for (Map.Entry<String, Object> entry : batchNo.entrySet()) {
|
|
|
|
+ JSONObject thresholdJn = (JSONObject) entry.getValue();
|
|
|
|
+ if (!Check.isNull(thresholdJn)) {
|
|
|
|
+ CombinationRule(ruleGroup, thresholdJn, indicators, matchData, complianceList, type, recordList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ boolean isGroup = "group".equals(ruleGroup.getRuleType());
|
|
|
|
+ //匹配组合规则
|
|
|
|
+ if (isGroup) {
|
|
|
|
+ CombinationRule(ruleGroup, thresholdObj, indicators, matchData, complianceList, type, recordList);
|
|
|
|
+ //匹配单规则
|
|
|
|
+ } else {
|
|
|
|
+ RuleBase ruleBase = ruleBaseList.get(0);
|
|
|
|
+ if (Check.isNull(ruleBase)) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ //指标对象
|
|
|
|
+ JSONObject indicator = indicators.getJSONObject(ruleBase.getIndicatorCode());
|
|
|
|
+ //阈值对象
|
|
|
|
+ JSONObject thresholdJson = thresholdObj.getJSONObject(ruleBase.getId().toString());
|
|
|
|
+ if (Check.isNull(thresholdJson) || thresholdJson.isEmpty()) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ //阈值
|
|
|
|
+ String threshold = thresholdJson.getString("threshold");
|
|
|
|
+ //阈值为空时,或者阈值为“unlimited”(不限),不执行该规则
|
|
|
|
+ if (Check.isNull(threshold) || threshold.contains("unlimited")) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ //维度数据
|
|
|
|
+ JSONArray dimensionData = matchData.getJSONArray(ruleBase.getRuleDimension());
|
|
|
|
+ if (!Check.isNull(dimensionData)) {
|
|
|
|
+ for (int i = 0; i < dimensionData.size(); i++) {
|
|
|
|
+ JSONObject obj = dimensionData.getJSONObject(i);
|
|
|
|
+ String value = obj.getString(ruleBase.getIndicatorCode());
|
|
|
|
+ if (MatchLogic.matchCondition(indicator, ruleBase.getRuleCondition(), threshold, value, obj, ruleBase.getIndicatorCode())) {
|
|
|
|
+ alarmRuleRecord(obj, ruleGroup, ruleBase, indicator, type, threshold, recordList);
|
|
|
|
+ complianceList.add(obj);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(complianceList)) {
|
|
|
|
+ getAndSendMessag(complianceList, ruleGroup, accountName, type, false);
|
|
|
|
+ Thread thread = new Thread() {
|
|
|
|
+ @Override
|
|
|
|
+ public void run() {
|
|
|
|
+ alarmRuleRecordService.saveBatch(recordList);
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ thread.start();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * B 含操作的规则匹配逻辑
|
|
|
|
+ */
|
|
|
|
+ private void checkRuleGroupsForOperation(boolean isCopy, JSONObject thresholdObj, RuleGroup ruleGroup, JSONObject indicators, JSONObject matchData, JSONArray complianceList, Integer type, List<RuleBase> ruleBaseList, String accountName) {
|
|
|
|
+ //存储触发预警的数据
|
|
|
|
+ List<AlarmRuleRecord> recordList = new ArrayList<>();
|
|
|
|
+ String indicatorCode = "";
|
|
|
|
+ //复制逻辑
|
|
|
|
+ if (isCopy) {
|
|
|
|
+ JSONObject batchNo = thresholdObj.getJSONObject(ruleGroup.getId().toString());
|
|
|
|
+ for (Map.Entry<String, Object> entry : batchNo.entrySet()) {
|
|
|
|
+ JSONObject thresholdJn = (JSONObject) entry.getValue();
|
|
|
|
+ if (!Check.isNull(thresholdJn)) {
|
|
|
|
+ CombinationRule(ruleGroup, thresholdJn, indicators, matchData, complianceList, type, recordList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ boolean isGroup = "group".equals(ruleGroup.getRuleType());
|
|
|
|
+ //匹配组合规则
|
|
|
|
+ if (isGroup) {
|
|
|
|
+ CombinationRule(ruleGroup, thresholdObj, indicators, matchData, complianceList, type, recordList);
|
|
|
|
+ //匹配单规则
|
|
|
|
+ } else {
|
|
|
|
+ RuleBase ruleBase = ruleBaseList.get(0);
|
|
|
|
+ if (Check.isNull(ruleBase)) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ indicatorCode = ruleBase.getIndicatorCode();
|
|
|
|
+ //比较指标
|
|
|
|
+ String cindicatorCode = ruleBase.getCindicatorCode();
|
|
|
|
+ //指标对象
|
|
|
|
+ JSONObject indicator = indicators.getJSONObject(indicatorCode);
|
|
|
|
+ //阈值对象
|
|
|
|
+ JSONObject thresholdJson = thresholdObj.getJSONObject(ruleBase.getId().toString());
|
|
|
|
+ if (Check.isNull(thresholdJson) || thresholdJson.isEmpty()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ //阈值
|
|
|
|
+ String threshold = thresholdJson.getString("threshold");
|
|
|
|
+ //阈值为空时,或者阈值为“unlimited”(不限),不执行该规则
|
|
|
|
+ if (Check.isNull(threshold) || threshold.contains("unlimited")) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ //维度数据
|
|
|
|
+ JSONArray dimensionData = matchData.getJSONArray(ruleBase.getRuleDimension());
|
|
|
|
+ if (!Check.isNull(dimensionData)) {
|
|
|
|
+ for (int i = 0; i < dimensionData.size(); i++) {
|
|
|
|
+ JSONObject obj = dimensionData.getJSONObject(i);
|
|
|
|
+ String value = obj.getString(indicatorCode);
|
|
|
|
+ String othreshold = "";
|
|
|
|
+ if (threshold.contains("~")) {
|
|
|
|
+ othreshold = threshold;
|
|
|
|
+ } else {
|
|
|
|
+ othreshold = getThresholdForOperation(obj, ruleBase, threshold, type);
|
|
|
|
+ }
|
|
|
|
+ if (MatchLogic.matchCondition(indicator, ruleBase.getRuleCondition(), othreshold, value, obj, ruleBase.getIndicatorCode())) {
|
|
|
|
+ alarmRuleRecord(obj, ruleGroup, ruleBase, indicator, type, othreshold, recordList);
|
|
|
|
+ obj.put("thresholdJson", thresholdJson);
|
|
|
|
+ complianceList.add(obj);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (!Check.isNull(complianceList)) {
|
|
|
|
+ performOperation(ruleGroup, complianceList, type, accountName);
|
|
|
|
+ Thread thread = new Thread() {
|
|
|
|
+ @Override
|
|
|
|
+ public void run() {
|
|
|
|
+ alarmRuleRecordService.saveBatch(recordList);
|
|
|
|
+ }
|
|
|
|
+ };
|
|
|
|
+ thread.start();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取操作阈值
|
|
|
|
+ */
|
|
|
|
+ private String getThresholdForOperation(JSONObject obj, RuleBase ruleBase, String threshold, Integer type) {
|
|
|
|
+ String othreshold = "";
|
|
|
|
+ Long accountId = obj.getLong("accountId");
|
|
|
|
+ //比较指标
|
|
|
|
+ String cindicatorCode = ruleBase.getCindicatorCode();
|
|
|
|
+ String indicatorCode = ruleBase.getIndicatorCode();
|
|
|
|
+ if (type == 1 || type == 3) {
|
|
|
|
+ //头条
|
|
|
|
+ Long planId = obj.getLong("planId");
|
|
|
|
+ ByteDanceAdvertisePlan byteDancePlan = byteDanceAdvertisePlanService.getById(planId);
|
|
|
|
+ if ("bid".equals(cindicatorCode)) {
|
|
|
|
+ BigDecimal bid = byteDancePlan.getBid();
|
|
|
|
+ if ("PRICING_OCPC".equals(byteDancePlan.getPricing()) || "PRICING_OCPM".equals(byteDancePlan.getPricing())) {
|
|
|
|
+ bid = byteDancePlan.getCpaBid();
|
|
|
|
+ }
|
|
|
|
+ //转化成本
|
|
|
|
+ if ("convertCost".equals(indicatorCode)) {
|
|
|
|
+ //倍数计算, 转化成本 高于or低于当前倍数时,预警
|
|
|
|
+ othreshold = bid.multiply(new BigDecimal(threshold)).toString();
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ othreshold = threshold;
|
|
|
|
+ }
|
|
|
|
+ if ("dayBudget".equals(cindicatorCode)) {
|
|
|
|
+ if ("cost".equals(indicatorCode)) {
|
|
|
|
+ //倍数计算, 转化成本 高于or低于当前倍数时,预警
|
|
|
|
+ threshold = new BigDecimal(String.valueOf(byteDancePlan.getBudget())).multiply(new BigDecimal(threshold)).toString();
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ othreshold = threshold;
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ //快手
|
|
|
|
+ Long unitId = obj.getLong("unitId");
|
|
|
|
+ KuaiShouGroup kuaiShouGroup = kuaiShouGroupService.selectGroupByUnitId(accountId, unitId);
|
|
|
|
+ if ("bid".equals(cindicatorCode)) {
|
|
|
|
+ Long bid = kuaiShouGroup.getBid();
|
|
|
|
+ if (kuaiShouGroup.getBidType() == 10) {
|
|
|
|
+ bid = kuaiShouGroup.getCpaBid();
|
|
|
|
+ }
|
|
|
|
+ //转化成本
|
|
|
|
+ if ("convertCost".equals(indicatorCode)) {
|
|
|
|
+ //倍数计算, 转化成本 高于or低于当前倍数时,预警
|
|
|
|
+ othreshold = new BigDecimal(String.valueOf(bid)).multiply(new BigDecimal(threshold)).toString();
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ othreshold = threshold;
|
|
|
|
+ }
|
|
|
|
+ if ("dayBudget".equals(cindicatorCode)) {
|
|
|
|
+ if ("charge".equals(indicatorCode)) {
|
|
|
|
+ //倍数计算, 转化成本 高于or低于当前倍数时,预警
|
|
|
|
+ othreshold = new BigDecimal(String.valueOf(kuaiShouGroup.getDayBudget())).multiply(new BigDecimal(threshold)).toString();
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ othreshold = threshold;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return othreshold;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 执行操作
|
|
|
|
+ */
|
|
|
|
+ private void performOperation(RuleGroup ruleGroup, JSONArray complianceList, Integer type, String accountName) {
|
|
|
|
+ String operationType = ruleGroup.getOperationType();
|
|
|
|
+ String operationValue = ruleGroup.getOperationValue();
|
|
|
|
+ String operate = ruleGroup.getOperate();
|
|
|
|
+ String ruleType = ruleGroup.getRuleType();
|
|
|
|
+ Long accountId = complianceList.getJSONObject(0).getLong("accountId");
|
|
|
|
+ CtopOauthToken token = tokenService.getTokenByAccountId(accountId);
|
|
|
|
+ //已操作成功的list
|
|
|
|
+ JSONArray alreadyOperatedList = new JSONArray();
|
|
|
|
+ for (int i = 0; i < complianceList.size(); i++) {
|
|
|
|
+ JSONObject obj = complianceList.getJSONObject(i);
|
|
|
|
+ AlarmRuleOperationRecord recordEntity = null;
|
|
|
|
+ JSONObject thresholdJson = obj.getJSONObject("thresholdJson");
|
|
|
|
+ if (Check.isNull(thresholdJson) || thresholdJson.isEmpty()) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- //复制逻辑
|
|
|
|
- if (isCopy) {
|
|
|
|
- JSONObject batchNo = thresholdObj.getJSONObject(ruleGroup.getId().toString());
|
|
|
|
- for (Map.Entry<String, Object> entry : batchNo.entrySet()) {
|
|
|
|
- JSONObject thresholdJn = (JSONObject) entry.getValue();
|
|
|
|
- if (!Check.isNull(thresholdJn)) {
|
|
|
|
- CombinationRule(ruleGroup, thresholdJn, indicators, matchData, complianceList, type, recordList);
|
|
|
|
|
|
+ //后续 操作阈值
|
|
|
|
+ String operationThreshold = thresholdJson.getString("operationThreshold");
|
|
|
|
+ //峰值
|
|
|
|
+ String maxValue = Check.isNull(thresholdJson.getString("maxValue")) ? "-1" : thresholdJson.getString("maxValue");
|
|
|
|
+ String minValue = Check.isNull(thresholdJson.getString("minValue")) ? "-1" : thresholdJson.getString("minValue");
|
|
|
|
+
|
|
|
|
+ if (type == 1 || type == 3) {
|
|
|
|
+ Long planId = obj.getLong("planId");//头条
|
|
|
|
+ if (Check.isNull(planId)) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ ByteDanceAdvertisePlan byteDancePlan = byteDanceAdvertisePlanService.getById(planId);
|
|
|
|
+ if (Check.isNull(byteDancePlan)) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ //修改出价
|
|
|
|
+ if ("BID".equals(operate)) {
|
|
|
|
+ BigDecimal oldBid = byteDancePlan.getBid();
|
|
|
|
+ if ("PRICING_OCPC".equals(byteDancePlan.getPricing()) || "PRICING_OCPM".equals(byteDancePlan.getPricing())) {
|
|
|
|
+ oldBid = byteDancePlan.getCpaBid();
|
|
|
|
+ }
|
|
|
|
+ if (("up".equals(operationType) && oldBid.compareTo(new BigDecimal(maxValue)) == 0) || ("down".equals(operationType) && oldBid.compareTo(new BigDecimal(minValue)) == 0)) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ Long newBid = calculatedValue(oldBid, operationType, operationValue, operationThreshold, maxValue, minValue);
|
|
|
|
+ //TODO
|
|
|
|
+ String code = externalLinkService.editBytedancePlanCpaBidOrBudget(accountId, planId.toString(), new BigDecimal(newBid.toString()), null, null);
|
|
|
|
+ String message = "success";
|
|
|
|
+ if (code.equals("")) {
|
|
|
|
+ alreadyOperatedList.add(obj);
|
|
|
|
+ } else {
|
|
|
|
+ message = "fail";
|
|
|
|
+ log.error("(头条)规则引擎修改出价失败,accountId={},unitId={}", accountId, planId);
|
|
|
|
+ }
|
|
|
|
+ recordEntity = getOperationRecordEntity(accountId, ruleGroup, maxValue, minValue, operate, null, planId, operationThreshold, oldBid.toString(), newBid.toString(), message, "头条");
|
|
|
|
+ //修改预算
|
|
|
|
+ } else if ("BUDGET".equals(operate)) {
|
|
|
|
+ BigDecimal oldBudget = byteDancePlan.getBudget();
|
|
|
|
+ if (("up".equals(operationType) && oldBudget.compareTo(new BigDecimal(maxValue)) == 0) || ("down".equals(operationType) && oldBudget.compareTo(new BigDecimal(minValue)) == 0)) {
|
|
|
|
+ continue;
|
|
}
|
|
}
|
|
|
|
+ Long newBudget = calculatedValue(oldBudget, operationType, operationValue, operationThreshold, maxValue, minValue);
|
|
|
|
+ //TODO
|
|
|
|
+ String code = externalLinkService.editBytedancePlanCpaBidOrBudget(accountId, planId.toString(), null, null, newBudget);
|
|
|
|
+ String message = "success";
|
|
|
|
+ if (code.equals("")) {
|
|
|
|
+ alreadyOperatedList.add(obj);
|
|
|
|
+ } else {
|
|
|
|
+ message = "fail";
|
|
|
|
+ log.error("(头条)规则引擎修改预算失败,accountId={},unitId={}", accountId, planId);
|
|
|
|
+ }
|
|
|
|
+ recordEntity = getOperationRecordEntity(accountId, ruleGroup, maxValue, minValue, operate, null, planId, operationThreshold, oldBudget.toString(), newBudget.toString(), message, "头条");
|
|
|
|
+ //修改投放时间
|
|
|
|
+ } else if ("TIME".equals(operate) && !byteDancePlan.getScheduleTime().equals(operationThreshold)) {
|
|
|
|
+ //TODO
|
|
|
|
+ String code = externalLinkService.editBytedancePlanCpaBidOrBudget(accountId, planId.toString(), null, operationThreshold, null);
|
|
|
|
+ String message = "success";
|
|
|
|
+ if (code.equals("")) {
|
|
|
|
+ alreadyOperatedList.add(obj);
|
|
|
|
+ } else {
|
|
|
|
+ message = "fail";
|
|
|
|
+ log.error("规则引擎修改投放时间段失败,accountId={},unitId={}", accountId, planId);
|
|
|
|
+ }
|
|
|
|
+ recordEntity = getOperationRecordEntity(accountId, ruleGroup, maxValue, minValue, operate, null, planId, operationThreshold, byteDancePlan.getScheduleTime(), operationThreshold, message, "头条");
|
|
}
|
|
}
|
|
|
|
+
|
|
} else {
|
|
} else {
|
|
- boolean isGroup = "group".equals(ruleGroup.getRuleType());
|
|
|
|
- //匹配组合规则
|
|
|
|
- if (isGroup) {
|
|
|
|
- CombinationRule(ruleGroup, thresholdObj, indicators, matchData, complianceList, type, recordList);
|
|
|
|
- //匹配单规则
|
|
|
|
- } else {
|
|
|
|
- RuleBase ruleBase = ruleBaseList.get(0);
|
|
|
|
- if (Check.isNull(ruleBase)) {
|
|
|
|
|
|
+ Long unitId = obj.getLong("unitId");//快手
|
|
|
|
+ if (Check.isNull(unitId)) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ KuaiShouGroup kuaiShouGroup = kuaiShouGroupService.selectGroupByUnitId(accountId, unitId);
|
|
|
|
+ if (Check.isNull(kuaiShouGroup)) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ //修改出价
|
|
|
|
+ if ("BID".equals(operate)) {
|
|
|
|
+ Integer bidType = kuaiShouGroup.getBidType();
|
|
|
|
+ Long oldBid = Check.isNull(kuaiShouGroup.getBid()) ? 0L : kuaiShouGroup.getBid();
|
|
|
|
+ if (bidType == 10) {
|
|
|
|
+ oldBid = kuaiShouGroup.getCpaBid();
|
|
|
|
+ }
|
|
|
|
+ if (("up".equals(operationType) && oldBid - Long.valueOf(maxValue) == 0) || ("down".equals(operationType) && oldBid - Long.valueOf(minValue) == 0)) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- //指标对象
|
|
|
|
- JSONObject indicator = indicators.getJSONObject(ruleBase.getIndicatorCode());
|
|
|
|
- //指标阈值
|
|
|
|
- String threshold = thresholdObj.getString(ruleBase.getId().toString());
|
|
|
|
- //阈值为空时,或者阈值为“unlimited”(不限),不执行该规则
|
|
|
|
- if (Check.isNull(threshold) || threshold.contains("unlimited")) {
|
|
|
|
|
|
+ Long newBid = calculatedValue(new BigDecimal(oldBid.toString()), operationType, operationValue, operationThreshold, maxValue, minValue);
|
|
|
|
+ JSONObject unitJson = new JSONObject();
|
|
|
|
+ unitJson.put("advertiser_id", accountId);
|
|
|
|
+ unitJson.put("unit_id", unitId);
|
|
|
|
+ String msg = "规则引擎修改bid";
|
|
|
|
+ if (bidType == 2) {
|
|
|
|
+ unitJson.put("bid", newBid);
|
|
|
|
+ } else if (bidType == 10) {
|
|
|
|
+ unitJson.put("cpa_bid", newBid);
|
|
|
|
+ msg = "规则引擎修改cpa_bid";
|
|
|
|
+ }
|
|
|
|
+ JSONObject jsonObject = kuaiShouUpdateService.updateUnit(token.getAccessToken(), unitJson);
|
|
|
|
+ Integer code = jsonObject.getInteger("code");
|
|
|
|
+ String message = "success";
|
|
|
|
+ if (code == 0) {
|
|
|
|
+ alreadyOperatedList.add(obj);
|
|
|
|
+ //添加改价记录
|
|
|
|
+ KuaiShouGroupBid groupBid = new KuaiShouGroupBid();
|
|
|
|
+ groupBid.setAccountId(accountId);
|
|
|
|
+ groupBid.setUnitId(unitId);
|
|
|
|
+ groupBid.setBid(newBid);
|
|
|
|
+ groupBid.setUpdateBid(oldBid);
|
|
|
|
+ groupBid.setUserId(msg);
|
|
|
|
+ groupBidMapper.insert(groupBid);
|
|
|
|
+ kuaiShouGroupService.getGroupByUnitId(token.getAccessToken(), accountId, unitId);
|
|
|
|
+ } else {
|
|
|
|
+ message = "fail," + jsonObject.getString("message");
|
|
|
|
+ log.error("(快手)规则引擎修改出价失败,accountId={},unitId={},{}", accountId, unitId, jsonObject.getString("message"));
|
|
|
|
+ }
|
|
|
|
+ recordEntity = getOperationRecordEntity(accountId, ruleGroup, maxValue, minValue, operate, unitId, null, operationThreshold, oldBid.toString(), newBid.toString(), message, "快手");
|
|
|
|
+ //修改预算
|
|
|
|
+ } else if ("BUDGET".equals(operate)) {
|
|
|
|
+ Long oldBudget = Check.isNull(kuaiShouGroup.getDayBudget()) ? 0L : kuaiShouGroup.getDayBudget();
|
|
|
|
+ if (("up".equals(operationType) && oldBudget - Long.valueOf(maxValue) == 0) || ("down".equals(operationType) && oldBudget - Long.valueOf(minValue) == 0)) {
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
- //维度数据
|
|
|
|
- JSONArray dimensionData = matchData.getJSONArray(ruleBase.getRuleDimension());
|
|
|
|
- if (!Check.isNull(dimensionData)) {
|
|
|
|
- for (int i = 0; i < dimensionData.size(); i++) {
|
|
|
|
- JSONObject obj = dimensionData.getJSONObject(i);
|
|
|
|
- String value = obj.getString(ruleBase.getIndicatorCode());
|
|
|
|
- if (MatchLogic.matchCondition(indicator, ruleBase.getRuleCondition(), threshold, value, obj, ruleBase.getIndicatorCode())) {
|
|
|
|
- alarmRuleRecord(obj, ruleGroup, ruleBase, indicator, type, threshold, recordList);
|
|
|
|
- complianceList.add(obj);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ Long newBudget = calculatedValue(new BigDecimal(oldBudget.toString()), operationType, operationValue, operationThreshold, maxValue, minValue);
|
|
|
|
+ Map<String, Object> updateMap = kuaiShouUpdateService.updateUnitDayBudget(token.getAccessToken(), accountId, unitId, newBudget, "规则引擎修改预算");
|
|
|
|
+ String message = "success";
|
|
|
|
+ if ((Integer) updateMap.get("code") == 0) {
|
|
|
|
+ alreadyOperatedList.add(obj);
|
|
|
|
+ kuaiShouGroupService.getGroupByUnitId(token.getAccessToken(), accountId, unitId);
|
|
|
|
+ } else {
|
|
|
|
+ message = "fail," + updateMap.get("message");
|
|
|
|
+ log.error("(快手)规则引擎修改预算失败,accountId={},unitId={},{}", accountId, unitId, updateMap.get("message"));
|
|
|
|
+ }
|
|
|
|
+ recordEntity = getOperationRecordEntity(accountId, ruleGroup, maxValue, minValue, operate, unitId, null, operationThreshold, oldBudget.toString(), newBudget.toString(), message, "快手");
|
|
|
|
+ //修改投放时间
|
|
|
|
+ } else if ("TIME".equals(operate)) {
|
|
|
|
+ String newScheduleTime = getNewScheduleTime(operationThreshold);
|
|
|
|
+ JSONObject unitJson = new JSONObject();
|
|
|
|
+ unitJson.put("advertiser_id", accountId);
|
|
|
|
+ unitJson.put("unit_id", unitId);
|
|
|
|
+ unitJson.put("schedule_time", newScheduleTime);
|
|
|
|
+ JSONObject jsonObject = kuaiShouUpdateService.updateUnit(token.getAccessToken(), unitJson);
|
|
|
|
+ Integer code = jsonObject.getInteger("code");
|
|
|
|
+ String message = "success";
|
|
|
|
+ if (code == 0) {
|
|
|
|
+ alreadyOperatedList.add(obj);
|
|
|
|
+ kuaiShouGroupService.getGroupByUnitId(token.getAccessToken(), accountId, unitId);
|
|
|
|
+ } else {
|
|
|
|
+ message = "fail," + jsonObject.getString("message");
|
|
|
|
+ log.error("(快手)规则引擎修改投放时间段失败,accountId={},unitId={},{}", accountId, unitId, jsonObject.getString("message"));
|
|
}
|
|
}
|
|
|
|
+ recordEntity = getOperationRecordEntity(accountId, ruleGroup, maxValue, minValue, operate, unitId, null, newScheduleTime, kuaiShouGroup.getScheduleTime(), operationThreshold, message, "快手");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- if (!Check.isNull(complianceList)) {
|
|
|
|
- getAndSendMessag(complianceList, ruleGroup, accountName, type);
|
|
|
|
- Thread thread = new Thread() {
|
|
|
|
- @Override
|
|
|
|
- public void run() {
|
|
|
|
- alarmRuleRecordService.saveBatch(recordList);
|
|
|
|
- }
|
|
|
|
- };
|
|
|
|
- thread.start();
|
|
|
|
|
|
+ if (!Check.isNull(recordEntity)) {
|
|
|
|
+ ruleOperationRecordMapper.insert(recordEntity);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ if (alreadyOperatedList.size() > 0) {
|
|
|
|
+ getAndSendMessag(alreadyOperatedList, ruleGroup, accountName, type, true);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 获取新的投放时间
|
|
|
|
+ */
|
|
|
|
+ private static String getNewScheduleTime(String operationThreshold) {
|
|
|
|
+ String ScheduleTime = "";
|
|
|
|
+ String WeekStr = DateUtils.getWhatDay(new Date().getTime());
|
|
|
|
+ Integer weekInt = -1;
|
|
|
|
+ switch (WeekStr) {
|
|
|
|
+ case "星期一":
|
|
|
|
+ weekInt = 0;
|
|
|
|
+ break;
|
|
|
|
+ case "星期二":
|
|
|
|
+ weekInt = 1;
|
|
|
|
+ break;
|
|
|
|
+ case "星期三":
|
|
|
|
+ weekInt = 2;
|
|
|
|
+ break;
|
|
|
|
+ case "星期四":
|
|
|
|
+ weekInt = 3;
|
|
|
|
+ break;
|
|
|
|
+ case "星期五":
|
|
|
|
+ weekInt = 4;
|
|
|
|
+ break;
|
|
|
|
+ case "星期六":
|
|
|
|
+ weekInt = 5;
|
|
|
|
+ break;
|
|
|
|
+ default:
|
|
|
|
+ weekInt = 6;
|
|
|
|
+ break;
|
|
|
|
+ }
|
|
|
|
+ //获取当前小时
|
|
|
|
+ Integer nowHour = -1;
|
|
|
|
+ try {
|
|
|
|
+ nowHour = DateUtils.getNowHour();
|
|
|
|
+ } catch (ParseException e) {
|
|
|
|
+ e.printStackTrace();
|
|
|
|
+ }
|
|
|
|
+ StringBuffer buf = new StringBuffer();
|
|
|
|
+ for (int i = 0; i < weekInt * 24 + nowHour; i++) {
|
|
|
|
+ buf.append("1");
|
|
|
|
+ }
|
|
|
|
+ Integer invalidTime = Integer.valueOf(operationThreshold);
|
|
|
|
+ for (int i = 0; i < invalidTime; i++) {
|
|
|
|
+ buf.append("0");
|
|
|
|
+ }
|
|
|
|
+ for (int i = 0; i < 7 * 24 - weekInt * 24 - nowHour - invalidTime; i++) {
|
|
|
|
+ buf.append("1");
|
|
|
|
+ }
|
|
|
|
+ return buf.toString();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 整合操作记录实体类
|
|
|
|
+ */
|
|
|
|
+ private AlarmRuleOperationRecord getOperationRecordEntity(Long accountId, RuleGroup ruleGroup, String maxValue, String minValue, String indicatorCode, Long unitId, Long planId, String operationThreshold, String oldValue, String newValue, String msg, String mediaType) {
|
|
|
|
+ AlarmRuleOperationRecord record = new AlarmRuleOperationRecord();
|
|
|
|
+ record.setAccountId(accountId);
|
|
|
|
+ record.setOperationType(ruleGroup.getOperationType());
|
|
|
|
+ record.setOperationValue(ruleGroup.getOperationValue());
|
|
|
|
+ record.setMaxValue(maxValue);
|
|
|
|
+ record.setMinValue(minValue);
|
|
|
|
+ record.setUnitId(unitId);
|
|
|
|
+ record.setPlanId(planId);
|
|
|
|
+ record.setGroupId(ruleGroup.getId());
|
|
|
|
+ record.setIndicatorCode(indicatorCode);
|
|
|
|
+ record.setBeforeValue(oldValue);
|
|
|
|
+ record.setAfterValue(newValue);
|
|
|
|
+ record.setOperationThreshold(operationThreshold);
|
|
|
|
+ record.setMediaType(mediaType);
|
|
|
|
+ record.setMessage(msg);
|
|
|
|
+ record.setValueTime(DateUtils.formatDate(new Date()));
|
|
|
|
+ return record;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 计算待调整数值
|
|
|
|
+ * <p>
|
|
|
|
+ * 广告组bid_type为CPC和eCPC时:不得低于0.2元,不得高于100元,单位:厘;广告组bid_type为OCPC时:行为出价不得低于1元;激活出价不得低于5元(白名单用户不得低于2元),单位:厘
|
|
|
|
+ *
|
|
|
|
+ * @param goalValue 目标值
|
|
|
|
+ * @param operationType 操作类型:up-提高,down-降低,to-调整至
|
|
|
|
+ * @param operationValue 操作内容:price-金额,percent-百分数
|
|
|
|
+ * @param operationThreshold 操作阈值
|
|
|
|
+ * @param fmaxValue 目标值的峰值
|
|
|
|
+ * @param fminValue 目标值的最低值
|
|
|
|
+ * @return
|
|
|
|
+ * @throws
|
|
|
|
+ */
|
|
|
|
+ private static Long calculatedValue(BigDecimal goal, String operationType, String operationValue, String operationThreshold, String fmaxValue, String fminValue) {
|
|
|
|
+ BigDecimal threshold = new BigDecimal(operationThreshold);
|
|
|
|
+ BigDecimal maxValue = new BigDecimal(fmaxValue);
|
|
|
|
+ BigDecimal minValue = new BigDecimal(fminValue);
|
|
|
|
+ BigDecimal value = null;
|
|
|
|
+ //操作金额
|
|
|
|
+ if ("price".equals(operationValue)) {
|
|
|
|
+ if ("up".equals(operationType)) {
|
|
|
|
+ value = goal.add(threshold);
|
|
|
|
+ } else if ("down".equals(operationType)) {
|
|
|
|
+ value = goal.subtract(threshold);
|
|
|
|
+ } else if ("to".equals(operationType)) {
|
|
|
|
+ value = threshold;
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ //操作百分数
|
|
|
|
+ if ("up".equals(operationType)) {
|
|
|
|
+ value = goal.add(goal.multiply(threshold));
|
|
|
|
+ } else if ("down".equals(operationType)) {
|
|
|
|
+ value = goal.subtract(goal.multiply(threshold));
|
|
|
|
+ } else if ("to".equals(operationType)) {
|
|
|
|
+ value = goal.multiply(threshold);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ if (value.compareTo(maxValue) == 1) {
|
|
|
|
+ value = maxValue;
|
|
|
|
+ }
|
|
|
|
+ if (value.compareTo(minValue) == -1) {
|
|
|
|
+ value = minValue;
|
|
|
|
+ }
|
|
|
|
+ return value.longValue();
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -315,7 +792,8 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
* @throws
|
|
* @throws
|
|
* @author ZHAOXA
|
|
* @author ZHAOXA
|
|
*/
|
|
*/
|
|
- private void alarmRuleRecord(JSONObject obj, RuleGroup ruleGroup, RuleBase ruleBase, JSONObject indicator, Integer mediaType, String threshold, List<AlarmRuleRecord> recordList) {
|
|
|
|
|
|
+ private void alarmRuleRecord(JSONObject obj, RuleGroup ruleGroup, RuleBase ruleBase, JSONObject
|
|
|
|
+ indicator, Integer mediaType, String threshold, List<AlarmRuleRecord> recordList) {
|
|
try {
|
|
try {
|
|
Long planId = obj.getLong("planId");
|
|
Long planId = obj.getLong("planId");
|
|
Long unidId = null;
|
|
Long unidId = null;
|
|
@@ -363,7 +841,8 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
* @throws
|
|
* @throws
|
|
* @author ZHAOXA
|
|
* @author ZHAOXA
|
|
*/
|
|
*/
|
|
- private void CombinationRule(RuleGroup ruleGroup, JSONObject thresholdObj, JSONObject indicators, JSONObject matchData, JSONArray complianceList, Integer type, List<AlarmRuleRecord> recordList) {
|
|
|
|
|
|
+ private void CombinationRule(RuleGroup ruleGroup, JSONObject thresholdObj, JSONObject indicators, JSONObject
|
|
|
|
+ matchData, JSONArray complianceList, Integer type, List<AlarmRuleRecord> recordList) {
|
|
List<RuleBase> ruleBaseList = ruleGroup.getRuleBaseList();
|
|
List<RuleBase> ruleBaseList = ruleGroup.getRuleBaseList();
|
|
//符合规则的数据集
|
|
//符合规则的数据集
|
|
JSONArray groupDatas = new JSONArray();
|
|
JSONArray groupDatas = new JSONArray();
|
|
@@ -374,8 +853,13 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
for (RuleBase ruleBase : ruleBaseList) {
|
|
for (RuleBase ruleBase : ruleBaseList) {
|
|
//指标对象
|
|
//指标对象
|
|
JSONObject indicator = indicators.getJSONObject(ruleBase.getIndicatorCode());
|
|
JSONObject indicator = indicators.getJSONObject(ruleBase.getIndicatorCode());
|
|
- //指标阈值
|
|
|
|
- String threshold = thresholdObj.getString(ruleBase.getId().toString());
|
|
|
|
|
|
+ //阈值对象
|
|
|
|
+ JSONObject thresholdJson = thresholdObj.getJSONObject(ruleBase.getId().toString());
|
|
|
|
+ if (Check.isNull(thresholdJson) || thresholdJson.isEmpty()) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+ //阈值
|
|
|
|
+ String threshold = thresholdJson.getString("threshold");
|
|
//阈值为空时,或者阈值为“unlimited”(不限),不执行该规则
|
|
//阈值为空时,或者阈值为“unlimited”(不限),不执行该规则
|
|
if (Check.isNull(threshold) || threshold.contains("unlimited")) {
|
|
if (Check.isNull(threshold) || threshold.contains("unlimited")) {
|
|
if (!Check.isNull(accountDatas)) {
|
|
if (!Check.isNull(accountDatas)) {
|
|
@@ -395,7 +879,9 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- JSONArray dimensionData = matchData.getJSONArray(ruleBase.getRuleDimension());
|
|
|
|
|
|
+ //获取维度数据
|
|
|
|
+ String ruleDimension = ruleBase.getRuleDimension();
|
|
|
|
+ JSONArray dimensionData = matchData.getJSONArray(ruleDimension);
|
|
if (Check.isNull(dimensionData)) {
|
|
if (Check.isNull(dimensionData)) {
|
|
if (!Check.isNull(accountDatas)) {
|
|
if (!Check.isNull(accountDatas)) {
|
|
accountDatas = null;
|
|
accountDatas = null;
|
|
@@ -415,7 +901,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
//账户维度数据
|
|
//账户维度数据
|
|
- if (ACCOUNT.equals(ruleBase.getRuleDimension())) {
|
|
|
|
|
|
+ if (ACCOUNT.equals(ruleDimension)) {
|
|
JSONObject accountEntity = dimensionData.getJSONObject(0);
|
|
JSONObject accountEntity = dimensionData.getJSONObject(0);
|
|
if (MatchLogic.matchCondition(indicator, ruleBase.getRuleCondition(), threshold, accountEntity.getString(ruleBase.getIndicatorCode()), accountEntity, ruleBase.getIndicatorCode())) {
|
|
if (MatchLogic.matchCondition(indicator, ruleBase.getRuleCondition(), threshold, accountEntity.getString(ruleBase.getIndicatorCode()), accountEntity, ruleBase.getIndicatorCode())) {
|
|
if (Check.isNull(accountDatas)) {
|
|
if (Check.isNull(accountDatas)) {
|
|
@@ -440,8 +926,8 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- } else if (PLAN.equals(ruleBase.getRuleDimension())) {
|
|
|
|
- planDatas = getOKData(planDatas, dimensionData, ruleBase, indicator, threshold, ruleGroup, type, recordList);
|
|
|
|
|
|
+ } else if (PLAN.equals(ruleDimension)) {
|
|
|
|
+ planDatas = getOKData(planDatas, dimensionData, ruleBase, indicator, thresholdJson, ruleGroup, type, recordList);
|
|
if (Check.isNull(planDatas)) {
|
|
if (Check.isNull(planDatas)) {
|
|
if (!Check.isNull(accountDatas)) {
|
|
if (!Check.isNull(accountDatas)) {
|
|
accountDatas = null;
|
|
accountDatas = null;
|
|
@@ -460,8 +946,8 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- } else if (CREATIVE.equals(ruleBase.getRuleDimension())) {
|
|
|
|
- creativeDatas = getOKData(creativeDatas, dimensionData, ruleBase, indicator, threshold, ruleGroup, type, recordList);
|
|
|
|
|
|
+ } else if (CREATIVE.equals(ruleDimension)) {
|
|
|
|
+ creativeDatas = getOKData(creativeDatas, dimensionData, ruleBase, indicator, thresholdJson, ruleGroup, type, recordList);
|
|
if (Check.isNull(creativeDatas)) {
|
|
if (Check.isNull(creativeDatas)) {
|
|
if (!Check.isNull(accountDatas)) {
|
|
if (!Check.isNull(accountDatas)) {
|
|
accountDatas = null;
|
|
accountDatas = null;
|
|
@@ -480,8 +966,8 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- } else if ("target".equals(ruleBase.getRuleDimension())) {
|
|
|
|
- targetDatas = getOKData(targetDatas, dimensionData, ruleBase, indicator, threshold, ruleGroup, type, recordList);
|
|
|
|
|
|
+ } else if ("target".equals(ruleDimension)) {
|
|
|
|
+ targetDatas = getOKData(targetDatas, dimensionData, ruleBase, indicator, thresholdJson, ruleGroup, type, recordList);
|
|
if (Check.isNull(targetDatas)) {
|
|
if (Check.isNull(targetDatas)) {
|
|
if (!Check.isNull(accountDatas)) {
|
|
if (!Check.isNull(accountDatas)) {
|
|
accountDatas = null;
|
|
accountDatas = null;
|
|
@@ -500,8 +986,8 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
}
|
|
}
|
|
break;
|
|
break;
|
|
}
|
|
}
|
|
- } else if (UNIT.equals(ruleBase.getRuleDimension())) {
|
|
|
|
- groupDatas = getOKData(groupDatas, dimensionData, ruleBase, indicator, threshold, ruleGroup, type, recordList);
|
|
|
|
|
|
+ } else if (UNIT.equals(ruleDimension)) {
|
|
|
|
+ groupDatas = getOKData(groupDatas, dimensionData, ruleBase, indicator, thresholdJson, ruleGroup, type, recordList);
|
|
if (Check.isNull(groupDatas)) {
|
|
if (Check.isNull(groupDatas)) {
|
|
if (!Check.isNull(accountDatas)) {
|
|
if (!Check.isNull(accountDatas)) {
|
|
accountDatas = null;
|
|
accountDatas = null;
|
|
@@ -544,14 +1030,25 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
* @throws
|
|
* @throws
|
|
* @author ZHAOXA
|
|
* @author ZHAOXA
|
|
*/
|
|
*/
|
|
- private JSONArray getOKData(JSONArray ruleDatas, JSONArray dimensionData, RuleBase ruleBase, JSONObject indicator, String threshold, RuleGroup ruleGroup, Integer type, List<AlarmRuleRecord> recordList) {
|
|
|
|
|
|
+ private JSONArray getOKData(JSONArray ruleDatas, JSONArray dimensionData, RuleBase ruleBase, JSONObject
|
|
|
|
+ indicator, JSONObject thresholdJson, RuleGroup ruleGroup, Integer type, List<AlarmRuleRecord> recordList) {
|
|
|
|
+ String threshold = thresholdJson.getString("threshold");
|
|
if (!Check.isNull(ruleDatas)) {
|
|
if (!Check.isNull(ruleDatas)) {
|
|
JSONArray okData = new JSONArray();
|
|
JSONArray okData = new JSONArray();
|
|
for (int i = 0; i < ruleDatas.size(); i++) {
|
|
for (int i = 0; i < ruleDatas.size(); i++) {
|
|
JSONObject obj = ruleDatas.getJSONObject(i);
|
|
JSONObject obj = ruleDatas.getJSONObject(i);
|
|
String value = obj.getString(ruleBase.getIndicatorCode());
|
|
String value = obj.getString(ruleBase.getIndicatorCode());
|
|
- if (MatchLogic.matchCondition(indicator, ruleBase.getRuleCondition(), threshold, value, obj, ruleBase.getIndicatorCode())) {
|
|
|
|
- alarmRuleRecord(obj, ruleGroup, ruleBase, indicator, type, threshold, recordList);
|
|
|
|
|
|
+ String othreshold = "";
|
|
|
|
+ if (threshold.contains("~")) {
|
|
|
|
+ othreshold = threshold;
|
|
|
|
+ } else {
|
|
|
|
+ othreshold = getThresholdForOperation(obj, ruleBase, threshold, type);
|
|
|
|
+ }
|
|
|
|
+ if (MatchLogic.matchCondition(indicator, ruleBase.getRuleCondition(), othreshold, value, obj, ruleBase.getIndicatorCode())) {
|
|
|
|
+ alarmRuleRecord(obj, ruleGroup, ruleBase, indicator, type, othreshold, recordList);
|
|
|
|
+ if (groupThresholdFromIndicator(thresholdJson, ruleGroup.getOperate())) {
|
|
|
|
+ obj.put("thresholdJson", thresholdJson);
|
|
|
|
+ }
|
|
okData.add(obj);
|
|
okData.add(obj);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -560,15 +1057,48 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
for (int i = 0; i < dimensionData.size(); i++) {
|
|
for (int i = 0; i < dimensionData.size(); i++) {
|
|
JSONObject obj = dimensionData.getJSONObject(i);
|
|
JSONObject obj = dimensionData.getJSONObject(i);
|
|
String value = obj.getString(ruleBase.getIndicatorCode());
|
|
String value = obj.getString(ruleBase.getIndicatorCode());
|
|
- if (MatchLogic.matchCondition(indicator, ruleBase.getRuleCondition(), threshold, value, obj, ruleBase.getIndicatorCode())) {
|
|
|
|
- alarmRuleRecord(obj, ruleGroup, ruleBase, indicator, type, threshold, recordList);
|
|
|
|
|
|
+ String othreshold = "";
|
|
|
|
+ if (threshold.contains("~")) {
|
|
|
|
+ othreshold = threshold;
|
|
|
|
+ } else {
|
|
|
|
+ othreshold = getThresholdForOperation(obj, ruleBase, threshold, type);
|
|
|
|
+ }
|
|
|
|
+ if (MatchLogic.matchCondition(indicator, ruleBase.getRuleCondition(), othreshold, value, obj, ruleBase.getIndicatorCode())) {
|
|
|
|
+ alarmRuleRecord(obj, ruleGroup, ruleBase, indicator, type, othreshold, recordList);
|
|
|
|
+ if (groupThresholdFromIndicator(thresholdJson, ruleGroup.getOperate())) {
|
|
|
|
+ obj.put("thresholdJson", thresholdJson);
|
|
|
|
+ }
|
|
ruleDatas.add(obj);
|
|
ruleDatas.add(obj);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return ruleDatas;
|
|
return ruleDatas;
|
|
}
|
|
}
|
|
|
|
|
|
- private void getAndSendMessag(JSONArray complianceList, RuleGroup ruleGroup, String accountName, Integer mediaType) {
|
|
|
|
|
|
+ private boolean groupThresholdFromIndicator(JSONObject thresholdJson, String operate) {
|
|
|
|
+ if ("SEND".equals(operate) || "PAUSE".equals(operate)) {
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+ RuleBase base = ruleBaseMapper.selectById(thresholdJson.getLong("ruleId"));
|
|
|
|
+ String code = base.getIndicatorCode();
|
|
|
|
+ if ("BID".equals(operate)) {
|
|
|
|
+ return "charge".equals(code) || "cost".equals(code);
|
|
|
|
+ } else if ("BUDGET".equals(operate)) {
|
|
|
|
+ return "convertCost".equals(code);
|
|
|
|
+ } else if ("TIME".equals(operate)) {
|
|
|
|
+ return "scheduleTime".equals(code);
|
|
|
|
+ }
|
|
|
|
+ return false;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * @param complianceList 触发规则数据
|
|
|
|
+ * @param ruleGroup 触发的规则组
|
|
|
|
+ * @param accountName 账户名称
|
|
|
|
+ * @param mediaType 媒体类型
|
|
|
|
+ * @param isOperation 是否有后续操作(仅做发送内容变更)
|
|
|
|
+ * @throws
|
|
|
|
+ */
|
|
|
|
+ private void getAndSendMessag(JSONArray complianceList, RuleGroup ruleGroup, String accountName, Integer mediaType, boolean isOperation) {
|
|
Long accountId = complianceList.getJSONObject(0).getLong("accountId");
|
|
Long accountId = complianceList.getJSONObject(0).getLong("accountId");
|
|
if (Check.isNull(accountId)) {
|
|
if (Check.isNull(accountId)) {
|
|
return;
|
|
return;
|
|
@@ -592,7 +1122,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, mediaType);
|
|
|
|
|
|
+ sendMsg(message, ruleGroup, user, CREATIVE, isNullCreativeJoiner.toString(), accountId, mediaType, isOperation);
|
|
isNullCreativeJoiner = new StringJoiner(",");
|
|
isNullCreativeJoiner = new StringJoiner(",");
|
|
isNullCreativeJoiner.add(obj.getString("creativeId"));
|
|
isNullCreativeJoiner.add(obj.getString("creativeId"));
|
|
}
|
|
}
|
|
@@ -601,13 +1131,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, mediaType);
|
|
|
|
|
|
+ sendMsg(msg, ruleGroup, user, PLAN, isNullPlanJoiner.toString(), accountId, mediaType, isOperation);
|
|
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, mediaType);
|
|
|
|
|
|
+ sendMsg(msg, ruleGroup, user, ACCOUNT, null, accountId, mediaType, isOperation);
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
if (!Check.isNull(obj.getString("creativeId"))) {
|
|
if (!Check.isNull(obj.getString("creativeId"))) {
|
|
@@ -616,7 +1146,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, mediaType);
|
|
|
|
|
|
+ sendMsg(message, ruleGroup, user, CREATIVE, creativeJoiner.toString(), accountId, mediaType, isOperation);
|
|
creativeJoiner = new StringJoiner(",");
|
|
creativeJoiner = new StringJoiner(",");
|
|
creativeJoiner.add(obj.getString("creativeId"));
|
|
creativeJoiner.add(obj.getString("creativeId"));
|
|
}
|
|
}
|
|
@@ -625,7 +1155,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
unitJoiner.add(obj.getString("unitId"));
|
|
unitJoiner.add(obj.getString("unitId"));
|
|
} else {
|
|
} else {
|
|
String msg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, UNIT, unitJoiner.toString(), isNull);
|
|
String msg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, UNIT, unitJoiner.toString(), isNull);
|
|
- sendMsg(msg, ruleGroup, user, UNIT, unitJoiner.toString(), accountId, mediaType);
|
|
|
|
|
|
+ sendMsg(msg, ruleGroup, user, UNIT, unitJoiner.toString(), accountId, mediaType, isOperation);
|
|
unitJoiner = new StringJoiner(",");
|
|
unitJoiner = new StringJoiner(",");
|
|
unitJoiner.add(obj.getString("unitId"));
|
|
unitJoiner.add(obj.getString("unitId"));
|
|
}
|
|
}
|
|
@@ -634,35 +1164,35 @@ 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, mediaType);
|
|
|
|
|
|
+ sendMsg(msg, ruleGroup, user, PLAN, planJoiner.toString(), accountId, mediaType, isOperation);
|
|
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, mediaType);
|
|
|
|
|
|
+ sendMsg(msg, ruleGroup, user, ACCOUNT, null, accountId, mediaType, isOperation);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
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, mediaType);
|
|
|
|
|
|
+ sendMsg(creativeMsg, ruleGroup, user, CREATIVE, creativeJoiner.toString(), accountId, mediaType, isOperation);
|
|
}
|
|
}
|
|
if (!Check.isNull(unitJoiner.toString())) {
|
|
if (!Check.isNull(unitJoiner.toString())) {
|
|
String creativeMsg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, UNIT, unitJoiner.toString(), false);
|
|
String creativeMsg = MatchLogic.getMessage(ruleGroup.getGroupName(), accountId, accountName, UNIT, unitJoiner.toString(), false);
|
|
- sendMsg(creativeMsg, ruleGroup, user, UNIT, unitJoiner.toString(), accountId, mediaType);
|
|
|
|
|
|
+ sendMsg(creativeMsg, ruleGroup, user, UNIT, unitJoiner.toString(), accountId, mediaType, isOperation);
|
|
}
|
|
}
|
|
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, isOperation);
|
|
}
|
|
}
|
|
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, mediaType);
|
|
|
|
|
|
+ sendMsg(isNullCreativeMsg, ruleGroup, user, CREATIVE, isNullCreativeJoiner.toString(), accountId, mediaType, isOperation);
|
|
}
|
|
}
|
|
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, mediaType);
|
|
|
|
|
|
+ sendMsg(isNullPlanMsg, ruleGroup, user, PLAN, isNullPlanJoiner.toString(), accountId, mediaType, isOperation);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -677,7 +1207,7 @@ 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, Integer mediaType) {
|
|
|
|
|
|
+ private void sendMsg(String msg, RuleGroup ruleGroup, JSONObject user, String type, String ids, Long accountId, Integer mediaType, boolean isOperation) {
|
|
try {
|
|
try {
|
|
boolean isPause = "PAUSE".equals(ruleGroup.getOperate());
|
|
boolean isPause = "PAUSE".equals(ruleGroup.getOperate());
|
|
if (isPause) {
|
|
if (isPause) {
|
|
@@ -691,10 +1221,18 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
msg = msg.replace(",", ",");
|
|
msg = msg.replace(",", ",");
|
|
}
|
|
}
|
|
if (ACCOUNT.equals(type)) {
|
|
if (ACCOUNT.equals(type)) {
|
|
- msg += "请您及时查看并调整!";
|
|
|
|
|
|
+ msg += "请您及时查看并调整";
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
- msg += "请您及时查看并调整!";
|
|
|
|
|
|
+ msg += "请您及时查看并调整";
|
|
|
|
+ }
|
|
|
|
+ if (isOperation) {
|
|
|
|
+ msg = msg.replace("请您及时查看并调整", "系统已按照设置调整出价,请您及时查看");
|
|
|
|
+ if ("BUDGET".equals(ruleGroup.getOperate())) {
|
|
|
|
+ msg = msg.replace("出价", "预算");
|
|
|
|
+ } else if ("TIME".equals(ruleGroup.getOperate())) {
|
|
|
|
+ msg = msg.replace("出价", "投放时间");
|
|
|
|
+ }
|
|
}
|
|
}
|
|
String sendType = ruleGroup.getSendType();
|
|
String sendType = ruleGroup.getSendType();
|
|
if ("SMS".equals(sendType)) {
|
|
if ("SMS".equals(sendType)) {
|
|
@@ -861,7 +1399,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
for (RuleAccountThreshold threshold : thresholdList) {
|
|
for (RuleAccountThreshold threshold : thresholdList) {
|
|
- batchNoObj.put(String.valueOf(threshold.getRuleId()), threshold.getThreshold());
|
|
|
|
|
|
+ batchNoObj.put(String.valueOf(threshold.getRuleId()), threshold);
|
|
}
|
|
}
|
|
groupIdObj.put(batchNo.toString(), batchNoObj);
|
|
groupIdObj.put(batchNo.toString(), batchNoObj);
|
|
}
|
|
}
|
|
@@ -873,7 +1411,7 @@ public class RuleGroupServiceImpl extends ServiceImpl<RuleGroupMapper, RuleGroup
|
|
return null;
|
|
return null;
|
|
}
|
|
}
|
|
for (RuleAccountThreshold threshold : thresholdList) {
|
|
for (RuleAccountThreshold threshold : thresholdList) {
|
|
- obj.put(String.valueOf(threshold.getRuleId()), threshold.getThreshold());
|
|
|
|
|
|
+ obj.put(String.valueOf(threshold.getRuleId()), threshold);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|