Просмотр исходного кода

视频内容池 相关内容字段查询

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

+ 3 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/longArticle/PublishSingleVideoSourceRepository.java

@@ -4,6 +4,9 @@ import com.tzld.longarticle.recommend.server.model.entity.longArticle.PublishSin
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.stereotype.Repository;
 
+import java.util.List;
+
 @Repository
 public interface PublishSingleVideoSourceRepository extends JpaRepository<PublishSingleVideoSource, Long> {
+    List<PublishSingleVideoSource> getByContentTraceIdIn(List<String> contentTraceIds);
 }

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

@@ -5,9 +5,11 @@ import com.google.common.collect.Lists;
 import com.tzld.longarticle.recommend.server.common.CostMonitor;
 import com.tzld.longarticle.recommend.server.common.ThreadPoolFactory;
 import com.tzld.longarticle.recommend.server.common.enums.StatusEnum;
+import com.tzld.longarticle.recommend.server.common.enums.aigc.PublishPlanInputSourceTypesEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.ArticleCategoryStatusEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.ArticlePoolPromotionSourceStatusEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.ArticleTypeEnum;
+import com.tzld.longarticle.recommend.server.common.enums.recommend.ContentPoolEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.FeishuRobotIdEnum;
 import com.tzld.longarticle.recommend.server.mapper.crawler.CrawlerBaseMapper;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
@@ -21,6 +23,7 @@ import com.tzld.longarticle.recommend.server.model.entity.crawler.ArticleDetailI
 import com.tzld.longarticle.recommend.server.model.entity.longArticle.AccountCategory;
 import com.tzld.longarticle.recommend.server.model.entity.longArticle.ArticleCategory;
 import com.tzld.longarticle.recommend.server.model.entity.longArticle.ArticlePoolPromotionSource;
+import com.tzld.longarticle.recommend.server.model.entity.longArticle.PublishSingleVideoSource;
 import com.tzld.longarticle.recommend.server.remote.aigc.AIGCWaitingPublishContentService;
 import com.tzld.longarticle.recommend.server.repository.aigc.CrawlerMetaArticleRepository;
 import com.tzld.longarticle.recommend.server.repository.aigc.PublishContentRepository;
@@ -31,6 +34,7 @@ import com.tzld.longarticle.recommend.server.repository.crawler.ArticleRepositor
 import com.tzld.longarticle.recommend.server.repository.longArticle.AccountCategoryRepository;
 import com.tzld.longarticle.recommend.server.repository.longArticle.ArticleCategoryRepository;
 import com.tzld.longarticle.recommend.server.repository.longArticle.ArticlePoolPromotionSourceRepository;
+import com.tzld.longarticle.recommend.server.repository.longArticle.PublishSingleVideoSourceRepository;
 import com.tzld.longarticle.recommend.server.service.recommend.config.AccountIndexAvgViewCountService;
 import com.tzld.longarticle.recommend.server.service.recommend.recall.strategy.DefaultRecallStrategy;
 import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreStrategy;
@@ -90,6 +94,8 @@ public class RecallService implements ApplicationContextAware {
     PublishContentRepository publishContentRepository;
     @Autowired
     AccountCategoryRepository accountCategoryRepository;
+    @Autowired
+    PublishSingleVideoSourceRepository publishSingleVideoSourceRepository;
 
     private final Map<String, RecallStrategy> strategyMap = new HashMap<>();
     private ApplicationContext applicationContext;
@@ -184,9 +190,35 @@ public class RecallService implements ApplicationContextAware {
         setTitleAvgViewCount(content, param.getGhId(), param.getType());
         long t4 = System.currentTimeMillis();
         CostMonitor.logCost("Recall", "SetAvgViewCount", t4 - t3);
+        // 视频内容池查询抓取时间
+        setVideoContent(content);
         return content;
     }
 
+    private void setVideoContent(List<Content> contentList) {
+        List<String> contentTraceIds = contentList.stream()
+                .filter(o -> PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal().equals(o.getSourceType()))
+                .map(Content::getSourceId).collect(Collectors.toList());
+        if (CollectionUtils.isEmpty(contentTraceIds)) {
+            return;
+        }
+        Map<String, Content> contentMap = contentList.stream()
+               .collect(Collectors.toMap(Content::getSourceId, Function.identity()));
+        List<PublishSingleVideoSource> sourceList = publishSingleVideoSourceRepository.getByContentTraceIdIn(contentTraceIds);
+        Map<String, PublishSingleVideoSource> sourceMap = sourceList.stream()
+              .collect(Collectors.toMap(PublishSingleVideoSource::getContentTraceId, Function.identity()));
+        for (String contentTraceId : contentTraceIds) {
+            Content content = contentMap.get(contentTraceId);
+            PublishSingleVideoSource source = sourceMap.get(contentTraceId);
+            if (Objects.isNull(source)) {
+                continue;
+            }
+            content.setCrawlerTimestamp(source.getCrawlerTimestamp());
+            ContentPoolEnum poolEnum = ContentPoolEnum.from(source.getFlowPoolLevel());
+            content.setContentPoolType(poolEnum.getContentPool());
+        }
+    }
+
     public void setContentCategory(List<Content> contentList) {
         List<String> channelContentIds = contentList.stream().map(Content::getCrawlerChannelContentId)
                 .collect(Collectors.toList());