From cdcd08459665a89844a14c1d376995ebc501e018 Mon Sep 17 00:00:00 2001
From: mac <user@users-MacBook-Pro.local>
Date: 星期三, 22 五月 2024 16:23:49 +0800
Subject: [PATCH] 2024年05月22日16:23:47

---
 app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseAndDeviceFragment.java |   82 ++++++++++++++++++++++++++++++----------
 1 files changed, 61 insertions(+), 21 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 61965cc..0563f1e 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,5 +1,6 @@
 package com.hdl.photovoltaic.ui.powerstation;
 
+import android.app.job.JobInfo;
 import android.content.Intent;
 import android.content.pm.PackageManager;
 import android.os.Bundle;
@@ -22,6 +23,7 @@
 import com.hdl.photovoltaic.databinding.FragmentHouseListBinding;
 import com.hdl.photovoltaic.base.CustomBaseFragment;
 import com.hdl.photovoltaic.enums.HomepageTitleTabSwitch;
+import com.hdl.photovoltaic.enums.LowerTagType;
 import com.hdl.photovoltaic.enums.PowerStationStatus;
 import com.hdl.photovoltaic.enums.ShowErrorMode;
 import com.hdl.photovoltaic.enums.SortType;
@@ -41,6 +43,7 @@
 import com.hdl.photovoltaic.ui.bean.StatusOverviewBean;
 import com.hdl.photovoltaic.uni.HDLUniMP;
 import com.hdl.photovoltaic.utils.PermissionUtils;
+import com.hdl.photovoltaic.utils.URLEncodingUtils;
 import com.hdl.photovoltaic.widget.DefaultFilteringDialog;
 import com.hdl.photovoltaic.widget.DelayedConfirmationCancelDialog;
 import com.hdl.sdk.link.common.exception.HDLLinkException;
@@ -59,6 +62,8 @@
  * 鐢电珯鍜岃澶�-鐣岄潰
  */
 public class HouseAndDeviceFragment extends CustomBaseFragment {
+
+    private boolean isReadData = false;
     private FragmentHouseListBinding viewBinding;
     private HouseInfoAdapter houseInfoAdapter;
 
@@ -66,8 +71,6 @@
 
     private List<HouseIdBean> houseListBeanIDList;
     private List<DeviceBean> deviceInfoList;
-
-
     private int currentHouseListPage = 0; // 褰撳墠鐢电珯鍒楄〃椤电爜
     private int currentHouseListTotal = 0; // 鐢电珯鍒楄〃鎬婚〉鐮�
     private boolean isHouseLoadingMore = false; // 鏍囪鐢电珯鍒楄〃姝e湪鍔犺浇鏇村鏁版嵁
@@ -96,9 +99,7 @@
 
     @Override
     public void onBindView(Bundle savedInstanceState) {
-        //鏀惧湪杩欓噷涔熷锛岃繖閲屽彧鏄鍒涘缓涓�娆�
-//        loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
-//        getStatusOverview();
+        getStatusOverview();
         initData();
         //鍒濆鍖�
         initView();
@@ -126,6 +127,7 @@
                     viewBinding.deviceNullDataIc.getRoot().setVisibility(View.GONE);
                 }
                 loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
+                getStatusOverview();
             }
         });
         //璁惧鏍囩
@@ -229,6 +231,7 @@
             public void onRefresh() {
                 viewBinding.fragmentHouseSrl.setRefreshing(false);
                 loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
+                getStatusOverview();
             }
         });
         //鐢电珯涓婃媺璇诲彇
