From d81fdeef2ad2f7ecc548cebad6ab15455bf3da27 Mon Sep 17 00:00:00 2001
From: rain <167982779@qq.com>
Date: Tue, 30 Jul 2024 14:53:11 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/ht-dev' into ht-dev

---
 src/main/java/com/dji/sample/manage/controller/DeviceController.java |   50 +++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 37 insertions(+), 13 deletions(-)

diff --git a/src/main/java/com/dji/sample/manage/controller/DeviceController.java b/src/main/java/com/dji/sample/manage/controller/DeviceController.java
index 9e8870e..3c608b3 100644
--- a/src/main/java/com/dji/sample/manage/controller/DeviceController.java
+++ b/src/main/java/com/dji/sample/manage/controller/DeviceController.java
@@ -74,6 +74,30 @@
     }
 
     /**
+     * 手动在线
+     * @param workspaceId
+     * @param receiver
+     * @return
+     */
+    @PostMapping("/{workspace_id}/deviceOnline")
+    public ResponseResult<List<DeviceDTO>> deviceOnline(@PathVariable("workspace_id") String workspaceId,
+                                                        @RequestBody CommonTopicReceiver<StatusGatewayReceiver> receiver) {
+        boolean offline = deviceService.deviceOnline(receiver.getData());
+        if (offline) {
+            // Notify pilot that the device is offline successfully.
+            deviceService.publishStatusReply(receiver.getData().getSn(),
+                    CommonTopicResponse.builder()
+                            .tid(receiver.getTid())
+                            .bid(receiver.getBid())
+                            .timestamp(System.currentTimeMillis())
+                            .method(receiver.getMethod())
+                            .build());
+
+        }
+        return ResponseResult.success();
+    }
+
+    /**
      * Get the topology list of all online devices in one workspace.
      * @param workspaceId
      * @return
@@ -85,19 +109,19 @@
         return ResponseResult.success(devicesList);
     }
 
-    @GetMapping("/{device_sn}/subscribeTopic")
-    public ResponseResult<List<DeviceDTO>> testBinding(@PathVariable("device_sn") String deviceSn) {
-        deviceService.subscribeTopicOnline(deviceSn);
-
-        return ResponseResult.success();
-    }
-
-    @GetMapping("/{device_sn}/unsubscribeTopic")
-    public ResponseResult<List<DeviceDTO>> testUnBinding(@PathVariable("device_sn") String deviceSn) {
-        deviceService.unsubscribeTopicOffline(deviceSn);
-
-        return ResponseResult.success();
-    }
+//    @GetMapping("/{device_sn}/subscribeTopic2")
+//    public ResponseResult<List<DeviceDTO>> testBinding(@PathVariable("device_sn") String deviceSn) {
+//        deviceService.subscribeTopicOnline(deviceSn);
+//
+//        return ResponseResult.success();
+//    }
+//
+//    @GetMapping("/{device_sn}/unsubscribeTopic2")
+//    public ResponseResult<List<DeviceDTO>> testUnBinding(@PathVariable("device_sn") String deviceSn) {
+//        deviceService.unsubscribeTopicOffline(deviceSn);
+//
+//        return ResponseResult.success();
+//    }
 
     /**
      * After binding the device to the workspace, the device data can only be seen on the web.

--
Gitblit v1.9.3