| | |
| | | import com.zy.asrs.wcs.rcs.News; |
| | | import com.zy.asrs.wcs.rcs.cache.SlaveConnection; |
| | | import com.zy.asrs.wcs.rcs.entity.Device; |
| | | import com.zy.asrs.wcs.rcs.model.enums.ShuttleProtocolStatusType; |
| | | import com.zy.asrs.wcs.rcs.model.enums.SlaveType; |
| | | import com.zy.asrs.wcs.rcs.model.protocol.ShuttleProtocol; |
| | | import com.zy.asrs.wcs.rcs.service.DeviceService; |
| | |
| | | } |
| | | |
| | | /** |
| | | * 搜索避让库位,通过小车号和目标库位 |
| | | * 搜索可用库位,通过小车号和目标库位 |
| | | */ |
| | | public String searchStandByLocNo(Integer shuttleNo, Long hostId, String locNo) { |
| | | public String searchAvailableLocNo(Integer shuttleNo, Long hostId, String currentLocNo, List<String> locNos) { |
| | | BasShuttle basShuttle = basShuttleService.getOne(new LambdaQueryWrapper<BasShuttle>() |
| | | .eq(BasShuttle::getShuttleNo, shuttleNo) |
| | | .eq(BasShuttle::getHostId, hostId)); |
| | |
| | | throw new CoolException("小车基础数据不存在"); |
| | | } |
| | | |
| | | String idleLoc = basShuttle.getIdleLoc(); |
| | | if (Cools.isEmpty(idleLoc)) { |
| | | throw new CoolException("小车避让数据不存在"); |
| | | } |
| | | |
| | | int lev = Utils.getLev(locNo);//当前楼层 |
| | | List<String> standbyLoc = JSON.parseArray(idleLoc, String.class); |
| | | if (standbyLoc.isEmpty()) { |
| | | throw new CoolException("避让数据异常"); |
| | | } |
| | | //获取当前层避让位置 |
| | | List<String> currentLevStandByLoc = new ArrayList<>(); |
| | | for (String loc : standbyLoc) { |
| | | if (Utils.getLev(loc) == lev) { |
| | | currentLevStandByLoc.add(loc); |
| | | } |
| | | } |
| | | if (currentLevStandByLoc.isEmpty()) { |
| | | if (locNos.isEmpty()) { |
| | | throw new CoolException("当前层无避让位置"); |
| | | } |
| | | |
| | | int lev = Utils.getLev(currentLocNo); |
| | | |
| | | Integer finalDistance = ShuttleDispatcher.INF; |
| | | String recentLoc = null; |
| | | for (String loc : currentLevStandByLoc) { |
| | | for (String loc : locNos) { |
| | | //当前穿梭车到避让位计算 |
| | | List<NavigateNode> currentShuttlePath = NavigateUtils.calc( |
| | | locNo |
| | | currentLocNo |
| | | , loc |
| | | , NavigationMapType.NORMAL.id |
| | | , Utils.getShuttlePoints(shuttleNo, lev) |
| | |
| | | |
| | | ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); |
| | | if (shuttleProtocol == null) { |
| | | continue; |
| | | } |
| | | |
| | | if (shuttleProtocol.getProtocolStatusType().equals(ShuttleProtocolStatusType.OFFLINE)) { |
| | | continue; |
| | | } |
| | | |
| | | if(!shuttleThread.isDeviceIdle()) { |
| | | continue; |
| | | } |
| | | |
| | | if(shuttleProtocol.getCurrentLocNo() == null) { |
| | | continue; |
| | | } |
| | | |
| | |
| | | return levCount < Integer.parseInt(dict.getValue()); |
| | | } |
| | | |
| | | //分析出库路径待机库位 |
| | | public String analyzeOutPathWaitLoc(String startLoc, String targetLoc, Device shuttleDevice) { |
| | | //计算路径并分解成两段动作 |
| | | List<NavigateNode> nodeList = NavigateUtils.calc(startLoc, targetLoc, NavigationMapType.DFX.id, Utils.getShuttlePoints(Integer.parseInt(shuttleDevice.getDeviceNo()), Utils.getLev(startLoc))); |
| | | if (nodeList == null) { |
| | | News.error("{} dash {} can't find navigate path!", startLoc, targetLoc); |
| | | return null; |
| | | } |
| | | //获取分段路径 |
| | | ArrayList<ArrayList<NavigateNode>> data = NavigateUtils.getSectionPath(nodeList); |
| | | if (data.size() <= 1) { |
| | | return null;//两点之间只有一段路径 |
| | | } |
| | | |
| | | //取出倒数第二段路径 |
| | | ArrayList<NavigateNode> navigateNodes = data.get(data.size() - 2); |
| | | NavigateNode startNode = navigateNodes.get(0); |
| | | String lastPathStartLoc = Utils.getLocNo(startNode.getX(), startNode.getY(), startNode.getZ()); |
| | | return lastPathStartLoc; |
| | | } |
| | | |
| | | |
| | | } |