瀏覽代碼

处理状态

zhouj1203@hotmail.com 3 年之前
父節點
當前提交
19e60555f0

+ 6 - 5
TEAMModelOS.FunctionV4/CosmosDB/TriggerExam.cs

@@ -388,17 +388,18 @@ namespace TEAMModelOS.FunctionV4
                                 {
                                     newStatus = 1;
                                 }
-                                //处理活动中间件
+                                /*//处理活动中间件
                                 List<StuActivity> stus = new();
                                 await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Student").GetItemQueryIterator<StuActivity>(
                                                    queryText: $"select c.id from c where c.id  = '{info.id}'"))
                                 {
                                     stus.Add(item);
-                                }
-                                if (info.source.Equals("1") && stus.Count == 0)
+                                }*/
+                                /*if (info.source.Equals("1") && stus.Count == 0)
                                 {
-                                    await Activity(_coreAPIHttpService, info, classes, client, _dingDing, sub, examClassResults);
-                                }
+                                   
+                                }*/
+                                await Activity(_coreAPIHttpService, info, classes, client, _dingDing, sub, examClassResults);
                                 foreach (ExamSubject subject in info.subjects)
                                 {
                                     await createClassResultAsync(info, examClassResults, subject, fno, _azureCosmos, _dingDing, _azureStorage);

+ 103 - 85
TEAMModelOS.SDK/Models/Service/FixDataService.cs

@@ -407,83 +407,102 @@ namespace TEAMModelOS.SDK.Models.Service
         /// <param name="client"></param>
         /// <param name="data"></param>
         /// <returns></returns>
-        public static async Task<List<string>> FixExamPublish(CosmosClient client, JsonElement data)
+        public static async Task<List<string>> FixExamPublish(CosmosClient client, DingDing _dingDing, JsonElement data, Option _option)
         {
             List<string> infos = new List<string>();
-            var dict = data.GetProperty("publish").GetInt32();
+            //var dict = data.GetProperty("publish").GetInt32();
             //List<(string id, string code)> ps = new List<(string id, string code)>();
             List<object> exams = new List<object>();
             List<Task<ItemResponse<ExamInfo>>> tasks = new List<Task<ItemResponse<ExamInfo>>>();
-            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: $"SELECT value(c) FROM c where c.pk = 'Exam'"))
-            {
-
-                using var json = await JsonDocument.ParseAsync(item.ContentStream);
-                if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
+            try {
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: $"SELECT value(c) FROM c where c.pk = 'Exam' and c.publish = '0'" ))
                 {
-                    foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
+
+                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
                     {
-                        if (obj.TryGetProperty("publish", out JsonElement publish))
+                        foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
                         {
-                            try
+                            if (obj.TryGetProperty("publish", out JsonElement publish))
                             {
-                                if (!string.IsNullOrEmpty(publish.GetString()) && publish.GetString().Equals("0"))
+                                try
                                 {
-                                    ExamInfo examInfo = new ExamInfo
+                                    if (string.IsNullOrEmpty(publish.GetString()) || publish.GetString().Equals("0"))
                                     {
-                                        id = obj.GetProperty("id").GetString(),
-                                        owner = obj.TryGetProperty("owner", out JsonElement owner) ? owner.GetString() : "",
-                                        //examInfo.owner = obj.GetProperty("owner").GetString();
-                                        name = obj.GetProperty("name").GetString(),
-                                        school = obj.GetProperty("school").GetString(),
-                                        creatorId = obj.GetProperty("creatorId").GetString(),
-                                        stuCount = obj.TryGetProperty("stuCount", out JsonElement stuCount) ? stuCount.GetInt32() : 0,
-                                        createTime = obj.GetProperty("createTime").GetInt64(),
-                                        updateTime = obj.TryGetProperty("updateTime", out JsonElement updateTime) ? updateTime.GetInt64() : DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
-                                        startTime = obj.GetProperty("startTime").GetInt64(),
-                                        endTime = obj.GetProperty("endTime").GetInt64(),
-                                        year = obj.TryGetProperty("year", out JsonElement year) ? year.GetInt32() : 0,
-                                        source = obj.TryGetProperty("source", out JsonElement source) ? source.GetString() : "0",
-                                        classes = obj.TryGetProperty("classes", out JsonElement classes) ? classes.ToObject<List<string>>() : new List<string>(),
-                                        stuLists = obj.TryGetProperty("stuLists", out JsonElement stuLists) ? stuLists.ToObject<List<string>>() : new List<string>(),
-                                        //examInfo.stuLists = obj.GetProperty("stuLists").ToObject<List<string>>();
-                                        papers = obj.TryGetProperty("papers", out JsonElement papers) ? papers.ToObject<List<PaperSimple>>() : new List<PaperSimple>(),
-                                        type = obj.TryGetProperty("type", out JsonElement type) ? type.GetString() : "",
-                                        period = obj.TryGetProperty("period", out JsonElement period) ? period.ToObject<PeriodSimple>() : new PeriodSimple(),
-                                        grades = obj.TryGetProperty("grades", out JsonElement grades) ? grades.ToObject<List<Grade>>() : new List<Grade>(),
-                                        subjects = obj.GetProperty("subjects").ToObject<List<ExamSubject>>(),
-                                        progress = obj.TryGetProperty("progress", out JsonElement progress) ? progress.GetString() : "finish",
-                                        scope = obj.TryGetProperty("scope", out JsonElement scope) ? scope.GetString() : "school",
-                                        examType = obj.TryGetProperty("examType", out JsonElement examType) ? examType.ToObject<Custom>() : new Custom(),
-                                        status = obj.TryGetProperty("status", out JsonElement status) ? status.GetInt32() : 0,
-                                        average = obj.TryGetProperty("average", out JsonElement average) ? average.GetDouble() : 0,
-                                        sRate = obj.TryGetProperty("sRate", out JsonElement sRate) ? sRate.GetDouble() : 0,
-                                        lostStu = obj.TryGetProperty("lostStu", out JsonElement lostStu) ? lostStu.ToObject<List<string>>() : new List<string>(),
-                                        standard = obj.TryGetProperty("standard", out JsonElement standard) ? standard.GetDouble() : 0,
-                                        size = obj.TryGetProperty("size", out JsonElement size) ? standard.GetInt64() : 0,
-                                        income = obj.TryGetProperty("income", out JsonElement income) ? income.GetInt32() : 0,
-                                        touch = obj.TryGetProperty("touch", out JsonElement touch) ? touch.GetInt32() : 0,
-                                        publish = 0,
-                                        groupLists = obj.TryGetProperty("groupLists", out JsonElement groupLists) ? groupLists.ToObject<List<Dictionary<string, List<string>>>>() : new List<Dictionary<string, List<string>>>(),
-                                        targets = obj.TryGetProperty("targets", out JsonElement targets) ? targets.ToObject<List<JsonElement>>() : new List<JsonElement>()
+                                        ExamInfo examInfo = new ExamInfo
+                                        {
+                                            id = obj.GetProperty("id").GetString(),
+                                            owner = obj.TryGetProperty("owner", out JsonElement owner) ? owner.GetString() : "",
+                                            code = obj.TryGetProperty("code", out JsonElement code) ? code.GetString() : "",
+                                            //examInfo.owner = obj.GetProperty("owner").GetString();
+                                            name = obj.GetProperty("name").GetString(),
+                                            school = obj.GetProperty("school").GetString(),
+                                            creatorId = obj.GetProperty("creatorId").GetString(),
+                                            stuCount = obj.TryGetProperty("stuCount", out JsonElement stuCount) ? stuCount.GetInt32() : 0,
+                                            createTime = obj.GetProperty("createTime").GetInt64(),
+                                            updateTime = obj.TryGetProperty("updateTime", out JsonElement updateTime) ? updateTime.GetInt64() : DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
+                                            startTime = obj.TryGetProperty("startTime", out JsonElement startTime) ? startTime.GetInt64() : DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
+                                            endTime = obj.TryGetProperty("endTime", out JsonElement endTime) ? endTime.GetInt64() : DateTimeOffset.UtcNow.ToUnixTimeMilliseconds(),
+                                            year = obj.TryGetProperty("year", out JsonElement year) ? year.GetInt32() : 0,
+                                            source = obj.TryGetProperty("source", out JsonElement source) ? source.GetString() : "0",
+                                            classes = obj.TryGetProperty("classes", out JsonElement classes) ? classes.ToObject<List<string>>() : new List<string>(),
+                                            stuLists = obj.TryGetProperty("stuLists", out JsonElement stuLists) ? stuLists.ToObject<List<string>>() : new List<string>(),
+                                            //examInfo.stuLists = obj.GetProperty("stuLists").ToObject<List<string>>();
+                                            papers = obj.TryGetProperty("papers", out JsonElement papers) ? papers.ToObject<List<PaperSimple>>() : new List<PaperSimple>(),
+                                            type = obj.TryGetProperty("type", out JsonElement type) ? type.GetString() : "",
+                                            period = obj.TryGetProperty("period", out JsonElement period) ? period.ToObject<PeriodSimple>() : new PeriodSimple(),
+                                            grades = obj.TryGetProperty("grades", out JsonElement grades) ? grades.ToObject<List<Grade>>() : new List<Grade>(),
+                                            subjects = obj.GetProperty("subjects").ToObject<List<ExamSubject>>(),
+                                            progress = obj.TryGetProperty("progress", out JsonElement progress) ? progress.GetString() : "finish",
+                                            scope = obj.TryGetProperty("scope", out JsonElement scope) ? scope.GetString() : "school",
+                                            examType = obj.TryGetProperty("examType", out JsonElement examType) ? examType.ToObject<Custom>() : new Custom(),
+                                            status = obj.TryGetProperty("status", out JsonElement status) ? status.GetInt32() : 0,
+                                            average = obj.TryGetProperty("average", out JsonElement average) ? average.GetDouble() : 0,
+                                            sRate = obj.TryGetProperty("sRate", out JsonElement sRate) ? sRate.GetDouble() : 0,
+                                            lostStu = obj.TryGetProperty("lostStu", out JsonElement lostStu) ? lostStu.ToObject<List<string>>() : new List<string>(),
+                                            standard = obj.TryGetProperty("standard", out JsonElement standard) ? standard.GetDouble() : 0,
+                                            size = obj.TryGetProperty("size", out JsonElement size) ? size.GetInt64() : 0,
+                                            income = obj.TryGetProperty("income", out JsonElement income) ? income.GetInt32() : 0,
+                                            touch = obj.TryGetProperty("touch", out JsonElement touch) ? touch.GetInt32() : 0,
+                                            publish = 0,
+                                            groupLists = obj.TryGetProperty("groupLists", out JsonElement groupLists) ? groupLists.ToObject<List<Dictionary<string, List<string>>>>() : new List<Dictionary<string, List<string>>>(),
+                                            targets = obj.TryGetProperty("targets", out JsonElement targets) ? targets.ToObject<List<JsonElement>>() : new List<JsonElement>()
+                                        };
+                                        tasks.Add(client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<ExamInfo>(examInfo, examInfo.id, new PartitionKey(examInfo.code)));
+                                        infos.Add(examInfo.id);
                                     };
-                                    tasks.Add(client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<ExamInfo>(examInfo, examInfo.id, new PartitionKey(examInfo.code)));
-                                    infos.Add(examInfo.id);
-                                };
-                            }
-                            catch (Exception e)
-                            {
-                                var aa = obj.GetProperty("id").GetString();
+                                }
+                                catch (Exception ex)
+                                {
+                                    await _dingDing.SendBotMsg($"OS,{_option.Location} /fix-data/fix-publish \n {ex.Message}{ex.StackTrace}", GroupNames.成都开发測試群組);
+                                }
+
                             }
 
                         }
-
+                    }                  
+                }
+                //await Task.WhenAll(tasks);
+                int pagesize = 50;
+                if (tasks.Count <= pagesize)
+                {
+                    await Task.WhenAll(tasks);
+                }
+                else
+                {
+                    int pages = (tasks.Count + pagesize) / pagesize; //256是批量操作最大值,pages = (total + max -1) / max;
+                    for (int i = 0; i < pages; i++)
+                    {
+                        var listssb = tasks.Skip((i) * pagesize).Take(pagesize).ToList();
+                        await Task.WhenAll(listssb);
                     }
                 }
