|
@@ -16,7 +16,6 @@ import com.tzld.piaoquan.ad.engine.service.predict.container.AbTestConfigContain
|
|
|
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.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.request.RoiPredictModelRequestParam;
|
|
|
import com.tzld.piaoquan.ad.engine.service.predict.param.request.ThresholdPredictModelRequestParam;
|
|
@@ -29,7 +28,6 @@ import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.*;
|
|
|
-import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
|
@Service
|
|
|
public class PredictModelServiceImpl implements PredictModelService {
|
|
@@ -57,6 +55,9 @@ public class PredictModelServiceImpl implements PredictModelService {
|
|
|
@Value("${ad.predict.break.exp.code:570}")
|
|
|
private String adPredictBreakExpCode;
|
|
|
|
|
|
+ @Value("${ad.predict.share0.exp.code:000}")
|
|
|
+ private String adPredictNoShareUserExpCode;
|
|
|
+
|
|
|
@Value("${ad.predict.param.testIds:0}")
|
|
|
private String testIds;
|
|
|
@Value("${ad.predict.without.ad.video_ids:0}")
|
|
@@ -83,17 +84,23 @@ public class PredictModelServiceImpl implements PredictModelService {
|
|
|
Map<String,Object> result=new HashMap<>();
|
|
|
List<Map<String,Object>> mapList=(List)requestParam.getAbExpInfo().get("ab_test002");
|
|
|
Map<String,List<JSONObject>> configMap=new HashMap<>();
|
|
|
+ //该用户所有实验合集
|
|
|
+ Set<String> expCodes=new HashSet<>();
|
|
|
+ boolean isHit = false;
|
|
|
for(Map<String,Object> map:mapList){
|
|
|
- if("555".equals(map.getOrDefault("abExpCode",""))){
|
|
|
+ String expCode=map.getOrDefault("abExpCode","").toString();
|
|
|
+ expCodes.add(expCode);
|
|
|
+ if("555".equals(expCode)){
|
|
|
configMap=JSONObject.parseObject(map.get("configValue").toString(),Map.class);
|
|
|
- break;
|
|
|
+ }
|
|
|
+ //判断570是否命中
|
|
|
+ if (StringUtils.equals(expCode, adPredictBreakExpCode)) {
|
|
|
+ isHit = true;
|
|
|
}
|
|
|
}
|
|
|
int hourOfDay= DateUtils.getCurrentHour();
|
|
|
Boolean condition1=abTestConfigContainer.inAdTimeTest(requestParam.getAbExpInfo());
|
|
|
Boolean condition2=abTestConfigContainer.containsCode(configMap,requestParam.getAbTestCode());
|
|
|
-
|
|
|
-
|
|
|
if(condition1
|
|
|
&&
|
|
|
condition2
|
|
@@ -111,28 +118,26 @@ public class PredictModelServiceImpl implements PredictModelService {
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- boolean isHit = false;
|
|
|
-
|
|
|
- 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);
|
|
|
- }
|
|
|
+ //人群选择算法判定-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());
|
|
|
if (abParamArr == null) {
|
|
@@ -148,7 +153,6 @@ public class PredictModelServiceImpl implements PredictModelService {
|
|
|
requestParam.setAbTestCode("ab5");
|
|
|
}
|
|
|
|
|
|
-
|
|
|
HashMap<String, Map<String, Object>> abConfigMap = abConfig.getAbConfigMap();
|
|
|
Map<String, Object> abtestParam = abConfigMap.getOrDefault(abtestId + "-" + abTestConfigTag, null);
|
|
|
if (abtestParam == null) {
|
|
@@ -159,13 +163,15 @@ public class PredictModelServiceImpl implements PredictModelService {
|
|
|
requestParam.setRegion(requestParam.getRegion().replace("省", ""));
|
|
|
requestParam.setCity(requestParam.getCity().replace("市", ""));
|
|
|
|
|
|
-
|
|
|
// 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);
|
|
|
+ String shareType =null;
|
|
|
if (midGroup == null) {
|
|
|
midGroup = "mean_group";
|
|
|
+ shareType="noShare";
|
|
|
}
|
|
|
|
|
|
String[] noAdMidGroupList = new String[0];
|
|
@@ -209,12 +215,23 @@ public class PredictModelServiceImpl implements PredictModelService {
|
|
|
modelParam.setAbtestParam(abtestParam);
|
|
|
modelParam.setMidGroup(midGroup);
|
|
|
modelParam.setExtraParam(new HashMap<>());
|
|
|
+ modelParam.addUserExtraFuture("shareType",shareType);
|
|
|
setExtraParam(modelParam);
|
|
|
|
|
|
if (adPredictBreakSwitch || isHit) {
|
|
|
- result = ThresholdModelContainer.
|
|
|
- getThresholdPredictModel("modelV2")
|
|
|
- .predict(modelParam);
|
|
|
+ if(expCodes.contains(adPredictNoShareUserExpCode)&&"noShare".equals(shareType)){
|
|
|
+ result = ThresholdModelContainer.
|
|
|
+ getThresholdPredictModel("share0")
|
|
|
+ .predict(modelParam);
|
|
|
+ }else if(expCodes.contains(adPredictNoShareUserExpCode)&&"return25_nmids".equals(shareType)){
|
|
|
+ result.put("mid_group", midGroup);
|
|
|
+ result.put("ad_predict", 1);
|
|
|
+ result.put("no_ad_strategy", adPredictNoShareUserExpCode+"_"+midGroup);
|
|
|
+ }else {
|
|
|
+ result = ThresholdModelContainer.
|
|
|
+ getThresholdPredictModel("modelV2")
|
|
|
+ .predict(modelParam);
|
|
|
+ }
|
|
|
} else {
|
|
|
Object thresholdMixFunc = abtestParam.getOrDefault("threshold_mix_func", "basic");
|
|
|
result = ThresholdModelContainer.
|