#
Junjie
2026-01-14 aa151079c2d02047f6cb5f8ad56ff92b98544e99
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, "任务号为空");
        }
        // 处理非移动命令
        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));
            }
        }
        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 {