From 277b4f8a32c2332bc067a263bcce2e763e8d13aa Mon Sep 17 00:00:00 2001
From: Xiajijian <1176061145@qq.com>
Date: Wed, 21 Jan 2026 16:38:01 +0800
Subject: [PATCH] 1. 新增航线任务接口。 2. 新增查询航线任务列表接口。 3. 新增获取航线任务详细信息。 4. 新增航线任务接口。 5. 新增修改航线任务接口。 6. 新增删除航线任务接口。 7. 新增修改航线任务状态接口。 8. 优化查询分组业务逻辑。 9. 航线(kmz)对象增加航线任务ID信息。 10. 新增航线(kmz)业务增加航线任务数据加工校验相关业务逻辑。 11. 新增航向任务下航点信息业务相关接口。

---
 ard-route/src/main/java/com/ard/route/service/impl/ArdRouteInfoServiceImpl.java |  119 ++++++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 96 insertions(+), 23 deletions(-)

diff --git a/ard-route/src/main/java/com/ard/route/service/impl/ArdRouteInfoServiceImpl.java b/ard-route/src/main/java/com/ard/route/service/impl/ArdRouteInfoServiceImpl.java
index 97f5cd3..662f980 100644
--- a/ard-route/src/main/java/com/ard/route/service/impl/ArdRouteInfoServiceImpl.java
+++ b/ard-route/src/main/java/com/ard/route/service/impl/ArdRouteInfoServiceImpl.java
@@ -21,12 +21,16 @@
 import com.ard.route.domain.djuav.UavRouteReq;
 import com.ard.route.domain.dto.ArdNoflyDto;
 import com.ard.route.domain.route.ArdRouteInfo;
+import com.ard.route.domain.route.ArdRouteMission;
 import com.ard.route.domain.vo.KmzResultVo;
 import com.ard.route.mapper.ArdRouteInfoMapper;
+import com.ard.route.mapper.ArdRouteMissionMapper;
 import com.ard.route.service.IArdRouteInfoService;
 import com.ard.route.service.UavRouteService;
+import com.ard.work.domain.cache.UavTelemetryDataCache;
 import com.ard.work.domain.cache.UavWaylineCache;
 import com.ard.work.domain.dto.state.PointData;
+import com.ard.work.domain.dto.telemetry.TelemetryData;
 import com.ard.work.domain.dto.wayline.*;
 import com.ard.work.service.ITyService;
 import org.slf4j.Logger;
@@ -59,9 +63,11 @@
     @Autowired
     private OssServiceContext ossService;
 
-
     @Autowired
     private UavRouteService routeService;
+
+    @Autowired
+    private ArdRouteMissionMapper ardRouteMissionMapper;
 
     @Resource
     private IArdNoFlyZoneService ardNoFlyZoneService;
