自动化立体仓库 - WCS系统
whycq
2023-03-10 84b74dfb03ee81307e88b128d57d55cbbe47678e
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -113,9 +113,9 @@
                if((inSta.getStaNo().equals(101) || inSta.getStaNo().equals(104)) && ( "NoRead".equals(barcode) || Cools.isEmpty(barcode) )){
                    BarcodeThread barcodeThread1 = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, inSta.getBarcode1());
                    if (barcodeThread1 != null) {
                        continue;
                        barcode = barcodeThread1.getBarcode();
                    }
                    barcode = barcodeThread1.getBarcode();
                    if("NoRead".equals(barcode) || Cools.isEmpty(barcode)) {
                        BarcodeThread barcodeThread2 = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, inSta.getBarcode2());
                        if (barcodeThread2 != null) {
@@ -123,18 +123,21 @@
                        }
                    }
//                    if("NoRead".equals(barcode) || Cools.isEmpty(barcode)) {
//                        barcode = "";
//                        continue;
//                    }
                }
                if (!Cools.isEmpty(barcode) && !"NoRead".equals(barcode)) {
                if (!Cools.isEmpty(barcode)) {
                    log.info("{}号条码扫描器检测条码信息:{}", inSta.getBarcode(), barcode);
//                    if ("NG".endsWith(barcode) || "NoRead".equals(barcode)) {
//                        continue;
//                    }
                    if ("NG".endsWith(barcode) || "NoRead".equals(barcode)) {
                        continue;
                    }
                } else {
                    // led 异常显示
                    LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed());
                    if (ledThread != null) {
                        String errorMsg = "扫码失败,请重试";
                        MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg));
                    }
                    continue;
                }
@@ -193,11 +196,15 @@
//                    }
                    // 判断重复工作档
                    WrkMast wrkMast = wrkMastMapper.selectPakInStep1(inSta.getStaNo(), barcode);
                    if (wrkMast != null) {
                        log.error("工作档中已存在该站状态为( 2.设备上走 )的数据,工作号={}", wrkMast.getWrkNo());
                        continue;
                    WrkMast wrkMast = new WrkMast();
                    if (barcode.length() == 8) {
                        wrkMast = wrkMastMapper.selectPakInStep1(inSta.getStaNo(), barcode);
                        if (wrkMast != null) {
                            log.error("工作档中已存在该站状态为( 2.设备上走 )的数据,工作号={}", wrkMast.getWrkNo());
                            continue;
                        }
                    }
//                    // 获取入库通知档
//                    List<WaitPakin> waitPakins = waitPakinMapper.selectList(new EntityWrapper<WaitPakin>().eq("zpallet", barcode).eq("io_status", "N"));
//                    if (waitPakins.isEmpty()) {
@@ -222,6 +229,8 @@
                                .build()
                                .doPost();
                        JSONObject jsonObject = JSON.parseObject(response);
                        LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed());
                        Integer code = jsonObject.getInteger("code");
                        if (jsonObject.getInteger("code").equals(200)) {
                            StartupDto dto = jsonObject.getObject("data", StartupDto.class);
@@ -229,12 +238,32 @@
                            staProtocol.setWorkNo(dto.getWorkNo().shortValue());
                            staProtocol.setStaNo(dto.getStaNo().shortValue());
                            devpThread.setPakMk(staProtocol.getSiteId(), false);
                            ledThread.errorReset();
                            boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                            if (!result) {
                                throw new CoolException("更新plc站点信息失败");
                            }
                        } else {
                        } else if(code == 500){
                            if (ledThread != null) {
                                String errorMsg = jsonObject.getString("msg");
                                if (!Cools.isEmpty(errorMsg)) {
                                    MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg));
                                }
                            }
                            log.error("请求接口失败!!!url:{};request:{};response:{}", wmsUrl + "/rpc/pakin/loc/v1", JSON.toJSONString(param), response);
                        } else if (code == 700) {
                            staProtocol.setWorkNo((short) 9995);
                            staProtocol.setStaNo(inSta.getBackSta().shortValue());
                            devpThread.setPakMk(staProtocol.getSiteId(), false);
                            MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                            // led 异常显示
                            if (ledThread != null) {
                                String errorMsg = barcode + "托盘识别异常,请先进行组托!";
                                MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errorMsg));
                            }
                        }
