#
luxiaotao1123
2022-12-06 a76a2df1f1f29e77647ade8aa9e212b82c51f166
#
4个文件已修改
323 ■■■■■ 已修改文件
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java 286 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/MainProcess.java 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/model/protocol/StaProtocol.java 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/core/thread/SiemensDevpThread.java 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -117,6 +117,54 @@
                        && !staProtocol.isEmptyMk() && (workNo == 0 || (workNo >= 9990 && workNo <= 9999))
                        && staProtocol.isPakMk()) {
                    // 尺寸检测异常
                    boolean back = false;
                    String errMsg = "";
                    if (staProtocol.isFrontErr()) {
                        errMsg = "前超限";
                        back = true;
                    }
                    if (!back && staProtocol.isBackErr()) {
                        errMsg = "后超限";
                        back = true;
                    }
                    if (!back && staProtocol.isHighErr()) {
                        errMsg = "高超限";
                        back = true;
                    }
                    if (!back && staProtocol.isLeftErr()) {
                        errMsg = "左超限";
                        back = true;
                    }
                    if (!back && staProtocol.isRightErr()) {
                        errMsg = "右超限";
                        back = true;
                    }
                    if (!back && staProtocol.isWeightErr()) {
                        errMsg = "超重";
                        back = true;
                    }
                    if (!back && staProtocol.isBarcodeErr()) {
                        errMsg = "扫码失败";
                        back = true;
                    }
                    // 退回
                    if (back) {
                        log.warn("扫码入库失败,{}入库站因{}异常,托盘已被退回", inSta.getStaNo(), errMsg);
                        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 异常显示
                        LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed());
                        if (ledThread != null) {
                            MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errMsg));
                        }
                        continue;
                    }
                    // 获取条码扫描仪信息
                    BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, inSta.getBarcode());
                    if (barcodeThread == null) {
@@ -155,16 +203,16 @@
                    }
                    // 过滤盘点/拣料/并板任务
                    if (null != wrkMastMapper.selectPickStepByBarcode(barcode)) {
                        continue;
                    }
//                    if (null != wrkMastMapper.selectPickStepByBarcode(barcode)) {
//                        continue;
//                    }
                    // 判断重复工作档
                    WrkMast wrkMast = wrkMastMapper.selectPakInStep1(inSta.getStaNo(), barcode);
                    if (wrkMast != null) {
                        log.error("工作档中已存在该站状态为( 2.设备上走 )的数据,工作号={}", wrkMast.getWrkNo());
                        continue;
                    }
