|
|
package com.yoho.search.recall.config;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.yoho.search.base.utils.CollectionUtils;
|
|
|
import com.yoho.search.core.personalized.models.SortBrand;
|
|
|
import com.yoho.search.recall.beans.strategy.SortBrandType;
|
|
|
import com.yoho.search.recall.beans.strategy.StrategyEnum;
|
|
|
import com.yoho.search.recall.models.personal.PagePersonalFactor;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
...
|
...
|
@@ -15,6 +18,8 @@ import java.util.Set; |
|
|
|
|
|
@Service
|
|
|
public class RecallConfigService {
|
|
|
|
|
|
private static final Logger RECALL_LOGGE = LoggerFactory.getLogger("RECALL");
|
|
|
@Autowired
|
|
|
private RecallConfigProductService recallConfigProductService;
|
|
|
@Autowired
|
...
|
...
|
@@ -37,8 +42,10 @@ public class RecallConfigService { |
|
|
*/
|
|
|
public int queryStrategyConfigSize(int pageId, StrategyEnum strategyEnum) {
|
|
|
String configKey = getStrategyConfigKey(strategyEnum);
|
|
|
int value = recallConfigCommonService.queryConfigSize(pageId, configKey, 0);
|
|
|
return this.legallValue(value, 0, 100);
|
|
|
int size = recallConfigCommonService.queryConfigSize(pageId, configKey, 0);
|
|
|
size = this.legallValue(size, 0, 100);
|
|
|
RECALL_LOGGE.info("queryStrategyConfigSize,pageId is [{}],strategyEnum is [{}],size is[{}]", pageId, strategyEnum.name(), size);
|
|
|
return size;
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -51,7 +58,9 @@ public class RecallConfigService { |
|
|
public int queryStrategyConfigInterval(int pageId, StrategyEnum strategyEnum) {
|
|
|
String configKey = getStrategyConfigKey(strategyEnum);
|
|
|
int interval = recallConfigCommonService.queryConfigInterval(pageId, configKey, 10);
|
|
|
return this.legallValue(interval, 2, 40);
|
|
|
interval = this.legallValue(interval, 2, 40);
|
|
|
RECALL_LOGGE.info("queryStrategyConfigInterval,pageId is [{}],strategyEnum is [{}],interval is[{}]", pageId, strategyEnum.name(), interval);
|
|
|
return interval;
|
|
|
}
|
|
|
|
|
|
private String getStrategyConfigKey(StrategyEnum strategyEnum) {
|
...
|
...
|
@@ -81,8 +90,10 @@ public class RecallConfigService { |
|
|
*/
|
|
|
public int querySortBrandConfigCount(int pageId, SortBrandType sortBrandType, int defaultSize) {
|
|
|
String sortBrandConfigKey = this.getSortBrandConfigKey(sortBrandType);
|
|
|
int value = recallConfigCommonService.queryConfigSize(pageId, sortBrandConfigKey, defaultSize);
|
|
|
return this.legallValue(value, 0, 30);
|
|
|
int size = recallConfigCommonService.queryConfigSize(pageId, sortBrandConfigKey, defaultSize);
|
|
|
size = this.legallValue(size, 0, 30);
|
|
|
RECALL_LOGGE.info("querySortBrandConfigCount,pageId is [{}],sortBrandType is [{}],size is[{}]", pageId, sortBrandType.name(), size);
|
|
|
return size;
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -96,6 +107,7 @@ public class RecallConfigService { |
|
|
String sortBrandConfigKey = this.getSortBrandConfigKey(sortBrandType);
|
|
|
RecallSknCount recallSknCount = recallConfigProductService.queryRecallSknCount(pageId, sortBrandConfigKey, sortBrand);
|
|
|
if (recallSknCount == null) {
|
|
|
RECALL_LOGGE.info("queryRecallSknCount,pageId is [{}],sortBrandType is [{}],RecallSknCount is[{}]", pageId, sortBrandType.name(), "null");
|
|
|
return null;
|
|
|
}
|
|
|
recallSknCount.setNewShelve(this.legallValue(recallSknCount.getNewShelve(), 0, 20));
|
...
|
...
|
@@ -104,6 +116,7 @@ public class RecallConfigService { |
|
|
recallSknCount.setHeatValue(this.legallValue(recallSknCount.getHeatValue(), 0, 20));
|
|
|
recallSknCount.setReducePrice(this.legallValue(recallSknCount.getReducePrice(), 0, 20));
|
|
|
recallSknCount.setRandom(this.legallValue(recallSknCount.getRandom(), 0, 20));
|
|
|
RECALL_LOGGE.info("queryRecallSknCount,pageId is [{}],sortBrandType is [{}],RecallSknCount is[{}]", pageId, sortBrandType.name(), JSON.toJSONString(recallSknCount));
|
|
|
return recallSknCount;
|
|
|
}
|
|
|
|
...
|
...
|
@@ -125,15 +138,16 @@ public class RecallConfigService { |
|
|
|
|
|
/**
|
|
|
* 随机获取configSortBrandCount数量
|
|
|
*
|
|
|
* @param pageFactor
|
|
|
* @param filterSortBrandKeys
|
|
|
* @param configSortBrandCount
|
|
|
* @return
|
|
|
*/
|
|
|
public List<SortBrand> queryConfigSortBrandList(PagePersonalFactor pageFactor, Set<String> filterSortBrandKeys, int configSortBrandCount) {
|
|
|
List<SortBrand> pageConfigSortBrands = recallConfigSortBrandService.queryConfigSortBrand(pageFactor,filterSortBrandKeys);
|
|
|
List<SortBrand> pageConfigSortBrands = recallConfigSortBrandService.queryConfigSortBrand(pageFactor, filterSortBrandKeys);
|
|
|
Collections.shuffle(pageConfigSortBrands);
|
|
|
return CollectionUtils.safeSubList(pageConfigSortBrands,0,configSortBrandCount);
|
|
|
return CollectionUtils.safeSubList(pageConfigSortBrands, 0, configSortBrandCount);
|
|
|
}
|
|
|
|
|
|
public static void main(String[] args) {
|
...
|
...
|
|