| 
					
				 | 
			
			
				@@ -9,15 +9,14 @@ import com.tzld.piaoquan.recommend.feature.model.feature.MultiGetFeatureResponse 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.tzld.piaoquan.recommend.feature.util.CommonCollectionUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import com.tzld.piaoquan.recommend.feature.util.JSONUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import lombok.extern.slf4j.Slf4j; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import org.apache.commons.lang3.StringUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.beans.factory.annotation.Autowired; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.beans.factory.annotation.Qualifier; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.data.redis.core.RedisTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import org.springframework.stereotype.Service; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import org.springframework.util.CollectionUtils; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.HashMap; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 import java.util.List; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-import java.util.Map; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+import java.util.Optional; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				 /** 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  * @author dyp 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -29,8 +28,8 @@ public class FeatureV2Service { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     @Autowired 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private RedisTemplate<String, String> redisTemplate; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    @ApolloJsonValue("${dts.config:}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-    private Map<String, List<String>> tableFieldConfig; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    @ApolloJsonValue("${dts.config.v2:}") 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+    private List<DTSConfig> dtsConfigs; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     public MultiGetFeatureResponse multiGetFeature(MultiGetFeatureRequest request) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         if (request.getFeatureKeyCount() == 0) { 
			 | 
		
	
	
		
			
				| 
					
				 | 
			
			
				@@ -55,11 +54,24 @@ public class FeatureV2Service { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				  
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     // Note:写入和读取的key生成规则应保持一致 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				     private String redisKey(FeatureKeyProto fk) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        List<String> fields = tableFieldConfig.get(fk.getTableName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        if (CollectionUtils.isEmpty(fields)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-            return fk.getTableName(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        Optional<DTSConfig> optional = dtsConfigs.stream() 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .filter(c -> c.getOdps() != null && StringUtils.equals(c.getOdps().getTable(), fk.getTableName())) 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+                .findFirst(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (!optional.isPresent()) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            log.error("table {} not config", fk.getTableName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return ""; 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        DTSConfig config = optional.get(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+ 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        // Note:写入和读取的key生成规则应保持一致 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        List<String> fields = config.getRedis().getKey(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (org.apache.commons.collections4.CollectionUtils.isEmpty(fields)) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            return config.getRedis().getPrefix(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        StringBuilder sb = new StringBuilder(); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+        if (StringUtils.isNotBlank(config.getRedis().getPrefix())) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				+            sb.append(config.getRedis().getPrefix()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         } 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				-        StringBuilder sb = new StringBuilder(fk.getTableName()); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				         for (String field : fields) { 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             sb.append(":"); 
			 | 
		
	
		
			
				 | 
				 | 
			
			
				             sb.append(fk.getFieldValueMap().get(field)); 
			 |