#
tqs
2024-05-18 d1fee2d2ac8f4bd510bf44f70aec743619712039
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -118,6 +118,7 @@
                if (barcodeThread == null) {
                    continue;
                }
                String barcode = barcodeThread.getBarcode();
                // 尺寸检测异常
                boolean back = false;
@@ -150,6 +151,12 @@
                    errMsg = "扫码失败";
                    back = true;
                }
                //拣料、盘点任务,不进入新板入库方法,直接跳出
                if(staProtocol.getWorkNo()>=3001 && staProtocol.getWorkNo()<=6000){
                    continue;
                }
                // 退回
                if (back) {
//                        News.warn("扫码入库失败,{}入库站因{}异常,托盘已被退回", inSta.getStaNo(), errMsg);
@@ -167,6 +174,7 @@
                    staProtocol.setStaNo(inSta.getBackSta().shortValue());
                    devpThread.setPakMk(staProtocol.getSiteId(), false);
                    MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                    MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errMsg));
                }
                // 判断是否满足入库条件
@@ -174,21 +182,32 @@
                        && staProtocol.isLoading()
                        && staProtocol.isInEnable()
                        && !staProtocol.isEmptyMk()
                        && staProtocol.isPakMk()) {// && !Cools.isEmpty(barcode)) {
                        && staProtocol.isPakMk() && !back) {// && !Cools.isEmpty(barcode)) {
                    if(Cools.isEmpty(barcode) || "NG".endsWith(barcode) || "NoRead".equals(barcode) || "00000000".equals(barcode)) {
                        News.info("{}号条码扫描器检测条码信息:{}", inSta.getBarcode(), barcode);
                        //条码为空或者不符合,退库到172站点
//                        staProtocol.setWorkNo((short)9999);
//                        staProtocol.setStaNo((short)172);
//                        devpThread.setPakMk(staProtocol.getSiteId(), false);
//                        boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
//                        if (!result) {
//                            throw new CoolException("更新plc站点信息失败");
//                        }
                        staProtocol.setWorkNo(wrkNo);
                        staProtocol.setStaNo(inSta.getBackSta().shortValue());
                        wrkNo++;
                        devpThread.setPakMk(staProtocol.getSiteId(), false);
                        boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                        if (!result) {
                            throw new CoolException("更新plc站点信息失败");
                        }
                        continue;
                    }
//                    //判断101和104是否是拣料、并板、盘点再入库   设备暂不支持101、104站盘点/拣料入库
//                    WrkMast wrkMast1=wrkMastMapper.selectpj(inSta.getStaNo(),barcode);
//                    if(!Cools.isEmpty(wrkMast1)){
//                        if (wrkMast1.getIoType()!=1){
//                            continue;
//                        }
//                    }
//                    if( !Cools.isEmpty(barcode)&&!Cools.isEmpty(wrkMast1)){
//                        log.error("101或104拣料、并板、盘点再入库", wrkMast1.getWrkNo());
//                        continue;
//                    }
                    // 判断重复工作档
                    WrkMast wrkMast = wrkMastMapper.selectPakInStep1(inSta.getStaNo(), barcode);
                    if (wrkMast != null) {
@@ -202,9 +221,11 @@
                    WrkMast checkPick = wrkMastService.selectOne(new EntityWrapper<WrkMast>()
                            .eq("barcode", barcode)
                            .in("io_type", 107,103));
                            .in("io_type", 107,103,57,53));
                    if (!Cools.isEmpty(checkPick)) {
                        continue;
                    } else {
                        News.info("新板入库条码===>>" + barcode);
                    }
//                    WrkMast checkPick2 = wrkMastService.selectOne(new EntityWrapper<WrkMast>()
//                            .eq("barcode", barcode)
@@ -241,6 +262,8 @@
                                News.error(methodName + ":更新plc站点信息失败");
                                throw new CoolException("更新plc站点信息失败");
                            }else {
                                ledThread.errorReset();
                            }
@@ -419,33 +442,39 @@
                }
                String barcode = barcodeThread.getBarcode();
                if (!Cools.isEmpty(barcode)) {
                WrkMast wrkMast1 = wrkMastMapper.selectPickStep1(staProtocol.getWorkNo().intValue());
                //任务号如果在工作档中存在,就不用去判断条码
                if(Cools.isEmpty(wrkMast1)) {
                    if (!Cools.isEmpty(barcode)) {
//                    log.info("{}号条码扫描器检测条码信息:{}", pickSta.getBarcode(), barcode);
                    if ("NG".endsWith(barcode) || "NoRead".equals(barcode) || "00000000".equals(barcode)) {
                        if (!staProtocol.isLoading()) {
                        if ("NG".endsWith(barcode) || "NoRead".equals(barcode) && staProtocol.isPakMk()) {
                            if (!staProtocol.isLoading()) {
                                continue;
                            }
                            if (!staProtocol.isPakMk()) {
                                continue;
                            }
                            if (staProtocol.getWorkNo() != 0) {
                                continue;
                            }
                            staProtocol.setWorkNo(wrkNo);
                            wrkNo++;
                            staProtocol.setStaNo(pickSta.getBackSta().shortValue());
                            devpThread.setPakMk(staProtocol.getSiteId(), false);
                            MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                            // led 异常显示
                            if (ledThread != null) {
                                String errorMsg = "扫码失败,请重试";
                                News.error(methodName + ":扫码失败,请重试");
                                MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg));
                            }
                            continue;
                        }
                        if (!staProtocol.isPakMk()) {
                            continue;
                        }
                        if(staProtocol.getWorkNo() != 0) {
                            continue;
                        }
                        staProtocol.setWorkNo(wrkNo);
                        wrkNo++;
                        staProtocol.setStaNo(pickSta.getBackSta().shortValue());
                        devpThread.setPakMk(staProtocol.getSiteId(), false);
                        MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                        // led 异常显示
                        if (ledThread != null) {
                            String errorMsg = "扫码失败,请重试";
                            News.error(methodName + ":扫码失败,请重试");
                            MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg));
                        }
                    } else {
                        continue;
                    }
                } else {
                    continue;
                }
