| | |
| | | import com.hdl.photovoltaic.R; |
| | | import com.hdl.photovoltaic.base.CustomBaseFragment; |
| | | import com.hdl.photovoltaic.config.ConstantManage; |
| | | import com.hdl.photovoltaic.config.UserConfigManage; |
| | | import com.hdl.photovoltaic.databinding.FragmentHomePageBinding; |
| | | import com.hdl.photovoltaic.enums.HomepageTitleTabSwitch; |
| | | import com.hdl.photovoltaic.enums.PowerStationStatus; |
| | | import com.hdl.photovoltaic.enums.TimeType; |
| | | import com.hdl.photovoltaic.enums.UnitType; |
| | | import com.hdl.photovoltaic.listener.CloudCallBeak; |
| | | import com.hdl.photovoltaic.other.HdlDeviceLogic; |
| | | import com.hdl.photovoltaic.other.HdlCommonLogic; |
| | | import com.hdl.photovoltaic.other.HdlLogLogic; |
| | | import com.hdl.photovoltaic.other.HdlPowerStationDataStatisticsLogic; |
| | | import com.hdl.photovoltaic.other.HdlResidenceLogic; |
| | |
| | | AAChartModel aaChartModel; |
| | | |
| | | |
| | | private String[] fieldNames = {"00:00", "02:00", "05:00", "07:00", "09:00", "17:00", "22:00", "23:59"};//图标X轴坐标值的数组 |
| | | private Object[] fieldValues = {35, 70.5, 150.5, 135, 170, 205, 222, 245};//图标Y轴坐标值的数组 |
| | | private String[] fieldNames = {"0", "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23"};//图标X轴坐标值的数组 |
| | | private Object[] fieldValues = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};//图标Y轴坐标值的数组 |
| | | |
| | | |
| | | private String timeType = TimeType.day;//时间类型(默认:天) |
| | |
| | | |
| | | @Override |
| | | public void onBindView(Bundle savedInstanceState) { |
| | | |
| | | //初始化 |
| | | initView(); |
| | | //初始化界面监听器 |
| | |
| | | HdlUniLogic.getInstance().openUniMP(HDLUniMP.UNI_EVENT_OPEN_HOME_CREATION, null); |
| | | } |
| | | }); |
| | | |
| | | //全部 |
| | | viewBinding.homeAllIl.parentLl.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | HdlCommonLogic.getInstance().postEventBus(ConstantManage.station_status, PowerStationStatus.All); |
| | | |
| | | } |
| | | }); |
| | | //故障 |
| | | viewBinding.homeFaultsIl.parentLl.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | HdlCommonLogic.getInstance().postEventBus(ConstantManage.station_status, PowerStationStatus.malfunction); |
| | | } |
| | | }); |
| | | //离线 |
| | | viewBinding.homeOfflineIl.parentLl.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | HdlCommonLogic.getInstance().postEventBus(ConstantManage.station_status, PowerStationStatus.off); |
| | | } |
| | | }); |
| | | //待接入 |
| | | viewBinding.homeConnectedIl.parentLl.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | | public void onClick(View v) { |
| | | HdlCommonLogic.getInstance().postEventBus(ConstantManage.station_status, PowerStationStatus.connecting); |
| | | } |
| | | }); |
| | | //时间选择器 |
| | | viewBinding.yearMonthDayTv.setOnClickListener(new View.OnClickListener() { |
| | | @Override |
| | |
| | | return; |
| | | } |
| | | timeType = TimeType.day; |
| | | |
| | | viewBinding.unitTextTv.setText(getString(R.string.pv_power)); |
| | | viewBinding.dayTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.time_selected_38c494)); |
| | | viewBinding.dayTv.setTextColor(_mActivity.getColor(R.color.text_38C494)); |
| | | |
| | |
| | | viewBinding.v3.setVisibility(View.VISIBLE); |
| | | viewBinding.homePageStationSelectTimeLl.setVisibility(View.VISIBLE); |
| | | |
| | | String dataStr = TimeUtils.getDateTimestamp(getCurrentTimestamp(), getTimeDateFormat()); |
| | | String dataStr = TimeUtils.getDateTimestamp(TimeUtils.getCurrentTimestamp(), TimeUtils.getTimeDateFormat(timeType)); |
| | | viewBinding.yearMonthDayTv.setText(dataStr); |
| | | getStatistics(); |
| | | |
| | |
| | | return; |
| | | } |
| | | timeType = TimeType.month; |
| | | viewBinding.unitTextTv.setText(getString(R.string.generation)); |
| | | viewBinding.dayTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000)); |
| | | viewBinding.dayTv.setTextColor(_mActivity.getColor(R.color.text_66000000)); |
| | | |
| | |
| | | viewBinding.v2.setVisibility(View.GONE); |
| | | viewBinding.v3.setVisibility(View.VISIBLE); |
| | | viewBinding.homePageStationSelectTimeLl.setVisibility(View.VISIBLE); |
| | | String dataStr = TimeUtils.getDateTimestamp(getCurrentTimestamp(), getTimeDateFormat()); |
| | | String dataStr = TimeUtils.getDateTimestamp(TimeUtils.getCurrentTimestamp(), TimeUtils.getTimeDateFormat(timeType)); |
| | | viewBinding.yearMonthDayTv.setText(dataStr); |
| | | getStatistics(); |
| | | |
| | |
| | | return; |
| | | } |
| | | timeType = TimeType.year; |
| | | viewBinding.unitTextTv.setText(getString(R.string.generation)); |
| | | viewBinding.dayTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000)); |
| | | viewBinding.dayTv.setTextColor(_mActivity.getColor(R.color.text_66000000)); |
| | | |
| | |
| | | viewBinding.v2.setVisibility(View.GONE); |
| | | viewBinding.v3.setVisibility(View.GONE); |
| | | viewBinding.homePageStationSelectTimeLl.setVisibility(View.VISIBLE); |
| | | String dataStr = TimeUtils.getDateTimestamp(getCurrentTimestamp(), getTimeDateFormat()); |
| | | String dataStr = TimeUtils.getDateTimestamp(TimeUtils.getCurrentTimestamp(), TimeUtils.getTimeDateFormat(timeType)); |
| | | viewBinding.yearMonthDayTv.setText(dataStr); |
| | | getStatistics(); |
| | | } |
| | |
| | | return; |
| | | } |
| | | timeType = TimeType.all; |
| | | viewBinding.unitTextTv.setText(getString(R.string.generation)); |
| | | viewBinding.dayTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000)); |
| | | viewBinding.dayTv.setTextColor(_mActivity.getColor(R.color.text_66000000)); |
| | | |
| | |
| | | if (TextUtils.isEmpty(currDate)) { |
| | | return; |
| | | } |
| | | String timeDateFormat = getTimeDateFormat(); |
| | | String timeDateFormat = TimeUtils.getTimeDateFormat(timeType); |
| | | Calendar calendar = TimeUtils.stringToCalendar(currDate, timeDateFormat); |
| | | String time = TimeUtils.subtractDayMonthYearFromDate(calendar, 1, timeDateFormat, timeType); |
| | | //不需要限制最小日期,因为是查询账号下所有电站,无法知道最小建站日期 |
| | | viewBinding.yearMonthDayTv.setText(time); |
| | | |
| | | getStatistics(); |
| | | |
| | | } |
| | | }); |
| | |
| | | if (TextUtils.isEmpty(currDate)) { |
| | | return; |
| | | } |
| | | String timeDateFormat = getTimeDateFormat(); |
| | | String timeDateFormat = TimeUtils.getTimeDateFormat(timeType); |
| | | Calendar calendar = TimeUtils.stringToCalendar(currDate, timeDateFormat); |
| | | String time = TimeUtils.addDayMonthYearToDate(calendar, 1, timeDateFormat, timeType); |
| | | if (TimeUtils.stringDateToTimestamp(time, timeDateFormat) > getCurrentTimestamp()) { |
| | | if (TimeUtils.stringDateToTimestamp(time, timeDateFormat) > TimeUtils.getCurrentTimestamp()) { |
| | | HdlThreadLogic.toast(_mActivity, getString(R.string.the_query_date_is_exceeded)); |
| | | |
| | | return; |
| | | } |
| | | viewBinding.yearMonthDayTv.setText(time); |
| | | getStatistics(); |
| | | } |
| | | }); |
| | | //设置下拉箭头颜色 |
| | |
| | | private void selectedTimePickerBuilder() { |
| | | String currDate = viewBinding.yearMonthDayTv.getText().toString(); |
| | | //时间选择器 |
| | | Calendar selectedDate = TimeUtils.stringToCalendar(currDate, getTimeDateFormat()); |
| | | Calendar selectedDate = TimeUtils.stringToCalendar(currDate, TimeUtils.getTimeDateFormat(timeType)); |
| | | Calendar startDate = Calendar.getInstance(); |
| | | Calendar endDate = TimeUtils.timestampToCalendar(getCurrentTimestamp()); |
| | | Calendar endDate = TimeUtils.timestampToCalendar(TimeUtils.getCurrentTimestamp()); |
| | | //设置日期【开始】和【结束】 |
| | | startDate.set(2023, 1, 1); |
| | | endDate.set(endDate.get(Calendar.YEAR), endDate.get(Calendar.MONTH), endDate.get(Calendar.DAY_OF_MONTH)); |
| | |
| | | TimePickerView pvTime = new TimePickerBuilder(_mActivity, new OnTimeSelectListener() { |
| | | @Override |
| | | public void onTimeSelect(Date date, View v) {//选中事件回调 |
| | | String timeDateFormat = getTimeDateFormat(); |
| | | String timeDateFormat = TimeUtils.getTimeDateFormat(timeType); |
| | | String time = TimeUtils.dateToString(date, timeDateFormat); |
| | | if (viewBinding.yearMonthDayTv.getText().toString().equals(time)) { |
| | | //表示同一个时间 |
| | |
| | | aaChartView = viewBinding.autoSizeMyAAChart; |
| | | aaChartView.callBack = this; |
| | | if (TimeType.day.equals(timeType)) { |
| | | aaChartModel = BasicChartComposer.configureAreaChart("Pv发电功率", fieldNames, fieldValues); |
| | | } else if (TimeType.month.equals(timeType) |
| | | || TimeType.year.equals(timeType) |
| | | || TimeType.all.equals(timeType)) { |
| | | aaChartModel = configureColorfulColumnChart("Pv发电功率", fieldNames, fieldValues); |
| | | aaChartModel = BasicChartComposer.configureAreaChart(getString(R.string.pv_power), fieldNames, fieldValues); |
| | | } else if (TimeType.month.equals(timeType) || TimeType.year.equals(timeType) || TimeType.all.equals(timeType)) { |
| | | aaChartModel = configureColorfulColumnChart(getString(R.string.generation), fieldNames, fieldValues); |
| | | } |
| | | aaChartView.aa_drawChartWithChartModel(aaChartModel); |
| | | |
| | |
| | | viewBinding.homeOfflineIl.stationTitleTv.setText(getString(R.string.my_power_station_off_line)); |
| | | viewBinding.homeConnectedIl.stationTitleTv.setText(getString(R.string.to_be_added)); |
| | | |
| | | String dataStr = TimeUtils.getDateTimestamp(getCurrentTimestamp(), getTimeDateFormat()); |
| | | String dataStr = TimeUtils.getDateTimestamp(TimeUtils.getCurrentTimestamp(), TimeUtils.getTimeDateFormat(timeType)); |
| | | viewBinding.yearMonthDayTv.setText(dataStr); |
| | | |
| | | String installed_capacity = getString(R.string.installed_capacity) + "(" + HdlDeviceLogic.kWp + ")"; |
| | | String installed_capacity = getString(R.string.installed_capacity) + "(" + UnitType.kWp + ")"; |
| | | viewBinding.infoRl1Text2Tv.setText(installed_capacity); |
| | | String generated_power = getString(R.string.generated_power) + "(" + HdlDeviceLogic.kW + ")"; |
| | | String generated_power = getString(R.string.generated_power) + "(" + UnitType.kW + ")"; |
| | | viewBinding.infoRl1Text4Tv.setText(generated_power); |
| | | String generation = getString(R.string.generation) + "(" + HdlDeviceLogic.kWh + ")"; |
| | | String generation = getString(R.string.generation) + "(" + UnitType.kWh + ")"; |
| | | viewBinding.homePageStationInfoRl1TitleTv.setText(generation); |
| | | |
| | | viewBinding.homePageStationInfoRl2DayIc.dataTypeTv.setText(R.string.day_power_generation); |
| | |
| | | viewBinding.homePageStationInfoRl2YearIc.dataTypeTv.setText(R.string.year_power_generation); |
| | | viewBinding.homePageStationInfoRl2CumulativeIc.dataTypeTv.setText(R.string.cumulative_power_generation); |
| | | |
| | | viewBinding.unitTv.setText(HdlDeviceLogic.kW); |
| | | viewBinding.unitTv.setText(UnitType.kW); |
| | | viewBinding.dayTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.time_selected_38c494)); |
| | | viewBinding.dayTv.setTextColor(_mActivity.getColor(R.color.text_38C494)); |
| | | viewBinding.monthTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000)); |
| | |
| | | } |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 电站状态概览 |
| | | */ |
| | |
| | | if (statusOverviewBean == null) { |
| | | return; |
| | | } |
| | | viewBinding.homeAllIl.stationTotalTv.setText(statusOverviewBean.getTotal() + ""); |
| | | viewBinding.homeFaultsIl.stationTotalTv.setText(statusOverviewBean.getFault() + ""); |
| | | viewBinding.homeOfflineIl.stationTotalTv.setText(statusOverviewBean.getOffline() + ""); |
| | | viewBinding.homeConnectedIl.stationTotalTv.setText(statusOverviewBean.getConnecting() + ""); |
| | | viewBinding.homeAllIl.stationTotalTv.setText(HdlCommonLogic.convertString(statusOverviewBean.getTotal())); |
| | | viewBinding.homeFaultsIl.stationTotalTv.setText(HdlCommonLogic.convertString(statusOverviewBean.getFault())); |
| | | viewBinding.homeOfflineIl.stationTotalTv.setText(HdlCommonLogic.convertString(statusOverviewBean.getOffline())); |
| | | viewBinding.homeConnectedIl.stationTotalTv.setText(HdlCommonLogic.convertString(statusOverviewBean.getConnecting())); |
| | | } |
| | | |
| | | @Override |
| | |
| | | * 获取统计概览数据(公司维度) |
| | | */ |
| | | private void getDataOver() { |
| | | |
| | | HdlPowerStationDataStatisticsLogic.getInstance().getDataOver(new CloudCallBeak<DataOverBean>() { |
| | | @Override |
| | | public void onSuccess(DataOverBean dataOverBean) { |
| | |
| | | if (dataOverBean == null) { |
| | | return; |
| | | } |
| | | viewBinding.infoRl1Text1Tv.setText(HdlDeviceLogic.getConvertDoubleUnit(dataOverBean.getInstalledCapacity())); |
| | | viewBinding.infoRl1Text3Tv.setText(HdlDeviceLogic.getConvertDoubleUnit(dataOverBean.getPower())); |
| | | viewBinding.infoRl1Text1Tv.setText(HdlCommonLogic.getConvertDoubleUnit(dataOverBean.getInstalledCapacity())); |
| | | viewBinding.infoRl1Text3Tv.setText(HdlCommonLogic.getConvertDoubleUnit(dataOverBean.getPower())); |
| | | viewBinding.infoRl1FText1Tv.setText(dataOverBean.getPowerRatio()); |
| | | |
| | | viewBinding.homePageStationInfoRl2DayIc.dataTv.setText(HdlDeviceLogic.getConvertDoubleUnit(dataOverBean.getTodayElectricity())); |
| | | viewBinding.homePageStationInfoRl2MonIc.dataTv.setText(HdlDeviceLogic.getConvertDoubleUnit(dataOverBean.getMonthElectricity())); |
| | | viewBinding.homePageStationInfoRl2YearIc.dataTv.setText(HdlDeviceLogic.getConvertDoubleUnit(dataOverBean.getYearElectricity())); |
| | | viewBinding.homePageStationInfoRl2CumulativeIc.dataTv.setText(HdlDeviceLogic.getConvertDoubleUnit(dataOverBean.getTotalElectricity())); |
| | | viewBinding.homePageStationInfoRl2DayIc.dataTv.setText(HdlCommonLogic.getConvertDoubleUnit(dataOverBean.getTodayElectricity())); |
| | | viewBinding.homePageStationInfoRl2MonIc.dataTv.setText(HdlCommonLogic.getConvertDoubleUnit(dataOverBean.getMonthElectricity())); |
| | | viewBinding.homePageStationInfoRl2YearIc.dataTv.setText(HdlCommonLogic.getConvertDoubleUnit(dataOverBean.getYearElectricity())); |
| | | viewBinding.homePageStationInfoRl2CumulativeIc.dataTv.setText(HdlCommonLogic.getConvertDoubleUnit(dataOverBean.getTotalElectricity())); |
| | | } |
| | | }); |
| | | } |
| | |
| | | */ |
| | | private void getStatistics() { |
| | | String currDate = viewBinding.yearMonthDayTv.getText().toString(); |
| | | HdlPowerStationDataStatisticsLogic.getInstance().getStatistics(currDate, timeType, new CloudCallBeak<List<StatisticsBean>>() { |
| | | HdlPowerStationDataStatisticsLogic.getInstance().getStatistics(timeType, currDate, new CloudCallBeak<List<StatisticsBean>>() { |
| | | @Override |
| | | public void onSuccess(List<StatisticsBean> list) { |
| | | if (list == null || list.size() == 0) { |
| | | return; |
| | | } |
| | | String[] keys = new String[list.size()]; |
| | | Object[] values = new Object[list.size()]; |
| | | for (int i = 0; i < list.size(); i++) { |
| | | keys[i] = list.get(i).getFieldName(); |
| | | values[i] = list.get(i).getFieldValue(); |
| | | } |
| | | fieldNames = keys; |
| | | fieldValues = values; |
| | | setUpAAChartView(); |
| | | HdlThreadLogic.runMainThread(new Runnable() { |
| | | @Override |
| | | public void run() { |
| | | if (list == null || list.size() == 0) { |
| | | return; |
| | | } |
| | | String[] keys = new String[list.size()]; |
| | | Object[] values = new Object[list.size()]; |
| | | for (int i = 0; i < list.size(); i++) { |
| | | keys[i] = list.get(i).getFieldName(); |
| | | values[i] = HdlCommonLogic.getBigDecimal(list.get(i).getFieldValue()).intValue();//获取整数部分 |
| | | } |
| | | fieldNames = keys; |
| | | fieldValues = values; |
| | | setUpAAChartView(); |
| | | } |
| | | }); |
| | | |
| | | } |
| | | |
| | | @Override |
| | |
| | | if (socialContributionBean == null) { |
| | | return; |
| | | } |
| | | viewBinding.socialContributionData1Tv.setText(socialContributionBean.getCoal()); |
| | | viewBinding.socialContributionData2Tv.setText(socialContributionBean.getCo2()); |
| | | viewBinding.socialContributionData3Tv.setText(socialContributionBean.getTreePlanting()); |
| | | viewBinding.socialContributionData1Tv.setText(HdlCommonLogic.convertString(HdlCommonLogic.getBigDecimal(socialContributionBean.getCoal()))); |
| | | viewBinding.socialContributionData2Tv.setText(HdlCommonLogic.convertString(HdlCommonLogic.getBigDecimal(socialContributionBean.getCo2()))); |
| | | viewBinding.socialContributionData3Tv.setText(HdlCommonLogic.convertString(socialContributionBean.getTreePlanting())); |
| | | } |
| | | |
| | | @Override |
| | |
| | | |
| | | } |
| | | }); |
| | | } |
| | | |
| | | |
| | | /** |
| | | * 获取当前系统日期时间戳 |
| | | * |
| | | * @return 时间戳 |
| | | */ |
| | | private long getCurrentTimestamp() { |
| | | return new Date().getTime(); |
| | | } |
| | | |
| | | /** |
| | | * 获取日期格式 (2024/2/09,yyyy/DD/dd) |
| | | * |
| | | * @return 日期格式 (2024/2/09,yyyy/DD/dd) |
| | | */ |
| | | private String getTimeDateFormat() { |
| | | String timeDateFormat = TimeUtils.zhDateYearMonthDayFormat; |
| | | switch (timeType) { |
| | | case TimeType.day: { |
| | | timeDateFormat = TimeUtils.zhDateYearMonthDayFormat; |
| | | if (!UserConfigManage.getInstance().isZh()) { |
| | | timeDateFormat = TimeUtils.enDateYearMonthDayFormat; |
| | | } |
| | | } |
| | | break; |
| | | case TimeType.month: { |
| | | timeDateFormat = TimeUtils.zhDateYearMonthFormat; |
| | | if (!UserConfigManage.getInstance().isZh()) { |
| | | timeDateFormat = TimeUtils.enDateYearMonthFormat; |
| | | } |
| | | } |
| | | break; |
| | | case TimeType.year: |
| | | case TimeType.all: { |
| | | timeDateFormat = TimeUtils.zhDateYearFormat; |
| | | if (!UserConfigManage.getInstance().isZh()) { |
| | | timeDateFormat = TimeUtils.enDateYearFormat; |
| | | } |
| | | } |
| | | break; |
| | | |
| | | } |
| | | return timeDateFormat; |
| | | } |
| | | |
| | | |