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 partial class SensorMegahealth_AlarmDataStatisticsPage : FrameLayout
|
{
|
|
SensorMegahealth_AlarmDataStatisticsPage bodyView;
|
|
FrameLayout showDataTypeView;
|
Button btnShowHistroyData_Day;
|
Button btnShowHistroyData_Week;
|
Button btnShowHistroyData_Month;
|
|
FrameLayout historyDataView;
|
|
MyEchartsViewOn myEchartsView;
|
|
Sensor sensorTemp = new Sensor();
|
|
Function function;
|
List<Function> showFunctions;
|
List<Function> sensorList;
|
/// <summary>
|
/// 当前查询类型
|
/// </summary>
|
string curQueryType = "hour";
|
|
List<string> tipColorStringList = new List<string>()
|
{
|
"#80AEFF","#FFD154","#FF9D54","#FE6A6A","#B183C3","#ADE764",
|
};
|
|
public SensorMegahealth_AlarmDataStatisticsPage(Function ss)
|
{
|
bodyView = this;
|
function = ss;
|
showFunctions = new List<Function>();
|
showFunctions.Add(ss);
|
sensorList = FunctionList.List.GetEnvirSensorsList();
|
}
|
|
public void LoadPage()
|
{
|
bodyView.BackgroundColor = CSS_Color.BackgroundColor;
|
|
VerticalScrolViewLayout contentView = new VerticalScrolViewLayout()
|
{
|
Y = Application.GetRealHeight(64),
|
Height = Application.GetRealHeight(600),
|
ScrollEnabled = false
|
};
|
bodyView.AddChidren(contentView);
|
|
contentView.AddChidren(new Button() { Height = Application.GetRealHeight(16) });
|
|
FrameLayout diagramView = new FrameLayout()
|
{
|
Gravity = Gravity.CenterHorizontal,
|
Width = Application.GetRealWidth(343),
|
Height = Application.GetRealWidth(450),
|
BackgroundColor = CSS_Color.MainBackgroundColor,
|
Radius = (uint)Application.GetRealWidth(12),
|
BorderColor = 0x00000000,
|
BorderWidth = 0,
|
};
|
contentView.AddChidren(diagramView);
|
|
#region 选择数据日期范围
|
showDataTypeView = new FrameLayout()
|
{
|
X = Application.GetRealWidth(183),
|
Y = Application.GetRealHeight(12),
|
Width = Application.GetRealWidth(144),
|
Height = Application.GetRealHeight(24),
|
BackgroundImagePath = "FunctionIcon/EnvironmentalScience/SensorHistoryBg1.png",
|
};
|
diagramView.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
|
|
historyDataView = new FrameLayout()
|
{
|
Gravity = Gravity.CenterHorizontal,
|
Y = Application.GetRealHeight(52),
|
Width = Application.GetRealWidth(343 - 22),
|
Height = Application.GetRealWidth(370),
|
};
|
diagramView.AddChidren(historyDataView);
|
|
myEchartsView = new MyEchartsViewOn();
|
|
historyDataView.AddChidren(myEchartsView);
|
|
|
contentView.AddChidren(new Button() { Height = Application.GetRealHeight(12) });
|
|
|
new TopViewDiv(bodyView, Language.StringByID(StringId.AlarmDataStatistics)).LoadTopView();
|
|
LoadMothed_GetSensorHistoryData();
|
LoadEvent_ChangeSensorHistoryShowType();
|
}
|
}
|
|
|
//------------
|
public partial class SensorMegahealth_AlarmDataStatisticsPage
|
{
|
/// <summary>
|
/// 读取传感器历史数据
|
/// </summary>
|
void LoadMothed_GetSensorHistoryData()
|
{
|
var loadPage = new Loading()
|
{
|
LodingBackgroundColor = 0x88888888,
|
};
|
historyDataView.AddChidren(loadPage);
|
|
new System.Threading.Thread(() =>
|
{
|
try
|
{
|
Application.RunOnMainThread(() => {
|
loadPage.Start(Language.StringByID(StringId.PleaseWait));
|
});
|
int i = 0;
|
|
var ebl = new EchartsOption_BrokenLine();
|
|
string yDataString = "";
|
|
foreach (var sr in showFunctions)
|
{
|
if (sr.spk != function.spk)
|
{
|
continue;
|
}
|
if (showFunctions.Find((obj) => obj.sid == sr.sid) == null)
|
{
|
i++;
|
continue;
|
}
|
|
var sensorType = sr.spk.Split(".")[1];
|
var queryType = sr.GetAttrState("spk").ToString();
|
if (queryType == "0")
|
{
|
queryType = "value";
|
}
|
|
var revertObj = new HttpServerRequest().GetSensorHistory(curQueryType, sr.deviceId, "target_status");
|
if (revertObj != null)
|
{
|
if (revertObj.Code == StateCode.SUCCESS)
|
{
|
var revertData = Newtonsoft.Json.JsonConvert.DeserializeObject<List<EnvironmentalSensorHistor>>(revertObj.Data.ToString());
|
|
if (i == 0)
|
{
|
List<string> vs = new List<string>();
|
foreach (var data in revertData)
|
{
|
vs.Add(data.fieldName);
|
}
|
ebl.InitXdataText(vs);
|
}
|
yDataString += ebl.InitYdataText(sr.name, revertData, tipColorStringList[i]);
|
}
|
}
|
i++;
|
}
|
|
|
Application.RunOnMainThread(() =>
|
{
|
myEchartsView.ShowWithOption(ebl.InitOption());
|
});
|
|
}
|
catch (Exception ex)
|
{
|
MainPage.Log($"sensor history error : {ex.Message}");
|
}
|
finally
|
{
|
Application.RunOnMainThread(() => {
|
loadPage.Hide();
|
});
|
}
|
})
|
{ IsBackground = true }.Start();
|
}
|
|
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";
|
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 = "month";
|
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 = "week";
|
LoadMothed_GetSensorHistoryData();
|
};
|
|
}
|
|
|
}
|
}
|