Bläddra i källkod

Merge branch 'wyp/1218-hisCacheFix' of Server/long-article-recommend into master

wangyunpeng 6 månader sedan
förälder
incheckning
8399a50739

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

@@ -341,6 +341,13 @@ public class RecallService implements ApplicationContextAware {
             if (CollectionUtils.isEmpty(cacheList)) {
                 return;
             }
+            List<String> sourceIds = cacheList.stream().map(ArticleTitleHisCache::getSourceId).collect(Collectors.toList());
+            List<ArticleTitleHisCache> existsList = articleTitleHisCacheRepository.getBySourceIdInAndType(sourceIds, type);
+            Set<String> existsIds = existsList.stream().map(ArticleTitleHisCache::getSourceId).collect(Collectors.toSet());
+            cacheList = cacheList.stream().filter(o -> !existsIds.contains(o.getSourceId())).collect(Collectors.toList());
+            if (CollectionUtils.isEmpty(cacheList)) {
+                return;
+            }
             longArticleBaseMapper.batchInsertArticleTitleHisCache(cacheList);
         } catch (Exception e) {
             log.error("saveArticleTitleHisCache error:{}", e.getMessage());