Przeglądaj źródła

增加飞书报警 使用titleMd5查询

wangyunpeng 10 miesięcy temu
rodzic
commit
71c5ef8eae
15 zmienionych plików z 175 dodań i 327 usunięć
  1. 2 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/crawler/ArticleRepository.java
  2. 4 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/entity/crawler/Article.java
  3. 32 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/RankStrategy.java
  4. 10 34
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/DefaultRankStrategy.java
  5. 5 34
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/FwhColdStartRankStrategy.java
  6. 9 35
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/RankV10Strategy.java
  7. 1 10
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/RankV2Strategy.java
  8. 9 35
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/RankV3Strategy.java
  9. 9 35
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/RankV4Strategy.java
  10. 9 35
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/RankV5Strategy.java
  11. 9 35
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/RankV7Strategy.java
  12. 9 35
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/RankV8Strategy.java
  13. 8 35
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/RankV9Strategy.java
  14. 5 4
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recall/RecallService.java
  15. 54 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/util/feishu/FeishuMessageSender.java

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

@@ -12,6 +12,8 @@ public interface ArticleRepository extends JpaRepository<Article, String> {
 
     List<Article> getByAccountNameAndItemIndexInAndTypeEquals(String accountName, List<Integer> indexList, String type);
 
+    List<Article> getByTitleMd5InAndTypeEquals(List<String> titleList, String type);
+
     List<Article> getByTitleInAndTypeEquals(List<String> titleList, String type);
 
     List<Article> getByGhIdInAndAppMsgIdInAndItemIndexAndTypeEquals(Set<String> ghIds, Set<String> appMsgIds, Integer itemIndex, String type);

+ 4 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/entity/crawler/Article.java

@@ -66,5 +66,9 @@ public class Article implements Serializable {
     private String wxSn;
     @Column(name = "baseInfo")
     private String baseInfo;
+    @Column(name = "title_md5")
+    private String titleMd5;
+    @Column(name = "article_group")
+    private String articleGroup;
 }
 

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

@@ -1,7 +1,9 @@
 package com.tzld.longarticle.recommend.server.service.rank;
 
 
+import com.tzld.longarticle.recommend.server.common.enums.ContentPoolEnum;
 import com.tzld.longarticle.recommend.server.model.Content;
+import com.tzld.longarticle.recommend.server.service.score.ScoreParam;
 import com.tzld.longarticle.recommend.server.util.TitleSimilarCheckUtil;
 
 import java.util.ArrayList;
@@ -50,4 +52,34 @@ public interface RankStrategy {
         }
     }
 
+    public static ScoreParam convertToScoreParam(RankParam param) {
+        ScoreParam scoreParam = new ScoreParam();
+        scoreParam.setGhId(param.getGhId());
+        scoreParam.setAccountName(param.getAccountName());
+        scoreParam.setContents(param.getContents());
+        scoreParam.setStrategy(param.getStrategy());
+        scoreParam.setScene(param.getScene());
+        return scoreParam;
+    }
+
+
+    public static List<Content> deduplication(List<Content> contents) {
+        List<String> titles = new ArrayList<>();
+        List<Content> result = new ArrayList<>();
+        // 遍历所有列表
+        for (String contentPool : ContentPoolEnum.getOrderContentPool()) {
+            for (Content c : contents) {
+                if (!contentPool.equals(c.getContentPoolType())) {
+                    continue;
+                }
+                if (!TitleSimilarCheckUtil.isDuplicateContent(c.getTitle(), titles)) {
+                    result.add(c);
+                    titles.add(c.getTitle());
+                }
+            }
+        }
+
+        return result;
+    }
+
 }

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

@@ -1,21 +1,19 @@
 package com.tzld.longarticle.recommend.server.service.rank.strategy;
 
 
-import com.tzld.longarticle.recommend.server.common.enums.ContentPoolEnum;
 import com.tzld.longarticle.recommend.server.model.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.service.score.strategy.SimilarityStrategy;
 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.TitleSimilarCheckUtil;
+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;
@@ -37,9 +35,9 @@ public class DefaultRankStrategy implements RankStrategy {
     private AccountContentPoolConfigService accountContentPoolConfigService;
 
     public RankResult rank(RankParam param) {
-
+        List<Content> result = new ArrayList<>();
         //log.info("RankParam {}", JSONUtils.toJson(param));
-        ScoreResult scoreResult = scoreService.score(convertToScoreParam(param));
+        ScoreResult scoreResult = scoreService.score(RankStrategy.convertToScoreParam(param));
         //log.info("ScoreResult {}", JSONUtils.toJson(scoreResult));
 
         Map<String, Map<String, Double>> scoreMap = scoreResult.getScoreMap();
@@ -82,6 +80,12 @@ public class DefaultRankStrategy implements RankStrategy {
                 }
             }
         }
+        // 相似度评分为0 报警返回
+        if (CollectionUtils.isNotEmpty(items) && items.get(0).getScoreMap().get(SimilarityStrategy.class.getSimpleName()) == 0) {
+            FeishuMessageSender.sendWebHookMessage("eca8eee2-33bc-4532-9be1-4ce427cff5fa", param.getAccountName() + " 内容评分为0");
+            return new RankResult(result);
+        }
+
         log.info("Sort result {}", JSONUtils.toJson(sortedItems));
         List<Content> contents = CommonCollectionUtils.toList(sortedItems, RankItem::getContent);
 
