Browse Source

Merge branch 'wyp/0421-fix' of Server/long-article-recommend into master

wangyunpeng 3 ngày trước cách đây
mục cha
commit
c57f8d1f82

+ 65 - 3
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/DataDashboardService.java

@@ -2736,11 +2736,41 @@ public class DataDashboardService {
         List<LongArticleCrawlerVideo> longArticleCrawlerVideoList = crawlerVideoRepository.getByContentIdInAndIsIllegal(contentIdList, 0);
         Map<String, List<LongArticleCrawlerVideo>> longArticleCrawlerVideoMap = longArticleCrawlerVideoList.stream()
                 .collect(Collectors.groupingBy(LongArticleCrawlerVideo::getContentId));
+        List<String> videoOssPathList = longArticleCrawlerVideoList.stream().map(LongArticleCrawlerVideo::getVideoOssPath)
+                .filter(StringUtils::hasText).collect(Collectors.toList());
+        List<PublishSingleVideoSource> singleVideoSourceList = videoPoolRepository.getByVideoOssPathIn(videoOssPathList);
+        Map<String, List<PublishSingleVideoSource>> singgleVideoSourceMap = singleVideoSourceList.stream()
+                .collect(Collectors.groupingBy(PublishSingleVideoSource::getVideoOssPath));
+        // 获取晋级
+        List<String> sourceIds = datastatSortStrategyList.stream().map(DatastatSortStrategy::getSourceId).distinct()
+                .collect(Collectors.toList());
+        List<ProducePlanExeRecord> exeRecordList = producePlanExeRecordRepository.findByPlanExeIdIn(sourceIds);
+        Map<String, String> sourceIdMap = exeRecordList.stream()
+                .collect(Collectors.toMap(ProducePlanExeRecord::getPlanExeId, ProducePlanExeRecord::getChannelContentId));
+        List<String> channelContentIds = exeRecordList.stream().map(ProducePlanExeRecord::getChannelContentId)
+                .collect(Collectors.toList());
+        List<ArticlePoolPromotionSource> promotionSourceList = articlePoolPromotionSourceRepository.getByChannelContentIdInAndStatusAndDeleted(
+                channelContentIds, ArticlePoolPromotionSourceStatusEnum.FINISH.getCode(), 0);
+        Map<String, String> promotionSourceMap = promotionSourceList.stream()
+                .collect(Collectors.toMap(ArticlePoolPromotionSource::getChannelContentId, ArticlePoolPromotionSource::getRootProduceContentId));
+        List<String> rootProduceContentIds = promotionSourceList.stream().map(ArticlePoolPromotionSource::getRootProduceContentId)
+               .collect(Collectors.toList());
+        List<LongArticleCrawlerVideo> promotionCrawlerVideoList = crawlerVideoRepository.getByContentIdInAndIsIllegal(rootProduceContentIds, 0);
+        Map<String, List<LongArticleCrawlerVideo>> promotionCrawlerVideoMap = promotionCrawlerVideoList.stream()
+                .collect(Collectors.groupingBy(LongArticleCrawlerVideo::getContentId));
+        List<String> promotionVideoOssPathList = promotionCrawlerVideoList.stream().map(LongArticleCrawlerVideo::getVideoOssPath)
+                .filter(StringUtils::hasText).collect(Collectors.toList());
+        List<PublishSingleVideoSource> promotionSingleVideoSourceList = videoPoolRepository.getByVideoOssPathIn(promotionVideoOssPathList);
+        Map<String, List<PublishSingleVideoSource>> promotionSinggleVideoSourceMap = promotionSingleVideoSourceList.stream()
+                .collect(Collectors.groupingBy(PublishSingleVideoSource::getVideoOssPath));
+
         for (Article article : articleList) {
             boolean isVideo = false;
             boolean isSameMiniProgram = false;
             String source = "";
             List<String> rootSourceIds = rootSourceIdMap.get(article.getWxSn());
+            List<ArticleDetailInfo> detailInfoList = articleDetailInfoMap.get(article.getWxSn());
+            DatastatSortStrategy datastatSortStrategy = datastatSortStrategyMap.get(article.getWxSn());
             if (CollectionUtil.isNotEmpty(rootSourceIds)) {
                 List<LongArticlesRootSourceId> rootSourceIdItemList = new ArrayList<>();
                 for (String rootSourceId : rootSourceIds) {
@@ -2753,21 +2783,53 @@ public class DataDashboardService {
                 if (CollectionUtils.isEmpty(rootSourceIdItemList)) {
                     continue;
                 }
+                // 判断是否冷启视频内容池
                 String contentId = rootSourceIdItemList.get(0).getContentId();
                 List<LongArticleCrawlerVideo> crawlerVideoList = longArticleCrawlerVideoMap.get(contentId);
                 List<String> videoOssPaths = crawlerVideoList.stream().map(LongArticleCrawlerVideo::getVideoOssPath)
                         .filter(StringUtils::hasText).collect(Collectors.toList());
-                List<PublishSingleVideoSource> singleVideoSources = videoPoolRepository.getByVideoOssPathIn(videoOssPaths);
+                List<PublishSingleVideoSource> singleVideoSources = new ArrayList<>();
+                for (String videoOssPath : videoOssPaths) {
+                    List<PublishSingleVideoSource> item = singgleVideoSourceMap.get(videoOssPath);
+                    if (CollectionUtil.isEmpty(item)) {
+                        continue;
+                    }
+                    singleVideoSources.addAll(item);
+                }
                 if (CollectionUtil.isNotEmpty(singleVideoSources)) {
                     isVideo = true;
                     source = VideoPoolPlatformEnum.from(singleVideoSources.get(0).getPlatform()).getDescription();
                 }
+                // 判断是否是晋级内容池
+                if (!isVideo && Objects.nonNull(datastatSortStrategy)) {
+                    String channelContentId = sourceIdMap.get(datastatSortStrategy.getSourceId());
+                    if (StringUtils.hasText(channelContentId)) {
+                        String rootProduceContentId = promotionSourceMap.get(channelContentId);
+                        if (StringUtils.hasText(rootProduceContentId)) {
+                            List<LongArticleCrawlerVideo> promotionCrawlerVideos = promotionCrawlerVideoMap.get(rootProduceContentId);
+                            if (CollectionUtil.isNotEmpty(promotionCrawlerVideos)) {
+                                List<String> promotionVideoOssPaths = promotionCrawlerVideos.stream().map(LongArticleCrawlerVideo::getVideoOssPath)
+                                        .filter(StringUtils::hasText).collect(Collectors.toList());
+                                List<PublishSingleVideoSource> promotionSingleVideoSources = new ArrayList<>();
+                                for (String videoOssPath : promotionVideoOssPaths) {
+                                    List<PublishSingleVideoSource> item = promotionSinggleVideoSourceMap.get(videoOssPath);
+                                    if (CollectionUtil.isEmpty(item)) {
+                                        continue;
+                                    }
+                                    promotionSingleVideoSources.addAll(item);
+                                }
+                                if (CollectionUtil.isNotEmpty(promotionSingleVideoSources)) {
+                                    isVideo = true;
+                                    source = VideoPoolPlatformEnum.from(promotionSingleVideoSources.get(0).getPlatform()).getDescription();
+                                }
+                            }
+                        }
+                    }
+                }
                 if (CollectionUtil.isNotEmpty(crawlerVideoList) && crawlerVideoList.size() == 1) {
                     isSameMiniProgram = true;
                 }
             }
-            List<ArticleDetailInfo> detailInfoList = articleDetailInfoMap.get(article.getWxSn());
-            DatastatSortStrategy datastatSortStrategy = datastatSortStrategyMap.get(article.getWxSn());
             if (isVideo) {
                 addContentEffectGroupBySourceRate(article, "视频", source, isSameMiniProgram, result, detailInfoList,
                         datastatSortStrategy);