Browse Source

增加rankV13 rankV14

wangyunpeng 9 months ago
parent
commit
af7a9bb754
16 changed files with 444 additions and 159 deletions
  1. 2 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/common/enums/RankStrategyEnum.java
  2. 2 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/crawler/ArticleRepository.java
  3. 27 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/RankStrategy.java
  4. 8 15
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/DefaultRankStrategy.java
  5. 8 16
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/RankV10Strategy.java
  6. 8 16
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/RankV11Strategy.java
  7. 8 16
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/RankV12Strategy.java
  8. 165 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/RankV13Strategy.java
  9. 165 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/RankV14Strategy.java
  10. 8 16
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/RankV3Strategy.java
  11. 8 16
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/RankV4Strategy.java
  12. 8 15
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/RankV5Strategy.java
  13. 8 16
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/RankV7Strategy.java
  14. 8 16
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/RankV8Strategy.java
  15. 8 16
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/RankV9Strategy.java
  16. 3 1
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/score/ScoreService.java

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

@@ -17,6 +17,8 @@ public enum RankStrategyEnum {
     ArticleRankV10("ArticleRankV10", "ArticleRankV10", "rankV10Strategy"),
     ArticleRankV11("ArticleRankV11", "ArticleRankV11", "rankV11Strategy"),
     ArticleRankV12("ArticleRankV12", "ArticleRankV12", "rankV12Strategy"),
+    ArticleRankV13("ArticleRankV13", "ArticleRankV13", "rankV13Strategy"),
+    ArticleRankV14("ArticleRankV14", "ArticleRankV14", "rankV14Strategy"),
 
     late_Strategy("ArticleRankLate", "晚间策略", "lateRankStrategy"),
     default_strategy("ArticleRankV1", "默认策略", "defaultRankStrategy"),

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

@@ -24,4 +24,6 @@ public interface ArticleRepository extends JpaRepository<Article, String> {
 
     List<Article> getByUpdateTimeGreaterThanAndTypeEquals(Long updateTIme, String type);
 
+    List<Article> getByGhIdAndItemIndexAndTypeEqualsAndStatusEquals(String ghId, Integer itemIndex, String type, Integer status);
+
 }

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

@@ -3,8 +3,12 @@ package com.tzld.longarticle.recommend.server.service.rank;
 
 import com.tzld.longarticle.recommend.server.common.enums.ContentPoolEnum;
 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.service.score.ScoreParam;
+import com.tzld.longarticle.recommend.server.service.score.strategy.SimilarityStrategy;
 import com.tzld.longarticle.recommend.server.util.TitleSimilarCheckUtil;
+import com.tzld.longarticle.recommend.server.util.feishu.FeishuMessageSender;
+import org.apache.commons.collections4.CollectionUtils;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -82,4 +86,27 @@ public interface RankStrategy {
         return result;
     }
 
+    static boolean SimilarityScoreZero(List<RankItem> items, RankParam param, List<Article> articleList) {
+        if (CollectionUtils.isNotEmpty(items)
+                && items.get(0).getScoreMap().containsKey(SimilarityStrategy.class.getSimpleName())
+                && items.get(0).getScoreMap().get(SimilarityStrategy.class.getSimpleName()) == 0) {
+                FeishuMessageSender.sendWebHookMessage("07026a9f-43f5-448b-ba40-a8d71bd6e634",
+                        "内容评分为0\n"
+                                + "ghId: " + param.getGhId() + "\n"
+                                + "账号名称: " + param.getAccountName() + "\n"
+                                + "策略: " + param.getStrategy());
+                return true;
+        }
+        return false;
+    }
+
+    static void sendFeishuFirstPoolEmpty(RankParam param, String contentPool) {
+        FeishuMessageSender.sendWebHookMessage("07026a9f-43f5-448b-ba40-a8d71bd6e634",
+                "内容池1为空\n"
+                        + "ghId: " + param.getGhId() + "\n"
+                        + "账号名称: " + param.getAccountName() + "\n"
+                        + "内容池: " + contentPool + "\n"
+                        + "策略: " + param.getStrategy());
+    }
+
 }

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

@@ -2,6 +2,8 @@ package com.tzld.longarticle.recommend.server.service.rank.strategy;
 
 
 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.repository.crawler.ArticleRepository;
 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;
@@ -13,7 +15,6 @@ import com.tzld.longarticle.recommend.server.service.score.strategy.SimilaritySt
 import com.tzld.longarticle.recommend.server.service.score.strategy.ViewCountStrategy;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import com.tzld.longarticle.recommend.server.util.JSONUtils;