@@ -98,13 +102,12 @@ public class DefaultRankStrategy implements RankStrategy {
         }
         log.info("ContentMap {}", JSONUtils.toJson(contentMap));
         // 5 按位置选文章
-        List<Content> result = new ArrayList<>();
-
         // 头
         List<Content> pool = contentMap.get(contentPools[0]);
         if (CollectionUtils.isNotEmpty(pool)) {
             result.add(pool.get(RandomUtils.nextInt(0, Math.min(pool.size(), 5))));
         } else {
+            FeishuMessageSender.sendWebHookMessage("eca8eee2-33bc-4532-9be1-4ce427cff5fa", param.getAccountName() + " 内容池1为空");
             return new RankResult(result);
         }
 
@@ -129,31 +132,4 @@ public class DefaultRankStrategy implements RankStrategy {
         return new RankResult(result);
     }
 
-    private ScoreParam convertToScoreParam(RankParam param) {
-        ScoreParam scoreParam = new ScoreParam();
-        scoreParam.setGhId(param.getGhId());
-        scoreParam.setAccountName(param.getAccountName());
-        scoreParam.setContents(param.getContents());
-        return scoreParam;
-    }
-
-    private List<Content> deduplication(List<Content> contents) {
-        List<String> titles = new ArrayList<>();
-        List<Content> result = new ArrayList<>();
-        // 遍历所有列表
-        for (String contentPool : ContentPoolEnum.getOrderContentPool()) {
-            for (Content c : contents) {
-                if (!contentPool.equals(c.getContentPoolType())) {
-                    continue;
-                }
-                if (!TitleSimilarCheckUtil.isDuplicateContent(c.getTitle(), titles)) {
-                    result.add(c);
-                    titles.add(c.getTitle());
-                }
-            }
-        }
-
-        return result;
-    }
-
 }

+ 5 - 34
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/FwhColdStartRankStrategy.java

@@ -1,25 +1,24 @@
 package com.tzld.longarticle.recommend.server.service.rank.strategy;
 
 
-import com.tzld.longarticle.recommend.server.common.enums.ContentPoolEnum;
 import com.tzld.longarticle.recommend.server.model.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.service.score.strategy.*;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
