From 7e1ff0216432f674021c3e882ae5ff3724accea7 Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期四, 12 十二月 2024 16:50:46 +0800
Subject: [PATCH] 2024年12月12日16:50:44
---
app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java | 150 ++++++++++++++++++++++++++++++++++++++++++++++++-
1 files changed, 145 insertions(+), 5 deletions(-)
diff --git a/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java b/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
index 7beca24..c369bc7 100644
--- a/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
+++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
@@ -37,6 +37,7 @@
import com.hdl.photovoltaic.bean.PageNumberObject;
import com.hdl.photovoltaic.config.AppConfigManage;
import com.hdl.photovoltaic.config.UserConfigManage;
+import com.hdl.photovoltaic.internet.HttpClient;
import com.hdl.photovoltaic.internet.HttpServer.MyNanoHttpServer;
import com.hdl.photovoltaic.internet.TcpClient;
import com.hdl.photovoltaic.internet.api.TopicApi;
@@ -48,6 +49,7 @@
import com.hdl.photovoltaic.ui.bean.DeviceTimeBean;
import com.hdl.photovoltaic.ui.bean.Geolocation;
import com.hdl.photovoltaic.ui.bean.HouseIdBean;
+import com.hdl.photovoltaic.ui.bean.HouseInfoBean;
import com.hdl.photovoltaic.ui.bean.LinkBean;
import com.hdl.photovoltaic.ui.bean.MemberBean;
import com.hdl.photovoltaic.ui.bean.NotRunBean;
@@ -77,6 +79,7 @@
import com.hdl.sdk.link.gateway.HDLLinkLocalGateway;
import org.greenrobot.eventbus.EventBus;
+import org.json.JSONArray;
import org.json.JSONObject;
@@ -241,9 +244,14 @@
}
}
break;
- //鐢电珯鐨勪氦浠樹簩缁寸爜(瀹夎鍟�)
+// //鐢电珯鐨勪氦浠樹簩缁寸爜(瀹夎鍟�)
+// case HDLUniMP.UNI_EVENT_REPLY_HOME_DELIVERYURLQRCODE: {
+// uniGetDeliveryUrlQrcode(type, data, callback);
+// }
+// break;
+ //鐢电珯鐨勪氦浠楿RL(瀹夎鍟�)
case HDLUniMP.UNI_EVENT_REPLY_HOME_DELIVERYURLQRCODE: {
- uniGetDeliveryUrlQrcode(type, data, callback);
+ uniGetDeliveryUrl(type, data, callback);
}
break;
//鐢电珯鎵嬪姩浜や粯(瀹夎鍟�)
@@ -700,10 +708,90 @@
}
break;
//link杩涜瀵嗙爜楠岃瘉
- case HDLUniMP.UNI_EVENT_REPLY_OTHER_Password_verifiy: {
+ case HDLUniMP.UNI_EVENT_REPLY_OTHER_PASSWORD_VERIFIY: {
uniCheckPasswordVerification(mode_type, data, callback);
}
break;
+ //鏈湴json璧勬簮鏂囦欢鑾峰彇
+ case HDLUniMP.UNI_EVENT_REPLY_OTHER_GET_LOCAL_JSON: {
+ String url = getKeyValue("url", getKeyValue("data", data));
+ String deviceModel = getKeyValue("deviceModel", getKeyValue("data", data));
+ String language = getKeyValue("language", getKeyValue("data", data));
+ String json = HdlESLocalJsonLogic.getInstance().readHdlESLocalJson(url, deviceModel);
+ if (TextUtils.isEmpty(json)) {
+ //鏈湴娌℃湁缂撳瓨
+ HdlESLocalJsonLogic.getInstance().getHdlESLocalJson(url, deviceModel, new CloudCallBeak<String>() {
+ @Override
+ public void onSuccess(String obj) {
+// if (callback != null) {
+// uniSuccessCallback(type, obj, callback);
+// }
+ String s = HdlESLocalJsonLogic.getInstance().readHdlESLocalJson(url, deviceModel);
+ //鏈湴缂撳瓨鏁版嵁
+ if (callback != null) {
+ try {
+ if (s.startsWith("{")) {
+ uniSuccessCallback(type, new Gson().fromJson(s, JsonObject.class), callback);
+ } else if (s.startsWith("[")) {
+ uniSuccessCallback(type, new Gson().fromJson(s, JsonArray.class), callback);
+ } else {
+ uniSuccessCallback(type, s, callback);
+ }
+ } catch (Exception e) {
+ uniSuccessCallback(type, s, callback);
+ }
+ }
+ }
+
+ @Override
+ public void onFailure(HDLException e) {
+ if (callback != null) {
+ uniExceptionCallback(type, e, callback);
+ }
+ }
+ });
+ } else {
+ //鏈湴缂撳瓨鏁版嵁
+ if (callback != null) {
+ try {
+ if (json.startsWith("{")) {
+ uniSuccessCallback(type, new Gson().fromJson(json, JsonObject.class), callback);
+ } else if (json.startsWith("[")) {
+ uniSuccessCallback(type, new Gson().fromJson(json, JsonArray.class), callback);
+ } else {
+ uniSuccessCallback(type, json, callback);
+ }
+ } catch (Exception e) {
+ uniSuccessCallback(type, json, callback);
+ }
+ }
+ }
+ }
+ break;
+ }
+ } else if (HDLUniMP.UNI_EVENT_REPLY_COMMON_MODEL.equals(topic)) {
+ //缃戠粶璇锋眰妯″潡
+ if (type.equals(HDLUniMP.UNI_EVENT_REPLY_UNI_SEND_TO_CLOUD)) {
+ String url = getKeyValue("url", getKeyValue("data", data));
+ JsonObject jObject = new JsonObject();
+ String body = getKeyValue("body", getKeyValue("data", data));
+ if (!TextUtils.isEmpty(body)) {
+ try {
+ jObject = new Gson().fromJson(body, JsonObject.class);
+ } catch (Exception ignored) {
+ }
+ }
+ HttpClient.getInstance().requestHttp(url, jObject.toString(), new CloudCallBeak<String>() {
+ @Override
+ public void onSuccess(String jsonStr) {
+ uniSuccessCallback(mode_type, jsonStr, callback);
+ }
+
+ @Override
+ public void onFailure(HDLException e) {
+ uniExceptionCallback(mode_type, e, callback);
+ }
+ });
}
}
@@ -889,6 +977,32 @@
@Override
public void onSuccess(String obj) {
uniSuccessCallback(type, obj, callback);
+ }
+
+ @Override
+ public void onFailure(HDLException e) {
+ uniExceptionCallback(type, e, callback);
+ }
+ });
+
+ }
+
+ /**
+ * 鐢电珯鐨勪氦浠楿Rl(瀹夎鍟�)
+ */
+ private void uniGetDeliveryUrl(String type, Object data, DCUniMPJSCallback callback) {
+ String homeId = getKeyValue("homeId", getKeyValue("data", data));
+ HdlResidenceLogic.getInstance().getDeliveryUrl(homeId, new CloudCallBeak<String>() {
+ @Override
+ public void onSuccess(String obj) {
+ try {
+ Gson g = new Gson();
+ JsonObject jObject = g.fromJson(obj, JsonObject.class);
+ String deliveryUrl = jObject.get("deliveryUrl").toString();
+ uniSuccessCallback(type, deliveryUrl, callback);
+ } catch (Exception ignored) {
+ uniSuccessCallback(type, obj, callback);
+ }
}
@Override
@@ -2251,8 +2365,9 @@
HdlDeviceLogic.getInstance().getCurrentHomeLocalAndCloudGatewayList(homeId, new CloudCallBeak<List<GatewayBean>>() {
@Override
public void onSuccess(List<GatewayBean> list) {
+ List<GatewayBean> newList = sortLogic(list);
if (callback != null) {
- uniSuccessCallback(type, list, callback);
+ uniSuccessCallback(type, newList, callback);
}
//EventBus浜嬩欢鍒嗗彂,杩涘叆浣忓畢寮�濮嬭闃呬富棰�
BaseEventBus baseEventBus = new BaseEventBus();
@@ -2261,7 +2376,7 @@
baseEventBus.setData(homeId);
EventBus.getDefault().post(baseEventBus);
//杩涙潵浣忓畢璇︽儏閮借涓婁紶涓�娆id鍒楄〃鍒颁簯绔�;
- HdlDeviceLogic.getInstance().uploadOidDataToCloud(homeId, list, false, null);
+ HdlDeviceLogic.getInstance().uploadOidDataToCloud(homeId, newList, false, null);
}
@Override
@@ -2275,6 +2390,31 @@
}
/**
+ * 杩涜鎺掑簭锛堥�嗗彉鍣�-璐熻浇涓績锛�
+ *
+ * @param list 婧愭暟鎹�
+ * @return 杩斿洖鍒楄〃
+ */
+ private List<GatewayBean> sortLogic(List<GatewayBean> list) {
+ if (list == null || list.size() == 0) {
+ return new ArrayList<>();
+ }
+ List<GatewayBean> newList = new ArrayList<>();
+ List<GatewayBean> inverterList = new ArrayList<>();
+ List<GatewayBean> lcList = new ArrayList<>();
+ for (int i = 0; i < list.size(); i++) {
+ if (list.get(i).getSpk().equals(HdlDeviceLogic.getInstance().INVERTER_DEVICE_SPK)) {
+ inverterList.add(list.get(i));
+ } else {
+ lcList.add(list.get(i));
+ }
+ }
+ newList.addAll(inverterList);
+ newList.addAll(lcList);
+ return newList;
+ }
+
+ /**
* link spk 灞炴�х紪杈�
*
* @param data uni鏁版嵁
--
Gitblit v1.8.0