丁云鹏 11 hónapja
szülő
commit
b6dc2cb4c0
16 módosított fájl, 320 hozzáadás és 25 törlés
  1. 1 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/common/enums/RankStrategyEnum.java
  2. 36 5
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/RecommendWithUserGroupResponse.java
  3. 4 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/RecommendParam.java
  4. 61 6
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/RecommendService.java
  5. 9 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/SceneConstants.java
  6. 1 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/filter/FilterParam.java
  7. 14 6
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/filter/FilterService.java
  8. 56 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/filter/strategy/HistoryTitleForFwhColdStartStrategy.java
  9. 3 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/RankParam.java
  10. 0 2
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/RankResult.java
  11. 16 2
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/RankService.java
  12. 113 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/rank/strategy/FwhColdStartRankStrategy.java
  13. 1 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recall/FilterParamFactory.java
  14. 2 0
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recall/RecallParam.java
  15. 0 1
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/service/recall/RecallService.java
  16. 3 3
      long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/web/RecommendController.java

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

@@ -10,6 +10,7 @@ public enum RankStrategyEnum {
     ArticleRankV3("ArticleRankV3", "ArticleRankV3", "rankV3Strategy"),
     ArticleRankV4("ArticleRankV4", "ArticleRankV4", "rankV4Strategy"),
     ArticleRankV5("ArticleRankV5", "ArticleRankV5", "rankV5Strategy"),
+    ArticleRankV6("ArticleRankV6", "ArticleRankV6", "rankV6Strategy"),
 
     default_strategy("ArticleRankV1", "默认策略", "defaultRankStrategy"),
     ;

+ 36 - 5
long-article-recommend-service/src/main/java/com/tzld/longarticle/recommend/server/model/RecommendWithUserGroupResponse.java

@@ -1,19 +1,50 @@
 package com.tzld.longarticle.recommend.server.model;
 
+import lombok.Data;
 import lombok.Getter;
 import lombok.NoArgsConstructor;
 import lombok.Setter;
 
+import java.util.List;
+
 /**
  * @author dyp
  */
 
-@NoArgsConstructor
-@Getter
-@Setter
+@Data
 public class RecommendWithUserGroupResponse {
-    private Integer code;
+    private int code;
     private String msg;
-    private ArticleSortResponseData data;
+    private RecommendWithUserGroupData data;
+
+    public RecommendWithUserGroupResponse(int code, String msg,
+                                          RecommendWithUserGroupData data) {
+        this.code = code;
+        this.msg = msg;
+        this.data = data;
+    }
+
+    @Data
+    public static class RecommendWithUserGroupData {
+        private List<RankData> rankList;
+        private List<FilterData> filterList;
+
+        public RecommendWithUserGroupData(List<RankData> rankList, List<FilterData> filterList) {
+            this.rankList = rankList;
+            this.filterList = filterList;
+        }
+    }
+
+    @Data
+    public static class RankData {
+        private Integer userGroupId;
+        private List<String> contentIds;
+    }
+
+    @Data
+    public static class FilterData {
+        private String contentId;
+        private String filterReason;
+    }
 }
 

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

@@ -4,6 +4,8 @@ import lombok.Getter;
 import lombok.NoArgsConstructor;
 import lombok.Setter;
 
+import java.util.List;
+
 /**
  * @author dyp
  */
@@ -20,5 +22,7 @@ public class RecommendParam {
     private String planId;
     // true 不记录日志
     private boolean excludeLog = false;
+    private String scene;
+    private List<Integer> userGroupIds;
 }
 

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

@@ -3,6 +3,7 @@ package com.tzld.longarticle.recommend.server.service;
 import com.alibaba.fastjson.JSONObject;
 import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
 import com.tzld.longarticle.recommend.server.model.*;
+import com.tzld.longarticle.recommend.server.repository.crawler.ArticleUserGroupRepository;
 import com.tzld.longarticle.recommend.server.repository.crawler.PublishContentSortLogRepository;
 import com.tzld.longarticle.recommend.server.repository.crawler.PublishSortLogRepository;
 import com.tzld.longarticle.recommend.server.repository.entity.crawler.PublishContentSortLog;
@@ -13,6 +14,7 @@ import com.tzld.longarticle.recommend.server.service.rank.RankService;
 import com.tzld.longarticle.recommend.server.service.recall.RecallParam;
 import com.tzld.longarticle.recommend.server.service.recall.RecallResult;
 import com.tzld.longarticle.recommend.server.service.recall.RecallService;
+import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
 import com.tzld.longarticle.recommend.server.util.DateUtils;
 import com.tzld.longarticle.recommend.server.util.JSONUtils;
 import lombok.extern.slf4j.Slf4j;
@@ -23,12 +25,15 @@ import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Service;
 import org.springframework.util.StringUtils;
 
+import java.time.LocalDate;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
 import java.util.stream.Collectors;
 
+import static com.tzld.longarticle.recommend.server.service.SceneConstants.FWH_COLD_START;
+
 /**
  * @author dyp
  */
@@ -46,6 +51,8 @@ public class RecommendService {
     private PublishSortLogRepository publishSortLogRepository;
     @Autowired
     AccountIndexAvgViewCountService accountIndexAvgViewCountService;
+    @Autowired
+    private ArticleUserGroupRepository articleUserGroupRepository;
 
     @ApolloJsonValue("${accountStrategyConfig:{}}")
     private Map<String, String> accountStrategyConfigMap;
@@ -55,7 +62,7 @@ public class RecommendService {
 
     public RecommendResponse recommend(RecommendRequest request) {
 
-        RecommendParam param = genRecommendParam(request);
+        RecommendParam param = genRecommendParam(request, SceneConstants.DEFAULT);
         log.info("genRecommendParam {}", JSONUtils.toJson(param));
         // 获取账号排序设置
         String strategyConfig = accountStrategyConfigMap.get(request.getAccountName());
@@ -73,9 +80,9 @@ public class RecommendService {
         return buildRecommendResponse(recallResult, rankResult, param.getPublishNum());
     }
 
-    public RecommendWithUserGroupResponse recommendWithUserGroup(RecommendRequest request) {
+    public RecommendWithUserGroupResponse recommend4FwhColdStart(RecommendRequest request) {
 
-        RecommendParam param = genRecommendParam(request);
+        RecommendParam param = genRecommendParam(request, FWH_COLD_START);
         log.info("genRecommendParam {}", JSONUtils.toJson(param));
         // 获取账号排序设置
         String strategyConfig = accountStrategyConfigMap.get(request.getAccountName());
@@ -90,7 +97,33 @@ public class RecommendService {
 
         saveSortLog(param, rankResult);
 
-        return buildRecommendWithUserGroupResponse(recallResult, rankResult, param.getPublishNum());
+
+        List<RecommendWithUserGroupResponse.RankData> rankList = new ArrayList<>();
+        List<Content> contentList = rankResult.getContents();
+        for (int i = 0, start = 0; i < param.getUserGroupIds().size() && start < contentList.size(); i++) {
+            RecommendWithUserGroupResponse.RankData rankData = new RecommendWithUserGroupResponse.RankData();
+            rankData.setUserGroupId(param.getUserGroupIds().get(i));
+            int end = Math.min(contentList.size(), start + param.getPublishNum() - 1);
+            rankData.setContentIds(CommonCollectionUtils.toList(contentList.subList(start, end), Content::getId));
+            rankList.add(rankData);
+            start = i * param.getPublishNum();
+        }
+
+        List<RecommendWithUserGroupResponse.FilterData> filterList = new ArrayList<>();
+        for (RecallResult.RecallData data : recallResult.getData()) {
+            if (CollectionUtils.isNotEmpty(data.getFilterContents())) {
+                for (Content filterContent : data.getFilterContents()) {
+                    RecommendWithUserGroupResponse.FilterData filterData = new RecommendWithUserGroupResponse.FilterData();
+                    filterData.setContentId(filterContent.getId());
+                    filterData.setFilterReason(filterContent.getFilterReason());
+                    filterList.add(filterData);
+                }
+            }
+        }
+
+
+        return new RecommendWithUserGroupResponse(0, "success",
+                new RecommendWithUserGroupResponse.RecommendWithUserGroupData(rankList, filterList));
     }
 
     private RecommendResponse buildRecommendResponse(RecallResult recallResult, RankResult rankResult, Integer publishNum) {
@@ -124,9 +157,28 @@ public class RecommendService {
         return response;
     }
 
-    public RecommendParam genRecommendParam(RecommendRequest request) {
+    public RecommendParam genRecommendParam(RecommendRequest request, String abCode) {
         RecommendParam param = new RecommendParam();
         BeanUtils.copyProperties(request, param);
+        param.setScene(abCode);
+
+        switch (abCode) {
+            case FWH_COLD_START:
+                List<Integer> userGroupIds = articleUserGroupRepository.findAllUserGroupId(request.getGhId());
+                LocalDate today = LocalDate.now(); // 获取当前日期
+                int dayOfYear = today.getDayOfYear();
+                int tailNum = dayOfYear % 8;
+                List<Integer> needPushUserGroupIds = new ArrayList<>();
+                for (int userGroupId : userGroupIds) {
+                    if (userGroupId % 8 == tailNum) {
+                        needPushUserGroupIds.add(userGroupId);
+                    }
+                }
+                param.setUserGroupIds(needPushUserGroupIds);
+
+                break;
+        }
+
         return param;
     }
 
@@ -159,11 +211,15 @@ public class RecommendService {
         rankParam.setGhId(param.getGhId());
         rankParam.setAccountName(param.getAccountName());
         rankParam.setSize(param.getPublishNum());
+        rankParam.setScene(param.getScene());
+        rankParam.setUserGroupIds(param.getUserGroupIds());
+
         return rankParam;
     }
 
     /**
      * 记录 账号、排序策略、结果。。。
+     *
      * @param param
      * @param rankResult
      */
@@ -179,7 +235,6 @@ public class RecommendService {
         log.setPublishContentId(JSONObject.toJSONString(publishContentIds));
         log.setCreateTimestamp(System.currentTimeMillis());
         publishContentSortLogRepository.save(log);
-        // 仅记录3-8条 冷启层内容
         List<PublishSortLog> publishSortLogSaveList = new ArrayList<>();
         for (int i = 1; i < rankResult.getContents().size() + 1; i++) {
             Content content = rankResult.getContents().get(i - 1);

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

@@ -0,0 +1,9 @@
+package com.tzld.longarticle.recommend.server.service;
+
+/**
+ * @author dyp
+ */
+public class SceneConstants {
+    public static final String DEFAULT = "DEFAULT";
+    public static final String FWH_COLD_START = "FWH_COLD_START";
+}

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

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

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

@@ -4,7 +4,7 @@ import com.tzld.longarticle.recommend.server.common.ThreadPoolFactory;
 import com.tzld.longarticle.recommend.server.model.Content;
 import com.tzld.longarticle.recommend.server.service.ServiceBeanFactory;
 import com.tzld.longarticle.recommend.server.service.filter.strategy.BadStrategy;
-import com.tzld.longarticle.recommend.server.service.filter.strategy.ColdStartBackupFilterStrategy;
+import com.tzld.longarticle.recommend.server.service.filter.strategy.HistoryTitleForFwhColdStartStrategy;
 import com.tzld.longarticle.recommend.server.service.filter.strategy.HistoryTitleStrategy;
 import com.tzld.longarticle.recommend.server.service.filter.strategy.SensitiveStrategy;
 import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
@@ -23,6 +23,8 @@ import java.util.concurrent.Future;
 import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 
+import static com.tzld.longarticle.recommend.server.service.SceneConstants.FWH_COLD_START;
+
 @Slf4j
 @Service
 public class FilterService {
@@ -90,11 +92,17 @@ public class FilterService {
 
     private List<FilterStrategy> getStrategies(FilterParam param) {
         List<FilterStrategy> strategies = new ArrayList<>();
-        strategies.add(ServiceBeanFactory.getBean(HistoryTitleStrategy.class));
-        strategies.add(ServiceBeanFactory.getBean(BadStrategy.class));
-        strategies.add(ServiceBeanFactory.getBean(SensitiveStrategy.class));
-        if (param.isBackup()) {
-            strategies.add(ServiceBeanFactory.getBean(ColdStartBackupFilterStrategy.class));
+        switch (param.getScene()) {
+            case FWH_COLD_START:
+                strategies.add(ServiceBeanFactory.getBean(HistoryTitleForFwhColdStartStrategy.class));
+                strategies.add(ServiceBeanFactory.getBean(BadStrategy.class));
+                strategies.add(ServiceBeanFactory.getBean(SensitiveStrategy.class));
+                break;
+            default:
+                strategies.add(ServiceBeanFactory.getBean(HistoryTitleStrategy.class));
+                strategies.add(ServiceBeanFactory.getBean(BadStrategy.class));
+                strategies.add(ServiceBeanFactory.getBean(SensitiveStrategy.class));
+                break;
         }
         return strategies;
     }

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

@@ -0,0 +1,56 @@
+package com.tzld.longarticle.recommend.server.service.filter.strategy;
+
+import com.tzld.longarticle.recommend.server.model.Content;
+import com.tzld.longarticle.recommend.server.remote.ArticleListRemoteService;
+import com.tzld.longarticle.recommend.server.repository.entity.crawler.Article;
+import com.tzld.longarticle.recommend.server.service.filter.FilterParam;
+import com.tzld.longarticle.recommend.server.service.filter.FilterResult;
+import com.tzld.longarticle.recommend.server.service.filter.FilterStrategy;
+import com.tzld.longarticle.recommend.server.util.TitleSimilarCheckUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Component;
+
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.List;
+import java.util.stream.Collectors;
+
+/**
+ * @author dyp
+ */
+@Component
+@Slf4j
+public class HistoryTitleForFwhColdStartStrategy implements FilterStrategy {
+
+    @Autowired
+    private ArticleListRemoteService articleListRemoteService;
+
+    private static final List<Integer> allIndex = Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8);
+
+
+    @Override
+    public FilterResult filter(FilterParam param) {
+        long start = System.currentTimeMillis();
+        FilterResult filterResult = new FilterResult();
+        List<String> result = new ArrayList<>();
+        List<Content> filterContents = new ArrayList<>();
+        List<Article> allArticleList = articleListRemoteService.articleList(param.getAccountName(), allIndex);
+        List<String> allTitleList = allArticleList.stream().map(Article::getTitle).distinct().collect(Collectors.toList());
+
+        for (Content content : param.getContents()) {
+            boolean isDuplicate = TitleSimilarCheckUtil.isDuplicateContent(content.getTitle(), allTitleList);
+            if (!isDuplicate) {
+                result.add(content.getId());
+            } else {
+                content.setFilterReason("历史已发布文章");
+                filterContents.add(content);
+            }
+        }
+        filterResult.setContentIds(result);
+        filterResult.setFilterContent(filterContents);
+        log.info("HistoryTitleStrategy cost:{}", System.currentTimeMillis() - start);
+        return filterResult;
+    }
+
+}

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

@@ -16,4 +16,7 @@ public class RankParam {
     private List<Content> backup;
     private int size;
     private String strategy;
+    private String scene;
+    private List<Integer> userGroupIds;
+
 }

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

@@ -15,6 +15,4 @@ import java.util.List;
 @AllArgsConstructor
 public class RankResult {
     private List<Content> contents;
-
-    private Map<Integer,>
 }

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

@@ -3,9 +3,16 @@ package com.tzld.longarticle.recommend.server.service.rank;
 
 import com.tzld.longarticle.recommend.server.common.enums.RankStrategyEnum;
 import com.tzld.longarticle.recommend.server.service.ServiceBeanFactory;
+import com.tzld.longarticle.recommend.server.service.filter.strategy.BadStrategy;
+import com.tzld.longarticle.recommend.server.service.filter.strategy.HistoryTitleForFwhColdStartStrategy;
+import com.tzld.longarticle.recommend.server.service.filter.strategy.HistoryTitleStrategy;
+import com.tzld.longarticle.recommend.server.service.filter.strategy.SensitiveStrategy;
+import com.tzld.longarticle.recommend.server.service.rank.strategy.FwhColdStartRankStrategy;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
 
+import static com.tzld.longarticle.recommend.server.service.SceneConstants.FWH_COLD_START;
+
 /**
  * @author dyp
  */
@@ -19,8 +26,15 @@ public class RankService {
     }
 
     private RankStrategy getRankStrategy(RankParam param) {
-        RankStrategyEnum rankStrategyEnum = RankStrategyEnum.from(param.getStrategy());
-        return (RankStrategy) ServiceBeanFactory.getBeanByName(rankStrategyEnum.getTaskExecutorName());
+
+        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());
+        }
+
     }
 
 }

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

@@ -0,0 +1,113 @@
+package com.tzld.longarticle.recommend.server.service.rank.strategy;
+
+
+import com.tzld.longarticle.recommend.server.common.enums.ContentPoolEnum;
+import com.tzld.longarticle.recommend.server.model.Content;
+import com.tzld.longarticle.recommend.server.service.AccountContentPoolConfigService;
+import com.tzld.longarticle.recommend.server.service.rank.RankItem;
+import com.tzld.longarticle.recommend.server.service.rank.RankParam;
+import com.tzld.longarticle.recommend.server.service.rank.RankResult;
+import com.tzld.longarticle.recommend.server.service.rank.RankStrategy;
+import com.tzld.longarticle.recommend.server.service.score.ScoreParam;
+import com.tzld.longarticle.recommend.server.service.score.ScoreResult;
+import com.tzld.longarticle.recommend.server.service.score.ScoreService;
+import com.tzld.longarticle.recommend.server.service.score.strategy.*;
+import com.tzld.longarticle.recommend.server.util.CommonCollectionUtils;
+import com.tzld.longarticle.recommend.server.util.JSONUtils;
+import com.tzld.longarticle.recommend.server.util.TitleSimilarCheckUtil;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+
+import java.util.*;
+
+/**
+ * @author dyp
+ */
+@Service
+@Slf4j
+public class FwhColdStartRankStrategy implements RankStrategy {
+
+    @Autowired
+    private ScoreService scoreService;
+    @Autowired
+    private AccountContentPoolConfigService accountContentPoolConfigService;
+
+    public RankResult rank(RankParam param) {
+
+        log.info("RankParam {}", JSONUtils.toJson(param));
+        ScoreResult scoreResult = scoreService.score(convertToScoreParam(param));
+        log.info("ScoreResult {}", JSONUtils.toJson(scoreResult));
+
+        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();
+            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(SimilarityStrategy.class.getSimpleName())
+                        + item.getScore(CategoryStrategy.class.getSimpleName())
+                        + item.getScore(FlowCtlDecreaseStrategy.class.getSimpleName());
+                if (item.getScore(PublishTimesStrategy.class.getSimpleName()) >= 0) {
+                    score += item.getScore(ViewCountRateStrategy.class.getSimpleName());
+                }
+            } else {
+                score = item.getScore(SimilarityStrategy.class.getSimpleName())
+                        + item.getScore(CategoryStrategy.class.getSimpleName())
+                        + item.getScore(AccountPreDistributeStrategy.class.getSimpleName())
+                        + item.getScore(PublishTimesStrategy.class.getSimpleName())
+                        + item.getScore(FlowCtlDecreaseStrategy.class.getSimpleName());
+            }
+            item.setScore(score);
+            return item;
+        });
+
+        // 1 排序
+        Collections.sort(items, (o1, o2) -> -Double.compare(o1.getScore(), o2.getScore()));
+        log.info("SortResult {}", JSONUtils.toJson(items));
+        // 2 相似去重
+        List<Content> contents = CommonCollectionUtils.toList(items, RankItem::getContent);
+        contents = deduplication(contents);
+        log.info("Deduplication {}", JSONUtils.toJson(contents));
+
+        // 3 选文章
+        List<Content> result = new ArrayList<>();
+        int size = param.getSize() * param.getUserGroupIds().size();
+        result.addAll(contents.subList(0, Math.min(contents.size(), size)));
+
+        return new RankResult(result);
+    }
+
+    private ScoreParam convertToScoreParam(RankParam param) {
+        ScoreParam scoreParam = new ScoreParam();
+        scoreParam.setGhId(param.getGhId());
+        scoreParam.setAccountName(param.getAccountName());
+        scoreParam.setContents(param.getContents());
+        scoreParam.setStrategy(param.getStrategy());
+        return scoreParam;
+    }
+
+    private List<Content> deduplication(List<Content> contents) {
+        List<String> titles = new ArrayList<>();
+        List<Content> result = new ArrayList<>();
+        // 遍历所有列表
+        for (String contentPool : ContentPoolEnum.getOrderContentPool()) {
+            for (Content c : contents) {
+                if (!contentPool.equals(c.getContentPoolType())) {
+                    continue;
+                }
+                if (!TitleSimilarCheckUtil.isDuplicateContent(c.getTitle(), titles)) {
+                    result.add(c);
+                    titles.add(c.getTitle());
+                }
+            }
+        }
+
+        return result;
+    }
+
+}

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

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

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

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

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

@@ -103,7 +103,6 @@ public class RecallService implements ApplicationContextAware {
     private List<RecallStrategy> getRecallStrategy(RecallParam param) {
         List<RecallStrategy> strategies = new ArrayList<>();
         strategies.add(strategyMap.get(DefaultRecallStrategy.class.getSimpleName()));
-//        strategies.add(strategyMap.get(ColdStartBackupRecallStrategy.class.getSimpleName()));
         return strategies;
     }
 

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

@@ -25,10 +25,10 @@ public class RecommendController {
         return recommendService.recommend(httpRequest);
     }
 
-    @RequestMapping("/recommendWithUserGroup")
-    public RecommendWithUserGroupResponse recommendWithUserGroup(@RequestBody RecommendRequest httpRequest) {
+    @RequestMapping("/recommend4FwhColdStart")
+    public RecommendWithUserGroupResponse recommend4FwhColdStart(@RequestBody RecommendRequest httpRequest) {
 
-        return recommendService.recommendWithUserGroup(httpRequest);
+        return recommendService.recommend4FwhColdStart(httpRequest);
     }
 
 }