From 9acd3887f1f8db40d59f991b1726a61aa7c7637c Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期三, 12 五月 2021 15:13:56 +0800 Subject: [PATCH] Merge branch 'CJL' into wxr4 --- HDL_ON/UI/UI2/FuntionControlView/Energy/EnergyMainPage.cs | 228 +++++++++++++++++++++++++++++--------------------------- 1 files changed, 117 insertions(+), 111 deletions(-) diff --git a/HDL_ON/UI/UI2/FuntionControlView/Energy/EnergyMainPage.cs b/HDL_ON/UI/UI2/FuntionControlView/Energy/EnergyMainPage.cs index 560fb7a..e985552 100644 --- a/HDL_ON/UI/UI2/FuntionControlView/Energy/EnergyMainPage.cs +++ b/HDL_ON/UI/UI2/FuntionControlView/Energy/EnergyMainPage.cs @@ -3,6 +3,7 @@ using HDL_ON.DAL.Server; using HDL_ON.Entity; using HDL_ON.UI.CSS; +using HDL_ON.UI.UI2.EchartsOption_Energy; using Shared; namespace HDL_ON.UI { @@ -15,7 +16,7 @@ List<string> colorList2 = new List<string>() { "#80AEFF", "#FFD154", "#FF9D54", "#FE6A6A", "#B183C3", "#ADE764", "#D7504B", "#C6E579", "#F4E001", "#F0805A", "#26C0C0"}; - + public EnergyMainPage() { bodyView = this; @@ -100,7 +101,8 @@ //Y = Application.GetRealWidth(16), }; generalTableView.AddChidren(echartsView); - MyEchartsViewOn myEchartsView = new MyEchartsViewOn() { + MyEchartsViewOn myEchartsView = new MyEchartsViewOn() + { Width = Application.GetRealWidth(118), Height = Application.GetRealWidth(118), }; @@ -134,21 +136,23 @@ var energyListView = new FrameLayout() { Y = generalTableView.Bottom + Application.GetRealWidth(8), - Height = Application.GetRealWidth(116 * energyList.Count) , + Height = Application.GetRealWidth(116 * energyList.Count), }; contentView.AddChidren(energyListView); int index = 0; - foreach(var energy in energyList) + foreach (var energy in energyList) { EnergyRow(energy, energyListView, index); index++; } } + FrameLayout diagramView; + List<Function> queryList = new List<Function>(); + string curQueryType = "hour"; - public void ddd(FrameLayout contentView) + void d1(FrameLayout contentView) { - - FrameLayout diagramView = new FrameLayout() + diagramView = new FrameLayout() { Gravity = Gravity.CenterHorizontal, Width = Application.GetRealWidth(343), @@ -206,6 +210,37 @@ Text = DateTime.Now.Month.ToString() + Language.StringByID(StringId.month), }; showDataTypeView.AddChidren(btnShowHistroyData_Month); + + + btnShowHistroyData_Day.MouseUpEventHandler = (sender, e) => + { + showDataTypeView.BackgroundImagePath = "FunctionIcon/EnvironmentalScience/SensorHistoryBg1.png"; + btnShowHistroyData_Day.IsSelected = true; + btnShowHistroyData_Month.IsSelected = false; + btnShowHistroyData_Week.IsSelected = false; + curQueryType = "hour"; + d2(); + }; + + btnShowHistroyData_Month.MouseUpEventHandler = (sender, e) => + { + showDataTypeView.BackgroundImagePath = "FunctionIcon/EnvironmentalScience/SensorHistoryBg3.png"; + btnShowHistroyData_Day.IsSelected = false; + btnShowHistroyData_Month.IsSelected = true; + btnShowHistroyData_Week.IsSelected = false; + curQueryType = "week"; + d2(); + }; + btnShowHistroyData_Week.MouseUpEventHandler = (sender, e) => + { + showDataTypeView.BackgroundImagePath = "FunctionIcon/EnvironmentalScience/SensorHistoryBg2.png"; + btnShowHistroyData_Day.IsSelected = false; + btnShowHistroyData_Month.IsSelected = false; + btnShowHistroyData_Week.IsSelected = true; + curQueryType = "month"; + d2(); + }; + #endregion var historyDataView = new FrameLayout() @@ -222,134 +257,105 @@ historyDataView.AddChidren(myEchartsView); } - /// <summary> - /// 璇诲彇浼犳劅鍣ㄥ巻鍙叉暟鎹� - /// </summary> - void ddd2(string curQueryType,Function function,int index) + + void d2() + { + int index = 0; + var echartRootJson = new EchartsOption_Energy(); + var seriesList = new List<EchartSeriesItem>(); + foreach (var function in queryList) { - var seriesList = new List<EchartSeriesItem>(); - var loadPage = new Loading() - { - LodingBackgroundColor = 0x88888888, - }; - historyDataView.AddChidren(loadPage); + var seriesItem = d3(function, index, echartRootJson.xAxis.data); + seriesList.Add(seriesItem); + } + } + /// <summary> + /// 鏌ヨ鍒楄〃 + /// </summary> + /// <summary> + /// 璇诲彇浼犳劅鍣ㄥ巻鍙叉暟鎹� + /// </summary> + EchartSeriesItem d3(Function function, int index, List<string> xAxisData) + { + EchartSeriesItem sItem = null; + List<string> data = new List<string>(); + var loadPage = new Loading() + { + LodingBackgroundColor = 0x88888888, + }; + diagramView.AddChidren(loadPage); - new System.Threading.Thread(() => + try + { + Application.RunOnMainThread(() => { - try + loadPage.Start(Language.StringByID(StringId.PleaseWait)); + }); + var sensorType = function.spk.Split(".")[1]; + var revertObj = new HttpServerRequest().GetSensorHistory(curQueryType, function.deviceId, sensorType); + + if (revertObj != null) + { + if (revertObj.Code == StateCode.SUCCESS) { - Application.RunOnMainThread(() => - { - loadPage.Start(Language.StringByID(StringId.PleaseWait)); - }); - int i = 0; + var revertData = Newtonsoft.Json.JsonConvert.DeserializeObject<List<EnvironmentalSensorHistor>>(revertObj.Data.ToString()); + sItem = new EchartSeriesItem { - var sensorType = function.spk.Split(".")[0]; - var revertObj = new HttpServerRequest().GetSensorHistory(curQueryType, function.deviceId, sensorType); - - if (revertObj != null) + data = new List<int>(), + lineStyle = new EchartLineStyle() { - if (revertObj.Code == StateCode.SUCCESS) - { - var revertData = Newtonsoft.Json.JsonConvert.DeserializeObject<List<EnvironmentalSensorHistor>>(revertObj.Data.ToString()); - - var sItem = new EchartSeriesItem - { - data = new List<int>(), - lineStyle = new EchartLineStyle() - { - color = colorList2[i], + color = colorList2[index], #if __IOS__ - width = 5, + width = 5, #elif __ANDROID__ width = 2, #endif - }, - }; + }, + }; - foreach (var d in revertData) - { - echartRootJson.xAxis.data.Add(d.fieldName); - echartRootJson.yAxis.data.Add(d.fieldValue); - } - seriesList.Add(sItem); - } - else + try + { + foreach (var d in revertData) + { + if (xAxisData.Count == 0) { - Application.RunOnMainThread(() => - { - IMessageCommon.Current.ShowErrorInfoAlter("", true, 2, Language.StringByID(StringId.GetSensorHistoryFailed), false); - }); + data.Add(d.fieldName); } + sItem.data.Add(Convert.ToInt32(d.fieldValue)); } - i++; + xAxisData.AddRange(data); } - + catch (Exception ex) + { + MainPage.Log($"revertData:{ex.Message}"); + } } - catch (Exception ex) - { - MainPage.Log($"sensor history error : {ex.Message}"); - } - finally + else { Application.RunOnMainThread(() => { - loadPage.Hide(); + IMessageCommon.Current.ShowErrorInfoAlter("", true, 2, Language.StringByID(StringId.GetSensorHistoryFailed), false); }); } - }) - { IsBackground = true }.Start(); - EchartsOption echartRootJson = new EchartsOption(); - echartRootJson.series = seriesList; - - -#if __IOS__ - echartRootJson.xAxis.axisLabel.fontSize = 22; - echartRootJson.yAxis.axisLabel.fontSize = 22; -#else - echartRootJson.xAxis.axisLabel.fontSize = 8; - echartRootJson.yAxis.axisLabel.fontSize = 8; -#endif - var echartRootJsonString = Newtonsoft.Json.JsonConvert.SerializeObject(echartRootJson); - myEchartsView.ShowWithOptionJsonString(echartRootJsonString); - + } } - - var curQueryType = ""; - - void LoadEvent_ChangeSensorHistoryShowType() + catch (Exception ex) { - btnShowHistroyData_Day.MouseUpEventHandler = (sender, e) => - { - showDataTypeView.BackgroundImagePath = "FunctionIcon/EnvironmentalScience/SensorHistoryBg1.png"; - btnShowHistroyData_Day.IsSelected = true; - btnShowHistroyData_Month.IsSelected = false; - btnShowHistroyData_Week.IsSelected = false; - curQueryType = "hour"; - LoadMothed_GetSensorHistoryData(); - }; - - btnShowHistroyData_Month.MouseUpEventHandler = (sender, e) => - { - showDataTypeView.BackgroundImagePath = "FunctionIcon/EnvironmentalScience/SensorHistoryBg3.png"; - btnShowHistroyData_Day.IsSelected = false; - btnShowHistroyData_Month.IsSelected = true; - btnShowHistroyData_Week.IsSelected = false; - curQueryType = "week"; - LoadMothed_GetSensorHistoryData(); - }; - btnShowHistroyData_Week.MouseUpEventHandler = (sender, e) => - { - showDataTypeView.BackgroundImagePath = "FunctionIcon/EnvironmentalScience/SensorHistoryBg2.png"; - btnShowHistroyData_Day.IsSelected = false; - btnShowHistroyData_Month.IsSelected = false; - btnShowHistroyData_Week.IsSelected = true; - curQueryType = "month"; - LoadMothed_GetSensorHistoryData(); - }; - + MainPage.Log($"sensor history error : {ex.Message}"); } + finally + { + Application.RunOnMainThread(() => + { + loadPage.Hide(); + }); + } + return sItem; + + //var echartRootJsonString = Newtonsoft.Json.JsonConvert.SerializeObject(echartRootJson); + //myEchartsView.ShowWithOptionJsonString(echartRootJsonString); + } /// <summary> @@ -475,4 +481,4 @@ } } -} +} \ No newline at end of file -- Gitblit v1.8.0