#
Junjie
7 天以前 f375928943ad4b9fe6d8508e151971dcdc23e982
src/main/java/com/zy/core/utils/DualCrnOperateProcessUtils.java
@@ -2,10 +2,10 @@
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.exception.CoolException;
import com.zy.asrs.domain.param.CreateLocMoveTaskParam;
import com.zy.asrs.entity.BasCrnp;
import com.zy.asrs.entity.BasDualCrnp;
import com.zy.asrs.entity.LocMast;
import com.zy.asrs.entity.WrkMast;
@@ -22,15 +22,14 @@
import com.zy.core.enums.*;
import com.zy.core.model.StationObjModel;
import com.zy.core.model.Task;
import com.zy.core.model.command.CrnCommand;
import com.zy.core.model.command.DualCrnCommand;
import com.zy.core.model.protocol.CrnProtocol;
import com.zy.core.model.command.StationCommand;
import com.zy.core.model.protocol.DualCrnProtocol;
import com.zy.core.model.protocol.StationProtocol;
import com.zy.core.thread.CrnThread;
import com.zy.core.thread.DualCrnThread;
import com.zy.core.thread.StationThread;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
@@ -42,6 +41,8 @@
@Component
public class DualCrnOperateProcessUtils {
    @Value("${mainProcessPlugin}")
    private String mainProcessPlugin;
    @Autowired
    private WrkMastService wrkMastService;
    @Autowired
@@ -56,7 +57,7 @@
    private CommonService commonService;
    //入出库  ===>>  双工位堆垛机入出库作业下发
    public synchronized void dualRrnIoExecute() {
    public synchronized void dualCrnIoExecute() {
        List<BasDualCrnp> basDualCrnps = basDualCrnpService.selectList(new EntityWrapper<>());
        for (BasDualCrnp basDualCrnp : basDualCrnps) {
            DualCrnThread dualCrnThread = (DualCrnThread) SlaveConnection.get(SlaveType.DualCrn, basDualCrnp.getCrnNo());
@@ -85,72 +86,67 @@
                continue;
            }
            int executeTaskNo = 0;
            if (dualCrnProtocol.getTaskNo() > 0) {
                executeTaskNo = dualCrnProtocol.getTaskNo();
            }
            if (dualCrnProtocol.getTaskNoTwo() > 0) {
                executeTaskNo = dualCrnProtocol.getTaskNoTwo();
            }
            if (executeTaskNo > 0) {
                WrkMast wrkMast = wrkMastService.selectByWorkNo(executeTaskNo);
                if (wrkMast != null) {
                    if (wrkMast.getIoType().equals(WrkIoType.IN.id)) {
                        this.crnExecuteIn(basDualCrnp, dualCrnThread); //  入库
                    } else if (wrkMast.getIoType().equals(WrkIoType.OUT.id)) {
                        this.crnExecuteOut(basDualCrnp, dualCrnThread); //  出库
                    }else {
                        continue;
                    }
                }
            }
            // 如果最近一次是入库模式
            if (dualCrnProtocol.getLastIo().equals("I")) {
                if (basDualCrnp.getInEnable().equals("Y")) {
                    this.crnExecuteIn(basDualCrnp, dualCrnThread); //  入库
                    dualCrnProtocol.setLastIo("O");
                } else if (basDualCrnp.getOutEnable().equals("Y")) {
                    this.crnExecuteOut(basDualCrnp, dualCrnThread); //  出库
                    dualCrnProtocol.setLastIo("I");
                }
            }
            // 如果最近一次是出库模式
            else if (dualCrnProtocol.getLastIo().equals("O")) {
                if (basDualCrnp.getOutEnable().equals("Y")) {
                    this.crnExecuteOut(basDualCrnp, dualCrnThread); //  出库
                    dualCrnProtocol.setLastIo("I");
                } else if (basDualCrnp.getInEnable().equals("Y")) {
                    this.crnExecuteIn(basDualCrnp, dualCrnThread); //  入库
                    dualCrnProtocol.setLastIo("O");
                }
            }
            this.crnExecute(basDualCrnp, dualCrnThread);
        }
    }
    private synchronized void crnExecuteIn(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread) {
    private synchronized void crnExecute(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread) {
        DualCrnProtocol dualCrnProtocol = dualCrnThread.getStatus();
        if(dualCrnProtocol == null){
            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.getLastIo().equals("O")) {
            allTaskList.addAll(inTaskList);
            allTaskList.addAll(outTaskList);
        }
        // 如果最近一次是入库模式
        else if (dualCrnProtocol.getLastIo().equals("I")) {
            allTaskList.addAll(outTaskList);
            allTaskList.addAll(inTaskList);
        }
        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;
                }
            }
        }
    }
    private List<WrkMast> getInTaskList(BasDualCrnp basDualCrnp) {
        List<WrkMast> list = new ArrayList<>();
        if(!basDualCrnp.getInEnable().equals("Y")){
            News.info("双工位堆垛机:{} 可入信号不满足", basDualCrnp.getCrnNo());
            return;
            return list;
        }
        List<StationObjModel> inStationList = basDualCrnp.getInStationList$();
        if(inStationList.isEmpty()){
            News.info("双工位堆垛机:{} 入库站点未设置", basDualCrnp.getCrnNo());
            return;
        }
        Integer crnNo = basDualCrnp.getCrnNo();
        int station = calcStation(dualCrnProtocol);
        if(station == 0){
            News.info("双工位堆垛机:{} 无可用工位", basDualCrnp.getCrnNo());
            return;
            return list;
        }
        for (StationObjModel stationObjModel : inStationList) {
@@ -190,30 +186,135 @@
            }
            if(wrkMast.getWrkSts() != WrkStsType.INBOUND_DEVICE_RUN.sts){
                News.taskInfo(stationProtocol.getTaskNo(), "工作号:{} 任务状态异常", stationProtocol.getTaskNo());
                continue;
            }
            list.add(wrkMast);
        }
        return list;
    }
    private List<WrkMast> getOutTaskList(BasDualCrnp basDualCrnp) {
        List<WrkMast> list = new ArrayList<>();
        if(!basDualCrnp.getOutEnable().equals("Y")){
            News.info("双工位堆垛机:{} 可出信号不满足", basDualCrnp.getCrnNo());
            return list;
        }
        List<StationObjModel> outStationList = basDualCrnp.getOutStationList$();
        if(outStationList.isEmpty()){
            News.info("双工位堆垛机:{} 出库站点未设置", basDualCrnp.getCrnNo());
            return list;
        }
        List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>()
                .eq("dual_crn_no", basDualCrnp.getCrnNo())
                .eq("wrk_sts", WrkStsType.NEW_OUTBOUND.sts)
        );
        list.addAll(wrkMasts);
        return list;
    }
    private List<WrkMast> getLocMoveTaskList(BasDualCrnp basDualCrnp) {
        List<WrkMast> list = new ArrayList<>();
        List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>()
                .eq("dual_crn_no", basDualCrnp.getCrnNo())
                .eq("wrk_sts", WrkStsType.NEW_LOC_MOVE.sts)
        );
        list.addAll(wrkMasts);
        return list;
    }
    private synchronized boolean crnExecuteIn(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread, WrkMast wrkMast) {
        DualCrnProtocol dualCrnProtocol = dualCrnThread.getStatus();
        if (dualCrnProtocol == null) {
            return false;
        }
        if (!basDualCrnp.getInEnable().equals("Y")) {
            News.info("双工位堆垛机:{} 可入信号不满足", basDualCrnp.getCrnNo());
            return false;
        }
        List<StationObjModel> inStationList = basDualCrnp.getInStationList$();
        if(inStationList.isEmpty()){
            News.info("双工位堆垛机:{} 入库站点未设置", basDualCrnp.getCrnNo());
            return false;
        }
        Integer crnNo = basDualCrnp.getCrnNo();
        int station = calcStation(dualCrnProtocol, "in");
        if (station == 0) {
            News.info("双工位堆垛机:{} 无可用工位", basDualCrnp.getCrnNo());
            return false;
        }
        if (wrkMast.getWrkSts() != WrkStsType.INBOUND_DEVICE_RUN.sts) {
            return false;
            }
            // 获取库位信息
            LocMast locMast = locMastService.selectById(wrkMast.getLocNo());
            if (locMast == null) {
                News.taskInfo(wrkMast.getWrkNo(), "目标库位:{} 信息不存在", wrkMast.getLocNo());
                continue;
            return false;
            }
            if (!locMast.getLocSts().equals("S")) {
                News.taskInfo(wrkMast.getWrkNo(), "目标库位:{} 状态异常", wrkMast.getLocNo());
                continue;
            return false;
            }
            //检测浅库位状态
            boolean checkStatus = checkShallowLocStatus(locMast.getLocNo(), wrkMast.getWrkNo());
            if (!checkStatus) {
                News.taskInfo(wrkMast.getWrkNo(), "因浅库位堵塞无法执行");
            return false;
        }
        StationObjModel inStationObjModel = null;
        for (StationObjModel stationObjModel : inStationList) {
            StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
            if (stationThread == null) {
                continue;
            }
            String sourceLocNo = Utils.getLocNo(stationObjModel.getDeviceRow(), stationObjModel.getDeviceBay(), stationObjModel.getDeviceLev());
            Map<Integer, StationProtocol> stationProtocolMap = stationThread.getStatusMap();
            StationProtocol stationProtocol = stationProtocolMap.get(stationObjModel.getStationId());
            if (stationProtocol == null) {
                continue;
            }
            if (!stationProtocol.isAutoing()) {
                continue;
            }
            if (!stationProtocol.isLoading()) {
                continue;
            }
            if (stationProtocol.getTaskNo() <= 0) {
                continue;
            }
            if (!stationProtocol.isInEnable()) {
                News.taskInfo(stationProtocol.getTaskNo(), "取货站点:{} 没有可入信号", stationObjModel.getStationId());
                continue;
            }
            if (stationProtocol.getTaskNo().equals(wrkMast.getWrkNo())) {
                inStationObjModel = stationObjModel;
                break;
            }
        }
        if (inStationObjModel == null) {
            News.taskInfo(wrkMast.getWrkNo(), "未搜索到取货站点");
            return false;
        }
        String sourceLocNo = Utils.getLocNo(inStationObjModel.getDeviceRow(), inStationObjModel.getDeviceBay(), inStationObjModel.getDeviceLev());
            List<DualCrnCommand> commandList = new ArrayList<>();
            DualCrnCommand pickCommand = dualCrnThread.getPickCommand(sourceLocNo, wrkMast.getWrkNo(), crnNo, station);
@@ -228,40 +329,36 @@
            if (wrkMastService.updateById(wrkMast)) {
                MessageQueue.offer(SlaveType.DualCrn, crnNo, new Task(2, commandList));
                News.info("双工位堆垛机命令下发成功,堆垛机号={},任务数据={}", crnNo, JSON.toJSON(commandList));
            dualCrnProtocol.setLastIo("I");
            return true;
            }
        }
        return false;
    }
    private synchronized void crnExecuteOut(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread) {
    private synchronized boolean crnExecuteOut(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread, WrkMast wrkMast) {
        DualCrnProtocol dualCrnProtocol = dualCrnThread.getStatus();
        if(dualCrnProtocol == null){
            return;
            return false;
        }
        if(!basDualCrnp.getOutEnable().equals("Y")){
            News.info("双工位堆垛机:{} 可出信号不满足", basDualCrnp.getCrnNo());
            return;
            return false;
        }
        List<StationObjModel> outStationList = basDualCrnp.getOutStationList$();
        if(outStationList.isEmpty()){
            News.info("双工位堆垛机:{} 出库站点未设置", basDualCrnp.getCrnNo());
            return;
            return false;
        }
        Integer crnNo = basDualCrnp.getCrnNo();
        int station = calcStation(dualCrnProtocol);
        int station = calcStation(dualCrnProtocol, "out");
        if(station == 0){
            News.info("双工位堆垛机:{} 无可用工位", basDualCrnp.getCrnNo());
            return;
            return false;
        }
        List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>()
                .eq("crn_no", crnNo)
                .eq("wrk_sts", WrkStsType.NEW_OUTBOUND.sts)
        );
        for (WrkMast wrkMast : wrkMasts) {
            for (StationObjModel stationObjModel : outStationList) {
                StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
                if (stationThread == null) {
@@ -324,13 +421,82 @@
                wrkMast.setIoTime(new Date());
                if (wrkMastService.updateById(wrkMast)) {
                    MessageQueue.offer(SlaveType.DualCrn, crnNo, new Task(2, commandList));
                    //取货后等待下一个任务时长
                    redisUtil.set(RedisKeyType.DUAL_CRN_PICK_WAIT_NEXT_TASK.key + crnNo, "wait", 5);
                    News.info("双工位堆垛机命令下发成功,堆垛机号={},任务数据={}", crnNo, JSON.toJSON(commandList));
                    return;
                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;
                }
            }
        return false;
        }
    private synchronized boolean crnExecuteLocMove(BasDualCrnp basDualCrnp, DualCrnThread dualCrnThread, WrkMast wrkMast) {
        DualCrnProtocol dualCrnProtocol = dualCrnThread.getStatus();
        if (dualCrnProtocol == null) {
            return false;
        }
        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;
        }
        if(!sourceLocMast.getLocSts().equals("R")){
            News.taskInfo(wrkMast.getWrkNo(), "源库位:{} 状态异常,不属于出库预约状态", wrkMast.getSourceLocNo());
            return false;
        }
        // 获取库位信息
        LocMast locMast = locMastService.selectById(wrkMast.getLocNo());
        if (locMast == null) {
            News.taskInfo(wrkMast.getWrkNo(), "库位:{} 信息不存在", wrkMast.getLocNo());
            return false;
        }
        if (!locMast.getLocSts().equals("S")) {
            News.taskInfo(wrkMast.getWrkNo(), "库位:{} 状态异常,不属于入库预约状态", wrkMast.getLocNo());
            return false;
        }
        //检测浅库位状态
        boolean checkStatus = checkShallowLocStatus(locMast.getLocNo(), wrkMast.getWrkNo());
        if (!checkStatus) {
            News.taskInfo(wrkMast.getWrkNo(), "因浅库位堵塞无法执行");
            return false;
        }
        List<DualCrnCommand> commandList = new ArrayList<>();
        DualCrnCommand pickCommand = dualCrnThread.getPickCommand(wrkMast.getSourceLocNo(), wrkMast.getWrkNo(), crnNo, station);
        DualCrnCommand putCommand = dualCrnThread.getPutCommand(wrkMast.getLocNo(), wrkMast.getWrkNo(), crnNo, station);
        commandList.add(pickCommand);
        commandList.add(putCommand);
        wrkMast.setWrkSts(WrkStsType.LOC_MOVE_RUN.sts);
        wrkMast.setDualCrnNo(crnNo);
        wrkMast.setSystemMsg("");
        wrkMast.setIoTime(new Date());
        if (wrkMastService.updateById(wrkMast)) {
            MessageQueue.offer(SlaveType.DualCrn, crnNo, new Task(2, commandList));
            News.info("双工位堆垛机命令下发成功,堆垛机号={},任务数据={}", crnNo, JSON.toJSON(commandList));
            dualCrnProtocol.setLastIo("I");
            return true;
        }
        return false;
    }
    //双工位堆垛机任务执行完成
@@ -357,12 +523,10 @@
            if(dualCrnProtocol.getTaskNo() > 0 && dualCrnProtocol.getStatus() == DualCrnStatusType.WAITING.id) {
                executeFinish(basDualCrnp, dualCrnThread, dualCrnProtocol, dualCrnProtocol.getTaskNo(), 1);
                continue;
            }
            if(dualCrnProtocol.getTaskNoTwo() > 0 && dualCrnProtocol.getStatusTwo() == DualCrnStatusType.WAITING.id) {
                executeFinish(basDualCrnp, dualCrnThread, dualCrnProtocol, dualCrnProtocol.getTaskNoTwo(), 2);
                continue;
            }
        }
    }
