自动化立体仓库 - WCS系统
#
luxiaotao1123
2022-12-13 7aa842ca0c3863da9024873cadd9fd64c72d26d2
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -39,7 +39,6 @@
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
@@ -118,6 +117,54 @@
                        && !staProtocol.isEmptyMk() && (workNo == 0 || (workNo >= 9990 && workNo <= 9999))
                        && staProtocol.isPakMk()) {
                    // 尺寸检测异常
                    boolean back = false;
                    String errMsg = "";
                    if (staProtocol.isFrontErr()) {
                        errMsg = "前超限";
                        back = true;
                    }
                    if (!back && staProtocol.isBackErr()) {
                        errMsg = "后超限";
                        back = true;
                    }
                    if (!back && staProtocol.isHighErr()) {
                        errMsg = "高超限";
                        back = true;
                    }
                    if (!back && staProtocol.isLeftErr()) {
                        errMsg = "左超限";
                        back = true;
                    }
                    if (!back && staProtocol.isRightErr()) {
                        errMsg = "右超限";
                        back = true;
                    }
                    if (!back && staProtocol.isWeightErr()) {
                        errMsg = "超重";
                        back = true;
                    }
                    if (!back && staProtocol.isBarcodeErr()) {
                        errMsg = "扫码失败";
                        back = true;
                    }
                    // 退回
                    if (back) {
                        log.warn("扫码入库失败,{}入库站因{}异常,托盘已被退回", inSta.getStaNo(), errMsg);
                        staProtocol.setWorkNo((short) 32002);
                        staProtocol.setStaNo(inSta.getBackSta().shortValue());
                        devpThread.setPakMk(staProtocol.getSiteId(), false);
                        MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                        // led 异常显示
                        LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed());
                        if (ledThread != null) {
                            MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errMsg));
                        }
                        continue;
                    }
                    // 获取条码扫描仪信息
                    BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, inSta.getBarcode());
                    if (barcodeThread == null) {
@@ -127,7 +174,7 @@
                    if(!Cools.isEmpty(barcode)) {
//                        log.info("{}号条码扫描器检测条码信息:{}", inSta.getBarcode(), barcode);
                        if("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode)) {
                            staProtocol.setWorkNo((short) 9995);
                            staProtocol.setWorkNo((short) 32002);
                            staProtocol.setStaNo(inSta.getBackSta().shortValue());
                            devpThread.setPakMk(staProtocol.getSiteId(), false);
                            MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
@@ -141,7 +188,7 @@
                            continue;
                        }
                    } else {
                        staProtocol.setWorkNo((short) 9995);
                        staProtocol.setWorkNo((short) 32002);
                        staProtocol.setStaNo(inSta.getBackSta().shortValue());
                        devpThread.setPakMk(staProtocol.getSiteId(), false);
                        MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
@@ -156,16 +203,16 @@
                    }
                    // 过滤盘点/拣料/并板任务
                    if (null != wrkMastMapper.selectPickStepByBarcode(barcode)) {
                        continue;
                    }
//                    if (null != wrkMastMapper.selectPickStepByBarcode(barcode)) {
//                        continue;
//                    }
                    // 判断重复工作档
                    WrkMast wrkMast = wrkMastMapper.selectPakInStep1(inSta.getStaNo(), barcode);
                    if (wrkMast != null) {
                        log.error("工作档中已存在该站状态为( 2.设备上走 )的数据,工作号={}", wrkMast.getWrkNo());
                        continue;
                    }
//                    WrkMast wrkMast = wrkMastMapper.selectPakInStep1(inSta.getStaNo(), barcode);
//                    if (wrkMast != null) {
//                        log.error("工作档中已存在该站状态为( 2.设备上走 )的数据,工作号={}", wrkMast.getWrkNo());
//                        continue;
//                    }
                    try {
                        LocTypeDto locTypeDto = new LocTypeDto(staProtocol);
@@ -204,7 +251,7 @@
                            }
                            log.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
                        } else if (code == 700) {
                            staProtocol.setWorkNo((short) 9995);
                            staProtocol.setWorkNo((short) 32002);
                            staProtocol.setStaNo(inSta.getBackSta().shortValue());
                            devpThread.setPakMk(staProtocol.getSiteId(), false);
                            MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
@@ -228,6 +275,7 @@
     * wms入库
     * 入库站,根据条码扫描生成入库工作档,工作状态 1 ==>> 2
     */
    @Deprecated
    public void generateStoreWrkFile0() {
        // 根据输送线plc遍历
        for (DevpSlave devp : slaveProperties.getDevp()) {
@@ -247,6 +295,55 @@
                        && staProtocol.isInEnable()
                        && !staProtocol.isEmptyMk() && (workNo == 0 || (workNo >= 9990 && workNo <= 9999))
                        && staProtocol.isPakMk()) {
                    // 尺寸检测异常
                    boolean back = false;
                    String errMsg = "";
                    if (staProtocol.isFrontErr()) {
                        errMsg = "前超限";
                        back = true;
                    }
                    if (!back && staProtocol.isBackErr()) {
                        errMsg = "后超限";
                        back = true;
                    }
                    if (!back && staProtocol.isHighErr()) {
                        errMsg = "高超限";
                        back = true;
                    }
                    if (!back && staProtocol.isLeftErr()) {
                        errMsg = "左超限";
                        back = true;
                    }
                    if (!back && staProtocol.isRightErr()) {
                        errMsg = "右超限";
                        back = true;
                    }
                    if (!back && staProtocol.isWeightErr()) {
                        errMsg = "超重";
                        back = true;
                    }
                    if (!back && staProtocol.isBarcodeErr()) {
                        errMsg = "扫码失败";
                        back = true;
                    }
                    // 退回
                    if (back) {
                        log.warn("扫码入库失败,{}入库站因{}异常,托盘已被退回", inSta.getStaNo(), errMsg);
                        staProtocol.setWorkNo((short) 32002);
                        staProtocol.setStaNo(inSta.getBackSta().shortValue());
                        devpThread.setPakMk(staProtocol.getSiteId(), false);
                        MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                        // led 异常显示
                        LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed());
                        if (ledThread != null) {
                            MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errMsg));
                        }
                        continue;
                    }
                    // 判断重复工作档
                    WrkMast wrkMast = wrkMastMapper.selectPakInStep11(inSta.getStaNo());
                    if (wrkMast == null) { continue; }
