Przeglądaj źródła

Merge branch 'PL/develop-BI' into develop

Li 2 lat temu
rodzic
commit
a000341eb3

+ 6 - 3
TEAMModelBI/Controllers/BISchool/SchoolController.cs

@@ -1614,6 +1614,7 @@ namespace TEAMModelBI.Controllers.BISchool
             List<string> schoolIds = await CommonFind.FindSchoolIds(cosmosClient, $"{tmdId}");
 
             int adCnt = 0;
+            int allCnt = 0;
             List<ScProdEd> scInfos = new();
             List<string> products = new();
             if (schoolIds.Count > 0)
@@ -1623,12 +1624,14 @@ namespace TEAMModelBI.Controllers.BISchool
 
                 scInfos = await CommonFind.GetObject<ScProdEd>(cosmosClient, "School", $"{scInfoSql} where {idSql}", "Base");
 
+                string serialSql = "SELECT value(count(ARRAY_LENGTH(c.deviceBound))) FROM c ";
+                string serialAllSql = "SELECT value(sum((c.deviceMax))) FROM c";
                 if (schoolIds.Count > 0)
                 {
                     foreach (var scProd in scInfos)
                     {
-                        string sqlText = "SELECT value(count(ARRAY_LENGTH(c.deviceBound))) FROM c where c.dataType ='serial'";
-                        adCnt += await CommonFind.GetSqlValueCount(cosmosClient, "School", sqlText, $"Product-{scProd.id}");
+                        adCnt += await CommonFind.GetSqlValueCount(cosmosClient, "School", serialSql, $"Product-{scProd.id}");
+                        allCnt += await CommonFind.GetSqlValueCount(cosmosClient, "School", serialAllSql, $"Product-{scProd.id}");
 
                         var response = await cosmosClient.GetContainer("TEAMModelOS", "School").ReadItemStreamAsync(scProd.id, new PartitionKey("ProductSum"));
                         if (response.Status == 200)
@@ -1681,7 +1684,7 @@ namespace TEAMModelBI.Controllers.BISchool
 
             var productAn = products.GroupBy(g => g).Select(s => new { key = s.Key, cnt = s.ToList().Count }).ToList();
 
-            return Ok(new { state = RespondCode.Ok, adCnt, scInfos, productAn });
+            return Ok(new { state = RespondCode.Ok, allCnt, adCnt, scInfos, productAn });
             // var productAn = products.GroupBy(x => x).Select(y => new { key = y.Key, count = y.ToList().Count }).ToList();
 
         }