Browse Source

取得學校IOT統計資料 追加統計起始日、統計結束日欄位

jeff 1 year ago
parent
commit
0fbe68cb73

+ 4 - 0
TEAMModelOS.SDK/Models/Cosmos/School/IotStatistics.cs

@@ -47,11 +47,15 @@ namespace TEAMModelOS.SDK.Models.Cosmos.School
     {
         public string schId { get; set; }
         public string schName { get; set; }
+        public string sdate { get; set; }
+        public string edate { get; set; }
         public int htcDevTotalCnt { get; set; } ///設備統計-HiTeach總數 (無視統計期間)
         public int htaDevTotalCnt { get; set; } ///設備統計-HiTA總數 (無視統計期間)
     }
     public class IotStatisticsArea : IotStatisticsBase
     {
+        public string sdate { get; set; }
+        public string edate { get; set; }
         public int htcDevTotalCnt { get; set; } ///設備統計-HiTeach總數 (無視統計期間)
         public int htaDevTotalCnt { get; set; } ///設備統計-HiTA總數 (無視統計期間)
     }

+ 5 - 0
TEAMModelOS/Controllers/School/SchoolController.cs

@@ -12,6 +12,7 @@ using StackExchange.Redis;
 using System;
 using System.Collections.Generic;
 using System.Dynamic;
+using System.Globalization;
 using System.IO;
 using System.Linq;
 using System.Net;
@@ -2294,6 +2295,8 @@ namespace TEAMModelOS.Controllers
                         schIot.Add(school.id, new IotStatisticsSch());
                         schIot[school.id].schId = school.id;
                         schIot[school.id].schName = schName;
+                        schIot[school.id].sdate = $"{dateFromYear}-{dateFromMonth}-{dateFromDay}";
+                        schIot[school.id].edate = $"{dateToYear}-{dateToMonth}-{dateToDay}";
                     }
 
                     //教室數(今年)
@@ -2386,6 +2389,8 @@ namespace TEAMModelOS.Controllers
                     //學校
                     schoolIotResult.Add(schIotData);
                     //學區
+                    areaIot.sdate = (string.IsNullOrWhiteSpace(areaIot.sdate)) ? schIotData.sdate : (DateTime.Parse(schIotData.sdate, CultureInfo.InvariantCulture) < DateTime.Parse(areaIot.sdate, CultureInfo.InvariantCulture)) ? schIotData.sdate : areaIot.sdate;
+                    areaIot.edate = (string.IsNullOrWhiteSpace(areaIot.edate)) ? schIotData.edate : (DateTime.Parse(schIotData.edate, CultureInfo.InvariantCulture) > DateTime.Parse(areaIot.edate, CultureInfo.InvariantCulture)) ? schIotData.edate : areaIot.edate;
                     areaIot.tmidList = areaIot.tmidList.Union(schIotData.tmidList).ToList();
                     areaIot.tmidCnt = areaIot.tmidList.Count;
                     areaIot.stuShow += schIotData.stuShow;