From f4d696baffce9c3bd8653a3598eb69f0962a5e92 Mon Sep 17 00:00:00 2001
From: zy <zy@123>
Date: 星期四, 17 七月 2025 13:56:42 +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