Explorar o código

增加安全分降权阶段

wangyunpeng hai 6 meses
pai
achega
b947474d64
Modificáronse 36 ficheiros con 759 adicións e 907 borrados
  1. 11 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/common/ThreadPoolFactory.java
  2. 2 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/common/enums/recommend/RankStrategyEnum.java
  3. 2 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/mapper/aigc/AigcBaseMapper.java
  4. 1 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/dto/Content.java
  5. 2 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/entity/longArticle/ArticleTitleHisCache.java
  6. 2 1
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/XxlJobService.java
  7. 45 12
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/RecommendService.java
  8. 1 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/RankParam.java
  9. 466 15
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/RankService.java
  10. 2 19
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/DefaultRankStrategy.java
  11. 2 48
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/FwhColdStartRankStrategy.java
  12. 2 47
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/HisJumpRankStrategy.java
  13. 2 37
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/InfiniteRankStrategy.java
  14. 2 37
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/LateRankStrategy.java
  15. 1 11
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RandomRankStrategy.java
  16. 3 49
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV10Strategy.java
  17. 3 69
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV11Strategy.java
  18. 3 69
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV12Strategy.java
  19. 3 70
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV13Strategy.java
  20. 3 70
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV14Strategy.java
  21. 3 53
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV15Strategy.java
  22. 2 22
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV2Strategy.java
  23. 3 40
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV3Strategy.java
  24. 3 39
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV4Strategy.java
  25. 2 56
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV5Strategy.java
  26. 3 42
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV7Strategy.java
  27. 3 53
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV8Strategy.java
  28. 3 41
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV9Strategy.java
  29. 19 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/recall/RecallService.java
  30. 17 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/reduce/ReduceParam.java
  31. 81 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/reduce/ReduceService.java
  32. 5 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/reduce/ReduceStrategy.java
  33. 31 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/reduce/strategy/SafeReduceStrategy.java
  34. 4 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/score/ScoreService.java
  35. 18 3
      long-article-recommend-service/src/main/resources/mapper/aigc/AigcBaseMapper.xml
  36. 4 4
      long-article-recommend-service/src/main/resources/mapper/longArticle/LongArticleBaseMapper.xml

+ 11 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/common/ThreadPoolFactory.java

@@ -39,6 +39,13 @@ public final class ThreadPoolFactory {
             new LinkedBlockingQueue<>(1000),
             new ThreadFactoryBuilder().setNameFormat("ScoreService-%d").build(),
             new ThreadPoolExecutor.AbortPolicy());
