|
@@ -64,6 +64,9 @@ public class PredictModelServiceImpl implements PredictModelService {
|
|
|
@Value("${ad.predict.without.ad.video_ids:0}")
|
|
|
private String withoutAdVideoIds;
|
|
|
|
|
|
+ List<Integer> appIdArr=Arrays.asList(new Integer[]{0,3,4,5,6,17,18,19,21,22});
|
|
|
+
|
|
|
+
|
|
|
public Map<String, Object> adPredict(ThresholdPredictModelRequestParam requestParam) {
|
|
|
String[] withoutAdVideoIdsArr=withoutAdVideoIds.split(",");
|
|
|
for(String videoId:withoutAdVideoIdsArr){
|
|
@@ -81,8 +84,6 @@ public class PredictModelServiceImpl implements PredictModelService {
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //先判断是否开启实验 和是否不出广告时间 而后判断默认0-8
|
|
|
- //不出广告时间判定
|
|
|
Map<String,Object> result=new HashMap<>();
|
|
|
List<Map<String,Object>> mapList=(List)requestParam.getAbExpInfo().get("ab_test002");
|
|
|
Map<String,List<JSONObject>> configMap=new HashMap<>();
|
|
@@ -115,71 +116,86 @@ public class PredictModelServiceImpl implements PredictModelService {
|
|
|
result.put("no_ad_strategy", "no_ad_time_with_fixed_time");
|
|
|
return result;
|
|
|
}
|
|
|
-
|
|
|
- String[] abParamArr = abConfig.getAbParams(requestParam.getAbTestCode(), requestParam.getAbExpInfo());
|
|
|
- if (abParamArr == null) {
|
|
|
- abParamArr= NewExpUserGroupConfig.newExpUserGroupMap.get(requestParam.getAppType().toString());
|
|
|
+ String abtestId=null;
|
|
|
+ String abTestConfigTag=null;
|
|
|
+ Map<String, Object> abtestParam=null;
|
|
|
+ String midGroup =null;
|
|
|
+ String shareType =null;
|
|
|
+ if(appIdArr.contains(requestParam.getAppType())){
|
|
|
+ //先判断是否开启实验 和是否不出广告时间 而后判断默认0-8
|
|
|
+ //不出广告时间判定
|
|
|
+ String[] abParamArr = abConfig.getAbParams(requestParam.getAbTestCode(), requestParam.getAbExpInfo());
|
|
|
if (abParamArr == null) {
|
|
|
+ abParamArr= NewExpUserGroupConfig.newExpUserGroupMap.get(requestParam.getAppType().toString());
|
|
|
+ if (abParamArr == null) {
|
|
|
+ result.put("msg", "abConfig_error");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ abtestId = abParamArr[0];
|
|
|
+ abTestConfigTag = abParamArr[1];
|
|
|
+ HashMap<String, Map<String, Object>> abConfigMap = abConfig.getAbConfigMap();
|
|
|
+ abtestParam = abConfigMap.getOrDefault(abtestId + "-" + abTestConfigTag, null);
|
|
|
+ if (abtestParam == null) {
|
|
|
result.put("msg", "abConfig_error");
|
|
|
return result;
|
|
|
}
|
|
|
- }
|
|
|
- String abtestId = abParamArr[0];
|
|
|
- String abTestConfigTag = abParamArr[1];
|
|
|
-
|
|
|
- HashMap<String, Map<String, Object>> abConfigMap = abConfig.getAbConfigMap();
|
|
|
- Map<String, Object> abtestParam = abConfigMap.getOrDefault(abtestId + "-" + abTestConfigTag, null);
|
|
|
- if (abtestParam == null) {
|
|
|
- result.put("msg", "abConfig_error");
|
|
|
- return result;
|
|
|
- }
|
|
|
-
|
|
|
- // Determine the group to which mid belongs
|
|
|
- String groupClassKey = (String) abtestParam.get("group_class_key");
|
|
|
- String midGroupKeyName = RuleRedisKeyConst.KEY_NAME_PREFIX_MID_GROUP + groupClassKey + ":" + requestParam.getMid();
|
|
|
- String midGroup = redisHelper.getString(midGroupKeyName);;
|
|
|
+ // Determine the group to which mid belongs
|
|
|
+ String groupClassKey = (String) abtestParam.get("group_class_key");
|
|
|
+ String midGroupKeyName = RuleRedisKeyConst.KEY_NAME_PREFIX_MID_GROUP + groupClassKey + ":" + requestParam.getMid();
|
|
|
+ midGroup = redisHelper.getString(midGroupKeyName);
|
|
|
// if(expCodes.contains(adPredict90DNoShareUserExpCode)){
|
|
|
// midGroup = redisHelper.getString(RuleRedisKeyConst.KEY_NAME_PREFIX_90_SHARE_TYPE+requestParam.getMid());
|
|
|
// }else {
|
|
|
// midGroup = redisHelper.getString(midGroupKeyName);
|
|
|
// }
|
|
|
-
|
|
|
- //没有时为新用户或者无分享用户
|
|
|
- String shareType =midGroup;
|
|
|
- if (midGroup == null) {
|
|
|
- midGroup = "mean_group";
|
|
|
- shareType="noShare";
|
|
|
- }
|
|
|
- String[] noAdMidGroupList = new String[0];
|
|
|
- noAdMidGroupList = ((JSONArray) abtestParam.get("no_ad_mid_group_list")).toArray(noAdMidGroupList);
|
|
|
-
|
|
|
- boolean inNoAdGroup = false;
|
|
|
- for (String group : noAdMidGroupList) {
|
|
|
- if (group.equals(midGroup)) {
|
|
|
- inNoAdGroup = true;
|
|
|
- break;
|
|
|
+ //没有时为新用户或者无分享用户
|
|
|
+ shareType =midGroup;
|
|
|
+ if (midGroup == null) {
|
|
|
+ midGroup = "mean_group";
|
|
|
+ shareType="noShare";
|
|
|
+ }
|
|
|
+ String[] noAdMidGroupList = new String[0];
|
|
|
+ noAdMidGroupList = ((JSONArray) abtestParam.get("no_ad_mid_group_list")).toArray(noAdMidGroupList);
|
|
|
+
|
|
|
+ boolean inNoAdGroup = false;
|
|
|
+ for (String group : noAdMidGroupList) {
|
|
|
+ if (group.equals(midGroup)) {
|
|
|
+ inNoAdGroup = true;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //不出广告组
|
|
|
+ if (inNoAdGroup) {
|
|
|
+ // User is in the no-ad group, no ad should be shown
|
|
|
+ result.put("mid_group", midGroup);
|
|
|
+ result.put("ad_predict", 1);
|
|
|
+ result.put("no_ad_strategy", "no_ad_mid_group_with_video");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ //top1广告不出视频
|
|
|
+ Map<String, List<String>> noAdGroupWithVideoMapping = (Map) abtestParam.getOrDefault("no_ad_group_with_video_mapping", new HashMap<>());
|
|
|
+ if (noAdGroupWithVideoMapping.keySet().contains(midGroup)
|
|
|
+ &&
|
|
|
+ topOneVideoContainer.inNoAdTopVideo(requestParam.getAppType().longValue(), requestParam.getVideoId())
|
|
|
+ ) {
|
|
|
+ result.put("mid_group", midGroup);
|
|
|
+ result.put("ad_predict", 1);
|
|
|
+ result.put("no_ad_strategy", "no_ad_mid_group_with_video");
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ String midGroupKeyName = RuleRedisKeyConst.KEY_NAME_PREFIX_MID_GROUP + "class1:" + requestParam.getMid();
|
|
|
+ midGroup = redisHelper.getString(midGroupKeyName);
|
|
|
+ shareType =midGroup;
|
|
|
+ if (midGroup == null) {
|
|
|
+ midGroup = "mean_group";
|
|
|
+ shareType="noShare";
|
|
|
}
|
|
|
- }
|
|
|
- //不出广告组
|
|
|
- if (inNoAdGroup) {
|
|
|
- // User is in the no-ad group, no ad should be shown
|
|
|
- result.put("mid_group", midGroup);
|
|
|
- result.put("ad_predict", 1);
|
|
|
- result.put("no_ad_strategy", "no_ad_mid_group_with_video");
|
|
|
- return result;
|
|
|
}
|
|
|
|
|
|
- //top1广告不出视频
|
|
|
- Map<String, List<String>> noAdGroupWithVideoMapping = (Map) abtestParam.getOrDefault("no_ad_group_with_video_mapping", new HashMap<>());
|
|
|
- if (noAdGroupWithVideoMapping.keySet().contains(midGroup)
|
|
|
- &&
|
|
|
- topOneVideoContainer.inNoAdTopVideo(requestParam.getAppType().longValue(), requestParam.getVideoId())
|
|
|
- ) {
|
|
|
- result.put("mid_group", midGroup);
|
|
|
- result.put("ad_predict", 1);
|
|
|
- result.put("no_ad_strategy", "no_ad_mid_group_with_video");
|
|
|
- return result;
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
//市-中文
|
|
|
requestParam.setRegion(requestParam.getRegion().replace("省", ""));
|
|
|
requestParam.setCity(requestParam.getCity().replace("市", ""));
|