From 936fb552a30c05fc7a60c20f47bf6fccbc2dc1c1 Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期三, 27 十二月 2023 16:17:23 +0800
Subject: [PATCH] 备份一下代码

---
 app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java |   72 +++++++++++++++++++++++-------------
 1 files changed, 46 insertions(+), 26 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 0667e34..034ccaa 100644
--- a/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
+++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlUniLogic.java
@@ -28,6 +28,7 @@
 import com.hdl.photovoltaic.uni.HDLUniMP;
 import com.hdl.photovoltaic.uni.HDLUniMPSDKManager;
 import com.hdl.photovoltaic.utils.AppManagerUtils;
+import com.hdl.photovoltaic.utils.NetworkUtils;
 import com.hdl.photovoltaic.utils.WifiUtils;
 import com.hdl.sdk.link.common.exception.HDLLinkCode;
 import com.hdl.sdk.link.common.exception.HDLLinkException;
@@ -97,9 +98,9 @@
                 switch (type) {
                     //鍒涘缓鐢电珯
                     case HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION: {
-
                         //EventBus浜嬩欢鍒嗗彂
                         BaseEventBus baseEventBus = new BaseEventBus();
+                        baseEventBus.setTopic(HDLUniMP.UNI_EVENT_REPLY_HOME_MODEL);
                         baseEventBus.setType(HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION);
                         baseEventBus.setData(getKeyValue("data", data));
                         EventBus.getDefault().post(baseEventBus);
@@ -115,6 +116,16 @@
                         //EventBus浜嬩欢鍒嗗彂
                         BaseEventBus baseEventBus = new BaseEventBus();
                         baseEventBus.setType(HDLUniMP.UNI_EVENT_REPLY_HOME_CLOSE_HOME_DETAILS_PAGE);
+                        baseEventBus.setData(getKeyValue("data", data));
+                        EventBus.getDefault().post(baseEventBus);
+                    }
+                    break;
+                    //浣忓畢銆愮數绔欍�戠紪杈�
+                    case HDLUniMP.UNI_EVENT_REPLY_HOME_EDIT: {
+                        //EventBus浜嬩欢鍒嗗彂
+                        BaseEventBus baseEventBus = new BaseEventBus();
+                        baseEventBus.setTopic(HDLUniMP.UNI_EVENT_REPLY_HOME_MODEL);
+                        baseEventBus.setType(HDLUniMP.UNI_EVENT_REPLY_HOME_EDIT);
                         baseEventBus.setData(getKeyValue("data", data));
                         EventBus.getDefault().post(baseEventBus);
                     }
@@ -144,7 +155,7 @@
                     break;
                     //鑾峰彇閫嗗彉鍣ㄥ垪琛�
                     case HDLUniMP.UNI_EVENT_REPLY_DEVICE_LIST: {
-                        this.uniGetCurrentHomeLocalAndCloudGatewayList(callback);
+                        this.uniGetCurrentHomeLocalAndCloudGatewayList(data, callback);
                     }
                     break;
                     //modBus鍗忚涓撶敤
@@ -182,7 +193,7 @@
                 }
 
             } else if (HDLUniMP.UNI_EVENT_REPLY_WIFI_MODEL.equals(topic)) {
-                WifiUtils wifiUtils = new WifiUtils(HDLApp.getInstance());
+                WifiUtils wifiUtils = WifiUtils.getInstance();
                 //wifi妯″潡
                 switch (type) {
                     //鑾峰彇wifi鍒楄〃
@@ -309,9 +320,9 @@
                     break;
                 }
             }
-            HdlLogLogic.print("uni===鍘熺敓鎺ユ敹uni鍙戞潵鐨勬暟鎹�===澶х被->" + topic + "\r\n" + data, true);
+            HdlLogLogic.print("uni鍙戞潵鐨勬暟鎹�--->澶х被-->" + topic + "\r\n" + data, true);
         } catch (Exception e) {
-            HdlLogLogic.print("uni===鍘熺敓鎺ユ敹uni鍙戞潵鐨勬暟鎹�===" + e.getMessage(), true);
+            HdlLogLogic.print("uni鍙戞潵鐨勬暟鎹�--->" + e.getMessage(), true);
         }
 
     }