+    private final static ExecutorService REDUCE = new CommonThreadPoolExecutor(
+            32,
+            128,
+            0L, TimeUnit.SECONDS,
+            new LinkedBlockingQueue<>(1000),
+            new ThreadFactoryBuilder().setNameFormat("ReduceService-%d").build(),
+            new ThreadPoolExecutor.AbortPolicy());
     private final static ExecutorService DeDuplicate = new CommonThreadPoolExecutor(
             128,
             128,
@@ -63,6 +70,10 @@ public final class ThreadPoolFactory {
         return SCORE;
     }
 
+    public static ExecutorService reducePool() {
+        return REDUCE;
+    }
+
     public static ExecutorService deDuplicatePool() {
         return DeDuplicate;
     }

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

@@ -27,6 +27,8 @@ public enum RankStrategyEnum {
     LATE_STRATEGY("ArticleRankLate", "晚间策略", "lateRankStrategy"),
     RANDOM_STRATEGY("ArticleRankRandom", "随机策略", "randomRankStrategy"),
     DEFAULT_STRATEGY("ArticleRankV1", "默认策略", "defaultRankStrategy"),
+
+    FWH_COLD_START_STRATEGY("ArticleRankFWH", "服务号策略", "fwhColdStartRankStrategy"),
     ;
 
     private final String strategy;

+ 2 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/mapper/aigc/AigcBaseMapper.java

@@ -72,4 +72,6 @@ public interface AigcBaseMapper {
     List<ProduceTaskAtom> getProduceScoreGreaterThan(Long startTimeStamp, Long endTimeStamp);
 
     void updatePublishContentSingleMiniProgram(List<String> publishContentIds);
+
+    List<ProduceTaskAtom> getProduceScoreByContentId(List<String> planExeIds);
 }

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

@@ -22,6 +22,7 @@ public class Content {
     private String sourceId;
     private String title;
     private String titleMd5;
+    private String kimiSafeScore;
     private Long createTimestamp;
     private String producePlanName;
     private String contentPoolType; // 内容池类别

+ 2 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/entity/longArticle/ArticleTitleHisCache.java

@@ -27,6 +27,8 @@ public class ArticleTitleHisCache implements Serializable {
     private String titleMd5;
     @Column(name = "crawler_title")
     private String crawlerTitle;
+    @Column(name = "kimi_safe_score")
+    private String kimiSafeScore;
     @Column(name = "channel_content_id")
     private String channelContentId;
     @Column(name = "root_publish_timestamp")

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

@@ -713,7 +713,7 @@ public class XxlJobService {
     public ReturnT<String> refreshArticleHisCache(String param) {
         // 刷新历史表现缓存
         long count = articleTitleHisCacheRepository.count();
-        int pageSize = 100;
+        int pageSize = 1000;
         long page = (count / pageSize) + 1;
         for (int i = 0; i < page; i++) {
             Page<ArticleTitleHisCache> articleTitleHisCachePage = articleTitleHisCacheRepository.findAll(
@@ -751,6 +751,7 @@ public class XxlJobService {
                         if (CollectionUtil.isNotEmpty(content.getCategory())) {
                             cache.setCategory(JSONObject.toJSONString(content.getCategory()));
                         }
+                        cache.setKimiSafeScore(content.getKimiSafeScore());
                         cache.setUpdateTimestamp(System.currentTimeMillis());
                         articleTitleHisCacheRepository.save(cache);
                     }

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

@@ -24,9 +24,13 @@ import com.tzld.longarticle.recommend.server.service.recommend.config.AccountInd
 import com.tzld.longarticle.recommend.server.service.recommend.rank.RankParam;
 import com.tzld.longarticle.recommend.server.service.recommend.rank.RankResult;
 import com.tzld.longarticle.recommend.server.service.recommend.rank.RankService;
+import com.tzld.longarticle.recommend.server.service.recommend.rank.RankStrategy;
 import com.tzld.longarticle.recommend.server.service.recommend.recall.RecallParam;
 import com.tzld.longarticle.recommend.server.service.recommend.recall.RecallResult;
 import com.tzld.longarticle.recommend.server.service.recommend.recall.RecallService;
+import com.tzld.longarticle.recommend.server.service.recommend.reduce.ReduceParam;
+import com.tzld.longarticle.recommend.server.service.recommend.reduce.ReduceService;
+import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreService;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import com.tzld.longarticle.recommend.server.util.DateUtils;
 import com.tzld.longarticle.recommend.server.util.JSONUtils;
@@ -57,6 +61,10 @@ public class RecommendService {
     @Autowired
     private RecallService recallService;
     @Autowired
+    private ScoreService scoreService;
+    @Autowired
+    private ReduceService reduceService;
+    @Autowired
     private RankService rankService;
     @Autowired
     private PublishSortLogRepository publishSortLogRepository;
@@ -84,18 +92,35 @@ public class RecommendService {
         // 获取账号排序设置
         setStrategy(request, param);
 
+        // 召回 过滤
         RecallResult recallResult = recallService.recall(convertToRecallParam(param));
+        RankParam rankParam = convertToRankParam(param, recallResult);
         long t2 = System.currentTimeMillis();
         CostMonitor.logCost("Recommend", "Recall", t2 - start);
-        RankResult rankResult = rankService.rank(convertToRankParam(param, recallResult));
+
+        // 评分
+        scoreService.score(RankStrategy.convertToScoreParam(rankParam));
+        rankService.setRankItemScore(rankParam);
         long t3 = System.currentTimeMillis();
-        CostMonitor.logCost("Recommend", "Rank", t3 - t2);
+        CostMonitor.logCost("Recommend", "Score", t3 - t2);
+
+        // 降权
+        reduceService.reduce(convertToReduceParam(param));
+        long t4 = System.currentTimeMillis();
+        CostMonitor.logCost("Recommend", "Reduce", t4 - t3);
+
+        // 排序
+        RankResult rankResult = rankService.rank(rankParam);
+        long t5 = System.currentTimeMillis();
+        CostMonitor.logCost("Recommend", "Rank", t5 - t4);
+        // 保存日志
         saveSortLog(param, rankResult);
-
+        // 构建返回结果
         RecommendResponse response = buildRecommendResponse(recallResult, rankResult, param.getPublishNum());
-        long t4  = System.currentTimeMillis();
-        log.info("recommendCost param:{} total cost:{} recall:{} rank:{} response: {}", JSONObject.toJSONString(request),
-                t4 - start, t2 - start, t3 - t2, JSONObject.toJSONString(response));
+        long t6 = System.currentTimeMillis();
+        log.info("recommendCost param:{} total cost:{} recall:{} score:{} reduce:{} rank:{} response: {}",
+                JSONObject.toJSONString(request), t6 - start, t2 - start, t3 - t2, t4 - t3, t5 - t4,
+                JSONObject.toJSONString(response));
         CostMonitor.logCost("Recommend", "Total", t4 - start);
         return response;
     }
@@ -134,14 +159,13 @@ public class RecommendService {
 
         RecommendParam param = genRecommendParam(request, FWH_COLD_START);
         log.info("genRecommendParam {}", JSONUtils.toJson(param));
-        // 获取账号排序设置
-        String strategyConfig = accountStrategyConfigMap.get(request.getAccountName());
-        if (StringUtils.hasText(strategyConfig)) {
-            param.setStrategy(strategyConfig);
-        }
+
         RecallResult recallResult = recallService.recall(convertToRecallParam(param));
 
-        RankResult rankResult = rankService.rank(convertToRankParam(param, recallResult));
+        RankParam rankParam = convertToRankParam(param, recallResult);
+        scoreService.score(RankStrategy.convertToScoreParam(rankParam));
+
+        RankResult rankResult = rankService.rank(rankParam);
 
         saveSortLog(param, rankResult);
 
@@ -223,12 +247,21 @@ public class RecommendService {
                     }
                 }
                 param.setUserGroupIds(needPushUserGroupIds);
+                param.setStrategy(RankStrategyEnum.FWH_COLD_START_STRATEGY.getStrategy());
                 break;
         }
 
         return param;
     }
 
+    public ReduceParam convertToReduceParam(RecommendParam param) {
+        ReduceParam reduceParam = new ReduceParam();
+        BeanUtils.copyProperties(param, reduceParam);
+        reduceParam.setStrategy(param.getStrategy());
+        reduceParam.setGhId(param.getGhId());
+        return reduceParam;
+    }
+
     public RecallParam convertToRecallParam(RecommendParam param) {
         RecallParam recallParam = new RecallParam();
         BeanUtils.copyProperties(param, recallParam);

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

@@ -14,6 +14,7 @@ public class RankParam {
     private String accountName;
     private List<Content> contents;
     private List<Content> backup;
+    private List<RankItem> rankItems;
     private int size;
     private String strategy;
     private String scene;

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

@@ -9,23 +9,22 @@ import com.ctrip.framework.apollo.spring.annotation.ApolloConfigChangeListener;
 import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
 import com.tzld.longarticle.recommend.server.common.enums.aigc.PublishPlanInputSourceTypesEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.RankStrategyEnum;
+import com.tzld.longarticle.recommend.server.common.enums.recommend.ScoreStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
 import com.tzld.longarticle.recommend.server.service.ServiceBeanFactory;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.strategy.FwhColdStartRankStrategy;
+import com.tzld.longarticle.recommend.server.service.recommend.config.AccountContentPoolConfigService;
+import com.tzld.longarticle.recommend.server.service.recommend.config.StrategyIndexScoreWeightService;
 import com.tzld.longarticle.recommend.server.service.recommend.score.AccountIndexReplacePoolConfig;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.RandomUtils;
 import org.springframework.beans.factory.InitializingBean;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
+import java.util.*;
 import java.util.stream.Collectors;
 
-import static com.tzld.longarticle.recommend.server.common.constant.SceneConstants.FWH_COLD_START;
-
 /**
  * @author dyp
  */
@@ -33,6 +32,11 @@ import static com.tzld.longarticle.recommend.server.common.constant.SceneConstan
 @Slf4j
 public class RankService implements InitializingBean {
 
+    @Autowired
+    private AccountContentPoolConfigService accountContentPoolConfigService;
+    @Autowired
+    private StrategyIndexScoreWeightService weightService;
+
     private static Map<String, Map<String, Integer>> staticStrategyPoolSourceTypeMap;
 
     @ApolloJsonValue("${strategyPoolSourceTypeConfig:{}}")
@@ -70,15 +74,8 @@ public class RankService implements InitializingBean {
     }
 
     private RankStrategy getRankStrategy(RankParam param) {
-
-        switch (param.getScene()) {
-            case FWH_COLD_START:
-                return ServiceBeanFactory.getBean(FwhColdStartRankStrategy.class);
-            default:
-                RankStrategyEnum rankStrategyEnum = RankStrategyEnum.from(param.getStrategy());
-                return (RankStrategy) ServiceBeanFactory.getBeanByName(rankStrategyEnum.getTaskExecutorName());
-        }
-
+        RankStrategyEnum rankStrategyEnum = RankStrategyEnum.from(param.getStrategy());
+        return (RankStrategy) ServiceBeanFactory.getBeanByName(rankStrategyEnum.getTaskExecutorName());
     }
 
     public static void printSortLog(String strategy, String accountName, String position, List<Content> contentList) {
@@ -168,4 +165,458 @@ public class RankService implements InitializingBean {
             result.addAll(pool.subList(0, Math.min(pool.size(), param.getSize() - result.size())));
         }
     }
+
+    public List<RankItem> setRankItemScore(RankParam param) {
+        List<Content> contents = param.getContents();
+        String strategy = param.getStrategy();
+        String ghId = param.getGhId();
+        String[] contentPools = accountContentPoolConfigService.getContentPools(param.getAccountName());
+        List<RankItem> result = new ArrayList<>();
+        for (Content content : contents) {
+            RankItem item = new RankItem();
+            item.setContent(content);
+            item.setScoreMap(content.getScoreMap());
+            Double score = 0.0;
+            int index = weightService.getIndex(item.getContent().getContentPoolType(), contentPools);
+            switch (strategy) {
+                case "ArticleRankV1":
+                case "ArticleRankV2":
+                case "ArticleRankV6":
+                case "ArticleRankRandom":
+                    break;
+                case "ArticleRankV3":
+                    if (contentPools[0].equals(item.getContent().getContentPoolType())
+                            || contentPools[1].equals(item.getContent().getContentPoolType())) {
+                        score = item.getScore(ScoreStrategyEnum.SIMILARITY.value())
+                                + item.getScore(ScoreStrategyEnum.CATEGORY.value())
+                                + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value())
+                                + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value());
+                        if (item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value()) >= 0) {
+                            score += item.getScore(ScoreStrategyEnum.VIEW_COUNT_RATE.value());
+                        }
+                    } else {
+                        score = item.getScore(ScoreStrategyEnum.SIMILARITY.value())
+                                + item.getScore(ScoreStrategyEnum.CATEGORY.value())
+                                + item.getScore(ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value())
+                                + item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value())
+                                + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value())
+                                + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value());
+                    }
+                    content.setScore(score);
+                    item.setScore(score);
+                    break;
+                case "ArticleRankV4":
+                    if (contentPools[0].equals(item.getContent().getContentPoolType())
+                            || contentPools[1].equals(item.getContent().getContentPoolType())) {
+                        score = item.getScore(ScoreStrategyEnum.SIMILARITY.value())
+                                + item.getScore(ScoreStrategyEnum.CATEGORY.value())
+                                + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value())
+                                + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value());
+                        if (item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value()) >= 0) {
+                            score += item.getScore(ScoreStrategyEnum.VIEW_COUNT_RATE_CORRELATION.value());
+                        }
+                    } else {
+                        score = item.getScore(ScoreStrategyEnum.SIMILARITY.value())
+                                + item.getScore(ScoreStrategyEnum.CATEGORY.value())
+                                + item.getScore(ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value())
+                                + item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value())
+                                + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value())
+                                + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value());
+                    }
+                    content.setScore(score);
+                    item.setScore(score);
+                    break;
+                case "ArticleRankV5":
+                case "ArticleRankV15":
+                    if (contentPools[0].equals(item.getContent().getContentPoolType())
+                            || contentPools[1].equals(item.getContent().getContentPoolType())) {
+                        score = item.getScore(ScoreStrategyEnum.SIMILARITY.value())
+                                * weightService.getWeight(strategy, ghId, index,
+                                ScoreStrategyEnum.SIMILARITY.value())
+                                + item.getScore(ScoreStrategyEnum.CATEGORY.value())
+                                * weightService.getWeight(strategy, ghId, index,
+                                ScoreStrategyEnum.CATEGORY.value())
+                                + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value())
+                                + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value());
+                        if (item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value()) >= 0) {
+                            score += item.getScore(ScoreStrategyEnum.VIEW_COUNT_RATE.value())
+                                    * weightService.getWeight(strategy, ghId, index,
+                                    ScoreStrategyEnum.VIEW_COUNT_RATE.value());
+                        }
+                    } else {
+                        score = item.getScore(ScoreStrategyEnum.SIMILARITY.value())
+                                * weightService.getWeight(strategy, ghId, index,
+                                ScoreStrategyEnum.SIMILARITY.value())
+                                + item.getScore(ScoreStrategyEnum.CATEGORY.value())
+                                * weightService.getWeight(strategy, ghId, index,
+                                ScoreStrategyEnum.CATEGORY.value())
+                                + item.getScore(ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value())
+                                + item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value())
+                                + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value())
+                                + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value());
+                    }
+                    content.setScore(score);
+                    item.setScore(score);
+                    break;
+                case "ArticleRankV7":
+                    if (contentPools[0].equals(item.getContent().getContentPoolType())) {
+                        score = item.getScore(ScoreStrategyEnum.HIS_FISSION_AVG_READ_RATE_CORRELATION_RATE.value())
+                                + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value());
+                    } else if (contentPools[1].equals(item.getContent().getContentPoolType())) {
+                        score = item.getScore(ScoreStrategyEnum.SIMILARITY.value())
+                                + item.getScore(ScoreStrategyEnum.CATEGORY.value())
+                                + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value())
+                                + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value());
+                        if (item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value()) >= 0) {
+                            score += item.getScore(ScoreStrategyEnum.VIEW_COUNT_RATE.value());
+                        }
+                    } else {
+                        score = item.getScore(ScoreStrategyEnum.SIMILARITY.value())
+                                + item.getScore(ScoreStrategyEnum.CATEGORY.value())
+                                + item.getScore(ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value())
+                                + item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value())
+                                + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value())
+                                + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value());
+                    }
+                    content.setScore(score);
+                    item.setScore(score);
+                    break;
+                case "ArticleRankV8":
+                    if (contentPools[0].equals(item.getContent().getContentPoolType())) {
+                        score = item.getScore(ScoreStrategyEnum.SIMILARITY.value())
+                                + item.getScore(ScoreStrategyEnum.CATEGORY.value())
+                                * weightService.getWeight(strategy, ghId, index,
+                                ScoreStrategyEnum.CATEGORY.value())
+                                + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value())
+                                + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value())
+                                + item.getScore(ScoreStrategyEnum.HIS_FISSION_AVG_READ_RATE_RATE.value());
+                    } else if (contentPools[1].equals(item.getContent().getContentPoolType())) {
+                        score = item.getScore(ScoreStrategyEnum.SIMILARITY.value())
+                                + item.getScore(ScoreStrategyEnum.CATEGORY.value())
+                                + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value())
+                                + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value());
+                        if (item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value()) >= 0) {
+                            score += item.getScore(ScoreStrategyEnum.VIEW_COUNT_RATE.value());
+                        }
+                    } else {
+                        score = item.getScore(ScoreStrategyEnum.SIMILARITY.value())
+                                + item.getScore(ScoreStrategyEnum.CATEGORY.value())
+                                * weightService.getWeight(strategy, ghId, index,
+                                ScoreStrategyEnum.CATEGORY.value())
+                                + item.getScore(ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value())
+                                + item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value())
+                                + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value())
+                                + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value());
+                    }
+                    content.setScore(score);
+                    item.setScore(score);
+                    break;
+                case "ArticleRankV9":
+                    if (contentPools[0].equals(item.getContent().getContentPoolType())) {
+                        score = item.getScore(ScoreStrategyEnum.HIS_FISSION_AVG_READ_RATE_RATE.value())
+                                + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value());
+                    } else if (contentPools[1].equals(item.getContent().getContentPoolType())) {
+                        score = item.getScore(ScoreStrategyEnum.SIMILARITY.value())
+                                + item.getScore(ScoreStrategyEnum.CATEGORY.value())
+                                + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value())
+                                + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value());
+                        if (item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value()) >= 0) {
+                            score += item.getScore(ScoreStrategyEnum.VIEW_COUNT_RATE.value());
+                        }
+                    } else {
+                        score = item.getScore(ScoreStrategyEnum.SIMILARITY.value())
+                                + item.getScore(ScoreStrategyEnum.CATEGORY.value())
+                                + item.getScore(ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value())
+                                + item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value())
+                                + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value())
+                                + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value());
+                    }
+                    content.setScore(score);
+                    item.setScore(score);
+                    break;
+                case "ArticleRankV10":
+                    if (contentPools[0].equals(item.getContent().getContentPoolType())) {
+                        score = item.getScore(ScoreStrategyEnum.HIS_FISSION_AVG_READ_SUM_RATE.value())
+                                + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value());
+                    } else if (contentPools[1].equals(item.getContent().getContentPoolType())) {
+                        score = item.getScore(ScoreStrategyEnum.SIMILARITY.value())
+                                + item.getScore(ScoreStrategyEnum.CATEGORY.value())
+                                * weightService.getWeight(strategy, ghId, index,
+                                ScoreStrategyEnum.CATEGORY.value())
+                                + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value())
+                                + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value());
+                        if (item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value()) >= 0) {
+                            score += item.getScore(ScoreStrategyEnum.VIEW_COUNT_RATE.value());
+                        }
+                    } else {
+                        score = item.getScore(ScoreStrategyEnum.SIMILARITY.value())
+                                + item.getScore(ScoreStrategyEnum.CATEGORY.value())
+                                * weightService.getWeight(strategy, ghId, index,
+                                ScoreStrategyEnum.CATEGORY.value())
+                                + item.getScore(ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value())
+                                + item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value())
+                                + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value())
+                                + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value());
+                    }
+                    content.setScore(score);
+                    item.setScore(score);
+                    break;
+                case "ArticleRankV11":
+                    if (contentPools[0].equals(item.getContent().getContentPoolType())) {
+                        score = item.getScore(ScoreStrategyEnum.HIS_FISSION_AVG_READ_RATE_RATE.value())
+                                * weightService.getWeight(strategy, ghId, index,
+                                ScoreStrategyEnum.HIS_FISSION_AVG_READ_RATE_RATE.value())
+                                + item.getScore(ScoreStrategyEnum.SIMILARITY.value())
+                                * weightService.getWeight(strategy, ghId, index,
+                                ScoreStrategyEnum.SIMILARITY.value())
+                                + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value());
+                        if (item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value()) >= 0) {
+                            score += item.getScore(ScoreStrategyEnum.VIEW_COUNT_RATE.value())
+                                    * weightService.getWeight(strategy, ghId, index,
+                                    ScoreStrategyEnum.VIEW_COUNT_RATE.value());
+                        }
+                    } else if (contentPools[1].equals(item.getContent().getContentPoolType())) {
+                        score = (item.getScore(ScoreStrategyEnum.SIMILARITY.value())
+                                * weightService.getWeight(strategy, ghId, index,
+                                ScoreStrategyEnum.SIMILARITY.value()))
+                                + item.getScore(ScoreStrategyEnum.CATEGORY.value())
+                                * weightService.getWeight(strategy, ghId, index,
+                                ScoreStrategyEnum.CATEGORY.value())
+                                + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value())
+                                + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value());
+                        if (item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value()) >= 0) {
+                            score += item.getScore(ScoreStrategyEnum.VIEW_COUNT_RATE.value())
+                                    * weightService.getWeight(strategy, ghId, index,
+                                    ScoreStrategyEnum.VIEW_COUNT_RATE.value());
+                        }
+                    } else {
+                        score = (item.getScore(ScoreStrategyEnum.SIMILARITY.value())
+                                * weightService.getWeight(strategy, ghId, index,
+                                ScoreStrategyEnum.SIMILARITY.value()))
+                                + item.getScore(ScoreStrategyEnum.CATEGORY.value())
+                                * weightService.getWeight(strategy, ghId, index,
+                                ScoreStrategyEnum.CATEGORY.value())
+                                + (item.getScore(ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value())
+                                * weightService.getWeight(strategy, ghId, index,
+                                ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value()))
+                                + item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value())
+                                + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value())
+                                + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value());
+                    }
+                    content.setScore(score);
+                    content.setHisPublishArticleList(null);
+                    item.setScore(score);
+                    break;
+                case "ArticleRankV12":
+                    if (contentPools[0].equals(item.getContent().getContentPoolType())) {
+                        score = item.getScore(ScoreStrategyEnum.HIS_FISSION_DE_WEIGHT_AVG_READ_SUM_RATE.value())
+                                * weightService.getWeight(strategy, ghId, index,
+                                ScoreStrategyEnum.HIS_FISSION_DE_WEIGHT_AVG_READ_SUM_RATE.value())
+                                + item.getScore(ScoreStrategyEnum.SIMILARITY.value())
+                                * weightService.getWeight(strategy, ghId, index,
+                                ScoreStrategyEnum.SIMILARITY.value())
+                                + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value());
+                        if (item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value()) >= 0) {
+                            score += item.getScore(ScoreStrategyEnum.VIEW_COUNT_RATE.value())
+                                    * weightService.getWeight(strategy, ghId, index,
+                                    ScoreStrategyEnum.VIEW_COUNT_RATE.value());
+                        }
+                    } else if (contentPools[1].equals(item.getContent().getContentPoolType())) {
+                        score = (item.getScore(ScoreStrategyEnum.SIMILARITY.value())
+                                * weightService.getWeight(strategy, ghId, index,
+                                ScoreStrategyEnum.SIMILARITY.value()))
+                                + item.getScore(ScoreStrategyEnum.CATEGORY.value())
+                                * weightService.getWeight(strategy, ghId, index,
+                                ScoreStrategyEnum.CATEGORY.value())
+                                + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value())
+                                + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value());
+                        if (item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value()) >= 0) {
+                            score += item.getScore(ScoreStrategyEnum.VIEW_COUNT_RATE.value())
+                                    * weightService.getWeight(strategy, ghId, index,
+                                    ScoreStrategyEnum.VIEW_COUNT_RATE.value());
+                        }
+                    } else {
+                        score = (item.getScore(ScoreStrategyEnum.SIMILARITY.value())
+                                * weightService.getWeight(strategy, ghId, index,
+                                ScoreStrategyEnum.SIMILARITY.value()))
+                                + item.getScore(ScoreStrategyEnum.CATEGORY.value())
+                                * weightService.getWeight(strategy, ghId, index,
+                                ScoreStrategyEnum.CATEGORY.value())
+                                + (item.getScore(ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value())
+                                * weightService.getWeight(strategy, ghId, index,
+                                ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value()))
+                                + item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value())
+                                + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value())
+                                + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value());
+                    }
+                    content.setScore(score);
+                    content.setHisPublishArticleList(null);
+                    item.setScore(score);
+                    break;
+                case "ArticleRankV13":
+                    if (contentPools[0].equals(item.getContent().getContentPoolType())) {
+                        double similarityScore = Math.pow(item.getScore(ScoreStrategyEnum.SIMILARITY.value()),
+                                weightService.getWeight(strategy, ghId, index,
+                                        ScoreStrategyEnum.SIMILARITY.value()));
+                        score = item.getScore(ScoreStrategyEnum.HIS_FISSION_AVG_READ_RATE_RATE.value())
+                                * weightService.getWeight(strategy, ghId, index,
+                                ScoreStrategyEnum.HIS_FISSION_AVG_READ_RATE_RATE.value())
+                                + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value());
+                        if (item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value()) >= 0) {
+                            score += item.getScore(ScoreStrategyEnum.VIEW_COUNT_RATE.value())
+                                    * weightService.getWeight(strategy, ghId, index,
+                                    ScoreStrategyEnum.VIEW_COUNT_RATE.value());
+                        }
+                        score = score * similarityScore;
+                    } else if (contentPools[1].equals(item.getContent().getContentPoolType())) {
+                        score = (item.getScore(ScoreStrategyEnum.SIMILARITY.value())
+                                * weightService.getWeight(strategy, ghId, index,
+                                ScoreStrategyEnum.SIMILARITY.value()))
+                                + item.getScore(ScoreStrategyEnum.CATEGORY.value())
+                                * weightService.getWeight(strategy, ghId, index,
+                                ScoreStrategyEnum.CATEGORY.value())
+                                + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value())
+                                + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value());
+                        if (item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value()) >= 0) {
+                            score += item.getScore(ScoreStrategyEnum.VIEW_COUNT_RATE.value())
+                                    * weightService.getWeight(strategy, ghId, index,
+                                    ScoreStrategyEnum.VIEW_COUNT_RATE.value());
+                        }
+                    } else {
+                        score = (item.getScore(ScoreStrategyEnum.SIMILARITY.value())
+                                * weightService.getWeight(strategy, ghId, index,
+                                ScoreStrategyEnum.SIMILARITY.value()))
+                                + item.getScore(ScoreStrategyEnum.CATEGORY.value())
+                                * weightService.getWeight(strategy, ghId, index,
+                                ScoreStrategyEnum.CATEGORY.value())
+                                + (item.getScore(ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value())
+                                * weightService.getWeight(strategy, ghId, index,
+                                ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value()))
+                                + item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value())
+                                + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value())
+                                + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value());
+                    }
+                    content.setScore(score);
+                    content.setHisPublishArticleList(null);
+                    item.setScore(score);
+                    break;
+                case "ArticleRankV14":
+                    if (contentPools[0].equals(item.getContent().getContentPoolType())) {
+                        double similarityScore = Math.pow(item.getScore(ScoreStrategyEnum.SIMILARITY.value()),
+                                weightService.getWeight(strategy, ghId, index,
+                                        ScoreStrategyEnum.SIMILARITY.value()));
+                        score = item.getScore(ScoreStrategyEnum.HIS_FISSION_DE_WEIGHT_AVG_READ_SUM_RATE.value())
+                                * weightService.getWeight(strategy, ghId, index,
+                                ScoreStrategyEnum.HIS_FISSION_DE_WEIGHT_AVG_READ_SUM_RATE.value())
+                                + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value());
+                        if (item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value()) >= 0) {
+                            score += item.getScore(ScoreStrategyEnum.VIEW_COUNT_RATE.value())
+                                    * weightService.getWeight(strategy, ghId, index,
+                                    ScoreStrategyEnum.VIEW_COUNT_RATE.value());
+                        }
+                        score = score * similarityScore;
+                    } else if (contentPools[1].equals(item.getContent().getContentPoolType())) {
+                        score = (item.getScore(ScoreStrategyEnum.SIMILARITY.value())
+                                * weightService.getWeight(strategy, ghId, index,
+                                ScoreStrategyEnum.SIMILARITY.value()))
+                                + item.getScore(ScoreStrategyEnum.CATEGORY.value())
+                                * weightService.getWeight(strategy, ghId, index,
+                                ScoreStrategyEnum.CATEGORY.value())
+                                + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value())
+                                + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value());
+                        if (item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value()) >= 0) {
+                            score += item.getScore(ScoreStrategyEnum.VIEW_COUNT_RATE.value())
+                                    * weightService.getWeight(strategy, ghId, index,
+                                    ScoreStrategyEnum.VIEW_COUNT_RATE.value());
+                        }
+                    } else {
+                        score = (item.getScore(ScoreStrategyEnum.SIMILARITY.value())
+                                * weightService.getWeight(strategy, ghId, index,
+                                ScoreStrategyEnum.SIMILARITY.value()))
+                                + item.getScore(ScoreStrategyEnum.CATEGORY.value())
+                                * weightService.getWeight(strategy, ghId, index,
+                                ScoreStrategyEnum.CATEGORY.value())
+                                + (item.getScore(ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value())
+                                * weightService.getWeight(strategy, ghId, index,
+                                ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value()))
+                                + item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value())
+                                + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value())
+                                + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value());
+                    }
+                    content.setScore(score);
+                    content.setHisPublishArticleList(null);
+                    item.setScore(score);
+                    break;
+                case "ArticleRankHisJump":
+                    if (contentPools[0].equals(item.getContent().getContentPoolType())
+                            || contentPools[1].equals(item.getContent().getContentPoolType())) {
+                        score = item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value())
+                                + item.getScore(ScoreStrategyEnum.CATEGORY.value())
+                                * weightService.getWeight(strategy, ghId, index,
+                                ScoreStrategyEnum.CATEGORY.value())
+                                + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value());
+                        if (item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value()) >= 0) {
+                            score += item.getScore(ScoreStrategyEnum.VIEW_COUNT_RATE.value())
+                                    * weightService.getWeight(strategy, ghId, index,
+                                    ScoreStrategyEnum.VIEW_COUNT_RATE.value());
+                        }
+                    } else {
+                        score = item.getScore(ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value())
+                                + item.getScore(ScoreStrategyEnum.CATEGORY.value())
+                                * weightService.getWeight(strategy, ghId, index,
+                                ScoreStrategyEnum.CATEGORY.value())
+                                + item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value())
+                                + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value())
+                                + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value());
+                    }
+                    content.setScore(score);
+                    item.setScore(score);
+                    break;
+                case "ArticleRankInfinite":
+                case "ArticleRankLate":
+                    if (contentPools[2].equals(item.getContent().getContentPoolType())) {
+                        score = item.getScore(ScoreStrategyEnum.SIMILARITY.value())
+                                + item.getScore(ScoreStrategyEnum.CATEGORY.value())
+                                * weightService.getWeight(strategy, ghId, index,
+                                ScoreStrategyEnum.CATEGORY.value())
+                                + item.getScore(ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value())
+                                + item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value())
+                                + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value())
+                                + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value());
+                    }
+                    content.setScore(score);
+                    item.setScore(score);
+                    break;
+                case "ArticleRankFWH":
+                    content.setHisPublishArticleList(null);
+                    if (contentPools[0].equals(item.getContent().getContentPoolType())
+                            || contentPools[1].equals(item.getContent().getContentPoolType())) {
+                        score = item.getScore(ScoreStrategyEnum.SIMILARITY.value())
+                                + item.getScore(ScoreStrategyEnum.CATEGORY.value())
+                                + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value());
+                        if (item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value()) >= 0) {
+                            score += item.getScore(ScoreStrategyEnum.VIEW_COUNT_RATE.value());
+                        }
+                    } else {
+                        score = item.getScore(ScoreStrategyEnum.SIMILARITY.value())
+                                + item.getScore(ScoreStrategyEnum.CATEGORY.value())
+                                + item.getScore(ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value())
+                                + item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value())
+                                + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value())
+                                + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value());
+                    }
+                    content.setScore(score);
+                    item.setScore(score);
+                    break;
+            }
+            result.add(item);
+        }
+        result.sort((o1, o2) -> -Double.compare(o1.getScore(), o2.getScore()));
+        param.setRankItems(result);
+        return result;
+    }
+
+    private void setSafeScoreDecrease(RankParam param) {
+
+    }
 }

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

