|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private void getUavConfig() { | 
|---|
|  |  |  | /*this.host = ConfigUtils.getConfigValue("uav_host"); | 
|---|
|  |  |  | this.host = ConfigUtils.getConfigValue("uav_host"); | 
|---|
|  |  |  | this.username = ConfigUtils.getConfigValue("uav_username"); | 
|---|
|  |  |  | this.password = ConfigUtils.getConfigValue("uav_password"); | 
|---|
|  |  |  | this.salt = ConfigUtils.getConfigValue("uav_salt");*/ | 
|---|
|  |  |  | this.host = "http://112.98.126.2:6100/"; | 
|---|
|  |  |  | this.salt = ConfigUtils.getConfigValue("uav_salt"); | 
|---|
|  |  |  | /*this.host = "http://112.98.126.2:6100/"; | 
|---|
|  |  |  | this.username = "znstest"; | 
|---|
|  |  |  | this.password = "znstest"; | 
|---|
|  |  |  | this.salt = "0123456789012345"; | 
|---|
|  |  |  | this.salt = "0123456789012345";*/ | 
|---|
|  |  |  | if (StringUtils.isEmpty(this.host) || StringUtils.isEmpty(this.username) || StringUtils.isEmpty(this.password) || StringUtils.isEmpty(this.salt)) { | 
|---|
|  |  |  | throw new RuntimeException("无人机参数配置缺失:"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | 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(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|