Jelajahi Sumber

Merge branch 'master' into wyp/1206-titleHisCache

# Conflicts:
#	long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/recall/RecallService.java
wangyunpeng 7 bulan lalu
induk
melakukan
cb7e3206e4
33 mengubah file dengan 410 tambahan dan 91 penghapusan
  1. 1 1
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/common/enums/SecretEnum.java
  2. 40 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/common/enums/aigc/PublishPlanInputSourceTypesEnum.java
  3. 16 6
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/common/enums/recommend/ContentPoolEnum.java
  4. 2 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/common/enums/recommend/RankStrategyEnum.java
  5. 2 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/mapper/aigc/AigcBaseMapper.java
  6. 1 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/dto/Content.java
  7. 1 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/vo/ArticleSortResponseDataItem.java
  8. 2 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/vo/ArticleVideoPoolSourceVO.java
  9. 3 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/longArticle/PublishSingleVideoSourceRepository.java
  10. 39 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/XxlJobService.java
  11. 72 9
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/RankService.java
  12. 1 5
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/HisJumpRankStrategy.java
  13. 3 9
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/InfiniteRankStrategy.java
  14. 3 9
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/LateRankStrategy.java
  15. 1 4
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RandomRankStrategy.java
  16. 2 2
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV10Strategy.java
  17. 3 3
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV11Strategy.java
  18. 3 3
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV12Strategy.java
  19. 3 3
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV13Strategy.java
  20. 3 3
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV14Strategy.java
  21. 133 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV15Strategy.java
  22. 2 9
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV3Strategy.java
  23. 2 2
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV4Strategy.java
  24. 3 4
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV5Strategy.java
  25. 2 2
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV7Strategy.java
  26. 3 3
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV8Strategy.java
  27. 2 2
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/rank/strategy/RankV9Strategy.java
  28. 41 9
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/recall/RecallService.java
  29. 2 1
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recommend/score/ScoreService.java
  30. 5 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/web/XxlJobController.java
  31. 12 0
      long-article-recommend-service/src/main/resources/mapper/aigc/AigcBaseMapper.xml
  32. 1 1
      long-article-recommend-service/src/main/resources/mapper/crawler/CrawlerBaseMapper.xml
  33. 1 1
      long-article-recommend-service/src/main/resources/mapper/longArticle/LongArticleBaseMapper.xml

+ 1 - 1
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/common/enums/SecretEnum.java

