wjc
2025-04-30 f91ef956cf482ed4ce0885dc47794b783c20c415
app/src/main/java/com/hdl/photovoltaic/ui/powerstation/HouseAndDeviceFragment.java
@@ -1,15 +1,20 @@
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.text.TextUtils;
import android.util.Log;
import android.view.View;
import android.view.Window;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
@@ -44,6 +49,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 +61,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 +261,6 @@
                        installedCapacityMinValue = min;//最小组串容量(装机容量)
                        installedCapacityMaxValue = max;//最大组串容量(装机容量)
                        screeningConditionStatus = state;//调试状态(全部;调试中;调试完成;已交付;授权调试)
                        getStatusOverview();
                        loadNextPageHouseList(true, key, value, installedCapacityMinValue, installedCapacityMaxValue, screeningConditionStatus, powerStationStatusValue, 1, true);
                    }
                });
@@ -357,7 +363,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 +378,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 +413,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 +458,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())) {
                            //这里只支持远程调试,远程拿不到mqtt通讯秘钥以及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);
@@ -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())) {
@@ -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);
            }
@@ -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();
            }