@@ -79,24 +85,35 @@
     public ArdRouteInfo selectArdRouteInfoById(String id) {
         ArdRouteInfo ardRouteInfo = ardRouteInfoMapper.selectArdRouteInfoById(id);
         try {
-            if (ardRouteInfo.getRouteData() != null){
-                ardRouteInfo.setUavRouteReq((UavRouteReq) deserialize(ardRouteInfo.getRouteData()));
+            if (ardRouteInfo != null) {
+                if (ardRouteInfo.getRouteData() != null){
+                    ardRouteInfo.setUavRouteReq((UavRouteReq) deserialize(ardRouteInfo.getRouteData()));
+                }
             }
         } catch (IOException | ClassNotFoundException e) {
             throw new RuntimeException(e);
         }
 
-        // 主逻辑优化
-        double altitudeOffset = getDoublePoint(ardRouteInfo.getUavRouteReq().getTakeOffRefPoint(), "alt");
+        // 如果参考起飞点不为空,将每个航点高度进行加工。
+        if (ardRouteInfo.getUavRouteReq().getTakeOffRefPoint() != null){
 
-        for (RoutePointReq routePointReq : ardRouteInfo.getUavRouteReq().getRoutePointList()) {
-            // 调整航点高度
-            adjustRoutePointHeight(routePointReq, altitudeOffset);
+            double altitudeOffset = getDoublePoint(ardRouteInfo.getUavRouteReq().getTakeOffRefPoint(), "alt");
+
+            for (RoutePointReq routePointReq : ardRouteInfo.getUavRouteReq().getRoutePointList()) {
+                // 调整每个航点高度
+                adjustRoutePointHeight(routePointReq, altitudeOffset);
+            }
+        }else {
+            // 如果没有设置参考起飞点,将第一个航点设置为参考起飞点。
+            ardRouteInfo.getUavRouteReq().setTakeOffRefPoint(
+                    ardRouteInfo.getUavRouteReq().getRoutePointList().get(0).getLatitude().toString() +"," +
+                    ardRouteInfo.getUavRouteReq().getRoutePointList().get(0).getLongitude().toString()+","+
+                    ardRouteInfo.getUavRouteReq().getRoutePointList().get(0).getHeight().toString());
         }
+
         return ardRouteInfo;
     }
 
-    // 提取航点高度调整逻辑到方法中
     private void adjustRoutePointHeight(RoutePointReq routePointReq, double altitudeOffset) {
         routePointReq.setHeight(routePointReq.getHeight() + altitudeOffset);
     }
@@ -125,6 +142,7 @@
      */
     @Override
     public String insertArdRouteInfo(ArdRouteInfo ardRouteInfo) {
+        processRouteMission(ardRouteInfo);
         ardRouteInfo.setId(IdUtils.simpleUUID());
         ardRouteInfo.setCreateTime(DateUtils.getNowDate());
         ardRouteInfo.setUpdateTime(DateUtils.getNowDate()); // 修改时间,用于排序
@@ -133,22 +151,24 @@
         }
         ardRouteInfo.getUavRouteReq().setDroneType(subStringDroneType(ardRouteInfo.getAircraft()));
         KmzResultVo kmzResult = routeService.buildKmz(ardRouteInfo.getUavRouteReq(),ardRouteInfo.getName());
-        if (M350_RTK.getValue().equals(ardRouteInfo.getUavRouteReq().getDroneType())) {
-            // 变焦数值加工
-            for (RoutePointReq routePointReq : ardRouteInfo.getUavRouteReq().getRoutePointList()) {
-                for (ActionGroupReq actionGroupReq : routePointReq.getActionGroupList()) {
-                    for (PointActionReq action : actionGroupReq.getActions()) {
-                        if (action.getZoom() != null){
-                            action.setZoom(divided_23(action.getZoom()));
-                        }
-                    }
-                }
-            }
-        }
+        zoomProcessing(ardRouteInfo);
         ardRouteInfo.setPath(kmzResult.getPath());
         ardRouteInfo.setReadOnly("0");
         ardRouteInfoMapper.insertArdRouteInfo(dataProcessing(ardRouteInfo));
         return kmzResult.getPath();
+    }
+
+    // 航线任务数据加工校验
+    private void processRouteMission(ArdRouteInfo ardRouteInfo){
+        if ("3".equals(ardRouteInfo.getType())) {
+            ArdRouteMission ardRouteMission = ardRouteMissionMapper.selectArdRouteMissionById(ardRouteInfo.getMissionId());
+            if ("0".equals(ardRouteMission.getRouteId())) {
+                ardRouteMission.setRouteId(ardRouteInfo.getId());
+                ardRouteMissionMapper.updateArdRouteMission(ardRouteMission);
+            }else {
+                throw new RuntimeException("不能修改默认分组");
+            }
+        }
     }
 
     /**
@@ -168,6 +188,8 @@
             // 先删除航线
             delOssService(route);
             // 再生成航线
+            ardRouteInfo.getUavRouteReq().setDroneType(subStringDroneType(ardRouteInfo.getAircraft()));
+            zoomProcessing(ardRouteInfo);
             kmzResult = routeService.buildKmz(ardRouteInfo.getUavRouteReq(), ardRouteInfo.getName());
             if ("更新航线kmz文件失败".equals(kmzResult.getData())) {
                 return 0;
@@ -175,6 +197,22 @@
             ardRouteInfo.setPath(kmzResult.getPath());
         }
         return ardRouteInfoMapper.updateArdRouteInfo(dataProcessing(ardRouteInfo));
+    }
+
+    // 变倍加工方法
+    private void zoomProcessing(ArdRouteInfo ardRouteInfo) {
+        if (M350_RTK.getValue().equals(ardRouteInfo.getUavRouteReq().getDroneType())) {
+            // 变焦数值加工
+            for (RoutePointReq routePointReq : ardRouteInfo.getUavRouteReq().getRoutePointList()) {
+                for (ActionGroupReq actionGroupReq : routePointReq.getActionGroupList()) {
+                    for (PointActionReq action : actionGroupReq.getActions()) {
+                        if (action.getZoom() != null){
+                            action.setZoom(divided_23(action.getZoom()));
+                        }
+                    }
+                }
+            }
+        }
     }
 
     // 新增信息加工
@@ -234,6 +272,9 @@
      */
     @Override
     public int deleteArdRouteInfoById(String id) {
+        // 删除航线(kmz)文件
+        ArdRouteInfo information = ardRouteInfoMapper.selectArdRouteInfoById(id);
+        delOssService(information);
         return ardRouteInfoMapper.deleteArdRouteInfoById(id);
     }
 
@@ -332,7 +373,6 @@
 
     /**
      * 上传航线到边缘服务器
-     *
      * ardNoflyDto
      * @return 结果
      */
@@ -346,6 +386,34 @@
         } catch (IOException | ClassNotFoundException e) {
             throw new RuntimeException(e);
         }
