From 3c45d4f9f3aba5bc85a9577e43c0dffc71b93a22 Mon Sep 17 00:00:00 2001
From: Junjie <fallin.jie@qq.com>
Date: 星期四, 10 七月 2025 15:54:27 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/asrs/task/ShuttlePowerEarlyWarning.java |   18 +++++++++++++-----
 1 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/src/main/java/com/zy/asrs/task/ShuttlePowerEarlyWarning.java b/src/main/java/com/zy/asrs/task/ShuttlePowerEarlyWarning.java
index 00b5259..deedfc0 100644
--- a/src/main/java/com/zy/asrs/task/ShuttlePowerEarlyWarning.java
+++ b/src/main/java/com/zy/asrs/task/ShuttlePowerEarlyWarning.java
@@ -3,12 +3,13 @@
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.mapper.EntityWrapper;
+import com.zy.asrs.entity.DeviceConfig;
+import com.zy.asrs.service.DeviceConfigService;
 import com.zy.common.utils.HttpHandler;
 import com.zy.core.cache.SlaveConnection;
 import com.zy.core.enums.SlaveType;
 import com.zy.core.model.ShuttleSlave;
 import com.zy.core.model.protocol.ShuttleProtocol;
-import com.zy.core.properties.SlaveProperties;
 import com.zy.core.thread.ShuttleThread;
 import com.zy.system.entity.Config;
 import com.zy.system.service.ConfigService;
@@ -18,6 +19,7 @@
 import org.springframework.stereotype.Component;
 
 import java.util.HashMap;
+import java.util.List;
 
 /**
  * 灏忚溅鐢甸噺棰勮妫�娴� => 寮哄埗棰勮
@@ -29,7 +31,7 @@
     @Autowired
     private ConfigService configService;
     @Autowired
-    private SlaveProperties slaveProperties;
+    private DeviceConfigService deviceConfigService;
 
     /**
      * 灏忚溅鐢甸噺棰勮妫�娴� => 寮哄埗棰勮
@@ -54,11 +56,13 @@
         }
 
         StringBuffer buffer = new StringBuffer();
-        buffer.append("銆愰�氱煡銆戜笁鍑洓鍚戝簱\n");//娑堟伅鏍囬
+        buffer.append("銆愰�氱煡銆戝洓鍚戝簱\n");//娑堟伅鏍囬
 
         boolean hasReport = false;//鏄惁鏈夐渶瑕佹姤鍛婄殑鏁版嵁
-        for (ShuttleSlave slave : slaveProperties.getShuttle()) {
-            ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, slave.getId());
+        List<DeviceConfig> shuttleList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
+                .eq("device_type", String.valueOf(SlaveType.Shuttle)));
+        for (DeviceConfig device : shuttleList) {
+            ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getDeviceNo());
             if (shuttleThread == null) {
                 continue;
             }
@@ -72,6 +76,10 @@
                 continue;//鍏呯數涓紝鏃犻渶閫氱煡
             }
 
+            if (shuttleProtocol.getBatteryPower() == null) {
+                continue;
+            }
+
             if (Integer.parseInt(shuttleProtocol.getBatteryPower()) < shuttlePowerEarlyValue) {
                 buffer.append(shuttleProtocol.getShuttleNo()).append("鍙峰皬杞︼紝鐢甸噺").append(shuttleProtocol.getBatteryPower()).append("锛岃娉ㄦ剰銆俓n");
                 hasReport = true;

--
Gitblit v1.9.1