wangyunpeng hai 9 meses
pai
achega
b90e247850

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

@@ -16,6 +16,8 @@ public class NewSortStrategyExport {
     private long fans;
     private Integer viewCount;
     private Double avgViewCount;
+    private Integer firstViewCount;
+    private Double firstAvgViewCount;
     private Integer firstLevel;
     private Integer fission0;
     private Integer fission1;

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

@@ -113,15 +113,15 @@ public class DataDashboardService {
 
         List<Pair<String, String>> styles = Arrays
                 .asList(
-                        Pair.of("P", "0.00%"),
-                        Pair.of("Q", "0.00%"),
                         Pair.of("R", "0.00%"),
                         Pair.of("S", "0.00%"),
                         Pair.of("T", "0.00%"),
                         Pair.of("U", "0.00%"),
-                        Pair.of("AA", "0.00%"),
-                        Pair.of("AB", "0.00%"),
-                        Pair.of("AC", "0.00%")
+                        Pair.of("V", "0.00%"),
+                        Pair.of("W", "0.00%"),
+                        Pair.of("AC", "0.00%"),
+                        Pair.of("AD", "0.00%"),
+                        Pair.of("AE", "0.00%")
                 );
 
         doSendFeishuSheet(dateStrList, sheetToken, sheetId, rowNum, rows, 2, styles);
@@ -132,6 +132,8 @@ public class DataDashboardService {
         List<AccountAvgInfo> accountAvgInfoList = accountAvgInfoRepository.getAllByStatusEquals(1);
         Set<String> ghIds = accountAvgInfoList.stream().map(AccountAvgInfo::getGhId).collect(Collectors.toSet());
         List<Article> articleList = articleRepository.getByGhIdInAndUpdateTimeGreaterThan(ghIds, timestamp);
+        Map<String, Map<String, Map<Integer, Article>>> articleMap = articleList.stream().collect(Collectors.groupingBy(Article::getGhId,
+                Collectors.groupingBy(Article::getAppMsgId, Collectors.toMap(Article::getItemIndex, o -> o))));
 
         Set<String> snList = articleList.stream().map(Article::getWxSn).collect(Collectors.toSet());
         List<ArticleDetailInfo> articleDetailInfoList = articleDetailInfoRepository.getAllByWxSnIn(new ArrayList<>(snList));
@@ -150,6 +152,7 @@ public class DataDashboardService {
             if (CollectionUtils.isEmpty(articleDetailInfos)) {
                 continue;
             }
+            Article firstArticle = articleMap.get(article.getGhId()).get(article.getAppMsgId()).get(1);
             Map<String, String> dateStrategy = sortStrategyMap.get(article.getGhId());
             Date minDate = articleDetailInfos.stream().map(ArticleDetailInfo::getRecallDt).min(Date::compareTo).orElse(new Date());
             int sumfirstLevel = 0;
@@ -166,8 +169,10 @@ public class DataDashboardService {
             }
             Map<String, AccountAvgInfo> accountAvgInfoMap = accountAvgInfoIndexMap.get(article.getGhId());
             AccountAvgInfo avgInfo = null;
+            AccountAvgInfo firstAvgInfo = null;
             if (Objects.nonNull(accountAvgInfoMap)) {
                 avgInfo = accountAvgInfoMap.get(article.getItemIndex().toString());
+                firstAvgInfo = accountAvgInfoMap.get("1");
             }
             String date = DateUtils.timestampToYMDStr(article.getUpdateTime(), "yyyyMMdd");
             NewSortStrategyExport obj = new NewSortStrategyExport();
@@ -184,6 +189,12 @@ public class DataDashboardService {
             obj.setFission1(sumFission1);
             obj.setFission2(sumFission2);
             obj.setWxSn(article.getWxSn());
+            if (Objects.nonNull(firstArticle)) {
+                obj.setFirstViewCount(firstArticle.getShowViewCount());
+            }
+            if (Objects.nonNull(firstAvgInfo)) {
+                obj.setFirstAvgViewCount(firstAvgInfo.getReadAvg());
+            }
             if (Objects.nonNull(dateStrategy)) {
                 obj.setStrategy(dateStrategy.get(date));
             }