Переглянути джерело

[BI]IOT統計追加「未上課」統計欄位 2.IOT學校輸出追加學區ID欄位

jeff 2 роки тому
батько
коміт
11d74dc1da

+ 4 - 2
TEAMModelBI/Controllers/BIProductAnalysis/ProductAnalysisController.cs

@@ -88,7 +88,7 @@ namespace TEAMModelBI.Controllers.ProductAnalysis
                 //CosmosDB資料取得
                 ////取得學校基本資訊 => 記入Dictionary
                 Dictionary<string, Dictionary<string, string>> schDic = new();
-                string SqlSch = $"SELECT c.id, c.name, c.code, c.region, c.province, c.city, c.dist FROM c WHERE (c.code = 'Base' OR c.code = 'VirtualBase')";
+                string SqlSch = $"SELECT c.id, c.name, c.code, c.region, c.province, c.city, c.areaId, c.dist FROM c WHERE (c.code = 'Base' OR c.code = 'VirtualBase')";
                 //ARRAY_CONTAINS({schIdListStr}, c.id, true) AND
                 if(schoolIds.Count > 0)
                 {
@@ -106,10 +106,11 @@ namespace TEAMModelBI.Controllers.ProductAnalysis
                         string province = Convert.ToString(obj.GetProperty("province"));
                         string city = Convert.ToString(obj.GetProperty("city"));
                         string dist = (obj.TryGetProperty("dist", out JsonElement distJ)) ? Convert.ToString(distJ) : string.Empty;
+                        string areaId = (obj.TryGetProperty("areaId", out JsonElement areaIdJ)) ? Convert.ToString(areaIdJ) : string.Empty;
                         string type = Convert.ToString(obj.GetProperty("code"));
                         if (!schDic.ContainsKey(schId))
                         {
-                            Dictionary<string, string> schDicRow = new() { { "name", name }, { "region", region }, { "province", province }, { "city", city }, { "dist", dist }, { "type", type } };
+                            Dictionary<string, string> schDicRow = new() { { "name", name }, { "region", region }, { "province", province }, { "city", city }, { "dist", dist }, { "areaId", areaId }, { "type", type } };
                             schDic.Add(schId, schDicRow);
                         }
                     }
@@ -138,6 +139,7 @@ namespace TEAMModelBI.Controllers.ProductAnalysis
                             resultRow.school.province = schDic[resultRow.schoolId]["province"];
                             resultRow.school.city = schDic[resultRow.schoolId]["city"];
                             resultRow.school.dist = schDic[resultRow.schoolId]["dist"];
+                            resultRow.school.areaId = schDic[resultRow.schoolId]["areaId"];
                             resultRow.school.type = schDic[resultRow.schoolId]["type"];
                         }
                         result.Add(resultRow);

+ 2 - 0
TEAMModelOS.SDK/Models/Cosmos/School/ProductAnalysis.cs

@@ -123,6 +123,7 @@ namespace TEAMModelOS.SDK.Models
         public int useHaboard { get; set; } //課堂中有使用Haboard
         public int useHita { get; set; } //課堂中有使用HiTA
         public int lessonLengMin { get; set; } //課堂時間(分鐘整數)
+        public int lessonLeng0 { get; set; } //課堂時間為0的課堂數
         public int stuShow { get; set; } //學生出席人次
         public long stuLessonLengMin { get; set; } //學生參與總時數 ※課堂時間x學生出席人次
         public int tGreen { get; set; } //T綠燈數(T>=70)
@@ -202,6 +203,7 @@ namespace TEAMModelOS.SDK.Models
         public string province { get; set; }
         public string city { get; set; }
         public string dist { get; set; }
+        public string areaId { get; set; }
         public string type { get; set; }
 }
 }

+ 3 - 2
TEAMModelOS.SDK/Models/Service/BI/BIProdAnalysis.cs

@@ -39,7 +39,7 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                 var redisClinet8 = _azureRedis.GetRedisClient(8);
                 var datetime = DateTimeOffset.UtcNow;
                 var ynow = datetime.Year;
-                List<string> calPropList = new List<string>() { "lessonRecord", "useIES", "useIES5Resource", "useWebIrs", "useDeviceIrs", "useHaboard", "useHita", "lessonLengMin", "stuShow", "stuLessonLengMin", "tGreen", "lTypeCoop", "lTypeIact", "lTypeMis", "lTypeTst", "lTypeDif", "lTypeNone", "lessonCnt928", "lessonCntId", "lessonCntDevice", "lessonCntIdDevice", "mission", "missionFin", "item", "interact", "sendSok" }; //要計算的ProdAnalysis欄位列表
+                List<string> calPropList = new List<string>() { "lessonRecord", "useIES", "useIES5Resource", "useWebIrs", "useDeviceIrs", "useHaboard", "useHita", "lessonLengMin", "lessonLeng0", "stuShow", "stuLessonLengMin", "tGreen", "lTypeCoop", "lTypeIact", "lTypeMis", "lTypeTst", "lTypeDif", "lTypeNone", "lessonCnt928", "lessonCntId", "lessonCntDevice", "lessonCntIdDevice", "mission", "missionFin", "item", "interact", "sendSok" }; //要計算的ProdAnalysis欄位列表
                 //取得CS Redis TeachingData (IOT紀錄只有三個月分)
                 List<IotTeachingData> IotTeachingDataList = new List<IotTeachingData>();
                 if (y.Equals(ynow.ToString()))
@@ -78,7 +78,7 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                             IotTeachingData.interact = (!string.IsNullOrWhiteSpace(tdata[23])) ? Convert.ToInt32(tdata[23]) : 0;
                             IotTeachingData.ip = (tdata.Length > 24) ? tdata[24] : "";
                             IotTeachingData.version = (tdata.Length > 25) ? tdata[25] : "";
-                            IotTeachingData.sendSok = (!string.IsNullOrWhiteSpace(tdata[26])) ? tdata[26] : "";
+                            IotTeachingData.sendSok = (tdata.Length > 26 && !string.IsNullOrWhiteSpace(tdata[26])) ? tdata[26] : "0";
                             IotTeachingDataList.Add(IotTeachingData);
                         }
                     }
@@ -161,6 +161,7 @@ namespace TEAMModelOS.SDK.Models.Service.BI
                             if (IotTeachingDatRow.useHaboard.Equals("1")) prodAnalysisRow.useHaboard++;
                             if (IotTeachingDatRow.useHita.Equals("1")) prodAnalysisRow.useHita++;
                             prodAnalysisRow.lessonLengMin += IotTeachingDatRow.lessonLengMin;
+                            if (IotTeachingDatRow.lessonLengMin.Equals(0)) prodAnalysisRow.lessonLeng0++;
                             prodAnalysisRow.stuShow += IotTeachingDatRow.stuShow;
                             prodAnalysisRow.stuLessonLengMin += IotTeachingDatRow.lessonLengMin * IotTeachingDatRow.stuShow;
                             if (IotTeachingDatRow.tPoint >= 70) prodAnalysisRow.tGreen++;