|
|
@ -1,6 +1,11 @@
|
|
|
|
package com.java3y.austin.service.deduplication;
|
|
|
|
package com.java3y.austin.service.deduplication;
|
|
|
|
|
|
|
|
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
import cn.hutool.core.date.DateUtil;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
|
|
|
import com.ctrip.framework.apollo.Config;
|
|
|
|
|
|
|
|
import com.ctrip.framework.apollo.spring.annotation.ApolloConfig;
|
|
|
|
|
|
|
|
import com.java3y.austin.constant.AustinConstant;
|
|
|
|
import com.java3y.austin.domain.DeduplicationParam;
|
|
|
|
import com.java3y.austin.domain.DeduplicationParam;
|
|
|
|
import com.java3y.austin.domain.TaskInfo;
|
|
|
|
import com.java3y.austin.domain.TaskInfo;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
@ -16,25 +21,42 @@ import java.util.Date;
|
|
|
|
@Service
|
|
|
|
@Service
|
|
|
|
public class DeduplicationRuleService {
|
|
|
|
public class DeduplicationRuleService {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 配置样例:{"contentDeduplication":{"num":1,"time":300},"frequencyDeduplication":{"num":5}}
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private static final String DEDUPLICATION_RULE_KEY = "deduplication";
|
|
|
|
|
|
|
|
private static final String CONTENT_DEDUPLICATION = "contentDeduplication";
|
|
|
|
|
|
|
|
private static final String FREQUENCY_DEDUPLICATION = "frequencyDeduplication";
|
|
|
|
|
|
|
|
private static final String TIME = "time";
|
|
|
|
|
|
|
|
private static final String NUM = "num";
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private ContentDeduplicationService contentDeduplicationService;
|
|
|
|
private ContentDeduplicationService contentDeduplicationService;
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private FrequencyDeduplicationService frequencyDeduplicationService;
|
|
|
|
private FrequencyDeduplicationService frequencyDeduplicationService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@ApolloConfig("boss.austin")
|
|
|
|
|
|
|
|
private Config config;
|
|
|
|
|
|
|
|
|
|
|
|
public void duplication(TaskInfo taskInfo) {
|
|
|
|
public void duplication(TaskInfo taskInfo) {
|
|
|
|
|
|
|
|
JSONObject property = JSON.parseObject(config.getProperty(DEDUPLICATION_RULE_KEY, AustinConstant.APOLLO_DEFAULT_VALUE_JSON_OBJECT));
|
|
|
|
|
|
|
|
JSONObject contentDeduplication = property.getJSONObject(CONTENT_DEDUPLICATION);
|
|
|
|
|
|
|
|
JSONObject frequencyDeduplication = property.getJSONObject(FREQUENCY_DEDUPLICATION);
|
|
|
|
|
|
|
|
|
|
|
|
// 文案去重
|
|
|
|
// 文案去重
|
|
|
|
DeduplicationParam contentParams = DeduplicationParam.builder()
|
|
|
|
DeduplicationParam contentParams = DeduplicationParam.builder()
|
|
|
|
.deduplicationTime(300L).countNum(1).taskInfo(taskInfo)
|
|
|
|
.deduplicationTime(contentDeduplication.getLong(TIME))
|
|
|
|
|
|
|
|
.countNum(contentDeduplication.getInteger(NUM)).taskInfo(taskInfo)
|
|
|
|
.build();
|
|
|
|
.build();
|
|
|
|
contentDeduplicationService.deduplication(contentParams);
|
|
|
|
contentDeduplicationService.deduplication(contentParams);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 运营总规则去重(一天内用户收到最多同一个渠道的消息次数)
|
|
|
|
// 运营总规则去重(一天内用户收到最多同一个渠道的消息次数)
|
|
|
|
Long seconds = (DateUtil.endOfDay(new Date()).getTime() - DateUtil.current()) / 1000;
|
|
|
|
Long seconds = (DateUtil.endOfDay(new Date()).getTime() - DateUtil.current()) / 1000;
|
|
|
|
DeduplicationParam businessParams = DeduplicationParam.builder()
|
|
|
|
DeduplicationParam businessParams = DeduplicationParam.builder()
|
|
|
|
.deduplicationTime(seconds).countNum(5).taskInfo(taskInfo)
|
|
|
|
.deduplicationTime(seconds)
|
|
|
|
|
|
|
|
.countNum(frequencyDeduplication.getInteger(NUM)).taskInfo(taskInfo)
|
|
|
|
.build();
|
|
|
|
.build();
|
|
|
|
frequencyDeduplicationService.deduplication(businessParams);
|
|
|
|
frequencyDeduplicationService.deduplication(businessParams);
|
|
|
|
}
|
|
|
|
}
|
|
|
|