From 5bc17eebfdcf79f3f577b9cc774e8e6e944b3414 Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期三, 18 十二月 2024 13:52:57 +0800
Subject: [PATCH] 2024年12月18日13:52:55

---
 app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java |   57 +++++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 47 insertions(+), 10 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 9316532..b4bb9f3 100644
--- a/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
+++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
@@ -13,6 +13,7 @@
 import android.os.SystemClock;
 import android.provider.Settings;
 import android.text.TextUtils;
+import android.util.Log;
 
 import androidx.core.app.ActivityCompat;
 
@@ -141,6 +142,8 @@
             if (!HDLUniMP.UNI_APP_ID.equals(appId)) {
                 return;
             }
+            long startTime = System.currentTimeMillis();
+            Log.d("===寮�濮嬫椂闂�===", String.valueOf(startTime));
             String type = getKeyValue("type", data);//灏忕被
             String logTag = getKeyValue("logTag", data);//鏍囪uni鎸囦护
             String mode_type = "澶х被-" + topic + "---" + "灏忕被-" + type;//鐢ㄦ潵鎵撳嵃鐨�
@@ -244,16 +247,15 @@
                         }
                     }
                     break;
-                    //鐢电珯鐨勪氦浠樹簩缁寸爜(瀹夎鍟�)
-                    case HDLUniMP.UNI_EVENT_REPLY_HOME_DELIVERYURLQRCODE: {
-                        uniGetDeliveryUrlQrcode(type, data, callback);
-                    }
-                    break;
+//                    //鐢电珯鐨勪氦浠樹簩缁寸爜(瀹夎鍟�)
+//                    case HDLUniMP.UNI_EVENT_REPLY_HOME_DELIVERYURLQRCODE: {
+//                        uniGetDeliveryUrlQrcode(type, data, callback);
+//                    }
+//                    break;
                     //鐢电珯鐨勪氦浠楿RL(瀹夎鍟�)
-                    case HDLUniMP.UNI_EVENT_REPLY_HOME_DELIVERYURL: {
+                    case HDLUniMP.UNI_EVENT_REPLY_HOME_DELIVERYURLQRCODE: {
                         uniGetDeliveryUrl(type, data, callback);
                     }
-
                     break;
                     //鐢电珯鎵嬪姩浜や粯(瀹夎鍟�)
                     case HDLUniMP.UNI_EVENT_REPLY_HOME_DELIVERTOACCOUNT: {
@@ -765,6 +767,8 @@
                                 } catch (Exception e) {
                                     uniSuccessCallback(type, json, callback);
                                 }
+                                long endTime = System.currentTimeMillis() - startTime;
+                                Log.d("====鑰楁椂鏃堕棿====", String.valueOf(endTime));
                             }
                         }
                     }
@@ -996,7 +1000,14 @@
         HdlResidenceLogic.getInstance().getDeliveryUrl(homeId, new CloudCallBeak<String>() {
             @Override
             public void onSuccess(String obj) {
-                uniSuccessCallback(type, obj, callback);
+                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
@@ -2359,8 +2370,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();
@@ -2369,7 +2381,7 @@
                 baseEventBus.setData(homeId);
                 EventBus.getDefault().post(baseEventBus);
                 //杩涙潵浣忓畢璇︽儏閮借涓婁紶涓�娆id鍒楄〃鍒颁簯绔�;
-                HdlDeviceLogic.getInstance().uploadOidDataToCloud(homeId, list, false, null);
+                HdlDeviceLogic.getInstance().uploadOidDataToCloud(homeId, newList, false, null);
             }
 
             @Override
@@ -2383,6 +2395,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