+
+        // 获取第一个点
+        double firstPointLng = route.getUavRouteReq().getRoutePointList().get(0).getLongitude();
+        double firstPointLat = route.getUavRouteReq().getRoutePointList().get(0).getLatitude();
+
+        // 获取最后一个点
+        double lastPointLng = route.getUavRouteReq().getRoutePointList().get(route.getUavRouteReq().getRoutePointList().size()-1).getLongitude();
+        double lastPointLat = route.getUavRouteReq().getRoutePointList().get(route.getUavRouteReq().getRoutePointList().size()-1).getLatitude();
+
+        // 无人机遥测数据,用于校验真实起飞点和第一个点是否在禁飞区
+        TelemetryData telemetryData = UavTelemetryDataCache.get(boxSn);
+        double telemetryDataLng = 0;
+        double telemetryDataLat = 0;
+        if (telemetryData != null){
+            telemetryDataLng = telemetryData.getLng();
+            telemetryDataLat = telemetryData.getLat();
+        }
+
+        ArdNoflyDto dto1 = new ArdNoflyDto();
+        dto1.setCurrent(new Vertex(telemetryDataLng,telemetryDataLat));
+        dto1.setTarget(new Vertex(firstPointLng,firstPointLat));
+        verifyNoFlyZone(dto1);
+
+        ArdNoflyDto dto2 = new ArdNoflyDto();
+        dto2.setCurrent(new Vertex(lastPointLng,lastPointLat));
+        dto2.setTarget(new Vertex(telemetryDataLng,telemetryDataLat));
+        verifyNoFlyZone(dto2);
+
         // 判断禁飞区
         arrayWithinNoFlyZone(route.getUavRouteReq().getRoutePointList());
         // 1.2通过minio获取航线信息
@@ -369,7 +437,12 @@
      * @return 结果
      */
     @Override
-    public Boolean routeBegins(String boxSn) {
+    public Boolean routeBegins(String id,String boxSn) {
+        ArdRouteInfo route = ardRouteInfoMapper.selectArdRouteInfoById(id);
+        // 判断是否循环航线
+        if (null != route && "0".equals(route.getIsLoop())){
+            deleteArdRouteInfoById(id);
+        }
         WayLineBeginDTO wayLineBeginDTO = new WayLineBeginDTO(boxSn);
         tyService.wayLineBegin(wayLineBeginDTO);
         return true;

--
Gitblit v1.9.3