pang.jiabao
昨天 9c1720c8f25fd0a77e16bf4b696fb1bfca6bcda9
src/main/java/com/zy/asrs/service/impl/MainServiceImpl.java
@@ -32,6 +32,8 @@
import com.zy.core.properties.SlaveProperties;
import com.zy.core.thread.BarcodeThread;
import com.zy.core.thread.SiemensDevpThread;
import com.zy.system.entity.Config;
import com.zy.system.service.ConfigService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
@@ -39,6 +41,7 @@
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.interceptor.TransactionAspectSupport;
import javax.annotation.Resource;
import java.io.IOException;
import java.util.Date;
import java.util.List;
@@ -182,6 +185,7 @@
                        storageEscalationParam.setBarcode(BoxNo);
                        storageEscalationParam.setMatIdList(staProtocol.getMatIdList());
                        storageEscalationParam.setFullPlt(staProtocol.isFullPlt() ? 1 : 0);
                        storageEscalationParam.setMpHigh((short) (staProtocol.getSiteId() < 200 ? 1 :staProtocol.isHigh() ? 2 : staProtocol.isLow() ? 1 : 0));    // 高度,侧面码盘的高度 低1,高2
                        log.info("组托入库={}", storageEscalationParam);
                        TaskWrk taskWrk = toWmsService.getLocNoFromWms(storageEscalationParam);
                        if (taskWrk == null) {
@@ -193,7 +197,7 @@
                            }
                        }
                        if (back) {
                            staProtocol.setWorkNo((short)9991);
                            staProtocol.setWorkNo((short) 9991);
                            staProtocol.setStaNo(inSta.getBackSta().shortValue());
                            devpThread.setPakMk(staProtocol.getSiteId(), false);
                            MessageQueue.offer(SlaveType.Devp, devp.getId(), new Task(2, staProtocol));
@@ -238,34 +242,73 @@
                        staProtocol = staProtocol.clone();
                    }
                    if (staProtocol.isAutoing() && staProtocol.isLoading() && (staProtocol.getWorkNo() == 0 || staProtocol.getStaNo() == 0)) {
                        // 查询工作档
                        TaskWrk taskWrk = taskWrkMapper.selectCrnStaWorking(crnSlave.getId(), String.valueOf(crnStn.getStaNo() - 1));
                        if (taskWrk == null) {
                            continue;
                        }
                        log.info("下发输送线任务:taskWrk:" + JSON.toJSONString(taskWrk));
                        staProtocol.setWorkNo(taskWrk.getWrkNo().shortValue());
                        staProtocol.setStaNo(Short.valueOf(taskWrk.getTargetPoint()));
                        if (!Cools.isEmpty(taskWrk.getType())) {
                            staProtocol.setHeight(taskWrk.getType());
                        }
                        boolean offer = false;
                        try {
                            offer = MessageQueue.offer(SlaveType.Devp, 1, new Task(2, staProtocol));
                        } catch (Exception e) {
                            log.error("下发输送线任务失败:异常:" + e);
                            log.error("下发输送线任务失败:异常:offer:" + offer);
                        }
                        if (offer) {
                            log.info("下发输送线任务成功:taskWrk:" + JSON.toJSONString(taskWrk));
                            taskWrk.setStatus(5);
                            taskWrk.setWrkSts(14);
                            taskWrk.setCompleteTime(new Date());
                            taskWrkService.updateById(taskWrk);
                        if (crnStn.getStaNo() >= 200) {
                            // 查询工作档
                            TaskWrk taskWrk = taskWrkMapper.selectCrnStaWorking(crnSlave.getId(), String.valueOf(crnStn.getStaNo() + 2));
                            if (taskWrk == null) {
                                continue;
                            }
                            log.info("下发输送线任务:taskWrk:" + JSON.toJSONString(taskWrk));
                            staProtocol.setWorkNo(taskWrk.getWrkNo().shortValue());
                            staProtocol.setStaNo(Short.valueOf(taskWrk.getTargetPoint()));
                            staProtocol.setBarcode(taskWrk.getBarcode());
                            if (!Cools.isEmpty(taskWrk.getType())) {
                                staProtocol.setHeight(taskWrk.getType());
                            }
                            boolean offer = false;
                            try {
                                offer = MessageQueue.offer(SlaveType.Devp, 1, new Task(2, staProtocol));
                                staProtocol.setMp(taskWrk.getMp());
                                staProtocol.setLx(taskWrk.getLx());
                                staProtocol.setLev(taskWrk.getLev());
                                MessageQueue.offer(SlaveType.Devp, 1, new Task(3, staProtocol));
                            } catch (Exception e) {
                                log.error("下发输送线任务失败:异常:" + e);
                                log.error("下发输送线任务失败:异常:offer:" + offer);
                            }
                            if (offer) {
                                log.info("下发输送线任务成功:taskWrk:" + JSON.toJSONString(taskWrk));
                                taskWrk.setStatus(5);
                                taskWrk.setWrkSts(14);
                                taskWrk.setCompleteTime(new Date());
                                taskWrkService.updateById(taskWrk);
                                // 侧面出库完成 上报执行状态
                                toWmsService.executionStatusReport(taskWrk.getTaskNo(), taskWrk.getWrkSts());
                            } else {
                                log.error("下发输送线任务失败:taskWrk:" + JSON.toJSONString(taskWrk));
                            }
                        } else {
                            log.error("下发输送线任务失败:taskWrk:" + JSON.toJSONString(taskWrk));
                            // 查询工作档
                            TaskWrk taskWrk = taskWrkMapper.selectCrnStaWorking(crnSlave.getId(), String.valueOf(crnStn.getStaNo() - 1));
                            if (taskWrk == null) {
                                continue;
                            }
                            log.info("下发输送线任务:taskWrk:" + JSON.toJSONString(taskWrk));
                            staProtocol.setWorkNo(taskWrk.getWrkNo().shortValue());
                            staProtocol.setStaNo(Short.valueOf(taskWrk.getTargetPoint()));
                            if (!Cools.isEmpty(taskWrk.getType())) {
                                staProtocol.setHeight(taskWrk.getType());
                            }
                            boolean offer = false;
                            try {
                                offer = MessageQueue.offer(SlaveType.Devp, 1, new Task(2, staProtocol));
                            } catch (Exception e) {
                                log.error("下发输送线任务失败:异常:" + e);
                                log.error("下发输送线任务失败:异常:offer:" + offer);
                            }
                            if (offer) {
                                log.info("下发输送线任务成功:taskWrk:" + JSON.toJSONString(taskWrk));
                                taskWrk.setStatus(5);
                                taskWrk.setWrkSts(14);
                                taskWrk.setCompleteTime(new Date());
                                taskWrkService.updateById(taskWrk);
                                // 正面出库完成 上报执行状态
                                toWmsService.executionStatusReport(taskWrk.getTaskNo(), taskWrk.getWrkSts());
                            } else {
                                log.error("下发输送线任务失败:taskWrk:" + JSON.toJSONString(taskWrk));
                            }
                        }
//                            }
                    }
                } catch (Exception e) {
@@ -421,6 +464,8 @@
            }
        }
    }
    @Resource
    private ConfigService configService;
    /**
     * 出库  ===>>  库位到堆垛机站
@@ -431,6 +476,13 @@
        if (taskWrksInitial.size() == 0) {
            return;
        }
        // 控制是否允许连续出库,不判断出库站点状态
        boolean crnAvailableOut = false;
        Config config = configService.selectOne(new EntityWrapper<Config>().eq("code","removeCrnAvailableOut"));
        if (config != null && config.getStatus() == 1) {
            crnAvailableOut = true;
        }
        for (CrnSlave.CrnStn crnStn : slave.getCrnOutStn()) {
            List<StaDesc> staDescs = staDescMapper.selectList(new EntityWrapper<StaDesc>().eq("crn_no", slave.getId()).eq("crn_stn", crnStn.getStaNo()));
            for (StaDesc staDesc : staDescs) {
@@ -461,6 +513,8 @@
                                .eq("lev1", locMast.getLev1()).eq("loc_sts", "F"));
                        if (!Cools.isEmpty(locMast1)) {
                            log.info(locMast.getLocNo() + "出深库位,浅库位有货");
                            taskWrk.setMemo("浅库位有货");
                            taskWrkService.updateById(taskWrk);
                            continue;
                        }
                    } else if (flag == 2) {
@@ -470,6 +524,8 @@
                                .eq("lev1", locMast.getLev1()).eq("loc_sts", "F"));
                        if (!Cools.isEmpty(locMast1)) {
                            log.info(locMast.getLocNo() + "出深库位,浅库位有货");
                            taskWrk.setMemo("浅库位有货");
                            taskWrkService.updateById(taskWrk);
                            continue;
                        }
                    }
@@ -490,10 +546,14 @@
                        log.error("出库 ===>> 堆垛机站点在数据库不存在, 站点编号={}", crnStn.getStaNo());
                        break;
                    }
                    // 只有205和210允许连续出库
                    if (staProtocol.getSiteId() != 205 && staProtocol.getSiteId() != 210) {
                        crnAvailableOut = false;
                    }
                    // 判断堆垛机出库站状态
                    if (staProtocol.isAutoing() && (outloading || !staProtocol.isLoading()) && staDetl.getCanouting() != null && staDetl.getCanouting().equals("Y")
                            && staProtocol.getWorkNo() == 0 && staProtocol.isOutEnable()) {
                    if (staProtocol.isAutoing()  && staDetl.getCanouting() != null && staDetl.getCanouting().equals("Y")
                            && (crnAvailableOut || !staProtocol.isLoading() && staProtocol.getWorkNo() == 0 && staProtocol.isOutEnable())) {
                        // 命令下发区 --------------------------------------------------------------------------
                        // 堆垛机控制过滤