#
yxFwq
2024-11-28 0a7eeda078e85194992c4dbc543815ea977970a6
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;
@@ -896,40 +898,40 @@
                            if (!result) {
                                throw new CoolException("更新plc站点信息失败");
                            }
                        } else  if (jsonObject.getInteger("code").equals(700)){
                            SearchLocParam param2 = new SearchLocParam();
                            param2.setBarcode(barcode);
                            param2.setSourceStaNo(inSta.getStaNo());
                            param2.setLocType1(locTypeDto.getLocType1());
                            String response2 = new HttpHandler.Builder()
                                    .setUri(wmsUrl)
                                    .setPath("/rpc/pakin/yx/loc/v33")
                                    .setJson(JSON.toJSONString(param2))
                                    .build()
                                    .doPost();
                            JSONObject jsonObject2 = JSON.parseObject(response2);
                            if (jsonObject2.getInteger("code").equals(200)) {
                                log.info("大料箱自动组托成功!!");
                            } else {
                                log.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
                                LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed());
                                if (ledThread != null) {
                                    ErrMsg errMsg1 = new ErrMsg();
                                    errMsg1.setErrMsg("入库失败!站点号:"+inSta.getStaNo());
                                    errMsg1.setArea("1");
                                    MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errMsg1));
                                }
                            }
//                        } else  if (jsonObject.getInteger("code").equals(700)){
//                            SearchLocParam param2 = new SearchLocParam();
//                            param2.setBarcode(barcode);
//                            param2.setSourceStaNo(inSta.getStaNo());
//                            param2.setLocType1(locTypeDto.getLocType1());
//                            String response2 = new HttpHandler.Builder()
//                                    .setUri(wmsUrl)
//                                    .setPath("/rpc/pakin/yx/loc/v33")
//                                    .setJson(JSON.toJSONString(param2))
//                                    .build()
//                                    .doPost();
//                            JSONObject jsonObject2 = JSON.parseObject(response2);
//                            if (jsonObject2.getInteger("code").equals(200)) {
//                                log.info("大料箱自动组托成功!!");
//                            } else {
//                                log.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
//
//                                LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed());
//
//                                if (ledThread != null) {
//                                    ErrMsg errMsg1 = new ErrMsg();
//                                    errMsg1.setErrMsg("入库失败!站点号:"+inSta.getStaNo());
//                                    errMsg1.setArea("1");
//                                    MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errMsg1));
//                                }
//                            }
                        } else {
                            log.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
                            String msg = jsonObject.getString("msg");
                            LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed());
                            if (ledThread != null) {
                                ErrMsg errMsg1 = new ErrMsg();
                                errMsg1.setErrMsg("入库失败!站点号:"+inSta.getStaNo());
                                errMsg1.setErrMsg("入库失败!站点号:"+inSta.getStaNo()+"==》失败原因:"+msg);
                                errMsg1.setArea("1");
                                MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errMsg1));
                            }
