From f10bd384ab2c5e459b9bf20766970615e429b4ec Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期四, 16 十一月 2023 16:53:22 +0800
Subject: [PATCH] 备份一下代码

---
 app/src/main/java/com/hdl/photovoltaic/uni/HDLUniMP.java              |    4 --
 app/src/main/java/com/hdl/photovoltaic/base/BaseActivity.java         |   12 +++++
 app/src/main/java/com/hdl/photovoltaic/ui/MyPowerStationActivity.java |   16 +++++++
 app/src/main/java/com/hdl/photovoltaic/utils/HDLMD5Utils.java         |    2 +
 app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java      |   41 +++++++++++++-------
 5 files changed, 54 insertions(+), 21 deletions(-)

diff --git a/app/src/main/java/com/hdl/photovoltaic/base/BaseActivity.java b/app/src/main/java/com/hdl/photovoltaic/base/BaseActivity.java
index f74016b..6a2b68c 100644
--- a/app/src/main/java/com/hdl/photovoltaic/base/BaseActivity.java
+++ b/app/src/main/java/com/hdl/photovoltaic/base/BaseActivity.java
@@ -1,6 +1,7 @@
 package com.hdl.photovoltaic.base;
 
 import android.app.Activity;
+import android.content.Context;
 import android.content.Intent;
 import android.os.Bundle;
 import android.view.View;
@@ -26,10 +27,11 @@
     private LoadingDialog loadingDialog;
     protected Activity _mActivity;
 
+
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
         super.onCreate(savedInstanceState);
-        LocalManageUtil.changeAppLanguage("en", this);
+
         _mActivity = this;
         Object content = getContentView();
         //娣诲姞Activity鍒板爢鏍�
@@ -47,6 +49,14 @@
 
     }
 
+    @Override
+    protected void attachBaseContext(Context newBase) {
+        super.attachBaseContext(newBase);
+//        //app涓嫳鏂囪缃�
+//        LocalManageUtil.changeAppLanguage("en", newBase);
+
+    }
+
     /**
      * 鑾峰彇LoadingDialog
      *
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 88f735e..27b5ee8 100644
--- a/app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java
+++ b/app/src/main/java/com/hdl/photovoltaic/other/HdlDeviceLogic.java
@@ -90,7 +90,8 @@
                 if (TextUtils.isEmpty(gatewayBean.getDevice_mac())) {
                     continue;
                 }
-                if (gatewayBean.getMaster().equals(GatewayMasterType.MasterTrue) && gatewayBean.getHomeId().equals(UserConfigManage.getInstance().getHomeId())) {
+                //鐢╤omeId绛涢�夊綋鍓嶄綇瀹呯殑閫嗗彉鍣ㄥ垪琛�
+                if (gatewayBean.getHomeId().equals(UserConfigManage.getInstance().getHomeId())) {
                     newList.add(gatewayBean);
                 }
             }
@@ -117,7 +118,6 @@
         }
         return null;
     }
-
 
 
     /**
@@ -564,7 +564,7 @@
 
     /**
      * 鑾峰彇閫嗗彉鍣ㄥ垪琛�
-     * 娉ㄦ剰:鏈夊缃戜互浜戠璁惧涓哄噯;鏈湴瀛樺湪锛屼簯绔病鏈夊垯鍒犻櫎锛涘唴缃戜互鏈湴涓轰富,鎼滅储澶氬皯涓澶囧氨鏄剧ず澶氬皯涓紱
+     * 娉ㄦ剰:鏈夊缃戜互浜戠璁惧涓哄噯,鏈湴瀛樺湪锛屼簯绔病鏈夊垯鍒犻櫎锛涘唴缃戜互鏈湴涓轰富,鎼滅储澶氬皯涓澶囧氨鏄剧ず澶氬皯涓紱
      *
      * @param cloudCallBeak 杩斿洖閫嗗彉鍣ㄥ垪琛�
      */
