#
yxFwq
2025-02-21 e0db508f1cd8cb3d3d296acc4f55197d22026845
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -2882,7 +2882,13 @@
                            wrkMast.setUpdMk("Y");
                            wrkMastMapper.updateById(wrkMast);
                            // 生成工作档,将浅库位移转到新的库位中
                            moveLocForDeepLoc(slave, shallowLoc);
                            try{
                                moveLocForDeepLoc(slave, shallowLoc);
                            } catch (Exception e){
                                log.error("{}任务出库失败,浅库位堵塞!异常", wrkMast.getWrkNo(), e);
                                log.error("{}任务出库失败,浅库位堵塞!浅库位号:{}", wrkMast.getWrkNo(), shallowLocNo);
                                continue;
                            }
                        }
                        log.error("{}任务出库失败,浅库位堵塞!浅库位号:{}", wrkMast.getWrkNo(), shallowLocNo);
                        continue;
@@ -3096,6 +3102,13 @@
            }
            Integer turnBigInt = 0;
            if (wrkMast.booleanStaNoSign() && wrkMast.getIoPri()<99D){
                Date now = new Date();
                long differenceInSeconds =  now.getTime() - wrkMast.getModiTime().getTime();
                if (differenceInSeconds<=2000){
                    continue;
                }
            }
