Преглед на файлове

召回内容增加视频内容库,排序策略可指定发送内容库来源

wangyunpeng преди 7 месеца
родител
ревизия
13a951184f
променени са 20 файла, в които са добавени 249 реда и са изтрити 58 реда
  1. 40 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/common/enums/aigc/PublishPlanInputSourceTypesEnum.java
  2. 16 6
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/common/enums/recommend/ContentPoolEnum.java
  3. 1 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/dto/Content.java
  4. 1 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/vo/ArticleSortResponseDataItem.java
  5. 61 9
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/RankService.java
  6. 16 3
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/HisJumpRankStrategy.java
  7. 3 9
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/InfiniteRankStrategy.java
  8. 3 9
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/LateRankStrategy.java
  9. 17 4
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RandomRankStrategy.java
  10. 8 1
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV10Strategy.java
  11. 8 1
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV11Strategy.java
  12. 8 1
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV12Strategy.java
  13. 8 1
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV13Strategy.java
  14. 8 1
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV14Strategy.java
  15. 12 8
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV3Strategy.java
  16. 8 1
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV4Strategy.java
  17. 7 1
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV5Strategy.java
  18. 8 1
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV7Strategy.java
  19. 8 1
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV8Strategy.java
  20. 8 1
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV9Strategy.java

+ 40 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/common/enums/aigc/PublishPlanInputSourceTypesEnum.java

@@ -0,0 +1,40 @@
+package com.tzld.longarticle.recommend.server.common.enums.aigc;
+
+import lombok.Getter;
+
+import java.util.Objects;
+
+@Getter
+public enum PublishPlanInputSourceTypesEnum {
+    producePlan(1, "生成计划"),
+    produceContent(2, "单个生成内容"),
+    crawlerPlan(3, "抓取计划"),
+    crawlerContent(4, "单个抓取内容"),
+    publishPlan(5, "发布计划"),
+    publishContent(6, "单个发布内容"),
+    pretreatPlan(7, "处理计划"),
+    pretreatContent(8, "单个处理内容"),
+    monitor_plan_query_contents(9, "监控计划查找输入源"),
+    template(10, "评论/私信模板"),
+    monitor_plan(11, "监控计划内容"),
+    longArticleVideoPoolSource(12, "长文视频池内容"),
+    other(999, ""),
+    ;
+
+    private final Integer val;
+    private final String description;
+
+    PublishPlanInputSourceTypesEnum(Integer val, String description) {
+        this.val = val;
+        this.description = description;
+    }
+
+    public static PublishPlanInputSourceTypesEnum from(Integer val) {
+        for (PublishPlanInputSourceTypesEnum typesEnum : PublishPlanInputSourceTypesEnum.values()) {
+            if (Objects.equals(typesEnum.val, val)) {
+                return typesEnum;
+            }
+        }
+        return null;
+    }
+}

+ 16 - 6
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/common/enums/recommend/ContentPoolEnum.java

