From bbd6b592a6b883e013ff1e0a574976ceba5009ea Mon Sep 17 00:00:00 2001
From: wxr <464027401@qq.com>
Date: 星期四, 27 十月 2022 09:11:33 +0800
Subject: [PATCH] Merge branch 'dev--wxr'

---
 HDL_ON/UI/UI2/FuntionControlView/Acst/AcstSubHistoryPage.cs |  417 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 417 insertions(+), 0 deletions(-)

diff --git a/HDL_ON/UI/UI2/FuntionControlView/Acst/AcstSubHistoryPage.cs b/HDL_ON/UI/UI2/FuntionControlView/Acst/AcstSubHistoryPage.cs
new file mode 100644
index 0000000..eb0b3db
--- /dev/null
+++ b/HDL_ON/UI/UI2/FuntionControlView/Acst/AcstSubHistoryPage.cs
@@ -0,0 +1,417 @@
+锘縰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 AcstSubHistoryPage :FrameLayout
+    {
+
+        AcstSubHistoryPage bodyView;
+
+        FrameLayout showDataTypeView;
+        Button btnShowHistroyData_Day;
+        Button btnShowHistroyData_Week;
+        Button btnShowHistroyData_Month;
+
+        /// <summary>
+        /// echart瀹瑰櫒
+        /// </summary>
+        MyEchartsViewOn tempEchartsView;
+        /// <summary>
+        /// echart缁樺埗鏁版嵁
+        /// </summary>
+        EchartsOption_BrokenLine tempEchartOption;
+        Button btnTempTipText;
+
+        MyEchartsViewOn humiEchartsView;
+        EchartsOption_BrokenLine humiEchartsOption;
+        Button btnHumiTipText;
+
+
+        string curQueryType = "hour";
+        string queryTime;
+        Function function;
+        public AcstSubHistoryPage(Function temp)
+        {
+            function = temp;
+            bodyView = this;
+        }
+
+
+        /// <summary>
+        /// 
+        /// </summary>
+        public void LoadPage()
+        {
+            new TopViewDiv(bodyView, function.GetRoomListName()).LoadTopView();
+            bodyView.BackgroundColor = CSS_Color.BackgroundColor;
+
+            //var contentView = new FrameLayout()
+            //{
+            //    Y = Application.GetRealHeight(64),
+            //    Height = Application.GetRealHeight(603),
+            //};
+            //bodyView.AddChidren(contentView);
+
+
+
+            #region 閫夋嫨鏁版嵁鏃ユ湡鑼冨洿
+
+            showDataTypeView = new FrameLayout()
+            {
+                X = Application.GetRealWidth(199),
+                Y = Application.GetRealHeight(83),
+                Width = Application.GetRealWidth(144),
+                Height = Application.GetRealHeight(24),
+                BackgroundImagePath = "FunctionIcon/EnvironmentalScience/SensorHistoryBg1.png",
+            };
+            bodyView.AddChidren(showDataTypeView);
+
+            btnShowHistroyData_Day = new Button()
+            {
+                Width = Application.GetRealWidth(48),
+                TextAlignment = TextAlignment.Center,
+                TextColor = CSS_Color.PromptingColor2,
+                SelectedTextColor = CSS_Color.MainColor,
+                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
+                IsSelected = true,
+                TextID = StringId.day,
+            };
+            showDataTypeView.AddChidren(btnShowHistroyData_Day);
+
+            btnShowHistroyData_Week = new Button()
+            {
+                X = Application.GetRealWidth(48),
+                Width = Application.GetRealWidth(48),
+                TextAlignment = TextAlignment.Center,
+                TextColor = CSS_Color.PromptingColor2,
+                SelectedTextColor = CSS_Color.MainColor,
+                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
+                TextID = StringId.week,
+            };
+            showDataTypeView.AddChidren(btnShowHistroyData_Week);
+
+            btnShowHistroyData_Month = new Button()
+            {
+                X = Application.GetRealWidth(48 * 2),
+                Width = Application.GetRealWidth(48),
+                TextAlignment = TextAlignment.Center,
+                TextColor = CSS_Color.PromptingColor2,
+                SelectedTextColor = CSS_Color.MainColor,
+                TextSize = CSS_FontSize.PromptFontSize_FirstLevel,
+                Text = Language.StringByID(StringId.month),//DateTime.Now.Month.ToString() + 
+            };
+            showDataTypeView.AddChidren(btnShowHistroyData_Month);
+            #endregion
+
+            #region 娓╁害鍘嗗彶鏁版嵁
+            var tempHistoryDataView = new FrameLayout()
+            {
+                Gravity = Gravity.CenterHorizontal,
+                Y = Application.GetRealHeight(123),
+                Height = Application.GetRealHeight(256),
+                Width = Application.GetRealWidth(343),
+                BackgroundColor = CSS_Color.MainBackgroundColor,
+                Radius = (uint)Application.GetRealWidth(6),
+            };
+            bodyView.AddChidren(tempHistoryDataView);
+
+
+            tempEchartsView = new MyEchartsViewOn()
+            {
+                Y = Application.GetRealWidth(10),
+                Height = Application.GetRealHeight(207),
+            };
+            tempHistoryDataView.AddChidren(tempEchartsView);
+
+            tempEchartOption = new EchartsOption_BrokenLine();
+
+            btnTempTipText = new Button()
+            {
+                Y = Application.GetRealHeight(222),
+                Height = Application.GetRealHeight(34),
+                Text = "鏈�杩�24灏忔椂鐨勫钩鍧囧鍐呮俯搴�",
+                TextSize = 10,
+                TextColor = 0xFF798394,
+                TextAlignment = TextAlignment.Center,
+            };
+            tempHistoryDataView.AddChidren(btnTempTipText);
+            #endregion
+
+
+            #region 婀垮害鍘嗗彶鏁版嵁
+            var humiHistoryDataView = new FrameLayout()
+            {
+                Gravity = Gravity.CenterHorizontal,
+                Y = tempHistoryDataView.Bottom + Application.GetRealWidth(10),
+                Height = Application.GetRealHeight(256),
+                Width = Application.GetRealWidth(343),
+                BackgroundColor = CSS_Color.MainBackgroundColor,
+                Radius = (uint)Application.GetRealWidth(6),
+            };
+            bodyView.AddChidren(humiHistoryDataView);
+
+
+            humiEchartsView = new MyEchartsViewOn()
+            {
+                Y = Application.GetRealWidth(10),
+                Height = Application.GetRealHeight(207),
+            };
+            humiHistoryDataView.AddChidren(humiEchartsView);
+
+            humiEchartsOption = new EchartsOption_BrokenLine();
+
+            btnHumiTipText = new Button()
+            {
+                Y = Application.GetRealHeight(222),
+                Height = Application.GetRealHeight(34),
+                Text = "鏈�杩�24灏忔椂鐨勫钩鍧囧鍐呮箍搴�",
+                TextSize = 10,
+                TextColor = 0xFF798394,
+                TextAlignment = TextAlignment.Center,
+            };
+            humiHistoryDataView.AddChidren(btnHumiTipText);
+            #endregion
+
+#if DEBUG
+
+            //List<string> vs = new List<string>() {
+            //            "1","2","3","4","5","6","7","8","9","10","11","12","13","14"
+            //        };
+            //tempEchartOption.InitXdataText(vs);
+            //tempEchartOption.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");
+            //tempEchartOption.yTitle = "娓╁害 (掳)";
+            //tempEchartOption.xTitle = "";
+            //var opString = tempEchartOption.InitOption();
+            //tempEchartsView.ShowWithOption(opString);
+
+
+
+
+            //List<string> vs2 = new List<string>() {
+            //            "1","2","3","4","5","6","7","8","9","10","11","12","13","14"
+            //        };
+            //humiEchartsOption.InitXdataText(vs2);
+            //humiEchartsOption.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");
+            //humiEchartsOption.yTitle = "婀垮害 (%)";
+            //humiEchartsOption.xTitle = "";
+            //var opString2 = humiEchartsOption.InitOption();
+
+            //humiEchartsView.ShowWithOption(opString2);
+
+#endif
+
+            LoadEvent_ChangeSensorHistoryShowType();
+            LoadMothed_GetHistoryData();
+        }
+
+
+        void LoadEvent_ChangeSensorHistoryShowType()
+        {
+            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";
+                tempEchartOption.YvalueText = "";
+                humiEchartsOption.YvalueText = "";
+                LoadMothed_GetHistoryData();
+            };
+
+            btnShowHistroyData_Month.MouseUpEventHandler = (sender, e) =>
+            {
+                showDataTypeView.BackgroundImagePath = "FunctionIcon/EnvironmentalScience/SensorHistoryBg3.png";
+                btnShowHistroyData_Day.IsSelected = false;
+                btnShowHistroyData_Month.IsSelected = true;
+                btnShowHistroyData_Week.IsSelected = false;
+                curQueryType = "month";
+                tempEchartOption.YvalueText = "";
+                humiEchartsOption.YvalueText = "";
+                LoadMothed_GetHistoryData();
+            };
+            btnShowHistroyData_Week.MouseUpEventHandler = (sender, e) =>
+            {
+                showDataTypeView.BackgroundImagePath = "FunctionIcon/EnvironmentalScience/SensorHistoryBg2.png";
+                btnShowHistroyData_Day.IsSelected = false;
+                btnShowHistroyData_Month.IsSelected = false;
+                btnShowHistroyData_Week.IsSelected = true;
+                curQueryType = "week";
+                tempEchartOption.YvalueText = "";
+                humiEchartsOption.YvalueText = "";
+                LoadMothed_GetHistoryData();
+            };
+
+        }
+        /// <summary>
+        /// 姝e湪璇诲彇娓╁害鍘嗗彶鏁版嵁
+        /// </summary>
+        bool inReadTempHistory = false;
+        /// <summary>
+        /// 姝e湪璇诲彇婀垮害鍘嗗彶鏁版嵁
+        /// </summary>
+        bool inReadHumiHistory = false;
+
+
+        /// <summary>
+        /// 璇诲彇鍘嗗彶鏁版嵁
+        /// </summary>
+        void LoadMothed_GetHistoryData()
+        {
+            inReadTempHistory = true;
+            inReadHumiHistory = true;
+
+            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(curQueryType, function.deviceId , "room_temp");
+                    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 (tempEchartOption.YvalueText == "")
+                            {
+                                foreach (var data in revertData)
+                                {
+                                    vs.Add(data.fieldName);
+                                }
+                                tempEchartOption.InitXdataText(vs);
+                            }
+                            tempEchartOption.InitYdataText("", revertData, "#FF80AEFF");
+
+                            tempEchartOption.xTitle = Language.StringByID(StringId.timeMode);
+                            var opString = tempEchartOption.InitOption();
+
+                            Application.RunOnMainThread(() =>
+                            {
+                                tempEchartsView.ShowWithOption(opString);
+                            });
+                        }
+                    }
+                }
+                catch (Exception ex)
+                {
+                    MainPage.Log($"history error : {ex.Message}");
+                }
+                finally
+                {
+                    inReadTempHistory = false;
+                    if (!inReadHumiHistory)
+                    {
+                        Application.RunOnMainThread(() =>
+                        {
+                            loadPage.Hide();
+                        });
+                    }
+                }
+            })
+            { IsBackground = true }.Start();
+
+
+            new System.Threading.Thread(() =>
+            {
+                try
+                {
+                    Application.RunOnMainThread(() =>
+                    {
+                        loadPage.Start(Language.StringByID(StringId.PleaseWait));
+                    });
+
+                    var revertObj = new HttpServerRequest().GetSensorHistory(curQueryType,function.deviceId, "room_humidity");
+                    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 (humiEchartsOption.YvalueText == "")
+                            {
+                                foreach (var data in revertData)
+                                {
+                                    vs.Add(data.fieldName);
+                                }
+                                humiEchartsOption.InitXdataText(vs);
+                            }
+                            humiEchartsOption.InitYdataText("", revertData, "#FF80AEFF");
+                        }
+                    }
+                    humiEchartsOption.xTitle = Language.StringByID(StringId.timeMode);
+                    var opString = humiEchartsOption.InitOption();
+
+                    Application.RunOnMainThread(() =>
+                    {
+                        humiEchartsView.ShowWithOption(opString);
+                    });
+                }
+                catch (Exception ex)
+                {
+                    MainPage.Log($"history error : {ex.Message}");
+                }
+                finally
+                {
+                    inReadHumiHistory = false;
+                    if (!inReadTempHistory)
+                    {
+                        Application.RunOnMainThread(() =>
+                        {
+                            loadPage.Hide();
+                        });
+                    }
+                }
+            })
+            { IsBackground = true }.Start();
+        }
+
+    }
+}

--
Gitblit v1.8.0