Ver Fonte

增加数据报表

xueyiming há 3 meses atrás
pai
commit
ca10027ca6

+ 28 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/entity/longArticle/LongArticlesNewVideoCover.java

@@ -0,0 +1,28 @@
+package com.tzld.longarticle.recommend.server.model.entity.longArticle;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.persistence.*;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Entity
+@Table(name = "long_articles_new_video_cover")
+public class LongArticlesNewVideoCover {
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id")
+    private Long id;
+
+
+    @Column(name = "version")
+    private Integer version;
+
+    @Column(name = "get_cover_status")
+    private Integer coverStatus;
+
+}

+ 34 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/entity/longArticle/LongArticlesPublishMiniprogram.java

@@ -0,0 +1,34 @@
+package com.tzld.longarticle.recommend.server.model.entity.longArticle;
+
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+
+import javax.persistence.*;
+
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+@Entity
+@Table(name = "long_articles_publish_miniprogram")
+public class LongArticlesPublishMiniprogram {
+
+    @Id
+    @GeneratedValue(strategy = GenerationType.IDENTITY)
+    @Column(name = "id")
+    private Long id;
+
+    @Column(name = "crawler_video_id")
+    private Integer crawlerVideoId;
+
+
+    @Column(name = "root_source_id")
+    private String rootSourceId;
+
+
+    @Column(name = "new_video_cover_id")
+    private Long newVideoCoverId;
+
+
+
+}

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

@@ -0,0 +1,61 @@
+package com.tzld.longarticle.recommend.server.model.vo;
+
+import lombok.Data;
+
+@Data
+public class CoverStatisticDataExport {
+
+    public CoverStatisticDataExport() {
+
+    }
+
+    public CoverStatisticDataExport(String dateStr, String channel, String group, String index) {
+        this.dateStr = dateStr;
+        this.channel = channel;
+        this.group = group;
+        this.group = group;
+
+    }
+
+    private String dateStr;
+
+    private String channel;
+
+    private String group;
+
+    private String index;
+
+    private Integer fans = 0;
+
+    private Integer publishCount = 0;
+
+    private Integer showViewCount = 0;
+
+    private Double showViewRate = 0.0;
+
+    private Integer allFirstLevel = 0;
+
+    private Integer oneFirstLevel = 0;
+
+    private Integer twoFirstLevel = 0;
+
+    private Double allFirstLevelRate = 0.0;
+
+    private Double oneFirstLevelRate = 0.0;
+
+    private Double twoFirstLevelRate = 0.0;
+
+    private Integer allFission0 = 0;
+
+    private Integer oneFission0 = 0;
+
+    private Integer twoFission0 = 0;
+
+    private Double allFission0Rate = 0.0;
+
+    private Double oneFission0Rate = 0.0;
+
+    private Double twoFission0Rate = 0.0;
+
+
+}

+ 5 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/crawler/ArticleDetailInfoRepository.java

@@ -4,10 +4,15 @@ import com.tzld.longarticle.recommend.server.model.entity.crawler.ArticleDetailI
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.stereotype.Repository;
 
+import java.util.Date;
 import java.util.List;
 
 @Repository
 public interface ArticleDetailInfoRepository extends JpaRepository<ArticleDetailInfo, ArticleDetailInfo.PK> {
 
     List<ArticleDetailInfo> getByWxSnIn(List<String> wxSnList);
+
+    List<ArticleDetailInfo> findByWxSnInAndPublishDtBetween(List<String> wxSnList, Date startDate, Date endDate);
+
+    List<ArticleDetailInfo> findByWxSnEqualsAndPublishDtBetween(String wxSn, Date startDate, Date endDate);
 }

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

@@ -0,0 +1,7 @@
+package com.tzld.longarticle.recommend.server.repository.longArticle;
+
+import com.tzld.longarticle.recommend.server.model.entity.longArticle.LongArticlesNewVideoCover;
+import org.springframework.data.jpa.repository.JpaRepository;
+
+public interface LongArticlesNewVideoCoverRepository extends JpaRepository<LongArticlesNewVideoCover, Long> {
+}

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

