From a59bbb7890e107a681f677765f2600e278c06a0d Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期一, 09 十月 2023 10:16:37 +0800
Subject: [PATCH] 2023年10月09日10:16:35
---
app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java | 141 +++++++++++++++++++++++++++++++++++++++++------
1 files changed, 123 insertions(+), 18 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 0f57fad..6462ac8 100644
--- a/app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java
+++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java
@@ -38,7 +38,6 @@
import java.util.ArrayList;
import java.util.List;
-import io.reactivex.rxjava3.disposables.Disposable;
/**
* 璁惧閫昏緫
@@ -55,10 +54,13 @@
if (list.size() > 0) {
for (int i = 0; i < list.size(); i++) {
GatewayBean gatewayBean = list.get(i);
+ if (TextUtils.isEmpty(gatewayBean.getDevice_mac())) {
+ continue;
+ }
if (gatewayBean.getMaster().equals("true")
&& gatewayBean.getHomeId().equals(UserConfigManage.getInstance().getHomeId())) {
- if("0101050217BBC400".equals(gatewayBean.getOid()))//娴嬭瘯鏃惰繃婊ゆ帀鏃犳晥鐨勶紝鍚庨潰杩欏姞浠g爜瑕佸垹闄�
- continue;
+// if ("0101050217BBC400".equals(gatewayBean.getOid()))//娴嬭瘯鏃惰繃婊ゆ帀鏃犳晥鐨勶紝杩欒鍚庨潰浠g爜瑕佸垹闄�
+// continue;
newList.add(gatewayBean);
}
}
@@ -110,6 +112,31 @@
public void onSuccess(String str) {
if (cloudCallBeak != null) {
cloudCallBeak.onSuccess(true);
+ //涓存椂鐨勯�昏緫锛屼笂浼爋id鍒楄〃鍒颁簯绔�
+ getGatewayOidList(mac, new LinkCallBack<List<OidBean>>() {
+ @Override
+ public void onSuccess(List<OidBean> obj) {
+ if (obj == null) {
+ return;
+ }
+ fullUpdateOid(obj, new CloudCallBeak<Boolean>() {
+ @Override
+ public void onSuccess(Boolean obj) {
+
+ }
+
+ @Override
+ public void onFailure(HDLException e) {
+
+ }
+ });
+ }
+
+ @Override
+ public void onError(HDLLinkException e) {
+
+ }
+ });
}
}
@@ -237,7 +264,7 @@
* @param cloudCallBeak 鍥炶皟update
*/
public void fullUpdateOid(List<OidBean> oidList, CloudCallBeak<Boolean> cloudCallBeak) {
- String requestUrl = HttpApi.POST_Device_ChildDevices_List;
+ String requestUrl = HttpApi.POST_Device_Oid;
JsonObject json = new JsonObject();
json.addProperty("operationSource", "PROGRAM_ENERGY");//
json.addProperty("homeId", UserConfigManage.getInstance().getHomeId());
@@ -247,7 +274,7 @@
JsonObject jsonObject = new JsonObject();
jsonObject.addProperty("protocolType", oidBean.getProtocolType());
jsonObject.addProperty("deviceType", oidBean.getDeviceType());
- jsonObject.addProperty("mac", oidBean.getMac());
+ jsonObject.addProperty("mac", oidBean.getDevice_mac());
jsonObject.addProperty("oid", oidBean.getOid());
jsonObject.addProperty("device_name", oidBean.getDevice_name());
jsonObject.addProperty("device_model", oidBean.getDevice_model());
@@ -318,6 +345,64 @@
}
/**
+ * 缃戝叧鏃堕棿璇诲彇
+ *
+ * @param mac 璁惧mac
+ * @param linkCallBack 鍥炶皟update
+ */
+ public void getGatewayTime(String mac, LinkCallBack<Boolean> linkCallBack) {
+ String requestUrl = TopicApi.GET_GATEWAY_TIME;
+ TcpClient.getInstance().sendDataToLinkGateway(mac, requestUrl, null, "", new HDLLinkCallBack() {
+ @Override
+ public void onSuccess(String msg) {
+ if (linkCallBack != null) {
+ linkCallBack.onSuccess(true);
+ }
+ }
+
+ @Override
+ public void onError(HDLLinkException e) {
+ if (linkCallBack != null) {
+ linkCallBack.onError(e);
+ }
+ }
+ });
+
+ }
+
+ /**
+ * 缃戝叧鏃堕棿淇敼
+ *
+ * @param mac 璁惧mac
+ * @param linkCallBack 鍥炶皟update
+ */
+ public void editGatewayTime(String mac, JsonObject jsonObject, LinkCallBack<Boolean> linkCallBack) {
+ String requestUrl = TopicApi.SET_GATEWAY_TIME_EDIT;
+// JsonObject json = new JsonObject();
+// json.addProperty("master", "true");
+// "objects": {
+// "date": "2020-08-15",
+// "time": "17:25:20"
+// }
+ TcpClient.getInstance().sendDataToLinkGateway(mac, requestUrl, jsonObject, "", new HDLLinkCallBack() {
+ @Override
+ public void onSuccess(String msg) {
+ if (linkCallBack != null) {
+ linkCallBack.onSuccess(true);
+ }
+ }
+
+ @Override
+ public void onError(HDLLinkException e) {
+ if (linkCallBack != null) {
+ linkCallBack.onError(e);
+ }
+ }
+ });
+
+ }
+
+ /**
* 缂栬緫缃戝叧鍙傛暟
*
* @param mac 璁惧mac
@@ -344,7 +429,6 @@
});
}
-
/**
* 鑾峰彇缃戝叧璇︽儏淇℃伅
@@ -457,8 +541,14 @@
}
}
for (int i = 0; i < removeSidList.size(); i++) {
- //鑾峰彇鏈湴鐨勯�嗗彉鍣�
+ //鍒犻櫎鏈湴鐨勯�嗗彉鍣�
removeInverter(removeSidList.get(i));
+ }
+
+ for (int i = 0; i < list.size(); i++) {
+ CloudInverterDeviceBean cloudInverterDeviceBean = list.get(i);
+ GatewayBean gatewayBean = HDLLinkLocalGateway.getInstance().getLocalGateway(cloudInverterDeviceBean.getSid());
+ objectAssignment(cloudInverterDeviceBean, gatewayBean);
}
if (cloudCallBeak != null) {
@@ -480,25 +570,20 @@
HdlDeviceLogic.getInstance().getCloudInverterDeviceList(UserConfigManage.getInstance().getHomeId(), new CloudCallBeak<List<CloudInverterDeviceBean>>() {
@Override
public void onSuccess(List<CloudInverterDeviceBean> list) {
+ //娓呮鏈湴缃戝叧鍒楄〃
+ HDLLinkLocalGateway.getInstance().getGatewayList().clear();
if (list == null || list.size() == 0) {
if (cloudCallBeak != null) {
cloudCallBeak.onSuccess(true);
}
return;
}
- //娓呮鏈湴缃戝叧鍒楄〃
- HDLLinkLocalGateway.getInstance().getGatewayList().clear();
for (int i = 0; i < list.size(); i++) {
CloudInverterDeviceBean cloudInverterDeviceBean = list.get(i);
+ //浜戠瀵硅薄鏁版嵁浜ゆ崲鍒版湰鍦板璞�
GatewayBean gatewayBean = new GatewayBean();
- gatewayBean.setOid(cloudInverterDeviceBean.getOid());
- gatewayBean.setSid(cloudInverterDeviceBean.getSid());
- gatewayBean.setGatewayId(cloudInverterDeviceBean.getGatewayId());
- gatewayBean.setOnline(cloudInverterDeviceBean.isOnline());
- gatewayBean.setDevice_name(cloudInverterDeviceBean.getGatewayName());
- gatewayBean.setHomeId(UserConfigManage.getInstance().getHomeId());
- gatewayBean.setLocalEncrypt(true);
- gatewayBean.setMaster("true");
+ objectAssignment(cloudInverterDeviceBean, gatewayBean);
+
//娣诲姞缃戝叧
HDLLinkLocalGateway.getInstance().getGatewayList().add(gatewayBean);
}
@@ -525,7 +610,6 @@
* @param sid 璁惧sid
*/
private void removeInverter(String sid) {
- //鑾峰彇鏈湴鐨勬绫虫尝
GatewayBean gatewayBean = HDLLinkLocalGateway.getInstance().getLocalGateway(sid);
if (gatewayBean != null) {
HDLLinkLocalGateway.getInstance().getGatewayList().remove(gatewayBean);
@@ -543,6 +627,27 @@
HDLLinkLocalGateway.getInstance().refreshGatewayByHomeIdAndSpk(UserConfigManage.getInstance().getHomeId(), spks, true, gatewayCallBack);
}
+
+ private void objectAssignment(CloudInverterDeviceBean cloudInverterDeviceBean, GatewayBean gatewayBean) {
+ if (cloudInverterDeviceBean == null || gatewayBean == null) {
+ return;
+ }
+ gatewayBean.setOid(cloudInverterDeviceBean.getOid());
+ gatewayBean.setSid(cloudInverterDeviceBean.getSid());
+ gatewayBean.setGatewayId(cloudInverterDeviceBean.getGatewayId());
+ gatewayBean.setOnline(cloudInverterDeviceBean.isOnline());
+ gatewayBean.setDevice_mac(cloudInverterDeviceBean.getOsn());//璁惧mac
+ gatewayBean.setDevice_name(cloudInverterDeviceBean.getGatewayName());
+ gatewayBean.setHomeId(UserConfigManage.getInstance().getHomeId());
+ gatewayBean.setLocalEncrypt(true);
+ gatewayBean.setMaster("true");
+ gatewayBean.setSystemStatusDesc(cloudInverterDeviceBean.getSystemStatusDesc());
+ gatewayBean.setHwVersion(cloudInverterDeviceBean.getHwVersion());
+ gatewayBean.setCategorySecondName(cloudInverterDeviceBean.getCategorySecondName());
+ gatewayBean.setDeviceId(cloudInverterDeviceBean.getDeviceId());
+
+ }
+
/**
* 鑾峰彇缃戝叧spk鍒楄〃
*
--
Gitblit v1.8.0