...
|
...
|
@@ -41,42 +41,61 @@ public class QueryUserPersionalFactorBean { |
|
|
*/
|
|
|
public UserPersonalFactor queryPersionalFactorNew(UserRecallRequest userRecallRequest) {
|
|
|
try {
|
|
|
boolean openDetailLog = this.openDetailLog(userRecallRequest);
|
|
|
int uid = userRecallRequest.getUid();
|
|
|
//1、获取页面上的个性化因子
|
|
|
long begin = System.currentTimeMillis();
|
|
|
PagePersonalFactor pageFactor = pageComponent.queryPagePersionalFactor(userRecallRequest.getParamQueryFilter());
|
|
|
RECALL_NEW_LOGGER.info("queryPagePersionalFactor . cost is[{}]", System.currentTimeMillis() - begin);
|
|
|
long cost = System.currentTimeMillis() - begin;
|
|
|
if (!openDetailLog) {
|
|
|
RECALL_NEW_LOGGER.info("QueryUserPersionalFactor[1]:queryPageFactor. uid is[{}], cost is[{}] ",uid, cost);
|
|
|
} else {
|
|
|
RECALL_NEW_LOGGER.info("QueryUserPersionalFactor[1]:queryPageFactor. uid is[{}], cost is[{}], pageFactor is[{}] ",uid, cost, JSON.toJSONString(pageFactor));
|
|
|
}
|
|
|
//2、获取用户的个性化因子
|
|
|
begin = System.currentTimeMillis();
|
|
|
UserPersonalFactorRspNew userFactorNew = userComponent.queryUserPersionalFactorNew(userRecallRequest.getUid(), userRecallRequest.getUdid(),pageFactor);
|
|
|
RECALL_NEW_LOGGER.info("queryUserPersionalFactorNew . cost is[{}]", System.currentTimeMillis() - begin);
|
|
|
UserPersonalFactorRspNew userFactor = userComponent.queryUserPersionalFactor(userRecallRequest.getUid(), userRecallRequest.getUdid(), pageFactor);
|
|
|
cost = System.currentTimeMillis() - begin;
|
|
|
if (!openDetailLog) {
|
|
|
RECALL_NEW_LOGGER.info("QueryUserPersionalFactor[2]:queryUserFactor. uid is[{}], cost is[{}]",uid, cost);
|
|
|
} else {
|
|
|
RECALL_NEW_LOGGER.info("QueryUserPersionalFactor[2]:queryUserFactor. uid is[{}], cost is[{}], userFactor is[{}]",uid, cost, JSON.toJSONString(userFactor));
|
|
|
}
|
|
|
//3、join获取最终的结果
|
|
|
List<SortBrand> sortBrandList = this.getSortBrandListWithSort(pageFactor, userFactorNew);
|
|
|
List<SortPriceAreas> sortPriceAreasList = this.getSortPriceAreasListWithSort(pageFactor, userFactorNew);
|
|
|
List<SortBrand> sortBrandList = this.getSortBrandListWithSort(pageFactor, userFactor);
|
|
|
List<SortPriceAreas> sortPriceAreasList = this.getSortPriceAreasListWithSort(pageFactor, userFactor);
|
|
|
//4、构造UserPersonalFactorRspNew
|
|
|
UserPersonalFactor userPersonalFactor = new UserPersonalFactor(sortBrandList, sortPriceAreasList,userFactorNew.getVector());
|
|
|
if(userRecallRequest.getUid()==13420925){
|
|
|
RECALL_NEW_LOGGER.info("innerJoinFactor . uid is[{}], userPersonalFactor is [{}], ", userRecallRequest.getUid(), JSON.toJSONString(userPersonalFactor));
|
|
|
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));
|
|
|
}
|
|
|
return userPersonalFactor;
|
|
|
} catch (Exception e) {
|
|
|
logger.error(e.getMessage(), e);
|
|
|
return new UserPersonalFactor(new ArrayList<>(),new ArrayList<>(), "");
|
|
|
return new UserPersonalFactor(new ArrayList<>(), new ArrayList<>(), "");
|
|
|
}
|
|
|
}
|
|
|
|
|
|
private boolean openDetailLog(UserRecallRequest userRecallRequest) {
|
|
|
return userRecallRequest.getUid() == 13420925;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 按顺序截取【品类+品牌】
|
|
|
*
|
|
|
* @param pageFactor
|
|
|
* @param userFactorNew
|
|
|
* @return
|
|
|
*/
|
|
|
private List<SortBrand> getSortBrandListWithSort(PagePersonalFactor pageFactor, UserPersonalFactorRspNew userFactorNew){
|
|
|
private List<SortBrand> getSortBrandListWithSort(PagePersonalFactor pageFactor, UserPersonalFactorRspNew userFactorNew) {
|
|
|
//1、返回结果定义
|
|
|
List<SortBrand> results = new ArrayList<>();
|
|
|
|
|
|
//2、构造brand2MiSortIdsMap
|
|
|
List<PageBrandSorts> brandSortsList = pageFactor.getBrandSortsList();
|
|
|
Map<Integer,List<Integer>> brand2MiSortIdsMap = new HashMap<>();
|
|
|
Map<Integer, List<Integer>> brand2MiSortIdsMap = new HashMap<>();
|
|
|
for (PageBrandSorts pageBrandSorts : brandSortsList) {
|
|
|
brand2MiSortIdsMap.put(pageBrandSorts.getBrandId(), pageBrandSorts.getMisorts());
|
|
|
}
|
...
|
...
|
@@ -84,15 +103,15 @@ public class QueryUserPersionalFactorBean { |
|
|
//3、构建SortBrands
|
|
|
int maxJoinSortBrandCount = searchDynamicConfigService.searchPersionalNewStrategyMaxJoinSortBrandCount();
|
|
|
for (SortBrand sortBrand : userFactorNew.getSortBrandList()) {
|
|
|
if(!brand2MiSortIdsMap.containsKey(sortBrand.getBrandId())){
|
|
|
if (!brand2MiSortIdsMap.containsKey(sortBrand.getBrandId())) {
|
|
|
continue;
|
|
|
}
|
|
|
List<Integer> miSortIds = brand2MiSortIdsMap.get(sortBrand.getBrandId());
|
|
|
if(miSortIds==null || !miSortIds.contains(sortBrand.getMisort())){
|
|
|
if (miSortIds == null || !miSortIds.contains(sortBrand.getMisort())) {
|
|
|
continue;
|
|
|
}
|
|
|
results.add(sortBrand);
|
|
|
if (results.size() >= maxJoinSortBrandCount){
|
|
|
if (results.size() >= maxJoinSortBrandCount) {
|
|
|
break;
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -101,13 +120,14 @@ public class QueryUserPersionalFactorBean { |
|
|
|
|
|
/**
|
|
|
* 【品类+价格带】
|
|
|
*
|
|
|
* @param pageFactor
|
|
|
* @param userFactorNew
|
|
|
* @return
|
|
|
*/
|
|
|
private List<SortPriceAreas> getSortPriceAreasListWithSort(PagePersonalFactor pageFactor, UserPersonalFactorRspNew userFactorNew){
|
|
|
private List<SortPriceAreas> getSortPriceAreasListWithSort(PagePersonalFactor pageFactor, UserPersonalFactorRspNew userFactorNew) {
|
|
|
List<SortPriceAreas> sortPriceAreas = userFactorNew.getSortPriceAreasList();
|
|
|
if(sortPriceAreas==null|| sortPriceAreas.isEmpty()){
|
|
|
if (sortPriceAreas == null || sortPriceAreas.isEmpty()) {
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
return sortPriceAreas;
|
...
|
...
|
|