#
野心家
2023-03-11 18a81e48e6559009ec39d2c2e28d64312f204189
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -315,9 +315,9 @@
                }
//                // 入出库模式判断
                if (inSta.getStaNo() == 203 && devpThread.ioModeOf2F != IoModeType.PAKIN_MODE) {
                    continue;
                }
//                if (inSta.getStaNo() == 203 && devpThread.ioModeOf2F != IoModeType.PAKIN_MODE) {
//                    continue;
//                }
                // 判断是否满足入库条件
                if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable()
@@ -517,8 +517,35 @@
        String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
        for (CrnSlave crnSlave : slaveProperties.getCrn()) {
            // 遍历堆垛机出库站
            for (CrnSlave.CrnStn crnStn : crnSlave.getCrnOutStn()) {
            //查询工作档
            List<WrkMast> wrkMasts= wrkMastService.selectList(new EntityWrapper<WrkMast>()
                    .eq("crn_no",crnSlave.getCrnOutStn())
                    .and()
                    .gt("io_type",100)
                    .orderBy("appe_time")
            );
            if(Cools.isEmpty(wrkMasts)){
                continue;
            }
            //遍历任务档,按生成时间进行排序
            for (WrkMast wrkMast: wrkMasts) {
                // 判断工作档条件
                if (wrkMast.getStaNo() == null || wrkMast.getSourceStaNo() == null) {
                    continue;
                }
                CrnSlave.CrnStn crnStn = null;
                for (CrnSlave.CrnStn crnStn1 : crnSlave.getCrnOutStn()) {
                    if (crnStn1.getStaNo() == wrkMast.getSourceStaNo()) {
                        crnStn = crnStn1;
                        break;
                    } else {
                        continue;
                    }
                }
                if (Cools.isEmpty(crnStn)) {
                    continue;
                }
                // 获取堆垛机出库站信息
                DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, crnStn.getDevpPlcId());
                StaProtocol staProtocol = devpThread.getStation().get(crnStn.getStaNo());
@@ -528,15 +555,8 @@
                    staProtocol = staProtocol.clone();
                }
                if (staProtocol.isAutoing() && staProtocol.isLoading() && (staProtocol.getWorkNo() == 0 || staProtocol.getStaNo() == null)) {
                    // 查询工作档
                    WrkMast wrkMast = wrkMastMapper.selectPakOutStep2(staProtocol.getSiteId());
                    if (wrkMast == null) {
                        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();
@@ -574,6 +594,68 @@
            }
        }
    }
