#
Junjie
2026-01-15 34b2641f4a039d4e1dcf8f4a93dd7928616c4b11
src/main/java/com/zy/core/plugin/FakeProcess.java
@@ -53,7 +53,7 @@
    private static final long METHOD_TIMEOUT_MS = 15000; // 15秒超时
    private static final ExecutorService timeoutExecutor = Executors.newCachedThreadPool();
    private static Map<Integer,Long> stationStayTimeMap = new ConcurrentHashMap<>();
    private static Map<Integer, Long> stationStayTimeMap = new ConcurrentHashMap<>();
    private static volatile String enableFake = "N";
    private static volatile String fakeRealTaskRequestWms = "N";
    private static volatile String fakeGenerateInTask = "Y";
@@ -88,8 +88,9 @@
    /**
     * 带超时保护执行方法
     *
     * @param taskName 任务名称(用于日志)
     * @param task 要执行的任务
     * @param task     要执行的任务
     */
    private void executeWithTimeout(String taskName, Runnable task) {
        Future<?> future = timeoutExecutor.submit(task);
@@ -110,24 +111,24 @@
        long startTime = System.currentTimeMillis();
        asyncFakeRun();
        //请求生成入库任务
        executeWithTimeout("generateStoreWrkFile", this::generateStoreWrkFile);
        // 请求生成入库任务
        this.generateStoreWrkFile();
        //执行堆垛机任务
        executeWithTimeout("crnIoExecute", crnOperateUtils::crnIoExecute);
        //堆垛机任务执行完成-具备仿真能力
        executeWithTimeout("crnIoExecuteFinish", this::crnIoExecuteFinish);
        //执行输送站点入库任务
        executeWithTimeout("stationInExecute", stationOperateProcessUtils::stationInExecute);
        //执行输送站点出库任务
        executeWithTimeout("stationOutExecute", stationOperateProcessUtils::stationOutExecute);
        //检测输送站点出库任务执行完成
        executeWithTimeout("stationOutExecuteFinish", stationOperateProcessUtils::stationOutExecuteFinish);
        // 执行堆垛机任务
        crnOperateUtils.crnIoExecuteNormal();
        // 堆垛机任务执行完成-具备仿真能力
        this.crnIoExecuteFinish();
        // 执行输送站点入库任务
        stationOperateProcessUtils.stationInExecute();
        // 执行输送站点出库任务
        stationOperateProcessUtils.stationOutExecute();
        // 检测输送站点出库任务执行完成
        stationOperateProcessUtils.stationOutExecuteFinish();
        //执行双工位堆垛机任务
        executeWithTimeout("dualCrnIoExecute", dualCrnOperateProcessUtils::dualCrnIoExecute);
        //双工位堆垛机任务执行完成
        executeWithTimeout("dualCrnIoExecuteFinish", dualCrnOperateProcessUtils::dualCrnIoExecuteFinish);
        // 执行双工位堆垛机任务
        dualCrnOperateProcessUtils.dualCrnIoExecute();
        // 双工位堆垛机任务执行完成
        dualCrnOperateProcessUtils.dualCrnIoExecuteFinish();
        News.info("[WCS Debug] 主线程Run执行完成,耗时:{}ms", System.currentTimeMillis() - startTime);
    }
