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 | 615 +++++++++++++++++++++++++++++++++++++++----------------
1 files changed, 435 insertions(+), 180 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 9eb7e7f..6977834 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;
@@ -91,24 +92,27 @@
/**
* 鑾峰彇褰撳墠浣忓畢鐨勯�嗗彉鍣ㄥ垪琛�(鍖呮嫭浠庣殑閫嗗彉鍣�)
*
- * @param homeId 鐢电珯ID
- * @param cloudInverterDeviceList 鍏冪涓婄殑閫嗗彉鍣ㄥ垪琛紙骞剁綉锛岀缃戯紝璐熻浇涓績锛�
+ * @param homeId 鐢电珯ID
*/
- public List<GatewayBean> getCurrentHomeGatewayList(String homeId, List<CloudInverterDeviceBean> cloudInverterDeviceList) {
+ public List<GatewayBean> getCurrentHomeGatewayList(String homeId) {
try {
+
List<GatewayBean> newList = new ArrayList<>();
//浜戠鏈夎澶囧垪琛紝鏈湴娌℃湁锛屽嵆HDLLinkLocalGateway.getInstance().getGatewayList()娌℃湁锛岄噷闈細璋冪敤refreshGatewayCacheData()鏂规硶铏氭嫙涓�涓�嗗彉鍣ㄥ疄浣撴坊鍔犳湰鍦板垪琛ㄩ噷闈紱
List<GatewayBean> list = HDLLinkLocalGateway.getInstance().getGatewayList();
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)) {
@@ -116,29 +120,7 @@
}
}
}
- //鏈夊缃戯紝浠ヤ簯绔澶囧垪琛ㄤ负鍑�;浜戠娌℃湁锛屾湰鍦板瓨鍦紝鍒欏垹闄ゆ湰鍦帮紱鍚﹀垯锛屾病鏈夊缃戝彧鏈夊眬鍩熺綉锛屼互鏈湴涓轰富,鎼滅储澶氬皯涓澶囧氨鏄剧ず澶氬皯涓�
- if (cloudInverterDeviceList != null && cloudInverterDeviceList.size() > 0) {
- List<GatewayBean> checkNewList = new ArrayList<>();
- for (int i = 0; i < cloudInverterDeviceList.size(); i++) {
- CloudInverterDeviceBean cloudInverterDevice = cloudInverterDeviceList.get(i);
- for (GatewayBean gatewayBean : newList) {
- if (cloudInverterDevice.getOsn().equals(gatewayBean.getDevice_mac())) {
- checkNewList.add(gatewayBean);
- break;
- }
- }
- }
- newList.clear();
- newList.addAll(checkNewList);
- }
-// // 妯℃嫙璁惧鍒楄〃鏁版嵁
-// List<GatewayBean> mockData = getGatewayDeviceListMockData(3);
-// if (mockData.size() > 0) {
-// for (GatewayBean mockDatum : mockData) {
-// newList.add(0, mockDatum);
-// }
-// }
return newList;
} catch (Exception e) {
@@ -146,6 +128,62 @@
}
}
+
+ /**
+ * 鑾峰彇褰撳墠浣忓畢鐨勯�嗗彉鍣ㄥ垪琛�(鍖呮嫭浠庣殑閫嗗彉鍣�)
+ * 鍙互璁剧疆鏄惁鏁村悎鏈湴閫嗗彉鍣ㄥ垪琛ㄦ暟鎹�
+ *
+ * @param homeId 鐢电珯ID
+ * @param cloudInverterDeviceList 浜戠涓婄殑閫嗗彉鍣ㄥ垪琛紙骞剁綉锛岀缃戯紝璐熻浇涓績锛�
+ * @param isIntegrateLocalData 鏄惁寮哄埗鏁村悎鏈湴閫嗗彉鍣ㄦ暟鎹紙false锛氫笉闇�瑕侊紙浠ヤ簯绔垪琛ㄤ负涓�(閫嗗彉鍣紝璐熻浇涓績)澶氬皯涓樉绀哄灏戜釜锛�,true锛氶渶瑕侊紙鏈夊缃戯紝浠ヤ簯绔澶囧垪琛ㄤ负鍑�;浜戠娌℃湁锛屾湰鍦板瓨鍦紝鍒欏垹闄ゆ湰鍦帮紱鍚﹀垯锛屾病鏈夊缃戝彧鏈夊眬鍩熺綉锛屼互鏈湴鍒楄〃涓轰富,鎼滅储澶氬皯涓澶囧氨鏄剧ず澶氬皯涓級锛�
+ */
+ public List<GatewayBean> IntegrateCloudAndLocalData(String homeId, List<CloudInverterDeviceBean> cloudInverterDeviceList, boolean isIntegrateLocalData) {
+ try {
+ List<GatewayBean> newList = new ArrayList<>();
+ //浜戠鏈夎澶囧垪琛紝鏈湴娌℃湁锛屽嵆HDLLinkLocalGateway.getInstance().getGatewayList()娌℃湁锛岄噷闈細璋冪敤refreshGatewayCacheData()鏂规硶铏氭嫙涓�涓�嗗彉鍣ㄥ疄浣撴坊鍔犳湰鍦板垪琛ㄩ噷闈紱
+ List<GatewayBean> localList = getCurrentHomeGatewayList(homeId);
+ if (localList != null && localList.size() > 0) {
+ newList.addAll(localList);
+ }
+
+ //鏈夊缃戯紝浠ヤ簯绔澶囧垪琛ㄤ负鍑�;浜戠娌℃湁锛屾湰鍦板瓨鍦紝鍒欏垹闄ゆ湰鍦帮紱鍚﹀垯锛屾病鏈夊缃戝彧鏈夊眬鍩熺綉锛屼互鏈湴newList鍒楄〃涓轰富,鎼滅储澶氬皯涓澶囧氨鏄剧ず澶氬皯涓�
+ if (cloudInverterDeviceList != null && cloudInverterDeviceList.size() > 0) {
+ List<GatewayBean> checkNewList = new ArrayList<>();
+ for (int i = 0; i < cloudInverterDeviceList.size(); i++) {
+ CloudInverterDeviceBean cloudInverterDevice = cloudInverterDeviceList.get(i);
+ for (GatewayBean gatewayBean : newList) {
+ if (cloudInverterDevice.getOsn().equals(gatewayBean.getDevice_mac())) {
+ //鑾峰彇鏇村叏閫嗗彉鍣ㄨ鎯呭瓧娈�
+ checkNewList.add(gatewayBean);
+ break;
+ }
+ }
+ }
+ newList.clear();
+ newList.addAll(checkNewList);
+ }
+
+
+// //妯℃嫙璁惧鍒楄〃鏁版嵁
+// List<GatewayBean> mockData = getGatewayDeviceListMockData(3);
+// if (mockData.size() > 0) {
+// for (GatewayBean mockDatum : mockData) {
+// newList.add(0, mockDatum);
+// }
+// }
+
+ //鑳″浆瑕佹眰鐨� 2025骞�05鏈�19鏃�13:28:47 鍗充娇閫嗗彉鍣ㄥ垹闄や簡浜戠涓婃垚鍔燂紝鏈湴閫嗗彉鍣ㄥ垵濮嬪寲涓嶆垚鍔燂紙鏂紑锛変緷鐒朵笉鏄剧ず锛�
+ if (!isIntegrateLocalData) {
+ //寮哄埗浠ヤ簯绔负涓伙紝浜戠鏈夊氨鏄剧ず閫嗗彉鍣ㄥ垪琛紝娌℃湁灏变笉鏄剧ず
+ if (cloudInverterDeviceList == null || cloudInverterDeviceList.size() == 0) {
+ newList.clear();
+ }
+ }
+ return newList;
+ } catch (Exception e) {
+ return new ArrayList<>();
+ }
+ }
/**
* 娣诲姞閫嗗彉鍣ㄥ埌缂撳瓨鍒楄〃閲岄潰鍘�
@@ -157,7 +195,7 @@
if (newGatewayBean == null || TextUtils.isEmpty(homeId)) {
return;
}
- List<GatewayBean> list = getCurrentHomeGatewayList(homeId, null);
+ List<GatewayBean> list = getCurrentHomeGatewayList(homeId);
if (list == null || list.size() == 0) {
return;
}
@@ -186,7 +224,7 @@
if (TextUtils.isEmpty(mac)) {
return;
}
- List<GatewayBean> list = getCurrentHomeGatewayList(homeId, null);
+ List<GatewayBean> list = getCurrentHomeGatewayList(homeId);
if (list == null || list.size() == 0) {
return;
}
@@ -213,7 +251,7 @@
if (TextUtils.isEmpty(deviceId)) {
return;
}
- List<GatewayBean> list = getCurrentHomeGatewayList(homeId, null);
+ List<GatewayBean> list = HDLLinkLocalGateway.getInstance().getGatewayList();
if (list == null || list.size() == 0) {
return;
}
@@ -225,9 +263,10 @@
break;
}
}
- if (index > 0) {
+ if (index > -1) {
list.remove(index);
}
+
}
/**
@@ -603,6 +642,43 @@
});
}
+ /**
+ * 鑾峰彇浜戠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");//鍖哄煙
+
+ 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);
+ }
+ }
+ });
+ }
+
/**
* 鍒犻櫎浜戠涓婇�嗗彉鍣�
@@ -692,7 +768,7 @@
}
String requestUrl = HttpApi.POST_Device_Oid;
JsonObject json = new JsonObject();
- json.addProperty("operationSource", "PROGRAM_ENERGY");//
+ json.addProperty("operationSource", "PROGRAM_ENERGY");//鎿嶄綔鏉ユ簮锛氬浐瀹氫紶锛歅ROGRAM_ENERGY = 鑳芥簮锛孭ROGRAM = studio 榛樿
json.addProperty("homeId", homeId);
JsonArray jsonArray = new JsonArray();
for (int i = 0; i < oidList.size(); i++) {
@@ -752,6 +828,7 @@
String requestUrl = HttpApi.POST_Device_IncrAdd;
JsonObject json = new JsonObject();
json.addProperty("homeId", homeId);
+ json.addProperty("operationSource", "PROGRAM_ENERGY");//鎿嶄綔鏉ユ簮锛氬浐瀹氫紶锛歅ROGRAM_ENERGY = 鑳芥簮锛孭ROGRAM = studio 榛樿
JsonArray jsonArray = new JsonArray();
for (int i = 0; i < oidList.size(); i++) {
OidBean oidBean = oidList.get(i);
@@ -1122,132 +1199,235 @@
}
+
/**
- * 鑾峰彇閫嗗彉鍣ㄥ垪琛�,鏁村悎浜戠閫嗗彉鍣ㄥ垪琛ㄥ拰鏈湴閫嗗彉鍣ㄥ垪琛�(璁惧绫诲瀷鏈�:骞剁綉閫嗗彉鍣紝绂荤嚎閫嗗彉鍣紝璐熻浇涓績璁惧);
- * 娉ㄦ剰:鏈夊缃戯紝浠ヤ簯绔澶囧垪琛ㄤ负鍑�;浜戠娌℃湁锛屾湰鍦板瓨鍦紝鍒欏垹闄ゆ湰鍦帮紱鍚﹀垯锛屾病鏈夊缃戝彧鏈夊眬鍩熺綉锛屼互鏈湴涓轰富,鎼滅储澶氬皯涓澶囧氨鏄剧ず澶氬皯涓�
+ * 鍒犻櫎oid锛堥�嗗彉鍣紝bms锛岀數姹犲寘锛�
*
- * @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 deleteOid(String mac, JsonArray oidList, LinkCallBack<Boolean> linkCallBack) {
+ String requestUrl = TopicApi.DELETE_DEVICE;
+ TcpClient.getInstance().sendDataToLinkGateway(mac, requestUrl, oidList, "", 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(getCurrentHomeGatewayList(homeId, null));
- }
- return;
- }
- //璁剧疆璁惧鐨勮繙绋嬩俊鎭�
- setDeviceRemoteInfo(loadCentreDeviceList, homeId, cloudCallBeak);
- }
-
- @Override
- public void onFailure(HDLException e) {
- //鍚戜簯绔幏鍙栬礋杞戒腑蹇冭澶囧垪琛ㄥけ璐ュ悗锛岄粯璁よ繑鍥炴湰鍦伴�嗗彉鍣ㄥ垪琛�;
- if (cloudCallBeak != null) {
- cloudCallBeak.onSuccess(getCurrentHomeGatewayList(homeId, null));
- }
- }
- });
-
- }
- });
+ 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 mac 缃戝叧mac
+ * @param linkCallBack 鍥炶皟
+ */
+ 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(String json) {
+ if (linkCallBack != null) {
+ linkCallBack.onSuccess(true);
+ }
+ }
+
+ @Override
+ public void onError(HDLLinkException e) {
+ 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<>());
+ }
+ }
+ });
+ }
+ });
+ }
+ });
+ }
}
/**
@@ -1261,13 +1441,32 @@
if (list == null || list.size() == 0) {
//浜戠娌℃湁缁戝畾閫嗗彉鍣�,榛樿杩斿洖鏈湴閫嗗彉鍣ㄥ垪琛�;
if (cloudCallBeak != null) {
- cloudCallBeak.onSuccess(getCurrentHomeGatewayList(homeId, list));
+ cloudCallBeak.onSuccess(IntegrateCloudAndLocalData(homeId, list, false));
}
return;
}
AtomicInteger atomicInteger = new AtomicInteger(0);
for (int i = 0; i < list.size(); i++) {
CloudInverterDeviceBean cloudInverterDeviceBean = list.get(i);
+ if (cloudInverterDeviceBean == null) {
+ 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>() {
@Override
@@ -1278,7 +1477,7 @@
//鍒版渶鍚庝竴鏉★紝鎵嶅鐞嗗洖璋�
if (atomicInteger.get() == list.size()) {
if (cloudCallBeak != null) {
- cloudCallBeak.onSuccess(getCurrentHomeGatewayList(homeId, list));
+ cloudCallBeak.onSuccess(IntegrateCloudAndLocalData(homeId, list, false));
}
}
}
@@ -1292,10 +1491,10 @@
//鍒版渶鍚庝竴鏉★紝鎵嶅鐞嗗洖璋�
if (atomicInteger.get() == list.size()) {
if (cloudCallBeak != null) {
- cloudCallBeak.onSuccess(getCurrentHomeGatewayList(homeId, list));
+ cloudCallBeak.onSuccess(IntegrateCloudAndLocalData(homeId, list, false));
}
}
- HdlLogLogic.print("鑾峰彇璁惧杩滅▼閫氳淇℃伅澶辫触(mac:"+cloudInverterDeviceBean.getOsn()+")------" + e.getMsg() + "(" + e.getCode() + ")",true);
+ HdlLogLogic.print("鑾峰彇璁惧杩滅▼閫氳淇℃伅澶辫触(mac:" + cloudInverterDeviceBean.getOsn() + ")------" + e.getMsg() + "(" + e.getCode() + ")", true);
}
});
}
@@ -1504,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);
+ }
+ }
+ });
+ }
}
@@ -1770,11 +1997,34 @@
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());
+ }
+ 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鍒楄〃
@@ -1786,6 +2036,7 @@
spks.add(INVERTER_DEVICE_SPK);
spks.add(LC_SPK);
spks.add(OFF_INVERTER_OG_SPK);
+ spks.add(HDL_BMS_SPK);
return spks;
}
@@ -1845,4 +2096,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