|
@@ -1,5 +1,7 @@
|
|
package com.sooka.sponest.monitor.uav.controller;
|
|
package com.sooka.sponest.monitor.uav.controller;
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import com.ruoyi.common.core.domain.R;
|
|
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;
|
|
@@ -7,12 +9,10 @@ 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.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.HttpGet;
|
|
@@ -27,20 +27,14 @@ 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.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
|
|
@@ -103,42 +97,39 @@ public class CentermonitorTUavController extends BaseController {
|
|
}
|
|
}
|
|
|
|
|
|
@GetMapping("/getSign")
|
|
@GetMapping("/getSign")
|
|
- public String getSign() {
|
|
|
|
|
|
+ public AjaxResult getSign() {
|
|
try (CloseableHttpClient httpClient = createCustomHttpClient()) {
|
|
try (CloseableHttpClient httpClient = createCustomHttpClient()) {
|
|
R<String> requestResult = remoteService.uavSignUrl();
|
|
R<String> requestResult = remoteService.uavSignUrl();
|
|
if (requestResult == null || requestResult.getData() == null) {
|
|
if (requestResult == null || requestResult.getData() == null) {
|
|
log.error("获取的请求 URL 为空");
|
|
log.error("获取的请求 URL 为空");
|
|
- return "获取的请求 URL 为空";
|
|
|
|
|
|
+ return AjaxResult.error("获取的请求 URL 为空");
|
|
}
|
|
}
|
|
- String requestUrl = requestResult.getData();
|
|
|
|
|
|
+ String requestUrl = requestResult.getData() + "/etkqq/loginToken";
|
|
// 使用 HttpGet 进行 GET 请求
|
|
// 使用 HttpGet 进行 GET 请求
|
|
- HttpGet httpGet = new HttpGet(String.valueOf(requestUrl));
|
|
|
|
|
|
+ HttpGet httpGet = new HttpGet(requestUrl);
|
|
// 发送请求
|
|
// 发送请求
|
|
HttpResponse response = httpClient.execute(httpGet);
|
|
HttpResponse response = httpClient.execute(httpGet);
|
|
int statusCode = response.getStatusLine().getStatusCode();
|
|
int statusCode = response.getStatusLine().getStatusCode();
|
|
if (statusCode == 200) {
|
|
if (statusCode == 200) {
|
|
HttpEntity responseEntity = response.getEntity();
|
|
HttpEntity responseEntity = response.getEntity();
|
|
if (responseEntity != null) {
|
|
if (responseEntity != null) {
|
|
- return EntityUtils.toString(responseEntity, StandardCharsets.UTF_8);
|
|
|
|
|
|
+ JSONObject json = JSON.parseObject(EntityUtils.toString(responseEntity, StandardCharsets.UTF_8));
|
|
|
|
+ String returnUrl = requestUrl + "/tower/pub/zgtt?sign=" + json.get("data").toString();
|
|
|
|
+ return AjaxResult.success("操作成功",returnUrl);
|
|
} else {
|
|
} else {
|
|
log.error("响应实体为空");
|
|
log.error("响应实体为空");
|
|
- return "响应实体为空";
|
|
|
|
|
|
+ return AjaxResult.error("响应实体为空");
|
|
}
|
|
}
|
|
} else {
|
|
} else {
|
|
log.error("请求失败,状态码: {}", statusCode);
|
|
log.error("请求失败,状态码: {}", statusCode);
|
|
- return "请求失败,状态码: " + statusCode;
|
|
|
|
}
|
|
}
|
|
- } catch (IOException e) {
|
|
|
|
- log.error("请求发生 IO 异常", e);
|
|
|
|
- return "请求发生 IO 异常: " + e.getClass().getSimpleName();
|
|
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
log.error("发生未知异常", e);
|
|
log.error("发生未知异常", e);
|
|
- return "发生未知异常: " + e.getClass().getSimpleName();
|
|
|
|
}
|
|
}
|
|
|
|
+ return AjaxResult.error("请求失败");
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* 工厂方法:创建自定义配置的 HttpClient
|
|
* 工厂方法:创建自定义配置的 HttpClient
|
|
*
|
|
*
|