@@ -140,22 +141,26 @@
        asyncFakeRunThread = new Thread(() -> {
            while (!Thread.currentThread().isInterrupted()) {
                try {
                    Config enableFakeConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "enableFake"));
                    Config enableFakeConfig = configService
                            .selectOne(new EntityWrapper<Config>().eq("code", "enableFake"));
                    if (enableFakeConfig != null) {
                        enableFake = enableFakeConfig.getValue();
                    }
                    Config fakeRealTaskRequestWmsConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "fakeRealTaskRequestWms"));
                    Config fakeRealTaskRequestWmsConfig = configService
                            .selectOne(new EntityWrapper<Config>().eq("code", "fakeRealTaskRequestWms"));
                    if (fakeRealTaskRequestWmsConfig != null) {
                        fakeRealTaskRequestWms = fakeRealTaskRequestWmsConfig.getValue();
                    }
                    Config fakeGenerateInTaskConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "fakeGenerateInTask"));
                    Config fakeGenerateInTaskConfig = configService
                            .selectOne(new EntityWrapper<Config>().eq("code", "fakeGenerateInTask"));
                    if (fakeGenerateInTaskConfig != null) {
                        fakeGenerateInTask = fakeGenerateInTaskConfig.getValue();
                    }
                    Config fakeGenerateOutTaskConfig = configService.selectOne(new EntityWrapper<Config>().eq("code", "fakeGenerateOutTask"));
                    Config fakeGenerateOutTaskConfig = configService
                            .selectOne(new EntityWrapper<Config>().eq("code", "fakeGenerateOutTask"));
                    if (fakeGenerateOutTaskConfig != null) {
                        fakeGenerateOutTask = fakeGenerateOutTaskConfig.getValue();
                    }
@@ -165,20 +170,20 @@
                        continue;
                    }
                    //检测入库站是否有任务生成,并仿真生成模拟入库站点数据
                    // 检测入库站是否有任务生成,并仿真生成模拟入库站点数据
                    checkInStationHasTask();
                    //生成仿真模拟入库任务
                    // 生成仿真模拟入库任务
                    generateFakeInTask();
                    //生成仿真模拟出库任务
                    // 生成仿真模拟出库任务
                    generateFakeOutTask();
                    //计算所有站点停留时间
                    // 计算所有站点停留时间
                    calcAllStationStayTime();
                    //检测出库站点停留是否超时
                    // 检测出库站点停留是否超时
                    checkOutStationStayTimeOut();
                    //检测入库站点堆垛机是否取走货物
                    // 检测入库站点堆垛机是否取走货物
                    checkInStationCrnTake();
                    //检测输送站点是否运行堵塞
                    // 检测输送站点是否运行堵塞
                    stationOperateProcessUtils.checkStationRunBlock();
                    // 间隔
