From 4f12f1e3543fce41e71ae9e21a782f8d9cb41947 Mon Sep 17 00:00:00 2001
From: wjc <1243177876@qq.com>
Date: 星期一, 07 七月 2025 10:45:11 +0800
Subject: [PATCH] Merge branch '1.3.1' into dev

---
 app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseAndDeviceFragment.java |   84 ++++++++++++++++++++++++++++-------------
 1 files changed, 57 insertions(+), 27 deletions(-)

diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseAndDeviceFragment.java b/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseAndDeviceFragment.java
index a78d845..4156922 100644
--- a/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseAndDeviceFragment.java
+++ b/app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseAndDeviceFragment.java
@@ -1,15 +1,19 @@
 package com.hdl.photovoltaic.ui.powerstation;
 
 import android.Manifest;
+import android.app.Dialog;
 import android.content.Context;
+import android.content.DialogInterface;
 import android.content.Intent;
 import android.content.pm.PackageManager;
 import android.location.LocationManager;
 import android.os.AsyncTask;
 import android.os.Bundle;
+import android.os.SystemClock;
 import android.provider.Settings;
-import android.util.Log;
+import android.text.TextUtils;
 import android.view.View;
+import android.view.Window;
 import android.widget.ImageView;
 import android.widget.LinearLayout;
 import android.widget.RelativeLayout;
@@ -18,8 +22,6 @@
 import androidx.annotation.NonNull;
 import androidx.appcompat.content.res.AppCompatResources;
 import androidx.recyclerview.widget.LinearLayoutManager;
-import androidx.recyclerview.widget.RecyclerView;
-import androidx.swiperefreshlayout.widget.SwipeRefreshLayout;
 
 import com.google.gson.Gson;
 import com.hdl.linkpm.sdk.core.exception.HDLException;
@@ -44,6 +46,7 @@
 import com.hdl.photovoltaic.other.HdlDeviceLogic;
 import com.hdl.photovoltaic.other.HdlDialogLogic;
 import com.hdl.photovoltaic.other.HdlLogLogic;
+import com.hdl.photovoltaic.other.HdlOtaLogic;
 import com.hdl.photovoltaic.other.HdlResidenceLogic;
 import com.hdl.photovoltaic.other.HdlThreadLogic;
 import com.hdl.photovoltaic.other.HdlUniLogic;
@@ -55,6 +58,7 @@
 import com.hdl.photovoltaic.uni.HDLUniMP;
 import com.hdl.photovoltaic.utils.GPSManagerUtils;
 import com.hdl.photovoltaic.utils.PermissionUtils;
+import com.hdl.photovoltaic.utils.ProcessManagerUtils;
 import com.hdl.photovoltaic.utils.URLEncodingUtils;
 import com.hdl.photovoltaic.widget.ConfirmationCancelDialog;
 import com.hdl.photovoltaic.widget.DefaultFilteringDialog;
@@ -254,7 +258,6 @@
                         installedCapacityMinValue = min;//鏈�灏忕粍涓插閲�(瑁呮満瀹归噺)
                         installedCapacityMaxValue = max;//鏈�澶х粍涓插閲�(瑁呮満瀹归噺)
                         screeningConditionStatus = state;//璋冭瘯鐘舵��(鍏ㄩ儴;璋冭瘯涓�;璋冭瘯瀹屾垚;宸蹭氦浠�;鎺堟潈璋冭瘯)
-                        getStatusOverview();
                         loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
                     }
                 });
@@ -357,7 +360,14 @@
 
             }
         });
-        //PV绛涢��
+//        //鐢电珯缂栬緫鎸夐挳
+//        viewBinding.editIv.setOnClickListener(new View.OnClickListener() {
+//            @Override
+//            public void onClick(View v) {
+//                startActivity(HouseListEditActivity.class);
+//            }
+//        });
+        //鐢电珯鍚嶇О绛涢��
         viewBinding.stationNameRl.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
@@ -365,11 +375,10 @@
                 screeningConditionStyle(viewBinding.stationNameRl, viewBinding.stationNameIv, isSelected);
                 key = SortType.installedCapacitySort;
                 value = isSelected ? SortValue.ascending : SortValue.descending;
-                getStatusOverview();
                 loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
             }
         });
