自动化立体仓库 - WCS系统
#
Junjie
2023-10-05 69e1880e5486ebc62da4806642ca817afda9c84c
src/main/java/com/zy/common/utils/ShuttleDispatchUtils.java
@@ -1,12 +1,17 @@
package com.zy.common.utils;
import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.mapper.EntityWrapper;
import com.core.common.SpringUtils;
import com.core.exception.CoolException;
import com.zy.asrs.entity.BasDevp;
import com.zy.asrs.entity.BasShuttle;
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.BasShuttleService;
import com.zy.asrs.service.WrkMastService;
import com.zy.asrs.utils.Utils;
import com.zy.common.model.NavigateNode;
@@ -24,6 +29,8 @@
import com.zy.core.properties.SlaveProperties;
import com.zy.core.thread.LiftThread;
import com.zy.core.thread.NyShuttleThread;
import com.zy.system.entity.Config;
import com.zy.system.service.ConfigService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -131,6 +138,13 @@
            if (wrkMast1 != null) {
                int lev = Utils.getLev(wrkMast1.getLocNo());//目标楼层
                //检测目标楼层车数量是否小于允许的最大数量
                boolean checkDispatchMaxNum = checkDispatchMaxNum(lev);
                if (!checkDispatchMaxNum) {
                    return false;
                }
                int recentValue = 99999;//最小差值
                for (NyShuttleThread shuttleThread : diffLev) {
                    //当前穿梭车库位号
@@ -266,6 +280,48 @@
    }
    /**
     * 检测目标楼层车数量是否小于允许的最大数量
     * true: 小于最大数量  false: 大于或等于最大数量
     */
    public boolean checkDispatchMaxNum(Integer lev) {
        BasShuttleService basShuttleService = SpringUtils.getBean(BasShuttleService.class);
        ConfigService configService = SpringUtils.getBean(ConfigService.class);
        EntityWrapper<Config> wrapper = new EntityWrapper<>();
        wrapper.eq("code", "dispatchShuttleMaxNum");
        Config config = configService.selectOne(wrapper);
        if (config == null) {
            return false;
        }
        int levCount = 0;//目标楼层车辆数量
        for (ShuttleSlave shuttle : slaveProperties.getShuttle()) {
            //获取四向穿梭车线程
            NyShuttleThread shuttleThread = (NyShuttleThread) SlaveConnection.get(SlaveType.Shuttle, shuttle.getId());
            NyShuttleProtocol shuttleProtocol = shuttleThread.getShuttleProtocol();
            if (shuttleProtocol == null || shuttleProtocol.getShuttleNo() == null) {
                continue;
            }
            NyShuttleProtocol.NyShuttlePointClass point = null;
            if (shuttleProtocol.getPoint() == null) {
                BasShuttle basShuttle = basShuttleService.selectById(shuttle.getId());//小车如果没有数据,从数据库取数据
                if (basShuttle == null || basShuttle.getPoint() == null) {
                    continue;
                }
                point = JSON.parseObject(basShuttle.getPoint(), NyShuttleProtocol.NyShuttlePointClass.class);
            }else {
                point = shuttleProtocol.getPoint();
            }
            if (point.getZ().equals(lev)) {
                levCount++;//目标楼层有车,数量增加
            }
        }
        return levCount < Integer.parseInt(config.getValue());
    }
    /**
     * 获取穿梭车最近且空闲的提升机输送站点
     */
    public LiftStaProtocol getRecentLiftSta(Integer shuttleNo) {