瀏覽代碼

Merge branch 'wyp/0926-export' of Server/long-article-recommend into master

wangyunpeng 9 月之前
父節點
當前提交
c0e41e787a

+ 5 - 0
long-article-recommend-service/pom.xml

@@ -131,6 +131,11 @@
             <groupId>com.xuxueli</groupId>
             <artifactId>xxl-job-core</artifactId>
         </dependency>
+        <dependency>
+            <groupId>org.apache.poi</groupId>
+            <artifactId>poi-ooxml</artifactId>
+            <version>5.2.3</version>
+        </dependency>
     </dependencies>
 
 

+ 1 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/entity/crawler/AccountAvgInfo.java

@@ -27,7 +27,7 @@ public class AccountAvgInfo implements Serializable {
     @Column(name = "update_time")
     private String updateTime;
     @Column(name = "fans")
-    private long fans;
+    private Integer fans;
     @Column(name = "read_avg")
     private Double readAvg;
     @Column(name = "like_avg")

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

@@ -11,6 +11,8 @@ public class IntermediateIndicatorsExport {
     private Integer articleReleaseSlot = 0;
     // 文章实际发布数
     private Integer actualArticleReleaseCount = 0;
+    // 粉丝数
+    private Integer fansCount = 0;
     // 文章发布篇数(去重)
     private Integer distinctArticleReleaseCount = 0;
     // 文章发布篇数(去重)/文章实际发布数

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

@@ -291,19 +291,10 @@ public class DataDashboardService {
                     sumThirdFission2 += Optional.ofNullable(articleDetailInfo.getFission2()).orElse(0);
                 }
             }
-            Map<String, Map<String, AccountAvgInfo>> dateAvgMap = accountAvgInfoIndexMap.get(article.getGhId());
-            String hisPublishDate = DateUtils.timestampToYMDStr(article.getUpdateTime(), "yyyy-MM-dd");
-            AccountAvgInfo avgInfo = null;
-            AccountAvgInfo firstAvgInfo = null;
-            if (Objects.nonNull(dateAvgMap)) {
-                List<String> avgMapDateList = new ArrayList<>(dateAvgMap.keySet());
-                hisPublishDate = DateUtils.findNearestDate(avgMapDateList, hisPublishDate, "yyyy-MM-dd");
-                Map<String, AccountAvgInfo> accountAvgInfoMap = dateAvgMap.get(hisPublishDate);
-                if (Objects.nonNull(accountAvgInfoMap)) {
-                    avgInfo = accountAvgInfoMap.get(article.getItemIndex().toString());
-                    firstAvgInfo = accountAvgInfoMap.get("1");
-                }
-            }
+            AccountAvgInfo avgInfo = getAccountAvgInfo(accountAvgInfoIndexMap, article.getGhId(),
+                    article.getUpdateTime(), article.getItemIndex());
+            AccountAvgInfo firstAvgInfo = getAccountAvgInfo(accountAvgInfoIndexMap, article.getGhId(),
+                    article.getUpdateTime(), 1);
             String date = DateUtils.timestampToYMDStr(article.getUpdateTime(), "yyyyMMdd");
             NewSortStrategyExport obj = new NewSortStrategyExport();
             obj.setGhId(article.getGhId());
@@ -517,7 +508,7 @@ public class DataDashboardService {
                     .builder()
                     .put("valueRange", MapBuilder
                             .builder()
-                            .put("range", String.format("%s!A" + startRow + ":CH", sheetId) + (partition.size() + startRow - 1))
+                            .put("range", String.format("%s!A" + startRow + ":CI", sheetId) + (partition.size() + startRow - 1))
                             .put("values", partition)
                             .build())
                     .build(), httpHeaders);
@@ -624,38 +615,38 @@ public class DataDashboardService {
 
         List<Pair<String, String>> styles = Arrays
                 .asList(
-                        Pair.of("V", "#,##0.00"),
-                        Pair.of("AH", "#,##0.00"),
-                        Pair.of("AM", "#,##0.00"),
-                        Pair.of("BB", "#,##0.00"),
-                        Pair.of("BK", "#,##0.00"),
-                        Pair.of("F", "0.00%"),
-                        Pair.of("O", "0.00%"),
+                        Pair.of("W", "#,##0.00"),
+                        Pair.of("AI", "#,##0.00"),
+                        Pair.of("AN", "#,##0.00"),
+                        Pair.of("BC", "#,##0.00"),
+                        Pair.of("BL", "#,##0.00"),
+                        Pair.of("G", "0.00%"),
                         Pair.of("P", "0.00%"),
                         Pair.of("Q", "0.00%"),
                         Pair.of("R", "0.00%"),
-                        Pair.of("W", "0.00%"),
+                        Pair.of("S", "0.00%"),
                         Pair.of("X", "0.00%"),
                         Pair.of("Y", "0.00%"),
                         Pair.of("Z", "0.00%"),
-                        Pair.of("AE", "0.00%"),
+                        Pair.of("AA", "0.00%"),
                         Pair.of("AF", "0.00%"),
                         Pair.of("AG", "0.00%"),
-                        Pair.of("AN", "0.00%"),
+                        Pair.of("AH", "0.00%"),
                         Pair.of("AO", "0.00%"),
                         Pair.of("AP", "0.00%"),
                         Pair.of("AQ", "0.00%"),
-                        Pair.of("AV", "0.00%"),
+                        Pair.of("AR", "0.00%"),
                         Pair.of("AW", "0.00%"),
                         Pair.of("AX", "0.00%"),
-                        Pair.of("BC", "0.00%"),
+                        Pair.of("AY", "0.00%"),
                         Pair.of("BD", "0.00%"),
                         Pair.of("BE", "0.00%"),
                         Pair.of("BF", "0.00%"),
-                        Pair.of("BL", "0.00%"),
+                        Pair.of("BG", "0.00%"),
                         Pair.of("BM", "0.00%"),
                         Pair.of("BN", "0.00%"),
-                        Pair.of("BO", "0.00%")
+                        Pair.of("BO", "0.00%"),
+                        Pair.of("BP", "0.00%")
                 );
 
         doSendFeishuSheet(dateStrs, sheetToken, sheetId, rowNum, rows, 3, styles);
@@ -708,9 +699,13 @@ public class DataDashboardService {
         Map<String, Integer> scoreHisPublishTimeMap = new HashMap<>();
         Map<String, Map<Integer, List<String>>> titleTypePoolMap = new HashMap<>();
         Map<String, Set<String>> wxsnHisDistinctSetMap = new HashMap<>();
+        Map<String, List<String>> fansAccountTypeMap = new HashMap<>();
         for (NewSortStrategyExport data : newSortStrategyExportList) {
             String type = getArticleType(data, small);
             Article article = articleMap.get(data.getWxSn());
+            if (!checkIsAigcPublish(article, publishSortLogMap)) {
+                continue;
+            }
             IntermediateIndicatorsExport item = resultMap.get(type);
             List<Article> list = hisPublishMap.get(data.getTitle());
             list = list.stream().filter(publish -> publish.getUpdateTime() < (article.getUpdateTime() - 3600 * 8))
@@ -721,7 +716,8 @@ public class DataDashboardService {
             List<String> poolTitles = titlePoolMap.computeIfAbsent(poolLevel, k -> new ArrayList<>());
 
             // 发布情况
-            setPublishSituation(item, type, titleTypeMap, titleTypePoolMap, poolLevel, data);
+            setPublishSituation(item, type, titleTypeMap, titleTypePoolMap, poolLevel, article, fansAccountTypeMap,
+                    accountAvgInfoIndexMap);
             // 发布表现
             setPublishPerformance(item, data, publishSortLogMap);
             // 发布依赖表现
@@ -737,6 +733,37 @@ public class DataDashboardService {
         return result;
     }
 
+    private boolean checkIsAigcPublish(Article article,
+                                       Map<String, Map<String, Map<Integer, PublishSortLog>>> publishSortLogMap
+    ) {
+        String publishDateStr = DateUtils.timestampToYMDStr(article.getUpdateTime(), "yyyyMMdd");
+        Map<String, Map<Integer, PublishSortLog>> dateSortMap = publishSortLogMap.get(article.getGhId());
+        if (Objects.nonNull(dateSortMap)) {
+            Map<Integer, PublishSortLog> indexMap = dateSortMap.get(publishDateStr);
+            if (Objects.nonNull(indexMap)) {
+                PublishSortLog log = indexMap.get(article.getItemIndex());
+                return Objects.nonNull(log);
+            }
+        }
+        return false;
+    }
+
+    private AccountAvgInfo getAccountAvgInfo(Map<String, Map<String, Map<String, AccountAvgInfo>>> accountAvgInfoIndexMap,
+                                             String ghId, Long updateTime, Integer itemIndex) {
+        Map<String, Map<String, AccountAvgInfo>> dateAvgMap = accountAvgInfoIndexMap.get(ghId);
+        String hisPublishDate = DateUtils.timestampToYMDStr(updateTime, "yyyy-MM-dd");
+        AccountAvgInfo avgInfo = null;
+        if (Objects.nonNull(dateAvgMap)) {
+            List<String> avgMapDateList = new ArrayList<>(dateAvgMap.keySet());
+            hisPublishDate = DateUtils.findNearestDate(avgMapDateList, hisPublishDate, "yyyy-MM-dd");
+            Map<String, AccountAvgInfo> accountAvgInfoMap = dateAvgMap.get(hisPublishDate);
+            if (Objects.nonNull(accountAvgInfoMap)) {
+                avgInfo = accountAvgInfoMap.get(itemIndex.toString());
+            }
+        }
+        return avgInfo;
+    }
+
     private void setPublishFuturePerformance(IntermediateIndicatorsExport item, NewSortStrategyExport data, Integer poolLevel,
                                              Map<String, List<Article>> futurePublishMap,
                                              Map<String, Map<String, Map<Integer, PublishSortLog>>> publishSortLogMap,
@@ -889,17 +916,8 @@ public class DataDashboardService {
                     sumThirdFission2 += Optional.ofNullable(articleDetailInfo.getFission2()).orElse(0);
                 }
             }
-            Map<String, Map<String, AccountAvgInfo>> dateAvgMap = accountAvgInfoIndexMap.get(article.getGhId());
-            String hisPublishDate = DateUtils.timestampToYMDStr(article.getUpdateTime(), "yyyy-MM-dd");
-            AccountAvgInfo avgInfo = null;
-            if (Objects.nonNull(dateAvgMap)) {
-                List<String> avgMapDateList = new ArrayList<>(dateAvgMap.keySet());
-                hisPublishDate = DateUtils.findNearestDate(avgMapDateList, hisPublishDate, "yyyy-MM-dd");
-                Map<String, AccountAvgInfo> accountAvgInfoMap = dateAvgMap.get(hisPublishDate);
-                if (Objects.nonNull(accountAvgInfoMap)) {
-                    avgInfo = accountAvgInfoMap.get(article.getItemIndex().toString());
-                }
-            }
+            AccountAvgInfo avgInfo = getAccountAvgInfo(accountAvgInfoIndexMap, article.getGhId(),
+                    article.getUpdateTime(), article.getItemIndex());
             String date = DateUtils.timestampToYMDStr(article.getUpdateTime(), "yyyyMMdd");
             NewSortStrategyExport obj = new NewSortStrategyExport();
             obj.setGhId(article.getGhId());
@@ -976,17 +994,8 @@ public class DataDashboardService {
                     continue;
                 }
             }
-            Map<String, Map<String, AccountAvgInfo>> dateAvgMap = accountAvgInfoIndexMap.get(publish.getGhId());
-            String hisPublishDate = DateUtils.timestampToYMDStr(publish.getUpdateTime(), "yyyy-MM-dd");
-            AccountAvgInfo avgInfo = null;
-            if (Objects.nonNull(dateAvgMap)) {
-                List<String> avgMapDateList = new ArrayList<>(dateAvgMap.keySet());
-                hisPublishDate = DateUtils.findNearestDate(avgMapDateList, hisPublishDate, "yyyy-MM-dd");
-                Map<String, AccountAvgInfo> accountAvgInfoMap = dateAvgMap.get(hisPublishDate);
-                if (Objects.nonNull(accountAvgInfoMap)) {
-                    avgInfo = accountAvgInfoMap.get(publish.getItemIndex().toString());
-                }
-            }
+            AccountAvgInfo avgInfo = getAccountAvgInfo(accountAvgInfoIndexMap, publish.getGhId(),
+                    publish.getUpdateTime(), publish.getItemIndex());
             if (wxsnHisDistinctSet.contains(publish.getWxSn())) {
                 continue;
             }
@@ -1112,14 +1121,21 @@ public class DataDashboardService {
 
     private void setPublishSituation(IntermediateIndicatorsExport item, String type, Map<String, List<String>> titleTypeMap,
                                      Map<String, Map<Integer, List<String>>> titleTypePoolMap, Integer poolLevel,
-                                     NewSortStrategyExport data) {
+                                     Article article, Map<String, List<String>> fansAccountTypeMap,
+                                     Map<String, Map<String, Map<String, AccountAvgInfo>>> accountAvgInfoIndexMap) {
         item.setArticleReleaseSlot(item.getArticleReleaseSlot() + 1);
         item.setActualArticleReleaseCount(item.getActualArticleReleaseCount() + 1);
-        if (titleTypeMap.containsKey(type) && !titleTypeMap.get(type).contains(data.getTitle())) {
+        if (titleTypeMap.containsKey(type) && !titleTypeMap.get(type).contains(article.getTitle())) {
             item.setDistinctArticleReleaseCount(item.getDistinctArticleReleaseCount() + 1);
         }
         item.setDistinctArticleReleaseRatio(item.getDistinctArticleReleaseCount() / (double) item.getActualArticleReleaseCount());
-
+        List<String> ghIds = fansAccountTypeMap.computeIfAbsent(type, k -> new ArrayList<>());
+        if (!ghIds.contains(article.getGhId())) {
+            ghIds.add(article.getGhId());
+            AccountAvgInfo accountAvgInfo = getAccountAvgInfo(accountAvgInfoIndexMap, article.getGhId(),
+                    article.getUpdateTime(), article.getItemIndex());
+            item.setFansCount(item.getFansCount() + accountAvgInfo.getFans());
+        }
         if (4 == poolLevel) {
             item.setActualReleaseCountL4(item.getActualReleaseCountL4() + 1);
         } else if (3 == poolLevel) {
@@ -1131,7 +1147,7 @@ public class DataDashboardService {
         }
         if (titleTypePoolMap.containsKey(type)
                 && titleTypePoolMap.get(type).containsKey(poolLevel)
-                && !titleTypePoolMap.get(type).get(poolLevel).contains(data.getTitle())) {
+                && !titleTypePoolMap.get(type).get(poolLevel).contains(article.getTitle())) {
             if (4 == poolLevel) {
                 item.setDistinctReleaseCountL4(item.getDistinctReleaseCountL4() + 1);
             } else if (3 == poolLevel) {

+ 192 - 24
long-article-recommend-service/src/test/java/com/tzld/longarticle/recommend/server/RecommendTest.java

@@ -4,23 +4,30 @@ import cn.hutool.core.collection.CollectionUtil;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.google.common.collect.Lists;
-import com.tzld.longarticle.recommend.server.repository.crawler.AccountAvgInfoRepository;
-import com.tzld.longarticle.recommend.server.repository.crawler.ArticleDetailInfoRepository;
-import com.tzld.longarticle.recommend.server.repository.crawler.ArticleRepository;
+import com.tzld.longarticle.recommend.server.mapper.crawler.CrawlerBaseMapper;
 import com.tzld.longarticle.recommend.server.model.entity.crawler.AccountAvgInfo;
 import com.tzld.longarticle.recommend.server.model.entity.crawler.Article;
 import com.tzld.longarticle.recommend.server.model.entity.crawler.ArticleDetailInfo;
-import com.tzld.longarticle.recommend.server.mapper.crawler.CrawlerBaseMapper;
+import com.tzld.longarticle.recommend.server.model.entity.crawler.PublishSortLog;
+import com.tzld.longarticle.recommend.server.repository.crawler.AccountAvgInfoRepository;
+import com.tzld.longarticle.recommend.server.repository.crawler.ArticleDetailInfoRepository;
+import com.tzld.longarticle.recommend.server.repository.crawler.ArticleRepository;
+import com.tzld.longarticle.recommend.server.repository.crawler.PublishSortLogRepository;
 import com.tzld.longarticle.recommend.server.service.RecommendService;
 import com.tzld.longarticle.recommend.server.service.recall.RecallService;
+import com.tzld.longarticle.recommend.server.util.DateUtils;
+import org.apache.poi.ss.usermodel.Cell;
+import org.apache.poi.ss.usermodel.Row;
+import org.apache.poi.ss.usermodel.Sheet;
+import org.apache.poi.ss.usermodel.Workbook;
+import org.apache.poi.xssf.usermodel.XSSFWorkbook;
 import org.junit.jupiter.api.Test;
 import org.springframework.boot.test.context.SpringBootTest;
 
 import javax.annotation.Resource;
-import java.util.Date;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.util.*;
 import java.util.stream.Collectors;
 
 @SpringBootTest(classes = Application.class)
@@ -38,6 +45,8 @@ public class RecommendTest {
     private AccountAvgInfoRepository accountAvgInfoRepository;
     @Resource
     private CrawlerBaseMapper crawlerBaseMapper;
+    @Resource
+    private PublishSortLogRepository publishSortLogRepository;
 
 //    @Test
 //    void recall() {
@@ -169,11 +178,11 @@ public class RecommendTest {
 
     @Test
     public void test() {
-        List<String> morning = Lists.newArrayList("gh_d2cc901deca7", "gh_9e559b3b94ca", "gh_e75dbdc73d80", "gh_26a307578776", "gh_4568b5a7e2fe", "gh_5ff48e9fb9ef", "gh_6d9f36e3a7be", "gh_9f8dc5b0c74e", "gh_183d80deffb8", "gh_084a485e859a", "gh_7b4a5f86d68c", "gh_660afe87b6fd", "gh_1686250f15b6", "gh_03d45c260115", "gh_57c9e8babea7", "gh_2e615fa75ffb", "gh_98ec0ffe69b3", "gh_6d3aa9d13402", "gh_7c66e0dbd2cf", "gh_bfea052b5baa", "gh_749271f1ccd5", "gh_e0eb490115f5", "gh_d5f935d0d1f2", "gh_51e4ad40466d", "gh_30816d8adb52", "gh_4c058673c07e", "gh_789a40fe7935", "gh_970460d9ccec", "gh_03d32e83122f", "gh_adca24a8f429", "gh_3e91f0624545", "gh_0e4fd9e88386", "gh_93e00e187787", "gh_95ed5ecf9363", "gh_68e7fdc09fe4", "gh_ac43e43b253b", "gh_be8c29139989", "gh_77f36c109fb1", "gh_744cb16f6e16", "gh_ac43eb24376d", "gh_c91b42649690", "gh_57573f01b2ee", "gh_008ef23062ee", "gh_de9f9ebc976b", "gh_058e41145a0c", "gh_969f5ea5fee1", "gh_e24da99dc899");
-        List<String> moon = Lists.newArrayList("gh_a2901d34f75b", "gh_1ee2e1b39ccf", "gh_ee78360d06f5", "gh_192c9cf58b13", "gh_b676b7ad9b74", "gh_3ed305b5817f", "gh_ff487cb5dab3", "gh_89ef4798d3ea", "gh_7e5818b2dd83", "gh_72bace6b3059", "gh_6d205db62f04", "gh_56ca3dae948c", "gh_5ae65db96cb7", "gh_b15de7c99912", "gh_c5cdf60d9ab4", "gh_b6f2c5332c72", "gh_6b7c2a257263", "gh_9eef14ad6c16", "gh_1d887d61088c", "gh_f902cea89e48", "gh_dd4c857bbb36", "gh_0c89e11f8bf3", "gh_bff0bcb0694a", "gh_d4dffc34ac39", "gh_1b27dd1beeca", "gh_bfe5b705324a", "gh_080bb43aa0dc", "gh_6cfd1132df94", "gh_29074b51f2b7", "gh_c69776baf2cd", "gh_f25b5fb01977", "gh_9877c8541764", "gh_d49df5e974ca", "gh_7f5075624a50");
+        List<String> morning = Lists.newArrayList("gh_084a485e859a", "gh_183d80deffb8", "gh_5ff48e9fb9ef", "gh_6d9f36e3a7be", "gh_9f8dc5b0c74e", "gh_e0eb490115f5", "gh_e24da99dc899");
+        List<String> noon = Lists.newArrayList("gh_080bb43aa0dc", "gh_0c89e11f8bf3", "gh_192c9cf58b13", "gh_1b27dd1beeca", "gh_1d887d61088c", "gh_29074b51f2b7", "gh_3ed305b5817f", "gh_5ae65db96cb7", "gh_6b7c2a257263", "gh_6cfd1132df94", "gh_6d205db62f04", "gh_72bace6b3059", "gh_7e5818b2dd83", "gh_7f5075624a50", "gh_89ef4798d3ea", "gh_9877c8541764", "gh_9eef14ad6c16", "gh_a2901d34f75b", "gh_b15de7c99912", "gh_b676b7ad9b74", "gh_b6f2c5332c72", "gh_bfe5b705324a", "gh_bff0bcb0694a", "gh_c5cdf60d9ab4", "gh_c69776baf2cd", "gh_d49df5e974ca", "gh_d4dffc34ac39", "gh_dd4c857bbb36", "gh_ee78360d06f5", "gh_f25b5fb01977", "gh_f902cea89e48", "gh_ff487cb5dab3");
         String dateStr = "2024-09-12";
-        List<Article> articleList = articleRepository.getByUpdateTimeGreaterThanAndTypeEquals(1726070400L, "9");
-        articleList = articleList.stream().filter(o -> o.getItemIndex() == 1).collect(Collectors.toList());
+        List<Article> articleList = articleRepository.getByUpdateTimeGreaterThanAndTypeEquals(1725120000L, "9");
+        articleList = articleList.stream().filter(o -> o.getItemIndex() == 1 && o.getUpdateTime() < 1726675200).collect(Collectors.toList());
         Map<String, List<Article>> map = articleList.stream().collect(Collectors.groupingBy(Article::getTitle));
         List<AccountAvgInfo> accountAvgInfoList = accountAvgInfoRepository.getAllByUpdateTime(dateStr);
         accountAvgInfoList = accountAvgInfoList.stream().filter(o -> o.getPosition().equals("1")).collect(Collectors.toList());
@@ -183,8 +192,12 @@ public class RecommendTest {
         Map<String, List<ArticleDetailInfo>> articleDetailInfoMap = articleDetailInfoList.stream()
                 .collect(Collectors.groupingBy(ArticleDetailInfo::getWxSn));
         JSONArray result = new JSONArray();
-        int sumFission0Morning = 0;
-        int sumFission0Moon = 0;
+        int sumFissionMorning = 0;
+        int sumFissionMoon = 0;
+        int sumReadMorning = 0;
+        int sumReadNoon = 0;
+        long sumFansMorning = 0;
+        long sumFansMoon = 0;
         double readAvgMorning = 0.0;
         double readAvgMoon = 0.0;
         for (Article article : articleList) {
@@ -194,39 +207,194 @@ public class RecommendTest {
             }
             Date minDate = articleDetailInfos.stream().map(ArticleDetailInfo::getRecallDt).min(Date::compareTo).orElse(new Date());
             AccountAvgInfo accountAvgInfo = accountAvgInfoMap.get(article.getGhId());
-            int sumFission0 = 0;
             for (ArticleDetailInfo articleDetailInfo : articleDetailInfos) {
-                if (articleDetailInfo.getRecallDt().equals(minDate) && Objects.nonNull(articleDetailInfo.getFission0())) {
+                if (articleDetailInfo.getRecallDt().equals(minDate)) {
                     if (morning.contains(article.getGhId())) {
-                        sumFission0Morning += articleDetailInfo.getFission0();
+                        sumFissionMorning += Optional.ofNullable(articleDetailInfo.getFission0()).orElse(0);
+                        sumFissionMorning += Optional.ofNullable(articleDetailInfo.getFission1()).orElse(0);
+                        sumFissionMorning += Optional.ofNullable(articleDetailInfo.getFission2()).orElse(0);
                     }
-                    if (moon.contains(article.getGhId())) {
-                        sumFission0Moon += articleDetailInfo.getFission0();
+                    if (noon.contains(article.getGhId())) {
+                        sumFissionMoon += Optional.ofNullable(articleDetailInfo.getFission0()).orElse(0);
+                        sumFissionMoon += Optional.ofNullable(articleDetailInfo.getFission1()).orElse(0);
+                        sumFissionMoon += Optional.ofNullable(articleDetailInfo.getFission2()).orElse(0);
                     }
                 }
             }
             if (Objects.nonNull(accountAvgInfo)) {
                 if (morning.contains(article.getGhId())) {
                     readAvgMorning += accountAvgInfo.getReadAvg();
+                    sumFansMorning += accountAvgInfo.getFans();
+                    sumReadMorning += article.getShowViewCount();
                 }
-                if (moon.contains(article.getGhId())) {
+                if (noon.contains(article.getGhId())) {
                     readAvgMoon += accountAvgInfo.getReadAvg();
+                    sumFansMoon += accountAvgInfo.getFans();
+                    sumReadNoon += article.getShowViewCount();
                 }
             }
         }
         JSONObject jsonObjectMorning = new JSONObject();
         jsonObjectMorning.put("时间", "早上");
-        jsonObjectMorning.put("sumFission0", sumFission0Morning);
+        jsonObjectMorning.put("sumFission", sumFissionMorning);
         jsonObjectMorning.put("readAvg", readAvgMorning);
-        jsonObjectMorning.put("rate", sumFission0Morning/ readAvgMorning);
+        jsonObjectMorning.put("rate", sumFissionMorning / readAvgMorning);
+        jsonObjectMorning.put("sumRead", sumReadMorning);
+        jsonObjectMorning.put("sumFans", sumFansMorning);
+        jsonObjectMorning.put("阅读率", sumReadMorning / (double) sumFansMorning);
         result.add(jsonObjectMorning);
         JSONObject jsonObjectMoon = new JSONObject();
         jsonObjectMoon.put("时间", "中午");
-        jsonObjectMoon.put("sumFission0", sumFission0Moon);
+        jsonObjectMoon.put("sumFission", sumFissionMoon);
         jsonObjectMoon.put("readAvg", readAvgMoon);
-        jsonObjectMoon.put("rate", sumFission0Moon/ readAvgMoon);
+        jsonObjectMoon.put("rate", sumFissionMoon / readAvgMoon);
+        jsonObjectMoon.put("sumRead", sumReadNoon);
+        jsonObjectMoon.put("sumFans", sumFansMoon);
+        jsonObjectMoon.put("阅读率", sumReadNoon / (double) sumFansMoon);
         result.add(jsonObjectMoon);
         System.out.println(JSONObject.toJSONString(result));
     }
 
+    @Test
+    public void exportScoreData() {
+        List<String> ghIds = Lists.newArrayList("gh_e24da99dc899",
+                "gh_183d80deffb8",
+                "gh_be8c29139989",
+                "gh_c69776baf2cd",
+                "gh_b15de7c99912",
+                "gh_1d887d61088c",
+                "gh_3ed305b5817f",
+                "gh_3e91f0624545",
+                "gh_30816d8adb52",
+                "gh_970460d9ccec",
+                "gh_749271f1ccd5"
+        );
+        List<PublishSortLog> sortLogList = publishSortLogRepository.findByGhIdInAndDateStrGreaterThanEqual(ghIds, "20240907");
+        sortLogList = sortLogList.stream().filter(o -> o.getIndex() == 1).collect(Collectors.toList());
+        sortLogList.sort(Comparator.comparing(PublishSortLog::getGhId).thenComparing(PublishSortLog::getDateStr));
+        List<Article> articleList = articleRepository.getByGhIdInAndUpdateTimeGreaterThanAndTypeEquals(ghIds, 1725638400L, "9");
+        articleList = articleList.stream().filter(o -> o.getItemIndex() == 1).collect(Collectors.toList());
+        Map<String, Article> articleMap = articleList.stream().collect(Collectors.toMap(
+                o -> DateUtils.timestampToYMDStr(o.getUpdateTime(),"yyyyMMdd"), o -> o,
+                (existing, replacement) -> replacement));
+        List<AccountAvgInfo> accountAvgInfoList = accountAvgInfoRepository.getAllByGhIdIn(new HashSet<>(ghIds));
+        Map<String, Map<String, AccountAvgInfo>> accountAvgInfoMap = accountAvgInfoList.stream()
+                .filter(o -> Objects.equals(o.getPosition(), "1")).collect(Collectors.groupingBy(AccountAvgInfo::getGhId,
+                        Collectors.toMap(AccountAvgInfo::getUpdateTime, o -> o)));
+        Workbook workbook = new XSSFWorkbook();
+        Sheet sheet = workbook.createSheet("ExampleSheet");
+        int rowNum = 0;
+        // 创建标题行
+        Row titleRow = sheet.createRow(rowNum);
+        Cell titleCell = titleRow.createCell(0);
+        titleCell.setCellValue("日期");
+        titleCell = titleRow.createCell(1);
+        titleCell.setCellValue("ghID");
+        titleCell = titleRow.createCell(2);
+        titleCell.setCellValue("账号名称");
+        titleCell = titleRow.createCell(3);
+        titleCell.setCellValue("标题");
+        titleCell = titleRow.createCell(4);
+        titleCell.setCellValue("策略");
+        titleCell = titleRow.createCell(5);
+        titleCell.setCellValue("得分");
+        titleCell = titleRow.createCell(6);
+        titleCell.setCellValue("HisFissionFansRateRateStrategy");
+        titleCell = titleRow.createCell(7);
+        titleCell.setCellValue("HisFissionAvgReadRateRateStrategy");
+        titleCell = titleRow.createCell(8);
+        titleCell.setCellValue("PublishTimesStrategy");
+        titleCell = titleRow.createCell(9);
+        titleCell.setCellValue("ViewCountRateCorrelationStrategy");
+        titleCell = titleRow.createCell(10);
+        titleCell.setCellValue("HisFissionAvgReadSumRateStrategy");
+        titleCell = titleRow.createCell(11);
+        titleCell.setCellValue("HisFissionAvgReadRateCorrelationRateStrategy");
+        titleCell = titleRow.createCell(12);
+        titleCell.setCellValue("HisFissionFansSumRateStrategy");
+        titleCell = titleRow.createCell(13);
+        titleCell.setCellValue("SimilarityStrategy");
+        titleCell = titleRow.createCell(14);
+        titleCell.setCellValue("ViewCountStrategy");
+        titleCell = titleRow.createCell(15);
+        titleCell.setCellValue("ViewCountRateStrategy");
+        titleCell = titleRow.createCell(16);
+        titleCell.setCellValue("HisFissionDeWeightAvgReadSumRateStrategy");
+        titleCell = titleRow.createCell(17);
+        titleCell.setCellValue("阅读量");
+        titleCell = titleRow.createCell(18);
+        titleCell.setCellValue("阅读均值");
+        titleCell = titleRow.createCell(19);
+        titleCell.setCellValue("阅读均值倍数");
+
+        // 填充数据
+        for (PublishSortLog publishSortLog : sortLogList) {
+            rowNum++;
+            Row row = sheet.createRow(rowNum);
+            Cell cell = row.createCell(0);
+            cell.setCellValue(publishSortLog.getDateStr());
+            cell = row.createCell(1);
+            cell.setCellValue(publishSortLog.getGhId());
+            cell = row.createCell(2);
+            cell.setCellValue(publishSortLog.getAccountName());
+            cell = row.createCell(3);
+            cell.setCellValue(publishSortLog.getTitle());
+            cell = row.createCell(4);
+            cell.setCellValue(publishSortLog.getStrategy());
+            cell = row.createCell(5);
+            cell.setCellValue(publishSortLog.getScore());
+            cell = row.createCell(6);
+            JSONObject scoreMap = JSONObject.parseObject(publishSortLog.getScoreMap());
+            cell.setCellValue(String.format("%.3f", Optional.of(scoreMap.getDoubleValue("HisFissionFansRateRateStrategy")).orElse(0.0)));
+            cell = row.createCell(7);
+            cell.setCellValue(String.format("%.3f", Optional.of(scoreMap.getDoubleValue("HisFissionAvgReadRateRateStrategy")).orElse(0.0)));
+            cell = row.createCell(8);
+            cell.setCellValue(String.format("%.3f", Optional.of(scoreMap.getDoubleValue("PublishTimesStrategy")).orElse(0.0)));
+            cell = row.createCell(9);
+            cell.setCellValue(String.format("%.3f", Optional.of(scoreMap.getDoubleValue("ViewCountRateCorrelationStrategy")).orElse(0.0)));
+            cell = row.createCell(10);
+            cell.setCellValue(String.format("%.3f", Optional.of(scoreMap.getDoubleValue("HisFissionAvgReadSumRateStrategy")).orElse(0.0)));
+            cell = row.createCell(11);
+            cell.setCellValue(String.format("%.3f", Optional.of(scoreMap.getDoubleValue("HisFissionAvgReadRateCorrelationRateStrategy")).orElse(0.0)));
+            cell = row.createCell(12);
+            cell.setCellValue(String.format("%.3f", Optional.of(scoreMap.getDoubleValue("HisFissionFansSumRateStrategy")).orElse(0.0)));
+            cell = row.createCell(13);
+            cell.setCellValue(String.format("%.3f", Optional.of(scoreMap.getDoubleValue("SimilarityStrategy")).orElse(0.0)));
+            cell = row.createCell(14);
+            cell.setCellValue(String.format("%.3f", Optional.of(scoreMap.getDoubleValue("ViewCountStrategy")).orElse(0.0)));
+            cell = row.createCell(15);
+            cell.setCellValue(String.format("%.3f", Optional.of(scoreMap.getDoubleValue("ViewCountRateStrategy")).orElse(0.0)));
+            cell = row.createCell(16);
+            cell.setCellValue(String.format("%.3f", Optional.of(scoreMap.getDoubleValue("HisFissionDeWeightAvgReadSumRateStrategy")).orElse(0.0)));
+            Article article = articleMap.get(publishSortLog.getDateStr());
+            if (Objects.nonNull(article)) {
+                cell = row.createCell(17);
+                cell.setCellValue(article.getShowViewCount());
+                cell = row.createCell(18);
+                Map<String, AccountAvgInfo> map = accountAvgInfoMap.get(article.getGhId());
+                if (Objects.nonNull(map)) {
+                    AccountAvgInfo accountAvgInfo = map.get(DateUtils.timestampToYMDStr(article.getUpdateTime(), "yyyy-MM-dd"));
+                    if (Objects.nonNull(accountAvgInfo)) {
+                        cell.setCellValue(accountAvgInfo.getReadAvg());
+                        cell = row.createCell(19);
+                        cell.setCellValue(String.format("%.3f", article.getShowViewCount() / (double) accountAvgInfo.getReadAvg()));
+                    }
+                }
+            }
+
+        }
+
+        try (FileOutputStream outputStream = new FileOutputStream("/Users/wangyunpeng/Downloads/example.xlsx")) {
+            workbook.write(outputStream);
+        } catch (IOException e) {
+            e.printStackTrace();
+        } finally {
+            try {
+                workbook.close();
+            } catch (IOException e) {
+                e.printStackTrace();
+            }
+        }
+    }
+
 }