Prechádzať zdrojové kódy

内容效果-分来源 来源溯源

wangyunpeng 3 dní pred
rodič
commit
04216d30c3

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

@@ -10,5 +10,6 @@ public class CategoryGroupDataExport {
     private Long fansCount = 0L;
     private Integer viewCount = 0;
     private Integer firstLevel = 0;
+    private Double readRate;
     private Double openRate;
 }

+ 1 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/aigc/ProducePlanExeRecordRepository.java

@@ -9,7 +9,7 @@ import java.util.List;
 @Repository
 public interface ProducePlanExeRecordRepository extends JpaRepository<ProducePlanExeRecord, String> {
 
-    List<ProducePlanExeRecord> findByPlanExeIdIn(List<String> planExeIds);
+    List<ProducePlanExeRecord> getByPlanExeIdIn(List<String> planExeIds);
 
     ProducePlanExeRecord getByPlanExeId(String contentId);
 }

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

@@ -291,7 +291,7 @@ public class DataDashboardService {
                 .map(PublishContentDTO::getSourceId).distinct().collect(Collectors.toList());
         List<ProducePlanExeRecord> planExeRecordList = new ArrayList<>();
         for (List<String> partitions : Lists.partition(contentSourceIds, 1000)) {
-            planExeRecordList.addAll(producePlanExeRecordRepository.findByPlanExeIdIn(partitions));
+            planExeRecordList.addAll(producePlanExeRecordRepository.getByPlanExeIdIn(partitions));
         }
         log.info("newSortStrategyData planExeRecordList finish");
         List<String> videoPoolSourceIds = publishContents.stream()
@@ -2744,7 +2744,7 @@ public class DataDashboardService {
         // 获取晋级
         List<String> sourceIds = datastatSortStrategyList.stream().map(DatastatSortStrategy::getSourceId).distinct()
                 .collect(Collectors.toList());
-        List<ProducePlanExeRecord> exeRecordList = producePlanExeRecordRepository.findByPlanExeIdIn(sourceIds);
+        List<ProducePlanExeRecord> exeRecordList = producePlanExeRecordRepository.getByPlanExeIdIn(sourceIds);
         Map<String, String> sourceIdMap = exeRecordList.stream()
                 .collect(Collectors.toMap(ProducePlanExeRecord::getPlanExeId, ProducePlanExeRecord::getChannelContentId));
         List<String> channelContentIds = exeRecordList.stream().map(ProducePlanExeRecord::getChannelContentId)
@@ -2754,7 +2754,8 @@ public class DataDashboardService {
         Map<String, String> promotionSourceMap = promotionSourceList.stream()
                 .collect(Collectors.toMap(ArticlePoolPromotionSource::getChannelContentId, ArticlePoolPromotionSource::getRootProduceContentId));
         List<String> rootProduceContentIds = promotionSourceList.stream().map(ArticlePoolPromotionSource::getRootProduceContentId)
-               .collect(Collectors.toList());
+                .collect(Collectors.toList());
+        // 视频溯源信息
         List<LongArticleCrawlerVideo> promotionCrawlerVideoList = crawlerVideoRepository.getByContentIdInAndIsIllegal(rootProduceContentIds, 0);
         Map<String, List<LongArticleCrawlerVideo>> promotionCrawlerVideoMap = promotionCrawlerVideoList.stream()
                 .collect(Collectors.groupingBy(LongArticleCrawlerVideo::getContentId));
@@ -2763,6 +2764,13 @@ public class DataDashboardService {
         List<PublishSingleVideoSource> promotionSingleVideoSourceList = videoPoolRepository.getByVideoOssPathIn(promotionVideoOssPathList);
         Map<String, List<PublishSingleVideoSource>> promotionSinggleVideoSourceMap = promotionSingleVideoSourceList.stream()
                 .collect(Collectors.groupingBy(PublishSingleVideoSource::getVideoOssPath));
+        // 文章溯源信息
+        List<ProducePlanExeRecord> rootProduceContentList = producePlanExeRecordRepository.getByPlanExeIdIn(rootProduceContentIds);
+        Map<String, String> rootProduceContentMap = rootProduceContentList.stream()
+                .collect(Collectors.toMap(ProducePlanExeRecord::getPlanExeId, ProducePlanExeRecord::getPlanId));
+        List<String> rootPlanIdList = rootProduceContentList.stream().map(ProducePlanExeRecord::getPlanId).distinct().collect(Collectors.toList());
+        List<ProducePlan> producePlanList = producePlanRepository.findByIdIn(rootPlanIdList);
+        Map<String, ProducePlan> producePlanMap = producePlanList.stream().collect(Collectors.toMap(ProducePlan::getId, Function.identity()));
 
         for (Article article : articleList) {
             boolean isVideo = false;
@@ -2801,31 +2809,33 @@ public class DataDashboardService {
                     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();
-                                }
-                            }
+                String channelContentId = null;
+                if (Objects.nonNull(datastatSortStrategy)) {
+                    channelContentId = sourceIdMap.get(datastatSortStrategy.getSourceId());
+                }
+                String rootProduceContentId = promotionSourceMap.get(channelContentId);
+                List<LongArticleCrawlerVideo> promotionCrawlerVideos = promotionCrawlerVideoMap.get(rootProduceContentId);
+                if (!isVideo && 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 (!isVideo) {
+                    String planId = rootProduceContentMap.get(rootProduceContentId);
+                    ProducePlan producePlan = producePlanMap.get(planId);
+                    source = getArticleSource(producePlan);
+                }
                 if (CollectionUtil.isNotEmpty(crawlerVideoList) && crawlerVideoList.size() == 1) {
                     isSameMiniProgram = true;
                 }
@@ -2861,9 +2871,6 @@ public class DataDashboardService {
         if (Objects.isNull(datastatSortStrategy)) {
             return;
         }
-        if ("文章".equals(type) && "".equals(source)) {
-            source = getArticleSource(datastatSortStrategy);
-        }
         for (ContentEffectGroupBySourceExport export : result) {
             if ((export.getType().contains("SUM") && export.getType().contains(type)) || export.getType().equals(type)) {
                 if ((export.getIsSameMiniprogram().equals("相同") && isSameMiniProgram)
@@ -2920,9 +2927,9 @@ public class DataDashboardService {
         }
     }
 
-    private String getArticleSource(DatastatSortStrategy datastatSortStrategy) {
-        if (StringUtils.hasText(datastatSortStrategy.getProducePlanName())
-                && datastatSortStrategy.getProducePlanName().contains("头条")) {
+    private String getArticleSource(ProducePlan producePlan) {
+        if (Objects.nonNull(producePlan)
+                && producePlan.getName().contains("今日头条")) {
             return "头条文章";
         } else {
             return "公众号文章";
@@ -3714,7 +3721,8 @@ public class DataDashboardService {
 
         List<Pair<String, String>> styles = Arrays
                 .asList(
-                        Pair.of("G", "0.00%")
+                        Pair.of("G", "0.00%"),
+                        Pair.of("H", "0.00%")
                 );
         doSendFeishuSheet(dateStrList, dailyDetailSheetToken, "bl1eL2", rowNum, rows,
                 2, styles, null, null);
@@ -3763,6 +3771,7 @@ public class DataDashboardService {
             for (Map.Entry<String, CategoryGroupDataExport> item : entry.getValue().entrySet()) {
                 CategoryGroupDataExport export = item.getValue();
                 if (export.getFansCount() != null && export.getFansCount() != 0) {
+                    export.setReadRate((double) export.getViewCount() / export.getFansCount());
                     export.setOpenRate((double) export.getFirstLevel() / export.getFansCount());
                 }
                 result.add(export);

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

@@ -493,7 +493,7 @@ public class RecallService implements ApplicationContextAware {
         Map<String, ArticleCategory> titleCategoryMap = articleCategoryList.stream()
                 .collect(Collectors.toMap(ArticleCategory::getTitleMd5, Function.identity(), (a, b) -> a));
         // 获取生成计划
-        List<ProducePlanExeRecord> planExeRecordList = producePlanExeRecordRepository.findByPlanExeIdIn(sourceIds);
+        List<ProducePlanExeRecord> planExeRecordList = producePlanExeRecordRepository.getByPlanExeIdIn(sourceIds);
         Map<String, ProducePlanExeRecord> planExeRecordMap = planExeRecordList.stream()
                 .collect(Collectors.toMap(ProducePlanExeRecord::getPlanExeId, Function.identity()));
         // 根据sourceId查询kimiSafeScore

+ 1 - 1
long-article-recommend-service/src/test/java/com/tzld/longarticle/recommend/server/ArticleVideoAuditTest.java

@@ -65,7 +65,7 @@ public class ArticleVideoAuditTest {
     public void updateTitleAuditFlowPoolLevel() {
         List<LongArticleTitleAudit> list = titleAuditRepository.getByFlowPoolLevelIsNull();
         List<String> contentIds = list.stream().map(LongArticleTitleAudit::getContentId).collect(Collectors.toList());
-        List<ProducePlanExeRecord> contentList = exeRecordRepository.findByPlanExeIdIn(contentIds);
+        List<ProducePlanExeRecord> contentList = exeRecordRepository.getByPlanExeIdIn(contentIds);
         Map<String, String> contentPlanMap = contentList.stream().collect(Collectors.toMap(ProducePlanExeRecord::getPlanExeId, ProducePlanExeRecord::getPlanId));
         List<String> planIds = contentList.stream().map(ProducePlanExeRecord::getPlanId).collect(Collectors.toList());
         List<ProducePlan> planList = producePlanRepository.findByIdIn(planIds);