-        //棰濆畾鍔熺巼绛涢��
+        //鐢电珯鍙戠數鍔熺巼绛涢��
         viewBinding.stationPowerRl.setOnClickListener(new View.OnClickListener() {
             @Override
             public void onClick(View v) {
@@ -401,7 +410,17 @@
                 screeningConditionStyle(viewBinding.stationDayRl, viewBinding.stationDayIv, isSelected);
                 key = SortType.todayElectricitySort;
                 value = isSelected ? SortValue.ascending : SortValue.descending;
-                getStatusOverview();
+                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
+            }
+        });
+        //鐢电珯鐢垫睜瀹归噺绛涢��
+        viewBinding.stationMonthRl.setOnClickListener(new View.OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                boolean isSelected = !v.isSelected();
+                screenIconState(viewBinding.stationMonthRl, viewBinding.stationMonthIv, isSelected);
+                key = SortType.batteryCapacitySort;
+                value = isSelected ? SortValue.ascending : SortValue.descending;
                 loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
             }
         });
@@ -436,7 +455,17 @@
                 HdlDeviceLogic.getInstance().setDeviceRemoteInfo(newList, deviceBean.getHomeId(), new CloudCallBeak<List<GatewayBean>>() {
                     @Override
                     public void onSuccess(List<GatewayBean> obj) {
+
                         GatewayBean newGatewayBean = HDLLinkLocalGateway.getInstance().getLocalGateway(deviceBean.getOsn());
+                        if (newGatewayBean == null) {
+                            HdlThreadLogic.toast(_mActivity, getString(R.string.device_off));
+                            return;
+                        }
+                        if (TextUtils.isEmpty(newGatewayBean.getGatewayId()) || TextUtils.isEmpty(newGatewayBean.getAesKey())) {
+                            //杩欓噷鍙敮鎸佽繙绋嬭皟璇曪紝杩滅▼鎷夸笉鍒癿qtt閫氳绉橀挜浠ュ強gatewayId锛�
+                            HdlThreadLogic.toast(_mActivity, getString(R.string.device_failed_to_certificate) + "(124004)");
+                            return;
+                        }
                         String jsonEncryption = URLEncodingUtils.encodeURIComponent(new Gson().toJson(newGatewayBean));
                         String path = HDLUniMP.UNI_EVENT_OPEN_DEVICE_DETAILS + "?inverterInfo=" + jsonEncryption;
                         HdlUniLogic.getInstance().openUniMP(path, null);
@@ -581,15 +610,18 @@
             if (HDLUniMP.UNI_EVENT_REPLY_HOME_CREATION.equals(eventBus.getType())) {
                 // 鍙栨秷绮樻�т簨浠�
                 EventBus.getDefault().removeStickyEvent(eventBus);
-                //uin鍒涘缓鐢电珯鎴愬姛鍚庨�氱煡
-                loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
-                if (eventBus.getData() != null) {
-                    Gson gson = new Gson();
-                    String json = eventBus.getData().toString();
-                    HouseIdBean houseIdBean = gson.fromJson(json, HouseIdBean.class);
-                    HdlResidenceLogic.getInstance().switchHouse(houseIdBean, true);
-
-                }
+//                HdlLogLogic.print("杩涙潵浜�---11111" + eventBus.getData().toString());
+//                //uin鍒涘缓鐢电珯鎴愬姛鍚庨�氱煡
+//                loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
+//                if (eventBus.getData() != null) {
+//                    HdlLogLogic.print("杩涙潵浜�---" + eventBus.getData().toString());
+//                    Gson gson = new Gson();
+//                    String json = eventBus.getData().toString();
+//                    HouseIdBean houseIdBean = gson.fromJson(json, HouseIdBean.class);
+//                    HdlResidenceLogic.getInstance().switchHouse(houseIdBean, true);
+//                    HdlLogLogic.print("杩涙潵浜�---缁撴潫" + eventBus.getData().toString());
+//
+//                }
             } else if (HDLUniMP.UNI_EVENT_REPLY_HOME_EDIT.equals(eventBus.getType())) {
                 // 鍙栨秷绮樻�т簨浠�
                 EventBus.getDefault().removeStickyEvent(eventBus);
@@ -626,7 +658,6 @@
 //                if (MqttRecvClient.getInstance() != null) {
 //                    MqttRecvClient.getInstance().removeAllTopic();
 //                }
-
                 loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
             }
         } else if (HDLUniMP.UNI_EVENT_REPLY_DEVICE_LIST.equals(eventBus.getType())) {
@@ -641,8 +672,8 @@
             }
             String homeId = eventBus.getData().toString();
             //杩涘幓浣忓畢璇︽儏uni璇诲彇閫嗗彉鍣ㄥ垪琛ㄦ垚鍔熷悗閫氱煡
-            for (int i = 0; i < HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(homeId, null).size(); i++) {
-                String gatewayId = HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(homeId, null).get(i).getGatewayId();
+            for (int i = 0; i < HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(homeId).size(); i++) {
+                String gatewayId = HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(homeId).get(i).getGatewayId();
                 //瀛楃涓叉槸鑷繁鎸夎鍒欐嫾鎺ョ殑,閲岄潰娉ㄥ唽涓婚鏃朵細瑙f瀽瀛楃涓�,鍙嬁getGatewayId()鍊�;
                 String topic = "/user/" + gatewayId + "/#";
                 //杩涘幓浣忓畢璇︽儏寮�濮嬭闃呬富棰�
@@ -800,7 +831,7 @@
                         if (isRefreshing) {
                             hideLoading();
                         }
-                        HdlThreadLogic.toast(_mActivity, e.getMsg() + "(" + e.getCode() + ")");
+
                     }
                 }, _mActivity, ShowErrorMode.YES);
             }
