| | |
| | | //获取同层小车 |
| | | 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()); |
| | |
| | | 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); |
| | | } |
| | | } |
| | | //搜索同层 |
| | |
| | | |
| | | //同层没有搜索到合适小车,跨楼层搜索 |
| | | if(resThread == null) { |
| | | resThread = this.searchDiffLevShuttle(diffLevDevices, locNo, task); |
| | | resThread = this.searchDiffLevShuttle(diffLevDeviceMap, locNo, task); |
| | | } |
| | | |
| | | return resThread; |
| | |
| | | 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; |
| | |
| | | } |
| | | } |
| | | |
| | | if (resThread != null) { |
| | | break; |
| | | } |
| | | } |
| | | return resThread; |
| | | } |
| | | |