Parcourir la source

Merge branch 'feature_gufengshou_20240107_predict_abInfo' into test

gufengshou1 il y a 1 an
Parent
commit
c2b8cd20bc

+ 23 - 18
ad-engine-service/src/main/java/com/tzld/piaoquan/ad/engine/service/predict/container/AbTestConfigContainer.java

@@ -14,6 +14,8 @@ import org.springframework.stereotype.Component;
 
 import javax.annotation.PostConstruct;
 import java.util.*;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentMap;
 
 @Component
 public class AbTestConfigContainer {
@@ -25,15 +27,19 @@ public class AbTestConfigContainer {
 
     //List<Tuple<Integer>>
     Map<String,List<JSONObject>> adTimePlanMap=new HashMap<>();
+//    Map<Integer,Map<String,List<JSONObject>>> appAdTimePlanMap=new ConcurrentHashMap<>() ;
     @PostConstruct
     public void initContainer(){
         Timer timer = new Timer();
-
         timer.schedule(new TimerTask() {
             @Override
             public void run() {
                 try {
-                    initMap(null,"ab_test002");
+//                    for (Integer appType:appAdTimePlanMap.keySet()){
+//                        initMap(appType,"ab_test002");
+//                    }
+                    initMap(3,"ab_test002");
+//                    log.info("svc=refresh_adTimePlanMap appAdTimePlanMap={}",JSONObject.toJSONString(appAdTimePlanMap));
                     log.info("svc=refresh_adTimePlanMap adTimePlanMap={}",JSONObject.toJSONString(adTimePlanMap));
                 }catch (Exception e){
                     e.printStackTrace();
@@ -42,12 +48,13 @@ public class AbTestConfigContainer {
         }, 0, 1000*30);
     }
 
-
-
-
     public void initMap(Integer appType,String typeValue){
         AbTestConfigRequest request=new  AbTestConfigRequest();
-        request.setAppType(0);
+        if(appType==null){
+            request.setAppType(0);
+        }else{
+            request.setAppType(appType);
+        }
         request.setTypeValue(typeValue);
         CommonResponse<JSONObject> response=longVideoFeign.getAbTestConfig(request);
         log.info("svc=initAdTimePlanMap_getConfigFromLongVideoApi response={}",JSONObject.toJSONString(response));
@@ -80,24 +87,22 @@ public class AbTestConfigContainer {
         return flag;
     }
 
-    public Boolean inAdTimeTest(JSONObject abExpInfo){
-        //todo youhua
-        List<Map<String,Object>> mapList=(List)abExpInfo.get("ab_test002");
-        for(Map<String,Object> map:mapList){
-            if(adTestCode.equals(map.getOrDefault("abExpCode",""))){
+    public Boolean inWithoutAdTime(Map<String,List<JSONObject>> abConfigMap,String code,Integer hourOfDay){
+        Boolean flag=false;
+        for(JSONObject object:abConfigMap.getOrDefault(code,new ArrayList<>())){
+            if(object.getInteger("x")<=hourOfDay&&hourOfDay<object.getInteger("y")){
                 return true;
             }
         }
         //
-        return false;
+        return flag;
     }
 
-
-    public Boolean inWithoutAdTime(Map<String,List<JSONObject>> abConfigMap,String code,Integer hourOfDay){
-
-        Boolean flag=false;
-        for(JSONObject object:abConfigMap.getOrDefault(code,new ArrayList<>())){
-            if(object.getInteger("x")<=hourOfDay&&hourOfDay<object.getInteger("y")){
+    public Boolean inAdTimeTest(JSONObject abExpInfo){
+        //todo youhua
+        List<Map<String,Object>> mapList=(List)abExpInfo.get("ab_test002");
+        for(Map<String,Object> map:mapList){
+            if(adTestCode.equals(map.getOrDefault("abExpCode",""))){
                 return true;
             }
         }