|
@@ -1,16 +1,21 @@
|
|
package com.sooka.sponest.monitor.uav.controller;
|
|
package com.sooka.sponest.monitor.uav.controller;
|
|
|
|
|
|
|
|
+import com.ruoyi.common.core.domain.R;
|
|
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
|
import com.ruoyi.common.core.utils.poi.ExcelUtil;
|
|
import com.ruoyi.common.core.web.controller.BaseController;
|
|
import com.ruoyi.common.core.web.controller.BaseController;
|
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
|
import com.ruoyi.common.core.web.domain.AjaxResult;
|
|
import com.ruoyi.common.core.web.page.TableDataInfo;
|
|
import com.ruoyi.common.core.web.page.TableDataInfo;
|
|
import com.ruoyi.common.log.annotation.Log;
|
|
import com.ruoyi.common.log.annotation.Log;
|
|
import com.ruoyi.common.log.enums.BusinessType;
|
|
import com.ruoyi.common.log.enums.BusinessType;
|
|
|
|
+import com.ruoyi.system.api.domain.SysDept;
|
|
|
|
+import com.sooka.sponest.monitor.remoteapi.service.center.system.RemoteService;
|
|
import com.sooka.sponest.monitor.uav.domain.CentermonitorTUav;
|
|
import com.sooka.sponest.monitor.uav.domain.CentermonitorTUav;
|
|
import com.sooka.sponest.monitor.uav.service.ICentermonitorTUavService;
|
|
import com.sooka.sponest.monitor.uav.service.ICentermonitorTUavService;
|
|
import org.apache.http.HttpEntity;
|
|
import org.apache.http.HttpEntity;
|
|
|
|
+import org.apache.http.HttpHeaders;
|
|
import org.apache.http.HttpResponse;
|
|
import org.apache.http.HttpResponse;
|
|
import org.apache.http.client.config.RequestConfig;
|
|
import org.apache.http.client.config.RequestConfig;
|
|
|
|
+import org.apache.http.client.methods.HttpGet;
|
|
import org.apache.http.client.methods.HttpPost;
|
|
import org.apache.http.client.methods.HttpPost;
|
|
import org.apache.http.conn.ssl.NoopHostnameVerifier;
|
|
import org.apache.http.conn.ssl.NoopHostnameVerifier;
|
|
import org.apache.http.entity.StringEntity;
|
|
import org.apache.http.entity.StringEntity;
|
|
@@ -22,13 +27,20 @@ import org.slf4j.Logger;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.slf4j.LoggerFactory;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
+import org.springframework.http.HttpMethod;
|
|
|
|
+import org.springframework.http.MediaType;
|
|
|
|
+import org.springframework.http.ResponseEntity;
|
|
import org.springframework.web.bind.annotation.*;
|
|
import org.springframework.web.bind.annotation.*;
|
|
|
|
+import org.springframework.web.client.RestTemplate;
|
|
|
|
|
|
|
|
+import javax.annotation.Resource;
|
|
import javax.net.ssl.SSLContext;
|
|
import javax.net.ssl.SSLContext;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.nio.charset.StandardCharsets;
|
|
import java.nio.charset.StandardCharsets;
|
|
|
|
+import java.util.HashMap;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.Map;
|
|
|
|
|
|
/**
|
|
/**
|
|
* 无人机Controller
|
|
* 无人机Controller
|
|
@@ -43,6 +55,9 @@ public class CentermonitorTUavController extends BaseController {
|
|
@Autowired
|
|
@Autowired
|
|
private ICentermonitorTUavService centermonitorTUavService;
|
|
private ICentermonitorTUavService centermonitorTUavService;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ private RemoteService remoteService;
|
|
|
|
+
|
|
private static final Logger log = LoggerFactory.getLogger(CentermonitorTUavController.class);
|
|
private static final Logger log = LoggerFactory.getLogger(CentermonitorTUavController.class);
|
|
|
|
|
|
@Value("${sooka.uav_server.username}")
|
|
@Value("${sooka.uav_server.username}")
|
|
@@ -87,6 +102,43 @@ public class CentermonitorTUavController extends BaseController {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @GetMapping("/getSign")
|
|
|
|
+ public String getSign() {
|
|
|
|
+ try (CloseableHttpClient httpClient = createCustomHttpClient()) {
|
|
|
|
+ R<String> requestResult = remoteService.uavSignUrl();
|
|
|
|
+ if (requestResult == null || requestResult.getData() == null) {
|
|
|
|
+ log.error("获取的请求 URL 为空");
|
|
|
|
+ return "获取的请求 URL 为空";
|
|
|
|
+ }
|
|
|
|
+ String requestUrl = requestResult.getData();
|
|
|
|
+ // 使用 HttpGet 进行 GET 请求
|
|
|
|
+ HttpGet httpGet = new HttpGet(String.valueOf(requestUrl));
|
|
|
|
+ // 发送请求
|
|
|
|
+ HttpResponse response = httpClient.execute(httpGet);
|
|
|
|
+ int statusCode = response.getStatusLine().getStatusCode();
|
|
|
|
+ if (statusCode == 200) {
|
|
|
|
+ HttpEntity responseEntity = response.getEntity();
|
|
|
|
+ if (responseEntity != null) {
|
|
|
|
+ return EntityUtils.toString(responseEntity, StandardCharsets.UTF_8);
|
|
|
|
+ } else {
|
|
|
|
+ log.error("响应实体为空");
|
|
|
|
+ return "响应实体为空";
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ log.error("请求失败,状态码: {}", statusCode);
|
|
|
|
+ return "请求失败,状态码: " + statusCode;
|
|
|
|
+ }
|
|
|
|
+ } catch (IOException e) {
|
|
|
|
+ log.error("请求发生 IO 异常", e);
|
|
|
|
+ return "请求发生 IO 异常: " + e.getClass().getSimpleName();
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("发生未知异常", e);
|
|
|
|
+ return "发生未知异常: " + e.getClass().getSimpleName();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* 工厂方法:创建自定义配置的 HttpClient
|
|
* 工厂方法:创建自定义配置的 HttpClient
|
|
*
|
|
*
|