@@ -274,63 +371,9 @@
    }
    /**
     * 拣料、并板、盘点再入库 【第1阶段】
     * 拣料、并板、盘点再入库
     */
    public synchronized void stnToCrnStnPick0(){
        for (DevpSlave devp : slaveProperties.getDevp()) {
            // 遍历拣料入库口
            for (DevpSlave.Sta pickSta : devp.getPickOutSta()) {
                // 获取拣料入库站信息
                DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
                StaProtocol staProtocol = devpThread.getStation().get(pickSta.getStaNo());
                if (staProtocol == null) {
                    continue;
                } else {
                    staProtocol = staProtocol.clone();
                }
                if (staProtocol.isAutoing()
                        && staProtocol.isLoading()
                        && staProtocol.isInEnable()
                        && staProtocol.getWorkNo() > 0
                        && staProtocol.isPakMk()) {
                    WrkMast wrkMast = wrkMastMapper.selectPickStep(staProtocol.getWorkNo());
                    if (wrkMast == null) {
                        // 无拣料数据
                        continue;
                    }
                    short staNo;
                    switch (wrkMast.getSourceStaNo()) {
                        case 104:
                        case 108:
                            staNo = 103;
                            break;
                        case 204:
                        case 208:
                            staNo = 203;
                            break;
                        default:
                            log.error("{}任务再入库失败,系统数据异常!", wrkMast.getWrkNo());
                            continue;
                    }
                    // 更新站点信息 且 下发plc命令
//                    staProtocol.setWorkNo((short) 9994);
                    staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue());
                    staProtocol.setStaNo(staNo);
                    devpThread.setPakMk(staProtocol.getSiteId(), false);
                    boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                    if (!result) {
                        log.error("发布命令至输送线队列失败!!! [plc编号:{}]", devp.getId());
                    }
                }
            }
        }
    }
    /**
     * 拣料、并板、盘点再入库【第2阶段】
     */
    public synchronized void stnToCrnStnPick1(){
    public synchronized void stnToCrnStnPick(){
        for (DevpSlave devp : slaveProperties.getDevp()) {
            // 遍历拣料入库口
            for (DevpSlave.Sta pickSta : devp.getPickInSta()) {
@@ -347,65 +390,63 @@
                        && staProtocol.isLoading()
                        && staProtocol.isInEnable()
                        // 0 - 9990 或者 9996
                        && ((staProtocol.getWorkNo() > 0 && staProtocol.getWorkNo() < 9990) || staProtocol.getWorkNo() == 9996)
                        && (staProtocol.getWorkNo() > 0 && staProtocol.getWorkNo() < 9990)
                        && staProtocol.getStaNo().equals(staProtocol.getSiteId().shortValue())
                        && staProtocol.isPakMk()){
                    // 获取条码扫描仪信息
                    BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, pickSta.getBarcode());
                    if (barcodeThread == null) {
                        continue;
                    }
//                    BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, pickSta.getBarcode());
//                    if (barcodeThread == null) {
//                        continue;
//                    }
                    WrkMast wrkMast = null;
                    if (staProtocol.getWorkNo() > 0 && staProtocol.getWorkNo() < 9990) {
                        wrkMast = wrkMastMapper.selectPickStep(staProtocol.getWorkNo());
                        if (null == wrkMast) {
                            log.error("{}任务号错误,暂无拣料任务!", staProtocol.getWorkNo());
                        }
                    }
                    if (staProtocol.getWorkNo() == 9996) {
                        String barcode = barcodeThread.getBarcode();
                        if(!Cools.isEmpty(barcode)) {
                            log.info("{}号条码扫描器检测条码信息:{}", pickSta.getBarcode(), barcode);
                            if("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode)) {
                                staProtocol.setWorkNo((short) 9995);
                                staProtocol.setStaNo(pickSta.getBackSta().shortValue());
                                devpThread.setPakMk(staProtocol.getSiteId(), false);
                                MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                                // led 异常显示
                                LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, pickSta.getLed());
                                if (ledThread != null) {
                                    String errorMsg = "扫码失败,请重试";
                                    MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg));
                                }
                                continue;
                            }
                        } else {
                            staProtocol.setWorkNo((short) 9995);
                            staProtocol.setStaNo(pickSta.getBackSta().shortValue());
                            devpThread.setPakMk(staProtocol.getSiteId(), false);
                            MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                            // led 异常显示
                            LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, pickSta.getLed());
                            if (ledThread != null) {
                                String errorMsg = "扫码失败,请重试";
                                MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg));
                            }
                            continue;
                        }
                        wrkMast = wrkMastMapper.selectPickStepByBarcode(barcode);
                        if (null == wrkMast) {
                            log.error("{}条码错误,暂无拣料任务!", barcode);
                        }
                    }
                    if (wrkMast == null) {
                        // 无拣料数据
                    } else {
                        continue;
                    }
