From 3e904bfa8a1bb53dcf461e5c717f9b808e179245 Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期三, 08 一月 2025 16:27:48 +0800
Subject: [PATCH] 2025年01月08日16:27:46
---
app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java | 113 +++++++++++++++++++++++++++++++++++++++++++++++++++-----
1 files changed, 102 insertions(+), 11 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 d93086a..f5eb2c4 100644
--- a/app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java
+++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java
@@ -8,6 +8,8 @@
import com.google.gson.JsonObject;
import com.google.gson.reflect.TypeToken;
import com.hdl.linkpm.sdk.core.exception.HDLException;
+import com.hdl.photovoltaic.bean.InverterBean;
+import com.hdl.photovoltaic.bean.LocalResponse;
import com.hdl.photovoltaic.bean.PageNumberObject;
import com.hdl.photovoltaic.config.AppConfigManage;
import com.hdl.photovoltaic.config.UserConfigManage;
@@ -909,7 +911,7 @@
* @param mac 缃戝叧mac
* @param linkCallBack 鍥炶皟
*/
- public void getGatewayInfo(String mac, LinkCallBack<GatewayBean> linkCallBack) {
+ public void getGatewayInfo(String mac, LinkCallBack<InverterBean> linkCallBack) {
String requestUrl = TopicApi.GET_GATEWAY_INFO;
JsonObject json = new JsonObject();
json.addProperty("device_mac", mac);
@@ -925,11 +927,11 @@
}
Gson gson = new Gson();
- Type typeOfT = new TypeToken<BaseLocalResponse<GatewayBean>>() {
+ Type typeOfT = new TypeToken<BaseLocalResponse<InverterBean>>() {
}.getType();
- BaseLocalResponse<GatewayBean> baseLocalResponse = gson.fromJson(json, typeOfT);
+ BaseLocalResponse<InverterBean> baseLocalResponse = gson.fromJson(json, typeOfT);
if (baseLocalResponse == null || baseLocalResponse.getObjects() == null) {
- linkCallBack.onSuccess(new GatewayBean());
+ linkCallBack.onSuccess(new InverterBean());
} else {
linkCallBack.onSuccess(baseLocalResponse.getObjects());
}
@@ -1166,19 +1168,63 @@
@Override
public void onError(HDLLinkException e) {
//澶栫綉鍙湁1绉嶆儏鍐�(鏈湴鎼滅储閫嗗彉鍣ㄥ垪琛ㄥけ璐ヤ簡)
+ //鍚戜簯绔幏鍙栭�嗗彉鍣ㄥ垪琛�
getCloudInverterDeviceList(homeId, new CloudCallBeak<List<CloudInverterDeviceBean>>() {
@Override
- public void onSuccess(List<CloudInverterDeviceBean> list) {
- //澶栫綉杩涙潵鍏堛�愰粯璁ゃ�戞竻绌烘湰鍦伴�嗗彉鍣ㄥ垪琛�
- HDLLinkLocalGateway.getInstance().getGatewayList().clear();
- setDeviceRemoteInfo(list, homeId, cloudCallBeak);
+ public void onSuccess(List<CloudInverterDeviceBean> cloudInverterList) {
+ //鍐嶅悜浜戠鑾峰彇璐熻浇涓績鍒楄〃
+ getLoadCentreDeviceList(homeId, new CloudCallBeak<List<CloudInverterDeviceBean>>() {
+ @Override
+ public void onSuccess(List<CloudInverterDeviceBean> loadCentreDeviceList) {
+ //澶栫綉杩涙潵鍏堛�愰粯璁ゃ�戞竻绌烘湰鍦伴�嗗彉鍣ㄥ垪琛�
+ HDLLinkLocalGateway.getInstance().getGatewayList().clear();
+ 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) {
+ //澶栫綉杩涙潵鍏堛�愰粯璁ゃ�戞竻绌烘湰鍦伴�嗗彉鍣ㄥ垪琛�
+ //鍚戜簯绔幏鍙栬礋杞戒腑蹇冨垪琛ㄥけ璐�,鐩存帴杩斿洖閫嗗彉鍣ㄥ垪琛紱
+ HDLLinkLocalGateway.getInstance().getGatewayList().clear();
+ setDeviceRemoteInfo(cloudInverterList, homeId, cloudCallBeak);
+ }
+ });
+// //澶栫綉杩涙潵鍏堛�愰粯璁ゃ�戞竻绌烘湰鍦伴�嗗彉鍣ㄥ垪琛�
+// HDLLinkLocalGateway.getInstance().getGatewayList().clear();
+// setDeviceRemoteInfo(list, homeId, cloudCallBeak);
}
@Override
public void onFailure(HDLException e) {
- if (cloudCallBeak != null) {
- cloudCallBeak.onFailure(e);
- }
+ //鍚戜簯绔幏鍙栭�嗗彉鍣ㄥ垪琛ㄥけ璐�
+ //鍐嶅悜浜戠鑾峰彇璐熻浇涓績鍒楄〃
+ getLoadCentreDeviceList(homeId, new CloudCallBeak<List<CloudInverterDeviceBean>>() {
+ @Override
+ public void onSuccess(List<CloudInverterDeviceBean> loadCentreDeviceList) {
+ //澶栫綉杩涙潵鍏堛�愰粯璁ゃ�戞竻绌烘湰鍦伴�嗗彉鍣ㄥ垪琛�
+ HDLLinkLocalGateway.getInstance().getGatewayList().clear();
+ //閫嗗彉鍣ㄥ垪琛ㄥ拰璐熻浇涓績鍒楄〃
+ setDeviceRemoteInfo(loadCentreDeviceList, homeId, cloudCallBeak);
+ }
+
+ @Override
+ public void onFailure(HDLException e) {
+ if (cloudCallBeak != null) {
+ cloudCallBeak.onFailure(e);
+ }
+ }
+ });
+// if (cloudCallBeak != null) {
+// cloudCallBeak.onFailure(e);
+// }
}
});
}
@@ -1600,6 +1646,46 @@
}
/**
+ * 閫嗗彉鍣ㄥ瘑鐮佺櫥褰�
+ *
+ * @param mac 閫嗗彉鍣╩ac
+ * @param password 閫嗗彉鍣ㄥ瘑鐮�
+ */
+ public void getPasswordVerification(String mac, String password, LinkCallBack<LocalResponse> callBeak) {
+ String requestUrl = TopicApi.DELETING_GATEWAY_password_verifiy;
+ JsonObject json = new JsonObject();
+ json.addProperty("password", password);
+ json.addProperty("mac", mac);
+ TcpClient.getInstance().sendDataToLinkGateway(mac, false, requestUrl, json, "", new HDLLinkCallBack() {
+ @Override
+ public void onSuccess(String msg) {
+ try {
+
+ Gson gson = new Gson();
+ LocalResponse localResponse = gson.fromJson(msg, LocalResponse.class);
+ if (localResponse == null) {
+ localResponse = new LocalResponse();
+ }
+ if (callBeak != null) {
+ callBeak.onSuccess(localResponse);
+ }
+ } catch (Exception e) {
+ if (callBeak != null) {
+ callBeak.onSuccess(new LocalResponse());
+ }
+ }
+ }
+
+ @Override
+ public void onError(HDLLinkException e) {
+ if (callBeak != null) {
+ callBeak.onError(e);
+ }
+ }
+ });
+ }
+
+ /**
* 鍒锋柊閫嗗彉鍣ㄧ紦瀛樹俊鎭�(鍖呮嫭璁剧疆mqtt绉橀挜锛�
* 娉�: //鐩殑鏄负浜嗚幏鍙栨嬁鍒扮綉鍏矷D锛宮qtt閫氳绉橀挜绛変俊鎭紝缂撳瓨鏈湴閫嗗彉鍣ㄥ垪琛ㄩ噷闈紝鍙戦�佹暟鎹暟鎹椂鑷姩鍘荤紦瀛樺垪琛ㄩ噷闈㈠幓鏌ユ壘锛�
* 1:鏈湴瀛樺湪,鏇存柊淇℃伅鍗冲彲;
@@ -1662,6 +1748,7 @@
public List<String> getGatewaySpk() {
List<String> spks = new ArrayList<>();
spks.add(INVERTER_DEVICE_SPK);
+ spks.add(LC_SPK);
return spks;
}
@@ -1681,4 +1768,8 @@
* 閫嗗彉鍣╯pk
*/
public final String INVERTER_DEVICE_SPK = "energy.hdl_inverter";
+ /**
+ * 璐熻浇涓績spk
+ */
+ public final String LC_SPK = "energy.hdl_lc";
}
--
Gitblit v1.8.0