Authored by wangnan9279

Merge branch '0920' into 0930

... ... @@ -19,13 +19,13 @@ import java.util.List;
import java.util.Map;
@Component
public class RecallConfigCommonService extends AbstractReloadEsCacheBean<CsRecallConfigCommon, Map<String, Map<Integer, Map<Integer, CsRecallConfigCommon>>>> {
public class RecallConfigCommonService extends AbstractReloadEsCacheBean<CsRecallConfigCommon, Map<String, Map<Integer, Map<Integer, Map<Integer, CsRecallConfigCommon>>>>> {
@Autowired
private SearchCommonService searchCommonService;
@Override
protected Map<String, Map<Integer, Map<Integer, CsRecallConfigCommon>>> newTempCache() {
protected Map<String, Map<Integer, Map<Integer, Map<Integer, CsRecallConfigCommon>>>> newTempCache() {
return new HashMap<>();
}
... ... @@ -49,19 +49,23 @@ public class RecallConfigCommonService extends AbstractReloadEsCacheBean<CsRecal
}
@Override
protected void addESObjectToTempCache(CsRecallConfigCommon csRecallConfigCommon, Map<String, Map<Integer, Map<Integer, CsRecallConfigCommon>>> tempCache) {
//召回类型---》 页面类型(排序) ==》 AB用户类型
protected void addESObjectToTempCache(CsRecallConfigCommon csRecallConfigCommon, Map<String, Map<Integer, Map<Integer, Map<Integer, CsRecallConfigCommon>>>> tempCache) {
//召回类型---》 页面 ==》 排序类型 == 》 AB用户类型
//1、类型判断
String configKey = csRecallConfigCommon.getConfigType();
Map<Integer, Map<Integer, CsRecallConfigCommon>> configKey2PageIdConfigMap = tempCache.computeIfAbsent(configKey, a -> new HashMap<>());
Map<Integer, Map<Integer, Map<Integer, CsRecallConfigCommon>>> configKey2ConfigMap = tempCache.computeIfAbsent(configKey, a -> new HashMap<>());
//2、生成页面结果
int pageId = csRecallConfigCommon.getConfigPage();
Map<Integer, CsRecallConfigCommon> pageId2AbTypeConfigMap = configKey2PageIdConfigMap.computeIfAbsent(pageId, a -> new HashMap<>());
Integer pageId = csRecallConfigCommon.getConfigPage();
Map<Integer, Map<Integer, CsRecallConfigCommon>> pageId2ConfigMap = configKey2ConfigMap.computeIfAbsent(pageId, a -> new HashMap<>());
//3、生成ab结果
int abType = csRecallConfigCommon.getAbType();
pageId2AbTypeConfigMap.put(abType, csRecallConfigCommon);
//3、生成排序类型
Integer orderType = csRecallConfigCommon.getOrderType();
Map<Integer, CsRecallConfigCommon> orderType2ConfigMap = pageId2ConfigMap.computeIfAbsent(orderType, a -> new HashMap<>());
//4、生成ab结果
Integer abType = csRecallConfigCommon.getAbType();
orderType2ConfigMap.put(abType, csRecallConfigCommon);
}
/**
... ... @@ -71,23 +75,36 @@ public class RecallConfigCommonService extends AbstractReloadEsCacheBean<CsRecal
* @return
*/
private CsRecallConfigCommon queryCsRecallConfigCommon(int pageId, boolean isDefaultOrder, String configKey, boolean isAUser) {
Map<Integer, Map<Integer, CsRecallConfigCommon>> pageConfigMap = this.getCache().get(configKey);
if (pageConfigMap == null) {
//1、按召回类型获取配置
Map<Integer, Map<Integer, Map<Integer, CsRecallConfigCommon>>> pageId2ConfigMap = this.getCache().get(configKey);
if (pageId2ConfigMap == null) {
return null;
}
//2、获取页面配置
Map<Integer, Map<Integer, CsRecallConfigCommon>> orderType2Config = pageId2ConfigMap.get(pageId);
if (orderType2Config == null) {
orderType2Config = pageId2ConfigMap.get(0);
}
if (orderType2Config == null) {
return null;
}
int configPageId = this.getConfigPage(pageId, isDefaultOrder);
int defaultConfigPageId = this.getDefaultConfigPage(isDefaultOrder);
Map<Integer, CsRecallConfigCommon> abTypeConfig = pageConfigMap.get(configPageId);
//3、获取排序配置
Integer orderType = isDefaultOrder ? 0 : 1;
Map<Integer, CsRecallConfigCommon> abTypeConfig = orderType2Config.get(orderType);
if (abTypeConfig == null) {
abTypeConfig = pageConfigMap.get(defaultConfigPageId);
abTypeConfig = orderType2Config.get(0);
}
if (abTypeConfig == null) {
return null;
}
//4、获取a/b类型配置
Integer abType = isAUser ? 0 : 1;
CsRecallConfigCommon csRecallConfigCommon = abTypeConfig.get(abType);
CsRecallConfigCommon config = abTypeConfig.get(abType);
// 使用0的数据兜底
if (csRecallConfigCommon == null) {
csRecallConfigCommon = abTypeConfig.get(0);
if (config == null) {
config = abTypeConfig.get(0);
}
return csRecallConfigCommon;
return config;
}
private int getConfigPage(int pageId, boolean isDefaultOrder) {
... ...