|
@@ -276,6 +276,97 @@ namespace TEAMModelOS.SDK.Models
|
|
|
}
|
|
|
return list;
|
|
|
}
|
|
|
+ public static async Task<List<GroupListDto> > GetGroupListListids(CosmosClient client, DingDing _dingDing, List<string> classes, string school,string SummarySql) {
|
|
|
+ List<GroupListDto> groupLists = null;
|
|
|
+ if (classes.Count == 1 && classes.First().Equals("default") && !string.IsNullOrEmpty(school))
|
|
|
+ {
|
|
|
+ //默认的教研组
|
|
|
+
|
|
|
+ GroupListDto groupList = new GroupListDto
|
|
|
+ {
|
|
|
+ id = "default",
|
|
|
+ name = "default",
|
|
|
+ code = $"GroupList-{school}",
|
|
|
+ school = school,
|
|
|
+ scope = "school",
|
|
|
+ type = "research",
|
|
|
+ };
|
|
|
+ groupLists = new List<GroupListDto> { groupList };
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ Dictionary<string, List<GroupListDto>> groups = new Dictionary<string, List<GroupListDto>>();
|
|
|
+ List<Student> students = new List<Student>();
|
|
|
+ string sql = string.Join(",", classes.Select(x => $"'{x}'"));
|
|
|
+ if (!string.IsNullOrEmpty(school))
|
|
|
+ {
|
|
|
+ List<GroupListDto> schoolList = new List<GroupListDto>();
|
|
|
+
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<GroupListDto>(queryText: $"select {SummarySql} from c where c.id in ({sql})",
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"GroupList-{school}") }))
|
|
|
+ {
|
|
|
+ schoolList.Add(item);
|
|
|
+ }
|
|
|
+ if (schoolList.IsNotEmpty())
|
|
|
+ {
|
|
|
+ groups.Add("School", schoolList);
|
|
|
+ }
|
|
|
+ //取差集,减少二次搜寻
|
|
|
+ classes = classes.Except(schoolList.Select(y => y.id)).ToList();
|
|
|
+ if (classes.IsNotEmpty())
|
|
|
+ {
|
|
|
+ sql = string.Join(",", classes.Select(x => $"'{x}'"));
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryIterator<Student>(queryText: $"select value(c) from c where c.classId in ({sql})",
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Base-{school}") }))
|
|
|
+ {
|
|
|
+ students.Add(item);
|
|
|
+ }
|
|
|
+ //取差集,减少二次搜寻
|
|
|
+ classes = classes.Except(students.Select(y => y.classId)).ToList();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (classes.IsNotEmpty())
|
|
|
+ {
|
|
|
+ List<GroupListDto> privateList = new List<GroupListDto>();
|
|
|
+ sql = string.Join(",", classes.Select(x => $"'{x}'"));
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<GroupListDto>(queryText: $"select {SummarySql} from c where c.id in ({sql})",
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"GroupList") }))
|
|
|
+ {
|
|
|
+ privateList.Add(item);
|
|
|
+ }
|
|
|
+ if (privateList.IsNotEmpty())
|
|
|
+ {
|
|
|
+ groups.Add("Teacher", privateList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ groupLists = groups.SelectMany(x => x.Value).ToList();
|
|
|
+ if (students.IsNotEmpty())
|
|
|
+ {
|
|
|
+ List<string> sqlList = students.Select(x => x.classId).ToList();
|
|
|
+ string insql = string.Join(",", sqlList.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<string> smembers = students.Where(x => x.classId.Equals(item.id)).Select(y => y.id).ToList();
|
|
|
+ GroupListDto group = new GroupListDto
|
|
|
+ {
|
|
|
+ id = item.id,
|
|
|
+ code = $"GroupList-{school}",
|
|
|
+ name = item.name,
|
|
|
+ periodId = item.periodId,
|
|
|
+ scope = "school",
|
|
|
+ school = school,
|
|
|
+ type = "class",
|
|
|
+ year = item.year,
|
|
|
+ scount = smembers.Count
|
|
|
+ };
|
|
|
+ groupLists.Add(group);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return groupLists;
|
|
|
+ }
|
|
|
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>();
|