|
|
@@ -43,6 +43,8 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
+import java.io.UnsupportedEncodingException;
|
|
|
+import java.net.URLEncoder;
|
|
|
import java.util.*;
|
|
|
import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
@@ -91,6 +93,8 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
private CgiReplyService cgiReplyService;
|
|
|
@Autowired
|
|
|
private TouLiuHttpClient touLiuHttpClient;
|
|
|
+ @Autowired
|
|
|
+ private ManagerApiService managerApiService;
|
|
|
|
|
|
|
|
|
@Value("${vlog.share.appType:11}")
|
|
|
@@ -175,6 +179,7 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
}
|
|
|
}
|
|
|
videoItemVO.setShareCover(getShareCover(ContentPlatformPlanService.getVideoCover(video)));
|
|
|
+ videoItemVO.setPageUrl(buildCustomPageUrl(videoItemVO, video));
|
|
|
videoVOList.add(videoItemVO);
|
|
|
}
|
|
|
planItemVO.setVideoList(videoVOList);
|
|
|
@@ -185,6 +190,22 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ private String buildCustomPageUrl(GzhPlanVideoContentItemVO videoItemVO, ContentPlatformGzhPlanVideo video) {
|
|
|
+ String pageUrl = videoItemVO.getPageUrl();
|
|
|
+ try {
|
|
|
+ if (Objects.nonNull(video.getCustomTitleId()) && StringUtils.hasText(videoItemVO.getCustomTitle())) {
|
|
|
+ pageUrl += URLEncoder.encode("&shareTitleId=" + video.getCustomTitleId() + "&shareTitle=" + video.getCustomTitle(), "UTF-8");
|
|
|
+ }
|
|
|
+ if (Objects.nonNull(video.getCustomCoverId()) && StringUtils.hasText(videoItemVO.getCustomCover())) {
|
|
|
+ pageUrl += URLEncoder.encode("&shareImageId=" + video.getCustomCoverId() + "&shareImageUrl=" + URLEncoder.encode(video.getCustomCover(), "UTF-8"), "UTF-8");
|
|
|
+ }
|
|
|
+ return pageUrl;
|
|
|
+ } catch (UnsupportedEncodingException e) {
|
|
|
+ log.error("buildCustomPageUrl error", e);
|
|
|
+ }
|
|
|
+ return videoItemVO.getPageUrl();
|
|
|
+ }
|
|
|
+
|
|
|
@Override
|
|
|
public List<ContentPlatformGzhPlanVideo> getGzhPlanVideoList(List<Long> planIds) {
|
|
|
ContentPlatformGzhPlanVideoExample example = new ContentPlatformGzhPlanVideoExample();
|
|
|
@@ -299,7 +320,7 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
// 更新gh_detail
|
|
|
updateGhDetail(account, param.getSelectVideoType(), videoIds);
|
|
|
// 更新cgi_reply_bucket_data
|
|
|
- updateCgiReplyBucketData(account.getGhId(), param.getVideoList());
|
|
|
+ updateCgiReplyBucketData(account.getGhId());
|
|
|
}
|
|
|
// 保存视频内容
|
|
|
saveGzhPlanVideo(param, videoIds, gzhPlan.getId(), account, loginAccount);
|
|
|
@@ -316,26 +337,8 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void updateCgiReplyBucketData(String ghId, List<GzhPlanVideoContentItemParam> videoList) {
|
|
|
+ private void updateCgiReplyBucketData(String ghId) {
|
|
|
cgiReplyBucketDataMapperExt.deleteBucketDataByGhId(ghId);
|
|
|
-// for (GzhPlanVideoContentItemParam video : videoList) {
|
|
|
-// if (!StringUtils.hasText(video.getCustomCover()) && !StringUtils.hasText(video.getCustomTitle())) {
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-// List<CgiReplyBucketData> dataList = cgiReplyService.getCgiReplyBucketDataListByVideoId(video.getVideoId());
|
|
|
-// if (CollectionUtils.isEmpty(dataList)) {
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-// String existsCover = dataList.get(0).getCoverUrl();
|
|
|
-// if (!existsCover.contains("?")) {
|
|
|
-// continue;
|
|
|
-// }
|
|
|
-// String coverSuffix = existsCover.substring(existsCover.indexOf("?"));
|
|
|
-// String cover = video.getCover().substring(0, existsCover.indexOf("?"));
|
|
|
-// cgiReplyBucketDataMapperExt.updateBucketDataTitleCoverByGhId(ghId, video.getVideoId(),
|
|
|
-// StringUtils.hasText(video.getCustomTitle()) ? video.getCustomTitle() : video.getTitle(),
|
|
|
-// StringUtils.hasText(video.getCustomCover()) ? video.getCustomCover() : cover + coverSuffix);
|
|
|
-// }
|
|
|
}
|
|
|
|
|
|
private void saveGzhPlanVideo(GzhPlanSaveParam param, List<Long> videoIds, Long planId,
|
|
|
@@ -359,9 +362,9 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
if (existsVideoIds.contains(vo.getVideoId())) {
|
|
|
ContentPlatformGzhPlanVideo item = existsVideoMap.get(vo.getVideoId());
|
|
|
item.setTitle(vo.getTitle());
|
|
|
- item.setCustomTitle(vo.getCustomTitle());
|
|
|
+ setCustomTitle(item, vo);
|
|
|
item.setCover(vo.getCover());
|
|
|
- item.setCustomCover(vo.getCustomCover());
|
|
|
+ setCustomCover(item, vo);
|
|
|
item.setCustomCoverType(vo.getCustomCoverType());
|
|
|
gzhPlanVideoMapper.updateByPrimaryKey(item);
|
|
|
} else {
|
|
|
@@ -369,9 +372,9 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
item.setPlanId(planId);
|
|
|
item.setVideoId(vo.getVideoId());
|
|
|
item.setTitle(vo.getTitle());
|
|
|
- item.setCustomTitle(vo.getCustomTitle());
|
|
|
+ setCustomTitle(item, vo);
|
|
|
item.setCover(vo.getCover());
|
|
|
- item.setCustomCover(vo.getCustomCover());
|
|
|
+ setCustomCover(item, vo);
|
|
|
item.setCustomCoverType(vo.getCustomCoverType());
|
|
|
item.setVideo(vo.getVideo());
|
|
|
if (param.getType() == ContentPlatformGzhPlanTypeEnum.FWH_PUSH.getVal()) {
|
|
|
@@ -397,6 +400,60 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private void setCustomTitle(ContentPlatformGzhPlanVideo item, GzhPlanVideoContentItemParam vo) {
|
|
|
+ if (StringUtils.hasText(vo.getCustomTitle())) {
|
|
|
+ List<ContentPlatformGzhPlanVideo> gzhPlanVideoList = gzhPlanVideoListByVideoTitle(vo.getVideoId());
|
|
|
+ boolean customCoverExist = false;
|
|
|
+ if (CollectionUtils.isNotEmpty(gzhPlanVideoList)) {
|
|
|
+ for (ContentPlatformGzhPlanVideo gzhPlanVideo : gzhPlanVideoList) {
|
|
|
+ if (gzhPlanVideo.getCustomTitle().equals(vo.getCustomTitle())) {
|
|
|
+ item.setCustomTitleId(gzhPlanVideo.getCustomTitleId());
|
|
|
+ customCoverExist = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!customCoverExist) {
|
|
|
+ JSONObject multiTitle = managerApiService.videoMultiTitleSave(vo.getVideoId(), vo.getCustomTitle());
|
|
|
+ item.setCustomTitleId(multiTitle.getLong("id"));
|
|
|
+ }
|
|
|
+ item.setCustomTitle(vo.getCustomTitle());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<ContentPlatformGzhPlanVideo> gzhPlanVideoListByVideoTitle(Long videoId) {
|
|
|
+ ContentPlatformGzhPlanVideoExample example = new ContentPlatformGzhPlanVideoExample();
|
|
|
+ example.createCriteria().andVideoIdEqualTo(videoId).andCustomTitleIdIsNotNull();
|
|
|
+ return gzhPlanVideoMapper.selectByExample(example);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void setCustomCover(ContentPlatformGzhPlanVideo item, GzhPlanVideoContentItemParam vo) {
|
|
|
+ if (StringUtils.hasText(vo.getCustomCover())) {
|
|
|
+ List<ContentPlatformGzhPlanVideo> gzhPlanVideoList = gzhPlanVideoListByVideoCover(vo.getVideoId());
|
|
|
+ boolean customCoverExist = false;
|
|
|
+ if (CollectionUtils.isNotEmpty(gzhPlanVideoList)) {
|
|
|
+ for (ContentPlatformGzhPlanVideo gzhPlanVideo : gzhPlanVideoList) {
|
|
|
+ if (gzhPlanVideo.getCustomCover().equals(vo.getCustomCover())) {
|
|
|
+ item.setCustomCoverId(gzhPlanVideo.getCustomCoverId());
|
|
|
+ customCoverExist = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!customCoverExist) {
|
|
|
+ JSONObject multiCover = managerApiService.videoMultiCoverSave(vo.getVideoId(), vo.getCustomCover());
|
|
|
+ item.setCustomCoverId(multiCover.getLong("id"));
|
|
|
+ }
|
|
|
+ item.setCustomCover(vo.getCustomCover());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private List<ContentPlatformGzhPlanVideo> gzhPlanVideoListByVideoCover(Long videoId) {
|
|
|
+ ContentPlatformGzhPlanVideoExample example = new ContentPlatformGzhPlanVideoExample();
|
|
|
+ example.createCriteria().andVideoIdEqualTo(videoId).andCustomCoverIdIsNotNull();
|
|
|
+ return gzhPlanVideoMapper.selectByExample(example);
|
|
|
+ }
|
|
|
+
|
|
|
private void saveChangeVideoLog(Long planId, List<Long> existsVideoIds, List<GzhPlanVideoContentItemParam> videoList) {
|
|
|
List<Long> newVideoIds = videoList.stream().map(GzhPlanVideoContentItemParam::getVideoId).collect(Collectors.toList());
|
|
|
boolean changed = false;
|
|
|
@@ -555,16 +612,16 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
type, Arrays.asList("sum", userChannel), videoIds);
|
|
|
Map<Long, Double> typeVideoScoreMap = videoDataStatAggList.stream()
|
|
|
.filter(o -> channel.equals(o.getChannel()) && "normal".equals(o.getStrategy())).collect(Collectors.toMap(
|
|
|
- ContentPlatformVideoDataStatAgg::getVideoId, ContentPlatformVideoDataStatAgg::getFissionRate));
|
|
|
+ ContentPlatformVideoDataStatAgg::getVideoId, ContentPlatformVideoDataStatAgg::getFissionRate));
|
|
|
Map<Long, Double> channelVideoScoreMap = videoDataStatAggList.stream()
|
|
|
.filter(o -> userChannel.equals(o.getChannel()) && "normal".equals(o.getStrategy())).collect(Collectors.toMap(
|
|
|
- ContentPlatformVideoDataStatAgg::getVideoId, ContentPlatformVideoDataStatAgg::getFissionRate));
|
|
|
+ ContentPlatformVideoDataStatAgg::getVideoId, ContentPlatformVideoDataStatAgg::getFissionRate));
|
|
|
Map<Long, Double> recommendTypeVideoScoreMap = videoDataStatAggList.stream()
|
|
|
.filter(o -> channel.equals(o.getChannel()) && "recommend".equals(o.getStrategy())).collect(Collectors.toMap(
|
|
|
- ContentPlatformVideoDataStatAgg::getVideoId, ContentPlatformVideoDataStatAgg::getFissionRate));
|
|
|
+ ContentPlatformVideoDataStatAgg::getVideoId, ContentPlatformVideoDataStatAgg::getFissionRate));
|
|
|
Map<Long, Double> recommendChannelVideoScoreMap = videoDataStatAggList.stream()
|
|
|
.filter(o -> userChannel.equals(o.getChannel()) && "recommend".equals(o.getStrategy())).collect(Collectors.toMap(
|
|
|
- ContentPlatformVideoDataStatAgg::getVideoId, ContentPlatformVideoDataStatAgg::getFissionRate));
|
|
|
+ ContentPlatformVideoDataStatAgg::getVideoId, ContentPlatformVideoDataStatAgg::getFissionRate));
|
|
|
List<VideoContentItemVO> result = new ArrayList<>();
|
|
|
for (ContentPlatformVideo video : videoList) {
|
|
|
VideoContentItemVO item = new VideoContentItemVO();
|
|
|
@@ -591,9 +648,9 @@ public class ContentPlatformPlanServiceImpl implements ContentPlatformPlanServic
|
|
|
|
|
|
@Override
|
|
|
public List<ContentPlatformVideoDataStatAgg> getTypeChannelVideoDataStatAggList(String datastatDt,
|
|
|
- String type,
|
|
|
- List<String> channels,
|
|
|
- List<Long> videoIds) {
|
|
|
+ String type,
|
|
|
+ List<String> channels,
|
|
|
+ List<Long> videoIds) {
|
|
|
ContentPlatformVideoDataStatAggExample example = new ContentPlatformVideoDataStatAggExample();
|
|
|
example.createCriteria().andVideoIdIn(videoIds).andDtEqualTo(datastatDt).andTypeEqualTo(type)
|
|
|
.andChannelIn(channels);
|