//            if (wrkMast.booleanStaNoSign()){
//                RgvOneSign rgvOneSign = rgvOneSignMapper.selectOneSign("LineUp"+wrkMast.getStaNo());
//                if (Cools.isEmpty(rgvOneSign)){
@@ -4634,6 +4647,7 @@
     */
    private synchronized void moveLocForDeepLoc(CrnSlave crn, LocMast shallowLoc) {
        try {
            log.info("移库:CrnSlave:{}、LocMast:{}",JSON.toJSON(crn),JSON.toJSON(shallowLoc));
            List<Integer> rows = locMastService.queryDistinctRow(crn.getId());
            LocMast loc = null;
            for (Integer row : rows) {
@@ -4676,68 +4690,68 @@
            if (null == loc) {
                log.error("双深库位 --- 浅库位阻塞异常! 待移转浅库位:" + shallowLoc.getLocNo());
                throw new CoolException("双深库位 --- 浅库位阻塞异常! 待移转浅库位:" + shallowLoc.getLocNo());
            }
            // 获取工作号
            int workNo = commonService.getWorkNo(0);
            // 保存工作档
            WrkMast wrkMast = new WrkMast();
            wrkMast.setWrkNo(workNo);
            wrkMast.setIoTime(new Date());
            wrkMast.setWrkSts(11L); // 工作状态:11.生成出库ID
            wrkMast.setIoType(11); // 入出库状态: 11.库格移载
            wrkMast.setIoPri(13D);
            wrkMast.setCrnNo(crn.getId());
            wrkMast.setSourceLocNo(shallowLoc.getLocNo()); // 源库位
            wrkMast.setLocNo(loc.getLocNo()); // 目标库位
            wrkMast.setFullPlt(shallowLoc.getFullPlt()); // 满板
            wrkMast.setPicking("N"); // 拣料
            wrkMast.setExitMk("N"); // 退出
            wrkMast.setEmptyMk(shallowLoc.getLocSts().equals("D") ? "Y" : "N"); // 空板
            wrkMast.setBarcode(shallowLoc.getBarcode()); // 托盘码
            wrkMast.setLinkMis("N");
            wrkMast.setAppeTime(new Date());
            wrkMast.setModiTime(new Date());
            int res = wrkMastMapper.insert(wrkMast);
            if (res == 0) {
                throw new CoolException("保存工作档失败");
            }
            // 工作档明细保存
            if (shallowLoc.getLocSts().equals("F")) {
                List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", shallowLoc.getLocNo()));
                for (LocDetl locDetl : locDetls) {
                    WrkDetl wrkDetl = new WrkDetl();
                    wrkDetl.setWrkNo(workNo);
                    wrkDetl.setIoTime(new Date());
                    wrkDetl.setAnfme(locDetl.getAnfme());
                    VersionUtils.setWrkDetl(wrkDetl, locDetl); // 版本控制
                    wrkDetl.setAppeTime(new Date());
                    wrkDetl.setModiTime(new Date());
                    if (!wrkDetlService.insert(wrkDetl)) {
                        throw new CoolException("保存工作档明细失败");
//                throw new CoolException("双深库位 --- 浅库位阻塞异常! 待移转浅库位:" + shallowLoc.getLocNo());
            } else {
                // 获取工作号
                int workNo = commonService.getWorkNo(0);
                // 保存工作档
                WrkMast wrkMast = new WrkMast();
                wrkMast.setWrkNo(workNo);
                wrkMast.setIoTime(new Date());
                wrkMast.setWrkSts(11L); // 工作状态:11.生成出库ID
                wrkMast.setIoType(11); // 入出库状态: 11.库格移载
                wrkMast.setIoPri(13D);
                wrkMast.setCrnNo(crn.getId());
                wrkMast.setSourceLocNo(shallowLoc.getLocNo()); // 源库位
                wrkMast.setLocNo(loc.getLocNo()); // 目标库位
                wrkMast.setFullPlt(shallowLoc.getFullPlt()); // 满板
                wrkMast.setPicking("N"); // 拣料
                wrkMast.setExitMk("N"); // 退出
                wrkMast.setEmptyMk(shallowLoc.getLocSts().equals("D") ? "Y" : "N"); // 空板
                wrkMast.setBarcode(shallowLoc.getBarcode()); // 托盘码
                wrkMast.setLinkMis("N");
                wrkMast.setAppeTime(new Date());
                wrkMast.setModiTime(new Date());
                int res = wrkMastMapper.insert(wrkMast);
                if (res == 0) {
                    throw new CoolException("保存工作档失败");
                }
                // 工作档明细保存
                if (shallowLoc.getLocSts().equals("F")) {
                    List<LocDetl> locDetls = locDetlService.selectList(new EntityWrapper<LocDetl>().eq("loc_no", shallowLoc.getLocNo()));
                    for (LocDetl locDetl : locDetls) {
                        WrkDetl wrkDetl = new WrkDetl();
                        wrkDetl.setWrkNo(workNo);
                        wrkDetl.setIoTime(new Date());
                        wrkDetl.setAnfme(locDetl.getAnfme());
                        VersionUtils.setWrkDetl(wrkDetl, locDetl); // 版本控制
                        wrkDetl.setAppeTime(new Date());
                        wrkDetl.setModiTime(new Date());
                        if (!wrkDetlService.insert(wrkDetl)) {
                            throw new CoolException("保存工作档明细失败");
                        }
                    }
                }
            }
            // 修改源库位状态
            if (shallowLoc.getLocSts().equals("D") || shallowLoc.getLocSts().equals("F")) {
                shallowLoc.setLocSts("R"); // R.出库预约
                shallowLoc.setModiTime(new Date());
                if (!locMastService.updateById(shallowLoc)) {
                    throw new CoolException("更新源库位状态失败");
                // 修改源库位状态
                if (shallowLoc.getLocSts().equals("D") || shallowLoc.getLocSts().equals("F")) {
                    shallowLoc.setLocSts("R"); // R.出库预约
                    shallowLoc.setModiTime(new Date());
                    if (!locMastService.updateById(shallowLoc)) {
                        throw new CoolException("更新源库位状态失败");
                    }
                } else {
                    throw new CoolException("源库位出库失败");
                }
            } else {
                throw new CoolException("源库位出库失败");
            }
            // 修改目标库位状态
            if (loc.getLocSts().equals("O")) {
                loc.setLocSts("S"); // S.入库预约
                loc.setModiTime(new Date());
                if (!locMastService.updateById(loc)) {
                    throw new CoolException("更新目标库位状态失败");
                // 修改目标库位状态
                if (loc.getLocSts().equals("O")) {
                    loc.setLocSts("S"); // S.入库预约
                    loc.setModiTime(new Date());
                    if (!locMastService.updateById(loc)) {
                        throw new CoolException("更新目标库位状态失败");
                    }
                } else {
                    throw new CoolException("移转失败");
                }
            } else {
                throw new CoolException("移转失败");
            }
        } catch (Exception e) {
            log.error("双深库位阻塞,对浅库位进行移转失败", e);
@@ -5165,7 +5179,7 @@
                                break;
                            }
                            if (count>0){
                                if (jarOtherProtocol.getJarTemperature()<jarTemperature){
                                if (jarOtherProtocol.getJarTemperature()<jarTemperature && jarOtherProtocol.modeType == JarModeType.AUTO){
                                    break;
                                }
                            }
@@ -5176,7 +5190,7 @@
//                                    if (jarOtherProtocol == null) {
//                                        break;
//                                    }
                                    if (jarOtherProtocol.getJarTemperature()>jarTemperature){
                                    if (jarOtherProtocol.getJarTemperature()>jarTemperature || jarOtherProtocol.modeType != JarModeType.AUTO){
                                        log.info("{}号硫化罐查询设备温度过高,等待降温....先执行入罐任务!!!",jarOtherProtocol.getJarNo());
                                    } else {
                                        if (basJarMastService.getJarMastByJarIdCount(jarSlave.getId())>0){
@@ -5902,6 +5916,42 @@
                add(8);
            }});
            if (basJarMastList.isEmpty()){
                return false;
            }
            StaProtocol staProtocolEnd = new StaProtocol();
            staProtocolEnd.setAutoing(false);
            for (DevpSlave devp : slaveProperties.getDevp()) {
                if (devp.getId() == 1){
                    continue;
                }
                // 遍历入库口
                for (DevpSlave.Sta inSta : devp.getOutJarInSta()) {
                    if (jarSlave.getId() == 1 || jarSlave.getId() == 2){
                        if (inSta.getStaNo() == 627){
                            SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
                            StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo());
                            if (staProtocol == null) {
                                break;
                            }
                            staProtocolEnd = staProtocol;
                            break;
                        }
                    } else if (jarSlave.getId() == 3 || jarSlave.getId() == 4){
                        if (inSta.getStaNo() == 628){
                            SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
                            StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo());
                            if (staProtocol == null) {
                                break;
                            }
                            staProtocolEnd = staProtocol;
                            break;
                        }
                    }
                }
            }
            if (!staProtocolEnd.isAutoing() || staProtocolEnd.isLoading()){
                return false;
            }
            List<BasJarMast> basJarMastList10 = basJarMastService.getJarMastByJarIdAndStatusList(jarSlave.getId(), new ArrayList<Integer>() {{
@@ -8047,6 +8097,7 @@
//
//                    }
                    List<WrkMastExecute> wrkMastExecuteByWrkNoList = wrkMastExecuteService.getWrkMastExecuteByWrkNoList(steProtocol.getTaskNo().longValue());
                    steReturn:
                    for (WrkMastExecute wrkMastExecute : wrkMastExecuteByWrkNoList){
                        if (!Cools.isEmpty(wrkMastExecute)){
                            switch (wrkMastExecute.getIoType()){
@@ -8063,12 +8114,14 @@
                                                            wrkMastExecute.getSteId(), JSON.toJSONString(wrkMastExecute), JSON.toJSON(steProtocol),sign);
                                                }
//                                                Thread.sleep(500);
                                                return true;
//                                                return true;
                                                break steReturn;
                                            }
                                        }
                                        log.error("穿梭车Ste命令下发失败===>下发异常,jar号={},任务数据={},穿梭车数据={},sign={}",
                                                wrkMastExecute.getSteId(), JSON.toJSONString(wrkMastExecute), JSON.toJSONString(steProtocol),sign);
                                        return true;
//                                        log.error("穿梭车Ste命令下发失败===>下发异常,jar号={},任务数据={},穿梭车数据={},sign={}",
//                                                wrkMastExecute.getSteId(), JSON.toJSONString(wrkMastExecute), JSON.toJSONString(steProtocol),sign);
//                                      return true;
                                        break steReturn;
                                    }
                                case 5:
                                    if (wrkMastExecute.getWrkSts()==5){
@@ -8082,12 +8135,14 @@
                                                    log.error("穿梭车Ste命令下发失败===>更新wrkMastExecute失败,jar号={},任务数据={},穿梭车数据={},sign={}",
                                                            wrkMastExecute.getSteId(), JSON.toJSON(wrkMastExecute), JSON.toJSON(steProtocol),sign);
                                                }
                                                return true;
//                                              return true;
                                                break steReturn;
                                            }
                                        }
                                        log.error("穿梭车Ste命令下发失败===>下发异常,jar号={},任务数据={},穿梭车数据={},sign={}",
                                                wrkMastExecute.getSteId(), JSON.toJSON(wrkMastExecute), JSON.toJSON(steProtocol),sign);
                                        return true;
//                                        log.error("穿梭车Ste命令下发失败===>下发异常,jar号={},任务数据={},穿梭车数据={},sign={}",
//                                                wrkMastExecute.getSteId(), JSON.toJSON(wrkMastExecute), JSON.toJSON(steProtocol),sign);
//                                      return true;
                                        break steReturn;
                                    }
                                    continue;
                                case 7:
@@ -8105,12 +8160,14 @@
                                                    log.error("穿梭车Ste命令下发失败===>更新wrkMastExecute失败,jar号={},任务数据={},穿梭车数据={},sign={}",
                                                            wrkMastExecute.getSteId(), JSON.toJSON(wrkMastExecute), JSON.toJSON(steProtocol),sign);
                                                }
                                                return true;
//                                              return true;
                                                break steReturn;
                                            }
                                        }
                                        log.error("穿梭车Ste命令下发失败===>下发异常,jar号={},任务数据={},穿梭车数据={},sign={}",
                                                wrkMastExecute.getSteId(), JSON.toJSON(wrkMastExecute), JSON.toJSON(steProtocol),sign);
                                        return true;