-import com.tzld.longarticle.recommend.server.util.JSONUtils;
-import com.tzld.longarticle.recommend.server.util.TitleSimilarCheckUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.*;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+import java.util.Map;
 
 /**
  * @author dyp
@@ -35,7 +34,7 @@ public class FwhColdStartRankStrategy implements RankStrategy {
 
     public RankResult rank(RankParam param) {
 
-        ScoreResult scoreResult = scoreService.score(convertToScoreParam(param));
+        ScoreResult scoreResult = scoreService.score(RankStrategy.convertToScoreParam(param));
 
         Map<String, Map<String, Double>> scoreMap = scoreResult.getScoreMap();
         String[] contentPools = accountContentPoolConfigService.getContentPools(param.getAccountName());
@@ -79,32 +78,4 @@ public class FwhColdStartRankStrategy implements RankStrategy {
         return new RankResult(result);
     }
 
-    private ScoreParam convertToScoreParam(RankParam param) {
-        ScoreParam scoreParam = new ScoreParam();
-        scoreParam.setGhId(param.getGhId());
-        scoreParam.setAccountName(param.getAccountName());
-        scoreParam.setContents(param.getContents());
-        scoreParam.setStrategy(param.getStrategy());
-        return scoreParam;
-    }
-
-    private List<Content> deduplication(List<Content> contents) {
-        List<String> titles = new ArrayList<>();
-        List<Content> result = new ArrayList<>();
-        // 遍历所有列表
-        for (String contentPool : ContentPoolEnum.getOrderContentPool()) {
-            for (Content c : contents) {
-                if (!contentPool.equals(c.getContentPoolType())) {
-                    continue;
-                }
-                if (!TitleSimilarCheckUtil.isDuplicateContent(c.getTitle(), titles)) {
-                    result.add(c);
-                    titles.add(c.getTitle());
-                }
-            }
-        }
-
-        return result;
-    }
-
 }

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

@@ -1,7 +1,6 @@
 package com.tzld.longarticle.recommend.server.service.rank.strategy;
 
 
-import com.tzld.longarticle.recommend.server.common.enums.ContentPoolEnum;
 import com.tzld.longarticle.recommend.server.model.Content;
 import com.tzld.longarticle.recommend.server.service.AccountContentPoolConfigService;
 import com.tzld.longarticle.recommend.server.service.rank.RankItem;
@@ -9,12 +8,11 @@ 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.AccountIndexReplacePoolConfig;
-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.service.score.strategy.*;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
-import com.tzld.longarticle.recommend.server.util.TitleSimilarCheckUtil;
+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;
@@ -36,9 +34,9 @@ public class RankV10Strategy implements RankStrategy {
     private AccountContentPoolConfigService accountContentPoolConfigService;
 
     public RankResult rank(RankParam param) {
-
+        List<Content> result = new ArrayList<>();
         //log.info("RankParam {}", JSONUtils.toJson(param));
-        ScoreResult scoreResult = scoreService.score(convertToScoreParam(param));
+        ScoreResult scoreResult = scoreService.score(RankStrategy.convertToScoreParam(param));
 
         Map<String, Map<String, Double>> scoreMap = scoreResult.getScoreMap();
         String[] contentPools = accountContentPoolConfigService.getContentPools(param.getAccountName());
@@ -70,6 +68,11 @@ public class RankV10Strategy implements RankStrategy {
             item.setScore(score);
             return item;
         });
+        // 相似度评分为0 报警返回
+        if (CollectionUtils.isNotEmpty(items) && items.get(0).getScoreMap().get(SimilarityStrategy.class.getSimpleName()) == 0) {
+            FeishuMessageSender.sendWebHookMessage("eca8eee2-33bc-4532-9be1-4ce427cff5fa", param.getAccountName() + " 内容评分为0");
+            return new RankResult(result);
+        }
 
         // 1 排序
         Collections.sort(items, (o1, o2) -> -Double.compare(o1.getScore(), o2.getScore()));
@@ -84,7 +87,6 @@ public class RankV10Strategy implements RankStrategy {
             data.add(c);
         }
         // 4 选文章
-        List<Content> result = new ArrayList<>();
         String[] publishPool = Arrays.copyOf(contentPools, contentPools.length);
 
         // 头
@@ -92,6 +94,7 @@ public class RankV10Strategy implements RankStrategy {
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
         } else {
+            FeishuMessageSender.sendWebHookMessage("eca8eee2-33bc-4532-9be1-4ce427cff5fa", param.getAccountName() + " 内容池1为空");
             return new RankResult(result);
         }
         // 次
@@ -134,33 +137,4 @@ public class RankV10Strategy implements RankStrategy {
         return new RankResult(result);
     }
 
-    private ScoreParam convertToScoreParam(RankParam param) {
-        ScoreParam scoreParam = new ScoreParam();
-        scoreParam.setGhId(param.getGhId());
-        scoreParam.setAccountName(param.getAccountName());
-        scoreParam.setContents(param.getContents());
-        scoreParam.setStrategy(param.getStrategy());
-        scoreParam.setScene(param.getScene());
-        return scoreParam;
-    }
-
-    private List<Content> deduplication(List<Content> contents) {
-        List<String> titles = new ArrayList<>();
-        List<Content> result = new ArrayList<>();
-        // 遍历所有列表
-        for (String contentPool : ContentPoolEnum.getOrderContentPool()) {
-            for (Content c : contents) {
-                if (!contentPool.equals(c.getContentPoolType())) {
-                    continue;
-                }
-                if (!TitleSimilarCheckUtil.isDuplicateContent(c.getTitle(), titles)) {
-                    result.add(c);
-                    titles.add(c.getTitle());
-                }
-            }
-        }
-
-        return result;
-    }
-
 }

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

@@ -6,7 +6,6 @@ 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.service.score.strategy.SimilarityStrategy;
@@ -35,7 +34,7 @@ public class RankV2Strategy implements RankStrategy {
     public RankResult rank(RankParam param) {
 
         //log.info("RankParam {}", JSONUtils.toJson(param));
-        ScoreResult scoreResult = scoreService.score(convertToScoreParam(param));
+        ScoreResult scoreResult = scoreService.score(RankStrategy.convertToScoreParam(param));
         //log.info("ScoreResult {}", JSONUtils.toJson(scoreResult));
 
         Map<String, Map<String, Double>> scoreMap = scoreResult.getScoreMap();
@@ -73,12 +72,4 @@ public class RankV2Strategy implements RankStrategy {
         return new RankResult(result);
     }
 
-    private ScoreParam convertToScoreParam(RankParam param) {
-        ScoreParam scoreParam = new ScoreParam();
-        scoreParam.setGhId(param.getGhId());
-        scoreParam.setAccountName(param.getAccountName());
-        scoreParam.setContents(param.getContents());
-        return scoreParam;
-    }
-
 }

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

@@ -1,7 +1,6 @@
 package com.tzld.longarticle.recommend.server.service.rank.strategy;
 
 
-import com.tzld.longarticle.recommend.server.common.enums.ContentPoolEnum;
 import com.tzld.longarticle.recommend.server.model.Content;
 import com.tzld.longarticle.recommend.server.service.AccountContentPoolConfigService;
 import com.tzld.longarticle.recommend.server.service.rank.RankItem;
@@ -9,12 +8,11 @@ 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.AccountIndexReplacePoolConfig;
-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.service.score.strategy.*;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
-import com.tzld.longarticle.recommend.server.util.TitleSimilarCheckUtil;
+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;
@@ -36,9 +34,9 @@ public class RankV3Strategy implements RankStrategy {
     private AccountContentPoolConfigService accountContentPoolConfigService;
 
     public RankResult rank(RankParam param) {
-
+        List<Content> result = new ArrayList<>();
         //log.info("RankParam {}", JSONUtils.toJson(param));
-        ScoreResult scoreResult = scoreService.score(convertToScoreParam(param));
+        ScoreResult scoreResult = scoreService.score(RankStrategy.convertToScoreParam(param));
 
         Map<String, Map<String, Double>> scoreMap = scoreResult.getScoreMap();
         String[] contentPools = accountContentPoolConfigService.getContentPools(param.getAccountName());
@@ -69,6 +67,11 @@ public class RankV3Strategy implements RankStrategy {
             item.setScore(score);
             return item;
         });
+        // 相似度评分为0 报警返回
+        if (CollectionUtils.isNotEmpty(items) && items.get(0).getScoreMap().get(SimilarityStrategy.class.getSimpleName()) == 0) {
+            FeishuMessageSender.sendWebHookMessage("eca8eee2-33bc-4532-9be1-4ce427cff5fa", param.getAccountName() + " 内容评分为0");
+            return new RankResult(result);
+        }
 
         // 1 排序
         Collections.sort(items, (o1, o2) -> -Double.compare(o1.getScore(), o2.getScore()));
@@ -83,7 +86,6 @@ public class RankV3Strategy implements RankStrategy {
             data.add(c);
         }
         // 4 选文章
-        List<Content> result = new ArrayList<>();
         String[] publishPool = Arrays.copyOf(contentPools, contentPools.length);
 
         // 头
@@ -91,6 +93,7 @@ public class RankV3Strategy implements RankStrategy {
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
         } else {
+            FeishuMessageSender.sendWebHookMessage("eca8eee2-33bc-4532-9be1-4ce427cff5fa", param.getAccountName() + " 内容池1为空");
             return new RankResult(result);
         }
         // 次
@@ -121,33 +124,4 @@ public class RankV3Strategy implements RankStrategy {
         return new RankResult(result);
     }
 
-    private ScoreParam convertToScoreParam(RankParam param) {
-        ScoreParam scoreParam = new ScoreParam();
-        scoreParam.setGhId(param.getGhId());
-        scoreParam.setAccountName(param.getAccountName());
-        scoreParam.setContents(param.getContents());
-        scoreParam.setStrategy(param.getStrategy());
-        scoreParam.setScene(param.getScene());
-        return scoreParam;
-    }
-
-    private List<Content> deduplication(List<Content> contents) {
-        List<String> titles = new ArrayList<>();
-        List<Content> result = new ArrayList<>();
-        // 遍历所有列表
-        for (String contentPool : ContentPoolEnum.getOrderContentPool()) {
-            for (Content c : contents) {
-                if (!contentPool.equals(c.getContentPoolType())) {
-                    continue;
-                }
-                if (!TitleSimilarCheckUtil.isDuplicateContent(c.getTitle(), titles)) {
-                    result.add(c);
-                    titles.add(c.getTitle());
-                }
-            }
-        }
-
-        return result;
-    }
-
 }

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

@@ -1,7 +1,6 @@
 package com.tzld.longarticle.recommend.server.service.rank.strategy;
 
 
-import com.tzld.longarticle.recommend.server.common.enums.ContentPoolEnum;
 import com.tzld.longarticle.recommend.server.model.Content;
 import com.tzld.longarticle.recommend.server.service.AccountContentPoolConfigService;
 import com.tzld.longarticle.recommend.server.service.rank.RankItem;
@@ -9,12 +8,11 @@ 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.AccountIndexReplacePoolConfig;
-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.service.score.strategy.*;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
-import com.tzld.longarticle.recommend.server.util.TitleSimilarCheckUtil;
+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;
@@ -36,9 +34,9 @@ public class RankV4Strategy implements RankStrategy {
     private AccountContentPoolConfigService accountContentPoolConfigService;
 
     public RankResult rank(RankParam param) {
-
+        List<Content> result = new ArrayList<>();
         //log.info("RankParam {}", JSONUtils.toJson(param));
-        ScoreResult scoreResult = scoreService.score(convertToScoreParam(param));
+        ScoreResult scoreResult = scoreService.score(RankStrategy.convertToScoreParam(param));
 
         Map<String, Map<String, Double>> scoreMap = scoreResult.getScoreMap();
         String[] contentPools = accountContentPoolConfigService.getContentPools(param.getAccountName());
@@ -69,6 +67,11 @@ public class RankV4Strategy implements RankStrategy {
             item.setScore(score);
             return item;
         });
+        // 相似度评分为0 报警返回
+        if (CollectionUtils.isNotEmpty(items) && items.get(0).getScoreMap().get(SimilarityStrategy.class.getSimpleName()) == 0) {
+            FeishuMessageSender.sendWebHookMessage("eca8eee2-33bc-4532-9be1-4ce427cff5fa", param.getAccountName() + " 内容评分为0");
+            return new RankResult(result);
+        }
 
         // 1 排序
         Collections.sort(items, (o1, o2) -> -Double.compare(o1.getScore(), o2.getScore()));
@@ -83,7 +86,6 @@ public class RankV4Strategy implements RankStrategy {
             data.add(c);
         }
         // 4 选文章
-        List<Content> result = new ArrayList<>();
         String[] publishPool = Arrays.copyOf(contentPools, contentPools.length);
 
         // 头
@@ -91,6 +93,7 @@ public class RankV4Strategy implements RankStrategy {
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
         } else {
+            FeishuMessageSender.sendWebHookMessage("eca8eee2-33bc-4532-9be1-4ce427cff5fa", param.getAccountName() + " 内容池1为空");
             return new RankResult(result);
         }
         // 次
@@ -133,33 +136,4 @@ public class RankV4Strategy implements RankStrategy {
         return new RankResult(result);
     }
 
-    private ScoreParam convertToScoreParam(RankParam param) {
-        ScoreParam scoreParam = new ScoreParam();
-        scoreParam.setGhId(param.getGhId());
-        scoreParam.setAccountName(param.getAccountName());
-        scoreParam.setContents(param.getContents());
-        scoreParam.setStrategy(param.getStrategy());
-        scoreParam.setScene(param.getScene());
-        return scoreParam;
-    }
-
-    private List<Content> deduplication(List<Content> contents) {
-        List<String> titles = new ArrayList<>();
-        List<Content> result = new ArrayList<>();
-        // 遍历所有列表
-        for (String contentPool : ContentPoolEnum.getOrderContentPool()) {
-            for (Content c : contents) {
-                if (!contentPool.equals(c.getContentPoolType())) {
-                    continue;
-                }
-                if (!TitleSimilarCheckUtil.isDuplicateContent(c.getTitle(), titles)) {
-                    result.add(c);
-                    titles.add(c.getTitle());
-                }
-            }
-        }
-
-        return result;
-    }
-
 }

+ 9 - 35
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.ContentPoolEnum;
 import com.tzld.longarticle.recommend.server.model.Content;
 import com.tzld.longarticle.recommend.server.service.AccountContentPoolConfigService;
 import com.tzld.longarticle.recommend.server.service.rank.RankItem;
@@ -9,12 +8,11 @@ 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.AccountIndexReplacePoolConfig;
-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.service.score.strategy.*;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
-import com.tzld.longarticle.recommend.server.util.TitleSimilarCheckUtil;
+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;
@@ -36,9 +34,9 @@ public class RankV5Strategy implements RankStrategy {
     private AccountContentPoolConfigService accountContentPoolConfigService;
 
     public RankResult rank(RankParam param) {
-
+        List<Content> result = new ArrayList<>();
         //log.info("RankParam {}", JSONUtils.toJson(param));
-        ScoreResult scoreResult = scoreService.score(convertToScoreParam(param));
+        ScoreResult scoreResult = scoreService.score(RankStrategy.convertToScoreParam(param));
 
         Map<String, Map<String, Double>> scoreMap = scoreResult.getScoreMap();
         String[] contentPools = accountContentPoolConfigService.getContentPools(param.getAccountName());
@@ -69,6 +67,11 @@ public class RankV5Strategy implements RankStrategy {
             item.setScore(score);
             return item;
         });
+        // 相似度评分为0 报警返回
+        if (CollectionUtils.isNotEmpty(items) && items.get(0).getScoreMap().get(SimilarityStrategy.class.getSimpleName()) == 0) {
+            FeishuMessageSender.sendWebHookMessage("eca8eee2-33bc-4532-9be1-4ce427cff5fa", param.getAccountName() + " 内容评分为0");
+            return new RankResult(result);
+        }
 
         // 1 排序
         Collections.sort(items, (o1, o2) -> -Double.compare(o1.getScore(), o2.getScore()));
@@ -83,7 +86,6 @@ public class RankV5Strategy implements RankStrategy {
             data.add(c);
         }
         // 4 选文章
-        List<Content> result = new ArrayList<>();
         String[] publishPool = Arrays.copyOf(contentPools, contentPools.length);
 
         // 头
@@ -91,6 +93,7 @@ public class RankV5Strategy implements RankStrategy {
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
         } else {
+            FeishuMessageSender.sendWebHookMessage("eca8eee2-33bc-4532-9be1-4ce427cff5fa", param.getAccountName() + " 内容池1为空");
             return new RankResult(result);
         }
         // 次
@@ -133,33 +136,4 @@ public class RankV5Strategy implements RankStrategy {
         return new RankResult(result);
     }
 
-    private ScoreParam convertToScoreParam(RankParam param) {
-        ScoreParam scoreParam = new ScoreParam();
-        scoreParam.setGhId(param.getGhId());
-        scoreParam.setAccountName(param.getAccountName());
-        scoreParam.setContents(param.getContents());
-        scoreParam.setStrategy(param.getStrategy());
-        scoreParam.setScene(param.getScene());
-        return scoreParam;
-    }
-
-    private List<Content> deduplication(List<Content> contents) {
-        List<String> titles = new ArrayList<>();
-        List<Content> result = new ArrayList<>();
-        // 遍历所有列表
-        for (String contentPool : ContentPoolEnum.getOrderContentPool()) {
-            for (Content c : contents) {
-                if (!contentPool.equals(c.getContentPoolType())) {
-                    continue;
-                }
-                if (!TitleSimilarCheckUtil.isDuplicateContent(c.getTitle(), titles)) {
-                    result.add(c);
-                    titles.add(c.getTitle());
-                }
-            }
-        }
-
-        return result;
-    }
-
 }

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

@@ -1,7 +1,6 @@
 package com.tzld.longarticle.recommend.server.service.rank.strategy;
 
 
-import com.tzld.longarticle.recommend.server.common.enums.ContentPoolEnum;
 import com.tzld.longarticle.recommend.server.model.Content;
 import com.tzld.longarticle.recommend.server.service.AccountContentPoolConfigService;
 import com.tzld.longarticle.recommend.server.service.rank.RankItem;
@@ -9,12 +8,11 @@ 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.AccountIndexReplacePoolConfig;
-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.service.score.strategy.*;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
-import com.tzld.longarticle.recommend.server.util.TitleSimilarCheckUtil;
+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;
@@ -36,9 +34,9 @@ public class RankV7Strategy implements RankStrategy {
     private AccountContentPoolConfigService accountContentPoolConfigService;
 
     public RankResult rank(RankParam param) {
-
+        List<Content> result = new ArrayList<>();
         //log.info("RankParam {}", JSONUtils.toJson(param));
-        ScoreResult scoreResult = scoreService.score(convertToScoreParam(param));
+        ScoreResult scoreResult = scoreService.score(RankStrategy.convertToScoreParam(param));
 
         Map<String, Map<String, Double>> scoreMap = scoreResult.getScoreMap();
         String[] contentPools = accountContentPoolConfigService.getContentPools(param.getAccountName());
@@ -70,6 +68,11 @@ public class RankV7Strategy implements RankStrategy {
             item.setScore(score);
             return item;
         });
+        // 相似度评分为0 报警返回
+        if (CollectionUtils.isNotEmpty(items) && items.get(0).getScoreMap().get(SimilarityStrategy.class.getSimpleName()) == 0) {
+            FeishuMessageSender.sendWebHookMessage("eca8eee2-33bc-4532-9be1-4ce427cff5fa", param.getAccountName() + " 内容评分为0");
+            return new RankResult(result);
+        }
 
         // 1 排序
         Collections.sort(items, (o1, o2) -> -Double.compare(o1.getScore(), o2.getScore()));
@@ -84,7 +87,6 @@ public class RankV7Strategy implements RankStrategy {
             data.add(c);
         }
         // 4 选文章
-        List<Content> result = new ArrayList<>();
         String[] publishPool = Arrays.copyOf(contentPools, contentPools.length);
 
         // 头
@@ -92,6 +94,7 @@ public class RankV7Strategy implements RankStrategy {
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
         } else {
+            FeishuMessageSender.sendWebHookMessage("eca8eee2-33bc-4532-9be1-4ce427cff5fa", param.getAccountName() + " 内容池1为空");
             return new RankResult(result);
         }
         // 次
@@ -134,33 +137,4 @@ public class RankV7Strategy implements RankStrategy {
         return new RankResult(result);
     }
 
-    private ScoreParam convertToScoreParam(RankParam param) {
-        ScoreParam scoreParam = new ScoreParam();
-        scoreParam.setGhId(param.getGhId());
-        scoreParam.setAccountName(param.getAccountName());
-        scoreParam.setContents(param.getContents());
-        scoreParam.setStrategy(param.getStrategy());
-        scoreParam.setScene(param.getScene());
-        return scoreParam;
-    }
-
-    private List<Content> deduplication(List<Content> contents) {
-        List<String> titles = new ArrayList<>();
-        List<Content> result = new ArrayList<>();
-        // 遍历所有列表
-        for (String contentPool : ContentPoolEnum.getOrderContentPool()) {
-            for (Content c : contents) {
-                if (!contentPool.equals(c.getContentPoolType())) {
-                    continue;
-                }
-                if (!TitleSimilarCheckUtil.isDuplicateContent(c.getTitle(), titles)) {
-                    result.add(c);
-                    titles.add(c.getTitle());
-                }
-            }
-        }
-
-        return result;
-    }
-
 }

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

@@ -1,7 +1,6 @@
 package com.tzld.longarticle.recommend.server.service.rank.strategy;
 
 
-import com.tzld.longarticle.recommend.server.common.enums.ContentPoolEnum;
 import com.tzld.longarticle.recommend.server.model.Content;
 import com.tzld.longarticle.recommend.server.service.AccountContentPoolConfigService;
 import com.tzld.longarticle.recommend.server.service.rank.RankItem;
@@ -9,12 +8,11 @@ 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.AccountIndexReplacePoolConfig;
-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.service.score.strategy.*;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
-import com.tzld.longarticle.recommend.server.util.TitleSimilarCheckUtil;
+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;
@@ -36,9 +34,9 @@ public class RankV8Strategy implements RankStrategy {
     private AccountContentPoolConfigService accountContentPoolConfigService;
 
     public RankResult rank(RankParam param) {
-
+        List<Content> result = new ArrayList<>();
         //log.info("RankParam {}", JSONUtils.toJson(param));
-        ScoreResult scoreResult = scoreService.score(convertToScoreParam(param));
+        ScoreResult scoreResult = scoreService.score(RankStrategy.convertToScoreParam(param));
 
         Map<String, Map<String, Double>> scoreMap = scoreResult.getScoreMap();
         String[] contentPools = accountContentPoolConfigService.getContentPools(param.getAccountName());
@@ -73,6 +71,11 @@ public class RankV8Strategy implements RankStrategy {
             item.setScore(score);
             return item;
         });
+        // 相似度评分为0 报警返回
+        if (CollectionUtils.isNotEmpty(items) && items.get(0).getScoreMap().get(SimilarityStrategy.class.getSimpleName()) == 0) {
+            FeishuMessageSender.sendWebHookMessage("eca8eee2-33bc-4532-9be1-4ce427cff5fa", param.getAccountName() + " 内容评分为0");
+            return new RankResult(result);
+        }
 
         // 1 排序
         Collections.sort(items, (o1, o2) -> -Double.compare(o1.getScore(), o2.getScore()));
@@ -87,7 +90,6 @@ public class RankV8Strategy implements RankStrategy {
             data.add(c);
         }
         // 4 选文章
-        List<Content> result = new ArrayList<>();
         String[] publishPool = Arrays.copyOf(contentPools, contentPools.length);
 
         // 头
@@ -95,6 +97,7 @@ public class RankV8Strategy implements RankStrategy {
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
         } else {
+            FeishuMessageSender.sendWebHookMessage("eca8eee2-33bc-4532-9be1-4ce427cff5fa", param.getAccountName() + " 内容池1为空");
             return new RankResult(result);
         }
         // 次
@@ -137,33 +140,4 @@ public class RankV8Strategy implements RankStrategy {
         return new RankResult(result);
     }
 
-    private ScoreParam convertToScoreParam(RankParam param) {
-        ScoreParam scoreParam = new ScoreParam();
-        scoreParam.setGhId(param.getGhId());
-        scoreParam.setAccountName(param.getAccountName());
-        scoreParam.setContents(param.getContents());
-        scoreParam.setStrategy(param.getStrategy());
-        scoreParam.setScene(param.getScene());
-        return scoreParam;
-    }
-
-    private List<Content> deduplication(List<Content> contents) {
-        List<String> titles = new ArrayList<>();
-        List<Content> result = new ArrayList<>();
-        // 遍历所有列表
-        for (String contentPool : ContentPoolEnum.getOrderContentPool()) {
-            for (Content c : contents) {
-                if (!contentPool.equals(c.getContentPoolType())) {
-                    continue;
-                }
-                if (!TitleSimilarCheckUtil.isDuplicateContent(c.getTitle(), titles)) {
-                    result.add(c);
-                    titles.add(c.getTitle());
-                }
-            }
-        }
-
-        return result;
-    }
-
 }

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

@@ -1,7 +1,6 @@
 package com.tzld.longarticle.recommend.server.service.rank.strategy;
 
 
-import com.tzld.longarticle.recommend.server.common.enums.ContentPoolEnum;
 import com.tzld.longarticle.recommend.server.model.Content;
 import com.tzld.longarticle.recommend.server.service.AccountContentPoolConfigService;
 import com.tzld.longarticle.recommend.server.service.rank.RankItem;
@@ -9,12 +8,11 @@ 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.AccountIndexReplacePoolConfig;
-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.service.score.strategy.*;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
-import com.tzld.longarticle.recommend.server.util.TitleSimilarCheckUtil;
+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;
@@ -36,9 +34,9 @@ public class RankV9Strategy implements RankStrategy {
     private AccountContentPoolConfigService accountContentPoolConfigService;
 
     public RankResult rank(RankParam param) {
-
+        List<Content> result = new ArrayList<>();
         //log.info("RankParam {}", JSONUtils.toJson(param));
-        ScoreResult scoreResult = scoreService.score(convertToScoreParam(param));
+        ScoreResult scoreResult = scoreService.score(RankStrategy.convertToScoreParam(param));
 
         Map<String, Map<String, Double>> scoreMap = scoreResult.getScoreMap();
         String[] contentPools = accountContentPoolConfigService.getContentPools(param.getAccountName());
@@ -70,6 +68,11 @@ public class RankV9Strategy implements RankStrategy {
             item.setScore(score);
             return item;
         });
+        // 相似度评分为0 报警返回
+        if (CollectionUtils.isNotEmpty(items) && items.get(0).getScoreMap().get(SimilarityStrategy.class.getSimpleName()) == 0) {
+            FeishuMessageSender.sendWebHookMessage("eca8eee2-33bc-4532-9be1-4ce427cff5fa", param.getAccountName() + " 内容评分为0");
+            return new RankResult(result);
+        }
 
         // 1 排序
         Collections.sort(items, (o1, o2) -> -Double.compare(o1.getScore(), o2.getScore()));
@@ -84,7 +87,6 @@ public class RankV9Strategy implements RankStrategy {
             data.add(c);
         }
         // 4 选文章
-        List<Content> result = new ArrayList<>();
         String[] publishPool = Arrays.copyOf(contentPools, contentPools.length);
 
         // 头
@@ -134,33 +136,4 @@ public class RankV9Strategy implements RankStrategy {
         return new RankResult(result);
     }
 
-    private ScoreParam convertToScoreParam(RankParam param) {
-        ScoreParam scoreParam = new ScoreParam();
-        scoreParam.setGhId(param.getGhId());
-        scoreParam.setAccountName(param.getAccountName());
-        scoreParam.setContents(param.getContents());
-        scoreParam.setStrategy(param.getStrategy());
-        scoreParam.setScene(param.getScene());
-        return scoreParam;
-    }
-
-    private List<Content> deduplication(List<Content> contents) {
-        List<String> titles = new ArrayList<>();
-        List<Content> result = new ArrayList<>();
-        // 遍历所有列表
-        for (String contentPool : ContentPoolEnum.getOrderContentPool()) {
-            for (Content c : contents) {
-                if (!contentPool.equals(c.getContentPoolType())) {
-                    continue;
-                }
-                if (!TitleSimilarCheckUtil.isDuplicateContent(c.getTitle(), titles)) {
-                    result.add(c);
-                    titles.add(c.getTitle());
-                }
-            }
-        }
-
-        return result;
-    }
-
 }

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

@@ -200,14 +200,15 @@ public class RecallService implements ApplicationContextAware {
         Map<String, Double> accountCorrelationMap = accountCorrelationList.stream().collect(
                 Collectors.toMap(AccountCorrelation::getRelGhId, AccountCorrelation::getCorrelation));
 
-        Set<String> titleList = contentList.stream().map(Content::getTitle).collect(Collectors.toSet());
+        Set<String> titleMd5List = contentList.stream().map(o -> Md5Util.encoderByMd5(o.getTitle())).collect(Collectors.toSet());
+//        Set<String> titleList = contentList.stream().map(Content::getTitle).collect(Collectors.toSet());
 //        Set<String> crawlerTitleList = contentList.stream().map(Content::getCrawlerTitle).collect(Collectors.toSet());
 //        titleList.addAll(crawlerTitleList);
         // 获取历史已发布文章
         List<Article> hisArticleList = new ArrayList<>();
-        List<List<String>> titlePartition = Lists.partition(new ArrayList<>(titleList), 1000);
-        for (List<String> titles : titlePartition) {
-            hisArticleList.addAll(articleRepository.getByTitleInAndTypeEquals(titles, "9"));
+        List<List<String>> titleMd5Partition = Lists.partition(new ArrayList<>(titleMd5List), 1000);
+        for (List<String> titleMd5s : titleMd5Partition) {
+            hisArticleList.addAll(articleRepository.getByTitleMd5InAndTypeEquals(titleMd5s, "9"));
         }
         Map<String, Map<Integer, List<Article>>> map = hisArticleList.stream()
                 .collect(Collectors.groupingBy(Article::getTitle, Collectors.groupingBy(Article::getItemIndex)));

+ 54 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/util/feishu/FeishuMessageSender.java

@@ -1,5 +1,7 @@
 package com.tzld.longarticle.recommend.server.util.feishu;
 
+import com.alibaba.fastjson.JSONObject;
+import com.tzld.longarticle.recommend.server.common.HttpPoolFactory;
 import com.tzld.longarticle.recommend.server.util.MapBuilder;
 import com.tzld.longarticle.recommend.server.util.feishu.model.Message;
 import com.tzld.longarticle.recommend.server.util.feishu.model.MessageParams;
@@ -13,11 +15,19 @@ import com.tzld.longarticle.recommend.server.util.feishu.model.header.MessageHea
 import com.tzld.longarticle.recommend.server.util.http.HttpClientUtils;
 import com.tzld.longarticle.recommend.server.util.http.HttpResponseContent;
 import lombok.extern.slf4j.Slf4j;
+import org.apache.http.HttpEntity;
+import org.apache.http.StatusLine;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.apache.http.util.EntityUtils;
 import org.apache.http.util.TextUtils;
 import org.slf4j.LoggerFactory;
 import org.springframework.data.util.Pair;
 import org.springframework.stereotype.Component;
 
+import java.nio.charset.StandardCharsets;
 import java.util.*;
 
 @Component
@@ -26,6 +36,10 @@ public class FeishuMessageSender {
 
     private static final org.slf4j.Logger LOGGER = LoggerFactory.getLogger(FeishuMessageSender.class);
 
+    private static final String webHookUrl = "https://open.feishu.cn/open-apis/bot/v2/hook/";
+
+    private static final CloseableHttpClient client = HttpPoolFactory.defaultPool();
+
     public void sendChat(String chatId, String title, Map<String, String> infos) {
         sendChat(chatId, null, title, infos);
     }
@@ -57,6 +71,46 @@ public class FeishuMessageSender {
         }
     }
 
+    public static void sendWebHookMessage(String robotId, String msg) {
+        // 使用自定义群机器人webhook方式,支持外部群
+        String webhookUrl = webHookUrl + robotId;
+        String hrc = request(msg, webhookUrl);
+        if (hrc == null) {
+            // 重试一次
+            hrc = request(msg, webhookUrl);
+        }
+        if (hrc == null) {
+            log.error("sendWebHookMessage,hrc is null");
+        }
+    }
+
+    public static String request(String msg, String webhookUrl) {
+        long start = System.currentTimeMillis();
+        JSONObject content = new JSONObject();
+        content.put("text", msg);
+        JSONObject bodyParam = new JSONObject();
+        bodyParam.put("msg_type", "text");
+        bodyParam.put("content", content);
+        try {
+            HttpPost httpPost = new HttpPost(webhookUrl);
+            StringEntity stringEntity = new StringEntity(bodyParam.toJSONString(), StandardCharsets.UTF_8);
+            httpPost.setHeader("Content-Type", "application/json");
+            httpPost.setEntity(stringEntity);
+            CloseableHttpResponse response = client.execute(httpPost);
+            StatusLine statusLine = response.getStatusLine();
+            if (statusLine.getStatusCode() == 200) {
+                HttpEntity responseEntity = response.getEntity();
+                if (Objects.nonNull(responseEntity)) {
+                    return EntityUtils.toString(responseEntity, "UTF-8");
+                }
+            }
+        } catch (Exception e) {
+            log.error("request error", e);
+        }
+        log.info("score耗时:{}", System.currentTimeMillis() - start);
+        return null;
+    }
+
 
     public static void main(String[] args) {
         FeishuMessageSender sender = new FeishuMessageSender();