|
@@ -1744,74 +1744,19 @@ namespace TEAMModelOS.FunctionV4.ServiceBus
|
|
|
//处理课堂选用的名单
|
|
|
if (lessonRecord.groupIds.IsNotEmpty())
|
|
|
{
|
|
|
- HashSet<string> grades = new HashSet<string>();
|
|
|
List<GroupListDto> groups = await GroupListService.GetGroupListByListids(client, _dingDing, lessonRecord.groupIds, lessonRecord.school);
|
|
|
-
|
|
|
- List<GroupListDto> groupLists = groups?.FindAll(x => !string.IsNullOrEmpty(x.periodId) && x.year > 0 && !string.IsNullOrEmpty(x.school));
|
|
|
- if (groupLists.IsNotEmpty() && !string.IsNullOrWhiteSpace(lessonRecord.periodId))
|
|
|
- {
|
|
|
- try
|
|
|
- {
|
|
|
- var gplist = groupLists.FindAll(x => lessonRecord.groupIds.Contains(x.id));
|
|
|
- School schoolObj = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(lessonRecord.school, new PartitionKey("Base"));
|
|
|
- //年级算法
|
|
|
- var period = schoolObj.period.Find(x => x.id.Equals(lessonRecord.periodId));
|
|
|
- int? Count = period?.grades?.Count;
|
|
|
- if (Count.HasValue)
|
|
|
- {
|
|
|
- int Day = DateTimeOffset.UtcNow.Day;
|
|
|
- int Month = DateTimeOffset.UtcNow.Month;
|
|
|
- int Year = DateTimeOffset.UtcNow.Year;
|
|
|
- int start = int.Parse($"{Year}0901");
|
|
|
- var se = period.semesters.Find(x => x.start == 1);
|
|
|
- if (se == null)
|
|
|
- {
|
|
|
- se = period.semesters.First();
|
|
|
- }
|
|
|
- if (se != null)
|
|
|
- {
|
|
|
- string sm = se.month >= 10 ? $"{se.month}" : $"0{se.month}";
|
|
|
- string sd = se.day >= 10 ? $"{se.day}" : $"0{se.day}";
|
|
|
- start = int.Parse($"{Year}{sm}{sd}");
|
|
|
- }
|
|
|
- int curr = int.Parse(DateTimeOffset.UtcNow.ToString("yyyyMMdd"));
|
|
|
- //新学年开学时间大于当前时间,计算年级需要减1 20220901-20220408 > 0 则当前20220408是2021年入学的,
|
|
|
- //当前时间大于新学年开学时间,计算年级则不需要 20220901-20221203 < 1 则当前20221203是2022年入学的,
|
|
|
- //20230901-20230101 > 0 则当前20230101是2022年入学的,
|
|
|
- int dis = start - curr;
|
|
|
- foreach (int year in gplist.Select(x => x.year))
|
|
|
- {
|
|
|
- int grade;
|
|
|
- if (dis > 0)
|
|
|
- {
|
|
|
- if (Year - year > 0)
|
|
|
- {
|
|
|
- grade = (Year - year - 1) % Count.Value;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- grade = Math.Abs((Year - year)) % Count.Value;
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- grade = Math.Abs((Year - year)) % Count.Value;
|
|
|
- }
|
|
|
- grades.Add($"{grade}");
|
|
|
- }
|
|
|
+ if ( !string.IsNullOrWhiteSpace(lessonRecord.school) && !string.IsNullOrWhiteSpace(lessonRecord.periodId)) {
|
|
|
+ HashSet<string> grades = new HashSet<string>();
|
|
|
+ School schoolObj = await client.GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(lessonRecord.school, new PartitionKey("Base"));
|
|
|
+ HashSet<int> gd = groups.SelectMany(z => z.grades).ToHashSet();
|
|
|
+ groups.ForEach(y => {
|
|
|
+ if (y.type.Equals("teach")|| y.type.Equals("class")) {
|
|
|
+ gd.Add(y.year);
|
|
|
}
|
|
|
- }
|
|
|
- catch (CosmosException ex) when (ex.Status == 404)
|
|
|
- {
|
|
|
-
|
|
|
- }
|
|
|
- catch (Exception ex)
|
|
|
- {
|
|
|
- await _dingDing.SendBotMsg($"{Environment.GetEnvironmentVariable("Option:Location")}-处理课堂记录的-年级处理异常{ex.Message}\n{ex.StackTrace}\n\n{lessonRecord.ToJsonString()}", GroupNames.醍摩豆服務運維群組);
|
|
|
- }
|
|
|
+ });
|
|
|
+ var gpdata = SchoolService.GetGrades(schoolObj, lessonRecord.periodId, gd);
|
|
|
+ lessonRecord.grade = gpdata.grades.ToList();
|
|
|
}
|
|
|
- lessonRecord.grade = grades.ToList();
|
|
|
}
|
|
|
//个人课例保存规则
|
|
|
try
|