Procházet zdrojové kódy

Merge branch 'wyp/1025-infinite' of Server/long-article-recommend into master

wangyunpeng před 8 měsíci
rodič
revize
3713719be2
32 změnil soubory, kde provedl 279 přidání a 52 odebrání
  1. 35 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/common/enums/PushTypeEnum.java
  2. 4 3
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/common/enums/RankStrategyEnum.java
  3. 3 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/param/RecommendParam.java
  4. 1 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/param/RecommendRequest.java
  5. 4 5
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/remote/ArticleListRemoteService.java
  6. 3 2
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/crawler/ArticleRepository.java
  7. 13 3
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/RecommendService.java
  8. 1 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/filter/FilterParam.java
  9. 9 10
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/filter/FilterService.java
  10. 0 1
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/filter/strategy/DeDuplicationStrategy.java
  11. 2 1
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/filter/strategy/HistoryTitleForFwhColdStartStrategy.java
  12. 1 1
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/filter/strategy/HistoryTitleStrategy.java
  13. 91 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/filter/strategy/InfiniteHisTitleStrategy.java
  14. 1 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/RankParam.java
  15. 1 2
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/DefaultRankStrategy.java
  16. 80 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/InfiniteRankStrategy.java
  17. 1 1
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/RankV10Strategy.java
  18. 1 1
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/RankV11Strategy.java
  19. 1 1
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/RankV12Strategy.java
  20. 1 1
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/RankV13Strategy.java
  21. 1 1
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/RankV14Strategy.java
  22. 1 1
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/RankV3Strategy.java
  23. 1 1
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/RankV4Strategy.java
  24. 1 2
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/RankV5Strategy.java
  25. 1 1
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/RankV7Strategy.java
  26. 1 1
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/RankV8Strategy.java
  27. 1 1
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/RankV9Strategy.java
  28. 1 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recall/FilterParamFactory.java
  29. 1 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recall/RecallParam.java
  30. 13 10
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recall/RecallService.java
  31. 2 1
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/score/ScoreService.java
  32. 2 1
      long-article-recommend-service/src/test/java/com/tzld/longarticle/recommend/server/ScoreStrategyTest.java

+ 35 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/common/enums/PushTypeEnum.java

@@ -0,0 +1,35 @@
+package com.tzld.longarticle.recommend.server.common.enums;
+
+import lombok.Getter;
+
+import java.util.Objects;
+
+@Getter
+public enum PushTypeEnum {
+    MANUAL_PUSH(1, "手动推送"),
+    AUTO_GROUP_PUBLISH(2, "自动群发"),
+    AUTO_PUBLISH(3, "自动发表"),
+    ROBOPOST(4, "自动发布"),
+    BATCH_GROUP_PUBLISH(5, "分组群发"),
+    TRIGGER_PUSH(6, "触发推送"),
+
+    other(999, "其他"),
+    ;
+
+    private final Integer val;
+    private final String description;
+
+    PushTypeEnum(Integer val, String description) {
+        this.val = val;
+        this.description = description;
+    }
+
+    public static PushTypeEnum from(Integer val) {
+        for (PushTypeEnum typeEnum : PushTypeEnum.values()) {
+            if (Objects.equals(typeEnum.val, val)) {
+                return typeEnum;
+            }
+        }
+        return other;
+    }
+}

+ 4 - 3
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/common/enums/RankStrategyEnum.java

@@ -20,8 +20,9 @@ public enum RankStrategyEnum {
     ArticleRankV13("ArticleRankV13", "ArticleRankV13", "rankV13Strategy"),
     ArticleRankV14("ArticleRankV14", "ArticleRankV14", "rankV14Strategy"),
 
-    late_Strategy("ArticleRankLate", "晚间策略", "lateRankStrategy"),
-    default_strategy("ArticleRankV1", "默认策略", "defaultRankStrategy"),
+    INFINITE_STRATEGY("ArticleRankInfinite", "无限发表", "infiniteRankStrategy"),
+    LATE_STRATEGY("ArticleRankLate", "晚间策略", "lateRankStrategy"),
+    DEFAULT_STRATEGY("ArticleRankV1", "默认策略", "defaultRankStrategy"),
     ;
 
     private final String strategy;
@@ -40,6 +41,6 @@ public enum RankStrategyEnum {
                 return statusEnum;
             }
         }
-        return default_strategy;
+        return DEFAULT_STRATEGY;
     }
 }

+ 3 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/param/RecommendParam.java

@@ -1,5 +1,6 @@
 package com.tzld.longarticle.recommend.server.model.param;
 
+import com.tzld.longarticle.recommend.server.common.enums.ArticleTypeEnum;
 import lombok.Getter;
 import lombok.NoArgsConstructor;
 import lombok.Setter;
