#
yxFwq
2024-11-19 fe198a9143ad5a6840f664a2f6c2cfa1beff0e57
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -61,6 +61,8 @@
//    private static final Integer jarMaxLoc1 = 7;
    private static  Integer jarMaxLoc = 0;
    private static  Integer signBigTurn = 0;
    private static  Integer signSmallTurn = 0;
    private static final Float jarTemperature = 50F;
    @Autowired
    private CommonService commonService;
@@ -3098,7 +3100,9 @@
            if (wrkMast == null) {
                continue;
            }
            if (wrkMast.getStaNoSign().equals(signBigTurn)){
                continue;
            }
            crnStation = crnStation1;
            CrnSlave.CrnStn crnStn = null;
@@ -3112,7 +3116,18 @@
                continue;
            }
            if (wrkMast.getStaNo()>300){
            if (wrkMast.getStaNo()>309){
                int wrkCount = wrkMastMapper.selectCount(new EntityWrapper<WrkMast>().eq("io_type", 110).gt("sta_no", 309).lt("sta_no", 314).gt("wrk_sts",11L));
                if (wrkCount>=12){
                    continue;
                }
                RgvOneSign bigTurn = rgvOneSignMapper.selectOneSign("bigTurn");
                if (Cools.isEmpty(bigTurn)){
                    continue;
                }
                if (bigTurn.getRgvOneSign()>13){
                    continue;
                }
                DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, 1);
                StaProtocol staProtocolEnt = devpThread.getStation().get(212);
                if (staProtocolEnt.isLoading() || staProtocolEnt.getWorkNo()!=0){
@@ -3337,6 +3352,10 @@
//                    }
//                }
            }
        }
        signBigTurn++;
        if (signBigTurn > 2){
            signBigTurn = 0;
        }
    }
