From 1609b77ba4715a7f17030d61d20c8e526861ca1a Mon Sep 17 00:00:00 2001
From: Xiajijian <1176061145@qq.com>
Date: Fri, 23 Jan 2026 14:16:04 +0800
Subject: [PATCH] 1. 修改任务航线业务逻辑,优化写法。
---
ard-route/src/main/java/com/ard/route/util/UavRouteReqUtils.java | 167 ++++++++++++++++++++++++++++++++++++++++++++++++++++---
1 files changed, 156 insertions(+), 11 deletions(-)
diff --git a/ard-route/src/main/java/com/ard/route/util/UavRouteReqUtils.java b/ard-route/src/main/java/com/ard/route/util/UavRouteReqUtils.java
index 8e90bb6..b9d620e 100644
--- a/ard-route/src/main/java/com/ard/route/util/UavRouteReqUtils.java
+++ b/ard-route/src/main/java/com/ard/route/util/UavRouteReqUtils.java
@@ -1,18 +1,21 @@
package com.ard.route.util;
-import com.ard.oss.service.impl.OssServiceContext;
import com.ard.route.domain.djuav.ActionGroupReq;
import com.ard.route.domain.djuav.PointActionReq;
import com.ard.route.domain.djuav.RoutePointReq;
import com.ard.route.domain.djuav.UavRouteReq;
import com.ard.route.domain.djuav.kml.*;
+import com.ard.route.domain.route.ArdRouteInfo;
import com.ard.route.domain.vo.KmzInfoVo;
+import com.ard.work.domain.dto.state.PointData;
+import com.ard.work.domain.dto.wayline.PlanLineData;
+import com.ard.work.domain.dto.wayline.PointAction;
+import com.ard.work.domain.dto.wayline.WayLineUploadDTO;
import org.apache.commons.compress.archivers.ArchiveEntry;
import org.apache.commons.compress.archivers.ArchiveInputStream;
import org.apache.commons.compress.archivers.zip.ZipArchiveInputStream;
import org.springframework.web.multipart.MultipartFile;
-import javax.annotation.Resource;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.List;
@@ -22,11 +25,8 @@
public class UavRouteReqUtils {
- @Resource
- private OssServiceContext ossService;
-
// 将文件转换成 UavRouteReq 实体
- public static KmzInfoVo fileConversionEntity(MultipartFile file){
+ public static UavRouteReq fileConversionEntity(MultipartFile file){
KmzInfoVo kmzInfoVO = new KmzInfoVo();
try (InputStream inputStream = file.getInputStream();
ArchiveInputStream archiveInputStream = new ZipArchiveInputStream(inputStream)){
@@ -39,14 +39,14 @@
kmzInfoVO.setWpmlInfo(RouteFileUtils.parseKml(archiveInputStream));
}
}
- return kmzInfoVO;
+ return kmzInfoVoToUavRouteReq(kmzInfoVO);
}catch (Exception e) {
e.printStackTrace();
}
return null;
}
- public static UavRouteReq kmzInfoVOToUavRouteReq(KmzInfoVo vo) {
+ public static UavRouteReq kmzInfoVoToUavRouteReq(KmzInfoVo vo) {
UavRouteReq uavRouteReq = new UavRouteReq();
if (vo.getKmlInfo().getDocument().getFolder().getTemplateType() != null){
uavRouteReq.setTemplateType(vo.getKmlInfo().getDocument().getFolder().getTemplateType());
@@ -119,16 +119,161 @@
pointActionReq.setGimbalYawRotateAngle(Double.valueOf(kmlAction.getActionActuatorFuncParam().getGimbalYawRotateAngle()));
}
}
- if ("zoom".equals(kmlAction.getActionActuatorFunc())) {
+ if ("zoom".equals(kmlAction.getActionActuatorFunc())) { // 变焦
pointActionReq.setZoom(Double.valueOf(kmlAction.getActionActuatorFuncParam().getFocalLength()));
}
- if ("hover".equals(kmlAction.getActionActuatorFunc())) {
+ if ("hover".equals(kmlAction.getActionActuatorFunc())) { // 悬停
pointActionReq.setHoverTime(Integer.valueOf(kmlAction.getActionActuatorFuncParam().getHoverTime()));
}
- if ("rotateYaw".equals(kmlAction.getActionActuatorFunc())) {
+ if ("rotateYaw".equals(kmlAction.getActionActuatorFunc())) { // 飞行器偏航
pointActionReq.setAircraftHeading(Double.valueOf(kmlAction.getActionActuatorFuncParam().getAircraftHeading()));
}
return pointActionReq;
}
+ /**
+ * ArdRouteInfo实体转换,WayLineUploadDTO
+ */
+ public static WayLineUploadDTO buildWayLineUploadDTO(ArdRouteInfo ardRouteInfo){
+ WayLineUploadDTO wayLineUploadDTO = new WayLineUploadDTO();
+ String finishAction = ardRouteInfo.getUavRouteReq().getFinishAction(); //1
+ Double autoFlightSpeed = ardRouteInfo.getUavRouteReq().getAutoFlightSpeed(); //15
+ Double globalTransitionalSpeed = ardRouteInfo.getUavRouteReq().getGlobalTransitionalSpeed(); //8
+ String exitOnRcLostAction = ardRouteInfo.getUavRouteReq().getExitOnRcLostAction(); //0
+
+ PlanLineData planLineData = new PlanLineData();
+ if (finishAction != null){
+ planLineData.setLoseAction(0);
+ }
+ if (autoFlightSpeed != null){
+ planLineData.setAutoSpeed(8);
+ }
+ planLineData.setMaxSpeed(15);
+// if (globalTransitionalSpeed != null){
+// planLineData.setMaxSpeed(15);
+// }
+ if (exitOnRcLostAction != null){
+ planLineData.setFinishedAction(1);
+ }
+ planLineData.setHomeHeight(50);
+ planLineData.setInterests(new ArrayList<>());
+ planLineData.setIsSaveEnergyMode(0);
+ planLineData.setPoints(buildPointDataList(ardRouteInfo.getUavRouteReq()));
+
+ wayLineUploadDTO.setWayLineData(planLineData);
+ return wayLineUploadDTO;
+ }
+
+ public static List<PointData> buildPointDataList(UavRouteReq uavRouteReq){
+ List<PointData> pointDataList = new ArrayList<>();
+ for (RoutePointReq routePointReq : uavRouteReq.getRoutePointList()) {
+ PointData pointData = new PointData();
+
+ Integer routePointIndex = routePointReq.getRoutePointIndex();
+ if (routePointIndex != null){
+ pointData.setGroupIndex(routePointIndex);
+ }
+ Double height = routePointReq.getHeight();
+ if (height != null){
+ pointData.setHeight(height.floatValue());
+ }
+ Double longitude = routePointReq.getLongitude();
+ if (longitude != null){
+ pointData.setLng(longitude.floatValue());
+ }
+ Double latitude = routePointReq.getLatitude();
+ if (latitude != null){
+ pointData.setLat(latitude.floatValue());
+ }
+ Double speed = routePointReq.getSpeed();
+ if (speed != null){
+ pointData.setSpeed(speed.floatValue());
+ }
+ pointData.setDampingDistance(0);
+ pointData.setFlightPathMode(1);
+ pointData.setHeading(0);
+ pointData.setHeadingMode(0);
+ pointData.setInterestIndex(-1);
+ pointData.setSafeGohomeFlag(0);
+ pointData.setActions(buildPointActionList(routePointReq.getActionGroupList()));
+ pointDataList.add(pointData);
+
+ }
+ return pointDataList;
+ }
+
+ public static List<PointAction> buildPointActionList(List<ActionGroupReq> actionGroupList){
+ List<PointAction> pointActionList = new ArrayList<>();
+ for (ActionGroupReq actionGroupReq : actionGroupList) {
+ for (PointActionReq action : actionGroupReq.getActions()) {
+ PointAction pointAction = typeProcessing(action);
+ pointActionList.add(pointAction);
+ }
+ }
+ return pointActionList;
+ }
+
+ public static PointAction typeProcessing(PointActionReq pointActionReq){
+ PointAction pointAction = new PointAction();
+
+ if (pointActionReq.getZoom() != null){
+ pointAction.setType(1);
+ pointAction.setParam(pointActionReq.getZoom().floatValue());
+ pointAction.setSpeakInfo("");
+ pointAction.setWaitTime(2);
+ }
+
+ if (pointActionReq.getTakePhotoType() != null){
+ pointAction.setType(2);
+ pointAction.setParam(1);
+ pointAction.setSpeakInfo("");
+ pointAction.setWaitTime(2);
+ }
+
+ if (pointActionReq.getStartRecord() != null){
+ pointAction.setType(3);
+ pointAction.setParam(1);
+ pointAction.setSpeakInfo("");
+ pointAction.setWaitTime(2);
+ }
+
+ if (pointActionReq.getStopRecord() != null){
+ pointAction.setType(4);
+ pointAction.setParam(1);
+ pointAction.setSpeakInfo("");
+ pointAction.setWaitTime(2);
+ }
+
+ if (pointActionReq.getAircraftHeading() != null){
+ pointAction.setType(5);
+ pointAction.setParam(pointActionReq.getAircraftHeading().floatValue());
+ pointAction.setSpeakInfo("");
+ pointAction.setWaitTime(2);
+ }
+
+ if (pointActionReq.getGimbalPitchRotateAngle() != null){
+ pointAction.setType(6);
+ pointAction.setParam(pointActionReq.getGimbalPitchRotateAngle().floatValue());
+ pointAction.setSpeakInfo("");
+ pointAction.setWaitTime(2);
+ }
+
+ if (pointActionReq.getGimbalYawRotateAngle() != null){
+ pointAction.setType(7);
+ pointAction.setParam(pointActionReq.getGimbalYawRotateAngle().floatValue());
+ pointAction.setSpeakInfo("");
+ pointAction.setWaitTime(2);
+ }
+
+ if (pointActionReq.getHoverTime() != null){
+ pointAction.setType(9);
+ pointAction.setParam(pointActionReq.getHoverTime().floatValue());
+ pointAction.setSpeakInfo("");
+ pointAction.setWaitTime(2);
+ }
+
+ return pointAction;
+
+ }
+
}
--
Gitblit v1.9.3