|
@@ -215,10 +215,7 @@ namespace TEAMModelOS.SDK
|
|
{
|
|
{
|
|
tmdids.AddRange(x.tmids);
|
|
tmdids.AddRange(x.tmids);
|
|
}
|
|
}
|
|
- if (x.teachers.IsNotEmpty())
|
|
|
|
- {
|
|
|
|
- tmdids.AddRange(x.teachers);
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
classes.Remove(x.id);
|
|
classes.Remove(x.id);
|
|
}
|
|
}
|
|
foreach (var x in tchLists)
|
|
foreach (var x in tchLists)
|
|
@@ -304,16 +301,6 @@ namespace TEAMModelOS.SDK
|
|
}
|
|
}
|
|
});
|
|
});
|
|
}
|
|
}
|
|
- if (x.teachers.IsNotEmpty())
|
|
|
|
- {
|
|
|
|
- x.teachers.ForEach(y => {
|
|
|
|
- var tmdinfo = tmdinfos.Where(z => z.id.Equals(y)).FirstOrDefault();
|
|
|
|
- if (tmdinfo != null)
|
|
|
|
- {
|
|
|
|
- classListInfo.tmdInfos.Add(tmdinfo);
|
|
|
|
- }
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
classInfo.Add(classListInfo);
|
|
classInfo.Add(classListInfo);
|
|
});
|
|
});
|
|
tchLists.ForEach(x => {
|
|
tchLists.ForEach(x => {
|
|
@@ -360,9 +347,10 @@ namespace TEAMModelOS.SDK
|
|
}
|
|
}
|
|
return (null, null, null);
|
|
return (null, null, null);
|
|
}
|
|
}
|
|
- public static async Task<(List<TmdInfo> tmdinfos, List<StuInfo> students,List<ClassListInfo>classInfo)> GetStuList(CosmosClient client, DingDing _dingDing, List<string> claes, string school)
|
|
|
|
|
|
+ public static async Task<(List<TmdInfo> tmdinfos, List<StuInfo> students, List<ClassListInfo> classInfo)> GetTchList(CosmosClient client, DingDing _dingDing, List<string> claes, string school)
|
|
{
|
|
{
|
|
- try {
|
|
|
|
|
|
+ try
|
|
|
|
+ {
|
|
List<string> classes = new List<string>();
|
|
List<string> classes = new List<string>();
|
|
foreach (string ss in claes)
|
|
foreach (string ss in claes)
|
|
{
|
|
{
|
|
@@ -372,13 +360,14 @@ namespace TEAMModelOS.SDK
|
|
List<Students> studentss = new List<Students>();
|
|
List<Students> studentss = new List<Students>();
|
|
List<string> tmdids = new List<string>();
|
|
List<string> tmdids = new List<string>();
|
|
List<StuInfo> stuInfos = new List<StuInfo>();
|
|
List<StuInfo> stuInfos = new List<StuInfo>();
|
|
- if (!classes.IsNotEmpty()) { return (tmdinfos, new List<StuInfo>(),null); }
|
|
|
|
|
|
+ if (!classes.IsNotEmpty()) { return (tmdinfos, new List<StuInfo>(), null); }
|
|
List<string> sqlList = new List<string>();
|
|
List<string> sqlList = new List<string>();
|
|
classes.ForEach(x => { sqlList.Add($" '{x}' "); });
|
|
classes.ForEach(x => { sqlList.Add($" '{x}' "); });
|
|
string sql = string.Join(" , ", sqlList);
|
|
string sql = string.Join(" , ", sqlList);
|
|
List<StuList> schList = new List<StuList>();
|
|
List<StuList> schList = new List<StuList>();
|
|
List<Student> students = new List<Student>();
|
|
List<Student> students = new List<Student>();
|
|
- if (!string.IsNullOrEmpty(school)) {
|
|
|
|
|
|
+ if (!string.IsNullOrEmpty(school))
|
|
|
|
+ {
|
|
await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id in ({sql})",
|
|
await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id in ({sql})",
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"StuList-{school}") }))
|
|
requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"StuList-{school}") }))
|
|
{
|
|
{
|
|
@@ -396,8 +385,9 @@ namespace TEAMModelOS.SDK
|
|
{
|
|
{
|
|
tchLists.Add(item);
|
|
tchLists.Add(item);
|
|
}
|
|
}
|
|
-
|
|
|
|
- foreach (var x in schList) {
|
|
|
|
|
|
+
|
|
|
|
+ foreach (var x in schList)
|
|
|
|
+ {
|
|
if (x.students.IsNotEmpty())
|
|
if (x.students.IsNotEmpty())
|
|
{
|
|
{
|
|
studentss.AddRange(x.students);
|
|
studentss.AddRange(x.students);
|
|
@@ -408,9 +398,10 @@ namespace TEAMModelOS.SDK
|
|
}
|
|
}
|
|
classes.Remove(x.id);
|
|
classes.Remove(x.id);
|
|
}
|
|
}
|
|
- foreach (var x in tchLists)
|
|
|
|
|
|
+ foreach (var x in tchLists)
|
|
{
|
|
{
|
|
- if (x.students.IsNotEmpty()) {
|
|
|
|
|
|
+ if (x.students.IsNotEmpty())
|
|
|
|
+ {
|
|
studentss.AddRange(x.students);
|
|
studentss.AddRange(x.students);
|
|
}
|
|
}
|
|
if (x.tmids.IsNotEmpty())
|
|
if (x.tmids.IsNotEmpty())
|
|
@@ -420,7 +411,8 @@ namespace TEAMModelOS.SDK
|
|
classes.Remove(x.id);
|
|
classes.Remove(x.id);
|
|
}
|
|
}
|
|
|
|
|
|
- if (tmdids.IsNotEmpty()) {
|
|
|
|
|
|
+ if (tmdids.IsNotEmpty())
|
|
|
|
+ {
|
|
List<TmdInfo> infos = new List<TmdInfo>();
|
|
List<TmdInfo> infos = new List<TmdInfo>();
|
|
List<string> inids = new List<string>();
|
|
List<string> inids = new List<string>();
|
|
tmdids.ForEach(x => { inids.Add($"'{x}'"); });
|
|
tmdids.ForEach(x => { inids.Add($"'{x}'"); });
|
|
@@ -433,9 +425,11 @@ namespace TEAMModelOS.SDK
|
|
}
|
|
}
|
|
tmdinfos.AddRange(infos);
|
|
tmdinfos.AddRange(infos);
|
|
}
|
|
}
|
|
- if (studentss.IsNotEmpty()) {
|
|
|
|
|
|
+ if (studentss.IsNotEmpty())
|
|
|
|
+ {
|
|
List<string> inidstus = new List<string>();
|
|
List<string> inidstus = new List<string>();
|
|
- foreach (Students stu in studentss) {
|
|
|
|
|
|
+ foreach (Students stu in studentss)
|
|
|
|
+ {
|
|
var querystu = $"SELECT c.id,c.code,c.name,c.picture,c.classId,c.year,c.schoolId FROM c where c.id = '{stu.id}'";
|
|
var querystu = $"SELECT c.id,c.code,c.name,c.picture,c.classId,c.year,c.schoolId FROM c where c.id = '{stu.id}'";
|
|
await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryIterator<StuInfo>(queryText: querystu, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{stu.code}") }))
|
|
await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryIterator<StuInfo>(queryText: querystu, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{stu.code}") }))
|
|
{
|
|
{
|
|
@@ -452,17 +446,20 @@ namespace TEAMModelOS.SDK
|
|
}
|
|
}
|
|
students.ForEach(x =>
|
|
students.ForEach(x =>
|
|
{
|
|
{
|
|
- if (!stuInfos.Select(y => y.classId).ToList().Contains(x.id)) {
|
|
|
|
- stuInfos.Add(new StuInfo { id = x.id, code = x.code, schoolId = x.schoolId, classId = x.classId, name = x.name, picture = x.picture, year = x.year,groupId=x.groupId,groupName=x.groupName,no=x.no });
|
|
|
|
|
|
+ if (!stuInfos.Select(y => y.classId).ToList().Contains(x.id))
|
|
|
|
+ {
|
|
|
|
+ stuInfos.Add(new StuInfo { id = x.id, code = x.code, schoolId = x.schoolId, classId = x.classId, name = x.name, picture = x.picture, year = x.year, groupId = x.groupId, groupName = x.groupName, no = x.no });
|
|
}
|
|
}
|
|
});
|
|
});
|
|
List<ClassListInfo> classInfo = new List<ClassListInfo>();
|
|
List<ClassListInfo> classInfo = new List<ClassListInfo>();
|
|
schList.ForEach(x => {
|
|
schList.ForEach(x => {
|
|
- ClassListInfo classListInfo = new ClassListInfo {id=x.id,name=x.name };
|
|
|
|
- if (x.students.IsNotEmpty()) {
|
|
|
|
|
|
+ ClassListInfo classListInfo = new ClassListInfo { id = x.id, name = x.name };
|
|
|
|
+ if (x.students.IsNotEmpty())
|
|
|
|
+ {
|
|
x.students.ForEach(y => {
|
|
x.students.ForEach(y => {
|
|
- var stuinfo= stuInfos.Where(z => z.id.Equals(y.id)).FirstOrDefault();
|
|
|
|
- if (stuinfo != null) {
|
|
|
|
|
|
+ var stuinfo = stuInfos.Where(z => z.id.Equals(y.id)).FirstOrDefault();
|
|
|
|
+ if (stuinfo != null)
|
|
|
|
+ {
|
|
classListInfo.stuInfos.Add(stuinfo);
|
|
classListInfo.stuInfos.Add(stuinfo);
|
|
}
|
|
}
|
|
});
|
|
});
|
|
@@ -505,6 +502,125 @@ namespace TEAMModelOS.SDK
|
|
});
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
+ //var classeids= students.GroupBy(x => x.classId).Select(x => x.Key).ToList();
|
|
|
|
+ List<ClassInfo> classInfos = await GetClassInfo(client, _dingDing, classes, school);
|
|
|
|
+ classInfos.ForEach(x =>
|
|
|
|
+ {
|
|
|
|
+ ClassListInfo classListInfo = new ClassListInfo { id = x.id, name = x.name };
|
|
|
|
+ var list = students.Where(y => y.classId.Equals(x.id)).ToList();
|
|
|
|
+ list.ForEach(z => { classListInfo.stuInfos.Add(new StuInfo { id = z.id, code = z.code, schoolId = z.schoolId, classId = z.classId, name = z.name, picture = z.picture, year = z.year, groupId = z.groupId, groupName = z.groupName, no = z.no }); });
|
|
|
|
+ classInfo.Add(classListInfo);
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ return (tmdinfos, stuInfos, classInfo);
|
|
|
|
+ }
|
|
|
|
+ catch (Exception ex)
|
|
|
|
+ {
|
|
|
|
+ await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-OS,TriggerStuActivity-GetStuList\n{ex.Message}\n{ex.StackTrace}", GroupNames.醍摩豆服務運維群組);
|
|
|
|
+ }
|
|
|
|
+ return (null, null, null);
|
|
|
|
+ }
|
|
|
|
+ public static async Task<(List<TmdInfo> tmdinfos, List<StuInfo> students,List<ClassListInfo>classInfo)> GetStuList(CosmosClient client, DingDing _dingDing, List<string> claes, string school)
|
|
|
|
+ {
|
|
|
|
+ try {
|
|
|
|
+ List<string> classes = new List<string>();
|
|
|
|
+ foreach (string ss in claes)
|
|
|
|
+ {
|
|
|
|
+ classes.Add(ss);
|
|
|
|
+ }
|
|
|
|
+ List<TmdInfo> tmdinfos = new List<TmdInfo>();
|
|
|
|
+ List<Students> studentss = new List<Students>();
|
|
|
|
+ List<string> tmdids = new List<string>();
|
|
|
|
+ List<StuInfo> stuInfos = new List<StuInfo>();
|
|
|
|
+ if (!classes.IsNotEmpty()) { return (tmdinfos, new List<StuInfo>(),null); }
|
|
|
|
+ List<string> sqlList = new List<string>();
|
|
|
|
+ classes.ForEach(x => { sqlList.Add($" '{x}' "); });
|
|
|
|
+ string sql = string.Join(" , ", sqlList);
|
|
|
|
+ List<StuList> schList = new List<StuList>();
|
|
|
|
+ List<Student> students = new List<Student>();
|
|
|
|
+ if (!string.IsNullOrEmpty(school)) {
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<StuList>(queryText: $"select value(c) from c where c.id in ({sql})",
|
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"StuList-{school}") }))
|
|
|
|
+ {
|
|
|
|
+ schList.Add(item);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ foreach (var x in schList) {
|
|
|
|
+ if (x.students.IsNotEmpty())
|
|
|
|
+ {
|
|
|
|
+ studentss.AddRange(x.students);
|
|
|
|
+ }
|
|
|
|
+ if (x.tmids.IsNotEmpty())
|
|
|
|
+ {
|
|
|
|
+ tmdids.AddRange(x.tmids);
|
|
|
|
+ }
|
|
|
|
+ classes.Remove(x.id);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ if (tmdids.IsNotEmpty()) {
|
|
|
|
+ List<TmdInfo> infos = new List<TmdInfo>();
|
|
|
|
+ List<string> inids = new List<string>();
|
|
|
|
+ tmdids.ForEach(x => { inids.Add($"'{x}'"); });
|
|
|
|
+ var insql = string.Join(",", inids);
|
|
|
|
+ var queryslt = $"SELECT value(c) FROM c where c.id in ({insql})";
|
|
|
|
+ //合并代码/
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryIterator<TmdInfo>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
|
|
|
|
+ {
|
|
|
|
+ infos.Add(item);
|
|
|
|
+ }
|
|
|
|
+ tmdinfos.AddRange(infos);
|
|
|
|
+ }
|
|
|
|
+ if (studentss.IsNotEmpty()) {
|
|
|
|
+ List<string> inidstus = new List<string>();
|
|
|
|
+ foreach (Students stu in studentss) {
|
|
|
|
+ var querystu = $"SELECT c.id,c.code,c.name,c.picture,c.classId,c.year,c.schoolId FROM c where c.id = '{stu.id}'";
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryIterator<StuInfo>(queryText: querystu, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"{stu.code}") }))
|
|
|
|
+ {
|
|
|
|
+ stuInfos.Add(item);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ /*studentss.Select(x => x.id).ToList().ForEach(x => { inidstus.Add($"'{x}'"); });
|
|
|
|
+ var insqlstu = string.Join(",", inidstus);
|
|
|
|
+ var querystu = $"SELECT c.id,c.code,c.name,c.picture,c.classId,c.year,c.schoolId FROM c where c.id in ({insqlstu})";
|
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryIterator<StuInfo>(queryText: querystu, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{school}") }))
|
|
|
|
+ {
|
|
|
|
+ stuInfos.Add(item);
|
|
|
|
+ }*/
|
|
|
|
+ }
|
|
|
|
+ students.ForEach(x =>
|
|
|
|
+ {
|
|
|
|
+ if (!stuInfos.Select(y => y.classId).ToList().Contains(x.id)) {
|
|
|
|
+ stuInfos.Add(new StuInfo { id = x.id, code = x.code, schoolId = x.schoolId, classId = x.classId, name = x.name, picture = x.picture, year = x.year,groupId=x.groupId,groupName=x.groupName,no=x.no });
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ List<ClassListInfo> classInfo = new List<ClassListInfo>();
|
|
|
|
+ schList.ForEach(x => {
|
|
|
|
+ ClassListInfo classListInfo = new ClassListInfo {id=x.id,name=x.name };
|
|
|
|
+ if (x.students.IsNotEmpty()) {
|
|
|
|
+ x.students.ForEach(y => {
|
|
|
|
+ var stuinfo= stuInfos.Where(z => z.id.Equals(y.id)).FirstOrDefault();
|
|
|
|
+ if (stuinfo != null) {
|
|
|
|
+ classListInfo.stuInfos.Add(stuinfo);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ if (x.tmids.IsNotEmpty())
|
|
|
|
+ {
|
|
|
|
+ x.tmids.ForEach(y => {
|
|
|
|
+ var tmdinfo = tmdinfos.Where(z => z.id.Equals(y)).FirstOrDefault();
|
|
|
|
+ if (tmdinfo != null)
|
|
|
|
+ {
|
|
|
|
+ classListInfo.tmdInfos.Add(tmdinfo);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ classInfo.Add(classListInfo);
|
|
|
|
+ });
|
|
|
|
+
|
|
//var classeids= students.GroupBy(x => x.classId).Select(x => x.Key).ToList();
|
|
//var classeids= students.GroupBy(x => x.classId).Select(x => x.Key).ToList();
|
|
List<ClassInfo> classInfos= await GetClassInfo(client, _dingDing, classes, school);
|
|
List<ClassInfo> classInfos= await GetClassInfo(client, _dingDing, classes, school);
|
|
classInfos.ForEach(x =>
|
|
classInfos.ForEach(x =>
|