|
@@ -198,8 +198,8 @@ namespace TEAMModelAPI.Controllers
|
|
|
courses.Add(item);
|
|
|
}
|
|
|
//不存在的课程
|
|
|
- var notInCourseIds= courseIds.Except(courses.Select(x => x.id));
|
|
|
- iptcourses=iptcourses.Where(x => !notInCourseIds.Contains(x.courseId));
|
|
|
+ var unexistCourseIds = courseIds.Except(courses.Select(x => x.id));
|
|
|
+ iptcourses=iptcourses.Where(x => !unexistCourseIds .Contains(x.courseId));
|
|
|
|
|
|
//排查 课程学段,课程排课作息,课程排课的星期几是否准确
|
|
|
List<ScheduleDto> import_schedules = new List<ScheduleDto>() ;
|
|
@@ -272,6 +272,7 @@ namespace TEAMModelAPI.Controllers
|
|
|
import_roomIdsConfuse = check_roomIds.Where(x => x.list.Count > 1).SelectMany(x => x.list);
|
|
|
import_schedules.RemoveAll(x => import_roomIdsConfuse.Contains(x));
|
|
|
|
|
|
+
|
|
|
//打散数据库已经有的排课信息
|
|
|
List<ScheduleDto> database_schedules = new List<ScheduleDto>();
|
|
|
courses.ForEach(x => {
|
|
@@ -313,6 +314,7 @@ namespace TEAMModelAPI.Controllers
|
|
|
List<ScheduleDto> database_teacherConfuse = new List<ScheduleDto>();
|
|
|
List<ScheduleDto> database_groupIdConfuse = new List<ScheduleDto>();
|
|
|
List<ScheduleDto> database_roomIdsConfuse = new List<ScheduleDto>();
|
|
|
+ //数据库排查
|
|
|
import_schedules.ForEach(x => {
|
|
|
//检查教师的排课是否冲突
|
|
|
if (database_schedules.FindAll(s => s.keyTeacher.Equals(x.keyTeacher)).IsNotEmpty())
|
|
@@ -336,17 +338,37 @@ namespace TEAMModelAPI.Controllers
|
|
|
import_schedules.RemoveAll(x => database_roomIdsConfuse.Contains(x));
|
|
|
//最终导入之前,必须检查,课程是否存在(notInCourseIds),教师是否存在,名单是否存在,并重新排列行政班,教学班,
|
|
|
//排课时间段id是否正确,星期几是否正确(import_weeksConfuse),教室是否正确
|
|
|
- School data = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(school, new PartitionKey("Base"));
|
|
|
+
|
|
|
//检查教师存在的
|
|
|
HashSet<string> teachers = import_schedules.Select(x => x.teacherId).ToHashSet();
|
|
|
- if (teachers.Count > 0) {
|
|
|
-
|
|
|
+ IEnumerable<string> unexistTeacherIds= null;
|
|
|
+ if (teachers.Count > 0) {
|
|
|
+ List<string> teacherIds = new List<string>();
|
|
|
+ string sqlTeacher = $"select value(c.id) from c where c.id in ({string.Join(",",teachers.Select(x=>$"'{x}'"))})";
|
|
|
+ await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School)
|
|
|
+ .GetItemQueryIterator<string>(queryText: sqlTeacher, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Teacher-{school}") }))
|
|
|
+ {
|
|
|
+ teacherIds.Add(item);
|
|
|
+ }
|
|
|
+ unexistTeacherIds= teachers.Except(teacherIds);
|
|
|
+ //移除不存在的教师
|
|
|
+ import_schedules.RemoveAll(x => unexistTeacherIds.Contains(x.teacherId));
|
|
|
}
|
|
|
- //检查教师存在的
|
|
|
+ //检查教室存在的
|
|
|
HashSet<string> roomIds = import_schedules.Select(x => x.roomId).ToHashSet();
|
|
|
+ IEnumerable<string> unexistRoomIds = null;
|
|
|
if (roomIds.Count > 0)
|
|
|
{
|
|
|
-
|
|
|
+ List<string> rooms = new List<string>();
|
|
|
+ string sqlRoom = $"select value(c.id) from c where c.id in ({string.Join(",", roomIds.Select(x => $"'{x}'"))})";
|
|
|
+ await foreach (var item in _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, Constant.School)
|
|
|
+ .GetItemQueryIterator<string>(queryText: sqlRoom, requestOptions: new QueryRequestOptions { PartitionKey = new PartitionKey($"Room-{school}") }))
|
|
|
+ {
|
|
|
+ rooms.Add(item);
|
|
|
+ }
|
|
|
+ unexistRoomIds= roomIds.Except(rooms);
|
|
|
+ //移除不存在的教师
|
|
|
+ import_schedules.RemoveAll(x => unexistRoomIds.Contains(x.roomId));
|
|
|
}
|
|
|
//检查名单存在的
|
|
|
List<string> groupIds = new List<string>();
|
|
@@ -359,22 +381,77 @@ namespace TEAMModelAPI.Controllers
|
|
|
{
|
|
|
groupIds.AddRange(stulists);
|
|
|
}
|
|
|
+ List<GroupListDto> groupListDtos= await GroupListService.GetGroupListListids(_azureCosmos.GetCosmosClient(), _dingDing, groupIds, school);
|
|
|
+ IEnumerable<string> unexistGroupIds = groupIds.Except(groupListDtos.Where(x=>!x.scope.Equals("private")).Select(x=>x.id));
|
|
|
+ //移除不存在的名单id
|
|
|
+ import_schedules.RemoveAll(x => unexistGroupIds.Contains(x.classId));
|
|
|
+ import_schedules.RemoveAll(x => unexistGroupIds.Contains(x.stulist));
|
|
|
+
|
|
|
+ School data = await _azureCosmos.GetCosmosClient().GetContainer(Constant.TEAMModelOS, "School").ReadItemAsync<School>(school, new PartitionKey("Base"));
|
|
|
+ HashSet<Course> update_course = new HashSet<Course>();
|
|
|
+ HashSet<string> unexistTimeTable = new HashSet<string>();
|
|
|
+ import_schedules.ForEach(schedule => {
|
|
|
+ Course course = courses.Find(x => x.id.Equals(schedule.courseId));
|
|
|
+ if (string.IsNullOrWhiteSpace(course?.period?.id))
|
|
|
+ {
|
|
|
+ Period period = data.period.Find(p => p.id.Equals(course.period.id));
|
|
|
+ TimeTable timeTable = period?.timetable.Find(x => x.id.Equals(schedule.timeId));
|
|
|
+ if (timeTable != null)
|
|
|
+ {
|
|
|
+ string groupId= string.IsNullOrWhiteSpace(schedule.classId)?schedule.stulist:schedule.classId;
|
|
|
+ GroupListDto groupList= groupListDtos.Find(g => g.id.Equals(groupId));
|
|
|
+ string classId = null;
|
|
|
+ string stulist = null;
|
|
|
+ if (groupList.type.Equals("class")) {
|
|
|
+ classId = groupList.id;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ stulist = groupList.id;
|
|
|
+ }
|
|
|
+ var course_schedule =course.schedule.Find(x => x.teacherId.Equals(schedule.teacherId));
|
|
|
+ if (course_schedule != null)
|
|
|
+ {
|
|
|
+ course_schedule.classId = classId;
|
|
|
+ course_schedule.stulist = stulist ;
|
|
|
+ course_schedule.room = schedule.roomId;
|
|
|
+ var time= course_schedule.time.Find(t => t.id.Equals(schedule.timeId) && t.week.Equals(schedule.week));
|
|
|
+ if (time != null)
|
|
|
+ {
|
|
|
+ time.id=schedule.timeId;
|
|
|
+ time.week=schedule.week;
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ course_schedule.time.Add(new TimeInfo { id = schedule.timeId, week = schedule.week });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ course.schedule.Add(new Schedule { classId = classId, stulist = stulist, room = schedule.roomId, time = new List<TimeInfo> { new TimeInfo { id=schedule.timeId,week=schedule.week} } });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else {
|
|
|
+ //课程,所在学段对应的作息时间不正确
|
|
|
+ unexistTimeTable.Add(schedule.timeId);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
return Ok(new {
|
|
|
import_check= new //导入数据自检信息
|
|
|
{
|
|
|
- import_groupIdConfuse,//名单冲突的排课
|
|
|
- import_roomIdsConfuse,//物理教室冲突的排课
|
|
|
- import_teacherConfuse,//教室冲突的排课
|
|
|
- import_weeksConfuse },//错误的星期几编码
|
|
|
+ import_teacherConfuse,//自检-教师冲突的排课
|
|
|
+ import_groupIdConfuse,//自检-名单冲突的排课
|
|
|
+ import_roomIdsConfuse,//自检-物理教室冲突的排课
|
|
|
+ import_weeksConfuse },//自检-错误的星期几编码
|
|
|
database_check= new //数据库比对信息
|
|
|
{
|
|
|
- notInCourseIds,//不存在的课程
|
|
|
- //不存在的教师
|
|
|
- //不存在的名单
|
|
|
- //不存在的教室
|
|
|
- //不存在的作息
|
|
|
+ database_teacherConfuse,//数据比对-教师冲突的排课
|
|
|
+ database_groupIdConfuse,//数据比对-名单冲突的排课
|
|
|
+ database_roomIdsConfuse,//数据比对-物理教室冲突的排课
|
|
|
+ unexistCourseIds ,//不存在的课程
|
|
|
+ unexistTeacherIds,//不存在的教师
|
|
|
+ unexistGroupIds,//不存在的名单
|
|
|
+ unexistRoomIds,//不存在的教室
|
|
|
+ //不存在的作息
|
|
|
},
|
|
|
-
|
|
|
});
|
|
|
}
|
|
|
|