|
@@ -71,8 +71,9 @@ namespace TEAMModelOS.SDK
|
|
|
/// <param name="memberType">成员类型</param>
|
|
|
/// <param name="school">成员所在的学校 ,可为空</param>
|
|
|
/// <param name="groupTypes">过滤名单的类型集合,不传则是全部</param>
|
|
|
+ /// <param name="graduate">毕业类型0在校,1毕业 , -1查全部。</param>
|
|
|
/// <returns></returns>
|
|
|
- public static async Task<List<GroupListGrp>> GetMemberInGroupList(CoreAPIHttpService _coreAPIHttpService, CosmosClient client, DingDing _dingDing, string memberId, int memberType, string school,List<string> groupTypes) {
|
|
|
+ public static async Task<List<GroupListGrp>> GetMemberInGroupList(CoreAPIHttpService _coreAPIHttpService, CosmosClient client, DingDing _dingDing, string memberId, int memberType, string school,List<string> groupTypes,int graduate =-1) {
|
|
|
|
|
|
List<GroupListGrp> groupLists = new List<GroupListGrp>();
|
|
|
if (groupTypes.IsEmpty() || groupTypes.Contains("class")) {
|
|
@@ -105,8 +106,20 @@ namespace TEAMModelOS.SDK
|
|
|
type = "class",
|
|
|
no = clazz.no,
|
|
|
leader = clazz.teacher?.id,
|
|
|
+ graduate=clazz.graduate,
|
|
|
};
|
|
|
- groupLists.Add(groupList);
|
|
|
+ //graduate传入的状态>=0 表示指定状态查询,且传入的状态与数据库的状态一致。
|
|
|
+ if (graduate >= 0 )
|
|
|
+ {
|
|
|
+ if (groupList.graduate == graduate) {
|
|
|
+ groupLists.Add(groupList);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //全部。
|
|
|
+ else if(graduate == -1)
|
|
|
+ {
|
|
|
+ groupLists.Add(groupList);
|
|
|
+ }
|
|
|
}
|
|
|
catch (CosmosException ex) when (ex.Status == 404)
|
|
|
{
|
|
@@ -499,8 +512,18 @@ namespace TEAMModelOS.SDK
|
|
|
}
|
|
|
return list;
|
|
|
}
|
|
|
+ /// <summary>
|
|
|
+ ///
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="client"></param>
|
|
|
+ /// <param name="_dingDing"></param>
|
|
|
+ /// <param name="classes"></param>
|
|
|
+ /// <param name="school"></param>
|
|
|
+ /// <param name="SummarySql"></param>
|
|
|
+ /// <param name="graduate">毕业类型0在校,1毕业 , -1查全部。</param>
|
|
|
+ /// <returns></returns>
|
|
|
public static async Task<List<GroupListDto>> GetGroupListListids(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 ")
|
|
|
+ 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 " ,int graduate = -1)
|
|
|
{
|
|
|
classes.RemoveAll(x => x == null);
|
|
|
if (!classes.IsNotEmpty()) {
|
|
@@ -551,7 +574,7 @@ namespace TEAMModelOS.SDK
|
|
|
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})",
|
|
|
+ $"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}") }))
|
|
|
{
|
|
|
///行政班(学生搜寻classId动态返回)class
|
|
@@ -568,8 +591,22 @@ namespace TEAMModelOS.SDK
|
|
|
leader = item.leader,
|
|
|
no = item.no,
|
|
|
pk = "GroupList",
|
|
|
+ graduate = item.graduate
|
|
|
};
|
|
|
- groupLists.Add(group);
|
|
|
+ //graduate传入的状态>=0 表示指定状态查询,且传入的状态与数据库的状态一致。
|
|
|
+ if (graduate >= 0)
|
|
|
+ {
|
|
|
+ if (group.graduate == graduate)
|
|
|
+ {
|
|
|
+ groupLists.Add(group);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //全部。
|
|
|
+ else
|
|
|
+ {
|
|
|
+ groupLists.Add(group);
|
|
|
+ }
|
|
|
+ // groupLists.Add(group);
|
|
|
}
|
|
|
//取差集,减少二次搜寻
|
|
|
classes = classes.Except(groupLists.Select(y => y.id)).ToList();
|
|
@@ -623,7 +660,19 @@ namespace TEAMModelOS.SDK
|
|
|
}
|
|
|
return groupLists;
|
|
|
}
|
|
|
- public static async Task<(List<RMember>, List<RGroupList> groups)> GetStutmdidListids(CoreAPIHttpService _coreAPIHttpService, CosmosClient client, DingDing _dingDing, List<string> classes, string school, List<(string, List<string>)> groupids = null)
|
|
|
+ /// <summary>
|
|
|
+ ///
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="_coreAPIHttpService"></param>
|
|
|
+ /// <param name="client"></param>
|
|
|
+ /// <param name="_dingDing"></param>
|
|
|
+ /// <param name="classes"></param>
|
|
|
+ /// <param name="school"></param>
|
|
|
+ /// <param name="groupids"></param>
|
|
|
+ /// <param name="graduate">毕业类型0在校,1毕业 , -1查全部。</param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public static async Task<(List<RMember>, List<RGroupList> groups)> GetStutmdidListids(CoreAPIHttpService _coreAPIHttpService, CosmosClient client, DingDing _dingDing,
|
|
|
+ List<string> classes, string school, List<(string, List<string>)> groupids = null, int graduate = -1)
|
|
|
{
|
|
|
List<RMember> members = new List<RMember>();
|
|
|
List<RGroupList> groupLists = new List<RGroupList>();
|
|
@@ -639,7 +688,9 @@ namespace TEAMModelOS.SDK
|
|
|
{
|
|
|
//默认的教研组
|
|
|
members = new List<RMember>();
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<TmdInfo>(queryText: $"SELECT c.id,c.name,c.picture FROM c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{school}") }))
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").
|
|
|
+ GetItemQueryIterator<TmdInfo>(queryText: $"SELECT c.id,c.name,c.picture FROM c ",
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Teacher-{school}") }))
|
|
|
{
|
|
|
RMember member = new RMember
|
|
|
{
|
|
@@ -690,7 +741,20 @@ namespace TEAMModelOS.SDK
|
|
|
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);
|
|
|
+ //graduate传入的状态>=0 表示指定状态查询,且传入的状态与数据库的状态一致。
|
|
|
+ if (graduate >= 0)
|
|
|
+ {
|
|
|
+ if (item.graduate == graduate)
|
|
|
+ {
|
|
|
+ students.Add(item);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //全部。
|
|
|
+ else
|
|
|
+ {
|
|
|
+ students.Add(item);
|
|
|
+ }
|
|
|
+ // students.Add(item);
|
|
|
}
|
|
|
//取差集,减少二次搜寻
|
|
|
classes = classes.Except(students.Select(y => y.classId)).ToList();
|
|
@@ -700,7 +764,7 @@ namespace TEAMModelOS.SDK
|
|
|
string insql = string.Join(",", classes.Select(x => $"'{x}'"));
|
|
|
//搜寻没有关联学生的行政班
|
|
|
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})",
|
|
|
+ .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 ,c.graduate from c where c.id in ({insql})",
|
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Class-{school}") }))
|
|
|
{
|
|
|
///行政班(学生搜寻classId动态返回)class
|
|
@@ -720,8 +784,24 @@ namespace TEAMModelOS.SDK
|
|
|
pk = "GroupList",
|
|
|
leader = item.leader,
|
|
|
no = item.no,
|
|
|
+ graduate = item.graduate
|
|
|
};
|
|
|
- groupLists.Add(group);
|
|
|
+
|
|
|
+ //graduate传入的状态>=0 表示指定状态查询,且传入的状态与数据库的状态一致。
|
|
|
+ if (graduate >= 0)
|
|
|
+ {
|
|
|
+ if (group.graduate == graduate)
|
|
|
+ {
|
|
|
+ groupLists.Add(group);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //全部。
|
|
|
+ else
|
|
|
+ {
|
|
|
+ groupLists.Add(group);
|
|
|
+ }
|
|
|
+
|
|
|
+ //groupLists.Add(group);
|
|
|
}
|
|
|
//取差集,减少二次搜寻
|
|
|
classes = classes.Except(groupLists.Select(y => y.id)).ToList();
|
|
@@ -765,7 +845,7 @@ namespace TEAMModelOS.SDK
|
|
|
var list = item.Value.GroupBy(x => x.type).Select(y => new { key = y.Key, list = y.ToList() });
|
|
|
foreach (var group in list)
|
|
|
{
|
|
|
- (List<RGroupList> rgroups, List<RMember> rmembers) = await GetGroupListMemberInfo(_coreAPIHttpService, client, group.key, group.list, item.Key, _dingDing, school);
|
|
|
+ (List<RGroupList> rgroups, List<RMember> rmembers) = await GetGroupListMemberInfo(_coreAPIHttpService, client, group.key, group.list, item.Key, _dingDing, school,graduate);
|
|
|
members.AddRange(rmembers);
|
|
|
}
|
|
|
}
|
|
@@ -775,7 +855,7 @@ namespace TEAMModelOS.SDK
|
|
|
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<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})",
|
|
|
+ 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 ,c.graduate from c where c.id in ({insql})",
|
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"Class-{school}") }))
|
|
|
{
|
|
|
///行政班(学生搜寻classId动态返回)class
|
|
@@ -811,9 +891,23 @@ namespace TEAMModelOS.SDK
|
|
|
scount = smembers.Count,
|
|
|
no = item.no,
|
|
|
leader = item.leader,
|
|
|
- pk = "GroupList"
|
|
|
+ pk = "GroupList",
|
|
|
+ graduate = item.graduate
|
|
|
};
|
|
|
- groupLists.Add(group);
|
|
|
+ //graduate传入的状态>=0 表示指定状态查询,且传入的状态与数据库的状态一致。
|
|
|
+ if (graduate >= 0)
|
|
|
+ {
|
|
|
+ if (group.graduate == graduate)
|
|
|
+ {
|
|
|
+ groupLists.Add(group);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ //全部。
|
|
|
+ else
|
|
|
+ {
|
|
|
+ groupLists.Add(group);
|
|
|
+ }
|
|
|
+ // groupLists.Add(group);
|
|
|
}
|
|
|
//去重。
|
|
|
members = members.FindAll(x => x.type == 2).Where((x, i) => members.FindAll(x => x.type == 2).FindIndex(n => n.id.Equals(x.id) && n.code.Equals(x.code)) == i).ToList();
|
|
@@ -858,7 +952,18 @@ namespace TEAMModelOS.SDK
|
|
|
return (members, groupLists);
|
|
|
}
|
|
|
}
|
|
|
- public static async Task<List<RGroupList>> GetGroupListMemberByType(CoreAPIHttpService _coreAPIHttpService, CosmosClient client, string type, List<string> scopes, string school, DingDing _dingDing)
|
|
|
+ /// <summary>
|
|
|
+ ///
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="_coreAPIHttpService"></param>
|
|
|
+ /// <param name="client"></param>
|
|
|
+ /// <param name="type"></param>
|
|
|
+ /// <param name="scopes"></param>
|
|
|
+ /// <param name="school"></param>
|
|
|
+ /// <param name="_dingDing"></param>
|
|
|
+ /// <param name="graduate">毕业类型0在校,1毕业 , -1查全部。</param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public static async Task<List<RGroupList>> GetGroupListMemberByType(CoreAPIHttpService _coreAPIHttpService, CosmosClient client, string type, List<string> scopes, string school, DingDing _dingDing, int graduate = -1)
|
|
|
{
|
|
|
StringBuilder sql = new StringBuilder($"SELECT distinct value(c) FROM c where c.type='{type}'");
|
|
|
|
|
@@ -908,13 +1013,26 @@ namespace TEAMModelOS.SDK
|
|
|
var list = item.Value.GroupBy(x => x.type).Select(y => new { key = y.Key, list = y.ToList() });
|
|
|
foreach (var group in list)
|
|
|
{
|
|
|
- (List<RGroupList> rgroups, List<RMember> rmembers) = await GetGroupListMemberInfo(_coreAPIHttpService, client, group.key, group.list, item.Key, _dingDing, school);
|
|
|
+ (List<RGroupList> rgroups, List<RMember> rmembers) = await GetGroupListMemberInfo(_coreAPIHttpService, client, group.key, group.list, item.Key, _dingDing, school,graduate);
|
|
|
}
|
|
|
}
|
|
|
var lists = groups.SelectMany(x => x.Value).ToList();
|
|
|
return lists;
|
|
|
}
|
|
|
- public static async Task<(List<RGroupList> groups, List<RMember> members)> GetGroupListMemberInfo(CoreAPIHttpService _coreAPIHttpService, CosmosClient client, string type, List<RGroupList> groups, string groupTbname, DingDing _dingDing, string school)
|
|
|
+ /// <summary>
|
|
|
+ ///
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="_coreAPIHttpService"></param>
|
|
|
+ /// <param name="client"></param>
|
|
|
+ /// <param name="type"></param>
|
|
|
+ /// <param name="groups"></param>
|
|
|
+ /// <param name="groupTbname"></param>
|
|
|
+ /// <param name="_dingDing"></param>
|
|
|
+ /// <param name="school"></param>
|
|
|
+ /// <param name="graduate">毕业类型0在校,1毕业 , -1查全部。</param>
|
|
|
+ /// <returns></returns>
|
|
|
+ public static async Task<(List<RGroupList> groups, List<RMember> members)> GetGroupListMemberInfo(CoreAPIHttpService _coreAPIHttpService, CosmosClient client,
|
|
|
+ string type, List<RGroupList> groups, string groupTbname, DingDing _dingDing, string school, int graduate = -1)
|
|
|
{
|
|
|
|
|
|
try
|
|
@@ -933,7 +1051,7 @@ namespace TEAMModelOS.SDK
|
|
|
var ids = item.list.Select(x => x.id).ToList();
|
|
|
if (ids.IsNotEmpty())
|
|
|
{
|
|
|
- StringBuilder stuSql = new StringBuilder($"SELECT distinct c.name,c.id,c.code,c.picture,c.no,c.irs,c.classId FROM c ");
|
|
|
+ StringBuilder stuSql = new StringBuilder($"SELECT distinct c.name,c.id,c.code,c.picture,c.no,c.irs,c.classId ,c.graduate FROM c ");
|
|
|
string insql = string.Join(",", ids.Select(x => $"'{x}'"));
|
|
|
stuSql.Append($"where c.id in ({insql})");
|
|
|
await foreach (var student in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryIterator<Student>(queryText: stuSql.ToString(),
|
|
@@ -1104,6 +1222,7 @@ namespace TEAMModelOS.SDK
|
|
|
// x.nickname = string.IsNullOrWhiteSpace(x.nickname) ? student?.name:x.nickname;
|
|
|
x.picture = student?.picture;
|
|
|
x.classId = student?.classId;
|
|
|
+ x.graduate = student.graduate;
|
|
|
});
|
|
|
var mbs = tmdids;
|
|
|
mbs.AddRange(students);
|
|
@@ -1132,6 +1251,7 @@ namespace TEAMModelOS.SDK
|
|
|
// y.nickname = string.IsNullOrWhiteSpace(y.nickname) ? student?.nickname : y.nickname;
|
|
|
y.picture = student?.picture;
|
|
|
y.classId = student?.classId;
|
|
|
+ y.graduate = student.graduate;
|
|
|
}
|
|
|
}));
|
|
|
|
|
@@ -1152,7 +1272,22 @@ namespace TEAMModelOS.SDK
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
- return (groups, mbs);
|
|
|
+ if (graduate >= 0)
|
|
|
+ {
|
|
|
+ groups= groups.FindAll(x => x.graduate == graduate);
|
|
|
+ if (groups != null) {
|
|
|
+ groups.ForEach(x =>
|
|
|
+ {
|
|
|
+ x.members.RemoveAll(y => y.graduate != graduate);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ mbs.RemoveAll(z => z.graduate != graduate);
|
|
|
+ }
|
|
|
+ //直接返回
|
|
|
+ else {
|
|
|
+ return (groups, mbs);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
@@ -1160,8 +1295,6 @@ namespace TEAMModelOS.SDK
|
|
|
}
|
|
|
return (null, null);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
}
|
|
|
|
|
|
|