Bladeren bron

Merge branch 'wyp/0418-fix' of Server/long-article-recommend into master

wangyunpeng 6 dagen geleden
bovenliggende
commit
c15f324cbb

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

@@ -449,9 +449,8 @@ public class RecallService implements ApplicationContextAware {
         Set<String> appMsgIds = hisArticleList.stream().map(Article::getAppMsgId).collect(Collectors.toSet());
         List<Article> firstIndexHisArticleList = articleMapper.getByGhIdInAndAppMsgIdInAndItemIndexAndTypeEqualsAndStatusEquals(
                 ghIds, appMsgIds, 1, type, 1);
-        Map<String, Map<String, Map<String, Article>>> firstIndexHisArticleMap = firstIndexHisArticleList.stream()
-                .collect(Collectors.groupingBy(Article::getGhId, Collectors.groupingBy(Article::getAppMsgId,
-                        Collectors.toMap(Article::getTitle, o -> o, (a, b) -> a))));
+        Map<String, Map<String, Article>> firstIndexHisArticleMap = firstIndexHisArticleList.stream()
+                .collect(Collectors.groupingBy(Article::getGhId, Collectors.toMap(Article::getAppMsgId, o -> o, (a, b) -> a)));
         // 获取发布账号 位置历史均值
         List<AccountAvgInfo> accountAvgInfoList = crawlerBaseMapper.getAllByGhIdIn(ghIds);
         Map<String, Map<String, Map<String, AccountAvgInfo>>> accountAvgInfoIndexMap = accountAvgInfoList.stream()
@@ -632,16 +631,13 @@ public class RecallService implements ApplicationContextAware {
                         article.setFans(firstIndexAvgInfo.getFans());
                     }
                 }
-                Map<String, Map<String, Article>> firstIndexArticle = firstIndexHisArticleMap.get(hisArticle.getGhId());
+                Map<String, Article> firstIndexArticle = firstIndexHisArticleMap.get(hisArticle.getGhId());
                 if (Objects.nonNull(firstIndexArticle) && firstIndexArticle.containsKey(hisArticle.getAppMsgId())) {
-                    Map<String, Article> firstAppMsgIdArticle = firstIndexArticle.get(hisArticle.getAppMsgId());
-                    if (Objects.nonNull(firstAppMsgIdArticle) && firstAppMsgIdArticle.containsKey(hisArticle.getTitle())) {
-                        Article firstArticle = firstAppMsgIdArticle.get(hisArticle.getTitle());
-                        article.setFirstViewCount(firstArticle.getShowViewCount());
-                        if (Objects.nonNull(firstIndexAvgInfo) && Objects.nonNull(firstIndexAvgInfo.getReadAvg())
-                                && firstIndexAvgInfo.getReadAvg() > 0 && Objects.nonNull(firstArticle.getShowViewCount())) {
-                            article.setFirstViewCountRate((firstArticle.getShowViewCount() * 1.0) / firstIndexAvgInfo.getReadAvg());
-                        }
+                    Article firstArticle = firstIndexArticle.get(hisArticle.getAppMsgId());
+                    article.setFirstViewCount(firstArticle.getShowViewCount());
+                    if (Objects.nonNull(firstIndexAvgInfo) && Objects.nonNull(firstIndexAvgInfo.getReadAvg())
+                            && firstIndexAvgInfo.getReadAvg() > 0 && Objects.nonNull(firstArticle.getShowViewCount())) {
+                        article.setFirstViewCountRate((firstArticle.getShowViewCount() * 1.0) / firstIndexAvgInfo.getReadAvg());
                     }
                 }
                 res.getHisPublishArticleList().add(article);