Authored by hugufei

Merge branch 'recall_config' into 0510

@@ -74,16 +74,13 @@ public class QueryUserPersionalFactorBean { @@ -74,16 +74,13 @@ public class QueryUserPersionalFactorBean {
74 //2、构造推荐的skn列表 74 //2、构造推荐的skn列表
75 List<Integer> recommendSknList = userFactor.getRecommendSknList(); 75 List<Integer> recommendSknList = userFactor.getRecommendSknList();
76 List<Integer> realTimeSimilarSknList = userFactor.getRealTimeSimilarSknList(); 76 List<Integer> realTimeSimilarSknList = userFactor.getRealTimeSimilarSknList();
77 -  
78 //3、获取页面中存在的所有的key 77 //3、获取页面中存在的所有的key
79 Set<String> pageSortBrandKeys = new HashSet<>(); 78 Set<String> pageSortBrandKeys = new HashSet<>();
80 for (SortBrand pageSortBrand : pageFactor.getSortBrandList()) { 79 for (SortBrand pageSortBrand : pageFactor.getSortBrandList()) {
81 pageSortBrandKeys.add(pageSortBrand.key()); 80 pageSortBrandKeys.add(pageSortBrand.key());
82 } 81 }
83 -  
84 //4、构造临时过滤对象 82 //4、构造临时过滤对象
85 Set<String> filterSortBrandKeys = new HashSet<>(); 83 Set<String> filterSortBrandKeys = new HashSet<>();
86 -  
87 //5、构造实时【品类+品牌】 84 //5、构造实时【品类+品牌】
88 int recSortBrandCount = recallConfigService.querySortBrandConfigCount(pageId, SortBrandType.REC_SORT_BRAND, 12); 85 int recSortBrandCount = recallConfigService.querySortBrandConfigCount(pageId, SortBrandType.REC_SORT_BRAND, 12);
89 List<SortBrand> realTimeSortBrandList = this.queryRealTimeSortBrandList(pageSortBrandKeys, filterSortBrandKeys, userFactor.getRealTimeSortBrandList(), recSortBrandCount); 86 List<SortBrand> realTimeSortBrandList = this.queryRealTimeSortBrandList(pageSortBrandKeys, filterSortBrandKeys, userFactor.getRealTimeSortBrandList(), recSortBrandCount);
@@ -105,11 +102,19 @@ public class QueryUserPersionalFactorBean { @@ -105,11 +102,19 @@ public class QueryUserPersionalFactorBean {
105 for (SortBrand existSortBrand : vectorW2vSortBrandList) { 102 for (SortBrand existSortBrand : vectorW2vSortBrandList) {
106 filterSortBrandKeys.add(existSortBrand.key()); 103 filterSortBrandKeys.add(existSortBrand.key());
107 } 104 }
108 - //8、构造基于配置的【品牌+品牌】,去除其他类型的品类和品牌 105 + //8、构造个性化结果[如果个性化结果为空,则取配置的品类品牌数据]
  106 + UserPersonalFactor userPersonalFactor = new UserPersonalFactor(recommendSknList, realTimeSimilarSknList, sortPriceAreasList, realTimeSortBrandList, vectorRnnSortBrandList, vectorW2vSortBrandList);
  107 + if (userPersonalFactor.isUserPersonalFactorEmpty()) {
  108 + this.fillConfigSortBrandList(userPersonalFactor, pageId, pageFactor, pageSortBrandKeys, filterSortBrandKeys);
  109 + }
  110 + //10、返回最终结果
  111 + return userPersonalFactor;
  112 + }
  113 +
  114 + private void fillConfigSortBrandList(UserPersonalFactor userPersonalFactor, int pageId, PagePersonalFactor pageFactor, Set<String> pageSortBrandKeys, Set<String> filterSortBrandKeys) {
109 int configSortBrandCount = recallConfigService.querySortBrandConfigCount(pageId, SortBrandType.CONFIG_SORT_BRAND, 0); 115 int configSortBrandCount = recallConfigService.querySortBrandConfigCount(pageId, SortBrandType.CONFIG_SORT_BRAND, 0);
110 - List<SortBrand> configSortBrandList = recallConfigService.queryConfigSortBrandList(pageFactor,pageSortBrandKeys, filterSortBrandKeys, configSortBrandCount);  
111 - //9、返回最终结果  
112 - return new UserPersonalFactor(recommendSknList, realTimeSimilarSknList, sortPriceAreasList, realTimeSortBrandList, vectorRnnSortBrandList, vectorW2vSortBrandList, configSortBrandList); 116 + List<SortBrand> configSortBrandList = recallConfigService.queryConfigSortBrandList(pageFactor, pageSortBrandKeys, filterSortBrandKeys, configSortBrandCount);
  117 + userPersonalFactor.setConfigSortBrandList(configSortBrandList);
113 } 118 }
114 119
115 private List<SortBrand> queryRealTimeSortBrandList(Set<String> pageSortBrandKeys, Set<String> filterSortBrandKeys, List<SortBrand> userSortBrands, int maxCount) { 120 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; @@ -2,6 +2,7 @@ package com.yoho.search.recall.models.personal;
2 2
3 import com.yoho.search.core.personalized.models.SortBrand; 3 import com.yoho.search.core.personalized.models.SortBrand;
4 import com.yoho.search.core.personalized.models.SortPriceAreas; 4 import com.yoho.search.core.personalized.models.SortPriceAreas;
  5 +import org.apache.commons.collections.CollectionUtils;
5 6
6 import java.util.ArrayList; 7 import java.util.ArrayList;
7 import java.util.List; 8 import java.util.List;
@@ -28,15 +29,13 @@ public class UserPersonalFactor { @@ -28,15 +29,13 @@ public class UserPersonalFactor {
28 this.configSortBrandList = new ArrayList<>(); 29 this.configSortBrandList = new ArrayList<>();
29 } 30 }
30 31
31 - public UserPersonalFactor(List<Integer> recommendSknList, List<Integer> realTimeSimilarSknList, List<SortPriceAreas> sortPriceAreasList, List<SortBrand> realTimeSortBrandList, List<SortBrand> vectorRnnSortBrandList, List<SortBrand> vectorW2vSortBrandList,List<SortBrand> configSortBrandList) { 32 + public UserPersonalFactor(List<Integer> recommendSknList, List<Integer> realTimeSimilarSknList, List<SortPriceAreas> sortPriceAreasList, List<SortBrand> realTimeSortBrandList, List<SortBrand> vectorRnnSortBrandList, List<SortBrand> vectorW2vSortBrandList) {
32 this.recommendSknList = recommendSknList; 33 this.recommendSknList = recommendSknList;
33 this.realTimeSimilarSknList = realTimeSimilarSknList; 34 this.realTimeSimilarSknList = realTimeSimilarSknList;
34 this.sortPriceAreasList = sortPriceAreasList; 35 this.sortPriceAreasList = sortPriceAreasList;
35 -  
36 this.realTimeSortBrandList = realTimeSortBrandList; 36 this.realTimeSortBrandList = realTimeSortBrandList;
37 this.vectorRnnSortBrandList = vectorRnnSortBrandList; 37 this.vectorRnnSortBrandList = vectorRnnSortBrandList;
38 this.vectorW2vSortBrandList = vectorW2vSortBrandList; 38 this.vectorW2vSortBrandList = vectorW2vSortBrandList;
39 - this.configSortBrandList = configSortBrandList;  
40 } 39 }
41 40
42 public List<Integer> getRecommendSknList() { 41 public List<Integer> getRecommendSknList() {
@@ -63,7 +62,36 @@ public class UserPersonalFactor { @@ -63,7 +62,36 @@ public class UserPersonalFactor {
63 return vectorW2vSortBrandList; 62 return vectorW2vSortBrandList;
64 } 63 }
65 64
  65 +
  66 + /**
  67 + * 判断用户个性化数据是否都为空
  68 + * @return
  69 + */
  70 + public boolean isUserPersonalFactorEmpty(){
  71 + if(!CollectionUtils.isEmpty(this.recommendSknList)){
  72 + return false;
  73 + }
  74 + if(!CollectionUtils.isEmpty(this.realTimeSimilarSknList)){
  75 + return false;
  76 + }
  77 + if(!CollectionUtils.isEmpty(this.realTimeSortBrandList)){
  78 + return false;
  79 + }
  80 + if(!CollectionUtils.isEmpty(this.vectorRnnSortBrandList)){
  81 + return false;
  82 + }
  83 + if(!CollectionUtils.isEmpty(this.vectorW2vSortBrandList)){
  84 + return false;
  85 + }
  86 + return true;
  87 + }
  88 +
  89 + public void setConfigSortBrandList(List<SortBrand> configSortBrandList) {
  90 + this.configSortBrandList = configSortBrandList;
  91 + }
  92 +
66 public List<SortBrand> getConfigSortBrandList() { 93 public List<SortBrand> getConfigSortBrandList() {
67 return configSortBrandList; 94 return configSortBrandList;
68 } 95 }
  96 +
69 } 97 }