From c4ae4589c6c001329ebb731589b209e8ddcbf7ca Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期二, 24 三月 2026 16:03:59 +0800
Subject: [PATCH] 2026年03月24日16:03:57

---
 app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java |  424 ++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 294 insertions(+), 130 deletions(-)

diff --git a/app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java b/app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java
index 4f12d4c..69a5cce 100644
--- a/app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java
+++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java
@@ -13,6 +13,8 @@
 import com.hdl.photovoltaic.bean.PageNumberObject;
 import com.hdl.photovoltaic.config.AppConfigManage;
 import com.hdl.photovoltaic.config.UserConfigManage;
+import com.hdl.photovoltaic.enums.DeviceType;
+import com.hdl.photovoltaic.enums.PowerStationType;
 import com.hdl.photovoltaic.internet.HttpClient;
 import com.hdl.photovoltaic.internet.TcpClient;
 import com.hdl.photovoltaic.internet.api.HttpApi;
@@ -38,7 +40,6 @@
 
 import java.lang.reflect.Type;
 import java.util.ArrayList;
-import java.util.Collections;
 import java.util.List;
 import java.util.Objects;
 import java.util.concurrent.atomic.AtomicBoolean;
@@ -102,13 +103,16 @@
             if (list.size() > 0) {
                 for (int i = 0; i < list.size(); i++) {
                     GatewayBean gatewayBean = list.get(i);
-                    if (!getGatewaySpk().contains(gatewayBean.getGatewayType())) {
-                        continue;
-                    }
-                    if (TextUtils.isEmpty(gatewayBean.getDevice_mac())
-                            || TextUtils.isEmpty(gatewayBean.getSid())
-                            || TextUtils.isEmpty(gatewayBean.getOid())) {
-                        continue;
+                    if (gatewayBean.isActivate()) {
+                        //宸叉縺娲伙紙getGatewayType锛実etDevice_mac锛実etSid锛実etOid锛夋墠鏈夊��
+                        if (!getGatewaySpk().contains(gatewayBean.getGatewayType())) {
+                            continue;
+                        }
+                        if (TextUtils.isEmpty(gatewayBean.getDevice_mac())
+                                || TextUtils.isEmpty(gatewayBean.getSid())
+                                || TextUtils.isEmpty(gatewayBean.getOid())) {
+                            continue;
+                        }
                     }
                     //鐢╤omeId绛涢�夊綋鍓嶄綇瀹呯殑閫嗗彉鍣ㄥ垪琛�
                     if (gatewayBean.getHomeId().equals(homeId)) {
@@ -137,9 +141,9 @@
         try {
             List<GatewayBean> newList = new ArrayList<>();
             //浜戠鏈夎澶囧垪琛紝鏈湴娌℃湁锛屽嵆HDLLinkLocalGateway.getInstance().getGatewayList()娌℃湁锛岄噷闈細璋冪敤refreshGatewayCacheData()鏂规硶铏氭嫙涓�涓�嗗彉鍣ㄥ疄浣撴坊鍔犳湰鍦板垪琛ㄩ噷闈紱
-            List<GatewayBean> list = getCurrentHomeGatewayList(homeId);
-            if (list != null && list.size() > 0) {
-                newList.addAll(list);
+            List<GatewayBean> localList = getCurrentHomeGatewayList(homeId);
+            if (localList != null && localList.size() > 0) {
+                newList.addAll(localList);
             }
 
             //鏈夊缃戯紝浠ヤ簯绔澶囧垪琛ㄤ负鍑�;浜戠娌℃湁锛屾湰鍦板瓨鍦紝鍒欏垹闄ゆ湰鍦帮紱鍚﹀垯锛屾病鏈夊缃戝彧鏈夊眬鍩熺綉锛屼互鏈湴newList鍒楄〃涓轰富,鎼滅储澶氬皯涓澶囧氨鏄剧ず澶氬皯涓�
@@ -149,6 +153,7 @@
                     CloudInverterDeviceBean cloudInverterDevice = cloudInverterDeviceList.get(i);
                     for (GatewayBean gatewayBean : newList) {
                         if (cloudInverterDevice.getOsn().equals(gatewayBean.getDevice_mac())) {
+                            //鑾峰彇鏇村叏閫嗗彉鍣ㄨ鎯呭瓧娈�
                             checkNewList.add(gatewayBean);
                             break;
                         }
@@ -246,7 +251,7 @@
         if (TextUtils.isEmpty(deviceId)) {
             return;
         }
-        List<GatewayBean> list = getCurrentHomeGatewayList(homeId);
+        List<GatewayBean> list = HDLLinkLocalGateway.getInstance().getGatewayList();
         if (list == null || list.size() == 0) {
             return;
         }
@@ -258,9 +263,10 @@
                 break;
             }
         }
-        if (index > 0) {
+        if (index > -1) {
             list.remove(index);
         }
+
     }
 
     /**
@@ -607,6 +613,43 @@
      */
     public void getCloudInverterDeviceList(String homeId, CloudCallBeak<List<CloudInverterDeviceBean>> cloudCallBeak) {
         String requestUrl = HttpApi.POST_Device_List;
+        JsonObject json = new JsonObject();
+        json.addProperty("homeId", homeId);
+        // json.addProperty("zoneType", "password");//鍖哄煙
+
+        HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() {
+            @Override
+            public void onSuccess(String jsonStr) {
+                if (TextUtils.isEmpty(jsonStr)) {
+                    if (cloudCallBeak != null) {
+                        cloudCallBeak.onSuccess(null);
+                    }
+                }
+                Type type = new TypeToken<List<CloudInverterDeviceBean>>() {
+                }.getType();
+                List<CloudInverterDeviceBean> list = new Gson().fromJson(jsonStr, type);
+                if (cloudCallBeak != null) {
+                    cloudCallBeak.onSuccess(list);
+                }
+            }
+
+            @Override
+            public void onFailure(HDLException e) {
+                if (cloudCallBeak != null) {
+                    cloudCallBeak.onFailure(e);
+                }
+            }
+        });
+    }
+
+    /**
+     * 鑾峰彇浜戠BMS璁惧鍒楄〃
+     *
+     * @param homeId        浣忓畢id
+     * @param cloudCallBeak 鍥炶皟
+     */
+    public void getCloudBmsDeviceList(String homeId, CloudCallBeak<List<CloudInverterDeviceBean>> cloudCallBeak) {
+        String requestUrl = HttpApi.POST_Device_bmsDevices;
         JsonObject json = new JsonObject();
         json.addProperty("homeId", homeId);
         // json.addProperty("zoneType", "password");//鍖哄煙
@@ -1184,131 +1227,208 @@
     }
 
     /**
-     * 鑾峰彇閫嗗彉鍣ㄥ垪琛�,鏁村悎浜戠閫嗗彉鍣ㄥ垪琛ㄥ拰鏈湴閫嗗彉鍣ㄥ垪琛�(璁惧绫诲瀷鏈�:骞剁綉閫嗗彉鍣紝绂荤嚎閫嗗彉鍣紝璐熻浇涓績璁惧);
-     * 娉ㄦ剰:鏈夊缃戯紝浠ヤ簯绔澶囧垪琛ㄤ负鍑�;浜戠娌℃湁锛屾湰鍦板瓨鍦紝鍒欏垹闄ゆ湰鍦帮紱鍚﹀垯锛屾病鏈夊缃戝彧鏈夊眬鍩熺綉锛屼互鏈湴涓轰富,鎼滅储澶氬皯涓澶囧氨鏄剧ず澶氬皯涓�
+     * 璁惧娓呯┖杩愯鏁版嵁
      *
-     * @param homeId        浣忓畢id
-     * @param cloudCallBeak 杩斿洖閫嗗彉鍣ㄥ垪琛�
+     * @param mac          缃戝叧mac
+     * @param linkCallBack 鍥炶皟
      */
-    public void getCurrentHomeLocalAndCloudGatewayList(String homeId, CloudCallBeak<List<GatewayBean>> cloudCallBeak) {
-        searchCurrentHomeGateway(homeId, new GatewayCallBack() {
+    public void DeviceClearData(String mac, LinkCallBack<Boolean> linkCallBack) {
+        String requestUrl = TopicApi.DEVICE_RUN_DATA_CLEAR;
+        TcpClient.getInstance().sendDataToLinkGateway(mac, requestUrl, null, "", new HDLLinkCallBack() {
             @Override
-            public void onSuccess(List<GatewayBean> gatewayBeanList) {
-                //鍚戜簯绔幏鍙栭�嗗彉鍣ㄥ垪琛�
-                getCloudInverterDeviceList(homeId, new CloudCallBeak<List<CloudInverterDeviceBean>>() {
-                    @Override
-                    public void onSuccess(List<CloudInverterDeviceBean> inverterDeviceList) {
-                        //鍚戜簯绔幏鍙栬礋杞戒腑蹇冨垪琛�
-                        getLoadCentreDeviceList(homeId, new CloudCallBeak<List<CloudInverterDeviceBean>>() {
-                            @Override
-                            public void onSuccess(List<CloudInverterDeviceBean> loadCentreDeviceList) {
-                                if (loadCentreDeviceList != null) {
-                                    //鍚堝苟璐熻浇涓績璁惧鍒楄〃锛岀劧鍚庡湪涓�璧峰仛澶勭悊
-                                    inverterDeviceList.addAll(loadCentreDeviceList);
-                                }
-                                //璁剧疆璁惧鐨勮繙绋嬩俊鎭�
-                                setDeviceRemoteInfo(inverterDeviceList, homeId, cloudCallBeak);
-                            }
-
-                            @Override
-                            public void onFailure(HDLException e) {
-                                //鍚戜簯绔幏鍙栬礋杞戒腑蹇冭澶囧垪琛ㄥけ璐ュ悗锛屼粛鐒跺鐞嗛�嗗彉鍣ㄨ澶囧垪琛�
-                                //璁剧疆璁惧鐨勮繙绋嬩俊鎭�
-                                setDeviceRemoteInfo(inverterDeviceList, homeId, cloudCallBeak);
-                            }
-                        });
-
-
-                    }
-
-                    @Override
-                    public void onFailure(HDLException e) {
-                        //鏈湴鏈夐�嗗彉鍣ㄥ垪琛�,鑾峰彇浜戠缁戝畾閫嗗彉鍣ㄥけ璐�,榛樿杩斿洖鏈湴閫嗗彉鍣ㄥ垪琛�;
-                        //鍚戜簯绔幏鍙栬礋杞戒腑蹇冨垪琛�
-                        getLoadCentreDeviceList(homeId, new CloudCallBeak<List<CloudInverterDeviceBean>>() {
-                            @Override
-                            public void onSuccess(List<CloudInverterDeviceBean> loadCentreDeviceList) {
-                                if (loadCentreDeviceList == null) {
-                                    if (cloudCallBeak != null) {
-                                        //娌℃湁鏁版嵁锛岄粯璁よ繑鍥炴湰鍦伴�嗗彉鍣ㄥ垪琛�;
-                                        cloudCallBeak.onSuccess(IntegrateCloudAndLocalData(homeId, null, false));
-                                    }
-                                    return;
-                                }
-                                //璁剧疆璁惧鐨勮繙绋嬩俊鎭�
-                                setDeviceRemoteInfo(loadCentreDeviceList, homeId, cloudCallBeak);
-                            }
-
-                            @Override
-                            public void onFailure(HDLException e) {
-                                //鍚戜簯绔幏鍙栬礋杞戒腑蹇冭澶囧垪琛ㄥけ璐ュ悗锛岄粯璁よ繑鍥炴湰鍦伴�嗗彉鍣ㄥ垪琛�;
-                                if (cloudCallBeak != null) {
-                                    cloudCallBeak.onSuccess(IntegrateCloudAndLocalData(homeId, null, false));
-                                }
-                            }
-                        });
-
-                    }
-                });
+            public void onSuccess(String json) {
+                if (linkCallBack != null) {
+                    linkCallBack.onSuccess(true);
+                }
             }
 
             @Override
             public void onError(HDLLinkException e) {
-//                //澶栫綉杩涙潵鍏堛�愰粯璁ゃ�戞竻绌烘湰鍦伴�嗗彉鍣ㄥ垪琛�
-//                HDLLinkLocalGateway.getInstance().getGatewayList().clear();
-                //鍚戜簯绔幏鍙栭�嗗彉鍣ㄥ垪琛�
-                getCloudInverterDeviceList(homeId, new CloudCallBeak<List<CloudInverterDeviceBean>>() {
-                    @Override
-                    public void onSuccess(List<CloudInverterDeviceBean> cloudInverterList) {
-                        //鍐嶅悜浜戠鑾峰彇璐熻浇涓績鍒楄〃
-                        getLoadCentreDeviceList(homeId, new CloudCallBeak<List<CloudInverterDeviceBean>>() {
-                            @Override
-                            public void onSuccess(List<CloudInverterDeviceBean> loadCentreDeviceList) {
-
-                                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) {
-                                //璁剧疆璁惧鐨勮繙绋嬩俊鎭�
-                                setDeviceRemoteInfo(cloudInverterList, homeId, cloudCallBeak);
-                            }
-                        });
-                    }
-
-                    @Override
-                    public void onFailure(HDLException e) {
-                        //鍚戜簯绔幏鍙栭�嗗彉鍣ㄥ垪琛ㄥけ璐�
-                        //鍐嶅悜浜戠鑾峰彇璐熻浇涓績鍒楄〃
-                        getLoadCentreDeviceList(homeId, new CloudCallBeak<List<CloudInverterDeviceBean>>() {
-                            @Override
-                            public void onSuccess(List<CloudInverterDeviceBean> loadCentreDeviceList) {
-                                //璁剧疆璁惧鐨勮繙绋嬩俊鎭�
-                                setDeviceRemoteInfo(loadCentreDeviceList, homeId, cloudCallBeak);
-                            }
-
-                            @Override
-                            public void onFailure(HDLException e) {
-                                //閮芥槸鑾峰彇澶辫触鐨勮瘽,鐩存帴杩斿洖绌哄垪琛�;
-                                if (cloudCallBeak != null) {
-                                    cloudCallBeak.onSuccess(new ArrayList<>());
-                                }
-                            }
-                        });
-                    }
-                });
+                if (linkCallBack != null) {
+                    linkCallBack.onError(e);
+                }
             }
         });
+
+    }
+
+    /**
+     * 鑾峰彇閫嗗彉鍣ㄥ垪琛�,鏁村悎浜戠閫嗗彉鍣ㄥ垪琛ㄥ拰鏈湴閫嗗彉鍣ㄥ垪琛�(璁惧绫诲瀷鏈�:骞剁綉閫嗗彉鍣紝绂荤嚎閫嗗彉鍣紝璐熻浇涓績璁惧);
+     * 娉ㄦ剰:鏈夊缃戯紝浠ヤ簯绔澶囧垪琛ㄤ负鍑�;浜戠娌℃湁锛屾湰鍦板瓨鍦紝鍒欏垹闄ゆ湰鍦帮紱鍚﹀垯锛屾病鏈夊缃戝彧鏈夊眬鍩熺綉锛屼互鏈湴涓轰富,鎼滅储澶氬皯涓澶囧氨鏄剧ず澶氬皯涓�
+     *
+     * @param homeId           浣忓畢id
+     * @param cloudCallBeak    杩斿洖閫嗗彉鍣ㄥ垪琛�
+     * @param powerStationType 鐢电珯绫诲瀷锛堥�嗗彉鍣紝BMS鐢电珯锛�
+     */
+    public void getCurrentHomeLocalAndCloudGatewayList(String homeId, String powerStationType, CloudCallBeak<List<GatewayBean>> cloudCallBeak) {
+//        HDLLinkLocalGateway.getInstance().getGatewayList().clear();//鍏堟竻绌轰箣鍓嶉�嗗彉鍣ㄥ垪琛�
+        if (powerStationType.equals(PowerStationType.BMS)) {
+            searchCurrentHomeGateway(homeId, new GatewayCallBack() {
+                @Override
+                public void onSuccess(List<GatewayBean> gatewayBeanList) {
+                    //鍚戜簯绔幏鍙栭�嗗彉鍣ㄥ垪琛�
+                    getCloudBmsDeviceList(homeId, new CloudCallBeak<List<CloudInverterDeviceBean>>() {
+                        @Override
+                        public void onSuccess(List<CloudInverterDeviceBean> inverterDeviceList) {
+                            //璁剧疆璁惧鐨勮繙绋嬩俊鎭�
+                            setDeviceRemoteInfo(inverterDeviceList, homeId, cloudCallBeak);
+                        }
+
+                        @Override
+                        public void onFailure(HDLException e) {
+                            //鏈湴鏈夐�嗗彉鍣ㄥ垪琛�,鑾峰彇浜戠缁戝畾閫嗗彉鍣ㄥけ璐�,榛樿杩斿洖鏈湴閫嗗彉鍣ㄥ垪琛�;
+                            //鍚戜簯绔幏鍙栬礋杞戒腑蹇冭澶囧垪琛ㄥけ璐ュ悗锛岄粯璁よ繑鍥炴湰鍦伴�嗗彉鍣ㄥ垪琛�;
+                            if (cloudCallBeak != null) {
+                                cloudCallBeak.onSuccess(IntegrateCloudAndLocalData(homeId, null, false));
+                            }
+
+                        }
+                    });
+                }
+
+                @Override
+                public void onError(HDLLinkException e) {
+//                //澶栫綉杩涙潵鍏堛�愰粯璁ゃ�戞竻绌烘湰鍦伴�嗗彉鍣ㄥ垪琛�
+//                HDLLinkLocalGateway.getInstance().getGatewayList().clear();
+                    //鍚戜簯绔幏鍙栭�嗗彉鍣ㄥ垪琛�
+                    getCloudBmsDeviceList(homeId, new CloudCallBeak<List<CloudInverterDeviceBean>>() {
+                        @Override
+                        public void onSuccess(List<CloudInverterDeviceBean> cloudInverterList) {
+                            //鏁村悎璁惧鍒楄〃鍚�,鍐嶄竴璧疯缃澶囩殑杩滅▼淇℃伅
+                            setDeviceRemoteInfo(cloudInverterList, homeId, cloudCallBeak);
+                        }
+
+                        @Override
+                        public void onFailure(HDLException e) {
+                            //鍚戜簯绔幏鍙栭�嗗彉鍣ㄥ垪琛ㄥけ璐�
+                            //閮芥槸鑾峰彇澶辫触鐨勮瘽,鐩存帴杩斿洖绌哄垪琛�;
+                            if (cloudCallBeak != null) {
+                                cloudCallBeak.onSuccess(new ArrayList<>());
+                            }
+                        }
+                    });
+                }
+            });
+        } else {
+            searchCurrentHomeGateway(homeId, new GatewayCallBack() {
+                @Override
+                public void onSuccess(List<GatewayBean> gatewayBeanList) {
+                    //鍚戜簯绔幏鍙栭�嗗彉鍣ㄥ垪琛�
+                    getCloudInverterDeviceList(homeId, new CloudCallBeak<List<CloudInverterDeviceBean>>() {
+                        @Override
+                        public void onSuccess(List<CloudInverterDeviceBean> inverterDeviceList) {
+                            //鍚戜簯绔幏鍙栬礋杞戒腑蹇冨垪琛�
+                            getLoadCentreDeviceList(homeId, new CloudCallBeak<List<CloudInverterDeviceBean>>() {
+                                @Override
+                                public void onSuccess(List<CloudInverterDeviceBean> loadCentreDeviceList) {
+                                    if (loadCentreDeviceList != null) {
+                                        //鍚堝苟璐熻浇涓績璁惧鍒楄〃锛岀劧鍚庡湪涓�璧峰仛澶勭悊
+                                        inverterDeviceList.addAll(loadCentreDeviceList);
+                                    }
+                                    //璁剧疆璁惧鐨勮繙绋嬩俊鎭�
+                                    setDeviceRemoteInfo(inverterDeviceList, homeId, cloudCallBeak);
+                                }
+
+                                @Override
+                                public void onFailure(HDLException e) {
+                                    //鍚戜簯绔幏鍙栬礋杞戒腑蹇冭澶囧垪琛ㄥけ璐ュ悗锛屼粛鐒跺鐞嗛�嗗彉鍣ㄨ澶囧垪琛�
+                                    //璁剧疆璁惧鐨勮繙绋嬩俊鎭�
+                                    setDeviceRemoteInfo(inverterDeviceList, homeId, cloudCallBeak);
+                                }
+                            });
+
+
+                        }
+
+                        @Override
+                        public void onFailure(HDLException e) {
+                            //鏈湴鏈夐�嗗彉鍣ㄥ垪琛�,鑾峰彇浜戠缁戝畾閫嗗彉鍣ㄥけ璐�,榛樿杩斿洖鏈湴閫嗗彉鍣ㄥ垪琛�;
+                            //鍚戜簯绔幏鍙栬礋杞戒腑蹇冨垪琛�
+                            getLoadCentreDeviceList(homeId, new CloudCallBeak<List<CloudInverterDeviceBean>>() {
+                                @Override
+                                public void onSuccess(List<CloudInverterDeviceBean> loadCentreDeviceList) {
+                                    if (loadCentreDeviceList == null) {
+                                        if (cloudCallBeak != null) {
+                                            //娌℃湁鏁版嵁锛岄粯璁よ繑鍥炴湰鍦伴�嗗彉鍣ㄥ垪琛�;
+                                            cloudCallBeak.onSuccess(IntegrateCloudAndLocalData(homeId, null, false));
+                                        }
+                                        return;
+                                    }
+                                    //璁剧疆璁惧鐨勮繙绋嬩俊鎭�
+                                    setDeviceRemoteInfo(loadCentreDeviceList, homeId, cloudCallBeak);
+                                }
+
+                                @Override
+                                public void onFailure(HDLException e) {
+                                    //鍚戜簯绔幏鍙栬礋杞戒腑蹇冭澶囧垪琛ㄥけ璐ュ悗锛岄粯璁よ繑鍥炴湰鍦伴�嗗彉鍣ㄥ垪琛�;
+                                    if (cloudCallBeak != null) {
+                                        cloudCallBeak.onSuccess(IntegrateCloudAndLocalData(homeId, null, false));
+                                    }
+                                }
+                            });
+
+                        }
+                    });
+                }
+
+                @Override
+                public void onError(HDLLinkException e) {
+//                //澶栫綉杩涙潵鍏堛�愰粯璁ゃ�戞竻绌烘湰鍦伴�嗗彉鍣ㄥ垪琛�
+//                HDLLinkLocalGateway.getInstance().getGatewayList().clear();
+                    //鍚戜簯绔幏鍙栭�嗗彉鍣ㄥ垪琛�
+                    getCloudInverterDeviceList(homeId, new CloudCallBeak<List<CloudInverterDeviceBean>>() {
+                        @Override
+                        public void onSuccess(List<CloudInverterDeviceBean> cloudInverterList) {
+                            //鍐嶅悜浜戠鑾峰彇璐熻浇涓績鍒楄〃
+                            getLoadCentreDeviceList(homeId, new CloudCallBeak<List<CloudInverterDeviceBean>>() {
+                                @Override
+                                public void onSuccess(List<CloudInverterDeviceBean> loadCentreDeviceList) {
+
+                                    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) {
+                                    //璁剧疆璁惧鐨勮繙绋嬩俊鎭�
+                                    setDeviceRemoteInfo(cloudInverterList, homeId, cloudCallBeak);
+                                }
+                            });
+                        }
+
+                        @Override
+                        public void onFailure(HDLException e) {
+                            //鍚戜簯绔幏鍙栭�嗗彉鍣ㄥ垪琛ㄥけ璐�
+                            //鍐嶅悜浜戠鑾峰彇璐熻浇涓績鍒楄〃
+                            getLoadCentreDeviceList(homeId, new CloudCallBeak<List<CloudInverterDeviceBean>>() {
+                                @Override
+                                public void onSuccess(List<CloudInverterDeviceBean> loadCentreDeviceList) {
+                                    //璁剧疆璁惧鐨勮繙绋嬩俊鎭�
+                                    setDeviceRemoteInfo(loadCentreDeviceList, homeId, cloudCallBeak);
+                                }
+
+                                @Override
+                                public void onFailure(HDLException e) {
+                                    //閮芥槸鑾峰彇澶辫触鐨勮瘽,鐩存帴杩斿洖绌哄垪琛�;
+                                    if (cloudCallBeak != null) {
+                                        cloudCallBeak.onSuccess(new ArrayList<>());
+                                    }
+                                }
+                            });
+                        }
+                    });
+                }
+            });
+        }
     }
 
     /**
@@ -1329,6 +1449,39 @@
         AtomicInteger atomicInteger = new AtomicInteger(0);
         for (int i = 0; i < list.size(); i++) {
             CloudInverterDeviceBean cloudInverterDeviceBean = list.get(i);
+            if (cloudInverterDeviceBean == null) {
+                if (cloudInverterDeviceBean.getDeviceType().equals(DeviceType.bms)) {
+                    //鏈縺娲昏澶�
+                    atomicInteger.set(atomicInteger.get() + 1);
+                    //娉ㄦ剰:杩欎釜閫嗗彉鍣ㄥ彧鑳芥湰鍦版帶鍒�(鍥犱负鎷夸笉鍒癿qtt閫氳绉橀挜浠ュ強GatewayID,鏃犳硶杩滅▼鎺у埗)
+                    //鏇存柊閫嗗彉鍣ㄦ湰鍦扮紦瀛樹俊鎭�
+                    refreshGatewayCacheData(false, cloudInverterDeviceBean, null, homeId);
+                    //鍒版渶鍚庝竴鏉★紝鎵嶅鐞嗗洖璋�
+                    if (atomicInteger.get() == list.size()) {
+                        if (cloudCallBeak != null) {
+                            cloudCallBeak.onSuccess(IntegrateCloudAndLocalData(homeId, list, false));
+                        }
+                    }
+                    HdlLogLogic.print("璁惧鏈縺娲�(mac:" + cloudInverterDeviceBean.getOsn() + "))", true);
+                    continue;
+                } else {
+                    if (!cloudInverterDeviceBean.isActivate()) {
+                        //鏈縺娲昏澶�
+                        atomicInteger.set(atomicInteger.get() + 1);
+                        //娉ㄦ剰:杩欎釜閫嗗彉鍣ㄥ彧鑳芥湰鍦版帶鍒�(鍥犱负鎷夸笉鍒癿qtt閫氳绉橀挜浠ュ強GatewayID,鏃犳硶杩滅▼鎺у埗)
+                        //鏇存柊閫嗗彉鍣ㄦ湰鍦扮紦瀛樹俊鎭�
+                        refreshGatewayCacheData(false, cloudInverterDeviceBean, null, homeId);
+                        //鍒版渶鍚庝竴鏉★紝鎵嶅鐞嗗洖璋�
+                        if (atomicInteger.get() == list.size()) {
+                            if (cloudCallBeak != null) {
+                                cloudCallBeak.onSuccess(IntegrateCloudAndLocalData(homeId, list, false));
+                            }
+                        }
+                        HdlLogLogic.print("璁惧鏈縺娲�(mac:" + cloudInverterDeviceBean.getOsn() + "))", true);
+                        continue;
+                    }
+                }
+            }
             //鑾峰彇杩滅▼璁惧閫氳淇℃伅(鎷垮埌缃戝叧ID锛宮qtt閫氳绉橀挜)
             getDeviceRemoteInfo(homeId, cloudInverterDeviceBean.getSpk(), cloudInverterDeviceBean.getOsn(), new CloudCallBeak<DeviceRemoteInfo>() {
                 @Override
@@ -1831,8 +1984,14 @@
             gatewayBean.setDevice_model(cloudInverterDeviceBean.getOmodel());//璁惧鍨嬪彿
         }
         gatewayBean.setSpk(cloudInverterDeviceBean.getSpk());//璁惧spk
+        gatewayBean.setActivate(cloudInverterDeviceBean.isActivate());//鏄惁婵�娲昏澶�(true锛氭縺娲伙紱false锛氭湭婵�娲�)
+        gatewayBean.setPopUpgrade(cloudInverterDeviceBean.isPopUpgrade());//鏀硅澶囨槸鍚︽湁寮圭獥鍗囩骇
+        gatewayBean.setSubPopUpgrade(cloudInverterDeviceBean.isSubPopUpgrade());//涓嬫寕璁惧鏄惁鏈夊脊绐楀崌绾�
 
-
+        if (cloudInverterDeviceBean.getDeviceType().equals(DeviceType.bms)) {
+            gatewayBean.setDeviceOidId(cloudInverterDeviceBean.getDeviceOidId());
+            gatewayBean.setFwVersion(cloudInverterDeviceBean.getFwVersion());
+        }
     }
 
 
@@ -1846,6 +2005,7 @@
         spks.add(INVERTER_DEVICE_SPK);
         spks.add(LC_SPK);
         spks.add(OFF_INVERTER_OG_SPK);
+        spks.add(HDL_BMS_SPK);
         return spks;
     }
 
@@ -1905,4 +2065,8 @@
      * 绂荤嚎閫嗗彉鍣╯pk
      */
     public final String OFF_INVERTER_OG_SPK = "energy.inverter_og";
+    /**
+     * BMS璁惧spk
+     */
+    public final String HDL_BMS_SPK = "energy.hdl_bms";
 }

--
Gitblit v1.8.0