@@ -196,8 +201,8 @@
        asyncFakeRunThread.start();
    }
    //检测入库站是否有任务生成,并仿真生成模拟入库站点数据
    private void checkInStationHasTask() {
    // 检测入库站是否有任务生成,并仿真生成模拟入库站点数据
    private synchronized void checkInStationHasTask() {
        if (!enableFake.equals("Y")) {
            return;
        }
@@ -209,7 +214,7 @@
        List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<>());
        for (BasDevp basDevp : basDevps) {
            StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo());
            if(stationThread == null){
            if (stationThread == null) {
                continue;
            }
@@ -218,7 +223,7 @@
            List<StationObjModel> list = basDevp.getInStationList$();
            for (StationObjModel entity : list) {
                Integer stationId = entity.getStationId();
                if(!stationMap.containsKey(stationId)){
                if (!stationMap.containsKey(stationId)) {
                    continue;
                }
@@ -228,16 +233,17 @@
                }
                Object lock = redisUtil.get(RedisKeyType.GENERATE_FAKE_IN_STATION_DATA_LIMIT.key + stationId);
                if(lock != null){
                if (lock != null) {
                    continue;
                }
                //满足自动、无物、工作号0,生成入库数据
                // 满足自动、无物、工作号0,生成入库数据
                if (stationProtocol.isAutoing()
                        && !stationProtocol.isLoading()
                        && stationProtocol.getTaskNo() == 0
                ) {
                    StationCommand command = stationThread.getCommand(StationCommandType.MOVE, commonService.getWorkNo(WrkIoType.FAKE_TASK_NO.id), stationId, entity.getBarcodeStation().getStationId(), 0);
                        && stationProtocol.getTaskNo() == 0) {
                    StationCommand command = stationThread.getCommand(StationCommandType.MOVE,
                            commonService.getWorkNo(WrkIoType.FAKE_TASK_NO.id), stationId,
                            entity.getBarcodeStation().getStationId(), 0);
                    MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command));
                    redisUtil.set(RedisKeyType.GENERATE_FAKE_IN_STATION_DATA_LIMIT.key + stationId, "lock", 5);
                }
@@ -245,8 +251,8 @@
        }
    }
    //生成仿真模拟入库任务
    private void generateFakeInTask() {
    // 生成仿真模拟入库任务
    private synchronized void generateFakeInTask() {
        if (!enableFake.equals("Y")) {
            return;
        }
@@ -262,7 +268,7 @@
        List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<>());
        for (BasDevp basDevp : basDevps) {
            StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo());
            if(stationThread == null){
            if (stationThread == null) {
                continue;
            }
@@ -271,7 +277,7 @@
            List<StationObjModel> list = basDevp.getBarcodeStationList$();
            for (StationObjModel model : list) {
                Integer stationId = model.getStationId();
                if(!stationMap.containsKey(stationId)){
                if (!stationMap.containsKey(stationId)) {
                    continue;
                }
@@ -285,22 +291,23 @@
                    continue;
                }
                //满足自动、有物、有工作号,生成入库数据
                // 满足自动、有物、有工作号,生成入库数据
                if (stationProtocol.isAutoing()
                        && stationProtocol.isLoading()
                        && stationProtocol.getTaskNo() > 0
                ) {
                        && stationProtocol.getTaskNo() > 0) {
                    if (Cools.isEmpty(stationProtocol.getBarcode())) {
                        continue;
                    }
                    //检测任务是否生成
                    List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("barcode", stationProtocol.getBarcode()));
                    // 检测任务是否生成
                    List<WrkMast> wrkMasts = wrkMastService
                            .selectList(new EntityWrapper<WrkMast>().eq("barcode", stationProtocol.getBarcode()));
                    if (!wrkMasts.isEmpty()) {
                        continue;
                    }
                    List<LocMast> locMastList = locMastService.selectList(new EntityWrapper<LocMast>().eq("loc_sts", String.valueOf(LocStsType.O)));
                    List<LocMast> locMastList = locMastService
                            .selectList(new EntityWrapper<LocMast>().eq("loc_sts", String.valueOf(LocStsType.O)));
                    if (locMastList.isEmpty()) {
                        continue;
                    }
@@ -326,8 +333,9 @@
                    taskParam.setBarcode(stationProtocol.getBarcode());
                    WrkMast wrkMast = commonService.createInTask(taskParam);
                    StationCommand command = stationThread.getCommand(StationCommandType.MOVE, wrkMast.getWrkNo(), stationId, stationId, 0);
                    if(command == null){
                    StationCommand command = stationThread.getCommand(StationCommandType.MOVE, wrkMast.getWrkNo(),
                            stationId, stationId, 0);
                    if (command == null) {
                        News.taskInfo(wrkMast.getWrkNo(), "获取输送线命令失败");
                        continue;
                    }
@@ -338,8 +346,8 @@
        }
    }
    //生成仿真模拟出库任务
    private void generateFakeOutTask() {
    // 生成仿真模拟出库任务
    private synchronized void generateFakeOutTask() {
        if (!enableFake.equals("Y")) {
            return;
        }
@@ -355,7 +363,7 @@
        List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<>());
        for (BasDevp basDevp : basDevps) {
            StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo());
            if(stationThread == null){
            if (stationThread == null) {
                continue;
            }
@@ -364,7 +372,7 @@
            List<StationObjModel> list = basDevp.getOutStationList$();
            for (StationObjModel entity : list) {
                Integer stationId = entity.getStationId();
                if(!stationMap.containsKey(stationId)){
                if (!stationMap.containsKey(stationId)) {
                    continue;
                }
@@ -374,16 +382,16 @@
                }
                Object object = redisUtil.get(RedisKeyType.GENERATE_FAKE_OUT_TASK_LIMIT.key + stationId);
                if(object != null){
                if (object != null) {
                    return;
                }
                //满足自动、无物、工作号0,生成出库数据
                // 满足自动、无物、工作号0,生成出库数据
                if (stationProtocol.isAutoing()
                        && !stationProtocol.isLoading()
                        && stationProtocol.getTaskNo() == 0
                ) {
                    List<LocMast> locMastList = locMastService.selectList(new EntityWrapper<LocMast>().eq("loc_sts", String.valueOf(LocStsType.F)));
                        && stationProtocol.getTaskNo() == 0) {
                    List<LocMast> locMastList = locMastService
                            .selectList(new EntityWrapper<LocMast>().eq("loc_sts", String.valueOf(LocStsType.F)));
                    if (locMastList.isEmpty()) {
                        continue;
                    }
@@ -419,7 +427,7 @@
            int conveyorStationTaskLimit = 30;
            String conveyorStationTaskLimitStr = systemConfigMap.get("conveyorStationTaskLimit");
            if(conveyorStationTaskLimitStr != null){
            if (conveyorStationTaskLimitStr != null) {
                conveyorStationTaskLimit = Integer.parseInt(conveyorStationTaskLimitStr);
            }
            int currentStationTaskCount = stationOperateProcessUtils.getCurrentStationTaskCount();
@@ -449,17 +457,17 @@
                        continue;
                    }
                    //满足自动、有物、有工作号,生成入库数据
                    // 满足自动、有物、有工作号,生成入库数据
                    if (stationProtocol.isAutoing()
                            && stationProtocol.isLoading()
                            && stationProtocol.getTaskNo() > 0
                    ) {
                            && stationProtocol.getTaskNo() > 0) {
                        if (Cools.isEmpty(stationProtocol.getBarcode())) {
                            continue;
                        }
                        //检测任务是否生成
                        List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("barcode", stationProtocol.getBarcode()));
                        // 检测任务是否生成
                        List<WrkMast> wrkMasts = wrkMastService
                                .selectList(new EntityWrapper<WrkMast>().eq("barcode", stationProtocol.getBarcode()));
                        if (!wrkMasts.isEmpty()) {
                            continue;
                        }
@@ -468,30 +476,62 @@
                        if (lock != null) {
                            continue;
                        }
                        redisUtil.set(RedisKeyType.GENERATE_IN_TASK_LIMIT.key + stationId, "lock", 2);
                        String response = wmsOperateUtils.applyInTask(stationProtocol.getBarcode(), stationProtocol.getStationId(), stationProtocol.getPalletHeight());
                        if (response == null) {
                            News.error("请求WMS入库接口失败,接口未响应!!!response:{}", response);
                            continue;
                        }
                        JSONObject jsonObject = JSON.parseObject(response);
                        if (jsonObject.getInteger("code").equals(200)) {
                            StartupDto dto = jsonObject.getObject("data", StartupDto.class);
                        String barcode = stationProtocol.getBarcode();
                        Integer stationIdVal = stationProtocol.getStationId();
                            CreateInTaskParam taskParam = new CreateInTaskParam();
                            taskParam.setTaskNo(dto.getTaskNo());
                            taskParam.setLocNo(dto.getLocNo());
                            taskParam.setTaskPri(dto.getTaskPri());
                            taskParam.setBarcode(stationProtocol.getBarcode());
                            WrkMast wrkMast = commonService.createInTask(taskParam);
                        // 1. 首先查询是否有已完成的异步响应
                        String response = wmsOperateUtils.queryAsyncInTaskResponse(barcode, stationIdVal);
                            StationCommand command = stationThread.getCommand(StationCommandType.WRITE_INFO, wrkMast.getWrkNo(), stationId, stationId, 0);
                            if (command == null) {
                                News.taskInfo(wrkMast.getWrkNo(), "获取输送线命令失败");
                        if (response != null) {
                            // 2. 有响应结果,处理响应
                            if (response.equals("FAILED") || response.startsWith("ERROR:")) {
                                // 请求失败,重新发起异步请求
                                News.error("WMS入库请求失败,重新发起请求,barcode={},stationId={},response={}", barcode,
                                        stationIdVal, response);
                                wmsOperateUtils.applyInTaskAsync(barcode, stationIdVal,
                                        stationProtocol.getPalletHeight());
                                redisUtil.set(RedisKeyType.GENERATE_IN_TASK_LIMIT.key + stationId, "lock", 2);
                                continue;
                            }
                            MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command));
                            // 解析响应
                            JSONObject jsonObject = JSON.parseObject(response);
                            if (jsonObject.getInteger("code").equals(200)) {
                                StartupDto dto = jsonObject.getObject("data", StartupDto.class);
                                CreateInTaskParam taskParam = new CreateInTaskParam();
                                taskParam.setTaskNo(dto.getTaskNo());
                                taskParam.setLocNo(dto.getLocNo());
                                taskParam.setTaskPri(dto.getTaskPri());
                                taskParam.setBarcode(barcode);
                                WrkMast wrkMast = commonService.createInTask(taskParam);
                                StationCommand command = stationThread.getCommand(StationCommandType.WRITE_INFO,
                                        wrkMast.getWrkNo(), stationId, stationId, 0);
                                if (command == null) {
                                    News.taskInfo(wrkMast.getWrkNo(), "获取输送线命令失败");
                                    continue;
                                }
                                MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command));
                            } else {
                                // 接口返回非200,重新发起请求
                                News.error("WMS入库接口返回非200,重新发起请求,barcode={},stationId={},response={}", barcode,
                                        stationIdVal, response);
                                wmsOperateUtils.applyInTaskAsync(barcode, stationIdVal,
                                        stationProtocol.getPalletHeight());
                                redisUtil.set(RedisKeyType.GENERATE_IN_TASK_LIMIT.key + stationId, "lock", 2);
                            }
                        } else {
                            // 3. 没有响应结果,检查是否有请求正在进行中
                            if (!wmsOperateUtils.isAsyncRequestInProgress(barcode, stationIdVal)) {
                                // 没有请求进行中,发起新的异步请求
                                News.info("发起异步WMS入库请求,barcode={},stationId={}", barcode, stationIdVal);
                                wmsOperateUtils.applyInTaskAsync(barcode, stationIdVal,
                                        stationProtocol.getPalletHeight());
                                redisUtil.set(RedisKeyType.GENERATE_IN_TASK_LIMIT.key + stationId, "lock", 2);
                            }
                            // 如果有请求进行中,等待下次循环再检查
                        }
                    }
                }
@@ -501,8 +541,8 @@
        }
    }
    //计算所有站点停留时间
    public void calcAllStationStayTime() {
    // 计算所有站点停留时间
    public synchronized void calcAllStationStayTime() {
        List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<>());
        for (BasDevp basDevp : basDevps) {
            StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo());
@@ -512,30 +552,33 @@
            List<StationProtocol> list = stationThread.getStatus();
            for (StationProtocol stationProtocol : list) {
                if (stationProtocol.getTaskNo() > 0 && !stationStayTimeMap.containsKey(stationProtocol.getStationId())) {
                if (stationProtocol.getTaskNo() > 0
                        && !stationStayTimeMap.containsKey(stationProtocol.getStationId())) {
                    stationStayTimeMap.put(stationProtocol.getStationId(), System.currentTimeMillis());
                }
                if(stationProtocol.getTaskNo() <= 0 && stationStayTimeMap.containsKey(stationProtocol.getStationId())) {
                if (stationProtocol.getTaskNo() <= 0
                        && stationStayTimeMap.containsKey(stationProtocol.getStationId())) {
                    stationStayTimeMap.remove(stationProtocol.getStationId());
                }
            }
        }
    }
    //检测出库站点停留是否超时
    public void checkOutStationStayTimeOut() {
    // 检测出库站点停留是否超时
    public synchronized void checkOutStationStayTimeOut() {
        List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<>());
        for (BasDevp basDevp : basDevps) {
            List<StationObjModel> outStationList = basDevp.getOutStationList$();
            if(outStationList.isEmpty()){
            if (outStationList.isEmpty()) {
                News.info("输送线:{} 出库站点未设置", basDevp.getDevpNo());
                continue;
            }
            for (StationObjModel stationObjModel : outStationList) {
                Object lock = redisUtil.get(RedisKeyType.CHECK_OUT_STATION_STAY_TIME_OUT_LIMIT.key + stationObjModel.getStationId());
                if(lock != null){
                Object lock = redisUtil
                        .get(RedisKeyType.CHECK_OUT_STATION_STAY_TIME_OUT_LIMIT.key + stationObjModel.getStationId());
                if (lock != null) {
                    continue;
                }
@@ -544,31 +587,36 @@
                    continue;
                }
                if(System.currentTimeMillis() - stayTime > 1000 * 15) {
                    StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
                    if(stationThread == null){
                if (System.currentTimeMillis() - stayTime > 1000 * 15) {
                    StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp,
                            stationObjModel.getDeviceNo());
                    if (stationThread == null) {
                        continue;
                    }
                    StationCommand command = stationThread.getCommand(StationCommandType.RESET, 0, stationObjModel.getStationId(), 0, 0);
                    if(command == null){
                    StationCommand command = stationThread.getCommand(StationCommandType.RESET, 0,
                            stationObjModel.getStationId(), 0, 0);
                    if (command == null) {
                        continue;
                    }
                    MessageQueue.offer(SlaveType.Devp, stationObjModel.getDeviceNo(), new Task(2, command));
                    redisUtil.set(RedisKeyType.CHECK_OUT_STATION_STAY_TIME_OUT_LIMIT.key + stationObjModel.getStationId(), "lock",10);
                    News.info("输送站点出库重置命令下发成功,站点号={},命令数据={}", stationObjModel.getStationId(), JSON.toJSONString(command));
                    redisUtil.set(
                            RedisKeyType.CHECK_OUT_STATION_STAY_TIME_OUT_LIMIT.key + stationObjModel.getStationId(),
                            "lock", 10);
                    News.info("输送站点出库重置命令下发成功,站点号={},命令数据={}", stationObjModel.getStationId(),
                            JSON.toJSONString(command));
                }
            }
        }
    }
    //检测入库站点堆垛机是否取走货物
    public void checkInStationCrnTake() {
    // 检测入库站点堆垛机是否取走货物
    public synchronized void checkInStationCrnTake() {
        List<BasCrnp> basCrnps = basCrnpService.selectList(new EntityWrapper<>());
        for (BasCrnp basCrnp : basCrnps) {
            List<StationObjModel> inStationList = basCrnp.getInStationList$();
            if(inStationList.isEmpty()){
            if (inStationList.isEmpty()) {
                News.info("堆垛机:{} 入库站点未设置", basCrnp.getCrnNo());
                continue;
            }
@@ -578,7 +626,7 @@
        List<BasDualCrnp> basDualCrnps = basDualCrnpService.selectList(new EntityWrapper<>());
        for (BasDualCrnp basDualCrnp : basDualCrnps) {
            List<StationObjModel> inStationList = basDualCrnp.getInStationList$();
            if(inStationList.isEmpty()){
            if (inStationList.isEmpty()) {
                News.info("双工位堆垛机:{} 入库站点未设置", basDualCrnp.getCrnNo());
                continue;
            }
@@ -586,15 +634,17 @@
        }
    }
    private void checkInStationListCrnTake(List<StationObjModel> inStationList) {
    private synchronized void checkInStationListCrnTake(List<StationObjModel> inStationList) {
        for (StationObjModel stationObjModel : inStationList) {
            Object lock = redisUtil.get(RedisKeyType.CHECK_IN_STATION_STAY_TIME_OUT_LIMIT.key + stationObjModel.getStationId());
            if(lock != null){
            Object lock = redisUtil
                    .get(RedisKeyType.CHECK_IN_STATION_STAY_TIME_OUT_LIMIT.key + stationObjModel.getStationId());
            if (lock != null) {
                continue;
            }
            StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
            if(stationThread == null){
            StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp,
                    stationObjModel.getDeviceNo());
            if (stationThread == null) {
                continue;
            }
@@ -604,19 +654,24 @@
                continue;
            }
            if(stationProtocol.getTaskNo() > 0) {
                StationCommand command = stationThread.getCommand(StationCommandType.RESET, 0, stationObjModel.getStationId(), 0, 0);
                if(command == null){
            if (stationProtocol.getTaskNo() > 0) {
                StationCommand command = stationThread.getCommand(StationCommandType.RESET, 0,
                        stationObjModel.getStationId(), 0, 0);
                if (command == null) {
                    continue;
                }
                WrkMast wrkMast = wrkMastService.selectByWorkNo(stationProtocol.getTaskNo());
                if (wrkMast == null) {
                    MessageQueue.offer(SlaveType.Devp, stationObjModel.getDeviceNo(), new Task(2, command));
                    redisUtil.set(RedisKeyType.CHECK_IN_STATION_STAY_TIME_OUT_LIMIT.key + stationObjModel.getStationId(), "lock",10);
                    News.info("输送站点重置命令下发成功(task_over),站点号={},命令数据={}", stationObjModel.getStationId(), JSON.toJSONString(command));
                }else {
                    if (wrkMast.getWrkSts() != WrkStsType.NEW_INBOUND.sts && wrkMast.getWrkSts() != WrkStsType.INBOUND_DEVICE_RUN.sts) {
                    redisUtil.set(
                            RedisKeyType.CHECK_IN_STATION_STAY_TIME_OUT_LIMIT.key + stationObjModel.getStationId(),
                            "lock", 10);
                    News.info("输送站点重置命令下发成功(task_over),站点号={},命令数据={}", stationObjModel.getStationId(),
                            JSON.toJSONString(command));
                } else {
                    if (wrkMast.getWrkSts() != WrkStsType.NEW_INBOUND.sts
                            && wrkMast.getWrkSts() != WrkStsType.INBOUND_DEVICE_RUN.sts) {
                        Integer crnNo = wrkMast.getCrnNo();
                        if (crnNo != null) {
                            CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crnNo);
@@ -624,16 +679,20 @@
                                continue;
                            }
                            CrnProtocol crnProtocol = crnThread.getStatus();
                            if (!crnProtocol.getStatusType().equals(CrnStatusType.PUT_MOVING) && !crnProtocol.getStatusType().equals(CrnStatusType.PUTTING)) {
                            if (!crnProtocol.getStatusType().equals(CrnStatusType.PUT_MOVING)
                                    && !crnProtocol.getStatusType().equals(CrnStatusType.PUTTING)) {
                                continue;
                            }
                            MessageQueue.offer(SlaveType.Devp, stationObjModel.getDeviceNo(), new Task(2, command));
                            redisUtil.set(RedisKeyType.CHECK_IN_STATION_STAY_TIME_OUT_LIMIT.key + stationObjModel.getStationId(), "lock",10);
                            News.info("输送站点重置命令下发成功(crn_fetch),站点号={},命令数据={}", stationObjModel.getStationId(), JSON.toJSONString(command));
                        }else {
                            redisUtil.set(RedisKeyType.CHECK_IN_STATION_STAY_TIME_OUT_LIMIT.key
                                    + stationObjModel.getStationId(), "lock", 10);
                            News.info("输送站点重置命令下发成功(crn_fetch),站点号={},命令数据={}", stationObjModel.getStationId(),
                                    JSON.toJSONString(command));
                        } else {
                            Integer dualCrnNo = wrkMast.getDualCrnNo();
                            DualCrnThread dualCrnThread = (DualCrnThread) SlaveConnection.get(SlaveType.DualCrn, dualCrnNo);
                            DualCrnThread dualCrnThread = (DualCrnThread) SlaveConnection.get(SlaveType.DualCrn,
                                    dualCrnNo);
                            if (dualCrnThread == null) {
                                continue;
                            }
@@ -653,8 +712,10 @@
                            }
                            MessageQueue.offer(SlaveType.Devp, stationObjModel.getDeviceNo(), new Task(2, command));
                            redisUtil.set(RedisKeyType.CHECK_IN_STATION_STAY_TIME_OUT_LIMIT.key + stationObjModel.getStationId(), "lock",10);
                            News.info("输送站点重置命令下发成功(crn_fetch),站点号={},命令数据={}", stationObjModel.getStationId(), JSON.toJSONString(command));
                            redisUtil.set(RedisKeyType.CHECK_IN_STATION_STAY_TIME_OUT_LIMIT.key
                                    + stationObjModel.getStationId(), "lock", 10);
                            News.info("输送站点重置命令下发成功(crn_fetch),站点号={},命令数据={}", stationObjModel.getStationId(),
                                    JSON.toJSONString(command));
                        }
                    }
                }
@@ -662,26 +723,25 @@
        }
    }
    //堆垛机任务执行完成
    public void crnIoExecuteFinish() {
    // 堆垛机任务执行完成
    public synchronized void crnIoExecuteFinish() {
        List<BasCrnp> basCrnps = basCrnpService.selectList(new EntityWrapper<>());
        for (BasCrnp basCrnp : basCrnps) {
            CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, basCrnp.getCrnNo());
            if(crnThread == null){
            if (crnThread == null) {
                continue;
            }
            CrnProtocol crnProtocol = crnThread.getStatus();
            if(crnProtocol == null){
            if (crnProtocol == null) {
                continue;
            }
            if (crnProtocol.getMode() == CrnModeType.AUTO.id
                    && crnProtocol.getTaskNo() > 0
                    && crnProtocol.getStatus() == CrnStatusType.WAITING.id
            ) {
                    && crnProtocol.getStatus() == CrnStatusType.WAITING.id) {
                Object lock = redisUtil.get(RedisKeyType.CRN_IO_EXECUTE_FINISH_LIMIT.key + basCrnp.getCrnNo());
                if(lock != null){
                if (lock != null) {
                    continue;
                }
@@ -693,14 +753,14 @@
                }
                Long updateWrkSts = null;
                if(wrkMast.getWrkSts() == WrkStsType.INBOUND_RUN.sts){
                if (wrkMast.getWrkSts() == WrkStsType.INBOUND_RUN.sts) {
                    updateWrkSts = WrkStsType.COMPLETE_INBOUND.sts;
                }else if(wrkMast.getWrkSts() == WrkStsType.OUTBOUND_RUN.sts){
                } else if (wrkMast.getWrkSts() == WrkStsType.OUTBOUND_RUN.sts) {
                    updateWrkSts = WrkStsType.OUTBOUND_RUN_COMPLETE.sts;
                    //生成仿真站点数据
                    // 生成仿真站点数据
                    List<StationObjModel> outStationList = basCrnp.getOutStationList$();
                    if(outStationList.isEmpty()){
                    if (outStationList.isEmpty()) {
                        News.info("堆垛机:{} 出库站点未设置", basCrnp.getCrnNo());
                        continue;
                    }
@@ -710,17 +770,19 @@
                            continue;
                        }
                        StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
                        StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp,
                                stationObjModel.getDeviceNo());
                        if (stationThread == null) {
                            continue;
                        }
                        //生成仿真站点数据
                        StationCommand command = stationThread.getCommand(StationCommandType.WRITE_INFO, 9998, wrkMast.getSourceStaNo(), 0, 0);
                        // 生成仿真站点数据
                        StationCommand command = stationThread.getCommand(StationCommandType.WRITE_INFO, 9998,
                                wrkMast.getSourceStaNo(), 0, 0);
                        MessageQueue.offer(SlaveType.Devp, stationObjModel.getDeviceNo(), new Task(2, command));
                    }
                }else if(wrkMast.getWrkSts() == WrkStsType.LOC_MOVE_RUN.sts){
                } else if (wrkMast.getWrkSts() == WrkStsType.LOC_MOVE_RUN.sts) {
                    updateWrkSts = WrkStsType.COMPLETE_LOC_MOVE.sts;
                }else{
                } else {
                    News.error("堆垛机处于等待确认且任务完成状态,但工作状态异常。堆垛机号={},工作号={}", basCrnp.getCrnNo(), crnProtocol.getTaskNo());
                    continue;
                }
@@ -734,7 +796,7 @@
                    News.info("堆垛机任务状态更新成功,堆垛机号={},工作号={}", basCrnp.getCrnNo(), crnProtocol.getTaskNo());
                }
                redisUtil.set(RedisKeyType.CRN_IO_EXECUTE_FINISH_LIMIT.key + basCrnp.getCrnNo(), "lock",10);
                redisUtil.set(RedisKeyType.CRN_IO_EXECUTE_FINISH_LIMIT.key + basCrnp.getCrnNo(), "lock", 10);
            }
        }
    }