Authored by hugufei

新增价格带品类召回

... ... @@ -190,8 +190,6 @@ public class RecallResultController {
Map<Integer, RecallSknInfo> sknRecallTypeMap = SearchCollectionUtils.toMap(recallSknInfos, (Transfer<RecallSknInfo, Integer>) (recallSknInfo) -> {
return recallSknInfo.getProductSkn();
});
List<Map<String, Object>> briefProductInfoList = new ArrayList<>();
for (Map<String, Object> productInfo : productInfoList) {
Map<String, Object> briefProductInfo = new HashMap<>();
... ...
... ... @@ -42,7 +42,7 @@ class BatchRequestResponseEntrace {
*/
public List<RecallRequestResponse> batchRecall(UserRecallRequest userRecallRequest, PagePersonalFactor pagePersonalFactor, UserPersonalFactor userPersonalFactor) {
//1、处理实时推荐SKN的召回
//1、处理推荐SKN的召回
CompletableFuture<List<RecallRequestResponse>> sknListCompletableFuture = this.doRecallSknList(userRecallRequest, userPersonalFactor);
//2、处理通用召回
... ...
... ... @@ -22,6 +22,8 @@ public class CommonRecallRequestBuilder {
private RecallConfigService recallConfigService;
@Autowired
private DirectTrainBrandRequestsBuiler directTrainBrandRequestsBuiler;
@Autowired
private DirectTrainSortPriceRequestsBuilder directTrainSortPriceRequestsBuilder;
/**
* 批量召回业务需求
... ... @@ -47,6 +49,9 @@ public class CommonRecallRequestBuilder {
requests.addAll(this.buildUfoDirectTrainRequest(userRecallRequest));
//6.3) 直通车-品牌召回
requests.addAll(directTrainBrandRequestsBuiler.buildDirectTrainBrandRequests(userRecallRequest, pagePersonalFactor));
//6.4) 直通车-品类价格带
requests.addAll(directTrainSortPriceRequestsBuilder.buildDirectTrainSortPriceRequests(userRecallRequest, pagePersonalFactor));
//7、 随机召回
requests.addAll(this.buildCommonRandomStrategy(userRecallRequest));
... ...
... ... @@ -4,6 +4,7 @@ import com.yoho.search.models.recall.PagePersonalFactor;
import com.yoho.search.models.recall.RecallRequest;
import com.yoho.search.models.recall.UserRecallRequest;
import com.yoho.search.service.recall.beans.RecallConfigService;
import com.yoho.search.service.recall.helper.RecallConfigConstants;
import com.yoho.search.service.recall.strategy.IStrategy;
import com.yoho.search.service.recall.strategy.StrategyEnum;
import com.yoho.search.service.recall.strategy.impls.DirectTrainBrandStrategy;
... ... @@ -36,9 +37,10 @@ public class DirectTrainBrandRequestsBuiler {
if (CollectionUtils.isEmpty(directTrainBrandIds)) {
return Collections.emptyList();
}
int productSize = RecallConfigConstants.DEFAULT_DIRECT_TRAIN_PRODUCT_SIZE;
List<RecallRequest> requests = new ArrayList<>();
for (Integer brand : directTrainBrandIds) {
IStrategy strategy = new DirectTrainBrandStrategy(brand, 10);
IStrategy strategy = new DirectTrainBrandStrategy(brand, productSize);
requests.add(new RecallRequest(userRecallRequest.getParamQueryFilter(), strategy));
}
return requests;
... ...
package com.yoho.search.service.recall.beans.requests;
import com.alibaba.fastjson.JSON;
import com.yoho.search.dal.model.CsRecallConfigSortPrice;
import com.yoho.search.models.recall.PagePersonalFactor;
import com.yoho.search.models.recall.RecallRequest;
import com.yoho.search.models.recall.UserRecallRequest;
import com.yoho.search.service.recall.beans.RecallConfigService;
import com.yoho.search.service.recall.helper.RecallConfigConstants;
import com.yoho.search.service.recall.strategy.IStrategy;
import com.yoho.search.service.recall.strategy.StrategyEnum;
import com.yoho.search.service.recall.strategy.impls.DirectTrainSortPriceStrategy;
import org.apache.commons.collections.CollectionUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
@Component
public class DirectTrainSortPriceRequestsBuilder {
private static final Logger RECALL_NEW_LOGGER = LoggerFactory.getLogger("RECALL");
@Autowired
private RecallConfigService recallConfigService;
/**
* 构造直通车-[品类价格带]的召回请求
*
* @param userRecallRequest
* @return
*/
public List<RecallRequest> buildDirectTrainSortPriceRequests(UserRecallRequest userRecallRequest, PagePersonalFactor pageFactor) {
int size = recallConfigService.queryStrategyConfigSize(userRecallRequest, StrategyEnum.DIRECT_TRAIN_SORT_PRICE, 0);
if (size == 0) {
return Collections.emptyList();
}
List<CsRecallConfigSortPrice> directTrainSortPriceList = recallConfigService.randomSortPrice(pageFactor, size);
if (CollectionUtils.isEmpty(directTrainSortPriceList)) {
return Collections.emptyList();
}
RECALL_NEW_LOGGER.info("randomSortPrice is[{}]", JSON.toJSONString(directTrainSortPriceList));
List<RecallRequest> requests = new ArrayList<>();
int productSize = RecallConfigConstants.DEFAULT_DIRECT_TRAIN_PRODUCT_SIZE;
for (CsRecallConfigSortPrice sortPrice : directTrainSortPriceList) {
IStrategy strategy = new DirectTrainSortPriceStrategy(sortPrice.getSortId(), sortPrice.getMinPrice().doubleValue(), sortPrice.getMaxPrice().doubleValue(), productSize);
requests.add(new RecallRequest(userRecallRequest.getParamQueryFilter(), strategy));
}
return requests;
}
}
... ...
... ... @@ -7,6 +7,8 @@ public class RecallConfigConstants {
public static final int DEFAULT_PAGE_ID = 0;
public static final int DEFAULT_PAGE_ID_GUANZHU = 10000;
public static final int DEFAULT_DIRECT_TRAIN_PRODUCT_SIZE = 10;
public static final String SORT = "SORT";
public static final String BRAND = "BRAND";
public static final String SORT_BRAND = "SORT_BRAND";
... ...