Authored by hugufei

当个性化数据为空时,使用配置的品类*品牌召回

... ... @@ -74,16 +74,13 @@ public class QueryUserPersionalFactorBean {
//2、构造推荐的skn列表
List<Integer> recommendSknList = userFactor.getRecommendSknList();
List<Integer> realTimeSimilarSknList = userFactor.getRealTimeSimilarSknList();
//3、获取页面中存在的所有的key
Set<String> pageSortBrandKeys = new HashSet<>();
for (SortBrand pageSortBrand : pageFactor.getSortBrandList()) {
pageSortBrandKeys.add(pageSortBrand.key());
}
//4、构造临时过滤对象
Set<String> filterSortBrandKeys = new HashSet<>();
//5、构造实时【品类+品牌】
int recSortBrandCount = recallConfigService.querySortBrandConfigCount(pageId, SortBrandType.REC_SORT_BRAND, 12);
List<SortBrand> realTimeSortBrandList = this.queryRealTimeSortBrandList(pageSortBrandKeys, filterSortBrandKeys, userFactor.getRealTimeSortBrandList(), recSortBrandCount);
... ... @@ -105,11 +102,19 @@ public class QueryUserPersionalFactorBean {
for (SortBrand existSortBrand : vectorW2vSortBrandList) {
filterSortBrandKeys.add(existSortBrand.key());
}
//8、构造基于配置的【品牌+品牌】,去除其他类型的品类和品牌
//8、构造个性化结果[如果个性化结果为空,则取配置的品类品牌数据]
UserPersonalFactor userPersonalFactor = new UserPersonalFactor(recommendSknList, realTimeSimilarSknList, sortPriceAreasList, realTimeSortBrandList, vectorRnnSortBrandList, vectorW2vSortBrandList);
if (userPersonalFactor.isUserPersonalFactorEmpty()) {
this.fillConfigSortBrandList(userPersonalFactor, pageId, pageFactor, pageSortBrandKeys, filterSortBrandKeys);
}
//10、返回最终结果
return userPersonalFactor;
}
private void fillConfigSortBrandList(UserPersonalFactor userPersonalFactor, int pageId, PagePersonalFactor pageFactor, Set<String> pageSortBrandKeys, Set<String> filterSortBrandKeys) {
int configSortBrandCount = recallConfigService.querySortBrandConfigCount(pageId, SortBrandType.CONFIG_SORT_BRAND, 0);
List<SortBrand> configSortBrandList = recallConfigService.queryConfigSortBrandList(pageFactor,pageSortBrandKeys, filterSortBrandKeys, configSortBrandCount);
//9、返回最终结果
return new UserPersonalFactor(recommendSknList, realTimeSimilarSknList, sortPriceAreasList, realTimeSortBrandList, vectorRnnSortBrandList, vectorW2vSortBrandList, configSortBrandList);
List<SortBrand> configSortBrandList = recallConfigService.queryConfigSortBrandList(pageFactor, pageSortBrandKeys, filterSortBrandKeys, configSortBrandCount);
userPersonalFactor.setConfigSortBrandList(configSortBrandList);
}
private List<SortBrand> queryRealTimeSortBrandList(Set<String> pageSortBrandKeys, Set<String> filterSortBrandKeys, List<SortBrand> userSortBrands, int maxCount) {
... ...
... ... @@ -2,6 +2,7 @@ package com.yoho.search.recall.models.personal;
import com.yoho.search.core.personalized.models.SortBrand;
import com.yoho.search.core.personalized.models.SortPriceAreas;
import org.apache.commons.collections.CollectionUtils;
import java.util.ArrayList;
import java.util.List;
... ... @@ -28,15 +29,13 @@ public class UserPersonalFactor {
this.configSortBrandList = new ArrayList<>();
}
public UserPersonalFactor(List<Integer> recommendSknList, List<Integer> realTimeSimilarSknList, List<SortPriceAreas> sortPriceAreasList, List<SortBrand> realTimeSortBrandList, List<SortBrand> vectorRnnSortBrandList, List<SortBrand> vectorW2vSortBrandList,List<SortBrand> configSortBrandList) {
public UserPersonalFactor(List<Integer> recommendSknList, List<Integer> realTimeSimilarSknList, List<SortPriceAreas> sortPriceAreasList, List<SortBrand> realTimeSortBrandList, List<SortBrand> vectorRnnSortBrandList, List<SortBrand> vectorW2vSortBrandList) {
this.recommendSknList = recommendSknList;
this.realTimeSimilarSknList = realTimeSimilarSknList;
this.sortPriceAreasList = sortPriceAreasList;
this.realTimeSortBrandList = realTimeSortBrandList;
this.vectorRnnSortBrandList = vectorRnnSortBrandList;
this.vectorW2vSortBrandList = vectorW2vSortBrandList;
this.configSortBrandList = configSortBrandList;
}
public List<Integer> getRecommendSknList() {
... ... @@ -63,7 +62,36 @@ public class UserPersonalFactor {
return vectorW2vSortBrandList;
}
/**
* 判断用户个性化数据是否都为空
* @return
*/
public boolean isUserPersonalFactorEmpty(){
if(!CollectionUtils.isEmpty(this.recommendSknList)){
return false;
}
if(!CollectionUtils.isEmpty(this.realTimeSimilarSknList)){
return false;
}
if(!CollectionUtils.isEmpty(this.realTimeSortBrandList)){
return false;
}
if(!CollectionUtils.isEmpty(this.vectorRnnSortBrandList)){
return false;
}
if(!CollectionUtils.isEmpty(this.vectorW2vSortBrandList)){
return false;
}
return true;
}
public void setConfigSortBrandList(List<SortBrand> configSortBrandList) {
this.configSortBrandList = configSortBrandList;
}
public List<SortBrand> getConfigSortBrandList() {
return configSortBrandList;
}
}
... ...