@@ -20,6 +21,8 @@ public class RecommendParam {
     private String strategy;
     private Integer publishNum;
     private String planId;
+    // 默认为群发 ArticleTypeEnum.QUNFA.getVal()
+    private String type = ArticleTypeEnum.QUNFA.getVal();
     // true 不记录日志
     private boolean excludeLog = false;
     private String scene;

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

@@ -18,6 +18,7 @@ public class RecommendRequest {
     private String strategy;
     private Integer publishNum;
     private String planId;
+    private Integer pushType;
     // true 不记录日志
     private boolean excludeLog = false;
     // true 强制走参数策略

+ 4 - 5
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/remote/ArticleListRemoteService.java

@@ -3,7 +3,6 @@ package com.tzld.longarticle.recommend.server.remote;
 import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.tzld.longarticle.recommend.server.common.HttpPoolFactory;
-import com.tzld.longarticle.recommend.server.common.enums.ArticleTypeEnum;
 import com.tzld.longarticle.recommend.server.model.entity.crawler.Article;
 import com.tzld.longarticle.recommend.server.repository.crawler.ArticleRepository;
 import lombok.extern.slf4j.Slf4j;
@@ -34,8 +33,8 @@ public class ArticleListRemoteService {
     private final CloseableHttpClient client = HttpPoolFactory.aigcPool();
     private static final String articleListUrl = "http://61.48.133.26:8179/artlce_list";
 
-    public List<Article> articleList(String accountName, List<Integer> indexList) {
-        return getArticleListByDB(accountName, indexList);
+    public List<Article> articleList(String ghId, List<Integer> indexList, String type) {
+        return getArticleListByDB(ghId, indexList, type);
     }
 
     private List<Article> getArticleListByApi(String accountName, List<Integer> indexList) {
@@ -92,8 +91,8 @@ public class ArticleListRemoteService {
     }
 
 
-    private List<Article> getArticleListByDB(String accountName, List<Integer> indexList) {
-        return articleRepository.getByAccountNameAndItemIndexInAndTypeEquals(accountName, indexList, ArticleTypeEnum.QUNFA.getVal());
+    private List<Article> getArticleListByDB(String ghId, List<Integer> indexList, String type) {
+        return articleRepository.getByGhIdAndItemIndexInAndTypeEquals(ghId, indexList, type);
     }
 
 }

+ 3 - 2
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/crawler/ArticleRepository.java

@@ -10,13 +10,14 @@ import java.util.Set;
 @Repository
 public interface ArticleRepository extends JpaRepository<Article, String> {
 
-    List<Article> getByAccountNameAndItemIndexInAndTypeEquals(String accountName, List<Integer> indexList, String type);
+    List<Article> getByGhIdAndItemIndexInAndTypeEquals(String ghId, List<Integer> indexList, String type);
 
     List<Article> getByTitleMd5InAndTypeEqualsAndStatusEquals(List<String> titleList, String type, Integer status);
 
     List<Article> getByTitleInAndTypeEqualsAndStatusEquals(List<String> titleList, String type, Integer status);
 
-    List<Article> getByGhIdInAndAppMsgIdInAndItemIndexAndTypeEqualsAndStatusEquals(Set<String> ghIds, Set<String> appMsgIds, Integer itemIndex, String type, Integer status);
+    List<Article> getByGhIdInAndAppMsgIdInAndItemIndexAndTypeEqualsAndStatusEquals(Set<String> ghIds, Set<String> appMsgIds,
+                                                                                   Integer itemIndex, String type, Integer status);
 
     List<Article> getByGhIdInAndUpdateTimeBetweenAndTypeEquals(List<String> ghIds, Long updateTimeStart, Long updateTimeEnd, String type);
 

+ 13 - 3
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/RecommendService.java

@@ -2,6 +2,8 @@ package com.tzld.longarticle.recommend.server.service;
 
 import com.alibaba.fastjson.JSONObject;
 import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
+import com.tzld.longarticle.recommend.server.common.enums.ArticleTypeEnum;
+import com.tzld.longarticle.recommend.server.common.enums.PushTypeEnum;
 import com.tzld.longarticle.recommend.server.common.enums.RankStrategyEnum;
 import com.tzld.longarticle.recommend.server.mapper.aigc.AigcBaseMapper;
 import com.tzld.longarticle.recommend.server.mapper.crawler.ArticleUserGroupMapper;
@@ -91,14 +93,18 @@ public class RecommendService {
     }
 
     private void setStrategy(RecommendRequest request, RecommendParam param) {
+        if (Objects.equals(request.getPushType(), PushTypeEnum.AUTO_PUBLISH.getVal())) {
+            param.setStrategy(RankStrategyEnum.INFINITE_STRATEGY.getStrategy());
+            param.setType(ArticleTypeEnum.WUXIANLIU.getVal());
+            return;
+        }
         String strategyConfig = accountStrategyConfigMap.get(request.getAccountName());
         if (StringUtils.hasText(strategyConfig) && !request.isParamStrategy()) {
             param.setStrategy(strategyConfig);
         }
         if (DateUtils.getCurrentHour() >= 19 && !request.isParamStrategy()) {
-            Integer pushType = aigcBaseMapper.getPublishPlanPushType(request.getPlanId());
-            if (Objects.equals(2, pushType)) {
-                param.setStrategy(RankStrategyEnum.late_Strategy.getStrategy());
+            if (Objects.equals(request.getPushType(), PushTypeEnum.AUTO_GROUP_PUBLISH.getVal())) {
+                param.setStrategy(RankStrategyEnum.LATE_STRATEGY.getStrategy());
             }
         }
     }
@@ -233,6 +239,7 @@ public class RecommendService {
         rankParam.setSize(param.getPublishNum());
         rankParam.setScene(param.getScene());
         rankParam.setUserGroupIds(param.getUserGroupIds());
+        rankParam.setType(param.getType());
 
         return rankParam;
     }
@@ -247,6 +254,9 @@ public class RecommendService {
         if (!"prod".equals(env) || param.isExcludeLog()) {
             return;
         }
+        if (!ArticleTypeEnum.QUNFA.getVal().equals(param.getType())) {
+            return;
+        }
         switch (param.getScene()) {
             case FWH_COLD_START:
                 break;

+ 1 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/filter/FilterParam.java

@@ -17,4 +17,5 @@ public class FilterParam {
     private String ghId;
     private boolean backup;
     private String scene;
+    private String type;
 }

+ 9 - 10
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/filter/FilterService.java

@@ -1,6 +1,7 @@
 package com.tzld.longarticle.recommend.server.service.filter;
 
 import com.tzld.longarticle.recommend.server.common.ThreadPoolFactory;
+import com.tzld.longarticle.recommend.server.common.enums.RankStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
 import com.tzld.longarticle.recommend.server.service.ServiceBeanFactory;
 import com.tzld.longarticle.recommend.server.service.filter.strategy.*;
@@ -10,10 +11,7 @@ import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.stereotype.Service;
 
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
+import java.util.*;
 import java.util.concurrent.CountDownLatch;
 import java.util.concurrent.ExecutorService;
 import java.util.concurrent.Future;
@@ -95,14 +93,15 @@ public class FilterService {
         strategies.add(ServiceBeanFactory.getBean(SensitiveStrategy.class));
         strategies.add(ServiceBeanFactory.getBean(DeDuplicationStrategy.class));
         strategies.add(ServiceBeanFactory.getBean(KeywordStrategy.class));
-        switch (param.getScene()) {
-            case FWH_COLD_START:
-                strategies.add(ServiceBeanFactory.getBean(HistoryTitleForFwhColdStartStrategy.class));
-                break;
-            default:
+        if (param.getScene().equals(FWH_COLD_START)) {
+            strategies.add(ServiceBeanFactory.getBean(HistoryTitleForFwhColdStartStrategy.class));
+        } else {
+            if (Objects.equals(param.getStrategy(), RankStrategyEnum.INFINITE_STRATEGY.getStrategy())) {
+                strategies.add(ServiceBeanFactory.getBean(InfiniteHisTitleStrategy.class));
+            } else {
                 strategies.add(ServiceBeanFactory.getBean(HistoryTitleStrategy.class));
                 strategies.add(ServiceBeanFactory.getBean(LowScoreStrategy.class));
-                break;
+            }
         }
         return strategies;
     }

+ 0 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/filter/strategy/DeDuplicationStrategy.java

@@ -27,7 +27,6 @@ public class DeDuplicationStrategy implements FilterStrategy {
 
     @Override
     public FilterResult filter(FilterParam param) {
-        long start = System.currentTimeMillis();
         FilterResult filterResult = new FilterResult();
         List<String> result;
         List<Content> filterContents = new CopyOnWriteArrayList<>();

+ 2 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/filter/strategy/HistoryTitleForFwhColdStartStrategy.java

@@ -1,5 +1,6 @@
 package com.tzld.longarticle.recommend.server.service.filter.strategy;
 
+import com.tzld.longarticle.recommend.server.common.enums.ArticleTypeEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
 import com.tzld.longarticle.recommend.server.remote.ArticleListRemoteService;
 import com.tzld.longarticle.recommend.server.model.entity.crawler.Article;
@@ -35,7 +36,7 @@ public class HistoryTitleForFwhColdStartStrategy implements FilterStrategy {
         FilterResult filterResult = new FilterResult();
         List<String> result = new ArrayList<>();
         List<Content> filterContents = new ArrayList<>();
-        List<Article> allArticleList = articleListRemoteService.articleList(param.getAccountName(), allIndex);
+        List<Article> allArticleList = articleListRemoteService.articleList(param.getGhId(), allIndex, ArticleTypeEnum.QUNFA.getVal());
         List<String> allTitleList = allArticleList.stream().map(Article::getTitle).distinct().collect(Collectors.toList());
 
         for (Content content : param.getContents()) {

+ 1 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/filter/strategy/HistoryTitleStrategy.java

@@ -47,7 +47,7 @@ public class HistoryTitleStrategy implements FilterStrategy {
         FilterResult filterResult = new FilterResult();
         List<String> result = new ArrayList<>();
         List<Content> filterContents = new ArrayList<>();
-        List<Article> allArticleList = articleListRemoteService.articleList(param.getAccountName(), allIndex);
+        List<Article> allArticleList = articleListRemoteService.articleList(param.getGhId(), allIndex, param.getType());
         List<String> allTitleList = allArticleList.stream().map(Article::getTitle).distinct().collect(Collectors.toList());
         List<String> firstSecondTitleList = allArticleList.stream()
                 .filter(article -> firstSecondIndex.contains(article.getItemIndex()))

+ 91 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/filter/strategy/InfiniteHisTitleStrategy.java

@@ -0,0 +1,91 @@
+package com.tzld.longarticle.recommend.server.service.filter.strategy;
+
+import com.tzld.longarticle.recommend.server.common.ThreadPoolFactory;
+import com.tzld.longarticle.recommend.server.common.enums.ArticleTypeEnum;
+import com.tzld.longarticle.recommend.server.model.dto.Content;
+import com.tzld.longarticle.recommend.server.model.entity.crawler.Article;
+import com.tzld.longarticle.recommend.server.remote.ArticleListRemoteService;
+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.FilterStrategy;
+import com.tzld.longarticle.recommend.server.util.TitleSimilarCheckUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+import org.springframework.util.StringUtils;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.Future;
+import java.util.stream.Collectors;
+
+@Component
+@Slf4j
+public class InfiniteHisTitleStrategy implements FilterStrategy {
+
+    @Autowired
+    private ArticleListRemoteService articleListRemoteService;
+
+    private static final List<Integer> firstSecondIndex = Arrays.asList(1, 2);
+    private static final List<Integer> allIndex = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8);
+
+    private final ExecutorService pool = ThreadPoolFactory.deDuplicatePool();
+
+    @Override
+    public FilterResult filter(FilterParam param) {
+        long start = System.currentTimeMillis();
+        FilterResult filterResult = new FilterResult();
+        List<String> result = new ArrayList<>();
+        List<Content> filterContents = new ArrayList<>();
+        List<Article> allArticleList = articleListRemoteService.articleList(param.getGhId(), allIndex, param.getType());
+        List<String> allTitleList = allArticleList.stream().map(Article::getTitle).distinct().collect(Collectors.toList());
+        List<Article> qunfaArticleList = articleListRemoteService.articleList(param.getGhId(), firstSecondIndex, ArticleTypeEnum.QUNFA.getVal());
+        List<String> qunfaTitleList = qunfaArticleList.stream().map(Article::getTitle).distinct().collect(Collectors.toList());
+        List<Future<Content>> futures = new ArrayList<>();
+        CountDownLatch cdl = new CountDownLatch(param.getContents().size());
+        for (Content content : param.getContents()) {
+            Future<Content> future = pool.submit(() -> {
+                try {
+                    boolean isDuplicate = TitleSimilarCheckUtil.isDuplicateContent(content.getTitle(), qunfaTitleList);
+                    if (!isDuplicate) {
+                        isDuplicate = TitleSimilarCheckUtil.isDuplicateContent(content.getTitle(), allTitleList);
+                    }
+                    if (isDuplicate) {
+                        content.setFilterReason("历史已发布文章");
+                    }
+                    return content;
+                } finally {
+                    cdl.countDown();
+                }
+            });
+            futures.add(future);
+        }
+        try {
+            cdl.await();
+        } catch (InterruptedException e) {
+            log.error("filter error", e);
+            return null;
+        }
+
+        for (Future<Content> f : futures) {
+            try {
+                Content content = f.get();
+                if (StringUtils.hasText(content.getFilterReason())) {
+                    filterContents.add(content);
+                } else {
+                    result.add(content.getId());
+                }
+            } catch (Exception e) {
+                log.error("future get error ", e);
+            }
+        }
+        filterResult.setContentIds(result);
+        filterResult.setFilterContent(filterContents);
+        log.info("InfiniteHisTitleStrategy cost:{}", System.currentTimeMillis() - start);
+        return filterResult;
+    }
+
+}

+ 1 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/RankParam.java

@@ -18,5 +18,6 @@ public class RankParam {
     private String strategy;
     private String scene;
     private List<Integer> userGroupIds;
+    private String type;
 
 }

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

@@ -1,7 +1,6 @@
 package com.tzld.longarticle.recommend.server.service.rank.strategy;
 
 
-import com.tzld.longarticle.recommend.server.common.enums.ArticleTypeEnum;
 import com.tzld.longarticle.recommend.server.common.enums.ScoreStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
 import com.tzld.longarticle.recommend.server.model.entity.crawler.Article;
@@ -83,7 +82,7 @@ public class DefaultRankStrategy implements RankStrategy {
         }
         // 相似度评分为0 报警返回
         List<Article> hisPublishFirstArticleList = articleRepository.getByGhIdAndItemIndexAndTypeEqualsAndStatusEquals(
-                param.getGhId(), 1, ArticleTypeEnum.QUNFA.getVal(), 1);
+                param.getGhId(), 1, param.getType(), 1);
         if (RankStrategy.SimilarityScoreZero(items, param, hisPublishFirstArticleList)) {
             return new RankResult(result);
         }

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

@@ -0,0 +1,80 @@
+package com.tzld.longarticle.recommend.server.service.rank.strategy;
+
+import com.tzld.longarticle.recommend.server.common.enums.ScoreStrategyEnum;
+import com.tzld.longarticle.recommend.server.model.dto.Content;
+import com.tzld.longarticle.recommend.server.service.AccountContentPoolConfigService;
+import com.tzld.longarticle.recommend.server.service.rank.RankItem;
+import com.tzld.longarticle.recommend.server.service.rank.RankParam;
+import com.tzld.longarticle.recommend.server.service.rank.RankResult;
+import com.tzld.longarticle.recommend.server.service.rank.RankStrategy;
+import com.tzld.longarticle.recommend.server.service.score.ScoreParam;
+import com.tzld.longarticle.recommend.server.service.score.ScoreResult;
+import com.tzld.longarticle.recommend.server.service.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;
+
+import java.util.*;
+import java.util.stream.Collectors;
+
+@Service
+@Slf4j
+public class InfiniteRankStrategy implements RankStrategy {
+
+    @Autowired
+    private ScoreService scoreService;
+    @Autowired
+    private AccountContentPoolConfigService accountContentPoolConfigService;
+
+    public RankResult rank(RankParam param) {
+        List<Content> result = new ArrayList<>();
+        String[] contentPools = accountContentPoolConfigService.getContentPools(param.getAccountName());
+        ScoreParam scoreParam = RankStrategy.convertToScoreParam(param);
+        scoreParam.setContents(scoreParam.getContents().stream().filter(
+                c -> contentPools[2].equals(c.getContentPoolType())).collect(Collectors.toList()));
+        ScoreResult scoreResult = scoreService.score(RankStrategy.convertToScoreParam(param));
+
+        Map<String, Map<String, Double>> scoreMap = scoreResult.getScoreMap();
+
+        List<RankItem> items = CommonCollectionUtils.toList(scoreParam.getContents(), c -> {
+            RankItem item = new RankItem();
+            item.setContent(c);
+            c.setScoreMap(scoreMap.get(c.getId()));
+            item.setScoreMap(scoreMap.get(c.getId()));
+            double score = 0.0;
+            if (contentPools[2].equals(item.getContent().getContentPoolType())) {
+                score = item.getScore(ScoreStrategyEnum.SIMILARITY.value())
+                        + item.getScore(ScoreStrategyEnum.CATEGORY.value())
+                        + item.getScore(ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value())
+                        + item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value())
+                        + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value());
+            }
+            c.setScore(score);
+            item.setScore(score);
+            return item;
+        });
+
+        // 1 排序
+        Collections.sort(items, (o1, o2) -> -Double.compare(o1.getScore(), o2.getScore()));
+        // 2 相似去重
+        List<Content> contents = CommonCollectionUtils.toList(items, RankItem::getContent);
+
+        // 3 文章按照内容池分组
+        Map<String, List<Content>> contentMap = new HashMap<>();
+        for (Content c : contents) {
+            List<Content> data = contentMap.computeIfAbsent(c.getContentPoolType(), k -> new ArrayList<>());
+            data.add(c);
+        }
+
+        // 全部使用3-8内容池
+        List<Content> pool = contentMap.get(contentPools[2]);
+        if (CollectionUtils.isNotEmpty(pool)) {
+            result.addAll(pool.subList(0, Math.min(pool.size(), param.getSize())));
+        }
+
+        return new RankResult(result);
+    }
+
+}

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

@@ -74,7 +74,7 @@ public class RankV10Strategy implements RankStrategy {
         });
         // 相似度评分为0 报警返回
         List<Article> hisPublishFirstArticleList = articleRepository.getByGhIdAndItemIndexAndTypeEqualsAndStatusEquals(
-                param.getGhId(), 1, ArticleTypeEnum.QUNFA.getVal(), 1);
+                param.getGhId(), 1, param.getType(), 1);
         if (RankStrategy.SimilarityScoreZero(items, param, hisPublishFirstArticleList)) {
             return new RankResult(result);
         }

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

@@ -95,7 +95,7 @@ public class RankV11Strategy implements RankStrategy {
         });
         // 相似度评分为0 报警返回
         List<Article> hisPublishFirstArticleList = articleRepository.getByGhIdAndItemIndexAndTypeEqualsAndStatusEquals(
-                param.getGhId(), 1, ArticleTypeEnum.QUNFA.getVal(), 1);
+                param.getGhId(), 1, param.getType(), 1);
         if (RankStrategy.SimilarityScoreZero(items, param, hisPublishFirstArticleList)) {
             return new RankResult(result);
         }

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

@@ -95,7 +95,7 @@ public class RankV12Strategy implements RankStrategy {
         });
         // 相似度评分为0 报警返回
         List<Article> hisPublishFirstArticleList = articleRepository.getByGhIdAndItemIndexAndTypeEqualsAndStatusEquals(
-                param.getGhId(), 1, ArticleTypeEnum.QUNFA.getVal(), 1);
+                param.getGhId(), 1, param.getType(), 1);
         if (RankStrategy.SimilarityScoreZero(items, param, hisPublishFirstArticleList)) {
             return new RankResult(result);
         }

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

@@ -96,7 +96,7 @@ public class RankV13Strategy implements RankStrategy {
         });
         // 相似度评分为0 报警返回
         List<Article> hisPublishFirstArticleList = articleRepository.getByGhIdAndItemIndexAndTypeEqualsAndStatusEquals(
-                param.getGhId(), 1, ArticleTypeEnum.QUNFA.getVal(), 1);
+                param.getGhId(), 1, param.getType(), 1);
         if (RankStrategy.SimilarityScoreZero(items, param, hisPublishFirstArticleList)) {
             return new RankResult(result);
         }

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

@@ -96,7 +96,7 @@ public class RankV14Strategy implements RankStrategy {
         });
         // 相似度评分为0 报警返回
         List<Article> hisPublishFirstArticleList = articleRepository.getByGhIdAndItemIndexAndTypeEqualsAndStatusEquals(
-                param.getGhId(), 1, ArticleTypeEnum.QUNFA.getVal(), 1);
+                param.getGhId(), 1, param.getType(), 1);
         if (RankStrategy.SimilarityScoreZero(items, param, hisPublishFirstArticleList)) {
             return new RankResult(result);
         }

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

@@ -73,7 +73,7 @@ public class RankV3Strategy implements RankStrategy {
         });
         // 相似度评分为0 报警返回
         List<Article> hisPublishFirstArticleList = articleRepository.getByGhIdAndItemIndexAndTypeEqualsAndStatusEquals(
-                param.getGhId(), 1, ArticleTypeEnum.QUNFA.getVal(), 1);
+                param.getGhId(), 1, param.getType(), 1);
         if (RankStrategy.SimilarityScoreZero(items, param, hisPublishFirstArticleList)) {
             return new RankResult(result);
         }

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

