Browse Source

区级统计返回数据

Li 3 năm trước cách đây
mục cha
commit
1232508a33
1 tập tin đã thay đổi với 47 bổ sung14 xóa
  1. 47 14
      TEAMModelBI/Controllers/Census/ActivitySticsController.cs

+ 47 - 14
TEAMModelBI/Controllers/Census/ActivitySticsController.cs

@@ -299,14 +299,14 @@ namespace TEAMModelBI.Controllers.Census
 
             var cosmosClient = _azureCosmos.GetCosmosClient();
             List<RecSchool> schools = new();
-            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<RecSchool>(queryText: $"select c.id,c.name,c.picture,c.size,c.scale from c where c.areaId='{areaId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
+            await foreach (var item in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<RecSchool>(queryText: $"select c.id,c.name,c.picture,c.size,c.scale,c.type from c where c.areaId='{areaId}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey("Base") }))
             {
                 schools.Add(item);
             }
-            //区级人员
-            int countArea = 0;
-            //区级评审人员
-            int appraiseArea = 0;
+            
+            int countArea = 0;//区级人员
+            int appraiseArea = 0;//区级评审人员
+            int areaSize = 0;   //区级空间
             long examAreaCount = 0;   //试卷活动
             long surveyAreaCount = 0;  //问卷活动
             long voteAreaCount = 0;   //投票活动
@@ -316,12 +316,25 @@ namespace TEAMModelBI.Controllers.Census
             int Basics = 0; //基础版数
             int standard = 0; //标准版数
             int major = 0;   //专业版数
+            int geCount = 0; //普教
+            int heCount = 0; //高教
+            int oeCount = 0; //其他教育
 
+            List<SchoolLesson> schoolLessons = new();  //学校课例集合 
             List<SchoolInfo> schoolInfos = new();
 
+
             int totalTime = 0;
             foreach (var school in schools)
             {
+                if (school.type == 2)
+                    heCount += 1;
+                else if (school.type == 1)
+                    geCount += 1;
+                else oeCount += 0;
+
+                areaSize += school.size;
+
                 int count = 0;
                 int appraise = 0;
                 await foreach (var info in cosmosClient.GetContainer("TEAMModelOS", "School").GetItemQueryIterator<bool>(queryText: $"select value(array_contains(c.permissions,'train-appraise')) from c", requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Teacher-{school.id}") }))
@@ -343,21 +356,33 @@ namespace TEAMModelBI.Controllers.Census
                 long stuCount = await CommonFind.FindTotals(cosmosClient, $"select count(c.id) as totals from c", "Student", $"Base-{school.id}");
 
                 //查询是否有服务
-                int serCount = await CommonFind.FindTotals(cosmosClient, $"select array_length(c.service) as totals from c where c.id'{school.id}'", "School", "ProductSum");
+                int serCount = await CommonFind.FindTotals(cosmosClient, $"select array_length(c.service) as totals from c where c.id='{school.id}'", "School", "ProductSum");
                 if (serCount > 0)
                     major += 1;
                 else if (school.size >= 300 && school.scale >= 500)
                     standard += 1;
                 else Basics += 1;
 
+                //课例
+                int lessCount = await CommonFind.FindTotals(cosmosClient, "select count(c.id) totals from c", "School", $"LessonRecord-{school.id}");
+                SchoolLesson schoolLesson = new()
+                {
+                    id = school.id,
+                    name = school.name,
+                    picture = school.picture,
+                    count = lessCount
+                };
+
+
                 SchoolInfo schoolInfo = new() { 
-                    schoolId = school.id, 
-                    schoolName = school.name,
+                    id = school.id, 
+                    name = school.name,
                     picture = school.picture,
                     teacherCount = count,
                     studentCount = stuCount, 
                     appraiseCount = appraise, 
-                    trainCount = tempCount };
+                    trainCount = tempCount 
+                };
 
                 ActivityCount tempActivity = new ActivityCount() { id = school.id, name = school.name != null ? school.name : school.id };
                 foreach (var type in types)
@@ -377,7 +402,6 @@ namespace TEAMModelBI.Controllers.Census
                     {
                         case "Exam":
                             examAreaCount += totals;
-
                             break;
                         case "Survey":
                             surveyAreaCount += totals;
@@ -392,9 +416,10 @@ namespace TEAMModelBI.Controllers.Census
                     schoolInfo.census.Add(new KeyValuePair<object, long>(type, totals));
                 }
                 schoolInfos.Add(schoolInfo);
+                schoolLessons.Add(schoolLesson);
             }
 
-            return Ok(new { state = 200, schoolCount = schools.Count, countArea, weekActivity, termActivity, totalTime, appraiseArea, examAreaCount, surveyAreaCount, voteAreaCount, homeworkAreaCount, schools = schoolInfos});
+            return Ok(new { state = 200, schoolCount = schools.Count, countArea, weekActivity, termActivity, totalTime, appraiseArea, examAreaCount, surveyAreaCount, voteAreaCount, homeworkAreaCount, schools = schoolInfos, schoolLessons });
         }
 
         /// <summary>
@@ -448,14 +473,15 @@ namespace TEAMModelBI.Controllers.Census
             public string id { get; set; }
             public string name { get; set; }
             public string picture { get; set; }
+            public int type { get; set; }
             public int size { get; set; }
             public int scale { get; set; }
         }
 
         private class SchoolInfo
         {
-            public string schoolId { get; set; }
-            public string schoolName { get; set; }
+            public string id { get; set; }
+            public string name { get; set; }
             public string picture { get; set; }
             //教师人数
             public int teacherCount { get; set; }
@@ -466,11 +492,18 @@ namespace TEAMModelBI.Controllers.Census
             //参训人数
             public int trainCount { get; set; }
             public List<KeyValuePair<object, long>> census { get; set; } = new List<KeyValuePair<object, long>>();
+        }
 
 
+        private record SchoolLesson
+        {
+            public string id { get; set; }
+            public string name { get; set; }
+            public string picture { get; set; }
+            public int count{get;set;}
         }
 
-        public record ActivityCount 
+            public record ActivityCount 
         {
             public string id { get; set; }
             public string name { get; set; }