...
|
...
|
@@ -6,44 +6,67 @@ import com.yoho.search.recall.models.personal.PagePersonalFactor; |
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.Executors;
|
|
|
import java.util.concurrent.ScheduledExecutorService;
|
|
|
|
|
|
@Component
|
|
|
class RecallConfigSortBrandService {
|
|
|
|
|
|
|
|
|
private List<SortBrand> configSortBrands = new ArrayList<>();
|
|
|
|
|
|
/**
|
|
|
* 随机获取页面中,属于配置的品牌品类
|
|
|
* 随机获取size个品类品牌
|
|
|
*
|
|
|
* @param pageFactor
|
|
|
* @param pageSortBrandKeys
|
|
|
* @param filterSortBrandKeys
|
|
|
* @param size
|
|
|
* @return
|
|
|
*/
|
|
|
public List<SortBrand> queryConfigSortBrand(PagePersonalFactor pageFactor, Set<String> filterSortBrandKeys, int size) {
|
|
|
//return new ArrayList<>();
|
|
|
List<SortBrand> pageSortBrands = new ArrayList<>();
|
|
|
if(pageFactor.getMisortIds().contains(26)){
|
|
|
if(pageFactor.getBrandIds().contains(650)){
|
|
|
pageSortBrands.add(new SortBrand(26,650));
|
|
|
private List<SortBrand> randomConfigSortBrands(List<SortBrand> configSortBrands, Set<String> pageSortBrandKeys, Set<String> filterSortBrandKeys, int size) {
|
|
|
List<SortBrand> copyList = new ArrayList<>(configSortBrands);
|
|
|
Collections.shuffle(copyList);
|
|
|
List<SortBrand> results = new ArrayList<>();
|
|
|
for (SortBrand sortBrand : copyList) {
|
|
|
if (results.size() >= size) {
|
|
|
break;
|
|
|
}
|
|
|
if(pageFactor.getBrandIds().contains(661)){
|
|
|
pageSortBrands.add(new SortBrand(26,661));
|
|
|
if (!pageSortBrandKeys.contains(sortBrand.key())) {
|
|
|
continue;
|
|
|
}
|
|
|
if(pageFactor.getBrandIds().contains(336)){
|
|
|
pageSortBrands.add(new SortBrand(26,336));
|
|
|
if (filterSortBrandKeys.contains(sortBrand.key())) {
|
|
|
continue;
|
|
|
}
|
|
|
if(pageFactor.getBrandIds().contains(518)){
|
|
|
pageSortBrands.add(new SortBrand(26,518));
|
|
|
results.add(sortBrand);
|
|
|
}
|
|
|
if(pageFactor.getBrandIds().contains(417)){
|
|
|
pageSortBrands.add(new SortBrand(26,417));
|
|
|
return results;
|
|
|
}
|
|
|
if(pageFactor.getBrandIds().contains(218)){
|
|
|
pageSortBrands.add(new SortBrand(26,218));
|
|
|
|
|
|
private List<SortBrand> randomConfigSortBrandForTest(PagePersonalFactor pageFactor, Set<String> pageSortBrandKeys, Set<String> filterSortBrandKeys, int size) {
|
|
|
List<SortBrand> randomReultsForTest = new ArrayList<>();
|
|
|
randomReultsForTest.add(new SortBrand(26, 650));
|
|
|
randomReultsForTest.add(new SortBrand(26, 661));
|
|
|
randomReultsForTest.add(new SortBrand(26, 336));
|
|
|
randomReultsForTest.add(new SortBrand(26, 417));
|
|
|
randomReultsForTest.add(new SortBrand(26, 218));
|
|
|
return this.randomConfigSortBrands(randomReultsForTest, pageSortBrandKeys, filterSortBrandKeys, size);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 随机获取页面中,属于配置的品牌品类
|
|
|
*
|
|
|
* @param pageFactor
|
|
|
* @param pageSortBrandKeys
|
|
|
* @param filterSortBrandKeys
|
|
|
* @param size
|
|
|
* @return
|
|
|
*/
|
|
|
public List<SortBrand> queryConfigSortBrand(PagePersonalFactor pageFactor, Set<String> pageSortBrandKeys, Set<String> filterSortBrandKeys, int size) {
|
|
|
if (size <= 0) {
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
// pageSortBrands.addAll(pageFactor.getSortBrandList());
|
|
|
// Collections.shuffle(pageSortBrands);
|
|
|
// return CollectionUtils.safeSubList(pageSortBrands, 0, size);
|
|
|
return CollectionUtils.safeSubList(pageSortBrands, 0, size);
|
|
|
//return this.randomConfigSortBrands(this.configSortBrands,pageSortBrandKeys, filterSortBrandKeys,size);
|
|
|
return this.randomConfigSortBrandForTest(pageFactor, pageSortBrandKeys, filterSortBrandKeys, size);
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|