#
Junjie
14 小时以前 58b2e9a664d9395654cd3865f01043e3cfc2f1dd
src/main/java/com/zy/core/utils/CrnOperateProcessUtils.java
@@ -2,6 +2,7 @@
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.enums.NotifyMsgType;
@@ -96,48 +97,68 @@
                    && crnProtocol.getForkPos() == 0
                    && crnProtocol.getAlarm() == 0
            ) {
                Object clearLock = redisUtil.get(RedisKeyType.CLEAR_CRN_TASK_LIMIT.key + basCrnp.getCrnNo());
                if (clearLock != null) {
                    continue;
                }
                // 如果最近一次是入库模式
                if (crnProtocol.getLastIo().equals("I")) {
                    if (basCrnp.getInEnable().equals("Y")) {
                        this.crnExecuteIn(basCrnp, crnThread); //  入库
                        boolean result = this.crnExecuteIn(basCrnp, crnThread);//  入库
                        crnProtocol.setLastIo("O");
                        if (result) {
                            break;
                        }
                    } else if (basCrnp.getOutEnable().equals("Y")) {
                        this.crnExecuteOut(basCrnp, crnThread); //  出库
                        boolean result = this.crnExecuteOut(basCrnp, crnThread);//  出库
                        crnProtocol.setLastIo("I");
                        if (result) {
                            break;
                        }
                    }
                }
                // 如果最近一次是出库模式
                else if (crnProtocol.getLastIo().equals("O")) {
                    if (basCrnp.getOutEnable().equals("Y")) {
                        this.crnExecuteOut(basCrnp, crnThread); //  出库
                        boolean result = this.crnExecuteOut(basCrnp, crnThread);//  出库
                        crnProtocol.setLastIo("I");
                        if (result) {
                            break;
                        }
                    } else if (basCrnp.getInEnable().equals("Y")) {
                        this.crnExecuteIn(basCrnp, crnThread); //  入库
                        boolean result = this.crnExecuteIn(basCrnp, crnThread);//  入库
                        crnProtocol.setLastIo("O");
                        if (result) {
                            break;
                        }
                    }
                }
                //库位移转
                this.crnExecuteLocTransfer(basCrnp, crnThread);
                boolean transfer = this.crnExecuteLocTransfer(basCrnp, crnThread);
                if (transfer) {
                    break;
                }
            }
        }
    }
    private synchronized void crnExecuteIn(BasCrnp basCrnp, CrnThread crnThread) {
    private synchronized boolean crnExecuteIn(BasCrnp basCrnp, CrnThread crnThread) {
        CrnProtocol crnProtocol = crnThread.getStatus();
        if(crnProtocol == null){
            return;
            return false;
        }
        if(!basCrnp.getInEnable().equals("Y")){
            News.info("堆垛机:{} 可入信号不满足", basCrnp.getCrnNo());
            return;
            return false;
        }
        List<StationObjModel> inStationList = basCrnp.getInStationList$();
        if(inStationList.isEmpty()){
            News.info("堆垛机:{} 入库站点未设置", basCrnp.getCrnNo());
            return;
            return false;
        }
        Integer crnNo = basCrnp.getCrnNo();
@@ -213,25 +234,27 @@
                MessageQueue.offer(SlaveType.Crn, crnNo, new Task(2, command));
                notifyUtils.notify(String.valueOf(SlaveType.Crn), crnNo, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.CRN_IN_TASK_RUN, null);
                News.info("堆垛机命令下发成功,堆垛机号={},任务数据={}", crnNo, JSON.toJSON(command));
                return true;
            }
        }
        return false;
    }
    private synchronized void crnExecuteOut(BasCrnp basCrnp, CrnThread crnThread) {
    private synchronized boolean crnExecuteOut(BasCrnp basCrnp, CrnThread crnThread) {
        CrnProtocol crnProtocol = crnThread.getStatus();
        if(crnProtocol == null){
            return;
            return false;
        }
        if(!basCrnp.getOutEnable().equals("Y")){
            News.info("堆垛机:{} 可出信号不满足", basCrnp.getCrnNo());
            return;
            return false;
        }
        List<StationObjModel> outStationList = basCrnp.getOutStationList$();
        if(outStationList.isEmpty()){
            News.info("堆垛机:{} 出库站点未设置", basCrnp.getCrnNo());
            return;
            return false;
        }
        Integer crnNo = basCrnp.getCrnNo();
@@ -302,10 +325,11 @@
                    MessageQueue.offer(SlaveType.Crn, crnNo, new Task(2, command));
                    notifyUtils.notify(String.valueOf(SlaveType.Crn), crnNo, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.CRN_OUT_TASK_RUN, null);
                    News.info("堆垛机命令下发成功,堆垛机号={},任务数据={}", crnNo, JSON.toJSON(command));
                    return;
                    return true;
                }
            }
        }
        return false;
    }
    private synchronized boolean crnExecuteInPlanner(BasCrnp basCrnp, CrnThread crnThread, WrkMast wrkMast) {
@@ -486,10 +510,10 @@
        return false;
    }
    private synchronized void crnExecuteLocTransfer(BasCrnp basCrnp, CrnThread crnThread) {
    private synchronized boolean crnExecuteLocTransfer(BasCrnp basCrnp, CrnThread crnThread) {
        CrnProtocol crnProtocol = crnThread.getStatus();
        if(crnProtocol == null){
            return;
            return false;
        }
        Integer crnNo = basCrnp.getCrnNo();
@@ -534,9 +558,10 @@
                MessageQueue.offer(SlaveType.Crn, crnNo, new Task(2, command));
                notifyUtils.notify(String.valueOf(SlaveType.Crn), crnNo, String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.CRN_TRANSFER_TASK_RUN, null);
                News.info("堆垛机命令下发成功,堆垛机号={},任务数据={}", crnNo, JSON.toJSON(command));
                return;
                return true;
            }
        }
        return false;
    }
    //堆垛机任务执行完成
@@ -576,6 +601,21 @@
                }else if(wrkMast.getWrkSts() == WrkStsType.OUTBOUND_RUN.sts){
                    updateWrkSts = WrkStsType.OUTBOUND_RUN_COMPLETE.sts;
                    notifyUtils.notify(String.valueOf(SlaveType.Crn), crnProtocol.getCrnNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.CRN_OUT_TASK_COMPLETE, null);
                    List<StationObjModel> outStationList = basCrnp.getOutStationList$();
                    if(outStationList.isEmpty()){
                        News.info("堆垛机:{} 出库站点未设置", basCrnp.getCrnNo());
                        return;
                    }
                    StationObjModel outStationObjModel = null;
                    for (StationObjModel stationObjModel : outStationList) {
                        if (stationObjModel.getStationId().equals(wrkMast.getSourceStaNo())) {
                            outStationObjModel = stationObjModel;
                            break;
                        }
                    }
                    redisUtil.set(RedisKeyType.CRN_OUT_TASK_COMPLETE_STATION_INFO.key + wrkMast.getWrkNo(), JSON.toJSONString(outStationObjModel, SerializerFeature.DisableCircularReferenceDetect), 60 * 60 * 24);
                }else if(wrkMast.getWrkSts() == WrkStsType.LOC_MOVE_RUN.sts){
                    updateWrkSts = WrkStsType.COMPLETE_LOC_MOVE.sts;
                    notifyUtils.notify(String.valueOf(SlaveType.Crn), crnProtocol.getCrnNo(), String.valueOf(wrkMast.getWrkNo()), wrkMast.getWmsWrkNo(), NotifyMsgType.CRN_TRANSFER_TASK_COMPLETE, null);
@@ -763,13 +803,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) {