wangyunpeng vor 8 Monaten
Ursprung
Commit
cfa49fabe4

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

@@ -191,15 +191,17 @@ public class RecallService implements ApplicationContextAware {
         // 根据produceContentId查询category
         List<ArticleCategory> articleCategoryList = articleCategoryRepository.getByProduceContentIdIn(produceContentIds);
         Map<String, ArticleCategory> categoryMap = articleCategoryList.stream().collect(Collectors.toMap(ArticleCategory::getProduceContentId, Function.identity()));
-        contentList.forEach(content -> {
+        for (Content content : contentList) {
             ArticlePoolPromotionSource source = sourceMap.get(content.getCrawlerChannelContentId());
             if (Objects.nonNull(source) && Objects.nonNull(source.getRootProduceContentId())) {
                 ArticleCategory category = categoryMap.get(source.getRootProduceContentId());
                 if (Objects.nonNull(category)) {
                     content.setCategory(Collections.singletonList(category.getCategory()));
+                    continue;
                 }
             }
-        });
+            log.error("setContentCategory NullError channelContentId:{}", content.getCrawlerChannelContentId());
+        }
     }
 
     private List<CrawlerMetaArticle> getByUniqueIndexIn(List<String> md5List) {

+ 2 - 2
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/score/strategy/CategoryStrategy.java

@@ -46,7 +46,7 @@ public class CategoryStrategy implements ScoreStrategy {
         if (Objects.isNull(accountCategory) || !StringUtils.hasText(accountCategory.getCategoryMap())) {
             return scores;
         }
-        Map<String, Double> categoryWeightMap = JSONObject.parseObject(accountCategory.getCategoryMap()).toJavaObject(HashMap.class);
+        JSONObject categoryWeightMap = JSONObject.parseObject(accountCategory.getCategoryMap());
         for (Content content : param.getContents()) {
             if (CollectionUtils.isEmpty(content.getCategory())) {
                 continue;
@@ -59,7 +59,7 @@ public class CategoryStrategy implements ScoreStrategy {
                 if (!categoryWeightMap.containsKey(category)) {
                     continue;
                 }
-                scoreValue += categoryWeightMap.get(category);
+                scoreValue += categoryWeightMap.getDoubleValue(category);
             }
             score.setScore(scoreValue);
             scores.add(score);