|
@@ -3,12 +3,9 @@ package com.tzld.piaoquan.ad.engine.service.predict.impl;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.TypeReference;
|
|
import com.alibaba.fastjson.TypeReference;
|
|
-import com.google.common.reflect.TypeToken;
|
|
|
|
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.commons.util.JSONUtils;
|
|
|
|
-import com.tzld.piaoquan.ad.engine.commons.util.TimerWatchUtil;
|
|
|
|
import com.tzld.piaoquan.ad.engine.service.predict.config.RoiModelConfig;
|
|
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.constant.RuleRedisKeyConst;
|
|
import com.tzld.piaoquan.ad.engine.service.predict.PredictModelService;
|
|
import com.tzld.piaoquan.ad.engine.service.predict.PredictModelService;
|
|
@@ -65,7 +62,6 @@ public class PredictModelServiceImpl implements PredictModelService {
|
|
private String withoutAdVideoIds;
|
|
private String withoutAdVideoIds;
|
|
|
|
|
|
public Map<String, Object> adPredict(ThresholdPredictModelRequestParam requestParam) {
|
|
public Map<String, Object> adPredict(ThresholdPredictModelRequestParam requestParam) {
|
|
-
|
|
|
|
String[] withoutAdVideoIdsArr=withoutAdVideoIds.split(",");
|
|
String[] withoutAdVideoIdsArr=withoutAdVideoIds.split(",");
|
|
for(String videoId:withoutAdVideoIdsArr){
|
|
for(String videoId:withoutAdVideoIdsArr){
|
|
if(videoId.equals(requestParam.getVideoId()+"")){
|
|
if(videoId.equals(requestParam.getVideoId()+"")){
|
|
@@ -90,6 +86,7 @@ public class PredictModelServiceImpl implements PredictModelService {
|
|
//该用户所有实验合集
|
|
//该用户所有实验合集
|
|
Set<String> expCodes=new HashSet<>();
|
|
Set<String> expCodes=new HashSet<>();
|
|
boolean isHit = false;
|
|
boolean isHit = false;
|
|
|
|
+// String randomModelExpCode=null;
|
|
for(Map<String,Object> map:mapList){
|
|
for(Map<String,Object> map:mapList){
|
|
String expCode=map.getOrDefault("abExpCode","").toString();
|
|
String expCode=map.getOrDefault("abExpCode","").toString();
|
|
expCodes.add(expCode);
|
|
expCodes.add(expCode);
|
|
@@ -100,6 +97,9 @@ public class PredictModelServiceImpl implements PredictModelService {
|
|
if (StringUtils.equals(expCode, adPredictBreakExpCode)) {
|
|
if (StringUtils.equals(expCode, adPredictBreakExpCode)) {
|
|
isHit = true;
|
|
isHit = true;
|
|
}
|
|
}
|
|
|
|
+// if(ExpCodeEnum.EXP_599.getCode().equals(expCode)||ExpCodeEnum.EXP_600.getCode().equals(expCode)){
|
|
|
|
+// randomModelExpCode=expCode;
|
|
|
|
+// }
|
|
}
|
|
}
|
|
|
|
|
|
int hourOfDay= DateUtils.getCurrentHour();
|
|
int hourOfDay= DateUtils.getCurrentHour();
|
|
@@ -122,27 +122,6 @@ public class PredictModelServiceImpl implements PredictModelService {
|
|
return result;
|
|
return result;
|
|
}
|
|
}
|
|
|
|
|
|
- //人群选择算法判定-570
|
|
|
|
-// try {
|
|
|
|
-// JSONObject object = requestParam.getAbExpInfo();
|
|
|
|
-// if (object != null) {
|
|
|
|
-// JSONArray array = object.getJSONArray("ab_test002");
|
|
|
|
-// if (array != null) {
|
|
|
|
-// List<Map<String, String>> abExps = JSONUtils.fromJson(array.toJSONString(),
|
|
|
|
-// new TypeToken<List<Map<String, String>>>() {
|
|
|
|
-// }, Collections.emptyList());
|
|
|
|
-// for (Map<String, String> abExpMap : abExps) {
|
|
|
|
-// if (StringUtils.equals(abExpMap.get("abExpCode"), adPredictBreakExpCode)) {
|
|
|
|
-// isHit = true;
|
|
|
|
-// break;
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
-// } catch (Exception e) {
|
|
|
|
-// log.error("adPredict hit error", e);
|
|
|
|
-// }
|
|
|
|
-
|
|
|
|
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");
|
|
@@ -150,12 +129,12 @@ public class PredictModelServiceImpl implements PredictModelService {
|
|
}
|
|
}
|
|
String abtestId = abParamArr[0];
|
|
String abtestId = abParamArr[0];
|
|
String abTestConfigTag = abParamArr[1];
|
|
String abTestConfigTag = abParamArr[1];
|
|
- if("173".equals(abtestId)&&(requestParam.getAbTestCode().equals("ab3")||requestParam.getAbTestCode().equals("ab4"))){
|
|
|
|
- requestParam.setAbTestCode("ab5");
|
|
|
|
- }
|
|
|
|
- if("243".equals(abtestId)&&(requestParam.getAbTestCode().equals("ab1")||requestParam.getAbTestCode().equals("ab2")||requestParam.getAbTestCode().equals("ab3"))){
|
|
|
|
- requestParam.setAbTestCode("ab5");
|
|
|
|
- }
|
|
|
|
|
|
+// if("173".equals(abtestId)&&(requestParam.getAbTestCode().equals("ab3")||requestParam.getAbTestCode().equals("ab4"))){
|
|
|
|
+// requestParam.setAbTestCode("ab5");
|
|
|
|
+// }
|
|
|
|
+// if("243".equals(abtestId)&&(requestParam.getAbTestCode().equals("ab1")||requestParam.getAbTestCode().equals("ab2")||requestParam.getAbTestCode().equals("ab3"))){
|
|
|
|
+// requestParam.setAbTestCode("ab5");
|
|
|
|
+// }
|
|
|
|
|
|
HashMap<String, Map<String, Object>> abConfigMap = abConfig.getAbConfigMap();
|
|
HashMap<String, Map<String, Object>> abConfigMap = abConfig.getAbConfigMap();
|
|
Map<String, Object> abtestParam = abConfigMap.getOrDefault(abtestId + "-" + abTestConfigTag, null);
|
|
Map<String, Object> abtestParam = abConfigMap.getOrDefault(abtestId + "-" + abTestConfigTag, null);
|
|
@@ -221,10 +200,23 @@ public class PredictModelServiceImpl implements PredictModelService {
|
|
modelParam.setExtraParam(new HashMap<>());
|
|
modelParam.setExtraParam(new HashMap<>());
|
|
modelParam.addUserExtraFuture("shareType",shareType);
|
|
modelParam.addUserExtraFuture("shareType",shareType);
|
|
setExtraParam(modelParam);
|
|
setExtraParam(modelParam);
|
|
- long startTime=System.currentTimeMillis();
|
|
|
|
- String methodName="adPredictNew";
|
|
|
|
- int step=1;
|
|
|
|
- if (adPredictBreakSwitch || isHit) {
|
|
|
|
|
|
+ if(expCodes.contains("602")){
|
|
|
|
+ String userEngineFuture=redisHelper.getString(RuleRedisKeyConst.AD_ENGINE_USER_FUTURE_KEY+requestParam.getMid());
|
|
|
|
+ if(userEngineFuture!=null){
|
|
|
|
+ modelParam.addAllIntoUserExtraFuture(JSONObject.parseObject(userEngineFuture,Map.class));
|
|
|
|
+ }else {
|
|
|
|
+ modelParam.addUserExtraFuture("30rp","0");
|
|
|
|
+ }
|
|
|
|
+ result = ThresholdModelContainer.
|
|
|
|
+ getThresholdPredictModel("random602")
|
|
|
|
+ .predict(modelParam);
|
|
|
|
+ } else if(expCodes.contains("599")){
|
|
|
|
+// if(randomModelExpCode!=null){
|
|
|
|
+// modelParam.addUserExtraFuture("randomModelKey",ExpCodeEnum.valueOfExpCode(randomModelExpCode).getRandomModelKey());
|
|
|
|
+ result = ThresholdModelContainer.
|
|
|
|
+ getThresholdPredictModel("random")
|
|
|
|
+ .predict(modelParam);
|
|
|
|
+ } else if (adPredictBreakSwitch || isHit) {
|
|
if(expCodes.contains(adPredictNoShareUserExpCode)&&"noShare".equals(shareType)){
|
|
if(expCodes.contains(adPredictNoShareUserExpCode)&&"noShare".equals(shareType)){
|
|
result = ThresholdModelContainer.
|
|
result = ThresholdModelContainer.
|
|
getThresholdPredictModel("share0")
|
|
getThresholdPredictModel("share0")
|
|
@@ -298,4 +290,5 @@ public class PredictModelServiceImpl implements PredictModelService {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+
|
|
}
|
|
}
|