|
@@ -377,30 +377,38 @@ namespace TEAMModelOS.Controllers
|
|
|
List<School> schools = new List<School>();
|
|
|
await foreach (var item in client.GetContainer(Constant.TEAMModelOS, "School").GetItemQueryIterator<School>(queryText: $"select value(c) from c where c.areaId='{area.id}'", requestOptions: new QueryRequestOptions() { PartitionKey = new PartitionKey($"Base") }))
|
|
|
{
|
|
|
-
|
|
|
schools.Add(item);
|
|
|
}
|
|
|
-
|
|
|
int countArea = 0;
|
|
|
int appraiseArea = 0;
|
|
|
List<SchoolInfos> schoolInfos = new List<SchoolInfos>();
|
|
|
TeacherTrainChangeMsg msg = new TeacherTrainChangeMsg() { areaId=area.id};
|
|
|
- foreach (var school in schools)
|
|
|
+ List<Task> tasks = new List<Task>();
|
|
|
+ List<string> updateTeach = new List<string>();
|
|
|
+ schools.ForEach( school =>
|
|
|
{
|
|
|
- schoolInfos.Add(new SchoolInfos { schoolId = school.id, schoolName = school.name, picture = school.picture });
|
|
|
- (List<TeacherTrain> trains, List<RGroupList> yxtrain, List < TeacherTrain > updateTeacherTrains)= await StatisticsService.StatisticsSchoolQuik(_coreAPIHttpService, school.id, setting, area, client, _dingDing, null);
|
|
|
- teacherTrains.AddRange( trains);
|
|
|
- schoolInfos.ForEach(y => {
|
|
|
- var list =yxtrain.Find(z => z.school.Equals(y.schoolId));
|
|
|
- if (list != null)
|
|
|
+ tasks.Add(Task.Run(async () =>
|
|
|
+ {
|
|
|
+ schoolInfos.Add(new SchoolInfos { schoolId = school.id, schoolName = school.name, picture = school.picture });
|
|
|
+ (List<TeacherTrain> trains, List<RGroupList> yxtrain, List<TeacherTrain> updateTeacherTrains) =
|
|
|
+ await StatisticsService.StatisticsSchoolQuik(_coreAPIHttpService, school.id, setting, area, client, _dingDing, null);
|
|
|
+ teacherTrains.AddRange(trains);
|
|
|
+ schoolInfos.ForEach(y =>
|
|
|
{
|
|
|
- y.trainCount = list.members.Count;
|
|
|
+ var list = yxtrain.Find(z => z.school.Equals(y.schoolId));
|
|
|
+ if (list != null)
|
|
|
+ {
|
|
|
+ y.trainCount = list.members.Count;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ if (updateTeacherTrains.IsNotEmpty())
|
|
|
+ {
|
|
|
+ updateTeach.AddRange(updateTeacherTrains.Select(z => z.id));
|
|
|
+ msg.schools.Add(new TeacherTrainChangeMsgSchoolTeachers { school = school.id, teachers = updateTeacherTrains.Select(z => z.id).ToList() });
|
|
|
}
|
|
|
- });
|
|
|
- if (updateTeacherTrains.IsNotEmpty()) {
|
|
|
- msg.schools.Add( new TeacherTrainChangeMsgSchoolTeachers { school = school.id, teachers = updateTeacherTrains.Select(z => z.id).ToList() });
|
|
|
- }
|
|
|
- }
|
|
|
+ }));
|
|
|
+ });
|
|
|
+ await Task.WhenAll(tasks);
|
|
|
bool isnew=false;
|
|
|
if (msg.schools.IsNotEmpty())
|
|
|
{
|
|
@@ -475,11 +483,11 @@ namespace TEAMModelOS.Controllers
|
|
|
isnew= true;
|
|
|
}
|
|
|
}
|
|
|
- return Ok(new { teacherTrains = dynamics, setting, schools = schoolInfos, totalTime, hgcount, teacherCount = countArea, appraiseCount = appraiseArea, isnew ,area.updateTime});
|
|
|
+ return Ok(new { teacherTrains = dynamics, setting, schools = schoolInfos, totalTime, hgcount, teacherCount = countArea, appraiseCount = appraiseArea, isnew ,area.updateTime, updateTeach });
|
|
|
}
|
|
|
catch (Exception ex)
|
|
|
{
|
|
|
- await _dingDing.SendBotMsg($"OS,{_option.Location},UpsertSubmitScore/UpsertSubmitScore()\n{ex.Message}\n{ex.StackTrace}\n", GroupNames.醍摩豆服務運維群組);
|
|
|
+ await _dingDing.SendBotMsg($"OS,{_option.Location},StatisticsAreaQuick()\n{ex.Message}\n{ex.StackTrace}\n", GroupNames.醍摩豆服務運維群組);
|
|
|
return BadRequest(new { ex.Message, ex.StackTrace });
|
|
|
|
|
|
}
|