diff --git a/FrontendWebApi/Models/HistoryClass.cs b/FrontendWebApi/Models/HistoryClass.cs index 4a94438..46dbd4f 100644 --- a/FrontendWebApi/Models/HistoryClass.cs +++ b/FrontendWebApi/Models/HistoryClass.cs @@ -281,7 +281,13 @@ namespace FrontendWebApi.Models } public class HistoryBuildingDevice { - public string building_tag { get; set; } + private string _building_tag; + + public string building_tag + { + get { return _building_tag; } + set { _building_tag = value.Replace("$3", ""); } + } public string building_name { get; set; } public List device_list { get; set; } @@ -360,14 +366,30 @@ namespace FrontendWebApi.Models public class HistoryRawData : DeviceItemInfo { - public string Value { get; set; } + private string _Value; + public string Value + { + get { return _Value; } + set + { + _Value = StringHelper.TruncateDecimal(value); + } + } public string Timestamp { get; set; } } public class HistoryExport { + private string _value; public string deviceName { get; set; } - public string value { get; set; } + public string value + { + get { return _value; } + set + { + _value = StringHelper.TruncateDecimal(value); + } + } public DateTime timestamp { get; set; } public DateTime starttime { get; set; } public DateTime? endtime { get; set; } @@ -376,6 +398,22 @@ namespace FrontendWebApi.Models public string building_tag { get; set; } public string device_number { get; set; } } + public static class StringHelper + { + // 截取小數點後兩位數字 + public static string TruncateDecimal(string input) + { + // 如果是科學記號先做解析,再截取 + if (double.TryParse(input, out double number)) + { + return number.ToString("F2"); + } + else + { + return string.Empty; + } + } + } public class History_Building { @@ -386,11 +424,16 @@ namespace FrontendWebApi.Models public class DeviceNumberPoint { + private string _FullDeviceNumberPoint; public string DeviceNumber { get; set; } public string Point { get; set; } - public string FullDeviceNumberPoint { get; set; } + public string FullDeviceNumberPoint + { + get { return _FullDeviceNumberPoint; } + set { _FullDeviceNumberPoint = value.Replace("$3", ""); } + } } - + public class BuildStation { public string system_value { get; set; }