|
@@ -5,15 +5,14 @@ import com.alibaba.fastjson.JSONObject;
|
|
import com.tzld.piaoquan.ad.engine.commons.enums.AppTypeEnum;
|
|
import com.tzld.piaoquan.ad.engine.commons.enums.AppTypeEnum;
|
|
import com.tzld.piaoquan.ad.engine.commons.redis.AlgorithmRedisHelper;
|
|
import com.tzld.piaoquan.ad.engine.commons.redis.AlgorithmRedisHelper;
|
|
import com.tzld.piaoquan.ad.engine.commons.util.DateUtils;
|
|
import com.tzld.piaoquan.ad.engine.commons.util.DateUtils;
|
|
-import com.tzld.piaoquan.ad.engine.service.predict.config.RoiModelConfig;
|
|
|
|
-import com.tzld.piaoquan.ad.engine.service.predict.constant.RuleRedisKeyConst;
|
|
|
|
import com.tzld.piaoquan.ad.engine.service.predict.PredictModelService;
|
|
import com.tzld.piaoquan.ad.engine.service.predict.PredictModelService;
|
|
import com.tzld.piaoquan.ad.engine.service.predict.config.AbConfig;
|
|
import com.tzld.piaoquan.ad.engine.service.predict.config.AbConfig;
|
|
|
|
+import com.tzld.piaoquan.ad.engine.service.predict.config.RoiModelConfig;
|
|
|
|
+import com.tzld.piaoquan.ad.engine.service.predict.constant.RuleRedisKeyConst;
|
|
import com.tzld.piaoquan.ad.engine.service.predict.container.AbTestConfigContainer;
|
|
import com.tzld.piaoquan.ad.engine.service.predict.container.AbTestConfigContainer;
|
|
import com.tzld.piaoquan.ad.engine.service.predict.container.ThresholdModelContainer;
|
|
import com.tzld.piaoquan.ad.engine.service.predict.container.ThresholdModelContainer;
|
|
import com.tzld.piaoquan.ad.engine.service.predict.container.TopOneVideoContainer;
|
|
import com.tzld.piaoquan.ad.engine.service.predict.container.TopOneVideoContainer;
|
|
import com.tzld.piaoquan.ad.engine.service.predict.param.RoiThresholdPredictModelParam;
|
|
import com.tzld.piaoquan.ad.engine.service.predict.param.RoiThresholdPredictModelParam;
|
|
-import com.tzld.piaoquan.ad.engine.service.predict.param.RuleParamHelper;
|
|
|
|
import com.tzld.piaoquan.ad.engine.service.predict.param.ThresholdPredictModelParam;
|
|
import com.tzld.piaoquan.ad.engine.service.predict.param.ThresholdPredictModelParam;
|
|
import com.tzld.piaoquan.ad.engine.service.predict.param.request.RoiPredictModelRequestParam;
|
|
import com.tzld.piaoquan.ad.engine.service.predict.param.request.RoiPredictModelRequestParam;
|
|
import com.tzld.piaoquan.ad.engine.service.predict.param.request.ThresholdPredictModelRequestParam;
|
|
import com.tzld.piaoquan.ad.engine.service.predict.param.request.ThresholdPredictModelRequestParam;
|
|
@@ -24,7 +23,10 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
-import java.util.*;
|
|
|
|
|
|
+import java.util.Date;
|
|
|
|
+import java.util.HashMap;
|
|
|
|
+import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
@Service
|
|
@Service
|
|
public class PredictModelServiceImpl implements PredictModelService {
|
|
public class PredictModelServiceImpl implements PredictModelService {
|
|
@@ -47,38 +49,6 @@ public class PredictModelServiceImpl implements PredictModelService {
|
|
@Autowired
|
|
@Autowired
|
|
RoiModelConfig roiModelConfig;
|
|
RoiModelConfig roiModelConfig;
|
|
|
|
|
|
-<<<<<<< HEAD
|
|
|
|
- public Map<String,Object> adPredict(ThresholdPredictModelRequestParam requestParam){
|
|
|
|
-
|
|
|
|
- JSONObject object=requestParam.getAbExpInfo();
|
|
|
|
- //先判断是否开启实验 和是否不出广告时间 而后判断默认0-8
|
|
|
|
- Map<String,Object> result=new HashMap<>();
|
|
|
|
- int hourOfDay= DateUtils.getCurrentHour();
|
|
|
|
- Boolean condition1=abTestConfigContainer.inAdTimeTest(requestParam.getAbExpInfo());
|
|
|
|
- Boolean condition2=abTestConfigContainer.containsCode(requestParam.getAbTestCode());
|
|
|
|
- if(condition1
|
|
|
|
- &&
|
|
|
|
- condition2
|
|
|
|
- &&
|
|
|
|
- abTestConfigContainer.inWithoutAdTime(requestParam.getAbTestCode(),hourOfDay)){
|
|
|
|
- result.put("ad_predict", 1);
|
|
|
|
- result.put("no_ad_strategy","no_ad_time_with_time_plan");
|
|
|
|
- return result;
|
|
|
|
- }else if(
|
|
|
|
- (!condition1 ||(condition1&&!condition2))
|
|
|
|
- &&
|
|
|
|
- (0<=hourOfDay&&hourOfDay<8)){
|
|
|
|
- result.put("ad_predict", 1);
|
|
|
|
- result.put("no_ad_strategy","no_ad_time_with_fixed_time");
|
|
|
|
- return result;
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- String[] abParamArr=abConfig.getAbParams(requestParam.getAbTestCode(),requestParam.getAbExpInfo());
|
|
|
|
- if(abParamArr==null){
|
|
|
|
- result.put("msg","abConfig_error");
|
|
|
|
-=======
|
|
|
|
@Value("${ad.predict.break.switch:false}")
|
|
@Value("${ad.predict.break.switch:false}")
|
|
private boolean adPredictBreakSwitch;
|
|
private boolean adPredictBreakSwitch;
|
|
|
|
|
|
@@ -91,19 +61,33 @@ public class PredictModelServiceImpl implements PredictModelService {
|
|
}
|
|
}
|
|
|
|
|
|
public Map<String, Object> adPredictNew(ThresholdPredictModelRequestParam requestParam) {
|
|
public Map<String, Object> adPredictNew(ThresholdPredictModelRequestParam requestParam) {
|
|
-//0-8不出广告
|
|
|
|
|
|
+ JSONObject object = requestParam.getAbExpInfo();
|
|
|
|
+ //先判断是否开启实验 和是否不出广告时间 而后判断默认0-8
|
|
Map<String, Object> result = new HashMap<>();
|
|
Map<String, Object> result = new HashMap<>();
|
|
int hourOfDay = DateUtils.getCurrentHour();
|
|
int hourOfDay = DateUtils.getCurrentHour();
|
|
- if (hourOfDay < 8 && hourOfDay >= 0) {
|
|
|
|
|
|
+ Boolean condition1 = abTestConfigContainer.inAdTimeTest(requestParam.getAbExpInfo());
|
|
|
|
+ Boolean condition2 = abTestConfigContainer.containsCode(requestParam.getAbTestCode());
|
|
|
|
+ if (condition1
|
|
|
|
+ &&
|
|
|
|
+ condition2
|
|
|
|
+ &&
|
|
|
|
+ abTestConfigContainer.inWithoutAdTime(requestParam.getAbTestCode(), hourOfDay)) {
|
|
result.put("ad_predict", 1);
|
|
result.put("ad_predict", 1);
|
|
- result.put("no_ad_strategy", "no_ad_time");
|
|
|
|
|
|
+ result.put("no_ad_strategy", "no_ad_time_with_time_plan");
|
|
|
|
+ return result;
|
|
|
|
+ } else if (
|
|
|
|
+ (!condition1 || (condition1 && !condition2))
|
|
|
|
+ &&
|
|
|
|
+ (0 <= hourOfDay && hourOfDay < 8)) {
|
|
|
|
+ result.put("ad_predict", 1);
|
|
|
|
+ result.put("no_ad_strategy", "no_ad_time_with_fixed_time");
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
String[] abParamArr = abConfig.getAbParams(requestParam.getAbTestCode(), requestParam.getAbExpInfo());
|
|
String[] abParamArr = abConfig.getAbParams(requestParam.getAbTestCode(), requestParam.getAbExpInfo());
|
|
if (abParamArr == null) {
|
|
if (abParamArr == null) {
|
|
result.put("msg", "abConfig_error");
|
|
result.put("msg", "abConfig_error");
|
|
->>>>>>> 543b435 (str rov model)
|
|
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
String abtestId = abParamArr[0];
|
|
String abtestId = abParamArr[0];
|
|
@@ -128,14 +112,9 @@ public class PredictModelServiceImpl implements PredictModelService {
|
|
midGroup = "mean_group";
|
|
midGroup = "mean_group";
|
|
}
|
|
}
|
|
|
|
|
|
-<<<<<<< HEAD
|
|
|
|
- String[] noAdMidGroupList=new String[0];
|
|
|
|
- noAdMidGroupList=((JSONArray) abtestParam.get("no_ad_mid_group_list")).toArray(noAdMidGroupList);
|
|
|
|
-
|
|
|
|
-=======
|
|
|
|
String[] noAdMidGroupList = new String[0];
|
|
String[] noAdMidGroupList = new String[0];
|
|
noAdMidGroupList = ((JSONArray) abtestParam.get("no_ad_mid_group_list")).toArray(noAdMidGroupList);
|
|
noAdMidGroupList = ((JSONArray) abtestParam.get("no_ad_mid_group_list")).toArray(noAdMidGroupList);
|
|
->>>>>>> 543b435 (str rov model)
|
|
|
|
|
|
+
|
|
boolean inNoAdGroup = false;
|
|
boolean inNoAdGroup = false;
|
|
for (String group : noAdMidGroupList) {
|
|
for (String group : noAdMidGroupList) {
|
|
if (group.equals(midGroup)) {
|
|
if (group.equals(midGroup)) {
|
|
@@ -153,14 +132,14 @@ public class PredictModelServiceImpl implements PredictModelService {
|
|
}
|
|
}
|
|
|
|
|
|
//top1广告不出视频
|
|
//top1广告不出视频
|
|
- Map<String,List<String>> noAdGroupWithVideoMapping=(Map) abtestParam.getOrDefault("no_ad_group_with_video_mapping",new HashMap<>());
|
|
|
|
- if(noAdGroupWithVideoMapping.keySet().contains(midGroup)
|
|
|
|
|
|
+ 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())
|
|
|
|
- ){
|
|
|
|
|
|
+ topOneVideoContainer.inNoAdTopVideo(requestParam.getAppType().longValue(), requestParam.getVideoId())
|
|
|
|
+ ) {
|
|
result.put("mid_group", midGroup);
|
|
result.put("mid_group", midGroup);
|
|
result.put("ad_predict", 1);
|
|
result.put("ad_predict", 1);
|
|
- result.put("no_ad_strategy","no_ad_mid_group_with_video");
|
|
|
|
|
|
+ result.put("no_ad_strategy", "no_ad_mid_group_with_video");
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -173,10 +152,6 @@ public class PredictModelServiceImpl implements PredictModelService {
|
|
modelParam.setAbTestConfigTag(abTestConfigTag);
|
|
modelParam.setAbTestConfigTag(abTestConfigTag);
|
|
modelParam.setAbtestParam(abtestParam);
|
|
modelParam.setAbtestParam(abtestParam);
|
|
modelParam.setMidGroup(midGroup);
|
|
modelParam.setMidGroup(midGroup);
|
|
-<<<<<<< HEAD
|
|
|
|
- Object thresholdMixFunc=abtestParam.getOrDefault("threshold_mix_func","basic");
|
|
|
|
- result= ThresholdModelContainer.
|
|
|
|
-=======
|
|
|
|
result = ThresholdModelContainer.
|
|
result = ThresholdModelContainer.
|
|
getThresholdPredictModel("modelV2")
|
|
getThresholdPredictModel("modelV2")
|
|
.predict(modelParam);
|
|
.predict(modelParam);
|
|
@@ -185,15 +160,31 @@ public class PredictModelServiceImpl implements PredictModelService {
|
|
}
|
|
}
|
|
|
|
|
|
public Map<String, Object> adPredictOld(ThresholdPredictModelRequestParam requestParam) {
|
|
public Map<String, Object> adPredictOld(ThresholdPredictModelRequestParam requestParam) {
|
|
- //0-8不出广告
|
|
|
|
|
|
+
|
|
|
|
+ JSONObject object = requestParam.getAbExpInfo();
|
|
|
|
+ //先判断是否开启实验 和是否不出广告时间 而后判断默认0-8
|
|
Map<String, Object> result = new HashMap<>();
|
|
Map<String, Object> result = new HashMap<>();
|
|
int hourOfDay = DateUtils.getCurrentHour();
|
|
int hourOfDay = DateUtils.getCurrentHour();
|
|
- if (hourOfDay < 8 && hourOfDay >= 0) {
|
|
|
|
|
|
+ Boolean condition1 = abTestConfigContainer.inAdTimeTest(requestParam.getAbExpInfo());
|
|
|
|
+ Boolean condition2 = abTestConfigContainer.containsCode(requestParam.getAbTestCode());
|
|
|
|
+ if (condition1
|
|
|
|
+ &&
|
|
|
|
+ condition2
|
|
|
|
+ &&
|
|
|
|
+ abTestConfigContainer.inWithoutAdTime(requestParam.getAbTestCode(), hourOfDay)) {
|
|
result.put("ad_predict", 1);
|
|
result.put("ad_predict", 1);
|
|
- result.put("no_ad_strategy", "no_ad_time");
|
|
|
|
|
|
+ result.put("no_ad_strategy", "no_ad_time_with_time_plan");
|
|
|
|
+ return result;
|
|
|
|
+ } else if (
|
|
|
|
+ (!condition1 || (condition1 && !condition2))
|
|
|
|
+ &&
|
|
|
|
+ (0 <= hourOfDay && hourOfDay < 8)) {
|
|
|
|
+ result.put("ad_predict", 1);
|
|
|
|
+ result.put("no_ad_strategy", "no_ad_time_with_fixed_time");
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+
|
|
String[] abParamArr = abConfig.getAbParams(requestParam.getAbTestCode(), requestParam.getAbExpInfo());
|
|
String[] abParamArr = abConfig.getAbParams(requestParam.getAbTestCode(), requestParam.getAbExpInfo());
|
|
if (abParamArr == null) {
|
|
if (abParamArr == null) {
|
|
result.put("msg", "abConfig_error");
|
|
result.put("msg", "abConfig_error");
|
|
@@ -223,6 +214,7 @@ public class PredictModelServiceImpl implements PredictModelService {
|
|
|
|
|
|
String[] noAdMidGroupList = new String[0];
|
|
String[] noAdMidGroupList = new String[0];
|
|
noAdMidGroupList = ((JSONArray) abtestParam.get("no_ad_mid_group_list")).toArray(noAdMidGroupList);
|
|
noAdMidGroupList = ((JSONArray) abtestParam.get("no_ad_mid_group_list")).toArray(noAdMidGroupList);
|
|
|
|
+
|
|
boolean inNoAdGroup = false;
|
|
boolean inNoAdGroup = false;
|
|
for (String group : noAdMidGroupList) {
|
|
for (String group : noAdMidGroupList) {
|
|
if (group.equals(midGroup)) {
|
|
if (group.equals(midGroup)) {
|
|
@@ -239,6 +231,18 @@ public class PredictModelServiceImpl implements PredictModelService {
|
|
return result;
|
|
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;
|
|
|
|
+ }
|
|
|
|
+
|
|
//设置信息
|
|
//设置信息
|
|
ThresholdPredictModelParam modelParam = ThresholdPredictModelParam.builder()
|
|
ThresholdPredictModelParam modelParam = ThresholdPredictModelParam.builder()
|
|
.build();
|
|
.build();
|
|
@@ -248,28 +252,19 @@ public class PredictModelServiceImpl implements PredictModelService {
|
|
modelParam.setAbTestConfigTag(abTestConfigTag);
|
|
modelParam.setAbTestConfigTag(abTestConfigTag);
|
|
modelParam.setAbtestParam(abtestParam);
|
|
modelParam.setAbtestParam(abtestParam);
|
|
modelParam.setMidGroup(midGroup);
|
|
modelParam.setMidGroup(midGroup);
|
|
- Object thresholdMixFunc = abtestParam.getOrDefault("threshold_mix_func", "default");
|
|
|
|
|
|
+ Object thresholdMixFunc = abtestParam.getOrDefault("threshold_mix_func", "basic");
|
|
result = ThresholdModelContainer.
|
|
result = ThresholdModelContainer.
|
|
->>>>>>> 543b435 (str rov model)
|
|
|
|
getThresholdPredictModel(thresholdMixFunc.toString())
|
|
getThresholdPredictModel(thresholdMixFunc.toString())
|
|
.predict(modelParam);
|
|
.predict(modelParam);
|
|
|
|
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
-<<<<<<< HEAD
|
|
|
|
- public Map<String,Object> adRecommendPredictByRoiModel(RoiPredictModelRequestParam requestParam){
|
|
|
|
-
|
|
|
|
- Map<String,Object> result=new HashMap<>();
|
|
|
|
- int hourOfDay= DateUtils.getCurrentHour();
|
|
|
|
- if(hourOfDay<8&&hourOfDay>=0){
|
|
|
|
-=======
|
|
|
|
public Map<String, Object> adRecommendPredictByRoiModel(RoiPredictModelRequestParam requestParam) {
|
|
public Map<String, Object> adRecommendPredictByRoiModel(RoiPredictModelRequestParam requestParam) {
|
|
- //0-8不出广告
|
|
|
|
|
|
+
|
|
Map<String, Object> result = new HashMap<>();
|
|
Map<String, Object> result = new HashMap<>();
|
|
int hourOfDay = DateUtils.getCurrentHour();
|
|
int hourOfDay = DateUtils.getCurrentHour();
|
|
if (hourOfDay < 8 && hourOfDay >= 0) {
|
|
if (hourOfDay < 8 && hourOfDay >= 0) {
|
|
->>>>>>> 543b435 (str rov model)
|
|
|
|
result.put("ad_predict", 1);
|
|
result.put("ad_predict", 1);
|
|
result.put("no_ad_strategy", "no_ad_time");
|
|
result.put("no_ad_strategy", "no_ad_time");
|
|
return result;
|
|
return result;
|