//    public synchronized void crnStnToOutStn1() {
//        String methodName = Thread.currentThread().getStackTrace()[1].getMethodName();
//
//        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();
//                }
//                if (staProtocol.isAutoing() && staProtocol.isLoading() && (staProtocol.getWorkNo() == 0 || staProtocol.getStaNo() == null)) {
//                    // 查询工作档
//                    WrkMast wrkMast = wrkMastMapper.selectPakOutStep2(staProtocol.getSiteId());
//                    if (wrkMast == null) {
//                        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) {
//
//                        // 命令下发区 --------------------------------------------------------------------------
//
//                        // 下发站点信息
//                        staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue());
//                        staProtocol.setStaNo(wrkMast.getStaNo().shortValue());
//                        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(methodName + ":更新工作档的工作状态为14失败!!! [工作号:{}]", wrkMast.getWrkNo());
//                        }
//
//                    }
//
//                }
//            }
//        }
//    }
    /**
     * 入出库  ===>>  堆垛机入出库作业下发
@@ -861,9 +943,9 @@
//            // 入出库模式判断
//            if (devpThread.ioMode != IoModeType.PAKOUT_MODE) { continue; }
                if (wrkMast.getStaNo() == 204 && devpThread.ioModeOf2F != IoModeType.PAKOUT_MODE) {
                    continue;
                }
//                if (wrkMast.getStaNo() == 204 && devpThread.ioModeOf2F != IoModeType.PAKOUT_MODE) {
//                    continue;
//                }
                // 查询站点详细信息
                BasDevp staDetl = basDevpService.selectById(crnStn.getStaNo());
@@ -2058,65 +2140,65 @@
    /**
     * 入出库模式切换函数
     */
    public synchronized void ioConvert() {
        try {
            // 根据输送线plc遍历
            for (DevpSlave devp : slaveProperties.getDevp()) {
                SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
                for (DevpSlave.Sta inSta : devp.getInSta()) {
                    if (inSta.getStaNo() == 2) {
                        continue;
                    }
                    WrkMast pakout = wrkMastMapper.selectWorkingPakout(inSta.getStaNo());
                    switch (inSta.getStaNo()) {
                        case 203://1F
                            if (pakout != null) {
                                if (devpThread.ioModeOf2F != IoModeType.PAKOUT_MODE) {
                                    // 出库切换中
                                    devpThread.ioModeOf2F = IoModeType.PAKOUT_BOOTING;
                                    WrkMast pakin = wrkMastMapper.selectWorkingPakin(inSta.getStaNo());
                                    if (pakin == null && !devpThread.getStation().get(inSta.getStaNo()).isLoading()
                                            && !devpThread.getStation().get(inSta.getStaNo() + 1).isLoading()
                                            && devpThread.getStation().get(inSta.getStaNo() + 1).getWorkNo() == 0) {
                                        // 出库模式
                                        devpThread.ioModeOf2F = IoModeType.PAKOUT_MODE;
                                    }
                                }
                            } else {
                                // 入库模式
                                devpThread.ioModeOf2F = IoModeType.PAKIN_MODE;
                            }
                            break;
                        case 401://1F
                            if (pakout != null) {
                                if (devpThread.ioModeOf4F != IoModeType.PAKOUT_MODE) {
                                    // 出库切换中
                                    devpThread.ioModeOf4F = IoModeType.PAKOUT_BOOTING;
                                    WrkMast pakin = wrkMastMapper.selectWorkingPakin(inSta.getStaNo());
                                    if (pakin == null && !devpThread.getStation().get(inSta.getStaNo()).isLoading()
                                            && !devpThread.getStation().get(inSta.getStaNo() + 1).isLoading()
                                            && devpThread.getStation().get(inSta.getStaNo() + 1).getWorkNo() == 0) {
                                        // 出库模式
                                        devpThread.ioModeOf4F = IoModeType.PAKOUT_MODE;
                                    }
                                }
                            } else {
                                // 入库模式
                                devpThread.ioModeOf4F = IoModeType.PAKIN_MODE;
                            }
                            break;
                    }
                }
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
//    public synchronized void ioConvert() {
//        try {
//            // 根据输送线plc遍历
//            for (DevpSlave devp : slaveProperties.getDevp()) {
//                SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
//
//                for (DevpSlave.Sta inSta : devp.getInSta()) {
//                    if (inSta.getStaNo() == 2) {
//                        continue;
//                    }
//                    WrkMast pakout = wrkMastMapper.selectWorkingPakout(inSta.getStaNo());
//                    switch (inSta.getStaNo()) {
//                        case 203://1F
//                            if (pakout != null) {
//                                if (devpThread.ioModeOf2F != IoModeType.PAKOUT_MODE) {
//                                    // 出库切换中
//                                    devpThread.ioModeOf2F = IoModeType.PAKOUT_BOOTING;
//                                    WrkMast pakin = wrkMastMapper.selectWorkingPakin(inSta.getStaNo());
//                                    if (pakin == null && !devpThread.getStation().get(inSta.getStaNo()).isLoading()
//                                            && !devpThread.getStation().get(inSta.getStaNo() + 1).isLoading()
//                                            && devpThread.getStation().get(inSta.getStaNo() + 1).getWorkNo() == 0) {
//                                        // 出库模式
//                                        devpThread.ioModeOf2F = IoModeType.PAKOUT_MODE;
//                                    }
//                                }
//                            } else {
//                                // 入库模式
//                                devpThread.ioModeOf2F = IoModeType.PAKIN_MODE;
//                            }
//                            break;
//                        case 401://1F
//                            if (pakout != null) {
//                                if (devpThread.ioModeOf4F != IoModeType.PAKOUT_MODE) {
//                                    // 出库切换中
//                                    devpThread.ioModeOf4F = IoModeType.PAKOUT_BOOTING;
//                                    WrkMast pakin = wrkMastMapper.selectWorkingPakin(inSta.getStaNo());
//                                    if (pakin == null && !devpThread.getStation().get(inSta.getStaNo()).isLoading()
//                                            && !devpThread.getStation().get(inSta.getStaNo() + 1).isLoading()
//                                            && devpThread.getStation().get(inSta.getStaNo() + 1).getWorkNo() == 0) {
//                                        // 出库模式
//                                        devpThread.ioModeOf4F = IoModeType.PAKOUT_MODE;
//                                    }
//                                }
//                            } else {
//                                // 入库模式
//                                devpThread.ioModeOf4F = IoModeType.PAKIN_MODE;
//                            }
//                            break;
//                    }
//                }
//
//            }
//
//        } catch (Exception e) {
//            e.printStackTrace();
//        }
//
//
//    }
    public synchronized void outOfDevp() {
        List<WrkMast> wrkMasts = wrkMastMapper.selectPick();