wangyunpeng 3 mesi fa
parent
commit
91a2d03831

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

@@ -473,8 +473,9 @@ 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, Article>> firstIndexHisArticleMap = firstIndexHisArticleList.stream()
-                .collect(Collectors.groupingBy(Article::getGhId, Collectors.toMap(Article::getAppMsgId, o -> o, (a, b) -> a)));
+        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))));
         // 获取发布账号 位置历史均值
         List<AccountAvgInfo> accountAvgInfoList = crawlerBaseMapper.getAllByGhIdIn(ghIds);
         Map<String, Map<String, Map<String, AccountAvgInfo>>> accountAvgInfoIndexMap = accountAvgInfoList.stream()
@@ -519,14 +520,14 @@ public class RecallService implements ApplicationContextAware {
         // 获取生成计划
         List<ProducePlanExeRecord> planExeRecordList = producePlanExeRecordRepository.findByPlanExeIdIn(sourceIds);
         Map<String, ProducePlanExeRecord> planExeRecordMap = planExeRecordList.stream()
-               .collect(Collectors.toMap(ProducePlanExeRecord::getPlanExeId, Function.identity()));
+                .collect(Collectors.toMap(ProducePlanExeRecord::getPlanExeId, Function.identity()));
         // 根据sourceId查询kimiSafeScore
         List<ProduceTaskAtom> safeScoreList = aigcBaseMapper.getProduceScoreByContentId(sourceIds);
         Map<String, ProduceTaskAtom> safeScoreMap = safeScoreList.stream().filter(o -> StringUtils.hasText(o.getOutput()))
-               .collect(Collectors.toMap(ProduceTaskAtom::getPlanExeId, o -> o));
+                .collect(Collectors.toMap(ProduceTaskAtom::getPlanExeId, o -> o));
         List<Account> accountList = accountRepository.getByStatus(1);
         Map<String, Account> accountMap = accountList.stream()
-              .collect(Collectors.toMap(Account::getGhId, Function.identity()));
+                .collect(Collectors.toMap(Account::getGhId, Function.identity()));
 
         for (TitleHisCacheParam cacheParam : paramList) {
             Content res = new Content();
@@ -655,13 +656,16 @@ public class RecallService implements ApplicationContextAware {
                         article.setFans(firstIndexAvgInfo.getFans());
                     }
                 }
-                Map<String, Article> firstIndexArticle = firstIndexHisArticleMap.get(hisArticle.getGhId());
+                Map<String, Map<String, Article>> firstIndexArticle = firstIndexHisArticleMap.get(hisArticle.getGhId());
                 if (Objects.nonNull(firstIndexArticle) && firstIndexArticle.containsKey(hisArticle.getAppMsgId())) {
-                    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());
+                    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());
+                        }
                     }
                 }
                 res.getHisPublishArticleList().add(article);