From 1837824a37c1a9e6c77280862abed282e7ca61b9 Mon Sep 17 00:00:00 2001
From: Xiajijian <1176061145@qq.com>
Date: Wed, 24 Dec 2025 13:51:09 +0800
Subject: [PATCH] 1. 开始航线增肌航线id用于判断是否是单次执行航线业务。 2. 增加判断无人机,禁飞区逻辑。

---
 ard-route/src/main/java/com/ard/route/domain/route/ArdRouteInfo.java             |   14 +++-
 ard-route/src/main/resources/mapper/ArdRouteInfoMapper.xml                       |   15 ++--
 ard-route/src/main/java/com/ard/route/service/impl/ArdRouteInfoServiceImpl.java  |   56 ++++++++++++++++--
 ard-work/src/main/java/com/ard/work/service/impl/ArdServerInfoServiceImpl.java   |   29 +++++++++
 ard-admin/src/main/java/com/ard/web/controller/work/ArdServerInfoController.java |   12 ++++
 ard-route/src/main/java/com/ard/route/service/IArdRouteInfoService.java          |    2 
 ard-work/src/main/java/com/ard/work/service/IArdServerInfoService.java           |    2 
 ard-admin/src/main/java/com/ard/web/controller/route/ArdRouteInfoController.java |    7 +-
 8 files changed, 111 insertions(+), 26 deletions(-)

diff --git a/ard-admin/src/main/java/com/ard/web/controller/route/ArdRouteInfoController.java b/ard-admin/src/main/java/com/ard/web/controller/route/ArdRouteInfoController.java
index 85d0068..2f4abf0 100644
--- a/ard-admin/src/main/java/com/ard/web/controller/route/ArdRouteInfoController.java
+++ b/ard-admin/src/main/java/com/ard/web/controller/route/ArdRouteInfoController.java
@@ -143,9 +143,10 @@
      * 开始航线
      */
     @ApiOperation("开始航线")
-    @PostMapping("/routeBegins/{boxSn}")
-    public AjaxResult routeBegins(@PathVariable("boxSn") String boxSn) {
-        ardRouteInfoService.routeBegins(boxSn);
+    @PostMapping("/routeBegins/{id}/{boxSn}")
+    public AjaxResult routeBegins(@PathVariable("id") String id,
+                                  @PathVariable("boxSn") String boxSn) {
+        ardRouteInfoService.routeBegins(id,boxSn);
         return AjaxResult.success();
     }
 
diff --git a/ard-admin/src/main/java/com/ard/web/controller/work/ArdServerInfoController.java b/ard-admin/src/main/java/com/ard/web/controller/work/ArdServerInfoController.java
index 8a531ba..7c14a8d 100644
--- a/ard-admin/src/main/java/com/ard/web/controller/work/ArdServerInfoController.java
+++ b/ard-admin/src/main/java/com/ard/web/controller/work/ArdServerInfoController.java
@@ -51,6 +51,18 @@
     }
 
     /**
+     * 查询服务器管理列表
+     */
+    @ApiOperation("查询服务器管理列表")
+    @PreAuthorize("@ss.hasPermi('work:server:listNo')")
+    @GetMapping("/listNo")
+    public TableDataInfo listNo(ArdServerInfo ardServerInfo) {
+        startPage();
+        List<ArdServerInfo> list = ardServerInfoService.selectArdServerInfoListNo(ardServerInfo);
+        return getDataTable(list);
+    }
+
+    /**
      * 导出服务器管理列表
      */
     @ApiOperation("导出服务器管理列表")
diff --git a/ard-route/src/main/java/com/ard/route/domain/route/ArdRouteInfo.java b/ard-route/src/main/java/com/ard/route/domain/route/ArdRouteInfo.java
index b2746ad..3835f2c 100644
--- a/ard-route/src/main/java/com/ard/route/domain/route/ArdRouteInfo.java
+++ b/ard-route/src/main/java/com/ard/route/domain/route/ArdRouteInfo.java
@@ -29,10 +29,6 @@
     @Excel(name = "文件路径")
     private String path;
 
-//    /** 文件路径1 */
-//    @Excel(name = "文件路径1")
-//    private String path1;
-
     /** 分组ID */
     @Excel(name = "分组ID")
     private String groupId;
@@ -50,7 +46,7 @@
     private String payload;
 
     /**
-     * 是否只读 是否只读
+     * 是否只读
      * 0:否
      * 1:是
      */
@@ -66,6 +62,14 @@
     private String orderByTime;
 
     /**
+     * 是否循环 isLoop
+     * 0:否
+     * 1:是
+     */
+    @Excel(name = "是否循环")
+    private String isLoop;
+
+    /**
      * 生成kmz文件实体类
      */
     private UavRouteReq uavRouteReq;
diff --git a/ard-route/src/main/java/com/ard/route/service/IArdRouteInfoService.java b/ard-route/src/main/java/com/ard/route/service/IArdRouteInfoService.java
index 19e0e1e..65e911c 100644
--- a/ard-route/src/main/java/com/ard/route/service/IArdRouteInfoService.java
+++ b/ard-route/src/main/java/com/ard/route/service/IArdRouteInfoService.java
@@ -114,7 +114,7 @@
      * @param boxSn 云盒SN编号
      * @return 结果
      */
