zhouj1203@hotmail.com 1 год назад
Родитель
Сommit
5bf1a1a635

+ 11 - 3
TEAMModelOS.SDK/Models/Service/ExamService.cs

@@ -1,4 +1,5 @@
 using Azure.Cosmos;
+using DocumentFormat.OpenXml.Drawing.Charts;
 using DocumentFormat.OpenXml.Office2010.Excel;
 using MathNet.Numerics.Distributions;
 using System;
@@ -63,7 +64,7 @@ namespace TEAMModelOS.SDK.Models.Service
             }
         }
 
-        public static async Task<List<(string name, List<(string classId, double average)> classMore, double total,List<(string studentId, double scores, string classId)>students )>> getGradeScore(CoreAPIHttpService _coreAPIHttpService, DingDing _dingDing, CosmosClient client, List<string> classIds, string periodId, string schooCode, long stime, long etime)
+        public static async Task<List<(string name, List<(string classId, double average)> classMore, double total,List<(string studentId, double scores, string classId)>students )>> getGradeScore(CoreAPIHttpService _coreAPIHttpService, DingDing _dingDing, CosmosClient client, List<string> classIds, string periodId, string schooCode,List<string> examType, long stime, long etime)
         {
             List<(string name, List<(string classId,double average)> classMore, double total, List<(string studentId, double scores, string classId)> stus)> grades = new();
             //List<(string grade, double score)> grades = new();
@@ -99,14 +100,21 @@ namespace TEAMModelOS.SDK.Models.Service
                         using var json = await JsonDocument.ParseAsync(response.ContentStream);
                         sc = json.ToObject<School>();
                     }
+                    StringBuilder stringBuilder = new($"select value(c) from c where c.startTime >= {stime} and c.startTime < {etime} and c.progress = 'finish' and c.period.id = '{periodId}'");
+                    if (examType.Any()) {
+                        stringBuilder.Append($" and c.examType.name in ({string.Join(",", examType.Select(o => $"'{o}'"))}) ");
+                    }
+                    stringBuilder.Append("order by c.createTime desc");
                     //var gradeNames = sc.period.Where(x => x.id.Equals(periodId.ToString()))?.FirstOrDefault().grades;
                     //var index = gradeNames.IndexOf(gradeName.ToString());
-                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamInfo>(queryText: $"select value(c) from c where c.startTime >= {stime} and c.startTime < {etime} and c.progress = 'finish' order by c.createTime desc", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Exam-{schooCode}") }))
+                    await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamInfo>(
+                        queryText: stringBuilder.ToString(), 
+                        requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Exam-{schooCode}") }))
                     {
                         exams.Add(item);
                     }
                     List<ExamInfo> newExams = new();
-                    exams = exams.Where(x => x.period.id.Equals(periodId)).ToList();
+                    //exams = exams.Where(x => x.period.id.Equals(periodId)).ToList();
                     foreach (ExamInfo info in exams)
                     {
                         bool flag = true;

+ 2 - 1
TEAMModelOS/Controllers/Student/OverallEducationController.cs

@@ -604,7 +604,8 @@ namespace TEAMModelOS.Controllers
                
                 var studyYear =  int.Parse($"{_studyYear}");
                 var semesterData=  SchoolService.GetSemester(period, time: SchoolService.GetOpensByStudyYearAndSemester(period.semesters,studyYear,$"{_semesterId}"));
-                var examData =  await ExamService.getGradeScore(_coreAPIHttpService, _dingDing,_azureCosmos.GetCosmosClient(), grade_classes.Select(x=>x.id).ToList(), $"{_periodId}", school.id,   semesterData.date.ToUnixTimeMilliseconds(), semesterData.nextSemester.ToUnixTimeMilliseconds());
+                var examData =  await ExamService.getGradeScore(_coreAPIHttpService, _dingDing,_azureCosmos.GetCosmosClient(), grade_classes.Select(x=>x.id).ToList(), $"{_periodId}", school.id,  schoolSetting.overallEducationSetting.examTypes
+                    , semesterData.date.ToUnixTimeMilliseconds(), semesterData.nextSemester.ToUnixTimeMilliseconds());
               
                 var groupExam= examData.GroupBy(x => x.name).Select(y => new { key = y.Key, list = y });
                 List<ExamScore> exam3Scores = new List<ExamScore>();