-                await Task.WhenAll(tasks);
-                /* info.publish = dict;
-                 await client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<ExamInfo>(info, info.id, new PartitionKey(info.code));
-                 infos.Add(info.id);*/
+
+
+            } catch (Exception e) {
+                await _dingDing.SendBotMsg($"OS,{_option.Location} /fix-data/fix-publish \n {e.Message}{e.StackTrace}", GroupNames.成都开发測試群組);
             }
+            
             /*foreach (var item in exams) {
                 dynamic dyn = JsonConvert.DeserializeObject(Convert.ToString(item)) ;
                 foreach (var obj in dyn)
@@ -514,16 +533,19 @@ namespace TEAMModelOS.SDK.Models.Service
             List<ExamClassResult> results = new List<ExamClassResult>();
             List<string> ids = new List<string>();
             List<Task<ItemResponse<ExamClassResult>>> tasks = new List<Task<ItemResponse<ExamClassResult>>>();
+            List<Task<ItemResponse<ExamInfo>>> taskInfo = new List<Task<ItemResponse<ExamInfo>>>();
             try
             {
-                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(queryText: $"SELECT value(c) FROM c where c.pk = 'ExamClassResult' and c.scIds <> []"))
+                /*await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamClassResult>(queryText: $"SELECT value(c) FROM c where c.pk = 'ExamClassResult' and c._ts >= 1640966400"))
                 {
                     results.Add(item);
                     //await Task.WhenAll(tasks);
                 }
+                HashSet<string> examIds = new HashSet<string>();
                 foreach (var item in results)
                 {
                     ids.Add(item.id);
+                    examIds.Add(item.examId);
                     List<int> status = new List<int>();
                     //List<string> classIds = new List<string>();
                     //classIds.Add(item.info.id);
@@ -554,39 +576,35 @@ namespace TEAMModelOS.SDK.Models.Service
                         }
                         item.status = vs;
                     }
-                    /*if (!string.IsNullOrEmpty(item.info.id) && item.scIds.Count == 0)
-                    {
-                        string school = string.Empty;
-                        if (item.scope.Equals("school"))
-                        {
-                            school = item.school;
-                        }
-                        (List<RMember> rs, List<RGroupList> groupLists) = await GroupListService.GetStutmdidListids(_coreAPIHttpService, client, _dingDing, classIds, school, null);
-                        foreach (string id in item.studentIds)
+                    *//*if (item.progress == true) {
+                        int n = 0;
+                        foreach (string sta in item.studentIds)
                         {
-                            if (rs.Count == 0)
-                            {
-                                item.scIds.Add("");
-                            }
-                            else
+                            for (int i = 0; i < item.studentScores[n].Count; i++)
                             {
-                                var code = rs.FirstOrDefault(c => c.id == id)?.code;
-                                //var code = rs.Where(x => x.id.Equals(id))?.FirstOrDefault().code;
-                                if (code != null)
+                                if (item.studentScores[n][i] == -1)
                                 {
-                                    item.scIds.Add(code.ToString());
-                                }
-                                else
-                                {
-                                    item.scIds.Add("");
+                                    item.studentScores[n][i] = 0;
                                 }
                             }
-
+                            n++;
                         }
-                    }*/
+                    }*//*
+
+                    
                     tasks.Add(client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<ExamClassResult>(item, item.id, new PartitionKey(item.code)));