@@ -73,7 +73,7 @@ public class RankV4Strategy implements RankStrategy {
         });
         // 相似度评分为0 报警返回
         List<Article> hisPublishFirstArticleList = articleRepository.getByGhIdAndItemIndexAndTypeEqualsAndStatusEquals(
-                param.getGhId(), 1, ArticleTypeEnum.QUNFA.getVal(), 1);
+                param.getGhId(), 1, param.getType(), 1);
         if (RankStrategy.SimilarityScoreZero(items, param, hisPublishFirstArticleList)) {
             return new RankResult(result);
         }

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

@@ -1,7 +1,6 @@
 package com.tzld.longarticle.recommend.server.service.rank.strategy;
 
 
-import com.tzld.longarticle.recommend.server.common.enums.ArticleTypeEnum;
 import com.tzld.longarticle.recommend.server.common.enums.RankStrategyEnum;
 import com.tzld.longarticle.recommend.server.common.enums.ScoreStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
@@ -79,7 +78,7 @@ public class RankV5Strategy implements RankStrategy {
         });
         // 相似度评分为0 报警返回
         List<Article> hisPublishFirstArticleList = articleRepository.getByGhIdAndItemIndexAndTypeEqualsAndStatusEquals(
-                param.getGhId(), 1, ArticleTypeEnum.QUNFA.getVal(), 1);
+                param.getGhId(), 1, param.getType(), 1);
         if (RankStrategy.SimilarityScoreZero(items, param, hisPublishFirstArticleList)) {
             return new RankResult(result);
         }

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