@@ -395,6 +559,30 @@
                updateWrkSts = WrkStsType.COMPLETE_INBOUND.sts;
            } else if (wrkMast.getWrkSts() == WrkStsType.OUTBOUND_RUN.sts) {
                updateWrkSts = WrkStsType.OUTBOUND_RUN_COMPLETE.sts;
                if(mainProcessPlugin.contains("Fake")) {
                    //生成仿真站点数据
                    List<StationObjModel> outStationList = basDualCrnp.getOutStationList$();
                    if(outStationList.isEmpty()){
                        News.info("双工位堆垛机:{} 出库站点未设置", basDualCrnp.getCrnNo());
                        return;
                    }
                    for (StationObjModel stationObjModel : outStationList) {
                        if (!stationObjModel.getStationId().equals(wrkMast.getSourceStaNo())) {
                            continue;
                        }
                        StationThread stationThread = (StationThread) SlaveConnection.get(SlaveType.Devp, stationObjModel.getDeviceNo());
                        if (stationThread == null) {
                            continue;
                        }
                        //生成仿真站点数据
                        StationCommand command = stationThread.getMoveCommand(9998, wrkMast.getSourceStaNo(), 0, 0);
                        MessageQueue.offer(SlaveType.Devp, stationObjModel.getDeviceNo(), new Task(2, command));
                    }
                }
            } else if (wrkMast.getWrkSts() == WrkStsType.LOC_MOVE_RUN.sts) {
                updateWrkSts = WrkStsType.COMPLETE_LOC_MOVE.sts;
            } else {
@@ -402,16 +590,24 @@
                return;
            }
            DualCrnCommand resetCommand = dualCrnThread.getResetCommand(dualCrnProtocol.getCrnNo(), station);
            boolean offer = MessageQueue.offer(SlaveType.DualCrn, dualCrnProtocol.getCrnNo(), new Task(3, resetCommand));
            if (offer) {
            wrkMast.setWrkSts(updateWrkSts);
            wrkMast.setSystemMsg("");
            wrkMast.setIoTime(new Date());
            if (wrkMastService.updateById(wrkMast)) {
                DualCrnCommand resetCommand = dualCrnThread.getResetCommand(dualCrnProtocol.getCrnNo(), station);
                MessageQueue.offer(SlaveType.DualCrn, dualCrnProtocol.getCrnNo(), new Task(3, resetCommand));
                News.info("双工位堆垛机任务状态更新成功,堆垛机号={},工作号={}", basDualCrnp.getCrnNo(), taskNo);
            }
            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);
@@ -481,15 +677,72 @@
        return false;
    }
    private int calcStation(DualCrnProtocol dualCrnProtocol) {
        int station = 0;
        if(dualCrnProtocol.getTaskNo() == 0){
            station = 1;
        }else if (dualCrnProtocol.getTaskNoTwo() == 0){
            station = 2;
    private int calcStation(DualCrnProtocol dualCrnProtocol, String type) {
        List<Integer> idleStationList = new ArrayList<>();
        if (dualCrnProtocol.getTaskNo() == 0
                && dualCrnProtocol.getLoaded() == 0
                && dualCrnProtocol.getStatusType().equals(DualCrnStatusType.IDLE)
        ) {
            idleStationList.add(1);
        }
        return station;
        if (dualCrnProtocol.getTaskNoTwo() == 0
                && dualCrnProtocol.getLoadedTwo() == 0
                && dualCrnProtocol.getStatusTypeTwo().equals(DualCrnStatusType.IDLE)
        ) {
            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;
    }
}