CrazyIter_Bin 3 年 前
コミット
410c021dab

+ 2 - 6
TEAMModelOS.SDK/Models/Service/FixDataService.cs

@@ -23,7 +23,7 @@ namespace TEAMModelOS.SDK.Models.Service
         /// <param name="_azureStorage"></param>
         /// <param name="data"></param>
         /// <returns></returns>
-        public static async Task FixStudentInfo(CosmosClient client, DingDing _dingDing, AzureStorageFactory _azureStorage, JsonElement data) {
+        public static async Task<List<Student>> FixStudentInfo(CosmosClient client, DingDing _dingDing, AzureStorageFactory _azureStorage, JsonElement data) {
             var code = data.GetProperty("code").GetString();
             var ids = data.GetProperty("ids").ToObject<List<string>>();
             var dict = data.GetProperty("dict").ToObject<Dictionary<string, object>>();
@@ -56,11 +56,7 @@ namespace TEAMModelOS.SDK.Models.Service
                     students.Add(item);
                 }
             }
-            //List<Task<ItemResponse<Student>>> studen = new List<Task<ItemResponse<Student>>>();
-            //students.ForEach(x => {
-            //    studen.Add(client.GetContainer("TEAMModelOS", "Student").ReplaceItemAsync<Student>(x,x.id,new PartitionKey(x.code)));
-            //});
-            //await Task.WhenAll(studen);
+            return students;
         }
         /// <summary>
         /// 修复内容模块数据

+ 24 - 24
TEAMModelOS/Controllers/School/StudentController.cs

@@ -876,24 +876,24 @@ namespace TEAMModelOS.Controllers
                                         )
                                     );
                             }
-                            else if(dicClassStuds.ContainsKey(classId))
-                            {
-                                Console.WriteLine(acc.ToJsonString());
-                                dicClassStuds[classId].Add(
-                                        (
-                                            acc.GetProperty("id").GetString(),
-                                            acc.GetProperty("name").GetString(),
-                                            acc.GetProperty("picture").GetString(),
-                                            acc.GetProperty("year").GetInt32(),
-                                            acc.GetProperty("no").GetString(), acc.TryGetProperty("periodId",out JsonElement _periodId)&&  _periodId.ValueKind.Equals(JsonValueKind.String) ? _periodId.GetString() : null
-                                        )
-                                    ); 
-                            }
-                            else
-                            {
-                                dicClassStuds.Add(classId, 
-                                        new List<(string id, string name, string pic, int year, string no,string periodId)>() 
-                                        {
+                            else {
+                                if (dicClassStuds.ContainsKey(classId))
+                                {
+                                    dicClassStuds[classId].Add(
+                                            (
+                                                acc.GetProperty("id").GetString(),
+                                                acc.GetProperty("name").GetString(),
+                                                acc.GetProperty("picture").GetString(),
+                                                acc.GetProperty("year").GetInt32(),
+                                                acc.GetProperty("no").GetString(), acc.TryGetProperty("periodId", out JsonElement _periodId) && _periodId.ValueKind.Equals(JsonValueKind.String) ? _periodId.GetString() : null
+                                            )
+                                        );
+                                }
+                                else
+                                {
+                                    dicClassStuds.Add(classId,
+                                            new List<(string id, string name, string pic, int year, string no, string periodId)>()
+                                            {
                                             (
                                                 acc.GetProperty("id").GetString(),
                                                 acc.GetProperty("name").GetString(),
@@ -901,8 +901,9 @@ namespace TEAMModelOS.Controllers
                                                 acc.GetProperty("year").GetInt32(),
                                                 acc.GetProperty("no").GetString(),  acc.TryGetProperty("periodId",out JsonElement _periodId)&&  _periodId.ValueKind.Equals(JsonValueKind.String) ? _periodId.GetString() : null
                                             )
-                                        }
-                                    );
+                                            }
+                                        );
+                                }
                             }
                         }
                     }
@@ -924,8 +925,7 @@ namespace TEAMModelOS.Controllers
                         classId = classInfos[classStud.Key].GetProperty("id").GetString();
                         classNo = classInfos[classStud.Key].GetProperty("no").GetString();
                         className = classInfos[classStud.Key].GetProperty("name").GetString();
-                        //gradeId = classInfos[classStud.Key].GetProperty("gradeId").GetString();
-                        periodId = classInfos[classStud.Key].GetProperty("periodId").ValueKind.Equals(JsonValueKind.String)? classInfos[classStud.Key].GetProperty("periodId").GetString():null;
+                        periodId = classInfos[classStud.Key].TryGetProperty("periodId", out JsonElement _periodId) && _periodId.ValueKind.Equals(JsonValueKind.String) ? _periodId.GetString() : null ;
                         if (classInfos[classStud.Key].TryGetProperty("year", out JsonElement year)) {
                             if (year.ValueKind.Equals(JsonValueKind.Number)) {
                                 classYear = classInfos[classStud.Key].GetProperty("year").GetInt32();
@@ -945,7 +945,7 @@ namespace TEAMModelOS.Controllers
                                          classNo,
                                          className,
                                          gradeId,
-                                         periodId,
+                                         periodId=  string.IsNullOrEmpty(periodId)?  o.periodId: periodId,
                                          classYear
 
                                      });
@@ -965,7 +965,7 @@ namespace TEAMModelOS.Controllers
                         classNo = (string)null,
                         className = (string)null,
                         gradeId = (string)null,
-                        periodId = o.periodId,
+                        o.periodId,
                         classYear = -1
                     }));
 

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

@@ -73,8 +73,8 @@ namespace TEAMModelOS.Controllers.XTest
             try
             {
                 var client = _azureCosmos.GetCosmosClient();
-                await FixDataService.FixStudentInfo(client, _dingDing, _azureStorage, data);
-                return Ok(new { });
+               var list= await FixDataService.FixStudentInfo(client, _dingDing, _azureStorage, data);
+                return Ok(new { list});
             }
             catch (Exception ex)
             {

+ 3 - 3
TEAMModelOS/TEAMModelOS.csproj

@@ -43,9 +43,9 @@
     <SpaRoot>ClientApp\</SpaRoot>
     <DefaultItemExcludes>$(DefaultItemExcludes);$(SpaRoot)node_modules\**</DefaultItemExcludes>
     <UserSecretsId>078b5d89-7d90-4f6a-88fc-7d96025990a8</UserSecretsId>
-    <Version>5.2107.13</Version>
-    <AssemblyVersion>5.2107.13.1</AssemblyVersion>
-    <FileVersion>5.2107.13.1</FileVersion>
+    <Version>5.2107.151</Version>
+    <AssemblyVersion>5.2107.151.1</AssemblyVersion>
+    <FileVersion>5.2107.151.1</FileVersion>
     <Description>1.修复Word导入题目转码失败的html代码。
 2.修复Word导入题目选项不能识别全角的A-Z字符,转为半角。
 3.学生信息增加学段信息。</Description>