|
@@ -0,0 +1,915 @@
|
|
|
+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.utils.poi.ExcelUtil;
|
|
|
+import com.ruoyi.common.core.web.controller.BaseController;
|
|
|
+import com.ruoyi.common.core.web.domain.AjaxResult;
|
|
|
+import com.ruoyi.common.core.web.page.TableDataInfo;
|
|
|
+import com.ruoyi.common.log.annotation.Log;
|
|
|
+import com.ruoyi.common.log.enums.BusinessType;
|
|
|
+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.dto.CentermonitorTUavDTO;
|
|
|
+import com.sooka.sponest.monitor.uav.service.ICentermonitorTUavService;
|
|
|
+import com.sooka.sponest.monitor.websocket.WebSocketUsers;
|
|
|
+import org.apache.http.HttpEntity;
|
|
|
+import org.apache.http.HttpResponse;
|
|
|
+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.conn.ssl.NoopHostnameVerifier;
|
|
|
+import org.apache.http.entity.StringEntity;
|
|
|
+import org.apache.http.impl.client.CloseableHttpClient;
|
|
|
+import org.apache.http.impl.client.HttpClients;
|
|
|
+import org.apache.http.ssl.SSLContextBuilder;
|
|
|
+import org.apache.http.util.EntityUtils;
|
|
|
+import org.slf4j.Logger;
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import javax.annotation.Resource;
|
|
|
+import javax.net.ssl.SSLContext;
|
|
|
+import javax.servlet.http.HttpServletResponse;
|
|
|
+import javax.websocket.*;
|
|
|
+import java.io.IOException;
|
|
|
+import java.net.URI;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
+import java.util.*;
|
|
|
+import java.util.concurrent.CountDownLatch;
|
|
|
+import java.util.concurrent.TimeUnit;
|
|
|
+
|
|
|
+/**
|
|
|
+ * 无人机Controller
|
|
|
+ *
|
|
|
+ * @author ruoyi
|
|
|
+ * @date 2025-03-19
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/uav")
|
|
|
+public class CentermonitorTUavController extends BaseController {
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private ICentermonitorTUavService centermonitorTUavService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private RemoteService remoteService;
|
|
|
+
|
|
|
+ private static final Logger log = LoggerFactory.getLogger(CentermonitorTUavController.class);
|
|
|
+
|
|
|
+ @Value("${sooka.uav_server.username}")
|
|
|
+ private String username;
|
|
|
+
|
|
|
+ @Value("${sooka.uav_server.password}")
|
|
|
+ private String password;
|
|
|
+
|
|
|
+ private static final String REQUEST_URL = "https://47.93.50.30/etkqq/login";
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 2.登录鉴权
|
|
|
+ */
|
|
|
+ @GetMapping("/getToken")
|
|
|
+ public String getToken() {
|
|
|
+ try (CloseableHttpClient httpClient = createCustomHttpClient()) {
|
|
|
+ HttpPost httpPost = new HttpPost(REQUEST_URL);
|
|
|
+ // 使用 JSON 处理库构建请求体
|
|
|
+ String requestBody = "{\"username\": \"" + username + "\", \"password\": \"" + password + "\"}";
|
|
|
+ StringEntity entity = new StringEntity(requestBody, StandardCharsets.UTF_8);
|
|
|
+ httpPost.setEntity(entity);
|
|
|
+ httpPost.setHeader("Content-Type", "application/json");
|
|
|
+
|
|
|
+ // 发送请求
|
|
|
+ HttpResponse response = httpClient.execute(httpPost);
|
|
|
+ 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 (Exception e) {
|
|
|
+ return "请求发生异常: " + e.getMessage();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @GetMapping("/getSign")
|
|
|
+ public AjaxResult getSign() {
|
|
|
+ try (CloseableHttpClient httpClient = createCustomHttpClient()) {
|
|
|
+ R<String> requestResult = remoteService.uavSignUrl();
|
|
|
+ if (requestResult == null || requestResult.getData() == null) {
|
|
|
+ log.error("获取的请求 URL 为空");
|
|
|
+ return AjaxResult.error("获取的请求 URL 为空");
|
|
|
+ }
|
|
|
+ String requestUrl = requestResult.getData();
|
|
|
+ // 使用 HttpGet 进行 GET 请求
|
|
|
+ HttpGet httpGet = new HttpGet(requestUrl + "/etkqq/loginToken");
|
|
|
+ // 发送请求
|
|
|
+ HttpResponse response = httpClient.execute(httpGet);
|
|
|
+ int statusCode = response.getStatusLine().getStatusCode();
|
|
|
+ if (statusCode == 200) {
|
|
|
+ HttpEntity responseEntity = response.getEntity();
|
|
|
+ if (responseEntity != null) {
|
|
|
+ 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 {
|
|
|
+ log.error("响应实体为空");
|
|
|
+ return AjaxResult.error("响应实体为空");
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.error("请求失败,状态码: {}", statusCode);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("发生未知异常", e);
|
|
|
+ }
|
|
|
+ return AjaxResult.error("请求失败");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 无人机组织树
|
|
|
+ */
|
|
|
+ @GetMapping("/getCopterTree")
|
|
|
+ public AjaxResult getCopterTree() {
|
|
|
+ String token = getToken();
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(token);
|
|
|
+ if (token == null) {
|
|
|
+ return AjaxResult.error("获取 token 失败");
|
|
|
+ }
|
|
|
+ try (CloseableHttpClient httpClient = createCustomHttpClient()) {
|
|
|
+ R<String> requestResult = remoteService.uavSignUrl();
|
|
|
+ if (requestResult == null || requestResult.getData() == null) {
|
|
|
+ log.error("获取的请求 URL 为空");
|
|
|
+ return AjaxResult.error("获取的请求 URL 为空");
|
|
|
+ }
|
|
|
+ String requestUrl = requestResult.getData();
|
|
|
+ // 使用 HttpGet 进行 GET 请求
|
|
|
+ HttpGet httpGet = new HttpGet(requestUrl + "/etkqq/copterMetaData/getCopterTree");
|
|
|
+ httpGet.setHeader("Authorization", jsonObject.get("token").toString());
|
|
|
+ // 发送请求
|
|
|
+ HttpResponse response = httpClient.execute(httpGet);
|
|
|
+ int statusCode = response.getStatusLine().getStatusCode();
|
|
|
+ if (statusCode == 200) {
|
|
|
+ HttpEntity responseEntity = response.getEntity();
|
|
|
+ if (responseEntity != null) {
|
|
|
+ JSONObject json = JSON.parseObject(EntityUtils.toString(responseEntity, StandardCharsets.UTF_8));
|
|
|
+ return AjaxResult.success(json.get("retMsg").toString(), json.get("result"));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.error("请求失败,状态码: {}", statusCode);
|
|
|
+ return AjaxResult.error("请求失败,状态码: " + statusCode);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("发生未知异常", e);
|
|
|
+ }
|
|
|
+ return AjaxResult.success("操作成功,暂无数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 无人机详细信息
|
|
|
+ */
|
|
|
+ @GetMapping("/getCopterBasicData/{copterId}")
|
|
|
+ public AjaxResult getCopterBasicData(@PathVariable("copterId") String copterId) {
|
|
|
+ String token = getToken();
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(token);
|
|
|
+ if (token == null) {
|
|
|
+ return AjaxResult.error("获取 token 失败");
|
|
|
+ }
|
|
|
+ try (CloseableHttpClient httpClient = createCustomHttpClient()) {
|
|
|
+ R<String> requestResult = remoteService.uavSignUrl();
|
|
|
+ if (requestResult == null || requestResult.getData() == null) {
|
|
|
+ log.error("获取的请求 URL 为空");
|
|
|
+ return AjaxResult.error("获取的请求 URL 为空");
|
|
|
+ }
|
|
|
+ String requestUrl = requestResult.getData();
|
|
|
+ // 使用 HttpGet 进行 GET 请求
|
|
|
+ HttpGet httpGet = new HttpGet(requestUrl + "/etkqq/copterMetaData/getCopterBasicData?copterId=" + copterId);
|
|
|
+ httpGet.setHeader("Authorization", jsonObject.get("token").toString());
|
|
|
+ // 发送请求
|
|
|
+ HttpResponse response = httpClient.execute(httpGet);
|
|
|
+ int statusCode = response.getStatusLine().getStatusCode();
|
|
|
+ if (statusCode == 200) {
|
|
|
+ HttpEntity responseEntity = response.getEntity();
|
|
|
+ if (responseEntity != null) {
|
|
|
+ JSONObject json = JSON.parseObject(EntityUtils.toString(responseEntity, StandardCharsets.UTF_8));
|
|
|
+ return AjaxResult.success(json.get("retMsg").toString(), json.get("result"));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.error("请求失败,状态码: {}", statusCode);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("发生未知异常", e);
|
|
|
+ }
|
|
|
+ return AjaxResult.success("操作成功,暂无数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 机库组织树
|
|
|
+ */
|
|
|
+ @GetMapping("/getOrgTree")
|
|
|
+ public AjaxResult getOrgTree() {
|
|
|
+ String token = getToken();
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(token);
|
|
|
+ if (token == null) {
|
|
|
+ return AjaxResult.error("获取 token 失败");
|
|
|
+ }
|
|
|
+ try (CloseableHttpClient httpClient = createCustomHttpClient()) {
|
|
|
+ R<String> requestResult = remoteService.uavSignUrl();
|
|
|
+ if (requestResult == null || requestResult.getData() == null) {
|
|
|
+ log.error("获取的请求 URL 为空");
|
|
|
+ return AjaxResult.error("获取的请求 URL 为空");
|
|
|
+ }
|
|
|
+ String requestUrl = requestResult.getData();
|
|
|
+ // 使用 HttpGet 进行 GET 请求
|
|
|
+ HttpGet httpGet = new HttpGet(requestUrl + "/etkqq/security/getOrgTree");
|
|
|
+ httpGet.setHeader("Authorization", jsonObject.get("token").toString());
|
|
|
+ // 发送请求
|
|
|
+ HttpResponse response = httpClient.execute(httpGet);
|
|
|
+ int statusCode = response.getStatusLine().getStatusCode();
|
|
|
+ if (statusCode == 200) {
|
|
|
+ HttpEntity responseEntity = response.getEntity();
|
|
|
+ if (responseEntity != null) {
|
|
|
+ JSONObject json = JSON.parseObject(EntityUtils.toString(responseEntity, StandardCharsets.UTF_8));
|
|
|
+ return AjaxResult.success(json.get("retMsg").toString(), json.get("result"));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.error("请求失败,状态码: {}", statusCode);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("发生未知异常", e);
|
|
|
+ }
|
|
|
+ return AjaxResult.success("操作成功,暂无数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 机库详细信息
|
|
|
+ */
|
|
|
+ @GetMapping("/getBoxBasicData/{boxId}")
|
|
|
+ public AjaxResult getBoxBasicData(@PathVariable("boxId") String boxId) {
|
|
|
+ String token = getToken();
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(token);
|
|
|
+ if (token == null) {
|
|
|
+ return AjaxResult.error("获取 token 失败");
|
|
|
+ }
|
|
|
+ try (CloseableHttpClient httpClient = createCustomHttpClient()) {
|
|
|
+ R<String> requestResult = remoteService.uavSignUrl();
|
|
|
+ if (requestResult == null || requestResult.getData() == null) {
|
|
|
+ log.error("获取的请求 URL 为空");
|
|
|
+ return AjaxResult.error("获取的请求 URL 为空");
|
|
|
+ }
|
|
|
+ String requestUrl = requestResult.getData();
|
|
|
+ // 使用 HttpGet 进行 GET 请求
|
|
|
+ HttpGet httpGet = new HttpGet(requestUrl + "/etkqq/boxMetaData/getBoxBasicData?boxId=" + boxId);
|
|
|
+ httpGet.setHeader("Authorization", jsonObject.get("token").toString());
|
|
|
+ // 发送请求
|
|
|
+ HttpResponse response = httpClient.execute(httpGet);
|
|
|
+ int statusCode = response.getStatusLine().getStatusCode();
|
|
|
+ if (statusCode == 200) {
|
|
|
+ HttpEntity responseEntity = response.getEntity();
|
|
|
+ if (responseEntity != null) {
|
|
|
+ JSONObject json = JSON.parseObject(EntityUtils.toString(responseEntity, StandardCharsets.UTF_8));
|
|
|
+ return AjaxResult.success(json.get("retMsg").toString(), json.get("result"));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.error("请求失败,状态码: {}", statusCode);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("发生未知异常", e);
|
|
|
+ }
|
|
|
+ return AjaxResult.success("操作成功,暂无数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 无人机直播视频
|
|
|
+ */
|
|
|
+ @PostMapping("/openLive")
|
|
|
+ public AjaxResult openLive(@RequestBody Map<String, Object> map) {
|
|
|
+ String token = getToken();
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(token);
|
|
|
+ if (token == null) {
|
|
|
+ return AjaxResult.error("获取 token 失败");
|
|
|
+ }
|
|
|
+ R<String> requestResult = remoteService.uavSignUrl();
|
|
|
+ if (requestResult == null || requestResult.getData() == null) {
|
|
|
+ log.error("获取的请求 URL 为空");
|
|
|
+ return AjaxResult.error("获取的请求 URL 为空");
|
|
|
+ }
|
|
|
+ String requestUrl = requestResult.getData();
|
|
|
+ try (CloseableHttpClient httpClient = createCustomHttpClient()) {
|
|
|
+ HttpPost httpPost = new HttpPost(requestUrl + "/etkqq/box/openLive");
|
|
|
+ // 使用 JSON 处理库构建请求体
|
|
|
+ String requestBody = "{" +
|
|
|
+ "\"copterId\": \"" + map.get("copterId") + "\", " +
|
|
|
+ "\"boxId\": \"" + map.get("boxId") + "\", " +
|
|
|
+ "\"copterSn\": \"" + map.get("copterSn") + "\", " +
|
|
|
+ "\"boxSn\": \"" + map.get("boxSn") + "\" ," +
|
|
|
+ "\"type\": \"" + map.get("type") + "\"}";
|
|
|
+ StringEntity entity = new StringEntity(requestBody, StandardCharsets.UTF_8);
|
|
|
+ httpPost.setEntity(entity);
|
|
|
+ httpPost.setHeader("Content-Type", "application/json");
|
|
|
+ httpPost.setHeader("Authorization", jsonObject.get("token").toString());
|
|
|
+
|
|
|
+ // 发送请求
|
|
|
+ HttpResponse response = httpClient.execute(httpPost);
|
|
|
+ int statusCode = response.getStatusLine().getStatusCode();
|
|
|
+ if (statusCode == 200) {
|
|
|
+ HttpEntity responseEntity = response.getEntity();
|
|
|
+ if (responseEntity != null) {
|
|
|
+ JSONObject json = JSON.parseObject(EntityUtils.toString(responseEntity, StandardCharsets.UTF_8));
|
|
|
+ return AjaxResult.success(json.get("retMsg").toString(), json.get("result"));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.error("请求失败,状态码: {}", statusCode);
|
|
|
+ return AjaxResult.error("请求失败,状态码: " + statusCode);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("发生未知异常", e);
|
|
|
+ }
|
|
|
+ return AjaxResult.success("操作成功,暂无数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 无人机控制指令
|
|
|
+ */
|
|
|
+ @PostMapping("/realControl")
|
|
|
+ public AjaxResult realControl(@RequestBody Map<String, Object> map) {
|
|
|
+ String token = getToken();
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(token);
|
|
|
+ if (token == null) {
|
|
|
+ return AjaxResult.error("获取 token 失败");
|
|
|
+ }
|
|
|
+ R<String> requestResult = remoteService.uavSignUrl();
|
|
|
+ if (requestResult == null || requestResult.getData() == null) {
|
|
|
+ log.error("获取的请求 URL 为空");
|
|
|
+ return AjaxResult.error("获取的请求 URL 为空");
|
|
|
+ }
|
|
|
+ String requestUrl = requestResult.getData();
|
|
|
+ try (CloseableHttpClient httpClient = createCustomHttpClient()) {
|
|
|
+ HttpPost httpPost = new HttpPost(requestUrl + "/etkqq/box/realControl");
|
|
|
+ // 使用 JSON 处理库构建请求体
|
|
|
+ LinkedHashMap<String, Object> point = (LinkedHashMap<String, Object>) map.get("point");
|
|
|
+ String requestBody = "{" +
|
|
|
+ "\"boxId\": \"" + map.get("boxId") + "\", " +
|
|
|
+ "\"copterId\": \"" + map.get("copterId") + "\", " +
|
|
|
+ "\"boxSn\": \"" + map.get("boxSn") + "\" ," +
|
|
|
+ "\"code\": \"" + map.get("code") + "\", " +
|
|
|
+ "\"speed\": \"" + map.get("speed") + "\", " +
|
|
|
+ "\"angle\": \"" + map.get("angle") + "\", " +
|
|
|
+ "\"mode\": \"" + map.get("mode") + "\", " +
|
|
|
+ "\"point\": {" +
|
|
|
+ "\"latitude\": \"" + point.get("latitude") + "\", " +
|
|
|
+ "\"longitude\": \"" + point.get("longitude") + "\", " +
|
|
|
+ "\"altitude\": \"" + point.get("altitude") + "\"" +
|
|
|
+ "}" +
|
|
|
+ "}";
|
|
|
+ StringEntity entity = new StringEntity(requestBody, StandardCharsets.UTF_8);
|
|
|
+ httpPost.setEntity(entity);
|
|
|
+ httpPost.setHeader("Content-Type", "application/json");
|
|
|
+ httpPost.setHeader("Authorization", jsonObject.get("token").toString());
|
|
|
+ // 发送请求
|
|
|
+ HttpResponse response = httpClient.execute(httpPost);
|
|
|
+ int statusCode = response.getStatusLine().getStatusCode();
|
|
|
+ if (statusCode == 200) {
|
|
|
+ HttpEntity responseEntity = response.getEntity();
|
|
|
+ if (responseEntity != null) {
|
|
|
+ JSONObject json = JSON.parseObject(EntityUtils.toString(responseEntity, StandardCharsets.UTF_8));
|
|
|
+ return AjaxResult.success(json.get("retMsg").toString());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.error("请求失败,状态码: {}", statusCode);
|
|
|
+ return AjaxResult.error("请求失败,状态码: " + statusCode);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("发生未知异常", e);
|
|
|
+ }
|
|
|
+ return AjaxResult.success("操作成功,暂无数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 无人机实时轨迹
|
|
|
+ */
|
|
|
+ @PostMapping("/currentWayline")
|
|
|
+ public AjaxResult currentWayline(@RequestBody Map<String, Object> map) {
|
|
|
+ String token = getToken();
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(token);
|
|
|
+ if (token == null) {
|
|
|
+ return AjaxResult.error("获取 token 失败");
|
|
|
+ }
|
|
|
+ R<String> requestResult = remoteService.uavSignUrl();
|
|
|
+ if (requestResult == null || requestResult.getData() == null) {
|
|
|
+ log.error("获取的请求 URL 为空");
|
|
|
+ return AjaxResult.error("获取的请求 URL 为空");
|
|
|
+ }
|
|
|
+ String requestUrl = requestResult.getData();
|
|
|
+ try (CloseableHttpClient httpClient = createCustomHttpClient()) {
|
|
|
+ HttpPost httpPost = new HttpPost(requestUrl + "/etkqq/task/currentWayline");
|
|
|
+ // 使用 JSON 处理库构建请求体
|
|
|
+ String requestBody = "{\"copterSn\": \"" + map.get("copterSn") + "\"}";
|
|
|
+ StringEntity entity = new StringEntity(requestBody, StandardCharsets.UTF_8);
|
|
|
+ httpPost.setEntity(entity);
|
|
|
+ httpPost.setHeader("Content-Type", "application/json");
|
|
|
+ httpPost.setHeader("Authorization", jsonObject.get("token").toString());
|
|
|
+ // 发送请求
|
|
|
+ HttpResponse response = httpClient.execute(httpPost);
|
|
|
+ int statusCode = response.getStatusLine().getStatusCode();
|
|
|
+ if (statusCode == 200) {
|
|
|
+ HttpEntity responseEntity = response.getEntity();
|
|
|
+ if (responseEntity != null) {
|
|
|
+ JSONObject json = JSON.parseObject(EntityUtils.toString(responseEntity, StandardCharsets.UTF_8));
|
|
|
+ return AjaxResult.success(json.get("retMsg").toString(), json.get("result"));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.error("请求失败,状态码: {}", statusCode);
|
|
|
+ return AjaxResult.error("请求失败,状态码: " + statusCode);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("发生未知异常", e);
|
|
|
+ }
|
|
|
+ return AjaxResult.success("操作成功,暂无数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 无人机历史轨迹
|
|
|
+ */
|
|
|
+ @PostMapping("/historyWayline")
|
|
|
+ public AjaxResult historyWayline(@RequestBody Map<String, Object> map) {
|
|
|
+ String token = getToken();
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(token);
|
|
|
+ if (token == null) {
|
|
|
+ return AjaxResult.error("获取 token 失败");
|
|
|
+ }
|
|
|
+ R<String> requestResult = remoteService.uavSignUrl();
|
|
|
+ if (requestResult == null || requestResult.getData() == null) {
|
|
|
+ log.error("获取的请求 URL 为空");
|
|
|
+ return AjaxResult.error("获取的请求 URL 为空");
|
|
|
+ }
|
|
|
+ String requestUrl = requestResult.getData();
|
|
|
+ try (CloseableHttpClient httpClient = createCustomHttpClient()) {
|
|
|
+ HttpPost httpPost = new HttpPost(requestUrl + "/etkqq/task/historyWayline");
|
|
|
+ // 使用 JSON 处理库构建请求体
|
|
|
+ String requestBody = "{\"copterSn\": \"" + map.get("copterSn") + "\"}";
|
|
|
+ StringEntity entity = new StringEntity(requestBody, StandardCharsets.UTF_8);
|
|
|
+ httpPost.setEntity(entity);
|
|
|
+ httpPost.setHeader("Content-Type", "application/json");
|
|
|
+ httpPost.setHeader("Authorization", jsonObject.get("token").toString());
|
|
|
+ // 发送请求
|
|
|
+ HttpResponse response = httpClient.execute(httpPost);
|
|
|
+ int statusCode = response.getStatusLine().getStatusCode();
|
|
|
+ if (statusCode == 200) {
|
|
|
+ HttpEntity responseEntity = response.getEntity();
|
|
|
+ if (responseEntity != null) {
|
|
|
+ JSONObject json = JSON.parseObject(EntityUtils.toString(responseEntity, StandardCharsets.UTF_8));
|
|
|
+ return AjaxResult.success(json.get("retMsg").toString(), json.get("result"));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.error("请求失败,状态码: {}", statusCode);
|
|
|
+ return AjaxResult.error("请求失败,状态码: " + statusCode);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("发生未知异常", e);
|
|
|
+ }
|
|
|
+ return AjaxResult.success("操作成功,暂无数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 喊话器喊话
|
|
|
+ */
|
|
|
+ @PostMapping("/drcSpeakerTtsPlayStart")
|
|
|
+ public AjaxResult drcSpeakerTtsPlayStart(@RequestBody Map<String, Object> map) {
|
|
|
+ String token = getToken();
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(token);
|
|
|
+ if (token == null) {
|
|
|
+ return AjaxResult.error("获取 token 失败");
|
|
|
+ }
|
|
|
+ R<String> requestResult = remoteService.uavSignUrl();
|
|
|
+ if (requestResult == null || requestResult.getData() == null) {
|
|
|
+ log.error("获取的请求 URL 为空");
|
|
|
+ return AjaxResult.error("获取的请求 URL 为空");
|
|
|
+ }
|
|
|
+ String requestUrl = requestResult.getData();
|
|
|
+ try (CloseableHttpClient httpClient = createCustomHttpClient()) {
|
|
|
+ HttpPost httpPost = new HttpPost(requestUrl + "/etkqq/box/drcSpeakerTtsPlayStart");
|
|
|
+ // 使用 JSON 处理库构建请求体
|
|
|
+ String requestBody = "{" +
|
|
|
+ "\"boxSn\": \"" + map.get("boxSn") + "\" ," +
|
|
|
+ "\"copterSn\": \"" + map.get("copterSn") + "\", " +
|
|
|
+ "\"name\": \"" + map.get("name") + "\", " +
|
|
|
+ "\"text\": \"" + map.get("text") + "\"}";
|
|
|
+ StringEntity entity = new StringEntity(requestBody, StandardCharsets.UTF_8);
|
|
|
+ httpPost.setEntity(entity);
|
|
|
+ httpPost.setHeader("Content-Type", "application/json");
|
|
|
+ httpPost.setHeader("Authorization", jsonObject.get("token").toString());
|
|
|
+
|
|
|
+ // 发送请求
|
|
|
+ HttpResponse response = httpClient.execute(httpPost);
|
|
|
+ int statusCode = response.getStatusLine().getStatusCode();
|
|
|
+ if (statusCode == 200) {
|
|
|
+ HttpEntity responseEntity = response.getEntity();
|
|
|
+ if (responseEntity != null) {
|
|
|
+ JSONObject json = JSON.parseObject(EntityUtils.toString(responseEntity, StandardCharsets.UTF_8));
|
|
|
+ return AjaxResult.success(json.get("retMsg").toString());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.error("请求失败,状态码: {}", statusCode);
|
|
|
+ return AjaxResult.error("请求失败,状态码: " + statusCode);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("发生未知异常", e);
|
|
|
+ }
|
|
|
+ return AjaxResult.success("操作成功,暂无数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 开始执行计划
|
|
|
+ */
|
|
|
+ @GetMapping("/startPlan")
|
|
|
+ public AjaxResult startPlan(@RequestParam(value = "boxSn") String boxSn, @RequestParam(value = "planId") String planId) {
|
|
|
+ String token = getToken();
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(token);
|
|
|
+ if (token == null) {
|
|
|
+ return AjaxResult.error("获取 token 失败");
|
|
|
+ }
|
|
|
+ try (CloseableHttpClient httpClient = createCustomHttpClient()) {
|
|
|
+ R<String> requestResult = remoteService.uavSignUrl();
|
|
|
+ if (requestResult == null || requestResult.getData() == null) {
|
|
|
+ log.error("获取的请求 URL 为空");
|
|
|
+ return AjaxResult.error("获取的请求 URL 为空");
|
|
|
+ }
|
|
|
+ String requestUrl = requestResult.getData();
|
|
|
+ // 使用 HttpGet 进行 GET 请求
|
|
|
+ HttpGet httpGet = new HttpGet(requestUrl + "/etkqq/boxMetaData/getBoxBasicData?boxSn=" + boxSn + "&planId=" + planId);
|
|
|
+ httpGet.setHeader("Authorization", jsonObject.get("token").toString());
|
|
|
+ // 发送请求
|
|
|
+ HttpResponse response = httpClient.execute(httpGet);
|
|
|
+ int statusCode = response.getStatusLine().getStatusCode();
|
|
|
+ if (statusCode == 200) {
|
|
|
+ HttpEntity responseEntity = response.getEntity();
|
|
|
+ if (responseEntity != null) {
|
|
|
+ JSONObject json = JSON.parseObject(EntityUtils.toString(responseEntity, StandardCharsets.UTF_8));
|
|
|
+ return AjaxResult.success(json.get("retMsg").toString());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.error("请求失败,状态码: {}", statusCode);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("发生未知异常", e);
|
|
|
+ }
|
|
|
+ return AjaxResult.success("操作成功,暂无数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 快速执飞
|
|
|
+ */
|
|
|
+ @PostMapping("/fastFlying")
|
|
|
+ public AjaxResult fastFlying(@RequestBody Map<String, Object> map) {
|
|
|
+ String token = getToken();
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(token);
|
|
|
+ if (token == null) {
|
|
|
+ return AjaxResult.error("获取 token 失败");
|
|
|
+ }
|
|
|
+ R<String> requestResult = remoteService.uavSignUrl();
|
|
|
+ if (requestResult == null || requestResult.getData() == null) {
|
|
|
+ log.error("获取的请求 URL 为空");
|
|
|
+ return AjaxResult.error("获取的请求 URL 为空");
|
|
|
+ }
|
|
|
+ String requestUrl = requestResult.getData();
|
|
|
+ try (CloseableHttpClient httpClient = createCustomHttpClient()) {
|
|
|
+ HttpPost httpPost = new HttpPost(requestUrl + "/etkqq/plan/fastFlying");
|
|
|
+ // 使用 JSON 处理库构建请求体
|
|
|
+ String requestBody = "{" +
|
|
|
+ "\"boxSn\": \"" + map.get("boxSn") + "\" ," +
|
|
|
+ "\"boxId\": \"" + map.get("boxId") + "\", " +
|
|
|
+ "\"copterId\": \"" + map.get("copterId") + "\", " +
|
|
|
+ "\"copterSn\": \"" + map.get("copterSn") + "\", " +
|
|
|
+ "\"longitude\": \"" + map.get("longitude") + "\", " +
|
|
|
+ "\"latitude\": \"" + map.get("latitude") + "\", " +
|
|
|
+ "\"flySpeed\": \"" + map.get("flySpeed") + "\", " +
|
|
|
+ "\"boxPosition\": \"" + map.get("boxPosition") + "\", " +
|
|
|
+ "\"expand2\": \"" + map.get("expand2") + "\"}";
|
|
|
+ StringEntity entity = new StringEntity(requestBody, StandardCharsets.UTF_8);
|
|
|
+ httpPost.setEntity(entity);
|
|
|
+ httpPost.setHeader("Content-Type", "application/json");
|
|
|
+ httpPost.setHeader("Authorization", jsonObject.get("token").toString());
|
|
|
+
|
|
|
+ // 发送请求
|
|
|
+ HttpResponse response = httpClient.execute(httpPost);
|
|
|
+ int statusCode = response.getStatusLine().getStatusCode();
|
|
|
+ if (statusCode == 200) {
|
|
|
+ HttpEntity responseEntity = response.getEntity();
|
|
|
+ if (responseEntity != null) {
|
|
|
+ JSONObject json = JSON.parseObject(EntityUtils.toString(responseEntity, StandardCharsets.UTF_8));
|
|
|
+ return AjaxResult.success(json.get("retMsg").toString());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.error("请求失败,状态码: {}", statusCode);
|
|
|
+ return AjaxResult.error("请求失败,状态码: " + statusCode);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("发生未知异常", e);
|
|
|
+ }
|
|
|
+ return AjaxResult.success("操作成功,暂无数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 规划航线
|
|
|
+ */
|
|
|
+ //todo 待完善 且调用接口返回500 根据增删改查修改返回类型
|
|
|
+ @PostMapping("/operationTask")
|
|
|
+ public AjaxResult operationTask(@RequestBody CentermonitorTUavDTO dto) {
|
|
|
+ String token = getToken();
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(token);
|
|
|
+ if (token == null) {
|
|
|
+ return AjaxResult.error("获取 token 失败");
|
|
|
+ }
|
|
|
+ R<String> requestResult = remoteService.uavSignUrl();
|
|
|
+ if (requestResult == null || requestResult.getData() == null) {
|
|
|
+ log.error("获取的请求 URL 为空");
|
|
|
+ return AjaxResult.error("获取的请求 URL 为空");
|
|
|
+ }
|
|
|
+ LinkedHashMap<String, Object> task = new LinkedHashMap<>();
|
|
|
+ task.put("taskType", dto.getTaskType());
|
|
|
+ task.put("taskName", dto.getTaskName());
|
|
|
+ task.put("heightMode", dto.getHeightMode());
|
|
|
+ task.put("relativeHeight", dto.getRelativeHeight());
|
|
|
+ task.put("globalHeight", dto.getGlobalHeight());
|
|
|
+ task.put("returnAltitude", dto.getReturnAltitude());
|
|
|
+ task.put("completeAction", dto.getCompleteAction());
|
|
|
+ task.put("flySpeed", dto.getFlySpeed());
|
|
|
+ task.put("lostSignal", dto.getLostSignal());
|
|
|
+ task.put("flyCourse", dto.getFlyCourse());
|
|
|
+ task.put("flySeconds", dto.getFlySeconds());
|
|
|
+ task.put("waypointNum", dto.getWaypointNum());
|
|
|
+ task.put("boxPosition", dto.getBoxPosition());
|
|
|
+ task.put("resolution", dto.getResolution());
|
|
|
+ task.put("headingOverlap", dto.getHeadingOverlap());
|
|
|
+ task.put("sideOverlap", dto.getSideOverlap());
|
|
|
+ task.put("heading", dto.getHeading());
|
|
|
+ task.put("wayLineYaw", dto.getWayLineYaw());
|
|
|
+ task.put("cameraId", dto.getCameraId());
|
|
|
+ task.put("wayPointList", dto.getWayPointList());
|
|
|
+ task.put("boxId", dto.getBoxId());
|
|
|
+ task.put("type", dto.getType());
|
|
|
+ String requestUrl = requestResult.getData();
|
|
|
+ try (CloseableHttpClient httpClient = createCustomHttpClient()) {
|
|
|
+ HttpPost httpPost = new HttpPost(requestUrl + "/etkqq/task/operationTask");
|
|
|
+ // 使用 JSON 处理库构建请求体
|
|
|
+ String requestBody = JSONObject.toJSONString(task);
|
|
|
+ StringEntity entity = new StringEntity(requestBody, StandardCharsets.UTF_8);
|
|
|
+ httpPost.setEntity(entity);
|
|
|
+ httpPost.setHeader("Content-Type", "application/json");
|
|
|
+ httpPost.setHeader("Authorization", jsonObject.get("token").toString());
|
|
|
+
|
|
|
+ // 发送请求
|
|
|
+ HttpResponse response = httpClient.execute(httpPost);
|
|
|
+ int statusCode = response.getStatusLine().getStatusCode();
|
|
|
+ if (statusCode == 200) {
|
|
|
+ HttpEntity responseEntity = response.getEntity();
|
|
|
+ if (responseEntity != null) {
|
|
|
+ JSONObject json = JSON.parseObject(EntityUtils.toString(responseEntity, StandardCharsets.UTF_8));
|
|
|
+ return AjaxResult.success(json.get("retMsg").toString());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.error("请求失败,状态码: {}", statusCode);
|
|
|
+ return AjaxResult.error("请求失败,状态码: " + statusCode);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("发生未知异常", e);
|
|
|
+ }
|
|
|
+ //todo websocket
|
|
|
+ WebSocketUsers.sendMessageToUsersByText(JSON.toJSONString(AjaxResult.success("10002",new ArrayList<>())));
|
|
|
+ return AjaxResult.success("操作成功,暂无数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 规划计划
|
|
|
+ */
|
|
|
+ //todo 待完善 且调用接口返回500 根据增删改查修改返回类型
|
|
|
+ @PostMapping("/operationPlan")
|
|
|
+ public AjaxResult operationPlan(@RequestBody Map<String, Object> map) {
|
|
|
+ String token = getToken();
|
|
|
+ JSONObject jsonObject = JSONObject.parseObject(token);
|
|
|
+ if (token == null) {
|
|
|
+ return AjaxResult.error("获取 token 失败");
|
|
|
+ }
|
|
|
+ R<String> requestResult = remoteService.uavSignUrl();
|
|
|
+ if (requestResult == null || requestResult.getData() == null) {
|
|
|
+ log.error("获取的请求 URL 为空");
|
|
|
+ return AjaxResult.error("获取的请求 URL 为空");
|
|
|
+ }
|
|
|
+ String requestUrl = requestResult.getData();
|
|
|
+ try (CloseableHttpClient httpClient = createCustomHttpClient()) {
|
|
|
+ HttpPost httpPost = new HttpPost(requestUrl + "/etkqq/plan/operationPlan");
|
|
|
+ // 使用 JSON 处理库构建请求体
|
|
|
+ String requestBody = "{" +
|
|
|
+ "\"caption\": \"" + map.get("caption") + "\" ," +
|
|
|
+ "\"planType\": \"" + map.get("planType") + "\", " +
|
|
|
+ "\"businessType\": \"" + map.get("businessType") + "\", " +
|
|
|
+ "\"isAi\": \"" + map.get("isAi") + "\", " +
|
|
|
+ "\"aiMode\": \"" + map.get("aiMode") + "\", " +
|
|
|
+ "\"isHover\": \"" + map.get("isHover") + "\", " +
|
|
|
+ "\"taskId\": \"" + map.get("taskId") + "\", " +
|
|
|
+ "\"type\": \"" + map.get("type") + "\", " +
|
|
|
+ "\"boxId\": \"" + map.get("boxId") + "\"}";
|
|
|
+ StringEntity entity = new StringEntity(requestBody, StandardCharsets.UTF_8);
|
|
|
+ httpPost.setEntity(entity);
|
|
|
+ httpPost.setHeader("Content-Type", "application/json");
|
|
|
+ httpPost.setHeader("Authorization", jsonObject.get("token").toString());
|
|
|
+
|
|
|
+ // 发送请求
|
|
|
+ HttpResponse response = httpClient.execute(httpPost);
|
|
|
+ int statusCode = response.getStatusLine().getStatusCode();
|
|
|
+ if (statusCode == 200) {
|
|
|
+ HttpEntity responseEntity = response.getEntity();
|
|
|
+ if (responseEntity != null) {
|
|
|
+ JSONObject json = JSON.parseObject(EntityUtils.toString(responseEntity, StandardCharsets.UTF_8));
|
|
|
+ return AjaxResult.success(json.get("retMsg").toString());
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ log.error("请求失败,状态码: {}", statusCode);
|
|
|
+ return AjaxResult.error("请求失败,状态码: " + statusCode);
|
|
|
+ }
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("发生未知异常", e);
|
|
|
+ }
|
|
|
+ return AjaxResult.success("操作成功,暂无数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 无人机机库实时数据
|
|
|
+ */
|
|
|
+ //todo 未测试接口连通性
|
|
|
+ @GetMapping("/getHangarRealTimeData")
|
|
|
+ public String getHangarRealTimeData(@RequestParam(value = "copterSn") String copterSn,@RequestParam(value = "boxSn") String boxSn) {
|
|
|
+ final CountDownLatch latch = new CountDownLatch(1);
|
|
|
+ final StringBuilder response = new StringBuilder();
|
|
|
+ try {
|
|
|
+ WebSocketContainer container = ContainerProvider.getWebSocketContainer();
|
|
|
+ String uri = "wss://47.93.50.30/etkqq/api/websocket/100";
|
|
|
+
|
|
|
+ Session session = container.connectToServer(new Endpoint() {
|
|
|
+ @Override
|
|
|
+ public void onOpen(Session session, EndpointConfig config) {
|
|
|
+ String message = String.format("{\"copterSn\": \"%s\", \"boxSn\": \"%s\"}",
|
|
|
+ copterSn, boxSn);
|
|
|
+ session.addMessageHandler(new MessageHandler.Whole<String>() {
|
|
|
+ @Override
|
|
|
+ public void onMessage(String msg) {
|
|
|
+ response.append(msg);
|
|
|
+ latch.countDown();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ session.getAsyncRemote().sendText(message);
|
|
|
+ }
|
|
|
+ }, ClientEndpointConfig.Builder.create().build(), new URI(uri));
|
|
|
+ latch.await(10, TimeUnit.SECONDS);
|
|
|
+ session.close();
|
|
|
+ return response.toString();
|
|
|
+ } catch (Exception e) {
|
|
|
+ return "Error: " + e.getMessage();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 机库日志
|
|
|
+ */
|
|
|
+ //todo 未测试接口连通性
|
|
|
+ @GetMapping("/getHangarLog")
|
|
|
+ public String getHangarLog(@RequestParam(value = "copterSn") String copterSn,@RequestParam(value = "boxSn") String boxSn) {
|
|
|
+ final CountDownLatch latch = new CountDownLatch(1);
|
|
|
+ final StringBuilder response = new StringBuilder();
|
|
|
+ try {
|
|
|
+ WebSocketContainer container = ContainerProvider.getWebSocketContainer();
|
|
|
+ String uri = "wss://47.93.50.30/etkqq/api/websocket/102";
|
|
|
+
|
|
|
+ Session session = container.connectToServer(new Endpoint() {
|
|
|
+ @Override
|
|
|
+ public void onOpen(Session session, EndpointConfig config) {
|
|
|
+ String message = String.format("{\"copterSn\": \"%s\", \"boxSn\": \"%s\"}",
|
|
|
+ copterSn, boxSn);
|
|
|
+ session.addMessageHandler(new MessageHandler.Whole<String>() {
|
|
|
+ @Override
|
|
|
+ public void onMessage(String msg) {
|
|
|
+ response.append(msg);
|
|
|
+ latch.countDown();
|
|
|
+ }
|
|
|
+ });
|
|
|
+ session.getAsyncRemote().sendText(message);
|
|
|
+ }
|
|
|
+ }, ClientEndpointConfig.Builder.create().build(), new URI(uri));
|
|
|
+ latch.await(10, TimeUnit.SECONDS);
|
|
|
+ session.close();
|
|
|
+ return response.toString();
|
|
|
+ } catch (Exception e) {
|
|
|
+ return "Error: " + e.getMessage();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 工厂方法:创建自定义配置的 HttpClient
|
|
|
+ *
|
|
|
+ * @return 配置好的 CloseableHttpClient 实例
|
|
|
+ * @throws Exception 如果配置过程中发生错误
|
|
|
+ */
|
|
|
+ private CloseableHttpClient createCustomHttpClient() throws Exception {
|
|
|
+ // 设置请求超时配置
|
|
|
+ RequestConfig requestConfig = RequestConfig.custom()
|
|
|
+ .setConnectTimeout(5000) // 连接超时:5秒
|
|
|
+ .setSocketTimeout(10000) // 读取超时:10秒
|
|
|
+ .setConnectionRequestTimeout(3000) // 请求连接超时:3秒
|
|
|
+ .build();
|
|
|
+
|
|
|
+ // 配置 SSL 上下文(可根据需求启用或禁用 SSL 验证)
|
|
|
+ SSLContext sslContext = SSLContextBuilder.create()
|
|
|
+ .loadTrustMaterial((chain, authType) -> true) // 忽略证书验证(仅用于测试环境)
|
|
|
+ .build();
|
|
|
+
|
|
|
+ return HttpClients.custom()
|
|
|
+ .setDefaultRequestConfig(requestConfig)
|
|
|
+ .setSSLContext(sslContext)
|
|
|
+ .setSSLHostnameVerifier(new NoopHostnameVerifier()) // 忽略主机名验证(仅用于测试环境)
|
|
|
+ .build();
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 查询无人机列表
|
|
|
+ */
|
|
|
+ @GetMapping("/list")
|
|
|
+ public TableDataInfo list(CentermonitorTUav centermonitorTUav) {
|
|
|
+ startPage();
|
|
|
+ List<CentermonitorTUav> list = centermonitorTUavService.selectCentermonitorTUavList(centermonitorTUav);
|
|
|
+ return getDataTable(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 导出无人机列表
|
|
|
+ */
|
|
|
+ @Log(title = "无人机", businessType = BusinessType.EXPORT)
|
|
|
+ @PostMapping("/export")
|
|
|
+ public void export(HttpServletResponse response, CentermonitorTUav centermonitorTUav) {
|
|
|
+ List<CentermonitorTUav> list = centermonitorTUavService.selectCentermonitorTUavList(centermonitorTUav);
|
|
|
+ ExcelUtil<CentermonitorTUav> util = new ExcelUtil<CentermonitorTUav>(CentermonitorTUav.class);
|
|
|
+ util.exportExcel(response, list, "无人机数据");
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取无人机详细信息
|
|
|
+ */
|
|
|
+ @GetMapping(value = "/{id}")
|
|
|
+ public AjaxResult getInfo(@PathVariable("id") Long id) {
|
|
|
+ return AjaxResult.success(centermonitorTUavService.selectCentermonitorTUavById(id));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 新增无人机
|
|
|
+ */
|
|
|
+ @Log(title = "无人机", businessType = BusinessType.INSERT)
|
|
|
+ @PostMapping
|
|
|
+ public AjaxResult add(@RequestBody CentermonitorTUav centermonitorTUav) {
|
|
|
+ return toAjax(centermonitorTUavService.insertCentermonitorTUav(centermonitorTUav));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 修改无人机
|
|
|
+ */
|
|
|
+ @Log(title = "无人机", businessType = BusinessType.UPDATE)
|
|
|
+ @PutMapping
|
|
|
+ public AjaxResult edit(@RequestBody CentermonitorTUav centermonitorTUav) {
|
|
|
+ return toAjax(centermonitorTUavService.updateCentermonitorTUav(centermonitorTUav));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 删除无人机
|
|
|
+ */
|
|
|
+ @Log(title = "无人机", businessType = BusinessType.DELETE)
|
|
|
+ @DeleteMapping("/{ids}")
|
|
|
+ public AjaxResult remove(@PathVariable Long[] ids) {
|
|
|
+ return toAjax(centermonitorTUavService.deleteCentermonitorTUavByIds(ids));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据部门id查询无人机列表
|
|
|
+ *
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ @GetMapping("/selectCentermonitorTUavByDeptId")
|
|
|
+ public AjaxResult selectCentermonitorTUavByDeptId() {
|
|
|
+ return AjaxResult.success(centermonitorTUavService.selectCentermonitorTUavByDeptId());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据uavId获取无人机及所属部门集合
|
|
|
+ */
|
|
|
+ @GetMapping("/selectUavByUavId/{uavId}")
|
|
|
+ public AjaxResult selectUavByUavId(@PathVariable("uavId") Long uavId) {
|
|
|
+ return AjaxResult.success(centermonitorTUavService.selectUavByUavId(uavId));
|
|
|
+ }
|
|
|
+
|
|
|
+}
|