Browse Source

名单的学生所属学校查询。

CrazyIter_Bin 3 years ago
parent
commit
bff9fe0225
1 changed files with 12 additions and 7 deletions
  1. 12 7
      TEAMModelOS.SDK/Models/Service/TriggerStuActivity.cs

+ 12 - 7
TEAMModelOS.SDK/Models/Service/TriggerStuActivity.cs

@@ -229,14 +229,19 @@ namespace TEAMModelFunction
                 }
                 if (studentss.IsNotEmpty())
                 {
-                    List<string> inidstus = new List<string>();
-                    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("TEAMModelOS", "Student").GetItemQueryIterator<StuInfo>(queryText: querystu, requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base-{school}") }))
-                    {
-                        stuInfos.Add(item);
+                    var stuGroups = studentss.GroupBy(x => x.code).ToList().Select(x => new { key = x.Key, list = x.ToList() }) ;
+                    foreach (var gp in stuGroups) {
+                        List<string> inidstus = new List<string>();
+                        gp.list.Select(x => x.id).ToList().ForEach(x => { inidstus.Add($"'{x}'"); });
+                        PartitionKey partitionKey = new PartitionKey($"Base-{gp.key.Replace("Base-", "")}");
+                        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("TEAMModelOS", "Student").GetItemQueryIterator<StuInfo>(queryText: querystu, requestOptions: new QueryRequestOptions() { PartitionKey= partitionKey }))
+                        {
+                            stuInfos.Add(item);
+                        }
                     }
+                    
                 }
                 students.ForEach(x =>
                 {