From ce511a3d55e5f349b1647172e562c1659bbc8172 Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期五, 09 一月 2026 15:27:27 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/core/utils/FakeDeviceUtils.java |   34 ++++++++++++++++++++++++----------
 1 files changed, 24 insertions(+), 10 deletions(-)

diff --git a/src/main/java/com/zy/core/utils/FakeDeviceUtils.java b/src/main/java/com/zy/core/utils/FakeDeviceUtils.java
index 27d6d9f..a77f72f 100644
--- a/src/main/java/com/zy/core/utils/FakeDeviceUtils.java
+++ b/src/main/java/com/zy/core/utils/FakeDeviceUtils.java
@@ -1,7 +1,6 @@
 package com.zy.core.utils;
 
 import com.alibaba.fastjson.JSON;
-import com.zy.common.R;
 import com.zy.common.exception.CoolException;
 import com.zy.common.utils.RedisUtil;
 import com.zy.core.ThreadHandler;
@@ -14,6 +13,7 @@
 import com.zy.core.thread.impl.LfdZyForkLiftMasterThread;
 import com.zy.core.thread.impl.NyShuttleThread;
 import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
 import org.springframework.stereotype.Component;
 
 import java.util.ArrayList;
@@ -22,17 +22,35 @@
 @Component
 public class FakeDeviceUtils {
 
+    @Value("${deviceMsgConfig.gatewayId}")
+    private Integer gatewayId;
     @Autowired
     private RedisUtil redisUtil;
-    @Autowired
-    private DeviceMsgUtils deviceMsgUtils;
 
-    public String getFakeDeviceConfig() {
+    public synchronized boolean applyShuttleConnect(Integer deviceNo) {
+        Object object = redisUtil.get(RedisKeyType.FAKE_SHUTTLE_APPLY_CONNECT.key);
+        if(object != null) {
+            return false;
+        }
+
+        return redisUtil.set(RedisKeyType.FAKE_SHUTTLE_APPLY_CONNECT.key, deviceNo, 10);
+    }
+
+    public List<DeviceConfig> getFakeDeviceConfig() {
+        List<DeviceConfig> list = new ArrayList<>();
         Object obj = redisUtil.get(RedisKeyType.FAKE_DEVICE_CONFIG.key);
         if(null == obj){
-            return null;
+            return list;
         }
-        return obj.toString();
+
+        List<DeviceConfig> deviceConfigs = JSON.parseArray(obj.toString(), DeviceConfig.class);
+        for (DeviceConfig deviceConfig : deviceConfigs) {
+            if(deviceConfig.getGatewayId().equals(gatewayId)){
+                list.add(deviceConfig);
+            }
+        }
+        return list;
+
     }
 
     public void addFakeDevice(DeviceConfig deviceConfig) {
@@ -53,10 +71,6 @@
             ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(slaveType, deviceNo);
             if(shuttleThread == null){
                 throw new CoolException("璁惧绾跨▼涓嶅瓨鍦�");
-            }
-
-            if (!shuttleThread.isFake()) {
-                throw new CoolException("涓嶅厑璁稿垹闄ょ湡瀹炶澶囩嚎绋�");
             }
 
             shuttleThread.stopThread();

--
Gitblit v1.9.1