@@ -397,15 +426,34 @@
            for (DevpSlave.Sta pickSta : devp.getPickSta()) {
                // 获取条码扫描仪信息
                BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, pickSta.getBarcode());
                if (barcodeThread == null) {
                    continue;
                }
                String barcode = barcodeThread.getBarcode();
                if(!Cools.isEmpty(barcode)) {
                    log.info("{}号条码扫描器检测条码信息:{}", pickSta.getBarcode(), barcode);
                    if("NG".endsWith(barcode) || "NoRead".equals(barcode)) {
                        continue;
                //101站有3个扫码器,当0扫码器没有数据时,获取9、10两个扫码器数据
                if((pickSta.getStaNo().equals(101) || pickSta.getStaNo().equals(104)) && ( "NoRead".equals(barcode) || Cools.isEmpty(barcode) )){
                    BarcodeThread barcodeThread1 = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, pickSta.getBarcode1());
                    if (barcodeThread1 != null) {
                        barcode = barcodeThread1.getBarcode();
                    }
                    if("NoRead".equals(barcode) || Cools.isEmpty(barcode)) {
                        BarcodeThread barcodeThread2 = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, pickSta.getBarcode2());
                        if (barcodeThread2 != null) {
                            barcode = barcodeThread2.getBarcode();
                        }
                    }
                }
                if (!Cools.isEmpty(barcode) && "NoRead".equals(barcode)) {
                    log.info("{}号条码扫描器检测条码信息:{}", pickSta.getBarcode(), barcode);
//                    if ("NG".endsWith(barcode) || "NoRead".equals(barcode)) {
//                        continue;
//                    }
                } else {
                    continue;
                }
@@ -419,33 +467,29 @@
                    staProtocol = staProtocol.clone();
                }
//                // 入出库模式判断
//                if (devpThread.ioMode != IoModeType.PAKIN_MODE) { continue; }
                if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable() && staProtocol.isPakMk()) {
//                    WrkMast wrkMast = wrkMastMapper.selectPickStep(barcode);
                    WrkMast wrkMast = wrkMastMapper.selectPakInStep3(staProtocol.getWorkNo().intValue());
                    LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, pickSta.getLed());
                    if (wrkMast == null) {
                        wrkMast = wrkMastMapper.selectPickStep(barcode);
                    }
                    if (wrkMast == null) {
                        // 无拣料数据
                        if (ledThread != null) {
                            String errorMsg = "暂无拣料信息!!!";
                            MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg));
                        }
                        continue;
                    }
                    if ((wrkMast.getIoType() != 103 && wrkMast.getIoType() != 104 && wrkMast.getIoType() != 107)
                            || Cools.isEmpty(wrkMast.getStaNo()) || Cools.isEmpty(wrkMast.getSourceStaNo())) {
                        continue;
                    }
                    ledThread.errorReset();
                    // 拣、盘、并 作业站转换
//                    int stnNo = 0;
//                    if (wrkMast.getStaNo() == 109) {
//                        stnNo = 127;
//                    } else if (wrkMast.getStaNo() == 113) {
//                        stnNo = 128;
//                    } else {
//                        log.error("{}号任务数据异常!", wrkMast.getWrkNo());
//                    }
                    // 获取目标站
                    Wrapper<StaDesc> wrapper = new EntityWrapper<StaDesc>()
                            .eq("type_no", wrkMast.getIoType() - 50)
@@ -1795,8 +1839,11 @@
                    }
                    LocMast sourceLoc = locMastService.queryDemoSourceLoc(crn.getId());
                    LocMast loc = locMastService.queryDemoLoc(crn.getId());
                    if (null == sourceLoc || null == loc) {
                    if (null == sourceLoc ) {
                        continue;
                    }
                    LocMast loc = locMastService.queryDemoLoc0(crn.getId(),sourceLoc.getLocType1());
                    if ( null == loc) {
                        continue;
                    }