#
Junjie
2025-08-11 22c00fb3f44e8ddda0380e156fa1500f01e323d5
#
1个文件已修改
148 ■■■■ 已修改文件
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java 148 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -650,75 +650,73 @@
     * 堆垛机站出库到出库站
     */
    public synchronized void crnStnToOutStn(Integer mark) {
        List<WrkMast> wrkMasts = wrkMastService.selectList(new EntityWrapper<WrkMast>()
                .eq("wrk_sts", 12)
        );
        for (CrnSlave crnSlave : slaveProperties.getCrn()) {
            // 遍历堆垛机出库站
            for (CrnSlave.CrnStn crnStn : crnSlave.getCrnOutStn()) {
                // 获取堆垛机出库站信息
                DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, crnStn.getDevpPlcId());
                StaProtocol staProtocol = devpThread.getStation().get(crnStn.getStaNo());
                if (staProtocol == null) {
                    continue;
                } else {
                    staProtocol = staProtocol.clone();
        for (WrkMast wrkMast : wrkMasts) {
            // 判断工作档条件
            if (wrkMast.getIoType() < 100 || wrkMast.getStaNo() == null || wrkMast.getSourceStaNo() == null) {
                continue;
            }
            Integer devpId = null;
            Integer sourceStaNo = wrkMast.getSourceStaNo();
            for (CrnSlave crnSlave : slaveProperties.getCrn()) {
                for (CrnSlave.CrnStn crnStn : crnSlave.getCrnOutStn()) {
                    if (crnStn.getStaNo().equals(sourceStaNo)) {
                        devpId = crnStn.getDevpPlcId();
                        break;
                    }
                }
                if (staProtocol.isAutoing() && staProtocol.isLoading() && (staProtocol.getWorkNo() == 0 || staProtocol.getStaNo() == null)) {
                    // 查询工作档
                    WrkMast wrkMast = wrkMastMapper.selectPakOutStep2(staProtocol.getSiteId());
                    if (wrkMast == null) {
            }
            if (devpId == null) {
                News.error("" + mark + " - 0" + " - 堆垛机站出库到出库站,未找到对应PLC");
                continue;
            }
            DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devpId);
            StaProtocol staProtocol = devpThread.getStation().get(sourceStaNo);
            if (staProtocol == null) {
                continue;
            } else {
                staProtocol = staProtocol.clone();
            }
            if (staProtocol.isAutoing() && (staProtocol.getWorkNo() == 0 || staProtocol.getStaNo() == null)) {
                CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, wrkMast.getCrnNo());
                CrnProtocol crnProtocol = crnThread.getCrnProtocol();
                if (crnProtocol.modeType == CrnModeType.AUTO && crnProtocol.getTaskNo().equals(wrkMast.getWrkNo().shortValue())
                        && (crnProtocol.statusType == CrnStatusType.PUTTING || crnProtocol.statusType == CrnStatusType.WAITING)) {
                    //放货中 或 等待确认
                    News.warnNoLog("" + mark + " - 0" + " - 开始执行");
                    // 命令下发区 --------------------------------------------------------------------------
                    LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>()
                            .eq("loc_no", wrkMast.getSourceLocNo()));
                    // 下发站点信息
                    staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue());
                    staProtocol.setStaNo(wrkMast.getStaNo().shortValue());
                    staProtocol.setPalletSize(locMast.getLocType2());
                    if (!MessageQueue.offer(SlaveType.Devp, devpId, new Task(2, staProtocol))) {
                        continue;
                    }
                    // 判断工作档条件
                    if (wrkMast.getIoType() < 100 || wrkMast.getStaNo() == null || wrkMast.getSourceStaNo() == null) {
                        continue;
                    }
                    // 判断吊车是否实际已完成,且电脑状态在move中,以备电脑进行更新工作档
                    CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, wrkMast.getCrnNo());
                    CrnProtocol crnProtocol = crnThread.getCrnProtocol();
                    if (crnProtocol.statusType == CrnStatusType.FETCHING || crnProtocol.statusType == CrnStatusType.PUTTING) {
                        // 移动中
                        continue;
                    }
                    //  判断堆垛机状态等待确认
                    if (crnProtocol.modeType == CrnModeType.AUTO && crnProtocol.getTaskNo().equals(wrkMast.getWrkNo().shortValue())
                            && crnProtocol.statusType == CrnStatusType.WAITING
                            && crnProtocol.forkPosType == CrnForkPosType.HOME) {
                        News.warnNoLog("" + mark + " - 0" + " - 开始执行");
                        // 命令下发区 --------------------------------------------------------------------------
                        LocMast locMast = locMastService.selectOne(new EntityWrapper<LocMast>()
                                .eq("loc_no", wrkMast.getSourceLocNo()));
                        // 下发站点信息
                        staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue());
                        staProtocol.setStaNo(wrkMast.getStaNo().shortValue());
                        staProtocol.setPalletSize(locMast.getLocType2());
                        if (!MessageQueue.offer(SlaveType.Devp, crnStn.getDevpPlcId(), new Task(2, staProtocol))) {
                            continue;
                        }
                        // 更新工作档状态为14失败
                        wrkMast.setWrkSts(14L);
                        wrkMast.setCrnEndTime(new Date());
                        if (wrkMastMapper.updateById(wrkMast) != 0) {
                            // 复位堆垛机
                            crnThread.setResetFlag(true);
                        } else {
                            News.error("" + mark + " - 1" + " - 更新工作档的工作状态为14失败!!! [工作号:{}]", wrkMast.getWrkNo());
                        }
                    // 更新工作档状态为14失败
                    wrkMast.setWrkSts(14L);
                    wrkMast.setCrnEndTime(new Date());
                    if (wrkMastMapper.updateById(wrkMast) != 0) {
                        News.info("" + mark + " - 1" + " - 更新工作档的工作状态为14成功!!! [工作号:{}]", wrkMast.getWrkNo());
                    } else {
                        News.errorNoLog("" + mark + " - 6" + " - 堆垛机信息不符合入库条件!!!"
                                + " 堆垛机状态:" + crnProtocol.modeType + "==自动AUTO:" + CrnModeType.AUTO
                                + "、堆垛机任务号:" + crnProtocol.getTaskNo() + "==工作档任务号:" + wrkMast.getWrkNo().shortValue()
                                + "、状态枚举:" + crnProtocol.statusType + "==WAITING:90 //任务完成等待WCS确认):" + CrnStatusType.WAITING
                                + "、货叉位置:" + crnProtocol.forkPosType + "==HOME:0  // 货叉原位:" + CrnForkPosType.HOME);
                        News.error("" + mark + " - 1" + " - 更新工作档的工作状态为14失败!!! [工作号:{}]", wrkMast.getWrkNo());
                    }
                }
            }
        }
        News.infoNoLog("" + mark + " - 0" + " - 堆垛机站出库到出库站  ===》执行完成");
    }