@@ -459,7 +488,12 @@
//                        && (staProtocol.getWorkNo() == 9999 || staProtocol.getWorkNo() == 9997 || staProtocol.getWorkNo() == 9995)
                        && staProtocol.isPakMk()) {
                    WrkMast wrkMast = wrkMastMapper.selectPickStep(barcode);
                    WrkMast wrkMast = null;
                    //优先查询任务号对应的工作档有没有,如果有的话就不用查条码号
                    wrkMast = wrkMastMapper.selectPickStep1(staProtocol.getWorkNo().intValue());
                    if(Cools.isEmpty(wrkMast)) {
                        wrkMast = wrkMastMapper.selectPickStep(barcode);
                    }
//                    WrkMast wrkMast = wrkMastMapper.selectPakInStep3(staProtocol.getWorkNo().intValue());
                    if (wrkMast == null) {
                        // 无拣料数据
@@ -538,12 +572,16 @@
                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
                        continue;
                    }
                    if (ledThread != null) {
                        ledThread.errorReset();
                    }
                    // 更新站点信息 且 下发plc命令
                    staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue());
                    staProtocol.setStaNo(wrkMast.getStaNo().shortValue());
                    devpThread.setPakMk(staProtocol.getSiteId(), false);
                    boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                    if (!result) {
                        News.error(methodName + ":发布命令至输送线队列失败!!! [plc编号:{}]", devp.getId());
@@ -610,6 +648,7 @@
                        wrkMast.setCrnEndTime(new Date());
                        if (wrkMastMapper.updateById(wrkMast) != 0) {
                            // 复位堆垛机
                            News.info("crnStnToOutStn堆垛机复位时工作号===>>" + crnProtocol.getTaskNo());
                            crnThread.setResetFlag(true);
                        } else {
                            News.error(methodName + ":更新工作档的工作状态为14失败!!! [工作号:{}]", wrkMast.getWrkNo());
@@ -786,6 +825,12 @@
            // 堆垛机控制过滤
            if (!crnProtocolNow.getStatusType().equals(CrnStatusType.IDLE) || crnProtocolNow.getTaskNo() != 0) {
                continue;
            }
            // 已经存在吊车执行任务时,则过滤
            if (wrkMastMapper.selectWorking(slave.getId()) != null) {
                break;
//                        return;
            }
            // 命令下发区 --------------------------------------------------------------------------
@@ -1499,6 +1544,7 @@
                    }
                    // 入库 + 库位转移  ==> 4.入库完成
                    if (wrkMast.getWrkSts() == 3 || (wrkMast.getWrkSts() == 12 && wrkMast.getIoType() == 11)) {
                        log.error("入库完成堆垛机任务=========》"+JSON.toJSONString(wrkMast));
                        wrkMast.setWrkSts(4L);
                    } else {
                        continue;
@@ -1509,6 +1555,7 @@
                    // 修改成功后复位堆垛机
                    if (wrkMastMapper.updateById(wrkMast) > 0) {
                        // 堆垛机复位
                        News.info("storeFinished堆垛机复位时工作号===>>" + crnProtocol.getTaskNo());
                        crnThread.setResetFlag(true);
                    }
                }
@@ -1820,9 +1867,7 @@
                        Double total = 0.0;
                        EntityWrapper<LocDetl> wrapper = new EntityWrapper<>();
                        LocDetl locDetl = locDetlService.selectOne(wrapper.eq("zpallet", wrkDetl.getZpallet()).eq("matnr", wrkDetl.getMatnr()));
                        if (Cools.isEmpty(locDetl)) {
                            total = wrkDetl.getAnfme();
                        } else {
                        if (!Cools.isEmpty(locDetl)) {
                            total = locDetl.getAnfme();
                        }
                        if (wrkMast.getIoType() == 101) {
@@ -1886,14 +1931,24 @@
            for (Integer staNo : led.getStaArr()) {
                // 获取叉车站点
                StaProtocol staProtocol = devpThread.getStation().get(staNo);
                StaProtocol staProtocol1 = devpThread.getStation().get(staNo+1);
                if (staProtocol == null) { continue; }
                if (staProtocol.getWorkNo() != 0) {
                if (staProtocol1 == null) { continue; }
                if (staProtocol.getWorkNo() != 0 || staProtocol.isLoading()) {
                    reset = false;
                    break;
                }
                if (staProtocol1.isLoading() || staProtocol1.getWorkNo() != 0) {
                    reset = false;
                    break;
                }
                if (!staProtocol.isLoading() && staProtocol.getWorkNo() == 0 && !staProtocol1.isLoading() && staProtocol1.getWorkNo() == 0){
//                    News.error("{}号LED入库口2个站点都没有数据,准备reset复位显示器!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort());
                }
            }
            // 获取led线程
            LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getDevpPlcId());
//            LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getDevpPlcId());
            LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getId());
            // led显示默认内容
            if (reset) {
                if (ledThread == null) {