Explorar el Código

优化查询区域列表

Li hace 2 años
padre
commit
db60930b14
Se han modificado 1 ficheros con 23 adiciones y 22 borrados
  1. 23 22
      TEAMModelBI/Controllers/Census/ActivitySticsController.cs

+ 23 - 22
TEAMModelBI/Controllers/Census/ActivitySticsController.cs

@@ -552,27 +552,28 @@ namespace TEAMModelBI.Controllers.Census
 
             foreach (var area in areaInfos)
             {
-                string scSql = $"select value(c.id) from c where c.areaId='{area.id}'";
-                List<string> scIds = await CommonFind.GetValueSingle(cosmosClient, "School", scSql,"Base");
+                //string scSql = $"select value(c.id) from c where c.areaId='{area.id}'";
+                //List<string> scIds = await CommonFind.GetValueSingle(cosmosClient, "School", scSql,"Base");
                 //allSize += recSchools.Select(s => s.size).Sum();
-                area.scCnt = scIds.Count;
-                int tTchCnt = 0;
-                int tStuCnt = 0;
-                if (scIds.Count > 0)
-                {
-                    scSql = BICommonWay.ManyScSql("REPLACE(c.code, 'Teacher-', '')", scIds);
-
-                    //查教师
-                    string tchSql = $"select value(count(c.id)) from c where c.pk='Teacher' and {scSql}";
-                    tTchCnt = await CommonFind.GetSqlValueCount(cosmosClient, "School", tchSql);
-
-                    scSql = BICommonWay.ManyScSql("REPLACE(c.code, 'Base-', '')", scIds);
-                    //查学生
-                    string stuSql = $"select value(count(c.id)) from c where c.pk='Base' and {scSql}";
-                    tStuCnt = await CommonFind.GetSqlValueCount(cosmosClient, "Student", stuSql);
-                }
-                area.tchCnt = tTchCnt;
-                area.stuCnt = tStuCnt;
+                area.scCnt = await CommonFind.GetSqlValueCount(cosmosClient, "School", $"select value(count(c.id)) from c where c.areaId='{area.id}'", "Base");
+                //area.scCnt = scIds.Count;
+                //int tTchCnt = 0;
+                //int tStuCnt = 0;
+                //if (scIds.Count > 0)
+                //{
+                //    scSql = BICommonWay.ManyScSql("REPLACE(c.code, 'Teacher-', '')", scIds);
+
+                //    //查教师
+                //    string tchSql = $"select value(count(c.id)) from c where c.pk='Teacher' and {scSql}";
+                //    tTchCnt = await CommonFind.GetSqlValueCount(cosmosClient, "School", tchSql);
+
+                //    scSql = BICommonWay.ManyScSql("REPLACE(c.code, 'Base-', '')", scIds);
+                //    //查学生
+                //    string stuSql = $"select value(count(c.id)) from c where c.pk='Base' and {scSql}";
+                //    tStuCnt = await CommonFind.GetSqlValueCount(cosmosClient, "Student", stuSql);
+                ////}
+                //area.tchCnt = tTchCnt;
+                //area.stuCnt = tStuCnt;
             }
 
             return Ok(new { state = RespondCode.Ok, areaInfos });
@@ -927,8 +928,8 @@ namespace TEAMModelBI.Controllers.Census
             public string standard { get; set; }
             public string standardName { get; set; }
             public int scCnt { get; set; } = 0;
-            public int tchCnt { get; set; } = 0;
-            public int stuCnt { get; set; } = 0;
+            //public int tchCnt { get; set; } = 0;
+            //public int stuCnt { get; set; } = 0;
         }