From 0771b90c0e49714e1682dc133d1bebafb545dd5a Mon Sep 17 00:00:00 2001
From: zhangnaisong <2434969829@qq.com>
Date: 星期六, 02 三月 2024 19:45:12 +0800
Subject: [PATCH] app无人机航线管理提交
---
ard-work/src/main/java/com/ruoyi/device/uav/controller/ArdUavController.java | 52 ++++++++++
ard-work/src/main/java/com/ruoyi/device/uav/service/UavService.java | 192 ++++++++++++++++++++++++++++++++++++++
2 files changed, 244 insertions(+), 0 deletions(-)
diff --git a/ard-work/src/main/java/com/ruoyi/device/uav/controller/ArdUavController.java b/ard-work/src/main/java/com/ruoyi/device/uav/controller/ArdUavController.java
index f6f979e..b04234e 100644
--- a/ard-work/src/main/java/com/ruoyi/device/uav/controller/ArdUavController.java
+++ b/ard-work/src/main/java/com/ruoyi/device/uav/controller/ArdUavController.java
@@ -1,6 +1,8 @@
package com.ruoyi.device.uav.controller;
+import com.alibaba.fastjson.JSON;
import com.ruoyi.common.core.controller.BaseController;
+import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.device.uav.service.UavService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
@@ -65,5 +67,55 @@
return this.uavService.getToken();
}
+ @PostMapping("/checkPointValid")
+ @ApiOperation("鏃犱汉鏈烘娴嬭埅鐐规湁鏁堟�ф帴鍙�")
+ public Object checkPointValid(@RequestBody Map<String,Map<String,Object>> param) {
+ String url = "wayline/api/v1/waylines/planning/check_point_valid";
+ return this.uavService.checkPointValid(url, param);
+ }
+
+ @PostMapping("/checkLineValid")
+ @ApiOperation("鏃犱汉鏈烘娴嬬嚎璺湁鏁堟�ф帴鍙�")
+ public Object checkLineValid(@RequestBody Map<String,List<Map<String,String>>> param) {
+ String url = "wayline/api/v1/waylines/planning/check_line_valid";
+ return this.uavService.checkLineValid(url, param);
+ }
+
+ @GetMapping("/getWorkspaceId")
+ @ApiOperation("鑾峰彇宸ヤ綔绌洪棿涓婚敭")
+ public AjaxResult getWorkspaceId() {
+ try{
+ String workspaceId = this.uavService.getWorkspaceId();
+ if(workspaceId != null){
+ return AjaxResult.success(workspaceId);
+ }else{
+ return AjaxResult.success("");
+ }
+ }catch(Exception e){
+ e.printStackTrace();
+ return AjaxResult.error();
+ }
+ }
+
+ @PostMapping("/addWaylinesPlanning")
+ @ApiOperation("鏂板鑸嚎")
+ public Object addWaylinesPlanning(@RequestBody Map<String,Object> param) {
+ String url = "wayline/api/v1/waylines/planning";
+ return this.uavService.addWaylinesPlanning(url, param);
+ }
+
+ @DeleteMapping("/deleteWaylinesPlanning")
+ @ApiOperation("鍒犻櫎鑸嚎")
+ public Object deleteWaylinesPlanning(@RequestBody Map<String,String> param) {
+ String url = "wayline/api/v1/waylines/delete/";
+ return this.uavService.deleteWaylinesPlanning(url, param);
+ }
+
+ @PutMapping("/updateWaylinesPlanning")
+ @ApiOperation("淇敼鑸嚎")
+ public Object updateWaylinesPlanning(@RequestBody Map<String,Object> param) {
+ String url = "wayline/api/v1/waylines/update";
+ return this.uavService.updateWaylinesPlanning(url, param);
+ }
}
diff --git a/ard-work/src/main/java/com/ruoyi/device/uav/service/UavService.java b/ard-work/src/main/java/com/ruoyi/device/uav/service/UavService.java
index 3ce9f56..4fc1e7a 100644
--- a/ard-work/src/main/java/com/ruoyi/device/uav/service/UavService.java
+++ b/ard-work/src/main/java/com/ruoyi/device/uav/service/UavService.java
@@ -13,6 +13,7 @@
import com.ruoyi.sy.controller.ArdSyCarController;
import com.ruoyi.utils.forest.UavClient;
import lombok.extern.slf4j.Slf4j;
+import okhttp3.*;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.collections4.map.HashedMap;
import org.java_websocket.WebSocket;
@@ -58,6 +59,8 @@
private String token;
+ private String workspaceId;
+
@Autowired
private UavClient uavClient;
@Autowired
@@ -77,6 +80,10 @@
this.username = ConfigUtils.getConfigValue("uav_username");
this.password = ConfigUtils.getConfigValue("uav_password");
this.salt = ConfigUtils.getConfigValue("uav_salt");
+ /*this.host = "http://112.98.126.2:6100/";
+ this.username = "znstest";
+ this.password = "znstest";
+ this.salt = "0123456789012345";*/
if (StringUtils.isEmpty(this.host) || StringUtils.isEmpty(this.username) || StringUtils.isEmpty(this.password) || StringUtils.isEmpty(this.salt)) {
throw new RuntimeException("鏃犱汉鏈哄弬鏁伴厤缃己澶�:");
}
@@ -128,6 +135,7 @@
//token璧嬪��
this.token = token;
+ this.workspaceId = (String) uavUser.get("workspace_id");
} catch (ForestNetworkException fe) {
if (fe.getStatusCode() == 401) {//token澶辨晥,閲嶆柊鐧诲綍
this.login();
@@ -136,6 +144,7 @@
token = (String) uavUser.get("access_token");
//token璧嬪��
this.token = token;
+ this.workspaceId = (String) uavUser.get("workspace_id");
return token;
}
}
@@ -546,4 +555,187 @@
}
return new Base64().encodeToString(encrypted);//姝ゅ浣跨敤BASE64鍋氳浆鐮佸姛鑳斤紝鍚屾椂鑳借捣鍒�2娆″姞瀵嗙殑浣滅敤銆�
}
+
+ public Object checkPointValid(String url, Map<String,Map<String,Object>> data) {
+ String token = this.getToken();
+ url = this.host + url;
+ Map<String,Object> resultMap = checkPointValid(url,token, data);
+ return resultMap;
+ }
+
+ public Map<String,Object> checkPointValid(String url,String access_token,Map<String,Map<String,Object>> map){
+ MediaType mediaType = MediaType.parse("application/json; charset=utf-8");
+ OkHttpClient okHttpClient = new OkHttpClient();
+
+ RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(map));
+
+ Request request = new Request.Builder().url(url).post(body).addHeader("x-auth-token",access_token).build();
+
+ Response response = null;
+ try {
+ response = okHttpClient.newCall(request).execute();
+ } catch (IOException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+
+ ResponseBody responseBody = response.body();
+
+ try {
+ String message = responseBody.string();// 鍝嶅簲浣�
+ Map<String,Object> map0 = (Map<String, Object>) JSON.parse(message);
+ return map0;
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ return new HashMap();
+ }
+ }
+
+ public Object checkLineValid(String url, Map<String,List<Map<String,String>>> data) {
+ String token = this.getToken();
+ url = this.host + url;
+ Map<String,Object> resultMap = checkLineValid(url,token, data);
+ return resultMap;
+ }
+
+ public Map<String,Object> checkLineValid(String url,String access_token,Map<String,List<Map<String,String>>> map){
+ MediaType mediaType = MediaType.parse("application/json; charset=utf-8");
+ OkHttpClient okHttpClient = new OkHttpClient();
+
+ RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(map));
+
+ Request request = new Request.Builder().url(url).post(body).addHeader("x-auth-token",access_token).build();
+
+ Response response = null;
+ try {
+ response = okHttpClient.newCall(request).execute();
+ } catch (IOException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+
+ ResponseBody responseBody = response.body();
+
+ try {
+ String message = responseBody.string();// 鍝嶅簲浣�
+ Map<String,Object> map0 = (Map<String, Object>) JSON.parse(message);
+ return map0;
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ return new HashMap();
+ }
+ }
+
+ public String getWorkspaceId(){
+ String token = this.getToken();
+ return this.workspaceId;
+ }
+
+ public Object addWaylinesPlanning(String url, Map<String,Object> data) {
+ String token = this.getToken();
+ url = this.host + url;
+ Map<String,Object> resultMap = addWaylinesPlanning(url,token, data);
+ return resultMap;
+ }
+
+ public Map<String,Object> addWaylinesPlanning(String url,String access_token,Map<String,Object> map){
+ MediaType mediaType = MediaType.parse("application/json; charset=utf-8");
+ OkHttpClient okHttpClient = new OkHttpClient();
+
+ RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(map));
+
+ Request request = new Request.Builder().url(url).post(body).addHeader("x-auth-token",access_token).build();
+
+ Response response = null;
+ try {
+ response = okHttpClient.newCall(request).execute();
+ } catch (IOException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+
+ ResponseBody responseBody = response.body();
+
+ try {
+ String message = responseBody.string();// 鍝嶅簲浣�
+ Map<String,Object> map0 = (Map<String, Object>) JSON.parse(message);
+ return map0;
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ return new HashMap();
+ }
+ }
+
+ public Object deleteWaylinesPlanning(String url, Map<String,String> data) {
+ String token = this.getToken();
+ String waylineId = data.get("waylineId");
+ url = this.host + url + waylineId;
+ Map<String,Object> resultMap = deleteWaylinesPlanning(url,token);
+ return resultMap;
+ }
+
+ public static Map<String,Object> deleteWaylinesPlanning(String url,String access_token){
+ OkHttpClient okHttpClient = new OkHttpClient();
+
+ Request request = new Request.Builder().url(url).delete().addHeader("x-auth-token",access_token).build();
+
+ Response response = null;
+ try {
+ response = okHttpClient.newCall(request).execute();
+ } catch (IOException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+
+ ResponseBody responseBody = response.body();
+
+ try {
+ String message = responseBody.string();// 鍝嶅簲浣�
+ Map<String,Object> map0 = (Map<String, Object>) JSON.parse(message);
+ return map0;
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ return new HashMap();
+ }
+ }
+
+ public Object updateWaylinesPlanning(String url, Map<String,Object> data) {
+ String token = this.getToken();
+ url = this.host + url;
+ Map<String,Object> resultMap = updateWaylinesPlanning(url,token, data);
+ return resultMap;
+ }
+
+ public Map<String,Object> updateWaylinesPlanning(String url,String access_token,Map<String,Object> map){
+ MediaType mediaType = MediaType.parse("application/json; charset=utf-8");
+ OkHttpClient okHttpClient = new OkHttpClient();
+
+ RequestBody body = RequestBody.create(mediaType, JSON.toJSONString(map));
+
+ Request request = new Request.Builder().url(url).post(body).addHeader("x-auth-token",access_token).build();
+
+ Response response = null;
+ try {
+ response = okHttpClient.newCall(request).execute();
+ } catch (IOException e1) {
+ // TODO Auto-generated catch block
+ e1.printStackTrace();
+ }
+
+ ResponseBody responseBody = response.body();
+
+ try {
+ String message = responseBody.string();// 鍝嶅簲浣�
+ Map<String,Object> map0 = (Map<String, Object>) JSON.parse(message);
+ return map0;
+ } catch (IOException e) {
+ // TODO Auto-generated catch block
+ e.printStackTrace();
+ return new HashMap();
+ }
+ }
}
--
Gitblit v1.9.3