| | |
| | | @Service |
| | | @Slf4j(topic = "uav") |
| | | public class UavService { |
| | | public static final String USERNAME = "ardbailu";//用户名 |
| | | public static final String PASSWORD = "ardkj12345";//密码 |
| | | public static final String USERNAME = "kaifabailu";//用户名 |
| | | public static final String PASSWORD = "ardkj@2014";//密码 |
| | | public static final String SALT = "0123456789012345";//盐 |
| | | |
| | | private Map uavUser;//登录的用户信息 |
| | |
| | | //执行method |
| | | this.getToken();//获取token验证,验证token有效性 |
| | | try { |
| | | res = (String) requestMethod.invoke(this.uavClient, url, this.getToken(), data); |
| | | String token = this.getToken(); |
| | | res = (String) requestMethod.invoke(this.uavClient, url, token, data); |
| | | } catch (IllegalAccessException e) { |
| | | System.out.println("doUavRequest 访问失败" + e.getMessage()); |
| | | } catch (InvocationTargetException e) { |
| | |
| | | //验证token有效性 |
| | | try { |
| | | String res = uavClient.GET("manage/api/v1/devices", token, "{}"); |
| | | System.out.println(res); |
| | | } catch (ForestNetworkException fe) { |
| | | if (fe.getStatusCode() == 401) {//token失效,重新登录 |
| | | this.login(); |
| | |
| | | } catch (ForestRuntimeException e) { |
| | | log.error("无人机连接超时" + e.getMessage()); |
| | | } catch (JsonMappingException e) { |
| | | e.printStackTrace(); |
| | | } catch (JsonProcessingException e) { |
| | | e.printStackTrace(); |
| | | } catch (IOException e) { |
| | | e.printStackTrace(); |
| | | } |
| | | } |
| | | |