@@ -572,13 +572,13 @@
         HdlDeviceLogic.getInstance().searchGateway(new GatewayCallBack() {
             @Override
             public void onSuccess(List<GatewayBean> gatewayBeanList) {
-                //灞�鍩熺綉鎯呭喌
+                //灞�鍩熺綉鏈�2绉嶆儏鍐�(1:鏈夊眬鍩熺綉锛屾湁澶栫綉锛�2:鏈夊眬鍩熺綉锛屾病鏈夊缃�);
                 HdlDeviceLogic.getInstance().getCloudInverterDeviceList(UserConfigManage.getInstance().getHomeId(), new CloudCallBeak<List<CloudInverterDeviceBean>>() {
                     @Override
                     public void onSuccess(List<CloudInverterDeviceBean> list) {
+                        ///鎯呭喌1:鏈夊眬鍩熺綉锛屾湁澶栫綉锛�
                         if (list == null || list.size() == 0) {
-//                            //浜戠娌℃湁缁戝畾閫嗗彉鍣�,浠ユ湰鍦颁负涓�;
-//                            HDLLinkLocalGateway.getInstance().getGatewayList().clear();
+                            //浜戠娌℃湁缁戝畾閫嗗彉鍣�,榛樿杩斿洖鏈湴閫嗗彉鍣ㄥ垪琛�;
                             if (cloudCallBeak != null) {
                                 cloudCallBeak.onSuccess(getCurrentHomeGatewayList());
                             }
@@ -588,11 +588,14 @@
                         AtomicInteger atomicInteger = new AtomicInteger(0);
                         for (int i = 0; i < list.size(); i++) {
                             CloudInverterDeviceBean cloudInverterDeviceBean = list.get(i);
+                            //鑾峰彇杩滅▼璁惧閫氳淇℃伅(鎷垮埌缃戝叧ID锛宮qtt閫氳绉橀挜)
                             getDeviceRemoteInfo(UserConfigManage.getInstance().getHomeId(), cloudInverterDeviceBean.getSpk(), cloudInverterDeviceBean.getOsn(), new CloudCallBeak<DeviceRemoteInfo>() {
                                 @Override
                                 public void onSuccess(DeviceRemoteInfo deviceRemoteInfo) {
                                     atomicInteger.set(atomicInteger.get() + 1);
+                                    //鏇存柊閫嗗彉鍣ㄦ湰鍦扮紦瀛樹俊鎭�
                                     refreshGatewayCacheData(true, cloudInverterDeviceBean, deviceRemoteInfo);
+                                    //鏈�鍚庝竴鏉℃墠鍋氬垹闄ら�嗗彉鍣ㄩ�昏緫澶勭悊
                                     if (atomicInteger.get() == list.size()) {
                                         //鏀堕泦鍒犻櫎閫嗗彉鍣╯id
                                         List<String> removeSidList = new ArrayList<>();
@@ -620,7 +623,7 @@
                                 @Override
                                 public void onFailure(HDLException e) {
                                     atomicInteger.set(atomicInteger.get() + 1);
-                                    //鏈夊彲鑳芥渶鍚庝竴鏉℃槸澶辫触鐨�
+                                    //褰撴渶鍚庝竴鏉¤姹傚け璐ヤ簡锛屾墠鍦ㄨ繖閲屽仛鍒犻櫎閫嗗彉鍣ㄩ�昏緫澶勭悊
                                     if (atomicInteger.get() == list.size()) {
                                         //鏀堕泦鍒犻櫎閫嗗彉鍣╯id
                                         List<String> removeSidList = new ArrayList<>();
@@ -653,8 +656,10 @@
 
                     @Override
                     public void onFailure(HDLException e) {
+                        ///鎯呭喌2:鏈夊眬鍩熺綉锛屾病鏈夊缃�;
+                        //鏈湴鏈夐�嗗彉鍣ㄥ垪琛�,鑾峰彇浜戠缁戝畾閫嗗彉鍣ㄥけ璐�,榛樿杩斿洖鏈湴閫嗗彉鍣ㄥ垪琛�;
                         if (cloudCallBeak != null) {
-                            cloudCallBeak.onFailure(e);
+                            cloudCallBeak.onSuccess(getCurrentHomeGatewayList());
                         }
                     }
                 });
@@ -662,27 +667,32 @@
 
             @Override
             public void onError(HDLLinkException e) {
-                //澶栫綉鎯呭喌
+                //澶栫綉鍙湁1鎯呭喌(鏈湴鎼滅储閫嗗彉鍣ㄥ垪琛ㄥけ璐ヤ簡)
                 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(getCurrentHomeGatewayList());
+                                //浜戠涔熸病鏈夐�嗗彉鍣ㄥ垪琛�,杩斿洖绌哄垪琛ㄥ洖鍘�
+                                cloudCallBeak.onSuccess(new ArrayList<>());
                             }
                             return;
                         }
                         //璁板綍鏉℃暟
                         AtomicInteger atomicInteger = new AtomicInteger(0);
+
                         for (int i = 0; i < list.size(); i++) {
                             CloudInverterDeviceBean cloudInverterDeviceBean = list.get(i);
+                            //鑾峰彇杩滅▼璁惧閫氳淇℃伅(鎷垮埌缃戝叧ID锛宮qtt閫氳绉橀挜)
                             getDeviceRemoteInfo(UserConfigManage.getInstance().getHomeId(), cloudInverterDeviceBean.getSpk(), cloudInverterDeviceBean.getOsn(), new CloudCallBeak<DeviceRemoteInfo>() {
                                 @Override
                                 public void onSuccess(DeviceRemoteInfo deviceRemoteInfo) {
                                     atomicInteger.set(atomicInteger.get() + 1);
+                                    //鏇存柊閫嗗彉鍣ㄦ湰鍦扮紦瀛樹俊鎭�
                                     refreshGatewayCacheData(false, cloudInverterDeviceBean, deviceRemoteInfo);
+                                    //鍒版渶鍚庝竴鏉★紝鎵嶆湁鍥炶皟
                                     if (atomicInteger.get() == list.size()) {
                                         if (cloudCallBeak != null) {
                                             cloudCallBeak.onSuccess(getCurrentHomeGatewayList());
@@ -693,6 +703,7 @@
                                 @Override
                                 public void onFailure(HDLException e) {
                                     atomicInteger.set(atomicInteger.get() + 1);
+                                    //褰撴渶鍚庝竴鏉¤姹傚け璐ヤ簡锛屾墠鏈夊洖璋�
                                     if (atomicInteger.get() == list.size()) {
                                         if (cloudCallBeak != null) {
                                             cloudCallBeak.onSuccess(getCurrentHomeGatewayList());
@@ -817,8 +828,8 @@
     /**
      * 鍒锋柊閫嗗彉鍣ㄧ紦瀛樹俊鎭�(鍖呮嫭璁剧疆mqtt绉橀挜锛�
      * 娉�:
-     * 1:鏈湴瀛樺湪鏇存柊淇℃伅鍗冲彲;
-     * 2:浜戠鏈夋湰鍦颁笉瀛樺湪,鍒欒櫄鎷熶竴涓�嗗彉鍣ㄥ璞℃坊鍔犲湪鏈湴;
+     * 1:鏈湴瀛樺湪,鏇存柊淇℃伅鍗冲彲;
+     * 2:鏈湴涓嶅瓨鍦�,鍒欒櫄鎷熶竴涓�嗗彉鍣ㄥ璞℃坊鍔犲湪鏈湴;
      *
      * @param deviceRemoteInfo        璁惧杩滅▼閫氳淇℃伅
      * @param cloudInverterDeviceBean 閫嗗彉鍣�
@@ -849,7 +860,7 @@
         gatewayBean.setDevice_name(cloudInverterDeviceBean.getName());//璁惧鍚嶇О
         gatewayBean.setGatewayType(cloudInverterDeviceBean.getSpk());//璁剧疆spk
         gatewayBean.setLocalEncrypt(true);
-        gatewayBean.setMaster(GatewayMasterType.MasterTrue);
+        gatewayBean.setMaster(GatewayMasterType.MasterTrue);//榛樿閮芥槸涓婚�嗗彉鍣�(浠ュ悗鏀寔浠庨�嗗彉鍣ㄨ鏇存敼)
         gatewayBean.setSystemStatusDesc(cloudInverterDeviceBean.getSystemStatusDesc());//璁惧鐘舵��
         gatewayBean.setHwVersion(cloudInverterDeviceBean.getHwVersion());//杞欢鐗堟湰鍙�
         gatewayBean.setCategorySecondName(cloudInverterDeviceBean.getCategorySecondName());//璁惧绫诲瀷(浜у搧浜岀骇鍒嗙被鍚嶇О
@@ -864,7 +875,7 @@
 
 
     /**
-     * 鑾峰彇缃戝叧spk鍒楄〃
+     * 鑾峰彇缃戝叧鏀寔spk鍒楄〃
      *
      * @return -
      */
diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/MyPowerStationActivity.java b/app/src/main/java/com/hdl/photovoltaic/ui/MyPowerStationActivity.java
index 4885c41..7e204c2 100644
--- a/app/src/main/java/com/hdl/photovoltaic/ui/MyPowerStationActivity.java
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/MyPowerStationActivity.java
@@ -30,9 +30,9 @@
 import com.hdl.photovoltaic.utils.PermissionUtils;
 import com.hdl.sdk.link.HDLLinkLocalSdk;
 import com.hdl.sdk.link.common.event.EventListener;
+import com.hdl.sdk.link.core.bean.LinkResponse;
 import com.hdl.sdk.link.core.bean.ModbusResponse;
 import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus;
-import com.hdl.sdk.link.core.bean.eventbus.EventNotifyRefreshGatewayAesKeyInfo;
 import com.hdl.sdk.link.core.bean.gateway.GatewayBean;
 import com.hdl.sdk.link.core.config.HDLLinkConfig;
 import com.hdl.sdk.link.core.utils.mqtt.MqttRecvClient;
@@ -206,6 +206,9 @@
             @Override
             public void onMessage(Object msg) {
 
+                if (msg == null) {
+                    return;
+                }
                 if (msg instanceof ModbusResponse) {
                     ModbusResponse response = (ModbusResponse) msg;
                     if (response.getTopic() == null) {
@@ -219,6 +222,17 @@
                     HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_NOTIFICATION_DEVICE_MODEL, uniCallBackBaseBean);
 //                    }
 
+                } else if (msg instanceof LinkResponse) {
+                    LinkResponse linkResponse = (LinkResponse) msg;
+                    if (linkResponse.getTopic() == null) {
+                        return;
+                    }
+                    if (linkResponse.getTopic().endsWith("/ota/device/progress/up")) {
+                        HDLUniMP.UniCallBackBaseBean uniCallBackBaseBean = new HDLUniMP.UniCallBackBaseBean();
+                        uniCallBackBaseBean.setType(linkResponse.getTopic());
+                        uniCallBackBaseBean.setData(linkResponse.getData());
+                        HdlUniLogic.getInstance().sendUni(HDLUniMP.UNI_EVENT_REPLY_OTA_MODEL, uniCallBackBaseBean);
+                    }
                 }
             }
         };
diff --git a/app/src/main/java/com/hdl/photovoltaic/uni/HDLUniMP.java b/app/src/main/java/com/hdl/photovoltaic/uni/HDLUniMP.java
index c6adc55..1157256 100644
--- a/app/src/main/java/com/hdl/photovoltaic/uni/HDLUniMP.java
+++ b/app/src/main/java/com/hdl/photovoltaic/uni/HDLUniMP.java
@@ -1,10 +1,6 @@
 package com.hdl.photovoltaic.uni;
 
 
-import com.google.gson.Gson;
-
-import org.json.JSONObject;
-
 import java.io.Serializable;
 
 /**
diff --git a/app/src/main/java/com/hdl/photovoltaic/utils/HDLMD5Utils.java b/app/src/main/java/com/hdl/photovoltaic/utils/HDLMD5Utils.java
index 84ffec6..c51dfcf 100644
--- a/app/src/main/java/com/hdl/photovoltaic/utils/HDLMD5Utils.java
+++ b/app/src/main/java/com/hdl/photovoltaic/utils/HDLMD5Utils.java
@@ -107,6 +107,8 @@
     }
 
 
+
+
     public final static String md5(String plainText) {
 
 // 杩斿洖瀛楃涓�

--
Gitblit v1.8.0