#
luxiaotao1123
2020-08-11 a853cf5758095db64924c8ccacd43fd61a20d597
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -1,5 +1,6 @@
package com.zy.asrs.service.impl;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.baomidou.mybatisplus.mapper.Wrapper;
import com.core.common.Cools;
@@ -19,6 +20,7 @@
import com.zy.core.model.CrnSlave;
import com.zy.core.model.DevpSlave;
import com.zy.core.model.Task;
import com.zy.core.model.command.CrnCommand;
import com.zy.core.model.protocol.CrnProtocol;
import com.zy.core.model.protocol.StaProtocol;
import com.zy.core.properties.SlaveProperties;
@@ -244,7 +246,7 @@
                StaProtocol staProtocol = devpThread.getStation().get(outSta.getStaNo());
                if (staProtocol.isAutoing() && staProtocol.isLoading() && (staProtocol.getWorkNo() == 0 || staProtocol.getStaNo() == null)) {
                    // 查询工作档
                    WrkMast wrkMast = wrkMastMapper.selectPakOutStep1(staProtocol.getSiteId());
                    WrkMast wrkMast = wrkMastMapper.selectPakOutStep2(staProtocol.getSiteId());
                    if (wrkMast == null) {
                        continue;
                    }
@@ -302,8 +304,8 @@
            if (basCrnp == null) {
                continue;
            }
            // 只有当堆垛机空闲 或者 无任务时才继续执行
            if (crnProtocol.getStatusType() == CrnStatusType.IDLE || crnProtocol.getTaskNo() == 0) {
            // 只有当堆垛机空闲 并且 无任务时才继续执行
            if (crnProtocol.getStatusType() == CrnStatusType.IDLE && crnProtocol.getTaskNo() == 0) {
                // 如果最近一次是入库模式
                if (crnProtocol.getLastIo().equals("I")) {
                    if (basCrnp.getInEnable().equals("Y")) {
@@ -346,11 +348,37 @@
                flag = true;
            }
            if (!flag) {
                return;
                continue;
            }
            WrkMast wrkMast = wrkMastMapper.selectById(staProtocol.getWorkNo());
            // 获取工作状态为2(设备上走)的入库工作档
            WrkMast wrkMast = wrkMastMapper.selectPakInStep2(slave.getId(), staProtocol.getWorkNo());
            if(null == wrkMast) {
                log.error("查询无待入库数据--wrk_sts=2, 工作号={}", staProtocol.getWorkNo());
                continue;
            }
            // 获取库位信息
            LocMast locMast = locMastService.selectById(wrkMast.getLocNo());
            if (locMast == null) {
                log.error("查询库存无数据--库位号{}", wrkMast.getLocNo());
                continue;
            }
            if (!locMast.getLocSts().equals("S") && !locMast.getLocSts().equals("Q")) {
                log.error("库位状态不符合--状态, 库位号={},库位状态={}", wrkMast.getLocNo(), locMast.getLocSts());
                continue;
            }
            // 命令下发区 --------------------------------------------------------------------------
//            CrnThread crnThread = (CrnThread) SlaveConnection.get(SlaveType.Crn, slave.getId());
//            CrnProtocol crnProtocol = crnThread.getCrnProtocol();
            CrnCommand crnCommand = new CrnCommand();
            crnCommand.setTaskNo(wrkMast.getWrkNo().shortValue()); // 工作号
            crnCommand.setDestinationPosX(locMast.getRow1().shortValue()); // 排
            crnCommand.setDestinationPosY(locMast.getBay1().shortValue()); // 列
            crnCommand.setDestinationPosZ(locMast.getLev1().shortValue()); // 层
            if (!MessageQueue.offer(SlaveType.Crn, wrkMast.getCrnNo(), new Task<>(2, crnCommand))) {
                log.error("堆垛机命令下发失败,堆垛机号={},任务数据={}", wrkMast.getCrnNo(), JSON.toJSON(crnCommand));
            }
        }
    }
@@ -363,6 +391,11 @@
            DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Devp, crnStn.getDevpPlcId());
            StaProtocol staProtocol = devpThread.getStation().get(crnStn.getStaNo());
            // 获取工作状态为11(生成出库ID)的出库工作档
            WrkMast wrkMast = wrkMastMapper.selectPakOutStep1(slave.getId());
            if (wrkMast == null) {
                continue;
            }
        }