From c660f059d4e07a1b784442a1bbb4a5109b82e837 Mon Sep 17 00:00:00 2001
From: hxb <hxb@hdlchina.com.cn>
Date: 星期二, 25 六月 2024 09:51:45 +0800
Subject: [PATCH] Merge branch 'dev' of http://172.16.1.23:6688/r/~wjc/HDLPhotovoltaicDebugAPP into dev

---
 app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java |  117 +++++++++++++++++++++++++++++++++++++++++++++-------------
 1 files changed, 90 insertions(+), 27 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 67a3800..6053f5a 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;
         }
@@ -157,6 +157,55 @@
             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;
+            }
+        }
+        if (index > 0) {
+            list.remove(index);
+        }
+    }
+
+    /**
+     * 娣诲姞銆愯澶囧垪琛ㄣ�戝埌鏈湴缂撳瓨
+     *
+     * @param list -璁惧鍒楄〃
+     */
+    public void setListDevice(List<CloudInverterDeviceBean> list) {
+        try {
+            if (list == null || list.size() == 0) {
+                return;
+            }
+            if (this.mListDevice.size() == 0) {
+                this.mListDevice.addAll(list);
+                return;
+            }
+            for (int i = 0; i < list.size(); i++) {
+                this.setSingleDevice(list.get(i));
+            }
+        } catch (Exception ignored) {
+        }
+    }
+
 
     /**
      * 鑾峰彇璁惧鍒楄〃(瀹夎鍟�)
@@ -198,28 +247,6 @@
                 }
             }
         });
-    }
-
-
-    /**
-     * 娣诲姞銆愯澶囧垪琛ㄣ�戝埌鏈湴缂撳瓨
-     *
-     * @param list -璁惧鍒楄〃
-     */
-    public void setListDevice(List<CloudInverterDeviceBean> list) {
-        try {
-            if (list == null || list.size() == 0) {
-                return;
-            }
-            if (this.mListDevice.size() == 0) {
-                this.mListDevice.addAll(list);
-                return;
-            }
-            for (int i = 0; i < list.size(); i++) {
-                this.setSingleDevice(list.get(i));
-            }
-        } catch (Exception ignored) {
-        }
     }
 
     /**
@@ -709,6 +736,42 @@
 
     }
 
+    /**
+     * 淇敼璁惧鍚嶇О閫嗗彉鍣˙MS鐢垫睜鍖�
+     * 鎻忚堪:  淇敼璁惧鍚嶇О锛屾敮鎸侀�嗗彉鍣紝BMS锛岀數姹犲寘璁惧鍚嶇О淇敼
+     *
+     * @param homeId        浣忓畢id
+     * @param deviceType    璁惧绫诲瀷(INV:閫嗗彉鍣�,BMS:BMS鎺у埗鐩�,BATTERY:鐢垫睜鍗曞厓)
+     * @param deviceId      璁惧id(deviceType = INV 鏄�嗗彉鍣╠eviceId;deviceType = BMS 鏄疊MS鐨刣eviceOidId;deviceType = BATTERY 鏄數姹犲寘鐨刣eviceOidId)
+     * @param cloudCallBeak 鍥炶皟update
+     */
+    public void setRename(String homeId, String deviceType, String deviceId, String name, CloudCallBeak<Boolean> cloudCallBeak) {
+        String requestUrl = HttpApi.POST_Device_Rename;
+        JsonObject json = new JsonObject();
+        json.addProperty("homeId", homeId);
+        json.addProperty("name", name);
+        json.addProperty("deviceType", deviceType);//璁惧绫诲瀷(INV:閫嗗彉鍣�,BMS:BMS鎺у埗鐩�,BATTERY:鐢垫睜鍗曞厓)
+        json.addProperty("deviceId", deviceId);//璁惧id(deviceType = INV 鏄�嗗彉鍣╠eviceId;deviceType = BMS 鏄疊MS鐨刣eviceOidId;deviceType = BATTERY 鏄數姹犲寘鐨刣eviceOidId)
+        // json.addProperty("zoneType", "password");//鍖哄煙
+        HttpClient.getInstance().requestHttp(requestUrl, json.toString(), new CloudCallBeak<String>() {
+            @Override
+            public void onSuccess(String str) {
+
+                if (cloudCallBeak != null) {
+                    cloudCallBeak.onSuccess(true);
+                }
+            }
+
+            @Override
+            public void onFailure(HDLException e) {
+                if (cloudCallBeak != null) {
+                    cloudCallBeak.onFailure(e);
+                }
+            }
+        });
+
+    }
+
 
     /**
      * 璁剧疆缃戝叧杩滅▼鍙傛暟
@@ -999,7 +1062,7 @@
      * @param cloudCallBeak 杩斿洖閫嗗彉鍣ㄥ垪琛�
      */
     public void getCurrentHomeLocalAndCloudGatewayList(String homeId, CloudCallBeak<List<GatewayBean>> cloudCallBeak) {
-        HdlDeviceLogic.getInstance().searchCurrentHomeGateway(homeId,new GatewayCallBack() {
+        HdlDeviceLogic.getInstance().searchCurrentHomeGateway(homeId, new GatewayCallBack() {
             @Override
             public void onSuccess(List<GatewayBean> gatewayBeanList) {
                 //灞�鍩熺綉鏈�2绉嶆儏鍐�(1:鏈夊眬鍩熺綉锛屾湁澶栫綉锛�2:鏈夊眬鍩熺綉锛屾病鏈夊缃�);
@@ -1201,7 +1264,7 @@
      *
      * @param gatewayCallBack -
      */
-    public void searchCurrentHomeGateway(String homeId,GatewayCallBack gatewayCallBack) {
+    public void searchCurrentHomeGateway(String homeId, GatewayCallBack gatewayCallBack) {
         List<String> spks = this.getGatewaySpk();
         //缃戝叧鎼滅储
         HDLLinkLocalGateway.getInstance().refreshGatewayByHomeIdAndSpk(homeId, spks, true, gatewayCallBack);
@@ -1225,8 +1288,8 @@
      * @param deviceMac 璁惧mac锛�
      * @param callBeak  杩斿洖 true=鏈湴杩炴帴;false=杩滅▼;
      */
-    public void isLocalConnect(String homeId,String deviceMac, CloudCallBeak<Boolean> callBeak) {
-        searchCurrentHomeGateway(homeId,new GatewayCallBack() {
+    public void isLocalConnect(String homeId, String deviceMac, CloudCallBeak<Boolean> callBeak) {
+        searchCurrentHomeGateway(homeId, new GatewayCallBack() {
             @Override
             public void onSuccess(List<GatewayBean> gatewayBeanList) {
                 if (gatewayBeanList == null || gatewayBeanList.size() == 0) {

--
Gitblit v1.8.0