|
|
@@ -1,9 +1,11 @@
|
|
|
package com.tzld.piaoquan.recommend.server.service.rank;
|
|
|
|
|
|
+import com.tzld.piaoquan.recommend.server.model.RootSessionIdExpConfig;
|
|
|
import com.tzld.piaoquan.recommend.server.service.ServiceBeanFactory;
|
|
|
import com.tzld.piaoquan.recommend.server.service.rank.strategy.*;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@@ -13,6 +15,10 @@ import java.util.*;
|
|
|
@Service
|
|
|
@Slf4j
|
|
|
public class RankRouter {
|
|
|
+
|
|
|
+ @Value("${root.session.id.exp.config:[]}")
|
|
|
+ private List<RootSessionIdExpConfig> rootSessionIdExpConfigs;
|
|
|
+
|
|
|
@Value("${rank.strategy.default:567}")
|
|
|
private String rankStrategyDefault;
|
|
|
|
|
|
@@ -51,11 +57,17 @@ public class RankRouter {
|
|
|
return strategyMap.get(relevantRank).rank(param);
|
|
|
}
|
|
|
|
|
|
+ // 裂变层实验,使用RootSessionId尾号进行实验
|
|
|
+ String rootSessionIdExpCode = this.findRootSessionIdExpCode(param);
|
|
|
+ if (StringUtils.isNotBlank(rootSessionIdExpCode) && strategyMap.containsKey(rootSessionIdExpCode)) {
|
|
|
+ return strategyMap.get(rootSessionIdExpCode).rank(param);
|
|
|
+ }
|
|
|
+
|
|
|
Set<String> abExpCodes = param.getAbExpCodes();
|
|
|
if (CollectionUtils.isNotEmpty(abExpCodes)) {
|
|
|
for (Map.Entry<String, RankService> entry : strategyMap.entrySet()) {
|
|
|
if (abExpCodes.contains(entry.getKey())) {
|
|
|
- //log.info("rank strategies {} {}", entry.getKey(), entry.getValue().getClass().getSimpleName());
|
|
|
+ // log.info("rank strategies {} {}", entry.getKey(), entry.getValue().getClass().getSimpleName());
|
|
|
return entry.getValue().rank(param);
|
|
|
}
|
|
|
}
|
|
|
@@ -74,5 +86,28 @@ public class RankRouter {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private String findRootSessionIdExpCode(RankParam param) {
|
|
|
+ String expCode = "";
|
|
|
+ if (CollectionUtils.isEmpty(rootSessionIdExpConfigs)) {
|
|
|
+ return expCode;
|
|
|
+ }
|
|
|
+
|
|
|
+ String rootSessionId = param.getRootSessionId();
|
|
|
+ if (StringUtils.isBlank(rootSessionId)) {
|
|
|
+ return expCode;
|
|
|
+ }
|
|
|
+
|
|
|
+ int appType = param.getAppType();
|
|
|
+ String tail = rootSessionId.substring(rootSessionId.length() - 1);
|
|
|
+ for (RootSessionIdExpConfig config : rootSessionIdExpConfigs) {
|
|
|
+ if (config.getAppType().contains(appType)
|
|
|
+ && config.getTail().contains(tail)
|
|
|
+ && strategyMap.containsKey(config.getExpCode())) {
|
|
|
+ return config.getExpCode();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ return expCode;
|
|
|
+ }
|
|
|
}
|
|
|
|