|
@@ -8,10 +8,15 @@ import com.tzld.longarticle.recommend.server.common.enums.recommend.RankStrategy
|
|
|
import com.tzld.longarticle.recommend.server.model.dto.Content;
|
|
|
import com.tzld.longarticle.recommend.server.service.ServiceBeanFactory;
|
|
|
import com.tzld.longarticle.recommend.server.service.recommend.rank.strategy.FwhColdStartRankStrategy;
|
|
|
+import com.tzld.longarticle.recommend.server.service.recommend.score.AccountIndexReplacePoolConfig;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
+import org.apache.commons.lang3.RandomUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
import static com.tzld.longarticle.recommend.server.common.constant.SceneConstants.FWH_COLD_START;
|
|
|
|
|
@@ -39,7 +44,7 @@ public class RankService {
|
|
|
|
|
|
}
|
|
|
|
|
|
- public static void printSortLog(String strategy, String accountName, List<Content> contentList) {
|
|
|
+ public static void printSortLog(String strategy, String accountName, String position, List<Content> contentList) {
|
|
|
JSONArray jsonArray = new JSONArray();
|
|
|
if (CollectionUtil.isEmpty(contentList)) {
|
|
|
return;
|
|
@@ -52,6 +57,48 @@ public class RankService {
|
|
|
obj.put("scoreMap", content.getScoreMap());
|
|
|
jsonArray.add(obj);
|
|
|
}
|
|
|
- log.info("{} 账号名称 {} 头条评分结果 {}", strategy, accountName, JSONObject.toJSONString(jsonArray));
|
|
|
+ log.info("{} 账号名称 {} {}评分结果 {}", strategy, accountName, position, JSONObject.toJSONString(jsonArray));
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void commonAddSecondContent(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)) {
|
|
|
+ int i = RandomUtils.nextInt(0, Math.min(pool.size(), 5));
|
|
|
+ int j = RandomUtils.nextInt(0, Math.min(pool.size(), 5));
|
|
|
+ result.add(pool.get(i));
|
|
|
+ // 替补 头条内容不足使用次条内容
|
|
|
+ if (result.size() == 1 && pool.size() > 1) {
|
|
|
+ while (i == j && pool.size() > 1) {
|
|
|
+ j = RandomUtils.nextInt(0, Math.min(pool.size(), 5));
|
|
|
+ if (i != j) {
|
|
|
+ publishPool[0] = contentPools[1];
|
|
|
+ result.add(pool.get(1));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } 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));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ 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]);
|
|
|
+ RankService.printSortLog(strategy, param.getAccountName(), "3-8", pool.subList(0, 200));
|
|
|
+ if (CollectionUtils.isNotEmpty(pool) && param.getSize() > result.size()) {
|
|
|
+ result.addAll(pool.subList(0, Math.min(pool.size(), param.getSize() - result.size())));
|
|
|
+ }
|
|
|
}
|
|
|
}
|