@@ -2181,6 +2183,7 @@
                log.error("入库 ===>> 堆垛机站点在数据库不存在, 站点编号={}", crnStn.getStaNoOther());
                continue;
            }
            boolean signStanOther81 = false;
            if (staProtocolOther.getWorkNo()!=0){
                WrkMast wrkMastOther = wrkMastMapper.selectPakInStep3(staProtocolOther.getWorkNo());
                if (Cools.isEmpty(wrkMastOther)){
@@ -2282,29 +2285,33 @@
                            return;
                        }
                    }
                    return;
                }
                return;
                signStanOther81 = true;
                crnStation=2;
            }
            StaProtocol staProtocolOther1 = devpThread.getStation().get(crnStn.getStaNoOther1());
            if (staProtocolOther1 == null) {
                continue;
            } else {
                staProtocolOther1 = staProtocolOther1.clone();
            }
            if (!signStanOther81){
                StaProtocol staProtocolOther1 = devpThread.getStation().get(crnStn.getStaNoOther1());
                if (staProtocolOther1 == null) {
                    continue;
                } else {
                    staProtocolOther1 = staProtocolOther1.clone();
                }
            if (staProtocolOther1.isAutoing() && staProtocolOther1.getWorkNo()!=0){
                return;
            }
                if (staProtocolOther1.isAutoing() || staProtocolOther1.getWorkNo()!=0){
                    return;
                }
            StaProtocol staProtocolOther2 = devpThread.getStation().get(crnStn.getStaNoOther2());
            if (staProtocolOther2 == null) {
                continue;
            } else {
                staProtocolOther2 = staProtocolOther2.clone();
            }
            if (staProtocolOther2.isAutoing() && staProtocolOther2.getWorkNo()!=0){
                return;
                StaProtocol staProtocolOther2 = devpThread.getStation().get(crnStn.getStaNoOther2());
                if (staProtocolOther2 == null) {
                    continue;
                } else {
                    staProtocolOther2 = staProtocolOther2.clone();
                }
                if (staProtocolOther2.isAutoing() || staProtocolOther2.getWorkNo()!=0){
                    return;
                }
            }
            crnStation = 2;
            // 命令下发区 --------------------------------------------------------------------------
@@ -3098,6 +3105,10 @@
            if (wrkMast == null) {
                continue;
            }
//            if (wrkMast.getStaNoSign().equals(signBigTurn)){
//                continue;
//            }
            crnStation = crnStation1;
@@ -3112,16 +3123,30 @@
                continue;
            }
            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){
            if (wrkMast.booleanStaNoSign()){
                RgvOneSign rgvOneSign = rgvOneSignMapper.selectOneSign("LineUp"+wrkMast.getStaNo());
                if (Cools.isEmpty(rgvOneSign)){
                    continue;
                }
                DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, 1);
                StaProtocol staProtocolEnt = devpThread.getStation().get(212);
                if (staProtocolEnt.isLoading() || staProtocolEnt.getWorkNo()!=0){
                if (rgvOneSign.getRgvOneSign()>=2){
                    continue;
                }
//                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(wrkMast.getStaNoBying());
//                if (staProtocolEnt.isLoading() || staProtocolEnt.getWorkNo()!=0){
//                    continue;
//                }
            }
            // 工作档状态判断
@@ -3342,6 +3367,10 @@
//                }
            }
        }
//        signBigTurn++;
//        if (signBigTurn > 2){
//            signBigTurn = 0;
//        }
    }
@@ -5125,7 +5154,7 @@
                            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;
                            }
