|
@@ -357,95 +357,109 @@ namespace TEAMModelOS.SDK
|
|
|
{
|
|
|
try
|
|
|
{
|
|
|
- List<string> classes = new List<string>();
|
|
|
- foreach (string ss in claes)
|
|
|
- {
|
|
|
- classes.Add(ss);
|
|
|
- }
|
|
|
List<TmdInfo> tmdinfos = new List<TmdInfo>();
|
|
|
- List<string> tmdids = new List<string>();
|
|
|
- List<StuInfo> stuInfos = new List<StuInfo>();
|
|
|
- if (!classes.IsNotEmpty()) { return (tmdinfos, null); }
|
|
|
- List<string> sqlList = new List<string>();
|
|
|
- classes.ForEach(x => { sqlList.Add($" '{x}' "); });
|
|
|
- string sql = string.Join(" , ", sqlList);
|
|
|
- List<TchList> tchLists = new List<TchList>();
|
|
|
-
|
|
|
- if (!string.IsNullOrEmpty(school))
|
|
|
+ List<ClassListInfo> classInfo = new List<ClassListInfo>();
|
|
|
+ if (claes.Count == 1 && claes.First().Equals("default"))
|
|
|
{
|
|
|
- await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<TchList>(queryText: $"select value(c) from c where c.id in ({sql})",
|
|
|
- requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"TchList-{school}") }))
|
|
|
+ List<TmdInfo> infos = new List<TmdInfo>();
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<TmdInfo>(queryText: $"SELECT value(c) FROM c ", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
|
|
|
{
|
|
|
- tchLists.Add(item);
|
|
|
+ infos.Add(item);
|
|
|
}
|
|
|
-
|
|
|
+ tmdinfos.AddRange(infos);
|
|
|
}
|
|
|
-
|
|
|
-
|
|
|
- foreach (var x in tchLists)
|
|
|
- {
|
|
|
-
|
|
|
- if (x.teachers.IsNotEmpty())
|
|
|
+ else {
|
|
|
+ List<string> classes = new List<string>();
|
|
|
+ foreach (string ss in claes)
|
|
|
{
|
|
|
- tmdids.AddRange(x.teachers);
|
|
|
+ classes.Add(ss);
|
|
|
}
|
|
|
- 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, "Teacher").GetItemQueryIterator<TmdInfo>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
|
|
|
+
|
|
|
+ List<string> tmdids = new List<string>();
|
|
|
+ List<StuInfo> stuInfos = new List<StuInfo>();
|
|
|
+ if (!classes.IsNotEmpty()) { return (tmdinfos, null); }
|
|
|
+ List<string> sqlList = new List<string>();
|
|
|
+ classes.ForEach(x => { sqlList.Add($" '{x}' "); });
|
|
|
+ string sql = string.Join(" , ", sqlList);
|
|
|
+ List<TchList> tchLists = new List<TchList>();
|
|
|
+
|
|
|
+ if (!string.IsNullOrEmpty(school))
|
|
|
{
|
|
|
- infos.Add(item);
|
|
|
+ await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<TchList>(queryText: $"select value(c) from c where c.id in ({sql})",
|
|
|
+ requestOptions: new QueryRequestOptions() { PartitionKey = new Azure.Cosmos.PartitionKey($"TchList-{school}") }))
|
|
|
+ {
|
|
|
+ tchLists.Add(item);
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
- tmdinfos.AddRange(infos);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- List<ClassListInfo> classInfo = new List<ClassListInfo>();
|
|
|
- tchLists.ForEach(x => {
|
|
|
- ClassListInfo classListInfo = new ClassListInfo { id = x.id, name = x.name };
|
|
|
- if (x.teachers.IsNotEmpty())
|
|
|
+
|
|
|
+
|
|
|
+ foreach (var x in tchLists)
|
|
|
{
|
|
|
- x.teachers.ForEach(y => {
|
|
|
- var tmdinfo = tmdinfos.Where(z => z.id.Equals(y)).FirstOrDefault();
|
|
|
- if (tmdinfo != null)
|
|
|
- {
|
|
|
- classListInfo.tmdInfos.Add(tmdinfo);
|
|
|
- }
|
|
|
- });
|
|
|
+
|
|
|
+ if (x.teachers.IsNotEmpty())
|
|
|
+ {
|
|
|
+ tmdids.AddRange(x.teachers);
|
|
|
+ }
|
|
|
+ classes.Remove(x.id);
|
|
|
}
|
|
|
- classInfo.Add(classListInfo);
|
|
|
- });
|
|
|
- tchLists.ForEach(x => {
|
|
|
- ClassListInfo classListInfo = new ClassListInfo { id = x.id, name = x.name };
|
|
|
- if (x.teachers.IsNotEmpty())
|
|
|
+
|
|
|
+ if (tmdids.IsNotEmpty())
|
|
|
{
|
|
|
- x.teachers.ForEach(y => {
|
|
|
- var tmdinfo = tmdinfos.Where(z => z.id.Equals(y)).FirstOrDefault();
|
|
|
- if (tmdinfo != null)
|
|
|
- {
|
|
|
- classListInfo.tmdInfos.Add(tmdinfo);
|
|
|
- }
|
|
|
- });
|
|
|
+ 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, "Teacher").GetItemQueryIterator<TmdInfo>(queryText: queryslt, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
|
|
|
+ {
|
|
|
+ infos.Add(item);
|
|
|
+ }
|
|
|
+ tmdinfos.AddRange(infos);
|
|
|
}
|
|
|
- classInfo.Add(classListInfo);
|
|
|
- });
|
|
|
|
|
|
|
|
|
- //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 };
|
|
|
- classInfo.Add(classListInfo);
|
|
|
- });
|
|
|
+
|
|
|
+ tchLists.ForEach(x => {
|
|
|
+ ClassListInfo classListInfo = new ClassListInfo { id = x.id, name = x.name };
|
|
|
+ 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);
|
|
|
+ });
|
|
|
+ tchLists.ForEach(x => {
|
|
|
+ ClassListInfo classListInfo = new ClassListInfo { id = x.id, name = x.name };
|
|
|
+ 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);
|
|
|
+ });
|
|
|
+
|
|
|
+
|
|
|
+ //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 };
|
|
|
+ classInfo.Add(classListInfo);
|
|
|
+ });
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
return (tmdinfos, classInfo);
|
|
|
}
|