@@ -9,7 +9,7 @@ public enum SecretEnum {
     SECRET_ENUM_1("3b83574b477d4c5b8508a6e33f6e35ec", "魅力", "ml"),
     SECRET_ENUM_2("70d342bf11a84ac7aca6b3e99541e085", "老来福", "llf"),
     SECRET_ENUM_3("595db67618174499b2bed23d8be6a3c1", "微小盟", "wxm"),
-    SECRET_ENUM_4("9a48498757774ddf8a3878b9c02d0fef", "福州像素", "fzxs");
+    SECRET_ENUM_4("9a48498757774ddf8a3878b9c02d0fef", "福州像素", "xs");
 
     SecretEnum(String secret, String desc, String channel) {
         this.secret = secret;

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

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

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

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

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

@@ -20,6 +20,8 @@ public enum RankStrategyEnum {
     ArticleRankV13("ArticleRankV13", "ArticleRankV13", "rankV13Strategy"),
     ArticleRankV14("ArticleRankV14", "ArticleRankV14", "rankV14Strategy"),
 
+    ArticleRankV15("ArticleRankV15", "ArticleRankV15", "rankV15Strategy"),
+
     HIS_JUMP_STRATEGY("ArticleRankHisJump", "历史表现跳过相似度策略", "hisJumpRankStrategy"),
     INFINITE_STRATEGY("ArticleRankInfinite", "无限发表", "infiniteRankStrategy"),
     LATE_STRATEGY("ArticleRankLate", "晚间策略", "lateRankStrategy"),

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

@@ -56,4 +56,6 @@ public interface AigcBaseMapper {
     PublishContentDTO getPublishContentById(String publishContentId);
 
     List<PublishContentDTO> getPublishContentBySourceIdIn(List<String> sourceIds);
+
+    List<CrawlerPlan> getColdCrawlerPlan(Long timeStart, Long timeEnd, List<String> planTags);
 }

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

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

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

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

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

@@ -12,6 +12,7 @@ public class ArticleVideoPoolSourceVO {
     private Integer flowPoolLevel;
     private String sourceId;
     private String title;
+    private String coverUrl;
 
     public static List<ArticleVideoPoolSourceVO> convertFromPublishSingleVideoSource(List<PublishSingleVideoSource> list) {
         return list.stream().map(publishSingleVideoSource -> {
@@ -20,6 +21,7 @@ public class ArticleVideoPoolSourceVO {
             articleVideoPoolSourceVO.setFlowPoolLevel(publishSingleVideoSource.getFlowPoolLevel());
             articleVideoPoolSourceVO.setSourceId(publishSingleVideoSource.getContentTraceId());
             articleVideoPoolSourceVO.setTitle(publishSingleVideoSource.getArticleTitle());
+            articleVideoPoolSourceVO.setCoverUrl(publishSingleVideoSource.getCoverUrl());
             return articleVideoPoolSourceVO;
         }).collect(Collectors.toList());
     }

+ 3 - 0
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/repository/longArticle/PublishSingleVideoSourceRepository.java

@@ -4,6 +4,9 @@ import com.tzld.longarticle.recommend.server.model.entity.longArticle.PublishSin
 import org.springframework.data.jpa.repository.JpaRepository;
 import org.springframework.stereotype.Repository;
 
+import java.util.List;
+
 @Repository
 public interface PublishSingleVideoSourceRepository extends JpaRepository<PublishSingleVideoSource, Long> {
+    List<PublishSingleVideoSource> getByContentTraceIdIn(List<String> contentTraceIds);
 }

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

@@ -18,6 +18,7 @@ import com.tzld.longarticle.recommend.server.model.dto.AccountTypeFansDTO;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
 import com.tzld.longarticle.recommend.server.model.dto.NotPublishPlan;
 import com.tzld.longarticle.recommend.server.model.dto.PublishPlanAccountNotifyDTO;
+import com.tzld.longarticle.recommend.server.model.entity.aigc.CrawlerPlan;
 import com.tzld.longarticle.recommend.server.model.entity.aigc.PublishAccount;
 import com.tzld.longarticle.recommend.server.model.entity.crawler.AccountAvgInfo;
 import com.tzld.longarticle.recommend.server.model.entity.crawler.GetOffVideoCrawler;
@@ -206,6 +207,44 @@ public class XxlJobService {
         return ReturnT.SUCCESS;
     }
 
+    @XxlJob("checkColdCrawlerPlan")
+    public ReturnT<String> checkColdCrawlerPlan(String param) {
+        long timeStamp = DateUtils.getBeforeDayStart(1);
+        if (StringUtils.hasText(param)) {
+            timeStamp = DateUtils.getStartOfDay(param, "yyyyMMdd");
+        }
+        String dateStr = DateUtils.timestampToYMDStr(timeStamp, "yyyyMMdd");
+        timeStamp = timeStamp * 1000;
+        List<String> planTags = Arrays.asList("账号联想_v1", "文章联想_v1", "品类冷启动");
+        List<CrawlerPlan> crawlerPlanList = aigcBaseMapper.getColdCrawlerPlan(timeStamp, timeStamp + 86400000, planTags);
+        if (CollectionUtil.isNotEmpty(crawlerPlanList)) {
+            for (CrawlerPlan crawlerPlan : crawlerPlanList) {
+                JSONObject crawlerModeValue = JSONObject.parseObject(crawlerPlan.getCrawlerModeValue());
+                if (crawlerModeValue == null) {
+                    continue;
+                }
+                JSONObject sourceModeValues = crawlerModeValue.getJSONObject("sourceModeValues");
+                if (sourceModeValues == null) {
+                    continue;
+                }
+                JSONArray inputModeValues = sourceModeValues.getJSONArray("inputModeValues");
+                if (inputModeValues == null) {
+                    continue;
+                }
+                log.info("checkColdCrawlerPlan crawlerPlan: {}", JSONObject.toJSONString(crawlerPlan));
+                FeishuMessageSender.sendWebHookMessage(FeishuRobotIdEnum.RECOMMEND.getRobotId(),
+                        dateStr + "冷启计划抓取数量\n"
+                                + "计划ID: " + crawlerPlan.getId() + "\n"
+                                + "计划名称: " + crawlerPlan.getName() + "\n"
+                                + "计划标签: " + crawlerPlan.getPlanTag() + "\n"
+                                + "计划抓取数量: " + inputModeValues.size() + "\n"
+                                + "实际抓取数量: " + crawlerPlan.getCrawlerTotalNum() + "\n"
+                                + "<at user_id=\"all\">所有人</at> ");
+            }
+        }
+        return ReturnT.SUCCESS;
+    }
+
     @XxlJob("migrateCrawlerRootSourceId")
     public ReturnT<String> migrateCrawlerRootSourceId(String param) {
         try {

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

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

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

@@ -1,9 +1,7 @@
 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.repository.crawler.ArticleRepository;
 import com.tzld.longarticle.recommend.server.service.recommend.config.AccountContentPoolConfigService;
 import com.tzld.longarticle.recommend.server.service.recommend.config.StrategyIndexScoreWeightService;
 import com.tzld.longarticle.recommend.server.service.recommend.rank.*;
@@ -28,8 +26,6 @@ public class HisJumpRankStrategy implements RankStrategy {
     @Autowired
     private AccountContentPoolConfigService accountContentPoolConfigService;
     @Autowired
-    private ArticleRepository articleRepository;
-    @Autowired
     private StrategyIndexScoreWeightService weightService;
 
     public RankResult rank(RankParam param) {
@@ -90,7 +86,7 @@ public class HisJumpRankStrategy implements RankStrategy {
 
         // 头
         List<Content> pool1 = contentMap.get(contentPools[0]);
-        RankService.printSortLog(RankStrategyEnum.HIS_JUMP_STRATEGY.getStrategy(), param.getAccountName(), "头条", pool1);
+        RankService.printSortLog(param.getStrategy(), param.getAccountName(), "头条", pool1);
         if (CollectionUtils.isNotEmpty(pool1)) {
             int i = RandomUtils.nextInt(0, Math.min(pool1.size(), 20));
             result.add(pool1.get(i));

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

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

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

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

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

@@ -3,10 +3,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.RankItem;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankParam;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankResult;
-import com.tzld.longarticle.recommend.server.service.recommend.rank.RankStrategy;
+import com.tzld.longarticle.recommend.server.service.recommend.rank.*;
 import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreService;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import lombok.extern.slf4j.Slf4j;

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

@@ -109,10 +109,10 @@ public class RankV10Strategy implements RankStrategy {
             return new RankResult(result);
         }
         // 次
-        RankService.commonAddSecondContent(result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
+        RankService.commonAddSecondContent(param, result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
 
         // 3-8
-        RankService.commonAdd38Content(param, result, contentPools, contentMap, RankStrategyEnum.ArticleRankV10.getStrategy());
+        RankService.commonAdd38Content(param, result, contentPools, contentMap, param.getStrategy());
 
         RankStrategy.deduplication(result, contentMap, publishPool);
 

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

@@ -121,7 +121,7 @@ public class RankV11Strategy implements RankStrategy {
 
         // 头
         List<Content> pool1 = contentMap.get(contentPools[0]);
-        RankService.printSortLog(RankStrategyEnum.ArticleRankV11.getStrategy(), param.getAccountName(), "头条", pool1);
+        RankService.printSortLog(param.getStrategy(), param.getAccountName(), "头条", pool1);
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
         } else {
@@ -129,10 +129,10 @@ public class RankV11Strategy implements RankStrategy {
             return new RankResult(result);
         }
         // 次
-        RankService.commonAddSecondContent(result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
+        RankService.commonAddSecondContent(param, result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
 
         // 3-8
-        RankService.commonAdd38Content(param, result, contentPools, contentMap, RankStrategyEnum.ArticleRankV11.getStrategy());
+        RankService.commonAdd38Content(param, result, contentPools, contentMap, param.getStrategy());
 
         RankStrategy.deduplication(result, contentMap, publishPool);
 

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

@@ -121,7 +121,7 @@ public class RankV12Strategy implements RankStrategy {
 
         // 头
         List<Content> pool1 = contentMap.get(contentPools[0]);
-        RankService.printSortLog(RankStrategyEnum.ArticleRankV12.getStrategy(), param.getAccountName(), "头条", pool1);
+        RankService.printSortLog(param.getStrategy(), param.getAccountName(), "头条", pool1);
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
         } else {
@@ -129,10 +129,10 @@ public class RankV12Strategy implements RankStrategy {
             return new RankResult(result);
         }
         // 次
-        RankService.commonAddSecondContent(result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
+        RankService.commonAddSecondContent(param, result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
 
         // 3-8
-        RankService.commonAdd38Content(param, result, contentPools, contentMap, RankStrategyEnum.ArticleRankV12.getStrategy());
+        RankService.commonAdd38Content(param, result, contentPools, contentMap, param.getStrategy());
 
         RankStrategy.deduplication(result, contentMap, publishPool);
 

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

@@ -122,7 +122,7 @@ public class RankV13Strategy implements RankStrategy {
 
         // 头
         List<Content> pool1 = contentMap.get(contentPools[0]);
-        RankService.printSortLog(RankStrategyEnum.ArticleRankV13.getStrategy(), param.getAccountName(), "头条", pool1);
+        RankService.printSortLog(param.getStrategy(), param.getAccountName(), "头条", pool1);
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
         } else {
@@ -130,10 +130,10 @@ public class RankV13Strategy implements RankStrategy {
             return new RankResult(result);
         }
         // 次
-        RankService.commonAddSecondContent(result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
+        RankService.commonAddSecondContent(param, result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
 
         // 3-8
-        RankService.commonAdd38Content(param, result, contentPools, contentMap, RankStrategyEnum.ArticleRankV13.getStrategy());
+        RankService.commonAdd38Content(param, result, contentPools, contentMap, param.getStrategy());
 
         RankStrategy.deduplication(result, contentMap, publishPool);
 

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

@@ -122,7 +122,7 @@ public class RankV14Strategy implements RankStrategy {
 
         // 头
         List<Content> pool1 = contentMap.get(contentPools[0]);
-        RankService.printSortLog(RankStrategyEnum.ArticleRankV14.getStrategy(), param.getAccountName(), "头条", pool1);
+        RankService.printSortLog(param.getStrategy(), param.getAccountName(), "头条", pool1);
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
         } else {
@@ -130,10 +130,10 @@ public class RankV14Strategy implements RankStrategy {
             return new RankResult(result);
         }
         // 次
-        RankService.commonAddSecondContent(result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
+        RankService.commonAddSecondContent(param, result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
 
         // 3-8
-        RankService.commonAdd38Content(param, result, contentPools, contentMap, RankStrategyEnum.ArticleRankV14.getStrategy());
+        RankService.commonAdd38Content(param, result, contentPools, contentMap, param.getStrategy());
 
         RankStrategy.deduplication(result, contentMap, publishPool);
 

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

@@ -0,0 +1,133 @@
+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;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.*;
+
+/**
+ * @author dyp
+ */
+@Service
+@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;
+
+    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;
+        });
+        // 相似度评分为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 文章按照内容池分组
+        Map<String, List<Content>> contentMap = new HashMap<>();
+        for (Content c : contents) {
+            List<Content> data = contentMap.computeIfAbsent(c.getContentPoolType(), k -> new ArrayList<>());
+            data.add(c);
+        }
+        // 4 选文章
+        String[] publishPool = Arrays.copyOf(contentPools, contentPools.length);
+
+        // 头
+        List<Content> pool1 = contentMap.get(contentPools[0]);
+        if (CollectionUtils.isNotEmpty(pool1)) {
+            pool1 = RankService.contentSourceTypeFilter(param.getStrategy(), pool1, 1);
+        }
+        RankService.printSortLog(param.getStrategy(), param.getAccountName(), "头条", pool1);
+        if (CollectionUtils.isNotEmpty(pool1)) {
+            result.add(pool1.get(0));
+        } else {
+            RankStrategy.sendFeishuFirstPoolEmpty(param, contentPools[0]);
+            return new RankResult(result);
+        }
+        // 次
+        RankService.commonAddSecondContent(param, result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
+
+        // 3-8
+        RankService.commonAdd38Content(param, result, contentPools, contentMap, param.getStrategy());
+
+        RankStrategy.deduplication(result, contentMap, publishPool);
+
+        return new RankResult(result);
+    }
+
+}

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

@@ -106,18 +106,11 @@ public class RankV3Strategy implements RankStrategy {
             result.add(pool2.get(i));
         } else {
             // 替补 根据设置替补内容池查找内容尽心替补
-            AccountIndexReplacePoolConfig replacePoolConfig = indexReplacePoolConfigMap.get(2);
-            if (Objects.nonNull(replacePoolConfig)) {
-                List<Content> pool2Replace = contentMap.get(replacePoolConfig.getContentPool());
-                if (CollectionUtils.isNotEmpty(pool2Replace)) {
-                    publishPool[1] = replacePoolConfig.getContentPool();
-                    result.add(pool2Replace.get(0));
-                }
-            }
+            RankService.findReplacePoolContent(result, publishPool, contentMap, indexReplacePoolConfigMap);
         }
 
         // 3-8
-        RankService.commonAdd38Content(param, result, contentPools, contentMap, RankStrategyEnum.ArticleRankV3.getStrategy());
+        RankService.commonAdd38Content(param, result, contentPools, contentMap, param.getStrategy());
 
         RankStrategy.deduplication(result, contentMap, publishPool);
 

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

@@ -99,10 +99,10 @@ public class RankV4Strategy implements RankStrategy {
             return new RankResult(result);
         }
         // 次
-        RankService.commonAddSecondContent(result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
+        RankService.commonAddSecondContent(param, result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
 
         // 3-8
-        RankService.commonAdd38Content(param, result, contentPools, contentMap, RankStrategyEnum.ArticleRankV4.getStrategy());
+        RankService.commonAdd38Content(param, result, contentPools, contentMap, param.getStrategy());
 
         RankStrategy.deduplication(result, contentMap, publishPool);
 

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

@@ -2,7 +2,6 @@ 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.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;
@@ -110,7 +109,7 @@ public class RankV5Strategy implements RankStrategy {
 
         // 头
         List<Content> pool1 = contentMap.get(contentPools[0]);
-        RankService.printSortLog(RankStrategyEnum.ArticleRankV5.getStrategy(), param.getAccountName(), "头条", pool1);
+        RankService.printSortLog(param.getStrategy(), param.getAccountName(), "头条", pool1);
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
         } else {
@@ -118,10 +117,10 @@ public class RankV5Strategy implements RankStrategy {
             return new RankResult(result);
         }
         // 次
-        RankService.commonAddSecondContent(result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
+        RankService.commonAddSecondContent(param, result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
 
         // 3-8
-        RankService.commonAdd38Content(param, result, contentPools, contentMap, RankStrategyEnum.ArticleRankV5.getStrategy());
+        RankService.commonAdd38Content(param, result, contentPools, contentMap, param.getStrategy());
 
         RankStrategy.deduplication(result, contentMap, publishPool);
 

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

@@ -101,10 +101,10 @@ public class RankV7Strategy implements RankStrategy {
             return new RankResult(result);
         }
         // 次
-        RankService.commonAddSecondContent(result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
+        RankService.commonAddSecondContent(param, result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
 
         // 3-8
-        RankService.commonAdd38Content(param, result, contentPools, contentMap, RankStrategyEnum.ArticleRankV7.getStrategy());
+        RankService.commonAdd38Content(param, result, contentPools, contentMap, param.getStrategy());
 
         RankStrategy.deduplication(result, contentMap, publishPool);
 

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

@@ -105,7 +105,7 @@ public class RankV8Strategy implements RankStrategy {
 
         // 头
         List<Content> pool1 = contentMap.get(contentPools[0]);
-        RankService.printSortLog(RankStrategyEnum.ArticleRankV8.getStrategy(), param.getAccountName(), "头条", pool1);
+        RankService.printSortLog(param.getStrategy(), param.getAccountName(), "头条", pool1);
         if (CollectionUtils.isNotEmpty(pool1)) {
             result.add(pool1.get(0));
         } else {
@@ -113,10 +113,10 @@ public class RankV8Strategy implements RankStrategy {
             return new RankResult(result);
         }
         // 次
-        RankService.commonAddSecondContent(result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
+        RankService.commonAddSecondContent(param, result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
 
         // 3-8
-        RankService.commonAdd38Content(param, result, contentPools, contentMap, RankStrategyEnum.ArticleRankV8.getStrategy());
+        RankService.commonAdd38Content(param, result, contentPools, contentMap, param.getStrategy());
 
         RankStrategy.deduplication(result, contentMap, publishPool);
 

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

@@ -101,10 +101,10 @@ public class RankV9Strategy implements RankStrategy {
             return new RankResult(result);
         }
         // 次
-        RankService.commonAddSecondContent(result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
+        RankService.commonAddSecondContent(param, result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
 
         // 3-8
-        RankService.commonAdd38Content(param, result, contentPools, contentMap, RankStrategyEnum.ArticleRankV9.getStrategy());
+        RankService.commonAdd38Content(param, result, contentPools, contentMap, param.getStrategy());
 
         RankStrategy.deduplication(result, contentMap, publishPool);
 

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

@@ -6,9 +6,11 @@ import com.google.common.collect.Lists;
 import com.tzld.longarticle.recommend.server.common.CostMonitor;
 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.ArticleCategoryStatusEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.ArticlePoolPromotionSourceStatusEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.ArticleTypeEnum;
+import com.tzld.longarticle.recommend.server.common.enums.recommend.ContentPoolEnum;
 import com.tzld.longarticle.recommend.server.common.enums.recommend.FeishuRobotIdEnum;
 import com.tzld.longarticle.recommend.server.mapper.crawler.CrawlerBaseMapper;
 import com.tzld.longarticle.recommend.server.model.dto.Content;
@@ -22,6 +24,7 @@ import com.tzld.longarticle.recommend.server.model.entity.crawler.ArticleDetailI
 import com.tzld.longarticle.recommend.server.model.entity.longArticle.AccountCategory;
 import com.tzld.longarticle.recommend.server.model.entity.longArticle.ArticleCategory;
 import com.tzld.longarticle.recommend.server.model.entity.longArticle.ArticlePoolPromotionSource;
+import com.tzld.longarticle.recommend.server.model.entity.longArticle.PublishSingleVideoSource;
 import com.tzld.longarticle.recommend.server.model.entity.longArticle.ArticleTitleHisCache;
 import com.tzld.longarticle.recommend.server.model.param.TitleHisCacheParam;
 import com.tzld.longarticle.recommend.server.remote.aigc.AIGCWaitingPublishContentService;
@@ -34,6 +37,7 @@ import com.tzld.longarticle.recommend.server.repository.crawler.ArticleRepositor
 import com.tzld.longarticle.recommend.server.repository.longArticle.AccountCategoryRepository;
 import com.tzld.longarticle.recommend.server.repository.longArticle.ArticleCategoryRepository;
 import com.tzld.longarticle.recommend.server.repository.longArticle.ArticlePoolPromotionSourceRepository;
+import com.tzld.longarticle.recommend.server.repository.longArticle.PublishSingleVideoSourceRepository;
 import com.tzld.longarticle.recommend.server.repository.longArticle.ArticleTitleHisCacheRepository;
 import com.tzld.longarticle.recommend.server.service.recommend.config.AccountIndexAvgViewCountService;
 import com.tzld.longarticle.recommend.server.service.recommend.recall.strategy.DefaultRecallStrategy;
@@ -95,6 +99,8 @@ public class RecallService implements ApplicationContextAware {
     @Autowired
     AccountCategoryRepository accountCategoryRepository;
     @Autowired
+    PublishSingleVideoSourceRepository publishSingleVideoSourceRepository;
+    @Autowired
     ArticleTitleHisCacheRepository articleTitleHisCacheRepository;
 
     private final Map<String, RecallStrategy> strategyMap = new HashMap<>();
@@ -190,9 +196,35 @@ public class RecallService implements ApplicationContextAware {
         setTitleAvgViewCount(content, param.getGhId(), param.getType());
         long t4 = System.currentTimeMillis();
         CostMonitor.logCost("Recall", "SetAvgViewCount", t4 - t3);
+        // 视频内容池查询抓取时间
+        setVideoContent(content);
         return content;
     }
 
+    private void setVideoContent(List<Content> contentList) {
+        List<String> contentTraceIds = contentList.stream()
+                .filter(o -> PublishPlanInputSourceTypesEnum.longArticleVideoPoolSource.getVal().equals(o.getSourceType()))
+                .map(Content::getSourceId).collect(Collectors.toList());
+        if (CollectionUtils.isEmpty(contentTraceIds)) {
+            return;
+        }
+        Map<String, Content> contentMap = contentList.stream()
+               .collect(Collectors.toMap(Content::getSourceId, Function.identity()));
+        List<PublishSingleVideoSource> sourceList = publishSingleVideoSourceRepository.getByContentTraceIdIn(contentTraceIds);
+        Map<String, PublishSingleVideoSource> sourceMap = sourceList.stream()
+              .collect(Collectors.toMap(PublishSingleVideoSource::getContentTraceId, Function.identity()));
+        for (String contentTraceId : contentTraceIds) {
+            Content content = contentMap.get(contentTraceId);
+            PublishSingleVideoSource source = sourceMap.get(contentTraceId);
+            if (Objects.isNull(source)) {
+                continue;
+            }
+            content.setCrawlerTimestamp(source.getCrawlerTimestamp());
+            ContentPoolEnum poolEnum = ContentPoolEnum.from(source.getFlowPoolLevel());
+            content.setContentPoolType(poolEnum.getContentPool());
+        }
+    }
+
     public void setContentCategory(List<Content> contentList) {
         contentList.forEach(content -> content.setTitleMd5(Md5Util.encoderByMd5(content.getTitle())));
         List<String> channelContentIds = contentList.stream().map(Content::getCrawlerChannelContentId)
@@ -443,15 +475,15 @@ public class RecallService implements ApplicationContextAware {
                         article.setInnerAccount(true);
                         avgViewCount = Optional.ofNullable(indexMap.get(hisArticle.getItemIndex().toString()).getReadAvg())
                                 .orElse(0.0).intValue();
-                    } else {
-                        if (ArticleTypeEnum.QUNFA.getVal().equals(type)) {
-                            FeishuMessageSender.sendWebHookMessage(FeishuRobotIdEnum.RECOMMEND.getRobotId(),
-                                    "历史表现阅读均值获取失败\n"
-                                            + "ghId: " + hisArticle.getGhId() + "\n"
-                                            + "账号名称: " + hisArticle.getAccountName() + "\n"
-                                            + "日期: " + hisPublishDate + "\n"
-                                            + "位置: " + hisArticle.getItemIndex());
-                        }
+//                    } else {
+//                        if (ArticleTypeEnum.QUNFA.getVal().equals(type)) {
+//                            FeishuMessageSender.sendWebHookMessage(FeishuRobotIdEnum.RECOMMEND.getRobotId(),
+//                                    "历史表现阅读均值获取失败\n"
+//                                            + "ghId: " + hisArticle.getGhId() + "\n"
+//                                            + "账号名称: " + hisArticle.getAccountName() + "\n"
+//                                            + "日期: " + hisPublishDate + "\n"
+//                                            + "位置: " + hisArticle.getItemIndex());
+//                        }
                     }
                 }
                 article.setAvgViewCount(avgViewCount);

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

@@ -122,7 +122,8 @@ public class ScoreService implements ApplicationContextAware {
                 || StringUtils.equals(param.getStrategy(), RankStrategyEnum.ArticleRankV11.getStrategy())
                 || StringUtils.equals(param.getStrategy(), RankStrategyEnum.ArticleRankV12.getStrategy())
                 || StringUtils.equals(param.getStrategy(), RankStrategyEnum.ArticleRankV13.getStrategy())
-                || StringUtils.equals(param.getStrategy(), RankStrategyEnum.ArticleRankV14.getStrategy())) {
+                || StringUtils.equals(param.getStrategy(), RankStrategyEnum.ArticleRankV14.getStrategy())
+                || StringUtils.equals(param.getStrategy(), RankStrategyEnum.ArticleRankV15.getStrategy())) {
             strategies.add(strategyMap.get(ScoreStrategyEnum.CATEGORY.value()));
             strategies.add(strategyMap.get(ScoreStrategyEnum.ACCOUNT_PRE_DISTRIBUTE.value()));
             strategies.add(strategyMap.get(ScoreStrategyEnum.FLOW_CTL_DECREASE.value()));

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

@@ -24,6 +24,11 @@ public class XxlJobController {
         service.checkPublishPlanAccount(null);
     }
 
+    @GetMapping("/checkColdCrawlerPlan")
+    public void checkColdCrawlerPlan(String dateStr) {
+        service.checkColdCrawlerPlan(dateStr);
+    }
+
     @GetMapping("/migrateCrawlerRootSourceId")
     public void migrateCrawlerRootSourceId(String dateStr) {
         service.migrateCrawlerRootSourceId(dateStr);

+ 12 - 0
long-article-recommend-service/src/main/resources/mapper/aigc/AigcBaseMapper.xml

@@ -271,4 +271,16 @@
         </foreach>
     </select>
 
+    <select id="getColdCrawlerPlan"
+            resultType="com.tzld.longarticle.recommend.server.model.entity.aigc.CrawlerPlan">
+        select *
+        from crawler_plan
+        where plan_type = 2 and channel = 5 and content_modal = 3
+        and create_timestamp between #{timeStart} and #{timeEnd}
+        and plan_tag in
+        <foreach collection="planTags" item="item" open="(" close=")" separator=",">
+            #{item}
+        </foreach>
+    </select>
+
 </mapper>

+ 1 - 1
long-article-recommend-service/src/main/resources/mapper/crawler/CrawlerBaseMapper.xml

@@ -88,7 +88,7 @@
 
     <select id="getByTitleMd5InAndTypeEqualsAndStatusEquals"
             resultType="com.tzld.longarticle.recommend.server.model.entity.crawler.Article">
-        select wx_sn, ghId, appMsgId, title, ItemIndex, publish_timestamp, show_view_count
+        select wx_sn, ghId, accountName, appMsgId, title, ItemIndex, publish_timestamp, show_view_count
         from official_articles_v2
         where title_md5 in
         <foreach collection="titleMd5s" item="item" separator="," open="(" close=")">

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

@@ -231,7 +231,7 @@
 
     <select id="getPublishSingleVideoSource"
             resultType="com.tzld.longarticle.recommend.server.model.entity.longArticle.PublishSingleVideoSource">
-        select content_trace_id, article_title, flow_pool_level
+        select content_trace_id, article_title, cover_url, flow_pool_level
         from publish_single_video_source
         where bad_status = 0 and audit_status = 1
         <if test="flowPoolLevel!= null ">