@@ -0,0 +1,11 @@
+package com.tzld.longarticle.recommend.server.repository.longArticle;
+
+import com.tzld.longarticle.recommend.server.model.entity.longArticle.LongArticlesPublishMiniprogram;
+import org.springframework.data.jpa.repository.JpaRepository;
+import org.springframework.stereotype.Repository;
+
+@Repository
+public interface LongArticlesPublishMiniprogramRepository extends JpaRepository<LongArticlesPublishMiniprogram, Long> {
+
+    LongArticlesPublishMiniprogram findByRootSourceIdEquals(String rootSourceId);
+}

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

@@ -114,6 +114,10 @@ public class DataDashboardService {
     private LongArticlesRootSourceIdRepository rootSourceIdRepository;
     @Autowired
     private DatastatSortStrategyRepository datastatSortStrategyRepository;
+    @Autowired
+    private LongArticlesPublishMiniprogramRepository longArticlesPublishMiniprogramRepository;
+    @Autowired
+    private LongArticlesNewVideoCoverRepository longArticlesNewVideoCoverRepository;
 
     @ApolloJsonValue("${export.account.ghId:[]}")
     private static List<String> ghIdList;
@@ -2924,4 +2928,329 @@ public class DataDashboardService {
         }
     }
 
+    public void coverStatisticDataExport(String dateStr) {
+        List<String> dateStrList = Arrays.asList(dateStr);
+        List<CoverStatisticDataExport> exportList = buildCoverStatisticDataExport(dateStr);
+        if (CollectionUtil.isEmpty(exportList)) {
+            return;
+        }
+        int rowNum = exportList.size();
+        List<List<Object>> rows = new ArrayList<>();
+        Field[] fields = CoverStatisticDataExport.class.getDeclaredFields();
+        for (CoverStatisticDataExport datum : exportList) {
+            List<Object> rowDatas = new ArrayList<>();
+            rows.add(rowDatas);
+
+            for (Field field : fields) {
+                field.setAccessible(true);
+                try {
+                    rowDatas.add(field.get(datum));
+                } catch (IllegalAccessException e) {
+                    log.error("获取值出错:{}", field.getName());
+                } catch (Exception e) {
+                    throw new RuntimeException(e.getMessage());
+                }
+            }
+        }
+        doSendFeishuSheet(dateStrList, dailyDetailSheetToken, "jwayC4", rowNum, rows,
+                2, null, null, null);
+    }
+
+
+    private List<CoverStatisticDataExport> buildCoverStatisticDataExport(String dateStr) {
+        List<CoverStatisticDataExport> result = new ArrayList<>();
+        CoverStatisticDataExport articleTestFirst = new CoverStatisticDataExport(dateStr, "文章", "实验组", "头条");
+        CoverStatisticDataExport articleTestSecond = new CoverStatisticDataExport(dateStr, "文章", "实验组", "次条");
+        CoverStatisticDataExport articleTestLast = new CoverStatisticDataExport(dateStr, "文章", "实验组", "3-8条");
+
+        CoverStatisticDataExport articleBaseFirst = new CoverStatisticDataExport(dateStr, "文章", "base组", "头条");
+        CoverStatisticDataExport articleBaseSecond = new CoverStatisticDataExport(dateStr, "文章", "base组", "次条");
+        CoverStatisticDataExport articleBaseLast = new CoverStatisticDataExport(dateStr, "文章", "base组", "3-8条");
+
+        CoverStatisticDataExport articleMinimumFirst = new CoverStatisticDataExport(dateStr, "文章", "兜底组", "头条");
+        CoverStatisticDataExport articleMinimumSecond = new CoverStatisticDataExport(dateStr, "文章", "兜底组", "次条");
+        CoverStatisticDataExport articleMinimumLast = new CoverStatisticDataExport(dateStr, "文章", "兜底组", "3-8条");
+
+        CoverStatisticDataExport articleSumFirst = new CoverStatisticDataExport(dateStr, "文章", "sum", "sum");
+
+        CoverStatisticDataExport videoTestFirst = new CoverStatisticDataExport(dateStr, "视频", "实验组", "头条");
+        CoverStatisticDataExport videoTestSecond = new CoverStatisticDataExport(dateStr, "视频", "实验组", "次条");
+        CoverStatisticDataExport videoTestLast = new CoverStatisticDataExport(dateStr, "视频", "实验组", "3-8条");
+
+        CoverStatisticDataExport videoBaseFirst = new CoverStatisticDataExport(dateStr, "视频", "base组", "头条");
+        CoverStatisticDataExport videoBaseSecond = new CoverStatisticDataExport(dateStr, "视频", "base组", "次条");
+        CoverStatisticDataExport videoBaseLast = new CoverStatisticDataExport(dateStr, "视频", "base组", "3-8条");
+
+        CoverStatisticDataExport videoMinimumFirst = new CoverStatisticDataExport(dateStr, "视频", "兜底组", "头条");
+        CoverStatisticDataExport videoMinimumSecond = new CoverStatisticDataExport(dateStr, "视频", "兜底组", "次条");
+        CoverStatisticDataExport videoMinimumLast = new CoverStatisticDataExport(dateStr, "视频", "兜底组", "3-8条");
+
+        CoverStatisticDataExport videoSumFirst = new CoverStatisticDataExport(dateStr, "视频", "sum", "sum");
+
+
+        Long start = DateUtils.getStartOfDay(dateStr, "yyyyMMdd");
+        Long end = start + 86400;
+        Date startDate = new Date(start * 1000);
+        Date endDate = new Date(end * 1000);
+        List<Article> articleList = articleRepository.getByPublishTimestampBetweenAndTypeEquals(start, end, ArticleTypeEnum.QUNFA.getVal());
+        List<String> wxSnList = articleList.stream().map(Article::getWxSn).collect(Collectors.toList());
+        List<ArticleDetailInfo> articleDetailInfoList = new ArrayList<>();
+        for (List<String> partitions : Lists.partition(wxSnList, 1000)) {
+            articleDetailInfoList.addAll(articleDetailInfoRepository.findByWxSnInAndPublishDtBetween(partitions, startDate, endDate));
+        }
+        List<DatastatSortStrategy> datastatSortStrategyList = datastatSortStrategyRepository.getByWxSnIn(wxSnList);
+        Map<String, DatastatSortStrategy> datastatSortStrategyMap = datastatSortStrategyList.stream()
+                .collect(Collectors.toMap(DatastatSortStrategy::getWxSn, Function.identity()));
+        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) {
+            boolean isVideo = false;
+            boolean isSameMiniProgram = false;
+            boolean isTest = false;
+            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)) {
+                        rootSourceIdItemList.add(longArticlesRootSourceId);
+                    }
+                    LongArticlesPublishMiniprogram longArticlesPublishMiniprogram
+                            = longArticlesPublishMiniprogramRepository.findByRootSourceIdEquals(rootSourceId);
+                    if (!Objects.isNull(longArticlesPublishMiniprogram)) {
+                        if (longArticlesPublishMiniprogram.getNewVideoCoverId() != null) {
+                            isTest = true;
+                        }
+                    }
+
+                }
+                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);
+                if (CollectionUtil.isNotEmpty(singleVideoSources)) {
+                    isVideo = true;
+                }
+                if (CollectionUtil.isNotEmpty(crawlerVideoList) && crawlerVideoList.size() == 1) {
+                    isSameMiniProgram = true;
+                }
+            }
+            List<ArticleDetailInfo> detailInfoList = articleDetailInfoMap.get(article.getWxSn());
+            List<AccountAvgInfo> accountAvgInfoList = accountAvgInfoRepository.getAllByGhIdEqualsAndStatusEquals(article.getGhId(), 1);
+            Integer fans = 0;
+            if (CollectionUtils.isNotEmpty(accountAvgInfoList)) {
+                fans = accountAvgInfoList.get(0).getFans();
+            }
+            if (isVideo) {
+                if (isSameMiniProgram) {
+                    if (isTest) {
+                        if (article.getItemIndex() == 1) {
+                            save(videoTestFirst, fans, article.getShowViewCount());
+                            for (ArticleDetailInfo articleDetailInfo : detailInfoList) {
+                                saveMini(videoTestFirst, articleDetailInfo.getFirstLevel(), articleDetailInfo.getFission0(), articleDetailInfo.getVideoIndex());
+                            }
+                        } else if (article.getItemIndex() == 2) {
+                            save(videoTestSecond, fans, article.getShowViewCount());
+                            for (ArticleDetailInfo articleDetailInfo : detailInfoList) {
+                                saveMini(videoTestSecond, articleDetailInfo.getFirstLevel(), articleDetailInfo.getFission0(), articleDetailInfo.getVideoIndex());
+                            }
+                        } else {
+                            save(videoTestLast, fans, article.getShowViewCount());
+                            for (ArticleDetailInfo articleDetailInfo : detailInfoList) {
+                                saveMini(videoTestLast, articleDetailInfo.getFirstLevel(), articleDetailInfo.getFission0(), articleDetailInfo.getVideoIndex());
+                            }
+                        }
+                    } else {
+                        if (article.getItemIndex() == 1) {
+                            save(videoMinimumFirst, fans, article.getShowViewCount());
+                            for (ArticleDetailInfo articleDetailInfo : detailInfoList) {
+                                saveMini(videoMinimumFirst, articleDetailInfo.getFirstLevel(), articleDetailInfo.getFission0(), articleDetailInfo.getVideoIndex());
+                            }
+                        } else if (article.getItemIndex() == 2) {
+                            save(videoMinimumSecond, fans, article.getShowViewCount());
+                            for (ArticleDetailInfo articleDetailInfo : detailInfoList) {
+                                saveMini(videoMinimumSecond, articleDetailInfo.getFirstLevel(), articleDetailInfo.getFission0(), articleDetailInfo.getVideoIndex());
+                            }
+                        } else {
+                            save(videoMinimumLast, fans, article.getShowViewCount());
+                            for (ArticleDetailInfo articleDetailInfo : detailInfoList) {
+                                saveMini(videoMinimumLast, articleDetailInfo.getFirstLevel(), articleDetailInfo.getFission0(), articleDetailInfo.getVideoIndex());
+                            }
+                        }
+                    }
+                } else {
+                    if (article.getItemIndex() == 1) {
+                        save(videoBaseFirst, fans, article.getShowViewCount());
+                        for (ArticleDetailInfo articleDetailInfo : detailInfoList) {
+                            saveMini(videoBaseFirst, articleDetailInfo.getFirstLevel(), articleDetailInfo.getFission0(), articleDetailInfo.getVideoIndex());
+                        }
+                    } else if (article.getItemIndex() == 2) {
+                        save(videoBaseSecond, fans, article.getShowViewCount());
+                        for (ArticleDetailInfo articleDetailInfo : detailInfoList) {
+                            saveMini(videoBaseSecond, articleDetailInfo.getFirstLevel(), articleDetailInfo.getFission0(), articleDetailInfo.getVideoIndex());
+                        }
+                    } else {
+                        save(videoBaseLast, fans, article.getShowViewCount());
+                        for (ArticleDetailInfo articleDetailInfo : detailInfoList) {
+                            saveMini(videoBaseLast, articleDetailInfo.getFirstLevel(), articleDetailInfo.getFission0(), articleDetailInfo.getVideoIndex());
+                        }
+                    }
+                }
+            } else {
+                if (isSameMiniProgram) {
+                    if (isTest) {
+                        if (article.getItemIndex() == 1) {
+                            save(articleTestFirst, fans, article.getShowViewCount());
+                            for (ArticleDetailInfo articleDetailInfo : detailInfoList) {
+                                saveMini(articleTestFirst, articleDetailInfo.getFirstLevel(), articleDetailInfo.getFission0(), articleDetailInfo.getVideoIndex());
+                            }
+                        } else if (article.getItemIndex() == 2) {
+                            save(articleTestSecond, fans, article.getShowViewCount());
+                            for (ArticleDetailInfo articleDetailInfo : detailInfoList) {
+                                saveMini(articleTestSecond, articleDetailInfo.getFirstLevel(), articleDetailInfo.getFission0(), articleDetailInfo.getVideoIndex());
+                            }
+                        } else {
+                            save(articleTestLast, fans, article.getShowViewCount());
+                            for (ArticleDetailInfo articleDetailInfo : detailInfoList) {
+                                saveMini(articleTestLast, articleDetailInfo.getFirstLevel(), articleDetailInfo.getFission0(), articleDetailInfo.getVideoIndex());
+                            }
+                        }
+                    } else {
+                        if (article.getItemIndex() == 1) {
+                            save(articleMinimumFirst, fans, article.getShowViewCount());
+                            for (ArticleDetailInfo articleDetailInfo : detailInfoList) {
+                                saveMini(articleMinimumFirst, articleDetailInfo.getFirstLevel(), articleDetailInfo.getFission0(), articleDetailInfo.getVideoIndex());
+                            }
+                        } else if (article.getItemIndex() == 2) {
+                            save(articleMinimumSecond, fans, article.getShowViewCount());
+                            for (ArticleDetailInfo articleDetailInfo : detailInfoList) {
+                                saveMini(articleMinimumSecond, articleDetailInfo.getFirstLevel(), articleDetailInfo.getFission0(), articleDetailInfo.getVideoIndex());
+                            }
+                        } else {
+                            save(articleMinimumLast, fans, article.getShowViewCount());
+                            for (ArticleDetailInfo articleDetailInfo : detailInfoList) {
+                                saveMini(articleMinimumLast, articleDetailInfo.getFirstLevel(), articleDetailInfo.getFission0(), articleDetailInfo.getVideoIndex());
+                            }
+                        }
+                    }
+                } else {
+                    if (article.getItemIndex() == 1) {
+                        save(articleBaseFirst, fans, article.getShowViewCount());
+                        for (ArticleDetailInfo articleDetailInfo : detailInfoList) {
+                            saveMini(articleBaseFirst, articleDetailInfo.getFirstLevel(), articleDetailInfo.getFission0(), articleDetailInfo.getVideoIndex());
+                        }
+                    } else if (article.getItemIndex() == 2) {
+                        save(articleBaseSecond, fans, article.getShowViewCount());
+                        for (ArticleDetailInfo articleDetailInfo : detailInfoList) {
+                            saveMini(articleBaseSecond, articleDetailInfo.getFirstLevel(), articleDetailInfo.getFission0(), articleDetailInfo.getVideoIndex());
+                        }
+                    } else {
+                        save(articleBaseLast, fans, article.getShowViewCount());
+                        for (ArticleDetailInfo articleDetailInfo : detailInfoList) {
+                            saveMini(articleBaseLast, articleDetailInfo.getFirstLevel(), articleDetailInfo.getFission0(), articleDetailInfo.getVideoIndex());
+                        }
+                    }
+                }
+            }
+        }
+        result.add(rate(articleTestFirst));
+        result.add(rate(articleTestSecond));
+        result.add(rate(articleTestLast));
+        result.add(rate(articleBaseFirst));
+        result.add(rate(articleBaseSecond));
+        result.add(rate(articleBaseLast));
+        result.add(rate(articleMinimumFirst));
+        result.add(rate(articleMinimumSecond));
+        result.add(rate(articleMinimumLast));
+
+        result.add(rate(videoTestFirst));
+        result.add(rate(videoTestSecond));
+        result.add(rate(videoTestLast));
+        result.add(rate(videoBaseFirst));
+        result.add(rate(videoBaseSecond));
+        result.add(rate(videoBaseLast));
+        result.add(rate(videoMinimumFirst));
+        result.add(rate(videoMinimumSecond));
+        result.add(rate(videoMinimumLast));
+
+        return result;
+    }
+
+    private void save(CoverStatisticDataExport coverStatisticDataExport, Integer fans, Integer showViewCount) {
+        if (fans != null) {
+            coverStatisticDataExport.setFans(coverStatisticDataExport.getFans() + fans);
+        }
+        if (showViewCount != null) {
+            coverStatisticDataExport.setShowViewCount(coverStatisticDataExport.getShowViewCount() + showViewCount);
+        }
+        coverStatisticDataExport.setPublishCount(coverStatisticDataExport.getPublishCount() + 1);
+    }
+
+    private void saveMini(CoverStatisticDataExport coverStatisticDataExport, Integer firstLevel, Integer fission0, Integer index) {
+        if (firstLevel != null) {
+            coverStatisticDataExport.setAllFirstLevel(coverStatisticDataExport.getAllFirstLevel() + firstLevel);
+            if (index == 1) {
+                coverStatisticDataExport.setOneFirstLevel(coverStatisticDataExport.getOneFirstLevel() + firstLevel);
+            }
+            if (index == 2) {
+                coverStatisticDataExport.setTwoFirstLevel(coverStatisticDataExport.getTwoFirstLevel() + firstLevel);
+            }
+        }
+        if (fission0 != null) {
+            coverStatisticDataExport.setAllFission0(coverStatisticDataExport.getAllFission0() + fission0);
+            if (index == 1) {
+                coverStatisticDataExport.setOneFission0(coverStatisticDataExport.getOneFission0() + fission0);
+            }
+            if (index == 2) {
+                coverStatisticDataExport.setTwoFission0(coverStatisticDataExport.getTwoFission0() + fission0);
+            }
+        }
+    }
+
+    private CoverStatisticDataExport rate(CoverStatisticDataExport coverStatisticDataExport) {
+        if (coverStatisticDataExport.getShowViewCount() != null && coverStatisticDataExport.getFans() != null) {
+            coverStatisticDataExport.setShowViewRate((double) coverStatisticDataExport.getShowViewCount() / coverStatisticDataExport.getFans());
+        }
+        if (coverStatisticDataExport.getShowViewCount() != null) {
+            if (coverStatisticDataExport.getAllFirstLevel() != null) {
+                coverStatisticDataExport.setAllFirstLevelRate((double) coverStatisticDataExport.getAllFirstLevel() / coverStatisticDataExport.getShowViewCount());
+            }
+            if (coverStatisticDataExport.getOneFirstLevel() != null) {
+                coverStatisticDataExport.setOneFirstLevelRate((double) coverStatisticDataExport.getOneFirstLevel() / coverStatisticDataExport.getShowViewCount());
+            }
+            if (coverStatisticDataExport.getTwoFirstLevel() != null) {
+                coverStatisticDataExport.setTwoFirstLevelRate((double) coverStatisticDataExport.getTwoFirstLevel() / coverStatisticDataExport.getShowViewCount());
+            }
+        }
+
+        if (coverStatisticDataExport.getAllFirstLevel() != null && coverStatisticDataExport.getAllFission0() != null) {
+            coverStatisticDataExport.setAllFission0Rate((double) coverStatisticDataExport.getAllFission0() / coverStatisticDataExport.getAllFirstLevel());
+        }
+        if (coverStatisticDataExport.getOneFirstLevel() != null && coverStatisticDataExport.getOneFission0() != null) {
+            coverStatisticDataExport.setOneFission0Rate((double) coverStatisticDataExport.getOneFission0() / coverStatisticDataExport.getOneFirstLevel());
+        }
+        if (coverStatisticDataExport.getTwoFirstLevel() != null && coverStatisticDataExport.getTwoFission0() != null) {
+            coverStatisticDataExport.setTwoFission0Rate((double) coverStatisticDataExport.getTwoFission0() / coverStatisticDataExport.getTwoFirstLevel());
+        }
+        return coverStatisticDataExport;
+    }
+
+
 }

