自动化立体仓库 - WCS系统
Junjie
2023-08-02 fffbf0c777f1189c7eed623b15660dbcbe50d2a1
src/main/java/com/zy/common/utils/ShuttleDispatchUtils.java
@@ -1,10 +1,12 @@
package com.zy.common.utils;
import com.core.exception.CoolException;
import com.zy.asrs.entity.BasDevp;
import com.zy.asrs.entity.WrkCharge;
import com.zy.asrs.entity.WrkMast;
import com.zy.asrs.mapper.WrkChargeMapper;
import com.zy.asrs.mapper.WrkMastMapper;
import com.zy.asrs.service.BasDevpService;
import com.zy.asrs.service.WrkMastService;
import com.zy.asrs.utils.Utils;
import com.zy.common.model.NavigateNode;
@@ -13,9 +15,12 @@
import com.zy.core.News;
import com.zy.core.cache.SlaveConnection;
import com.zy.core.enums.SlaveType;
import com.zy.core.model.LiftSlave;
import com.zy.core.model.ShuttleSlave;
import com.zy.core.model.protocol.LiftProtocol;
import com.zy.core.model.protocol.NyShuttleProtocol;
import com.zy.core.properties.SlaveProperties;
import com.zy.core.thread.LiftThread;
import com.zy.core.thread.NyShuttleThread;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@@ -41,6 +46,8 @@
    private WrkChargeMapper wrkChargeMapper;
    @Autowired
    private CommonService commonService;
    @Autowired
    private BasDevpService basDevpService;
    /**
     * 调度车辆-调度指定穿梭车
@@ -146,7 +153,7 @@
     * 小车迁移任务生成
     */
    @Transactional
    private boolean shuttleMoveGenerate(Integer wrkNo, String locNo, Integer shuttleNo) {
    public boolean shuttleMoveGenerate(Integer wrkNo, String locNo, Integer shuttleNo) {
        Date now = new Date();
        //获取四向穿梭车线程
        NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo);
@@ -214,4 +221,41 @@
        return true;
    }
    /**
     * 获取穿梭车最近且空闲的提升机输送站点
     */
    public BasDevp getRecentLiftSta(Integer shuttleNo) {
        //获取四向穿梭车线程
        NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttleNo);
        if (shuttleThread == null) {
            return null;
        }
        NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol();
        if (shuttleProtocol == null) {
            return null;
        }
        for (LiftSlave slave : slaveProperties.getLift()) {
            LiftThread liftThread = (LiftThread) SlaveConnection.get(SlaveType.Lift, slave.getId());
            if (liftThread == null) {
                continue;
            }
            LiftProtocol liftProtocol = liftThread.getLiftProtocol();
            if (liftProtocol == null) {
                continue;
            }
            if (!liftProtocol.isIdle()) {
                continue;
            }
            BasDevp basDevp = basDevpService.selectByLevAndLiftNo(Utils.getLev(shuttleProtocol.getCurrentLocNo()), slave.getId());
            if (basDevp == null) {
                continue;
            }
            return basDevp;
        }
        return null;
    }
}