wangyunpeng 7 ماه پیش
والد
کامیت
c62a6de321

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

@@ -281,8 +281,8 @@ public class RecallService implements ApplicationContextAware {
                 .filter(o -> Objects.nonNull(o.getReadAvg()) && o.getReadAvg() > 0 && o.getFans() > 1000)
                 .collect(Collectors.groupingBy(AccountAvgInfo::getGhId, Collectors.toMap(AccountAvgInfo::getUpdateTime, o -> o)));
         List<AccountCategory> accountCategoryList = accountCategoryRepository.getByStatus(StatusEnum.ONE.getCode());
-        Map<String, AccountCategory> accountCategoryMap = accountCategoryList.stream()
-                .collect(Collectors.toMap(AccountCategory::getGhId, Function.identity()));
+        Map<String, JSONObject> accountCategoryMap = accountCategoryList.stream().filter(o -> StringUtils.hasText(o.getCategoryMap()))
+                .collect(Collectors.toMap(AccountCategory::getGhId, o -> JSONObject.parseObject(o.getCategoryMap())));
         for (Content content : contentList) {
             List<Article> hisArticles = new ArrayList<>();
             Map<Integer, List<Article>> indexArticleMap = map.get(content.getTitle());
@@ -314,16 +314,13 @@ public class RecallService implements ApplicationContextAware {
                     continue;
                 }
                 // 历史表现 文章品类如果与历史发布账号负相关 则过滤,不计算该历史发布表现
-                AccountCategory accountCategory = accountCategoryMap.get(hisArticle.getGhId());
-                if (Objects.nonNull(accountCategory) && StringUtils.hasText(accountCategory.getCategoryMap())) {
-                    JSONObject categoryWeightMap = JSONObject.parseObject(accountCategory.getCategoryMap());
-                    if (Objects.nonNull(categoryWeightMap) && CollectionUtils.isNotEmpty(content.getCategory())) {
-                        String category = content.getCategory().get(0);
-                        if (categoryWeightMap.containsKey(category)) {
-                            double weight = categoryWeightMap.getDoubleValue(category);
-                            if (weight < 0) {
-                                continue;
-                            }
+                JSONObject categoryWeightMap = accountCategoryMap.get(hisArticle.getGhId());
+                if (Objects.nonNull(categoryWeightMap) && CollectionUtils.isNotEmpty(content.getCategory())) {
+                    String category = content.getCategory().get(0);
+                    if (categoryWeightMap.containsKey(category)) {
+                        double weight = categoryWeightMap.getDoubleValue(category);
+                        if (weight < 0) {
+                            continue;
                         }
                     }
                 }