From bd80ca98ffb4f483ca2eba47051281fa69e790ac Mon Sep 17 00:00:00 2001
From: 刘卫锦 <lwj@hdlchina.com.cn>
Date: 星期一, 14 八月 2023 10:24:25 +0800
Subject: [PATCH] 代码同步

---
 app/src/main/java/com/hdl/photovoltaic/other/HdlResidenceLogic.java |   36 ++++++++++++++++++++++++++++++------
 1 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/app/src/main/java/com/hdl/photovoltaic/other/HdlResidenceLogic.java b/app/src/main/java/com/hdl/photovoltaic/other/HdlResidenceLogic.java
index 83e6b6a..370410a 100644
--- a/app/src/main/java/com/hdl/photovoltaic/other/HdlResidenceLogic.java
+++ b/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;
                         }
                         //鏀堕泦鍒犻櫎閫嗗彉鍣╯id
@@ -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);

--
Gitblit v1.8.0