| | |
| | | Integer shuttleNo = shuttleProtocol.getShuttleNo(); |
| | | //获取小车移动速度 |
| | | Integer runSpeed = Optional.ofNullable(basShuttleService.selectOne(new EntityWrapper<BasShuttle>().eq("shuttle_no", shuttleNo)).getRunSpeed()).orElse(1000); |
| | | List<NavigateNode> nodeList = navigateUtils.calc(startLocNo, endLocNo, mapType, Utils.getShuttlePoints(shuttleNo, Utils.getLev(startLocNo)), whites); |
| | | if (nodeList == null) { |
| | | News.error("{} dash {} can't find navigate path!", startLocNo, endLocNo); |
| | | shuttleThread.offerSystemMsg("{} dash {} can't find navigate path!", startLocNo, endLocNo); |
| | | return null; |
| | | } |
| | | |
| | | List<NavigateNode> allNode = new ArrayList<>(); |
| | | List<NavigateNode> lockNode = new ArrayList<>(); |
| | | for (NavigateNode node : nodeList) { |
| | | allNode.add(node.clone()); |
| | | |
| | | if (whites != null) { |
| | | boolean flag = false; |
| | | for (int[] white : whites) { |
| | | if(white[0] == node.getX() && white[1] == node.getY()) { |
| | | flag = true; |
| | | break; |
| | | } |
| | | } |
| | | |
| | | if (flag) {//白名单跳过锁定 |
| | | continue; |
| | | } |
| | | } |
| | | lockNode.add(node.clone()); |
| | | } |
| | | |
| | | List<ShuttleCommand> commands = new ArrayList<>(); |
| | | //获取分段路径 |
| | | ArrayList<ArrayList<NavigateNode>> data = navigateUtils.getSectionPath(nodeList); |
| | | //将每一段路径分成command指令 |
| | | for (ArrayList<NavigateNode> nodes : data) { |
| | | //开始路径 |
| | | NavigateNode startPath = nodes.get(0); |
| | | |
| | | //目标路径 |
| | | NavigateNode endPath = nodes.get(nodes.size() - 1); |
| | | Integer allDistance = navigateUtils.getCurrentPathAllDistance(nodes);//计算当前路径行走总距离 |
| | | //通过xy坐标小车二维码 |
| | | String startCodeNum = NavigatePositionConvert.xyToPosition(startPath.getX(), startPath.getY(), startPath.getZ()); |
| | | //通过xy坐标小车二维码 |
| | | String distCodeNum = NavigatePositionConvert.xyToPosition(endPath.getX(), endPath.getY(), endPath.getZ()); |
| | | //获取移动命令 |
| | | ShuttleCommand command = shuttleThread.getMoveCommand(assignCommand.getDeviceTaskNo(), startCodeNum, distCodeNum, allDistance, ShuttleRunDirection.get(startPath.getDirection()).id.intValue(), runSpeed, nodes); |
| | | command.setNodes(nodes);//将行走节点添加到每一步命令中 |
| | | commands.add(command); |
| | | } |
| | | |
| | | assignCommand.setNodes(allNode);//当前任务所占用的节点list |
| | | |
| | | boolean result = navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(startLocNo), shuttleNo, lockNode, true);//锁定路径 |
| | | if (!result) { |
| | | News.error("{} dash {} can't lock path!", startLocNo, endLocNo); |
| | | shuttleThread.offerSystemMsg("{} dash {} can't lock path!", startLocNo, endLocNo); |
| | | return null;//路径锁定失败 |
| | | } |
| | | return commands; |
| | | } |
| | | |
| | | public synchronized List<ShuttleCommand> shuttleInOutLiftCommand(String startLocNo, String endLocNo, Integer mapType, ShuttleAssignCommand assignCommand, ShuttleThread shuttleThread) { |
| | | NavigateNode startNode = NavigatePositionConvert.locNoToNode(startLocNo); |
| | | NavigateNode endNode = NavigatePositionConvert.locNoToNode(endLocNo); |
| | | List<NavigateNode> unlockPath = new ArrayList<>(); |
| | | unlockPath.add(startNode); |
| | | unlockPath.add(endNode); |
| | | |
| | | ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); |
| | | if (shuttleProtocol == null) { |
| | | return null; |
| | | } |
| | | |
| | | Integer shuttleNo = shuttleProtocol.getShuttleNo(); |
| | | //所使用的路径进行锁定/解锁 |
| | | boolean lockResult = navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(endLocNo), shuttleProtocol.getShuttleNo(), unlockPath, false);//所使用的路径进行解锁 |
| | | if (!lockResult) { |
| | | News.error("{} dash {} can't find unlock path!", startLocNo, endLocNo); |
| | | shuttleThread.offerSystemMsg("{} dash {} can't find unlock path!", startLocNo, endLocNo); |
| | | return null;//解锁失败 |
| | | } |
| | | |
| | | //获取小车移动速度 |
| | | Integer runSpeed = Optional.ofNullable(basShuttleService.selectOne(new EntityWrapper<BasShuttle>().eq("shuttle_no", shuttleNo)).getRunSpeed()).orElse(1000); |
| | | List<NavigateNode> nodeList = navigateUtils.calc(startLocNo, endLocNo, mapType, Utils.getShuttlePoints(shuttleNo, Utils.getLev(startLocNo)), null); |
| | | if (nodeList == null) { |
| | | News.error("{} dash {} can't find navigate path!", startLocNo, endLocNo); |
| | | shuttleThread.offerSystemMsg("{} dash {} can't find navigate path!", startLocNo, endLocNo); |
| | | return null; |
| | | } |
| | | |
| | |
| | | return commands; |
| | | } |
| | | |
| | | public synchronized List<ShuttleCommand> shuttleInOutLiftCommand(String startLocNo, String endLocNo, Integer mapType, ShuttleAssignCommand assignCommand, ShuttleThread shuttleThread) { |
| | | NavigateNode startNode = NavigatePositionConvert.locNoToNode(startLocNo); |
| | | NavigateNode endNode = NavigatePositionConvert.locNoToNode(endLocNo); |
| | | List<NavigateNode> unlockPath = new ArrayList<>(); |
| | | unlockPath.add(startNode); |
| | | unlockPath.add(endNode); |
| | | |
| | | ShuttleProtocol shuttleProtocol = shuttleThread.getStatus(); |
| | | if (shuttleProtocol == null) { |
| | | return null; |
| | | } |
| | | |
| | | Integer shuttleNo = shuttleProtocol.getShuttleNo(); |
| | | //所使用的路径进行锁定/解锁 |
| | | boolean lockResult = navigateMapUtils.writeNavigateNodeToRedisMap(Utils.getLev(endLocNo), shuttleProtocol.getShuttleNo(), unlockPath, false);//所使用的路径进行解锁 |
| | | if (!lockResult) { |
| | | News.error("{} dash {} can't find unlock path!", startLocNo, endLocNo); |
| | | return null;//解锁失败 |
| | | } |
| | | |
| | | //获取小车移动速度 |
| | | Integer runSpeed = Optional.ofNullable(basShuttleService.selectOne(new EntityWrapper<BasShuttle>().eq("shuttle_no", shuttleNo)).getRunSpeed()).orElse(1000); |
| | | List<NavigateNode> nodeList = navigateUtils.calc(startLocNo, endLocNo, mapType, Utils.getShuttlePoints(shuttleNo, Utils.getLev(startLocNo)), null); |
| | | if (nodeList == null) { |
| | | News.error("{} dash {} can't find navigate path!", startLocNo, endLocNo); |
| | | return null; |
| | | } |
| | | |
| | | List<NavigateNode> allNode = new ArrayList<>(); |
| | | for (NavigateNode node : nodeList) { |
| | | allNode.add(node.clone()); |
| | | } |
| | | |
| | | /** |
| | | * 获取充电命令 |
| | | */ |
| | | public synchronized List<ShuttleCommand> getShuttleChargeCommand(ShuttleAssignCommand assignCommand, ShuttleThread shuttleThread, Boolean openCharge) { |
| | | List<ShuttleCommand> commands = new ArrayList<>(); |
| | | //获取分段路径 |
| | | ArrayList<ArrayList<NavigateNode>> data = navigateUtils.getSectionPath(nodeList); |
| | | //将每一段路径分成command指令 |
| | | for (ArrayList<NavigateNode> nodes : data) { |
| | | //开始路径 |
| | | NavigateNode startPath = nodes.get(0); |
| | | |
| | | //目标路径 |
| | | NavigateNode endPath = nodes.get(nodes.size() - 1); |
| | | Integer allDistance = navigateUtils.getCurrentPathAllDistance(nodes);//计算当前路径行走总距离 |
| | | //通过xy坐标小车二维码 |
| | | String startCodeNum = NavigatePositionConvert.xyToPosition(startPath.getX(), startPath.getY(), startPath.getZ()); |
| | | //通过xy坐标小车二维码 |
| | | String distCodeNum = NavigatePositionConvert.xyToPosition(endPath.getX(), endPath.getY(), endPath.getZ()); |
| | | //获取移动命令 |
| | | ShuttleCommand command = shuttleThread.getMoveCommand(assignCommand.getDeviceTaskNo(), startCodeNum, distCodeNum, allDistance, ShuttleRunDirection.get(startPath.getDirection()).id.intValue(), runSpeed, nodes); |
| | | command.setNodes(nodes);//将行走节点添加到每一步命令中 |
| | | commands.add(command); |
| | | } |
| | | //获取充电命令 |
| | | ShuttleCommand command = shuttleThread.getChargeCommand(assignCommand.getDeviceTaskNo(), openCharge); |
| | | commands.add(command); |
| | | return commands; |
| | | } |
| | | |
| | | assignCommand.setNodes(allNode);//当前任务所占用的节点list |
| | | /** |
| | | * 获取顶升命令 |
| | | */ |
| | | public synchronized List<ShuttleCommand> getShuttleLiftCommand(ShuttleAssignCommand assignCommand, ShuttleThread shuttleThread, Boolean lift) { |
| | | List<ShuttleCommand> commands = new ArrayList<>(); |
| | | |
| | | //获取顶升命令 |
| | | ShuttleCommand command = shuttleThread.getLiftCommand(assignCommand.getDeviceTaskNo(), lift); |
| | | commands.add(command); |
| | | return commands; |
| | | } |
| | | |