liusuyi
2025-10-14 39e8bb722006c55fb986a7394bfb4747d482b8c4
ard-work/src/main/java/com/ard/work/service/impl/TyServiceImpl.java
@@ -59,6 +59,7 @@
import javax.annotation.Resource;
import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Optional;
@@ -112,8 +113,7 @@
    @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);
        TyHttpCommonReceiver<BoxStreamUrlReceiver> boxLiveUrl = tyClient.getBoxLiveUrl(ardDroneInfo.getServerInfoId(),boxSn);
        return boxLiveUrl.getContent();
    }
@@ -125,8 +125,8 @@
    @Override
    public List<BoxHistoryReceiver> getBoxHistory(BoxHistoryDTO boxHistoryDTO) {
        ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxHistoryDTO.getBoxSn());
        String baseUrl="http://"+ardDroneInfo.getArdServerInfo().getHost()+":"+ardDroneInfo.getArdServerInfo().getHttpPort();
        TyHttpCommonReceiver<List<BoxHistoryReceiver>> boxHistory = tyClient.getBoxHistory(baseUrl,boxHistoryDTO);
        TyHttpCommonReceiver<List<BoxHistoryReceiver>> boxHistory = tyClient.getBoxHistory(ardDroneInfo.getServerInfoId(),
                boxHistoryDTO);
        return boxHistory.getContent();
    }
@@ -138,8 +138,7 @@
    @Override
    public List<BoxPhotosReceiver> getBoxPhotos(BoxPhotosDTO boxPhotosDTO) {
        ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxPhotosDTO.getBoxSn());
        String baseUrl="http://"+ardDroneInfo.getArdServerInfo().getHost()+":"+ardDroneInfo.getArdServerInfo().getHttpPort();
        TyHttpCommonReceiver<List<BoxPhotosReceiver>> boxPhotos = tyClient.getBoxPhotos(baseUrl,boxPhotosDTO);
        TyHttpCommonReceiver<List<BoxPhotosReceiver>> boxPhotos = tyClient.getBoxPhotos(ardDroneInfo.getServerInfoId(),boxPhotosDTO);
        return boxPhotos.getContent();
    }
@@ -149,8 +148,7 @@
    @Override
    public Boolean updateBoxSettings(BoxSettingsDTO boxSettingsDTO) {
        ArdDroneInfo ardDroneInfo = ardDroneService.selectArdDroneByboxSn(boxSettingsDTO.getBoxSn());
        String baseUrl="http://"+ardDroneInfo.getArdServerInfo().getHost()+":"+ardDroneInfo.getArdServerInfo().getHttpPort();
        TyHttpCommonReceiver<?> result = tyClient.updateBoxSettings(baseUrl,boxSettingsDTO);
        TyHttpCommonReceiver<?> result = tyClient.updateBoxSettings(ardDroneInfo.getServerInfoId(),boxSettingsDTO);
        return result.getState() == 1;
    }
@@ -843,22 +841,26 @@
     * @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);
    public List<BoxInfoReceiver> getBoxSnToList(String id) {
        List<BoxInfoReceiver> lisbox = new ArrayList<>();
        try {
            lisbox = tyClient.getBoxList(id).getContent();
            return lisbox;
        } catch (Exception e) {
            log.error("获取云盒列表失败: {}", id, e);
            return lisbox;
        }
    }
    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();
                        List<BoxInfoReceiver> boxes = tyClient.getBoxList(ardServerInfo.getId()).getContent();
                        return Optional.ofNullable(boxes).orElse(Collections.emptyList()).stream();
                    } catch (Exception e) {
                        log.error("获取云盒列表失败: {}", baseUrl, e);
                        log.error("获取云盒列表失败: {}", ardServerInfo.getId(), e);
                        return Stream.empty();
                    }
                })