From d9505e143cdf452c3a33752b380ee1b3a410601d Mon Sep 17 00:00:00 2001
From: Junjie <xjj@123>
Date: 星期四, 16 十月 2025 14:48:52 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/asrs/task/ShuttlePowerEarlyWarning.java |   40 ++++++++++++++++++++++++++++------------
 1 files changed, 28 insertions(+), 12 deletions(-)

diff --git a/src/main/java/com/zy/asrs/task/ShuttlePowerEarlyWarning.java b/src/main/java/com/zy/asrs/task/ShuttlePowerEarlyWarning.java
index 6a79cf5..9af0b90 100644
--- a/src/main/java/com/zy/asrs/task/ShuttlePowerEarlyWarning.java
+++ b/src/main/java/com/zy/asrs/task/ShuttlePowerEarlyWarning.java
@@ -3,13 +3,14 @@
 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.NyShuttleProtocol;
-import com.zy.core.properties.SlaveProperties;
-import com.zy.core.thread.NyShuttleThread;
+import com.zy.core.model.protocol.ShuttleProtocol;
+import com.zy.core.thread.ShuttleThread;
 import com.zy.system.entity.Config;
 import com.zy.system.service.ConfigService;
 import lombok.extern.slf4j.Slf4j;
@@ -18,6 +19,7 @@
 import org.springframework.stereotype.Component;
 
 import java.util.HashMap;
+import java.util.List;
 
 /**
  * 灏忚溅鐢甸噺棰勮妫�娴� => 寮哄埗棰勮
@@ -29,13 +31,13 @@
     @Autowired
     private ConfigService configService;
     @Autowired
-    private SlaveProperties slaveProperties;
+    private DeviceConfigService deviceConfigService;
 
     /**
      * 灏忚溅鐢甸噺棰勮妫�娴� => 寮哄埗棰勮
      * 姣�30鍒嗛挓鎵弿涓�娆�
      */
-    @Scheduled(cron = "*/30 * * * * ? ")
+    @Scheduled(cron = "0 30 * * * ? ")
     public synchronized void shuttlePowerEarlyWarning() {
         Config config = configService.selectOne(new EntityWrapper<Config>().eq("code","dingdingReportUrl"));
         if (config == null) {
@@ -53,27 +55,41 @@
             shuttlePowerEarlyValue = Integer.parseInt(shuttlePowerEarlyConfig.getValue());
         }
 
+        String title = "";
+        Config dingdingReportTitleConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "dingdingReportTitle"));
+        if (dingdingReportTitleConfig != null) {
+            title = dingdingReportTitleConfig.getValue();
+        }
+
         StringBuffer buffer = new StringBuffer();
-        buffer.append("銆愰�氱煡銆戜笁鍑洓鍚戝簱\n");//娑堟伅鏍囬
+        buffer.append("銆愰�氱煡銆�");
+        buffer.append(title);
+        buffer.append("鍥涘悜搴揬n");//娑堟伅鏍囬
 
         boolean hasReport = false;//鏄惁鏈夐渶瑕佹姤鍛婄殑鏁版嵁
-        for (ShuttleSlave slave : slaveProperties.getShuttle()) {
-            NyShuttleThread shuttleThread = (NyShuttleThread) 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;
             }
 
-            NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol();
+            ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
             if (shuttleProtocol == null) {
                 continue;
             }
 
-            if (shuttleProtocol.getChargState() == 1) {
+            if (shuttleThread.isCharging()) {
                 continue;//鍏呯數涓紝鏃犻渶閫氱煡
             }
 
-            if (shuttleProtocol.getPowerPercent() < shuttlePowerEarlyValue) {
-                buffer.append(shuttleProtocol.getShuttleNo()).append("鍙峰皬杞︼紝鐢甸噺").append(shuttleProtocol.getPowerPercent$()).append("锛岃娉ㄦ剰銆俓n");
+            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