123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.Entities;
- using EMIS.ViewModel.ExaminationManage;
- using EMIS.ViewModel;
- using EMIS.CommonLogic.ExaminationManage;
- using Bowin.Common.Utility;
- using EMIS.ViewModel.EducationSchedule;
- using System.IO;
- using EMIS.Utility;
- using Bowin.Common.DataTime;
- using AutoMapper;
- using EMIS.ViewModel.UniversityManage.ClassroomManage;
- namespace EMIS.ExtensionLogic.ServiceLogic.ExaminationManage
- {
- public class ExaminationPlanServices : EMIS.CommonLogic.ExaminationManage.ExaminationPlanServices
- {
- protected override bool AutoSchedule(List<ExamiationPlanAutoScheduleView> notCompleteExaminationPlanList, List<EX_ExaminationRoomSetting> examinationRoomList,
- List<ClassroomView> classroomViewList, TimeSegmentView examinationDate, List<EX_ExaminationTeacher> examinationTeacherList,
- List<StudentClassroomView> scheduledStudentList, List<ViewModel.EducationSchedule.EducationSchedulingWeekNumView> schedulingList,
- List<ClassroomExcessiveUseWeekNumView> excessiveUseList)
- {
- var needScheduleCount = notCompleteExaminationPlanList.Count;
- var scheduledCount = 0;
- var needModifyRecordList = new List<AutoScheduleModifyView>();
- foreach (var examinationRoom in examinationRoomList)
- {
- //如果考场在当前时间有排课,跳过
- var schedule = schedulingList.FirstOrDefault(x => x.ClassroomID == examinationRoom.ClassroomID
- && x.Date == examinationDate.ExaminationDate && x.StartTime <= examinationDate.EndTime
- && x.EndTime >= examinationDate.StartTime);
- if (schedule != null)
- {
- continue;
- }
- var excessiveUse = excessiveUseList.FirstOrDefault(x => x.ClassroomID == examinationRoom.ClassroomID
- && x.Date == examinationDate.ExaminationDate && x.StartTime <= examinationDate.EndTime
- && x.EndTime >= examinationDate.StartTime);
- if (excessiveUse != null)
- {
- continue;
- }
- //按照排考人数从多到少排序,第一行拿出未排过的考试计划,然后从第二个计划开始,优先拿出排过考的考试计划,
- //这样做的目的是保证考试计划能排到最少的考场去,不至于学生太过分散
- var orderedExaminationPlanViewList = notCompleteExaminationPlanList
- .Where(x => (x.MissionStudentCount - x.StudentCount) > 0)
- .OrderBy(x => x.MissionStudentCount - x.StudentCount).Take(1).ToList();
- orderedExaminationPlanViewList = orderedExaminationPlanViewList
- .Concat(notCompleteExaminationPlanList.Where(x =>
- !orderedExaminationPlanViewList.Select(w => w.ExaminationPlan.ExaminationPlanID)
- .Contains(x.ExaminationPlan.ExaminationPlanID)
- && (x.MissionStudentCount - x.StudentCount) > 0)
- .OrderBy(x => x.StudentCount > 0 ? 0 : 1)
- .ThenByDescending(x => x.MissionStudentCount - x.StudentCount)).ToList();
- #region 获取目前有空的监考员,并随机抽出两个
- //先找出排课没有冲突的监考员
- var noScheduleTeacherList = (from allteacher in examinationTeacherList
- from scheduling in schedulingList.Where(x => x.TeacherList.Any(w => w.UserID == allteacher.UserID)
- && x.Date == examinationDate.ExaminationDate && x.StartTime <= examinationDate.EndTime
- && x.EndTime >= examinationDate.StartTime).DefaultIfEmpty()
- where scheduling == null
- select allteacher).ToList();
- var teacherList = this.GetAvailableExaminationTeacher(noScheduleTeacherList,
- examinationDate.ExaminationDate, examinationDate.StartTime, examinationDate.EndTime, scheduledStudentList);
- if (teacherList.Count < 2)
- {
- return false;
- }
- #endregion
- //这个循环需要把考室尽量塞满……
- foreach (var orderedExaminationPlanView in orderedExaminationPlanViewList)
- {
- //获取要排考的学生
- var needScheduleStudentList = this.GetNeedScheduleStudentList(orderedExaminationPlanView, scheduledStudentList);
- //首先判断是否指定了考试时间,但并不是当前时间,这些自动排考无法处理
- if (orderedExaminationPlanView.ExaminationPlan.ExaminationDate.HasValue
- && !(orderedExaminationPlanView.ExaminationPlan.ExaminationDate == examinationDate.ExaminationDate
- && orderedExaminationPlanView.ExaminationPlan.StartTime == examinationDate.StartTime
- && orderedExaminationPlanView.ExaminationPlan.EndTime == examinationDate.EndTime))
- {
- continue;
- }
- //然后判断冲突
- if (IsConflict(orderedExaminationPlanView, needScheduleStudentList.Select(x => x.UserID).ToList(), examinationDate, examinationRoom.CF_Classroom, scheduledStudentList))
- {
- continue;
- }
- var roomRemainSeat = examinationRoom.CF_Classroom.Examinationseating - scheduledStudentList
- .Where(x => x.ExaminationDate == examinationDate.ExaminationDate
- && x.ClassroomID == examinationRoom.ClassroomID
- && x.StartTime <= examinationDate.EndTime
- && x.EndTime >= examinationDate.StartTime).Count();
- if (roomRemainSeat < needScheduleStudentList.Count)
- {
- continue;
- }
- var actualScheduleStudentList = needScheduleStudentList.ToList();
- //记录住这些数据需要修改,后面所有考场和考试任务都检查完后,再统一修改
- var result = new AutoScheduleModifyView
- {
- ExaminationPlan = orderedExaminationPlanView.ExaminationPlan,
- ExaminationDate = examinationDate.ExaminationDate,
- StartTime = examinationDate.StartTime,
- EndTime = examinationDate.EndTime,
- ExaminationRoom = examinationRoom,
- ScheduleStudentList = needScheduleStudentList
- };
- var lastExaminationRoomLayout = scheduledStudentList.Where(x => x.ClassroomID == examinationRoom.ClassroomID).FirstOrDefault();
- if (lastExaminationRoomLayout != null)
- {
- result.CF_Staff = new HashSet<CF_Staff>(
- examinationTeacherList.Where(x => lastExaminationRoomLayout.TeacherIDList.Contains(x.UserID ?? Guid.NewGuid())).Select(x => x.CF_Staff)
- );
- }
- else
- {
- result.CF_Staff = new HashSet<CF_Staff>(teacherList);
- }
- needModifyRecordList.Add(result);
- //更新已排完的计划,这样后续的判断才会没问题
- scheduledStudentList.AddRange(needScheduleStudentList.Select(x => new StudentClassroomView
- {
- UserID = x.UserID,
- ExaminationDate = examinationDate.ExaminationDate,
- StartTime = examinationDate.StartTime,
- EndTime = examinationDate.EndTime,
- ClassroomID = examinationRoom.ClassroomID,
- ExaminationStyleID = orderedExaminationPlanView.ExaminationPlan.ExaminationStyleID,
- TeacherIDList = result.CF_Staff.Select(w => w.UserID).ToList(),
- ExaminationPlanID = orderedExaminationPlanView.ExaminationPlan.ExaminationPlanID
- }));
- orderedExaminationPlanView.StudentCount += needScheduleStudentList.Count();
- scheduledCount++;
- }
- }
- //如果排不完,返回失败,让外部决定如何处理
- if (scheduledCount < needScheduleCount)
- {
- return false;
- }
- foreach (var needModifyRecord in needModifyRecordList)
- {
- #region 判断成功,开始更新数据
- needModifyRecord.ExaminationPlan.ExaminationDate = examinationDate.ExaminationDate;
- needModifyRecord.ExaminationPlan.StartTime = examinationDate.StartTime;
- needModifyRecord.ExaminationPlan.EndTime = examinationDate.EndTime;
- var examinationRoomLayout = new EX_ExaminationRoomLayout
- {
- ExaminationRoomLayoutID = Guid.NewGuid(),
- ExaminationPlanID = needModifyRecord.ExaminationPlan.ExaminationPlanID,
- EX_ExaminationPlan = needModifyRecord.ExaminationPlan,
- ClassroomID = needModifyRecord.ExaminationRoom.ClassroomID,
- RowSpacing = 0,
- ColumnSpacing = 0,
- StudentOrderType = (int)CF_StudentOrderType.StudentNo,
- CF_Staff = needModifyRecord.CF_Staff
- };
- this.SetNewStatus(examinationRoomLayout);
- //这块需要挪到上面检测的地方,在上面如何判断这个考场能容纳多少学生?
- var examinationRoomStudentViewList = needModifyRecord.ScheduleStudentList.Select(x => new ExaminationRoomStudentView
- {
- ExaminationRoomStudentID = Guid.NewGuid(),
- ExaminationRoomLayoutID = examinationRoomLayout.ExaminationRoomLayoutID,
- UserID = x.UserID,
- LoginID = x.Sys_User.LoginID,
- Remark = ""
- }).ToList();
- var classroomView = classroomViewList.FirstOrDefault(x => x.ClassroomID == needModifyRecord.ExaminationRoom.ClassroomID);
- var examinationRoomStudentList = this.SetRoomStudentSeats(examinationRoomStudentViewList, classroomView, 0, 0, CF_StudentOrderType.StudentNo);
- examinationRoomLayout.EX_ExaminationRoomStudent = new HashSet<EX_ExaminationRoomStudent>(examinationRoomStudentList);
- needModifyRecord.ExaminationPlan.EX_ExaminationRoomLayout.Add(examinationRoomLayout);
- needModifyRecord.ExaminationRoom.CF_Classroom.EX_ExaminationRoomLayout.Add(examinationRoomLayout);
- #endregion
- }
- return true;
- }
- public override string AdultImport(string filePath, out string returnMessage)
- {
- StringBuilder errorMsg = new StringBuilder(); // 错误信息
- List<AdultExaminationPlanImportView> errList = new List<AdultExaminationPlanImportView>(); //错误数据行
- List<AdultExaminationPlanImportView> successList = new List<AdultExaminationPlanImportView>(); //导入的数据行
- DataTimeHelper dth = new DataTimeHelper();
- #region 解析文件,存放到一个List集合里
- Dictionary<string, string> cellheader = new Dictionary<string, string>
- {
- { "CoursematerialName", "考试科目" }, { "ClassName", "考试班级名称" },
- { "MissionStudentCount", "学生数" }, { "StudentCount", "排考人数" },
- { "ExamsCategoryName", "考试性质" }, { "ExaminationModeName", "考试方式" },
- { "ExaminationWeekNumString", "考试周次" }, { "ExaminationDateString", "考试日期" },
- { "StartTimeString", "考试时间起"},{ "EndTimeString", "考试时间止" },
- { "ClassroomName", "考室"},{ "TeacherNames", "监考老师" }
- };
- List<AdultExaminationPlanImportView> importRowlist =
- NpoiExcelHelper.ExcelToEntityList<AdultExaminationPlanImportView>(cellheader, filePath, out errorMsg, out errList);
- File.Delete(filePath);
- cellheader.Add("ErrorMessage", "错误信息");//还原字典项
- #endregion
- #region 清空格
- for (int i = 0; i < importRowlist.Count(); i++)
- {
- if (importRowlist[i].CoursematerialName != null)
- importRowlist[i].CoursematerialName = importRowlist[i].CoursematerialName.Trim();
- if (importRowlist[i].ClassName != null)
- importRowlist[i].ClassName = importRowlist[i].ClassName.Trim();
- if (importRowlist[i].MissionStudentCount != null)
- importRowlist[i].MissionStudentCount = importRowlist[i].MissionStudentCount.Trim();
- if (importRowlist[i].StudentCount != null)
- importRowlist[i].StudentCount = importRowlist[i].StudentCount.Trim();
- if (importRowlist[i].ExamsCategoryName != null)
- importRowlist[i].ExamsCategoryName = importRowlist[i].ExamsCategoryName.Trim();
- if (importRowlist[i].ExaminationModeName != null)
- importRowlist[i].ExaminationModeName = importRowlist[i].ExaminationModeName.Trim();
- if (importRowlist[i].ExaminationWeekNumString != null)
- importRowlist[i].ExaminationWeekNumString = importRowlist[i].ExaminationWeekNumString.Trim();
- if (importRowlist[i].ExaminationDateString != null)
- importRowlist[i].ExaminationDateString = importRowlist[i].ExaminationDateString.Trim();
- if (importRowlist[i].StartTimeString != null)
- importRowlist[i].StartTimeString = importRowlist[i].StartTimeString.Trim();
- if (importRowlist[i].EndTimeString != null)
- importRowlist[i].EndTimeString = importRowlist[i].EndTimeString.Trim();
- if (importRowlist[i].ClassroomName != null)
- importRowlist[i].ClassroomName = importRowlist[i].ClassroomName.Trim();
- if (importRowlist[i].TeacherNames != null)
- importRowlist[i].TeacherNames = importRowlist[i].TeacherNames.Trim();
- }
- #endregion
- #region 检查文件中的内容
- #region 读取用于校验的数据,便于后续处理
- var coursematerialNameList = importRowlist.Select(x => x.CoursematerialName).ToList();
- var classNameList = importRowlist.Select(x => x.ClassName).ToList();
- //默认排当前学年学期的考试计划
- var curSchoolyear = SchoolYearServices.Value.GetCurrentSchoolYear();
- var classroomNameList = importRowlist.Select(x => x.ClassroomName).ToList();
- var teacherNameList = importRowlist.Where(x => !string.IsNullOrEmpty(x.TeacherNames))
- .SelectMany(x => x.TeacherNames.Split('/').ToList()).Distinct().ToList();
- var coursematerialList = ExaminationPlanDAL.CoursematerialRepository.GetList(x => coursematerialNameList.Contains(x.CourseName)).ToList();
- var examinationPlanList = ExaminationPlanDAL.ExaminationPlanRepository.GetList(x => classNameList.Contains(x.ClassName) && x.SchoolyearID == curSchoolyear.SchoolYearID, (x => x.EX_ExaminationRoomLayout.Select(w => w.CF_Staff)), (x => x.CF_Student.Select(w => w.Sys_User))).ToList();
- var examsCategoryList = DictionaryHelper.GetDictionaryValue(DictionaryItem.CF_ExamsCategory);
- var examinationModeList = DictionaryHelper.GetDictionaryValue(DictionaryItem.CF_ExaminationMode);
- var classroomList = ExaminationRoomSettingRepository
- .GetList(x => classroomNameList.Contains(x.CF_Classroom.Name))
- .Select(x => x.CF_Classroom).ToList();
- var classroomViewList = ClassroomDAL.GetClassroomViewQueryable(x => classroomNameList.Contains(x.Name)).ToList();
- var teacherList = ExaminationPlanDAL.StaffDAL.staffRepository.GetList(x => teacherNameList.Contains(x.Sys_User.Name), (x => x.Sys_User)).ToList();
- #endregion
- foreach (var importRow in importRowlist)
- {
- string errorMessage = "";
- var errorItem = Mapper.DynamicMap<AdultExaminationPlanImportView>(importRow);
- #region 检查基本录入格式
- var curCoursematerialList = coursematerialList.Where(x => x.CourseName == (importRow.CoursematerialName ?? "").Trim()).ToList();
- var examsCategory = examsCategoryList.FirstOrDefault(x => x.Name == (importRow.ExamsCategoryName ?? "").Trim());
- var examinationMode = examinationModeList.FirstOrDefault(x => x.Name == (importRow.ExaminationModeName ?? "").Trim());
- var classroom = classroomList.FirstOrDefault(x => x.Name == (importRow.ClassroomName ?? "").Trim());
- var curTeacherNameList = (importRow.TeacherNames ?? "").Trim().Split('/').Where(x => !string.IsNullOrEmpty(x)).ToList();
- var teacher = teacherList.Where(x => curTeacherNameList.Contains(x.Sys_User.Name)).ToList();
- if (curCoursematerialList.Count == 0)
- {
- errorMessage += "没有对应的课程名称,请检查输入。";
- }
- if (examsCategory == null)
- {
- errorMessage += "考试性质错误,请检查输入。";
- }
- if (examinationMode == null)
- {
- errorMessage += "考试方式错误,请检查输入。";
- }
- if (importRow.StudentCount == null)
- {
- importRow.StudentCount = importRow.MissionStudentCount;
- }
- if (string.IsNullOrEmpty(importRow.ClassroomName))
- {
- errorMessage += "请填写考室。";
- }
- else if (classroom == null)
- {
- errorMessage += "考室信息错误,并未将" + importRow.ClassroomName + "安排为考室,请检查输入。";
- }
- var errorTeacherList = curTeacherNameList.Where(x => !teacher.Select(w => w.Sys_User.Name).Contains(x)).ToList();
- if (errorTeacherList.Count > 0)
- {
- errorMessage += "监考老师" + string.Join("/", errorTeacherList) + "名字输入错误,请检查输入。";
- }
- else if (teacher.Count == 0)
- {
- errorMessage += "请填写监考老师信息。";
- }
- var coursematerialIDList = curCoursematerialList.Select(x => (Guid?)x.CoursematerialID).ToList();
- var examinationPlan = examinationPlanList.FirstOrDefault(x => x.ClassName == importRow.ClassName
- && coursematerialIDList.Contains(x.CoursematerialID));
- if (examsCategory != null && examinationMode != null)
- {
- examinationPlan = examinationPlanList.FirstOrDefault(x => x.ClassName == importRow.ClassName
- && coursematerialIDList.Contains(x.CoursematerialID) && x.ExamsCategoryID == examsCategory.Value
- && x.ExaminationModeID == examinationMode.Value);
- }
- if (examinationPlan == null)
- {
- examinationPlan = examinationPlanList.FirstOrDefault(x => x.ClassName == importRow.ClassName
- && coursematerialIDList.Contains(x.CoursematerialID));
- if (examinationPlan == null)
- {
- errorMessage += "并没有该班级名称和课程名称的考试安排,请检查输入。";
- }
- }
- else if (examinationPlan.RecordStatus == (int)CF_ApprovalStatus.Submitted)
- {
- errorMessage += "已存在相同的已提交的考试计划";
- }
- if (classroom != null && examinationPlan != null && classroom.Examinationseating < examinationPlan.CF_Student.Count)
- {
- errorMessage += "所选考室可容纳的座位数不足,无法安排学生进行考试。";
- }
- DateTime examinationDate = default(DateTime);
- if (string.IsNullOrEmpty(importRow.ExaminationDateString))
- {
- errorMessage += "请填写考试日期。";
- }
- else
- {
- try
- {
- DateTime date;
- if (DateTime.TryParse(importRow.ExaminationDateString.Trim().ToString(), out date))
- {
- examinationDate = Convert.ToDateTime(importRow.ExaminationDateString.Trim().ToString());
- }
- else
- {
- var dateTime = DateTime.FromOADate(double.Parse(importRow.ExaminationDateString.Trim().ToString()));
- examinationDate = dateTime;
- }
- }
- catch
- {
- errorMessage += "考试日期必须为年-月-日的日期格式。";
- }
- }
- TimeSpan startTime = default(TimeSpan);
- if (string.IsNullOrEmpty(importRow.StartTimeString))
- {
- errorMessage += "请填写考试时间起。";
- }
- else
- {
- try
- {
- DateTime date;
- if (DateTime.TryParse(importRow.StartTimeString.Trim().ToString(), out date))
- {
- startTime = Convert.ToDateTime(importRow.StartTimeString.Trim().ToString()).TimeOfDay;
- }
- else
- {
- var dateTime = DateTime.FromOADate(double.Parse(importRow.StartTimeString.Trim().ToString()));
- startTime = dateTime.TimeOfDay;
- }
- }
- catch
- {
- errorMessage += "考试时间起必须为时:分的时间格式。";
- }
- }
- TimeSpan endTime = default(TimeSpan);
- if (string.IsNullOrEmpty(importRow.EndTimeString))
- {
- errorMessage += "请填写考试时间止。";
- }
- else
- {
- try
- {
- DateTime date;
- if (DateTime.TryParse(importRow.EndTimeString.Trim().ToString(), out date))
- {
- endTime = Convert.ToDateTime(importRow.EndTimeString.Trim().ToString()).TimeOfDay;
- }
- else
- {
- var dateTime = DateTime.FromOADate(double.Parse(importRow.EndTimeString.Trim().ToString()));
- endTime = dateTime.TimeOfDay;
- }
- }
- catch
- {
- errorMessage += "考试时间止必须为时:分的时间格式。";
- }
- }
- if (startTime >= endTime)
- {
- errorMessage += "结束时间需大于开始时间。";
- }
- #endregion
- if (errorMessage != "")
- {
- errorItem.ErrorMessage = errorMessage;
- if (endTime != default(TimeSpan))
- {
- errorItem.EndTimeString = " " + endTime;
- }
- if (startTime != default(TimeSpan))
- {
- errorItem.StartTimeString = " " + startTime;
- }
- if (examinationDate != default(DateTime))
- {
- errorItem.ExaminationDateString = " " + examinationDate;
- }
- errList.Add(errorItem);
- continue;
- }
- else
- {
- importRow.CoursematerialID = examinationPlan.CoursematerialID;
- importRow.ExaminationPlan = examinationPlan;
- importRow.ExamsCategoryID = examsCategory.Value;
- importRow.ExaminationModeID = examinationMode.Value;
- importRow.ExaminationStyleID = examinationPlan.ExaminationStyleID;
- importRow.ExaminationDate = examinationDate;
- importRow.StartTime = startTime;
- importRow.EndTime = endTime;
- importRow.ClassroomID = classroom.ClassroomID;
- importRow.Examinationseating = classroom.Examinationseating;
- importRow.TeacherList = teacher;
- successList.Add(importRow);
- }
- }
- var checkList = successList;
- #endregion
- #region 准备排课数据用于校验
- var scheduleDateTimeList = successList.GroupBy(x => x.ExaminationPlan.SchoolyearID)
- .Select(x => new
- {
- SchoolyearID = x.Key,
- DataTimeList = x.GroupBy(w => new
- {
- StartTime = w.ExaminationDate.Value.Add(w.StartTime.Value),
- EndTime = w.ExaminationDate.Value.Add(w.EndTime.Value)
- })
- .Select(w => new StartEndTimeView { StartTime = w.Key.StartTime, EndTime = w.Key.EndTime }).ToList()
- }).ToList();
- List<EducationSchedulingWeekNumView> schedulingList = new List<EducationSchedulingWeekNumView>();
- List<ClassroomExcessiveUseWeekNumView> excessiveUseList = new List<ClassroomExcessiveUseWeekNumView>();
- scheduleDateTimeList.ForEach(x =>
- {
- schedulingList.AddRange(this.ScheduleServices.Value.GetEducationSchedulingWeekNumViewForExaminationTeacher(x.SchoolyearID.Value,
- x.DataTimeList));
- excessiveUseList.AddRange(this.ClassroomExcessiveUseServices.Value.GetClassroomExcessiveUseWeekNumViewByDateTimeList(
- x.SchoolyearID.Value, x.DataTimeList));
- });
- #endregion
- #region 检查导入文件内部数据的冲突
- #region 检查考室冲突
- //var classroomConflictList = (from source in successList
- // from dest in successList.Where(x => x.ExaminationPlan.ExaminationPlanID != source.ExaminationPlan.ExaminationPlanID
- // && x.ExaminationDate == source.ExaminationDate
- // && x.StartTime <= source.EndTime && x.EndTime >= source.StartTime
- // && x.ClassroomID == source.ClassroomID)
- // select new { source, dest }).ToList();
- //classroomConflictList.ForEach(x =>
- //{
- // var errorItem = x.source;
- // errorItem.ErrorMessage = "考场安排和其他行存在时间冲突,请检查。";
- // errList.Add(errorItem);
- // successList.Remove(x.source);
- //});
- #endregion
- #region 检查导入文件导入同一考室,并且时间重复的,人数是否超过可排人次
- var classroomstudentCount = (from source in successList
- from studentcount in successList.Where(x => x.ExaminationPlan.ExaminationPlanID != source.ExaminationPlan.ExaminationPlanID
- && x.ExaminationDate == source.ExaminationDate
- && x.StartTime <= source.EndTime && x.EndTime >= source.StartTime
- && x.ClassroomID == source.ClassroomID)
- group studentcount by studentcount.ExaminationPlan.ExaminationPlanID
- into gstucount
- join succ in successList
- on gstucount.Key equals succ.ExaminationPlan.ExaminationPlanID
- select new
- {
- //source,
- succ
- }).ToList();
- classroomstudentCount.ForEach(x =>
- {
- var count = int.Parse(x.succ.MissionStudentCount);
- var isrepeatList = checkList.Any(y => y.ExaminationPlan.ExaminationPlanID != x.succ.ExaminationPlan.ExaminationPlanID && y.ExaminationDate == x.succ.ExaminationDate
- && y.StartTime <= x.succ.EndTime && y.EndTime >= x.succ.StartTime && y.ClassroomID == x.succ.ClassroomID);
- if (isrepeatList)
- {
- var repeatList = checkList.Where(y => y.ExaminationPlan.ExaminationPlanID != x.succ.ExaminationPlan.ExaminationPlanID && y.ExaminationDate == x.succ.ExaminationDate
- && y.StartTime <= x.succ.EndTime && y.EndTime >= x.succ.StartTime && y.ClassroomID == x.succ.ClassroomID).ToList();
- foreach (var repeat in repeatList)
- {
- count = count + int.Parse(repeat.MissionStudentCount);
- }
- }
- if (count > classroomList.FirstOrDefault(w => w.ClassroomID == x.succ.ClassroomID).Examinationseating)
- {
- var errorItem = x.succ;
- errorItem.ErrorMessage = "考场座位数不足,请检查。";
- errList.Add(errorItem);
- successList.Remove(x.succ);
- }
- });
- #endregion
- #region 检查教师冲突
- var teacherConflictList = (from source in successList
- from dest in successList.Where(x => x.ExaminationPlan.ExaminationPlanID != source.ExaminationPlan.ExaminationPlanID
- && x.ExaminationDate == source.ExaminationDate
- && x.ClassroomID != source.ClassroomID
- && x.StartTime <= source.EndTime && x.EndTime >= source.StartTime
- && x.TeacherList.Select(w => w.UserID).Intersect(source.TeacherList.Select(w => w.UserID)).Count() > 0).Take(1)
- select source).ToList();
- teacherConflictList.ForEach(x =>
- {
- var errorItem = x;
- errorItem.ErrorMessage = "监考老师和其他行存在时间冲突,请检查。";
- errList.Add(errorItem);
- successList.Remove(x);
- });
- var teacherClassroomConflictList = (from source in successList
- from dest in successList.Where(x => x.ExaminationPlan.ExaminationPlanID != source.ExaminationPlan.ExaminationPlanID
- && x.ExaminationDate == source.ExaminationDate
- && x.ClassroomID == source.ClassroomID
- && x.StartTime <= source.EndTime && x.EndTime >= source.StartTime
- && x.TeacherList.Select(w => w.UserID).Intersect(source.TeacherList.Select(w => w.UserID)).Count() != x.TeacherList.Count).Take(1)
- select source).ToList();
- teacherClassroomConflictList.ForEach(x =>
- {
- var errorItem = x;
- errorItem.ErrorMessage = "同一考场的监考老师必须相同,请检查考室或监考老师是否存在冲突。";
- errList.Add(errorItem);
- successList.Remove(x);
- });
- #endregion
- #region 检查学生冲突
- var studentConflictList = (from source in successList
- from dest in successList.Where(x => x.ExaminationPlan.ExaminationPlanID != source.ExaminationPlan.ExaminationPlanID
- && x.ExaminationDate == source.ExaminationDate
- && x.StartTime <= source.EndTime && x.EndTime >= source.StartTime
- && x.ExaminationPlan.CF_Student.Select(w => w.UserID).Intersect(source.ExaminationPlan.CF_Student.Select(w => w.UserID)).Count() > 0)
- select new { source, dest }).ToList();
- studentConflictList.ForEach(x =>
- {
- var errorItem = x.source;
- errorItem.ErrorMessage = "考试学生和其他行存在时间冲突,请检查。";
- errList.Add(errorItem);
- successList.Remove(x.source);
- });
- #endregion
- #endregion
- #region 检查和其他考场安排之间的冲突
- var examinationDateList = successList.Select(x => x.ExaminationDate).Distinct().ToList();
- var sameDateExaminationPlanQuery = ExaminationPlanDAL.ExaminationRoomLayoutRepository
- .GetList(x => examinationDateList.Contains(x.EX_ExaminationPlan.ExaminationDate),
- (x => x.EX_ExaminationPlan),
- (x => x.EX_ExaminationPlan.CF_Student),
- (x => x.CF_Staff),
- (x => x.EX_ExaminationRoomStudent));
- var sameDateExaminationPlanList = sameDateExaminationPlanQuery.ToList();
- #region 检查考室冲突
- //var classroomOuterConflictList = (from source in successList
- // from dest in sameDateExaminationPlanList.Where(x => x.EX_ExaminationPlan.ExaminationPlanID != source.ExaminationPlan.ExaminationPlanID
- // && x.EX_ExaminationPlan.ExaminationDate == source.ExaminationDate
- // && x.EX_ExaminationPlan.StartTime <= source.EndTime && x.EX_ExaminationPlan.EndTime >= source.StartTime
- // && x.ClassroomID == source.ClassroomID)
- // select new { source, dest }).ToList();
- //classroomOuterConflictList.ForEach(x =>
- //{
- // var errorItem1 = x.source;
- // errorItem1.ErrorMessage = "考场安排和已有的考试安排存在时间冲突,请检查。";
- // errList.Add(errorItem1);
- // successList.Remove(x.source);
- //});
- #endregion
- #region 检查教师冲突
- var teacherOuterConflictList = (from source in successList
- from dest in sameDateExaminationPlanList.Where(x => x.EX_ExaminationPlan.ExaminationPlanID != source.ExaminationPlan.ExaminationPlanID
- && x.EX_ExaminationPlan.ExaminationDate == source.ExaminationDate
- && x.EX_ExaminationPlan.StartTime <= source.EndTime && x.EX_ExaminationPlan.EndTime >= source.StartTime
- && x.ClassroomID != source.ClassroomID
- && x.CF_Staff.Select(w => w.UserID).Intersect(source.TeacherList.Select(w => w.UserID)).Count() > 0).Take(1)
- select new { source, dest }).ToList();
- teacherOuterConflictList.ForEach(x =>
- {
- var errorItem1 = x.source;
- errorItem1.ErrorMessage = "监考老师和已有的考试安排存在时间冲突,请检查。";
- errList.Add(errorItem1);
- successList.Remove(x.source);
- });
- var teacherOuterClassroomConflictList = (from source in successList
- from dest in sameDateExaminationPlanList.Where(x => x.EX_ExaminationPlan.ExaminationPlanID != source.ExaminationPlan.ExaminationPlanID
- && x.EX_ExaminationPlan.ExaminationDate == source.ExaminationDate
- && x.ClassroomID == source.ClassroomID
- && x.EX_ExaminationPlan.StartTime <= source.EndTime && x.EX_ExaminationPlan.EndTime >= source.StartTime
- && x.CF_Staff.Select(w => w.UserID).Intersect(source.TeacherList.Select(w => w.UserID)).Count() != x.CF_Staff.Count).Take(1)
- select source).ToList();
- teacherOuterClassroomConflictList.ForEach(x =>
- {
- var errorItem = x;
- errorItem.ErrorMessage = "监考老师和已有的考试安排存在冲突,同一考场的监考老师必须相同,请检查。";
- errList.Add(errorItem);
- successList.Remove(x);
- });
- #endregion
- #region 检查学生冲突
- var studentOuterConflictList = (from source in successList
- from dest in sameDateExaminationPlanList.Where(x => x.EX_ExaminationPlan.ExaminationPlanID != source.ExaminationPlan.ExaminationPlanID
- && x.EX_ExaminationPlan.ExaminationDate == source.ExaminationDate
- && x.EX_ExaminationPlan.StartTime <= source.EndTime && x.EX_ExaminationPlan.EndTime >= source.StartTime
- && x.EX_ExaminationPlan.CF_Student.Select(w => w.UserID).Intersect(source.ExaminationPlan.CF_Student.Select(w => w.UserID)).Count() > 0)
- select new { source, dest }).ToList();
- studentOuterConflictList.ForEach(x =>
- {
- var errorItem = x.source;
- errorItem.ErrorMessage = "考试学生和已有的考试安排存在时间冲突,请检查。";
- errList.Add(errorItem);
- successList.Remove(x.source);
- });
- #endregion
- #endregion
- #region 检查教室占用冲突
- var classroomExcessUseConflictList = (from source in successList
- from dest in excessiveUseList.Where(x =>
- x.Date == source.ExaminationDate
- && x.StartTime <= source.EndTime && x.EndTime >= source.StartTime
- && x.ClassroomID == source.ClassroomID).Take(1)
- select new { source, dest }).ToList();
- classroomExcessUseConflictList.ForEach(x =>
- {
- var errorItem2 = x.source;
- errorItem2.ErrorMessage = "考场已被占用,请检查。";
- errList.Add(errorItem2);
- successList.Remove(x.source);
- });
- #endregion
- #region 检查和课表的冲突
- #region 检查考室冲突
- var classroomScheduleConflictList = (from source in successList
- from dest in schedulingList.Where(x =>
- x.Date == source.ExaminationDate
- && x.StartTime <= source.EndTime && x.EndTime >= source.StartTime
- && x.ClassroomID == source.ClassroomID).Take(1)
- select new { source, dest }).ToList();
- classroomScheduleConflictList.ForEach(x =>
- {
- var errorItem2 = x.source;
- errorItem2.ErrorMessage = "考场安排和已有的排课存在时间冲突,请检查。";
- errList.Add(errorItem2);
- successList.Remove(x.source);
- });
- #endregion
- #region 检查教师冲突
- var teacherScheduleConflictList = (from source in successList
- from dest in schedulingList.Where(x =>
- x.Date == source.ExaminationDate
- && x.StartTime <= source.EndTime && x.EndTime >= source.StartTime
- && x.TeacherList.Select(w => w.UserID)
- .Intersect(source.TeacherList.Select(w => (Guid?)w.UserID)).Count() > 0).Take(1)
- select new { source, dest }).ToList();
- teacherScheduleConflictList.ForEach(x =>
- {
- var errorItem1 = x.source;
- errorItem1.ErrorMessage = "监考老师和已有的排课存在时间冲突,请检查。";
- errList.Add(errorItem1);
- successList.Remove(x.source);
- });
- #endregion
- #region 检查学生冲突
- var studentScheduleConflictList = (from source in successList
- from dest in schedulingList.Where(x =>
- x.Date == source.ExaminationDate
- && x.StartTime <= source.EndTime && x.EndTime >= source.StartTime
- && x.StudentList.Select(w => w.UserID).Intersect(source.ExaminationPlan.CF_Student.Select(w => w.UserID)).Count() > 0).Take(1)
- select new { source, dest }).ToList();
- studentScheduleConflictList.ForEach(x =>
- {
- var errorItem = x.source;
- errorItem.ErrorMessage = "考试学生和已有的排课存在时间冲突,请检查。";
- errList.Add(errorItem);
- successList.Remove(x.source);
- });
- #endregion
- #endregion
- #region 添加数据
- var scheduledStudentList = new List<StudentClassroomView>();
- var deletedExaminationPlanIDList = new List<Guid>();
- foreach (var succesResult in successList)
- {
- succesResult.ExaminationPlan.ExaminationDate = succesResult.ExaminationDate;
- succesResult.ExaminationPlan.StartTime = succesResult.StartTime;
- succesResult.ExaminationPlan.EndTime = succesResult.EndTime;
- succesResult.ExaminationStyleID = succesResult.ExaminationStyleID;
- //succesResult.ExaminationPlan.EX_ExaminationRoomLayout.ForEach(x => this.UnitOfWork.Remove(x));
- //succesResult.ExaminationPlan.EX_ExaminationRoomLayout = new HashSet<EX_ExaminationRoomLayout>();
- EX_ExaminationRoomLayout newLayout = new EX_ExaminationRoomLayout()
- {
- ExaminationRoomLayoutID = Guid.NewGuid(),
- ExaminationPlanID = succesResult.ExaminationPlan.ExaminationPlanID,
- ClassroomID = succesResult.ClassroomID,
- RowSpacing = 0,
- ColumnSpacing = 0,
- StudentOrderType = (int)CF_StudentOrderType.StudentNo,
- CF_Staff = new HashSet<CF_Staff>(succesResult.TeacherList)
- };
- this.SetNewStatus(newLayout);
- var roomRemainSeat = succesResult.Examinationseating - sameDateExaminationPlanList
- .Where(x => x.EX_ExaminationPlan != null
- && x.EX_ExaminationPlan.ExaminationPlanID != succesResult.ExaminationPlan.ExaminationPlanID
- && x.EX_ExaminationPlan.ExaminationDate == succesResult.ExaminationDate
- && x.ClassroomID == succesResult.ClassroomID
- && x.EX_ExaminationPlan.StartTime <= succesResult.EndTime
- && x.EX_ExaminationPlan.EndTime >= succesResult.StartTime).Sum(x => x.EX_ExaminationRoomStudent.Count)
- - scheduledStudentList.Where(x => x.ClassroomID == succesResult.ClassroomID
- && x.ExaminationDate == succesResult.ExaminationDate
- && x.StartTime <= succesResult.EndTime
- && x.EndTime >= succesResult.StartTime)
- .Count();
- if (roomRemainSeat <= succesResult.ExaminationPlan.CF_Student.Count)
- {
- var errorItem = succesResult;
- errorItem.ErrorMessage = "考场剩余座位不足,无法安排考试,请检查考场的使用情况。";
- errList.Add(errorItem);
- continue;
- }
- var studentList = (from s in succesResult.ExaminationPlan.CF_Student
- join ss in scheduledStudentList.Where(x => x.ExaminationDate == succesResult.ExaminationDate
- && x.StartTime <= succesResult.EndTime
- && x.EndTime >= succesResult.StartTime)
- on s.UserID equals ss.UserID into dss
- from ess in dss.DefaultIfEmpty()
- where ess == null
- select s).ToList();
- var examinationRoomStudentViewList = studentList.Take(roomRemainSeat ?? 0)
- .Select(x => new ExaminationRoomStudentView
- {
- ExaminationRoomStudentID = Guid.NewGuid(),
- ExaminationRoomLayoutID = newLayout.ExaminationRoomLayoutID,
- UserID = x.UserID,
- LoginID = x.Sys_User.LoginID,
- Remark = ""
- }).ToList();
- var classroomView = classroomViewList.FirstOrDefault(x => x.ClassroomID == succesResult.ClassroomID);
- var examinationRoomStudentList = this.SetRoomStudentSeats(examinationRoomStudentViewList, classroomView, 0, 0, CF_StudentOrderType.StudentNo);
- if (!deletedExaminationPlanIDList.Contains(succesResult.ExaminationPlan.ExaminationPlanID))
- {
- UnitOfWork.Remove<EX_ExaminationRoomStudent>(x => x.EX_ExaminationRoomLayout.ExaminationPlanID == succesResult.ExaminationPlan.ExaminationPlanID);
- UnitOfWork.Remove<EX_ExaminationRoomLayout>(x => x.ExaminationPlanID == succesResult.ExaminationPlan.ExaminationPlanID);
- deletedExaminationPlanIDList.Add(succesResult.ExaminationPlan.ExaminationPlanID);
- }
- newLayout.EX_ExaminationRoomStudent = new HashSet<EX_ExaminationRoomStudent>(examinationRoomStudentList);
- scheduledStudentList.AddRange(newLayout.EX_ExaminationRoomStudent.Select(x => new StudentClassroomView
- {
- ExaminationDate = succesResult.ExaminationDate,
- StartTime = succesResult.StartTime,
- EndTime = succesResult.EndTime,
- ClassroomID = newLayout.ClassroomID,
- UserID = x.UserID
- }));
- this.UnitOfWork.Add(newLayout);
- succesResult.ExaminationPlan.EX_ExaminationRoomLayout.Add(newLayout);
- }
- #endregion
- this.UnitOfWork.Commit();
- returnMessage = string.Format("提示:成功导入{0}条记录,失败{1}条,详情请点击错误数据下载查看。",
- (importRowlist.Count - errList.Count), errList.Count);
- if (errList.Count > 0)
- {
- return NpoiExcelHelper.EntityListToExcel2003(cellheader, errList, "导入问题列表", "");
- }
- else
- {
- return "";
- }
- }
- /// <summary>
- /// 松山逻辑,提交时需要判断和课表或教室占用的冲突,判断课表主要是因为在排考的同时可能因为调课操作导致课表变动
- /// </summary>
- /// <param name="examinationPlanIDList"></param>
- public override void Submit(IList<Guid?> examinationPlanIDList)
- {
- var examinationPlanList = examinationPlanRepository.GetList(x => examinationPlanIDList.Contains(x.ExaminationPlanID),
- (x => x.EX_ExaminationRoomLayout)).ToList();
- var examinationPlanLayoutList = ExaminationPlanDAL.ExaminationRoomLayoutRepository
- .GetList(x => examinationPlanIDList.Contains(x.ExaminationPlanID),
- (x => x.CF_Staff.Select(w => w.Sys_User)),
- (x => x.EX_ExaminationRoomStudent.Select(w => w.CF_Student.Sys_User)),
- (x => x.CF_Classroom));
- var submitedPlan = examinationPlanList.Where(x => x.RecordStatus != (int)CF_ApprovalStatus.NotSubmitted).ToList();
- if (submitedPlan.Count > 0)
- {
- string submitedClassNames = string.Join(",", submitedPlan.Select(x => x.ClassName)) + "并不在未提交状态,请选择正确的记录进行提交。";
- throw new Exception(submitedClassNames);
- }
- var noLayoutPlanList = (from ep in examinationPlanList
- join epl in examinationPlanLayoutList on ep.ExaminationPlanID equals epl.ExaminationPlanID into depl
- from eepl in depl.DefaultIfEmpty()
- where eepl == null
- select ep).ToList();
- if (noLayoutPlanList.Count > 0)
- {
- string noLayoutPlanClassNames = string.Join(",", noLayoutPlanList.Select(x => x.ClassName)) + "没有设置对应的考场,请先设置再进行提交。";
- throw new Exception(noLayoutPlanClassNames);
- }
- var noTeacherPlanList = (from ep in examinationPlanList
- join epl in examinationPlanLayoutList on ep.ExaminationPlanID equals epl.ExaminationPlanID
- from s in epl.CF_Staff.DefaultIfEmpty()
- where s == null
- select new { Plan = ep, Classroom = epl.CF_Classroom }).ToList();
- if (noTeacherPlanList.Count > 0)
- {
- string noTeacherPlanClassNames = string.Join(";", noTeacherPlanList.Select(x => x.Plan.ClassName + ",考场" + x.Classroom.Name)) + "没有设置监考老师,请先设置再进行提交。";
- throw new Exception(noTeacherPlanClassNames);
- }
- var noStudentPlanList = (from ep in examinationPlanList
- join epl in examinationPlanLayoutList on ep.ExaminationPlanID equals epl.ExaminationPlanID
- from s in epl.EX_ExaminationRoomStudent.DefaultIfEmpty()
- where s == null
- select new { Plan = ep, Classroom = epl.CF_Classroom }).ToList();
- if (noStudentPlanList.Count > 0)
- {
- string noStudentPlanClassNames = string.Join(";", noStudentPlanList.Select(x => x.Plan.ClassName + ",考场" + x.Classroom.Name)) + "没有设置学生,请先设置再进行提交。";
- throw new Exception(noStudentPlanClassNames);
- }
- var scheduleDateTimeList = examinationPlanList.GroupBy(x => x.SchoolyearID)
- .Select(x => new
- {
- SchoolyearID = x.Key,
- DataTimeList = x.GroupBy(w => new
- {
- StartTime = w.ExaminationDate.Value.Add(w.StartTime.Value),
- EndTime = w.ExaminationDate.Value.Add(w.EndTime.Value)
- })
- .Select(w => new StartEndTimeView { StartTime = w.Key.StartTime, EndTime = w.Key.EndTime }).ToList()
- }).ToList();
- List<EducationSchedulingWeekNumView> schedulingList = new List<EducationSchedulingWeekNumView>();
- List<ClassroomExcessiveUseWeekNumView> excessiveUseList = new List<ClassroomExcessiveUseWeekNumView>();
- scheduleDateTimeList.ForEach(x =>
- {
- schedulingList.AddRange(this.ScheduleServices.Value.GetEducationSchedulingWeekNumViewForExaminationTeacher(x.SchoolyearID.Value,
- x.DataTimeList));
- excessiveUseList.AddRange(this.ClassroomExcessiveUseServices.Value.GetClassroomExcessiveUseWeekNumViewByDateTimeList(
- x.SchoolyearID.Value, x.DataTimeList));
- });
- #region 检查教室占用冲突
- var classroomExcessUseConflictList = (from ep in examinationPlanList
- join epl in examinationPlanLayoutList on ep.ExaminationPlanID equals epl.ExaminationPlanID
- from dest in excessiveUseList.Where(x => x.Date == ep.ExaminationDate
- && x.StartTime <= ep.EndTime && x.EndTime >= ep.StartTime
- && epl.ClassroomID == x.ClassroomID).Take(1)
- group epl by new { ep.ExaminationPlanID, ep.ClassName } into g
- select g.Key.ClassName + "的教室" + string.Join("、", g.Select(w => w.CF_Classroom.Name))).ToList();
- if (classroomExcessUseConflictList.Count > 0)
- {
- throw new Exception(string.Join(";", classroomExcessUseConflictList) + "被占用,无法提交。");
- }
- #endregion
- #region 检查和课表的冲突
- #region 检查考室冲突
- var classroomScheduleConflictList = (from ep in examinationPlanList
- join epl in examinationPlanLayoutList on ep.ExaminationPlanID equals epl.ExaminationPlanID
- from dest in schedulingList.Where(x =>
- x.Date == ep.ExaminationDate
- && x.StartTime <= ep.EndTime && x.EndTime >= ep.StartTime
- && x.ClassroomID == epl.ClassroomID).Take(1)
- group epl by new { ep.ExaminationPlanID, ep.ClassName } into g
- select g.Key.ClassName + "的教室" + string.Join("、", g.Select(w => w.CF_Classroom.Name))).ToList();
- if (classroomScheduleConflictList.Count > 0)
- {
- throw new Exception(string.Join(";", classroomScheduleConflictList) + "和已有的排课存在时间冲突,请检查。");
- }
- #endregion
- #region 检查教师冲突
- var teacherScheduleConflictList = (from ep in examinationPlanList
- join epl in examinationPlanLayoutList on ep.ExaminationPlanID equals epl.ExaminationPlanID
- from s in epl.CF_Staff
- from dest in schedulingList.Where(x =>
- x.Date == ep.ExaminationDate
- && x.StartTime <= ep.EndTime && x.EndTime >= ep.StartTime
- && x.TeacherList.Select(w => w.UserID).Contains(s.UserID)).Take(1)
- group s by new { ep.ExaminationPlanID, ep.ClassName } into g
- select g.Key.ClassName + "的监考老师" + string.Join("、", g.Select(w => w.Sys_User.Name))).ToList();
- if (teacherScheduleConflictList.Count > 0)
- {
- throw new Exception(string.Join("、", teacherScheduleConflictList) + "和已有的排课存在时间冲突,请检查。");
- }
- #endregion
- #region 检查学生冲突
- var studentScheduleConflictList = (from ep in examinationPlanList
- join epl in examinationPlanLayoutList on ep.ExaminationPlanID equals epl.ExaminationPlanID
- from s in epl.EX_ExaminationRoomStudent
- from dest in schedulingList.Where(x =>
- x.Date == ep.ExaminationDate
- && x.StartTime <= ep.EndTime && x.EndTime >= ep.StartTime
- && x.StudentList.Select(w => (Guid?)w.UserID).Contains(s.UserID)).Take(1)
- group s by new { ep.ExaminationPlanID, ep.ClassName } into g
- select g.Key.ClassName + "的考试学生" + string.Join("、", g.Select(w => w.CF_Student.Sys_User.Name))).ToList();
- if (studentScheduleConflictList.Count > 0)
- {
- throw new Exception(string.Join("、", studentScheduleConflictList) + "和已有的排课存在时间冲突,请检查。");
- }
- #endregion
- #endregion
- if (examinationPlanIDList.Count > 0)
- {
- UnitOfWork.Update<EX_ExaminationPlan>((x => new EX_ExaminationPlan { RecordStatus = (int)CF_ApprovalStatus.Submitted }), (x => examinationPlanIDList.Contains(x.ExaminationPlanID)));
- }
- }
- }
- }
|