-    public Boolean routeBegins(String boxSn);
+    public Boolean routeBegins(String id, String boxSn);
 
     /**
      * 暂停航线
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..ded68b2 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
@@ -25,8 +25,10 @@
 import com.ard.route.mapper.ArdRouteInfoMapper;
 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;
@@ -86,17 +88,20 @@
             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);
+            }
         }
+
         return ardRouteInfo;
     }
 
-    // 提取航点高度调整逻辑到方法中
     private void adjustRoutePointHeight(RoutePointReq routePointReq, double altitudeOffset) {
         routePointReq.setHeight(routePointReq.getHeight() + altitudeOffset);
     }
@@ -234,6 +239,9 @@
      */
     @Override
     public int deleteArdRouteInfoById(String id) {
+        // 删除航线(kmz)文件
+        ArdRouteInfo information = ardRouteInfoMapper.selectArdRouteInfoById(id);
+        delOssService(information);
         return ardRouteInfoMapper.deleteArdRouteInfoById(id);
     }
 
@@ -332,7 +340,6 @@
 
     /**
      * 上传航线到边缘服务器
-     *
      * ardNoflyDto
      * @return 结果
      */
@@ -346,6 +353,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 +404,12 @@
      * @return 结果
      */
     @Override
-    public Boolean routeBegins(String boxSn) {
+    public Boolean routeBegins(String id,String boxSn) {
+        ArdRouteInfo route = ardRouteInfoMapper.selectArdRouteInfoById(id);
+        // 判断是否循环航线
+        if ("1".equals(route.getIsLoop())) {
+            deleteArdRouteInfoById(id);
+        }
         WayLineBeginDTO wayLineBeginDTO = new WayLineBeginDTO(boxSn);
         tyService.wayLineBegin(wayLineBeginDTO);
         return true;
diff --git a/ard-route/src/main/resources/mapper/ArdRouteInfoMapper.xml b/ard-route/src/main/resources/mapper/ArdRouteInfoMapper.xml
index 94af829..658cfeb 100644
--- a/ard-route/src/main/resources/mapper/ArdRouteInfoMapper.xml
+++ b/ard-route/src/main/resources/mapper/ArdRouteInfoMapper.xml
@@ -8,7 +8,6 @@
         <result property="id"    column="id"    />
         <result property="name"    column="name"    />
         <result property="path"    column="path"    />
-<!--        <result property="path1"    column="path1"    />-->
         <result property="groupId"    column="group_id"    />
         <result property="type"    column="type"    />
         <result property="aircraft"    column="aircraft"    />
@@ -20,13 +19,13 @@
         <result property="updateBy"    column="update_by"    />
         <result property="updateTime"    column="update_time"    />
         <result property="pointCount"    column="point_count"    />
+        <result property="isLoop"    column="is_loop"    />
     </resultMap>
 
     <sql id="selectArdRouteInfoVo">
         select id,
                name,
                path,
-<!--               path1,-->
                group_id,
                type,
                aircraft,
@@ -37,7 +36,8 @@
                create_time,
                update_by,
                update_time,
-               point_count
+               point_count,
+               is_loop
         from ard_route_info
     </sql>
 
@@ -50,6 +50,7 @@
             <if test="type != null  and type != ''"> and type = #{type}</if>
             <if test="path != null  and path != ''"> and path = #{path}</if>
             <if test="groupId != null"> and group_id = #{groupId}</if>
+            <if test="isLoop != null"> and is_loop = #{isLoop}</if>
         </where>
         <if test="orderByTime == null and orderByTime == ''">
             ORDER BY update_time DESC
@@ -71,7 +72,6 @@
             <if test="id != null">id,</if>
             <if test="name != null">name,</if>
             <if test="path != null">path,</if>
-<!--            <if test="path1 != null">path1,</if>-->
             <if test="groupId != null">group_id,</if>
             <if test="type != null">type,</if>
             <if test="aircraft != null">aircraft,</if>
@@ -83,12 +83,12 @@
             <if test="updateBy != null">update_by,</if>
             <if test="updateTime != null">update_time,</if>
             <if test="pointCount != null">point_count,</if>
+            <if test="isLoop != null">is_loop,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="id != null">#{id},</if>
             <if test="name != null">#{name},</if>
             <if test="path != null">#{path},</if>
-<!--            <if test="path1 != null">#{path1},</if>-->
             <if test="groupId != null">#{groupId},</if>
             <if test="type != null">#{type},</if>
             <if test="aircraft != null">#{aircraft},</if>
@@ -100,6 +100,7 @@
             <if test="updateBy != null">#{updateBy},</if>
             <if test="updateTime != null">#{updateTime},</if>
             <if test="pointCount != null">#{pointCount},</if>
+            <if test="isLoop != null">#{isLoop},</if>
          </trim>
     </insert>
 
@@ -108,7 +109,6 @@
         <trim prefix="SET" suffixOverrides=",">
             <if test="name != null">name = #{name},</if>
             <if test="path != null">path = #{path},</if>
-<!--            <if test="path1 != null">path1 = #{path1},</if>-->
             <if test="groupId != null">group_id = #{groupId},</if>
             <if test="type != null">type = #{type},</if>
             <if test="aircraft != null">aircraft = #{aircraft},</if>
@@ -120,6 +120,7 @@
             <if test="updateBy != null">update_by = #{updateBy},</if>
             <if test="updateTime != null">update_time = #{updateTime},</if>
             <if test="pointCount != null">point_count = #{pointCount},</if>
+            <if test="isLoop != null">is_loop = #{isLoop},</if>
         </trim>
         where id = #{id}
     </update>
@@ -148,7 +149,7 @@
     </delete>
 
     <select id="selectArdRouteInfoByGroupId" parameterType="String" resultMap="ArdRouteInfoResult">
-        select id,name,path,group_id,type,aircraft,payload,read_only,create_by,create_time,update_by,update_time,point_count from ard_route_info
+        select id,name,path,group_id,type,aircraft,payload,read_only,create_by,create_time,update_by,update_time,point_count,is_loop from ard_route_info
         <where>
             <if test="groupId != null "> and group_id = #{groupId}</if>
         </where>
diff --git a/ard-work/src/main/java/com/ard/work/service/IArdServerInfoService.java b/ard-work/src/main/java/com/ard/work/service/IArdServerInfoService.java
index 78b1125..2e25e77 100644
--- a/ard-work/src/main/java/com/ard/work/service/IArdServerInfoService.java
+++ b/ard-work/src/main/java/com/ard/work/service/IArdServerInfoService.java
@@ -28,6 +28,8 @@
      */
     public List<ArdServerInfo> selectArdServerInfoList(ArdServerInfo ardServerInfo);
 
+    public List<ArdServerInfo> selectArdServerInfoListNo(ArdServerInfo ardServerInfo);
+
     /**
      * 新增服务器管理
      * 
diff --git a/ard-work/src/main/java/com/ard/work/service/impl/ArdServerInfoServiceImpl.java b/ard-work/src/main/java/com/ard/work/service/impl/ArdServerInfoServiceImpl.java
index d4063de..ad2e534 100644
--- a/ard-work/src/main/java/com/ard/work/service/impl/ArdServerInfoServiceImpl.java
+++ b/ard-work/src/main/java/com/ard/work/service/impl/ArdServerInfoServiceImpl.java
@@ -5,9 +5,11 @@
 import com.ard.work.component.forest.TyClient;
 import com.ard.work.component.netty.TyTcpClientManager;
 import com.ard.work.domain.dto.TokenDTO;
+import com.ard.work.domain.entity.ArdDroneInfo;
 import com.ard.work.domain.entity.ArdServerInfo;
 import com.ard.work.domain.receiver.AccessTokenReceiver;
 import com.ard.work.domain.receiver.TyHttpCommonReceiver;
+import com.ard.work.mapper.ArdDroneInfoMapper;
 import com.ard.work.mapper.ArdServerInfoMapper;
 import com.ard.work.service.IArdServerInfoService;
 import com.dtflys.forest.exceptions.ForestRuntimeException;
@@ -30,11 +32,16 @@
 public class ArdServerInfoServiceImpl implements IArdServerInfoService {
 
     @Resource
-    private ArdServerInfoMapper ardServerInfoMapper;
-    @Resource
     private TyClient tyClient;
+
+    @Resource
+    private ArdServerInfoMapper ardServerInfoMapper;
+
     @Resource
     private TyTcpClientManager tyTcpClientManager;
+
+    @Resource
+    private ArdDroneInfoMapper ArdDroneInfoMapper;
 
     /**
      * 查询服务器管理
@@ -59,6 +66,24 @@
         return ardServerInfoMapper.selectArdServerInfoList(ardServerInfo);
     }
 
+    @Override
+    @DataScope(deptAlias = "d", userAlias = "u")
+    public List<ArdServerInfo> selectArdServerInfoListNo(ArdServerInfo ardServerInfo) {
+
+//        List<ArdDroneInfo> ardDroneInfos = ArdDroneInfoMapper.selectArdDroneList(new ArdDroneInfo());
+//        for (ArdDroneInfo ardDroneInfo : ardDroneInfos) {
+//            ardDroneInfo.getBoxSn();
+//        }
+//        List<ArdServerInfo> servers = ardServerInfoMapper.selectArdServerInfoList(ardServerInfo);
+//        for (ArdServerInfo server : servers) {
+//            for (ArdDroneInfo ardDroneInfo : server.getArdDroneInfoList()) {
+//                ardDroneInfo.getBoxSn();
+//            }
+//        }
+
+        return ardServerInfoMapper.selectArdServerInfoList(ardServerInfo);
+    }
+
     /**
      * 新增服务器管理
      *

--
Gitblit v1.9.3