CrazyIter_Bin 3 年之前
父節點
當前提交
40d46c2191

+ 1 - 1
TEAMModelOS.FunctionV4/ServiceBus/ActiveTaskTopic.cs

@@ -1010,7 +1010,7 @@ namespace TEAMModelOS.FunctionV4.ServiceBus
                                  
                                 catch (Exception ex)
                                 {
-                                    await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}课程读取base.json,{_lessonId}\n{ex.Message}\n{ex.StackTrace}\n{lessonRecord.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
+                                   // await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}课程读取base.json,{_lessonId}\n{ex.Message}\n{ex.StackTrace}\n{lessonRecord.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
                                 }
                                 break;
                             //更新 时间线

+ 1 - 1
TEAMModelOS/Controllers/Client/HiTeachController.cs

@@ -116,7 +116,7 @@ namespace TEAMModelOS.Controllers.Client
                 msg = new { lesson_id = $"{_lessonId}", tmdid = $"{_tmdid}", grant_types = updates, school = $"{_school}", scope = $"{_scope}" }.ToJsonString();
                 var messageChange = new ServiceBusMessage(msg);
                 messageChange.ApplicationProperties.Add("name", "LessonRecordEvent");
-                await _dingDing.SendBotMsg($"{_option.Location},课堂id:{_lessonId} 更新事件,{msg}", GroupNames.醍摩豆服務運維群組);
+                //await _dingDing.SendBotMsg($"{_option.Location},课堂id:{_lessonId} 更新事件,{msg}", GroupNames.醍摩豆服務運維群組);
                 await _serviceBus.GetServiceBusClient().SendMessageAsync(ActiveTask, messageChange);
                 return Ok(new { status = 200 });
             }

+ 71 - 25
TEAMModelOS/Controllers/XTest/FixDataController.cs

@@ -1714,7 +1714,20 @@ namespace TEAMModelOS.Controllers
                             tasks.Add(cosmosClient.GetContainer("TEAMModelOS", "Student").ReplaceItemAsync<StuActivity>(stuActivity, stuActivity.id, new PartitionKey(stuActivity.code)));
                         }
                     }
-                    await Task.WhenAll(tasks);
+                    int pagesize = 1000;
+                    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);
+                        }
+                    }
                     return Ok(new { state = 200, msg = "去重成功" });
                 }
                 else
@@ -2166,6 +2179,9 @@ namespace TEAMModelOS.Controllers
             }
             List<Student> studentsData = new List<Student>();
             foreach (var id in ids) {
+                if (id.Equals("ydzt")) {
+                    continue;
+                }
                 List<Student> students = new List<Student>();
                 string sqlstu = "select value(c) from c ";
                 await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student)
@@ -2173,11 +2189,26 @@ namespace TEAMModelOS.Controllers
                 {
                     students.Add(item);
                 }
+                List<Task<ItemResponse<Student>>> tasks = new List<Task<ItemResponse<Student>>>();
                 var groups= students.Where(x => !string.IsNullOrWhiteSpace(x.classId)).GroupBy(y => y.classId).Select(z => new { key = z.Key,list = z.ToList() });
                 foreach (var group in groups) {
                     foreach (var stu in group.list) {
                         var lst = DoIrs(group.list, stu);
-                        await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).ReplaceItemAsync(stu, stu.id, new PartitionKey($"Base-{id}"));
+                        tasks.Add(_azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).ReplaceItemAsync(stu, stu.id, new PartitionKey($"Base-{id}")));
+                    }
+                }
+                int pagesize = 1000;
+                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);
                     }
                 }
                 studentsData.AddRange(students);
@@ -2186,36 +2217,51 @@ namespace TEAMModelOS.Controllers
         }
         private List<Student> DoIrs(List<Student> students, Student student) {
             string irs = string.Empty;
-            List<string> irsOrder = students.Select(x => x.irs)?.Where(y => !string.IsNullOrEmpty(y) && Regex.IsMatch(y, @"^\d*$")).OrderBy(x => int.Parse(x)).ToList();
-            if (!irsOrder.Contains("0"))
+            if (int.TryParse(student.id.Substring(student.id.Length - 2, 2), out int _no2))
             {
-                irsOrder.Insert(0, "0");
+                irs = $"{_no2}";
             }
-            if (irsOrder != null)
+            if (string.IsNullOrWhiteSpace(irs))
             {
-                if (!irsOrder.Contains("0"))
+                if (int.TryParse(student.id.Substring(student.id.Length - 1, 1), out int _no1))
                 {
-                    irsOrder.Insert(0, "0");
+                    irs = $"{_no1}";
                 }
             }
-            else { irsOrder = new List<string>() { "0" }; }
-            for (int i = 0; i < irsOrder.Count; i++)
-            {
-                irs = $"{int.Parse(irsOrder[i]) + 1}";
-                int index = i + 1;
-                if (index <= irsOrder.Count - 1)
-                {
-                    if (!irs.Equals(irsOrder[index]))
-                    {
-                        break;
-                    }
-                }
+            //if (string.IsNullOrWhiteSpace(irs))
+            //{
+            //    List<string> irsOrder = students.Select(x => x.irs)?.Where(y => !string.IsNullOrEmpty(y) && Regex.IsMatch(y, @"^\d*$")).OrderBy(x => int.Parse(x)).ToList();
+            //    if (!irsOrder.Contains("0"))
+            //    {
+            //        irsOrder.Insert(0, "0");
+            //    }
+            //    if (irsOrder != null)
+            //    {
+            //        if (!irsOrder.Contains("0"))
+            //        {
+            //            irsOrder.Insert(0, "0");
+            //        }
+            //    }
+            //    else { irsOrder = new List<string>() { "0" }; }
+            //    for (int i = 0; i < irsOrder.Count; i++)
+            //    {
+            //        irs = $"{int.Parse(irsOrder[i]) + 1}";
+            //        int index = i + 1;
+            //        if (index <= irsOrder.Count - 1)
+            //        {
+            //            if (!irs.Equals(irsOrder[index]))
+            //            {
+            //                break;
+            //            }
+            //        }
+            //    }
+            //}
+            if (!string.IsNullOrWhiteSpace(irs)) {
+                student.irs = irs;
+                student.no = irs;
+                var stu = students.Find(x => x.id.Equals(student.id));
+                stu.irs = irs; stu.no = irs;
             }
-          
-            student.irs = irs;
-            student.no = irs;
-            var stu= students.Find(x => x.id.Equals(student.id));
-            stu.irs = irs; stu.no = irs;
             return students;
         }