From d7ff801372431e64aee8f68ece4b8532cffb2207 Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期二, 02 七月 2024 18:32:49 +0800
Subject: [PATCH] 2024年07月02日18:32:40

---
 app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java |   43 +++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 41 insertions(+), 2 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 bb731c8..867c317 100644
--- a/app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java
+++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java
@@ -137,7 +137,7 @@
      * @param homeId 鐢电珯id
      * @param mac    閫嗗彉鍣╩ac
      */
-    public void removeLocalCacheMemoryGateway(String homeId, String mac) {
+    public void removeLocalCacheMemoryGatewayToMac(String homeId, String mac) {
         if (TextUtils.isEmpty(mac)) {
             return;
         }
@@ -149,6 +149,33 @@
         for (int i = 0; i < list.size(); i++) {
             GatewayBean gatewayBean = list.get(i);
             if (gatewayBean.getDevice_mac().equals(mac)) {
+                index = i;
+                break;
+            }
+        }
+        if (index > 0) {
+            list.remove(index);
+        }
+    }
+
+    /**
+     * 绉婚櫎缂撳瓨鍒楄〃閲岄潰閫嗗彉鍣�
+     *
+     * @param homeId   鐢电珯id
+     * @param deviceId 閫嗗彉鍣╠eviceId
+     */
+    public void removeLocalCacheMemoryGatewayToDeviceId(String homeId, String deviceId) {
+        if (TextUtils.isEmpty(deviceId)) {
+            return;
+        }
+        List<GatewayBean> list = getCurrentHomeGatewayList(homeId);
+        if (list == null || list.size() == 0) {
+            return;
+        }
+        int index = -1;
+        for (int i = 0; i < list.size(); i++) {
+            GatewayBean gatewayBean = list.get(i);
+            if (gatewayBean.getDeviceId().equals(deviceId)) {
                 index = i;
                 break;
             }
@@ -1042,7 +1069,19 @@
                 HdlDeviceLogic.getInstance().getCloudInverterDeviceList(homeId, new CloudCallBeak<List<CloudInverterDeviceBean>>() {
                     @Override
                     public void onSuccess(List<CloudInverterDeviceBean> list) {
-                        ///鎯呭喌1:鏈夊眬鍩熺綉锛屾湁澶栫綉锛�
+                        List<String> removeSidList = new ArrayList<>();
+                        for (int j = 0; j < HDLLinkLocalGateway.getInstance().getGatewayList().size(); j++) {
+                            GatewayBean gatewayBean = HDLLinkLocalGateway.getInstance().getGatewayList().get(j);
+                            if (!querySidInverter(list, gatewayBean.getSid())) {
+                                //鏈湴鏈夛紝浜戠娌℃湁,鍒犻櫎鏈湴锛�
+                                removeSidList.add(gatewayBean.getSid());
+                            }
+                        }
+                        for (int i = 0; i < removeSidList.size(); i++) {
+                            //鍒犻櫎鏈湴鐨勯�嗗彉鍣�
+                            removeLocalInverter(removeSidList.get(i));
+                        }
+                        //鎯呭喌1:鏈夊眬鍩熺綉锛屾湁澶栫綉锛�
                         setDeviceRemoteInfo(list, homeId, cloudCallBeak);
                     }
 

--
Gitblit v1.8.0