From aa151079c2d02047f6cb5f8ad56ff92b98544e99 Mon Sep 17 00:00:00 2001
From: Junjie <DELL@qq.com>
Date: 星期三, 14 一月 2026 08:30:49 +0800
Subject: [PATCH] #

---
 src/main/java/com/zy/core/network/fake/ZyStationFakeSegConnect.java |   68 +++++++++++++++++++++++++++++----
 1 files changed, 59 insertions(+), 9 deletions(-)

diff --git a/src/main/java/com/zy/core/network/fake/ZyStationFakeSegConnect.java b/src/main/java/com/zy/core/network/fake/ZyStationFakeSegConnect.java
index 9680550..c78afa0 100644
--- a/src/main/java/com/zy/core/network/fake/ZyStationFakeSegConnect.java
+++ b/src/main/java/com/zy/core/network/fake/ZyStationFakeSegConnect.java
@@ -3,6 +3,7 @@
 import com.alibaba.fastjson.JSON;
 import com.alibaba.fastjson.JSONObject;
 import com.zy.asrs.entity.DeviceConfig;
+import com.zy.asrs.utils.Utils;
 import com.zy.common.model.NavigateNode;
 import com.zy.common.utils.RedisUtil;
 import com.zy.core.News;
@@ -49,6 +50,34 @@
 
     @Override
     public boolean connect() {
+        Thread checkThread = new Thread(() -> {
+            while (true) {
+                try {
+                    for (Map.Entry<Integer, List<ZyStationStatusEntity>> entry : deviceStatusMap.entrySet()) {
+                        List<ZyStationStatusEntity> stationList = entry.getValue();
+                        for (ZyStationStatusEntity statusEntity : stationList) {
+                            if (statusEntity.isAutoing()
+                                    && statusEntity.isLoading()
+                                    && statusEntity.getTaskNo() > 0
+                                    && !statusEntity.isRunBlock()
+                                    && !statusEntity.getStationId().equals(statusEntity.getTargetStaNo())
+                            ) {
+                                BlockingQueue<StationCommand> commands = taskQueues.get(statusEntity.getTaskNo());
+                                if (commands == null) {
+                                    statusEntity.setRunBlock(true);
+                                }
+                            }
+                        }
+                    }
+
+
+                    Thread.sleep(100);
+                } catch (Exception e) {
+                    e.printStackTrace();
+                }
+            }
+        });
+        checkThread.start();
         return true;
     }
 
@@ -94,11 +123,16 @@
             return new CommandResponse(false, "浠诲姟鍙蜂负绌�");
         }
 
-        taskQueues.computeIfAbsent(taskNo, k -> new LinkedBlockingQueue<>()).offer(command);
-        taskLastUpdateTime.put(taskNo, System.currentTimeMillis());
+        // 澶勭悊闈炵Щ鍔ㄥ懡浠�
+        if (command.getCommandType() != StationCommandType.MOVE) {
+            handleCommand(deviceNo, command);
+        }else {
+            taskQueues.computeIfAbsent(taskNo, k -> new LinkedBlockingQueue<>()).offer(command);
+            taskLastUpdateTime.put(taskNo, System.currentTimeMillis());
 
-        if (taskRunning.putIfAbsent(taskNo, true) == null) {
-            executor.submit(() -> runTaskLoop(deviceNo, taskNo));
+            if (taskRunning.putIfAbsent(taskNo, true) == null) {
+                executor.submit(() -> runTaskLoop(deviceNo, taskNo));
+            }
         }
 
         return new CommandResponse(true, "鍛戒护宸插彈鐞嗭紙寮傛鎵ц锛�");
@@ -118,6 +152,7 @@
             StationCommand initialCommand = null;
             Integer finalTargetStationId = null;
             boolean generateBarcode = false;
+            long stepExecuteTime = System.currentTimeMillis();
 
             while (true) {
                 BlockingQueue<StationCommand> commandQueue = taskQueues.get(taskNo);
@@ -128,6 +163,7 @@
                 // 灏濊瘯鑾峰彇鏂板懡浠わ紝濡傛灉娌℃湁鏂板懡浠ゅ垯缁х画鎵ц鐜版湁璺緞
                 StationCommand command = commandQueue.poll(100, TimeUnit.MILLISECONDS);
                 if (command != null) {
+                    stepExecuteTime = System.currentTimeMillis();
                     taskLastUpdateTime.put(taskNo, System.currentTimeMillis());
                     
                     if (initialCommand == null) {
@@ -159,11 +195,6 @@
                                 pathQueue.offer(stationId);
                             }
                         }
-                    }
-                    
-                    // 澶勭悊闈炵Щ鍔ㄥ懡浠�
-                    if (command.getCommandType() != StationCommandType.MOVE) {
-                        handleCommand(deviceNo, command);
                     }
                 }
 
@@ -200,8 +231,27 @@
                             if (moveSuccess) {
                                 currentPathIndex++;
                                 pathQueue.poll();
+                                stepExecuteTime = System.currentTimeMillis();
                                 sleep(1000); // 妯℃嫙鑰楁椂
                             } else {
+                                if (!checkTaskNoInArea(taskNo)) {
+                                    boolean fakeAllowCheckBlock = true;
+                                    Object systemConfigMapObj = redisUtil.get(RedisKeyType.SYSTEM_CONFIG_MAP.key);
+                                    if (systemConfigMapObj != null) {
+                                        HashMap<String, String> systemConfigMap = (HashMap<String, String>) systemConfigMapObj;
+                                        if (systemConfigMap.get("fakeAllowCheckBlock") != null && !systemConfigMap.get("fakeAllowCheckBlock").equals("Y")) {
+                                            fakeAllowCheckBlock = false;
+                                        }
+                                    }
+
+                                    if (fakeAllowCheckBlock && System.currentTimeMillis() - stepExecuteTime > 1000 * 10) {
+                                        //璁ゅ畾鍫靛
+                                        boolean result = runBlockStation(taskNo, currentStationId, currentDeviceNo, taskNo, currentStationId);
+                                        if(result) {
+                                            break;
+                                        }
+                                    }
+                                }
                                 sleep(1000); // 澶辫触閲嶈瘯绛夊緟
                             }
                         } else {

--
Gitblit v1.9.1