|
@@ -28,64 +28,64 @@ public class AbTestConfigContainer {
|
|
|
|
|
|
Map<String,List<JSONObject>> adTimePlanMap=new HashMap<>();
|
|
|
|
|
|
- @PostConstruct
|
|
|
- public void initContainer(){
|
|
|
- Timer timer = new Timer();
|
|
|
- timer.schedule(new TimerTask() {
|
|
|
- @Override
|
|
|
- public void run() {
|
|
|
- try {
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- initMap(3,"ab_test002");
|
|
|
-
|
|
|
- log.info("svc=refresh_adTimePlanMap adTimePlanMap={}",JSONObject.toJSONString(adTimePlanMap));
|
|
|
- }catch (Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
- }, 0, 1000*30);
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
- public void initMap(Integer appType,String typeValue){
|
|
|
- AbTestConfigRequest request=new AbTestConfigRequest();
|
|
|
- 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));
|
|
|
- JSONObject object=response.getData();
|
|
|
- for(Map.Entry<String,Object> entry:object.getInnerMap().entrySet()){
|
|
|
- for(Map<String,Object> map:(List<Map>)entry.getValue()){
|
|
|
- if(adTestCode.equals(map.get("abExpCode").toString())){
|
|
|
- adTimePlanMap=JSONObject.parseObject(map.get("configValue").toString(),Map.class);
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
- public Boolean containsCode(String code){
|
|
|
- return adTimePlanMap.keySet().contains(code);
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
public Boolean containsCode(Map<String,List<JSONObject>> configMap,String code){
|
|
|
return configMap.keySet().contains(code);
|
|
|
}
|
|
|
|
|
|
- public Boolean inWithoutAdTime(String code,Integer hourOfDay){
|
|
|
- Boolean flag=false;
|
|
|
- for(JSONObject object:adTimePlanMap.getOrDefault(code,new ArrayList<>())){
|
|
|
- if(object.getInteger("x")<=hourOfDay&&hourOfDay<object.getInteger("y")){
|
|
|
- return true;
|
|
|
- }
|
|
|
- }
|
|
|
- return flag;
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
|
|
|
public Boolean inWithoutAdTime(Map<String,List<JSONObject>> abConfigMap,String code,Integer hourOfDay){
|
|
|
Boolean flag=false;
|
|
@@ -110,13 +110,4 @@ public class AbTestConfigContainer {
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
- public static void main(String[] args){
|
|
|
- Map<String, Tuple<Integer>> map =new HashMap<>();
|
|
|
- Tuple<Integer> t=new Tuple<>();
|
|
|
- t.setX(1);
|
|
|
- t.setY(2);
|
|
|
- map.put("sk",t);
|
|
|
- System.out.println(JSONObject.toJSONString(map));
|
|
|
- }
|
|
|
}
|