...
|
...
|
@@ -63,15 +63,7 @@ public class QueryUserPersionalFactorBean { |
|
|
RECALL_NEW_LOGGER.info("QueryUserPersionalFactor[2]:queryUserFactor. uid is[{}], cost is[{}],sortBrand size is[{}] , userFactor is[{}] ",uid, cost,userSortBrandSize,JSON.toJSONString(userFactor));
|
|
|
}
|
|
|
//3、join获取最终的结果
|
|
|
List<SortBrand> sortBrandList = this.getSortBrandListWithSort(pageFactor, userFactor);
|
|
|
List<SortPriceAreas> sortPriceAreasList = this.getSortPriceAreasListWithSort(pageFactor, userFactor);
|
|
|
//4、构造UserPersonalFactorRspNew
|
|
|
UserPersonalFactor userPersonalFactor = new UserPersonalFactor(sortBrandList, sortPriceAreasList, userFactor.getVector());
|
|
|
if (!openDetailLog) {
|
|
|
RECALL_NEW_LOGGER.info("QueryUserPersionalFactor[3]:join. uid is[{}], sortBrand size is[{}], sortPriceAreas size is [{}] ", uid, sortBrandList.size(),sortPriceAreasList.size());
|
|
|
} else {
|
|
|
RECALL_NEW_LOGGER.info("QueryUserPersionalFactor[3]:join. uid is[{}], sortBrand size is[{}], sortPriceAreas size is [{}], data is [{}], ", uid, sortBrandList.size(),sortPriceAreasList.size(),JSON.toJSONString(userPersonalFactor));
|
|
|
}
|
|
|
UserPersonalFactor userPersonalFactor = this.buildUserPersonalFactor(pageFactor,userFactor,uid,openDetailLog);
|
|
|
return userPersonalFactor;
|
|
|
} catch (Exception e) {
|
|
|
logger.error(e.getMessage(), e);
|
...
|
...
|
@@ -83,27 +75,40 @@ public class QueryUserPersionalFactorBean { |
|
|
return userRecallRequest.getUid() == 13420925;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 按顺序截取【品类+品牌】
|
|
|
*
|
|
|
* @param pageFactor
|
|
|
* @param userFactorNew
|
|
|
* @return
|
|
|
*/
|
|
|
private List<SortBrand> getSortBrandListWithSort(PagePersonalFactor pageFactor, UserPersonalFactorRspNew userFactorNew) {
|
|
|
//1、返回结果定义
|
|
|
List<SortBrand> results = new ArrayList<>();
|
|
|
private UserPersonalFactor buildUserPersonalFactor(PagePersonalFactor pageFactor,UserPersonalFactorRspNew userFactor,int uid, boolean openDetailLog){
|
|
|
//1、构造页面中的品牌品类map
|
|
|
Map<Integer, List<Integer>> pageBrand2MiSortIdsMap = this.getPageBrand2MiSortIdsMap(pageFactor);
|
|
|
//2、构造实时【品类+品牌】
|
|
|
List<SortBrand> realTimeSortBrandList = this.getSortBrandListWithSort(pageBrand2MiSortIdsMap, userFactor.getRealTimeSortBrandList(),10);
|
|
|
//3、构造预测的【品牌+品牌】
|
|
|
int forecastSortBrandCount = searchDynamicConfigService.searchPersionalNewStrategyMaxJoinSortBrandCount();
|
|
|
List<SortBrand> forecastSortBrandList = this.getSortBrandListWithSort(pageBrand2MiSortIdsMap, userFactor.getSortBrandList(),forecastSortBrandCount);
|
|
|
//4、构造品类价格带
|
|
|
List<SortPriceAreas> sortPriceAreasList = this.getSortPriceAreasListWithSort(pageFactor, userFactor);
|
|
|
RECALL_NEW_LOGGER.info("QueryUserPersionalFactor[3]:join. uid is[{}], forecastSortBrand size is[{}],realTimeSortBrand size is[{}],sortPriceAreas size is [{}] ", uid, forecastSortBrandList.size(),realTimeSortBrandList.size(),sortPriceAreasList.size());
|
|
|
if (openDetailLog) {
|
|
|
RECALL_NEW_LOGGER.info("QueryUserPersionalFactor[3]:join. userFactor is [{}], ", JSON.toJSONString(userFactor));
|
|
|
}
|
|
|
//5、返回最终结果
|
|
|
List<SortBrand> sortBrands = new ArrayList<>();
|
|
|
sortBrands.addAll(realTimeSortBrandList);
|
|
|
sortBrands.addAll(forecastSortBrandList);
|
|
|
return new UserPersonalFactor(sortBrands,sortPriceAreasList, userFactor.getVector());
|
|
|
}
|
|
|
|
|
|
//2、构造brand2MiSortIdsMap
|
|
|
private Map<Integer, List<Integer>> getPageBrand2MiSortIdsMap(PagePersonalFactor pageFactor){
|
|
|
//1、构造brand2MiSortIdsMap
|
|
|
List<PageBrandSorts> brandSortsList = pageFactor.getBrandSortsList();
|
|
|
Map<Integer, List<Integer>> brand2MiSortIdsMap = new HashMap<>();
|
|
|
for (PageBrandSorts pageBrandSorts : brandSortsList) {
|
|
|
brand2MiSortIdsMap.put(pageBrandSorts.getBrandId(), pageBrandSorts.getMisorts());
|
|
|
}
|
|
|
return brand2MiSortIdsMap;
|
|
|
}
|
|
|
|
|
|
//3、构建SortBrands
|
|
|
int maxJoinSortBrandCount = searchDynamicConfigService.searchPersionalNewStrategyMaxJoinSortBrandCount();
|
|
|
for (SortBrand sortBrand : userFactorNew.getSortBrandList()) {
|
|
|
private List<SortBrand> getSortBrandListWithSort(Map<Integer, List<Integer>> brand2MiSortIdsMap,List<SortBrand> userSortBrands,int maxCount){
|
|
|
List<SortBrand> results = new ArrayList<>();
|
|
|
for (SortBrand sortBrand :userSortBrands) {
|
|
|
if (!brand2MiSortIdsMap.containsKey(sortBrand.getBrandId())) {
|
|
|
continue;
|
|
|
}
|
...
|
...
|
@@ -112,7 +117,7 @@ public class QueryUserPersionalFactorBean { |
|
|
continue;
|
|
|
}
|
|
|
results.add(sortBrand);
|
|
|
if (results.size() >= maxJoinSortBrandCount) {
|
|
|
if (results.size() >= maxCount) {
|
|
|
break;
|
|
|
}
|
|
|
}
|
...
|
...
|
|