Browse Source

返回空名单。

CrazyIter_Bin 3 years ago
parent
commit
b1a88cd3c7
1 changed files with 26 additions and 2 deletions
  1. 26 2
      TEAMModelOS.SDK/Models/Service/GroupListService.cs

+ 26 - 2
TEAMModelOS.SDK/Models/Service/GroupListService.cs

@@ -370,7 +370,7 @@ namespace TEAMModelOS.SDK.Models
         public static async Task<(List<RMember>, List<RGroupList> groups)> GetStutmdidListids(CosmosClient client, DingDing _dingDing, List<string> classes, string school)
         {
             List<RMember> members = new List<RMember>();
-            List<RGroupList> groupLists = null;
+            List<RGroupList> groupLists = new List<RGroupList>();
             if (classes.Count == 1 && classes.First().Equals("default") && !string.IsNullOrEmpty(school))
             {
                 //默认的教研组
@@ -429,6 +429,30 @@ namespace TEAMModelOS.SDK.Models
                         //取差集,减少二次搜寻
                         classes = classes.Except(students.Select(y => y.classId)).ToList();
                     }
+                    string insql = string.Join(",", classes.Select(x => $"'{x}'"));
+                    //搜寻没有关联学生的行政班
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<ClassInfo>(queryText: $"select c.id,c.name ,c.periodId  ,c.year from c where c.id in ({insql})",
+                            requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Class-{school}") }))
+                    {
+                        ///行政班(学生搜寻classId动态返回)class
+                        List<RMember> smembers = new List<RMember>();
+                        RGroupList group = new RGroupList
+                        {
+                            id = item.id,
+                            code = $"GroupList-{school}",
+                            name = item.name,
+                            periodId = item.periodId,
+                            scope = "school",
+                            school = school,
+                            type = "class",
+                            year = item.year,
+                            members = smembers,
+                            scount = smembers.Count
+                        };
+                        groupLists.Add(group);
+                    }
+                    //取差集,减少二次搜寻
+                    classes = classes.Except(students.Select(y => y.classId)).ToList();
                 }
                 if (classes.IsNotEmpty())
                 {
@@ -453,7 +477,7 @@ namespace TEAMModelOS.SDK.Models
                         members.AddRange(rmembers);
                     }
                 }
-                groupLists = groups.SelectMany(x => x.Value).ToList();
+                groupLists .AddRange(groups.SelectMany(x => x.Value).ToList());
                 if (students.IsNotEmpty())
                 {
                     List<string> sqlList = students.Select(x => x.classId).ToList();