From 56f5de5eb6c1501175e7a36b10cf3d1b57284b47 Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期二, 31 三月 2026 17:13:26 +0800
Subject: [PATCH] 2026年03月31日17:12:34

---
 app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java |  133 +++++++++++++++++++++++++++-----------------
 1 files changed, 82 insertions(+), 51 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 69a5cce..6977834 100644
--- a/app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java
+++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java
@@ -1277,7 +1277,6 @@
                         @Override
                         public void onFailure(HDLException e) {
                             //鏈湴鏈夐�嗗彉鍣ㄥ垪琛�,鑾峰彇浜戠缁戝畾閫嗗彉鍣ㄥけ璐�,榛樿杩斿洖鏈湴閫嗗彉鍣ㄥ垪琛�;
-                            //鍚戜簯绔幏鍙栬礋杞戒腑蹇冭澶囧垪琛ㄥけ璐ュ悗锛岄粯璁よ繑鍥炴湰鍦伴�嗗彉鍣ㄥ垪琛�;
                             if (cloudCallBeak != null) {
                                 cloudCallBeak.onSuccess(IntegrateCloudAndLocalData(homeId, null, false));
                             }
@@ -1450,37 +1449,23 @@
         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;
+                atomicInteger.set(atomicInteger.get() + 1);
+                continue;
+            }
+            if (!cloudInverterDeviceBean.getSpk().equals(HDL_BMS_SPK) && !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>() {
@@ -1718,32 +1703,60 @@
      *
      * @param deviceMac 璁惧mac
      */
-    public void checkInverterConnectedCloud(String homeId, String deviceMac, CloudCallBeak<CloudInverterDeviceBean> cloudCallBeak) {
-        this.getCloudInverterDeviceList(homeId, new CloudCallBeak<List<CloudInverterDeviceBean>>() {
-            @Override
-            public void onSuccess(List<CloudInverterDeviceBean> list) {
-                CloudInverterDeviceBean cloudInverterDeviceBean = null;
-                if (list != null && list.size() > 0) {
-                    for (int i = 0; i < list.size(); i++) {
-                        if (list.get(i).getOsn().equals(deviceMac)) {
-                            cloudInverterDeviceBean = list.get(i);
-                            break;
-                        }
+    public void checkInverterConnectedCloud(String homeId, String deviceMac, String plantType, CloudCallBeak<CloudInverterDeviceBean> cloudCallBeak) {
+        if (plantType.equals(PowerStationType.BMS)) {
+            this.getCloudBmsDeviceList(homeId, new CloudCallBeak<List<CloudInverterDeviceBean>>() {
+                @Override
+                public void onSuccess(List<CloudInverterDeviceBean> list) {
+                    CloudInverterDeviceBean cloudInverterDeviceBean = null;
+                    if (list != null && list.size() > 0) {
+                        for (int i = 0; i < list.size(); i++) {
+                            if (list.get(i).getOsn().equals(deviceMac)) {
+                                cloudInverterDeviceBean = list.get(i);
+                                break;
+                            }
 
+                        }
+                    }
+                    if (cloudCallBeak != null) {
+                        cloudCallBeak.onSuccess(cloudInverterDeviceBean);
                     }
                 }
-                if (cloudCallBeak != null) {
-                    cloudCallBeak.onSuccess(cloudInverterDeviceBean);
-                }
-            }
 
-            @Override
-            public void onFailure(HDLException e) {
-                if (cloudCallBeak != null) {
-                    cloudCallBeak.onFailure(e);
+                @Override
+                public void onFailure(HDLException e) {
+                    if (cloudCallBeak != null) {
+                        cloudCallBeak.onFailure(e);
+                    }
                 }
-            }
-        });
+            });
+        } else {
+            this.getCloudInverterDeviceList(homeId, new CloudCallBeak<List<CloudInverterDeviceBean>>() {
+                @Override
+                public void onSuccess(List<CloudInverterDeviceBean> list) {
+                    CloudInverterDeviceBean cloudInverterDeviceBean = null;
+                    if (list != null && list.size() > 0) {
+                        for (int i = 0; i < list.size(); i++) {
+                            if (list.get(i).getOsn().equals(deviceMac)) {
+                                cloudInverterDeviceBean = list.get(i);
+                                break;
+                            }
+
+                        }
+                    }
+                    if (cloudCallBeak != null) {
+                        cloudCallBeak.onSuccess(cloudInverterDeviceBean);
+                    }
+                }
+
+                @Override
+                public void onFailure(HDLException e) {
+                    if (cloudCallBeak != null) {
+                        cloudCallBeak.onFailure(e);
+                    }
+                }
+            });
+        }
     }
 
 
@@ -1992,8 +2005,26 @@
             gatewayBean.setDeviceOidId(cloudInverterDeviceBean.getDeviceOidId());
             gatewayBean.setFwVersion(cloudInverterDeviceBean.getFwVersion());
         }
+        gatewayBean.setBmsSource(cloudInverterDeviceBean.getBmsSource());
+        //鏄惁鍙敮鎸佽繙绋嬪彂閫佸懡浠�
+        gatewayBean.setSupportLocalSendCommands(!this.isBmsDevice(gatewayBean.getDevice_model()));
+
     }
 
+    /**
+     * 鏄惁鏄疊MS璁惧锛堜负浠�涔堜娇鐢ㄨ澶囩被鍨嬫煡鎵撅紝鏄洜涓烘湁浜汢MS璁惧鏈夊彲鑳芥敮鎸乀CP鍜岃繙绋嬶紝鏈変簺BMS璁惧鍙敮鎸佽繙绋嬶紝鍥犱负鏈夊彲鑳戒娇鐢ㄥ拰閫嗗彉鍣ㄤ竴鏍风殑绯荤粺锛岃�屼笉鏄幇鍦ㄧ敤鍗曠墖鏈猴級
+     *
+     * @param model 璁惧绫诲瀷
+     * @return true琛ㄧず鏄疊MS璁惧锛屽惁鍒欎笉鏄�
+     */
+    private boolean isBmsDevice(String model) {
+        List<String> bmsModels = new ArrayList<>();
+        bmsModels.add("ME-GLE-BW5K");
+        if (bmsModels.contains("ME-GLE-BW5K")) {
+            return true;
+        }
+        return false;
+    }
 
     /**
      * 鑾峰彇缃戝叧鏀寔spk鍒楄〃

--
Gitblit v1.8.0