|
@@ -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;
|
|
|
}
|
|
|
|