mac
2024-09-28 8c1e2e91e3f20af896c1863d0e8fad51b632b24f
app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java
@@ -1166,19 +1166,63 @@
            @Override
            public void onError(HDLLinkException e) {
                //外网只有1种情况(本地搜索逆变器列表失败了)
                //向云端获取逆变器列表
                getCloudInverterDeviceList(homeId, new CloudCallBeak<List<CloudInverterDeviceBean>>() {
                    @Override
                    public void onSuccess(List<CloudInverterDeviceBean> list) {
                        //外网进来先【默认】清空本地逆变器列表
                        HDLLinkLocalGateway.getInstance().getGatewayList().clear();
                        setDeviceRemoteInfo(list, homeId, cloudCallBeak);
                    public void onSuccess(List<CloudInverterDeviceBean> cloudInverterList) {
                        //再向云端获取负载中心列表
                        getLoadCentreDeviceList(homeId, new CloudCallBeak<List<CloudInverterDeviceBean>>() {
                            @Override
                            public void onSuccess(List<CloudInverterDeviceBean> loadCentreDeviceList) {
                                //外网进来先【默认】清空本地逆变器列表
                                HDLLinkLocalGateway.getInstance().getGatewayList().clear();
                                List<CloudInverterDeviceBean> newList = new ArrayList<>();
                                if (cloudInverterList != null) {
                                    newList.addAll(cloudInverterList);
                                }
                                if (loadCentreDeviceList != null) {
                                    newList.addAll(loadCentreDeviceList);
                                }
                                //逆变器列表和负载中心列表相加
                                setDeviceRemoteInfo(newList, homeId, cloudCallBeak);
                            }
                            @Override
                            public void onFailure(HDLException e) {
                                //外网进来先【默认】清空本地逆变器列表
                                //向云端获取负载中心列表失败,直接返回逆变器列表;
                                HDLLinkLocalGateway.getInstance().getGatewayList().clear();
                                setDeviceRemoteInfo(cloudInverterList, homeId, cloudCallBeak);
                            }
                        });
//                        //外网进来先【默认】清空本地逆变器列表
//                        HDLLinkLocalGateway.getInstance().getGatewayList().clear();
//                        setDeviceRemoteInfo(list, homeId, cloudCallBeak);
                    }
                    @Override
                    public void onFailure(HDLException e) {
                        if (cloudCallBeak != null) {
                            cloudCallBeak.onFailure(e);
                        }
                        //向云端获取逆变器列表失败
                        //再向云端获取负载中心列表
                        getLoadCentreDeviceList(homeId, new CloudCallBeak<List<CloudInverterDeviceBean>>() {
                            @Override
                            public void onSuccess(List<CloudInverterDeviceBean> loadCentreDeviceList) {
                                //外网进来先【默认】清空本地逆变器列表
                                HDLLinkLocalGateway.getInstance().getGatewayList().clear();
                                //逆变器列表和负载中心列表
                                setDeviceRemoteInfo(loadCentreDeviceList, homeId, cloudCallBeak);
                            }
                            @Override
                            public void onFailure(HDLException e) {
                                if (cloudCallBeak != null) {
                                    cloudCallBeak.onFailure(e);
                                }
                            }
                        });
//                        if (cloudCallBeak != null) {
//                            cloudCallBeak.onFailure(e);
//                        }
                    }
                });
            }