+                }*/
+                List<ExamInfo> info = new List<ExamInfo>();
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamInfo>(queryText: $"SELECT value(c) FROM c where c.pk = 'Exam' and c.progress = 'finish' and c._ts >= 1640966400"))
+                {
+                    info.Add(item);
+                    //await Task.WhenAll(tasks);
+                }
+                foreach (var item in info) {
+                    item.updateTime = DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
+                    taskInfo.Add(client.GetContainer(Constant.TEAMModelOS, "Common").ReplaceItemAsync<ExamInfo>(item, item.id, new PartitionKey(item.code)));
                 }
-                await Task.WhenAll(tasks);
+                await Task.WhenAll(taskInfo);
             }
             catch (Exception ex)
             {

+ 88 - 57
TEAMModelOS/Controllers/Common/ExamController.cs

@@ -424,6 +424,87 @@ namespace TEAMModelOS.Controllers
         [AuthToken(Roles = "teacher,admin")]
         [HttpPost("find")]
         public async Task<IActionResult> Find(JsonElement requert)
+        {
+            try
+            {
+                if (!requert.TryGetProperty("code", out JsonElement code)) return BadRequest();
+                var client = _azureCosmos.GetCosmosClient();               
+                var query = $"select c.id,c.name,c.code,c.period,c.startTime,c.endTime,c.stuCount,c.type,c.progress,c.examType,c.createTime,c.source, c.subjects, c.grades,c.owner, c.scope,c.classes,c.sRate,c.lostStu,c.sStatus,c.qamode,c.school from c where (c.status<>404 or IS_DEFINED(c.status) = false)";
+                if (requert.TryGetProperty("classIds", out JsonElement classIds))
+                {
+                    List<string> ids = classIds.ToObject<List<string>>();
+                    HashSet<string> strs = new HashSet<string>();
+                    if (ids.Count > 1)
+                    {
+                        foreach (string id in ids)
+                        {
+                            strs.Add($"array_contains(c.classes,'{id}')");
+                        }
+                    }
+                    else
+                    {
+                        string ssr = ids.Count > 0 ? ids[0] : "";
+                        strs.Add($"array_contains(c.classes,'{ssr}')");
+                    }
+                    string ss = string.Join(" or ", strs);
+                    query = $"select c.id,c.name,c.code,c.period,c.startTime,c.endTime,c.stuCount,c.type,c.progress,c.examType,c.createTime, c.source,c.subjects, c.grades,c.owner, c.scope,c.classes,c.sRate,c.lostStu,c.sStatus,c.qamode,c.school from c where ({ss}) and (c.status<>404 or IS_DEFINED(c.status) = false)";
+                };
+
+                string continuationToken = string.Empty;
+                string token = default;
+                //是否需要进行分页查询,默认不分页
+                bool iscontinuation = false;
+                if (requert.TryGetProperty("token", out JsonElement token_1))
+                {
+                    token = token_1.GetString();
+                    iscontinuation = true;
+                };
+                //默认不指定返回大小
+                int? topcout = null;
+                if (requert.TryGetProperty("count", out JsonElement jcount))
+                {
+                    if (!jcount.ValueKind.Equals(JsonValueKind.Undefined) && !jcount.ValueKind.Equals(JsonValueKind.Null) && jcount.TryGetInt32(out int data))
+                    {
+                        topcout = data;
+                    }
+                }
+
+                List<ExamInfo> examInfo = new List<ExamInfo>();
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: query, continuationToken: token, requestOptions: new QueryRequestOptions() { MaxItemCount = topcout, PartitionKey = new PartitionKey($"Exam-{code}") }))
+                {
+
+                    using var json = await JsonDocument.ParseAsync(item.ContentStream);
+                    if (json.RootElement.TryGetProperty("_count", out JsonElement count) && count.GetUInt16() > 0)
+                    {
+                        foreach (var obj in json.RootElement.GetProperty("Documents").EnumerateArray())
+                        {
+                            //obj.TryGetProperty("progress", out JsonElement progress);
+                            examInfo.Add(obj.ToObject<ExamInfo>());
+                        }
+                    }
+                    if (iscontinuation)
+                    {
+                        continuationToken = item.GetContinuationToken();
+                        break;
+                    }
+
+                }               
+                return Ok(new { examInfo, token = continuationToken});
+            }
+            catch (Exception e)
+            {
+                await _dingDing.SendBotMsg($"OS,{_option.Location},exam/find()\n{e.Message}", GroupNames.醍摩豆服務運維群組);
+                return BadRequest();
+            }
+
+        }
+
+
+        [ProducesDefaultResponseType]
+        [Authorize(Roles = "IES")]
+        [AuthToken(Roles = "teacher,admin")]
+        [HttpPost("find-by-analysis")]
+        public async Task<IActionResult> FindByAnalysis(JsonElement requert)
         {
             try
             {
@@ -481,10 +562,10 @@ namespace TEAMModelOS.Controllers
                         PartitionKey = "Exam",
                         year = year
                     };
-
                     await table.Save<SchoolYear>(sy);
                 }