//                                        log.error("穿梭车Ste命令下发失败===>下发异常,jar号={},任务数据={},穿梭车数据={},sign={}",
//                                                wrkMastExecute.getSteId(), JSON.toJSON(wrkMastExecute), JSON.toJSON(steProtocol),sign);
//                                      return true;
                                        break steReturn;
                                    }
                                    continue;
                                case 9:
@@ -8125,17 +8182,17 @@
                                                    log.error("穿梭车Ste命令下发失败===>更新wrkMastExecute失败,jar号={},任务数据={},穿梭车数据={},sign={}",
                                                            wrkMastExecute.getSteId(), JSON.toJSON(wrkMastExecute), JSON.toJSON(steProtocol),sign);
                                                }
                                                return true;
//                                              return true;
                                                break steReturn;
                                            }
                                        }
                                        log.error("穿梭车Ste命令下发失败===>下发异常,jar号={},任务数据={},穿梭车数据={},sign={}",
                                                wrkMastExecute.getSteId(), JSON.toJSON(wrkMastExecute), JSON.toJSON(steProtocol),sign);
//                                        log.error("穿梭车Ste命令下发失败===>下发异常,jar号={},任务数据={},穿梭车数据={},sign={}",
//                                                wrkMastExecute.getSteId(), JSON.toJSON(wrkMastExecute), JSON.toJSON(steProtocol),sign);
                                        continue;
                                    }
                                default: continue;
                            }
                        }
                    }
                }
            }