@@ -298,10 +301,11 @@
             public void onDelClick(int position, HouseIdBean houseIdBean) {
 
                 DelayedConfirmationCancelDialog delayedConfirmationCancelDialog = new DelayedConfirmationCancelDialog(_mActivity);
-                delayedConfirmationCancelDialog.setTitleContent(getString(R.string.loading_title_tip));
+                delayedConfirmationCancelDialog.show();
+                delayedConfirmationCancelDialog.isHideTitle(true);
                 String homeName = "\"" + houseIdBean.getHomeName() + "\"";
                 delayedConfirmationCancelDialog.setContent(getString(R.string.delete_power_station).replace("%s", homeName));
-                delayedConfirmationCancelDialog.show();
+
                 delayedConfirmationCancelDialog.startCountdown(4);
                 delayedConfirmationCancelDialog.setYesOnclickListener(new DelayedConfirmationCancelDialog.onYesOnclickListener() {
                     @Override
@@ -408,7 +412,22 @@
         deviceInfoAdapter.setOnclickListener(new DeviceInfoAdapter.OnClickListener() {
             @Override
             public void onClick(int position, DeviceBean deviceBean) {
-
+                GatewayBean gatewayBean = new GatewayBean();
+                gatewayBean.setCategorySecondName(deviceBean.getCategorySecondName());
+                gatewayBean.setDevice_mac(deviceBean.getOsn());
+                gatewayBean.setDevice_model(deviceBean.getOmodel());
+                gatewayBean.setOid(deviceBean.getOid());
+                gatewayBean.setGatewayId(deviceBean.getGatewayId());
+                gatewayBean.setAddresses(deviceBean.getAddresses());
+                gatewayBean.setSid(deviceBean.getSid());
+                gatewayBean.setDeviceId(deviceBean.getDeviceId());
+                gatewayBean.setDevice_name(deviceBean.getName());
+                gatewayBean.setDeviceStatus(deviceBean.getDeviceStatus());
+                gatewayBean.setHomeId(deviceBean.getHomeId());
+                gatewayBean.setDeviceType(deviceBean.getDeviceType());
+                String jsonEncryption = URLEncodingUtils.encodeURIComponent(new Gson().toJson(gatewayBean));
+                String path = HDLUniMP.UNI_EVENT_OPEN_DEVICE_DETAILS + "?inverterInfo=" + jsonEncryption;
+                HdlUniLogic.getInstance().openUniMP(path, null);
             }
         });
         //璁惧璁剧疆涓嬫媺绠ご棰滆壊
@@ -579,15 +598,20 @@
         } else if (HDLUniMP.UNI_EVENT_REPLY_HOME_CLOSE_HOME_DETAILS_PAGE.equals(eventBus.getType())) {
             // 鍙栨秷绮樻�т簨浠�
             EventBus.getDefault().removeStickyEvent(eventBus);
-            //uin鍏抽棴浣忓畢璇︽儏鐣岄潰閫氱煡
-            if (MqttRecvClient.getInstance() != null) {
-                MqttRecvClient.getInstance().removeAllTopic();
+            //鏄湪鐢电珯鍒楄〃椤垫墠杩涙潵杩欓噷
+            if (HdlCommonLogic.lowerTagType == LowerTagType.power_station && isClickPowerStationLabel) {
+                //uin鍏抽棴浣忓畢璇︽儏鐣岄潰閫氱煡
+                if (MqttRecvClient.getInstance() != null) {
+                    MqttRecvClient.getInstance().removeAllTopic();
+                }
+                loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
             }
-            loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
-
         } else if (HDLUniMP.UNI_EVENT_REPLY_DEVICE_LIST.equals(eventBus.getType())) {
             // 鍙栨秷绮樻�т簨浠�
             EventBus.getDefault().removeStickyEvent(eventBus);
+//            if (!isClickPowerStationLabel) {
+//                return;
+//            }
             //杩涘幓浣忓畢璇︽儏uni璇诲彇閫嗗彉鍣ㄥ垪琛ㄦ垚鍔熷悗閫氱煡
             for (int i = 0; i < HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(UserConfigManage.getInstance().getHomeId()).size(); i++) {
                 String gatewayId = HdlDeviceLogic.getInstance().getCurrentHomeGatewayList(UserConfigManage.getInstance().getHomeId()).get(i).getGatewayId();
@@ -602,14 +626,29 @@
                 // 鍙栨秷绮樻�т簨浠�
                 EventBus.getDefault().removeStickyEvent(eventBus);
                 HdlLogLogic.print("姝e湪鐐瑰嚮銆愮數绔欍��");
-//                HdlThreadLogic.runSubThread(new Runnable() {
-//                    @Override
-//                    public void run() {
-                loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
-                getStatusOverview();
-//                    }
-//                });
-
+                if (!isReadData) {
+                    //1锛屼粠棣栭〉-鏁呴殰-杩涙潵-鐢电珯锛堜笉璇诲彇锛�
+                    //1锛屼粠鐢电珯-杩涙潵-鐢电珯锛堣鍙栦竴娆�,鍚庨潰杩涙潵涓嶅湪璇诲彇锛�
+                    loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
+                    getStatusOverview();
+                }
+            } else if (eventBus.getType().equals(PowerStationStatus.All)) {
+                viewBinding.powerStationAllIl.parentLl.performClick();
+            } else if (eventBus.getType().equals(PowerStationStatus.malfunction)) {
+                viewBinding.powerStationFaultsIl.parentLl.performClick();
+            } else if (eventBus.getType().equals(PowerStationStatus.off)) {
+                viewBinding.powerStationOfflineIl.parentLl.performClick();
+            } else if (eventBus.getType().equals(PowerStationStatus.connecting)) {
+                viewBinding.powerStationConnectedIl.parentLl.performClick();
+            } else if (eventBus.getType().equals(ConstantManage.station_edit)) {
+                //缂栬緫鍚庢洿鏂颁竴涓嬩綇瀹呭垪琛�
+                //loadNextPageHouseList(false, key, value, installedCapacityMinValue, installedCapacityMaxValue, gridTypeValue, powerStationStatusValue, 1, true);
+//                getStatusOverview();
+                if (houseInfoAdapter != null) {
+                    initData();
+                    //鏇存柊UI
+                    houseInfoAdapter.setList(houseListBeanIDList);
+                }
             }
         }
     }
@@ -656,6 +695,7 @@
      * @param isClear              鏄惁娓呴櫎鏁版嵁
      */
     private void loadNextPageHouseList(boolean isRefreshing, String key, String keyValue, String installedCapacityMin, String installedCapacityMax, String gridType, String powerStationStatus, long pageNo, boolean isClear) {
+        isReadData = true;
         if (isClear) {
             clearData();
         }

--
Gitblit v1.8.0