@@ -6,12 +6,7 @@ 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.recommend.config.AccountContentPoolConfigService;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankItem;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankParam;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankResult;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankStrategy;
-import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreResult;
-import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreService;
+import com.tzld.longarticle.recommend.server.service.recommend.rank.*;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import com.tzld.longarticle.recommend.server.util.JSONUtils;
 import lombok.extern.slf4j.Slf4j;
@@ -29,8 +24,6 @@ import java.util.*;
 @Slf4j
 public class DefaultRankStrategy implements RankStrategy {
 
-    @Autowired
-    private ScoreService scoreService;
     @Autowired
     private AccountContentPoolConfigService accountContentPoolConfigService;
     @Autowired
@@ -39,17 +32,7 @@ public class DefaultRankStrategy implements RankStrategy {
     public RankResult rank(RankParam param) {
         List<Content> result = new ArrayList<>();
 
-        ScoreResult scoreResult = scoreService.score(RankStrategy.convertToScoreParam(param));
-        Map<String, Map<String, Double>> scoreMap = scoreResult.getScoreMap();
-
-        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()));
-            return item;
-
-        });
+        List<RankItem> items = param.getRankItems();
 
         // 1 排序
         String[] contentPools = accountContentPoolConfigService.getContentPools(param.getAccountName());

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

