Bladeren bron

头尾小程序表现导出

wangyunpeng 3 weken geleden
bovenliggende
commit
3b08af70b4

+ 2 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/vo/FirstEndMiniprogramFirstLevelExport.java

@@ -6,6 +6,8 @@ import lombok.Data;
 public class FirstEndMiniprogramFirstLevelExport {
     private String dateStr;
     private String accountName;
+    private Integer isVideo = 0;
+    private Integer isSameMiniProgram = 0;
     private String title;
     private Integer position;
     private Integer viewCount;

+ 3 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/longArticle/LongArticleCrawlerVideoRepository.java

@@ -16,6 +16,8 @@ public interface LongArticleCrawlerVideoRepository extends JpaRepository<LongArt
 
     List<LongArticleCrawlerVideo> getByContentIdAndIsIllegal(String contentId, Integer isIllegal);
 
+    List<LongArticleCrawlerVideo> getByContentIdInAndIsIllegal(List<String> contentIds, Integer isIllegal);
+
     List<LongArticleCrawlerVideo> getByVideoOssPath(String ossPath);
 
     LongArticleCrawlerVideo getById(Long videoId);
@@ -27,4 +29,5 @@ public interface LongArticleCrawlerVideoRepository extends JpaRepository<LongArt
     long countByStatusAndAuditTimestampBetween(Integer status, Long start, Long end);
 
     List<LongArticleCrawlerVideo> getByContentId(String rootProduceContentId);
+
 }

+ 2 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/longArticle/PublishSingleVideoSourceRepository.java

@@ -27,4 +27,6 @@ public interface PublishSingleVideoSourceRepository extends JpaRepository<Publis
     List<PublishSingleVideoSource> getByVideoPoolAuditTimestampBetween(Long start, Long end);
 
     List<PublishSingleVideoSource> getByVideoPoolAuditTimestampBetweenAndPlatform(Long start, Long end, String platform);
+
+    List<PublishSingleVideoSource> getByVideoOssPathIn(List<String> videoOssPaths);
 }

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

@@ -107,6 +107,8 @@ public class DataDashboardService {
     private LongArticleTitleAuditRepository longArticleTitleAuditRepository;
     @Autowired
     private PublishSingleVideoSourceRepository videoPoolRepository;
+    @Autowired
+    private LongArticlesRootSourceIdRepository rootSourceIdRepository;
 
     @ApolloJsonValue("${export.account.ghId:[]}")
     private static List<String> ghIdList;
@@ -2670,6 +2672,22 @@ public class DataDashboardService {
         }
         Map<String, List<ArticleDetailInfo>> articleDetailInfoMap = articleDetailInfoList.stream()
                 .collect(Collectors.groupingBy(ArticleDetailInfo::getWxSn));
+        // 获取rootSourceId
+        Map<String, List<String>> rootSourceIdMap = new HashMap<>();
+        List<String> rootSourceIdList = new ArrayList<>();
+        for (Article article : articleList) {
+            List<String> rootSourceIds = JSONArray.parseArray(article.getRootSourceIdList(), String.class);
+            rootSourceIdMap.put(article.getWxSn(), rootSourceIds);
+            rootSourceIdList.addAll(rootSourceIds);
+        }
+        List<LongArticlesRootSourceId> longArticlesRootSourceIdList = rootSourceIdRepository.getByRootSourceIdIn(rootSourceIdList);
+        Map<String, LongArticlesRootSourceId> longArticlesRootSourceIdMap = longArticlesRootSourceIdList.stream()
+               .collect(Collectors.toMap(LongArticlesRootSourceId::getRootSourceId, Function.identity()));
+        // 获取视频
+        List<String> contentIdList = longArticlesRootSourceIdList.stream().map(LongArticlesRootSourceId::getContentId).distinct().collect(Collectors.toList());
+        List<LongArticleCrawlerVideo> longArticleCrawlerVideoList = crawlerVideoRepository.getByContentIdInAndIsIllegal(contentIdList, 0);
+        Map<String, List<LongArticleCrawlerVideo>> longArticleCrawlerVideoMap = longArticleCrawlerVideoList.stream()
+               .collect(Collectors.groupingBy(LongArticleCrawlerVideo::getContentId));
 
         for (Article article : articleList) {
             FirstEndMiniprogramFirstLevelExport item = new FirstEndMiniprogramFirstLevelExport();
@@ -2678,10 +2696,30 @@ public class DataDashboardService {
             item.setTitle(article.getTitle());
             item.setPosition(article.getItemIndex());
             item.setViewCount(article.getShowViewCount());
-
             if (Objects.isNull(item.getViewCount()) || item.getViewCount() == 0) {
                 continue;
             }
+            List<String> rootSourceIds = rootSourceIdMap.get(article.getWxSn());
+            if (CollectionUtil.isNotEmpty(rootSourceIds)) {
+                List<LongArticlesRootSourceId> rootSourceIdItemList = new ArrayList<>();
+                for (String rootSourceId : rootSourceIds) {
+                    LongArticlesRootSourceId longArticlesRootSourceId = longArticlesRootSourceIdMap.get(rootSourceId);
+                    if (Objects.isNull(longArticlesRootSourceId)) {
+                        continue;
+                    }
+                    rootSourceIdItemList.add(longArticlesRootSourceId);
+                }
+                String contentId = rootSourceIdItemList.get(0).getContentId();
+                List<LongArticleCrawlerVideo> crawlerVideoList = longArticleCrawlerVideoMap.get(contentId);
+                List<String> videoOssPaths = crawlerVideoList.stream().map(LongArticleCrawlerVideo::getVideoOssPath).collect(Collectors.toList());
+                List<PublishSingleVideoSource> singleVideoSources = videoPoolRepository.getByVideoOssPathIn(videoOssPaths);
+                if (CollectionUtil.isNotEmpty(singleVideoSources)) {
+                    item.setIsVideo(1);
+                }
+                if (CollectionUtil.isNotEmpty(crawlerVideoList) && crawlerVideoList.size() == 1) {
+                    item.setIsSameMiniProgram(1);
+                }
+            }
             List<ArticleDetailInfo> detailInfoList = articleDetailInfoMap.get(article.getWxSn());
             if (CollectionUtil.isNotEmpty(detailInfoList)) {
                 int totalFirstLevel = 0;