#
Junjie
4 天以前 691f0d4c4836c75fefa1d3b7fba4a72153751dd4
src/main/java/com/zy/core/dispatcher/ShuttleDispatchUtils.java
@@ -7,8 +7,10 @@
import com.zy.asrs.domain.ShuttleGatherResult;
import com.zy.asrs.domain.param.ShuttleGatherParam;
import com.zy.asrs.entity.BasShuttle;
import com.zy.asrs.entity.DeviceConfig;
import com.zy.asrs.entity.WrkMast;
import com.zy.asrs.service.BasShuttleService;
import com.zy.asrs.service.DeviceConfigService;
import com.zy.asrs.service.WrkMastService;
import com.zy.asrs.utils.Utils;
import com.zy.common.model.NavigateNode;
@@ -24,7 +26,6 @@
import com.zy.core.model.ForkLiftSlave;
import com.zy.core.model.ShuttleSlave;
import com.zy.core.model.protocol.*;
import com.zy.core.properties.SlaveProperties;
import com.zy.core.thread.ForkLiftThread;
import com.zy.core.thread.ShuttleThread;
import com.zy.system.entity.Config;
@@ -42,8 +43,6 @@
public class ShuttleDispatchUtils {
    @Autowired
    private SlaveProperties slaveProperties;
    @Autowired
    private WrkMastService wrkMastService;
    @Autowired
    private CommonService commonService;
@@ -53,6 +52,8 @@
    private ConfigService configService;
    @Autowired
    private BasShuttleService basShuttleService;
    @Autowired
    private DeviceConfigService deviceConfigService;
    /**
     * 调度车辆-调度指定穿梭车
@@ -68,15 +69,17 @@
        ArrayList<ShuttleThread> sameLev = new ArrayList<>();//相同楼层的穿梭车
        ArrayList<ShuttleThread> diffLev = new ArrayList<>();//不同楼层的穿梭车
        for (ShuttleSlave shuttle : slaveProperties.getShuttle()) {
        List<DeviceConfig> shuttleList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
                .eq("device_type", String.valueOf(SlaveType.Shuttle)));
        for (DeviceConfig device : shuttleList) {
            //获取四向穿梭车线程
            ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttle.getId());
            ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getDeviceNo());
            ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
            if (shuttleProtocol == null || shuttleProtocol.getShuttleNo() == null) {
                continue;
            }
            if (checkChargeWrk(shuttle.getId())) {
            if (checkChargeWrk(device.getDeviceNo())) {
                continue;//存在充电任务,过滤小车
            }
@@ -84,7 +87,7 @@
                continue;//小车忙碌中
            }
            BasShuttle basShuttle = basShuttleService.selectOne(new EntityWrapper<BasShuttle>().eq("shuttle_no", shuttle.getId()));
            BasShuttle basShuttle = basShuttleService.selectOne(new EntityWrapper<BasShuttle>().eq("shuttle_no", device.getDeviceNo()));
            if (basShuttle != null) {
                if (basShuttle.getStatus() == 0) {
                    continue;//小车被禁用
@@ -168,7 +171,8 @@
                    //当前穿梭车库位号
                    String currentLocNo = shuttleProtocol.getCurrentLocNo();
                    int currentLev = Utils.getLev(currentLocNo);
                    List<WrkMast> wrkMasts1 = wrkMastService.selectNoShuttleWrkByLev(currentLev);//判断当前穿梭车楼层是否有待分配车辆的任务,如果有则不分配这辆车
                    //判断当前楼层是否有任务,如果有则不分配这辆车
                    List<WrkMast> wrkMasts1 = wrkMastService.selectWrkByLev(currentLev);
                    int shuttleCount = this.getShuttleCountByLev(currentLev);//获取穿梭车楼层车辆数量
                    if (!wrkMasts1.isEmpty() && shuttleCount <= 1) {
                        //存在其他任务且可用小车数量小于等于1,跳过这辆车
@@ -340,10 +344,12 @@
            return false;
        }
        List<DeviceConfig> shuttleList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
                .eq("device_type", String.valueOf(SlaveType.Shuttle)));
        int levCount = 0;//目标楼层车辆数量
        for (ShuttleSlave shuttle : slaveProperties.getShuttle()) {
        for (DeviceConfig device : shuttleList) {
            //获取四向穿梭车线程
            ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttle.getId());
            ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getDeviceNo());
            ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
            if (shuttleProtocol == null || shuttleProtocol.getShuttleNo() == null) {
                continue;
@@ -409,11 +415,14 @@
            return null;
        }
        List<DeviceConfig> forkliftList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
                .eq("device_type", String.valueOf(SlaveType.ForkLift)));
        //获取小车同一楼层的站点
        ArrayList<ForkLiftStaProtocol> list = new ArrayList<>();
        int lev = Utils.getLev(shuttleProtocol.getCurrentLocNo());//小车楼层
        for (ForkLiftSlave slave : slaveProperties.getForkLift()) {
            ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, slave.getId());
        for (DeviceConfig device : forkliftList) {
            ForkLiftThread forkLiftThread = (ForkLiftThread) SlaveConnection.get(SlaveType.ForkLift, device.getDeviceNo());
            if (forkLiftThread == null) {
                continue;
            }
@@ -425,7 +434,7 @@
                continue;
            }
            ForkLiftStaProtocol forkLiftStaProtocol = ForkLiftUtils.getLiftStaByLev(slave.getId(), lev);
            ForkLiftStaProtocol forkLiftStaProtocol = ForkLiftUtils.getLiftStaByLev(device.getDeviceNo(), lev);
            if (forkLiftStaProtocol == null) {
                continue;
            }
@@ -440,7 +449,7 @@
            }
            //判断目标楼层站点是否无托盘
            ForkLiftStaProtocol targetLiftStaProtocol = ForkLiftUtils.getLiftStaByLev(slave.getId(), targetLev);
            ForkLiftStaProtocol targetLiftStaProtocol = ForkLiftUtils.getLiftStaByLev(device.getDeviceNo(), targetLev);
            if (targetLiftStaProtocol == null) {
                continue;
            }
@@ -500,10 +509,12 @@
     * 获取楼层可用小车数量
     */
    public int getShuttleCountByLev(int lev) {
        List<DeviceConfig> shuttleList = deviceConfigService.selectList(new EntityWrapper<DeviceConfig>()
                .eq("device_type", String.valueOf(SlaveType.Shuttle)));
        int count = 0;
        for (ShuttleSlave slave : slaveProperties.getShuttle()) {
        for (DeviceConfig device : shuttleList) {
            //获取四向穿梭车线程
            ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, slave.getId());
            ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getDeviceNo());
            if (shuttleThread == null) {
                continue;
            }
@@ -513,7 +524,7 @@
                continue;
            }
            if (checkChargeWrk(slave.getId())) {
            if (checkChargeWrk(device.getDeviceNo())) {
                continue;//存在充电任务,过滤小车
            }