Junjie
10 小时以前 03c3ae747f82ad22c761c79e7b1c0e0031c57d41
#出库站点命令下发
9个文件已修改
281 ■■■■ 已修改文件
src/main/java/com/zy/core/enums/RedisKeyType.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/StationThread.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/impl/ZyStationThread.java 11 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/impl/ZyStationV3Thread.java 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/impl/ZyStationV4Thread.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/impl/ZyStationV5Thread.java 38 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/impl/v5/StationV5StatusReader.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/utils/station/StationOutboundDispatchProcessor.java 169 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/utils/station/StationRegularDispatchProcessor.java 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/enums/RedisKeyType.java
@@ -46,6 +46,7 @@
    DUAL_CRN_IO_EXECUTE_FINISH_LIMIT("dual_crn_io_execute_finish_limit_"),
    STATION_IN_EXECUTE_LIMIT("station_in_execute_limit_"),
    STATION_OUT_EXECUTE_LIMIT("station_out_execute_limit_"),
    STATION_OUT_PENDING_DISPATCH_("station_out_pending_dispatch_"),
    STATION_OUT_ORDER_DISPATCH_LIMIT_("station_out_order_dispatch_limit_"),
    STATION_OUT_EXECUTE_COMPLETE_LIMIT("station_out_execute_complete_limit_"),
    CHECK_STATION_RUN_BLOCK_LIMIT_("check_station_run_block_limit_"),
src/main/java/com/zy/core/thread/StationThread.java
@@ -14,6 +14,8 @@
    Map<Integer, StationProtocol> getStatusMap();
    List<Integer> getAllTaskNoList();
    default boolean hasRecentArrival(Integer stationId, Integer taskNo) {
        return false;
    }
src/main/java/com/zy/core/thread/impl/ZyStationThread.java
@@ -44,6 +44,7 @@
public class ZyStationThread implements Runnable, StationThread {
    private List<StationProtocol> statusList = new ArrayList<>();
    private volatile List<Integer> taskNoList = new ArrayList<>();
    private DeviceConfig deviceConfig;
    private RedisUtil redisUtil;
    private ZyStationConnectDriver zyStationConnectDriver;
@@ -128,6 +129,7 @@
        }
        List<ZyStationStatusEntity> zyStationStatusEntities = zyStationConnectDriver.getStatus();
        LinkedHashSet<Integer> taskNoSet = new LinkedHashSet<>();
        for (ZyStationStatusEntity statusEntity : zyStationStatusEntities) {
            for (StationProtocol stationProtocol : statusList) {
                if(stationProtocol.getStationId().equals(statusEntity.getStationId())) {
@@ -147,6 +149,9 @@
                    stationProtocol.setEnableIn(statusEntity.isEnableIn());
                    stationProtocol.setWeight(statusEntity.getWeight());
                    stationProtocol.setIoMode(statusEntity.getIoMode());
                    if (statusEntity.getTaskNo() != null && statusEntity.getTaskNo() > 0) {
                        taskNoSet.add(statusEntity.getTaskNo());
                    }
                    recentArrivalTracker.observe(statusEntity.getStationId(), statusEntity.getTaskNo(), statusEntity.isLoading());
                }
@@ -159,6 +164,7 @@
                }
            }
        }
        taskNoList = new ArrayList<>(taskNoSet);
        OutputQueue.DEVP.offer(MessageFormat.format("【{0}】[id:{1}] <<<<< 实时数据更新成功",DateUtils.convert(new Date()), deviceConfig.getDeviceNo()));
        StationErrLogSupport.sync(deviceConfig, redisUtil, statusList);