@@ -5116,16 +5135,17 @@
                                break;
                            }
                            BasJar basJar = basJarMapper.selectById(jarSlave.getId());
                            BasJar basJarOther = basJarMapper.selectById(jarSlave.getJarOtherId());
                            jarMaxLoc = basJar.getJarCount();
                            if (jarMaxLoc == 0) {
                            if (jarMaxLoc == 0 || basJarOther.getJarCount() == 0) {
                                break;
                            }
                            int count = basJarMastService.selectCount(new EntityWrapper<BasJarMast>().eq("jar_regin", basJar.getRegion()).lt("status", 17).gt("status", 11));
                            int count = basJarMastService.selectCount(new EntityWrapper<BasJarMast>().eq("jar_regin", basJar.getRegion()).lt("status", 17).gt("status", 6));
                            if (count>0){
                                break;
                            }
                            if (basJarMastService.selectJarMastOperation(jarSlave.getJarOtherId(),3)!=0){
                                if (basJarMastService.selectJarMastOperation(jarSlave.getJarOtherId(), 3).equals(jarMaxLoc)){
                                if (basJarMastService.selectJarMastOperation(jarSlave.getJarOtherId(), 3).equals(basJarOther.getJarCount())){
                                    JarThread jarOtherThread = (JarThread) SlaveConnection.get(SlaveType.Jar, jarSlave.getJarOtherId());
                                    JarProtocol jarOtherProtocol = jarOtherThread.getJarProtocol();
                                    if (jarOtherProtocol == null) {
@@ -5329,11 +5349,11 @@
                case 3:
                case 4:
                    signExecute = jarWrkMastExecuteGenerateJar(signExecute,sign);//硫化罐任务
//                case 5:
//                    signExecute = jarWrkMastExecuteGenerateBurial(signExecute, sign);//冷却槽取输送线
                default:
//                    jarWrkMastExecuteGenerateSte(signExecute,sign);//小车移动
                case 5:
                    signExecute = jarWrkMastExecuteGenerateBurial(signExecute, sign);//冷却槽取输送线
                default:
                    jarWrkMastExecuteGenerateSte(signExecute,sign);//小车移动
//                    signExecute = jarWrkMastExecuteGenerateBurial(signExecute, sign);//冷却槽取输送线
            }
            if (!signExecute[0] && !signExecute[1]){
@@ -5458,13 +5478,13 @@
                }
                //门作业  无
                //自动、空闲、右门关闭、   Other左门关闭
                if (jarProtocol.isAutoing() && jarProtocol.jarErr==0
                        && jarProtocol.leftDoorOpen==0  && jarProtocol.leftDoorClose==0 && jarProtocol.rightDoorOpen==0  && jarProtocol.rightDoorClose==0){
                if (jarProtocol.isAutoing() && jarProtocol.jarErr==0){
                    if (jarWrkMastExecuteGenerate5(jarSlave,sign)){
                        signExecute[jarSlave.getId()-5] = true;
                        return signExecute;
                        //冷却完成上输送线
                    }
                    continue;
                }
            } catch (Exception e){
                log.error("{}号硫化罐JarWrkMastExecute任务创建异常,异常原因={}",jarSlave.getId(),e.getMessage());
@@ -5473,65 +5493,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;
////                    }
//
//                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;
//                            }
    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;
//                    }
//                }
//            } catch (Exception e){
//                log.error("{}号硫化罐JarWrkMastExecute任务创建异常,异常原因={}",jarSlave.getId(),e.getMessage());
//            }
//        }
//        return signExecute;
//    }
                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;
    }
    /**
     *  JarWrkMastExecute任务创建   //完成
@@ -5756,11 +5776,6 @@
            List<BasJarMast> basJarMastList = basJarMastService.getJarMastByJarIdAndStatusList(jarSlave.getId(), new ArrayList<Integer>() {{
                add(6);
            }});
//            if (basJarMastService.selectJarMastOperation(jarSlave.getJarOtherId(),5)!=0
//                    && basJarMastService.selectJarMastOperation(jarSlave.getJarOtherId(),5)!=jarMaxLoc
//                    && basJarMastService.selectJarMastOperation(jarSlave.getJarOtherId(),5)!=jarMaxLoc*2){
//                return false;
//            }
            if (basJarMastList.isEmpty()){
                return false;
            }
@@ -5822,6 +5837,15 @@
                        log.error("JarWrkMastExecute任务创建===>执行异常===》异常数据:BasJar:"+ JSON.toJSONString(basJar)+";BasJarMast:"+JSON.toJSONString(basJarMastSign));
                    }
                    return true;
                } else if (jarProtocol.isAutoing() && jarProtocol.statusType != JarStatusType.SOS
                        && jarProtocol.statusType != JarStatusType.WAITING2 && jarProtocol.jarErr==0
                            && jarProtocol.isLeftDoor() && jarProtocol.isRightDoor()
                            && jarProtocol.leftDoorOpen==0  && jarProtocol.leftDoorClose==0 && jarProtocol.rightDoorOpen==0  && jarProtocol.rightDoorClose==0){
                        Integer integer = basJarMastService.updateStatus(jarProtocol.getJarNo(), 6, 8);
                        if (basJarMastList.size()!=integer){
                            log.error("{}号硫化罐硫化完成后开门完成修改硫化档案状态结果数量不一致!!!查询资料数量={},更新返回数量={}",jarProtocol.getJarNo(),basJarMastList.size(),integer);
                        }
                        return true;
                }
                return false;
            } else {
@@ -5908,7 +5932,24 @@
                if (basJarMastList10.size()==jarMaxLoc){
                    return false;
                }
                if (basJarMastService.selectJarMastOperation(jarSlave.getJarOtherId(),4)!=0 && !basJarMastService.selectJarMastOperation(jarSlave.getJarOtherId(), 4).equals(jarMaxLoc)){
                BasJar basJarOther = basJarMapper.selectById(jarSlave.getJarOtherId());
                if (Cools.isEmpty(basJarOther)){
                    log.error("{}号硫化罐查询设备档案无信息!!!",jarSlave.getJarOtherId());
                    return false;
                }
                if (basJarOther.getJarCount() == 0) {
                    return false;
                }
                List<BasJarMast> basJarMastListOther = basJarMastService.getJarMastByJarIdAndStatusList(jarSlave.getJarOtherId(), new ArrayList<Integer>() {{
                    add(8);
                }});
                if (!basJarMastListOther.isEmpty() && basJarMastListOther.size() < basJarOther.getJarCount()){
                    return false;
                }
                if (basJarMastService.selectJarMastOperation(jarSlave.getJarOtherId(),4)!=0 && !basJarMastService.selectJarMastOperation(jarSlave.getJarOtherId(), 4).equals(basJarOther.getJarCount() )){
                    return false;
                }
@@ -7867,26 +7908,18 @@
        try{
            switch (sign){
                case 1:
                case 5:
                case 9:
                    if (jarWrkMastExecuteGenerateSteComplete(sign)){
                        break;
                    }
                case 2:
                case 6:
                case 10:
                    if (jarWrkMastExecuteGenerateJarComplete(sign)){
                        break;
                    }
                case 3:
                case 7:
                case 11:
                    if (jarWrkMastExecuteGenerateRgvComplete1(sign)){
                        break;
                    }
                case 4:
                case 8:
                case 12:
                    if (jarWrkMastExecuteGenerateRgvComplete2(sign)){
                        break;
                    }
@@ -8099,7 +8132,7 @@
                        && (jarProtocol.leftDoorClose==2  || jarProtocol.rightDoorClose==2)){
                    if (jarProtocol.getJarTemperature()>jarTemperature){
                        log.error("{}号硫化罐查询设备温度过高,等待降温....!!!",jarProtocol.getJarNo());
                        return false;
                        continue;
                    }
                    WrkMastExecute wrkMastExecuteSou = new WrkMastExecute();
                    wrkMastExecuteSou.setWrkSts(3);
@@ -8670,13 +8703,44 @@
            }
        }
        try{
            for (int idi = 1;idi<5;idi++){
                LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, idi);
                if (ledThread != null) {
                    ErrMsg errMsg1 = new ErrMsg();
                    errMsg1.setErrMsg("测试:"+idi);
                    errMsg1.setArea("1");
                    MessageQueue.offer(SlaveType.Led, idi, new Task(5, errMsg1));
                } try {
                    Thread.sleep(500);
                } catch (Exception e){
                }
            }
            LedThread ledThread3 = (LedThread) SlaveConnection.get(SlaveType.Led, 3);
            if (ledThread3 != null) {
                ErrMsg errMsg1 = new ErrMsg();
                errMsg1.setErrMsg("测试测试测试测试测试测试测试测试测试测试测试测试测试:"+3);
                errMsg1.setArea("1");
                MessageQueue.offer(SlaveType.Led, 3, new Task(5, errMsg1));
            } try {
                Thread.sleep(500);
            } catch (Exception e){
            }
        } catch (Exception e){
        }
    }
    public synchronized Integer jarGetStartStaNo(Integer staNo) {
        try {
            int[] jarNos=new int[]{3,1,4,2};//(607分配硫化罐)
            ArrayList<Integer> staNos = new ArrayList<Integer>() {{
                add(607);add(608);add(609);add(610);add(611);add(612);
                add(608);add(609);add(610);add(611);add(612);
                add(613);add(614);add(615);add(616);add(617);add(618);
                add(619);add(620);add(621);add(622);
            }};
@@ -8784,7 +8848,7 @@
                    DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, 2);
                    StaProtocol staProtocolEnt = devpThread.getStation().get(staNoEnt);
                    if (staProtocolEnt == null || (staProtocolEnt.isLoading() && staProtocolEnt.getWorkNo()==0)){
                        log.error("站点异常,计数加一,站点号:"+staNoEnt);
//                        log.error("站点异常,计数加一,站点号:"+staNoEnt);
                        count++;
                    } else if (staProtocolEnt != null && staProtocolEnt.getWorkNo()!=0 && !wrkNoList.contains(staProtocolEnt.getWorkNo())){
                        if (staProtocolEnt.getStaNo().equals(basJar.getEntStaNo$())){