From 0017dec8baea29062ccac94a15248a61f7bdf77d Mon Sep 17 00:00:00 2001 From: zhangjianrock@163.com <zhangjianrock@163.com> Date: 星期一, 29 一月 2024 16:15:56 +0800 Subject: [PATCH] 无人机读取配置文件 --- ard-work/src/main/java/com/ruoyi/device/uav/service/UavService.java | 17 ++++++++++------- 1 files changed, 10 insertions(+), 7 deletions(-) diff --git a/ard-work/src/main/java/com/ruoyi/device/uav/service/UavService.java b/ard-work/src/main/java/com/ruoyi/device/uav/service/UavService.java index dec574f..2a009f9 100644 --- a/ard-work/src/main/java/com/ruoyi/device/uav/service/UavService.java +++ b/ard-work/src/main/java/com/ruoyi/device/uav/service/UavService.java @@ -41,7 +41,7 @@ private String salt; //鐩� - private String host;//uav鏈嶅姟鍣� + private String host;//uav鏈嶅姟鍣�11 private Map uavUser;//鐧诲綍鐨勭敤鎴蜂俊鎭� @@ -69,6 +69,8 @@ } public String doUavRequest(HttpMethod method, String url, String data) { + + getUavConfig(); String res = null; Method requestMethod = null; //鑾峰彇method @@ -78,14 +80,14 @@ e.printStackTrace(); } //鎵цmethod - this.getToken();//鑾峰彇token楠岃瘉,楠岃瘉token鏈夋晥鎬� + // this.getToken();//鑾峰彇token楠岃瘉,楠岃瘉token鏈夋晥鎬� try { String token = this.getToken(); res = (String) requestMethod.invoke(this.uavClient, this.host + url, token, data); } catch (IllegalAccessException e) { - System.out.println("doUavRequest 璁块棶澶辫触" + e.getMessage()); + log.error("doUavRequest 璁块棶澶辫触" + e.getMessage()); } catch (InvocationTargetException e) { - System.out.println("doUavRequest 鎵ц澶辫触" + e.getMessage()); + log.error("doUavRequest 鎵ц澶辫触" + e.getMessage()); e.printStackTrace(); } @@ -103,7 +105,8 @@ //楠岃瘉token鏈夋晥鎬� try { String res = uavClient.GET(this.host+"manage/api/v1/devices", token, "{}"); - System.out.println(res); + res+=""; + //System.out.println(res); } catch (ForestNetworkException fe) { if (fe.getStatusCode() == 401) {//token澶辨晥,閲嶆柊鐧诲綍 this.login(); @@ -122,12 +125,12 @@ log.debug("鐧诲綍鏃犱汉鏈哄閮ㄦ帴鍙�"); String codedPassword = this.Encrypt(password, salt); String body = "{\"username\":\"" + username + "\",\"password\":\"" + codedPassword + "\"}"; - System.out.println("body:" + body); + log.debug("body:" + body); try { //uavClient.GET("logout", null, "{}"); String res = uavClient.POST(this.host+"login", null, body); Map resMap = om.readValue(res, Map.class); - if (resMap != null) { + if (resMap != null&& resMap.get("data") instanceof Map) { redisCache.setCacheMap("uav:uavUser", (Map) resMap.get("data")); } } catch (ForestRuntimeException e) { -- Gitblit v1.9.3