From a7aaeabc7873a0eafb4a7ecad7f65b018b7a9bc9 Mon Sep 17 00:00:00 2001
From: sean.zhou <sean.zhou@dji.com>
Date: Fri, 24 Feb 2023 19:31:23 +0800
Subject: [PATCH] What's new? 1. Add license for dock. 2. Modify the logic corresponding to the firmware file and device type. 3. Add multiple mqtt clients options. 4. Modify the structure of the interface for obtaining the device list. 5. Fixed some issues.

---
 src/main/java/com/dji/sample/manage/controller/DevicePayloadController.java |   41 +++++------------------------------------
 1 files changed, 5 insertions(+), 36 deletions(-)

diff --git a/src/main/java/com/dji/sample/manage/controller/DevicePayloadController.java b/src/main/java/com/dji/sample/manage/controller/DevicePayloadController.java
index 0c0ba2c..17a7658 100644
--- a/src/main/java/com/dji/sample/manage/controller/DevicePayloadController.java
+++ b/src/main/java/com/dji/sample/manage/controller/DevicePayloadController.java
@@ -2,14 +2,11 @@
 
 import com.dji.sample.component.mqtt.model.ChannelName;
 import com.dji.sample.manage.model.receiver.DeviceBasicReceiver;
-import com.dji.sample.manage.model.receiver.DevicePayloadReceiver;
 import com.dji.sample.manage.service.IDevicePayloadService;
-import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.integration.annotation.ServiceActivator;
+import org.springframework.messaging.MessageHeaders;
 import org.springframework.web.bind.annotation.RestController;
-
-import java.util.List;
 
 /**
  * @author sean.zhou
@@ -17,30 +14,10 @@
  * @version 0.1
  */
 @RestController
-@Slf4j
 public class DevicePayloadController {
 
     @Autowired
     private IDevicePayloadService devicePayloadService;
-
-    /**
-     * Handles the data for the payload messages in the state topic.
-     * @param payloadsList  List of payload information.
-     * @return  drone's sn
-     */
-    @ServiceActivator(inputChannel = ChannelName.INBOUND_STATE_PAYLOAD,
-            outputChannel = ChannelName.INBOUND_STATE_PAYLOAD_UPDATE)
-    public String statePayload(List<DevicePayloadReceiver> payloadsList) {
-        // Delete all payload information for the drone based on the drone's sn.
-        devicePayloadService.deletePayloadsByDeviceSn(List.of(payloadsList.get(0).getDeviceSn()));
-
-        // Save the new payload information.
-        devicePayloadService.savePayloadDTOs(payloadsList);
-
-        log.debug("The result of saving the payload is successful.");
-
-        return payloadsList.get(0).getDeviceSn();
-    }
 
     /**
      * Handles messages in the state topic about basic drone data.
@@ -48,19 +25,11 @@
      * Note: Only the data of the drone payload is handled here. You can handle other data from the drone
      * according to your business needs.
      * @param deviceBasic   basic drone data
-     * @return  drone's sn
+     * @param headers
      */
-    @ServiceActivator(inputChannel = ChannelName.INBOUND_STATE_BASIC,
-            outputChannel = ChannelName.INBOUND_STATE_PAYLOAD_UPDATE)
-    public String stateBasic(DeviceBasicReceiver deviceBasic) {
-        // Delete all payload information for the drone based on the drone's sn.
-        devicePayloadService.deletePayloadsByDeviceSn(List.of(deviceBasic.getDeviceSn()));
+    @ServiceActivator(inputChannel = ChannelName.INBOUND_STATE_BASIC)
+    public void stateBasic(DeviceBasicReceiver deviceBasic, MessageHeaders headers) {
 
-        // Save the new payload information.
-        boolean isSave = devicePayloadService.savePayloadDTOs(deviceBasic.getPayloads());
-
-        log.debug("The result of saving the payloads is {}.", isSave);
-
-        return deviceBasic.getDeviceSn();
+        devicePayloadService.saveDeviceBasicPayload(deviceBasic.getPayloads(), headers.getTimestamp());
     }
 }
\ No newline at end of file

--
Gitblit v1.9.3