@@ -8168,6 +8225,11 @@
                BasJar basJar = basJarMapper.selectById(jarProtocol.getJarNo());
                if (Cools.isEmpty(basJar)){
                    log.error("{}号硫化罐查询设备档案无信息!!!",jarProtocol.getJarNo());
                    continue;
                }
                if (jarProtocol.leftDoorOpen==1 || jarProtocol.leftDoorClose==1 ||
                        jarProtocol.rightDoorOpen==1 || jarProtocol.rightDoorClose==1
                ){
                    continue;
                }
                if (jarProtocol.getJarErr()==0 && (jarProtocol.getStatusType().equals(JarStatusType.WAITING1) || jarProtocol.getStatusType().equals(JarStatusType.MOVING))
@@ -8267,7 +8329,7 @@
                            log.error("硫化罐Jar命令下发失败,jar号={},任务数据={},硫化罐数据={},sign={}",
                                    execute.getJarId(), JSON.toJSON(execute), JSON.toJSON(jarProtocol),sign);
                        }
                        return true;
                        continue;
                    }
                    for (WrkMastExecute wrkMastExecute : wrkMastExecuteList){
                        if (wrkMastExecute.getIoType() == 2 || wrkMastExecute.getIoType() == 4){
@@ -8282,7 +8344,7 @@
                                        wrkMastExecute.getSteId(), JSON.toJSON(wrkMastExecute), JSON.toJSON(jarProtocol),sign);
                                return false;
                            }
                            return true;
                            continue;
                        }
                    }
                }
@@ -8858,6 +8920,9 @@
    public synchronized void stackingCompletionDriveTray2() {
        SiemensDevpThread devpThread = (SiemensDevpThread) SlaveConnection.get(SlaveType.Devp, 2);
        StaProtocol staProtocol = devpThread.getStation().get(518);
        if (Cools.isEmpty(staProtocol)) {
            return;
        }
        String barcode = staProtocol.getBarcode();
        if (!Cools.isEmpty(barcode)) {
            if ("NG".endsWith(barcode) || "NoRead".equals(barcode) || "00000000".equals(barcode) || !CodeDetectionUtil.barcodeDetection(barcode)) {