wangyunpeng 3 месяцев назад
Родитель
Сommit
d15f732cb4

+ 4 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/XxlJobService.java

@@ -814,12 +814,15 @@ public class XxlJobService {
                 Content content = articlesWithHistory.get(sourceId);
                 if (Objects.nonNull(content) && CollectionUtils.isNotEmpty(content.getHisPublishArticleList())) {
                     ArticleTitleHisCache cache = sourceIdToCacheMap.get(sourceId);
-                    cache.setHisPublishArticleList(JSONObject.toJSONString(content.getHisPublishArticleList()));
+                    if (CollectionUtil.isNotEmpty(content.getHisPublishArticleList())) {
+                        cache.setHisPublishArticleList(JSONObject.toJSONString(content.getHisPublishArticleList()));
+                    }
                     if (CollectionUtil.isNotEmpty(content.getCategory())) {
                         cache.setCategory(JSONObject.toJSONString(content.getCategory()));
                     }
                     cache.setKimiSafeScore(content.getKimiSafeScore());
                     cache.setPlanId(content.getProducePlanId());
+                    cache.setRootPublishTimestamp(content.getRootPublishTimestamp());
                     cache.setUpdateTimestamp(System.currentTimeMillis());
                     articleTitleHisCacheRepository.save(cache);
                 }

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

@@ -361,7 +361,6 @@ public class RecallService implements ApplicationContextAware {
             cacheParam.setCategory(content.getCategory());
             return cacheParam;
         }).collect(Collectors.toList());
-        Map<String, Content> articlesWithHistory = getArticleWithHistory(paramList, type);
         List<Content> newCacheSaveList = new ArrayList<>();
         Set<String> newCacheSourceIdSet = new HashSet<>();
         for (Content content : contentList) {
@@ -380,21 +379,7 @@ public class RecallService implements ApplicationContextAware {
                 content.setRootPublishTimestamp(cache.getRootPublishTimestamp());
                 content.setHisPublishArticleList(hisPublishArticleList);
                 setT0Data(content, ghId);
-                continue;
-            }
-            if (articlesWithHistory.containsKey(content.getSourceId())) {
-                Content articleWithHistory = articlesWithHistory.get(content.getSourceId());
-                content.setHisPublishArticleList(articleWithHistory.getHisPublishArticleList());
-                if (CollectionUtils.isNotEmpty(articleWithHistory.getCategory())) {
-                    content.setCategory(articleWithHistory.getCategory());
-                }
-                content.setProducePlanId(articleWithHistory.getProducePlanId());
-                content.setKimiSafeScore(articleWithHistory.getKimiSafeScore());
-                content.setRootPublishTimestamp(articleWithHistory.getRootPublishTimestamp());
-                for (ContentHisPublishArticle article : content.getHisPublishArticleList()) {
-                    article.setCorrelation(Optional.ofNullable(accountCorrelationMap.get(article.getGhId())).orElse(0.0));
-                }
-                setT0Data(content, ghId);
+            } else {
                 if (!newCacheSourceIdSet.contains(content.getSourceId())) {
                     newCacheSaveList.add(content);
                     newCacheSourceIdSet.add(content.getSourceId());
@@ -413,9 +398,6 @@ public class RecallService implements ApplicationContextAware {
         List<ArticleTitleHisCache> cacheList = new ArrayList<>();
         try {
             for (Content content : saveList) {
-                if (CollectionUtils.isEmpty(content.getHisPublishArticleList())) {
-                    continue;
-                }
                 ArticleTitleHisCache cache = new ArticleTitleHisCache();
                 BeanUtils.copyProperties(content, cache);
                 cache.setType(type);
@@ -425,13 +407,12 @@ public class RecallService implements ApplicationContextAware {
                     cache.setCategory(JSONObject.toJSONString(content.getCategory()));
                 }
                 cache.setRootPublishTimestamp(content.getRootPublishTimestamp());
-                cache.setHisPublishArticleList(JSONObject.toJSONString(content.getHisPublishArticleList()));
+                if (CollectionUtils.isNotEmpty(content.getHisPublishArticleList())) {
+                    cache.setHisPublishArticleList(JSONObject.toJSONString(content.getHisPublishArticleList()));
+                }
                 cache.setCreateTimestamp(System.currentTimeMillis());
                 cacheList.add(cache);
             }
-            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());