fyxc
2025-05-22 09fcc4ec56a1ce6c0fcb308348d8dd5e2c08d336
src/main/java/com/zy/core/dispatcher/ShuttleDispatchUtils.java
@@ -30,7 +30,6 @@
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.rmi.CORBA.Util;
import java.util.*;
/**
@@ -363,7 +362,7 @@
    /**
     * 调度车辆
     */
    public boolean searchDispatchShuttleNoLift(Integer wrkNo, String sourceLocNo, String locNo, String flag) {
    public synchronized boolean searchDispatchShuttleNoLift(Integer wrkNo, String sourceLocNo, String locNo, String flag) {
        ArrayList<ShuttleThread> diffLev = new ArrayList<>();//不同楼层的穿梭车
        int lev1 = 0;
        boolean tongLev = false;
@@ -389,6 +388,10 @@
                    continue;//小车被禁用
                }
            }
            WrkMast wrkMast = wrkMastService.selectByShuttleNo(basShuttle.getShuttleNo());
            if(wrkMast!=null){
                continue;
            }
            diffLev.add(shuttleThread);
            if (lev1 != 0) {
                if (lev1 == Utils.getLev(shuttleProtocol.getCurrentLocNo())) {
@@ -399,7 +402,7 @@
            }
        }
        //寻找离任务楼层最近的穿梭车(不考虑跨楼层小车移动距离)
        //
        if (!diffLev.isEmpty()) {
            Map<Integer, ShuttleThread> diffShuttles = new TreeMap<>();//自然排序小车Map
            //获取任务
@@ -420,11 +423,11 @@
                //检测目标楼层车数量是否小于允许的最大数量
                boolean checkDispatchMaxNum = checkDispatchMaxNum(lev);
                if (!checkDispatchMaxNum) {
                    News.info("{}任务,{}层,已经达到当前楼层调度车辆最大值", wrkMast1.getWrkNo(), lev);
                    return false;
                }
//                boolean checkDispatchMaxNum = checkDispatchMaxNum(lev);
//                if (!checkDispatchMaxNum) {
//                    News.info("{}任务,{}层,已经达到当前楼层调度车辆最大值", wrkMast1.getWrkNo(), lev);
//                    return false;
//                }
                for (ShuttleThread shuttleThread : diffLev) {
                    ShuttleProtocol shuttleProtocol = shuttleThread.getStatus();
@@ -434,25 +437,35 @@
                    if (wrkMast1.getIoType() == 101 && currentLocNo.equals(locNo)) {
                        //车辆当前位置已经是目标库位,调度该车
                        //给工作档绑定小车号
                        diffShuttles.put(-1, shuttleThread);
                        diffShuttles.put(-2, shuttleThread);
                    } else {
                        if (tongLev && diffLev.size() >= 2) {
                            //当前穿梭车线程到目标地点距离
                            List<NavigateNode> currentShuttlePath = navigateUtils.calc(currentLocNo, locNo, NavigationMapType.NORMAL.id, Utils.getShuttlePoints(shuttleProtocol.getShuttleNo(), Utils.getLev(currentLocNo)), null);//搜索空闲穿梭车,使用正常通道地图
                            if (currentShuttlePath == null) {
                                continue;
                            }
                            Integer currentAllDistance = navigateUtils.getOriginPathAllDistance(currentShuttlePath);//计算当前路径行走总距离
                            diffShuttles.put(currentAllDistance, shuttleThread);
                        } else {
                            //ABS(目标楼层 - 当前楼层) 得到差距,取最小差值
                            int currentValue = Math.abs(lev - currentLev);
                            if (diffShuttles.get(currentValue) != null) {
//                        if (tongLev && diffLev.size() >= 2) {
//                            //当前穿梭车线程到目标地点距离
//                            List<NavigateNode> currentShuttlePath = navigateUtils.calc(currentLocNo, locNo, NavigationMapType.NORMAL.id, Utils.getShuttlePoints(shuttleProtocol.getShuttleNo(), Utils.getLev(currentLocNo)), null);//搜索空闲穿梭车,使用正常通道地图
//                            if (currentShuttlePath == null) {
//                                continue;
//                            }
//                            Integer currentAllDistance = navigateUtils.getOriginPathAllDistance(currentShuttlePath);//计算当前路径行走总距离
//                            diffShuttles.put(currentAllDistance, shuttleThread);
//                        } else {
                        //ABS(目标楼层 - 当前楼层) 得到差距,取最小差值
                        int currentValue = Math.abs(lev - currentLev);
                        if (diffShuttles.get(currentValue) != null) {
                            try {
                                List<NavigateNode> currentShuttlePath = navigateUtils.calc(currentLocNo, locNo, NavigationMapType.NORMAL.id, Utils.getShuttlePoints(shuttleProtocol.getShuttleNo(), Utils.getLev(currentLocNo)), null);//搜索空闲穿梭车,使用正常通道地图
                                if (currentShuttlePath == null) {
                                    continue;
                                }
                                Integer currentAllDistance = navigateUtils.getOriginPathAllDistance(currentShuttlePath);//计算当前路径行走总距离
                                diffShuttles.put(currentAllDistance, shuttleThread);
                                diffShuttles.put(currentValue - 1, shuttleThread);
                            } catch (Exception e) {
                                diffShuttles.put(currentValue + 1, shuttleThread);
                            } else {
                                diffShuttles.put(currentValue, shuttleThread);
                            }
                        } else {
                            diffShuttles.put(currentValue, shuttleThread);
                        }
                        //                   }
                    }
                }