소스 검색

获取待发布内容抽取

wangyunpeng 11 달 전
부모
커밋
2500814956

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

@@ -1,7 +1,10 @@
 package com.tzld.longarticle.recommend.server.service.recall;
 
+import com.tzld.longarticle.recommend.server.model.Content;
 import lombok.Data;
 
+import java.util.List;
+
 /**
  * @author dyp
  */
@@ -13,4 +16,5 @@ public class RecallParam {
     private String planId;
     private String strategy;
     private String ghId;
+    private List<Content> content;
 }

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

@@ -3,6 +3,7 @@ package com.tzld.longarticle.recommend.server.service.recall;
 import com.tzld.longarticle.recommend.server.common.ThreadPoolFactory;
 import com.tzld.longarticle.recommend.server.model.Content;
 import com.tzld.longarticle.recommend.server.model.ContentHisPublishArticle;
+import com.tzld.longarticle.recommend.server.remote.AIGCRemoteService;
 import com.tzld.longarticle.recommend.server.repository.aigc.CrawlerMetaArticleRepository;
 import com.tzld.longarticle.recommend.server.repository.crawler.ArticleRepository;
 import com.tzld.longarticle.recommend.server.repository.entity.aigc.CrawlerMetaArticle;
@@ -39,6 +40,8 @@ public class RecallService implements ApplicationContextAware {
     ArticleRepository articleRepository;
     @Autowired
     CrawlerMetaArticleRepository crawlerMetaArticleRepository;
+    @Autowired
+    private AIGCRemoteService aigcRemoteService;
 
     private final Map<String, RecallStrategy> strategyMap = new HashMap<>();
     private ApplicationContext applicationContext;
@@ -58,6 +61,8 @@ public class RecallService implements ApplicationContextAware {
         List<RecallStrategy> strategies = getRecallStrategy(param);
         log.info("RecallStrategy {}", JSONUtils.toJson(CommonCollectionUtils.toList(strategies,
                 s -> s.getClass().getSimpleName())));
+        List<Content> content = getAllContent(param);
+        param.setContent(content);
         CountDownLatch cdl = new CountDownLatch(strategies.size());
         List<Future<RecallResult.RecallData>> recallResultFutures = new ArrayList<>();
         for (final RecallStrategy strategy : strategies) {
@@ -102,6 +107,15 @@ public class RecallService implements ApplicationContextAware {
         this.applicationContext = applicationContext;
     }
 
+    private List<Content> getAllContent(RecallParam param) {
+        List<Content> content = aigcRemoteService.getAllContent(param);
+        // 标题历史均值
+        setTitleAvgViewCount(content);
+        // category 查询
+        setContentCategory(content);
+        return content;
+    }
+
     public void setContentCategory(List<Content> contentList) {
         long start = System.currentTimeMillis();
         List<String> channelContentIds = contentList.stream().map(Content::getCrawlerChannelContentId).collect(Collectors.toList());

+ 1 - 9
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recall/strategy/ColdStartBackupRecallStrategy.java

@@ -1,7 +1,6 @@
 package com.tzld.longarticle.recommend.server.service.recall.strategy;
 
 import com.tzld.longarticle.recommend.server.model.Content;
-import com.tzld.longarticle.recommend.server.remote.AIGCRemoteService;
 import com.tzld.longarticle.recommend.server.service.filter.FilterParam;
 import com.tzld.longarticle.recommend.server.service.filter.FilterResult;
 import com.tzld.longarticle.recommend.server.service.filter.FilterService;
@@ -23,18 +22,11 @@ public class ColdStartBackupRecallStrategy implements RecallStrategy {
     @Autowired
     private FilterService filterService;
     @Autowired
-    private AIGCRemoteService aigcRemoteService;
-    @Autowired
     RecallService recallService;
 
     @Override
     public RecallResult.RecallData recall(RecallParam param) {
-
-        List<Content> content = aigcRemoteService.getAllContent(param);
-        // 标题历史均值
-        recallService.setTitleAvgViewCount(content);
-        // category 查询
-        recallService.setContentCategory(content);
+        List<Content> content = param.getContent();
         // 处理 content
         FilterParam filterParam = FilterParamFactory.create(param, content);
         filterParam.setBackup(true);

+ 1 - 13
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recall/strategy/DefaultRecallStrategy.java

@@ -1,19 +1,14 @@
 package com.tzld.longarticle.recommend.server.service.recall.strategy;
 
 import com.tzld.longarticle.recommend.server.model.Content;
-import com.tzld.longarticle.recommend.server.remote.AIGCRemoteService;
-import com.tzld.longarticle.recommend.server.repository.mapper.crawler.CrawlerBaseMapper;
 import com.tzld.longarticle.recommend.server.service.filter.FilterParam;
 import com.tzld.longarticle.recommend.server.service.filter.FilterResult;
 import com.tzld.longarticle.recommend.server.service.filter.FilterService;
 import com.tzld.longarticle.recommend.server.service.recall.*;
-import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
-import java.util.ArrayList;
 import java.util.List;
-import java.util.Map;
 import java.util.stream.Collectors;
 
 /**
@@ -25,18 +20,11 @@ public class DefaultRecallStrategy implements RecallStrategy {
     @Autowired
     private FilterService filterService;
     @Autowired
-    private AIGCRemoteService aigcRemoteService;
-    @Autowired
     RecallService recallService;
 
     @Override
     public RecallResult.RecallData recall(RecallParam param) {
-
-        List<Content> content = aigcRemoteService.getAllContent(param);
-        // 标题历史均值
-        recallService.setTitleAvgViewCount(content);
-        // category 查询
-        recallService.setContentCategory(content);
+        List<Content> content = param.getContent();
         // 处理 content
         FilterParam filterParam = FilterParamFactory.create(param, content);
         FilterResult filterResult = filterService.filter(filterParam);