zhouj1203@hotmail.com 1 year ago
parent
commit
78367802c1

+ 6 - 1
TEAMModelOS.SDK/Models/Cosmos/Common/ArtEvaluation.cs

@@ -68,7 +68,7 @@ namespace TEAMModelOS.SDK.Models.Cosmos.Common
         //发布层级 0校级,1区级
         public int? publish { get; set; } = 0;
         public List<ArtSubject> subjects { get; set; } = new List<ArtSubject>();
-        public PeriodSimple period { get; set; }
+        public ArtPeriod period { get; set; } = new ArtPeriod();
         public string periodType { get; set; }
         public List<LostStudent> lost { get; set; } = new List<LostStudent>();
         //用来判定是否已经处理过缺考人数逻辑标识
@@ -98,6 +98,11 @@ namespace TEAMModelOS.SDK.Models.Cosmos.Common
         public string id { get; set; }
         public string name { get; set; }
     }
+    public class ArtPeriod
+    {
+        public string id { get; set; }
+        public string name { get; set; }
+    }
     public class Acs {
         [JsonPropertyName("infoId")]
         public string infoId { get; set; }

+ 33 - 8
TEAMModelOS/Controllers/XTest/FixDataController.cs

@@ -56,6 +56,7 @@ using TEAMModelOS.Models.Dto;
 using TEAMModelOS.SDK.Models.Cosmos.OpenEntity;
 using DocumentFormat.OpenXml.Office2021.DocumentTasks;
 using Task = System.Threading.Tasks.Task;
+using System.Threading;
 
 namespace TEAMModelOS.Controllers
 {
@@ -613,20 +614,44 @@ namespace TEAMModelOS.Controllers
                 tasks.Add(client.GetContainer(Constant.TEAMModelOS, Constant.Common).ReplaceItemAsync(evaluation, evaluation.id, new PartitionKey(evaluation.code)));
             }
             await tasks.TaskPage(10);*/
-            List<Task<ItemResponse<ArtEvaluation>>> tasks = new List<Task<ItemResponse<ArtEvaluation>>>();
+            /*List<Task<ItemResponse<ArtEvaluation>>> tasks = new List<Task<ItemResponse<ArtEvaluation>>>();
             foreach (ArtEvaluation evaluation in art)
             {
                 evaluation.endTime = 1709112600000;
                 tasks.Add(client.GetContainer(Constant.TEAMModelOS, Constant.Common).ReplaceItemAsync(evaluation, evaluation.id, new PartitionKey(evaluation.code)));
-            }
-            await tasks.TaskPage(10);
-            List<Task<ItemResponse<ExamInfo>>> taskInfo = new List<Task<ItemResponse<ExamInfo>>>();
-            foreach (ExamInfo info in infos)
+            }*/
+            //await tasks.TaskPage(10);
+            /*            List<Task<ItemResponse<ExamInfo>>> taskInfo = new List<Task<ItemResponse<ExamInfo>>>();
+                        foreach (ExamInfo info in infos)
+                        {
+                            info.period = art.Where(c => c.school.Equals(info.school)).FirstOrDefault().period;
+                            taskInfo.Add(client.GetContainer(Constant.TEAMModelOS, Constant.Common).ReplaceItemAsync(info, info.id, new PartitionKey(info.code)));
+                        }*/
+            string sql = $"SELECT  value(c) FROM c ";
+            List<School> schools = new();
+            await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<School>(queryText: sql, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Base") }))
             {
-                info.endTime = 1709112600000;
-                taskInfo.Add(client.GetContainer(Constant.TEAMModelOS, Constant.Common).ReplaceItemAsync(info, info.id, new PartitionKey(info.code)));
+                schools.Add(item);
             }
-            await taskInfo.TaskPage(10);           
+            await Parallel.ForEachAsync(art, async(rt,_)  => {
+                //School scInfo = new();
+                //School scInfo = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>($"{art.school}", partitionKey: new Azure.Cosmos.PartitionKey("Base"));
+                /*var response = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemStreamAsync($"{rt.school}", partitionKey: new Azure.Cosmos.PartitionKey("Base"));
+                if (response.Status == 200)
+                {
+                    using var cJson = await JsonDocument.ParseAsync(response.ContentStream);
+                    scInfo = cJson.ToObject<School>();
+                }*/
+                var periods = schools.Where(c => c.id.Equals(rt.school)).SelectMany(z => z.period).Where(p => p.periodType.Equals(rt.periodType)).ToList();
+                if (periods.Count > 0) {
+                    ArtPeriod artPeriod = new() { 
+                        id = periods.FirstOrDefault().id,
+                        name = periods.FirstOrDefault().name
+                    };
+                    rt.period = artPeriod;
+                }
+                await client.GetContainer(Constant.TEAMModelOS, Constant.Common).ReplaceItemAsync(rt, rt.id, new PartitionKey(rt.code));
+            });         
             return Ok();
         }
         [ProducesDefaultResponseType]