//                    WrkMast wrkMast = wrkMastMapper.selectPakInStep1(inSta.getStaNo(), barcode);
//                    if (wrkMast != null) {
//                        log.error("工作档中已存在该站状态为( 2.设备上走 )的数据,工作号={}", wrkMast.getWrkNo());
//                        continue;
//                    }
                    try {
                        LocTypeDto locTypeDto = new LocTypeDto(staProtocol);
@@ -227,6 +275,7 @@
     * wms入库
     * 入库站,根据条码扫描生成入库工作档,工作状态 1 ==>> 2
     */
    @Deprecated
    public void generateStoreWrkFile0() {
        // 根据输送线plc遍历
        for (DevpSlave devp : slaveProperties.getDevp()) {
@@ -246,6 +295,55 @@
                        && staProtocol.isInEnable()
                        && !staProtocol.isEmptyMk() && (workNo == 0 || (workNo >= 9990 && workNo <= 9999))
                        && staProtocol.isPakMk()) {
                    // 尺寸检测异常
                    boolean back = false;
                    String errMsg = "";
                    if (staProtocol.isFrontErr()) {
                        errMsg = "前超限";
                        back = true;
                    }
                    if (!back && staProtocol.isBackErr()) {
                        errMsg = "后超限";
                        back = true;
                    }
                    if (!back && staProtocol.isHighErr()) {
                        errMsg = "高超限";
                        back = true;
                    }
                    if (!back && staProtocol.isLeftErr()) {
                        errMsg = "左超限";
                        back = true;
                    }
                    if (!back && staProtocol.isRightErr()) {
                        errMsg = "右超限";
                        back = true;
                    }
                    if (!back && staProtocol.isWeightErr()) {
                        errMsg = "超重";
                        back = true;
                    }
                    if (!back && staProtocol.isBarcodeErr()) {
                        errMsg = "扫码失败";
                        back = true;
                    }
                    // 退回
                    if (back) {
                        log.warn("扫码入库失败,{}入库站因{}异常,托盘已被退回", inSta.getStaNo(), errMsg);
                        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 异常显示
                        LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, inSta.getLed());
                        if (ledThread != null) {
                            MessageQueue.offer(SlaveType.Led, inSta.getLed(), new Task(3, errMsg));
                        }
                        continue;
                    }
                    // 判断重复工作档
                    WrkMast wrkMast = wrkMastMapper.selectPakInStep11(inSta.getStaNo());
                    if (wrkMast == null) { continue; }
@@ -273,63 +371,9 @@
    }
    /**
     * 拣料、并板、盘点再入库 【第1阶段】
     * 拣料、并板、盘点再入库
     */
    public synchronized void stnToCrnStnPick0(){
        for (DevpSlave devp : slaveProperties.getDevp()) {
            // 遍历拣料入库口
            for (DevpSlave.Sta pickSta : devp.getPickOutSta()) {
                // 获取拣料入库站信息
                DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, devp.getId());
                StaProtocol staProtocol = devpThread.getStation().get(pickSta.getStaNo());
                if (staProtocol == null) {
                    continue;
                } else {
                    staProtocol = staProtocol.clone();
                }
                if (staProtocol.isAutoing()
                        && staProtocol.isLoading()
                        && staProtocol.isInEnable()
                        && staProtocol.getWorkNo() > 0
                        && staProtocol.isPakMk()) {
                    WrkMast wrkMast = wrkMastMapper.selectPickStep(staProtocol.getWorkNo());
                    if (wrkMast == null) {
                        // 无拣料数据
                        continue;
                    }
                    short staNo;
                    switch (wrkMast.getSourceStaNo()) {
                        case 104:
                        case 108:
                            staNo = 103;
                            break;
                        case 204:
                        case 208:
                            staNo = 203;
                            break;
                        default:
                            log.error("{}任务再入库失败,系统数据异常!", wrkMast.getWrkNo());
                            continue;
                    }
                    // 更新站点信息 且 下发plc命令
//                    staProtocol.setWorkNo((short) 9994);
                    staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue());
                    staProtocol.setStaNo(staNo);
                    devpThread.setPakMk(staProtocol.getSiteId(), false);
                    boolean result = MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                    if (!result) {
                        log.error("发布命令至输送线队列失败!!! [plc编号:{}]", devp.getId());
                    }
                }
            }
        }
    }
    /**
     * 拣料、并板、盘点再入库【第2阶段】
     */
    public synchronized void stnToCrnStnPick1(){
    public synchronized void stnToCrnStnPick(){
        for (DevpSlave devp : slaveProperties.getDevp()) {
            // 遍历拣料入库口
            for (DevpSlave.Sta pickSta : devp.getPickInSta()) {
@@ -346,65 +390,63 @@
                        && staProtocol.isLoading()
                        && staProtocol.isInEnable()
                        // 0 - 9990 或者 9996
                        && ((staProtocol.getWorkNo() > 0 && staProtocol.getWorkNo() < 9990) || staProtocol.getWorkNo() == 9996)
                        && (staProtocol.getWorkNo() > 0 && staProtocol.getWorkNo() < 9990)
                        && staProtocol.getStaNo().equals(staProtocol.getSiteId().shortValue())
                        && staProtocol.isPakMk()){
                    // 获取条码扫描仪信息
                    BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, pickSta.getBarcode());
                    if (barcodeThread == null) {
                        continue;
                    }
//                    BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, pickSta.getBarcode());
//                    if (barcodeThread == null) {
//                        continue;
//                    }
                    WrkMast wrkMast = null;
                    if (staProtocol.getWorkNo() > 0 && staProtocol.getWorkNo() < 9990) {
                        wrkMast = wrkMastMapper.selectPickStep(staProtocol.getWorkNo());
                        if (null == wrkMast) {
                            log.error("{}任务号错误,暂无拣料任务!", staProtocol.getWorkNo());
                        }
                    }
                    if (staProtocol.getWorkNo() == 9996) {
                        String barcode = barcodeThread.getBarcode();
                        if(!Cools.isEmpty(barcode)) {
                            log.info("{}号条码扫描器检测条码信息:{}", pickSta.getBarcode(), barcode);
                            if("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode)) {
                                staProtocol.setWorkNo((short) 9995);
                                staProtocol.setStaNo(pickSta.getBackSta().shortValue());
                                devpThread.setPakMk(staProtocol.getSiteId(), false);
                                MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                                // led 异常显示
                                LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, pickSta.getLed());
                                if (ledThread != null) {
                                    String errorMsg = "扫码失败,请重试";
                                    MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg));
                                }
                                continue;
                            }
                        } else {
                            staProtocol.setWorkNo((short) 9995);
                            staProtocol.setStaNo(pickSta.getBackSta().shortValue());
                            devpThread.setPakMk(staProtocol.getSiteId(), false);
                            MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
                            // led 异常显示
                            LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, pickSta.getLed());
                            if (ledThread != null) {
                                String errorMsg = "扫码失败,请重试";
                                MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg));
                            }
                            continue;
                        }
                        wrkMast = wrkMastMapper.selectPickStepByBarcode(barcode);
                        if (null == wrkMast) {
                            log.error("{}条码错误,暂无拣料任务!", barcode);
                        }
                    }
                    if (wrkMast == null) {
                        // 无拣料数据
                    } else {
                        continue;
                    }
