|
@@ -296,7 +296,7 @@ namespace TEAMModelOS.SDK.Models
|
|
|
else
|
|
|
{
|
|
|
Dictionary<string, List<GroupListDto>> groups = new Dictionary<string, List<GroupListDto>>();
|
|
|
- List<Student> students = new List<Student>();
|
|
|
+ //List<Student> students = new List<Student>();
|
|
|
string sql = string.Join(",", classes.Select(x => $"'{x}'"));
|
|
|
if (!string.IsNullOrEmpty(school))
|
|
|
{
|
|
@@ -315,14 +315,30 @@ namespace TEAMModelOS.SDK.Models
|
|
|
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}") }))
|
|
|
+ string insql = string.Join(",", classes.Select(x => $"'{x}'"));
|
|
|
+ //搜寻没有关联学生的行政班
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<GroupListDto>(queryText: $"select c.id,c.code,c.name,c.no,c.periodId,c.scope,c.school,c.creatorId,c.type,c.year,c.tcount,c.scount,c.teacher.id as leader from c where c.id in ({insql})",
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Class-{school}") }))
|
|
|
{
|
|
|
- students.Add(item);
|
|
|
+ ///行政班(学生搜寻classId动态返回)class
|
|
|
+ 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,
|
|
|
+ leader= item.leader,
|
|
|
+ no= item.no,
|
|
|
+ pk= "GroupList",
|
|
|
+ };
|
|
|
+ groupLists.Add(group);
|
|
|
}
|
|
|
//取差集,减少二次搜寻
|
|
|
- classes = classes.Except(students.Select(y => y.classId)).ToList();
|
|
|
+ classes = classes.Except(groupLists.Select(y => y.id)).ToList();
|
|
|
}
|
|
|
}
|
|
|
if (classes.IsNotEmpty())
|
|
@@ -340,30 +356,6 @@ namespace TEAMModelOS.SDK.Models
|
|
|
}
|
|
|
}
|
|
|
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;
|
|
|
}
|
|
@@ -432,7 +424,8 @@ namespace TEAMModelOS.SDK.Models
|
|
|
if (classes.IsNotEmpty()) {
|
|
|
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})",
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School")
|
|
|
+ .GetItemQueryIterator<RGroupList>(queryText: $"select c.id,c.code,c.name,c.no,c.periodId,c.scope,c.school,c.creatorId,c.type,c.year,c.tcount,c.scount,c.teacher.id as leader from c where c.id in ({insql})",
|
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Class-{school}") }))
|
|
|
{
|
|
|
///行政班(学生搜寻classId动态返回)class
|
|
@@ -448,7 +441,10 @@ namespace TEAMModelOS.SDK.Models
|
|
|
type = "class",
|
|
|
year = item.year,
|
|
|
members = smembers,
|
|
|
- scount = smembers.Count
|
|
|
+ scount = smembers.Count,
|
|
|
+ pk= "GroupList",
|
|
|
+ leader=item.leader,
|
|
|
+ no=item.no,
|
|
|
};
|
|
|
groupLists.Add(group);
|
|
|
}
|
|
@@ -485,11 +481,12 @@ namespace TEAMModelOS.SDK.Models
|
|
|
{
|
|
|
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})",
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").
|
|
|
+ GetItemQueryIterator<RGroupList>(queryText: $"select c.id,c.code,c.name,c.no,c.periodId,c.scope,c.school,c.creatorId,c.type,c.year,c.tcount,c.scount,c.teacher.id as leader from c where c.id in ({insql})",
|
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Class-{school}") }))
|
|
|
{
|
|
|
///行政班(学生搜寻classId动态返回)class
|
|
|
- List<RMember> smembers = students.Where(x => x.classId.Equals(item.id)).Select(y => new RMember { id = y.id, code = school, name = y.name, type = 2, picture = y.picture, no = y.no }).ToList();
|
|
|
+ List<RMember> smembers = students.Where(x => x.classId.Equals(item.id)).Select(y => new RMember { id = y.id, code = school, name = y.name, type = 2, picture = y.picture, no = y.no,classId=y.classId }).ToList();
|
|
|
members.AddRange(smembers);
|
|
|
|
|
|
RGroupList group = new RGroupList
|
|
@@ -503,7 +500,10 @@ namespace TEAMModelOS.SDK.Models
|
|
|
type = "class",
|
|
|
year = item.year,
|
|
|
members = smembers,
|
|
|
- scount = smembers.Count
|
|
|
+ scount = smembers.Count,
|
|
|
+ no=item.no,
|
|
|
+ leader=item.leader,
|
|
|
+ pk= "GroupList"
|
|
|
};
|
|
|
groupLists.Add(group);
|
|
|
}
|