From 1ad4e77cc910abdb7e95ebea160473526c8ac9ce Mon Sep 17 00:00:00 2001
From: guoshilong <123456>
Date: Sun, 08 Oct 2023 17:32:13 +0800
Subject: [PATCH] 添加重复定时和连续执行

---
 src/main/java/com/dji/sample/manage/service/impl/DeviceServiceImpl.java |   22 +++++++++++++---------
 1 files changed, 13 insertions(+), 9 deletions(-)

diff --git a/src/main/java/com/dji/sample/manage/service/impl/DeviceServiceImpl.java b/src/main/java/com/dji/sample/manage/service/impl/DeviceServiceImpl.java
index 40b5314..c15873f 100644
--- a/src/main/java/com/dji/sample/manage/service/impl/DeviceServiceImpl.java
+++ b/src/main/java/com/dji/sample/manage/service/impl/DeviceServiceImpl.java
@@ -279,10 +279,13 @@
     public List<DeviceDTO> getDevicesByParams(DeviceQueryParam param) {
         return mapper.selectList(
                 new LambdaQueryWrapper<DeviceEntity>()
+                        //设备编码
                         .eq(StringUtils.hasText(param.getDeviceSn()),
                                 DeviceEntity::getDeviceSn, param.getDeviceSn())
+                        //设备类型
                         .eq(param.getDeviceType() != null,
                                 DeviceEntity::getDeviceType, param.getDeviceType())
+                        //负载类型
                         .eq(param.getSubType() != null,
                                 DeviceEntity::getSubType, param.getSubType())
                         .eq(StringUtils.hasText(param.getChildSn()),
@@ -908,7 +911,7 @@
 
         Optional<DeviceDTO> deviceOpt = deviceRedisService.getDeviceOnline(deviceOtaFirmwares.get(0).getSn());
         if (deviceOpt.isEmpty()) {
-            throw new RuntimeException("Device is offline.");
+            throw new RuntimeException("设备离线");
         }
         DeviceDTO device = deviceOpt.get();
         String gatewaySn = DeviceDomainEnum.DOCK.getVal() == device.getDomain() ? device.getDeviceSn() : device.getParentSn();
@@ -919,7 +922,7 @@
         ServiceReply serviceReply = messageSender.publishServicesTopic(
                 gatewaySn, FirmwareMethodEnum.OTA_CREATE.getMethod(), Map.of(MapKeyConst.DEVICES, deviceOtaFirmwares), bid);
         if (serviceReply.getResult() != ResponseResult.CODE_SUCCESS) {
-            return ResponseResult.error(serviceReply.getResult(), "Firmware Error Code: " + serviceReply.getResult());
+            return ResponseResult.error(serviceReply.getResult(), "硬件错误码 " + serviceReply.getResult());
         }
 
         // Record the device state that needs to be updated.
@@ -936,16 +939,17 @@
     private void checkOtaConditions(String dockSn) {
         Optional<OsdDockReceiver> deviceOpt = deviceRedisService.getDeviceOsd(dockSn, OsdDockReceiver.class);
         if (deviceOpt.isEmpty()) {
-            throw new RuntimeException("Dock is offline.");
+            throw new RuntimeException("机场离线");
         }
         boolean emergencyStopState = deviceOpt.get().getEmergencyStopState();
         if (emergencyStopState) {
-            throw new RuntimeException("The emergency stop button of the dock is pressed and can't be upgraded.");
+//            throw new RuntimeException("The emergency stop button of the dock is pressed and can't be upgraded.");
+            throw new RuntimeException("机场急停按钮被按下,无法升级");
         }
 
         DockModeCodeEnum dockMode = this.getDockMode(dockSn);
         if (DockModeCodeEnum.IDLE != dockMode) {
-            throw new RuntimeException("The current status of the dock can't be upgraded.");
+            throw new RuntimeException("当前机场状态无法升级");
         }
     }
 
@@ -953,13 +957,13 @@
     public void devicePropertySet(String workspaceId, String dockSn, DeviceSetPropertyEnum propertyEnum, JsonNode param) {
         Optional<DeviceDTO> dockOpt = deviceRedisService.getDeviceOnline(dockSn);
         if (dockOpt.isEmpty()) {
-            throw new RuntimeException("Dock is offline.");
+            throw new RuntimeException("机场离线");
         }
         String childSn = dockOpt.get().getChildDeviceSn();
         boolean deviceOnline = deviceRedisService.checkDeviceOnline(childSn);
         Optional<OsdSubDeviceReceiver> osdOpt = deviceRedisService.getDeviceOsd(childSn, OsdSubDeviceReceiver.class);
         if (!deviceOnline || osdOpt.isEmpty()) {
-            throw new RuntimeException("Device is offline.");
+            throw new RuntimeException("设备离线");
         }
 
         // Make sure the data is valid.
@@ -1011,7 +1015,7 @@
 
         SetReply setReply = objectMapper.convertValue(reply, SetReply.class);
         if (SetReplyStatusResultEnum.SUCCESS.getVal() != setReply.getResult()) {
-            throw new RuntimeException("Failed to set " + value.getKey() + "; Error Code: " + setReply.getResult());
+            throw new RuntimeException("设置失败" + value.getKey() + "; 错误码: " + setReply.getResult());
         }
 
     }
@@ -1194,4 +1198,4 @@
         }
         return deviceBasic.getPayloads();
     }
-}
\ No newline at end of file
+}

--
Gitblit v1.9.3