//                    if (staProtocol.getWorkNo() == 9996) {
//                        String barcode = barcodeThread.getBarcode();
//                        if(!Cools.isEmpty(barcode)) {
//                            log.info("{}号条码扫描器检测条码信息:{}", pickSta.getBarcode(), barcode);
//                            if("NG".endsWith(barcode) || "NoRead".equals(barcode) || "empty".equals(barcode)) {
//                                staProtocol.setWorkNo((short) 9995);
//                                staProtocol.setStaNo(pickSta.getBackSta().shortValue());
//                                devpThread.setPakMk(staProtocol.getSiteId(), false);
//                                MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
//
//                                // led 异常显示
//                                LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, pickSta.getLed());
//                                if (ledThread != null) {
//                                    String errorMsg = "扫码失败,请重试";
//                                    MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg));
//                                }
//                                continue;
//                            }
//                        } else {
//                            staProtocol.setWorkNo((short) 9995);
//                            staProtocol.setStaNo(pickSta.getBackSta().shortValue());
//                            devpThread.setPakMk(staProtocol.getSiteId(), false);
//                            MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
//
//                            // led 异常显示
//                            LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, pickSta.getLed());
//                            if (ledThread != null) {
//                                String errorMsg = "扫码失败,请重试";
//                                MessageQueue.offer(SlaveType.Led, pickSta.getLed(), new Task(3, errorMsg));
//                            }
//                            continue;
//                        }
//                        wrkMast = wrkMastMapper.selectPickStepByBarcode(barcode);
//                        if (null == wrkMast) {
//                            log.error("{}条码错误,暂无拣料任务!", barcode);
//                        }
//                    }
                    if ((wrkMast.getIoType() != 103 && wrkMast.getIoType() != 104 && wrkMast.getIoType() != 107)
                        || Cools.isEmpty(wrkMast.getStaNo()) || Cools.isEmpty(wrkMast.getSourceStaNo()) ) {
                        continue;
@@ -417,7 +459,7 @@
                        param.setWrkNo(wrkMast.getWrkNo());
                        param.setIoType(wrkMast.getIoType());
                        param.setSourceStaNo(pickSta.getStaNo());
                        param.setLocType1(locTypeDto.getLocType1());
//                        param.setLocType1(locTypeDto.getLocType1());
                        String response = new HttpHandler.Builder()
                                .setUri(wmsUrl)
                                .setPath("/rpc/pakin/loc/v1")
@@ -468,27 +510,6 @@
                            if (wrkMastMapper.setSteEmpty(wrkMast.getWrkNo()) == 0) {
                                throw new CoolException(wrkMast.getWrkNo() + "更新工作档数据状态失败");
                            }
                            // 修改源库位状态 O.空库位
                            LocMast locMast = locMastService.selectById(sourceLocNo);
                            locMast.setLocSts("O");
                            locMast.setModiTime(new Date());
                            if (!locMastService.updateById(locMast)) {
                                throw new CoolException(wrkMast.getWrkNo() + "修改源库位状态 O.空库位");
                            }
                            // 修改目标库位状态 Q.拣料/盘点/并板再入库
                            locMast = locMastService.selectById(wrkMast.getLocNo());
                            locMast.setLocSts("Q");
                            locMast.setModiTime(new Date());
                            if (!locMastService.updateById(locMast)) {
                                throw new CoolException(wrkMast.getWrkNo() + "修改目标库位状态 Q.拣料/盘点/并板再入库");
                            }
                            // 库存明细转移
                            if (!locDetlService.updateLocNo(wrkMast.getLocNo(), sourceLocNo)) {
                                throw new CoolException(wrkMast.getWrkNo() + "任务库存明细转移失败!!!");
                            }
                            // 条码设备处理
                            barcodeThread.setBarcode("");
                            // 更新站点信息 且 下发plc命令
                            staProtocol.setWorkNo(wrkMast.getWrkNo().shortValue());
@@ -524,7 +545,6 @@
                    } catch (Exception e) {
                        e.printStackTrace();
                        TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
//                        continue;
                    }
                }
