#
yxFwq
2024-10-24 e597fc1db67c560adecbd8d1e37d13c8f5a50fe3
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;
@@ -139,7 +140,7 @@
                if (!Cools.isEmpty(barcode)) {
//                    log.info("{}号条码扫描器检测条码信息:{}", inSta.getBarcode(), barcode);
                    if ("NG".endsWith(barcode) || "NoRead".equals(barcode) || !CodeDetectionUtil.barcodeDetection(barcode)) {
                    if ("00000000".endsWith(barcode) || "NG".endsWith(barcode) || "NoRead".equals(barcode) || !CodeDetectionUtil.barcodeDetection(barcode)) {
                        continue;
                    }
                } else {
@@ -235,7 +236,7 @@
                        staProtocol.setWorkNo(wrkMast.getWrkNo());
                        staProtocol.setStaNo(wrkMast.getStaNo());
                        devpThread.setPakMk(staProtocol.getSiteId(), false);
                        devpThread.setPakMk(staProtocol.getSiteId(), false,238);
                        boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                        if (!result) {
                            throw new CoolException("更新plc站点信息失败");
@@ -280,7 +281,7 @@
                                staProtocol.setStaNo(dto.getRgvSstaNo());
                            }
                            devpThread.setPakMk(staProtocol.getSiteId(), false);
                            devpThread.setPakMk(staProtocol.getSiteId(), false,283);
                            boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                            if (!result) {
                                throw new CoolException("更新plc站点信息失败");
@@ -323,7 +324,7 @@
                if (!Cools.isEmpty(barcode)) {
//                    log.info("{}号条码扫描器检测条码信息:{}", inSta.getBarcode(), barcode);
                    if ("NG".endsWith(barcode) || "NoRead".equals(barcode) || !CodeDetectionUtil.barcodeDetection(barcode)) {
                    if ("00000000".endsWith(barcode) || "NG".endsWith(barcode) || "NoRead".equals(barcode) || !CodeDetectionUtil.barcodeDetection(barcode)) {
                        continue;
                    }
                } else {
@@ -419,7 +420,7 @@
                        staProtocol.setWorkNo(wrkMast.getWrkNo());
                        staProtocol.setStaNo(wrkMast.getStaNo());
                        devpThread.setPakMk(staProtocol.getSiteId(), false);
                        devpThread.setPakMk(staProtocol.getSiteId(), false,422);
                        boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                        if (!result) {
                            throw new CoolException("更新plc站点信息失败");
@@ -464,7 +465,7 @@
                                staProtocol.setStaNo(dto.getRgvSstaNo());
                            }
                            devpThread.setPakMk(staProtocol.getSiteId(), false);
                            devpThread.setPakMk(staProtocol.getSiteId(), false,467);
                            boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                            if (!result) {
                                throw new CoolException("更新plc站点信息失败");
@@ -538,7 +539,7 @@
                if (!Cools.isEmpty(barcode)) {
//                    log.info("{}号条码扫描器检测条码信息:{}", inSta.getBarcode(), barcode);
                    if ("NG".endsWith(barcode) || "NoRead".equals(barcode) || !CodeDetectionUtil.barcodeDetection(barcode)) {
                    if ("00000000".endsWith(barcode) || "NG".endsWith(barcode) || "NoRead".equals(barcode) || !CodeDetectionUtil.barcodeDetection(barcode)) {
                        continue;
                    }
                } else {
@@ -634,7 +635,7 @@
                        staProtocol.setWorkNo(wrkMast111.getWrkNo());
                        staProtocol.setStaNo(wrkMast111.getStaNo());
                        devpThread.setPakMk(staProtocol.getSiteId(), false);
                        devpThread.setPakMk(staProtocol.getSiteId(), false,637);
                        boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                        if (!result) {
                            if (ledThread != null) {
@@ -692,7 +693,7 @@
                                staProtocol.setStaNo(dto.getRgvSstaNo());
                            }
                            devpThread.setPakMk(staProtocol.getSiteId(), false);
                            devpThread.setPakMk(staProtocol.getSiteId(), false,695);
                            boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                            if (!result) {
                                if (ledThread != null) {
@@ -738,19 +739,7 @@
                if (!Cools.isEmpty(barcode)) {
//                    log.info("{}号条码扫描器检测条码信息:{}", inSta.getBarcode(), barcode);
                    if ("NG".endsWith(barcode) || "NoRead".equals(barcode) || !CodeDetectionUtil.barcodeDetection(barcode)) {
                        continue;
                    }
                    if ("00000000".equals(barcode)){
                        log.error(inSta+"站点,扫码失败,barcode:"+barcode);
                        // led 异常显示
                        LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed());
                        if (ledThread != null) {
                            ErrMsg errMsg1 = new ErrMsg();
                            errMsg1.setErrMsg(inSta+"站点,扫码失败,barcode:"+barcode);
                            errMsg1.setArea("1");
                            MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(5, errMsg1));
                        }
                    if ("NG".endsWith(barcode) || "NoRead".equals(barcode) || "00000000".equals(barcode) || !CodeDetectionUtil.barcodeDetection(barcode)) {
                        continue;
                    }
                } else {
@@ -852,7 +841,8 @@
                        staProtocol.setWorkNo(wrkMast.getWrkNo());
                        staProtocol.setStaNo(wrkMast.getStaNo());
                        devpThread.setPakMk(staProtocol.getSiteId(), false);
                        devpThread.setPakMk(staProtocol.getSiteId(), false,843);
                        log.info("锁定标记flase===》N===》站点号:{},工作号:{},条码:{}",staProtocol.getSiteId(),staProtocol.getWorkNo(),barcode);
                        boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                        if (!result) {
                            if (ledThread != null) {
@@ -900,7 +890,8 @@
                                staProtocol.setStaNo(dto.getRgvSstaNo());
                            }
                            devpThread.setPakMk(staProtocol.getSiteId(), false);
                            devpThread.setPakMk(staProtocol.getSiteId(), false,892);
                            log.info("锁定标记flase===》N===》站点号:{},工作号:{},条码:{}",staProtocol.getStaNo(),staProtocol.getWorkNo(),barcode);
                            boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                            if (!result) {
                                throw new CoolException("更新plc站点信息失败");
@@ -995,7 +986,7 @@
                        staNo = 147;
                    }
                    staProtocol.setStaNo(staNo);
                    devpThread.setPakMk(staProtocol.getSiteId(), false);
                    devpThread.setPakMk(staProtocol.getSiteId(), false,988);
                    boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                    if (result) {
                        // 更新工作主档
@@ -1103,7 +1094,7 @@
                                    // 更新站点信息 且 下发plc命令
                                    staProtocol.setWorkNo(wrkMast.getWrkNo());
                                    staProtocol.setStaNo(dto.getStaNo());
                                    devpThread.setPakMk(staProtocol.getSiteId(), false);
                                    devpThread.setPakMk(staProtocol.getSiteId(), false,1096);
//                                    ledThread.errorReset();
                                    boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                                    if (!result) {
@@ -1218,7 +1209,7 @@
                                    // 更新站点信息 且 下发plc命令
                                    staProtocol.setWorkNo(wrkMast.getWrkNo());
                                    staProtocol.setStaNo(dto.getStaNo());
                                    devpThread.setPakMk(staProtocol.getSiteId(), false);
                                    devpThread.setPakMk(staProtocol.getSiteId(), false,1211);
//                                    ledThread.errorReset();
                                    boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                                    if (!result) {
@@ -2332,7 +2323,7 @@
            staProtocol.setWorkNo(wrkMast.getWrkNo());
            staProtocol.setStaNo(wrkMast.getStaNo());
            devpThread.setPakMk(staProtocol.getSiteId(), false);
            devpThread.setPakMk(staProtocol.getSiteId(), false,2325);
            if (!MessageQueue.offer(SlaveType.Devp, crnStn.getDevpPlcId(), new Task(99, crnCommand.getCrnNo()-2))) {
                log.error("输送线锁定命令下发失败,堆垛机号={},任务数据={}", wrkMast.getCrnNo(), crnCommand.getCrnNo()-2);
@@ -4094,7 +4085,7 @@
                            // 更新站点信息 且 下发plc命令
                            staProtocol.setWorkNo(dto.getWorkNo());
                            staProtocol.setStaNo(dto.getStaNo());
                            devpThread.setPakMk(staProtocol.getSiteId(), false);
                            devpThread.setPakMk(staProtocol.getSiteId(), false,4087);
                            boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                            if (!result) {
                                throw new CoolException("更新plc站点信息失败");
@@ -4157,7 +4148,7 @@
                            // 更新站点信息 且 下发plc命令
                            staProtocol.setWorkNo(dto.getWorkNo());
                            staProtocol.setStaNo(dto.getStaNo());
                            devpThread.setPakMk(staProtocol.getSiteId(), false);
                            devpThread.setPakMk(staProtocol.getSiteId(), false,4150);
                            boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                            if (!result) {
                                throw new CoolException("更新plc站点信息失败");
@@ -4220,7 +4211,7 @@
                            // 更新站点信息 且 下发plc命令
                            staProtocol.setWorkNo(dto.getWorkNo());
                            staProtocol.setStaNo(dto.getStaNo());
                            devpThread.setPakMk(staProtocol.getSiteId(), false);
                            devpThread.setPakMk(staProtocol.getSiteId(), false,4213);
                            boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                            if (!result) {
                                throw new CoolException("更新plc站点信息失败");
@@ -5117,12 +5108,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) {
@@ -5663,7 +5658,7 @@
            List<BasJarMast> basJarMastList = basJarMastService.getJarMastByJarIdAndStatusList(jarSlave.getId(), new ArrayList<Integer>() {{
                add(4);
            }});
            if (basJarMastList.size() != jarMaxLoc){
            if (basJarMastList.isEmpty()){
                return false;
            }
@@ -5706,8 +5701,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;
                }
@@ -5744,14 +5746,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)){
@@ -5793,6 +5795,13 @@
                    log.error("{}号硫化罐查询设备档案无信息!!!",jarProtocol.getJarNo());
                    return false;
                }
                jarMaxLoc = basJar.getJarCount();
                if (jarMaxLoc == 0) {
                    return false;
                }
                if (basJarMastList.size() != jarMaxLoc){
                    return false;
                }
                //门作业  无
                if (jarProtocol.isAutoing() && jarProtocol.statusType == JarStatusType.WAITING2 && jarProtocol.jarErr==0
@@ -5824,6 +5833,12 @@
            if (wrkMastExecuteService.getWrkMastExecuteByJarIdCount(jarSlave.getId())!=0){
                return false;
            }
            List<BasJarMast> basJarMastList1 = basJarMastService.getJarMastByJarIdAndStatusList(jarSlave.getJarOtherId(), new ArrayList<Integer>() {{
                add(0);add(1);add(2);add(3);
            }});
            if (!basJarMastList1.isEmpty()){
                return false;
            }
            List<BasJarMast> basJarMastList = basJarMastService.getJarMastByJarIdAndStatusList(jarSlave.getId(), new ArrayList<Integer>() {{
                add(8);
            }});
@@ -5833,12 +5848,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)){
@@ -5879,6 +5888,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;
                }
@@ -6039,7 +6059,7 @@
                return false;
            }
            if (steProtocol.getMode() != (short)1) {
                log.error(steNo + "号小车离线,无法操作");
//                log.error(steNo + "号小车离线,无法操作");
                return false;
            }
            if (steProtocol.getChargeStatus()!=0){
@@ -6094,7 +6114,7 @@
                return false;
            }
            if (steProtocol.getMode() != (short)1) {
                log.error(steNo + "号小车离线,无法操作");
//                log.error(steNo + "号小车离线,无法操作");
                return false;
            }
            if (steProtocol.getCharge()<31.0F && chargeSign){
@@ -8375,7 +8395,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());
@@ -8489,7 +8516,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;
                }
@@ -8650,6 +8684,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);
                }
@@ -8712,6 +8756,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);
@@ -8719,13 +8767,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());