|
@@ -130,7 +130,7 @@ namespace TEAMModelOS.SDK
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
- string SummarySql = " 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.leader ,c.froms ,c.joinLock ,c.review,c.limit ,c.expire,c.qrcodeExpire ,c.grades ";
|
|
|
|
|
|
+ string SummarySql = " 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.leader ,c.froms ,c.joinLock ,c.review,c.limitCount ,c.expire,c.qrcodeExpire ,c.qrcodeDays ,c.grades ";
|
|
if (groupTypes.IsEmpty() || groupTypes.Contains("teach")) {
|
|
if (groupTypes.IsEmpty() || groupTypes.Contains("teach")) {
|
|
//教学班
|
|
//教学班
|
|
string teachsql="";
|
|
string teachsql="";
|
|
@@ -211,7 +211,7 @@ namespace TEAMModelOS.SDK
|
|
//状态=4 表示未开放加入。
|
|
//状态=4 表示未开放加入。
|
|
return (4, item, null) ;
|
|
return (4, item, null) ;
|
|
}
|
|
}
|
|
- if (item.members!=null &&item.limit>0 && item.members.Count>item.limit) {
|
|
|
|
|
|
+ if (item.members!=null &&item.limitCount>0 && item.members.Count>item.limitCount) {
|
|
if (item.review ==1)
|
|
if (item.review ==1)
|
|
{
|
|
{
|
|
//状态=6 ,人数已满,需要审核通过再加入。
|
|
//状态=6 ,人数已满,需要审核通过再加入。
|
|
@@ -558,142 +558,149 @@ namespace TEAMModelOS.SDK
|
|
/// <param name="graduate">毕业类型0在校,1毕业 , -1查全部。</param>
|
|
/// <param name="graduate">毕业类型0在校,1毕业 , -1查全部。</param>
|
|
/// <returns></returns>
|
|
/// <returns></returns>
|
|
public static async Task<List<GroupListDto>> GetGroupListByListids(CosmosClient client, DingDing _dingDing, List<string> classes, string school,
|
|
public static async Task<List<GroupListDto>> GetGroupListByListids(CosmosClient client, DingDing _dingDing, List<string> classes, string school,
|
|
- string SummarySql = " 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.leader ,c.froms ,c.joinLock ,c.review,c.limit ,c.expire ,c.qrcodeExpire ,c.grades ", int graduate = -1)
|
|
|
|
|
|
+ string SummarySql = " 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.leader ,c.froms ,c.joinLock ,c.review,c.limitCount ,c.expire ,c.qrcodeExpire,c.qrcodeDays ,c.grades ", int graduate = -1)
|
|
{
|
|
{
|
|
- classes.RemoveAll(x => x == null);
|
|
|
|
- if (!classes.IsNotEmpty()) {
|
|
|
|
- return null;
|
|
|
|
- }
|
|
|
|
List<GroupListDto> groupLists = null;
|
|
List<GroupListDto> groupLists = null;
|
|
- if (classes.Count == 1 && classes.First().Equals("TeacherAll") && !string.IsNullOrEmpty(school))
|
|
|
|
|
|
+ try
|
|
{
|
|
{
|
|
- //默认的教研组
|
|
|
|
-
|
|
|
|
- GroupListDto groupList = new GroupListDto
|
|
|
|
|
|
+ classes.RemoveAll(x => x == null);
|
|
|
|
+ if (!classes.IsNotEmpty())
|
|
{
|
|
{
|
|
- id = "TeacherAll",
|
|
|
|
- name = "TeacherAll",
|
|
|
|
- code = $"GroupList-{school}",
|
|
|
|
- school = school,
|
|
|
|
- scope = "school",
|
|
|
|
- type = "yxtrain",
|
|
|
|
- };
|
|
|
|
- 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))
|
|
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if (classes.Count == 1 && classes.First().Equals("TeacherAll") && !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())
|
|
|
|
|
|
+ GroupListDto groupList = new GroupListDto
|
|
{
|
|
{
|
|
- groups.Add("School", schoolList);
|
|
|
|
- }
|
|
|
|
- //取差集,减少二次搜寻
|
|
|
|
- classes = classes.Except(schoolList.Select(y => y.id)).ToList();
|
|
|
|
- if (classes.IsNotEmpty())
|
|
|
|
|
|
+ id = "TeacherAll",
|
|
|
|
+ name = "TeacherAll",
|
|
|
|
+ code = $"GroupList-{school}",
|
|
|
|
+ school = school,
|
|
|
|
+ scope = "school",
|
|
|
|
+ type = "yxtrain",
|
|
|
|
+ };
|
|
|
|
+ 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))
|
|
{
|
|
{
|
|
- if (!groupLists.IsNotEmpty())
|
|
|
|
|
|
+ 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}") }))
|
|
{
|
|
{
|
|
- groupLists = new List<GroupListDto>();
|
|
|
|
|
|
+ schoolList.Add(item);
|
|
}
|
|
}
|
|
- 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 ,c.graduate from c where c.id in ({insql})",
|
|
|
|
- requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Class-{school}") }))
|
|
|
|
|
|
+ if (schoolList.IsNotEmpty())
|
|
{
|
|
{
|
|
- ///行政班(学生搜寻classId动态返回)class
|
|
|
|
- GroupListDto group = new GroupListDto
|
|
|
|
|
|
+ groups.Add("School", schoolList);
|
|
|
|
+ }
|
|
|
|
+ //取差集,减少二次搜寻
|
|
|
|
+ classes = classes.Except(schoolList.Select(y => y.id)).ToList();
|
|
|
|
+ if (classes.IsNotEmpty())
|
|
|
|
+ {
|
|
|
|
+ if (!groupLists.IsNotEmpty())
|
|
{
|
|
{
|
|
- id = item.id,
|
|
|
|
- code = $"GroupList-{school}",
|
|
|
|
- name = item.name,
|
|
|
|
- periodId = item.periodId,
|
|
|
|
- scope = "school",
|
|
|
|
- school = school,
|
|
|
|
- type = "class",
|
|
|
|
- year = item.year,
|
|
|
|
- expire = item.expire,
|
|
|
|
- leader = item.leader,
|
|
|
|
- no = item.no,
|
|
|
|
- pk = "GroupList",
|
|
|
|
- graduate = item.graduate,
|
|
|
|
- grades= new HashSet<int> { item.year}
|
|
|
|
- };
|
|
|
|
- //graduate传入的状态>=0 表示指定状态查询,且传入的状态与数据库的状态一致。
|
|
|
|
- if (graduate >= 0)
|
|
|
|
|
|
+ groupLists = new List<GroupListDto>();
|
|
|
|
+ }
|
|
|
|
+ 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 ,c.graduate from c where c.id in ({insql})",
|
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Class-{school}") }))
|
|
{
|
|
{
|
|
- if (group.graduate == graduate)
|
|
|
|
|
|
+ ///行政班(学生搜寻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,
|
|
|
|
+ expire = item.expire,
|
|
|
|
+ leader = item.leader,
|
|
|
|
+ no = item.no,
|
|
|
|
+ pk = "GroupList",
|
|
|
|
+ graduate = item.graduate,
|
|
|
|
+ grades= new HashSet<int> { item.year }
|
|
|
|
+ };
|
|
|
|
+ //graduate传入的状态>=0 表示指定状态查询,且传入的状态与数据库的状态一致。
|
|
|
|
+ if (graduate >= 0)
|
|
|
|
+ {
|
|
|
|
+ if (group.graduate == graduate)
|
|
|
|
+ {
|
|
|
|
+ groupLists.Add(group);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ //全部。
|
|
|
|
+ else
|
|
{
|
|
{
|
|
groupLists.Add(group);
|
|
groupLists.Add(group);
|
|
}
|
|
}
|
|
|
|
+ // groupLists.Add(group);
|
|
}
|
|
}
|
|
- //全部。
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- groupLists.Add(group);
|
|
|
|
- }
|
|
|
|
- // groupLists.Add(group);
|
|
|
|
|
|
+ //取差集,减少二次搜寻
|
|
|
|
+ classes = classes.Except(groupLists.Select(y => y.id)).ToList();
|
|
}
|
|
}
|
|
- //取差集,减少二次搜寻
|
|
|
|
- classes = classes.Except(groupLists.Select(y => y.id)).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 (string.IsNullOrWhiteSpace(school))
|
|
|
|
- //{
|
|
|
|
- // privateList.Add(item);
|
|
|
|
- //}
|
|
|
|
- //else
|
|
|
|
- //{
|
|
|
|
- // if (!string.IsNullOrWhiteSpace(item.school))
|
|
|
|
- // {
|
|
|
|
- // if (item.school.Equals(school))
|
|
|
|
- // {
|
|
|
|
- // privateList.Add(item);
|
|
|
|
- // }
|
|
|
|
- // }
|
|
|
|
- // else
|
|
|
|
- // {
|
|
|
|
- // privateList.Add(item);
|
|
|
|
- // }
|
|
|
|
- //}
|
|
|
|
}
|
|
}
|
|
- if (privateList.IsNotEmpty())
|
|
|
|
|
|
+ if (classes.IsNotEmpty())
|
|
{
|
|
{
|
|
- groups.Add("Teacher", privateList);
|
|
|
|
|
|
+ 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 (string.IsNullOrWhiteSpace(school))
|
|
|
|
+ //{
|
|
|
|
+ // privateList.Add(item);
|
|
|
|
+ //}
|
|
|
|
+ //else
|
|
|
|
+ //{
|
|
|
|
+ // if (!string.IsNullOrWhiteSpace(item.school))
|
|
|
|
+ // {
|
|
|
|
+ // if (item.school.Equals(school))
|
|
|
|
+ // {
|
|
|
|
+ // privateList.Add(item);
|
|
|
|
+ // }
|
|
|
|
+ // }
|
|
|
|
+ // else
|
|
|
|
+ // {
|
|
|
|
+ // privateList.Add(item);
|
|
|
|
+ // }
|
|
|
|
+ //}
|
|
|
|
+ }
|
|
|
|
+ if (privateList.IsNotEmpty())
|
|
|
|
+ {
|
|
|
|
+ groups.Add("Teacher", privateList);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
- if (groups.Count != 0)
|
|
|
|
|
|
+ if (groups.Count != 0)
|
|
|
|
|
|
- {
|
|
|
|
- if (groupLists.IsNotEmpty())
|
|
|
|
- {
|
|
|
|
- groupLists.AddRange(groups.SelectMany(x => x.Value).ToList());
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
{
|
|
{
|
|
- groupLists = groups.SelectMany(x => x.Value).ToList();
|
|
|
|
|
|
+ if (groupLists.IsNotEmpty())
|
|
|
|
+ {
|
|
|
|
+ groupLists.AddRange(groups.SelectMany(x => x.Value).ToList());
|
|
|
|
+ }
|
|
|
|
+ else
|
|
|
|
+ {
|
|
|
|
+ groupLists = groups.SelectMany(x => x.Value).ToList();
|
|
|
|
+ }
|
|
}
|
|
}
|
|
- }
|
|
|
|
|
|
|
|
|
|
+ }
|
|
|
|
+ } catch (Exception ex ) {
|
|
|
|
+ await _dingDing.SendBotMsg($"{ex.Message}\n{ex.StackTrace}", GroupNames.成都开发測試群組);
|
|
}
|
|
}
|
|
return groupLists;
|
|
return groupLists;
|
|
}
|
|
}
|