From 4c586bb23cdcae56ae4e4c62e90e148dc10b9d90 Mon Sep 17 00:00:00 2001 From: wxr <464027401@qq.com> Date: 星期二, 17 五月 2022 14:19:31 +0800 Subject: [PATCH] Merge branch 'Dev-Branch' into wxr1215 --- HDL_ON/UI/UI2/FuntionControlView/1ContorlPage/CacDayHistoryPage.cs | 199 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 files changed, 199 insertions(+), 0 deletions(-) diff --git a/HDL_ON/UI/UI2/FuntionControlView/1ContorlPage/CacDayHistoryPage.cs b/HDL_ON/UI/UI2/FuntionControlView/1ContorlPage/CacDayHistoryPage.cs new file mode 100644 index 0000000..4553294 --- /dev/null +++ b/HDL_ON/UI/UI2/FuntionControlView/1ContorlPage/CacDayHistoryPage.cs @@ -0,0 +1,199 @@ +锘縰sing 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 CacDayHistoryPage : FrameLayout + { + CacDayHistoryPage bodyView; + EchartsOption_BrokenLine brokenLine; + MyEchartsViewOn myEchartsView_Line; + string curQueryType = "hour"; + string queryTime; + string functionId; + string time; + public CacDayHistoryPage(string functionId,string queryType, string time) + { + this.time = time; + this.functionId = functionId; + curQueryType = queryType; + bodyView = this; + queryTime = time; + } + + + /// <summary> + /// + /// </summary> + public void InitView() + { + new TopViewDiv(bodyView, Language.StringByID(StringId.StatisticalChart24Hour)).LoadTopView(); + bodyView.BackgroundColor = CSS_Color.BackgroundColor; + + var contentView = new FrameLayout() + { + Y = Application.GetRealHeight(64), + Height = Application.GetRealHeight(603), + }; + bodyView.AddChidren(contentView); + + var btnTitle = new Button() + { + Height = Application.GetRealHeight(60), + TextAlignment = TextAlignment.Center, + TextSize = CSS_FontSize.SubheadingFontSize, + TextColor = CSS_Color.FirstLevelTitleColor, + }; + if(curQueryType == "room_temp") + { + btnTitle.Text = queryTime + "瀹ゅ唴娓╁害鍘嗗彶鏁版嵁"; + } + else + { + btnTitle.Text = queryTime + "瀹ゅ唴婀垮害鍘嗗彶鏁版嵁"; + } + contentView.AddChidren(btnTitle); + + + var historyDataView = new FrameLayout() + { + Gravity = Gravity.CenterHorizontal, + Y = Application.GetRealWidth(52), + Height = Application.GetRealWidth(350), + }; + contentView.AddChidren(historyDataView); + + + brokenLine = new EchartsOption_BrokenLine(); + + myEchartsView_Line = new MyEchartsViewOn() + { + Y = Application.GetRealWidth(10), + Height = Application.GetRealWidth(338), + }; + historyDataView.AddChidren(myEchartsView_Line); + + +#if DEBUG + + //List<string> vs = new List<string>() { + // "1","2","3","4","5","6","7","8","9","10","11","12","13","14" + // }; + //brokenLine.InitXdataText(vs); + //brokenLine.InitYdataText("yData", new List<EnvironmentalSensorHistor>() { + // 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" } + //}, "#FF9D54"); + //brokenLine.yTitle = "(鈩�)"; + //brokenLine.xTitle = ""; + ////if (curQueryType != "hour") + ////{ + //// brokenLine.xTitle = Language.StringByID(StringId.Date); + ////} + //var opString = brokenLine.InitOption(); + + // myEchartsView_Line.ShowWithOption(opString); + +#endif + LoadMothed_GetHistoryData(); + } + + /// <summary> + /// 璇诲彇鍘嗗彶鏁版嵁 + /// </summary> + void LoadMothed_GetHistoryData() + { + + var loadPage = new Loading() + { + LodingBackgroundColor = 0x88888888, + }; + bodyView.AddChidren(loadPage); + + new System.Threading.Thread(() => + { + try + { + Application.RunOnMainThread(() => + { + loadPage.Start(Language.StringByID(StringId.PleaseWait)); + }); + + var revertObj = new HttpServerRequest().GetSensorHistory("day_hour", functionId, curQueryType,time); + if (revertObj != null) + { + if (revertObj.Code == StateCode.SUCCESS) + { + var revertData = Newtonsoft.Json.JsonConvert.DeserializeObject<List<EnvironmentalSensorHistor>>(revertObj.Data.ToString()); + + List<string> vs = new List<string>(); + if (brokenLine.YvalueText == "") + { + foreach (var data in revertData) + { + vs.Add(data.fieldName); + } + brokenLine.InitXdataText(vs); + } + //if (sr.GetAttribute("ydata") == null) + //{ + // sr.attributes.Add(new FunctionAttributes() { key = "ydata" }); + //} + //sr.SetAttrState("ydata", + brokenLine.InitYdataText("", revertData, "#FF9D54");// + ","); + } + } + brokenLine.yTitle = Language.StringByID(StringId.Uint); + if(curQueryType == "room_temp") + { + brokenLine.yTitle += ":掳C"; + } + else + { + brokenLine.yTitle += ":%"; + } + brokenLine.xTitle = Language.StringByID(StringId.timeMode); + //if (curQueryType != "hour") + //{ + // brokenLine.xTitle = Language.StringByID(StringId.Date); + //} + var opString = brokenLine.InitOption(); + + Application.RunOnMainThread(() => + { + myEchartsView_Line.ShowWithOption(opString); + }); + } + catch (Exception ex) + { + MainPage.Log($"sensor history error : {ex.Message}"); + } + finally + { + Application.RunOnMainThread(() => + { + loadPage.Hide(); + }); + } + }) + { IsBackground = true }.Start(); + } + + } +} -- Gitblit v1.8.0