|
@@ -14,7 +14,6 @@ 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.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
@@ -55,20 +54,26 @@ public class RankService {
|
|
|
List<RankItem> data = itemMap.computeIfAbsent(c.getContent().getContentPoolType(), k -> new ArrayList<>());
|
|
|
data.add(c);
|
|
|
}
|
|
|
- for (Map.Entry<String, List<RankItem>> e : itemMap.entrySet()) {
|
|
|
- if (StringUtils.equals(contentPools[1], e.getKey())) {
|
|
|
+ List<RankItem> sortedItems = new ArrayList<>();
|
|
|
+ for (int i = 0; i < contentPools.length; i++) {
|
|
|
+ if (i == 1) {
|
|
|
// 播放量排序
|
|
|
- Collections.sort(e.getValue(), (o1, o2) -> -Double.compare(
|
|
|
+ List<RankItem> data = itemMap.get(contentPools[i]);
|
|
|
+ Collections.sort(data, (o1, o2) -> -Double.compare(
|
|
|
o1.getScore(ViewCountStrategy.class.getSimpleName()),
|
|
|
o2.getScore(ViewCountStrategy.class.getSimpleName())));
|
|
|
+ sortedItems.addAll(data);
|
|
|
} else {
|
|
|
// 相似排序
|
|
|
- Collections.sort(e.getValue(), (o1, o2) -> -Double.compare(
|
|
|
+ List<RankItem> data = itemMap.get(contentPools[i]);
|
|
|
+ Collections.sort(data, (o1, o2) -> -Double.compare(
|
|
|
o1.getScore(SimilarityStrategy.class.getSimpleName()),
|
|
|
o2.getScore(SimilarityStrategy.class.getSimpleName())));
|
|
|
+ sortedItems.addAll(data);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+<<<<<<< HEAD
|
|
|
|
|
|
List<RankItem> sortedItems = new ArrayList<>();
|
|
|
for (String pool : contentPools) {
|
|
@@ -76,6 +81,8 @@ public class RankService {
|
|
|
sortedItems.addAll(itemMap.get(pool));
|
|
|
}
|
|
|
}
|
|
|
+=======
|
|
|
+>>>>>>> 031bdba (init)
|
|
|
List<Content> contents = CommonCollectionUtils.toList(sortedItems, RankItem::getContent);
|
|
|
log.info("Sort result {}", JSONUtils.toJson(contents));
|
|
|
|