|
@@ -2,9 +2,11 @@ package com.tzld.longarticle.recommend.server.service.strategy.reply.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.tzld.longarticle.recommend.server.common.enums.StrategyStatusEnum;
|
|
|
import com.tzld.longarticle.recommend.server.common.enums.cgi.ReplyStrategyServiceEnum;
|
|
|
import com.tzld.longarticle.recommend.server.mapper.growth.AlgGhAutoreplyVideoRankDataMapper;
|
|
|
import com.tzld.longarticle.recommend.server.mapper.growth.CgiReplyBucketDataMapper;
|
|
|
+import com.tzld.longarticle.recommend.server.model.bo.VideoDetail;
|
|
|
import com.tzld.longarticle.recommend.server.model.cgi.*;
|
|
|
import com.tzld.longarticle.recommend.server.repository.model.AlgGhAutoreplyVideoRankData;
|
|
|
import com.tzld.longarticle.recommend.server.repository.model.AlgGhAutoreplyVideoRankDataExample;
|
|
@@ -12,6 +14,7 @@ import com.tzld.longarticle.recommend.server.repository.model.CgiReplyBucketData
|
|
|
import com.tzld.longarticle.recommend.server.repository.model.CgiReplyBucketDataExample;
|
|
|
import com.tzld.longarticle.recommend.server.service.cgi.TouLiuHttpClientService;
|
|
|
import com.tzld.longarticle.recommend.server.service.strategy.reply.ReplyStrategyService;
|
|
|
+import com.tzld.longarticle.recommend.server.util.DateUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
@@ -207,38 +210,72 @@ public class PushMessageStrategyV1 implements ReplyStrategyService {
|
|
|
// base作为人工控制
|
|
|
continue;
|
|
|
}
|
|
|
- // 获取最新dt的策略
|
|
|
- String dtVersion = algGhAutoreplyVideoRankDataMapper.selectLatestDtVersionByStrategyKeyAndGhId(key, bucketDataParam.getGhId());
|
|
|
- // 判断当前的dtVersion是否已经处理过了
|
|
|
- CgiReplyBucketDataExample cgiReplyBucketDataExample = new CgiReplyBucketDataExample();
|
|
|
- cgiReplyBucketDataExample.createCriteria().andIsDeleteEqualTo(0).andStrategyDtEqualTo(dtVersion).andStrategyEqualTo(key).andGhIdEqualTo(bucketDataParam.getGhId());
|
|
|
- long count = cgiReplyBucketDataMapper.countByExample(cgiReplyBucketDataExample);
|
|
|
- if (count != 0) {
|
|
|
- // 说明已处理过该dtVersion数据
|
|
|
- continue;
|
|
|
- }
|
|
|
- // 获取最新dt数据
|
|
|
- List<AlgGhAutoreplyVideoRankData> dtVersionStrategyData = getDtVersionStrategyData(key, dtVersion, bucketDataParam.getGhId());
|
|
|
- List<Long> videoIds = dtVersionStrategyData.stream().map(AlgGhAutoreplyVideoRankData::getVideoId).collect(Collectors.toList());
|
|
|
- Map<Long, String> videoDetailMap = TouLiuHttpClientService.getVideoDetailRequest(videoIds);
|
|
|
- result.addAll(dtVersionStrategyData.stream().map(x -> {
|
|
|
- CgiReplyBucketData cgiReplyBucketData = new CgiReplyBucketData();
|
|
|
- cgiReplyBucketData.setStrategy(key);
|
|
|
- cgiReplyBucketData.setSort(x.getSort());
|
|
|
- cgiReplyBucketData.setStrategyDt(x.getDtVersion());
|
|
|
- cgiReplyBucketData.setGhId(x.getGhId());
|
|
|
- cgiReplyBucketData.setMsgType(1);
|
|
|
- cgiReplyBucketData.setTitle(x.getTitle());
|
|
|
- String cover = videoDetailMap.get(x.getVideoId());
|
|
|
- if (StringUtils.isNotEmpty(cover)) {
|
|
|
- cgiReplyBucketData.setCoverUrl(cover);
|
|
|
- } else {
|
|
|
- cgiReplyBucketData.setCoverUrl(CDN_URL + x.getCoverUrl());
|
|
|
+ if (Objects.equals(StrategyStatusEnum.DEFAULT.status, bucketDataParam.getStrategyStatus())) {
|
|
|
+ if (CollectionUtils.isEmpty(bucketDataParam.getVideos())) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ Map<Long, VideoDetail> videoDetailMap = TouLiuHttpClientService.getVideoDetailRequest(bucketDataParam.getVideos());
|
|
|
+ int sort = 1;
|
|
|
+ for (Long videoId : bucketDataParam.getVideos()) {
|
|
|
+ CgiReplyBucketDataExample cgiReplyBucketDataExample = new CgiReplyBucketDataExample();
|
|
|
+ cgiReplyBucketDataExample.createCriteria().andIsDeleteEqualTo(0).andStrategyEqualTo(key)
|
|
|
+ .andGhIdEqualTo(bucketDataParam.getGhId()).andMiniVideoIdIn(bucketDataParam.getVideos());
|
|
|
+ long count = cgiReplyBucketDataMapper.countByExample(cgiReplyBucketDataExample);
|
|
|
+ if (count == bucketDataParam.getVideos().size()) {
|
|
|
+ // 已经存在就不处理
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ CgiReplyBucketData cgiReplyBucketData = new CgiReplyBucketData();
|
|
|
+ cgiReplyBucketData.setStrategy(key);
|
|
|
+ cgiReplyBucketData.setSort(sort);
|
|
|
+ cgiReplyBucketData.setGhId(bucketDataParam.getGhId());
|
|
|
+ cgiReplyBucketData.setMsgType(1);
|
|
|
+ VideoDetail videoDetail = videoDetailMap.get(videoId);
|
|
|
+ if (videoDetail != null && StringUtils.isNotEmpty(videoDetail.getCover())) {
|
|
|
+ cgiReplyBucketData.setCoverUrl(videoDetail.getCover());
|
|
|
+ }
|
|
|
+ if (videoDetail != null && StringUtils.isNotEmpty(videoDetail.getTitle())) {
|
|
|
+ cgiReplyBucketData.setTitle(videoDetail.getTitle());
|
|
|
+ }
|
|
|
+ cgiReplyBucketData.setMiniAppId(SMALL_APP_Id);
|
|
|
+ cgiReplyBucketData.setMiniVideoId(videoId);
|
|
|
+ result.add(cgiReplyBucketData);
|
|
|
+ sort++;
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ // 获取最新dt的策略
|
|
|
+ String dtVersion = algGhAutoreplyVideoRankDataMapper.selectLatestDtVersionByStrategyKeyAndGhId(key, bucketDataParam.getGhId());
|
|
|
+ // 判断当前的dtVersion是否已经处理过了
|
|
|
+ CgiReplyBucketDataExample cgiReplyBucketDataExample = new CgiReplyBucketDataExample();
|
|
|
+ cgiReplyBucketDataExample.createCriteria().andIsDeleteEqualTo(0).andStrategyDtEqualTo(dtVersion).andStrategyEqualTo(key).andGhIdEqualTo(bucketDataParam.getGhId());
|
|
|
+ long count = cgiReplyBucketDataMapper.countByExample(cgiReplyBucketDataExample);
|
|
|
+ if (count != 0) {
|
|
|
+ // 说明已处理过该dtVersion数据
|
|
|
+ continue;
|
|
|
}
|
|
|
- cgiReplyBucketData.setMiniAppId(SMALL_APP_Id);
|
|
|
- cgiReplyBucketData.setMiniVideoId(x.getVideoId());
|
|
|
- return cgiReplyBucketData;
|
|
|
- }).collect(Collectors.toList()));
|
|
|
+ // 获取最新dt数据
|
|
|
+ List<AlgGhAutoreplyVideoRankData> dtVersionStrategyData = getDtVersionStrategyData(key, dtVersion, bucketDataParam.getGhId());
|
|
|
+ List<Long> videoIds = dtVersionStrategyData.stream().map(AlgGhAutoreplyVideoRankData::getVideoId).collect(Collectors.toList());
|
|
|
+ Map<Long, VideoDetail> videoDetailMap = TouLiuHttpClientService.getVideoDetailRequest(videoIds);
|
|
|
+ result.addAll(dtVersionStrategyData.stream().map(x -> {
|
|
|
+ CgiReplyBucketData cgiReplyBucketData = new CgiReplyBucketData();
|
|
|
+ cgiReplyBucketData.setStrategy(key);
|
|
|
+ cgiReplyBucketData.setSort(x.getSort());
|
|
|
+ cgiReplyBucketData.setStrategyDt(x.getDtVersion());
|
|
|
+ cgiReplyBucketData.setGhId(x.getGhId());
|
|
|
+ cgiReplyBucketData.setMsgType(1);
|
|
|
+ cgiReplyBucketData.setTitle(x.getTitle());
|
|
|
+ VideoDetail videoDetail = videoDetailMap.get(x.getVideoId());
|
|
|
+ if (videoDetail != null && StringUtils.isNotEmpty(videoDetail.getCover())) {
|
|
|
+ cgiReplyBucketData.setCoverUrl(videoDetail.getCover());
|
|
|
+ } else {
|
|
|
+ cgiReplyBucketData.setCoverUrl(CDN_URL + x.getCoverUrl());
|
|
|
+ }
|
|
|
+ cgiReplyBucketData.setMiniAppId(SMALL_APP_Id);
|
|
|
+ cgiReplyBucketData.setMiniVideoId(x.getVideoId());
|
|
|
+ return cgiReplyBucketData;
|
|
|
+ }).collect(Collectors.toList()));
|
|
|
+ }
|
|
|
}
|
|
|
// 获取最新数据版本
|
|
|
return CollectionUtils.isEmpty(result) ? null : result;
|