|  |  |  | 
|---|
|  |  |  | @Autowired | 
|---|
|  |  |  | private RedisCache redisCache; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Value("${uav.enabled}") | 
|---|
|  |  |  | private Boolean uavEnabled; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @PostConstruct | 
|---|
|  |  |  | public void created() { | 
|---|
|  |  |  | if(!uavEnabled){//无人机加入开关 | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | getUavConfig(); | 
|---|
|  |  |  | this.login(); | 
|---|
|  |  |  | 
|---|
|  |  |  | return new HashMap(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public Object addAlarm(String url, Map<String,Object> data) { | 
|---|
|  |  |  | String token = this.getToken(); | 
|---|
|  |  |  | url = this.host + url; | 
|---|
|  |  |  | data.put("userName",this.username); | 
|---|
|  |  |  | Map<String,Object> resultMap = addAlarm(url,token, data); | 
|---|
|  |  |  | return resultMap; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public Map<String,Object> addAlarm(String url,String access_token,Map<String,Object> map){ | 
|---|
|  |  |  | MediaType mediaType = MediaType.parse("application/json; charset=utf-8"); | 
|---|
|  |  |  | OkHttpClient okHttpClient = new OkHttpClient(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(map)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Request request = new Request.Builder().url(url).post(body).addHeader("x-auth-token",access_token).build(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Response response = null; | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | response = okHttpClient.newCall(request).execute(); | 
|---|
|  |  |  | } catch (IOException e1) { | 
|---|
|  |  |  | // TODO Auto-generated catch block | 
|---|
|  |  |  | e1.printStackTrace(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ResponseBody responseBody = response.body(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | String message = responseBody.string();// 响应体 | 
|---|
|  |  |  | Map<String,Object> map0 = (Map<String, Object>) JSON.parse(message); | 
|---|
|  |  |  | return map0; | 
|---|
|  |  |  | } catch (IOException e) { | 
|---|
|  |  |  | // TODO Auto-generated catch block | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | return new HashMap(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public Object saveCurrentGroup(String url, Map<String,Object> data) { | 
|---|
|  |  |  | String token = this.getToken(); | 
|---|
|  |  |  | url = this.host + url; | 
|---|
|  |  |  | Map<String,Object> resultMap = addWaylinesPlanning(url,token, data); | 
|---|
|  |  |  | return resultMap; | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public Map<String,Object> saveCurrentGroup(String url,String access_token,Map<String,Object> map){ | 
|---|
|  |  |  | MediaType mediaType = MediaType.parse("application/json; charset=utf-8"); | 
|---|
|  |  |  | OkHttpClient okHttpClient = new OkHttpClient(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(map)); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Request request = new Request.Builder().url(url).post(body).addHeader("x-auth-token",access_token).build(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | Response response = null; | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | response = okHttpClient.newCall(request).execute(); | 
|---|
|  |  |  | } catch (IOException e1) { | 
|---|
|  |  |  | // TODO Auto-generated catch block | 
|---|
|  |  |  | e1.printStackTrace(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | ResponseBody responseBody = response.body(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | String message = responseBody.string();// 响应体 | 
|---|
|  |  |  | Map<String,Object> map0 = (Map<String, Object>) JSON.parse(message); | 
|---|
|  |  |  | return map0; | 
|---|
|  |  |  | } catch (IOException e) { | 
|---|
|  |  |  | // TODO Auto-generated catch block | 
|---|
|  |  |  | e.printStackTrace(); | 
|---|
|  |  |  | return new HashMap(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|