+ 9 - 0
long-article-recommend-service/src/test/java/com/tzld/longarticle/recommend/server/XxlJobTest.java

@@ -15,6 +15,7 @@ import com.tzld.longarticle.recommend.server.model.vo.ProduceContentCrawlerVO;
 import com.tzld.longarticle.recommend.server.repository.longArticle.ArticleCategoryRepository;
 import com.tzld.longarticle.recommend.server.repository.longArticle.ArticlePoolPromotionSourceRepository;
 import com.tzld.longarticle.recommend.server.service.recommend.ArticleService;
+import com.tzld.longarticle.recommend.server.service.recommend.DataDashboardService;
 import com.tzld.longarticle.recommend.server.util.Md5Util;
 import org.junit.jupiter.api.Test;
 import org.springframework.boot.test.context.SpringBootTest;
@@ -39,6 +40,9 @@ public class XxlJobTest {
     @Resource
     private ArticleCategoryRepository articleCategoryRepository;
 
+    @Resource
+    private DataDashboardService dataDashboardService;
+
     @ApolloJsonValue("${cold.pool.produce.planId:[\"20240802021606053813696\", \"20240802080355355308981\",\n" +
             "\"20240805154433785506170\", \"20240805154359027876170\", \"20241024100016206421084\", " +
             "\"20241030070010871546586\"]}")
@@ -107,4 +111,9 @@ public class XxlJobTest {
         List<PublishAccountTypeDTO> accountTypeList = publishContentMapper.getAccountTypeList(null);
         System.out.println(JSONObject.toJSONString(accountTypeList));
     }
+
+    @Test
+    public void coverStatisticDataExportTest() {
+        dataDashboardService.coverStatisticDataExport("20250407");
+    }
 }