//                    if (staProtocol.getWorkNo() == 9996) {
//                        String barcode = barcodeThread.getBarcode();
//                        if(!Cools.isEmpty(barcode)) {
//                            log.info("{}号条码扫描器检测条码信息:{}", pickSta.getBarcode(), barcode);
//                            if("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode)) {
//                                staProtocol.setWorkNo((short) 32002);
//                                staProtocol.setStaNo(pickSta.getBackSta().shortValue());
//                                devpThread.setPakMk(staProtocol.getSiteId(), false);
//                                MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
//
//                                // led 异常显示
//                                LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, pickSta.getLed());
//                                if (ledThread != null) {
//                                    String errorMsg = "扫码失败,请重试";
//                                    MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg));
//                                }
//                                continue;
//                            }
//                        } else {
//                            staProtocol.setWorkNo((short) 32002);
//                            staProtocol.setStaNo(pickSta.getBackSta().shortValue());
//                            devpThread.setPakMk(staProtocol.getSiteId(), false);
//                            MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
//
//                            // led 异常显示
//                            LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, pickSta.getLed());
//                            if (ledThread != null) {
//                                String errorMsg = "扫码失败,请重试";
//                                MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg));
//                            }
//                            continue;
//                        }
//                        wrkMast = wrkMastMapper.selectPickStepByBarcode(barcode);
//                        if (null == wrkMast) {
//                            log.error("{}条码错误,暂无拣料任务!", barcode);
//                        }
//                    }
                    if ((wrkMast.getIoType() != 103 && wrkMast.getIoType() != 104 && wrkMast.getIoType() != 107)
                        || Cools.isEmpty(wrkMast.getStaNo()) || Cools.isEmpty(wrkMast.getSourceStaNo()) ) {
                        continue;
@@ -418,7 +459,7 @@
                        param.setWrkNo(wrkMast.getWrkNo());
                        param.setIoType(wrkMast.getIoType());
                        param.setSourceStaNo(pickSta.getStaNo());
                        param.setLocType1(locTypeDto.getLocType1());
//                        param.setLocType1(locTypeDto.getLocType1());
                        String response = new HttpHandler.Builder()
                                .setUri(wmsUrl)
                                .setPath("/rpc/pakin/loc/v1")
@@ -469,27 +510,6 @@
                            if (wrkMastMapper.setSteEmpty(wrkMast.getWrkNo()) == 0) {
                                throw new CoolException(wrkMast.getWrkNo() + "更新工作档数据状态失败");
                            }
                            // 修改源库位状态 O.空库位
                            LocMast locMast = locMastService.selectById(sourceLocNo);
                            locMast.setLocSts("O");
                            locMast.setModiTime(new Date());
                            if (!locMastService.updateById(locMast)) {
                                throw new CoolException(wrkMast.getWrkNo() + "修改源库位状态 O.空库位");
                            }
                            // 修改目标库位状态 Q.拣料/盘点/并板再入库
                            locMast = locMastService.selectById(wrkMast.getLocNo());
                            locMast.setLocSts("Q");
                            locMast.setModiTime(new Date());
                            if (!locMastService.updateById(locMast)) {
                                throw new CoolException(wrkMast.getWrkNo() + "修改目标库位状态 Q.拣料/盘点/并板再入库");
                            }
                            // 库存明细转移
                            if (!locDetlService.updateLocNo(wrkMast.getLocNo(), sourceLocNo)) {
                                throw new CoolException(wrkMast.getWrkNo() + "任务库存明细转移失败!!!");
                            }
                            // 条码设备处理
                            barcodeThread.setBarcode("");
                            // 更新站点信息 且 下发plc命令
                            staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue());
