#
luxiaotao1123
2020-09-11 0e3cb0f173a4996a743f4b4e5b03f15fdb9f9e9c
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -88,19 +88,19 @@
                    continue;
                }
                // 判断是否满足入库条件
                if (staProtocol.isAutoing() && staProtocol.isLoading()
                if (staProtocol.isAutoing() && staProtocol.isLoading() && staProtocol.isInEnable()
                        && !staProtocol.isEmptyMk() && staProtocol.getWorkNo() == 0
                        && staProtocol.isPakMk() && !Cools.isEmpty(barcode)) {
                    // 判断重复工作档
                    WrkMast wrkMast = wrkMastMapper.selectPakInStep1(inSta.getStaNo(), barcode);
                    if (wrkMast != null) {
                        log.warn("工作档中已存在该站状态为( 2.设备上走 )的数据,工作号={}", wrkMast.getWrkNo());
                        log.error("工作档中已存在该站状态为( 2.设备上走 )的数据,工作号={}", wrkMast.getWrkNo());
                        continue;
                    }
                    // 获取入库通知档
                    List<WaitPakin> waitPakins = waitPakinMapper.selectList(new EntityWrapper<WaitPakin>().eq("zpallet", barcode).eq("io_status", "N"));
                    if (waitPakins.isEmpty()) {
                        log.warn("无此入库条码数据。条码号={}", barcode);
                        log.error("无此入库条码数据。条码号={}", barcode);
                        continue;
                    }
                    // 工作号
@@ -145,7 +145,7 @@
                    }
                    // 将入库通知档修改为已启动
                    if (wrkMastMapper.updateWaitPakInStep1(barcode) == 0) {
                        throw new CoolException("修改入库通知档状态为已启动");
                        throw new CoolException("修改入库通知档状态为已启动失败");
                    }
                    // 命令下发区 --------------------------------------------------------------------------
@@ -371,7 +371,7 @@
                continue;
            }
            // 只有当堆垛机空闲 并且 无任务时才继续执行
            if (crnProtocol.getStatusType() == CrnStatusType.IDLE && crnProtocol.getTaskNo() == 0) {
            if (crnProtocol.getStatusType() == CrnStatusType.IDLE && crnProtocol.getTaskNo() == 0 && crnProtocol.getModeType() == CrnModeType.AUTO) {
                // 如果最近一次是入库模式
                if (crnProtocol.getLastIo().equals("I")) {
                    if (basCrnp.getInEnable().equals("Y")) {
@@ -746,20 +746,43 @@
            for (Integer staNo : led.getStaArr()) {
                // 获取叉车站点
                StaProtocol staProtocol = devpThread.getStation().get(staNo);
                if (null == staProtocol || null == staProtocol.getWorkNo() || 0 == staProtocol.getWorkNo()) { continue; }
                if (null == staProtocol || null == staProtocol.getWorkNo() || 0 == staProtocol.getWorkNo() || !staProtocol.isLoading()) { continue; }
                // 获取工作档数据
                WrkMast wrkMast = wrkMastMapper.selectById(staProtocol.getWorkNo());
                if (wrkMast.getWrkSts() == 14L || wrkMast.getWrkSts() == 15L) {
                    wrkMasts.add(wrkMast);
                    // 添加命令
                    List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkMast.getWrkNo());
                    LedCommand ledCommand = new LedCommand();
                    ledCommand.setWorkNo(wrkMast.getWrkNo());
                    ledCommand.setSourceLocNo(wrkMast.getSourceLocNo());
                    ledCommand.setStaNo(wrkMast.getStaNo());
                    wrkDetls.forEach(wrkDetl -> ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMatnr(), wrkDetl.getAnfme())));
                    commands.add(ledCommand);
                if (null == wrkMast || wrkMast.getWrkSts() < 14 || wrkMast.getIoType() < 100) { continue; }
                wrkMasts.add(wrkMast);
                // 组装命令
                LedCommand ledCommand = new LedCommand();
                ledCommand.setWorkNo(wrkMast.getWrkNo());
                // 出库模式
                switch (wrkMast.getIoType()) {
                    case 101:
                        ledCommand.setTitle("全板出库");
                        break;
                    case 103:
                        ledCommand.setTitle("拣料出库");
                        break;
                    case 104:
                        ledCommand.setTitle("并板出库");
                        break;
                    case 107:
                        ledCommand.setTitle("盘点出库");
                        break;
                    case 110:
                        ledCommand.setTitle("空板出库");
                        ledCommand.setEmptyMk(true);
                        break;
                    default:
                        log.error("任务入出库类型错误!!![工作号:{}] [入出库类型:{}]", wrkMast.getWrkNo(), wrkMast.getIoType());
                        break;
                }
                ledCommand.setSourceLocNo(wrkMast.getSourceLocNo());
                ledCommand.setStaNo(wrkMast.getStaNo());
                if (wrkMast.getIoType() != 110) {
                    List<WrkDetl> wrkDetls = wrkDetlService.findByWorkNo(wrkMast.getWrkNo());
                    wrkDetls.forEach(wrkDetl -> ledCommand.getMatDtos().add(new MatDto(wrkDetl.getMatnr(), wrkDetl.getMatnr(), wrkDetl.getAnfme())));
                }
                commands.add(ledCommand);
            }
            Set<Integer> workNos = wrkMasts.stream().map(WrkMast::getWrkNo).collect(Collectors.toSet());
            // 获取LED线程
@@ -771,6 +794,7 @@
            // 命令下发 -------------------------------------------------------------------------------
            if (!commands.isEmpty()) {
                if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(1, commands))) {
                    log.error("{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort());
                    continue;
                }
            }
@@ -790,4 +814,33 @@
        }
    }
    /**
     * 其他  ===>> LED显示器复位,显示默认信息
     */
    @Async
    public void ledReset() {
        for (LedSlave led : slaveProperties.getLed()) {
            // 获取输送线plc线程
            DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, led.getDevpPlcId());
            // 命令集合
            boolean reset = true;
            for (Integer staNo : led.getStaArr()) {
                // 获取叉车站点
                StaProtocol staProtocol = devpThread.getStation().get(staNo);
                if (staProtocol.getWorkNo() != 0) {
                    reset = false;
                    break;
                }
            }
            // 获取led线程
            LedThread ledThread = (LedThread) SlaveConnection.get(SlaveType.Led, led.getDevpPlcId());
            // led显示默认内容
            if (!ledThread.isResetStatus() && reset) {
                if (!MessageQueue.offer(SlaveType.Led, led.getId(), new Task(2, new ArrayList<>()))) {
                    log.error("{}号LED命令下发失败!!![ip:{}] [port:{}]", led.getId(), led.getIp(), led.getPort());
                }
            }
        }
    }
}