#
cpT
7 天以前 4a1aabe58c417352b62504255603f790b0a6228b
#
1个文件已添加
9个文件已修改
1398 ■■■■ 已修改文件
src/main/java/com/zy/core/enums/RedisKeyType.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/model/StationObjModel.java 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/model/param/SendDualCrnCommandParam.java 19 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/plugin/NormalProcess.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/plugin/XiaosongProcess.java 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/impl/ZySiemensDualCrnThread.java 230 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/utils/CrnOperateProcessUtils.java 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/utils/DualCrnOperateProcessUtils.java 502 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/utils/StationOperateProcessUtils.java 636 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/resources/application.yml 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/enums/RedisKeyType.java
@@ -10,7 +10,6 @@
    LIFT_FLAG("lift_"),
    DUAL_CRN_COMMAND_("dual_crn_command_"),
    DUAL_CRN_COMMAND_STATION_TASK_NO("dual_crn_command_station_task_no_"),
    QUEUE_CRN("queue_crn_"),
    QUEUE_DUAL_CRN("queue_dual_crn_"),
src/main/java/com/zy/core/model/StationObjModel.java
@@ -26,6 +26,4 @@
    private StationObjModel backStation;
    private StationObjModel dualCrnSlaveStation;
}
src/main/java/com/zy/core/model/param/SendDualCrnCommandParam.java
New file
@@ -0,0 +1,19 @@
package com.zy.core.model.param;
import com.zy.core.model.command.DualCrnCommand;
import lombok.Data;
import java.util.List;
@Data
public class SendDualCrnCommandParam {
    private Integer crnNo;
    private Integer station;
    private List<DualCrnCommand> commands;
    private Integer commandIdx;
}
src/main/java/com/zy/core/plugin/NormalProcess.java
@@ -124,6 +124,7 @@
                    // 满足自动、有物、有工作号,生成入库数据
                    if (stationProtocol.isAutoing()
                            && stationProtocol.isLoading()
                            && stationProtocol.isInEnable()
                            && stationProtocol.getTaskNo() > 0) {
                        if (Cools.isEmpty(stationProtocol.getBarcode())) {
                            continue;
src/main/java/com/zy/core/plugin/XiaosongProcess.java
@@ -134,6 +134,7 @@
                    // 满足自动、有物、有工作号,生成入库数据
                    if (stationProtocol.isAutoing()
                            && stationProtocol.isLoading()
                            && stationProtocol.isInEnable()
                            && stationProtocol.getTaskNo() > 0) {
                        if (Cools.isEmpty(stationProtocol.getBarcode())) {
                            continue;
src/main/java/com/zy/core/thread/impl/ZySiemensDualCrnThread.java
@@ -20,6 +20,7 @@
import com.zy.core.model.StationObjModel;
import com.zy.core.model.Task;
import com.zy.core.model.command.DualCrnCommand;
import com.zy.core.model.param.SendDualCrnCommandParam;
import com.zy.core.model.protocol.DualCrnProtocol;
import com.zy.core.model.protocol.StationProtocol;
import com.zy.core.network.DeviceConnectPool;
@@ -31,10 +32,8 @@
import lombok.extern.slf4j.Slf4j;
import java.text.MessageFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.*;
import com.zy.asrs.entity.BasDualCrnpErrLog;
import com.zy.asrs.service.BasDualCrnpErrLogService;
@@ -85,15 +84,8 @@
                    }
                    if (step == 2) {
                        List<DualCrnCommand> commandList = (List<DualCrnCommand>) task.getData();
                        DualCrnCommand command = commandList.get(0);
                        HashMap<String, Object> map = new HashMap<>();
                        map.put("commands", commandList);
                        map.put("idx", 1);
                        redisUtil.set(RedisKeyType.DUAL_CRN_COMMAND_.key + command.getTaskNo(), JSON.toJSONString(map, SerializerFeature.DisableCircularReferenceDetect), 60 * 60 * 24);
                        redisUtil.set(RedisKeyType.DUAL_CRN_COMMAND_STATION_TASK_NO.key + crnProtocol.getCrnNo() + "_" + command.getStation(), command.getTaskNo(), 60 * 60 * 24);
                        sendCommand(command);
                        List<SendDualCrnCommandParam> commandList = (List<SendDualCrnCommandParam>) task.getData();
                        redisUtil.set(RedisKeyType.DUAL_CRN_COMMAND_.key + crnProtocol.getCrnNo(), JSON.toJSONString(commandList, SerializerFeature.DisableCircularReferenceDetect), 60 * 60 * 24);
                    } else if (step == 3) {
                        sendCommand((DualCrnCommand) task.getData());
                    }
@@ -117,121 +109,28 @@
                        continue;
                    }
                    if (crnProtocol.getLoaded() == 1 && crnProtocol.getLoadedTwo() == 1) {
                        Object wait = redisUtil.get(RedisKeyType.DUAL_CRN_PICK_WAIT_NEXT_TASK.key + crnProtocol.getCrnNo());
                        if (wait != null) {
                            redisUtil.del(RedisKeyType.DUAL_CRN_PICK_WAIT_NEXT_TASK.key + crnProtocol.getCrnNo());
//                    if (crnProtocol.getLoaded() == 1 && crnProtocol.getLoadedTwo() == 1) {
//                        Object wait = redisUtil.get(RedisKeyType.DUAL_CRN_PICK_WAIT_NEXT_TASK.key + crnProtocol.getCrnNo());
//                        if (wait != null) {
//                            redisUtil.del(RedisKeyType.DUAL_CRN_PICK_WAIT_NEXT_TASK.key + crnProtocol.getCrnNo());
//                        }
//                    }
                    Object commandListObj = redisUtil.get(RedisKeyType.DUAL_CRN_COMMAND_.key + crnProtocol.getCrnNo());
                    if (commandListObj == null) {
                        continue;
                    }
                    List<SendDualCrnCommandParam> commandList = JSON.parseArray(commandListObj.toString(), SendDualCrnCommandParam.class);
                    List<SendDualCrnCommandParam> newCommandList = new ArrayList<>();
                    for (SendDualCrnCommandParam commandParam : commandList) {
                        SendDualCrnCommandParam processed = processStation(commandParam);
                        if(processed != null) {
                            newCommandList.add(processed);
                        }
                    }
                    if(crnProtocol.getTaskNo() == 0 && crnProtocol.getStatus().equals(DualCrnStatusType.FETCH_COMPLETE.id)) {
                        Integer taskNo = null;
                        Object stationObj = redisUtil.get(RedisKeyType.DUAL_CRN_COMMAND_STATION_TASK_NO.key + crnProtocol.getCrnNo() + "_" + 1);
                        if(stationObj != null) {
                            taskNo = Integer.parseInt(String.valueOf(stationObj));
                        }
                        if (taskNo == null) {
                            News.error("双工位堆垛机,工位1空闲等待下发命令,但未找到工作号。堆垛机号={}", crnProtocol.getCrnNo());
                            continue;
                        }
                        Object commandObj = redisUtil.get(RedisKeyType.DUAL_CRN_COMMAND_.key + taskNo);
                        if (commandObj == null) {
                            News.error("双工位堆垛机,工位1空闲等待下发命令,但未找到命令。堆垛机号={},工作号={}", crnProtocol.getCrnNo(), taskNo);
                            continue;
                        }
                        JSONObject commandMap = JSON.parseObject(commandObj.toString());
                        Integer idx = commandMap.getInteger("idx");
                        List<DualCrnCommand> commandList = commandMap.getJSONArray("commands").toJavaList(DualCrnCommand.class);
                        if (idx >= commandList.size()) {
                            continue;
                        }
                        DualCrnCommand dualCommand = commandList.get(idx);
                        if (dualCommand.getTaskMode() == DualCrnTaskModeType.PUT.id.shortValue()) {
                            //等待下一个任务
                            Object wait = redisUtil.get(RedisKeyType.DUAL_CRN_PICK_WAIT_NEXT_TASK.key + crnProtocol.getCrnNo());
                            if (wait != null) {
                                continue;
                            }
                            Object outTaskStationInfoObj = redisUtil.get(RedisKeyType.DUAL_CRN_OUT_TASK_STATION_INFO.key + taskNo);
                            if (outTaskStationInfoObj != null) {
                                //检测出口站是否可执行放货动作
                                StationObjModel stationObjModel = JSON.parseObject(outTaskStationInfoObj.toString(), StationObjModel.class);
                                StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
                                if (stationThread == null) {
                                    continue;
                                }
                                Map<Integer, StationProtocol> statusMap = stationThread.getStatusMap();
                                StationProtocol stationProtocol = statusMap.get(stationObjModel.getStationId());
                                if (stationProtocol == null) {
                                    continue;
                                }
                                if (!stationProtocol.isAutoing()) {
                                    continue;
                                }
                                if (stationProtocol.isLoading()) {
                                    continue;
                                }
                                if (stationProtocol.getTaskNo() > 0) {
                                    continue;
                                }
                            }
                        }
                        idx++;
                        commandMap.put("idx", idx);
                        sendCommand(dualCommand);
                        redisUtil.set(RedisKeyType.DUAL_CRN_COMMAND_.key + taskNo, commandMap.toJSONString(), 60 * 60 * 24);
                    }
                    if(crnProtocol.getTaskNoTwo() == 0 && crnProtocol.getStatusTwo().equals(DualCrnStatusType.FETCH_COMPLETE.id)) {
                        Integer taskNo = null;
                        Object stationObj = redisUtil.get(RedisKeyType.DUAL_CRN_COMMAND_STATION_TASK_NO.key + crnProtocol.getCrnNo() + "_" + 2);
                        if(stationObj != null) {
                            taskNo = Integer.parseInt(String.valueOf(stationObj));
                        }
                        if (taskNo == null) {
                            News.error("双工位堆垛机,工位1空闲等待下发命令,但未找到工作号。堆垛机号={}", crnProtocol.getCrnNo());
                            continue;
                        }
                        Object commandObj = redisUtil.get(RedisKeyType.DUAL_CRN_COMMAND_.key + taskNo);
                        if (commandObj == null) {
                            News.error("双工位堆垛机,工位2空闲等待下发命令,但未找到命令。堆垛机号={},工作号={}", crnProtocol.getCrnNo(), taskNo);
                            continue;
                        }
                        JSONObject commandMap = JSON.parseObject(commandObj.toString());
                        Integer idx = commandMap.getInteger("idx");
                        List<DualCrnCommand> commandList = commandMap.getJSONArray("commands").toJavaList(DualCrnCommand.class);
                        if (idx >= commandList.size()) {
                            continue;
                        }
                        DualCrnCommand dualCommand = commandList.get(idx);
                        if (dualCommand.getTaskMode() == DualCrnTaskModeType.PUT.id.shortValue()) {
                            //等待下一个任务
                            Object wait = redisUtil.get(RedisKeyType.DUAL_CRN_PICK_WAIT_NEXT_TASK.key + crnProtocol.getCrnNo());
                            if (wait != null) {
                                continue;
                            }
                        }
                        idx++;
                        commandMap.put("idx", idx);
                        sendCommand(dualCommand);
                        redisUtil.set(RedisKeyType.DUAL_CRN_COMMAND_.key + taskNo, commandMap.toJSONString(), 60 * 60 * 24);
                    }
                    redisUtil.set(RedisKeyType.DUAL_CRN_COMMAND_.key + crnProtocol.getCrnNo(), JSON.toJSONString(newCommandList, SerializerFeature.DisableCircularReferenceDetect), 60 * 60 * 24);
                    Thread.sleep(100);
                } catch (Exception e) {
                    log.error("DualCrnCommand Fail", e);
@@ -239,6 +138,85 @@
            }
        });
        commandThread.start();
    }
    private SendDualCrnCommandParam processStation(SendDualCrnCommandParam commandParam) {
        Integer station = commandParam.getStation();
        Integer idx = commandParam.getCommandIdx();
        List<DualCrnCommand> commandList = commandParam.getCommands();
        if (idx >= commandList.size()) {
            return commandParam;
        }
        DualCrnCommand dualCommand = commandList.get(idx);
        boolean send = false;
        if (station == 1) {
            if (crnProtocol.getStatus().equals(DualCrnStatusType.FETCH_COMPLETE.id)
                    || crnProtocol.getStatus().equals(DualCrnStatusType.IDLE.id)
            ) {
                send = true;
            }
        }else {
            if (crnProtocol.getStatusTwo().equals(DualCrnStatusType.FETCH_COMPLETE.id)
                    || crnProtocol.getStatusTwo().equals(DualCrnStatusType.IDLE.id)
            ) {
                send = true;
            }
        }
        if (idx == 0) {
            if(send) {
                idx++;
                commandParam.setCommandIdx(idx);
                sendCommand(dualCommand);
                redisUtil.set(RedisKeyType.DUAL_CRN_PICK_WAIT_NEXT_TASK.key + crnProtocol.getCrnNo(), "lock", 5);
            }
            return commandParam;
        }else {
            if (dualCommand.getTaskMode() == DualCrnTaskModeType.PUT.id.shortValue()) {
                //等待下一个任务
                Object wait = redisUtil.get(RedisKeyType.DUAL_CRN_PICK_WAIT_NEXT_TASK.key + crnProtocol.getCrnNo());
                if (wait != null) {
                    return commandParam;
                }
                Integer taskNo = dualCommand.getTaskNo();
                Object outTaskStationInfoObj = redisUtil.get(RedisKeyType.DUAL_CRN_OUT_TASK_STATION_INFO.key + taskNo);
                if (outTaskStationInfoObj != null) {
                    //检测出口站是否可执行放货动作
                    StationObjModel stationObjModel = JSON.parseObject(outTaskStationInfoObj.toString(), StationObjModel.class);
                    StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
                    if (stationThread == null) {
                        return commandParam;
                    }
                    Map<Integer, StationProtocol> statusMap = stationThread.getStatusMap();
                    StationProtocol stationProtocol = statusMap.get(stationObjModel.getStationId());
                    if (stationProtocol == null) {
                        return commandParam;
                    }
                    if (!stationProtocol.isAutoing()) {
                        return commandParam;
                    }
                    if (stationProtocol.isLoading()) {
                        return commandParam;
                    }
                    if (stationProtocol.getTaskNo() > 0) {
                        return commandParam;
                    }
                }
            }
            if(send) {
                idx++;
                commandParam.setCommandIdx(idx);
                sendCommand(dualCommand);
            }
            return commandParam;
        }
    }
    /**
@@ -513,7 +491,7 @@
    }
    @Override
    public synchronized CommandResponse sendCommand(DualCrnCommand command) {
    public CommandResponse sendCommand(DualCrnCommand command) {
        this.crnProtocol.setLastCommandTime(System.currentTimeMillis());
        CommandResponse response = null;
        try {
src/main/java/com/zy/core/utils/CrnOperateProcessUtils.java
@@ -779,13 +779,13 @@
        if (lock != null) {
            return false;
        }
        redisUtil.set(RedisKeyType.CHECK_SHALLOW_LOC_STATUS_LIMIT.key + taskNo, "lock", 5);
        Integer shallowRow = Utils.getShallowRowByDeepRow(Utils.getRow(locNo));
        if (shallowRow == null) {
            return true;
        }
        redisUtil.set(RedisKeyType.CHECK_SHALLOW_LOC_STATUS_LIMIT.key + taskNo, "lock", 5);
        String shallowLocNo = Utils.getLocNo(shallowRow, Utils.getBay(locNo), Utils.getLev(locNo));
        LocMast shallowLocMast = locMastService.queryByLoc(shallowLocNo);
        if (shallowLocMast == null) {
src/main/java/com/zy/core/utils/DualCrnOperateProcessUtils.java
@@ -15,7 +15,6 @@
import com.zy.asrs.service.WrkMastService;
import com.zy.asrs.utils.NotifyUtils;
import com.zy.asrs.utils.Utils;
import com.zy.common.entity.FindCrnNoResult;
import com.zy.common.model.StartupDto;
import com.zy.common.service.CommonService;
import com.zy.common.utils.RedisUtil;
@@ -27,6 +26,7 @@
import com.zy.core.model.Task;
import com.zy.core.model.command.DualCrnCommand;
import com.zy.core.model.command.StationCommand;
import com.zy.core.model.param.SendDualCrnCommandParam;
import com.zy.core.model.protocol.DualCrnProtocol;
import com.zy.core.model.protocol.StationProtocol;
import com.zy.core.thread.DualCrnThread;
@@ -101,43 +101,175 @@
            return;
        }
        List<WrkMast> allTaskList = new ArrayList<>();
        List<WrkMast> inTaskList = getInTaskList(basDualCrnp);
        List<WrkMast> outTaskList = getOutTaskList(basDualCrnp);
        List<WrkMast> locMoveTaskList = getLocMoveTaskList(basDualCrnp);
        if (!locMoveTaskList.isEmpty()) {
            allTaskList.addAll(locMoveTaskList);
        if (!(dualCrnProtocol.getStatusType().equals(DualCrnStatusType.IDLE) && dualCrnProtocol.getStatusTypeTwo().equals(DualCrnStatusType.IDLE))) {
            return;
        }
        // 如果最近一次是出库模式
        if (dualCrnProtocol.getLastIo().equals("O")) {
            allTaskList.addAll(inTaskList);
            allTaskList.addAll(outTaskList);
            processLoveMove(basDualCrnp, dualCrnThread);
            processIn(basDualCrnp, dualCrnThread);
            processOut(basDualCrnp, dualCrnThread);
        }
        // 如果最近一次是入库模式
        else if (dualCrnProtocol.getLastIo().equals("I")) {
            allTaskList.addAll(outTaskList);
            allTaskList.addAll(inTaskList);
            processLoveMove(basDualCrnp, dualCrnThread);
            processOut(basDualCrnp, dualCrnThread);
            processIn(basDualCrnp, dualCrnThread);
        }
    }
    private void processIn(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread) {
        List<WrkMast> inTaskList = getInTaskList(basDualCrnp);
        if (inTaskList.isEmpty()) {
            return;
        }
        for (WrkMast wrkMast : allTaskList) {
            if (wrkMast.getIoType() == WrkIoType.IN.id) {
                boolean result = this.crnExecuteIn(basDualCrnp, dualCrnThread, wrkMast);
                if (result) {
                    break;
                }
            } else if (wrkMast.getIoType() == WrkIoType.OUT.id) {
                boolean result = this.crnExecuteOut(basDualCrnp, dualCrnThread, wrkMast);
                if (result) {
                    break;
                }
            } else if (wrkMast.getIoType() == WrkIoType.LOC_MOVE.id) {
                boolean result = this.crnExecuteLocMove(basDualCrnp, dualCrnThread, wrkMast);
                if (result) {
                    break;
        WrkMast stationOneWrkMast = inTaskList.get(0);
        WrkMast stationTwoWrkMast = null;
        if (inTaskList.size() >= 2) {
            stationTwoWrkMast = inTaskList.get(1);
        }
        SendDualCrnCommandParam oneResult = null;
        SendDualCrnCommandParam twoResult = null;
        if(stationOneWrkMast != null){
            oneResult = crnExecuteIn(basDualCrnp, dualCrnThread, stationOneWrkMast);
        }
        if(stationTwoWrkMast != null){
            twoResult = crnExecuteIn(basDualCrnp, dualCrnThread, stationTwoWrkMast);
        }
        List<SendDualCrnCommandParam> list = new ArrayList<>();
        if (oneResult != null) {
            list.add(oneResult);
        }
        if (twoResult != null) {
            list.add(twoResult);
        }
        if (!list.isEmpty()) {
            DualCrnProtocol dualCrnProtocol = dualCrnThread.getStatus();
            Integer crnNo = basDualCrnp.getCrnNo();
            MessageQueue.offer(SlaveType.DualCrn, crnNo, new Task(2, list));
            News.info("双工位堆垛机命令下发成功,堆垛机号={},任务数据={}", crnNo, JSON.toJSON(list));
            dualCrnProtocol.setLastIo("I");
        }
    }
    private void processOut(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread) {
        List<WrkMast> outTaskList = getOutTaskList(basDualCrnp);
        if (outTaskList.isEmpty()) {
            return;
        }
        WrkMast stationOneWrkMast = null;
        WrkMast stationTwoWrkMast = null;
        List<Integer> disableList = basDualCrnp.getDisableStationOneBays$();
        for (WrkMast wrkMast : outTaskList) {
            if (stationOneWrkMast == null) {
                if (!disableList.contains(Utils.getBay(wrkMast.getSourceLocNo()))) {
                    stationOneWrkMast = wrkMast;
                    continue;
                }
            }
            if (stationTwoWrkMast == null) {
                if (!disableList.contains(Utils.getBay(wrkMast.getSourceLocNo()))) {
                    stationTwoWrkMast = wrkMast;
                    continue;
                }
            }
        }
        SendDualCrnCommandParam oneResult = null;
        SendDualCrnCommandParam twoResult = null;
        if(stationOneWrkMast != null){
            oneResult = crnExecuteOut(basDualCrnp, dualCrnThread, stationOneWrkMast, 1);
        }
        if(stationTwoWrkMast != null){
            twoResult = crnExecuteOut(basDualCrnp, dualCrnThread, stationTwoWrkMast, 2);
        }
        List<SendDualCrnCommandParam> list = new ArrayList<>();
        if (oneResult != null) {
            list.add(oneResult);
        }
        if (twoResult != null) {
            list.add(twoResult);
        }
        if (!list.isEmpty()) {
            DualCrnProtocol dualCrnProtocol = dualCrnThread.getStatus();
            Integer crnNo = basDualCrnp.getCrnNo();
            MessageQueue.offer(SlaveType.DualCrn, crnNo, new Task(2, list));
            News.info("双工位堆垛机命令下发成功,堆垛机号={},任务数据={}", crnNo, JSON.toJSON(list));
            dualCrnProtocol.setLastIo("O");
        }
    }
    private void processLoveMove(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread) {
        List<WrkMast> locMoveTaskList = getLocMoveTaskList(basDualCrnp);
        if (locMoveTaskList.isEmpty()) {
            return;
        }
        WrkMast stationOneWrkMast = null;
        WrkMast stationTwoWrkMast = null;
        List<Integer> disableList = basDualCrnp.getDisableStationOneBays$();
        for (WrkMast wrkMast : locMoveTaskList) {
            if (stationOneWrkMast == null) {
                if (!disableList.contains(Utils.getBay(wrkMast.getSourceLocNo()))) {
                    stationOneWrkMast = wrkMast;
                    continue;
                }
            }
            if (stationTwoWrkMast == null) {
                if (!disableList.contains(Utils.getBay(wrkMast.getSourceLocNo()))) {
                    stationTwoWrkMast = wrkMast;
                    continue;
                }
            }
        }
        SendDualCrnCommandParam oneResult = null;
        SendDualCrnCommandParam twoResult = null;
        if(stationOneWrkMast != null){
            oneResult = crnExecuteLocMove(basDualCrnp, dualCrnThread, stationOneWrkMast, 1);
        }
        if(stationTwoWrkMast != null){
            twoResult = crnExecuteLocMove(basDualCrnp, dualCrnThread, stationTwoWrkMast, 2);
        }
        List<SendDualCrnCommandParam> list = new ArrayList<>();
        if (oneResult != null) {
            list.add(oneResult);
        }
        if (twoResult != null) {
            list.add(twoResult);
        }
        if (!list.isEmpty()) {
            DualCrnProtocol dualCrnProtocol = dualCrnThread.getStatus();
            Integer crnNo = basDualCrnp.getCrnNo();
            MessageQueue.offer(SlaveType.DualCrn, crnNo, new Task(2, list));
            News.info("双工位堆垛机命令下发成功,堆垛机号={},任务数据={}", crnNo, JSON.toJSON(list));
            dualCrnProtocol.setLastIo("O");
        }
    }
@@ -148,55 +280,39 @@
            return list;
        }
        List<Integer> taskList = new ArrayList<>();
        List<StationObjModel> inStationList = basDualCrnp.getInStationList$();
        if(inStationList.isEmpty()){
            News.info("双工位堆垛机:{} 入库站点未设置", basDualCrnp.getCrnNo());
            return list;
        }
        for (StationObjModel stationObjModel : inStationList) {
            StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
            if (stationThread == null) {
                continue;
            }
            Map<Integer, StationProtocol> stationProtocolMap = stationThread.getStatusMap();
            StationProtocol stationProtocol = stationProtocolMap.get(stationObjModel.getStationId());
            Map<Integer, StationProtocol> map = stationThread.getStatusMap();
            StationProtocol stationProtocol = map.get(stationObjModel.getStationId());
            if (stationProtocol == null) {
                continue;
            }
            if (!stationProtocol.isAutoing()) {
                continue;
            if (stationProtocol.isAutoing()
                    && stationProtocol.isLoading()
                    && stationProtocol.getTaskNo() > 0
            ) {
                taskList.add(stationProtocol.getTaskNo());
            }
        }
            if (!stationProtocol.isLoading()) {
                continue;
            }
            if (stationProtocol.getTaskNo() <= 0) {
                continue;
            }
            if (!stationProtocol.isInEnable()) {
                News.taskInfo(stationProtocol.getTaskNo(), "取货站点:{} 没有可入信号", stationObjModel.getStationId());
                continue;
            }
            // 获取任务
            WrkMast wrkMast = wrkMastService.selectByWorkNo(stationProtocol.getTaskNo());
            if (null == wrkMast) {
                News.taskInfo(stationProtocol.getTaskNo(), "工作号:{} 任务信息不存在", stationProtocol.getTaskNo());
                continue;
            }
        // 获取任务
        List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>()
                .eq("dual_crn_no", basDualCrnp.getCrnNo())
                .in("wrk_no", taskList)
        );
        for (WrkMast wrkMast : wrkMasts) {
            if(wrkMast.getWrkSts() != WrkStsType.INBOUND_DEVICE_RUN.sts){
                continue;
            }
            list.add(wrkMast);
        }
        return list;
    }
@@ -231,46 +347,46 @@
        return list;
    }
    private synchronized boolean crnExecuteIn(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread, WrkMast wrkMast) {
    private synchronized SendDualCrnCommandParam crnExecuteIn(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread, WrkMast wrkMast) {
        DualCrnProtocol dualCrnProtocol = dualCrnThread.getStatus();
        if (dualCrnProtocol == null) {
            return false;
            return null;
        }
        if (!basDualCrnp.getInEnable().equals("Y")) {
            News.info("双工位堆垛机:{} 可入信号不满足", basDualCrnp.getCrnNo());
            return false;
            return null;
        }
        List<StationObjModel> inStationList = basDualCrnp.getInStationList$();
        if(inStationList.isEmpty()){
            News.info("双工位堆垛机:{} 入库站点未设置", basDualCrnp.getCrnNo());
            return false;
            return null;
        }
        Integer crnNo = basDualCrnp.getCrnNo();
        if (wrkMast.getWrkSts() != WrkStsType.INBOUND_DEVICE_RUN.sts) {
            return false;
            return null;
        }
        // 获取库位信息
        LocMast locMast = locMastService.selectById(wrkMast.getLocNo());
        if (locMast == null) {
            News.taskInfo(wrkMast.getWrkNo(), "目标库位:{} 信息不存在", wrkMast.getLocNo());
            return false;
            return null;
        }
        if (!locMast.getLocSts().equals("S")) {
            News.taskInfo(wrkMast.getWrkNo(), "目标库位:{} 状态异常", wrkMast.getLocNo());
            return false;
            return null;
        }
        //检测浅库位状态
        boolean checkStatus = checkShallowLocStatus(locMast.getLocNo(), wrkMast.getWrkNo());
        if (!checkStatus) {
            News.taskInfo(wrkMast.getWrkNo(), "因浅库位堵塞无法执行");
            return false;
            return null;
        }
        StationObjModel inStationObjModel = null;
@@ -307,38 +423,11 @@
                inStationObjModel = stationObjModel;
                break;
            }
            StationObjModel dualCrnSlaveStationObjModel = stationObjModel.getDualCrnSlaveStation();
            if (dualCrnSlaveStationObjModel == null) {
                continue;
            }
            StationProtocol slaveStationProtocol = stationProtocolMap.get(dualCrnSlaveStationObjModel.getStationId());
            if (slaveStationProtocol == null) {
                continue;
            }
            if (!slaveStationProtocol.isAutoing()) {
                continue;
            }
            if (!slaveStationProtocol.isLoading()) {
                continue;
            }
            if (slaveStationProtocol.getTaskNo() <= 0) {
                continue;
            }
            if (slaveStationProtocol.getTaskNo().equals(wrkMast.getWrkNo())) {
                inStationObjModel = dualCrnSlaveStationObjModel;
                break;
            }
        }
        if (inStationObjModel == null) {
            News.taskInfo(wrkMast.getWrkNo(), "未搜索到取货站点");
            return false;
            return null;
        }
        Integer station = inStationObjModel.getDualCrnExecuteStation();
@@ -347,14 +436,14 @@
            if (basList.contains(Utils.getBay(wrkMast.getLocNo()))) {
                //禁止放货列,申请重新分配
                reassignTaskLocNo(wrkMast, inStationObjModel);
                return false;
                return null;
            }
        }else {
            List<Integer> basList = basDualCrnp.getDisableStationTwoBays$();
            if (basList.contains(Utils.getBay(wrkMast.getLocNo()))) {
                //禁止放货列,申请重新分配
                reassignTaskLocNo(wrkMast, inStationObjModel);
                return false;
                return null;
            }
        }
@@ -371,60 +460,44 @@
        wrkMast.setSystemMsg("");
        wrkMast.setIoTime(new Date());
        if (wrkMastService.updateById(wrkMast)) {
            MessageQueue.offer(SlaveType.DualCrn, crnNo, new Task(2, commandList));
            SendDualCrnCommandParam sendDualCrnCommandParam = new SendDualCrnCommandParam();
            sendDualCrnCommandParam.setCrnNo(crnNo);
            sendDualCrnCommandParam.setStation(station);
            sendDualCrnCommandParam.setCommands(commandList);
            sendDualCrnCommandParam.setCommandIdx(0);
            notifyUtils.notify(String.valueOf(SlaveType.DualCrn), crnNo, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.DUAL_CRN_IN_TASK_RUN, null);
            News.info("双工位堆垛机命令下发成功,堆垛机号={},任务数据={}", crnNo, JSON.toJSON(commandList));
            dualCrnProtocol.setLastIo("I");
            return true;
            return sendDualCrnCommandParam;
        }
        return false;
        return null;
    }
    private synchronized boolean crnExecuteOut(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread, WrkMast wrkMast) {
    private synchronized SendDualCrnCommandParam crnExecuteOut(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread, WrkMast wrkMast, int station) {
        DualCrnProtocol dualCrnProtocol = dualCrnThread.getStatus();
        if (dualCrnProtocol == null) {
            return false;
            return null;
        }
        if (!basDualCrnp.getOutEnable().equals("Y")) {
            News.info("双工位堆垛机:{} 可出信号不满足", basDualCrnp.getCrnNo());
            return false;
            return null;
        }
        List<StationObjModel> outStationList = basDualCrnp.getOutStationList$();
        if (outStationList.isEmpty()) {
            News.info("双工位堆垛机:{} 出库站点未设置", basDualCrnp.getCrnNo());
            return false;
            return null;
        }
        Integer crnNo = basDualCrnp.getCrnNo();
        int station = calcStation(dualCrnProtocol, "out");
        if (station == 0) {
            News.info("双工位堆垛机:{} 无可用工位", basDualCrnp.getCrnNo());
            return false;
        }
        List<StationObjModel> enableUseStationList = new ArrayList<>();
        for (StationObjModel stationObjModel : outStationList) {
            if (!stationObjModel.getStationId().equals(wrkMast.getSourceStaNo())) {
            StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
            if (stationThread == null) {
                continue;
            }
            if(stationObjModel.getDualCrnExecuteStation().equals(station)) {
                enableUseStationList.add(stationObjModel);
            }
            StationObjModel dualCrnSlaveStation = stationObjModel.getDualCrnSlaveStation();
            if(dualCrnSlaveStation != null) {
                if (dualCrnSlaveStation.getDualCrnExecuteStation().equals(station)) {
                    enableUseStationList.add(stationObjModel);
                }
            }
        }
        for (StationObjModel stationObjModel : enableUseStationList) {
            StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
            if (stationThread == null) {
            if (stationObjModel.getDualCrnExecuteStation() != station) {
                continue;
            }
@@ -483,65 +556,58 @@
            wrkMast.setSystemMsg("");
            wrkMast.setIoTime(new Date());
            if (wrkMastService.updateById(wrkMast)) {
                MessageQueue.offer(SlaveType.DualCrn, crnNo, new Task(2, commandList));
                notifyUtils.notify(String.valueOf(SlaveType.DualCrn), crnNo, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.DUAL_CRN_OUT_TASK_RUN, null);
                News.info("双工位堆垛机命令下发成功,堆垛机号={},任务数据={}", crnNo, JSON.toJSON(commandList));
                dualCrnProtocol.setLastIo("O");
                redisUtil.set(RedisKeyType.DUAL_CRN_OUT_TASK_STATION_INFO.key + wrkMast.getWrkNo(), JSON.toJSONString(stationObjModel, SerializerFeature.DisableCircularReferenceDetect), 60 * 60 * 24);
                return true;
                SendDualCrnCommandParam sendDualCrnCommandParam = new SendDualCrnCommandParam();
                sendDualCrnCommandParam.setCrnNo(crnNo);
                sendDualCrnCommandParam.setStation(station);
                sendDualCrnCommandParam.setCommands(commandList);
                sendDualCrnCommandParam.setCommandIdx(0);
                notifyUtils.notify(String.valueOf(SlaveType.DualCrn), crnNo, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.DUAL_CRN_OUT_TASK_RUN, null);
                return sendDualCrnCommandParam;
            }
        }
        return false;
        return null;
    }
    private synchronized boolean crnExecuteLocMove(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread, WrkMast wrkMast) {
    private synchronized SendDualCrnCommandParam crnExecuteLocMove(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread, WrkMast wrkMast, int station) {
        DualCrnProtocol dualCrnProtocol = dualCrnThread.getStatus();
        if (dualCrnProtocol == null) {
            return false;
            return null;
        }
        Integer crnNo = basDualCrnp.getCrnNo();
        int station = calcStation(dualCrnProtocol, "locMove");
        if (station == 0) {
            News.info("双工位堆垛机:{} 无可用工位", basDualCrnp.getCrnNo());
            return false;
        }
        List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>()
                .eq("crn_no", crnNo)
                .eq("wrk_sts", WrkStsType.NEW_LOC_MOVE.sts)
        );
        // 获取源库位信息
        LocMast sourceLocMast = locMastService.selectById(wrkMast.getSourceLocNo());
        if (sourceLocMast == null) {
            News.taskInfo(wrkMast.getWrkNo(), "源库位:{} 信息不存在", wrkMast.getSourceLocNo());
            return false;
            return null;
        }
        if(!sourceLocMast.getLocSts().equals("R")){
        if (!sourceLocMast.getLocSts().equals("R")) {
            News.taskInfo(wrkMast.getWrkNo(), "源库位:{} 状态异常,不属于出库预约状态", wrkMast.getSourceLocNo());
            return false;
            return null;
        }
        // 获取库位信息
        LocMast locMast = locMastService.selectById(wrkMast.getLocNo());
        if (locMast == null) {
            News.taskInfo(wrkMast.getWrkNo(), "库位:{} 信息不存在", wrkMast.getLocNo());
            return false;
            return null;
        }
        if (!locMast.getLocSts().equals("S")) {
            News.taskInfo(wrkMast.getWrkNo(), "库位:{} 状态异常,不属于入库预约状态", wrkMast.getLocNo());
            return false;
            return null;
        }
        //检测浅库位状态
        boolean checkStatus = checkShallowLocStatus(locMast.getLocNo(), wrkMast.getWrkNo());
        if (!checkStatus) {
            News.taskInfo(wrkMast.getWrkNo(), "因浅库位堵塞无法执行");
            return false;
            return null;
        }
        List<DualCrnCommand> commandList = new ArrayList<>();
@@ -555,13 +621,16 @@
        wrkMast.setSystemMsg("");
        wrkMast.setIoTime(new Date());
        if (wrkMastService.updateById(wrkMast)) {
            MessageQueue.offer(SlaveType.DualCrn, crnNo, new Task(2, commandList));
            SendDualCrnCommandParam sendDualCrnCommandParam = new SendDualCrnCommandParam();
            sendDualCrnCommandParam.setCrnNo(crnNo);
            sendDualCrnCommandParam.setStation(station);
            sendDualCrnCommandParam.setCommands(commandList);
            sendDualCrnCommandParam.setCommandIdx(0);
            notifyUtils.notify(String.valueOf(SlaveType.DualCrn), crnNo, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.DUAL_CRN_TRANSFER_TASK_RUN, null);
            News.info("双工位堆垛机命令下发成功,堆垛机号={},任务数据={}", crnNo, JSON.toJSON(commandList));
            dualCrnProtocol.setLastIo("I");
            return true;
            return sendDualCrnCommandParam;
        }
        return false;
        return null;
    }
    //双工位堆垛机任务执行完成
@@ -609,15 +678,27 @@
            return;
        }
        Object commandObj = redisUtil.get(RedisKeyType.DUAL_CRN_COMMAND_.key + wrkMast.getWrkNo());
        if (commandObj == null) {
        Object commandListObj = redisUtil.get(RedisKeyType.DUAL_CRN_COMMAND_.key + basDualCrnp.getCrnNo());
        if (commandListObj == null) {
            News.error("双工位堆垛机处于等待确认且任务完成状态,但未找到命令。堆垛机号={},工作号={}", basDualCrnp.getCrnNo(), taskNo);
            return;
        }
        List<SendDualCrnCommandParam> dualCrnCommandParamList = JSON.parseArray(commandListObj.toString(), SendDualCrnCommandParam.class);
        SendDualCrnCommandParam taskCommand = null;
        for (SendDualCrnCommandParam sendDualCrnCommandParam : dualCrnCommandParamList) {
            DualCrnCommand dualCrnCommand = sendDualCrnCommandParam.getCommands().get(0);
            if(dualCrnCommand.getTaskNo() == taskNo){
                taskCommand = sendDualCrnCommandParam;
                break;
            }
        }
        if (taskCommand == null) {
            News.error("双工位堆垛机处于等待确认且任务完成状态,但未找到命令。堆垛机号={},工作号={}", basDualCrnp.getCrnNo(), taskNo);
            return;
        }
        JSONObject commandMap = JSON.parseObject(commandObj.toString());
        Integer idx = commandMap.getInteger("idx");
        List<DualCrnCommand> commandList = commandMap.getJSONArray("commands").toJavaList(DualCrnCommand.class);
        Integer idx = taskCommand.getCommandIdx();
        List<DualCrnCommand> commandList = taskCommand.getCommands();
        if (idx >= commandList.size()) {
            Long updateWrkSts = null;
            if (wrkMast.getWrkSts() == WrkStsType.INBOUND_RUN.sts) {
@@ -631,25 +712,6 @@
                if(outStationList.isEmpty()){
                    News.info("双工位堆垛机:{} 出库站点未设置", basDualCrnp.getCrnNo());
                    return;
                }
                StationObjModel outStationObjModel = null;
                for (StationObjModel stationObjModel : outStationList) {
                    if (stationObjModel.getStationId().equals(wrkMast.getSourceStaNo())) {
                        outStationObjModel = stationObjModel;
                        break;
                    }
                }
                if (outStationObjModel == null) {
                    News.info("双工位堆垛机:{} 未找到匹配的任务出库站", basDualCrnp.getCrnNo());
                    return;
                }
                if (station == 1) {
                    redisUtil.set(RedisKeyType.DUAL_CRN_OUT_TASK_COMPLETE_STATION_INFO.key + wrkMast.getWrkNo(), JSON.toJSONString(outStationObjModel, SerializerFeature.DisableCircularReferenceDetect), 60 * 60 * 24);
                }else {
                    redisUtil.set(RedisKeyType.DUAL_CRN_OUT_TASK_COMPLETE_STATION_INFO.key + wrkMast.getWrkNo(), JSON.toJSONString(outStationObjModel.getDualCrnSlaveStation(), SerializerFeature.DisableCircularReferenceDetect), 60 * 60 * 24);
                }
                if(mainProcessPlugin.contains("Fake")) {
@@ -689,12 +751,6 @@
                redisUtil.set(RedisKeyType.DUAL_CRN_IO_EXECUTE_FINISH_LIMIT.key + basDualCrnp.getCrnNo() + "_" + taskNo, "lock", 10);
            }
        }else {
            DualCrnCommand command = commandList.get(idx - 1);
            if (command.getTaskMode() == DualCrnTaskModeType.PICK.id.shortValue()) {
                //取货后等待下一个任务时长
                redisUtil.set(RedisKeyType.DUAL_CRN_PICK_WAIT_NEXT_TASK.key + basDualCrnp.getCrnNo(), "wait", 10);
            }
            DualCrnCommand resetCommand = dualCrnThread.getResetCommand(dualCrnProtocol.getCrnNo(), station);
            MessageQueue.offer(SlaveType.DualCrn, dualCrnProtocol.getCrnNo(), new Task(3, resetCommand));
            News.info("双工位堆垛机命令完成确认成功,堆垛机号={},工作号={}", basDualCrnp.getCrnNo(), taskNo);
@@ -718,13 +774,13 @@
        if (lock != null) {
            return false;
        }
        redisUtil.set(RedisKeyType.CHECK_SHALLOW_LOC_STATUS_LIMIT.key + taskNo, "lock", 5);
        Integer shallowRow = Utils.getShallowRowByDeepRow(Utils.getRow(locNo));
        if (shallowRow == null) {
            return true;
        }
        redisUtil.set(RedisKeyType.CHECK_SHALLOW_LOC_STATUS_LIMIT.key + taskNo, "lock", 5);
        String shallowLocNo = Utils.getLocNo(shallowRow, Utils.getBay(locNo), Utils.getLev(locNo));
        LocMast shallowLocMast = locMastService.queryByLoc(shallowLocNo);
        if (shallowLocMast == null) {
@@ -762,76 +818,6 @@
            }
        }
        return false;
    }
    private int calcStation(DualCrnProtocol dualCrnProtocol, String type) {
        List<Integer> idleStationList = new ArrayList<>();
        if (dualCrnProtocol.getTaskNo() == 0
                && dualCrnProtocol.getLoaded() == 0
                && dualCrnProtocol.getStatusType().equals(DualCrnStatusType.IDLE)
                && dualCrnProtocol.getTaskReceive() == 0
        ) {
            idleStationList.add(1);
        }
        if (dualCrnProtocol.getTaskNoTwo() == 0
                && dualCrnProtocol.getLoadedTwo() == 0
                && dualCrnProtocol.getStatusTypeTwo().equals(DualCrnStatusType.IDLE)
                && dualCrnProtocol.getTaskReceiveTwo() == 0
        ) {
            idleStationList.add(2);
        }
        if (type.equals("locMove")) {
            if (idleStationList.size() != 2) {
                return 0;
            }
            return idleStationList.get(0);
        }
        if (idleStationList.size() == 2) {
            return idleStationList.get(0);
        }
        Integer idleStation = idleStationList.get(0);
        int workingStation = idleStation == 1 ? 2 : 1;
        int executeTaskNo = 0;
        if (workingStation == 1) {
            executeTaskNo = dualCrnProtocol.getTaskNo();
            //检测工位已进入放货阶段,放货阶段不接新任务
            if (dualCrnProtocol.getStatusType().equals(DualCrnStatusType.PUT_MOVING)
                    || dualCrnProtocol.getStatusType().equals(DualCrnStatusType.PUTTING)
                    || dualCrnProtocol.getStatusType().equals(DualCrnStatusType.WAITING)
            ) {
                return 0;
            }
        } else {
            executeTaskNo = dualCrnProtocol.getTaskNoTwo();
            //检测工位已进入放货阶段,放货阶段不接新任务
            if (dualCrnProtocol.getStatusTypeTwo().equals(DualCrnStatusType.PUT_MOVING)
                    || dualCrnProtocol.getStatusTypeTwo().equals(DualCrnStatusType.PUTTING)
                    || dualCrnProtocol.getStatusTypeTwo().equals(DualCrnStatusType.WAITING)
            ) {
                return 0;
            }
        }
        if (executeTaskNo == 0) {
            return 0;
        }
        WrkMast wrkMast = wrkMastService.selectByWorkNo(executeTaskNo);
        if (wrkMast.getIoType().equals(WrkIoType.IN.id) && type.equals("in")) {
            return idleStation;
        }
        if (wrkMast.getIoType().equals(WrkIoType.OUT.id) && type.equals("out")) {
            return idleStation;
        }
        return 0;
    }
    private boolean reassignTaskLocNo(WrkMast wrkMast, StationObjModel stationObjModel) {
src/main/java/com/zy/core/utils/StationOperateProcessUtils.java
@@ -46,203 +46,7 @@
    //执行输送站点入库任务
    public synchronized void stationInExecute() {
        List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<>());
        for (BasDevp basDevp : basDevps) {
            StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo());
            if(stationThread == null){
                continue;
            }
            Map<Integer, StationProtocol> stationMap = stationThread.getStatusMap();
            List<StationObjModel> list = basDevp.getBarcodeStationList$();
            for (StationObjModel entity : list) {
                Integer stationId = entity.getStationId();
                if(!stationMap.containsKey(stationId)){
                    continue;
                }
                StationProtocol stationProtocol = stationMap.get(stationId);
                if (stationProtocol == null) {
                    continue;
                }
                Object lock = redisUtil.get(RedisKeyType.STATION_IN_EXECUTE_LIMIT.key + stationId);
                if(lock != null){
                    continue;
                }
                //满足自动、有物、有工作号
                if (stationProtocol.isAutoing()
                        && stationProtocol.isLoading()
                        && stationProtocol.getTaskNo() > 0
                ) {
                    //检测任务是否生成
                    WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("barcode", stationProtocol.getBarcode()));
                    if (wrkMast == null) {
                        continue;
                    }
                    if (wrkMast.getWrkSts() == WrkStsType.INBOUND_DEVICE_RUN.sts) {
                        continue;
                    }
                    String locNo = wrkMast.getLocNo();
                    FindCrnNoResult findCrnNoResult = commonService.findCrnNoByLocNo(locNo);
                    if (findCrnNoResult == null) {
                        News.taskInfo(wrkMast.getWrkNo(), "{}工作,未匹配到堆垛机", wrkMast.getWrkNo());
                        continue;
                    }
                    Integer targetStationId = commonService.findInStationId(findCrnNoResult, stationId);
                    if (targetStationId == null) {
                        News.taskInfo(wrkMast.getWrkNo(), "{}站点,搜索入库站点失败", stationId);
                        continue;
                    }
                    StationCommand command = stationThread.getCommand(StationCommandType.MOVE, wrkMast.getWrkNo(), stationId, targetStationId, 0);
                    if(command == null){
                        News.taskInfo(wrkMast.getWrkNo(), "{}工作,获取输送线命令失败", wrkMast.getWrkNo());
                        continue;
                    }
                    wrkMast.setWrkSts(WrkStsType.INBOUND_DEVICE_RUN.sts);
                    wrkMast.setSourceStaNo(stationProtocol.getStationId());
                    wrkMast.setStaNo(targetStationId);
                    wrkMast.setSystemMsg("");
                    wrkMast.setIoTime(new Date());
                    if (wrkMastService.updateById(wrkMast)) {
                        MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command));
                        News.info("输送站点入库命令下发成功,站点号={},工作号={},命令数据={}", stationId, wrkMast.getWrkNo(), JSON.toJSONString(command));
                        redisUtil.set(RedisKeyType.STATION_IN_EXECUTE_LIMIT.key + stationId, "lock", 5);
                    }
                }
            }
        }
    }
    //执行堆垛机输送站点出库任务
    public synchronized void crnStationOutExecute() {
        List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>()
                .eq("wrk_sts", WrkStsType.OUTBOUND_RUN_COMPLETE.sts)
                .isNotNull("crn_no")
        );
        for (WrkMast wrkMast : wrkMasts) {
            Object infoObj = redisUtil.get(RedisKeyType.CRN_OUT_TASK_COMPLETE_STATION_INFO.key + wrkMast.getWrkNo());
            if (infoObj == null) {
                News.info("出库任务{}数据缓存不存在", wrkMast.getWrkNo());
                continue;
            }
            StationObjModel stationObjModel = JSON.parseObject(infoObj.toString(), StationObjModel.class);
            StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
            if(stationThread == null){
                continue;
            }
            Map<Integer, StationProtocol> stationMap = stationThread.getStatusMap();
            StationProtocol stationProtocol = stationMap.get(stationObjModel.getStationId());
            if (stationProtocol == null) {
                continue;
            }
            Object lock = redisUtil.get(RedisKeyType.STATION_OUT_EXECUTE_LIMIT.key + stationProtocol.getStationId());
            if (lock != null) {
                continue;
            }
            //满足自动、有物、工作号0
            if (stationProtocol.isAutoing()
                    && stationProtocol.isLoading()
                    && stationProtocol.getTaskNo() == 0
            ) {
                StationCommand command = stationThread.getCommand(StationCommandType.MOVE, wrkMast.getWrkNo(), stationProtocol.getStationId(), wrkMast.getStaNo(), 0);
                if(command == null){
                    News.taskInfo(wrkMast.getWrkNo(), "获取输送线命令失败");
                    continue;
                }
                wrkMast.setWrkSts(WrkStsType.STATION_RUN.sts);
                wrkMast.setSystemMsg("");
                wrkMast.setIoTime(new Date());
                if (wrkMastService.updateById(wrkMast)) {
                    MessageQueue.offer(SlaveType.Devp, stationObjModel.getDeviceNo(), new Task(2, command));
                    News.info("输送站点出库命令下发成功,站点号={},工作号={},命令数据={}", stationProtocol.getStationId(), wrkMast.getWrkNo(), JSON.toJSONString(command));
                    redisUtil.set(RedisKeyType.STATION_OUT_EXECUTE_LIMIT.key + stationProtocol.getStationId(), "lock", 5);
                    redisUtil.set(RedisKeyType.STATION_OUT_EXECUTE_COMPLETE_LIMIT.key + wrkMast.getWrkNo(), "lock", 60 * 5);
                    redisUtil.del(RedisKeyType.CRN_OUT_TASK_COMPLETE_STATION_INFO.key + wrkMast.getWrkNo());
                }
            }
        }
    }
    //执行双工位堆垛机输送站点出库任务
    public synchronized void dualCrnStationOutExecute() {
        List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>()
                .eq("wrk_sts", WrkStsType.OUTBOUND_RUN_COMPLETE.sts)
                .isNotNull("dual_crn_no")
        );
        for (WrkMast wrkMast : wrkMasts) {
            Object infoObj = redisUtil.get(RedisKeyType.DUAL_CRN_OUT_TASK_COMPLETE_STATION_INFO.key + wrkMast.getWrkNo());
            if (infoObj == null) {
                News.info("出库任务{}数据缓存不存在", wrkMast.getWrkNo());
                continue;
            }
            StationObjModel stationObjModel = JSON.parseObject(infoObj.toString(), StationObjModel.class);
            StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
            if(stationThread == null){
                continue;
            }
            Map<Integer, StationProtocol> stationMap = stationThread.getStatusMap();
            StationProtocol stationProtocol = stationMap.get(stationObjModel.getStationId());
            if (stationProtocol == null) {
                continue;
            }
            Object lock = redisUtil.get(RedisKeyType.STATION_OUT_EXECUTE_LIMIT.key + stationProtocol.getStationId());
            if (lock != null) {
                continue;
            }
            //满足自动、有物、工作号0
            if (stationProtocol.isAutoing()
                    && stationProtocol.isLoading()
                    && stationProtocol.getTaskNo() == 0
            ) {
                StationCommand command = stationThread.getCommand(StationCommandType.MOVE, wrkMast.getWrkNo(), stationProtocol.getStationId(), wrkMast.getStaNo(), 0);
                if(command == null){
                    News.taskInfo(wrkMast.getWrkNo(), "获取输送线命令失败");
                    continue;
                }
                wrkMast.setWrkSts(WrkStsType.STATION_RUN.sts);
                wrkMast.setSystemMsg("");
                wrkMast.setIoTime(new Date());
                if (wrkMastService.updateById(wrkMast)) {
                    MessageQueue.offer(SlaveType.Devp, stationObjModel.getDeviceNo(), new Task(2, command));
                    News.info("输送站点出库命令下发成功,站点号={},工作号={},命令数据={}", stationProtocol.getStationId(), wrkMast.getWrkNo(), JSON.toJSONString(command));
                    redisUtil.set(RedisKeyType.STATION_OUT_EXECUTE_LIMIT.key + stationProtocol.getStationId(), "lock", 5);
                    redisUtil.set(RedisKeyType.STATION_OUT_EXECUTE_COMPLETE_LIMIT.key + wrkMast.getWrkNo(), "lock", 60 * 5);
                    redisUtil.del(RedisKeyType.DUAL_CRN_OUT_TASK_COMPLETE_STATION_INFO.key + wrkMast.getWrkNo());
                }
            }
        }
    }
    //检测输送站点出库任务执行完成
    public synchronized void stationOutExecuteFinish() {
        List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", WrkStsType.STATION_RUN.sts));
        for (WrkMast wrkMast : wrkMasts) {
            Integer wrkNo = wrkMast.getWrkNo();
            Object lock = redisUtil.get(RedisKeyType.STATION_OUT_EXECUTE_COMPLETE_LIMIT.key + wrkNo);
            if (lock != null) {
                continue;
            }
            boolean complete = true;
        try {
            List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<>());
            for (BasDevp basDevp : basDevps) {
                StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo());
@@ -250,152 +54,368 @@
                    continue;
                }
                List<StationProtocol> list = stationThread.getStatus();
                for (StationProtocol stationProtocol : list) {
                    if (stationProtocol.getTaskNo().equals(wrkNo)) {
                        complete = false;
                Map<Integer, StationProtocol> stationMap = stationThread.getStatusMap();
                List<StationObjModel> list = basDevp.getBarcodeStationList$();
                for (StationObjModel entity : list) {
                    Integer stationId = entity.getStationId();
                    if (!stationMap.containsKey(stationId)) {
                        continue;
                    }
                    StationProtocol stationProtocol = stationMap.get(stationId);
                    if (stationProtocol == null) {
                        continue;
                    }
                    Object lock = redisUtil.get(RedisKeyType.STATION_IN_EXECUTE_LIMIT.key + stationId);
                    if (lock != null) {
                        continue;
                    }
                    //满足自动、有物、有工作号
                    if (stationProtocol.isAutoing()
                            && stationProtocol.isLoading()
                            && stationProtocol.getTaskNo() > 0
                    ) {
                        //检测任务是否生成
                        WrkMast wrkMast = wrkMastService.selectOne(new EntityWrapper<WrkMast>().eq("barcode", stationProtocol.getBarcode()));
                        if (wrkMast == null) {
                            continue;
                        }
                        if (wrkMast.getWrkSts() == WrkStsType.INBOUND_DEVICE_RUN.sts) {
                            continue;
                        }
                        String locNo = wrkMast.getLocNo();
                        FindCrnNoResult findCrnNoResult = commonService.findCrnNoByLocNo(locNo);
                        if (findCrnNoResult == null) {
                            News.taskInfo(wrkMast.getWrkNo(), "{}工作,未匹配到堆垛机", wrkMast.getWrkNo());
                            continue;
                        }
                        Integer targetStationId = commonService.findInStationId(findCrnNoResult, stationId);
                        if (targetStationId == null) {
                            News.taskInfo(wrkMast.getWrkNo(), "{}站点,搜索入库站点失败", stationId);
                            continue;
                        }
                        StationCommand command = stationThread.getCommand(StationCommandType.MOVE, wrkMast.getWrkNo(), stationId, targetStationId, 0);
                        if (command == null) {
                            News.taskInfo(wrkMast.getWrkNo(), "{}工作,获取输送线命令失败", wrkMast.getWrkNo());
                            continue;
                        }
                        wrkMast.setWrkSts(WrkStsType.INBOUND_DEVICE_RUN.sts);
                        wrkMast.setSourceStaNo(stationProtocol.getStationId());
                        wrkMast.setStaNo(targetStationId);
                        wrkMast.setSystemMsg("");
                        wrkMast.setIoTime(new Date());
                        if (wrkMastService.updateById(wrkMast)) {
                            MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command));
                            News.info("输送站点入库命令下发成功,站点号={},工作号={},命令数据={}", stationId, wrkMast.getWrkNo(), JSON.toJSONString(command));
                            redisUtil.set(RedisKeyType.STATION_IN_EXECUTE_LIMIT.key + stationId, "lock", 5);
                        }
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
            if (complete) {
                wrkMast.setWrkSts(WrkStsType.COMPLETE_OUTBOUND.sts);
                wrkMast.setIoTime(new Date());
                wrkMastService.updateById(wrkMast);
    //执行堆垛机输送站点出库任务
    public synchronized void crnStationOutExecute() {
        try {
            List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>()
                    .eq("wrk_sts", WrkStsType.OUTBOUND_RUN_COMPLETE.sts)
                    .isNotNull("crn_no")
            );
            for (WrkMast wrkMast : wrkMasts) {
                Object infoObj = redisUtil.get(RedisKeyType.CRN_OUT_TASK_COMPLETE_STATION_INFO.key + wrkMast.getWrkNo());
                if (infoObj == null) {
                    News.info("出库任务{}数据缓存不存在", wrkMast.getWrkNo());
                    continue;
                }
                StationObjModel stationObjModel = JSON.parseObject(infoObj.toString(), StationObjModel.class);
                StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
                if (stationThread == null) {
                    continue;
                }
                Map<Integer, StationProtocol> stationMap = stationThread.getStatusMap();
                StationProtocol stationProtocol = stationMap.get(stationObjModel.getStationId());
                if (stationProtocol == null) {
                    continue;
                }
                Object lock = redisUtil.get(RedisKeyType.STATION_OUT_EXECUTE_LIMIT.key + stationProtocol.getStationId());
                if (lock != null) {
                    continue;
                }
                //满足自动、有物、工作号0
                if (stationProtocol.isAutoing()
                        && stationProtocol.isLoading()
                        && stationProtocol.getTaskNo() == 0
                ) {
                    StationCommand command = stationThread.getCommand(StationCommandType.MOVE, wrkMast.getWrkNo(), stationProtocol.getStationId(), wrkMast.getStaNo(), 0);
                    if (command == null) {
                        News.taskInfo(wrkMast.getWrkNo(), "获取输送线命令失败");
                        continue;
                    }
                    wrkMast.setWrkSts(WrkStsType.STATION_RUN.sts);
                    wrkMast.setSystemMsg("");
                    wrkMast.setIoTime(new Date());
                    if (wrkMastService.updateById(wrkMast)) {
                        MessageQueue.offer(SlaveType.Devp, stationObjModel.getDeviceNo(), new Task(2, command));
                        News.info("输送站点出库命令下发成功,站点号={},工作号={},命令数据={}", stationProtocol.getStationId(), wrkMast.getWrkNo(), JSON.toJSONString(command));
                        redisUtil.set(RedisKeyType.STATION_OUT_EXECUTE_LIMIT.key + stationProtocol.getStationId(), "lock", 5);
                        redisUtil.set(RedisKeyType.STATION_OUT_EXECUTE_COMPLETE_LIMIT.key + wrkMast.getWrkNo(), "lock", 60);
                        redisUtil.del(RedisKeyType.CRN_OUT_TASK_COMPLETE_STATION_INFO.key + wrkMast.getWrkNo());
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    //执行双工位堆垛机输送站点出库任务
    public synchronized void dualCrnStationOutExecute() {
        try {
            List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>()
                    .eq("wrk_sts", WrkStsType.OUTBOUND_RUN_COMPLETE.sts)
                    .isNotNull("dual_crn_no")
            );
            for (WrkMast wrkMast : wrkMasts) {
                Object infoObj = redisUtil.get(RedisKeyType.DUAL_CRN_OUT_TASK_STATION_INFO.key + wrkMast.getWrkNo());
                if (infoObj == null) {
                    News.info("出库任务{}数据缓存不存在", wrkMast.getWrkNo());
                    continue;
                }
                StationObjModel stationObjModel = JSON.parseObject(infoObj.toString(), StationObjModel.class);
                StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
                if (stationThread == null) {
                    continue;
                }
                Map<Integer, StationProtocol> stationMap = stationThread.getStatusMap();
                StationProtocol stationProtocol = stationMap.get(stationObjModel.getStationId());
                if (stationProtocol == null) {
                    continue;
                }
                Object lock = redisUtil.get(RedisKeyType.STATION_OUT_EXECUTE_LIMIT.key + stationProtocol.getStationId());
                if (lock != null) {
                    continue;
                }
                //满足自动、有物、工作号0
                if (stationProtocol.isAutoing()
                        && stationProtocol.isLoading()
                        && stationProtocol.getTaskNo() == 0
                ) {
                    StationCommand command = stationThread.getCommand(StationCommandType.MOVE, wrkMast.getWrkNo(), stationProtocol.getStationId(), wrkMast.getStaNo(), 0);
                    if (command == null) {
                        News.taskInfo(wrkMast.getWrkNo(), "获取输送线命令失败");
                        continue;
                    }
                    wrkMast.setWrkSts(WrkStsType.STATION_RUN.sts);
                    wrkMast.setSystemMsg("");
                    wrkMast.setIoTime(new Date());
                    if (wrkMastService.updateById(wrkMast)) {
                        MessageQueue.offer(SlaveType.Devp, stationObjModel.getDeviceNo(), new Task(2, command));
                        News.info("输送站点出库命令下发成功,站点号={},工作号={},命令数据={}", stationProtocol.getStationId(), wrkMast.getWrkNo(), JSON.toJSONString(command));
                        redisUtil.set(RedisKeyType.STATION_OUT_EXECUTE_LIMIT.key + stationProtocol.getStationId(), "lock", 5);
                        redisUtil.set(RedisKeyType.STATION_OUT_EXECUTE_COMPLETE_LIMIT.key + wrkMast.getWrkNo(), "lock", 60);
                        redisUtil.del(RedisKeyType.DUAL_CRN_OUT_TASK_STATION_INFO.key + wrkMast.getWrkNo());
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    //检测输送站点出库任务执行完成
    public synchronized void stationOutExecuteFinish() {
        try {
            List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>().eq("wrk_sts", WrkStsType.STATION_RUN.sts));
            for (WrkMast wrkMast : wrkMasts) {
                Integer wrkNo = wrkMast.getWrkNo();
                Object lock = redisUtil.get(RedisKeyType.STATION_OUT_EXECUTE_COMPLETE_LIMIT.key + wrkNo);
                if (lock != null) {
                    continue;
                }
                boolean complete = true;
                List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<>());
                for (BasDevp basDevp : basDevps) {
                    StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo());
                    if (stationThread == null) {
                        continue;
                    }
                    List<StationProtocol> list = stationThread.getStatus();
                    for (StationProtocol stationProtocol : list) {
                        if (stationProtocol.getTaskNo().equals(wrkNo)) {
                            complete = false;
                        }
                    }
                }
                if (complete) {
                    wrkMast.setWrkSts(WrkStsType.COMPLETE_OUTBOUND.sts);
                    wrkMast.setIoTime(new Date());
                    wrkMastService.updateById(wrkMast);
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    //检测输送站点是否运行堵塞
    public synchronized void checkStationRunBlock() {
        List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<>());
        for (BasDevp basDevp : basDevps) {
            StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo());
            if(stationThread == null){
                continue;
            }
        try {
            List<BasDevp> basDevps = basDevpService.selectList(new EntityWrapper<>());
            for (BasDevp basDevp : basDevps) {
                StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, basDevp.getDevpNo());
                if (stationThread == null) {
                    continue;
                }
            List<Integer> runBlockReassignLocStationList = new ArrayList<>();
            for (StationObjModel stationObjModel : basDevp.getRunBlockReassignLocStationList$()) {
                runBlockReassignLocStationList.add(stationObjModel.getStationId());
            }
                List<Integer> runBlockReassignLocStationList = new ArrayList<>();
                for (StationObjModel stationObjModel : basDevp.getRunBlockReassignLocStationList$()) {
                    runBlockReassignLocStationList.add(stationObjModel.getStationId());
                }
            List<StationProtocol> list = stationThread.getStatus();
            for (StationProtocol stationProtocol : list) {
                if(stationProtocol.isAutoing()
                    && stationProtocol.isLoading()
                    && stationProtocol.getTaskNo() > 0
                    && stationProtocol.isRunBlock()
                ) {
                    WrkMast wrkMast = wrkMastService.selectByWorkNo(stationProtocol.getTaskNo());
                    if (wrkMast == null) {
                        News.info("输送站点号={} 运行阻塞,但无法找到对应任务,工作号={}", stationProtocol.getStationId(), stationProtocol.getTaskNo());
                        continue;
                    }
                    Object lock = redisUtil.get(RedisKeyType.CHECK_STATION_RUN_BLOCK_LIMIT_.key + stationProtocol.getTaskNo());
                    if (lock != null) {
                        continue;
                    }
                    redisUtil.set(RedisKeyType.CHECK_STATION_RUN_BLOCK_LIMIT_.key + stationProtocol.getTaskNo(), "lock", 15);
                    if (wrkMast.getIoType() == WrkIoType.IN.id && runBlockReassignLocStationList.contains(stationProtocol.getStationId())) {
                        //站点处于重新分配库位区域
                        //运行堵塞,重新申请任务
                        String response = wmsOperateUtils.applyReassignTaskLocNo(wrkMast.getWrkNo(), stationProtocol.getStationId());
                        if (response == null) {
                            News.taskError(wrkMast.getWrkNo(), "请求WMS重新分配库位接口失败,接口未响应!!!response:{}", response);
                List<StationProtocol> list = stationThread.getStatus();
                for (StationProtocol stationProtocol : list) {
                    if (stationProtocol.isAutoing()
                            && stationProtocol.isLoading()
                            && stationProtocol.getTaskNo() > 0
                            && stationProtocol.isRunBlock()
                    ) {
                        WrkMast wrkMast = wrkMastService.selectByWorkNo(stationProtocol.getTaskNo());
                        if (wrkMast == null) {
                            News.info("输送站点号={} 运行阻塞,但无法找到对应任务,工作号={}", stationProtocol.getStationId(), stationProtocol.getTaskNo());
                            continue;
                        }
                        JSONObject jsonObject = JSON.parseObject(response);
                        if (jsonObject.getInteger("code").equals(200)) {
                            StartupDto dto = jsonObject.getObject("data", StartupDto.class);
                            String sourceLocNo = wrkMast.getLocNo();
                            String locNo = dto.getLocNo();
                        Object lock = redisUtil.get(RedisKeyType.CHECK_STATION_RUN_BLOCK_LIMIT_.key + stationProtocol.getTaskNo());
                        if (lock != null) {
                            continue;
                        }
                        redisUtil.set(RedisKeyType.CHECK_STATION_RUN_BLOCK_LIMIT_.key + stationProtocol.getTaskNo(), "lock", 15);
                            LocMast sourceLocMast = locMastService.queryByLoc(sourceLocNo);
                            if (sourceLocMast == null) {
                                News.taskInfo(wrkMast.getWrkNo(), "库位号:{} 源库位信息不存在", sourceLocNo);
                        if (wrkMast.getIoType() == WrkIoType.IN.id && runBlockReassignLocStationList.contains(stationProtocol.getStationId())) {
                            //站点处于重新分配库位区域
                            //运行堵塞,重新申请任务
                            String response = wmsOperateUtils.applyReassignTaskLocNo(wrkMast.getWrkNo(), stationProtocol.getStationId());
                            if (response == null) {
                                News.taskError(wrkMast.getWrkNo(), "请求WMS重新分配库位接口失败,接口未响应!!!response:{}", response);
                                continue;
                            }
                            JSONObject jsonObject = JSON.parseObject(response);
                            if (jsonObject.getInteger("code").equals(200)) {
                                StartupDto dto = jsonObject.getObject("data", StartupDto.class);
                            if (!sourceLocMast.getLocSts().equals("S")) {
                                News.taskInfo(wrkMast.getWrkNo(), "库位号:{} 源库位状态不处于入库预约", sourceLocNo);
                                continue;
                            }
                                String sourceLocNo = wrkMast.getLocNo();
                                String locNo = dto.getLocNo();
                            LocMast locMast = locMastService.queryByLoc(locNo);
                            if (locMast == null) {
                                News.taskInfo(wrkMast.getWrkNo(), "库位号:{} 目标库位信息不存在", locNo);
                                continue;
                            }
                                LocMast sourceLocMast = locMastService.queryByLoc(sourceLocNo);
                                if (sourceLocMast == null) {
                                    News.taskInfo(wrkMast.getWrkNo(), "库位号:{} 源库位信息不存在", sourceLocNo);
                                    continue;
                                }
                            if (!locMast.getLocSts().equals("O")) {
                                News.taskInfo(wrkMast.getWrkNo(), "库位号:{} 目标库位状态不处于空库位", locNo);
                                continue;
                            }
                                if (!sourceLocMast.getLocSts().equals("S")) {
                                    News.taskInfo(wrkMast.getWrkNo(), "库位号:{} 源库位状态不处于入库预约", sourceLocNo);
                                    continue;
                                }
                            FindCrnNoResult findCrnNoResult = commonService.findCrnNoByLocNo(locNo);
                            if (findCrnNoResult == null) {
                                News.taskInfo(wrkMast.getWrkNo(), "{}工作,未匹配到堆垛机", wrkMast.getWrkNo());
                                continue;
                            }
                            Integer crnNo = findCrnNoResult.getCrnNo();
                                LocMast locMast = locMastService.queryByLoc(locNo);
                                if (locMast == null) {
                                    News.taskInfo(wrkMast.getWrkNo(), "库位号:{} 目标库位信息不存在", locNo);
                                    continue;
                                }
                            Integer targetStationId = commonService.findInStationId(findCrnNoResult, stationProtocol.getStationId());
                            if (targetStationId == null) {
                                News.taskInfo(wrkMast.getWrkNo(), "{}站点,搜索入库站点失败", stationProtocol.getStationId());
                                continue;
                            }
                                if (!locMast.getLocSts().equals("O")) {
                                    News.taskInfo(wrkMast.getWrkNo(), "库位号:{} 目标库位状态不处于空库位", locNo);
                                    continue;
                                }
                            StationCommand command = stationThread.getCommand(StationCommandType.MOVE, wrkMast.getWrkNo(), stationProtocol.getStationId(), targetStationId, 0);
                            if(command == null){
                                News.taskInfo(wrkMast.getWrkNo(), "{}工作,获取输送线命令失败", wrkMast.getWrkNo());
                                continue;
                            }
                                FindCrnNoResult findCrnNoResult = commonService.findCrnNoByLocNo(locNo);
                                if (findCrnNoResult == null) {
                                    News.taskInfo(wrkMast.getWrkNo(), "{}工作,未匹配到堆垛机", wrkMast.getWrkNo());
                                    continue;
                                }
                                Integer crnNo = findCrnNoResult.getCrnNo();
                            //更新源库位
                            sourceLocMast.setLocSts("O");
                            sourceLocMast.setModiTime(new Date());
                            locMastService.updateById(sourceLocMast);
                                Integer targetStationId = commonService.findInStationId(findCrnNoResult, stationProtocol.getStationId());
                                if (targetStationId == null) {
                                    News.taskInfo(wrkMast.getWrkNo(), "{}站点,搜索入库站点失败", stationProtocol.getStationId());
                                    continue;
                                }
                            //更新目标库位
                            locMast.setLocSts("S");
                            locMast.setModiTime(new Date());
                            locMastService.updateById(locMast);
                                StationCommand command = stationThread.getCommand(StationCommandType.MOVE, wrkMast.getWrkNo(), stationProtocol.getStationId(), targetStationId, 0);
                                if (command == null) {
                                    News.taskInfo(wrkMast.getWrkNo(), "{}工作,获取输送线命令失败", wrkMast.getWrkNo());
                                    continue;
                                }
                            //更新工作档数据
                            wrkMast.setLocNo(locNo);
                            wrkMast.setStaNo(targetStationId);
                                //更新源库位
                                sourceLocMast.setLocSts("O");
                                sourceLocMast.setModiTime(new Date());
                                locMastService.updateById(sourceLocMast);
                            if (findCrnNoResult.getCrnType().equals(SlaveType.Crn)) {
                                wrkMast.setCrnNo(crnNo);
                            } else if (findCrnNoResult.getCrnType().equals(SlaveType.DualCrn)) {
                                wrkMast.setDualCrnNo(crnNo);
                            }else {
                                throw new CoolException("未知设备类型");
                            }
                                //更新目标库位
                                locMast.setLocSts("S");
                                locMast.setModiTime(new Date());
                                locMastService.updateById(locMast);
                            if (wrkMastService.updateById(wrkMast)) {
                                MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command));
                                //更新工作档数据
                                wrkMast.setLocNo(locNo);
                                wrkMast.setStaNo(targetStationId);
                                if (findCrnNoResult.getCrnType().equals(SlaveType.Crn)) {
                                    wrkMast.setCrnNo(crnNo);
                                } else if (findCrnNoResult.getCrnType().equals(SlaveType.DualCrn)) {
                                    wrkMast.setDualCrnNo(crnNo);
                                } else {
                                    throw new CoolException("未知设备类型");
                                }
                                if (wrkMastService.updateById(wrkMast)) {
                                    MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command));
                                }
                            } else {
                                News.error("请求WMS接口失败!!!response:{}", response);
                            }
                        } else {
                            News.error("请求WMS接口失败!!!response:{}", response);
                        }
                    }else {
                        //运行堵塞,重新计算路线
                        StationCommand command = stationThread.getCommand(StationCommandType.MOVE, wrkMast.getWrkNo(), stationProtocol.getStationId(), wrkMast.getStaNo(), 0);
                        if(command == null){
                            News.taskInfo(wrkMast.getWrkNo(), "获取输送线命令失败");
                            continue;
                        }
                            //运行堵塞,重新计算路线
                            StationCommand command = stationThread.getCommand(StationCommandType.MOVE, wrkMast.getWrkNo(), stationProtocol.getStationId(), wrkMast.getStaNo(), 0);
                            if (command == null) {
                                News.taskInfo(wrkMast.getWrkNo(), "获取输送线命令失败");
                                continue;
                            }
                        MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command));
                        News.info("输送站点堵塞后重新计算路径命令下发成功,站点号={},工作号={},命令数据={}", stationProtocol.getStationId(), wrkMast.getWrkNo(), JSON.toJSONString(command));
                            MessageQueue.offer(SlaveType.Devp, basDevp.getDevpNo(), new Task(2, command));
                            News.info("输送站点堵塞后重新计算路径命令下发成功,站点号={},工作号={},命令数据={}", stationProtocol.getStationId(), wrkMast.getWrkNo(), JSON.toJSONString(command));
                        }
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
src/main/resources/application.yml
@@ -1,6 +1,6 @@
# 系统版本信息
app:
  version: 1.0.2.2
  version: 1.0.3.0
  version-type: dev  # prd 或 dev
server:
@@ -72,7 +72,7 @@
  threadControlCount: 10
  liftType: lift
mainProcessPlugin: FakeProcess
mainProcessPlugin: XiaosongProcess
deviceLogStorage:
  # 设备日志存储方式 mysql file