@@ -2353,7 +2373,7 @@
                            param.setBarcode(barcode);
                        }
                        param.setSourceStaNo(emptyInSta.getStaNo());
                        param.setLocType1(locTypeDto.getLocType1());
//                        param.setLocType1(locTypeDto.getLocType1());
                        String response = new HttpHandler.Builder()
                                .setUri(wmsUrl)
                                .setPath("/rpc/pakin/loc/v1")
src/main/java/com/zy/core/MainProcess.java
@@ -44,14 +44,13 @@
                    // 入库  ===>> 入库站到堆垛机站,根据条码扫描生成入库工作档
                    mainService.generateStoreWrkFile(); // 组托
                    mainService.generateStoreWrkFile0(); // WMS入库
//                    mainService.generateStoreWrkFile0(); // WMS入库
                    // 间隔
                    Thread.sleep(500);
                    // 拣料、并板、盘点再入库
                    mainService.stnToCrnStnPick0();
                    mainService.stnToCrnStnPick1();
                    mainService.stnToCrnStnPick();
                    // 出库  ===>>  堆垛机出库站到出库站
                    mainService.crnStnToOutStn();
                    // 入出库  ===>>  堆垛机入出库作业下发
src/main/java/com/zy/core/model/protocol/StaProtocol.java
@@ -52,25 +52,25 @@
    // 外形检测 ------------------------------------------------------------------------
    // 前超限
    private Boolean frontErr;
    private boolean frontErr;
    // 后超限
    private Boolean backErr;
    private boolean backErr;
    // 高超限
    private Boolean highErr;
    private boolean highErr;
    // 左超限
    private Boolean leftErr;
    private boolean leftErr;
    // 右超限
    private Boolean rightErr;
    private boolean rightErr;
    // 超重
    private Boolean weightErr;
    private boolean weightErr;
    // 扫码失败
    private Boolean barcodeErr;
    private boolean barcodeErr;
    public BasDevp toSqlModel(){
        BasDevp basDevp = new BasDevp();
src/main/java/com/zy/core/thread/SiemensDevpThread.java
@@ -176,14 +176,28 @@
        OperateResultExOne<byte[]> result4 = siemensS7Net.Read("DB102.129.", (short)1);
        if (result4.IsSuccess) {
            boolean[] status = siemensS7Net.getByteTransform().TransBool(result4.Content, 0, 1);
            System.out.println(JSON.toJSONString(status));
            StaProtocol staProtocol = station.get(2);   // 102
            staProtocol.setFrontErr(status[0]);
            staProtocol.setBackErr(status[1]);
            staProtocol.setHighErr(status[2]);
            staProtocol.setLeftErr(status[3]);
            staProtocol.setRightErr(status[4]);
            staProtocol.setWeightErr(status[5]);
            staProtocol.setBarcodeErr(status[6]);
        }
        // 外形检测 - 203
        Thread.sleep(50);
        OperateResultExOne<byte[]> result5 = siemensS7Net.Read("DB102.130.", (short)1);
        if (result5.IsSuccess) {
            boolean[] status = siemensS7Net.getByteTransform().TransBool(result5.Content, 0, 1);
            System.out.println(JSON.toJSONString(status));
            StaProtocol staProtocol = station.get(25);   // 203
            staProtocol.setFrontErr(status[0]);
            staProtocol.setBackErr(status[1]);
            staProtocol.setHighErr(status[2]);
            staProtocol.setLeftErr(status[3]);
            staProtocol.setRightErr(status[4]);
            staProtocol.setWeightErr(status[5]);
            staProtocol.setBarcodeErr(status[6]);
        }
        if (result.IsSuccess && result1.IsSuccess) {