using System; using System.Collections.Generic; using HDL_ON.DAL.Server; using HDL_ON.Entity; using HDL_ON.UI.CSS; using Shared; namespace HDL_ON.UI { public class WetarHeaterJinmaoHistoryPage : FrameLayout { WetarHeaterJinmaoHistoryPage bodyView; Function function; FrameLayout infoView1; EchartsOption_Histogram tempEchartOption; MyEchartsViewOn infoView1_EchartsView; Button infoView1_Date_Day; Button infoView1_Date_Month; Button infoView1_Date_Year; Button infoView1_DateInfo_PreClickButton; Button infoView1_DateInfo_DateTextButton; Button infoView1_DateInfo_NextClickButton; FrameLayout infoView2; MyEchartsViewOn infoView2_EchartsView; EchartsOption_Histogram echartOption2; Button infoView2_Date_Day; Button infoView2_Date_Month; Button infoView2_Date_Year; Button infoView2_DateInfo_PreClickButton; Button infoView2_DateInfo_DateTextButton; Button infoView2_DateInfo_NextClickButton; public WetarHeaterJinmaoHistoryPage(Function deviceFunction) { bodyView = this; function = deviceFunction; this.BackgroundColor = CSS_Color.BackgroundColor; } public void LoadPage() { var topView = new TopViewDiv(bodyView, function.name); topView.maginY = 10; topView.LoadTopView(); var contentView = new VerticalScrolViewLayout() { Y = Application.GetRealHeight(74 + 16), Height = Application.GetRealHeight(Application.DesignHeight - 74), }; bodyView.AddChidren(contentView); #region 温度值 infoView1 = new FrameLayout() { Width = Application.GetRealWidth(343), Height = Application.GetRealWidth(382), Gravity = Gravity.CenterHorizontal, BackgroundColor = CSS_Color.MainBackgroundColor, Radius = (uint)Application.GetRealWidth(12), BorderColor = 0x00FFFFFF, BorderWidth = 0, }; contentView.AddChidren(infoView1); #region 时间条件选择 var infoView1_DateView = new HorizontalScrolViewLayout() { Width = Application.GetRealWidth(343 - 34), Height = Application.GetRealWidth(26), Gravity = Gravity.CenterHorizontal, Y = Application.GetRealWidth(17), BackgroundColor = CSS_Color.BackgroundColor, Radius = (uint)Application.GetRealWidth(13), BorderColor = 0x00FFFFFF, BorderWidth = 0, ScrollEnabled = false, }; infoView1.AddChidren(infoView1_DateView); infoView1_Date_Day = new Button() { Width = Application.GetRealWidth(103), Height = Application.GetRealWidth(26), BackgroundColor = CSS_Color.BackgroundColor, SelectedBackgroundColor = CSS_Color.MainBackgroundColor, Radius = (uint)Application.GetRealWidth(13), BorderColor = CSS_Color.BackgroundColor, BorderWidth = (uint)Application.GetRealWidth(1), Text = "日", TextAlignment = TextAlignment.Center, TextColor = CSS_Color.FirstLevelTitleColor, SelectedTextColor = CSS_Color.MainColor, TextSize = CSS_FontSize.TextFontSize, IsSelected = true, }; infoView1_DateView.AddChidren(infoView1_Date_Day); infoView1_Date_Month = new Button() { Width = Application.GetRealWidth(103), Height = Application.GetRealWidth(26), BackgroundColor = CSS_Color.BackgroundColor, SelectedBackgroundColor = CSS_Color.MainBackgroundColor, Radius = (uint)Application.GetRealWidth(13), BorderColor = CSS_Color.BackgroundColor, BorderWidth = (uint)Application.GetRealWidth(1), Text = "月", TextAlignment = TextAlignment.Center, TextColor = CSS_Color.FirstLevelTitleColor, SelectedTextColor = CSS_Color.MainColor, TextSize = CSS_FontSize.TextFontSize, IsSelected = false, }; infoView1_DateView.AddChidren(infoView1_Date_Month); infoView1_Date_Year = new Button() { Width = Application.GetRealWidth(103), Height = Application.GetRealWidth(26), BackgroundColor = CSS_Color.BackgroundColor, SelectedBackgroundColor = CSS_Color.MainBackgroundColor, Radius = (uint)Application.GetRealWidth(13), BorderColor = CSS_Color.BackgroundColor, BorderWidth = (uint)Application.GetRealWidth(1), Text = "年", TextAlignment = TextAlignment.Center, TextColor = CSS_Color.FirstLevelTitleColor, SelectedTextColor = CSS_Color.MainColor, TextSize = CSS_FontSize.TextFontSize, IsSelected = false, }; infoView1_DateView.AddChidren(infoView1_Date_Year); var infoView1_DateInfoView = new FrameLayout() { Y = Application.GetRealWidth(43), Height = Application.GetRealWidth(55), }; infoView1.AddChidren(infoView1_DateInfoView); var infoView1_DateInfo_PreIconButton = new Button() { X = Application.GetRealWidth(18), Gravity = Gravity.CenterVertical, Width = Application.GetRealWidth(6), Height = Application.GetRealWidth(10), UnSelectedImagePath = "FunctionIcon/Acst/WaterHeater/PreIcon.png", }; infoView1_DateInfoView.AddChidren(infoView1_DateInfo_PreIconButton); infoView1_DateInfo_PreClickButton = new Button() { Width = Application.GetRealWidth(32 + 6), }; infoView1_DateInfoView.AddChidren(infoView1_DateInfo_PreClickButton); infoView1_DateInfo_DateTextButton = new Button() { Gravity = Gravity.Center, Width = Application.GetRealWidth(200), TextAlignment = TextAlignment.Center, Text = "2024-8-12", TextColor = CSS_Color.FirstLevelTitleColor, IsBold = true, TextSize = 16, }; infoView1_DateInfoView.AddChidren(infoView1_DateInfo_DateTextButton); var infoView1_DateInfo_NextIconButton = new Button() { X = Application.GetRealWidth(343 - 18 - 6), Gravity = Gravity.CenterVertical, Width = Application.GetRealWidth(6), Height = Application.GetRealWidth(10), UnSelectedImagePath = "FunctionIcon/Acst/WaterHeater/NextIcon.png", }; infoView1_DateInfoView.AddChidren(infoView1_DateInfo_NextIconButton); infoView1_DateInfo_NextClickButton = new Button() { Width = Application.GetRealWidth(32 + 6), }; infoView1_DateInfoView.AddChidren(infoView1_DateInfo_NextClickButton); #endregion #region 数据图表 infoView1_EchartsView = new MyEchartsViewOn() { Y = Application.GetRealWidth(101), Height = Application.GetRealWidth(246), }; infoView1.AddChidren(infoView1_EchartsView); tempEchartOption = new EchartsOption_Histogram(); tempEchartOption.xTitle = "时间"; tempEchartOption.yTitle = "温度(℃)"; tempEchartOption.InitXdataText(new List() { "21","22","23","24","25","26","26","27","28","29", "21","22","23","24","25","26","26","27","28","29", "21","22","23","24" }); tempEchartOption.InitYdataText(new List() { new EnvironmentalSensorHistor{ fieldName = "1", fieldValue= "23" }, new EnvironmentalSensorHistor{ fieldName = "2", fieldValue= "22" }, new EnvironmentalSensorHistor{ fieldName = "3", fieldValue= "11" }, new EnvironmentalSensorHistor{ fieldName = "4", fieldValue= "21" }, new EnvironmentalSensorHistor{ fieldName = "5", fieldValue= "41" }, new EnvironmentalSensorHistor{ fieldName = "6", fieldValue= "23" }, new EnvironmentalSensorHistor{ fieldName = "7", fieldValue= "31" }, new EnvironmentalSensorHistor{ fieldName = "8", fieldValue= "23" }, new EnvironmentalSensorHistor{ fieldName = "9", fieldValue= "11" }, new EnvironmentalSensorHistor{ fieldName = "10", fieldValue= "21" }, new EnvironmentalSensorHistor{ fieldName = "11", fieldValue= "24" }, new EnvironmentalSensorHistor{ fieldName = "12", fieldValue= "41" }, new EnvironmentalSensorHistor{ fieldName = "13", fieldValue= "32" }, new EnvironmentalSensorHistor{ fieldName = "14", fieldValue= "23" }, new EnvironmentalSensorHistor{ fieldName = "15", fieldValue= "23" }, new EnvironmentalSensorHistor{ fieldName = "16", fieldValue= "22" }, new EnvironmentalSensorHistor{ fieldName = "17", fieldValue= "11" }, new EnvironmentalSensorHistor{ fieldName = "18", fieldValue= "21" }, new EnvironmentalSensorHistor{ fieldName = "19", fieldValue= "41" }, new EnvironmentalSensorHistor{ fieldName = "20", fieldValue= "23" }, new EnvironmentalSensorHistor{ fieldName = "21", fieldValue= "31" }, new EnvironmentalSensorHistor{ fieldName = "22", fieldValue= "23" }, new EnvironmentalSensorHistor{ fieldName = "23", fieldValue= "11" }, new EnvironmentalSensorHistor{ fieldName = "24", fieldValue= "21" }, }); var ddd = tempEchartOption.InitOption(); infoView1_EchartsView.ShowWithOption(ddd); infoView1.AddChidren(new Button() { Height = Application.GetRealWidth(35), Y = Application.GetRealWidth(340), Text = "温度值", TextSize = 14, TextAlignment = TextAlignment.Center, TextColor = 0xFFC0C7D4 }); #endregion #endregion contentView.AddChidren(new Button() { Height = Application.GetRealWidth(16) }); #region 用水量 infoView2 = new FrameLayout() { Width = Application.GetRealWidth(343), Height = Application.GetRealWidth(382), Y = Application.GetRealHeight(16) + infoView1.Bottom, Gravity = Gravity.CenterHorizontal, BackgroundColor = CSS_Color.MainBackgroundColor, Radius = (uint)Application.GetRealWidth(12), BorderColor = 0x00FFFFFF, BorderWidth = 0, }; contentView.AddChidren(infoView2); #region 时间条件选择 var infoView2_DateView = new HorizontalScrolViewLayout() { Width = Application.GetRealWidth(343 - 34), Height = Application.GetRealWidth(26), Gravity = Gravity.CenterHorizontal, Y = Application.GetRealWidth(17), BackgroundColor = CSS_Color.BackgroundColor, Radius = (uint)Application.GetRealWidth(13), BorderColor = 0x00FFFFFF, BorderWidth = 0, ScrollEnabled = false, }; infoView2.AddChidren(infoView2_DateView); infoView2_Date_Day = new Button() { Width = Application.GetRealWidth(103), Height = Application.GetRealWidth(26), BackgroundColor = CSS_Color.BackgroundColor, SelectedBackgroundColor = CSS_Color.MainBackgroundColor, Radius = (uint)Application.GetRealWidth(13), BorderColor = CSS_Color.BackgroundColor, BorderWidth = (uint)Application.GetRealWidth(1), Text = "日", TextAlignment = TextAlignment.Center, TextColor = CSS_Color.FirstLevelTitleColor, SelectedTextColor = CSS_Color.MainColor, TextSize = CSS_FontSize.TextFontSize, IsSelected = true, }; infoView2_DateView.AddChidren(infoView2_Date_Day); infoView2_Date_Month = new Button() { Width = Application.GetRealWidth(103), Height = Application.GetRealWidth(26), BackgroundColor = CSS_Color.BackgroundColor, SelectedBackgroundColor = CSS_Color.MainBackgroundColor, Radius = (uint)Application.GetRealWidth(13), BorderColor = CSS_Color.BackgroundColor, BorderWidth = (uint)Application.GetRealWidth(1), Text = "月", TextAlignment = TextAlignment.Center, TextColor = CSS_Color.FirstLevelTitleColor, SelectedTextColor = CSS_Color.MainColor, TextSize = CSS_FontSize.TextFontSize, IsSelected = false, }; infoView2_DateView.AddChidren(infoView2_Date_Month); infoView2_Date_Year = new Button() { Width = Application.GetRealWidth(103), Height = Application.GetRealWidth(26), BackgroundColor = CSS_Color.BackgroundColor, SelectedBackgroundColor = CSS_Color.MainBackgroundColor, Radius = (uint)Application.GetRealWidth(13), BorderColor = CSS_Color.BackgroundColor, BorderWidth = (uint)Application.GetRealWidth(1), Text = "年", TextAlignment = TextAlignment.Center, TextColor = CSS_Color.FirstLevelTitleColor, SelectedTextColor = CSS_Color.MainColor, TextSize = CSS_FontSize.TextFontSize, IsSelected = false, }; infoView2_DateView.AddChidren(infoView2_Date_Year); var infoView2_DateInfoView = new FrameLayout() { Y = Application.GetRealWidth(43), Height = Application.GetRealWidth(55), }; infoView2.AddChidren(infoView2_DateInfoView); var infoView2_DateInfo_PreIconButton = new Button() { X = Application.GetRealWidth(18), Gravity = Gravity.CenterVertical, Width = Application.GetRealWidth(6), Height = Application.GetRealWidth(10), UnSelectedImagePath = "FunctionIcon/Acst/WaterHeater/PreIcon.png", }; infoView2_DateInfoView.AddChidren(infoView2_DateInfo_PreIconButton); infoView2_DateInfo_PreClickButton = new Button() { Width = Application.GetRealWidth(32 + 6), }; infoView2_DateInfoView.AddChidren(infoView2_DateInfo_PreClickButton); infoView2_DateInfo_DateTextButton = new Button() { Gravity = Gravity.Center, Width = Application.GetRealWidth(200), TextAlignment = TextAlignment.Center, Text = "2024-8-12", TextColor = CSS_Color.FirstLevelTitleColor, IsBold = true, TextSize = 16, }; infoView2_DateInfoView.AddChidren(infoView2_DateInfo_DateTextButton); var infoView2_DateInfo_NextIconButton = new Button() { X = Application.GetRealWidth(343 - 18 - 6), Gravity = Gravity.CenterVertical, Width = Application.GetRealWidth(6), Height = Application.GetRealWidth(10), UnSelectedImagePath = "FunctionIcon/Acst/WaterHeater/NextIcon.png", }; infoView2_DateInfoView.AddChidren(infoView2_DateInfo_NextIconButton); infoView2_DateInfo_NextClickButton = new Button() { Width = Application.GetRealWidth(32 + 6), }; infoView2_DateInfoView.AddChidren(infoView2_DateInfo_NextClickButton); #endregion #region 数据图表 infoView2_EchartsView = new MyEchartsViewOn() { Y = Application.GetRealWidth(101), Height = Application.GetRealWidth(246), }; infoView2.AddChidren(infoView2_EchartsView); echartOption2 = new EchartsOption_Histogram(); echartOption2.xTitle = "时间"; echartOption2.yTitle = "用水量(t)"; echartOption2.InitXdataText(new List() { "21","22","23","24","25","26","26","27","28","29", "21","22","23","24","25","26","26","27","28","29", "21","22","23","24" }); echartOption2.InitYdataText(new List() { new EnvironmentalSensorHistor{ fieldName = "1", fieldValue= "23" }, new EnvironmentalSensorHistor{ fieldName = "2", fieldValue= "22" }, new EnvironmentalSensorHistor{ fieldName = "3", fieldValue= "11" }, new EnvironmentalSensorHistor{ fieldName = "4", fieldValue= "21" }, new EnvironmentalSensorHistor{ fieldName = "5", fieldValue= "41" }, new EnvironmentalSensorHistor{ fieldName = "6", fieldValue= "23" }, new EnvironmentalSensorHistor{ fieldName = "7", fieldValue= "31" }, new EnvironmentalSensorHistor{ fieldName = "8", fieldValue= "23" }, new EnvironmentalSensorHistor{ fieldName = "9", fieldValue= "11" }, new EnvironmentalSensorHistor{ fieldName = "10", fieldValue= "21" }, new EnvironmentalSensorHistor{ fieldName = "11", fieldValue= "24" }, new EnvironmentalSensorHistor{ fieldName = "12", fieldValue= "41" }, new EnvironmentalSensorHistor{ fieldName = "13", fieldValue= "32" }, new EnvironmentalSensorHistor{ fieldName = "14", fieldValue= "23" }, new EnvironmentalSensorHistor{ fieldName = "15", fieldValue= "23" }, new EnvironmentalSensorHistor{ fieldName = "16", fieldValue= "22" }, new EnvironmentalSensorHistor{ fieldName = "17", fieldValue= "11" }, new EnvironmentalSensorHistor{ fieldName = "18", fieldValue= "21" }, new EnvironmentalSensorHistor{ fieldName = "19", fieldValue= "41" }, new EnvironmentalSensorHistor{ fieldName = "20", fieldValue= "23" }, new EnvironmentalSensorHistor{ fieldName = "21", fieldValue= "31" }, new EnvironmentalSensorHistor{ fieldName = "22", fieldValue= "23" }, new EnvironmentalSensorHistor{ fieldName = "23", fieldValue= "11" }, new EnvironmentalSensorHistor{ fieldName = "24", fieldValue= "21" }, }); infoView2_EchartsView.ShowWithOption(echartOption2.InitOption()); infoView2.AddChidren(new Button() { Height = Application.GetRealWidth(35), Y = Application.GetRealWidth(340), Text = "用水量", TextSize = 14, TextAlignment = TextAlignment.Center, TextColor = 0xFFC0C7D4 }); #endregion #endregion contentView.AddChidren(new Button() { Height = Application.GetRealWidth(26) }); } /// /// 读取温度值历史数据 /// private void getTempHistory(string queryType) { var loadPage = new Loading() { LodingBackgroundColor = 0x88888888, }; infoView1.AddChidren(loadPage); new System.Threading.Thread(() => { try { Application.RunOnMainThread(() => { loadPage.Start(Language.StringByID(StringId.PleaseWait)); }); var revertObj = new HttpServerRequest().GetSensorHistory(queryType, function.deviceId, WaterHeaterJinmao_AttrEnum.temp.ToString()); if (revertObj != null) { if (revertObj.Code == StateCode.SUCCESS) { var revertData = Newtonsoft.Json.JsonConvert.DeserializeObject>(revertObj.Data.ToString()); List vs = new List(); foreach (var data in revertData) { vs.Add(data.fieldName); } tempEchartOption.InitXdataText(vs); tempEchartOption.InitYdataText(revertData); Application.RunOnMainThread(() => { infoView1_EchartsView.ShowWithOption(tempEchartOption.InitOption()); }); } } } catch (Exception ex) { MainPage.Log($"history error : {ex.Message}"); } finally { Application.RunOnMainThread(() => { loadPage.Hide(); }); } }) { IsBackground = true }.Start(); } /// /// 获取用水量历史记录 /// /// private void getWaterHistory(string queryType) { var loadPage = new Loading() { LodingBackgroundColor = 0x88888888, }; infoView2.AddChidren(loadPage); new System.Threading.Thread(() => { try { Application.RunOnMainThread(() => { loadPage.Start(Language.StringByID(StringId.PleaseWait)); }); var revertObj = new HttpServerRequest().GetSensorHistory(queryType, function.deviceId, WaterHeaterJinmao_AttrEnum.volume.ToString()); if (revertObj != null) { if (revertObj.Code == StateCode.SUCCESS) { var revertData = Newtonsoft.Json.JsonConvert.DeserializeObject>(revertObj.Data.ToString()); List vs = new List(); foreach (var data in revertData) { vs.Add(data.fieldName); } echartOption2.InitXdataText(vs); echartOption2.InitYdataText(revertData); Application.RunOnMainThread(() => { infoView2_EchartsView.ShowWithOption(echartOption2.InitOption()); }); } } } catch (Exception ex) { MainPage.Log($"history 2 error : {ex.Message}"); } finally { Application.RunOnMainThread(() => { loadPage.Hide(); }); } }) { IsBackground = true }.Start(); } private void initQueryButton() { infoView1_Date_Day.MouseUpEventHandler = (sender, e) => { if (infoView1_Date_Day.IsSelected) { return; } infoView1_Date_Day.IsSelected = true; infoView1_Date_Month.IsSelected = false; infoView1_Date_Year.IsSelected = false; //getTempHistory("day") }; } } }