Junjie
2024-12-13 d9cea3d7757a8d580bb0574d419ba6dd9c2478e7
#search shuttle
1个文件已修改
25 ■■■■ 已修改文件
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/ShuttleDispatcher.java 25 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
zy-asrs-wcs/src/main/java/com/zy/asrs/wcs/core/utils/ShuttleDispatcher.java
@@ -70,7 +70,7 @@
        //获取同层小车
        List<Device> currentLevDevices = new ArrayList<>();
        //获取跨层小车
        List<Device> diffLevDevices = new ArrayList<>();
        HashMap<Integer,List<Device>> diffLevDeviceMap = new HashMap<>();
        for (Device device : list) {
            //获取四向穿梭车线程
            ShuttleThread shuttleThread = (ShuttleThread) SlaveConnection.get(SlaveType.Shuttle, device.getId().intValue());
@@ -79,10 +79,18 @@
                continue;
            }
            if (Utils.getLev(shuttleProtocol.getCurrentLocNo()) == lev) {
            int shuttleLev = Utils.getLev(shuttleProtocol.getCurrentLocNo());
            if (shuttleLev == lev) {
                currentLevDevices.add(device);
            }else {
                diffLevDevices.add(device);
                List<Device> devices = null;
                if(diffLevDeviceMap.containsKey(shuttleLev)) {
                    devices = diffLevDeviceMap.get(shuttleLev);
                }else {
                    devices = new ArrayList<>();
                }
                devices.add(device);
                diffLevDeviceMap.put(shuttleLev, devices);
            }
        }
        //搜索同层
@@ -90,7 +98,7 @@
        //同层没有搜索到合适小车,跨楼层搜索
        if(resThread == null) {
            resThread = this.searchDiffLevShuttle(diffLevDevices, locNo, task);
            resThread = this.searchDiffLevShuttle(diffLevDeviceMap, locNo, task);
        }
        return resThread;
@@ -173,13 +181,16 @@
        return resThread;
    }
    private synchronized ShuttleThread searchDiffLevShuttle(List<Device> devices, String locNo, Task task) {
    private synchronized ShuttleThread searchDiffLevShuttle(HashMap<Integer,List<Device>> devicesMap, String locNo, Task task) {
        ShuttleThread resThread = null;
        Integer finalDistance = ShuttleDispatcher.INF;
        //检测目标楼层车数量是否小于允许的最大数量
        boolean checkDispatchMaxNum = checkDispatchMaxNum(Utils.getLev(locNo), task.getHostId());
        for (Map.Entry<Integer, List<Device>> entry : devicesMap.entrySet()) {
            Integer lev = entry.getKey();
            List<Device> devices = entry.getValue();
        for (Device device : devices) {
            if (taskService.hasBusyOutboundByShuttle(Integer.parseInt(device.getDeviceNo()))) {
                continue;
@@ -269,6 +280,10 @@
            }
        }
            if (resThread != null) {
                break;
            }
        }
        return resThread;
    }