| 
					
				 | 
			
			
				@@ -2,6 +2,7 @@ package com.tzld.piaoquan.ad.engine.service.predict.impl; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.alibaba.fastjson.JSONArray; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.alibaba.fastjson.JSONObject; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+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.redis.AlgorithmRedisHelper; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -28,6 +29,7 @@ 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 { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -55,6 +57,9 @@ public class PredictModelServiceImpl implements PredictModelService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Value("${ad.predict.break.exp.code:0}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private String adPredictBreakExpCode; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Value("${ad.predict.param.testIds:0}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private String testIds; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public Map<String, Object> adPredict(ThresholdPredictModelRequestParam requestParam) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         boolean isHit = false; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -196,6 +201,8 @@ public class PredictModelServiceImpl implements PredictModelService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         modelParam.setAbTestConfigTag(abTestConfigTag); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         modelParam.setAbtestParam(abtestParam); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         modelParam.setMidGroup(midGroup); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        modelParam.setExtraParam(new HashMap<>()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        setExtraParam(modelParam); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         result = ThresholdModelContainer. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 getThresholdPredictModel("modelV2") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 .predict(modelParam); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -314,6 +321,8 @@ public class PredictModelServiceImpl implements PredictModelService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         modelParam.setAbTestConfigTag(abTestConfigTag); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         modelParam.setAbtestParam(abtestParam); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         modelParam.setMidGroup(midGroup); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        modelParam.setExtraParam(new HashMap<>()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        setExtraParam(modelParam); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         Object thresholdMixFunc = abtestParam.getOrDefault("threshold_mix_func", "basic"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         result = ThresholdModelContainer. 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 getThresholdPredictModel(thresholdMixFunc.toString()) 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -350,4 +359,19 @@ public class PredictModelServiceImpl implements PredictModelService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 .predict(modelParam); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    public void setExtraParam(ThresholdPredictModelParam modelParam){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        String[] ids=testIds.split(","); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<String> idList=Arrays.asList(ids); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<Map<String,Object>> mapList=(List)modelParam.getAbExpInfo().get("ab_test002"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Map<String,Object> configMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        for(Map<String,Object> map:mapList){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if(idList.contains(map.getOrDefault("abExpCode",""))){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                configMap=JSONObject.parseObject(map.get("configValue").toString(),new TypeReference<Map<String,Object>>(){}); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                for(Map.Entry<String,Object> entry:configMap.entrySet()){ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    modelParam.getExtraParam().put(entry.getKey(),entry.getValue()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 } 
			 |