|
@@ -28,64 +28,64 @@ 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 {
|
|
|
-// 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();
|
|
|
- }
|
|
|
- }
|
|
|
- }, 0, 1000*30);
|
|
|
- }
|
|
|
+// @PostConstruct
|
|
|
+// public void initContainer(){
|
|
|
+// Timer timer = new Timer();
|
|
|
+// timer.schedule(new TimerTask() {
|
|
|
+// @Override
|
|
|
+// public void run() {
|
|
|
+// try {
|
|
|
+//// 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();
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }, 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 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(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(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));
|
|
|
- }
|
|
|
}
|