@@ -509,7 +529,7 @@
                            }
                            log.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
                        } else {
                            staProtocol.setWorkNo((short) 9995);
                            staProtocol.setWorkNo((short) 32002);
                            staProtocol.setStaNo(pickSta.getBackSta().shortValue());
                            devpThread.setPakMk(staProtocol.getSiteId(), false);
                            MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
@@ -525,7 +545,6 @@
                    } catch (Exception e) {
                        e.printStackTrace();
                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
//                        continue;
                    }
                }
@@ -537,7 +556,6 @@
    /**
     * 堆垛机站出库到出库站
     */
    @Async
    public void crnStnToOutStn() {
        for (CrnSlave crnSlave : slaveProperties.getCrn()) {
            // 遍历堆垛机出库站
@@ -674,6 +692,15 @@
//                log.error("{}站点查询无待入库数据 工作号={}", crnStn.getStaNo(), staProtocol.getWorkNo());
                continue;
            }
            // 同库位组进行校验
            List<String> groupLocNo = Utils.getGroupLocNo(wrkMast.getLocNo());
            if (!Cools.isEmpty(groupLocNo)) {
                if (null != wrkMastMapper.selectPakoutWorkingByGroupLoc(groupLocNo)) {
                    continue;
                }
            }
            if (wrkMast.getWrkSts() < 3) {
                if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.getWorkNo() > 0 && staProtocol.isInEnable()
                        && staDetl.getCanining()!=null && staDetl.getCanining().equals("Y")) {
@@ -777,8 +804,9 @@
                        wrkMast.setModiTime(now);
                        if (wrkMastMapper.updateById(wrkMast) == 0) {
                            log.error("修改工作档状态 {} => 7.吊车入库中 失败!!,工作号={}", wrkMast.getWrkSts$(), wrkMast.getWrkNo());
                        } else {
                            return true;
                        }
                        return true;
                    }
                }
            } else {
@@ -793,11 +821,13 @@
                            // 没有其他任务
                            if (null == wrkMastMapper.selectPakin(slave.getId(), steNo)) {
                                this.letCarBeReady(wrkMast, steNo, wrkMast.getLocNo());
                                return true;
                            }
                        }
                        // 小车搬走
                        if (wrkMast.getWrkSts() == 3L) {
                            this.carMoveOut(wrkMast, steNo, crnProtocol);
                            return true;
                        }
                        // 没有小车
                    } else {
@@ -834,8 +864,9 @@
                                wrkMast.setModiTime(now);
                                if (wrkMastMapper.updateById(wrkMast) == 0) {
                                    log.error("修改工作档状态 {} => 7.吊车入库中 失败!!,工作号={}", wrkMast.getWrkSts$(), wrkMast.getWrkNo());
                                } else {
                                    return true;
                                }
                                return true;
                            }
                        }