@@ -74,7 +74,7 @@ public class RankV7Strategy implements RankStrategy {
         });
         // 相似度评分为0 报警返回
         List<Article> hisPublishFirstArticleList = articleRepository.getByGhIdAndItemIndexAndTypeEqualsAndStatusEquals(
-                param.getGhId(), 1, ArticleTypeEnum.QUNFA.getVal(), 1);
+                param.getGhId(), 1, param.getType(), 1);
         if (RankStrategy.SimilarityScoreZero(items, param, hisPublishFirstArticleList)) {
             return new RankResult(result);
         }

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

@@ -77,7 +77,7 @@ public class RankV8Strategy implements RankStrategy {
         });
         // 相似度评分为0 报警返回
         List<Article> hisPublishFirstArticleList = articleRepository.getByGhIdAndItemIndexAndTypeEqualsAndStatusEquals(
-                param.getGhId(), 1, ArticleTypeEnum.QUNFA.getVal(), 1);
+                param.getGhId(), 1, param.getType(), 1);
         if (RankStrategy.SimilarityScoreZero(items, param, hisPublishFirstArticleList)) {
             return new RankResult(result);
         }

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

@@ -74,7 +74,7 @@ public class RankV9Strategy implements RankStrategy {
         });
         // 相似度评分为0 报警返回
         List<Article> hisPublishFirstArticleList = articleRepository.getByGhIdAndItemIndexAndTypeEqualsAndStatusEquals(
-                param.getGhId(), 1, ArticleTypeEnum.QUNFA.getVal(), 1);
+                param.getGhId(), 1, param.getType(), 1);
         if (RankStrategy.SimilarityScoreZero(items, param, hisPublishFirstArticleList)) {
             return new RankResult(result);
         }

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

