wei
2021-03-03 d4811b7d34b45ff6b21b97f11da128b5572ec526
HDL_ON/UI/UI2/FuntionControlView/EnvironmentalScience/EnvironmentalSensorPage.cs
@@ -27,7 +27,7 @@
        /// <summary>
        /// 当前查询类型
        /// </summary>
        QueryType curQueryType = QueryType.NowDay;
        string curQueryType = "hour";
        List<uint> tipColorList = new List<uint>()
        {
@@ -163,9 +163,9 @@
            };
            diagramView.AddChidren(tipTextView);
            switch (sensor.functionType)
            switch (sensor.spk)
            {
                case FunctionType.PM25:
                case SPK.SensorPm25:
                    tipValuesView.AddChidren(new Button()
                    {
                        Width = Application.GetRealWidth(101),
@@ -223,7 +223,7 @@
                        TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel,
                    });
                    break;
                //case FunctionType.PM25:
                //case SPK.SensorPm25:
                //_intervalValue.Add("0 ~ 35");
                //_intervalValue.Add("36 ~ 75");
                //_intervalValue.Add("76 ~ 115");
@@ -233,7 +233,7 @@
                //_levelTextList.Add(StringId.MildPollution);
                //_levelTextList.Add(StringId.HeavyPollution);
                //break;
                case FunctionType.CO2:
                case SPK.SensorCO2:
                    tipValuesView.AddChidren(new Button()
                    {
                        Width = Application.GetRealWidth(101),
@@ -291,7 +291,7 @@
                        TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel,
                    });
                    break;
                case FunctionType.Temp:
                case SPK.SensorTemperature:
                    tipValuesView.AddChidren(new Button()
                    {
                        Width = Application.GetRealWidth(50),
@@ -411,7 +411,7 @@
                    //_levelTextList.Add(StringId.);
                    //_levelTextList.Add(StringId.ExtremeHeat);
                    break;
                case FunctionType.TVOC:
                case SPK.SensorTVOC:
                    tipValuesView.AddChidren(new Button()
                    {
                        Width = Application.GetRealWidth(101),
@@ -469,7 +469,7 @@
                        TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel,
                    });
                    break;
                case FunctionType.Humidity:
                case SPK.SensorHumidity:
                    tipValuesView.AddChidren(new Button()
                    {
                        Width = Application.GetRealWidth(151),
@@ -648,7 +648,7 @@
                {
                    continue;
                }
                if (tempSensor.functionType != sensor.functionType)
                if (tempSensor.spk != sensor.spk)
                {
                    continue;
                }
@@ -801,14 +801,6 @@
    //------------
    public partial class EnvironmentalSensorPage
    {
       public  enum QueryType
        {
            NowDay = 0,//当天
            NowMonth = 1,//指定月
            NowYear = 2,//今年
            LatelySevenDay = 3//最近七天
        }
        /// <summary>
        /// 读取传感器历史数据
        /// </summary>
@@ -828,74 +820,13 @@
                try
                {
                    Application.RunOnMainThread(() => {
                        loadPage.Start("Loading...");
                        loadPage.Start(Language.StringByID(StringId.PleaseWait));
                    });
                    var curMonth = 0;
                    if(curQueryType == QueryType.NowMonth)
                    {
                        curMonth = DateTime.Now.Month;
                    }
                    int i = 0;
//#if DEBUG
//                    var sItem = new EchartSeriesItem
//                    {
//                        name = sensor.GetRoomListName(),
//                        data = new List<int>(),
//                        lineStyle = new EchartLineStyle()
//                        {
//                            color = tipColorStringList[i],
//#if __IOS__
//                            width = 5,
//#elif __ANDROID__
//                                        width = 2,
//#endif
//                        },
//                    };
//                    Random random = new Random();
//                    double level = 0.0;
//                    int countddd = 24;
//                    for (int j = 0; j < countddd; j++)
//                    {
//                        switch (sensor.functionType)
//                        {
//                            case FunctionType.PM25:
//                                level = Math.Round(random.NextDouble() * 130, 0);
//                                break;
//                            case FunctionType.CO2:
//                                level = Math.Round(random.NextDouble() * 6000, 0);
//                                break;
//                            case FunctionType.Temp:
//                                level = Math.Round(random.NextDouble() * 40, 0);
//                                break;
//                            case FunctionType.TVOC:
//                                level = Math.Round(random.NextDouble() * 10, 1);
//                                break;
//                            case FunctionType.Humidity:
//                                level = Math.Round(random.NextDouble() * 100, 0);
//                                break;
//                        }
//                        sItem.data.Add((int)level);
//                    }
//                        seriesList.Add(sItem);
//                    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
//                    echartRootJsonString = Newtonsoft.Json.JsonConvert.SerializeObject(echartRootJson);
//                    Application.RunOnMainThread(() =>
//                    {
//                        myEchartsView.ShowWithOptionJsonString(echartRootJsonString);
//                    });
//#endif
                    foreach (var sr in FunctionList.List.sensorsEnvironmentalScience)
                    {
                        if (sr.functionType != sensor.functionType)
                        if (sr.spk != sensor.spk)
                        {
                            continue;
                        }
@@ -904,15 +835,15 @@
                            i++;
                            continue;
                        }
                        var revertObj = new HttpServerRequest().GetSensorHistory(sr.bus_Data.SubnetID, sr.bus_Data.DeviceID,
                               5, (int)(sr.functionType) % 256, (int)curQueryType, sr.bus_Data.loopId, curMonth,
                               DB_ResidenceData.residenceData.residenceGatewayMAC);
                        var sensorType = sr.spk.Split(".")[0];
                        var revertObj = new HttpServerRequest().GetSensorHistory(curQueryType, sr.deviceId,sensorType);
                        if (revertObj != null)
                        {
                            if (revertObj.StateCode == StateCode.SUCCESS)
                            if (revertObj.Code == StateCode.SUCCESS)
                            {
                                var revertData = Newtonsoft.Json.JsonConvert.DeserializeObject<List<SensorPushHistoryRes>>(revertObj.ResponseData.ToString());
                                var revertData = Newtonsoft.Json.JsonConvert.DeserializeObject<List<EnvironmentalSensorHistor>>(revertObj.Data.ToString());
                                var sItem = new EchartSeriesItem
                                {
@@ -929,34 +860,10 @@
                                    },
                                };
                                int ass = 0;
                                for (int j = 0; j < revertData.Count; j++)
                                foreach (var d in revertData)
                                {
                                    if (curQueryType == QueryType.NowMonth && revertData[j].CreatedOnUtc.Day > DateTime.Now.Day)
                                    {
                                        continue;
                                    }
                                    if (revertData[j].TargetValue.ToString() != "NaN")
                                    {
                                        ass = Convert.ToInt32(revertData[j].TargetValue);
                                    }
                                    else
                                    {
                                        ass = 0;
                                    }
                                    sItem.data.Add(ass);
                                    switch (curQueryType)
                                    {
                                        case QueryType.NowDay:
                                            echartRootJson.xAxis.data.Add(revertData[j].CreatedOnUtc.Hour.ToString());
                                            break;
                                        case QueryType.LatelySevenDay:
                                            echartRootJson.xAxis.data.Add(System.Globalization.CultureInfo.CurrentCulture.DateTimeFormat.GetDayName(revertData[j].CreatedOnUtc.DayOfWeek));
                                            break;
                                        case QueryType.NowMonth:
                                            echartRootJson.xAxis.data.Add(revertData[j].CreatedOnUtc.Day.ToString());
                                            break;
                                    }
                                    echartRootJson.xAxis.data.Add(d.fieldName);
                                    echartRootJson.yAxis.data.Add(d.fieldValue);
                                }
                                seriesList.Add(sItem);
                            }
@@ -1010,7 +917,7 @@
                btnShowHistroyData_Day.IsSelected = true;
                btnShowHistroyData_Month.IsSelected = false;
                btnShowHistroyData_Week.IsSelected = false;
                curQueryType = QueryType.NowDay;
                curQueryType = "hour";
                LoadMothed_GetSensorHistoryData();
            };
@@ -1020,7 +927,7 @@
                btnShowHistroyData_Day.IsSelected = false;
                btnShowHistroyData_Month.IsSelected = true;
                btnShowHistroyData_Week.IsSelected = false;
                curQueryType = QueryType.NowMonth;
                curQueryType = "week";
                LoadMothed_GetSensorHistoryData();
            };
            btnShowHistroyData_Week.MouseUpEventHandler = (sender, e) =>
@@ -1029,7 +936,7 @@
                btnShowHistroyData_Day.IsSelected = false;
                btnShowHistroyData_Month.IsSelected = false;
                btnShowHistroyData_Week.IsSelected = true;
                curQueryType = QueryType.LatelySevenDay;
                curQueryType = "month";
                LoadMothed_GetSensorHistoryData();
            };
@@ -1041,17 +948,14 @@
        }
    }
    public class SensorPushHistoryRes
    public class EnvironmentalSensorHistor
    {
        /// <summary>
        /// </summary>
        public string fieldName { get; set; }
        /// <summary>
        /// 实际目标值
        /// </summary>
        public float TargetValue { get; set; }
        /// <summary>
        /// 查询的时间集群
        /// </summary>
        public DateTime CreatedOnUtc { get; set; }
        public string fieldValue { get; set; }
    }
}