Parcourir la source

Merge branch 'wyp/1216-bugFix' of Server/long-article-recommend into master

wangyunpeng il y a 7 mois
Parent
commit
ba126b3ff8

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

@@ -389,18 +389,22 @@ public class RecallService implements ApplicationContextAware {
 
         // 获取品类
         List<String> channelContentIds = paramList.stream().map(TitleHisCacheParam::getCrawlerChannelContentId)
-                .collect(Collectors.toList());
+                .filter(StringUtils::hasText).collect(Collectors.toList());
         // 查询晋升rootProduceContentId
-        List<ArticlePoolPromotionSource> sourceList = articlePoolPromotionSourceRepository
-                .getByChannelContentIdInAndStatusAndDeleted(channelContentIds,
-                        ArticlePoolPromotionSourceStatusEnum.FINISH.getCode(), 0);
-        Map<String, ArticlePoolPromotionSource> sourceMap = sourceList.stream()
-                .collect(Collectors.toMap(ArticlePoolPromotionSource::getChannelContentId, Function.identity()));
-        List<String> publishContentIds = sourceList.stream().
-                map(ArticlePoolPromotionSource::getRootPublishContentId).collect(Collectors.toList());
-        List<PublishContent> publishContentList = publishContentRepository.getByIdIn(publishContentIds);
-        Map<String, PublishContent> publishContentMap = publishContentList.stream()
-                .collect(Collectors.toMap(PublishContent::getId, Function.identity()));
+        Map<String, ArticlePoolPromotionSource> sourceMap = new HashMap<>();
+        Map<String, PublishContent> publishContentMap = new HashMap<>();
+        if (CollectionUtils.isNotEmpty(channelContentIds)) {
+            List<ArticlePoolPromotionSource> sourceList = articlePoolPromotionSourceRepository
+                    .getByChannelContentIdInAndStatusAndDeleted(channelContentIds,
+                            ArticlePoolPromotionSourceStatusEnum.FINISH.getCode(), 0);
+            sourceMap = sourceList.stream()
+                    .collect(Collectors.toMap(ArticlePoolPromotionSource::getChannelContentId, Function.identity()));
+            List<String> publishContentIds = sourceList.stream().
+                    map(ArticlePoolPromotionSource::getRootPublishContentId).collect(Collectors.toList());
+            List<PublishContent> publishContentList = publishContentRepository.getByIdIn(publishContentIds);
+            publishContentMap = publishContentList.stream()
+                    .collect(Collectors.toMap(PublishContent::getId, Function.identity()));
+        }
         // 根据produceContentId查询category
         List<ArticleCategory> articleCategoryList = articleCategoryRepository.getByStatus(ArticleCategoryStatusEnum.SUCCESS.getCode());
         Map<String, ArticleCategory> categoryMap = articleCategoryList.stream()