|
@@ -14,6 +14,8 @@ import org.springframework.stereotype.Component;
|
|
|
|
|
|
import javax.annotation.PostConstruct;
|
|
import javax.annotation.PostConstruct;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
+import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
+import java.util.concurrent.ConcurrentMap;
|
|
|
|
|
|
@Component
|
|
@Component
|
|
public class AbTestConfigContainer {
|
|
public class AbTestConfigContainer {
|
|
@@ -25,15 +27,19 @@ public class AbTestConfigContainer {
|
|
|
|
|
|
//List<Tuple<Integer>>
|
|
//List<Tuple<Integer>>
|
|
Map<String,List<JSONObject>> adTimePlanMap=new HashMap<>();
|
|
Map<String,List<JSONObject>> adTimePlanMap=new HashMap<>();
|
|
|
|
+// Map<Integer,Map<String,List<JSONObject>>> appAdTimePlanMap=new ConcurrentHashMap<>() ;
|
|
@PostConstruct
|
|
@PostConstruct
|
|
public void initContainer(){
|
|
public void initContainer(){
|
|
Timer timer = new Timer();
|
|
Timer timer = new Timer();
|
|
-
|
|
|
|
timer.schedule(new TimerTask() {
|
|
timer.schedule(new TimerTask() {
|
|
@Override
|
|
@Override
|
|
public void run() {
|
|
public void run() {
|
|
try {
|
|
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));
|
|
log.info("svc=refresh_adTimePlanMap adTimePlanMap={}",JSONObject.toJSONString(adTimePlanMap));
|
|
}catch (Exception e){
|
|
}catch (Exception e){
|
|
e.printStackTrace();
|
|
e.printStackTrace();
|
|
@@ -42,12 +48,13 @@ public class AbTestConfigContainer {
|
|
}, 0, 1000*30);
|
|
}, 0, 1000*30);
|
|
}
|
|
}
|
|
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
public void initMap(Integer appType,String typeValue){
|
|
public void initMap(Integer appType,String typeValue){
|
|
AbTestConfigRequest request=new AbTestConfigRequest();
|
|
AbTestConfigRequest request=new AbTestConfigRequest();
|
|
- request.setAppType(0);
|
|
|
|
|
|
+ if(appType==null){
|
|
|
|
+ request.setAppType(0);
|
|
|
|
+ }else{
|
|
|
|
+ request.setAppType(appType);
|
|
|
|
+ }
|
|
request.setTypeValue(typeValue);
|
|
request.setTypeValue(typeValue);
|
|
CommonResponse<JSONObject> response=longVideoFeign.getAbTestConfig(request);
|
|
CommonResponse<JSONObject> response=longVideoFeign.getAbTestConfig(request);
|
|
log.info("svc=initAdTimePlanMap_getConfigFromLongVideoApi response={}",JSONObject.toJSONString(response));
|
|
log.info("svc=initAdTimePlanMap_getConfigFromLongVideoApi response={}",JSONObject.toJSONString(response));
|
|
@@ -80,24 +87,22 @@ public class AbTestConfigContainer {
|
|
return flag;
|
|
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 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;
|
|
return true;
|
|
}
|
|
}
|
|
}
|
|
}
|