@@ -204,6 +210,11 @@
    }
    @Override
    public List<Integer> getAllTaskNoList() {
        return taskNoList;
    }
    @Override
    public StationCommand getCommand(StationCommandType commandType, Integer taskNo, Integer stationId, Integer targetStationId, Integer palletSize) {
        StationCommand stationCommand = new StationCommand();
        stationCommand.setTaskNo(taskNo);
src/main/java/com/zy/core/thread/impl/ZyStationV3Thread.java
@@ -42,6 +42,7 @@
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
@@ -50,6 +51,7 @@
public class ZyStationV3Thread implements Runnable, com.zy.core.thread.StationThread {
    private List<StationProtocol> statusList = new ArrayList<>();
    private volatile List<Integer> taskNoList = new ArrayList<>();
    private DeviceConfig deviceConfig;
    private RedisUtil redisUtil;
    private ZyStationConnectDriver zyStationConnectDriver;
@@ -134,6 +136,7 @@
        }
        List<ZyStationStatusEntity> zyStationStatusEntities = zyStationConnectDriver.getStatus();
        LinkedHashSet<Integer> taskNoSet = new LinkedHashSet<>();
        for (ZyStationStatusEntity statusEntity : zyStationStatusEntities) {
            for (StationProtocol stationProtocol : statusList) {
                if (stationProtocol.getStationId().equals(statusEntity.getStationId())) {
@@ -152,6 +155,9 @@
                    stationProtocol.setRunBlock(statusEntity.isRunBlock());
                    stationProtocol.setEnableIn(statusEntity.isEnableIn());
                    stationProtocol.setWeight(statusEntity.getWeight());
                    if (statusEntity.getTaskNo() != null && statusEntity.getTaskNo() > 0) {
                        taskNoSet.add(statusEntity.getTaskNo());
                    }
                    recentArrivalTracker.observe(statusEntity.getStationId(), statusEntity.getTaskNo(), statusEntity.isLoading());
                }
@@ -164,6 +170,7 @@
                }
            }
        }
        taskNoList = new ArrayList<>(taskNoSet);
        OutputQueue.DEVP.offer(MessageFormat.format("【{0}】[id:{1}] <<<<< 实时数据更新成功", DateUtils.convert(new Date()), deviceConfig.getDeviceNo()));
        StationErrLogSupport.sync(deviceConfig, redisUtil, statusList);
@@ -214,6 +221,11 @@
    }
    @Override
    public List<Integer> getAllTaskNoList() {
        return taskNoList;
    }
    @Override
    public boolean hasRecentArrival(Integer stationId, Integer taskNo) {
        return recentArrivalTracker.hasRecentArrival(stationId, taskNo);
    }
src/main/java/com/zy/core/thread/impl/ZyStationV4Thread.java
@@ -51,6 +51,7 @@
    private static final double DEFAULT_STATION_COMMAND_SEGMENT_ADVANCE_RATIO = 0.3d;
    private List<StationProtocol> statusList = new ArrayList<>();
    private volatile List<Integer> taskNoList = new ArrayList<>();
    private DeviceConfig deviceConfig;
    private RedisUtil redisUtil;
    private ZyStationConnectDriver zyStationConnectDriver;
@@ -141,6 +142,7 @@
        }
        List<ZyStationStatusEntity> zyStationStatusEntities = zyStationConnectDriver.getStatus();
        LinkedHashSet<Integer> taskNoSet = new LinkedHashSet<>();
        for (ZyStationStatusEntity statusEntity : zyStationStatusEntities) {
            for (StationProtocol stationProtocol : statusList) {
                if (stationProtocol.getStationId().equals(statusEntity.getStationId())) {
@@ -161,6 +163,17 @@
                    stationProtocol.setWeight(statusEntity.getWeight());
                    stationProtocol.setTaskWriteIdx(statusEntity.getTaskWriteIdx());
                    stationProtocol.setTaskBufferItems(statusEntity.getTaskBufferItems());
                    if (statusEntity.getTaskNo() != null && statusEntity.getTaskNo() > 0) {
                        taskNoSet.add(statusEntity.getTaskNo());
                    }
                    if (statusEntity.getTaskBufferItems() != null) {
                        statusEntity.getTaskBufferItems().forEach(item -> {
                            Integer bufferTaskNo = item == null ? null : item.getTaskNo();
                            if (bufferTaskNo != null && bufferTaskNo > 0) {
                                taskNoSet.add(bufferTaskNo);
                            }
                        });
                    }
                    recentArrivalTracker.observe(statusEntity.getStationId(), statusEntity.getTaskNo(), statusEntity.isLoading());
                }
@@ -173,6 +186,7 @@
                }
            }
        }
        taskNoList = new ArrayList<>(taskNoSet);
        OutputQueue.DEVP.offer(MessageFormat.format("【{0}】[id:{1}] <<<<< 实时数据更新成功", DateUtils.convert(new Date()), deviceConfig.getDeviceNo()));
        StationErrLogSupport.sync(deviceConfig, redisUtil, statusList);
