|
@@ -1,23 +1,20 @@
|
|
|
package com.tzld.longarticle.recommend.server.service.recommend.rank.strategy;
|
|
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.common.enums.recommend.ScoreStrategyEnum;
|
|
|
import com.tzld.longarticle.recommend.server.model.dto.Content;
|
|
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.model.entity.crawler.Article;
|
|
|
import com.tzld.longarticle.recommend.server.repository.crawler.ArticleRepository;
|
|
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.AccountContentPoolConfigService;
|
|
|
import com.tzld.longarticle.recommend.server.service.recommend.config.StrategyIndexScoreWeightService;
|
|
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.AccountIndexReplacePoolConfig;
|
|
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.ScoreResult;
|
|
|
import com.tzld.longarticle.recommend.server.service.recommend.score.ScoreService;
|
|
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.CommonCollectionUtils;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
-import org.apache.commons.lang3.RandomUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
@@ -112,39 +109,10 @@ public class RankV10Strategy implements RankStrategy {
|
|
|
return new RankResult(result);
|
|
return new RankResult(result);
|
|
|
}
|
|
}
|
|
|
// 次
|
|
// 次
|
|
|
- List<Content> pool2 = contentMap.get(contentPools[1]);
|
|
|
|
|
- if (CollectionUtils.isNotEmpty(pool2)) {
|
|
|
|
|
- int i = RandomUtils.nextInt(0, Math.min(pool2.size(), 5));
|
|
|
|
|
- int j = RandomUtils.nextInt(0, Math.min(pool2.size(), 5));
|
|
|
|
|
- result.add(pool2.get(i));
|
|
|
|
|
- // 替补 头条内容不足使用次条内容
|
|
|
|
|
- if (result.size() == 1 && pool2.size() > 1) {
|
|
|
|
|
- while (i == j && pool2.size() > 1) {
|
|
|
|
|
- j = RandomUtils.nextInt(0, Math.min(pool2.size(), 5));
|
|
|
|
|
- if (i != j) {
|
|
|
|
|
- publishPool[0] = contentPools[1];
|
|
|
|
|
- result.add(pool2.get(1));
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- } else {
|
|
|
|
|
- // 替补 根据设置替补内容池查找内容尽心替补
|
|
|
|
|
- AccountIndexReplacePoolConfig replacePoolConfig = indexReplacePoolConfigMap.get(2);
|
|
|
|
|
- if (Objects.nonNull(replacePoolConfig)) {
|
|
|
|
|
- List<Content> pool2Replace = contentMap.get(replacePoolConfig.getContentPool());
|
|
|
|
|
- if (CollectionUtils.isNotEmpty(pool2Replace)) {
|
|
|
|
|
- publishPool[1] = replacePoolConfig.getContentPool();
|
|
|
|
|
- result.add(pool2Replace.get(0));
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ RankService.commonAddSecondContent(result, publishPool, contentPools, contentMap, indexReplacePoolConfigMap);
|
|
|
|
|
|
|
|
// 3-8
|
|
// 3-8
|
|
|
- List<Content> pool = contentMap.get(contentPools[2]);
|
|
|
|
|
- if (CollectionUtils.isNotEmpty(pool) && param.getSize() > result.size()) {
|
|
|
|
|
- result.addAll(pool.subList(0, Math.min(pool.size(), param.getSize() - result.size())));
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ RankService.commonAdd38Content(param, result, contentPools, contentMap, RankStrategyEnum.ArticleRankV10.getStrategy());
|
|
|
|
|
|
|
|
RankStrategy.deduplication(result, contentMap, publishPool);
|
|
RankStrategy.deduplication(result, contentMap, publishPool);
|
|
|
|
|
|