-                var query = $"select c.id,c.name,c.code,c.period,c.startTime,c.endTime,c.stuCount,c.type,c.progress,c.examType,c.createTime,c.source, c.subjects, c.grades,c.owner, c.scope,c.classes,c.sRate,c.lostStu,c.sStatus ,c.school from c where (c.status<>404 or IS_DEFINED(c.status) = false )";
+                var query = $"select c.id,c.name,c.code,c.period,c.startTime,c.endTime,c.stuCount,c.type,c.progress,c.examType,c.createTime,c.source, c.subjects, c.grades,c.owner, c.scope,c.classes,c.sRate,c.lostStu,c.sStatus,c.qamode,c.school from c " +
+                    $"where (c.status<>404 or IS_DEFINED(c.status) = false and c.scope = 'school' and c.school = {code}) and c.pk = 'Exam'";
                 if (requert.TryGetProperty("classIds", out JsonElement classIds))
                 {
                     List<string> ids = classIds.ToObject<List<string>>();
@@ -502,7 +583,8 @@ namespace TEAMModelOS.Controllers
                         strs.Add($"array_contains(c.classes,'{ssr}')");
                     }
                     string ss = string.Join(" or ", strs);
-                    query = $"select c.id,c.name,c.code,c.period,c.startTime,c.endTime,c.stuCount,c.type,c.progress,c.examType,c.createTime, c.source,c.subjects, c.grades,c.owner, c.scope,c.classes,c.sRate,c.lostStu,c.sStatus  ,c.school from c where ({ss}) and (c.status<>404 or IS_DEFINED(c.status) = false )";
+                    query = $"select c.id,c.name,c.code,c.period,c.startTime,c.endTime,c.stuCount,c.type,c.progress,c.examType,c.createTime, c.source,c.subjects, c.grades,c.owner, c.scope,c.classes,c.sRate,c.lostStu,c.sStatus,c.qamode,c.school from c " +
+                        $"where ({ss}) and (c.status<>404 or IS_DEFINED(c.status) = false and c.scope = 'school' and c.school = {code}) and c.pk = 'Exam'";
                 };
 
                 string continuationToken = string.Empty;
