From 1a0aaa0bd03b3a491c751b5ce1bfca16302767b1 Mon Sep 17 00:00:00 2001 From: mac <user@users-MacBook-Pro.local> Date: 星期三, 19 六月 2024 19:30:12 +0800 Subject: [PATCH] 2024年06月19日19:30:03 --- app/src/main/java/com/hdl/photovoltaic/ui/home/HomePageFragment.java | 722 +++++++++++++++++++++++++++++++++++++++---------------- 1 files changed, 512 insertions(+), 210 deletions(-) diff --git a/app/src/main/java/com/hdl/photovoltaic/ui/home/HomePageFragment.java b/app/src/main/java/com/hdl/photovoltaic/ui/home/HomePageFragment.java index 691f49c..ebc8306 100644 --- a/app/src/main/java/com/hdl/photovoltaic/ui/home/HomePageFragment.java +++ b/app/src/main/java/com/hdl/photovoltaic/ui/home/HomePageFragment.java @@ -1,73 +1,57 @@ package com.hdl.photovoltaic.ui.home; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.adjustYAxisMaxAndMinValues; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureAreaChartThreshold; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureChartWithShadowStyle; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureColorfulChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureColorfulColumnChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureColorfulDataLabelsStepLineChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureColorfulGradientAreaChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureColorfulGradientColorAndColorfulDataLabelsStepAreaChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureColorfulGradientColorChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureColorfulGradientSplineChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureColorfulShadowSplineChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureDiscontinuousDataChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureGradientColorAreasplineChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureHexagonRadarChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureMaxAndMinDataLabelsForChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureMultiLevelStopsArrGradientColorAreasplineMixedLineChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureNightingaleRoseChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configurePentagonRadarChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureQuadrangleRadarChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureSpecialStyleColumnForNegativeDataMixedPositiveData; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureSpecialStyleColumnOfSingleDataElementChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureSpecialStyleMarkerOfSingleDataElementChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.configureTriangleRadarChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.connectNullsForSingleAASeriesElement; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.customAreasplineChartWithColorfulGradientColorZones; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.customBarChartHoverColorAndSelectColor; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.customChartHoverAndSelectHaloStyle; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.customColumnChartBorderStyleAndStatesHoverColor; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.customLineChartMarkerSymbolContent; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.customLineChartWithColorfulMarkersAndLines; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.customLineChartWithColorfulMarkersAndLines2; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.customNormalStackingChartDataLabelsContentAndStyle; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.customScatterChartMarkerSymbolContent; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.customSpecialStyleDataLabelOfSingleDataElementChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.customSplineChartMarkerStatesHoverStyle; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.customVerticalXAxisCategoriesLabelsByHTMLBreakLineTag; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.disableSomeOfLinesMouseTrackingEffect; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.disableSplineChartMarkerHoverEffect; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.doubleLayerPieChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.drawLineChartWithPointsCoordinates; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.freeStyleRoundedCornersStackingColumnChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.largeDataStackingColumnChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.lineChartsWithLargeDifferencesInTheNumberOfDataInDifferentSeriesElement; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.noMoreGroupingAndNestedColumnChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.noMoreGroupingAndOverlapEachOtherColumnChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.splineChartHoverLineWithNoChangeAndCustomMarkerStatesHoverStyle; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.topRoundedCornersStackingColumnChart; -import static com.hdl.photovoltaic.ui.home.CustomStyleChartComposer.upsideDownPyramidChart; +import static com.hdl.photovoltaic.ui.home.aachart.CustomStyleChartComposer.configureColorfulColumnChart; -import android.content.Intent; import android.os.Bundle; +import android.os.SystemClock; +import android.text.TextUtils; import android.view.View; + +import androidx.appcompat.content.res.AppCompatResources; +import androidx.swiperefreshlayout.widget.SwipeRefreshLayout; + +import com.bigkoo.pickerview.builder.TimePickerBuilder; +import com.bigkoo.pickerview.listener.OnTimeSelectListener; +import com.bigkoo.pickerview.view.TimePickerView; import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartModel; import com.github.AAChartModel.AAChartCore.AAChartCreator.AAChartView; import com.github.AAChartModel.AAChartCore.AAChartCreator.AAMoveOverEventMessageModel; -import com.github.AAChartModel.AAChartCore.AAChartEnum.AAChartType; +import com.hdl.linkpm.sdk.core.exception.HDLException; +import com.hdl.photovoltaic.R; import com.hdl.photovoltaic.base.CustomBaseFragment; import com.hdl.photovoltaic.config.ConstantManage; 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.HdlCommonLogic; +import com.hdl.photovoltaic.other.HdlDeviceLogic; import com.hdl.photovoltaic.other.HdlLogLogic; +import com.hdl.photovoltaic.other.HdlPowerStationDataStatisticsLogic; +import com.hdl.photovoltaic.other.HdlResidenceLogic; +import com.hdl.photovoltaic.other.HdlThreadLogic; +import com.hdl.photovoltaic.other.HdlUniLogic; +import com.hdl.photovoltaic.ui.bean.DataOverBean; +import com.hdl.photovoltaic.ui.bean.SocialContributionBean; +import com.hdl.photovoltaic.ui.bean.StatisticsBean; +import com.hdl.photovoltaic.ui.bean.StatusOverviewBean; +import com.hdl.photovoltaic.ui.home.aachart.BasicChartComposer; +import com.hdl.photovoltaic.uni.HDLUniMP; +import com.hdl.photovoltaic.utils.TimeUtils; import com.hdl.sdk.link.core.bean.eventbus.BaseEventBus; import org.greenrobot.eventbus.EventBus; import org.greenrobot.eventbus.Subscribe; import org.greenrobot.eventbus.ThreadMode; + +import java.util.Calendar; +import java.util.Date; +import java.util.List; + /** * 棣栭〉妯″潡 @@ -77,15 +61,16 @@ FragmentHomePageBinding viewBinding; - AAChartView aaChartView1; + AutoSizeMyAAChart aaChartView; - AAChartModel aaChartModel1; - AAChartView aaChartView2; + AAChartModel aaChartModel; - AAChartModel aaChartModel2; - AAChartView aaChartView3; - AAChartModel aaChartModel3; + 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 @@ -96,173 +81,370 @@ @Override public void onBindView(Bundle savedInstanceState) { - viewBinding.test1.setOnClickListener(new View.OnClickListener() { + //鍒濆鍖� + initView(); + //鍒濆鍖栫晫闈㈢洃鍚櫒 + initEvent(); + //璇诲彇鏁版嵁 + readDate(); + } + + + /** + * 璇诲彇鏁版嵁 + */ + private void readDate() { + HdlThreadLogic.runSubThread(new Runnable() { @Override - public void onClick(View v) { - setUpAAChartView(1); - } - }); - viewBinding.test2.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - setUpAAChartView(2); - } - }); - viewBinding.test3.setOnClickListener(new View.OnClickListener() { - @Override - public void onClick(View v) { - setUpAAChartView(3); + public void run() { + getStatusOverview(); + getDataOver(); + getStatistics(); + getSocialContribution(); + } }); } - private void setUpAAChartView(int value) { - if (value == 1) { - aaChartView1 = viewBinding.AAChartView1; - aaChartView1.callBack = this; - aaChartModel1 = configureAAChartModel(); - aaChartView1.aa_drawChartWithChartModel(aaChartModel1); - } else if (value == 2) { - aaChartView2 = viewBinding.AAChartView2; - aaChartView2.callBack = this; - aaChartModel2 = configureColorfulColumnChart();// configureTheAAChartModel("colorfulColumnChart"); - aaChartView2.aa_drawChartWithChartModel(aaChartModel2); - } else if (value == 3) { - aaChartView3 = viewBinding.AAChartView3; - aaChartView3.callBack = this; - aaChartModel3 = configureAAChartModel(); - aaChartView3.aa_drawChartWithChartModel(aaChartModel3); + private void initEvent() { + //鐢电珯娣诲姞 + viewBinding.homePageStationAddIv.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + 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 + public void onClick(View v) { + selectedTimePickerBuilder(); + + } + }); + //鏃� + viewBinding.dayTv.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (timeType.equals(TimeType.day)) { + //鐐瑰嚮鍚屼竴涓被鍨� + return; + } + timeType = TimeType.day; + viewBinding.unitTv.setText(UnitType.kW); + 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.monthTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000)); + viewBinding.monthTv.setTextColor(_mActivity.getColor(R.color.text_66000000)); + + viewBinding.yearTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000)); + viewBinding.yearTv.setTextColor(_mActivity.getColor(R.color.text_66000000)); + + viewBinding.lifeCycleTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000)); + viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_66000000)); + + viewBinding.v1.setVisibility(View.GONE); + viewBinding.v2.setVisibility(View.VISIBLE); + viewBinding.v3.setVisibility(View.VISIBLE); + viewBinding.homePageStationSelectTimeLl.setVisibility(View.VISIBLE); + + String dataStr = TimeUtils.getDateTimestamp(TimeUtils.getCurrentTimestamp(), TimeUtils.getTimeDateFormat(timeType)); + viewBinding.yearMonthDayTv.setText(dataStr); + getStatistics(); + + } + }); + //鏈� + viewBinding.monthTv.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (timeType.equals(TimeType.month)) { + //鐐瑰嚮鍚屼竴涓被鍨� + return; + } + timeType = TimeType.month; + viewBinding.unitTv.setText(UnitType.kWh); + 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.monthTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.time_selected_38c494)); + viewBinding.monthTv.setTextColor(_mActivity.getColor(R.color.text_38C494)); + + viewBinding.yearTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000)); + viewBinding.yearTv.setTextColor(_mActivity.getColor(R.color.text_66000000)); + + viewBinding.lifeCycleTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000)); + viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_66000000)); + + viewBinding.v1.setVisibility(View.GONE); + viewBinding.v2.setVisibility(View.GONE); + viewBinding.v3.setVisibility(View.VISIBLE); + viewBinding.homePageStationSelectTimeLl.setVisibility(View.VISIBLE); + String dataStr = TimeUtils.getDateTimestamp(TimeUtils.getCurrentTimestamp(), TimeUtils.getTimeDateFormat(timeType)); + viewBinding.yearMonthDayTv.setText(dataStr); + getStatistics(); + + + } + }); + //骞� + viewBinding.yearTv.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (timeType.equals(TimeType.year)) { + //鐐瑰嚮鍚屼竴涓被鍨� + return; + } + timeType = TimeType.year; + viewBinding.unitTv.setText(UnitType.kWh); + 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.monthTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000)); + viewBinding.monthTv.setTextColor(_mActivity.getColor(R.color.text_66000000)); + + viewBinding.yearTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.time_selected_38c494)); + viewBinding.yearTv.setTextColor(_mActivity.getColor(R.color.text_38C494)); + + viewBinding.lifeCycleTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000)); + viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_66000000)); + + viewBinding.v1.setVisibility(View.VISIBLE); + viewBinding.v2.setVisibility(View.GONE); + viewBinding.v3.setVisibility(View.GONE); + viewBinding.homePageStationSelectTimeLl.setVisibility(View.VISIBLE); + String dataStr = TimeUtils.getDateTimestamp(TimeUtils.getCurrentTimestamp(), TimeUtils.getTimeDateFormat(timeType)); + viewBinding.yearMonthDayTv.setText(dataStr); + getStatistics(); + } + }); + //鐢熷懡鏈� + viewBinding.lifeCycleTv.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + if (timeType.equals(TimeType.all)) { + //鐐瑰嚮鍚屼竴涓被鍨� + return; + } + timeType = TimeType.all; + viewBinding.unitTv.setText(UnitType.kWh); + 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.monthTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000)); + viewBinding.monthTv.setTextColor(_mActivity.getColor(R.color.text_66000000)); + + viewBinding.yearTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000)); + viewBinding.yearTv.setTextColor(_mActivity.getColor(R.color.text_66000000)); + + viewBinding.lifeCycleTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.drawable.time_selected_38c494)); + viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_38C494)); + + viewBinding.v1.setVisibility(View.VISIBLE); + viewBinding.v2.setVisibility(View.VISIBLE); + viewBinding.v3.setVisibility(View.GONE); + viewBinding.homePageStationSelectTimeLl.setVisibility(View.GONE); + getStatistics(); + + } + }); + //涓婁竴姝� + viewBinding.lastStepClickLl.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + String currDate = viewBinding.yearMonthDayTv.getText().toString(); + if (TextUtils.isEmpty(currDate)) { + return; + } + String timeDateFormat = TimeUtils.getTimeDateFormat(timeType); + Calendar calendar = TimeUtils.stringToCalendar(currDate, timeDateFormat); + String time = TimeUtils.subtractDayMonthYearFromDate(calendar, 1, timeDateFormat, timeType); + //涓嶉渶瑕侀檺鍒舵渶灏忔棩鏈燂紝鍥犱负鏄煡璇㈣处鍙蜂笅鎵�鏈夌數绔欙紝鏃犳硶鐭ラ亾鏈�灏忓缓绔欐棩鏈� + viewBinding.yearMonthDayTv.setText(time); + getStatistics(); + + } + }); + //涓嬩竴姝� + viewBinding.nextStepClickLl.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View v) { + String currDate = viewBinding.yearMonthDayTv.getText().toString(); + if (TextUtils.isEmpty(currDate)) { + return; + } + String timeDateFormat = TimeUtils.getTimeDateFormat(timeType); + Calendar calendar = TimeUtils.stringToCalendar(currDate, timeDateFormat); + String time = TimeUtils.addDayMonthYearToDate(calendar, 1, timeDateFormat, timeType); + if (TimeUtils.stringDateToTimestamp(time, timeDateFormat) > TimeUtils.getCurrentTimestamp()) { + HdlThreadLogic.toast(_mActivity, getString(R.string.the_query_date_is_exceeded)); + + return; + } + viewBinding.yearMonthDayTv.setText(time); + getStatistics(); + } + }); + //璁剧疆涓嬫媺绠ご棰滆壊 + viewBinding.srl.setColorSchemeResources(R.color.text_FF245EC3); + viewBinding.srl.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() { + @Override + public void onRefresh() { + viewBinding.srl.setRefreshing(false); + readDate(); + } + }); + + + } + + /** + * 鏃堕棿閫夋嫨鍣� + */ + private void selectedTimePickerBuilder() { + + String currDate = viewBinding.yearMonthDayTv.getText().toString(); + //鏃堕棿閫夋嫨鍣� + Calendar selectedDate = TimeUtils.stringToCalendar(currDate, TimeUtils.getTimeDateFormat(timeType)); + Calendar startDate = Calendar.getInstance(); + 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)); + boolean day = true; + boolean month = true; + boolean year = true; + if (timeType.equals(TimeType.month)) { + day = false; + } else if (timeType.equals(TimeType.year)) { + day = false; + month = false; } + TimePickerView pvTime = new TimePickerBuilder(_mActivity, new OnTimeSelectListener() { + @Override + public void onTimeSelect(Date date, View v) {//閫変腑浜嬩欢鍥炶皟 + String timeDateFormat = TimeUtils.getTimeDateFormat(timeType); + String time = TimeUtils.dateToString(date, timeDateFormat); + if (viewBinding.yearMonthDayTv.getText().toString().equals(time)) { + //琛ㄧず鍚屼竴涓椂闂� + return; + } + viewBinding.yearMonthDayTv.setText(time); + getStatistics(); + } + }).setType(new boolean[]{year, month, day, false, false, false})// 榛樿鍏ㄩ儴鏄剧ず + .setCancelText(_mActivity.getString(R.string.loading_cancel))//鍙栨秷鎸夐挳鏂囧瓧 + .setSubmitText(_mActivity.getString(R.string.loading_affirm))//纭鎸夐挳鏂囧瓧 + .setContentTextSize(18)//婊氳疆鏂囧瓧澶у皬 + .setTitleSize(18)//鏍囬鏂囧瓧澶у皬 + .setTitleText(_mActivity.getString(R.string.time_selectd))//鏍囬鏂囧瓧 + .setOutSideCancelable(true)//鐐瑰嚮灞忓箷锛岀偣鍦ㄦ帶浠跺閮ㄨ寖鍥存椂锛屾槸鍚﹀彇娑堟樉绀� + .isCyclic(false)//鏄惁寰幆婊氬姩 + .setTitleColor(_mActivity.getColor(R.color.text_E6000000))//鏍囬鏂囧瓧棰滆壊 + .setSubmitColor(_mActivity.getColor(R.color.text_38C494))//纭畾鎸夐挳鏂囧瓧棰滆壊 + .setCancelColor(_mActivity.getColor(R.color.text_66000000))//鍙栨秷鎸夐挳鏂囧瓧棰滆壊 + .setTitleBgColor(_mActivity.getColor(R.color.text_FFFFFFFF))//鏍囬鑳屾櫙棰滆壊 Night mode + .setBgColor(_mActivity.getColor(R.color.text_FFFFFFFF))//婊氳疆鑳屾櫙棰滆壊 Night mode + .setTextColorCenter(_mActivity.getColor(R.color.text_E6000000)).setDate(selectedDate)// 濡傛灉涓嶈缃殑璇濓紝榛樿鏄郴缁熸椂闂�*/ + .setRangDate(startDate, endDate)//璧峰缁堟骞存湀鏃ヨ瀹� + .setLabel(_mActivity.getString(R.string.year), _mActivity.getString(R.string.month), _mActivity.getString(R.string.day), _mActivity.getString(R.string.hour), _mActivity.getString(R.string.minute), _mActivity.getString(R.string.seconds))//榛樿璁剧疆涓哄勾鏈堟棩鏃跺垎绉� + .isCenterLabel(false) //鏄惁鍙樉绀轰腑闂撮�変腑椤圭殑label鏂囧瓧锛宖alse鍒欐瘡椤筰tem鍏ㄩ儴閮藉甫鏈塴abel銆� + .isDialog(false)//鏄惁鏄剧ず涓哄璇濇鏍峰紡 + .setItemVisibleCount(7)//瀵硅瘽妗嗛珮搴� + .setDividerColor(_mActivity.getColor(R.color.text_E1E1E1)).setLineSpacingMultiplier(3f)// + .build(); + pvTime.show(); } - private AAChartModel configureAAChartModel() { -// Intent intent = getIntent(); - String chartType = AAChartType.Area; - int position = 0; - aaChartModel1 = BasicChartComposer.configureAreaChart(); - configureTheStyleForDifferentTypeChart(chartType, position); -// configureViewsVisibility(chartType); - return aaChartModel1; - } - - private void configureTheStyleForDifferentTypeChart(String chartType, int position) { - if ((chartType.equals(AAChartType.Area) || chartType.equals(AAChartType.Line)) - && (position == 4 || position == 5)) { - aaChartModel1 = BasicChartComposer.configureStepAreaChartAndStepLineChart(); - } else if (chartType.equals(AAChartType.Column) || chartType.equals(AAChartType.Bar)) { - - aaChartModel1 = BasicChartComposer.configureColumnChartAndBarChart(); - } else if (chartType.equals(AAChartType.Area) || chartType.equals(AAChartType.Areaspline)) { - aaChartModel1 = BasicChartComposer.configureAreaChartAndAreasplineChartStyle(chartType); - } else if (chartType.equals(AAChartType.Line) || chartType.equals(AAChartType.Spline)) { - aaChartModel1 = BasicChartComposer.configureLineChartAndSplineChartStyle(chartType); + /** + * 鍥捐〃鍔犺浇 + */ + private void setUpAAChartView() { + aaChartView = viewBinding.autoSizeMyAAChart; + aaChartView.callBack = this; + if (TimeType.day.equals(timeType)) { + 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); } - aaChartModel1.chartType = chartType; + aaChartView.aa_drawChartWithChartModel(aaChartModel); + } - private AAChartModel configureTheAAChartModel(String chartType) { - switch (chartType) { - case "colorfulChart": - return configureColorfulChart(); - case "gradientColorfulChart": - return configureColorfulGradientColorChart(); - case "discontinuousDataChart": - return configureDiscontinuousDataChart(); - case "colorfulColumnChart": - return configureColorfulColumnChart(); - case "nightingaleRoseChart": - return configureNightingaleRoseChart(); - case "chartWithShadowStyle": - return configureChartWithShadowStyle(); - case "colorfulGradientAreaChart": - return configureColorfulGradientAreaChart(); - case "colorfulGradientSplineChart": - return configureColorfulGradientSplineChart(); - case "gradientColorAreasplineChart": - return configureGradientColorAreasplineChart(); - case "SpecialStyleMarkerOfSingleDataElementChart": - return configureSpecialStyleMarkerOfSingleDataElementChart(); - case "SpecialStyleColumnOfSingleDataElementChart": - return configureSpecialStyleColumnOfSingleDataElementChart(); - case "AreaChartThreshold": - return configureAreaChartThreshold(); - case "customScatterChartMarkerSymbolContent": - return customScatterChartMarkerSymbolContent(); - case "customLineChartMarkerSymbolContent": - return customLineChartMarkerSymbolContent(); - case "TriangleRadarChart": - return configureTriangleRadarChart(); - case "QuadrangleRadarChart": - return configureQuadrangleRadarChart(); - case "PentagonRadarChart": - return configurePentagonRadarChart(); - case "HexagonRadarChart": - return configureHexagonRadarChart(); - case "adjustYAxisMaxAndMinValues": - return adjustYAxisMaxAndMinValues(); - case "customSpecialStyleDataLabelOfSingleDataElementChart": - return customSpecialStyleDataLabelOfSingleDataElementChart(); - case "customBarChartHoverColorAndSelectColor": - return customBarChartHoverColorAndSelectColor(); - case "customChartHoverAndSelectHaloStyle": - return customChartHoverAndSelectHaloStyle(); - case "customSplineChartMarkerStatesHoverStyle": - return customSplineChartMarkerStatesHoverStyle(); - case "splineChartHoverLineWithNoChangeAndCustomMarkerStatesHoverStyle": - return splineChartHoverLineWithNoChangeAndCustomMarkerStatesHoverStyle(); - case "customNormalStackingChartDataLabelsContentAndStyle": - return customNormalStackingChartDataLabelsContentAndStyle(); - case "upsideDownPyramidChart": - return upsideDownPyramidChart(); - case "doubleLayerPieChart": - return doubleLayerPieChart(); - case "disableSomeOfLinesMouseTrackingEffect": - return disableSomeOfLinesMouseTrackingEffect(); - case "configureColorfulShadowSplineChart": - return configureColorfulShadowSplineChart(); - case "configureColorfulDataLabelsStepLineChart": - return configureColorfulDataLabelsStepLineChart(); - case "configureColorfulGradientColorAndColorfulDataLabelsStepAreaChart": - return configureColorfulGradientColorAndColorfulDataLabelsStepAreaChart(); - case "disableSplineChartMarkerHoverEffect": - return disableSplineChartMarkerHoverEffect(); - case "configureMaxAndMinDataLabelsForChart": - return configureMaxAndMinDataLabelsForChart(); - case "customVerticalXAxisCategoriesLabelsByHTMLBreakLineTag": - return customVerticalXAxisCategoriesLabelsByHTMLBreakLineTag(); - case "noMoreGroupingAndOverlapEachOtherColumnChart": - return noMoreGroupingAndOverlapEachOtherColumnChart(); - case "noMoreGroupingAndNestedColumnChart": - return noMoreGroupingAndNestedColumnChart(); - case "topRoundedCornersStackingColumnChart": - return topRoundedCornersStackingColumnChart(); - case "freeStyleRoundedCornersStackingColumnChart": - return freeStyleRoundedCornersStackingColumnChart(); - case "customColumnChartBorderStyleAndStatesHoverColor": - return customColumnChartBorderStyleAndStatesHoverColor(); - case "customLineChartWithColorfulMarkersAndLines": - return customLineChartWithColorfulMarkersAndLines(); - case "customLineChartWithColorfulMarkersAndLines2": - return customLineChartWithColorfulMarkersAndLines2(); - case "drawLineChartWithPointsCoordinates": - return drawLineChartWithPointsCoordinates(); - case "configureSpecialStyleColumnForNegativeDataMixedPositiveData": - return configureSpecialStyleColumnForNegativeDataMixedPositiveData(); - case "configureMultiLevelStopsArrGradientColorAreasplineMixedLineChart": - return configureMultiLevelStopsArrGradientColorAreasplineMixedLineChart(); - case "connectNullsForSingleAASeriesElement": - return connectNullsForSingleAASeriesElement(); - case "lineChartsWithLargeDifferencesInTheNumberOfDataInDifferentSeriesElement": - return lineChartsWithLargeDifferencesInTheNumberOfDataInDifferentSeriesElement(); - case "customAreasplineChartWithColorfulGradientColorZones": - return customAreasplineChartWithColorfulGradientColorZones(); - case "largeDataStackingColumnChart": - return largeDataStackingColumnChart(); + private void initView() { - } - return configureColorfulChart(); + viewBinding.homeAllIl.stationTitleTv.setText(getString(R.string.message_all)); + viewBinding.homeFaultsIl.stationTitleTv.setText(getString(R.string.my_power_station_malfunction)); + 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(TimeUtils.getCurrentTimestamp(), TimeUtils.getTimeDateFormat(timeType)); + viewBinding.yearMonthDayTv.setText(dataStr); + + String installed_capacity = getString(R.string.string_capacity) + "(" + UnitType.kWp + ")"; + viewBinding.infoRl1Text2Tv.setText(installed_capacity); + String generated_power = getString(R.string.generated_power) + "(" + UnitType.kW + ")"; + viewBinding.infoRl1Text4Tv.setText(generated_power); + String generation = getString(R.string.generation) + "(" + UnitType.kWh + ")"; + viewBinding.homePageStationInfoRl1TitleTv.setText(generation); + + viewBinding.homePageStationInfoRl2DayIc.dataTypeTv.setText(R.string.day_power_generation); + viewBinding.homePageStationInfoRl2MonIc.dataTypeTv.setText(R.string.month_power_generation); + viewBinding.homePageStationInfoRl2YearIc.dataTypeTv.setText(R.string.year_power_generation); + viewBinding.homePageStationInfoRl2CumulativeIc.dataTypeTv.setText(R.string.cumulative_power_generation); + + 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)); + viewBinding.monthTv.setTextColor(_mActivity.getColor(R.color.text_66000000)); + viewBinding.yearTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000)); + viewBinding.yearTv.setTextColor(_mActivity.getColor(R.color.text_66000000)); + viewBinding.lifeCycleTv.setBackground(AppCompatResources.getDrawable(_mActivity, R.color.text_00000000)); + viewBinding.lifeCycleTv.setTextColor(_mActivity.getColor(R.color.text_66000000)); + viewBinding.v1.setVisibility(View.GONE); + viewBinding.v2.setVisibility(View.VISIBLE); + viewBinding.v3.setVisibility(View.VISIBLE); + viewBinding.homePageStationSelectTimeLl.setVisibility(View.VISIBLE); + setUpAAChartView();//鍥捐〃鍔犺浇 } + @Override public void chartViewDidFinishLoad(AAChartView aaChartView) { @@ -287,8 +469,128 @@ // 鍙栨秷绮樻�т簨浠� EventBus.getDefault().removeStickyEvent(eventBus); HdlLogLogic.print("姝e湪鐐瑰嚮銆愰椤点��"); - } } } + + + /** + * 鐢电珯鐘舵�佹瑙� + */ + private void getStatusOverview() { + HdlResidenceLogic.getInstance().getStatusOverview(new CloudCallBeak<StatusOverviewBean>() { + @Override + public void onSuccess(StatusOverviewBean statusOverviewBean) { + if (statusOverviewBean == null) { + return; + } + 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 + public void onFailure(HDLException e) { + + } + }); + } + + + /** + * 鑾峰彇缁熻姒傝鏁版嵁(鍏徃缁村害) + */ + private void getDataOver() { + + HdlPowerStationDataStatisticsLogic.getInstance().getDataOver(new CloudCallBeak<DataOverBean>() { + @Override + public void onSuccess(DataOverBean dataOverBean) { + HdlThreadLogic.runMainThread(new Runnable() { + @Override + public void run() { + if (dataOverBean == null) { + return; + } + viewBinding.infoRl1Text1Tv.setText(HdlCommonLogic.getConvertDoubleUnit(dataOverBean.getInstalledCapacity())); + viewBinding.infoRl1Text3Tv.setText(HdlCommonLogic.getConvertDoubleUnit(dataOverBean.getPower(), UnitType.kW, false)); + viewBinding.infoRl1FText1Tv.setText(dataOverBean.getPowerRatio()); + + 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())); + } + }); + } + + @Override + public void onFailure(HDLException e) { + + } + }); + } + + /** + * 鍙戠數閲忕粺璁�(鍏徃缁村害) + */ + private void getStatistics() { + String currDate = viewBinding.yearMonthDayTv.getText().toString(); + HdlPowerStationDataStatisticsLogic.getInstance().getStatistics(timeType, currDate, new CloudCallBeak<List<StatisticsBean>>() { + @Override + public void onSuccess(List<StatisticsBean> list) { + 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(); + if (TimeType.day.equals(timeType)) { + values[i] = HdlCommonLogic.divideByOneThousandAndFormat(list.get(i).getFieldValue());// HdlCommonLogic.getBigDecimal(list.get(i).getFieldValue()).intValue();//鑾峰彇鏁存暟閮ㄥ垎 + } else { + values[i] = HdlCommonLogic.getBigDecimal(list.get(i).getFieldValue()); + } + } + fieldNames = keys; + fieldValues = values; + setUpAAChartView(); + } + }); + + } + + @Override + public void onFailure(HDLException e) { + + } + }); + } + + /** + * 绀句細璐$尞(鍏徃缁村害) + */ + private void getSocialContribution() { + HdlPowerStationDataStatisticsLogic.getInstance().getSocialContribution(new CloudCallBeak<SocialContributionBean>() { + @Override + public void onSuccess(SocialContributionBean socialContributionBean) { + if (socialContributionBean == null) { + return; + } + 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 + public void onFailure(HDLException e) { + + } + }); + } + + } \ No newline at end of file -- Gitblit v1.8.0