@@ -223,6 +237,11 @@
    }
    @Override
    public List<Integer> getAllTaskNoList() {
        return taskNoList;
    }
    @Override
    public boolean hasRecentArrival(Integer stationId, Integer taskNo) {
        return recentArrivalTracker.hasRecentArrival(stationId, taskNo);
    }
src/main/java/com/zy/core/thread/impl/ZyStationV5Thread.java
@@ -42,7 +42,8 @@
@Slf4j
public class ZyStationV5Thread implements Runnable, com.zy.core.thread.StationThread {
    private static final int SEGMENT_EXECUTOR_POOL_SIZE = 64;
    private static final int DEFAULT_SEGMENT_EXECUTOR_POOL_SIZE = 128;
    private static final String CFG_SEGMENT_EXECUTOR_POOL_SIZE = "stationV5SegmentExecutorPoolSize";
    private static final int EXECUTOR_QUEUE_WARN_THRESHOLD = 20;
    private static final int EXECUTOR_ACTIVE_WARN_THRESHOLD = 48;
    private static final long SEGMENT_EXECUTE_WARN_MS = 10_000L;
@@ -50,7 +51,7 @@
    private DeviceConfig deviceConfig;
    private RedisUtil redisUtil;
    private ZyStationConnectDriver zyStationConnectDriver;
    private final ExecutorService executor = Executors.newFixedThreadPool(SEGMENT_EXECUTOR_POOL_SIZE);
    private final ExecutorService executor;
    private StationV5SegmentExecutor segmentExecutor;
    private final RecentStationArrivalTracker recentArrivalTracker;
    private final StationV5StatusReader statusReader;
@@ -59,10 +60,13 @@
    public ZyStationV5Thread(DeviceConfig deviceConfig, RedisUtil redisUtil) {
        this.deviceConfig = deviceConfig;
        this.redisUtil = redisUtil;
        int poolSize = resolveSegmentExecutorPoolSize(redisUtil);
        this.executor = Executors.newFixedThreadPool(poolSize);
        this.recentArrivalTracker = new RecentStationArrivalTracker(redisUtil);
        this.segmentExecutor = new StationV5SegmentExecutor(deviceConfig, redisUtil, this::sendCommand);
        this.statusReader = new StationV5StatusReader(deviceConfig, redisUtil, recentArrivalTracker);
        this.runBlockReroutePlanner = new StationV5RunBlockReroutePlanner(redisUtil);
        log.info("初始化V5输送线程池,deviceNo={}, poolSize={}", deviceConfig == null ? null : deviceConfig.getDeviceNo(), poolSize);
    }
    @Override
@@ -128,6 +132,11 @@
            map.put(stationProtocol.getStationId(), stationProtocol);
        }
        return map;
    }
    @Override
    public List<Integer> getAllTaskNoList() {
        return statusReader.getTaskNoList();
    }
    private void pollAndDispatchQueuedCommand() {
@@ -426,6 +435,31 @@
                threadPoolExecutor.getCompletedTaskCount());
    }
    @SuppressWarnings("unchecked")
    private int resolveSegmentExecutorPoolSize(RedisUtil redisUtil) {
        if (redisUtil == null) {
            return DEFAULT_SEGMENT_EXECUTOR_POOL_SIZE;
        }
        try {
            Object systemConfigMapObj = redisUtil.get(com.zy.core.enums.RedisKeyType.SYSTEM_CONFIG_MAP.key);
            if (!(systemConfigMapObj instanceof HashMap)) {
                return DEFAULT_SEGMENT_EXECUTOR_POOL_SIZE;
            }
            HashMap<String, String> systemConfigMap = (HashMap<String, String>) systemConfigMapObj;
            String poolSizeText = systemConfigMap.get(CFG_SEGMENT_EXECUTOR_POOL_SIZE);
            if (poolSizeText == null || poolSizeText.trim().isEmpty()) {
                return DEFAULT_SEGMENT_EXECUTOR_POOL_SIZE;
            }
            int configured = Integer.parseInt(poolSizeText.trim());
            if (configured < 16) {
                return 16;
            }
            return Math.min(configured, 512);
        } catch (Exception ignore) {
            return DEFAULT_SEGMENT_EXECUTOR_POOL_SIZE;
        }
    }
    @Override
    public CommandResponse sendOriginCommand(String address, short[] data) {
        return zyStationConnectDriver.sendOriginCommand(address, data);
src/main/java/com/zy/core/thread/impl/v5/StationV5StatusReader.java
@@ -24,6 +24,7 @@
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedHashSet;
import java.util.List;
public class StationV5StatusReader {
@@ -32,6 +33,7 @@
    private final RedisUtil redisUtil;
    private final RecentStationArrivalTracker recentArrivalTracker;
    private final List<StationProtocol> statusList = new ArrayList<>();
    private volatile List<Integer> taskNoList = new ArrayList<>();
    private boolean initialized = false;
    private long deviceDataLogTime = System.currentTimeMillis();
@@ -75,6 +77,7 @@
        int deviceLogCollectTime = initialized ? Utils.getDeviceLogCollectTime() : 200;
        List<ZyStationStatusEntity> zyStationStatusEntities = zyStationConnectDriver.getStatus();
        LinkedHashSet<Integer> taskNoSet = new LinkedHashSet<>();
        for (ZyStationStatusEntity statusEntity : zyStationStatusEntities) {
            for (StationProtocol stationProtocol : statusList) {
                if (stationProtocol.getStationId().equals(statusEntity.getStationId())) {
@@ -96,6 +99,17 @@
                    stationProtocol.setTaskWriteIdx(statusEntity.getTaskWriteIdx());
                    stationProtocol.setTaskBufferItems(statusEntity.getTaskBufferItems());
                    stationProtocol.setIoMode(statusEntity.getIoMode());
                    if (statusEntity.getTaskNo() != null && statusEntity.getTaskNo() > 0) {
                        taskNoSet.add(statusEntity.getTaskNo());
                    }
                    if (statusEntity.getTaskBufferItems() != null) {
                        statusEntity.getTaskBufferItems().forEach(item -> {
                            Integer bufferTaskNo = item == null ? null : item.getTaskNo();
                            if (bufferTaskNo != null && bufferTaskNo > 0) {
                                taskNoSet.add(bufferTaskNo);
                            }
                        });
                    }
                    recentArrivalTracker.observe(statusEntity.getStationId(), statusEntity.getTaskNo(), statusEntity.isLoading());
                }
@@ -106,6 +120,7 @@
                }
            }
        }
        taskNoList = new ArrayList<>(taskNoSet);
        OutputQueue.DEVP.offer(MessageFormat.format("【{0}】[id:{1}] <<<<< 实时数据更新成功",
                DateUtils.convert(new Date()), deviceConfig.getDeviceNo()));
@@ -127,4 +142,8 @@
    public List<StationProtocol> getStatusList() {
        return statusList;
    }
    public List<Integer> getTaskNoList() {
        return taskNoList;
    }
}
src/main/java/com/zy/core/utils/station/StationOutboundDispatchProcessor.java
@@ -2,8 +2,10 @@
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.zy.asrs.entity.BasStation;
import com.zy.asrs.domain.enums.NotifyMsgType;
import com.zy.asrs.entity.WrkMast;
import com.zy.asrs.service.BasStationService;
import com.zy.asrs.service.WrkAnalysisService;
import com.zy.asrs.service.WrkMastService;
import com.zy.asrs.utils.NotifyUtils;
@@ -30,12 +32,17 @@
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;
@Component
public class StationOutboundDispatchProcessor {
    private static final int PENDING_DISPATCH_EXPIRE_SECONDS = 60 * 10;
    @Autowired
    private WrkMastService wrkMastService;
    @Autowired
    private BasStationService basStationService;
    @Autowired
    private WrkAnalysisService wrkAnalysisService;
    @Autowired
@@ -68,6 +75,55 @@
        try {
            if (wrkMast == null || wrkMast.getWrkNo() == null) {
                return;
            }
            Object pendingObj = redisUtil.get(RedisKeyType.STATION_OUT_PENDING_DISPATCH_.key + wrkMast.getWrkNo());
            if (pendingObj != null) {
                if (!Objects.equals(wrkMast.getWrkSts(), WrkStsType.OUTBOUND_RUN_COMPLETE.sts)) {
                    clearPendingDispatch(wrkMast.getWrkNo());
                    return;
                }
                StationObjModel pendingStationObjModel = getOutboundSourceStation(wrkMast);
                if (pendingStationObjModel == null
                        || pendingStationObjModel.getDeviceNo() == null
                        || pendingStationObjModel.getStationId() == null) {
                    clearPendingDispatch(wrkMast.getWrkNo());
                    return;
                }
                StationThread pendingStationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, pendingStationObjModel.getDeviceNo());
                if (pendingStationThread != null) {
                    List<Integer> taskNoList = pendingStationThread.getAllTaskNoList();
                    if (taskNoList != null && taskNoList.contains(wrkMast.getWrkNo())) {
                        Date now = new Date();
                        wrkMast.setWrkSts(WrkStsType.STATION_RUN.sts);
                        wrkMast.setSystemMsg("");
                        wrkMast.setIoTime(now);
                        wrkMast.setModiTime(now);
                        if (wrkMastService.updateById(wrkMast)) {
                            wrkAnalysisService.markOutboundStationStart(wrkMast, now);
                            notifyUtils.notify(String.valueOf(SlaveType.Devp), pendingStationObjModel.getDeviceNo(),
                                    String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(),
                                    NotifyMsgType.STATION_OUT_TASK_RUN, null);
                            clearPendingDispatch(wrkMast.getWrkNo());
                            News.info("输送设备已发现任务号,任务转运行中。deviceNo={},源站={},工作号={}",
                                    pendingStationObjModel.getDeviceNo(), pendingStationObjModel.getStationId(), wrkMast.getWrkNo());
                        }
                        return;
                    }
                }
                long createdAt;
                try {
                    createdAt = Long.parseLong(String.valueOf(pendingObj));
                } catch (Exception ignore) {
                    createdAt = System.currentTimeMillis();
                }
                if (System.currentTimeMillis() - createdAt < 15_000L) {
                    return;
                }
                clearPendingDispatch(wrkMast.getWrkNo());
                News.warn("输送站点执行超时,已释放重试资格。工作号={}", wrkMast.getWrkNo());
            }
            Object infoObj = redisUtil.get(RedisKeyType.CRN_OUT_TASK_COMPLETE_STATION_INFO.key + wrkMast.getWrkNo());
@@ -150,30 +206,25 @@
                return;
            }
            Date now = new Date();
            wrkMast.setWrkSts(WrkStsType.STATION_RUN.sts);
            wrkMast.setSystemMsg("");
            wrkMast.setIoTime(now);
            wrkMast.setModiTime(now);
            if (wrkMastService.updateById(wrkMast)) {
                wrkAnalysisService.markOutboundStationStart(wrkMast, now);
                boolean offered = offerDevpCommandWithDedup(stationObjModel.getDeviceNo(), command, "crnStationOutExecute");
                if (offered && stationMoveCoordinator != null) {
                    stationMoveCoordinator.recordDispatch(
                            wrkMast.getWrkNo(),
                            stationProtocol.getStationId(),
                            "crnStationOutExecute",
                            command,
                            false
                    );
                }
                News.info("输送站点出库命令下发成功,站点号={},工作号={},命令数据={}",
                        stationProtocol.getStationId(), wrkMast.getWrkNo(), JSON.toJSONString(command));
                redisUtil.set(RedisKeyType.STATION_OUT_EXECUTE_LIMIT.key + stationProtocol.getStationId(), "lock", 5);
                redisUtil.del(RedisKeyType.CRN_OUT_TASK_COMPLETE_STATION_INFO.key + wrkMast.getWrkNo());
                loadGuardState.reserveLoopTask(loopHitResult.getLoopNo());
                stationDispatchLoadSupport.saveLoopLoadReserve(wrkMast.getWrkNo(), loopHitResult);
            boolean offered = offerDevpCommandWithDedup(stationObjModel.getDeviceNo(), command, "crnStationOutExecute");
            if (!offered) {
                return;
            }
            if (stationMoveCoordinator != null) {
                stationMoveCoordinator.recordDispatch(
                        wrkMast.getWrkNo(),
                        stationProtocol.getStationId(),
                        "crnStationOutExecute",
                        command,
                        false
                );
            }
            markPendingDispatch(wrkMast.getWrkNo());
            News.info("输送站点出库命令已入设备执行链路,等待源站执行。站点号={},工作号={},命令数据={}",
                    stationProtocol.getStationId(), wrkMast.getWrkNo(), JSON.toJSONString(command));
            redisUtil.set(RedisKeyType.STATION_OUT_EXECUTE_LIMIT.key + stationProtocol.getStationId(), "lock", 5);
            loadGuardState.reserveLoopTask(loopHitResult.getLoopNo());
            stationDispatchLoadSupport.saveLoopLoadReserve(wrkMast.getWrkNo(), loopHitResult);
        } catch (Exception e) {
            e.printStackTrace();
        }