@@ -525,7 +607,7 @@ namespace TEAMModelOS.Controllers
                 }
 
                 List<ExamInfo> examInfo = new List<ExamInfo>();
-                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: query, continuationToken: token, requestOptions: new QueryRequestOptions() { MaxItemCount = topcout, PartitionKey = new PartitionKey($"Exam-{code}") }))
+                await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryStreamIterator(queryText: query, continuationToken: token, requestOptions: new QueryRequestOptions() { MaxItemCount = topcout}))
                 {
 
                     using var json = await JsonDocument.ParseAsync(item.ContentStream);
@@ -543,63 +625,12 @@ namespace TEAMModelOS.Controllers
                         break;
                     }
 
-                }
-                //List<string> examIds = new List<string>();
-                /* List<ExamResult> examResults = new List<ExamResult>();
-                 foreach (ExamInfo info in examInfos) {                    
-                     await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "Common").GetItemQueryIterator<ExamResult>(
-                                        queryText: $"select value(c) from c where c.examId  = '{info.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"ExamResult-{info.id}") }))
-                     {
-                         examResults.Add(item);
-                     }
-                 }*/
-
-                /* List<(string id, double scores)> listExamInfo = new List<(string id, double scores)>(); 
-                 foreach (ExamInfo info in examInfos)
-                 {
-                     //记录某次考试所有学生得分总分
-                     double score = 0;
-                     double allScore = 0;
-                     int stuCount = 0;
-                     foreach (ExamResult examResult in examResults) {
-                         if (info.id == examResult.examId) {
-                             foreach (List<double> sc in examResult.studentScores) {
-                                 score += sc.Sum();
-                             }
-                             stuCount = examResult.studentIds.Count;
-                         }                        
-                     }
-                     double ascore = stuCount > 0 ? Math.Round(score * 0.1 / stuCount, 2) : 0;
-                     foreach (PaperSimple simple in  info.papers) {
-                         allScore += simple.point.Sum();
-                     }
-                     listExamInfo.Add((info.id, (allScore> 0 ? ascore / allScore * 100: 0)));
-                 }
-                 var examInfo = examInfos.Select(o =>
-                                     new
-                                     {
-                                         o.id,
-                                         o.scope,
-                                         o.stuCount,
-                                         o.name,
-                                         o.period,
-                                         o.startTime,
-                                         o.endTime,
-                                         o.type,
-                                         o.progress,
-                                         o.examType,
-                                         o.createTime,
-                                         o.subjects,
-                                         o.grades,
-                                         o.classes,
-                                         score = listExamInfo.FirstOrDefault(c => c.id == o.id).scores,
-                                     }
-                );*/
+                }               
                 return Ok(new { examInfo, token = continuationToken, year });
             }
             catch (Exception e)
             {
-                await _dingDing.SendBotMsg($"OS,{_option.Location},exam/find()\n{e.Message}", GroupNames.醍摩豆服務運維群組);
+                await _dingDing.SendBotMsg($"OS,{_option.Location},exam/find-by-analysis()\n{e.Message}", GroupNames.醍摩豆服務運維群組);
                 return BadRequest();
             }
 

+ 1 - 1
TEAMModelOS/Controllers/XTest/FixDataController.cs

@@ -1342,7 +1342,7 @@ namespace TEAMModelOS.Controllers
         public async Task<IActionResult> FixExamPublish(JsonElement data)
         {
             var client = _azureCosmos.GetCosmosClient();
-            List<string> infos = await FixDataService.FixExamPublish(client, data);
+            List<string> infos = await FixDataService.FixExamPublish(client, _dingDing, data, _option);
             return Ok(new { infos });
         }
         [ProducesDefaultResponseType]