| | |
| | | */ |
| | | @Override |
| | | public AccessTokenReceiver getAccessToken(String serverId) { |
| | | |
| | | return ardServerService.getAccessToken(serverId); |
| | | } |
| | | |
| | |
| | | @Override |
| | | public List<BoxInfoReceiver> getBoxList() { |
| | | List<ArdServerInfo> ardServerInfos = ardServerService.selectArdServerManagementList(new ArdServerInfo()); |
| | | |
| | | return ardServerInfos.stream() |
| | | .flatMap(ardServerInfo -> { |
| | | String baseUrl = "http://" + ardServerInfo.getHost() + ":" + ardServerInfo.getHttpPort(); |
| | | try { |
| | | List<BoxInfoReceiver> boxes = tyClient.getBoxList(baseUrl).getContent(); |
| | | return Optional.ofNullable(boxes).orElse(Collections.emptyList()).stream(); |
| | | } catch (Exception e) { |
| | | log.error("获取云盒列表失败: {}", baseUrl, e); |
| | | return Stream.empty(); |
| | | } |
| | | }) |
| | | .collect(Collectors.toList()); |
| | | return getBoxList(ardServerInfos); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取直播地址 |
| | |
| | | */ |
| | | @Override |
| | | public BoxStreamUrlReceiver getBoxLiveUrl(String boxSn) { |
| | | |
| | | ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSn); |
| | | String baseUrl="http://"+ardDroneInfo.getArdServerInfo().getHost()+":"+ardDroneInfo.getArdServerInfo().getHttpPort(); |
| | | TyHttpCommonReceiver<BoxStreamUrlReceiver> boxLiveUrl = tyClient.getBoxLiveUrl(baseUrl,boxSn); |
| | |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 根据boxSn获取六合盒子列表 |
| | | * @return List<BoxInfoReceiver> |
| | | */ |
| | | @Override |
| | | public List<BoxInfoReceiver> getBoxSnToList(String boxSn) { |
| | | ArdServerInfo serverInfo = new ArdServerInfo(); |
| | | serverInfo.setHost(boxSn); |
| | | List<ArdServerInfo> ardServerInfos = ardServerService.selectArdServerManagementList(serverInfo); |
| | | return getBoxList(ardServerInfos); |
| | | } |
| | | |
| | | private List<BoxInfoReceiver> getBoxList(List<ArdServerInfo> ls) { |
| | | return ls.stream() |
| | | .flatMap(ardServerInfo -> { |
| | | String baseUrl = "http://" + ardServerInfo.getHost() + ":" + ardServerInfo.getHttpPort(); |
| | | try { |
| | | List<BoxInfoReceiver> boxes = tyClient.getBoxList(baseUrl).getContent(); |
| | | return Optional.ofNullable(boxes).orElse(Collections.emptyList()).stream(); |
| | | } catch (Exception e) { |
| | | log.error("获取云盒列表失败: {}", baseUrl, e); |
| | | return Stream.empty(); |
| | | } |
| | | }) |
| | | .collect(Collectors.toList()); |
| | | } |
| | | |
| | | //公共日志打印 |
| | | private void logPrint(String message, Object obj) { |
| | | log.debug("收到{}回复{}", message, obj); |
| | |
| | | |
| | | |
| | | /** |
| | | * 定时向所有已连接的天宇服务器发送心跳 |
| | | * 定时向所有已连接的六合服务器发送心跳 |
| | | */ |
| | | @Scheduled(fixedRate = 5000) // 每5秒执行一次 |
| | | public void sendHeartBeat() { |