刘卫锦
2023-08-14 bd80ca98ffb4f483ca2eba47051281fa69e790ac
app/src/main/java/com/hdl/photovoltaic/other/HdlResidenceLogic.java
@@ -531,16 +531,24 @@
        HdlFileLogic.getInstance().createDirectory();
        //配置本地通信的信息
        initLocalLinkSdk();
        getGatewayList(null);
    }
    public void getGatewayList(CloudCallBeak<Boolean> baseSuccessFailureCallBeak) {
        HdlDeviceLogic.getInstance().searchGateway(new GatewayCallBack() {
            @Override
            public void onSuccess(List<GatewayBean> gatewayBeanList) {
                HdlDeviceLogic.getInstance().getCloudInverterDeviceList(UserConfigManage.getInstance().getHomeId(), new CloudCallBeak<List<CloudInverterDeviceBean>>() {
                    @Override
                    public void onSuccess(List<CloudInverterDeviceBean> list) {
                        if (list == null) {
                        if (list == null||list.size()==0) {
                            //云端没有绑定逆变器,清空本地列表;
                            HDLLinkLocalGateway.getInstance().getGatewayList().clear();
                            if (baseSuccessFailureCallBeak != null) {
                                baseSuccessFailureCallBeak.onSuccess(true);
                            }
                            return;
                        }
                        //收集删除逆变器sid
@@ -560,11 +568,17 @@
                            //获取本地的毫米波
                            removeInverter(removeSidList.get(i));
                        }
                        if (baseSuccessFailureCallBeak != null) {
                            baseSuccessFailureCallBeak.onSuccess(true);
                        }
                    }
                    @Override
                    public void onFailure(Exception exception) {
                        if (baseSuccessFailureCallBeak != null) {
                            baseSuccessFailureCallBeak.onFailure(exception);
                        }
                    }
                });
            }
@@ -575,9 +589,15 @@
                    @Override
                    public void onSuccess(List<CloudInverterDeviceBean> list) {
                        if (list == null) {
                            if (baseSuccessFailureCallBeak != null) {
                                baseSuccessFailureCallBeak.onSuccess(true);
                            }
                            return;
                        }
                        if (list.size() <= 0) {
                            if (baseSuccessFailureCallBeak != null) {
                                baseSuccessFailureCallBeak.onSuccess(true);
                            }
                            return;
                        }
                        HDLLinkLocalGateway.getInstance().getGatewayList().clear();
@@ -589,23 +609,27 @@
                            gatewayBean.setGatewayId(cloudInverterDeviceBean.getGatewayId());
                            gatewayBean.setOnline(cloudInverterDeviceBean.isOnline());
                            gatewayBean.setDevice_name(cloudInverterDeviceBean.getGatewayName());
                            gatewayBean.setDevice_mac(cloudInverterDeviceBean.getOsn());
                            gatewayBean.setHomeId(UserConfigManage.getInstance().getHomeId());
                            gatewayBean.setLocalEncrypt(true);
                            gatewayBean.setMaster("true");
                            HDLLinkLocalGateway.getInstance().getGatewayList().add(gatewayBean);
                        }
                        if (baseSuccessFailureCallBeak != null) {
                            baseSuccessFailureCallBeak.onSuccess(true);
                        }
                    }
                    @Override
                    public void onFailure(Exception exception) {
                        if (baseSuccessFailureCallBeak != null) {
                            baseSuccessFailureCallBeak.onFailure(exception);
                        }
                    }
                });
            }
        });
    }
    /**
@@ -614,7 +638,7 @@
     * @param sid 设备sid
     */
    private void removeInverter(String sid) {
        //获取本地的毫米波
        //获取本地
        GatewayBean gatewayBean = HDLLinkLocalGateway.getInstance().getLocalGateway(sid);
        if (gatewayBean != null) {
            HDLLinkLocalGateway.getInstance().getGatewayList().remove(gatewayBean);