@@ -869,7 +900,6 @@
                         if (isRefreshing) {
                             hideLoading();
                         }
-                        HdlThreadLogic.toast(_mActivity, e.getMsg() + "(" + e.getCode() + ")");
                     }
                 }, _mActivity, ShowErrorMode.YES);
             }
@@ -958,7 +988,7 @@
             @Override
             public void onSuccess(Boolean obj) {
                 hideLoading();
-                initializeInverter(list); //鍙戣捣鍒濆鍖栨寚浠ょ粰閫嗗彉鍣�;锛堟敞鎰�:鍙兘鏄湰鍦板彂閫佷簡(瑕佹悳绱㈠眬鍩熺綉閫嗗彉鍣ㄥ垪琛紝寤虹珛鏈湴閫氳閫氶亾),鍒犻櫎鐢电珯鎴愬姛鍚�,浜戠瑙g粦閫嗗彉鍣ㄧ殑鍏崇郴锛�
+                initializeInverter(list); //鍙戣捣鍒濆鍖栨寚浠ょ粰閫嗗彉鍣�;锛堟敞鎰�:鍓嶉潰宸插厛瑙g粦浜戠閫嗗彉鍣紝mqtt閫氶亾宸叉柇寮�锛屽垵濮嬪寲鍙兘鏄湰鍦板彂閫�(鍏堟悳绱㈠眬鍩熺綉閫嗗彉鍣ㄥ垪琛紝寤虹珛鏈湴閫氳閫氶亾)锛�
                 HdlResidenceLogic.getInstance().delHouseId(homeId);//鍒犻櫎鐢电珯缂撳瓨
                 initData();//鍒濆鍖栫紦瀛樻暟鎹�
                 houseInfoAdapter.setList(houseListBeanIDList, powerStationStatusValue);//閲嶆柊鍒锋柊鍒楄〃
@@ -1002,8 +1032,8 @@
 
     public void requestPermissions(OnCallBeak onCallBeak) {
 
-        //ACCESS_FINE_LOCATION	鍏佽浣跨敤GPS瀹氫綅
-        //ACCESS_COARSE_LOCATION	鍏佽浣跨敤WIFI鐑偣鎴栧熀绔欐潵鑾峰彇绮楃暐鐨勫畾浣�
+        //ACCESS_FINE_LOCATION    鍏佽浣跨敤GPS瀹氫綅
+        //ACCESS_COARSE_LOCATION    鍏佽浣跨敤WIFI鐑偣鎴栧熀绔欐潵鑾峰彇绮楃暐鐨勫畾浣�
         String[] ary = PermissionUtils.checkPermission(_mActivity, new String[]{Manifest.permission.ACCESS_FINE_LOCATION, Manifest.permission.ACCESS_COARSE_LOCATION});
         if (ary.length > 0) {
             this.requestPermissions(ary, PermissionUtils.STATUS_SUCCESS);
@@ -1079,7 +1109,7 @@
                         // 鎵ц浠诲姟锛堝鏇存柊UI銆佽烦杞瓑锛�
                         viewBinding.fragmentHouseSrl.endRefreshing();
                         //鍔犺浇鏈�鏂版暟鎹畬鎴�
-                        loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
+                        loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
                         getStatusOverview();
                     }
                 }.execute();
@@ -1142,7 +1172,7 @@
                     @Override
                     protected void onPostExecute(Void aVoid) {
                         viewBinding.fragmentDeviceSrl.endRefreshing();
-                        loadNextPageDeviceList(true, 1, true);
+                        loadNextPageDeviceList(false, 1, true);
                     }
                 }.execute();
             }

--
Gitblit v1.8.0