Browse Source

[BI]學校統計數修正
1.区级统计:追加學校數統計欄位(schCnt) 2.所有区级的统计:學校數修正為實體學校數+虛擬學校數

jeff 1 year ago
parent
commit
4cf893e4e6
1 changed files with 10 additions and 3 deletions
  1. 10 3
      TEAMModelBI/Controllers/Census/SchoolController.cs

+ 10 - 3
TEAMModelBI/Controllers/Census/SchoolController.cs

@@ -1016,6 +1016,11 @@ namespace TEAMModelBI.Controllers.Census
                 lastYear.Add(item);
                 }
             }
+            //本學區虛擬學校數取得
+            string schcntSql = $"SELECT VALUE COUNT(c.id) FROM c WHERE c.areaId='{areaId}'";
+            int sbCnt = await JointlySingleQuery.GetValueInt(cosmosClient, "School", "Base", schcntSql);
+            int vrCnt = await JointlySingleQuery.GetValueInt(cosmosClient, "School", "VirtualBase", schcntSql);
+            int schCnt = sbCnt + vrCnt;
 
             StatsInfo statsInfo = null;
             statsInfo = SchoolStatsWay.GetAreaStats(cosmosClient, _option, statsInfos, scIds, area);
@@ -1200,7 +1205,7 @@ namespace TEAMModelBI.Controllers.Census
                 }
             }
 
-            return Ok(new { state = RespondCode.Ok, areaScStats, schoolInfos, weekLess, assists = assits.Where((w, i) => assits.FindIndex(s => s.id.Equals(w.id)) == i).ToList(), saless = saless.Where((w, i) => saless.FindIndex(f => f.id.Equals(w.id)) == i).ToList(), useSize, typeStics = typeStics.ToList() });
+            return Ok(new { state = RespondCode.Ok, areaScStats, schCnt, schoolInfos, weekLess, assists = assits.Where((w, i) => assits.FindIndex(s => s.id.Equals(w.id)) == i).ToList(), saless = saless.Where((w, i) => saless.FindIndex(f => f.id.Equals(w.id)) == i).ToList(), useSize, typeStics = typeStics.ToList() });
         }
 
         /// <summary>
@@ -1239,7 +1244,8 @@ namespace TEAMModelBI.Controllers.Census
                 easyInfos.Add(item);
             }
 
-            int scCnt = await JointlySingleQuery.GetValueInt(cosmosClient, "Normal", "Base", sql);
+            int scCnt = await JointlySingleQuery.GetValueInt(cosmosClient, "School", "Base", sql);
+            int vrCnt = await JointlySingleQuery.GetValueInt(cosmosClient, "School", "VirtualBase", sql);
             int scWeekCnt = await JointlySingleQuery.GetValueInt(cosmosClient, "Normal", "Base", $"{sql} where c.createTime >= {weekS} and c.createTime <= {weekE}");
             int scMonthCnt = await JointlySingleQuery.GetValueInt(cosmosClient, "Normal", "Base", $"{sql} where c.createTime >= {mthS} and c.createTime <= {mthE}");
             List<string> scId = new();
@@ -1258,7 +1264,7 @@ namespace TEAMModelBI.Controllers.Census
             if (statsInfo != null)
             {
                 allScStats.areaCnt = easyInfos.Count;
-                allScStats.sc = statsInfos.Count;
+                //allScStats.sc = statsInfos.Count;
                 allScStats.weekSc = scWeekCnt;
                 allScStats.monthSc = scMonthCnt;
                 allScStats.tch = statsInfo.tch;
@@ -1315,6 +1321,7 @@ namespace TEAMModelBI.Controllers.Census
                     allScStats.srStats.finish = statsInfo.study.finish;
                 }
             }
+            allScStats.sc = scCnt + vrCnt; //學校數
 
             return Ok(new { state = RespondCode.Ok, allScStats, areaGroup });
         }