|
@@ -18,6 +18,7 @@ import com.tzld.longarticle.recommend.server.util.JSONUtils;
|
|
|
import com.tzld.longarticle.recommend.server.util.TitleSimilarCheckUtil;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
+import org.apache.commons.lang3.RandomUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -104,10 +105,18 @@ public class RankV5Strategy implements RankStrategy {
|
|
|
// 次
|
|
|
List<Content> pool2 = contentMap.get(contentPools[1]);
|
|
|
if (CollectionUtils.isNotEmpty(pool2)) {
|
|
|
- result.add(pool2.get(0));
|
|
|
+ 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) {
|
|
|
- result.add(pool2.get(1));
|
|
|
+ while (i == j && pool2.size() > 1) {
|
|
|
+ j = RandomUtils.nextInt(0, Math.min(pool2.size(), 5));
|
|
|
+ if (i != j) {
|
|
|
+ result.add(pool2.get(1));
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
} else {
|
|
|
// 替补 根据设置替补内容池查找内容尽心替补
|