@@ -1627,20 +1625,25 @@
                if (crnProtocol.getTaskNo() == 9999) {
                    // 堆垛机复位
                    crnThread.setResetFlag(true);
                } else {
                    // 获取入库待确认工作档
                    WrkMast wrkMast = wrkMastMapper.selectPakInStep3(crnProtocol.getTaskNo().intValue());
                    if (wrkMast == null) {
                        News.error("" + mark + " - 1" + " - 堆垛机处于等待确认且任务完成状态,但未找到工作档。堆垛机号={},工作号={}", crn.getId(), crnProtocol.getTaskNo());
                        continue;
                    }
                    continue;
                }
                // 获取待确认工作档
                WrkMast wrkMast = wrkMastMapper.selectPakInStep3(crnProtocol.getTaskNo().intValue());
                if (wrkMast == null) {
                    News.error("" + mark + " - 1" + " - 堆垛机处于等待确认且任务完成状态,但未找到工作档。堆垛机号={},工作号={}", crn.getId(), crnProtocol.getTaskNo());
                    continue;
                }
                Date now = new Date();
                if(wrkMast.getIoType() < 100){
                    // 入库 + 库位转移  ==> 4.入库完成
                    if (wrkMast.getWrkSts() == 3 || (wrkMast.getWrkSts() == 12 && (wrkMast.getIoType() == 11 || wrkMast.getIoType() == 111))) {
                        wrkMast.setWrkSts(4L);
                    } else {
                        continue;
                    }
                    Date now = new Date();
                    wrkMast.setCrnEndTime(now);
                    wrkMast.setModiTime(now);
                    // 修改成功后复位堆垛机
@@ -1649,6 +1652,17 @@
                        News.warnNoLog("" + mark + " - 2" + " - 修改成功后复位堆垛机 : 堆垛机号={}", crnThread.getCrnProtocol().getCrnNo());
                        crnThread.setResetFlag(true);
                    }
                }else {
                    if (wrkMast.getWrkSts() != 14) {
                        News.error("" + mark + " - 1" + " - 堆垛机处于等待确认但工作档状态未完成。堆垛机号={},工作号={}", crn.getId(), crnProtocol.getTaskNo());
                        continue;
                    }
                    wrkMast.setCrnEndTime(now);
                    if (wrkMastMapper.updateById(wrkMast) != 0) {
                        // 复位堆垛机
                        crnThread.setResetFlag(true);
                    }
                }
            }