|
@@ -21,7 +21,7 @@ namespace TEAMModelOS.SDK
|
|
|
{
|
|
|
public class GroupListService
|
|
|
{
|
|
|
- public static async Task<(int status, GroupList stuList)> CodeJoinList(CosmosClient client, string _stuListNo, string userid, int type, string school)
|
|
|
+ public static async Task<(int status, GroupList stuList)> CodeJoinList(CosmosClient client, string _stuListNo, string userid, int type, string school)
|
|
|
{
|
|
|
var queryNo = $"SELECT value(c) FROM c where c.no ='{_stuListNo}'";
|
|
|
(int status, GroupList stuList) data = (-1, null);
|
|
@@ -30,7 +30,7 @@ namespace TEAMModelOS.SDK
|
|
|
await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<GroupList>(queryText: queryNo,
|
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"GroupList-{school}") }))
|
|
|
{
|
|
|
- data = JoinList(item, userid , type, school);
|
|
|
+ data = JoinList(item, userid, type, school);
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
@@ -42,17 +42,19 @@ namespace TEAMModelOS.SDK
|
|
|
}
|
|
|
return data;
|
|
|
}
|
|
|
- public static (int status, GroupList stuList) JoinList(GroupList stuList, string userid, int type, string school)
|
|
|
+ public static (int status, GroupList stuList) JoinList(GroupList stuList, string userid, int type, string school)
|
|
|
{
|
|
|
int status = -1;
|
|
|
- if (!string.IsNullOrWhiteSpace(stuList.school) && !string.IsNullOrWhiteSpace(school)) {
|
|
|
- if (!stuList.school.Equals(school)) {
|
|
|
+ if (!string.IsNullOrWhiteSpace(stuList.school) && !string.IsNullOrWhiteSpace(school))
|
|
|
+ {
|
|
|
+ if (!stuList.school.Equals(school))
|
|
|
+ {
|
|
|
status = 3;//不允许跨校加入名单
|
|
|
return (status, stuList);
|
|
|
}
|
|
|
}
|
|
|
- string irs=string.Empty;
|
|
|
- List<string> irsOrder= stuList.members.Select(x => x.irs)?.Where(y => !string.IsNullOrEmpty(y)&& Regex.IsMatch(y, @"^\d*$")).OrderBy(x => int.Parse(x)).ToList();
|
|
|
+ string irs = string.Empty;
|
|
|
+ List<string> irsOrder = stuList.members.Select(x => x.irs)?.Where(y => !string.IsNullOrEmpty(y) && Regex.IsMatch(y, @"^\d*$")).OrderBy(x => int.Parse(x)).ToList();
|
|
|
if (!irsOrder.Contains("0"))
|
|
|
{
|
|
|
irsOrder.Insert(0, "0");
|
|
@@ -77,7 +79,7 @@ namespace TEAMModelOS.SDK
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
if (string.IsNullOrEmpty($"{userid}"))
|
|
|
{
|
|
|
//加入学生或醍摩豆ID为空
|
|
@@ -97,7 +99,7 @@ namespace TEAMModelOS.SDK
|
|
|
{
|
|
|
//加入成功
|
|
|
status = 0;
|
|
|
- stuList.members.Add(new Member { id = userid,type = type, irs = irs, no = irs });
|
|
|
+ stuList.members.Add(new Member { id = userid, type = type, irs = irs, no = irs });
|
|
|
}
|
|
|
}
|
|
|
else if (type == 2)
|
|
@@ -111,14 +113,14 @@ namespace TEAMModelOS.SDK
|
|
|
else
|
|
|
{
|
|
|
status = 0;
|
|
|
- stuList.members.Add(new Member { id = userid, code = school, type = type, irs = irs, no = irs });
|
|
|
+ stuList.members.Add(new Member { id = userid, code = school, type = type, irs = irs, no = irs });
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
return (status, stuList);
|
|
|
}
|
|
|
|
|
|
- public static async Task<GroupList> UpsertList(GroupList list, AzureCosmosFactory _azureCosmos, IConfiguration _configuration, AzureServiceBusFactory _serviceBus)
|
|
|
+ public static async Task<GroupList> UpsertList(GroupList list, AzureCosmosFactory _azureCosmos, IConfiguration _configuration, AzureServiceBusFactory _serviceBus)
|
|
|
{
|
|
|
bool isnew = false;
|
|
|
var client = _azureCosmos.GetCosmosClient();
|
|
@@ -129,7 +131,7 @@ namespace TEAMModelOS.SDK
|
|
|
}
|
|
|
string tbname = list.scope.Equals("private") ? "Teacher" : "School";
|
|
|
var tmembers = list.members.Where(x => x.type == 1);
|
|
|
- var smembers= list.members.Where(x => x.type == 2);
|
|
|
+ var smembers = list.members.Where(x => x.type == 2);
|
|
|
list.scount = smembers.Count();
|
|
|
list.tcount = tmembers.Count();
|
|
|
//if (smembers.Count() > 0 && smembers.Select(x => x.code).ToHashSet().Count()>=2) {
|
|
@@ -142,17 +144,19 @@ namespace TEAMModelOS.SDK
|
|
|
// list.members.RemoveAll(x => codes.Contains(x.code));
|
|
|
// }
|
|
|
// else {
|
|
|
- // list.members.RemoveAll(x => x.code.Equals(list.school));
|
|
|
+ // list.members.RemoveAll(x => !x.code.Equals(list.school));
|
|
|
// }
|
|
|
//}
|
|
|
- if (string.IsNullOrWhiteSpace(list.school) && smembers.Count() >= 1) {
|
|
|
+ if (string.IsNullOrWhiteSpace(list.school) && smembers.Count() >= 1)
|
|
|
+ {
|
|
|
list.school = smembers.First().code;
|
|
|
}
|
|
|
- if (!string.IsNullOrWhiteSpace(list.school) && smembers.Count() == 0 && list.scope.Equals("private")) {
|
|
|
+ if (!string.IsNullOrWhiteSpace(list.school) && smembers.Count() == 0 && list.scope.Equals("private"))
|
|
|
+ {
|
|
|
list.school = null;
|
|
|
}
|
|
|
//学生名单,教研组会触发活动中间表刷新
|
|
|
- if (list.type.Equals("teach") || list.type.Equals("research") || list.type.Equals("yxtrain")|| list.type.Equals("activity"))
|
|
|
+ if (list.type.Equals("teach") || list.type.Equals("research") || list.type.Equals("yxtrain") || list.type.Equals("activity"))
|
|
|
{
|
|
|
GroupChange change = new GroupChange()
|
|
|
{
|
|
@@ -231,11 +235,12 @@ namespace TEAMModelOS.SDK
|
|
|
else
|
|
|
{
|
|
|
//离开的
|
|
|
- if (oldList != null) {
|
|
|
+ if (oldList != null)
|
|
|
+ {
|
|
|
var tmdids = oldList.members.FindAll(x => x.type == 1);
|
|
|
if (tmdids.IsNotEmpty())
|
|
|
{
|
|
|
- if (list.type.Equals("research")|| list.type.Equals("yxtrain"))
|
|
|
+ if (list.type.Equals("research") || list.type.Equals("yxtrain"))
|
|
|
{
|
|
|
change.tchleave.AddRange(tmdids);
|
|
|
}
|
|
@@ -334,8 +339,9 @@ namespace TEAMModelOS.SDK
|
|
|
}
|
|
|
return list;
|
|
|
}
|
|
|
- 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 ") {
|
|
|
+ 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 ")
|
|
|
+ {
|
|
|
List<GroupListDto> groupLists = null;
|
|
|
if (classes.Count == 1 && classes.First().Equals("TeacherAll") && !string.IsNullOrEmpty(school))
|
|
|
{
|
|
@@ -374,7 +380,8 @@ namespace TEAMModelOS.SDK
|
|
|
classes = classes.Except(schoolList.Select(y => y.id)).ToList();
|
|
|
if (classes.IsNotEmpty())
|
|
|
{
|
|
|
- if (!groupLists.IsNotEmpty()) {
|
|
|
+ if (!groupLists.IsNotEmpty())
|
|
|
+ {
|
|
|
groupLists = new List<GroupListDto>();
|
|
|
}
|
|
|
string insql = string.Join(",", classes.Select(x => $"'{x}'"));
|
|
@@ -393,9 +400,9 @@ namespace TEAMModelOS.SDK
|
|
|
school = school,
|
|
|
type = "class",
|
|
|
year = item.year,
|
|
|
- leader= item.leader,
|
|
|
- no= item.no,
|
|
|
- pk= "GroupList",
|
|
|
+ leader = item.leader,
|
|
|
+ no = item.no,
|
|
|
+ pk = "GroupList",
|
|
|
};
|
|
|
groupLists.Add(group);
|
|
|
}
|
|
@@ -410,24 +417,25 @@ namespace TEAMModelOS.SDK
|
|
|
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") }))
|
|
|
{
|
|
|
- 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);
|
|
|
- }
|
|
|
- }
|
|
|
+ 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())
|
|
|
{
|
|
@@ -439,24 +447,27 @@ namespace TEAMModelOS.SDK
|
|
|
{
|
|
|
if (groupLists.IsNotEmpty())
|
|
|
{
|
|
|
- groupLists .AddRange(groups.SelectMany(x => x.Value).ToList());
|
|
|
+ groupLists.AddRange(groups.SelectMany(x => x.Value).ToList());
|
|
|
}
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
groupLists = groups.SelectMany(x => x.Value).ToList();
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
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)
|
|
|
+ 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)
|
|
|
{
|
|
|
List<RMember> members = new List<RMember>();
|
|
|
List<RGroupList> groupLists = new List<RGroupList>();
|
|
|
- if (classes != null) {
|
|
|
+ if (classes != null)
|
|
|
+ {
|
|
|
classes.RemoveAll(x => x == null);
|
|
|
}
|
|
|
- if (classes==null || classes.Count<=0) {
|
|
|
+ if (classes == null || classes.Count <= 0)
|
|
|
+ {
|
|
|
return (members, groupLists);
|
|
|
}
|
|
|
if (classes.Count == 1 && classes.First().Equals("TeacherAll") && !string.IsNullOrEmpty(school))
|
|
@@ -473,7 +484,7 @@ namespace TEAMModelOS.SDK
|
|
|
type = 1,
|
|
|
};
|
|
|
members.Add(member);
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
RGroupList groupList = new RGroupList
|
|
|
{
|
|
@@ -519,7 +530,8 @@ namespace TEAMModelOS.SDK
|
|
|
//取差集,减少二次搜寻
|
|
|
classes = classes.Except(students.Select(y => y.classId)).ToList();
|
|
|
}
|
|
|
- if (classes.IsNotEmpty()) {
|
|
|
+ if (classes.IsNotEmpty())
|
|
|
+ {
|
|
|
string insql = string.Join(",", classes.Select(x => $"'{x}'"));
|
|
|
//搜寻没有关联学生的行政班
|
|
|
await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School")
|
|
@@ -540,16 +552,16 @@ namespace TEAMModelOS.SDK
|
|
|
year = item.year,
|
|
|
members = smembers,
|
|
|
scount = smembers.Count,
|
|
|
- pk= "GroupList",
|
|
|
- leader=item.leader,
|
|
|
- no=item.no,
|
|
|
+ pk = "GroupList",
|
|
|
+ leader = item.leader,
|
|
|
+ no = item.no,
|
|
|
};
|
|
|
groupLists.Add(group);
|
|
|
}
|
|
|
//取差集,减少二次搜寻
|
|
|
classes = classes.Except(groupLists.Select(y => y.id)).ToList();
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
if (classes.IsNotEmpty())
|
|
|
{
|
|
@@ -558,24 +570,25 @@ namespace TEAMModelOS.SDK
|
|
|
await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<RGroupList>(queryText: $"select value(c) from c where c.id in ({sql})",
|
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"GroupList") }))
|
|
|
{
|
|
|
- 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);
|
|
|
- }
|
|
|
- }
|
|
|
+ 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())
|
|
|
{
|
|
@@ -587,11 +600,11 @@ 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);
|
|
|
members.AddRange(rmembers);
|
|
|
}
|
|
|
}
|
|
|
- groupLists .AddRange(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();
|
|
@@ -602,21 +615,21 @@ namespace TEAMModelOS.SDK
|
|
|
{
|
|
|
///行政班(学生搜寻classId动态返回)class
|
|
|
List<RMember> smembers = students.Where(x => x.classId.Equals(item.id))
|
|
|
- .Select(y => new RMember
|
|
|
+ .Select(y => new RMember
|
|
|
{
|
|
|
id = y.id,
|
|
|
- code = school,
|
|
|
+ code = school,
|
|
|
name = y.name,
|
|
|
- type = 2,
|
|
|
+ type = 2,
|
|
|
picture = y.picture,
|
|
|
no = y.no,
|
|
|
- classId=y.classId,
|
|
|
+ classId = y.classId,
|
|
|
//groupId=y.groupId,
|
|
|
- groupName=y.groupName ,
|
|
|
- irs=y.irs,
|
|
|
+ groupName = y.groupName,
|
|
|
+ irs = y.irs,
|
|
|
}).ToList();
|
|
|
members.AddRange(smembers);
|
|
|
-
|
|
|
+
|
|
|
RGroupList group = new RGroupList
|
|
|
{
|
|
|
id = item.id,
|
|
@@ -629,9 +642,9 @@ namespace TEAMModelOS.SDK
|
|
|
year = item.year,
|
|
|
members = smembers,
|
|
|
scount = smembers.Count,
|
|
|
- no=item.no,
|
|
|
- leader=item.leader,
|
|
|
- pk= "GroupList"
|
|
|
+ no = item.no,
|
|
|
+ leader = item.leader,
|
|
|
+ pk = "GroupList"
|
|
|
};
|
|
|
groupLists.Add(group);
|
|
|
}
|
|
@@ -639,29 +652,32 @@ namespace TEAMModelOS.SDK
|
|
|
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();
|
|
|
}
|
|
|
}
|
|
|
- if (groupids.IsNotEmpty()) {
|
|
|
+ if (groupids.IsNotEmpty())
|
|
|
+ {
|
|
|
List<RMember> rmembers = new List<RMember>();
|
|
|
groupLists.ForEach(y => {
|
|
|
(string id, List<string> grpids) = groupids.Find(x => x.Item1.Equals(y.id));
|
|
|
var gpmember = y.members.FindAll(x => !string.IsNullOrEmpty(x.groupName) && grpids.Contains(x.groupName));
|
|
|
- if ( grpids.Contains("default"))
|
|
|
+ if (grpids.Contains("default"))
|
|
|
{
|
|
|
var gpmemberdft = y.members.FindAll(x => string.IsNullOrWhiteSpace(x.groupName));
|
|
|
if (gpmember.IsNotEmpty())
|
|
|
{
|
|
|
gpmember.AddRange(gpmemberdft);
|
|
|
}
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
gpmember = gpmemberdft;
|
|
|
}
|
|
|
}
|
|
|
y.members = gpmember;
|
|
|
|
|
|
});
|
|
|
- var gpgpmembers = groupLists.SelectMany(x => x.members).ToList();
|
|
|
+ var gpgpmembers = groupLists.SelectMany(x => x.members).ToList();
|
|
|
List<RMember> tmdids = gpgpmembers.FindAll(x => x.type == 1).Where((x, i) => gpgpmembers.FindAll(x => x.type == 1).FindIndex(n => n.id.Equals(x.id)) == i).ToList();
|
|
|
List<RMember> students = gpgpmembers.FindAll(x => x.type == 2).Where((x, i) => gpgpmembers.FindAll(x => x.type == 2).FindIndex(n => n.id.Equals(x.id) && n.code.Equals(x.code)) == i).ToList();
|
|
|
- if (tmdids.IsNotEmpty()) {
|
|
|
+ if (tmdids.IsNotEmpty())
|
|
|
+ {
|
|
|
rmembers.AddRange(tmdids);
|
|
|
}
|
|
|
if (students.IsNotEmpty())
|
|
@@ -670,20 +686,21 @@ namespace TEAMModelOS.SDK
|
|
|
}
|
|
|
return (rmembers, groupLists);
|
|
|
}
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
return (members, groupLists);
|
|
|
}
|
|
|
}
|
|
|
- public static async Task< List<RGroupList> > GetGroupListMemberByType(CoreAPIHttpService _coreAPIHttpService,CosmosClient client,string type, List<string> scopes, string school, DingDing _dingDing)
|
|
|
+ public static async Task<List<RGroupList>> GetGroupListMemberByType(CoreAPIHttpService _coreAPIHttpService, CosmosClient client, string type, List<string> scopes, string school, DingDing _dingDing)
|
|
|
{
|
|
|
StringBuilder sql = new StringBuilder($"SELECT distinct value(c) FROM c where c.type='{type}'");
|
|
|
-
|
|
|
+
|
|
|
Dictionary<string, List<RGroupList>> groups = new Dictionary<string, List<RGroupList>>();
|
|
|
if (scopes.Contains("school"))
|
|
|
{
|
|
|
if (!string.IsNullOrEmpty(school))
|
|
|
{
|
|
|
- List<RGroupList> groupLists= new List<RGroupList>();
|
|
|
+ List<RGroupList> groupLists = new List<RGroupList>();
|
|
|
await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<RGroupList>(queryText: sql.ToString(),
|
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"GroupList-{school}") }))
|
|
|
{
|
|
@@ -692,28 +709,30 @@ namespace TEAMModelOS.SDK
|
|
|
groups.Add("School", groupLists);
|
|
|
}
|
|
|
}
|
|
|
- else if (scopes.Contains("private")) {
|
|
|
+ else if (scopes.Contains("private"))
|
|
|
+ {
|
|
|
List<RGroupList> groupLists = new List<RGroupList>();
|
|
|
await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<RGroupList>(queryText: sql.ToString(),
|
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"GroupList") }))
|
|
|
{
|
|
|
- if (string.IsNullOrWhiteSpace(school))
|
|
|
- {
|
|
|
- groupLists.Add(item);
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- if (!string.IsNullOrWhiteSpace(item.school))
|
|
|
- {
|
|
|
- if (item.school.Equals(school))
|
|
|
- {
|
|
|
- groupLists.Add(item);
|
|
|
- }
|
|
|
- }
|
|
|
- else {
|
|
|
- groupLists.Add(item);
|
|
|
- }
|
|
|
- }
|
|
|
+ groupLists.Add(item);
|
|
|
+ //if (string.IsNullOrWhiteSpace(school))
|
|
|
+ //{
|
|
|
+ // groupLists.Add(item);
|
|
|
+ //}
|
|
|
+ //else
|
|
|
+ //{
|
|
|
+ // if (!string.IsNullOrWhiteSpace(item.school))
|
|
|
+ // {
|
|
|
+ // if (item.school.Equals(school))
|
|
|
+ // {
|
|
|
+ // groupLists.Add(item);
|
|
|
+ // }
|
|
|
+ // }
|
|
|
+ // else {
|
|
|
+ // groupLists.Add(item);
|
|
|
+ // }
|
|
|
+ //}
|
|
|
}
|
|
|
groups.Add("Teacher", groupLists);
|
|
|
}
|
|
@@ -722,16 +741,17 @@ 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);
|
|
|
}
|
|
|
}
|
|
|
- var lists= groups.SelectMany(x => x.Value).ToList() ;
|
|
|
+ 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)
|
|
|
+ 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)
|
|
|
{
|
|
|
|
|
|
- try {
|
|
|
+ try
|
|
|
+ {
|
|
|
HashSet<RGroupList> changes = new HashSet<RGroupList>();
|
|
|
var members = groups.SelectMany(y => y.members).ToList();
|
|
|
//去重
|
|
@@ -768,7 +788,7 @@ namespace TEAMModelOS.SDK
|
|
|
});
|
|
|
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
List<TmdUser> tmdsData = new List<TmdUser>();
|
|
|
if (tmdids.IsNotEmpty())
|
|
|
{
|
|
@@ -776,8 +796,9 @@ namespace TEAMModelOS.SDK
|
|
|
if ($"{type}".Equals("activity"))
|
|
|
{
|
|
|
var mbers = groups.SelectMany(x => x.members).Where(z => !string.IsNullOrEmpty(z.code));
|
|
|
- var schoolTeachers = mbers.GroupBy(y=>y.code).Select(m=>new {key= m.Key,list = m.ToList() });
|
|
|
- foreach (var schoolTeacher in schoolTeachers) {
|
|
|
+ var schoolTeachers = mbers.GroupBy(y => y.code).Select(m => new { key = m.Key, list = m.ToList() });
|
|
|
+ foreach (var schoolTeacher in schoolTeachers)
|
|
|
+ {
|
|
|
StringBuilder tmdidSql = new StringBuilder($"SELECT distinct c.name,c.id,c.picture FROM c ");
|
|
|
string insql = string.Join(",", schoolTeacher.list.Select(x => $"'{x.id}'"));
|
|
|
tmdidSql.Append($" where c.id in ({insql})");
|
|
@@ -797,8 +818,9 @@ namespace TEAMModelOS.SDK
|
|
|
}
|
|
|
});
|
|
|
}
|
|
|
- else {
|
|
|
-
|
|
|
+ else
|
|
|
+ {
|
|
|
+
|
|
|
//处理研修名单,如果是学校老师的,则需要检查SchoolTeacher
|
|
|
//处理 学校教研组,学校管理人员,学校任课教师,学校研修名单。
|
|
|
if (!string.IsNullOrEmpty(school) && ($"{type}".Equals("yxtrain") || $"{type}".Equals("research") || $"{type}".Equals("manage") || $"{type}".Equals("subject")))
|
|
@@ -859,9 +881,10 @@ namespace TEAMModelOS.SDK
|
|
|
}
|
|
|
|
|
|
///获取真实的名称
|
|
|
- var content = new StringContent(tmdids.Select(x=>x.id).ToJsonString(), Encoding.UTF8, "application/json");
|
|
|
+ var content = new StringContent(tmdids.Select(x => x.id).ToJsonString(), Encoding.UTF8, "application/json");
|
|
|
string json = await _coreAPIHttpService.GetUserInfos(content);
|
|
|
- if (!string.IsNullOrWhiteSpace(json)) {
|
|
|
+ if (!string.IsNullOrWhiteSpace(json))
|
|
|
+ {
|
|
|
try
|
|
|
{
|
|
|
List<TmdInfo> tmdInfos = json.ToObject<List<TmdInfo>>();
|
|
@@ -875,7 +898,8 @@ namespace TEAMModelOS.SDK
|
|
|
y.name = tmd?.name;
|
|
|
y.picture = tmd?.picture;
|
|
|
}
|
|
|
- else {
|
|
|
+ else
|
|
|
+ {
|
|
|
groups.ForEach(x =>
|
|
|
{
|
|
|
int item = x.members.RemoveAll(z => z.id.Equals(y.id) && z.type == 1);
|
|
@@ -914,49 +938,55 @@ namespace TEAMModelOS.SDK
|
|
|
{
|
|
|
change.tcount = change.members.Where(x => x.type == 1).Count();
|
|
|
change.scount = change.members.Where(x => x.type == 2).Count();
|
|
|
- GroupList group= change.ToJsonString().ToObject<GroupList>();
|
|
|
+ GroupList group = change.ToJsonString().ToObject<GroupList>();
|
|
|
await client.GetContainer(Constant.TEAMModelOS, groupTbname).ReplaceItemAsync(group, group.id, new PartitionKey(group.code));
|
|
|
}
|
|
|
}
|
|
|
- groups.ForEach(x => x.members.ForEach(y=> {
|
|
|
- if (y.type == 1) {
|
|
|
- var tmd =tmdids.Find(t => t.id.Equals(y.id));
|
|
|
+ groups.ForEach(x => x.members.ForEach(y => {
|
|
|
+ if (y.type == 1)
|
|
|
+ {
|
|
|
+ var tmd = tmdids.Find(t => t.id.Equals(y.id));
|
|
|
y.name = tmd?.name;
|
|
|
y.picture = tmd?.picture;
|
|
|
}
|
|
|
if (y.type == 2)
|
|
|
{
|
|
|
- var student = students.Find(t => t.id.Equals(y.id)&& t.code.Equals(y.code));
|
|
|
+ var student = students.Find(t => t.id.Equals(y.id) && t.code.Equals(y.code));
|
|
|
y.name = student?.name;
|
|
|
y.picture = student?.picture;
|
|
|
y.classId = student?.classId;
|
|
|
}
|
|
|
}));
|
|
|
-
|
|
|
- HashSet<string > schoolCodes= groups.SelectMany(x=>x.members).Where(y=>!string.IsNullOrEmpty(y.code)).Select(z=>z.code).ToHashSet();
|
|
|
- if (schoolCodes != null && schoolCodes.Count > 0) {
|
|
|
- List<School> schools= new List<School>();
|
|
|
- string insql = $"select c.name,c.id from c where c.id in ({string.Join(",",schoolCodes.Select(x=>$"'{x}'"))})";
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<School>(queryText: insql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") })) {
|
|
|
+
|
|
|
+ HashSet<string> schoolCodes = groups.SelectMany(x => x.members).Where(y => !string.IsNullOrEmpty(y.code)).Select(z => z.code).ToHashSet();
|
|
|
+ if (schoolCodes != null && schoolCodes.Count > 0)
|
|
|
+ {
|
|
|
+ List<School> schools = new List<School>();
|
|
|
+ string insql = $"select c.name,c.id from c where c.id in ({string.Join(",", schoolCodes.Select(x => $"'{x}'"))})";
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<School>(queryText: insql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey("Base") }))
|
|
|
+ {
|
|
|
schools.Add(item);
|
|
|
}
|
|
|
- if (schools.IsNotEmpty()) {
|
|
|
+ if (schools.IsNotEmpty())
|
|
|
+ {
|
|
|
groups.SelectMany(x => x.members).Where(y => !string.IsNullOrEmpty(y.code)).ToList().ForEach(z => {
|
|
|
- var school= schools.Find(j => j.id.Equals(z.code));
|
|
|
+ var school = schools.Find(j => j.id.Equals(z.code));
|
|
|
z.schoolName = school?.name;
|
|
|
});
|
|
|
}
|
|
|
}
|
|
|
return (groups, mbs);
|
|
|
- } catch (Exception ex) {
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
await _dingDing.SendBotMsg($"{_coreAPIHttpService.options.Get("Default").location},GetGroupListMemberInfo()\n{ex.Message}{ex.StackTrace}\n", GroupNames.醍摩豆服務運維群組);
|
|
|
}
|
|
|
return (null, null);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
|
|
|
public class CompareIdCode : IEqualityComparer<(string id, string code)>
|
|
|
{
|