@@ -1,24 +1,15 @@
 package com.tzld.longarticle.recommend.server.service.recommend.rank.strategy;
 
 
-import com.tzld.longarticle.recommend.server.common.enums.recommend.ScoreStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
-import com.tzld.longarticle.recommend.server.service.recommend.config.AccountContentPoolConfigService;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankItem;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankParam;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankResult;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankStrategy;
-import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreResult;
-import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreService;
+import com.tzld.longarticle.recommend.server.service.recommend.rank.*;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
-import java.util.Map;
 
 /**
  * @author dyp
@@ -27,47 +18,10 @@ import java.util.Map;
 @Slf4j
 public class FwhColdStartRankStrategy implements RankStrategy {
 
-    @Autowired
-    private ScoreService scoreService;
-    @Autowired
-    private AccountContentPoolConfigService accountContentPoolConfigService;
-
     public RankResult rank(RankParam param) {
 
-        ScoreResult scoreResult = scoreService.score(RankStrategy.convertToScoreParam(param));
-
-        Map<String, Map<String, Double>> scoreMap = scoreResult.getScoreMap();
-        String[] contentPools = accountContentPoolConfigService.getContentPools(param.getAccountName());
-
-        List<RankItem> items = CommonCollectionUtils.toList(param.getContents(), c -> {
-            RankItem item = new RankItem();
-            c.setHisPublishArticleList(null);
-            item.setContent(c);
-            item.setScoreMap(scoreMap.get(c.getId()));
-            double score;
-            if (contentPools[0].equals(item.getContent().getContentPoolType())
-                    || contentPools[1].equals(item.getContent().getContentPoolType())) {
-                score = item.getScore(ScoreStrategyEnum.SIMILARITY.value())
-                        + item.getScore(ScoreStrategyEnum.CATEGORY.value())
-                        + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value());
-                if (item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value()) >= 0) {
-                    score += item.getScore(ScoreStrategyEnum.VIEW_COUNT_RATE.value());
-                }
-            } else {
-                score = item.getScore(ScoreStrategyEnum.SIMILARITY.value())
-                        + item.getScore(ScoreStrategyEnum.CATEGORY.value())
-                        + item.getScore(ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value())
-                        + item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value())
-                        + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value())
-                        + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value());
-            }
-            item.setScore(score);
-            return item;
-        });
+        List<RankItem> items = param.getRankItems();
 
-        // 1 排序
-        Collections.sort(items, (o1, o2) -> -Double.compare(o1.getScore(), o2.getScore()));
-        // 2 相似去重
         List<Content> contents = CommonCollectionUtils.toList(items, RankItem::getContent);
 
         // 3 选文章

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

@@ -1,13 +1,9 @@
 package com.tzld.longarticle.recommend.server.service.recommend.rank.strategy;
 
-import com.tzld.longarticle.recommend.server.common.enums.recommend.ScoreStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
 import com.tzld.longarticle.recommend.server.service.recommend.config.AccountContentPoolConfigService;
-import com.tzld.longarticle.recommend.server.service.recommend.config.StrategyIndexScoreWeightService;
 import com.tzld.longarticle.recommend.server.service.recommend.rank.*;
 import com.tzld.longarticle.recommend.server.service.recommend.score.AccountIndexReplacePoolConfig;
-import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreResult;
-import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreService;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
@@ -21,58 +17,17 @@ import java.util.*;
 @Slf4j
 public class HisJumpRankStrategy implements RankStrategy {
 
-    @Autowired
-    private ScoreService scoreService;
     @Autowired
     private AccountContentPoolConfigService accountContentPoolConfigService;
-    @Autowired
-    private StrategyIndexScoreWeightService weightService;
 
     public RankResult rank(RankParam param) {
         List<Content> result = new ArrayList<>();
 
-        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;
-            int index = weightService.getIndex(item.getContent().getContentPoolType(), contentPools);
-            if (contentPools[0].equals(item.getContent().getContentPoolType())
-                    || contentPools[1].equals(item.getContent().getContentPoolType())) {
-                score = item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value())
-                        + item.getScore(ScoreStrategyEnum.CATEGORY.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.CATEGORY.value())
-                        + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value());
-                if (item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value()) >= 0) {
-                    score += item.getScore(ScoreStrategyEnum.VIEW_COUNT_RATE.value())
-                            * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                            ScoreStrategyEnum.VIEW_COUNT_RATE.value());
-                }
-            } else {
-                score = item.getScore(ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value())
-                        + item.getScore(ScoreStrategyEnum.CATEGORY.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.CATEGORY.value())
-                        + item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value())
-                        + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value())
-                        + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value());
-            }
-            c.setScore(score);
-            item.setScore(score);
-            return item;
-        });
-
-        // 1 排序
-        Collections.sort(items, (o1, o2) -> -Double.compare(o1.getScore(), o2.getScore()));
-        // 2 相似去重
+        List<RankItem> items = param.getRankItems();
+        
         List<Content> contents = CommonCollectionUtils.toList(items, RankItem::getContent);
 
         // 3 文章按照内容池分组

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

@@ -1,14 +1,9 @@
 package com.tzld.longarticle.recommend.server.service.recommend.rank.strategy;
 
-import com.tzld.longarticle.recommend.server.common.enums.recommend.RankStrategyEnum;
-import com.tzld.longarticle.recommend.server.common.enums.recommend.ScoreStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
 import com.tzld.longarticle.recommend.server.service.recommend.config.AccountContentPoolConfigService;
-import com.tzld.longarticle.recommend.server.service.recommend.config.StrategyIndexScoreWeightService;
 import com.tzld.longarticle.recommend.server.service.recommend.rank.*;
 import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreParam;
-import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreResult;
-import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreService;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -21,12 +16,8 @@ import java.util.stream.Collectors;
 @Slf4j
 public class InfiniteRankStrategy implements RankStrategy {
 
-    @Autowired
-    private ScoreService scoreService;
     @Autowired
     private AccountContentPoolConfigService accountContentPoolConfigService;
-    @Autowired
-    private StrategyIndexScoreWeightService weightService;
 
     public RankResult rank(RankParam param) {
         List<Content> result = new ArrayList<>();
@@ -34,35 +25,9 @@ public class InfiniteRankStrategy implements RankStrategy {
         ScoreParam scoreParam = RankStrategy.convertToScoreParam(param);
         scoreParam.setContents(scoreParam.getContents().stream().filter(
                 c -> contentPools[2].equals(c.getContentPoolType())).collect(Collectors.toList()));
-        ScoreResult scoreResult = scoreService.score(RankStrategy.convertToScoreParam(param));
-
-        Map<String, Map<String, Double>> scoreMap = scoreResult.getScoreMap();
-
-        List<RankItem> items = CommonCollectionUtils.toList(scoreParam.getContents(), c -> {
-            RankItem item = new RankItem();
-            item.setContent(c);
-            c.setScoreMap(scoreMap.get(c.getId()));
-            item.setScoreMap(scoreMap.get(c.getId()));
-            double score = 0.0;
-            int index = weightService.getIndex(item.getContent().getContentPoolType(), contentPools);
-            if (contentPools[2].equals(item.getContent().getContentPoolType())) {
-                score = item.getScore(ScoreStrategyEnum.SIMILARITY.value())
-                        + item.getScore(ScoreStrategyEnum.CATEGORY.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.CATEGORY.value())
-                        + item.getScore(ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value())
-                        + item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value())
-                        + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value())
-                        + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value());
-            }
-            c.setScore(score);
-            item.setScore(score);
-            return item;
-        });
 
-        // 1 排序
-        Collections.sort(items, (o1, o2) -> -Double.compare(o1.getScore(), o2.getScore()));
-        // 2 相似去重
+        List<RankItem> items = param.getRankItems();
+        
         List<Content> contents = CommonCollectionUtils.toList(items, RankItem::getContent);
 
         // 3 文章按照内容池分组

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

@@ -1,14 +1,9 @@
 package com.tzld.longarticle.recommend.server.service.recommend.rank.strategy;
 
-import com.tzld.longarticle.recommend.server.common.enums.recommend.RankStrategyEnum;
-import com.tzld.longarticle.recommend.server.common.enums.recommend.ScoreStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
 import com.tzld.longarticle.recommend.server.service.recommend.config.AccountContentPoolConfigService;
-import com.tzld.longarticle.recommend.server.service.recommend.config.StrategyIndexScoreWeightService;
 import com.tzld.longarticle.recommend.server.service.recommend.rank.*;
 import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreParam;
-import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreResult;
-import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreService;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -21,12 +16,8 @@ import java.util.stream.Collectors;
 @Slf4j
 public class LateRankStrategy implements RankStrategy {
 
-    @Autowired
-    private ScoreService scoreService;
     @Autowired
     private AccountContentPoolConfigService accountContentPoolConfigService;
-    @Autowired
-    private StrategyIndexScoreWeightService weightService;
 
     public RankResult rank(RankParam param) {
         List<Content> result = new ArrayList<>();
@@ -34,35 +25,9 @@ public class LateRankStrategy implements RankStrategy {
         ScoreParam scoreParam = RankStrategy.convertToScoreParam(param);
         scoreParam.setContents(scoreParam.getContents().stream().filter(
                 c -> contentPools[2].equals(c.getContentPoolType())).collect(Collectors.toList()));
-        ScoreResult scoreResult = scoreService.score(RankStrategy.convertToScoreParam(param));
-
-        Map<String, Map<String, Double>> scoreMap = scoreResult.getScoreMap();
-
-        List<RankItem> items = CommonCollectionUtils.toList(scoreParam.getContents(), c -> {
-            RankItem item = new RankItem();
-            item.setContent(c);
-            c.setScoreMap(scoreMap.get(c.getId()));
-            item.setScoreMap(scoreMap.get(c.getId()));
-            double score = 0.0;
-            int index = weightService.getIndex(item.getContent().getContentPoolType(), contentPools);
-            if (contentPools[2].equals(item.getContent().getContentPoolType())) {
-                score = item.getScore(ScoreStrategyEnum.SIMILARITY.value())
-                        + item.getScore(ScoreStrategyEnum.CATEGORY.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.CATEGORY.value())
-                        + item.getScore(ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value())
-                        + item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value())
-                        + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value())
-                        + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value());
-            }
-            c.setScore(score);
-            item.setScore(score);
-            return item;
-        });
 
-        // 1 排序
-        Collections.sort(items, (o1, o2) -> -Double.compare(o1.getScore(), o2.getScore()));
-        // 2 相似去重
+        List<RankItem> items = param.getRankItems();
+        
         List<Content> contents = CommonCollectionUtils.toList(items, RankItem::getContent);
 
         // 3 文章按照内容池分组

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

@@ -2,9 +2,7 @@ package com.tzld.longarticle.recommend.server.service.recommend.rank.strategy;
 
 import com.tzld.longarticle.recommend.server.model.dto.Content;
 import com.tzld.longarticle.recommend.server.service.recommend.config.AccountContentPoolConfigService;
-import com.tzld.longarticle.recommend.server.service.recommend.config.StrategyIndexScoreWeightService;
 import com.tzld.longarticle.recommend.server.service.recommend.rank.*;
-import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreService;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
@@ -17,22 +15,14 @@ import java.util.*;
 @Slf4j
 public class RandomRankStrategy implements RankStrategy {
 
-    @Autowired
-    private ScoreService scoreService;
     @Autowired
     private AccountContentPoolConfigService accountContentPoolConfigService;
-    @Autowired
-    private StrategyIndexScoreWeightService weightService;
 
     public RankResult rank(RankParam param) {
         List<Content> result = new ArrayList<>();
         String[] contentPools = accountContentPoolConfigService.getContentPools(param.getAccountName());
 
-        List<RankItem> items = CommonCollectionUtils.toList(param.getContents(), c -> {
-            RankItem item = new RankItem();
-            item.setContent(c);
-            return item;
-        });
+        List<RankItem> items = param.getRankItems();
 
         List<Content> contents = CommonCollectionUtils.toList(items, RankItem::getContent);
         // 3 文章按照内容池分组

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

@@ -1,16 +1,12 @@
 package com.tzld.longarticle.recommend.server.service.recommend.rank.strategy;
 
 
-import com.tzld.longarticle.recommend.server.common.enums.recommend.ScoreStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
 import com.tzld.longarticle.recommend.server.model.entity.crawler.Article;
 import com.tzld.longarticle.recommend.server.repository.crawler.ArticleRepository;
 import com.tzld.longarticle.recommend.server.service.recommend.config.AccountContentPoolConfigService;
-import com.tzld.longarticle.recommend.server.service.recommend.config.StrategyIndexScoreWeightService;
 import com.tzld.longarticle.recommend.server.service.recommend.rank.*;
 import com.tzld.longarticle.recommend.server.service.recommend.score.AccountIndexReplacePoolConfig;
-import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreResult;
-import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreService;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
@@ -26,68 +22,26 @@ import java.util.*;
 @Slf4j
 public class RankV10Strategy 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<>();
 
-        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;
-            int index = weightService.getIndex(item.getContent().getContentPoolType(), contentPools);
-            if (contentPools[0].equals(item.getContent().getContentPoolType())) {
-                score = item.getScore(ScoreStrategyEnum.HIS_FISSION_AVG_READ_SUM_RATE.value())
-                        + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value());
-            } else if (contentPools[1].equals(item.getContent().getContentPoolType())) {
-                score = item.getScore(ScoreStrategyEnum.SIMILARITY.value())
-                        + item.getScore(ScoreStrategyEnum.CATEGORY.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.CATEGORY.value())
-                        + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value())
-                        + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value());
-                if (item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value()) >= 0) {
-                    score += item.getScore(ScoreStrategyEnum.VIEW_COUNT_RATE.value());
-                }
-            } else {
-                score = item.getScore(ScoreStrategyEnum.SIMILARITY.value())
-                        + item.getScore(ScoreStrategyEnum.CATEGORY.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.CATEGORY.value())
-                        + item.getScore(ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value())
-                        + item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value())
-                        + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value())
-                        + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value());
-            }
-            c.setScore(score);
-            item.setScore(score);
-            return item;
-        });
+        List<RankItem> items = param.getRankItems();
+
         // 相似度评分为0 报警返回
         List<Article> hisPublishFirstArticleList = articleRepository.getByGhIdAndItemIndexAndTypeEqualsAndStatusEquals(
                 param.getGhId(), 1, param.getType(), 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);
 
         // 3 文章按照内容池分组

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

@@ -1,17 +1,12 @@
 package com.tzld.longarticle.recommend.server.service.recommend.rank.strategy;
 
 
-import com.tzld.longarticle.recommend.server.common.enums.recommend.RankStrategyEnum;
-import com.tzld.longarticle.recommend.server.common.enums.recommend.ScoreStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
 import com.tzld.longarticle.recommend.server.model.entity.crawler.Article;
 import com.tzld.longarticle.recommend.server.repository.crawler.ArticleRepository;
 import com.tzld.longarticle.recommend.server.service.recommend.config.AccountContentPoolConfigService;
-import com.tzld.longarticle.recommend.server.service.recommend.config.StrategyIndexScoreWeightService;
 import com.tzld.longarticle.recommend.server.service.recommend.rank.*;
 import com.tzld.longarticle.recommend.server.service.recommend.score.AccountIndexReplacePoolConfig;
-import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreResult;
-import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreService;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
@@ -27,87 +22,26 @@ import java.util.*;
 @Slf4j
 public class RankV11Strategy 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<>();
 
-        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;
-            int index = weightService.getIndex(item.getContent().getContentPoolType(), contentPools);
-            if (contentPools[0].equals(item.getContent().getContentPoolType())) {
-                score = item.getScore(ScoreStrategyEnum.HIS_FISSION_AVG_READ_RATE_RATE.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.HIS_FISSION_AVG_READ_RATE_RATE.value())
-                        + item.getScore(ScoreStrategyEnum.SIMILARITY.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.SIMILARITY.value())
-                        + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value());
-                if (item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value()) >= 0) {
-                    score += item.getScore(ScoreStrategyEnum.VIEW_COUNT_RATE.value())
-                            * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                            ScoreStrategyEnum.VIEW_COUNT_RATE.value());
-                }
-            } else if (contentPools[1].equals(item.getContent().getContentPoolType())) {
-                score = (item.getScore(ScoreStrategyEnum.SIMILARITY.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.SIMILARITY.value()))
-                        + item.getScore(ScoreStrategyEnum.CATEGORY.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.CATEGORY.value())
-                        + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value())
-                        + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value());
-                if (item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value()) >= 0) {
-                    score += item.getScore(ScoreStrategyEnum.VIEW_COUNT_RATE.value())
-                            * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                            ScoreStrategyEnum.VIEW_COUNT_RATE.value());
-                }
-            } else {
-                score = (item.getScore(ScoreStrategyEnum.SIMILARITY.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.SIMILARITY.value()))
-                        + item.getScore(ScoreStrategyEnum.CATEGORY.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.CATEGORY.value())
-                        + (item.getScore(ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value()))
-                        + item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value())
-                        + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value())
-                        + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value());
-            }
-            c.setScore(score);
-            c.setHisPublishArticleList(null);
-            item.setScore(score);
-            return item;
-        });
+        List<RankItem> items = param.getRankItems();
+
         // 相似度评分为0 报警返回
         List<Article> hisPublishFirstArticleList = articleRepository.getByGhIdAndItemIndexAndTypeEqualsAndStatusEquals(
                 param.getGhId(), 1, param.getType(), 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);
 
         // 3 文章按照内容池分组

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

@@ -1,17 +1,12 @@
 package com.tzld.longarticle.recommend.server.service.recommend.rank.strategy;
 
 
-import com.tzld.longarticle.recommend.server.common.enums.recommend.RankStrategyEnum;
-import com.tzld.longarticle.recommend.server.common.enums.recommend.ScoreStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
 import com.tzld.longarticle.recommend.server.model.entity.crawler.Article;
 import com.tzld.longarticle.recommend.server.repository.crawler.ArticleRepository;
 import com.tzld.longarticle.recommend.server.service.recommend.config.AccountContentPoolConfigService;
-import com.tzld.longarticle.recommend.server.service.recommend.config.StrategyIndexScoreWeightService;
 import com.tzld.longarticle.recommend.server.service.recommend.rank.*;
 import com.tzld.longarticle.recommend.server.service.recommend.score.AccountIndexReplacePoolConfig;
-import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreResult;
-import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreService;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
@@ -27,87 +22,26 @@ import java.util.*;
 @Slf4j
 public class RankV12Strategy 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<>();
 
-        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;
-            int index = weightService.getIndex(item.getContent().getContentPoolType(), contentPools);
-            if (contentPools[0].equals(item.getContent().getContentPoolType())) {
-                score = item.getScore(ScoreStrategyEnum.HIS_FISSION_DE_WEIGHT_AVG_READ_SUM_RATE.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.HIS_FISSION_DE_WEIGHT_AVG_READ_SUM_RATE.value())
-                        + item.getScore(ScoreStrategyEnum.SIMILARITY.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.SIMILARITY.value())
-                        + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value());
-                if (item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value()) >= 0) {
-                    score += item.getScore(ScoreStrategyEnum.VIEW_COUNT_RATE.value())
-                            * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                            ScoreStrategyEnum.VIEW_COUNT_RATE.value());
-                }
-            } else if (contentPools[1].equals(item.getContent().getContentPoolType())) {
-                score = (item.getScore(ScoreStrategyEnum.SIMILARITY.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.SIMILARITY.value()))
-                        + item.getScore(ScoreStrategyEnum.CATEGORY.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.CATEGORY.value())
-                        + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value())
-                        + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value());
-                if (item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value()) >= 0) {
-                    score += item.getScore(ScoreStrategyEnum.VIEW_COUNT_RATE.value())
-                            * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                            ScoreStrategyEnum.VIEW_COUNT_RATE.value());
-                }
-            } else {
-                score = (item.getScore(ScoreStrategyEnum.SIMILARITY.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.SIMILARITY.value()))
-                        + item.getScore(ScoreStrategyEnum.CATEGORY.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.CATEGORY.value())
-                        + (item.getScore(ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value()))
-                        + item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value())
-                        + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value())
-                        + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value());
-            }
-            c.setScore(score);
-            c.setHisPublishArticleList(null);
-            item.setScore(score);
-            return item;
-        });
+        List<RankItem> items = param.getRankItems();
+
         // 相似度评分为0 报警返回
         List<Article> hisPublishFirstArticleList = articleRepository.getByGhIdAndItemIndexAndTypeEqualsAndStatusEquals(
                 param.getGhId(), 1, param.getType(), 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);
 
         // 3 文章按照内容池分组

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

@@ -1,17 +1,12 @@
 package com.tzld.longarticle.recommend.server.service.recommend.rank.strategy;
 
 
-import com.tzld.longarticle.recommend.server.common.enums.recommend.RankStrategyEnum;
-import com.tzld.longarticle.recommend.server.common.enums.recommend.ScoreStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
 import com.tzld.longarticle.recommend.server.model.entity.crawler.Article;
 import com.tzld.longarticle.recommend.server.repository.crawler.ArticleRepository;
 import com.tzld.longarticle.recommend.server.service.recommend.config.AccountContentPoolConfigService;
-import com.tzld.longarticle.recommend.server.service.recommend.config.StrategyIndexScoreWeightService;
 import com.tzld.longarticle.recommend.server.service.recommend.rank.*;
 import com.tzld.longarticle.recommend.server.service.recommend.score.AccountIndexReplacePoolConfig;
-import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreResult;
-import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreService;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
@@ -27,88 +22,26 @@ import java.util.*;
 @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<>();
 
-        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;
-            int index = weightService.getIndex(item.getContent().getContentPoolType(), contentPools);
-            if (contentPools[0].equals(item.getContent().getContentPoolType())) {
-                double similarityScore = Math.pow(item.getScore(ScoreStrategyEnum.SIMILARITY.value()),
-                        weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                                ScoreStrategyEnum.SIMILARITY.value()));
-                score = item.getScore(ScoreStrategyEnum.HIS_FISSION_AVG_READ_RATE_RATE.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.HIS_FISSION_AVG_READ_RATE_RATE.value())
-                        + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value());
-                if (item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value()) >= 0) {
-                    score += item.getScore(ScoreStrategyEnum.VIEW_COUNT_RATE.value())
-                            * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                            ScoreStrategyEnum.VIEW_COUNT_RATE.value());
-                }
-                score = score * similarityScore;
-            } else if (contentPools[1].equals(item.getContent().getContentPoolType())) {
-                score = (item.getScore(ScoreStrategyEnum.SIMILARITY.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.SIMILARITY.value()))
-                        + item.getScore(ScoreStrategyEnum.CATEGORY.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.CATEGORY.value())
-                        + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value())
-                        + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value());
-                if (item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value()) >= 0) {
-                    score += item.getScore(ScoreStrategyEnum.VIEW_COUNT_RATE.value())
-                            * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                            ScoreStrategyEnum.VIEW_COUNT_RATE.value());
-                }
-            } else {
-                score = (item.getScore(ScoreStrategyEnum.SIMILARITY.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.SIMILARITY.value()))
-                        + item.getScore(ScoreStrategyEnum.CATEGORY.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.CATEGORY.value())
-                        + (item.getScore(ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value()))
-                        + item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value())
-                        + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value())
-                        + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value());
-            }
-            c.setScore(score);
-            c.setHisPublishArticleList(null);
-            item.setScore(score);
-            return item;
-        });
+        List<RankItem> items = param.getRankItems();
+
         // 相似度评分为0 报警返回
         List<Article> hisPublishFirstArticleList = articleRepository.getByGhIdAndItemIndexAndTypeEqualsAndStatusEquals(
                 param.getGhId(), 1, param.getType(), 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);
 
         // 3 文章按照内容池分组

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

@@ -1,17 +1,12 @@
 package com.tzld.longarticle.recommend.server.service.recommend.rank.strategy;
 
 
-import com.tzld.longarticle.recommend.server.common.enums.recommend.RankStrategyEnum;
-import com.tzld.longarticle.recommend.server.common.enums.recommend.ScoreStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
 import com.tzld.longarticle.recommend.server.model.entity.crawler.Article;
 import com.tzld.longarticle.recommend.server.repository.crawler.ArticleRepository;
 import com.tzld.longarticle.recommend.server.service.recommend.config.AccountContentPoolConfigService;
-import com.tzld.longarticle.recommend.server.service.recommend.config.StrategyIndexScoreWeightService;
 import com.tzld.longarticle.recommend.server.service.recommend.rank.*;
 import com.tzld.longarticle.recommend.server.service.recommend.score.AccountIndexReplacePoolConfig;
-import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreResult;
-import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreService;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
@@ -27,88 +22,26 @@ import java.util.*;
 @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<>();
 
-        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;
-            int index = weightService.getIndex(item.getContent().getContentPoolType(), contentPools);
-            if (contentPools[0].equals(item.getContent().getContentPoolType())) {
-                double similarityScore = Math.pow(item.getScore(ScoreStrategyEnum.SIMILARITY.value()),
-                        weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                                ScoreStrategyEnum.SIMILARITY.value()));
-                score = item.getScore(ScoreStrategyEnum.HIS_FISSION_DE_WEIGHT_AVG_READ_SUM_RATE.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.HIS_FISSION_DE_WEIGHT_AVG_READ_SUM_RATE.value())
-                        + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value());
-                if (item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value()) >= 0) {
-                    score += item.getScore(ScoreStrategyEnum.VIEW_COUNT_RATE.value())
-                            * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                            ScoreStrategyEnum.VIEW_COUNT_RATE.value());
-                }
-                score = score * similarityScore;
-            } else if (contentPools[1].equals(item.getContent().getContentPoolType())) {
-                score = (item.getScore(ScoreStrategyEnum.SIMILARITY.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.SIMILARITY.value()))
-                        + item.getScore(ScoreStrategyEnum.CATEGORY.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.CATEGORY.value())
-                        + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value())
-                        + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value());
-                if (item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value()) >= 0) {
-                    score += item.getScore(ScoreStrategyEnum.VIEW_COUNT_RATE.value())
-                            * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                            ScoreStrategyEnum.VIEW_COUNT_RATE.value());
-                }
-            } else {
-                score = (item.getScore(ScoreStrategyEnum.SIMILARITY.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.SIMILARITY.value()))
-                        + item.getScore(ScoreStrategyEnum.CATEGORY.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.CATEGORY.value())
-                        + (item.getScore(ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value()))
-                        + item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value())
-                        + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value())
-                        + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value());
-            }
-            c.setScore(score);
-            c.setHisPublishArticleList(null);
-            item.setScore(score);
-            return item;
-        });
+        List<RankItem> items = param.getRankItems();
+
         // 相似度评分为0 报警返回
         List<Article> hisPublishFirstArticleList = articleRepository.getByGhIdAndItemIndexAndTypeEqualsAndStatusEquals(
                 param.getGhId(), 1, param.getType(), 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);
 
         // 3 文章按照内容池分组

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

@@ -3,16 +3,12 @@ package com.tzld.longarticle.recommend.server.service.recommend.rank.strategy;
 
 import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
 import com.tzld.longarticle.recommend.server.common.enums.aigc.PublishPlanInputSourceTypesEnum;
-import com.tzld.longarticle.recommend.server.common.enums.recommend.ScoreStrategyEnum;
 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.recommend.config.AccountContentPoolConfigService;
-import com.tzld.longarticle.recommend.server.service.recommend.config.StrategyIndexScoreWeightService;
 import com.tzld.longarticle.recommend.server.service.recommend.rank.*;
 import com.tzld.longarticle.recommend.server.service.recommend.score.AccountIndexReplacePoolConfig;
-import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreResult;
-import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreService;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
@@ -29,14 +25,10 @@ import java.util.stream.Collectors;
 @Slf4j
 public class RankV15Strategy implements RankStrategy {
 
-    @Autowired
-    private ScoreService scoreService;
     @Autowired
     private AccountContentPoolConfigService accountContentPoolConfigService;
     @Autowired
     private ArticleRepository articleRepository;
-    @Autowired
-    private StrategyIndexScoreWeightService weightService;
 
     @ApolloJsonValue("${touliu.account.ghIds:[\"gh_93e00e187787\", \"gh_ac43e43b253b\", \"gh_68e7fdc09fe4\",\"gh_77f36c109fb1\", \"gh_b181786a6c8c\", \"gh_1ee2e1b39ccf\"]}")
     private List<String> touliuAccountGhIds;
@@ -44,60 +36,18 @@ public class RankV15Strategy implements RankStrategy {
     public RankResult rank(RankParam param) {
         List<Content> result = new ArrayList<>();
 
-        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;
-            int index = weightService.getIndex(item.getContent().getContentPoolType(), contentPools);
-            if (contentPools[0].equals(item.getContent().getContentPoolType())
-                    || contentPools[1].equals(item.getContent().getContentPoolType())) {
-                score = item.getScore(ScoreStrategyEnum.SIMILARITY.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.SIMILARITY.value())
-                        + item.getScore(ScoreStrategyEnum.CATEGORY.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.CATEGORY.value())
-                        + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value())
-                        + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value());
-                if (item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value()) >= 0) {
-                    score += item.getScore(ScoreStrategyEnum.VIEW_COUNT_RATE.value())
-                            * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                            ScoreStrategyEnum.VIEW_COUNT_RATE.value());
-                }
-            } else {
-                score = item.getScore(ScoreStrategyEnum.SIMILARITY.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.SIMILARITY.value())
-                        + item.getScore(ScoreStrategyEnum.CATEGORY.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.CATEGORY.value())
-                        + item.getScore(ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value())
-                        + item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value())
-                        + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value())
-                        + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value());
-            }
-            c.setScore(score);
-            item.setScore(score);
-            return item;
-        });
+        List<RankItem> items = param.getRankItems();
+
         // 相似度评分为0 报警返回
         List<Article> hisPublishFirstArticleList = articleRepository.getByGhIdAndItemIndexAndTypeEqualsAndStatusEquals(
                 param.getGhId(), 1, param.getType(), 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);
 
         // 3 文章按照内容池分组

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

@@ -3,13 +3,7 @@ package com.tzld.longarticle.recommend.server.service.recommend.rank.strategy;
 
 import com.tzld.longarticle.recommend.server.common.enums.recommend.ScoreStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankItem;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankParam;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankResult;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankStrategy;
-import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreResult;
-import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreService;
-import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
+import com.tzld.longarticle.recommend.server.service.recommend.rank.*;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -18,7 +12,6 @@ import org.springframework.stereotype.Service;
 import java.util.ArrayList;
 import java.util.Collections;
 import java.util.List;
-import java.util.Map;
 
 /**
  * @author dyp
@@ -27,22 +20,9 @@ import java.util.Map;
 @Slf4j
 public class RankV2Strategy implements RankStrategy {
 
-    @Autowired
-    private ScoreService scoreService;
-
     public RankResult rank(RankParam param) {
 
-        ScoreResult scoreResult = scoreService.score(RankStrategy.convertToScoreParam(param));
-        Map<String, Map<String, Double>> scoreMap = scoreResult.getScoreMap();
-
-        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()));
-            return item;
-
-        });
+        List<RankItem> items = param.getRankItems();
 
         // 1 排序
         Collections.sort(items, (o1, o2) -> {

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

@@ -1,16 +1,12 @@
 package com.tzld.longarticle.recommend.server.service.recommend.rank.strategy;
 
 
-import com.tzld.longarticle.recommend.server.common.enums.recommend.RankStrategyEnum;
-import com.tzld.longarticle.recommend.server.common.enums.recommend.ScoreStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
 import com.tzld.longarticle.recommend.server.model.entity.crawler.Article;
 import com.tzld.longarticle.recommend.server.repository.crawler.ArticleRepository;
 import com.tzld.longarticle.recommend.server.service.recommend.config.AccountContentPoolConfigService;
 import com.tzld.longarticle.recommend.server.service.recommend.rank.*;
 import com.tzld.longarticle.recommend.server.service.recommend.score.AccountIndexReplacePoolConfig;
-import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreResult;
-import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreService;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
@@ -27,8 +23,6 @@ import java.util.*;
 @Slf4j
 public class RankV3Strategy implements RankStrategy {
 
-    @Autowired
-    private ScoreService scoreService;
     @Autowired
     private AccountContentPoolConfigService accountContentPoolConfigService;
     @Autowired
@@ -37,49 +31,18 @@ public class RankV3Strategy implements RankStrategy {
     public RankResult rank(RankParam param) {
         List<Content> result = new ArrayList<>();
 
-        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())
-                    || contentPools[1].equals(item.getContent().getContentPoolType())) {
-                score = item.getScore(ScoreStrategyEnum.SIMILARITY.value())
-                        + item.getScore(ScoreStrategyEnum.CATEGORY.value())
-                        + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value())
-                        + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value());
-                if (item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value()) >= 0) {
-                    score += item.getScore(ScoreStrategyEnum.VIEW_COUNT_RATE.value());
-                }
-            } else {
-                score = item.getScore(ScoreStrategyEnum.SIMILARITY.value())
-                        + item.getScore(ScoreStrategyEnum.CATEGORY.value())
-                        + item.getScore(ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value())
-                        + item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value())
-                        + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value())
-                        + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value());
-            }
-            c.setScore(score);
-            item.setScore(score);
-            return item;
-        });
+        List<RankItem> items = param.getRankItems();
+
         // 相似度评分为0 报警返回
         List<Article> hisPublishFirstArticleList = articleRepository.getByGhIdAndItemIndexAndTypeEqualsAndStatusEquals(
                 param.getGhId(), 1, param.getType(), 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);
 
         // 3 文章按照内容池分组

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

@@ -1,15 +1,12 @@
 package com.tzld.longarticle.recommend.server.service.recommend.rank.strategy;
 
 
-import com.tzld.longarticle.recommend.server.common.enums.recommend.ScoreStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
 import com.tzld.longarticle.recommend.server.model.entity.crawler.Article;
 import com.tzld.longarticle.recommend.server.repository.crawler.ArticleRepository;
 import com.tzld.longarticle.recommend.server.service.recommend.config.AccountContentPoolConfigService;
 import com.tzld.longarticle.recommend.server.service.recommend.rank.*;
 import com.tzld.longarticle.recommend.server.service.recommend.score.AccountIndexReplacePoolConfig;
-import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreResult;
-import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreService;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
@@ -25,8 +22,6 @@ import java.util.*;
 @Slf4j
 public class RankV4Strategy implements RankStrategy {
 
-    @Autowired
-    private ScoreService scoreService;
     @Autowired
     private AccountContentPoolConfigService accountContentPoolConfigService;
     @Autowired
@@ -35,49 +30,18 @@ public class RankV4Strategy implements RankStrategy {
     public RankResult rank(RankParam param) {
         List<Content> result = new ArrayList<>();
 
-        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())
-                    || contentPools[1].equals(item.getContent().getContentPoolType())) {
-                score = item.getScore(ScoreStrategyEnum.SIMILARITY.value())
-                        + item.getScore(ScoreStrategyEnum.CATEGORY.value())
-                        + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value())
-                        + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value());
-                if (item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value()) >= 0) {
-                    score += item.getScore(ScoreStrategyEnum.VIEW_COUNT_RATE_CORRELATION.value());
-                }
-            } else {
-                score = item.getScore(ScoreStrategyEnum.SIMILARITY.value())
-                        + item.getScore(ScoreStrategyEnum.CATEGORY.value())
-                        + item.getScore(ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value())
-                        + item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value())
-                        + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value())
-                        + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value());
-            }
-            c.setScore(score);
-            item.setScore(score);
-            return item;
-        });
+        List<RankItem> items = param.getRankItems();
+
         // 相似度评分为0 报警返回
         List<Article> hisPublishFirstArticleList = articleRepository.getByGhIdAndItemIndexAndTypeEqualsAndStatusEquals(
                 param.getGhId(), 1, param.getType(), 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);
 
         // 3 文章按照内容池分组

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

@@ -1,17 +1,12 @@
 package com.tzld.longarticle.recommend.server.service.recommend.rank.strategy;
 
 
-import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
-import com.tzld.longarticle.recommend.server.common.enums.recommend.ScoreStrategyEnum;
 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.recommend.config.AccountContentPoolConfigService;
-import com.tzld.longarticle.recommend.server.service.recommend.config.StrategyIndexScoreWeightService;
 import com.tzld.longarticle.recommend.server.service.recommend.rank.*;
 import com.tzld.longarticle.recommend.server.service.recommend.score.AccountIndexReplacePoolConfig;
-import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreResult;
-import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreService;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
@@ -27,65 +22,19 @@ import java.util.*;
 @Slf4j
 public class RankV5Strategy implements RankStrategy {
 
-    @Autowired
-    private ScoreService scoreService;
     @Autowired
     private AccountContentPoolConfigService accountContentPoolConfigService;
     @Autowired
     private ArticleRepository articleRepository;
-    @Autowired
-    private StrategyIndexScoreWeightService weightService;
-
-    @ApolloJsonValue("${touliu.account.ghIds:[\"gh_93e00e187787\", \"gh_ac43e43b253b\", \"gh_68e7fdc09fe4\",\"gh_77f36c109fb1\", \"gh_b181786a6c8c\", \"gh_1ee2e1b39ccf\"]}")
-    private List<String> touliuAccountGhIds;
 
     public RankResult rank(RankParam param) {
         List<Content> result = new ArrayList<>();
 
-        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;
-            int index = weightService.getIndex(item.getContent().getContentPoolType(), contentPools);
-            if (contentPools[0].equals(item.getContent().getContentPoolType())
-                    || contentPools[1].equals(item.getContent().getContentPoolType())) {
-                score = item.getScore(ScoreStrategyEnum.SIMILARITY.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.SIMILARITY.value())
-                        + item.getScore(ScoreStrategyEnum.CATEGORY.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.CATEGORY.value())
-                        + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value())
-                        + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value());
-                if (item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value()) >= 0) {
-                    score += item.getScore(ScoreStrategyEnum.VIEW_COUNT_RATE.value())
-                            * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                            ScoreStrategyEnum.VIEW_COUNT_RATE.value());
-                }
-            } else {
-                score = item.getScore(ScoreStrategyEnum.SIMILARITY.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.SIMILARITY.value())
-                        + item.getScore(ScoreStrategyEnum.CATEGORY.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.CATEGORY.value())
-                        + item.getScore(ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value())
-                        + item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value())
-                        + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value())
-                        + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value());
-            }
-            c.setScore(score);
-            item.setScore(score);
-            return item;
-        });
+        List<RankItem> items = param.getRankItems();
+
         // 相似度评分为0 报警返回
         List<Article> hisPublishFirstArticleList = articleRepository.getByGhIdAndItemIndexAndTypeEqualsAndStatusEquals(
                 param.getGhId(), 1, param.getType(), 1);
@@ -93,9 +42,6 @@ public class RankV5Strategy implements RankStrategy {
             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);
 
         // 3 文章按照内容池分组

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

@@ -1,16 +1,12 @@
 package com.tzld.longarticle.recommend.server.service.recommend.rank.strategy;
 
 
-import com.tzld.longarticle.recommend.server.common.enums.recommend.RankStrategyEnum;
-import com.tzld.longarticle.recommend.server.common.enums.recommend.ScoreStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
 import com.tzld.longarticle.recommend.server.model.entity.crawler.Article;
 import com.tzld.longarticle.recommend.server.repository.crawler.ArticleRepository;
 import com.tzld.longarticle.recommend.server.service.recommend.config.AccountContentPoolConfigService;
 import com.tzld.longarticle.recommend.server.service.recommend.rank.*;
 import com.tzld.longarticle.recommend.server.service.recommend.score.AccountIndexReplacePoolConfig;
-import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreResult;
-import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreService;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
@@ -26,8 +22,6 @@ import java.util.*;
 @Slf4j
 public class RankV7Strategy implements RankStrategy {
 
-    @Autowired
-    private ScoreService scoreService;
     @Autowired
     private AccountContentPoolConfigService accountContentPoolConfigService;
     @Autowired
@@ -36,51 +30,18 @@ public class RankV7Strategy implements RankStrategy {
     public RankResult rank(RankParam param) {
         List<Content> result = new ArrayList<>();
 
-        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(ScoreStrategyEnum.HIS_FISSION_AVG_READ_RATE_CORRELATION_RATE.value())
-                        + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value());
-            } else if (contentPools[1].equals(item.getContent().getContentPoolType())) {
-                score = item.getScore(ScoreStrategyEnum.SIMILARITY.value())
-                        + item.getScore(ScoreStrategyEnum.CATEGORY.value())
-                        + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value())
-                        + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value());
-                if (item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value()) >= 0) {
-                    score += item.getScore(ScoreStrategyEnum.VIEW_COUNT_RATE.value());
-                }
-            } else {
-                score = item.getScore(ScoreStrategyEnum.SIMILARITY.value())
-                        + item.getScore(ScoreStrategyEnum.CATEGORY.value())
-                        + item.getScore(ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value())
-                        + item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value())
-                        + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value())
-                        + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value());
-            }
-            c.setScore(score);
-            item.setScore(score);
-            return item;
-        });
+        List<RankItem> items = param.getRankItems();
+
         // 相似度评分为0 报警返回
         List<Article> hisPublishFirstArticleList = articleRepository.getByGhIdAndItemIndexAndTypeEqualsAndStatusEquals(
                 param.getGhId(), 1, param.getType(), 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);
 
         // 3 文章按照内容池分组

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

@@ -1,17 +1,12 @@
 package com.tzld.longarticle.recommend.server.service.recommend.rank.strategy;
 
 
-import com.tzld.longarticle.recommend.server.common.enums.recommend.RankStrategyEnum;
-import com.tzld.longarticle.recommend.server.common.enums.recommend.ScoreStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
 import com.tzld.longarticle.recommend.server.model.entity.crawler.Article;
 import com.tzld.longarticle.recommend.server.repository.crawler.ArticleRepository;
 import com.tzld.longarticle.recommend.server.service.recommend.config.AccountContentPoolConfigService;
-import com.tzld.longarticle.recommend.server.service.recommend.config.StrategyIndexScoreWeightService;
 import com.tzld.longarticle.recommend.server.service.recommend.rank.*;
 import com.tzld.longarticle.recommend.server.service.recommend.score.AccountIndexReplacePoolConfig;
-import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreResult;
-import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreService;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
@@ -27,71 +22,26 @@ import java.util.*;
 @Slf4j
 public class RankV8Strategy 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<>();
 
-        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;
-            int index = weightService.getIndex(item.getContent().getContentPoolType(), contentPools);
-            if (contentPools[0].equals(item.getContent().getContentPoolType())) {
-                score = item.getScore(ScoreStrategyEnum.SIMILARITY.value())
-                        + item.getScore(ScoreStrategyEnum.CATEGORY.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.CATEGORY.value())
-                        + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value())
-                        + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value())
-                        + item.getScore(ScoreStrategyEnum.HIS_FISSION_AVG_READ_RATE_RATE.value());
-            } else if (contentPools[1].equals(item.getContent().getContentPoolType())) {
-                score = item.getScore(ScoreStrategyEnum.SIMILARITY.value())
-                        + item.getScore(ScoreStrategyEnum.CATEGORY.value())
-                        + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value())
-                        + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value());
-                if (item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value()) >= 0) {
-                    score += item.getScore(ScoreStrategyEnum.VIEW_COUNT_RATE.value());
-                }
-            } else {
-                score = item.getScore(ScoreStrategyEnum.SIMILARITY.value())
-                        + item.getScore(ScoreStrategyEnum.CATEGORY.value())
-                        * weightService.getWeight(param.getStrategy(), param.getGhId(), index,
-                        ScoreStrategyEnum.CATEGORY.value())
-                        + item.getScore(ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value())
-                        + item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value())
-                        + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value())
-                        + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value());
-            }
-            c.setScore(score);
-            item.setScore(score);
-            return item;
-        });
+        List<RankItem> items = param.getRankItems();
+
         // 相似度评分为0 报警返回
         List<Article> hisPublishFirstArticleList = articleRepository.getByGhIdAndItemIndexAndTypeEqualsAndStatusEquals(
                 param.getGhId(), 1, param.getType(), 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);
 
         // 3 文章按照内容池分组

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

@@ -1,15 +1,12 @@
 package com.tzld.longarticle.recommend.server.service.recommend.rank.strategy;
 
 
-import com.tzld.longarticle.recommend.server.common.enums.recommend.ScoreStrategyEnum;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
 import com.tzld.longarticle.recommend.server.model.entity.crawler.Article;
 import com.tzld.longarticle.recommend.server.repository.crawler.ArticleRepository;
 import com.tzld.longarticle.recommend.server.service.recommend.config.AccountContentPoolConfigService;
 import com.tzld.longarticle.recommend.server.service.recommend.rank.*;
 import com.tzld.longarticle.recommend.server.service.recommend.score.AccountIndexReplacePoolConfig;
-import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreResult;
-import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreService;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.collections4.CollectionUtils;
@@ -25,8 +22,6 @@ import java.util.*;
 @Slf4j
 public class RankV9Strategy implements RankStrategy {
 
-    @Autowired
-    private ScoreService scoreService;
     @Autowired
     private AccountContentPoolConfigService accountContentPoolConfigService;
     @Autowired
@@ -35,51 +30,18 @@ public class RankV9Strategy implements RankStrategy {
     public RankResult rank(RankParam param) {
         List<Content> result = new ArrayList<>();
 
-        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(ScoreStrategyEnum.HIS_FISSION_AVG_READ_RATE_RATE.value())
-                        + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value());
-            } else if (contentPools[1].equals(item.getContent().getContentPoolType())) {
-                score = item.getScore(ScoreStrategyEnum.SIMILARITY.value())
-                        + item.getScore(ScoreStrategyEnum.CATEGORY.value())
-                        + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value())
-                        + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value());
-                if (item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value()) >= 0) {
-                    score += item.getScore(ScoreStrategyEnum.VIEW_COUNT_RATE.value());
-                }
-            } else {
-                score = item.getScore(ScoreStrategyEnum.SIMILARITY.value())
-                        + item.getScore(ScoreStrategyEnum.CATEGORY.value())
-                        + item.getScore(ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value())
-                        + item.getScore(ScoreStrategyEnum.PUBLISH_TIMES.value())
-                        + item.getScore(ScoreStrategyEnum.CRAWLER_DAYS_DECREASE_STRATEGY.value())
-                        + item.getScore(ScoreStrategyEnum.FLOW_CTL_DECREASE.value());
-            }
-            c.setScore(score);
-            item.setScore(score);
-            return item;
-        });
+        List<RankItem> items = param.getRankItems();
+
         // 相似度评分为0 报警返回
         List<Article> hisPublishFirstArticleList = articleRepository.getByGhIdAndItemIndexAndTypeEqualsAndStatusEquals(
                 param.getGhId(), 1, param.getType(), 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);
 
         // 3 文章按照内容池分组

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

@@ -8,12 +8,14 @@ import com.tzld.longarticle.recommend.server.common.ThreadPoolFactory;
 import com.tzld.longarticle.recommend.server.common.enums.StatusEnum;
 import com.tzld.longarticle.recommend.server.common.enums.aigc.PublishPlanInputSourceTypesEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.*;
+import com.tzld.longarticle.recommend.server.mapper.aigc.AigcBaseMapper;
 import com.tzld.longarticle.recommend.server.mapper.crawler.ArticleMapper;
 import com.tzld.longarticle.recommend.server.mapper.crawler.CrawlerBaseMapper;
 import com.tzld.longarticle.recommend.server.mapper.longArticle.LongArticleBaseMapper;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
 import com.tzld.longarticle.recommend.server.model.dto.ContentHisPublishArticle;
 import com.tzld.longarticle.recommend.server.model.entity.aigc.CrawlerMetaArticle;
+import com.tzld.longarticle.recommend.server.model.entity.aigc.ProduceTaskAtom;
 import com.tzld.longarticle.recommend.server.model.entity.aigc.PublishContent;
 import com.tzld.longarticle.recommend.server.model.entity.crawler.AccountAvgInfo;
 import com.tzld.longarticle.recommend.server.model.entity.crawler.AccountCorrelation;
@@ -96,6 +98,8 @@ public class RecallService implements ApplicationContextAware {
     ArticleTitleHisCacheRepository articleTitleHisCacheRepository;
     @Autowired
     LongArticleBaseMapper longArticleBaseMapper;
+    @Autowired
+    AigcBaseMapper aigcBaseMapper;
 
     private final Map<String, RecallStrategy> strategyMap = new HashMap<>();
     private ApplicationContext applicationContext;
@@ -292,6 +296,7 @@ public class RecallService implements ApplicationContextAware {
                 if (StringUtils.hasText(cache.getCategory())) {
                     content.setCategory(JSONArray.parseArray(cache.getCategory(), String.class));
                 }
+                content.setKimiSafeScore(cache.getKimiSafeScore());
                 content.setRootPublishTimestamp(cache.getRootPublishTimestamp());
                 content.setHisPublishArticleList(hisPublishArticleList);
                 setT0Data(content);
@@ -303,6 +308,7 @@ public class RecallService implements ApplicationContextAware {
                 if (CollectionUtils.isNotEmpty(articleWithHistory.getCategory())) {
                     content.setCategory(articleWithHistory.getCategory());
                 }
+                content.setKimiSafeScore(articleWithHistory.getKimiSafeScore());
                 content.setRootPublishTimestamp(articleWithHistory.getRootPublishTimestamp());
                 for (ContentHisPublishArticle article : content.getHisPublishArticleList()) {
                     article.setCorrelation(Optional.ofNullable(accountCorrelationMap.get(article.getGhId())).orElse(0.0));
@@ -360,6 +366,7 @@ public class RecallService implements ApplicationContextAware {
     public Map<String, Content> getArticleWithHistory(List<TitleHisCacheParam> paramList, String type) {
         Map<String, Content> result = new HashMap<>();
         List<String> titleMd5List = paramList.stream().map(TitleHisCacheParam::getTitleMd5).collect(Collectors.toList());
+        List<String> sourceIds = paramList.stream().map(TitleHisCacheParam::getSourceId).collect(Collectors.toList());
         // 获取历史已发布文章
         List<Article> hisArticleList = new ArrayList<>();
         List<List<String>> titleMd5Partition = Lists.partition(new ArrayList<>(titleMd5List), 1000);
@@ -427,6 +434,10 @@ public class RecallService implements ApplicationContextAware {
                 .collect(Collectors.toMap(ArticleCategory::getChannelContentId, Function.identity(), (a, b) -> a));
         Map<String, ArticleCategory> titleCategoryMap = articleCategoryList.stream()
                 .collect(Collectors.toMap(ArticleCategory::getTitleMd5, Function.identity(), (a, b) -> a));
+        // 根据sourceId查询kimiSafeScore
+        List<ProduceTaskAtom> safeScoreList = aigcBaseMapper.getProduceScoreByContentId(sourceIds);
+        Map<String, String> safeScoreMap = safeScoreList.stream()
+               .collect(Collectors.toMap(ProduceTaskAtom::getPlanExeId, ProduceTaskAtom::getOutput));
 
         for (TitleHisCacheParam cacheParam : paramList) {
             Content res = new Content();
@@ -441,6 +452,14 @@ public class RecallService implements ApplicationContextAware {
             if (Objects.nonNull(category)) {
                 res.setCategory(Collections.singletonList(category.getCategory()));
             }
+            // 设置kimiSafeScore
+            String safeScore = safeScoreMap.get(cacheParam.getSourceId());
+            if (StringUtils.hasText(safeScore)) {
+                safeScore = safeScore.replaceAll("\n","");
+                if (safeScore.length() == 1) {
+                    res.setKimiSafeScore(safeScore);
+                }
+            }
             // 溯源查找源发布时间
             ArticlePoolPromotionSource source = sourceMap.get(cacheParam.getCrawlerChannelContentId());
             if (Objects.nonNull(source) && Objects.nonNull(source.getRootProduceContentId())) {

+ 17 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/reduce/ReduceParam.java

@@ -0,0 +1,17 @@
+package com.tzld.longarticle.recommend.server.service.recommend.reduce;
+
+import com.tzld.longarticle.recommend.server.model.dto.Content;
+import lombok.Data;
+
+import java.util.List;
+
+@Data
+public class ReduceParam {
+    private String accountId;
+    private String accountName;
+    private Integer publishNum;
+    private String planId;
+    private String strategy;
+    private String ghId;
+    private List<Content> content;
+}

+ 81 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/reduce/ReduceService.java

@@ -0,0 +1,81 @@
+package com.tzld.longarticle.recommend.server.service.recommend.reduce;
+
+import com.tzld.longarticle.recommend.server.common.ThreadPoolFactory;
+import com.tzld.longarticle.recommend.server.service.recommend.reduce.strategy.SafeReduceStrategy;
+import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
+import com.tzld.longarticle.recommend.server.util.JSONUtils;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.BeansException;
+import org.springframework.context.ApplicationContext;
+import org.springframework.context.ApplicationContextAware;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.PostConstruct;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.ExecutorService;
+import java.util.concurrent.TimeUnit;
+
+@Service
+@Slf4j
+public class ReduceService implements ApplicationContextAware {
+
+    private final Map<String, ReduceStrategy> strategyMap = new HashMap<>();
+    private ApplicationContext applicationContext;
+    private final ExecutorService pool = ThreadPoolFactory.reducePool();
+
+
+
+    @PostConstruct
+    public void init() {
+        Map<String, ReduceStrategy> type = applicationContext.getBeansOfType(ReduceStrategy.class);
+        for (Map.Entry<String, ReduceStrategy> entry : type.entrySet()) {
+            ReduceStrategy value = entry.getValue();
+            strategyMap.put(value.getClass().getSimpleName(), value);
+        }
+    }
+
+    public void reduce(ReduceParam param) {
+        long start = System.currentTimeMillis();
+        List<ReduceStrategy> strategies = getReduceStrategy();
+        log.info("ReduceStrategy {}", JSONUtils.toJson(CommonCollectionUtils.toList(strategies,
+                s -> s.getClass().getSimpleName())));
+        CountDownLatch cdl = new CountDownLatch(strategies.size());
+        for (final ReduceStrategy strategy : strategies) {
+            pool.submit(() -> {
+                try {
+                    strategy.reduce(param);
+                } catch (Exception e) {
+                    log.error("reduceService error:{}", e.getMessage(), e);
+                } finally {
+                    cdl.countDown();
+                }
+                return new ArrayList<>();
+            });
+        }
+        try {
+            cdl.await(30, TimeUnit.SECONDS);
+        } catch (InterruptedException e) {
+            log.error("reduce error", e);
+            return;
+        }
+        param.getContent().sort((o1, o2) -> -Double.compare(o1.getScore(), o2.getScore()));
+        log.info("reduce耗时:{}", System.currentTimeMillis() - start);
+    }
+
+    private List<ReduceStrategy> getReduceStrategy() {
+        List<ReduceStrategy> strategies = new ArrayList<>();
+        strategies.add(strategyMap.get(SafeReduceStrategy.class.getSimpleName()));
+        return strategies;
+    }
+
+    @Override
+    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
+        this.applicationContext = applicationContext;
+    }
+
+
+}

+ 5 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/reduce/ReduceStrategy.java

@@ -0,0 +1,5 @@
+package com.tzld.longarticle.recommend.server.service.recommend.reduce;
+
+public interface ReduceStrategy {
+    void reduce(ReduceParam param);
+}

+ 31 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/reduce/strategy/SafeReduceStrategy.java

@@ -0,0 +1,31 @@
+package com.tzld.longarticle.recommend.server.service.recommend.reduce.strategy;
+
+import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
+import com.tzld.longarticle.recommend.server.model.dto.Content;
+import com.tzld.longarticle.recommend.server.service.recommend.reduce.ReduceParam;
+import com.tzld.longarticle.recommend.server.service.recommend.reduce.ReduceStrategy;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.stereotype.Component;
+
+import java.util.Map;
+import java.util.Objects;
+
+@Component
+@Slf4j
+public class SafeReduceStrategy implements ReduceStrategy {
+
+    @ApolloJsonValue("${reduce.safe.config:[]}")
+    private Map<String, Double> safeReduceConfig;
+
+    @Override
+    public void reduce(ReduceParam param) {
+        for (Content content : param.getContent()) {
+            if (Objects.nonNull(content.getKimiSafeScore())) {
+                Double safeScore = safeReduceConfig.get(content.getKimiSafeScore());
+                if (Objects.nonNull(safeScore)) {
+                    content.setScore(content.getScore() - safeScore);
+                }
+            }
+        }
+    }
+}

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

@@ -5,6 +5,7 @@ import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
 import com.tzld.longarticle.recommend.server.common.ThreadPoolFactory;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.RankStrategyEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.ScoreStrategyEnum;
+import com.tzld.longarticle.recommend.server.model.dto.Content;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import com.tzld.longarticle.recommend.server.util.JSONUtils;
 import lombok.extern.slf4j.Slf4j;
@@ -88,6 +89,9 @@ public class ScoreService implements ApplicationContextAware {
                 log.error("future get error ", e);
             }
         }
+        for (Content content : param.getContents()) {
+            content.setScoreMap(scoreMap.get(content.getId()));
+        }
         log.info("score耗时:{}", System.currentTimeMillis() - start);
         return new ScoreResult(scoreMap);
     }

+ 18 - 3
long-article-recommend-service/src/main/resources/mapper/aigc/AigcBaseMapper.xml

@@ -355,9 +355,8 @@
             resultType="com.tzld.longarticle.recommend.server.model.entity.aigc.ProduceTaskAtom">
         select atom.plan_exe_id, atom.input, atom.output, record.audit_timestamp as createTimestamp
         from produce_task_atom atom
-         join produce_plan_module_task_exe_record exe on exe.task_exe_id = atom.task_exe_id
-         join produce_plan_exe_record record on exe.plan_exe_id = record.plan_exe_id
-         join produce_plan_module_task task on task.task_id = exe.task_id
+         join produce_plan_exe_record record on atom.plan_exe_id = record.plan_exe_id
+         join produce_plan_module_task task on task.task_id = atom.task_id
         where task.name in ('title 安全分', 'titile 安全分')
           and record.audit_timestamp between #{startTimeStamp} and #{endTimeStamp}
           and atom.output >= 7
@@ -373,4 +372,20 @@
         </foreach>
     </update>
 
+    <select id="getProduceScoreByContentId"
+            resultType="com.tzld.longarticle.recommend.server.model.entity.aigc.ProduceTaskAtom">
+        select atom.plan_exe_id, atom.input, atom.output, record.audit_timestamp as createTimestamp
+        from produce_task_atom atom
+        join produce_plan_exe_record record on atom.plan_exe_id = record.plan_exe_id
+        join produce_plan_module_task task on task.task_id = atom.task_id
+        where task.name in ('title 安全分', 'titile 安全分')
+        and record.plan_exe_id in
+        <foreach collection="planExeIds" item="item" open="(" close=")" separator=",">
+            #{item}
+        </foreach>
+        and record.status in (2, 6, 9)
+        and record.audit_status in (1, 3)
+        order by record.audit_timestamp desc
+    </select>
+
 </mapper>

+ 4 - 4
long-article-recommend-service/src/main/resources/mapper/longArticle/LongArticleBaseMapper.xml

@@ -235,13 +235,13 @@
 
     <insert id="batchInsertArticleTitleHisCache">
         insert into article_title_his_cache
-        (source_id, type, title, title_md5, channel_content_id, root_publish_timestamp, crawler_title,
+        (source_id, type, title, title_md5, kimi_safe_score, channel_content_id, root_publish_timestamp, crawler_title,
          category, his_publish_article_list, create_timestamp)
         values
         <foreach collection="list" item="item" separator=",">
-            (#{item.sourceId}, #{item.type}, #{item.title}, #{item.titleMd5}, #{item.channelContentId},
-             #{item.rootPublishTimestamp}, #{item.crawlerTitle}, #{item.category}, #{item.hisPublishArticleList},
-             #{item.createTimestamp})
+            (#{item.sourceId}, #{item.type}, #{item.title}, #{item.titleMd5}, #{item.kimiSafeScore},
+             #{item.channelContentId}, #{item.rootPublishTimestamp}, #{item.crawlerTitle}, #{item.category},
+             #{item.hisPublishArticleList}, #{item.createTimestamp})
         </foreach>
     </insert>