...
|
...
|
@@ -19,13 +19,13 @@ import java.util.List; |
|
|
import java.util.Map;
|
|
|
|
|
|
@Component
|
|
|
public class RecallConfigCommonService extends AbstractReloadEsCacheBean<CsRecallConfigCommon, Map<String, Map<Integer, CsRecallConfigCommon>>> {
|
|
|
public class RecallConfigCommonService extends AbstractReloadEsCacheBean<CsRecallConfigCommon, Map<String, Map<Integer, Map<Integer, CsRecallConfigCommon>>>> {
|
|
|
|
|
|
@Autowired
|
|
|
private SearchCommonService searchCommonService;
|
|
|
|
|
|
@Override
|
|
|
protected Map<String, Map<Integer, CsRecallConfigCommon>> newTempCache() {
|
|
|
protected Map<String, Map<Integer, Map<Integer, CsRecallConfigCommon>>> newTempCache() {
|
|
|
return new HashMap<>();
|
|
|
}
|
|
|
|
...
|
...
|
@@ -49,14 +49,20 @@ public class RecallConfigCommonService extends AbstractReloadEsCacheBean<CsRecal |
|
|
}
|
|
|
|
|
|
@Override
|
|
|
protected void addESObjectToTempCache(CsRecallConfigCommon csRecallConfigCommon, Map<String, Map<Integer, CsRecallConfigCommon>> tempCache) {
|
|
|
protected void addESObjectToTempCache(CsRecallConfigCommon csRecallConfigCommon, Map<String, Map<Integer, Map<Integer, CsRecallConfigCommon>>> tempCache) {
|
|
|
//类型---》 页面(排序) ==》 AB类型
|
|
|
|
|
|
//1、类型判断
|
|
|
String configKey = csRecallConfigCommon.getConfigType();
|
|
|
Map<Integer, CsRecallConfigCommon> page2SizeIntervalMap = tempCache.computeIfAbsent(configKey, a -> new HashMap<>());
|
|
|
Map<Integer, Map<Integer, CsRecallConfigCommon>> configKey2PageIdConfigMap = tempCache.computeIfAbsent(configKey, a -> new HashMap<>());
|
|
|
|
|
|
//2、生成页面结果
|
|
|
int pageId = csRecallConfigCommon.getConfigPage();
|
|
|
page2SizeIntervalMap.put(pageId, csRecallConfigCommon);
|
|
|
Map<Integer, CsRecallConfigCommon> pageId2AbTypeConfigMap = configKey2PageIdConfigMap.computeIfAbsent(pageId, a -> new HashMap<>());
|
|
|
|
|
|
//3、生成ab结果
|
|
|
int abType = csRecallConfigCommon.getAbType();
|
|
|
pageId2AbTypeConfigMap.put(abType, csRecallConfigCommon);
|
|
|
}
|
|
|
|
|
|
/**
|
...
|
...
|
@@ -65,18 +71,19 @@ public class RecallConfigCommonService extends AbstractReloadEsCacheBean<CsRecal |
|
|
* @param configKey
|
|
|
* @return
|
|
|
*/
|
|
|
private CsRecallConfigCommon queryCsRecallConfigCommon(int pageId, boolean isDefaultOrder, String configKey) {
|
|
|
Map<Integer, CsRecallConfigCommon> pageConfigMap = this.getCache().get(configKey);
|
|
|
private CsRecallConfigCommon queryCsRecallConfigCommon(int pageId, boolean isDefaultOrder, String configKey, boolean isAUser) {
|
|
|
Map<Integer, Map<Integer, CsRecallConfigCommon>> pageConfigMap = this.getCache().get(configKey);
|
|
|
if (pageConfigMap == null) {
|
|
|
return null;
|
|
|
}
|
|
|
int configPageId = this.getConfigPage(pageId, isDefaultOrder);
|
|
|
int defaultConfigPageId = this.getDefaultConfigPage(isDefaultOrder);
|
|
|
CsRecallConfigCommon config = pageConfigMap.get(configPageId);
|
|
|
if (config == null) {
|
|
|
config = pageConfigMap.get(defaultConfigPageId);
|
|
|
Map<Integer, CsRecallConfigCommon> abTypeConfig = pageConfigMap.get(configPageId);
|
|
|
if (abTypeConfig == null) {
|
|
|
abTypeConfig = pageConfigMap.get(defaultConfigPageId);
|
|
|
}
|
|
|
return config;
|
|
|
Integer abType = isAUser ? 0 : 1;
|
|
|
return abTypeConfig.get(abType);
|
|
|
}
|
|
|
|
|
|
private int getConfigPage(int pageId, boolean isDefaultOrder) {
|
...
|
...
|
@@ -107,20 +114,14 @@ public class RecallConfigCommonService extends AbstractReloadEsCacheBean<CsRecal |
|
|
if (StringUtils.isBlank(configKey)) {
|
|
|
return defaultSize;
|
|
|
}
|
|
|
CsRecallConfigCommon stragetySize = queryCsRecallConfigCommon(pageId, isDefaultOrder, configKey);
|
|
|
CsRecallConfigCommon stragetySize = queryCsRecallConfigCommon(pageId, isDefaultOrder, configKey, isAUser);
|
|
|
if (stragetySize == null) {
|
|
|
return defaultSize;
|
|
|
}
|
|
|
if (isAUser && stragetySize.getAbType() == 2) {
|
|
|
return 0;
|
|
|
}
|
|
|
if (!isAUser && stragetySize.getAbType() == 1) {
|
|
|
return 0;
|
|
|
}
|
|
|
return stragetySize.getSize();
|
|
|
} catch (Exception e) {
|
|
|
RecallLoggerHelper.error(e.getMessage(), e);
|
|
|
return 0;
|
|
|
return defaultSize;
|
|
|
}
|
|
|
}
|
|
|
|
...
|
...
|
@@ -131,13 +132,13 @@ public class RecallConfigCommonService extends AbstractReloadEsCacheBean<CsRecal |
|
|
* @param isDefaultOrder
|
|
|
* @return
|
|
|
*/
|
|
|
public List<StragetyIntervalInfo> queryIntervalStrategyNames(int pageId, boolean isDefaultOrder) {
|
|
|
public List<StragetyIntervalInfo> queryIntervalStrategyNames(int pageId, boolean isDefaultOrder, boolean isAUser) {
|
|
|
try {
|
|
|
List<String> strageNameKeys = new ArrayList();
|
|
|
strageNameKeys.addAll(this.getCache().keySet());
|
|
|
List<StragetyIntervalInfo> result = new ArrayList<>();
|
|
|
for (String strageName : strageNameKeys) {
|
|
|
CsRecallConfigCommon common = queryCsRecallConfigCommon(pageId, isDefaultOrder, strageName);
|
|
|
CsRecallConfigCommon common = queryCsRecallConfigCommon(pageId, isDefaultOrder, strageName, isAUser);
|
|
|
if (common != null && common.getInterval() > 0) {
|
|
|
result.add(new StragetyIntervalInfo(common));
|
|
|
}
|
...
|
...
|
|