@@ -185,6 +236,9 @@
                    .eq("wrk_sts", WrkStsType.OUTBOUND_RUN_COMPLETE.sts)
                    .isNotNull("dual_crn_no"));
            for (WrkMast wrkMast : wrkMasts) {
                if (hasPendingDispatch(wrkMast.getWrkNo())) {
                    continue;
                }
                Object infoObj = redisUtil.get(RedisKeyType.DUAL_CRN_OUT_TASK_STATION_INFO.key + wrkMast.getWrkNo());
                if (infoObj == null) {
                    News.info("出库任务{}数据缓存不存在", wrkMast.getWrkNo());
@@ -224,28 +278,23 @@
                        continue;
                    }
                    wrkMast.setWrkSts(WrkStsType.STATION_RUN.sts);
                    wrkMast.setSystemMsg("");
                    wrkMast.setIoTime(new Date());
                    if (wrkMastService.updateById(wrkMast)) {
                        boolean offered = offerDevpCommandWithDedup(stationObjModel.getDeviceNo(), command, "dualCrnStationOutExecute");
                        if (offered && stationMoveCoordinator != null) {
                            stationMoveCoordinator.recordDispatch(
                                    wrkMast.getWrkNo(),
                                    stationProtocol.getStationId(),
                                    "dualCrnStationOutExecute",
                                    command,
                                    false
                            );
                        }
                        notifyUtils.notify(String.valueOf(SlaveType.Devp), stationObjModel.getDeviceNo(),
                                String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(),
                                NotifyMsgType.STATION_OUT_TASK_RUN, null);
                        News.info("输送站点出库命令下发成功,站点号={},工作号={},命令数据={}",
                                stationProtocol.getStationId(), wrkMast.getWrkNo(), JSON.toJSONString(command));
                        redisUtil.set(RedisKeyType.STATION_OUT_EXECUTE_LIMIT.key + stationProtocol.getStationId(), "lock", 5);
                        redisUtil.del(RedisKeyType.DUAL_CRN_OUT_TASK_STATION_INFO.key + wrkMast.getWrkNo());
                    boolean offered = offerDevpCommandWithDedup(stationObjModel.getDeviceNo(), command, "dualCrnStationOutExecute");
                    if (!offered) {
                        continue;
                    }
                    if (stationMoveCoordinator != null) {
                        stationMoveCoordinator.recordDispatch(
                                wrkMast.getWrkNo(),
                                stationProtocol.getStationId(),
                                "dualCrnStationOutExecute",
                                command,
                                false
                        );
                    }
                    markPendingDispatch(wrkMast.getWrkNo());
                    News.info("输送站点出库命令已入设备执行链路,等待源站接单。站点号={},工作号={},命令数据={}",
                            stationProtocol.getStationId(), wrkMast.getWrkNo(), JSON.toJSONString(command));
                    redisUtil.set(RedisKeyType.STATION_OUT_EXECUTE_LIMIT.key + stationProtocol.getStationId(), "lock", 5);
                }
            }
        } catch (Exception e) {
@@ -258,4 +307,36 @@
                .dispatch(deviceNo, command, "station-operate-process", scene);
        return dispatchResult.isAccepted();
    }
    private StationObjModel getOutboundSourceStation(WrkMast wrkMast) {
        if (wrkMast == null || wrkMast.getSourceStaNo() == null) {
            return null;
        }
        BasStation basStation = basStationService.getById(wrkMast.getSourceStaNo());
        if (basStation == null || basStation.getDeviceNo() == null) {
            return null;
        }
        StationObjModel stationObjModel = new StationObjModel();
        stationObjModel.setStationId(wrkMast.getSourceStaNo());
        stationObjModel.setDeviceNo(basStation.getDeviceNo());
        return stationObjModel;
    }
    private boolean hasPendingDispatch(Integer wrkNo) {
        return wrkNo != null && redisUtil.get(RedisKeyType.STATION_OUT_PENDING_DISPATCH_.key + wrkNo) != null;
    }
    private void markPendingDispatch(Integer wrkNo) {
        if (wrkNo == null) {
            return;
        }
        redisUtil.set(RedisKeyType.STATION_OUT_PENDING_DISPATCH_.key + wrkNo, String.valueOf(System.currentTimeMillis()), PENDING_DISPATCH_EXPIRE_SECONDS);
    }
    private void clearPendingDispatch(Integer wrkNo) {
        if (wrkNo == null) {
            return;
        }
        redisUtil.del(RedisKeyType.STATION_OUT_PENDING_DISPATCH_.key + wrkNo);
    }
}
src/main/java/com/zy/core/utils/station/StationRegularDispatchProcessor.java
@@ -116,6 +116,7 @@
            wrkAnalysisService.markOutboundStationComplete(wrkMast, now);
            notifyUtils.notify(String.valueOf(SlaveType.Devp), stationObjModel.getDeviceNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.STATION_OUT_TASK_RUN_COMPLETE, null);
            redisUtil.set(RedisKeyType.STATION_OUT_EXECUTE_COMPLETE_LIMIT.key + wrkMast.getWrkNo(), "lock", 60);
            clearOutboundDispatchCache(wrkMast);
            attemptClearTaskPath(stationThread, wrkNo);
        } catch (Exception e) {
            e.printStackTrace();
@@ -169,12 +170,21 @@
                wrkMast.setWrkSts(WrkStsType.COMPLETE_OUTBOUND.sts);
                wrkMast.setIoTime(new Date());
                wrkMastService.updateById(wrkMast);
                clearOutboundDispatchCache(wrkMast);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    private void clearOutboundDispatchCache(WrkMast wrkMast) {
        if (wrkMast == null || wrkMast.getWrkNo() == null) {
            return;
        }
        redisUtil.del(RedisKeyType.CRN_OUT_TASK_COMPLETE_STATION_INFO.key + wrkMast.getWrkNo());
        redisUtil.del(RedisKeyType.DUAL_CRN_OUT_TASK_STATION_INFO.key + wrkMast.getWrkNo());
    }
    public void attemptClearTaskPath(StationThread stationThread, Integer taskNo) {
        if (stationThread == null || taskNo == null || taskNo <= 0) {
            return;