自动化立体仓库 - WCS系统
*
lsh
2024-10-24 96bf3f238144416b09ff7c7c346f7d88b98214b8
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -59,7 +59,8 @@
//    private static final int[][] execute = new int[][]{{1,4},{2,4},{3,4},{4,4},{5,6},{6,6},{7,4},{8,4},{9,3},{10,4},{11,4}};
    private static final int[][] execute = new int[][]{{1,4},{2,4},{3,4},{4,4},{5,6},{6,6},{7,4},{8,4},{9,3},{10,4},{11,4}};
    private static final Integer jarMaxLoc = 7;
//    private static final Integer jarMaxLoc1 = 7;
    private static  Integer jarMaxLoc = 0;
    private static final Float jarTemperature = 50F;
    @Autowired
    private CommonService commonService;
@@ -3111,18 +3112,26 @@
                continue;
            }
            if (wrkMast.getStaNo()>300){
                DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, 1);
                StaProtocol staProtocolEnt = devpThread.getStation().get(212);
                if (staProtocolEnt.isLoading() || staProtocolEnt.getWorkNo()!=0){
                    continue;
                }
            }
            // 工作档状态判断
            if (wrkMast.getIoType() < 100 || wrkMast.getSourceStaNo() == null) {
                log.error("查询工作档数据不符合条件--入出类型/站点, 工作号={},源库位={},入出类型={}", wrkMast.getWrkNo(), wrkMast.getSourceLocNo(), wrkMast.getIoType());
                continue;
            }
            //退库模式跳过118、119出库任务
            if (wrkMast.getStaNo()==118 || wrkMast.getStaNo()==119){
                RgvOneSign rgvOneSign = rgvOneSignMapper.selectOneSign("oneSign");
                if (Cools.isEmpty(rgvOneSign) || rgvOneSign.getRgvOneSign()==1){
                    continue;
                }
            }