-import com.tzld.longarticle.recommend.server.util.feishu.FeishuMessageSender;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.RandomUtils;
@@ -33,6 +34,8 @@ public class DefaultRankStrategy implements RankStrategy {
     private ScoreService scoreService;
     @Autowired
     private AccountContentPoolConfigService accountContentPoolConfigService;
+    @Autowired
+    private ArticleRepository articleRepository;
 
     public RankResult rank(RankParam param) {
         List<Content> result = new ArrayList<>();
@@ -81,14 +84,9 @@ public class DefaultRankStrategy implements RankStrategy {
             }
         }
         // 相似度评分为0 报警返回
-        if (CollectionUtils.isNotEmpty(items)
-                && items.get(0).getScoreMap().containsKey(SimilarityStrategy.class.getSimpleName())
-                && items.get(0).getScoreMap().get(SimilarityStrategy.class.getSimpleName()) == 0) {
-            FeishuMessageSender.sendWebHookMessage("07026a9f-43f5-448b-ba40-a8d71bd6e634",
-                    "内容评分为0\n"
-                            + "ghId: " + param.getGhId() + "\n"
-                            + "账号名称: " + param.getAccountName() + "\n"
-                            + "策略: " + this.getClass().getSimpleName());
+        List<Article> hisPublishFirstArticleList = articleRepository.getByGhIdAndItemIndexAndTypeEqualsAndStatusEquals(
+                param.getGhId(), 1, "9", 1);
+        if (RankStrategy.SimilarityScoreZero(items, param, hisPublishFirstArticleList)) {
             return new RankResult(result);
         }
 
@@ -113,12 +111,7 @@ public class DefaultRankStrategy implements RankStrategy {
         if (CollectionUtils.isNotEmpty(pool)) {
             result.add(pool.get(RandomUtils.nextInt(0, Math.min(pool.size(), 5))));
         } else {
-            FeishuMessageSender.sendWebHookMessage("07026a9f-43f5-448b-ba40-a8d71bd6e634",
-                    "内容池1为空\n"
-                            + "ghId: " + param.getGhId() + "\n"
-                            + "账号名称: " + param.getAccountName() + "\n"
-                            + "内容池: " + contentPools[0] + "\n"
-                            + "策略: " + this.getClass().getSimpleName());
+            RankStrategy.sendFeishuFirstPoolEmpty(param, contentPools[0]);
             return new RankResult(result);
         }
 

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

@@ -2,6 +2,8 @@ package com.tzld.longarticle.recommend.server.service.rank.strategy;
 
 
 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.repository.crawler.ArticleRepository;
 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;
@@ -12,7 +14,6 @@ import com.tzld.longarticle.recommend.server.service.score.ScoreResult;
 import com.tzld.longarticle.recommend.server.service.score.ScoreService;
 import com.tzld.longarticle.recommend.server.service.score.strategy.*;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
-import com.tzld.longarticle.recommend.server.util.feishu.FeishuMessageSender;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.RandomUtils;
@@ -32,6 +33,8 @@ public class RankV10Strategy implements RankStrategy {
     private ScoreService scoreService;
     @Autowired
     private AccountContentPoolConfigService accountContentPoolConfigService;
+    @Autowired
+    private ArticleRepository articleRepository;
 
     public RankResult rank(RankParam param) {
         List<Content> result = new ArrayList<>();
@@ -69,15 +72,9 @@ public class RankV10Strategy implements RankStrategy {
             return item;
         });
         // 相似度评分为0 报警返回
-        
-        if (CollectionUtils.isNotEmpty(items)
-                && items.get(0).getScoreMap().containsKey(SimilarityStrategy.class.getSimpleName())
-                && items.get(0).getScoreMap().get(SimilarityStrategy.class.getSimpleName()) == 0) {
-            FeishuMessageSender.sendWebHookMessage("07026a9f-43f5-448b-ba40-a8d71bd6e634",
-                    "内容评分为0\n"
-                            + "ghId: " + param.getGhId() + "\n"
-                            + "账号名称: " + param.getAccountName() + "\n"
-                            + "策略: " + this.getClass().getSimpleName());
+        List<Article> hisPublishFirstArticleList = articleRepository.getByGhIdAndItemIndexAndTypeEqualsAndStatusEquals(
+                param.getGhId(), 1, "9", 1);
+        if (RankStrategy.SimilarityScoreZero(items, param, hisPublishFirstArticleList)) {
             return new RankResult(result);
         }
 
@@ -101,12 +98,7 @@ public class RankV10Strategy implements RankStrategy {
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
         } else {
-            FeishuMessageSender.sendWebHookMessage("07026a9f-43f5-448b-ba40-a8d71bd6e634",
-                    "内容池1为空\n"
-                            + "ghId: " + param.getGhId() + "\n"
-                            + "账号名称: " + param.getAccountName() + "\n"
-                            + "内容池: " + contentPools[0] + "\n"
-                            + "策略: " + this.getClass().getSimpleName());
+            RankStrategy.sendFeishuFirstPoolEmpty(param, contentPools[0]);
             return new RankResult(result);
         }
         // 次

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

@@ -3,6 +3,8 @@ package com.tzld.longarticle.recommend.server.service.rank.strategy;
 
 import com.tzld.longarticle.recommend.server.common.enums.RankStrategyEnum;
 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.repository.crawler.ArticleRepository;
 import com.tzld.longarticle.recommend.server.service.AccountContentPoolConfigService;
 import com.tzld.longarticle.recommend.server.service.StrategyIndexScoreWeightService;
 import com.tzld.longarticle.recommend.server.service.rank.*;
@@ -11,7 +13,6 @@ import com.tzld.longarticle.recommend.server.service.score.ScoreResult;
 import com.tzld.longarticle.recommend.server.service.score.ScoreService;
 import com.tzld.longarticle.recommend.server.service.score.strategy.*;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
-import com.tzld.longarticle.recommend.server.util.feishu.FeishuMessageSender;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.RandomUtils;
@@ -32,6 +33,8 @@ public class RankV11Strategy implements RankStrategy {
     @Autowired
     private AccountContentPoolConfigService accountContentPoolConfigService;
     @Autowired
+    private ArticleRepository articleRepository;
+    @Autowired
     private StrategyIndexScoreWeightService weightService;
 
     public RankResult rank(RankParam param) {
@@ -89,15 +92,9 @@ public class RankV11Strategy implements RankStrategy {
             return item;
         });
         // 相似度评分为0 报警返回
-        
-        if (CollectionUtils.isNotEmpty(items)
-                && items.get(0).getScoreMap().containsKey(SimilarityStrategy.class.getSimpleName())
-                && items.get(0).getScoreMap().get(SimilarityStrategy.class.getSimpleName()) == 0) {
-            FeishuMessageSender.sendWebHookMessage("07026a9f-43f5-448b-ba40-a8d71bd6e634",
-                    "内容评分为0\n"
-                            + "ghId: " + param.getGhId() + "\n"
-                            + "账号名称: " + param.getAccountName() + "\n"
-                            + "策略: " + this.getClass().getSimpleName());
+        List<Article> hisPublishFirstArticleList = articleRepository.getByGhIdAndItemIndexAndTypeEqualsAndStatusEquals(
+                param.getGhId(), 1, "9", 1);
+        if (RankStrategy.SimilarityScoreZero(items, param, hisPublishFirstArticleList)) {
             return new RankResult(result);
         }
 
@@ -122,12 +119,7 @@ public class RankV11Strategy implements RankStrategy {
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
         } else {
-            FeishuMessageSender.sendWebHookMessage("07026a9f-43f5-448b-ba40-a8d71bd6e634",
-                    "内容池1为空\n"
-                            + "ghId: " + param.getGhId() + "\n"
-                            + "账号名称: " + param.getAccountName() + "\n"
-                            + "内容池: " + contentPools[0] + "\n"
-                            + "策略: " + this.getClass().getSimpleName());
+            RankStrategy.sendFeishuFirstPoolEmpty(param, contentPools[0]);
             return new RankResult(result);
         }
         // 次

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

@@ -3,6 +3,8 @@ package com.tzld.longarticle.recommend.server.service.rank.strategy;
 
 import com.tzld.longarticle.recommend.server.common.enums.RankStrategyEnum;
 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.repository.crawler.ArticleRepository;
 import com.tzld.longarticle.recommend.server.service.AccountContentPoolConfigService;
 import com.tzld.longarticle.recommend.server.service.StrategyIndexScoreWeightService;
 import com.tzld.longarticle.recommend.server.service.rank.*;
@@ -11,7 +13,6 @@ import com.tzld.longarticle.recommend.server.service.score.ScoreResult;
 import com.tzld.longarticle.recommend.server.service.score.ScoreService;
 import com.tzld.longarticle.recommend.server.service.score.strategy.*;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
-import com.tzld.longarticle.recommend.server.util.feishu.FeishuMessageSender;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.RandomUtils;
@@ -32,6 +33,8 @@ public class RankV12Strategy implements RankStrategy {
     @Autowired
     private AccountContentPoolConfigService accountContentPoolConfigService;
     @Autowired
+    private ArticleRepository articleRepository;
+    @Autowired
     private StrategyIndexScoreWeightService weightService;
 
     public RankResult rank(RankParam param) {
@@ -89,15 +92,9 @@ public class RankV12Strategy implements RankStrategy {
             return item;
         });
         // 相似度评分为0 报警返回
-        
-        if (CollectionUtils.isNotEmpty(items)
-                && items.get(0).getScoreMap().containsKey(SimilarityStrategy.class.getSimpleName())
-                && items.get(0).getScoreMap().get(SimilarityStrategy.class.getSimpleName()) == 0) {
-            FeishuMessageSender.sendWebHookMessage("07026a9f-43f5-448b-ba40-a8d71bd6e634",
-                    "内容评分为0\n"
-                            + "ghId: " + param.getGhId() + "\n"
-                            + "账号名称: " + param.getAccountName() + "\n"
-                            + "策略: " + this.getClass().getSimpleName());
+        List<Article> hisPublishFirstArticleList = articleRepository.getByGhIdAndItemIndexAndTypeEqualsAndStatusEquals(
+                param.getGhId(), 1, "9", 1);
+        if (RankStrategy.SimilarityScoreZero(items, param, hisPublishFirstArticleList)) {
             return new RankResult(result);
         }
 
@@ -122,12 +119,7 @@ public class RankV12Strategy implements RankStrategy {
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
         } else {
-            FeishuMessageSender.sendWebHookMessage("07026a9f-43f5-448b-ba40-a8d71bd6e634",
-                    "内容池1为空\n"
-                            + "ghId: " + param.getGhId() + "\n"
-                            + "账号名称: " + param.getAccountName() + "\n"
-                            + "内容池: " + contentPools[0] + "\n"
-                            + "策略: " + this.getClass().getSimpleName());
+            RankStrategy.sendFeishuFirstPoolEmpty(param, contentPools[0]);
             return new RankResult(result);
         }
         // 次

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

@@ -0,0 +1,165 @@
+package com.tzld.longarticle.recommend.server.service.rank.strategy;
+
+
+import com.tzld.longarticle.recommend.server.common.enums.RankStrategyEnum;
+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.repository.crawler.ArticleRepository;
+import com.tzld.longarticle.recommend.server.service.AccountContentPoolConfigService;
+import com.tzld.longarticle.recommend.server.service.StrategyIndexScoreWeightService;
+import com.tzld.longarticle.recommend.server.service.rank.*;
+import com.tzld.longarticle.recommend.server.service.score.AccountIndexReplacePoolConfig;
+import com.tzld.longarticle.recommend.server.service.score.ScoreResult;
+import com.tzld.longarticle.recommend.server.service.score.ScoreService;
+import com.tzld.longarticle.recommend.server.service.score.strategy.*;
+import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.RandomUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.*;
+
+/**
+ * @author dyp
+ */
+@Service
+@Slf4j
+public class RankV13Strategy implements RankStrategy {
+
+    @Autowired
+    private ScoreService scoreService;
+    @Autowired
+    private AccountContentPoolConfigService accountContentPoolConfigService;
+    @Autowired
+    private ArticleRepository articleRepository;
+    @Autowired
+    private StrategyIndexScoreWeightService weightService;
+
+    public RankResult rank(RankParam param) {
+        List<Content> result = new ArrayList<>();
+        //log.info("RankParam {}", JSONUtils.toJson(param));
+        ScoreResult scoreResult = scoreService.score(RankStrategy.convertToScoreParam(param));
+
+        Map<String, Map<String, Double>> scoreMap = scoreResult.getScoreMap();
+        String[] contentPools = accountContentPoolConfigService.getContentPools(param.getAccountName());
+        Map<Integer, AccountIndexReplacePoolConfig> indexReplacePoolConfigMap = accountContentPoolConfigService.getContentReplacePools(param.getAccountName());
+
+        List<RankItem> items = CommonCollectionUtils.toList(param.getContents(), c -> {
+            RankItem item = new RankItem();
+            item.setContent(c);
+            c.setScoreMap(scoreMap.get(c.getId()));
+            item.setScoreMap(scoreMap.get(c.getId()));
+            double score;
+            if (contentPools[0].equals(item.getContent().getContentPoolType())) {
+                score = item.getScore(HisFissionAvgReadRateRateStrategy.class.getSimpleName())
+                        * weightService.getWeight(param.getStrategy(), 1,
+                        HisFissionAvgReadRateRateStrategy.class.getSimpleName());
+                score += item.getScore(SimilarityStrategy.class.getSimpleName())
+                        * weightService.getWeight(param.getStrategy(), 1,
+                        SimilarityStrategy.class.getSimpleName());
+                if (item.getScore(PublishTimesStrategy.class.getSimpleName()) >= 0) {
+                    score += item.getScore(ViewCountRateStrategy.class.getSimpleName())
+                            * weightService.getWeight(param.getStrategy(), 1,
+                            ViewCountRateStrategy.class.getSimpleName());
+                }
+            } else if (contentPools[1].equals(item.getContent().getContentPoolType())) {
+                score = (item.getScore(SimilarityStrategy.class.getSimpleName())
+                        * weightService.getWeight(param.getStrategy(), 2,
+                        SimilarityStrategy.class.getSimpleName()))
+                        + item.getScore(CategoryStrategy.class.getSimpleName())
+                        + item.getScore(FlowCtlDecreaseStrategy.class.getSimpleName());
+                if (item.getScore(PublishTimesStrategy.class.getSimpleName()) >= 0) {
+                    score += item.getScore(ViewCountRateStrategy.class.getSimpleName())
+                            * weightService.getWeight(param.getStrategy(), 2,
+                            ViewCountRateStrategy.class.getSimpleName());
+                }
+            } else {
+                score = (item.getScore(SimilarityStrategy.class.getSimpleName())
+                        * weightService.getWeight(param.getStrategy(), 3,
+                        SimilarityStrategy.class.getSimpleName()))
+                        + item.getScore(CategoryStrategy.class.getSimpleName())
+                        + (item.getScore(AccountPreDistributeStrategy.class.getSimpleName())
+                        * weightService.getWeight(param.getStrategy(), 3,
+                        AccountPreDistributeStrategy.class.getSimpleName()))
+                        + item.getScore(PublishTimesStrategy.class.getSimpleName())
+                        + item.getScore(FlowCtlDecreaseStrategy.class.getSimpleName());
+            }
+            c.setScore(score);
+            c.setHisPublishArticleList(null);
+            item.setScore(score);
+            return item;
+        });
+        // 相似度评分为0 报警返回
+        List<Article> hisPublishFirstArticleList = articleRepository.getByGhIdAndItemIndexAndTypeEqualsAndStatusEquals(
+                param.getGhId(), 1, "9", 1);
+        if (RankStrategy.SimilarityScoreZero(items, param, hisPublishFirstArticleList)) {
+            return new RankResult(result);
+        }
+
+        // 1 排序
+        Collections.sort(items, (o1, o2) -> -Double.compare(o1.getScore(), o2.getScore()));
+        // 2 相似去重
+        List<Content> contents = CommonCollectionUtils.toList(items, RankItem::getContent);
+//        contents = deduplication(contents);
+
+        // 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);
+        }
+        // 4 选文章
+        String[] publishPool = Arrays.copyOf(contentPools, contentPools.length);
+
+        // 头
+        List<Content> pool1 = contentMap.get(contentPools[0]);
+        RankService.printSortLog(RankStrategyEnum.ArticleRankV13.getStrategy(), param.getAccountName(), pool1);
+        if (CollectionUtils.isNotEmpty(pool1)) {
+            result.add(pool1.get(0));
+        } else {
+            RankStrategy.sendFeishuFirstPoolEmpty(param, contentPools[0]);
+            return new RankResult(result);
+        }
+        // 次
+        List<Content> pool2 = contentMap.get(contentPools[1]);
+        if (CollectionUtils.isNotEmpty(pool2)) {
+            int i = RandomUtils.nextInt(0, Math.min(pool2.size(), 5));
+            int j = RandomUtils.nextInt(0, Math.min(pool2.size(), 5));
+            result.add(pool2.get(i));
+            // 替补 头条内容不足使用次条内容
+            if (result.size() == 1 && pool2.size() > 1) {
+                while (i == j && pool2.size() > 1) {
+                    j = RandomUtils.nextInt(0, Math.min(pool2.size(), 5));
+                    if (i != j) {
+                        publishPool[0] = contentPools[1];
+                        result.add(pool2.get(1));
+                        break;
+                    }
+                }
+            }
+        } 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));
+                }
+            }
+        }
+
+        // 3-8
+        List<Content> pool = contentMap.get(contentPools[2]);
+        if (CollectionUtils.isNotEmpty(pool) && param.getSize() > result.size()) {
+            result.addAll(pool.subList(0, Math.min(pool.size(), param.getSize() - result.size())));
+        }
+
+        RankStrategy.deduplication(result, contentMap, publishPool);
+
+        return new RankResult(result);
+    }
+
+}

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

@@ -0,0 +1,165 @@
+package com.tzld.longarticle.recommend.server.service.rank.strategy;
+
+
+import com.tzld.longarticle.recommend.server.common.enums.RankStrategyEnum;
+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.repository.crawler.ArticleRepository;
+import com.tzld.longarticle.recommend.server.service.AccountContentPoolConfigService;
+import com.tzld.longarticle.recommend.server.service.StrategyIndexScoreWeightService;
+import com.tzld.longarticle.recommend.server.service.rank.*;
+import com.tzld.longarticle.recommend.server.service.score.AccountIndexReplacePoolConfig;
+import com.tzld.longarticle.recommend.server.service.score.ScoreResult;
+import com.tzld.longarticle.recommend.server.service.score.ScoreService;
+import com.tzld.longarticle.recommend.server.service.score.strategy.*;
+import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.collections4.CollectionUtils;
+import org.apache.commons.lang3.RandomUtils;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.*;
+
+/**
+ * @author dyp
+ */
+@Service
+@Slf4j
+public class RankV14Strategy implements RankStrategy {
+
+    @Autowired
+    private ScoreService scoreService;
+    @Autowired
+    private AccountContentPoolConfigService accountContentPoolConfigService;
+    @Autowired
+    private ArticleRepository articleRepository;
+    @Autowired
+    private StrategyIndexScoreWeightService weightService;
+
+    public RankResult rank(RankParam param) {
+        List<Content> result = new ArrayList<>();
+        //log.info("RankParam {}", JSONUtils.toJson(param));
+        ScoreResult scoreResult = scoreService.score(RankStrategy.convertToScoreParam(param));
+
+        Map<String, Map<String, Double>> scoreMap = scoreResult.getScoreMap();
+        String[] contentPools = accountContentPoolConfigService.getContentPools(param.getAccountName());
+        Map<Integer, AccountIndexReplacePoolConfig> indexReplacePoolConfigMap = accountContentPoolConfigService.getContentReplacePools(param.getAccountName());
+
+        List<RankItem> items = CommonCollectionUtils.toList(param.getContents(), c -> {
+            RankItem item = new RankItem();
+            item.setContent(c);
+            c.setScoreMap(scoreMap.get(c.getId()));
+            item.setScoreMap(scoreMap.get(c.getId()));
+            double score;
+            if (contentPools[0].equals(item.getContent().getContentPoolType())) {
+                score = item.getScore(HisFissionDeWeightAvgReadSumRateStrategy.class.getSimpleName())
+                        * weightService.getWeight(param.getStrategy(), 1,
+                        HisFissionDeWeightAvgReadSumRateStrategy.class.getSimpleName());
+                score += item.getScore(SimilarityStrategy.class.getSimpleName())
+                        * weightService.getWeight(param.getStrategy(), 1,
+                        SimilarityStrategy.class.getSimpleName());
+                if (item.getScore(PublishTimesStrategy.class.getSimpleName()) >= 0) {
+                    score += item.getScore(ViewCountRateStrategy.class.getSimpleName())
+                            * weightService.getWeight(param.getStrategy(), 1,
+                            ViewCountRateStrategy.class.getSimpleName());
+                }
+            } else if (contentPools[1].equals(item.getContent().getContentPoolType())) {
+                score = (item.getScore(SimilarityStrategy.class.getSimpleName())
+                        * weightService.getWeight(param.getStrategy(), 2,
+                        SimilarityStrategy.class.getSimpleName()))
+                        + item.getScore(CategoryStrategy.class.getSimpleName())
+                        + item.getScore(FlowCtlDecreaseStrategy.class.getSimpleName());
+                if (item.getScore(PublishTimesStrategy.class.getSimpleName()) >= 0) {
+                    score += item.getScore(ViewCountRateStrategy.class.getSimpleName())
+                            * weightService.getWeight(param.getStrategy(), 2,
+                            ViewCountRateStrategy.class.getSimpleName());
+                }
+            } else {
+                score = (item.getScore(SimilarityStrategy.class.getSimpleName())
+                        * weightService.getWeight(param.getStrategy(), 3,
+                        SimilarityStrategy.class.getSimpleName()))
+                        + item.getScore(CategoryStrategy.class.getSimpleName())
+                        + (item.getScore(AccountPreDistributeStrategy.class.getSimpleName())
+                        * weightService.getWeight(param.getStrategy(), 3,
+                        AccountPreDistributeStrategy.class.getSimpleName()))
+                        + item.getScore(PublishTimesStrategy.class.getSimpleName())
+                        + item.getScore(FlowCtlDecreaseStrategy.class.getSimpleName());
+            }
+            c.setScore(score);
+            c.setHisPublishArticleList(null);
+            item.setScore(score);
+            return item;
+        });
+        // 相似度评分为0 报警返回
+        List<Article> hisPublishFirstArticleList = articleRepository.getByGhIdAndItemIndexAndTypeEqualsAndStatusEquals(
+                param.getGhId(), 1, "9", 1);
+        if (RankStrategy.SimilarityScoreZero(items, param, hisPublishFirstArticleList)) {
+            return new RankResult(result);
+        }
+
+        // 1 排序
+        Collections.sort(items, (o1, o2) -> -Double.compare(o1.getScore(), o2.getScore()));
+        // 2 相似去重
+        List<Content> contents = CommonCollectionUtils.toList(items, RankItem::getContent);
+//        contents = deduplication(contents);
+
+        // 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);
+        }
+        // 4 选文章
+        String[] publishPool = Arrays.copyOf(contentPools, contentPools.length);
+
+        // 头
+        List<Content> pool1 = contentMap.get(contentPools[0]);
+        RankService.printSortLog(RankStrategyEnum.ArticleRankV14.getStrategy(), param.getAccountName(), pool1);
+        if (CollectionUtils.isNotEmpty(pool1)) {
+            result.add(pool1.get(0));
+        } else {
+            RankStrategy.sendFeishuFirstPoolEmpty(param, contentPools[0]);
+            return new RankResult(result);
+        }
+        // 次
+        List<Content> pool2 = contentMap.get(contentPools[1]);
+        if (CollectionUtils.isNotEmpty(pool2)) {
+            int i = RandomUtils.nextInt(0, Math.min(pool2.size(), 5));
+            int j = RandomUtils.nextInt(0, Math.min(pool2.size(), 5));
+            result.add(pool2.get(i));
+            // 替补 头条内容不足使用次条内容
+            if (result.size() == 1 && pool2.size() > 1) {
+                while (i == j && pool2.size() > 1) {
+                    j = RandomUtils.nextInt(0, Math.min(pool2.size(), 5));
+                    if (i != j) {
+                        publishPool[0] = contentPools[1];
+                        result.add(pool2.get(1));
+                        break;
+                    }
+                }
+            }
+        } 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));
+                }
+            }
+        }
+
+        // 3-8
+        List<Content> pool = contentMap.get(contentPools[2]);
+        if (CollectionUtils.isNotEmpty(pool) && param.getSize() > result.size()) {
+            result.addAll(pool.subList(0, Math.min(pool.size(), param.getSize() - result.size())));
+        }
+
+        RankStrategy.deduplication(result, contentMap, publishPool);
+
+        return new RankResult(result);
+    }
+
+}

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

