|
@@ -2,7 +2,6 @@ package com.tzld.piaoquan.recommend.server.service;
|
|
|
|
|
|
import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
|
|
import com.ctrip.framework.apollo.spring.annotation.ApolloJsonValue;
|
|
import com.google.common.base.Strings;
|
|
import com.google.common.base.Strings;
|
|
-import com.google.common.reflect.TypeToken;
|
|
|
|
import com.tzld.piaoquan.recommend.server.common.enums.AppTypeEnum;
|
|
import com.tzld.piaoquan.recommend.server.common.enums.AppTypeEnum;
|
|
import com.tzld.piaoquan.recommend.server.gen.common.Result;
|
|
import com.tzld.piaoquan.recommend.server.gen.common.Result;
|
|
import com.tzld.piaoquan.recommend.server.gen.recommend.RecommendRequest;
|
|
import com.tzld.piaoquan.recommend.server.gen.recommend.RecommendRequest;
|
|
@@ -26,7 +25,6 @@ import com.tzld.piaoquan.recommend.server.service.recall.strategy.RegionRelative
|
|
import com.tzld.piaoquan.recommend.server.util.DateUtils;
|
|
import com.tzld.piaoquan.recommend.server.util.DateUtils;
|
|
import com.tzld.piaoquan.recommend.server.util.JSONUtils;
|
|
import com.tzld.piaoquan.recommend.server.util.JSONUtils;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
import lombok.extern.slf4j.Slf4j;
|
|
-import org.apache.commons.collections4.MapUtils;
|
|
|
|
import org.apache.commons.lang3.RandomUtils;
|
|
import org.apache.commons.lang3.RandomUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.apache.commons.lang3.StringUtils;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -99,7 +97,7 @@ public class RecommendService {
|
|
&& redisTemplate.opsForSet().isMember("special:mid", request.getMid())) {
|
|
&& redisTemplate.opsForSet().isMember("special:mid", request.getMid())) {
|
|
return specialMidRecommend(request);
|
|
return specialMidRecommend(request);
|
|
}
|
|
}
|
|
- RecommendParam param = genRecommendParam(request, 0);
|
|
|
|
|
|
+ RecommendParam param = genRecommendParam(request, recommendType);
|
|
log.info("genRecommendParam : {}", JSONUtils.toJson(param));
|
|
log.info("genRecommendParam : {}", JSONUtils.toJson(param));
|
|
|
|
|
|
List<Video> videos = videoRecommend(param);
|
|
List<Video> videos = videoRecommend(param);
|
|
@@ -190,15 +188,8 @@ public class RecommendService {
|
|
param.setUid(request.getUid());
|
|
param.setUid(request.getUid());
|
|
param.setSize(request.getSize());
|
|
param.setSize(request.getSize());
|
|
param.setVideoId(request.getVideoId());
|
|
param.setVideoId(request.getVideoId());
|
|
-
|
|
|
|
- // client_info: {"cityCode": "", "provinceCode": "330000"}
|
|
|
|
- if (StringUtils.isNotBlank(request.getClientInfo())) {
|
|
|
|
- Map<String, String> clientInfoMap = JSONUtils.fromJson(request.getClientInfo(),
|
|
|
|
- new TypeToken<Map<String, String>>() {
|
|
|
|
- }, Collections.emptyMap());
|
|
|
|
- param.setCityCode(clientInfoMap.get("cityCode"));
|
|
|
|
- param.setProvinceCode(clientInfoMap.get("provinceCode"));
|
|
|
|
- }
|
|
|
|
|
|
+ param.setCityCode(request.getCityCode());
|
|
|
|
+ param.setProvinceCode(request.getProvinceCode());
|
|
|
|
|
|
String abInitialConfig = ab_initial_config_map.getOrDefault(request.getAppType(), "095-1");
|
|
String abInitialConfig = ab_initial_config_map.getOrDefault(request.getAppType(), "095-1");
|
|
Map<String, String> abExpCode = abExpCodeMap.get(abInitialConfig);
|
|
Map<String, String> abExpCode = abExpCodeMap.get(abInitialConfig);
|
|
@@ -208,16 +199,8 @@ public class RecommendService {
|
|
param.setRankKeyPrefix("rank:score1:");
|
|
param.setRankKeyPrefix("rank:score1:");
|
|
|
|
|
|
// 实验配置
|
|
// 实验配置
|
|
- if (StringUtils.isNotBlank(request.getAbExpInfo())) {
|
|
|
|
- Set<String> abExpCodes = new HashSet<>();
|
|
|
|
- Map<String, List<Map<String, String>>> map = JSONUtils.fromJson(request.getAbExpInfo(),
|
|
|
|
- new TypeToken<Map<String, List<Map<String, String>>>>() {
|
|
|
|
- },
|
|
|
|
- Collections.emptyMap());
|
|
|
|
- for (List<Map<String, String>> list : map.values()) {
|
|
|
|
- list.stream().forEach(m -> abExpCodes.add(m.get("abExpCode")));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ if (request.getAbExpCodeCount() > 0) {
|
|
|
|
+ Set<String> abExpCodes = request.getAbExpCodeList().stream().collect(Collectors.toSet());
|
|
// 流量池视频分发概率
|
|
// 流量池视频分发概率
|
|
if (abExpCodes.contains("211")) {
|
|
if (abExpCodes.contains("211")) {
|
|
param.setFlowPoolP(0.9);
|
|
param.setFlowPoolP(0.9);
|
|
@@ -247,24 +230,9 @@ public class RecommendService {
|
|
}
|
|
}
|
|
|
|
|
|
// app实验组
|
|
// app实验组
|
|
- // {"10018":{"eventId":"100182","ifAddedRootEventId":true},"10020":{"eventId":"100201","ifAddedRootEventId":true}}
|
|
|
|
- if (StringUtils.isNotBlank(request.getAbInfoData())) {
|
|
|
|
- Map<String, String> abInfoAppMap = new HashMap<>();
|
|
|
|
- Map<String, Map<String, String>> map = JSONUtils.fromJson(request.getAbInfoData(),
|
|
|
|
- new TypeToken<Map<String, Map<String, String>>>() {
|
|
|
|
- },
|
|
|
|
- Collections.emptyMap());
|
|
|
|
- for (Map.Entry<String, Map<String, String>> entry : map.entrySet()) {
|
|
|
|
- if (MapUtils.isEmpty(entry.getValue())) {
|
|
|
|
- continue;
|
|
|
|
- }
|
|
|
|
- String eventId = entry.getValue().get("eventId");
|
|
|
|
- if (StringUtils.isNotBlank(eventId)) {
|
|
|
|
- abInfoAppMap.put(entry.getKey(), eventId);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
|
|
+ if (request.getEventIdCount() > 0) {
|
|
if (recommendType == 0) {
|
|
if (recommendType == 0) {
|
|
- String eventId = abInfoAppMap.get("10003");
|
|
|
|
|
|
+ String eventId = request.getEventIdMap().get("10003");
|
|
Map<String, Map<String, String>> appAbCode = appAbCodeMap.get("10003");
|
|
Map<String, Map<String, String>> appAbCode = appAbCodeMap.get("10003");
|
|
if (StringUtils.isNotBlank(eventId) && appAbCode.containsKey(eventId)) {
|
|
if (StringUtils.isNotBlank(eventId) && appAbCode.containsKey(eventId)) {
|
|
param.setAbCode(appAbCode.get(eventId).get("ab_code"));
|
|
param.setAbCode(appAbCode.get(eventId).get("ab_code"));
|
|
@@ -272,19 +240,15 @@ public class RecommendService {
|
|
param.setDataKey(appAbCode.get(eventId).get("data_key"));
|
|
param.setDataKey(appAbCode.get(eventId).get("data_key"));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ }
|
|
|
|
|
|
- // 流量池分发实验组划分
|
|
|
|
- int flowPoolIdChoice = flowPoolIdList[RandomUtils.nextInt(0, flowPoolIdList.length - 1)];
|
|
|
|
- param.setFlowPoolAbtestGroup("control_group");
|
|
|
|
- try {
|
|
|
|
- Map<String, List<Integer>> flowPoolConfig = flowPoolConfigService.getFlowPoolConfig();
|
|
|
|
- for (Map.Entry<String, List<Integer>> entry : flowPoolConfig.entrySet()) {
|
|
|
|
- if (entry.getValue().contains(flowPoolIdChoice)) {
|
|
|
|
- param.setFlowPoolAbtestGroup(entry.getKey());
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
- } catch (Exception e) {
|
|
|
|
- log.error("flowPoolConfigCache get error", e);
|
|
|
|
|
|
+ // 流量池分发实验组划分
|
|
|
|
+ int flowPoolIdChoice = flowPoolIdList[RandomUtils.nextInt(0, flowPoolIdList.length - 1)];
|
|
|
|
+ param.setFlowPoolAbtestGroup("control_group");
|
|
|
|
+ Map<String, List<Integer>> flowPoolConfig = flowPoolConfigService.getFlowPoolConfig();
|
|
|
|
+ for (Map.Entry<String, List<Integer>> entry : flowPoolConfig.entrySet()) {
|
|
|
|
+ if (entry.getValue().contains(flowPoolIdChoice)) {
|
|
|
|
+ param.setFlowPoolAbtestGroup(entry.getKey());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|