//            //退库模式跳过118、119出库任务
//            if (wrkMast.getStaNo()==118 || wrkMast.getStaNo()==119){
//                RgvOneSign rgvOneSign = rgvOneSignMapper.selectOneSign("oneSign");
//                if (Cools.isEmpty(rgvOneSign) || rgvOneSign.getRgvOneSign()==1){
//                    continue;
//                }
//            }
            // 获取源库位信息
            LocMast sourceSta = locMastService.selectById(wrkMast.getSourceLocNo());
            if (!sourceSta.getLocSts().equals("R") && !sourceSta.getLocSts().equals("P")) {
@@ -5107,12 +5116,16 @@
                                break;
                            }
                            BasJar basJar = basJarMapper.selectById(jarSlave.getId());
                            jarMaxLoc = basJar.getJarCount();
                            if (jarMaxLoc == 0) {
                                break;
                            }
                            int count = basJarMastService.selectCount(new EntityWrapper<BasJarMast>().eq("jar_regin", basJar.getRegion()).lt("status", 17).gt("status", 11));
                            if (count>0){
                                break;
                            }
                            if (basJarMastService.selectJarMastOperation(jarSlave.getJarOtherId(),3)!=0){
                                if (basJarMastService.selectJarMastOperation(jarSlave.getJarOtherId(),3)==7){
                                if (basJarMastService.selectJarMastOperation(jarSlave.getJarOtherId(), 3).equals(jarMaxLoc)){
                                    JarThread jarOtherThread = (JarThread) SlaveConnection.get(SlaveType.Jar, jarSlave.getJarOtherId());
                                    JarProtocol jarOtherProtocol = jarOtherThread.getJarProtocol();
                                    if (jarOtherProtocol == null) {
@@ -5316,10 +5329,12 @@
                case 3:
                case 4:
                    signExecute = jarWrkMastExecuteGenerateJar(signExecute,sign);//硫化罐任务
                case 5:
                    signExecute = jarWrkMastExecuteGenerateBurial(signExecute, sign);//冷却槽取输送线
//                case 5:
//                    signExecute = jarWrkMastExecuteGenerateBurial(signExecute, sign);//冷却槽取输送线
                default:
                    jarWrkMastExecuteGenerateSte(signExecute,sign);//小车移动
//                    jarWrkMastExecuteGenerateSte(signExecute,sign);//小车移动
                    signExecute = jarWrkMastExecuteGenerateBurial(signExecute, sign);//冷却槽取输送线
            }
            if (!signExecute[0] && !signExecute[1]){
                //Ste移动
@@ -5443,13 +5458,13 @@
                }
                //门作业  无
                //自动、空闲、右门关闭、   Other左门关闭
                if (jarProtocol.isAutoing() && jarProtocol.jarErr==0){
                if (jarProtocol.isAutoing() && jarProtocol.jarErr==0
                        && jarProtocol.leftDoorOpen==0  && jarProtocol.leftDoorClose==0 && jarProtocol.rightDoorOpen==0  && jarProtocol.rightDoorClose==0){
                    if (jarWrkMastExecuteGenerate5(jarSlave,sign)){
                        signExecute[jarSlave.getId()-5] = true;
                        return signExecute;
                        //冷却完成上输送线
                    }
                    continue;
                }
            } catch (Exception e){
                log.error("{}号硫化罐JarWrkMastExecute任务创建异常,异常原因={}",jarSlave.getId(),e.getMessage());
@@ -5458,65 +5473,65 @@
        return signExecute;
    }
    public synchronized boolean[] jarWrkMastExecuteGenerateSte(boolean[] signExecute,Integer sign) {
        for (JarSlave jarSlave : slaveProperties.getJar()) {
            if (jarSlave.getId()<5){
                continue;
            }
            try{
                if (signExecute[jarSlave.getId()-5]){
                    continue;
                }
                if (wrkMastExecuteService.getWrkMastExecuteByJarIdCount(jarSlave.getId())!=0){
                    continue;
                }
                // 获取硫化罐信息
                JarThread jarThread = (JarThread) SlaveConnection.get(SlaveType.Jar, jarSlave.getId());
                JarProtocol jarProtocol = jarThread.getJarProtocol();
                if (jarProtocol == null) {
                    continue;
                }
                if (jarProtocol.modeType != JarModeType.AUTO){
                    continue;
                }
                if (jarProtocol.getJarTemperature()>jarTemperature){
                    log.error("{}号硫化罐查询设备温度过高,等待降温....!!!",jarProtocol.getJarNo());
                    continue;
                }
                JarThread jarOtherThread = (JarThread) SlaveConnection.get(SlaveType.Jar, jarSlave.getJarOtherId());
                JarProtocol jarOtherProtocol = jarOtherThread.getJarProtocol();
                if (jarOtherProtocol == null) {
                    continue;
                }
//                    if (jarOtherProtocol.modeType != JarModeType.AUTO){
//                        continue;
//    public synchronized boolean[] jarWrkMastExecuteGenerateSte(boolean[] signExecute,Integer sign) {
//        for (JarSlave jarSlave : slaveProperties.getJar()) {
//            if (jarSlave.getId()<5){
//                continue;
//            }
//            try{
//                if (signExecute[jarSlave.getId()-5]){
//                    continue;
//                }
//                if (wrkMastExecuteService.getWrkMastExecuteByJarIdCount(jarSlave.getId())!=0){
//                    continue;
//                }
//
//                // 获取硫化罐信息
//                JarThread jarThread = (JarThread) SlaveConnection.get(SlaveType.Jar, jarSlave.getId());
//                JarProtocol jarProtocol = jarThread.getJarProtocol();
//                if (jarProtocol == null) {
//                    continue;
//                }
//                if (jarProtocol.modeType != JarModeType.AUTO){
//                    continue;
//                }
//                if (jarProtocol.getJarTemperature()>jarTemperature){
//                    log.error("{}号硫化罐查询设备温度过高,等待降温....!!!",jarProtocol.getJarNo());
//                    continue;
//                }
//
//                JarThread jarOtherThread = (JarThread) SlaveConnection.get(SlaveType.Jar, jarSlave.getJarOtherId());
//                JarProtocol jarOtherProtocol = jarOtherThread.getJarProtocol();
//                if (jarOtherProtocol == null) {
//                    continue;
//                }
////                    if (jarOtherProtocol.modeType != JarModeType.AUTO){
////                        continue;
////                    }
//
//                BasJar basJar = basJarMapper.selectById(jarProtocol.getJarNo());
//                if (Cools.isEmpty(basJar)){
//                    log.error("{}号硫化罐查询设备档案无信息!!!",jarProtocol.getJarNo());
//                    continue;
//                }
//                //门作业  无
//                //自动、空闲、右门关闭、   Other左门关闭
//                if (jarProtocol.isAutoing() && jarProtocol.jarErr==0
//                        && jarProtocol.leftDoorOpen==0  && jarProtocol.leftDoorClose==0 && jarProtocol.rightDoorOpen==0  && jarProtocol.rightDoorClose==0){
//                    switch (sign){
//                        case 5:
//                            if (jarWrkMastExecuteGenerate5(jarSlave,sign)){
//                                signExecute[jarSlave.getId()-5] = true;
//                                break;
//                            }
//                    }
                BasJar basJar = basJarMapper.selectById(jarProtocol.getJarNo());
                if (Cools.isEmpty(basJar)){
                    log.error("{}号硫化罐查询设备档案无信息!!!",jarProtocol.getJarNo());
                    continue;
                }
                //门作业  无
                //自动、空闲、右门关闭、   Other左门关闭
                if (jarProtocol.isAutoing() && jarProtocol.jarErr==0
                        && jarProtocol.leftDoorOpen==0  && jarProtocol.leftDoorClose==0 && jarProtocol.rightDoorOpen==0  && jarProtocol.rightDoorClose==0){
                    switch (sign){
                        case 5:
                            if (jarWrkMastExecuteGenerate5(jarSlave,sign)){
                                signExecute[jarSlave.getId()-5] = true;
                                break;//出硫化罐 ===》 入冷却槽
                            }
                    }
                }
            } catch (Exception e){
                log.error("{}号硫化罐JarWrkMastExecute任务创建异常,异常原因={}",jarSlave.getId(),e.getMessage());
            }
        }
        return signExecute;
    }
//                }
//            } catch (Exception e){
//                log.error("{}号硫化罐JarWrkMastExecute任务创建异常,异常原因={}",jarSlave.getId(),e.getMessage());
//            }
//        }
//        return signExecute;
//    }
    /**
     *  JarWrkMastExecute任务创建   //完成
@@ -5653,7 +5668,7 @@
            List<BasJarMast> basJarMastList = basJarMastService.getJarMastByJarIdAndStatusList(jarSlave.getId(), new ArrayList<Integer>() {{
                add(4);
            }});
            if (basJarMastList.size() != jarMaxLoc){
            if (basJarMastList.isEmpty()){
                return false;
            }
@@ -5696,8 +5711,15 @@
                    log.error("{}号硫化罐查询设备档案无信息!!!",jarProtocol.getJarNo());
                    return false;
                }
                if (!basJar.getJarCount().equals(jarMaxLoc)){
                    log.error("{}号硫化罐查询设备库存数异常!!!库存待入数:{}",jarProtocol.getJarNo(),basJar.getJarCount());
                jarMaxLoc = basJar.getJarCount();
                if (jarMaxLoc == 0) {
                    return false;
                }
//                if (!basJar.getJarCount().equals(jarMaxLoc)){
//                    log.error("{}号硫化罐查询设备库存数异常!!!库存待入数:{}",jarProtocol.getJarNo(),basJar.getJarCount());
//                    return false;
//                }
                if (basJarMastList.size() != jarMaxLoc){
                    return false;
                }
@@ -5734,14 +5756,14 @@
            List<BasJarMast> basJarMastList = basJarMastService.getJarMastByJarIdAndStatusList(jarSlave.getId(), new ArrayList<Integer>() {{
                add(6);
            }});
            if (basJarMastList.size() != jarMaxLoc){
                return false;
            }
//            if (basJarMastService.selectJarMastOperation(jarSlave.getJarOtherId(),5)!=0
//                    && basJarMastService.selectJarMastOperation(jarSlave.getJarOtherId(),5)!=7
//                    && basJarMastService.selectJarMastOperation(jarSlave.getJarOtherId(),5)!=14){
//                    && basJarMastService.selectJarMastOperation(jarSlave.getJarOtherId(),5)!=jarMaxLoc
//                    && basJarMastService.selectJarMastOperation(jarSlave.getJarOtherId(),5)!=jarMaxLoc*2){
//                return false;
//            }
            if (basJarMastList.isEmpty()){
                return false;
            }
            BasJarMast basJarMastSign = basJarMastList.get(0);
            if (Cools.isEmpty(basJarMastSign)){
@@ -5781,6 +5803,13 @@
                BasJar basJar = basJarMapper.selectById(jarProtocol.getJarNo());
                if (Cools.isEmpty(basJar)){
                    log.error("{}号硫化罐查询设备档案无信息!!!",jarProtocol.getJarNo());
                    return false;
                }
                jarMaxLoc = basJar.getJarCount();
                if (jarMaxLoc == 0) {
                    return false;
                }
                if (basJarMastList.size() != jarMaxLoc){
                    return false;
                }
@@ -5829,12 +5858,6 @@
            List<BasJarMast> basJarMastList10 = basJarMastService.getJarMastByJarIdAndStatusList(jarSlave.getId(), new ArrayList<Integer>() {{
                add(10);
            }});
            if (basJarMastList10.size()==jarMaxLoc){
                return false;
            }
            if (basJarMastService.selectJarMastOperation(jarSlave.getJarOtherId(),4)!=0 && basJarMastService.selectJarMastOperation(jarSlave.getJarOtherId(),4)!=7){
                return false;
            }
            BasJarMast jarMastByJarIdMin = basJarMastService.getJarMastByJarIdMin(jarSlave.getId(),8,8);
            if (Cools.isEmpty(jarMastByJarIdMin)){
@@ -5875,6 +5898,17 @@
                BasJar basJar = basJarMapper.selectById(jarProtocol.getJarNo());
                if (Cools.isEmpty(basJar)){
                    log.error("{}号硫化罐查询设备档案无信息!!!",jarProtocol.getJarNo());
                    return false;
                }
                jarMaxLoc = basJar.getJarCount();
                if (jarMaxLoc == 0) {
                    return false;
                }
                if (basJarMastList10.size()==jarMaxLoc){
                    return false;
                }
                if (basJarMastService.selectJarMastOperation(jarSlave.getJarOtherId(),4)!=0 && !basJarMastService.selectJarMastOperation(jarSlave.getJarOtherId(), 4).equals(jarMaxLoc)){
                    return false;
                }
@@ -8371,7 +8405,14 @@
                    continue;
                }
                SteProtocol steProtocol = steThread.getSteProtocol();
                if (steProtocol == null || steProtocol.getChargeStatus()!=0) {
                if (steProtocol == null) {
                    continue;
                }
                if (Cools.isEmpty(steProtocol.getChargeStatus())) {
                    log.error("{}号小车,充电状态信息异常,小车信息:{}",steProtocol.getSteNo(),steProtocol.toString());
                    continue;
                }
                if (steProtocol.getChargeStatus()!=0) {
                    continue;
                }
                WrkMastExecute wrkMastExecuteByCharge = wrkMastExecuteService.getWrkMastExecuteByCharge(steSlave.getId());
@@ -8485,7 +8526,14 @@
                    continue;
                }
                SteProtocol steProtocol = steThread.getSteProtocol();
                if (steProtocol == null || steProtocol.getChargeStatus()!=1) {
                if (steProtocol == null) {
                    continue;
                }
                if (Cools.isEmpty(steProtocol.getChargeStatus())) {
                    log.error("{}号小车,充电状态信息异常,小车信息:{}",steProtocol.getSteNo(),steProtocol.toString());
                    continue;
                }
                if (steProtocol.getChargeStatus()!=1) {
                    continue;
                }
@@ -8646,6 +8694,16 @@
                if (basJarMastList.isEmpty()){
                    continue;
                }
                BasJar basJar = basJarMapper.selectById(jarNo);
                if (Cools.isEmpty(basJar)){
                    log.error("{}号硫化罐查询设备档案无信息!!!",jarNo);
                    continue;
                }
                jarMaxLoc = basJar.getJarCount();
                if (jarMaxLoc == 0) {
                    continue;
                }
                if (basJarMastList.size()>0 && basJarMastList.size()<jarMaxLoc){
                    jarNoList.add(jarNo);
                }
@@ -8708,6 +8766,10 @@
                    log.error("{}号硫化罐查询设备档案无信息!!!",jarProtocol.getJarNo());
                    continue;
                }
                jarMaxLoc = basJar.getJarCount();
                if (jarMaxLoc == 0) {
                    continue;
                }
                List<BasJarMast> basJarMastList = basJarMastService.getJarMastByJarIdAndStatusList(jarNo, new ArrayList<Integer>() {{
                    add(0);
                    add(1);
@@ -8715,13 +8777,16 @@
                    add(3);
                    add(4);
                }});
                DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, 2);
                Integer count = basJarMastList.size();
                ArrayList<Integer> wrkNoList = new ArrayList<>();
                for (Integer staNoEnt : staNos){
                    DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, 2);
                    StaProtocol staProtocolEnt = devpThread.getStation().get(staNoEnt);
                    if (staProtocolEnt != null && staProtocolEnt.getWorkNo()!=0 && !wrkNoList.contains(staProtocolEnt.getWorkNo())){
                    if (staProtocolEnt == null || (staProtocolEnt.isLoading() && staProtocolEnt.getWorkNo()==0)){
                        log.error("站点异常,计数加一,站点号:"+staNoEnt);
                        count++;
                    } else if (staProtocolEnt != null && staProtocolEnt.getWorkNo()!=0 && !wrkNoList.contains(staProtocolEnt.getWorkNo())){
                        if (staProtocolEnt.getStaNo().equals(basJar.getEntStaNo$())){
                            count++;
                            wrkNoList.add(staProtocolEnt.getWorkNo());