Authored by hugufei

添加实时品牌品类预测支持

... ... @@ -101,9 +101,9 @@ public class UserRecallRequestResponseCacheBean extends AbstractCacheBean<UserRe
//2、构造非个性化的请求
List<RecallRequest> commonRequests = commonRequestBuilder.buildCommonRecallRequests(param.getParamQueryFilter(), param.getFirstProductSkns());
allRequests.addAll(commonRequests);
//3、构建个性化品类+品牌的召回请求
List<RecallRequest> brandRequests = sortBrandRecallRequestBuilder.buildSortBrandRecallRequests(param.getParamQueryFilter(), userPersonalFactor.getSortBrandList());
allRequests.addAll(brandRequests);
//2、构【品类+品牌】的召回请求
List<RecallRequest> realTimeSortBrandRequests = sortBrandRecallRequestBuilder.buildSortBrandRecallRequests(param.getParamQueryFilter(), userPersonalFactor.getSortBrandList());
allRequests.addAll(realTimeSortBrandRequests);
return allRequests;
}
... ...
... ... @@ -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;
}
}
... ...
... ... @@ -46,12 +46,15 @@ class UserPersionalFactorComponent {
if (rsp == null) {
return new UserPersonalFactorRspNew();
}
if(rsp.getSortPriceAreasList()==null){
rsp.setSortPriceAreasList(new ArrayList<>());
}
if(rsp.getSortBrandList()==null){
rsp.setSortBrandList(new ArrayList<>());
}
if(rsp.getRealTimeSortBrandList()==null){
rsp.setRealTimeSortBrandList(new ArrayList<>());
}
if(rsp.getSortPriceAreasList()==null){
rsp.setSortPriceAreasList(new ArrayList<>());
}
return rsp;
} catch (Exception e) {
RECALL_NEW_LOGGER.error(e.getMessage(), e);
... ...
... ... @@ -11,7 +11,7 @@ public class UserPersonalFactor {
private List<SortPriceAreas> sortPriceAreasList;
private String vector;
public UserPersonalFactor(List<SortBrand> sortBrandList, List<SortPriceAreas> sortPriceAreasList, String vector) {
public UserPersonalFactor(List<SortBrand> sortBrandList,List<SortPriceAreas> sortPriceAreasList, String vector) {
this.sortBrandList = sortBrandList;
this.sortPriceAreasList = sortPriceAreasList;
this.vector = vector;
... ...