From 53a71007458bdded764dc52a39d596f8c4ca28db Mon Sep 17 00:00:00 2001
From: DELL <DELL@qq.com>
Date: 星期四, 18 九月 2025 15:42:41 +0800
Subject: [PATCH] #

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

diff --git a/src/main/java/com/zy/core/utils/FakeDeviceUtils.java b/src/main/java/com/zy/core/utils/FakeDeviceUtils.java
index 847646e..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) {

--
Gitblit v1.9.1