@@ -852,6 +883,8 @@
                            // 没有其他任务
                            if (null == wrkMastMapper.selectPakin(slave.getId(), steNo)) {
                                this.letCarBeWaiting(wrkMast, steNo, wrkMast.getLocNo());
                            } else {
                                return true;
                            }
                        }
                        // 堆垛机将货放至小车上 3.小车待搬(小车不用搬运,已经在当前组库位) / 6.小车待入  ===>> 7.吊车入库中
@@ -888,8 +921,9 @@
                                    wrkMast.setModiTime(now);
                                    if (wrkMastMapper.updateById(wrkMast) == 0) {
                                        log.error("修改工作档状态 3.小车待搬/6.小车待入 => 7.吊车入库中 失败!!,工作号={}", wrkMast.getWrkNo());
                                    } else {
                                        return true;
                                    }
                                    return true;
                                }
                            }
                        }
@@ -903,12 +937,14 @@
                                if (null == wrkMastMapper.selectPakin(slave.getId(), steNo)) {
                                    // 让小车等待搬运待续
                                    this.letCarBeReady(wrkMast, steThread.getSlave().getId(), wrkMast.getLocNo());
                                    return true;
                                }
                            }
                        }
                        // 堆垛机搬运小车
                        if (wrkMast.getWrkSts() == 3L) {
                            this.carMoveIn(wrkMast, wrkMast.getSteNo(), crnProtocol);
                            return true;
                        }
                    }
                }