@@ -8,19 +8,20 @@ import java.util.Objects;
 
 @Getter
 public enum ContentPoolEnum {
-    autoArticlePoolLevel1("autoArticlePoolLevel1", "内容池1层"),
-    autoArticlePoolLevel2("autoArticlePoolLevel2", "内容池2层"),
-    autoArticlePoolLevel3("autoArticlePoolLevel3", "内容池3层"),
-    autoArticlePoolLevel4("autoArticlePoolLevel4", "冷启层"),
+    autoArticlePoolLevel1("autoArticlePoolLevel1", 1, "内容池1层"),
+    autoArticlePoolLevel2("autoArticlePoolLevel2", 2, "内容池2层"),
+    autoArticlePoolLevel3("autoArticlePoolLevel3", 3, "内容池3层"),
+    autoArticlePoolLevel4("autoArticlePoolLevel4", 4, "冷启层"),
 
     ;
 
-
     private final String contentPool;
+    private final Integer value;
     private final String description;
 
-    ContentPoolEnum(String contentPool, String description) {
+    ContentPoolEnum(String contentPool, Integer value, String description) {
         this.contentPool = contentPool;
+        this.value = value;
         this.description = description;
     }
 
@@ -33,6 +34,15 @@ public enum ContentPoolEnum {
         return autoArticlePoolLevel4;
     }
 
+    public static ContentPoolEnum from(Integer value) {
+        for (ContentPoolEnum poolEnum : ContentPoolEnum.values()) {
+            if (Objects.equals(poolEnum.value, value)) {
+                return poolEnum;
+            }
+        }
+        return autoArticlePoolLevel4;
+    }
+
     public static List<String> getOrderContentPool() {
         List<String> result = new ArrayList<>();
         result.add(autoArticlePoolLevel1.getContentPool());

+ 1 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/dto/Content.java

@@ -18,6 +18,7 @@ import java.util.Map;
 @AllArgsConstructor
 public class Content {
     private String id;
+    private Integer sourceType;
     private String sourceId;
     private String title;
     private Long createTimestamp;

+ 1 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/vo/ArticleSortResponseDataItem.java

@@ -11,6 +11,7 @@ import java.util.Map;
 @Accessors(chain = true)
 public class ArticleSortResponseDataItem {
     private String id;
+    private Integer sourceType;
     private String sourceId;
     private String contentPoolType; // 内容池类别
     private String title;

+ 61 - 9
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/RankService.java

@@ -4,6 +4,8 @@ package com.tzld.longarticle.recommend.server.service.recommend.rank;
 import cn.hutool.core.collection.CollectionUtil;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
+import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
+import com.tzld.longarticle.recommend.server.common.enums.aigc.PublishPlanInputSourceTypesEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.RankStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
 import com.tzld.longarticle.recommend.server.service.ServiceBeanFactory;
@@ -12,11 +14,13 @@ import com.tzld.longarticle.recommend.server.service.recommend.score.AccountInde
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.RandomUtils;
+import org.springframework.beans.factory.InitializingBean;
 import org.springframework.stereotype.Service;
 
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
+import java.util.stream.Collectors;
 
 import static com.tzld.longarticle.recommend.server.common.constant.SceneConstants.FWH_COLD_START;
 
@@ -25,7 +29,30 @@ import static com.tzld.longarticle.recommend.server.common.constant.SceneConstan
  */
 @Service
 @Slf4j
-public class RankService {
+public class RankService implements InitializingBean {
+
+    private static Map<String, Map<Integer, Integer>> staticAccountPoolSourceTypeMap;
+
+    @ApolloJsonValue("${accountPoolSourceTypeConfig:{}}")
+    private Map<String, Map<Integer, Integer>> accountPoolSourceTypeMap;
+
+    @Override
+    public void afterPropertiesSet() throws Exception {
+        RankService.staticAccountPoolSourceTypeMap = accountPoolSourceTypeMap;
+    }
+
+    public static Integer getAccountPoolSourceType(String ghId, Integer index) {
+        Integer sourceType = 0;
+        Map<Integer, Integer> indexSourceTypeMap = staticAccountPoolSourceTypeMap.get(ghId);
+        if (Objects.nonNull(indexSourceTypeMap)) {
+            sourceType = indexSourceTypeMap.get(index);
+        }
+        return sourceType;
+    }
+
+    public static Map<Integer, Integer> getAccountPoolSourceType(String ghId) {
+        return staticAccountPoolSourceTypeMap.get(ghId);
+    }
 
     public RankResult rank(RankParam param) {
         RankStrategy strategy = getRankStrategy(param);
@@ -60,11 +87,16 @@ public class RankService {
         log.info("{} 账号名称 {} {}评分结果 {}", strategy, accountName, position, JSONObject.toJSONString(jsonArray));
     }
 
-    public static void commonAddSecondContent(List<Content> result,
+    public static void commonAddSecondContent(RankParam param, List<Content> result,
                                               String[] publishPool, String[] contentPools,
                                               Map<String, List<Content>> contentMap,
                                               Map<Integer, AccountIndexReplacePoolConfig> indexReplacePoolConfigMap) {
         List<Content> pool = contentMap.get(contentPools[1]);
+        if (CollectionUtils.isNotEmpty(pool)) {
+            Integer sourceType = getAccountPoolSourceType(param.getGhId(), 2);
+            Integer videoSourceType = PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal();
+            pool = contentSourceTypeFilter(videoSourceType, pool, sourceType);
+        }
         if (CollectionUtils.isNotEmpty(pool)) {
             int i = RandomUtils.nextInt(0, Math.min(pool.size(), 5));
             int j = RandomUtils.nextInt(0, Math.min(pool.size(), 5));
@@ -82,20 +114,40 @@ public class RankService {
             }
         } else {
             // 替补 根据设置替补内容池查找内容进行替补
-            AccountIndexReplacePoolConfig replacePoolConfig = indexReplacePoolConfigMap.get(2);
-            if (Objects.nonNull(replacePoolConfig)) {
-                List<Content> poolReplace = contentMap.get(replacePoolConfig.getContentPool());
-                if (CollectionUtils.isNotEmpty(poolReplace)) {
-                    publishPool[1] = replacePoolConfig.getContentPool();
-                    result.add(poolReplace.get(0));
-                }
+            findReplacePoolContent(result, publishPool, contentMap, indexReplacePoolConfigMap);
+        }
+    }
+
+    public static void findReplacePoolContent(List<Content> result, String[] publishPool,
+                                              Map<String, List<Content>> contentMap,
+                                              Map<Integer, AccountIndexReplacePoolConfig> indexReplacePoolConfigMap) {
+        AccountIndexReplacePoolConfig replacePoolConfig = indexReplacePoolConfigMap.get(2);
+        if (Objects.nonNull(replacePoolConfig)) {
+            List<Content> poolReplace = contentMap.get(replacePoolConfig.getContentPool());
+            if (CollectionUtils.isNotEmpty(poolReplace)) {
+                publishPool[1] = replacePoolConfig.getContentPool();
+                result.add(poolReplace.get(0));
             }
         }
     }
 
+    public static List<Content> contentSourceTypeFilter(Integer videoSourceType, List<Content> pool, Integer sourceType) {
+        if (Objects.nonNull(sourceType) && sourceType.equals(videoSourceType)) {
+            pool = pool.stream().filter(o -> Objects.equals(o.getSourceType(), videoSourceType)).collect(Collectors.toList());
+        } else {
+            pool = pool.stream().filter(o -> !Objects.equals(o.getSourceType(), videoSourceType)).collect(Collectors.toList());
+        }
+        return pool;
+    }
+
     public static void commonAdd38Content(RankParam param, List<Content> result, String[] contentPools,
                                           Map<String, List<Content>> contentMap, String strategy) {
         List<Content> pool = contentMap.get(contentPools[2]);
+        if (CollectionUtils.isNotEmpty(pool)) {
+            Integer sourceType = getAccountPoolSourceType(param.getGhId(), 3);
+            Integer videoSourceType = PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal();
+            pool = contentSourceTypeFilter(videoSourceType, pool, sourceType);
+        }
         if (CollectionUtils.isNotEmpty(pool) && param.getSize() > result.size()) {
             RankService.printSortLog(strategy, param.getAccountName(), "3-8", pool.subList(0, Math.min(pool.size(), 200)));
             result.addAll(pool.subList(0, Math.min(pool.size(), param.getSize() - result.size())));

+ 16 - 3
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/HisJumpRankStrategy.java

@@ -1,9 +1,9 @@
 package com.tzld.longarticle.recommend.server.service.recommend.rank.strategy;
 
+import com.tzld.longarticle.recommend.server.common.enums.aigc.PublishPlanInputSourceTypesEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.RankStrategyEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.ScoreStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
-import com.tzld.longarticle.recommend.server.repository.crawler.ArticleRepository;
 import com.tzld.longarticle.recommend.server.service.recommend.config.AccountContentPoolConfigService;
 import com.tzld.longarticle.recommend.server.service.recommend.config.StrategyIndexScoreWeightService;
 import com.tzld.longarticle.recommend.server.service.recommend.rank.*;
@@ -28,8 +28,6 @@ public class HisJumpRankStrategy implements RankStrategy {
     @Autowired
     private AccountContentPoolConfigService accountContentPoolConfigService;
     @Autowired
-    private ArticleRepository articleRepository;
-    @Autowired
     private StrategyIndexScoreWeightService weightService;
 
     public RankResult rank(RankParam param) {
@@ -90,6 +88,11 @@ public class HisJumpRankStrategy implements RankStrategy {
 
         // 头
         List<Content> pool1 = contentMap.get(contentPools[0]);
+        if (CollectionUtils.isNotEmpty(pool1)) {
+            Integer sourceType = RankService.getAccountPoolSourceType(param.getGhId(), 1);
+            Integer videoSourceType = PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal();
+            pool1 = RankService.contentSourceTypeFilter(videoSourceType, pool1, sourceType);
+        }
         RankService.printSortLog(RankStrategyEnum.HIS_JUMP_STRATEGY.getStrategy(), param.getAccountName(), "头条", pool1);
         if (CollectionUtils.isNotEmpty(pool1)) {
             int i = RandomUtils.nextInt(0, Math.min(pool1.size(), 20));
@@ -100,6 +103,11 @@ public class HisJumpRankStrategy implements RankStrategy {
         }
         // 次
         List<Content> pool2 = contentMap.get(contentPools[1]);
+        if (CollectionUtils.isNotEmpty(pool2)) {
+            Integer sourceType = RankService.getAccountPoolSourceType(param.getGhId(), 2);
+            Integer videoSourceType = PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal();
+            pool2 = RankService.contentSourceTypeFilter(videoSourceType, pool2, sourceType);
+        }
         if (CollectionUtils.isNotEmpty(pool2)) {
             int i = RandomUtils.nextInt(0, Math.min(pool2.size(), 20));
             result.add(pool2.get(i));
@@ -118,6 +126,11 @@ public class HisJumpRankStrategy implements RankStrategy {
 
         // 3-8
         List<Content> pool = contentMap.get(contentPools[2]);
+        if (CollectionUtils.isNotEmpty(pool)) {
+            Integer sourceType = RankService.getAccountPoolSourceType(param.getGhId(), 3);
+            Integer videoSourceType = PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal();
+            pool = RankService.contentSourceTypeFilter(videoSourceType, pool, sourceType);
+        }
         if (CollectionUtils.isNotEmpty(pool) && param.getSize() > result.size()) {
             int slotNum = param.getSize() - result.size();
             List<Content> subPool = pool.subList(0, Math.min(pool.size(), 30));

+ 3 - 9
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/InfiniteRankStrategy.java

@@ -1,19 +1,16 @@
 package com.tzld.longarticle.recommend.server.service.recommend.rank.strategy;
 
+import com.tzld.longarticle.recommend.server.common.enums.recommend.RankStrategyEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.ScoreStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
 import com.tzld.longarticle.recommend.server.service.recommend.config.AccountContentPoolConfigService;
 import com.tzld.longarticle.recommend.server.service.recommend.config.StrategyIndexScoreWeightService;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankItem;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankParam;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankResult;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankStrategy;
+import com.tzld.longarticle.recommend.server.service.recommend.rank.*;
 import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreParam;
 import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreResult;
 import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreService;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -76,10 +73,7 @@ public class InfiniteRankStrategy implements RankStrategy {
         }
 
         // 全部使用3-8内容池
-        List<Content> pool = contentMap.get(contentPools[2]);
-        if (CollectionUtils.isNotEmpty(pool)) {
-            result.addAll(pool.subList(0, Math.min(pool.size(), param.getSize())));
-        }
+        RankService.commonAdd38Content(param, result, contentPools, contentMap, RankStrategyEnum.INFINITE_STRATEGY.getStrategy());
 
         return new RankResult(result);
     }

+ 3 - 9
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/LateRankStrategy.java

@@ -1,19 +1,16 @@
 package com.tzld.longarticle.recommend.server.service.recommend.rank.strategy;
 
+import com.tzld.longarticle.recommend.server.common.enums.recommend.RankStrategyEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.ScoreStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
 import com.tzld.longarticle.recommend.server.service.recommend.config.AccountContentPoolConfigService;
 import com.tzld.longarticle.recommend.server.service.recommend.config.StrategyIndexScoreWeightService;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankItem;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankParam;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankResult;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankStrategy;
+import com.tzld.longarticle.recommend.server.service.recommend.rank.*;
 import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreParam;
 import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreResult;
 import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreService;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import lombok.extern.slf4j.Slf4j;
-import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
@@ -76,10 +73,7 @@ public class LateRankStrategy implements RankStrategy {
         }
 
         // 全部使用3-8内容池
-        List<Content> pool = contentMap.get(contentPools[2]);
-        if (CollectionUtils.isNotEmpty(pool)) {
-            result.addAll(pool.subList(0, Math.min(pool.size(), param.getSize())));
-        }
+        RankService.commonAdd38Content(param, result, contentPools, contentMap, RankStrategyEnum.LATE_STRATEGY.getStrategy());
 
         return new RankResult(result);
     }

+ 17 - 4
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RandomRankStrategy.java

@@ -1,12 +1,10 @@
 package com.tzld.longarticle.recommend.server.service.recommend.rank.strategy;
 
+import com.tzld.longarticle.recommend.server.common.enums.aigc.PublishPlanInputSourceTypesEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
 import com.tzld.longarticle.recommend.server.service.recommend.config.AccountContentPoolConfigService;
 import com.tzld.longarticle.recommend.server.service.recommend.config.StrategyIndexScoreWeightService;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankItem;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankParam;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankResult;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankStrategy;
+import com.tzld.longarticle.recommend.server.service.recommend.rank.*;
 import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreService;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import lombok.extern.slf4j.Slf4j;
@@ -46,12 +44,22 @@ public class RandomRankStrategy implements RankStrategy {
         }
         // 头
         List<Content> pool = contentMap.get(contentPools[0]);
+        if (CollectionUtils.isNotEmpty(pool)) {
+            Integer sourceType = RankService.getAccountPoolSourceType(param.getGhId(), 1);
+            Integer videoSourceType = PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal();
+            pool = RankService.contentSourceTypeFilter(videoSourceType, pool, sourceType);
+        }
         if (CollectionUtils.isNotEmpty(pool)) {
             Collections.shuffle(pool);
             result.add(pool.get(0));
         }
         // 次
         pool = contentMap.get(contentPools[1]);
+        if (CollectionUtils.isNotEmpty(pool)) {
+            Integer sourceType = RankService.getAccountPoolSourceType(param.getGhId(), 2);
+            Integer videoSourceType = PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal();
+            pool = RankService.contentSourceTypeFilter(videoSourceType, pool, sourceType);
+        }
         if (CollectionUtils.isNotEmpty(pool)) {
             Collections.shuffle(pool);
             result.add(pool.get(0));
@@ -61,6 +69,11 @@ public class RandomRankStrategy implements RankStrategy {
         }
         // 全部使用3-8内容池
         pool = contentMap.get(contentPools[2]);
+        if (CollectionUtils.isNotEmpty(pool)) {
+            Integer sourceType = RankService.getAccountPoolSourceType(param.getGhId(), 3);
+            Integer videoSourceType = PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal();
+            pool = RankService.contentSourceTypeFilter(videoSourceType, pool, sourceType);
+        }
         if (CollectionUtils.isNotEmpty(pool)) {
             Collections.shuffle(pool);
             result.addAll(pool.subList(0, Math.min(pool.size(), param.getSize())));

+ 8 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV10Strategy.java

@@ -1,6 +1,8 @@
 package com.tzld.longarticle.recommend.server.service.recommend.rank.strategy;
 
 
+import com.tzld.longarticle.recommend.server.common.enums.aigc.PublishPlanInputSourceTypesEnum;
+import com.tzld.longarticle.recommend.server.common.enums.recommend.ContentPoolEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.RankStrategyEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.ScoreStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
@@ -102,6 +104,11 @@ public class RankV10Strategy implements RankStrategy {
 
         // 头
         List<Content> pool1 = contentMap.get(contentPools[0]);
+        if (CollectionUtils.isNotEmpty(pool1)) {
+            Integer sourceType = RankService.getAccountPoolSourceType(param.getGhId(), 1);
+            Integer videoSourceType = PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal();
+            pool1 = RankService.contentSourceTypeFilter(videoSourceType, pool1, sourceType);
+        }
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
         } else {
@@ -109,7 +116,7 @@ public class RankV10Strategy implements RankStrategy {
             return new RankResult(result);
         }
         // 次
-        RankService.commonAddSecondContent(result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
+        RankService.commonAddSecondContent(param, result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
 
         // 3-8
         RankService.commonAdd38Content(param, result, contentPools, contentMap, RankStrategyEnum.ArticleRankV10.getStrategy());

+ 8 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV11Strategy.java

@@ -1,6 +1,8 @@
 package com.tzld.longarticle.recommend.server.service.recommend.rank.strategy;
 
 
+import com.tzld.longarticle.recommend.server.common.enums.aigc.PublishPlanInputSourceTypesEnum;
+import com.tzld.longarticle.recommend.server.common.enums.recommend.ContentPoolEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.RankStrategyEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.ScoreStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
@@ -121,6 +123,11 @@ public class RankV11Strategy implements RankStrategy {
 
         // 头
         List<Content> pool1 = contentMap.get(contentPools[0]);
+        if (CollectionUtils.isNotEmpty(pool1)) {
+            Integer sourceType = RankService.getAccountPoolSourceType(param.getGhId(), 1);
+            Integer videoSourceType = PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal();
+            pool1 = RankService.contentSourceTypeFilter(videoSourceType, pool1, sourceType);
+        }
         RankService.printSortLog(RankStrategyEnum.ArticleRankV11.getStrategy(), param.getAccountName(), "头条", pool1);
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
@@ -129,7 +136,7 @@ public class RankV11Strategy implements RankStrategy {
             return new RankResult(result);
         }
         // 次
-        RankService.commonAddSecondContent(result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
+        RankService.commonAddSecondContent(param, result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
 
         // 3-8
         RankService.commonAdd38Content(param, result, contentPools, contentMap, RankStrategyEnum.ArticleRankV11.getStrategy());

+ 8 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV12Strategy.java

@@ -1,6 +1,8 @@
 package com.tzld.longarticle.recommend.server.service.recommend.rank.strategy;
 
 
+import com.tzld.longarticle.recommend.server.common.enums.aigc.PublishPlanInputSourceTypesEnum;
+import com.tzld.longarticle.recommend.server.common.enums.recommend.ContentPoolEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.RankStrategyEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.ScoreStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
@@ -121,6 +123,11 @@ public class RankV12Strategy implements RankStrategy {
 
         // 头
         List<Content> pool1 = contentMap.get(contentPools[0]);
+        if (CollectionUtils.isNotEmpty(pool1)) {
+            Integer sourceType = RankService.getAccountPoolSourceType(param.getGhId(), 1);
+            Integer videoSourceType = PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal();
+            pool1 = RankService.contentSourceTypeFilter(videoSourceType, pool1, sourceType);
+        }
         RankService.printSortLog(RankStrategyEnum.ArticleRankV12.getStrategy(), param.getAccountName(), "头条", pool1);
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
@@ -129,7 +136,7 @@ public class RankV12Strategy implements RankStrategy {
             return new RankResult(result);
         }
         // 次
-        RankService.commonAddSecondContent(result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
+        RankService.commonAddSecondContent(param, result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
 
         // 3-8
         RankService.commonAdd38Content(param, result, contentPools, contentMap, RankStrategyEnum.ArticleRankV12.getStrategy());

+ 8 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV13Strategy.java

@@ -1,6 +1,8 @@
 package com.tzld.longarticle.recommend.server.service.recommend.rank.strategy;
 
 
+import com.tzld.longarticle.recommend.server.common.enums.aigc.PublishPlanInputSourceTypesEnum;
+import com.tzld.longarticle.recommend.server.common.enums.recommend.ContentPoolEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.RankStrategyEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.ScoreStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
@@ -122,6 +124,11 @@ public class RankV13Strategy implements RankStrategy {
 
         // 头
         List<Content> pool1 = contentMap.get(contentPools[0]);
+        if (CollectionUtils.isNotEmpty(pool1)) {
+            Integer sourceType = RankService.getAccountPoolSourceType(param.getGhId(), 1);
+            Integer videoSourceType = PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal();
+            pool1 = RankService.contentSourceTypeFilter(videoSourceType, pool1, sourceType);
+        }
         RankService.printSortLog(RankStrategyEnum.ArticleRankV13.getStrategy(), param.getAccountName(), "头条", pool1);
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
@@ -130,7 +137,7 @@ public class RankV13Strategy implements RankStrategy {
             return new RankResult(result);
         }
         // 次
-        RankService.commonAddSecondContent(result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
+        RankService.commonAddSecondContent(param, result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
 
         // 3-8
         RankService.commonAdd38Content(param, result, contentPools, contentMap, RankStrategyEnum.ArticleRankV13.getStrategy());

+ 8 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV14Strategy.java

@@ -1,6 +1,8 @@
 package com.tzld.longarticle.recommend.server.service.recommend.rank.strategy;
 
 
+import com.tzld.longarticle.recommend.server.common.enums.aigc.PublishPlanInputSourceTypesEnum;
+import com.tzld.longarticle.recommend.server.common.enums.recommend.ContentPoolEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.RankStrategyEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.ScoreStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
@@ -122,6 +124,11 @@ public class RankV14Strategy implements RankStrategy {
 
         // 头
         List<Content> pool1 = contentMap.get(contentPools[0]);
+        if (CollectionUtils.isNotEmpty(pool1)) {
+            Integer sourceType = RankService.getAccountPoolSourceType(param.getGhId(), 1);
+            Integer videoSourceType = PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal();
+            pool1 = RankService.contentSourceTypeFilter(videoSourceType, pool1, sourceType);
+        }
         RankService.printSortLog(RankStrategyEnum.ArticleRankV14.getStrategy(), param.getAccountName(), "头条", pool1);
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
@@ -130,7 +137,7 @@ public class RankV14Strategy implements RankStrategy {
             return new RankResult(result);
         }
         // 次
-        RankService.commonAddSecondContent(result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
+        RankService.commonAddSecondContent(param, result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
 
         // 3-8
         RankService.commonAdd38Content(param, result, contentPools, contentMap, RankStrategyEnum.ArticleRankV14.getStrategy());

+ 12 - 8
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV3Strategy.java

@@ -1,6 +1,7 @@
 package com.tzld.longarticle.recommend.server.service.recommend.rank.strategy;
 
 
+import com.tzld.longarticle.recommend.server.common.enums.aigc.PublishPlanInputSourceTypesEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.RankStrategyEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.ScoreStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
@@ -93,6 +94,11 @@ public class RankV3Strategy implements RankStrategy {
 
         // 头
         List<Content> pool1 = contentMap.get(contentPools[0]);
+        if (CollectionUtils.isNotEmpty(pool1)) {
+            Integer sourceType = RankService.getAccountPoolSourceType(param.getGhId(), 1);
+            Integer videoSourceType = PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal();
+            pool1 = RankService.contentSourceTypeFilter(videoSourceType, pool1, sourceType);
+        }
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
         } else {
@@ -101,19 +107,17 @@ public class RankV3Strategy implements RankStrategy {
         }
         // 次
         List<Content> pool2 = contentMap.get(contentPools[1]);
+        if (CollectionUtils.isNotEmpty(pool2)) {
+            Integer sourceType = RankService.getAccountPoolSourceType(param.getGhId(), 2);
+            Integer videoSourceType = PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal();
+            pool2 = RankService.contentSourceTypeFilter(videoSourceType, pool2, sourceType);
+        }
         if (CollectionUtils.isNotEmpty(pool2)) {
             int i = RandomUtils.nextInt(0, Math.min(pool2.size(), 5));
             result.add(pool2.get(i));
         } else {
             // 替补 根据设置替补内容池查找内容尽心替补
-            AccountIndexReplacePoolConfig replacePoolConfig = indexReplacePoolConfigMap.get(2);
-            if (Objects.nonNull(replacePoolConfig)) {
-                List<Content> pool2Replace = contentMap.get(replacePoolConfig.getContentPool());
-                if (CollectionUtils.isNotEmpty(pool2Replace)) {
-                    publishPool[1] = replacePoolConfig.getContentPool();
-                    result.add(pool2Replace.get(0));
-                }
-            }
+            RankService.findReplacePoolContent(result, publishPool, contentMap, indexReplacePoolConfigMap);
         }
 
         // 3-8

+ 8 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV4Strategy.java

@@ -1,6 +1,8 @@
 package com.tzld.longarticle.recommend.server.service.recommend.rank.strategy;
 
 
+import com.tzld.longarticle.recommend.server.common.enums.aigc.PublishPlanInputSourceTypesEnum;
+import com.tzld.longarticle.recommend.server.common.enums.recommend.ContentPoolEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.RankStrategyEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.ScoreStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
@@ -92,6 +94,11 @@ public class RankV4Strategy implements RankStrategy {
 
         // 头
         List<Content> pool1 = contentMap.get(contentPools[0]);
+        if (CollectionUtils.isNotEmpty(pool1)) {
+            Integer sourceType = RankService.getAccountPoolSourceType(param.getGhId(), 1);
+            Integer videoSourceType = PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal();
+            pool1 = RankService.contentSourceTypeFilter(videoSourceType, pool1, sourceType);
+        }
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
         } else {
@@ -99,7 +106,7 @@ public class RankV4Strategy implements RankStrategy {
             return new RankResult(result);
         }
         // 次
-        RankService.commonAddSecondContent(result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
+        RankService.commonAddSecondContent(param, result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
 
         // 3-8
         RankService.commonAdd38Content(param, result, contentPools, contentMap, RankStrategyEnum.ArticleRankV4.getStrategy());

+ 7 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV5Strategy.java

@@ -2,6 +2,7 @@ package com.tzld.longarticle.recommend.server.service.recommend.rank.strategy;
 
 
 import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
+import com.tzld.longarticle.recommend.server.common.enums.aigc.PublishPlanInputSourceTypesEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.RankStrategyEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.ScoreStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
@@ -110,6 +111,11 @@ public class RankV5Strategy implements RankStrategy {
 
         // 头
         List<Content> pool1 = contentMap.get(contentPools[0]);
+        if (CollectionUtils.isNotEmpty(pool1)) {
+            Integer sourceType = RankService.getAccountPoolSourceType(param.getGhId(), 1);
+            Integer videoSourceType = PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal();
+            pool1 = RankService.contentSourceTypeFilter(videoSourceType, pool1, sourceType);
+        }
         RankService.printSortLog(RankStrategyEnum.ArticleRankV5.getStrategy(), param.getAccountName(), "头条", pool1);
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
@@ -118,7 +124,7 @@ public class RankV5Strategy implements RankStrategy {
             return new RankResult(result);
         }
         // 次
-        RankService.commonAddSecondContent(result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
+        RankService.commonAddSecondContent(param, result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
 
         // 3-8
         RankService.commonAdd38Content(param, result, contentPools, contentMap, RankStrategyEnum.ArticleRankV5.getStrategy());

+ 8 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV7Strategy.java

@@ -1,6 +1,8 @@
 package com.tzld.longarticle.recommend.server.service.recommend.rank.strategy;
 
 
+import com.tzld.longarticle.recommend.server.common.enums.aigc.PublishPlanInputSourceTypesEnum;
+import com.tzld.longarticle.recommend.server.common.enums.recommend.ContentPoolEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.RankStrategyEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.ScoreStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
@@ -94,6 +96,11 @@ public class RankV7Strategy implements RankStrategy {
 
         // 头
         List<Content> pool1 = contentMap.get(contentPools[0]);
+        if (CollectionUtils.isNotEmpty(pool1)) {
+            Integer sourceType = RankService.getAccountPoolSourceType(param.getGhId(), 1);
+            Integer videoSourceType = PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal();
+            pool1 = RankService.contentSourceTypeFilter(videoSourceType, pool1, sourceType);
+        }
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
         } else {
@@ -101,7 +108,7 @@ public class RankV7Strategy implements RankStrategy {
             return new RankResult(result);
         }
         // 次
-        RankService.commonAddSecondContent(result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
+        RankService.commonAddSecondContent(param, result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
 
         // 3-8
         RankService.commonAdd38Content(param, result, contentPools, contentMap, RankStrategyEnum.ArticleRankV7.getStrategy());

+ 8 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV8Strategy.java

@@ -1,6 +1,8 @@
 package com.tzld.longarticle.recommend.server.service.recommend.rank.strategy;
 
 
+import com.tzld.longarticle.recommend.server.common.enums.aigc.PublishPlanInputSourceTypesEnum;
+import com.tzld.longarticle.recommend.server.common.enums.recommend.ContentPoolEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.RankStrategyEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.ScoreStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
@@ -105,6 +107,11 @@ public class RankV8Strategy implements RankStrategy {
 
         // 头
         List<Content> pool1 = contentMap.get(contentPools[0]);
+        if (CollectionUtils.isNotEmpty(pool1)) {
+            Integer sourceType = RankService.getAccountPoolSourceType(param.getGhId(), 1);
+            Integer videoSourceType = PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal();
+            pool1 = RankService.contentSourceTypeFilter(videoSourceType, pool1, sourceType);
+        }
         RankService.printSortLog(RankStrategyEnum.ArticleRankV8.getStrategy(), param.getAccountName(), "头条", pool1);
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
@@ -113,7 +120,7 @@ public class RankV8Strategy implements RankStrategy {
             return new RankResult(result);
         }
         // 次
-        RankService.commonAddSecondContent(result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
+        RankService.commonAddSecondContent(param, result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
 
         // 3-8
         RankService.commonAdd38Content(param, result, contentPools, contentMap, RankStrategyEnum.ArticleRankV8.getStrategy());

+ 8 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV9Strategy.java

@@ -1,6 +1,8 @@
 package com.tzld.longarticle.recommend.server.service.recommend.rank.strategy;
 
 
+import com.tzld.longarticle.recommend.server.common.enums.aigc.PublishPlanInputSourceTypesEnum;
+import com.tzld.longarticle.recommend.server.common.enums.recommend.ContentPoolEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.RankStrategyEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.ScoreStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
@@ -94,6 +96,11 @@ public class RankV9Strategy implements RankStrategy {
 
         // 头
         List<Content> pool1 = contentMap.get(contentPools[0]);
+        if (CollectionUtils.isNotEmpty(pool1)) {
+            Integer sourceType = RankService.getAccountPoolSourceType(param.getGhId(), 1);
+            Integer videoSourceType = PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal();
+            pool1 = RankService.contentSourceTypeFilter(videoSourceType, pool1, sourceType);
+        }
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
         } else {
@@ -101,7 +108,7 @@ public class RankV9Strategy implements RankStrategy {
             return new RankResult(result);
         }
         // 次
-        RankService.commonAddSecondContent(result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
+        RankService.commonAddSecondContent(param, result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
 
         // 3-8
         RankService.commonAdd38Content(param, result, contentPools, contentMap, RankStrategyEnum.ArticleRankV9.getStrategy());