|
@@ -2291,6 +2291,57 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
return Ok(new { lessonRecords });
|
|
|
}
|
|
|
+ /// <summary>
|
|
|
+ /// 修复学校课例及blob计算
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="jsonElement"></param>
|
|
|
+ /// <returns></returns>
|
|
|
+ [HttpPost("check-scteacher")]
|
|
|
+ public async Task<IActionResult> CheckScTeacher(JsonElement request) {
|
|
|
+ if (!request.TryGetProperty("accessConfig", out JsonElement accessConfig)) return BadRequest();
|
|
|
+ if (!request.TryGetProperty("city", out JsonElement city)) return BadRequest();
|
|
|
+ if (!request.TryGetProperty("dist", out JsonElement dist)) return BadRequest();
|
|
|
+ if (!request.TryGetProperty("areaId", out JsonElement areaId)) return BadRequest();
|
|
|
+ if (!request.TryGetProperty("standard", out JsonElement standard)) return BadRequest();
|
|
|
+ var table = _azureStorage.GetCloudTableClient().GetTableReference("ScYxpt");
|
|
|
+ var ScTeachers = await table.FindListByDict<ScTeacher>(new Dictionary<string, object>() { { "PartitionKey", "ScTeacher" }, { "areaId", $"{areaId}" } });
|
|
|
+ Dictionary<string, object> dict = new Dictionary<string, object> { { "accessConfig", $"{accessConfig}" }, { "areaId", $"{areaId}" } };
|
|
|
+ (int status, string json) = await _httpTrigger.RequestHttpTrigger(dict, _option.Location, "GetTeachersListByProject");
|
|
|
+ var teachers = json.ToObject<List<ScTeacher>>(new JsonSerializerOptions { PropertyNameCaseInsensitive = false });
|
|
|
+ var dbIds = ScTeachers.Select(x => x.PXID);
|
|
|
+ var scIds = teachers.Select(x => x.PXID);
|
|
|
+ var dbMore= dbIds.Except(scIds);
|
|
|
+ List<ScTeacher> dbtech = new List<ScTeacher>();
|
|
|
+ foreach (var item in dbMore) {
|
|
|
+ dbtech.Add(ScTeachers.Find(x => x.PXID==item));
|
|
|
+ }
|
|
|
+ List<ScTeacher> sctech = new List<ScTeacher>();
|
|
|
+ var scMore = scIds.Except(dbIds);
|
|
|
+ foreach (var item in scMore)
|
|
|
+ {
|
|
|
+ sctech.Add(teachers.Find(x => x.PXID == item));
|
|
|
+ }
|
|
|
+ List<string> tmdids = new List<string>();
|
|
|
+ var group= ScTeachers.Where(x => !string.IsNullOrWhiteSpace(x.tmdid)).GroupBy(x => x.tmdid).Select(x => new { x.Key,list= x.ToList() });
|
|
|
+ group.ToList().ForEach(x =>
|
|
|
+ {
|
|
|
+ if (x.list.Count > 1) {
|
|
|
+ tmdids.Add(x.Key);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ List<string> teacherTrainsIds = new List<string>();
|
|
|
+ string insql = $"where c.id in ({string.Join(",", ScTeachers.Select(x => $"'{x.tmdid}'"))})";
|
|
|
+ string selsql = $"select value(c.id) from c {insql} and c.pk='TeacherTrain' ";
|
|
|
+ await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "Teacher").GetItemQueryIterator<string>(queryText: selsql,
|
|
|
+ requestOptions: new QueryRequestOptions() { }))
|
|
|
+ {
|
|
|
+ teacherTrainsIds.Add(item);
|
|
|
+ }
|
|
|
+ var bindids= ScTeachers.Where(x => !string.IsNullOrWhiteSpace(x.tmdid)).Select(x => x.tmdid);
|
|
|
+ var noTrains= bindids.Except(teacherTrainsIds);
|
|
|
+ return Ok(new { dbtech , sctech,ScCount= teachers .Count, DBCount= ScTeachers.Count , ScTeachers, tmdids, noTrains });
|
|
|
+ }
|
|
|
+
|
|
|
/// <summary>
|
|
|
/// 修复学校课例及blob计算
|
|
|
/// </summary>
|
|
@@ -2319,9 +2370,11 @@ namespace TEAMModelOS.Controllers
|
|
|
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);
|
|
|
- tasks.Add(_azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).ReplaceItemAsync(stu, stu.id, new PartitionKey($"Base-{id}")));
|
|
|
+ var list= DoIrs(group.list);
|
|
|
+ if (list != null) {
|
|
|
+ list.ForEach(stu => {
|
|
|
+ tasks.Add(_azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.Student).ReplaceItemAsync(stu, stu.id, new PartitionKey($"Base-{id}")));
|
|
|
+ });
|
|
|
}
|
|
|
}
|
|
|
int pagesize = 1000;
|
|
@@ -2342,54 +2395,40 @@ namespace TEAMModelOS.Controllers
|
|
|
}
|
|
|
return Ok(studentsData);
|
|
|
}
|
|
|
- private List<Student> DoIrs(List<Student> students, Student student) {
|
|
|
- string irs = string.Empty;
|
|
|
- if (int.TryParse(student.id.Substring(student.id.Length - 2, 2), out int _no2))
|
|
|
- {
|
|
|
- irs = $"{_no2}";
|
|
|
- }
|
|
|
- if (string.IsNullOrWhiteSpace(irs))
|
|
|
+ private List<Student> DoIrs(List<Student> students) {
|
|
|
+ List<int> ids = new List<int>(students.Count);
|
|
|
+ bool hasAbc=false;
|
|
|
+ int index = students.Count;
|
|
|
+ if (!students.Select(x => x.irs).Contains("1"))
|
|
|
{
|
|
|
- if (int.TryParse(student.id.Substring(student.id.Length - 1, 1), out int _no1))
|
|
|
+ foreach (var stu in students)
|
|
|
{
|
|
|
- irs = $"{_no1}";
|
|
|
+ if (int.TryParse(stu.id, out int id))
|
|
|
+ {
|
|
|
+ ids.Add(id);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ hasAbc = true;
|
|
|
+ }
|
|
|
}
|
|
|
+ ids = ids.OrderBy(x => x).ToList();
|
|
|
+ if (!hasAbc)
|
|
|
+ {
|
|
|
+ for (int i = 0; i < ids.Count; i++)
|
|
|
+ {
|
|
|
+ var stu = students.Find(x => x.id.Equals($"{ids[i]}"));
|
|
|
+ if (stu != null)
|
|
|
+ {
|
|
|
+ stu.irs = $"{(i + 1)}";
|
|
|
+ stu.no = $"{(i + 1)}";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return students;
|
|
|
}
|
|
|
- //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;
|
|
|
- }
|
|
|
- return students;
|
|
|
+ else { return null; }
|
|
|
+
|
|
|
}
|
|
|
|
|
|
|