@@ -921,7 +957,7 @@
    /**
     * 出库  ===>>  库位到堆垛机站
     */
    public boolean locToCrnStn(CrnSlave slave, CrnProtocol crnProtocol){
    public synchronized boolean locToCrnStn(CrnSlave slave, CrnProtocol crnProtocol){
        for (CrnSlave.CrnStn crnStn : slave.getCrnOutStn()) {
            // 获取工作状态为11(生成出库ID)的出库工作档
            WrkMast wrkMast = wrkMastMapper.selectPakOutStep111215(slave.getId(), crnStn.getStaNo());
@@ -939,6 +975,24 @@
                log.error("出库操作库位状态不符合--状态, 库位号={},库位状态={}", wrkMast.getLocNo(), sourceSta.getLocSts());
                continue;
            }
            // 同库位组进行校验
            List<String> groupLocNo = Utils.getGroupLocNo(wrkMast.getSourceLocNo());
            if (!Cools.isEmpty(groupLocNo)) {
                if (null != wrkMastMapper.selectPakinWorkingByGroupLoc(groupLocNo)) {
                    continue;
                }
            }
            // 判断是否有同库位组的出库任务,如果有,则暂停
            List<String> outsideLoc = Utils.getGroupOutsideLoc(wrkMast.getSourceLocNo());
            if (!Cools.isEmpty(outsideLoc)) {
                if (!Cools.isEmpty(wrkMastMapper.selectWorkingOfPakOutBySource(outsideLoc))) {
//                    log.warn("{}工作档出库失败,原因:外层库位{}正在执行出库任务!", wrkMast.getWrkNo(), JSON.toJSONString(outsideLoc));
                    continue;
                }
            }
            // 获取堆垛机出库站信息
            DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, crnStn.getDevpPlcId());
            StaProtocol staProtocol = devpThread.getStation().get(crnStn.getStaNo());
@@ -970,7 +1024,7 @@
                }
                // 置顶任务
                wrkMast.setIoPri((double) 9999);
                wrkMast.setIoPri((double) 9998);
                wrkMastMapper.updateById(wrkMast);
                // 判断是否为穿梭库
@@ -987,7 +1041,7 @@
                                log.error("{}库位异常,未检索到相应工作档!", shallowLocNo);
                            } else {
                                if(waitWrkMast.getWrkSts() == 11) {
                                    waitWrkMast.setIoPri(20D);
                                    waitWrkMast.setIoPri(wrkMast.getIoPri() + 1);
                                    waitWrkMast.setModiTime(new Date());
                                    if (wrkMastMapper.updateById(waitWrkMast) == 0) {
                                        log.error("调整工作档优先级失败!工作号={}", waitWrkMast.getWrkNo());
@@ -1035,8 +1089,9 @@
                        wrkMast.setModiTime(now);
                        if (wrkMastMapper.updateById(wrkMast) == 0) {
                            log.error("修改工作档状态 11.生成出库ID => 16.吊车出库中 失败!!,工作号={}", wrkMast.getWrkNo());
                        } else {
                            return true;
                        }
                        break;
                    }
                } else {
@@ -1070,8 +1125,9 @@
                            wrkMast.setModiTime(now);
                            if (wrkMastMapper.updateById(wrkMast) == 0) {
                                log.error("修改工作档状态 11.生成出库ID => 16.吊车出库中 失败!!,工作号={}", wrkMast.getWrkNo());
                            } else {
                                return true;
                            }
                            return true;
                        }
                    // 不是最外层库位,需要使用穿梭车搬运后,再堆垛机出库
                    } else {
@@ -1106,8 +1162,13 @@
                                        wrkMast.setSteNo(steNo);
                                        wrkMast.setCrnStrTime(now);
                                        wrkMast.setModiTime(now);
                                        LocMast locMast = locMastService.selectById(wrkMast.getSourceLocNo());
                                        Integer outCrnNo = locMastService.getOutCrnNo(locMast);
                                        wrkMast.setCrnNo(outCrnNo);
                                        if (wrkMastMapper.updateById(wrkMast) == 0) {
                                            log.error("修改工作档状态 11.生成出库ID => 14.小车搬出库 失败!!,工作号={}", wrkMast.getWrkNo());
                                        } else {
                                            return true;
                                        }
                                    }
                                }
