From c2fd9425e2a8df82938d72ec73523105c1e66f90 Mon Sep 17 00:00:00 2001
From: liusuyi <1951119284@qq.com>
Date: Mon, 20 Oct 2025 11:12:02 +0800
Subject: [PATCH] 优化

---
 ard-work/src/main/java/com/ard/work/service/impl/TyServiceImpl.java |   46 ++++++++++++++++++++++++++++++++--------------
 1 files changed, 32 insertions(+), 14 deletions(-)

diff --git a/ard-work/src/main/java/com/ard/work/service/impl/TyServiceImpl.java b/ard-work/src/main/java/com/ard/work/service/impl/TyServiceImpl.java
index 39eb921..b230b18 100644
--- a/ard-work/src/main/java/com/ard/work/service/impl/TyServiceImpl.java
+++ b/ard-work/src/main/java/com/ard/work/service/impl/TyServiceImpl.java
@@ -52,6 +52,7 @@
 import com.ard.work.service.ITyService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.stereotype.Service;
+
 import javax.annotation.Resource;
 import java.util.*;
 import java.util.stream.Collectors;
@@ -74,7 +75,7 @@
     private TyClient tyClient;
 
     /**
-     * 获取六合token信息
+     * 获取边缘服务器token信息
      *
      * @return AccessTokenReceiver
      */
@@ -84,7 +85,7 @@
     }
 
     /**
-     * 获取云盒列表
+     * 获取全部云盒列表
      *
      * @return List<BoxInfoReceiver>
      */
@@ -95,6 +96,17 @@
     }
 
     /**
+     * 获取指定服务器云盒列表
+     *
+     * @return List<BoxInfoReceiver>
+     */
+    @Override
+    public List<BoxInfoReceiver> getBoxList(String serverId) {
+        TyHttpCommonReceiver<List<BoxInfoReceiver>> boxList = tyClient.getBoxList(serverId);
+        return boxList == null ? null : boxList.getContent();
+    }
+
+    /**
      * 获取直播地址
      *
      * @return BoxStreamUrlReceiver
@@ -102,8 +114,13 @@
     @Override
     public BoxStreamUrlReceiver getBoxLiveUrl(String boxSn) {
         ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn);
-        TyHttpCommonReceiver<BoxStreamUrlReceiver> boxLiveUrl = tyClient.getBoxLiveUrl(ardDroneInfo.getServerId(),boxSn);
-        return boxLiveUrl.getContent();
+        if (ardDroneInfo == null) {
+            log.warn("未找到对应的飞行器信息,boxSn:{}", boxSn);
+            return null;
+        }
+        TyHttpCommonReceiver<BoxStreamUrlReceiver> boxLiveUrl = tyClient.getBoxLiveUrl(ardDroneInfo.getServerId(),
+                boxSn);
+        return boxLiveUrl == null ? null : boxLiveUrl.getContent();
     }
 
     /**
@@ -116,7 +133,7 @@
         ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxHistoryDTO.getBoxSn());
         TyHttpCommonReceiver<List<BoxHistoryReceiver>> boxHistory = tyClient.getBoxHistory(ardDroneInfo.getServerId(),
                 boxHistoryDTO);
-        return boxHistory.getContent();
+        return boxHistory == null ? null : boxHistory.getContent();
     }
 
     /**
@@ -127,8 +144,9 @@
     @Override
     public List<BoxPhotosReceiver> getBoxPhotos(BoxPhotosDTO boxPhotosDTO) {
         ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxPhotosDTO.getBoxSn());
-        TyHttpCommonReceiver<List<BoxPhotosReceiver>> boxPhotos = tyClient.getBoxPhotos(ardDroneInfo.getServerId(),boxPhotosDTO);
-        return boxPhotos.getContent();
+        TyHttpCommonReceiver<List<BoxPhotosReceiver>> boxPhotos = tyClient.getBoxPhotos(ardDroneInfo.getServerId(),
+                boxPhotosDTO);
+        return boxPhotos == null ? null : boxPhotos.getContent();
     }
 
     /**
@@ -137,7 +155,7 @@
     @Override
     public Boolean updateBoxSettings(BoxSettingsDTO boxSettingsDTO) {
         ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSettingsDTO.getBoxSn());
-        TyHttpCommonReceiver<?> result = tyClient.updateBoxSettings(ardDroneInfo.getServerId(),boxSettingsDTO);
+        TyHttpCommonReceiver<?> result = tyClient.updateBoxSettings(ardDroneInfo.getServerId(), boxSettingsDTO);
         return result.getState() == 1;
     }
 
@@ -175,7 +193,7 @@
     }
 
     /**
-     * 注册六合平台
+     * 注册边缘服务器平台
      */
     @Override
     public Boolean registerMessage(String serverId) {
@@ -184,7 +202,7 @@
             RegisterCmd registerMessage = new RegisterCmd(tyToken.getCompanyId(), tyToken.getAccessToken().getBytes());
             this.sendMessage(serverId, registerMessage);
         } catch (Exception e) {
-            log.error("注册六合平台失败:{}", e.getMessage());
+            log.error("注册边缘服务器平台失败:{}", e.getMessage());
         }
         return true;
     }
@@ -642,7 +660,7 @@
     }
 
     /**
-     * 处理六合服务器返回的消息
+     * 处理边缘服务器返回的消息
      */
     @Override
     public void processReplyMessage(String key, BaseCmd tyCommand) {
@@ -660,8 +678,8 @@
                 break;
             case 0x02:
                 // 处理注册消息
-                 HeartbeatReplyCmd heartbeatReplyCmd = (HeartbeatReplyCmd) tyCommand;
-                 logPrint("心跳消息", heartbeatReplyCmd.getTimestamp());
+                HeartbeatReplyCmd heartbeatReplyCmd = (HeartbeatReplyCmd) tyCommand;
+                logPrint("心跳消息", heartbeatReplyCmd.getTimestamp());
                 break;
             case 0x03:
                 // 处理订阅消息
@@ -826,7 +844,7 @@
     }
 
     /**
-     * 根据[服务器id]获取六合盒子列表
+     * 根据[服务器id]获取边缘服务器盒子列表
      */
     @Override
     public List<BoxInfoReceiver> getBoxSnToList(String id) {

--
Gitblit v1.9.3