ソースを参照

修复历史缓存

wangyunpeng 7 ヶ月 前
コミット
19b438e13a

+ 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());