@@ -1140,8 +1201,9 @@
                                    wrkMast.setModiTime(now);
                                    if (wrkMastMapper.updateById(wrkMast) == 0) {
                                        log.error("修改工作档状态 15.等待吊车 => 16.吊车出库中 失败!!,工作号={}", wrkMast.getWrkNo());
                                    } else {
                                        return true;
                                    }
                                    return true;
                                }
                            }
@@ -1155,12 +1217,14 @@
                                    if (null == wrkMastMapper.selectPakout(slave.getId(), steNo)) {
                                        // 让小车等待搬运待续
                                        this.letCarBeReady(wrkMast, steThread.getSlave().getId(), wrkMast.getSourceLocNo());
                                        return true;
                                    }
                                }
                            }
                            // 堆垛机搬运小车
                            if (wrkMast.getWrkSts() == 12L) {
                                this.carMoveIn(wrkMast, wrkMast.getSteNo(), crnProtocol);
                                return true;
                            }
                        }
                    }
@@ -1329,6 +1393,12 @@
            if (!steProtocol.isIdle()) { continue; }
            if (steProtocol.getRow() == 1) { continue; }
            String locNo = wrkMast.getWrkSts() < 10 ? wrkMast.getLocNo() : wrkMast.getSourceLocNo();
            // 如果在同一个库位组
            if (Utils.getGroupRow(locNo, true).equals(Utils.getGroupRow(steProtocol.getRow().intValue(), true))
                    && steProtocol.getBay().intValue() == Utils.getBay(locNo)
                    && steProtocol.getLev().intValue() == Utils.getLev(locNo)) {
                return steThread;
            }
            LocMast locMast = locMastService.selectById(locNo);
            int lev = locMast.getLev1();
            int bay = locMast.getBay1();
