|
@@ -48,6 +48,8 @@ public class ContentPlatformVideoJob {
|
|
|
private ContentPlatformUploadVideoMapper uploadVideoMapper;
|
|
private ContentPlatformUploadVideoMapper uploadVideoMapper;
|
|
|
@Autowired
|
|
@Autowired
|
|
|
private ContentPlatformAccountMapper accountMapper;
|
|
private ContentPlatformAccountMapper accountMapper;
|
|
|
|
|
+ @Autowired
|
|
|
|
|
+ private ContentPlatformVideoAccountRelMapper videoAccountRelMapper;
|
|
|
|
|
|
|
|
@Value("${video.agg.days:3}")
|
|
@Value("${video.agg.days:3}")
|
|
|
private Integer videoAggDays;
|
|
private Integer videoAggDays;
|
|
@@ -527,12 +529,21 @@ public class ContentPlatformVideoJob {
|
|
|
List<String> typeList = Arrays.asList("自动回复", "服务号推送", "公众号推送", "企微-社群", "企微-自动回复");
|
|
List<String> typeList = Arrays.asList("自动回复", "服务号推送", "公众号推送", "企微-社群", "企微-自动回复");
|
|
|
List<ContentPlatformAccount> accountList = getAllContentPlatformAccount();
|
|
List<ContentPlatformAccount> accountList = getAllContentPlatformAccount();
|
|
|
List<String> channelList = accountList.stream().map(ContentPlatformAccount::getChannel).collect(Collectors.toList());
|
|
List<String> channelList = accountList.stream().map(ContentPlatformAccount::getChannel).collect(Collectors.toList());
|
|
|
|
|
+ List<Long> accountIds = accountList.stream().map(ContentPlatformAccount::getId).collect(Collectors.toList());
|
|
|
|
|
+ List<ContentPlatformVideoAccountRel> videoAccountRelList = getContentPlatformVideoAccountRelList(accountIds);
|
|
|
|
|
+ Map<Long, List<ContentPlatformVideoAccountRel>> videoAccountRelMap = videoAccountRelList.stream()
|
|
|
|
|
+ .collect(Collectors.groupingBy(ContentPlatformVideoAccountRel::getVideoId));
|
|
|
|
|
+ Map<String, ContentPlatformAccount> accountMap = accountList.stream().collect(Collectors.toMap(ContentPlatformAccount::getChannel, o -> o));
|
|
|
channelList.add("sum");
|
|
channelList.add("sum");
|
|
|
List<ContentPlatformVideoDataStatAgg> saveList = new ArrayList<>();
|
|
List<ContentPlatformVideoDataStatAgg> saveList = new ArrayList<>();
|
|
|
Long now = System.currentTimeMillis();
|
|
Long now = System.currentTimeMillis();
|
|
|
String strategy = "recommend";
|
|
String strategy = "recommend";
|
|
|
- for (String type : typeList) {
|
|
|
|
|
- for (String channel : channelList) {
|
|
|
|
|
|
|
+ for (String channel : channelList) {
|
|
|
|
|
+ ContentPlatformAccount account = accountMap.get(channel);
|
|
|
|
|
+ List<ContentPlatformVideoAccountRel> accoutnVideoAccountRelList = videoAccountRelMap.getOrDefault(account.getId(), new ArrayList<>());
|
|
|
|
|
+ Map<Long, Double> videoSimScoreMap = accoutnVideoAccountRelList.stream().collect(
|
|
|
|
|
+ Collectors.toMap(ContentPlatformVideoAccountRel::getVideoId, ContentPlatformVideoAccountRel::getSimScore));
|
|
|
|
|
+ for (String type : typeList) {
|
|
|
for (ContentPlatformVideoAgg video : videoList) {
|
|
for (ContentPlatformVideoAgg video : videoList) {
|
|
|
if (!videoIdTypeChannelScoreMap.containsKey(type)) {
|
|
if (!videoIdTypeChannelScoreMap.containsKey(type)) {
|
|
|
continue;
|
|
continue;
|
|
@@ -551,7 +562,8 @@ public class ContentPlatformVideoJob {
|
|
|
if (Objects.nonNull(typeVideoScoreMap) && typeVideoScoreMap.containsKey(video.getVideoId())) {
|
|
if (Objects.nonNull(typeVideoScoreMap) && typeVideoScoreMap.containsKey(video.getVideoId())) {
|
|
|
typeRate = typeVideoScoreMap.get(video.getVideoId());
|
|
typeRate = typeVideoScoreMap.get(video.getVideoId());
|
|
|
}
|
|
}
|
|
|
- Double recommendScore = calRecommendScore(platformScore, channelRate, typeRate);
|
|
|
|
|
|
|
+ Double simScore = videoSimScoreMap.getOrDefault(video.getVideoId(), 0.0);
|
|
|
|
|
+ Double recommendScore = calRecommendScore(platformScore, channelRate, typeRate, simScore);
|
|
|
ContentPlatformVideoDataStatAgg agg = new ContentPlatformVideoDataStatAgg();
|
|
ContentPlatformVideoDataStatAgg agg = new ContentPlatformVideoDataStatAgg();
|
|
|
agg.setDt(datastatDt);
|
|
agg.setDt(datastatDt);
|
|
|
agg.setVideoId(video.getVideoId());
|
|
agg.setVideoId(video.getVideoId());
|
|
@@ -574,7 +586,13 @@ public class ContentPlatformVideoJob {
|
|
|
return ReturnT.SUCCESS;
|
|
return ReturnT.SUCCESS;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- private Double calRecommendScore(Double platformScore, Double channelRate, Double typeRate) {
|
|
|
|
|
|
|
+ private List<ContentPlatformVideoAccountRel> getContentPlatformVideoAccountRelList(List<Long> accountIds) {
|
|
|
|
|
+ ContentPlatformVideoAccountRelExample example = new ContentPlatformVideoAccountRelExample();
|
|
|
|
|
+ example.createCriteria().andAccountIdIn(accountIds);
|
|
|
|
|
+ return videoAccountRelMapper.selectByExample(example);
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ private Double calRecommendScore(Double platformScore, Double channelRate, Double typeRate, Double simScore) {
|
|
|
// channelRate 本渠道传播率,不存在的为0
|
|
// channelRate 本渠道传播率,不存在的为0
|
|
|
if (Objects.isNull(channelRate)) {
|
|
if (Objects.isNull(channelRate)) {
|
|
|
channelRate = 0.0;
|
|
channelRate = 0.0;
|
|
@@ -583,13 +601,18 @@ public class ContentPlatformVideoJob {
|
|
|
if (Objects.isNull(typeRate)) {
|
|
if (Objects.isNull(typeRate)) {
|
|
|
typeRate = 0.0;
|
|
typeRate = 0.0;
|
|
|
}
|
|
}
|
|
|
|
|
+ // simScore 不存在的为0
|
|
|
|
|
+ if (Objects.isNull(simScore)) {
|
|
|
|
|
+ simScore = 0.0;
|
|
|
|
|
+ }
|
|
|
Double platformWeight = recommendScoreConfig.getOrDefault("platformWeight", 0.5);
|
|
Double platformWeight = recommendScoreConfig.getOrDefault("platformWeight", 0.5);
|
|
|
Double channelWeight = recommendScoreConfig.getOrDefault("channelWeight", 0.5);
|
|
Double channelWeight = recommendScoreConfig.getOrDefault("channelWeight", 0.5);
|
|
|
|
|
+ Double simWeight = recommendScoreConfig.getOrDefault("simWeight", 30.0);
|
|
|
Double typeWeight = recommendScoreConfig.getOrDefault("typeWeight", 0.1);
|
|
Double typeWeight = recommendScoreConfig.getOrDefault("typeWeight", 0.1);
|
|
|
Double scalingWeight = recommendScoreConfig.getOrDefault("scalingWeight", 1.5);
|
|
Double scalingWeight = recommendScoreConfig.getOrDefault("scalingWeight", 1.5);
|
|
|
Double maxScore = recommendScoreConfig.getOrDefault("maxScore", 10.0);
|
|
Double maxScore = recommendScoreConfig.getOrDefault("maxScore", 10.0);
|
|
|
|
|
|
|
|
- Double score = platformWeight * platformScore + channelWeight * channelRate;
|
|
|
|
|
|
|
+ Double score = platformWeight * platformScore + channelWeight * channelRate + scaleScore(simWeight * simScore, 3.0);
|
|
|
score += typeWeight * (10 - Math.min(10, typeRate));
|
|
score += typeWeight * (10 - Math.min(10, typeRate));
|
|
|
score *= scalingWeight;
|
|
score *= scalingWeight;
|
|
|
|
|
|
|
@@ -600,6 +623,13 @@ public class ContentPlatformVideoJob {
|
|
|
return bdScore.setScale(2, RoundingMode.HALF_UP).doubleValue();
|
|
return bdScore.setScale(2, RoundingMode.HALF_UP).doubleValue();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ public static double scaleScore(Double score, Double maxScore) {
|
|
|
|
|
+ if (score > maxScore) {
|
|
|
|
|
+ return maxScore + (score - maxScore) / 10;
|
|
|
|
|
+ }
|
|
|
|
|
+ return score;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
|
|
|
private List<ContentPlatformAccount> getAllContentPlatformAccount() {
|
|
private List<ContentPlatformAccount> getAllContentPlatformAccount() {
|
|
|
ContentPlatformAccountExample example = new ContentPlatformAccountExample();
|
|
ContentPlatformAccountExample example = new ContentPlatformAccountExample();
|