Administrator
2023-08-11 5ad4e2b2e881204102cd0a5e96da936db19f39c7
ard-work/src/main/java/com/ruoyi/device/uav/service/UavService.java
@@ -1,10 +1,12 @@
package com.ruoyi.device.uav.service;
import com.dtflys.forest.exceptions.ForestNetworkException;
import com.dtflys.forest.exceptions.ForestRuntimeException;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonMappingException;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.ruoyi.utils.forest.UavClient;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.codec.binary.Base64;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpMethod;
@@ -21,6 +23,7 @@
import java.util.Map;
@Service
@Slf4j(topic = "uav")
public class UavService {
    public static final String USERNAME = "ardbailu";//用户名
    public static final String PASSWORD = "ardkj12345";//密码
@@ -70,14 +73,14 @@
    }
    public Map getUavUser() {
        if (this.uavUser==null){
        if (this.uavUser == null) {
            this.login();
        }
        return this.uavUser;
    }
    public void login() {
        System.out.println("登录无人机外部接口");
        log.debug("登录无人机外部接口");
        String codedPassword = this.Encrypt(PASSWORD, SALT);
        String body = "{\"username\":\"" + USERNAME + "\",\"password\":\"" + codedPassword + "\"}";
        try {
@@ -87,8 +90,8 @@
            if (this.uavUser != null) {
                this.token = (String) this.uavUser.get("access_token");
            }
        } catch (ForestNetworkException e) {
            e.printStackTrace();
        } catch (ForestRuntimeException e) {
            log.error("无人机连接超时" + e.getMessage());
        } catch (JsonMappingException e) {
            e.printStackTrace();
        } catch (JsonProcessingException e) {