@@ -1611,7 +1681,6 @@
    /**
     * 执行对工作档的完成操作
     */
    @Async
    @Transactional
    public void storeFinished() {
        for (CrnSlave crn : slaveProperties.getCrn()) {
@@ -1854,6 +1923,9 @@
                            Date now = new Date();
                            wrkMast.setCrnEndTime(now);
                            wrkMast.setModiTime(now);
                            LocMast locMast = locMastService.selectById(wrkMast.getSourceLocNo());
                            Integer outCrnNo = locMastService.getOutCrnNo(locMast);
                            wrkMast.setCrnNo(outCrnNo);
                            // 修改成功后复位堆垛机
                            if (wrkMastMapper.updateById(wrkMast) > 0) {
                                // 堆垛机复位
@@ -2274,7 +2346,6 @@
    /**
     * 空栈板初始化入库,叉车入库站放货
     */
    @Async
    public void storeEmptyPlt(){
        for (DevpSlave devp : slaveProperties.getDevp()) {
            // 遍历空板入库口
@@ -2319,7 +2390,7 @@
                            param.setBarcode(barcode);
                        }
                        param.setSourceStaNo(emptyInSta.getStaNo());
                        param.setLocType1(locTypeDto.getLocType1());
//                        param.setLocType1(locTypeDto.getLocType1());
                        String response = new HttpHandler.Builder()
                                .setUri(wmsUrl)
                                .setPath("/rpc/pakin/loc/v1")
@@ -2363,7 +2434,6 @@
    /**
     * 出库  ===>> 工作档信息写入led显示器
     */
    @Async
    public void ledExecute() {
        for (LedSlave led : slaveProperties.getLed()) {
            // 获取输送线plc线程
@@ -2464,7 +2534,6 @@
    /**
     * 其他  ===>> LED显示器复位,显示默认信息
     */
    @Async
    public void ledReset() {
        for (LedSlave led : slaveProperties.getLed()) {
            // 获取输送线plc线程
@@ -2581,6 +2650,40 @@
                        continue;
                    }
                    // 小车处于通道
                    List<String> channel = slaveProperties.getChannel();
                    for (String channelLocNo : channel) {
                        if (steProtocol.getRow().intValue() == Utils.getRow(channelLocNo)
                                && steProtocol.getBay().intValue() == Utils.getBay(channelLocNo)
                                && steProtocol.getLev().intValue() == Utils.getLev(channelLocNo)) {
                            Integer otherSte = existOtherSte(channelLocNo, wrkCharge.getSteNo());
                            if (null != otherSte) {
                                log.warn("{}号小车充电阻断,原因:通道存在{}号穿梭车!", wrkCharge.getSteNo(), otherSte);
                            } else {
                                // 命令下发区 --------------------------------------------------------------------------
                                SteCommand steCommand = new SteCommand();
                                steCommand.setSteNo(wrkCharge.getSteNo()); // 穿梭车编号
                                steCommand.setTaskNo(wrkCharge.getWrkNo()); // 工作号
                                steCommand.setTaskMode(SteTaskModeType.GO_ORIGIN);  // 去右端
                                steCommand.setRow(Utils.getGroupRow(steProtocol.getRow().intValue(), false).shortValue());
                                steCommand.setBay(steProtocol.getBay());
                                steCommand.setLev(steProtocol.getLev());
                                if (!MessageQueue.offer(SlaveType.Ste, wrkCharge.getSteNo(), new Task(2, steCommand))) {
                                    log.error("穿梭车命令下发失败,穿梭车号={},任务数据={}", wrkCharge.getSteNo(), JSON.toJSON(steCommand));
                                } else {
                                    // 修改工作档状态 21.准备充电 ===> 25.小车走行
                                    wrkCharge.setWrkSts(25L);
                                    Date now = new Date();
                                    wrkCharge.setModiTime(now);
                                    if (!wrkChargeService.updateById(wrkCharge)) {
                                        log.error("修改充电任务状态 21.准备充电 ===> 25.小车走行 失败!!,工作号={}", wrkCharge.getWrkNo());
                                    }
                                }
                            }
                        }
                    }
                    // 处于充电库位组
                    if (steProtocol.getRow().intValue() == Utils.getRow(chargeLocNo)
                            && steProtocol.getBay().intValue() == Utils.getBay(chargeLocNo)
@@ -2639,6 +2742,11 @@
            // 22.小车待搬
            if (wrkCharge.getWrkSts() == 22) {
                // 入出库任务优先
                if (null != wrkMastMapper.selectWorkingByCrn(wrkCharge.getCrnNo())) {
                    return;
                }
                // 搬小车至小车走向通道
                List<String> channel = slaveProperties.getChannel();
@@ -2715,6 +2823,11 @@
            } else if (wrkCharge.getWrkSts() == 26) {
                // 固定堆垛机
                int crnNo = 1;
                // 入出库任务优先
                if (null != wrkMastMapper.selectWorkingByCrn(crnNo)) {
                    return;
                }
                // 充电位
                LocMast chargeLoc = locMastService.selectById(wrkCharge.getLocNo());
@@ -2870,6 +2983,10 @@
                } else {
                    // 固定堆垛机
                    int crnNo = 1;
                    if (null != wrkMastMapper.selectWorkingByCrn(crnNo)) {
                        return;
                    }
                    LocMast channelLoc = locMastService.selectById(channelLocNo);
                    CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, crnNo);
@@ -2934,6 +3051,10 @@
                }
            }
        } else if (wrkCharge.getWrkSts() == 45L) {
            if (null != wrkMastMapper.selectWorkingByCrn(wrkCharge.getCrnNo())) {
                return;
            }
            LocMast idleLoc = locMastService.selectById(basSte.getIdleLoc());
            Integer otherSte = existOtherSte(idleLoc.getLocNo(), wrkCharge.getSteNo());