@@ -5216,7 +5245,7 @@
            if (jarProtocol.modeType != JarModeType.AUTO){
                return false;
            }
            if (jarProtocol.statusType .equals(JarStatusType.SOS)){
            if (jarProtocol.statusType .equals(JarStatusType.SOS) || jarProtocol.statusType .equals(JarStatusType.SOS2)){
                log.error("{}号硫化罐查询设备正在硫化中,任务异常!!!",jarProtocol.getJarNo());
                return false;
            }
@@ -5246,7 +5275,7 @@
            //自动、空闲、右门关闭、   Other左门关闭
            if (jarProtocol.isAutoing() && jarProtocol.jarErr==0
                    && jarProtocol.leftDoorOpen==0  && jarProtocol.leftDoorClose==0 && jarProtocol.rightDoorOpen==0  && jarProtocol.rightDoorClose==0){
                if (jarProtocol.statusType != JarStatusType.SOS){
                if (jarProtocol.statusType != JarStatusType.SOS && jarProtocol.statusType != JarStatusType.SOS2){
                    log.error("Jar任务创建===》执行===>行={}",4537);
                    BasJarMast basJarMast = new BasJarMast(basJar, wrkMast, jarLocDigit);
                    basJarMast.setJarEnterStaNo(staNo);//入硫化罐站点
@@ -5595,7 +5624,7 @@
                        if (jarProtocol.modeType != JarModeType.AUTO){
                            return false;
                        }
                        if (jarProtocol.statusType .equals(JarStatusType.WAITING2) || jarProtocol.statusType .equals(JarStatusType.SOS)){
                        if (jarProtocol.statusType .equals(JarStatusType.WAITING2) || jarProtocol.statusType .equals(JarStatusType.SOS) || jarProtocol.statusType .equals(JarStatusType.SOS2)){
                            return false;
                        }
                        if (jarProtocol.getJarTemperature()>jarTemperature){
@@ -5703,7 +5732,7 @@
                    return false;
                }
                if (jarProtocol.statusType .equals(JarStatusType.WAITING2) || jarProtocol.statusType .equals(JarStatusType.SOS)){
                if (jarProtocol.statusType .equals(JarStatusType.WAITING2) || jarProtocol.statusType .equals(JarStatusType.SOS) || jarProtocol.statusType .equals(JarStatusType.SOS2)){
                    log.error("{}号硫化罐查询设备正在硫化中,任务异常!!!",jarProtocol.getJarNo());
                    return false;
                }
@@ -5729,7 +5758,7 @@
                }
                //门作业  无
                if (jarProtocol.isAutoing() && jarProtocol.statusType != JarStatusType.SOS && jarProtocol.jarErr==0
                if (jarProtocol.isAutoing() && jarProtocol.statusType != JarStatusType.SOS && jarProtocol.statusType!= JarStatusType.SOS2 && jarProtocol.jarErr==0
                        && jarProtocol.isRightDoor() && jarProtocol.isLeftDoor()
                        && jarProtocol.leftDoorOpen==0  && jarProtocol.leftDoorClose==0 && jarProtocol.rightDoorOpen==0  && jarProtocol.rightDoorClose==0){
                    //关进料门
@@ -5792,7 +5821,7 @@
                    return false;
                }
                if (jarProtocol.statusType .equals(JarStatusType.SOS)){
                if (jarProtocol.statusType .equals(JarStatusType.SOS) || jarProtocol.statusType .equals(JarStatusType.SOS2)){
                    log.error("{}号硫化罐查询设备正在硫化中,任务异常!!!",jarProtocol.getJarNo());
                    return false;
                }
@@ -5822,7 +5851,7 @@
                        log.error("JarWrkMastExecute任务创建===>执行异常===》异常数据:BasJar:"+ JSON.toJSONString(basJar)+";BasJarMast:"+JSON.toJSONString(basJarMastSign));
                    }
                    return true;
                } else if (jarProtocol.isAutoing() && jarProtocol.statusType != JarStatusType.SOS
                } else if (jarProtocol.isAutoing() && jarProtocol.statusType != JarStatusType.SOS && jarProtocol.statusType != JarStatusType.SOS2
                        && jarProtocol.statusType != JarStatusType.WAITING2 && jarProtocol.jarErr==0
                            && jarProtocol.isLeftDoor() && jarProtocol.isRightDoor()
                            && jarProtocol.leftDoorOpen==0  && jarProtocol.leftDoorClose==0 && jarProtocol.rightDoorOpen==0  && jarProtocol.rightDoorClose==0){
@@ -5899,7 +5928,7 @@
                    return false;
                }
                if (jarProtocol.statusType .equals(JarStatusType.SOS)){
                if (jarProtocol.statusType .equals(JarStatusType.SOS) || jarProtocol.statusType .equals(JarStatusType.SOS2)){
                    log.error("{}号硫化罐查询设备正在硫化中,任务异常!!!",jarProtocol.getJarNo());
                    return false;
                }
@@ -6467,7 +6496,7 @@
            if (jarProtocol.modeType != JarModeType.AUTO){
                return false;
            }
            if (jarProtocol.statusType .equals(JarStatusType.SOS)){
            if (jarProtocol.statusType .equals(JarStatusType.SOS) || jarProtocol.statusType .equals(JarStatusType.SOS2)){
                log.error("{}号硫化罐查询设备正在硫化中,任务异常!!!",jarProtocol.getJarNo());
                return false;
            }
@@ -6595,7 +6624,7 @@
            if (jarProtocol.modeType != JarModeType.AUTO){
                return false;
            }
            if (jarProtocol.statusType .equals(JarStatusType.WAITING2) || jarProtocol.statusType .equals(JarStatusType.SOS)){
            if (jarProtocol.statusType .equals(JarStatusType.WAITING2) || jarProtocol.statusType .equals(JarStatusType.SOS) || jarProtocol.statusType .equals(JarStatusType.SOS2)){
                log.error("{}号硫化罐查询设备正在硫化中,任务异常!!!",jarProtocol.getJarNo());
                return false;
            }
@@ -6723,7 +6752,7 @@
            if (jarProtocol.modeType != JarModeType.AUTO){
                return false;
            }
            if (jarProtocol.statusType .equals(JarStatusType.WAITING2) || jarProtocol.statusType .equals(JarStatusType.SOS)){
            if (jarProtocol.statusType .equals(JarStatusType.WAITING2) || jarProtocol.statusType .equals(JarStatusType.SOS) || jarProtocol.statusType .equals(JarStatusType.SOS2)){
                log.error("{}号硫化罐查询设备正在硫化中,任务异常!!!",jarProtocol.getJarNo());
                return false;
            }
@@ -6839,7 +6868,7 @@
            if (jarProtocol.modeType != JarModeType.AUTO){
                return false;
            }
            if (jarProtocol.statusType .equals(JarStatusType.WAITING2) || jarProtocol.statusType .equals(JarStatusType.SOS)){
            if (jarProtocol.statusType .equals(JarStatusType.WAITING2) || jarProtocol.statusType .equals(JarStatusType.SOS) || jarProtocol.statusType .equals(JarStatusType.SOS2)){
                log.error("{}号硫化罐查询设备正在硫化中,任务异常!!!",jarProtocol.getJarNo());
                return false;
            }
@@ -6955,7 +6984,7 @@
            if (jarProtocol.modeType != JarModeType.AUTO){
                return false;
            }
            if (jarProtocol.statusType .equals(JarStatusType.SOS)){
            if (jarProtocol.statusType .equals(JarStatusType.SOS) || jarProtocol.statusType .equals(JarStatusType.SOS2)){
                log.error("{}号硫化罐查询设备正在硫化中,任务异常!!!",jarProtocol.getJarNo());
                return false;
            }
@@ -7091,7 +7120,7 @@
                return false;
            }
            if (jarProtocol.statusType .equals(JarStatusType.SOS)){
            if (jarProtocol.statusType .equals(JarStatusType.SOS) || jarProtocol.statusType .equals(JarStatusType.SOS2)){
                log.error("{}号硫化罐查询设备正在硫化中,任务异常!!!",jarProtocol.getJarNo());
                return false;
            }
@@ -7563,7 +7592,7 @@
                return false;
            }
            if (jarProtocol.statusType .equals(JarStatusType.SOS)){
            if (jarProtocol.statusType .equals(JarStatusType.SOS) || jarProtocol.statusType .equals(JarStatusType.SOS2)){
                log.error("{}号硫化罐查询设备正在硫化中,任务异常!!!",jarProtocol.getJarNo());
                return false;
            }
@@ -7615,7 +7644,7 @@
                    continue;
                }
                if (jarProtocolOther.statusType .equals(JarStatusType.SOS)){
                if (jarProtocolOther.statusType .equals(JarStatusType.SOS)  || jarProtocol.statusType .equals(JarStatusType.SOS2)){
//                    log.error("{}号硫化罐查询设备正在硫化中,任务异常!!!",jarProtocol.getJarNo());
                    continue;
                }
@@ -7893,26 +7922,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;
                    }
@@ -8455,6 +8476,9 @@
                        add(5);
                        add(11);
                        add(17);
                        add(99);
                        add(100);
                        add(999);
                    }});
                    if(!basJarMastList.isEmpty()){
                        continue;
@@ -8505,7 +8529,7 @@
                            if (jarProtocol.modeType != JarModeType.AUTO){
                                continue;
                            }
                            if (jarProtocol.statusType .equals(JarStatusType.SOS)){
                            if (jarProtocol.statusType .equals(JarStatusType.SOS) || jarProtocol.statusType .equals(JarStatusType.SOS2)){
                                continue;
                            }
                            if (jarProtocol.getJarTemperature()>jarTemperature){
@@ -8569,6 +8593,9 @@
                        add(5);
                        add(11);
                        add(17);
                        add(99);
                        add(100);
                        add(999);
                    }});
                    if(basJarMastList.isEmpty()){
                        if (wrkMastExecuteService.selectNoStartCharge(steSlave.getId())==0){
@@ -8593,7 +8620,7 @@
                                        if (jarProtocol.modeType != JarModeType.AUTO){
                                            continue;
                                        }
                                        if (jarProtocol.statusType .equals(JarStatusType.SOS)){
                                        if (jarProtocol.statusType .equals(JarStatusType.SOS) || jarProtocol.statusType .equals(JarStatusType.SOS2)){
                                            continue;
                                        }
                                        if (jarProtocol.getJarTemperature()>jarTemperature){
@@ -8637,6 +8664,11 @@
                        if (!jarSteTake(wrkMastExecuteByCharge,SteLocaType.POINT20.id,SteLocaType.POINT20.id,SteTaskModeType.CLOSE_CHARGE,true,wrkMastExecuteByCharge.getJarId())){
                            log.error("穿梭板Ste命令下发失败,ste号={},任务数据={}",
                                    wrkMastExecuteByCharge.getSteId(), JSON.toJSONString(wrkMastExecuteByCharge));
                        }
                        try{
                            Thread.sleep(1000);
                        } catch (Exception e){
                        }
                        wrkMastExecuteByCharge.setWrkType(2);
                        wrkMastExecuteByCharge.setWrkSts(100);
@@ -8696,36 +8728,34 @@
            }
        }
        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){
        }
//        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){ }
    }
@@ -8810,7 +8840,7 @@
                if (jarProtocol.modeType != JarModeType.AUTO){
                    continue;
                }
                if (jarProtocol.statusType .equals(JarStatusType.SOS)){
                if (jarProtocol.statusType .equals(JarStatusType.SOS) || jarProtocol.statusType .equals(JarStatusType.SOS2)){
                    continue;
                }
                if (jarProtocol.getJarTemperature()>jarTemperature){