@@ -2,6 +2,8 @@ package com.tzld.longarticle.recommend.server.service.rank.strategy;
 
 
 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.repository.crawler.ArticleRepository;
 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;
@@ -12,7 +14,6 @@ import com.tzld.longarticle.recommend.server.service.score.ScoreResult;
 import com.tzld.longarticle.recommend.server.service.score.ScoreService;
 import com.tzld.longarticle.recommend.server.service.score.strategy.*;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
-import com.tzld.longarticle.recommend.server.util.feishu.FeishuMessageSender;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.RandomUtils;
@@ -32,6 +33,8 @@ public class RankV3Strategy implements RankStrategy {
     private ScoreService scoreService;
     @Autowired
     private AccountContentPoolConfigService accountContentPoolConfigService;
+    @Autowired
+    private ArticleRepository articleRepository;
 
     public RankResult rank(RankParam param) {
         List<Content> result = new ArrayList<>();
@@ -68,15 +71,9 @@ public class RankV3Strategy implements RankStrategy {
             return item;
         });
         // 相似度评分为0 报警返回
-        
-        if (CollectionUtils.isNotEmpty(items)
-                && items.get(0).getScoreMap().containsKey(SimilarityStrategy.class.getSimpleName())
-                && items.get(0).getScoreMap().get(SimilarityStrategy.class.getSimpleName()) == 0) {
-            FeishuMessageSender.sendWebHookMessage("07026a9f-43f5-448b-ba40-a8d71bd6e634",
-                    "内容评分为0\n"
-                            + "ghId: " + param.getGhId() + "\n"
-                            + "账号名称: " + param.getAccountName() + "\n"
-                            + "策略: " + this.getClass().getSimpleName());
+        List<Article> hisPublishFirstArticleList = articleRepository.getByGhIdAndItemIndexAndTypeEqualsAndStatusEquals(
+                param.getGhId(), 1, "9", 1);
+        if (RankStrategy.SimilarityScoreZero(items, param, hisPublishFirstArticleList)) {
             return new RankResult(result);
         }
 
@@ -100,12 +97,7 @@ public class RankV3Strategy implements RankStrategy {
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
         } else {
-            FeishuMessageSender.sendWebHookMessage("07026a9f-43f5-448b-ba40-a8d71bd6e634",
-                    "内容池1为空\n"
-                            + "ghId: " + param.getGhId() + "\n"
-                            + "账号名称: " + param.getAccountName() + "\n"
-                            + "内容池: " + contentPools[0] + "\n"
-                            + "策略: " + this.getClass().getSimpleName());
+            RankStrategy.sendFeishuFirstPoolEmpty(param, contentPools[0]);
             return new RankResult(result);
         }
         // 次

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

@@ -2,6 +2,8 @@ package com.tzld.longarticle.recommend.server.service.rank.strategy;
 
 
 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.repository.crawler.ArticleRepository;
 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;
@@ -12,7 +14,6 @@ import com.tzld.longarticle.recommend.server.service.score.ScoreResult;
 import com.tzld.longarticle.recommend.server.service.score.ScoreService;
 import com.tzld.longarticle.recommend.server.service.score.strategy.*;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
-import com.tzld.longarticle.recommend.server.util.feishu.FeishuMessageSender;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.RandomUtils;
@@ -32,6 +33,8 @@ public class RankV4Strategy implements RankStrategy {
     private ScoreService scoreService;
     @Autowired
     private AccountContentPoolConfigService accountContentPoolConfigService;
+    @Autowired
+    private ArticleRepository articleRepository;
 
     public RankResult rank(RankParam param) {
         List<Content> result = new ArrayList<>();
@@ -68,15 +71,9 @@ public class RankV4Strategy implements RankStrategy {
             return item;
         });
         // 相似度评分为0 报警返回
-        
-        if (CollectionUtils.isNotEmpty(items)
-                && items.get(0).getScoreMap().containsKey(SimilarityStrategy.class.getSimpleName())
-                && items.get(0).getScoreMap().get(SimilarityStrategy.class.getSimpleName()) == 0) {
-            FeishuMessageSender.sendWebHookMessage("07026a9f-43f5-448b-ba40-a8d71bd6e634",
-                    "内容评分为0\n"
-                            + "ghId: " + param.getGhId() + "\n"
-                            + "账号名称: " + param.getAccountName() + "\n"
-                            + "策略: " + this.getClass().getSimpleName());
+        List<Article> hisPublishFirstArticleList = articleRepository.getByGhIdAndItemIndexAndTypeEqualsAndStatusEquals(
+                param.getGhId(), 1, "9", 1);
+        if (RankStrategy.SimilarityScoreZero(items, param, hisPublishFirstArticleList)) {
             return new RankResult(result);
         }
 
@@ -100,12 +97,7 @@ public class RankV4Strategy implements RankStrategy {
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
         } else {
-            FeishuMessageSender.sendWebHookMessage("07026a9f-43f5-448b-ba40-a8d71bd6e634",
-                    "内容池1为空\n"
-                            + "ghId: " + param.getGhId() + "\n"
-                            + "账号名称: " + param.getAccountName() + "\n"
-                            + "内容池: " + contentPools[0] + "\n"
-                            + "策略: " + this.getClass().getSimpleName());
+            RankStrategy.sendFeishuFirstPoolEmpty(param, contentPools[0]);
             return new RankResult(result);
         }
         // 次

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

@@ -3,6 +3,8 @@ package com.tzld.longarticle.recommend.server.service.rank.strategy;
 
 import com.tzld.longarticle.recommend.server.common.enums.RankStrategyEnum;
 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.repository.crawler.ArticleRepository;
 import com.tzld.longarticle.recommend.server.service.AccountContentPoolConfigService;
 import com.tzld.longarticle.recommend.server.service.rank.*;
 import com.tzld.longarticle.recommend.server.service.score.AccountIndexReplacePoolConfig;
@@ -10,7 +12,6 @@ import com.tzld.longarticle.recommend.server.service.score.ScoreResult;
 import com.tzld.longarticle.recommend.server.service.score.ScoreService;
 import com.tzld.longarticle.recommend.server.service.score.strategy.*;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
-import com.tzld.longarticle.recommend.server.util.feishu.FeishuMessageSender;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.RandomUtils;
@@ -30,6 +31,8 @@ public class RankV5Strategy implements RankStrategy {
     private ScoreService scoreService;
     @Autowired
     private AccountContentPoolConfigService accountContentPoolConfigService;
+    @Autowired
+    private ArticleRepository articleRepository;
 
     public RankResult rank(RankParam param) {
         List<Content> result = new ArrayList<>();
@@ -66,14 +69,9 @@ public class RankV5Strategy implements RankStrategy {
             return item;
         });
         // 相似度评分为0 报警返回
-        if (CollectionUtils.isNotEmpty(items)
-                && items.get(0).getScoreMap().containsKey(SimilarityStrategy.class.getSimpleName())
-                && items.get(0).getScoreMap().get(SimilarityStrategy.class.getSimpleName()) == 0) {
-            FeishuMessageSender.sendWebHookMessage("07026a9f-43f5-448b-ba40-a8d71bd6e634",
-                    "内容评分为0\n"
-                            + "ghId: " + param.getGhId() + "\n"
-                            + "账号名称: " + param.getAccountName() + "\n"
-                            + "策略: " + this.getClass().getSimpleName());
+        List<Article> hisPublishFirstArticleList = articleRepository.getByGhIdAndItemIndexAndTypeEqualsAndStatusEquals(
+                param.getGhId(), 1, "9", 1);
+        if (RankStrategy.SimilarityScoreZero(items, param, hisPublishFirstArticleList)) {
             return new RankResult(result);
         }
 
@@ -100,12 +98,7 @@ public class RankV5Strategy implements RankStrategy {
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
         } else {
-            FeishuMessageSender.sendWebHookMessage("07026a9f-43f5-448b-ba40-a8d71bd6e634",
-                    "内容池1为空\n"
-                            + "ghId: " + param.getGhId() + "\n"
-                            + "账号名称: " + param.getAccountName() + "\n"
-                            + "内容池: " + contentPools[0] + "\n"
-                            + "策略: " + this.getClass().getSimpleName());
+            RankStrategy.sendFeishuFirstPoolEmpty(param, contentPools[0]);
             return new RankResult(result);
         }
         // 次

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

@@ -2,6 +2,8 @@ package com.tzld.longarticle.recommend.server.service.rank.strategy;
 
 
 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.repository.crawler.ArticleRepository;
 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;
@@ -12,7 +14,6 @@ import com.tzld.longarticle.recommend.server.service.score.ScoreResult;
 import com.tzld.longarticle.recommend.server.service.score.ScoreService;
 import com.tzld.longarticle.recommend.server.service.score.strategy.*;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
-import com.tzld.longarticle.recommend.server.util.feishu.FeishuMessageSender;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.RandomUtils;
@@ -32,6 +33,8 @@ public class RankV7Strategy implements RankStrategy {
     private ScoreService scoreService;
     @Autowired
     private AccountContentPoolConfigService accountContentPoolConfigService;
+    @Autowired
+    private ArticleRepository articleRepository;
 
     public RankResult rank(RankParam param) {
         List<Content> result = new ArrayList<>();
@@ -69,15 +72,9 @@ public class RankV7Strategy implements RankStrategy {
             return item;
         });
         // 相似度评分为0 报警返回
-        
-        if (CollectionUtils.isNotEmpty(items)
-                && items.get(0).getScoreMap().containsKey(SimilarityStrategy.class.getSimpleName())
-                && items.get(0).getScoreMap().get(SimilarityStrategy.class.getSimpleName()) == 0) {
-            FeishuMessageSender.sendWebHookMessage("07026a9f-43f5-448b-ba40-a8d71bd6e634",
-                    "内容评分为0\n"
-                            + "ghId: " + param.getGhId() + "\n"
-                            + "账号名称: " + param.getAccountName() + "\n"
-                            + "策略: " + this.getClass().getSimpleName());
+        List<Article> hisPublishFirstArticleList = articleRepository.getByGhIdAndItemIndexAndTypeEqualsAndStatusEquals(
+                param.getGhId(), 1, "9", 1);
+        if (RankStrategy.SimilarityScoreZero(items, param, hisPublishFirstArticleList)) {
             return new RankResult(result);
         }
 
@@ -101,12 +98,7 @@ public class RankV7Strategy implements RankStrategy {
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
         } else {
-            FeishuMessageSender.sendWebHookMessage("07026a9f-43f5-448b-ba40-a8d71bd6e634",
-                    "内容池1为空\n"
-                            + "ghId: " + param.getGhId() + "\n"
-                            + "账号名称: " + param.getAccountName() + "\n"
-                            + "内容池: " + contentPools[0] + "\n"
-                            + "策略: " + this.getClass().getSimpleName());
+            RankStrategy.sendFeishuFirstPoolEmpty(param, contentPools[0]);
             return new RankResult(result);
         }
         // 次

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

@@ -2,6 +2,8 @@ package com.tzld.longarticle.recommend.server.service.rank.strategy;
 
 
 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.repository.crawler.ArticleRepository;
 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;
@@ -12,7 +14,6 @@ import com.tzld.longarticle.recommend.server.service.score.ScoreResult;
 import com.tzld.longarticle.recommend.server.service.score.ScoreService;
 import com.tzld.longarticle.recommend.server.service.score.strategy.*;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
-import com.tzld.longarticle.recommend.server.util.feishu.FeishuMessageSender;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.RandomUtils;
@@ -32,6 +33,8 @@ public class RankV8Strategy implements RankStrategy {
     private ScoreService scoreService;
     @Autowired
     private AccountContentPoolConfigService accountContentPoolConfigService;
+    @Autowired
+    private ArticleRepository articleRepository;
 
     public RankResult rank(RankParam param) {
         List<Content> result = new ArrayList<>();
@@ -72,15 +75,9 @@ public class RankV8Strategy implements RankStrategy {
             return item;
         });
         // 相似度评分为0 报警返回
-        
-        if (CollectionUtils.isNotEmpty(items)
-                && items.get(0).getScoreMap().containsKey(SimilarityStrategy.class.getSimpleName())
-                && items.get(0).getScoreMap().get(SimilarityStrategy.class.getSimpleName()) == 0) {
-            FeishuMessageSender.sendWebHookMessage("07026a9f-43f5-448b-ba40-a8d71bd6e634",
-                    "内容评分为0\n"
-                            + "ghId: " + param.getGhId() + "\n"
-                            + "账号名称: " + param.getAccountName() + "\n"
-                            + "策略: " + this.getClass().getSimpleName());
+        List<Article> hisPublishFirstArticleList = articleRepository.getByGhIdAndItemIndexAndTypeEqualsAndStatusEquals(
+                param.getGhId(), 1, "9", 1);
+        if (RankStrategy.SimilarityScoreZero(items, param, hisPublishFirstArticleList)) {
             return new RankResult(result);
         }
 
@@ -104,12 +101,7 @@ public class RankV8Strategy implements RankStrategy {
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
         } else {
-            FeishuMessageSender.sendWebHookMessage("07026a9f-43f5-448b-ba40-a8d71bd6e634",
-                    "内容池1为空\n"
-                            + "ghId: " + param.getGhId() + "\n"
-                            + "账号名称: " + param.getAccountName() + "\n"
-                            + "内容池: " + contentPools[0] + "\n"
-                            + "策略: " + this.getClass().getSimpleName());
+            RankStrategy.sendFeishuFirstPoolEmpty(param, contentPools[0]);
             return new RankResult(result);
         }
         // 次

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

@@ -2,6 +2,8 @@ package com.tzld.longarticle.recommend.server.service.rank.strategy;
 
 
 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.repository.crawler.ArticleRepository;
 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;
@@ -12,7 +14,6 @@ import com.tzld.longarticle.recommend.server.service.score.ScoreResult;
 import com.tzld.longarticle.recommend.server.service.score.ScoreService;
 import com.tzld.longarticle.recommend.server.service.score.strategy.*;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
-import com.tzld.longarticle.recommend.server.util.feishu.FeishuMessageSender;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.RandomUtils;
@@ -32,6 +33,8 @@ public class RankV9Strategy implements RankStrategy {
     private ScoreService scoreService;
     @Autowired
     private AccountContentPoolConfigService accountContentPoolConfigService;
+    @Autowired
+    private ArticleRepository articleRepository;
 
     public RankResult rank(RankParam param) {
         List<Content> result = new ArrayList<>();
@@ -69,15 +72,9 @@ public class RankV9Strategy implements RankStrategy {
             return item;
         });
         // 相似度评分为0 报警返回
-        
-        if (CollectionUtils.isNotEmpty(items)
-                && items.get(0).getScoreMap().containsKey(SimilarityStrategy.class.getSimpleName())
-                && items.get(0).getScoreMap().get(SimilarityStrategy.class.getSimpleName()) == 0) {
-            FeishuMessageSender.sendWebHookMessage("07026a9f-43f5-448b-ba40-a8d71bd6e634",
-                    "内容评分为0\n"
-                            + "ghId: " + param.getGhId() + "\n"
-                            + "账号名称: " + param.getAccountName() + "\n"
-                            + "策略: " + this.getClass().getSimpleName());
+        List<Article> hisPublishFirstArticleList = articleRepository.getByGhIdAndItemIndexAndTypeEqualsAndStatusEquals(
+                param.getGhId(), 1, "9", 1);
+        if (RankStrategy.SimilarityScoreZero(items, param, hisPublishFirstArticleList)) {
             return new RankResult(result);
         }
 
@@ -101,12 +98,7 @@ public class RankV9Strategy implements RankStrategy {
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
         } else {
-            FeishuMessageSender.sendWebHookMessage("07026a9f-43f5-448b-ba40-a8d71bd6e634",
-                    "内容池1为空\n"
-                            + "ghId: " + param.getGhId() + "\n"
-                            + "账号名称: " + param.getAccountName() + "\n"
-                            + "内容池: " + contentPools[0] + "\n"
-                            + "策略: " + this.getClass().getSimpleName());
+            RankStrategy.sendFeishuFirstPoolEmpty(param, contentPools[0]);
             return new RankResult(result);
         }
         // 次

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

@@ -110,7 +110,9 @@ public class ScoreService implements ApplicationContextAware {
                 || StringUtils.equals(param.getStrategy(), RankStrategyEnum.ArticleRankV9.getStrategy())
                 || StringUtils.equals(param.getStrategy(), RankStrategyEnum.ArticleRankV10.getStrategy())
                 || StringUtils.equals(param.getStrategy(), RankStrategyEnum.ArticleRankV11.getStrategy())
-                || StringUtils.equals(param.getStrategy(), RankStrategyEnum.ArticleRankV12.getStrategy())) {
+                || StringUtils.equals(param.getStrategy(), RankStrategyEnum.ArticleRankV12.getStrategy())
+                || StringUtils.equals(param.getStrategy(), RankStrategyEnum.ArticleRankV13.getStrategy())
+                || StringUtils.equals(param.getStrategy(), RankStrategyEnum.ArticleRankV14.getStrategy())) {
             strategies.add(strategyMap.get(CategoryStrategy.class.getSimpleName()));
             strategies.add(strategyMap.get(AccountPreDistributeStrategy.class.getSimpleName()));
             strategies.add(strategyMap.get(FlowCtlDecreaseStrategy.class.getSimpleName()));