@@ -326,7 +337,7 @@
     public void openUniMP(String path, JSONObject jsonObject) {
         JSONObject json = this.createdJSONObject(jsonObject, true);
         HDLUniMPSDKManager.getInstance().openUniMP(HDLUniMP.UNI_APP_ID, path, json, HdlUniLogic.this);
-        HdlLogLogic.print("uni===缁勮uni鍙戦�佹暟鎹牸寮�===" + json, false);
+        HdlLogLogic.print("uni--->缁勮uni鍙戦�佹暟鎹牸寮�--->" + json, false);
     }
 
     /**
@@ -340,7 +351,7 @@
         try {
             HDLUniMPSDKManager.getInstance().sendUniMPEvent(HDLUniMP.UNI_APP_ID, topic, getJSONObject(callBackBaseBean));
         } catch (Exception e) {
-            HdlLogLogic.print("uni===鍘熺敓涓诲姩鍚戝皬绋嬪簭鍙戦�侀�氱煡浜嬩欢===" + e.getMessage(), false);
+            HdlLogLogic.print("uni--->鍘熺敓涓诲姩鍚戝皬绋嬪簭鍙戦�侀�氱煡浜嬩欢--->" + e.getMessage(), false);
         }
     }
 
@@ -512,6 +523,7 @@
             @Override
             public void onSuccess(Boolean b) {
                 if (b) {
+                    HdlLogLogic.print("鏈湴鍗囩骇--->", true);
                     //鏈湴
                     //1,寤虹珛鏈湴鏈嶅姟锛�
                     //2,鍛婅瘔缃戝叧鎵嬫満ip鍜岀鍙o紱
@@ -528,7 +540,7 @@
                             }
                             String md5 = HDLMD5Utils.encodeMD5(data);//缃戝叧鍥轰欢闇�瑕�
                             //鍗囩骇鍥轰欢鏂囦欢鍦板潃
-                            String upgradeFileLocalPathUrl = "http://" + AppManagerUtils.getAppManager().getIPAddress(HDLApp.getInstance()) + ":" + MyNanoHttpServer.HTTP_PORT + firmwarePathFileName;
+                            String upgradeFileLocalPathUrl = "http://" + NetworkUtils.getInstance().getIPAddress(HDLApp.getInstance()) + ":" + MyNanoHttpServer.HTTP_PORT + firmwarePathFileName;
                             //閫氱煡缁欑綉鍏冲崌绾у浐浠舵枃浠跺湴鍧�绛変俊鎭�
                             HdlOtaLogic.getInstance().pushUpgradePacketInfo(deviceMac, oid, module, version, data.length + "", upgradeFileLocalPathUrl, md5, new LinkCallBack<String>() {
                                 @Override
@@ -550,6 +562,7 @@
                         }
                     });
                 } else {
+                    HdlLogLogic.print("鍦ㄧ嚎鍗囩骇--->", true);
                     //杩滅▼鍗囩骇闇�瑕佹娴嬪湪閫嗗彉鍣ㄦ湁娌℃湁杩炴帴涓婁簯
                     HdlDeviceLogic.getInstance().checkInverterConnectedCloud(deviceMac, new CloudCallBeak<CloudInverterDeviceBean>() {
                         @Override
@@ -588,6 +601,7 @@
 
             @Override
             public void onFailure(HDLException e) {
+                HdlLogLogic.print("鍦ㄧ嚎鍗囩骇--->", true);
                 //杩滅▼鍗囩骇闇�瑕佹娴嬪湪閫嗗彉鍣ㄦ湁娌℃湁杩炴帴涓婁簯
                 HdlDeviceLogic.getInstance().checkInverterConnectedCloud(deviceMac, new CloudCallBeak<CloudInverterDeviceBean>() {
                     @Override
@@ -703,6 +717,7 @@
      * 鍚戜簯绔彂璧枫�愯澶囬┍鍔ㄤ笅杞姐�戞寚浠�
      */
     private void uniGatewayDriverDownload(Object data, DCUniMPJSCallback callback) {
+
         String deviceOid = getKeyValue("oid", getKeyValue("data", data));//閫嗗彉鍣ㄨ澶噊id
         String driverCode = getKeyValue("driverCode", getKeyValue("data", data));//椹卞姩缂栫爜
         String imageId = getKeyValue("imageId", getKeyValue("data", data));//椹卞姩闀滃儚id
@@ -763,6 +778,7 @@
             @Override
             public void onSuccess(Boolean b) {
                 if (b) {
+                    HdlLogLogic.print("鏈湴鍗囩骇--->", true);
                     //鏈湴
                     //1,寤虹珛鏈湴鏈嶅姟锛�
                     // 2锛屽憡璇夌綉鍏虫墜鏈篿p鍜岀鍙o紱
@@ -779,7 +795,7 @@
                             }
                             String md5 = HDLMD5Utils.encodeMD5(data);//缃戝叧椹卞姩闇�瑕�
                             //鍗囩骇椹卞姩鏂囦欢鍦板潃
-                            String upgradeFileLocalPathUrl = "http://" + AppManagerUtils.getAppManager().getIPAddress(HDLApp.getInstance()) + ":" + MyNanoHttpServer.HTTP_PORT + drivePathFileName;
+                            String upgradeFileLocalPathUrl = "http://" + NetworkUtils.getInstance().getIPAddress(HDLApp.getInstance()) + ":" + MyNanoHttpServer.HTTP_PORT + drivePathFileName;
                             //閫氱煡缁欑綉鍏冲崌绾ч┍鍔ㄦ枃浠跺湴鍧�绛変俊鎭�
                             HdlOtaLogic.getInstance().pushUpgradePacketInfo(deviceMac, deviceOid, module, version, data.length + "", upgradeFileLocalPathUrl, md5, new LinkCallBack<String>() {
                                 @Override
@@ -801,6 +817,7 @@
                         }
                     });
                 } else {
+                    HdlLogLogic.print("鍦ㄧ嚎鍗囩骇--->", true);
                     //杩滅▼鍗囩骇闇�瑕併�愭娴嬨�戝湪閫嗗彉鍣ㄦ湁娌℃湁杩炴帴涓婁簯
                     HdlDeviceLogic.getInstance().checkInverterConnectedCloud(deviceMac, new CloudCallBeak<CloudInverterDeviceBean>() {
                         @Override
@@ -839,6 +856,7 @@
 
             @Override
             public void onFailure(HDLException e) {
+                HdlLogLogic.print("鍦ㄧ嚎鍗囩骇--->", true);
                 //杩滅▼鍗囩骇闇�瑕併�愭娴嬨�戝湪閫嗗彉鍣ㄦ湁娌℃湁杩炴帴涓婁簯
                 HdlDeviceLogic.getInstance().checkInverterConnectedCloud(deviceMac, new CloudCallBeak<CloudInverterDeviceBean>() {
                     @Override
@@ -976,7 +994,7 @@
      */
     private void uniUploadDataToCloud(Object data, DCUniMPJSCallback callback) {
         String mac = getKeyValue("mac", getKeyValue("data", data));
-        HdlDeviceLogic.getInstance().uploadDataToCloud(mac, null);
+        HdlDeviceLogic.getInstance().uploadDataToCloud(UserConfigManage.getInstance().getHomeId(), mac, null);
     }
 
     /**
@@ -1142,25 +1160,27 @@
      *
      * @param callback uni鍥炶皟
      */
-    private void uniGetCurrentHomeLocalAndCloudGatewayList(DCUniMPJSCallback callback) {
-        HdlDeviceLogic.getInstance().getCurrentHomeLocalAndCloudGatewayList(new CloudCallBeak<List<GatewayBean>>() {
+    private void uniGetCurrentHomeLocalAndCloudGatewayList(Object data, DCUniMPJSCallback callback) {
+        String homeId = getKeyValue("homeId", getKeyValue("data", data));
+        HdlDeviceLogic.getInstance().getCurrentHomeLocalAndCloudGatewayList(homeId, new CloudCallBeak<List<GatewayBean>>() {
             @Override
             public void onSuccess(List<GatewayBean> list) {
+                GatewayBean gatewayBean = HdlDeviceLogic.getInstance().queryCurrentHomeMainGateway(list);
+                if (gatewayBean != null) {
+                    //杩涙潵浣忓畢璇︽儏閮借涓婁紶涓�娆id鍒楄〃鍒颁簯绔�;
+                    HdlDeviceLogic.getInstance().uploadDataToCloud(homeId, gatewayBean.getDevice_mac(), null);
+                }
+                //EventBus浜嬩欢鍒嗗彂,杩涘叆浣忓畢寮�濮嬭闃呬富棰�
+                BaseEventBus baseEventBus = new BaseEventBus();
+                baseEventBus.setType(HDLUniMP.UNI_EVENT_REPLY_DEVICE_LIST);
+                baseEventBus.setData(list);
+
+                EventBus.getDefault().post(baseEventBus);
                 if (callback != null) {
                     uniCallbackData(list, callback);
-                    //EventBus浜嬩欢鍒嗗彂,杩涘叆浣忓畢寮�濮嬭闃呬富棰�
-                    BaseEventBus baseEventBus = new BaseEventBus();
-                    baseEventBus.setType(HDLUniMP.UNI_EVENT_REPLY_DEVICE_LIST);
-                    baseEventBus.setData(list);
-                    EventBus.getDefault().post(baseEventBus);
-                    GatewayBean gatewayBean = HdlDeviceLogic.getInstance().queryCurrentHomeMainGateway(list);
-                    if (gatewayBean != null) {
-                        //杩涙潵浣忓畢璇︽儏閮借涓婁紶涓�娆id鍒楄〃鍒颁簯绔�;
-                        HdlDeviceLogic.getInstance().uploadDataToCloud(gatewayBean.getDevice_mac(), null);
-                    }
-
-
                 }
+
+
             }
 
             @Override
@@ -1288,7 +1308,7 @@
      *
      * @return JSONObject
      */
-    private JSONObject getJSONObject(Object obj) {
+    public JSONObject getJSONObject(Object obj) {
         try {
             if (obj == null) {
                 return new JSONObject();
@@ -1317,7 +1337,7 @@
      * @param obj -
      * @return value
      */
-    private String getKeyValue(String key, Object obj) {
+    public String getKeyValue(String key, Object obj) {
         try {
             JSONObject jsonObject = this.getJSONObject(obj);
             if (jsonObject.has(key)) {

--
Gitblit v1.8.0