@@ -17,6 +17,7 @@ public class FilterParamFactory {
         filterParam.setStrategy(param.getStrategy());
         filterParam.setGhId(param.getGhId());
         filterParam.setScene(param.getScene());
+        filterParam.setType(param.getType());
         return filterParam;
     }
 }

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

@@ -19,4 +19,5 @@ public class RecallParam {
     private List<Content> content;
     // 实现配置化之前,连接各个过程
     private String scene;
+    private String type;
 }

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

@@ -150,7 +150,7 @@ public class RecallService implements ApplicationContextAware {
             return content;
         }
         // 标题历史均值
-        setTitleAvgViewCount(content, param.getGhId());
+        setTitleAvgViewCount(content, param.getGhId(), param.getType());
         // category 查询
         setContentCategory(content);
         return content;
@@ -210,7 +210,7 @@ public class RecallService implements ApplicationContextAware {
         }
     }
 
-    public void setTitleAvgViewCount(List<Content> contentList, String ghId) {
+    public void setTitleAvgViewCount(List<Content> contentList, String ghId, String type) {
         long start = System.currentTimeMillis();
         // 获取账号相关性
         List<AccountCorrelation> accountCorrelationList = accountCorrelationRepository.findByGhIdAndStatus(ghId, 1);
@@ -225,7 +225,7 @@ public class RecallService implements ApplicationContextAware {
         List<Article> hisArticleList = new ArrayList<>();
         List<List<String>> titleMd5Partition = Lists.partition(new ArrayList<>(titleMd5List), 1000);
         for (List<String> titleMd5s : titleMd5Partition) {
-            hisArticleList.addAll(articleRepository.getByTitleMd5InAndTypeEqualsAndStatusEquals(titleMd5s, ArticleTypeEnum.QUNFA.getVal(), 1));
+            hisArticleList.addAll(articleRepository.getByTitleMd5InAndTypeEqualsAndStatusEquals(titleMd5s, type, 1));
         }
         Map<String, Map<Integer, List<Article>>> map = hisArticleList.stream()
                 .collect(Collectors.groupingBy(Article::getTitle, Collectors.groupingBy(Article::getItemIndex)));
@@ -240,7 +240,8 @@ public class RecallService implements ApplicationContextAware {
         // 获取历史已发布文章所属头条内容
         Set<String> ghIds = hisArticleList.stream().map(Article::getGhId).collect(Collectors.toSet());
         Set<String> appMsgIds = hisArticleList.stream().map(Article::getAppMsgId).collect(Collectors.toSet());
-        List<Article> firstIndexHisArticleList = articleRepository.getByGhIdInAndAppMsgIdInAndItemIndexAndTypeEqualsAndStatusEquals(ghIds, appMsgIds, 1, ArticleTypeEnum.QUNFA.getVal(), 1);
+        List<Article> firstIndexHisArticleList = articleRepository.getByGhIdInAndAppMsgIdInAndItemIndexAndTypeEqualsAndStatusEquals(
+                ghIds, appMsgIds, 1, type, 1);
         Map<String, Map<String, Article>> firstIndexHisArticleMap = firstIndexHisArticleList.stream()
                 .collect(Collectors.groupingBy(Article::getGhId, Collectors.toMap(Article::getAppMsgId, o -> o)));
         // 获取发布账号 位置历史均值
@@ -301,12 +302,14 @@ public class RecallService implements ApplicationContextAware {
                         avgViewCount = Optional.ofNullable(indexMap.get(hisArticle.getItemIndex().toString()).getReadAvg())
                                 .orElse(0.0).intValue();
                     } else {
-                        FeishuMessageSender.sendWebHookMessage(FeishuRobotIdEnum.RECOMMEND.getRobotId(),
-                                "历史表现阅读均值获取失败\n"
-                                        + "ghId: " + hisArticle.getGhId() + "\n"
-                                        + "账号名称: " + hisArticle.getAccountName() + "\n"
-                                        + "日期: " + hisPublishDate + "\n"
-                                        + "位置: " + hisArticle.getItemIndex());
+                        if (ArticleTypeEnum.QUNFA.getVal().equals(type)) {
+                            FeishuMessageSender.sendWebHookMessage(FeishuRobotIdEnum.RECOMMEND.getRobotId(),
+                                    "历史表现阅读均值获取失败\n"
+                                            + "ghId: " + hisArticle.getGhId() + "\n"
+                                            + "账号名称: " + hisArticle.getAccountName() + "\n"
+                                            + "日期: " + hisPublishDate + "\n"
+                                            + "位置: " + hisArticle.getItemIndex());
+                        }
                     }
                 }
                 article.setAvgViewCount(avgViewCount);

+ 2 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/score/ScoreService.java

@@ -94,7 +94,8 @@ public class ScoreService implements ApplicationContextAware {
         if (!similarityStopStrategies.contains(param.getStrategy())) {
             strategies.add(strategyMap.get(ScoreStrategyEnum.SIMILARITY.value()));
         }
-        if (StringUtils.equals(param.getStrategy(), RankStrategyEnum.late_Strategy.getStrategy())) {
+        if (StringUtils.equals(param.getStrategy(), RankStrategyEnum.LATE_STRATEGY.getStrategy())
+                || StringUtils.equals(param.getStrategy(), RankStrategyEnum.INFINITE_STRATEGY.getStrategy())) {
             strategies.add(strategyMap.get(ScoreStrategyEnum.CATEGORY.value()));
             strategies.add(strategyMap.get(ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value()));
             strategies.add(strategyMap.get(ScoreStrategyEnum.PUBLISH_TIMES.value()));

+ 2 - 1
long-article-recommend-service/src/test/java/com/tzld/longarticle/recommend/server/ScoreStrategyTest.java

@@ -1,6 +1,7 @@
 package com.tzld.longarticle.recommend.server;
 
 import com.alibaba.fastjson.JSONObject;
+import com.tzld.longarticle.recommend.server.common.enums.ArticleTypeEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
 import com.tzld.longarticle.recommend.server.service.recall.RecallService;
 import com.tzld.longarticle.recommend.server.service.score.Score;
@@ -51,7 +52,7 @@ public class ScoreStrategyTest {
         content.setCrawlerChannelContentId("0065561559007185d167afdd61b9ac5a");
         contentList.add(content);
         param.setContents(contentList);
-        recallService.setTitleAvgViewCount(contentList, "gh_bff0bcb0694a");
+        recallService.setTitleAvgViewCount(contentList, "gh_bff0bcb0694a", ArticleTypeEnum.QUNFA.getVal());
         System.out.println(JSONObject.toJSONString(param.getContents().get(0).getHisPublishArticleList()));
         List<Score> result = viewCountRateStrategy.score(param);
         System.out.println(JSONObject.toJSONString(result));