Authored by hugufei

fix Collections.sort

... ... @@ -3,6 +3,7 @@ package com.yoho.search.service.recall;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Map;
... ... @@ -180,15 +181,20 @@ public class CommonSceneProductListService {
List<String> firstProductSkns = Arrays.asList(MapUtils.getString(paramMap, SearchRequestParams.PARAM_SEARCH_FIRST_PRODUCRSKN, "").split(","));
for (CommonRecallSkn commonRecallSkn : commonRecallResult.getRecallSknList()) {
if (firstProductSkns.contains(String.valueOf(commonRecallSkn.getProductSkn()))) {
commonRecallSkn.setScore(10000);// firstSkn排第一个
commonRecallSkn.setScore(10000d);// firstSkn排第一个
} else {
commonRecallSkn.setScore(productFeatureFactorHepler.calProductFeatureFactor(userFeatureFactor, commonRecallSkn.getProductFeatureFactor()));
}
}
Collections.sort(commonRecallResult.getRecallSknList());
Collections.sort(commonRecallResult.getRecallSknList(),new Comparator<CommonRecallSkn>() {
@Override
public int compare(CommonRecallSkn o1, CommonRecallSkn o2) {
return o2.getScore().compareTo(o1.getScore());//大的排前面
}
});
return commonRecallResult;
}
/**
* 非个性化的列表接口-去除uid缓存
*
... ...
... ... @@ -2,7 +2,7 @@ package com.yoho.search.service.recall.model;
import java.io.Serializable;
public class CommonRecallSkn implements Comparable<CommonRecallSkn>,Serializable {
public class CommonRecallSkn implements Serializable {
private static final long serialVersionUID = -6820037942157341237L;
... ... @@ -10,7 +10,7 @@ public class CommonRecallSkn implements Comparable<CommonRecallSkn>,Serializable
private int brandId;
private int smallSortId;
private String productFeatureFactor;
private double score;
private Double score;
public int getProductSkn() {
return productSkn;
... ... @@ -44,23 +44,12 @@ public class CommonRecallSkn implements Comparable<CommonRecallSkn>,Serializable
this.productFeatureFactor = productFeatureFactor;
}
public double score() {
public Double getScore() {
return score;
}
public void setScore(double score) {
public void setScore(Double score) {
this.score = score;
}
@Override
public int compareTo(CommonRecallSkn old) {
double c = score - old.score;
if(c>0){
return -1;
}
if(c<0){
return 1;
}
return 0;
}
}
... ...