| 
					
				 | 
			
			
				@@ -13,6 +13,7 @@ import com.tzld.piaoquan.recommend.server.gen.recommend.VideoProto; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.tzld.piaoquan.recommend.server.model.MachineInfo; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.tzld.piaoquan.recommend.server.model.RecommendParam; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.tzld.piaoquan.recommend.server.model.Video; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import com.tzld.piaoquan.recommend.server.remote.ABTestRemoteService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.tzld.piaoquan.recommend.server.service.flowpool.FlowPoolConfigService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.tzld.piaoquan.recommend.server.service.flowpool.FlowPoolConstants; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.tzld.piaoquan.recommend.server.service.flowpool.FlowPoolService; 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -34,6 +35,7 @@ import org.apache.commons.lang3.RandomUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.beans.factory.annotation.Qualifier; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.springframework.beans.factory.annotation.Value; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.data.redis.core.RedisTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -74,6 +76,9 @@ public class RecommendService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @ApolloJsonValue("${new.exp,config.v2:[]}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private List<ExpConfig> expConfigs; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Value("${new.exp.abtest.service.switch:true}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private boolean newExpABTestServiceSwitch; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private FlowPoolConfigService flowPoolConfigService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -87,6 +92,9 @@ public class RecommendService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private StatisticsLogService statisticsLogService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private ABTestRemoteService abTestRemoteService; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @PostConstruct 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public void init() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         ab_initial_config_map.put(AppTypeEnum.VLOG.getCode(), "095"); 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -408,28 +416,33 @@ public class RecommendService { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         // TODO:hard code 为了快速做AB验证,应该由AB系统支持 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (newExpList.contains(param.getAppType())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            Map<String, List<Layer>> layerMap = CommonCollectionUtils.toMap(expConfigs, c -> c.getAppType(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    c -> c.getLayers()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            if (MapUtils.isNotEmpty(layerMap)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                Map<String, Integer> bucketMap = JSONUtils.fromJson(request.getNewExpGroup(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        new TypeToken<Map<String, Integer>>() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        }, Collections.emptyMap()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                if (MapUtils.isNotEmpty(bucketMap)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    List<Layer> layers = layerMap.get(param.getAppType() + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				- 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                    if (CollectionUtils.isNotEmpty(layers)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        Map<String, String> expIdMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        for (Layer layer : layers) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                            for (Exp exp : layer.getExps()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                if (bucketMap.containsKey(layer.getLayerId()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                        && exp.getRange().length == 2 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                        && exp.getRange()[0] <= bucketMap.get(layer.getLayerId()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                        && exp.getRange()[1] >= bucketMap.get(layer.getLayerId())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                                    expIdMap.put(layer.getLayerId(), exp.getExpId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            if (newExpABTestServiceSwitch) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                param.setExpIdMap(abTestRemoteService.getExp(param.getMid(), param.getUid(), param.getAppType(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        request.getNewExpGroup())); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            } else { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                Map<String, List<Layer>> layerMap = CommonCollectionUtils.toMap(expConfigs, c -> c.getAppType(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        c -> c.getLayers()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                if (MapUtils.isNotEmpty(layerMap)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    Map<String, Integer> bucketMap = JSONUtils.fromJson(request.getNewExpGroup(), 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            new TypeToken<Map<String, Integer>>() { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            }, Collections.emptyMap()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                    if (MapUtils.isNotEmpty(bucketMap)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        List<Layer> layers = layerMap.get(param.getAppType() + ""); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                        if (CollectionUtils.isNotEmpty(layers)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            Map<String, String> expIdMap = new HashMap<>(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            for (Layer layer : layers) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                for (Exp exp : layer.getExps()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    if (bucketMap.containsKey(layer.getLayerId()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                            && exp.getRange().length == 2 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                            && exp.getRange()[0] <= bucketMap.get(layer.getLayerId()) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                            && exp.getRange()[1] >= bucketMap.get(layer.getLayerId())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                        expIdMap.put(layer.getLayerId(), exp.getExpId()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                                    } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                             } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                            param.setExpIdMap(expIdMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-                        param.setExpIdMap(expIdMap); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                     } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				                 } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             } 
			 |