123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185 |
- using System;
- using System.Collections.Generic;
- using System.Data.Entity;
- using System.Linq;
- using System.Linq.Expressions;
- using System.Text;
- using Bowin.Common.Linq;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel.EducationSchedule;
- using EMIS.ViewModel;
- using EMIS.Entities;
- using EMIS.CommonLogic.SystemServices;
- using EMIS.DataLogic.EducationSchedule;
- using EMIS.ViewModel.EducationManage;
- using EMIS.Utility.FormValidate;
- using System.Transactions;
- using EMIS.CommonLogic.CalendarManage;
- using EMIS.ViewModel.CalendarManage;
- using EMIS.CommonLogic.ExaminationManage;
- using EMIS.DataLogic.Repositories;
- using EMIS.DataLogic.ExaminationManage;
- using EMIS.ViewModel.ExaminationManage;
- namespace EMIS.CommonLogic.EducationSchedule
- {
- public class EducationSchedulingAdjustmentServices : BaseWorkflowServices<ES_EducationSchedulingAdjustment>, IEducationSchedulingAdjustmentServices
- {
- public EducationSchedulingDAL EducationSchedulingDAL { get; set; }
- public EducationSchedulingAdjustmentDAL EducationSchedulingAdjustmentDAL { get; set; }
- public EducationSchedulingStopDAL EducationSchedulingStopDAL { get; set; }
- public ExaminationPlanDAL ExaminationPlanDAL { get; set; }
- public Lazy<IScheduleServices> ScheduleServices { get; set; }
- public Lazy<ISchoolYearServices> SchoolYearServices { get; set; }
- public Lazy<ICoursesTimeServices> CoursesTimeServices { get; set; }
- public Lazy<IEducationSchedulingStopServices> EducationSchedulingStopServices { get; set; }
- public void Save(ScheduleAdjustmentEditView scheduleAdjustmentView)
- {
- ES_EducationScheduling educationSchedule;
- if (scheduleAdjustmentView.EducationSchedulingID.HasValue)
- {
- educationSchedule = this.EducationSchedulingDAL.EducationSchedulingRepository.GetSingle(x =>
- x.EducationSchedulingID == scheduleAdjustmentView.EducationSchedulingID,
- (x => x.EM_EducationSchedulingClass),
- (x => x.ES_EducationSchedulingTeacher));
- }
- else
- {
- educationSchedule = this.EducationSchedulingDAL.EducationSchedulingRepository.GetSingle(x =>
- x.EM_EducationSchedulingClass.EducationMissionClassID == scheduleAdjustmentView.EducationMissionClassID
- && x.Weekday == scheduleAdjustmentView.Weekday && x.CoursesTimeID == scheduleAdjustmentView.CoursesTimeID
- && x.ES_EducationSchedulingWeekNum.Any(w => scheduleAdjustmentView.WeekNum == w.WeekNum),
- (x => x.EM_EducationSchedulingClass),
- (x => x.ES_EducationSchedulingTeacher));
- }
- if (educationSchedule == null)
- {
- throw new Exception("所选排课记录不存在,请退出重新选择。");
- }
- var startStatusID = this.GetStartStatus();
- var backpointStatusList = this.GetBackpointStatus();
- var scheduleAdjustment = new ES_EducationSchedulingAdjustment();
- if (scheduleAdjustmentView.EducationSchedulingAdjustmentID != Guid.Empty)
- {
- scheduleAdjustment = this.EducationSchedulingAdjustmentDAL.EducationSchedulingAdjustmentRepository
- .GetSingle(x => x.EducationSchedulingAdjustmentID == scheduleAdjustmentView.EducationSchedulingAdjustmentID,
- (x => x.ES_EducationSchedulingAdjustmentTeacher),
- (x => x.ES_EducationSchedulingAdjustmentToTeacher));
- if (scheduleAdjustment == null)
- {
- throw new Exception("数据已经被删除,请退出重新选择。");
- }
- if (scheduleAdjustment.RecordStatus != startStatusID && !backpointStatusList.Contains(scheduleAdjustment.RecordStatus))
- {
- throw new Exception("数据已提交,不能修改。");
- }
- this.SetModifyStatus(scheduleAdjustment);
- }
- else
- {
- scheduleAdjustment.EducationSchedulingAdjustmentID = Guid.NewGuid();
- this.SetNewStatus(scheduleAdjustment);
- scheduleAdjustment.RecordStatus = startStatusID;
- this.UnitOfWork.Add(scheduleAdjustment);
- }
- scheduleAdjustment.EducationMissionClassID = educationSchedule.EM_EducationSchedulingClass.EducationMissionClassID;
- scheduleAdjustment.Weekday = scheduleAdjustmentView.Weekday;
- scheduleAdjustment.CoursesTimeID = scheduleAdjustmentView.CoursesTimeID;
- scheduleAdjustment.ClassroomTypeID = scheduleAdjustmentView.ClassroomTypeID;
- scheduleAdjustment.ClassroomID = scheduleAdjustmentView.ClassroomID;
- scheduleAdjustment.UserID = scheduleAdjustmentView.UserID;
- scheduleAdjustment.ToWeekday = scheduleAdjustmentView.ToWeekday;
- scheduleAdjustment.ToCoursesTimeID = scheduleAdjustmentView.ToCoursesTimeID;
- scheduleAdjustment.ToClassroomTypeID = scheduleAdjustmentView.ToClassroomTypeID;
- scheduleAdjustment.ToClassroomID = scheduleAdjustmentView.ToClassroomID;
- scheduleAdjustment.ToUserID = scheduleAdjustmentView.ToUserID;
- scheduleAdjustment.WeekNum = scheduleAdjustmentView.WeekNum;
- scheduleAdjustment.ToWeekNum = scheduleAdjustmentView.ToWeekNum;
- scheduleAdjustment.ES_EducationSchedulingAdjustmentTeacher = new HashSet<ES_EducationSchedulingAdjustmentTeacher>();
- foreach (var teacher in educationSchedule.ES_EducationSchedulingTeacher)
- {
- var fromTeacher = new ES_EducationSchedulingAdjustmentTeacher();
- fromTeacher.EducationSchedulingAdjustmentTeacherID = Guid.NewGuid();
- fromTeacher.EducationSchedulingAdjustmentID = scheduleAdjustment.EducationSchedulingAdjustmentID;
- fromTeacher.UserID = teacher.UserID;
- fromTeacher.TeachingMethod = teacher.TeachingMethod;
- this.SetNewStatus(fromTeacher);
- scheduleAdjustment.ES_EducationSchedulingAdjustmentTeacher.Add(fromTeacher);
- }
- scheduleAdjustment.ES_EducationSchedulingAdjustmentToTeacher = new HashSet<ES_EducationSchedulingAdjustmentToTeacher>();
- foreach (var teacher in educationSchedule.ES_EducationSchedulingTeacher)
- {
- var toTeacher = new ES_EducationSchedulingAdjustmentToTeacher();
- toTeacher.EducationSchedulingAdjustmentToTeacherID = Guid.NewGuid();
- toTeacher.EducationSchedulingAdjustmentID = scheduleAdjustment.EducationSchedulingAdjustmentID;
- toTeacher.UserID = (teacher.UserID == scheduleAdjustment.UserID && scheduleAdjustment.ToUserID.HasValue) ? scheduleAdjustment.ToUserID : teacher.UserID;
- toTeacher.TeachingMethod = teacher.TeachingMethod;
- this.SetNewStatus(toTeacher);
- scheduleAdjustment.ES_EducationSchedulingAdjustmentToTeacher.Add(toTeacher);
- }
- this.UnitOfWork.Commit();
- }
- public IGridResultSet<ScheduleAdjustmentView> GetScheduleAdjustmentViewList(ConfiguretView configuretView,
- Guid? schoolyearID, Guid? coursematerialID, Guid? collegeID, Guid? userID, Guid? classroomID, Guid? applyUserID,
- DateTime? startTime, DateTime? endTime, int? recordStatus, int? pageIndex, int? pageSize)
- {
- var statusList = this.GetStatusViewList();
- Expression<Func<ES_EducationSchedulingAdjustment, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- Expression<Func<EM_EducationMission, bool>> missionExp = (x => true);
- Expression<Func<EM_EducationMissionClass, bool>> missionClassExp = (x => true);
- Expression<Func<CF_Staff, bool>> staffExp = (x => true);
- if (schoolyearID.HasValue)
- {
- missionExp = missionExp.And(x => x.SchoolyearID == schoolyearID);
- }
- if (coursematerialID.HasValue)
- {
- missionClassExp = missionClassExp.And(x => x.CoursematerialID == coursematerialID);
- }
- if (collegeID.HasValue)
- {
- staffExp = staffExp.And(x => x.CollegeID == collegeID);
- }
- if (userID.HasValue)
- {
- exp = exp.And(x => x.ES_EducationSchedulingAdjustmentTeacher.Any(y => y.UserID == userID));
- //staffExp = staffExp.And(x => x.UserID == userID);
- }
- if (classroomID.HasValue)
- {
- exp = exp.And(x => x.ClassroomID == classroomID);
- }
- if (applyUserID.HasValue)
- {
- exp = exp.And(x => x.CreateUserID == applyUserID);
- }
- if (startTime.HasValue)
- {
- exp = exp.And(x => x.ApplyTime >= startTime);
- }
- if (endTime.HasValue)
- {
- var correctEndTime = endTime.Value.Date.AddDays(1);
- exp = exp.And(x => x.ApplyTime < correctEndTime);
- }
- if (recordStatus.HasValue)
- {
- exp = exp.And(x => x.RecordStatus == recordStatus);
- }
- var query = this.EducationSchedulingAdjustmentDAL.GetScheduleAdjustmentViewQueryable(exp, missionExp, missionClassExp, staffExp);
- var teacherQuery = this.EducationSchedulingAdjustmentDAL.GetEducationSchedulingAdjustmentTeacherQueryable(
- exp, missionExp, missionClassExp, staffExp);
- var toTeacherQuery = this.EducationSchedulingAdjustmentDAL.GetEducationSchedulingAdjustmentToTeacherQueryable(
- exp, missionExp, missionClassExp, staffExp);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- query = this.GetQueryByDataRange(query, (x => x.UserID));
- var resultQuery = query.OrderByDescending(x => x.SchoolyearCode)
- .ThenByDescending(x => x.ApplyTime).ThenBy(x => x.ApplyUserID).ThenBy(x => x.WeekNum).ThenBy(x => x.Weekday)
- .ThenBy(x => x.StartTimes);
- var result = resultQuery.ToGridResultSet<ScheduleAdjustmentView>(pageIndex, pageSize);
- if (pageIndex.HasValue && pageSize.HasValue)
- {
- var adjustmentIDList = result.rows.Select(x => (Guid?)x.EducationSchedulingAdjustmentID).ToList();
- var teacherList = teacherQuery.Where(x => adjustmentIDList.Contains(x.EducationSchedulingAdjustmentID))
- .OrderBy(x => x.TeachingMethod).ThenBy(x => x.Name)
- .ToList();
- var toTeacherList = toTeacherQuery.Where(x => adjustmentIDList.Contains(x.EducationSchedulingAdjustmentID))
- .OrderBy(x => x.TeachingMethod).ThenBy(x => x.Name).ToList();
- result.rows.ForEach(x =>
- {
- x.TeacherNames = string.Join(",", teacherList
- .Where(w => w.EducationSchedulingAdjustmentID == x.EducationSchedulingAdjustmentID)
- .Select(w => w.Name));
- x.ToTeacherNames = string.Join(",", toTeacherList
- .Where(w => w.EducationSchedulingAdjustmentID == x.EducationSchedulingAdjustmentID)
- .Select(w => w.Name));
- x.RecordStatusName = statusList.FirstOrDefault(w => w.ID == x.RecordStatus).Name;
- });
- }
- else
- {
- var teacherList = teacherQuery
- .OrderBy(x => x.TeachingMethod).ThenBy(x => x.Name).ToList();
- var toTeacherList = toTeacherQuery
- .OrderBy(x => x.TeachingMethod).ThenBy(x => x.Name).ToList();
- result.rows.ForEach(x =>
- {
- x.TeacherNames = string.Join(",", teacherList
- .Where(w => w.EducationSchedulingAdjustmentID == x.EducationSchedulingAdjustmentID)
- .Select(w => w.Name));
- x.ToTeacherNames = string.Join(",", toTeacherList
- .Where(w => w.EducationSchedulingAdjustmentID == x.EducationSchedulingAdjustmentID)
- .Select(w => w.Name));
- x.RecordStatusName = statusList.FirstOrDefault(w => w.ID == x.RecordStatus).Name;
- });
- }
- return result;
- }
- public List<ScheduleAdjustmentView> GetScheduleAdjustmentViewList(ConfiguretView configuretView,
- Guid? schoolyearID, Guid? coursematerialID, Guid? collegeID, Guid? userID, Guid? classroomID,
- Guid? applyUserID, DateTime? startTime, DateTime? endTime, int? recordStatus)
- {
- return this.GetScheduleAdjustmentViewList(configuretView, schoolyearID, coursematerialID, collegeID,
- userID, classroomID, applyUserID, startTime, endTime, recordStatus, null, null).rows;
- }
- public void OnApproved(List<Guid> scheduleAdjustmentIDList, Guid userID)
- {
- var scheduleAdjustmentList = EducationSchedulingAdjustmentDAL.EducationSchedulingAdjustmentRepository
- .GetList(x => scheduleAdjustmentIDList.Contains(x.EducationSchedulingAdjustmentID),
- (x => x.ES_EducationSchedulingAdjustmentTeacher), (x => x.ES_EducationSchedulingAdjustmentToTeacher)).ToList();
- var endStatusID = this.GetCorrectEndStatus();
- var startStatusID = this.GetStartStatus();
- var backpointStatusList = this.GetBackpointStatus();
- var submitedStatusList = this.GetStatusViewList().Where(x => x.ID != startStatusID && x.ID != endStatusID
- && !backpointStatusList.Contains(x.ID)).Select(x => x.ID).ToList();
- var currentSchoolyear = this.SchoolYearServices.Value.GetCurrentSchoolYear();
- var adjustmentList = this.EducationSchedulingAdjustmentDAL.EducationSchedulingAdjustmentRepository
- .GetList(x => scheduleAdjustmentIDList.Contains(x.EducationSchedulingAdjustmentID), (x => x.CoursesTimeID_Nav), (x => x.ToCoursesTimeID_Nav),
- (x => x.EM_EducationMissionClass.EM_EducationSchedulingClass.Select(w => w.CF_Student))).ToList();
- var stopApprovedStatus = this.EducationSchedulingStopServices.Value.GetCorrectEndStatus().Value;
- var stopList = this.EducationSchedulingStopDAL.GetEducationSchedulingAdjustmentStopView(x =>
- scheduleAdjustmentIDList.Contains(x.EducationSchedulingAdjustmentID), stopApprovedStatus).ToList();
- if (adjustmentList.Any(x => SchoolYearServices.Value.IsTimePassed(
- currentSchoolyear, x.WeekNum, x.Weekday, x.CoursesTimeID_Nav.StartHour, x.CoursesTimeID_Nav.StartMinutes)
- && !stopList.Any(w => w.IsStop && w.EducationSchedulingAdjustmentID == x.EducationSchedulingAdjustmentID))
- || adjustmentList.Any(x => SchoolYearServices.Value.IsTimePassed(
- currentSchoolyear, x.ToWeekNum, x.ToWeekday, x.ToCoursesTimeID_Nav.StartHour, x.ToCoursesTimeID_Nav.StartMinutes)))
- {
- throw new Exception("调整前后的时间均不能早于当前时间,请核对。");
- }
- var adjustmentQuery = this.EducationSchedulingDAL
- .GetConflictAdjustmentSchedule(x => scheduleAdjustmentIDList.Contains(x.EducationSchedulingAdjustmentID), submitedStatusList);
- var adjustmentConflictList = this.EducationSchedulingDAL.GetSelfClassroomConflictQueryable(adjustmentQuery).ToList()
- .Concat(this.EducationSchedulingDAL.GetSelfTeacherConflictQueryable(adjustmentQuery).ToList())
- .Concat(this.EducationSchedulingDAL.GetSelfStudentConflictQueryable(adjustmentQuery).ToList()
- .GroupBy(w => new { w.EducationSchedulingWeekNumID, w.EducationSchedulingAdjustmentID })
- .Select(w => w.FirstOrDefault()).ToList())
- .Concat(this.EducationSchedulingDAL.GetSelfConflictQueryable(adjustmentQuery).ToList())
- .Concat(this.EducationSchedulingDAL.GetClassroomSeatConflictQueryable(adjustmentQuery).ToList())
- .Concat(this.EducationSchedulingDAL.GetClassroomReserveQueryable(adjustmentQuery).ToList())
- .Concat(this.EducationSchedulingDAL.GetClassroomScheduleConflicQueryable(adjustmentQuery).ToList())
- .Concat(this.EducationSchedulingDAL.GetClassroomConflicQueryable(adjustmentQuery).ToList())
- .Concat(this.EducationSchedulingDAL.GetClassroomExcessiveUseQueryable(adjustmentQuery).ToList())
- .Concat(this.EducationSchedulingDAL.GetClassroomAdjustmentConflictQueryable(adjustmentQuery, submitedStatusList).ToList())
- .Concat(this.EducationSchedulingDAL.GetCourseScheduleConflictQueryable(adjustmentQuery).ToList())
- .Concat(this.EducationSchedulingDAL.GetTeacherScheduleConflictQueryable(adjustmentQuery).ToList())
- .Concat(this.EducationSchedulingDAL.GetTeacherConflictQueryable(adjustmentQuery).ToList())
- .Concat(this.EducationSchedulingDAL.GetTeacherAdjustmentConflictQueryable(adjustmentQuery, submitedStatusList).ToList())
- .Concat(this.EducationSchedulingDAL.GetStudentScheduleConflictQueryable(adjustmentQuery).ToList())
- .Concat(this.EducationSchedulingDAL.GetStudentConflictQueryable(adjustmentQuery).ToList())
- .Concat(this.EducationSchedulingDAL.GetStudentAdjustmentConflictQueryable(adjustmentQuery, submitedStatusList).ToList()).ToList();
- var dateList = SchoolYearServices.Value.GetDateByCoursesTime(currentSchoolyear.SchoolYearID ?? Guid.Empty,
- adjustmentList.Select(x => new FullCoursesTimeView
- {
- WeekNum = x.ToWeekNum,
- Weekday = x.ToWeekday
- }).ToList());
- var examinationPlanList = ExaminationPlanDAL.GetExaminationPlanView(x => dateList.Contains(x.ExaminationDate ?? DateTime.MinValue) && x.SchoolyearID == currentSchoolyear.SchoolYearID
- && x.RecordStatus == (int)EX_ExaminationPlanStatus.Submitted).ToList();
- var examinationPlanIDList = examinationPlanList.Select(x => x.ExaminationPlanID).ToList();
- var examinationRoomLayoutViewList = ExaminationPlanDAL.GetExaminationRoomLayoutView(x => examinationPlanIDList.Contains((Guid)x.ExaminationPlanID)).ToList();
- examinationPlanList.ForEach(x => x.ExaminationRoomLayoutView = new HashSet<ExaminationRoomLayoutView>(examinationRoomLayoutViewList.Where(y => y.ExaminationPlanID == x.ExaminationPlanID)));
- var firstWeek = currentSchoolyear.FirstWeek.Value.AddDays(1 - (int)currentSchoolyear.FirstWeek.Value.DayOfWeek);
- adjustmentConflictList = adjustmentConflictList.Concat(
- adjustmentList.Where(x => examinationPlanList.Any(w => SchoolYearServices.Value.GetStartEndTimeByCourseTime(firstWeek, new FullCoursesTimeView
- {
- WeekNum = x.ToWeekNum,
- Weekday = x.ToWeekday,
- CoursesTimeID = x.ToCoursesTimeID,
- StartHour = x.ToCoursesTimeID_Nav.StartHour,
- StartMinute = x.ToCoursesTimeID_Nav.StartMinutes,
- EndHour = x.ToCoursesTimeID_Nav.EndHour,
- EndMinute = x.ToCoursesTimeID_Nav.EndMinutes
- }).IsOverlap(w.ExaminationDate.Value.Add(w.StartTime.Value), w.ExaminationDate.Value.Add(w.EndTime.Value)) && w.ExaminationRoomLayoutView.Select(v => (Guid?)v.ClassroomID).Contains(x.ToClassroomID))
- ).Select(x => new EducationSchedulingConflictView
- {
- EducationSchedulingAdjustmentID = x.EducationSchedulingAdjustmentID,
- EducationMissionClassName = x.EM_EducationMissionClass.Name,
- WeekNum = x.WeekNum,
- Weekday = x.Weekday,
- StartTimes = x.CoursesTimeID_Nav.StartTimes,
- EndTimes = x.CoursesTimeID_Nav.EndTimes,
- ClassroomID = x.ClassroomID,
- Reason = "教室在该节次安排了考试。"
- }).ToList()).Concat(
- adjustmentList.Where(x => examinationPlanList.Any(w => SchoolYearServices.Value.GetStartEndTimeByCourseTime(firstWeek, new FullCoursesTimeView
- {
- WeekNum = x.ToWeekNum,
- Weekday = x.ToWeekday,
- CoursesTimeID = x.ToCoursesTimeID,
- StartHour = x.ToCoursesTimeID_Nav.StartHour,
- StartMinute = x.ToCoursesTimeID_Nav.StartMinutes,
- EndHour = x.ToCoursesTimeID_Nav.EndHour,
- EndMinute = x.ToCoursesTimeID_Nav.EndMinutes
- }).IsOverlap(w.ExaminationDate.Value.Add(w.StartTime.Value), w.ExaminationDate.Value.Add(w.EndTime.Value)) && w.ExaminationRoomLayoutView
- .SelectMany(v => v.Sys_User).Select(v => (Guid?)v.UserID).Contains(x.ToUserID))
- ).Select(x => new EducationSchedulingConflictView
- {
- EducationSchedulingAdjustmentID = x.EducationSchedulingAdjustmentID,
- EducationMissionClassName = x.EM_EducationMissionClass.Name,
- WeekNum = x.WeekNum,
- Weekday = x.Weekday,
- StartTimes = x.CoursesTimeID_Nav.StartTimes,
- EndTimes = x.CoursesTimeID_Nav.EndTimes,
- ClassroomID = x.ClassroomID,
- Reason = "教师在该节次安排了考试。"
- }).ToList()).Concat(
- adjustmentList.Where(x => examinationPlanList.Any(w => SchoolYearServices.Value.GetStartEndTimeByCourseTime(firstWeek, new FullCoursesTimeView
- {
- WeekNum = x.ToWeekNum,
- Weekday = x.ToWeekday,
- CoursesTimeID = x.ToCoursesTimeID,
- StartHour = x.ToCoursesTimeID_Nav.StartHour,
- StartMinute = x.ToCoursesTimeID_Nav.StartMinutes,
- EndHour = x.ToCoursesTimeID_Nav.EndHour,
- EndMinute = x.ToCoursesTimeID_Nav.EndMinutes
- }).IsOverlap(w.ExaminationDate.Value.Add(w.StartTime.Value), w.ExaminationDate.Value.Add(w.EndTime.Value)) && w.ExaminationRoomLayoutView
- .SelectMany(v => v.EX_ExaminationRoomStudent).Select(v => v.UserID)
- .Intersect(x.EM_EducationMissionClass.EM_EducationSchedulingClass.SelectMany(v => v.CF_Student).Select(v => (Guid?)v.UserID)).Count() > 0)
- ).Select(x => new EducationSchedulingConflictView
- {
- EducationSchedulingAdjustmentID = x.EducationSchedulingAdjustmentID,
- EducationMissionClassName = x.EM_EducationMissionClass.Name,
- WeekNum = x.WeekNum,
- Weekday = x.Weekday,
- StartTimes = x.CoursesTimeID_Nav.StartTimes,
- EndTimes = x.CoursesTimeID_Nav.EndTimes,
- ClassroomID = x.ClassroomID,
- Reason = "学生在该节次安排了考试。"
- }).ToList()).ToList();
- if (adjustmentConflictList.Count > 0)
- {
- var errorMessage = string.Join(";", adjustmentConflictList.Select(x =>
- string.Format("{0}第{1}周星期{2}的{3}-{4}节调整失败,原因:{5}",
- x.EducationMissionClassName, x.WeekNum, WeekDayView.GetWeekdayName(x.Weekday), x.StartTimes, x.EndTimes, x.Reason)
- ));
- throw new Exception(errorMessage);
- }
- var educationSchedulingList = this.EducationSchedulingAdjustmentDAL.GetEducationSchedulingQueryableByAdjustment(x =>
- scheduleAdjustmentIDList.Contains(x.EducationSchedulingAdjustmentID)).Include(x => x.EM_EducationSchedulingClass).ToList();
- var educationSchedulingWeekNumList = this.EducationSchedulingAdjustmentDAL.GetEducationSchedulingWeekNumQueryableByAdjustment(x =>
- scheduleAdjustmentIDList.Contains(x.EducationSchedulingAdjustmentID)).ToList();
- var educationSchedulingTeacherList = this.EducationSchedulingAdjustmentDAL.GetEducationSchedulingTeacherQueryableByAdjustment(x =>
- scheduleAdjustmentIDList.Contains(x.EducationSchedulingAdjustmentID)).ToList();
- var newEducationSchedulingList = this.EducationSchedulingAdjustmentDAL.GetNewEducationSchedulingQueryableByAdjustment(x =>
- scheduleAdjustmentIDList.Contains(x.EducationSchedulingAdjustmentID)).Include(x => x.EM_EducationSchedulingClass).ToList();
- var newEducationSchedulingWeekNumList = this.EducationSchedulingAdjustmentDAL.GetNewEducationSchedulingWeekNumQueryableByAdjustment(x =>
- scheduleAdjustmentIDList.Contains(x.EducationSchedulingAdjustmentID)).ToList();
- var newEducationSchedulingTeacherList = this.EducationSchedulingAdjustmentDAL.GetNewEducationSchedulingTeacherQueryableByAdjustment(x =>
- scheduleAdjustmentIDList.Contains(x.EducationSchedulingAdjustmentID)).ToList();
- List<ES_EducationScheduling> insertEducationSchedulingList = new List<ES_EducationScheduling>();
- List<ES_EducationSchedulingTeacher> insertEducationSchedulingTeacherList = new List<ES_EducationSchedulingTeacher>();
- List<ES_EducationSchedulingWeekNum> insertEducationSchedulingWeekNumList = new List<ES_EducationSchedulingWeekNum>();
- List<ES_EducationScheduling> deleteEducationSchedulingList = new List<ES_EducationScheduling>();
- List<ES_EducationSchedulingTeacher> deleteEducationSchedulingTeacherList = new List<ES_EducationSchedulingTeacher>();
- List<ES_EducationSchedulingWeekNum> deleteEducationSchedulingWeekNumList = new List<ES_EducationSchedulingWeekNum>();
- foreach (var scheduleAdjustment in scheduleAdjustmentList)
- {
- var educationScheduling = educationSchedulingList
- .FirstOrDefault(x => x.Weekday == scheduleAdjustment.Weekday
- && x.CoursesTimeID == scheduleAdjustment.CoursesTimeID
- && x.EM_EducationSchedulingClass.EducationMissionClassID == scheduleAdjustment.EducationMissionClassID
- && educationSchedulingTeacherList.Any(w => w.EducationSchedulingID == x.EducationSchedulingID && w.UserID == scheduleAdjustment.UserID)
- && educationSchedulingWeekNumList.Any(w => w.EducationSchedulingID == x.EducationSchedulingID && scheduleAdjustment.WeekNum == w.WeekNum));
- var curEducationSchedulingTeacherList = educationSchedulingTeacherList
- .Where(w => w.EducationSchedulingID == educationScheduling.EducationSchedulingID)
- .ToList();
- var curEducationSchedulingWeekNumList = educationSchedulingWeekNumList
- .Where(w => w.EducationSchedulingID == educationScheduling.EducationSchedulingID)
- .ToList();
- if (educationScheduling != null)
- {
- var toTeacherList = scheduleAdjustment.ES_EducationSchedulingAdjustmentToTeacher.Select(x => new CourseProcessTeacherView
- {
- UserID = x.UserID ?? Guid.Empty,
- TeachingMethod = x.TeachingMethod
- }).ToList();
- ES_EducationScheduling newEducationScheduling;
- var curNewEducationSchedulingList = newEducationSchedulingList
- .Where(x => x.Weekday == scheduleAdjustment.ToWeekday
- && x.CoursesTimeID == scheduleAdjustment.ToCoursesTimeID
- && x.EM_EducationSchedulingClass.EducationMissionClassID == scheduleAdjustment.EducationMissionClassID
- && x.ClassroomID == scheduleAdjustment.ToClassroomID).ToList();
- newEducationScheduling = curNewEducationSchedulingList.FirstOrDefault(x =>
- string.Join(",", newEducationSchedulingTeacherList.Where(w => x.EducationSchedulingID == w.EducationSchedulingID)
- .Select(w => w.UserID.ToString() + "," + w.TeachingMethod).OrderBy(w => w))
- == string.Join(",", toTeacherList.Select(w => w.UserID.ToString() + "," + w.TeachingMethod).OrderBy(w => w)));
- if (newEducationScheduling == null)
- {
- newEducationScheduling = new ES_EducationScheduling
- {
- EducationSchedulingID = Guid.NewGuid(),
- SchoolyearID = educationScheduling.SchoolyearID,
- EducationSchedulingClassID = educationScheduling.EducationSchedulingClassID,
- EM_EducationSchedulingClass = educationScheduling.EM_EducationSchedulingClass,
- Weekday = scheduleAdjustment.ToWeekday,
- CoursesTimeID = scheduleAdjustment.ToCoursesTimeID,
- ClassroomID = scheduleAdjustment.ToClassroomID
- };
- toTeacherList.ForEach(x =>
- {
- var educationSchedulingTeacher = new ES_EducationSchedulingTeacher
- {
- EducationSchedulingTeacherID = Guid.NewGuid(),
- EducationSchedulingID = newEducationScheduling.EducationSchedulingID,
- UserID = x.UserID,
- TeachingMethod = x.TeachingMethod
- };
- this.SetNewStatus(educationSchedulingTeacher);
- insertEducationSchedulingTeacherList.Add(educationSchedulingTeacher);
- newEducationSchedulingTeacherList.Add(educationSchedulingTeacher);
- });
- this.SetNewStatus(newEducationScheduling);
- insertEducationSchedulingList.Add(newEducationScheduling);
- newEducationSchedulingList.Add(newEducationScheduling);
- }
- var curNewEducationSchedulingWeekNumList = newEducationSchedulingWeekNumList.Where(x => x.EducationSchedulingID == newEducationScheduling.EducationSchedulingID).ToList();
- if (curNewEducationSchedulingWeekNumList.Any(w => scheduleAdjustment.ToWeekNum == w.WeekNum && w.EducationSchedulingID != educationScheduling.EducationSchedulingID))
- {
- throw new Exception("调整后的课程周次冲突,请检查课表。");
- }
- var educationSchedulingWeekNum = new ES_EducationSchedulingWeekNum
- {
- EducationSchedulingWeekNumID = Guid.NewGuid(),
- EducationSchedulingID = newEducationScheduling.EducationSchedulingID,
- WeekNum = scheduleAdjustment.ToWeekNum
- };
- this.SetNewStatus(educationSchedulingWeekNum);
- insertEducationSchedulingWeekNumList.Add(educationSchedulingWeekNum);
- newEducationSchedulingWeekNumList.Add(educationSchedulingWeekNum);
- deleteEducationSchedulingWeekNumList.AddRange(curEducationSchedulingWeekNumList.Where(x => x.EducationSchedulingID == educationScheduling.EducationSchedulingID
- && x.WeekNum == scheduleAdjustment.WeekNum).ToList());
- educationSchedulingWeekNumList.RemoveAll(x => x.EducationSchedulingID == educationScheduling.EducationSchedulingID
- && x.WeekNum == scheduleAdjustment.WeekNum);
- curEducationSchedulingWeekNumList.RemoveAll(x => x.EducationSchedulingID == educationScheduling.EducationSchedulingID
- && x.WeekNum == scheduleAdjustment.WeekNum);
- newEducationSchedulingWeekNumList.RemoveAll(x => x.EducationSchedulingID == educationScheduling.EducationSchedulingID
- && x.WeekNum == scheduleAdjustment.WeekNum);
- if (curEducationSchedulingWeekNumList.Count == 0)
- {
- deleteEducationSchedulingTeacherList.AddRange(curEducationSchedulingTeacherList);
- deleteEducationSchedulingList.Add(educationScheduling);
- }
- }
- else
- {
- throw new Exception("原先选定的课程已经被调整。");
- }
- }
- using (var scope = new TransactionScope())
- {
- UnitOfWork.BulkInsert(insertEducationSchedulingList);
- UnitOfWork.BulkInsert(insertEducationSchedulingTeacherList);
- UnitOfWork.BulkInsert(insertEducationSchedulingWeekNumList);
- UnitOfWork.Delete(deleteEducationSchedulingWeekNumList);
- UnitOfWork.Delete(deleteEducationSchedulingTeacherList);
- UnitOfWork.Delete(deleteEducationSchedulingList);
- scope.Complete();
- }
- }
- public ScheduleAdjustmentEditView GetScheduleAdjustmentEditView(Guid educationAdjustmentSchedulingID)
- {
- var result = this.EducationSchedulingAdjustmentDAL
- .GetScheduleAdjustmentEditViewQueryable(x => x.EducationSchedulingAdjustmentID == educationAdjustmentSchedulingID,
- (x => true), (x => true), (x => true)).FirstOrDefault();
- return result;
- }
- public void Delete(IList<Guid> adjustmentIDList)
- {
- var startStatus = this.GetStartStatus();
- var submitedAdjustmentList = this.EducationSchedulingAdjustmentDAL.EducationSchedulingAdjustmentRepository
- .GetList(x => adjustmentIDList.Contains(x.EducationSchedulingAdjustmentID) && x.RecordStatus != startStatus).ToList();
- if (submitedAdjustmentList.Count > 0)
- {
- throw new Exception("所选记录当中存在已经提交的记录,无法删除。");
- }
- var nullableAdjustmentIDList = adjustmentIDList.Select(x => (Guid?)x).ToList();
- this.UnitOfWork.Delete<ES_EducationSchedulingAdjustmentTeacher>(x => nullableAdjustmentIDList.Contains(x.EducationSchedulingAdjustmentID));
- this.UnitOfWork.Delete<ES_EducationSchedulingAdjustmentToTeacher>(x => nullableAdjustmentIDList.Contains(x.EducationSchedulingAdjustmentID));
- this.UnitOfWork.Delete<ES_EducationSchedulingAdjustment>(x => adjustmentIDList.Contains(x.EducationSchedulingAdjustmentID));
- }
- public void Submit(IList<Guid> adjustmentIDList, Guid userID)
- {
- var startStatusID = this.GetStartStatus();
- var endStatusID = this.GetCorrectEndStatus();
- var backpointStatusList = this.GetBackpointStatus();
- var submitedStatusList = this.GetStatusViewList().Where(x => x.ID != startStatusID && x.ID != endStatusID
- && !backpointStatusList.Contains(x.ID)).Select(x => x.ID).ToList();
- var currentSchoolyear = this.SchoolYearServices.Value.GetCurrentSchoolYear();
-
- var adjustmentList = this.EducationSchedulingAdjustmentDAL.EducationSchedulingAdjustmentRepository
- .GetList(x => adjustmentIDList.Contains(x.EducationSchedulingAdjustmentID), (x => x.CoursesTimeID_Nav), (x => x.ToCoursesTimeID_Nav),
- (x => x.EM_EducationMissionClass.EM_EducationSchedulingClass.Select(w => w.CF_Student))).ToList();
- if (adjustmentList.Any(x => x.RecordStatus != startStatusID && !backpointStatusList.Contains(x.RecordStatus)))
- {
- throw new Exception("只能提交已提交和已退回的记录。");
- }
- var stopApprovedStatus = this.EducationSchedulingStopServices.Value.GetCorrectEndStatus().Value;
- var stopList = this.EducationSchedulingStopDAL.GetEducationSchedulingAdjustmentStopView(x =>
- adjustmentIDList.Contains(x.EducationSchedulingAdjustmentID), stopApprovedStatus).ToList();
- if (adjustmentList.Any(x => SchoolYearServices.Value.IsTimePassed(
- currentSchoolyear, x.WeekNum, x.Weekday, x.CoursesTimeID_Nav.StartHour, x.CoursesTimeID_Nav.StartMinutes)
- && !stopList.Any(w => w.IsStop && w.EducationSchedulingAdjustmentID == x.EducationSchedulingAdjustmentID))
- || adjustmentList.Any(x => SchoolYearServices.Value.IsTimePassed(
- currentSchoolyear, x.ToWeekNum, x.ToWeekday, x.ToCoursesTimeID_Nav.StartHour, x.ToCoursesTimeID_Nav.StartMinutes)))
- {
- throw new Exception("调整前后的时间均不能早于当前时间,请核对。");
- }
- var adjustmentQuery = this.EducationSchedulingDAL.GetConflictAdjustmentSchedule(x => adjustmentIDList.Contains(x.EducationSchedulingAdjustmentID), submitedStatusList);
- var adjustmentConflictList =
- //提交的各调整记录之间的教室冲突
- this.EducationSchedulingDAL.GetSelfClassroomConflictQueryable(adjustmentQuery).ToList()
- //提交的各调整记录之间的教师冲突
- .Concat(this.EducationSchedulingDAL.GetSelfTeacherConflictQueryable(adjustmentQuery).ToList())
- //提交的各调整记录之间的学生冲突
- .Concat(this.EducationSchedulingDAL.GetSelfStudentConflictQueryable(adjustmentQuery).ToList()
- .GroupBy(w => new { w.EducationSchedulingWeekNumID, w.EducationSchedulingAdjustmentID })
- .Select(w => w.FirstOrDefault()).ToList())
- //提交的各调整记录之间的同一节课的重复调动冲突
- .Concat(this.EducationSchedulingDAL.GetSelfConflictQueryable(adjustmentQuery).ToList())
- //座位不足冲突
- .Concat(this.EducationSchedulingDAL.GetClassroomSeatConflictQueryable(adjustmentQuery).ToList())
- //教室预留冲突
- .Concat(this.EducationSchedulingDAL.GetClassroomReserveQueryable(adjustmentQuery).ToList())
- //教室可排时间冲突
- .Concat(this.EducationSchedulingDAL.GetClassroomScheduleConflicQueryable(adjustmentQuery).ToList())
- //教室课表冲突
- .Concat(this.EducationSchedulingDAL.GetClassroomConflicQueryable(adjustmentQuery).ToList())
- //教室占用冲突
- .Concat(this.EducationSchedulingDAL.GetClassroomExcessiveUseQueryable(adjustmentQuery).ToList())
- //教室被他人调课占用冲突
- .Concat(this.EducationSchedulingDAL.GetClassroomAdjustmentConflictQueryable(adjustmentQuery, submitedStatusList).ToList())
- //课程可排时间冲突
- .Concat(this.EducationSchedulingDAL.GetCourseScheduleConflictQueryable(adjustmentQuery).ToList())
- //教师可排时间冲突
- .Concat(this.EducationSchedulingDAL.GetTeacherScheduleConflictQueryable(adjustmentQuery).ToList())
- //教师课表冲突
- .Concat(this.EducationSchedulingDAL.GetTeacherConflictQueryable(adjustmentQuery).ToList())
- //教师被他人调课占用冲突
- .Concat(this.EducationSchedulingDAL.GetTeacherAdjustmentConflictQueryable(adjustmentQuery, submitedStatusList).ToList())
- //班级可排时间冲突
- .Concat(this.EducationSchedulingDAL.GetStudentScheduleConflictQueryable(adjustmentQuery).ToList())
- //学生课表冲突
- .Concat(this.EducationSchedulingDAL.GetStudentConflictQueryable(adjustmentQuery).ToList())
- //学生被他人调课占用冲突
- .Concat(this.EducationSchedulingDAL.GetStudentAdjustmentConflictQueryable(adjustmentQuery, submitedStatusList).ToList())
- .ToList();
- var dateList = SchoolYearServices.Value.GetDateByCoursesTime(currentSchoolyear.SchoolYearID ?? Guid.Empty,
- adjustmentList.Select(x => new FullCoursesTimeView
- {
- WeekNum = x.ToWeekNum,
- Weekday = x.ToWeekday
- }).ToList());
- var examinationPlanList = ExaminationPlanDAL.GetExaminationPlanView(x => dateList.Contains(x.ExaminationDate ?? DateTime.MinValue) && x.SchoolyearID == currentSchoolyear.SchoolYearID
- && x.RecordStatus == (int)EX_ExaminationPlanStatus.Submitted).ToList();
- var examinationPlanIDList = examinationPlanList.Select(x => x.ExaminationPlanID).ToList();
- var examinationRoomLayoutViewList = ExaminationPlanDAL.GetExaminationRoomLayoutView(x => examinationPlanIDList.Contains((Guid)x.ExaminationPlanID)).ToList();
- examinationPlanList.ForEach(x => x.ExaminationRoomLayoutView = new HashSet<ExaminationRoomLayoutView>(examinationRoomLayoutViewList.Where(y => y.ExaminationPlanID == x.ExaminationPlanID)));
- var firstWeek = currentSchoolyear.FirstWeek.Value.AddDays(1 - (int)currentSchoolyear.FirstWeek.Value.DayOfWeek);
- //学年学期还有问题,应该按照提交的记录找出他们的学年学期
- adjustmentConflictList = adjustmentConflictList.Concat(
- adjustmentList.Where(x => examinationPlanList.Any(w => SchoolYearServices.Value.GetStartEndTimeByCourseTime(firstWeek, new FullCoursesTimeView {
- WeekNum = x.ToWeekNum,
- Weekday = x.ToWeekday,
- CoursesTimeID = x.ToCoursesTimeID,
- StartHour = x.ToCoursesTimeID_Nav.StartHour,
- StartMinute = x.ToCoursesTimeID_Nav.StartMinutes,
- EndHour = x.ToCoursesTimeID_Nav.EndHour,
- EndMinute = x.ToCoursesTimeID_Nav.EndMinutes
- }).IsOverlap(w.ExaminationDate.Value.Add(w.StartTime.Value), w.ExaminationDate.Value.Add(w.EndTime.Value)) && w.ExaminationRoomLayoutView.Select(v => (Guid?)v.ClassroomID).Contains(x.ToClassroomID))
- ).Select(x => new EducationSchedulingConflictView
- {
- EducationSchedulingAdjustmentID = x.EducationSchedulingAdjustmentID,
- EducationMissionClassName = x.EM_EducationMissionClass.Name,
- WeekNum = x.WeekNum,
- Weekday = x.Weekday,
- StartTimes = x.CoursesTimeID_Nav.StartTimes,
- EndTimes = x.CoursesTimeID_Nav.EndTimes,
- ClassroomID = x.ClassroomID,
- Reason = "教室在该节次安排了考试。"
- }).ToList()).Concat(
- adjustmentList.Where(x => examinationPlanList.Any(w => SchoolYearServices.Value.GetStartEndTimeByCourseTime(firstWeek, new FullCoursesTimeView
- {
- WeekNum = x.ToWeekNum,
- Weekday = x.ToWeekday,
- CoursesTimeID = x.ToCoursesTimeID,
- StartHour = x.ToCoursesTimeID_Nav.StartHour,
- StartMinute = x.ToCoursesTimeID_Nav.StartMinutes,
- EndHour = x.ToCoursesTimeID_Nav.EndHour,
- EndMinute = x.ToCoursesTimeID_Nav.EndMinutes
- }).IsOverlap(w.ExaminationDate.Value.Add(w.StartTime.Value), w.ExaminationDate.Value.Add(w.EndTime.Value)) && w.ExaminationRoomLayoutView
- .SelectMany(v => v.Sys_User).Select(v => (Guid?)v.UserID).Contains(x.ToUserID))
- ).Select(x => new EducationSchedulingConflictView
- {
- EducationSchedulingAdjustmentID = x.EducationSchedulingAdjustmentID,
- EducationMissionClassName = x.EM_EducationMissionClass.Name,
- WeekNum = x.WeekNum,
- Weekday = x.Weekday,
- StartTimes = x.CoursesTimeID_Nav.StartTimes,
- EndTimes = x.CoursesTimeID_Nav.EndTimes,
- ClassroomID = x.ClassroomID,
- Reason = "教师在该节次安排了考试。"
- }).ToList()).Concat(
- adjustmentList.Where(x => examinationPlanList.Any(w => SchoolYearServices.Value.GetStartEndTimeByCourseTime(firstWeek, new FullCoursesTimeView
- {
- WeekNum = x.ToWeekNum,
- Weekday = x.ToWeekday,
- CoursesTimeID = x.ToCoursesTimeID,
- StartHour = x.ToCoursesTimeID_Nav.StartHour,
- StartMinute = x.ToCoursesTimeID_Nav.StartMinutes,
- EndHour = x.ToCoursesTimeID_Nav.EndHour,
- EndMinute = x.ToCoursesTimeID_Nav.EndMinutes
- }).IsOverlap(w.ExaminationDate.Value.Add(w.StartTime.Value), w.ExaminationDate.Value.Add(w.EndTime.Value)) && w.ExaminationRoomLayoutView
- .SelectMany(v => v.EX_ExaminationRoomStudent).Select(v => v.UserID)
- .Intersect(x.EM_EducationMissionClass.EM_EducationSchedulingClass.SelectMany(v => v.CF_Student).Select(v => (Guid?)v.UserID)).Count() > 0)
- ).Select(x => new EducationSchedulingConflictView
- {
- EducationSchedulingAdjustmentID = x.EducationSchedulingAdjustmentID,
- EducationMissionClassName = x.EM_EducationMissionClass.Name,
- WeekNum = x.WeekNum,
- Weekday = x.Weekday,
- StartTimes = x.CoursesTimeID_Nav.StartTimes,
- EndTimes = x.CoursesTimeID_Nav.EndTimes,
- ClassroomID = x.ClassroomID,
- Reason = "学生在该节次安排了考试。"
- }).ToList()).ToList();
- if (adjustmentConflictList.Count > 0)
- {
- var errorMessage = string.Join(";", adjustmentConflictList.Select(x =>
- string.Format("{0}第{1}周{2}的{3}-{4}节调整失败,原因:{5}",
- x.EducationMissionClassName, x.WeekNum, WeekDayView.GetWeekdayName(x.Weekday), x.StartTimes, x.EndTimes, x.Reason)
- ));
- throw new Exception(errorMessage);
- }
- var notSubmitList = adjustmentList.Where(x => x.RecordStatus == startStatusID).Select(x => x.EducationSchedulingAdjustmentID).ToList();
- var submitedList = adjustmentList.Where(x => x.RecordStatus != startStatusID).Select(x => x.EducationSchedulingAdjustmentID).ToList();
- if (notSubmitList.Count > 0)
- {
- this.StartUp(notSubmitList, userID);
- }
- if (submitedList.Count > 0)
- {
- var action = this.GetActionView(submitedList.First(), userID).FirstOrDefault();
- if (action != null)
- {
- this.Approve(submitedList, userID, action.ActionID);
- }
- }
- var nowTime = DateTime.Now;
- UnitOfWork.Update<ES_EducationSchedulingAdjustment>((x => new ES_EducationSchedulingAdjustment { ApplyUserID = userID, ApplyTime = nowTime }), (x => adjustmentIDList.Contains(x.EducationSchedulingAdjustmentID)));
- }
- public IGridResultSet<ScheduleAdjustmentView> GetScheduleAdjustmentViewApproveList(ConfiguretView configuretView,
- Guid? schoolyearID, Guid? coursematerialID, Guid? collegeID, Guid? userID, Guid? classroomID, Guid? applyUserID,
- DateTime? startTime, DateTime? endTime, int? recordStatus, int? pageIndex, int? pageSize)
- {
- var statusList = this.GetStatusViewList();
- Expression<Func<ES_EducationSchedulingAdjustment, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- Expression<Func<EM_EducationMission, bool>> missionExp = (x => true);
- Expression<Func<EM_EducationMissionClass, bool>> missionClassExp = (x => true);
- Expression<Func<CF_Staff, bool>> staffExp = (x => true);
- if (schoolyearID.HasValue)
- {
- missionExp = missionExp.And(x => x.SchoolyearID == schoolyearID);
- }
- if (coursematerialID.HasValue)
- {
- missionClassExp = missionClassExp.And(x => x.CoursematerialID == coursematerialID);
- }
- if (collegeID.HasValue)
- {
- staffExp = staffExp.And(x => x.CollegeID == collegeID);
- }
- if (userID.HasValue)
- {
- exp = exp.And(x => x.ES_EducationSchedulingAdjustmentTeacher.Any(y => y.UserID == userID));
- //staffExp = staffExp.And(x => x.UserID == userID);
- }
- if (classroomID.HasValue)
- {
- exp = exp.And(x => x.ClassroomID == classroomID);
- }
- if (applyUserID.HasValue)
- {
- exp = exp.And(x => x.CreateUserID == applyUserID);
- }
- if (startTime.HasValue)
- {
- exp = exp.And(x => x.ApplyTime >= startTime);
- }
- if (endTime.HasValue)
- {
- var correctEndTime = endTime.Value.Date.AddDays(1);
- exp = exp.And(x => x.ApplyTime < correctEndTime);
- }
- if (recordStatus.HasValue)
- {
- exp = exp.And(x => x.RecordStatus == recordStatus);
- }
- var query = this.EducationSchedulingAdjustmentDAL.GetScheduleAdjustmentViewQueryable(exp, missionExp, missionClassExp, staffExp);
- var teacherQuery = this.EducationSchedulingAdjustmentDAL.GetEducationSchedulingAdjustmentTeacherQueryable(
- exp, missionExp, missionClassExp, staffExp);
- var toTeacherQuery = this.EducationSchedulingAdjustmentDAL.GetEducationSchedulingAdjustmentToTeacherQueryable(
- exp, missionExp, missionClassExp, staffExp);
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- query = this.GetQueryByDataRangeByDepartment(query);
- var resultQuery = query.OrderByDescending(x => x.SchoolyearCode)
- .ThenByDescending(x => x.ApplyTime).ThenBy(x => x.ApplyUserID).ThenBy(x => x.WeekNum).ThenBy(x => x.Weekday)
- .ThenBy(x => x.StartTimes);
- var result = resultQuery.ToGridResultSet<ScheduleAdjustmentView>(pageIndex, pageSize);
- if (pageIndex.HasValue && pageSize.HasValue)
- {
- var adjustmentIDList = result.rows.Select(x => (Guid?)x.EducationSchedulingAdjustmentID).ToList();
- var teacherList = teacherQuery.Where(x => adjustmentIDList.Contains(x.EducationSchedulingAdjustmentID))
- .OrderBy(x => x.TeachingMethod).ThenBy(x => x.Name)
- .ToList();
- var toTeacherList = toTeacherQuery.Where(x => adjustmentIDList.Contains(x.EducationSchedulingAdjustmentID))
- .OrderBy(x => x.TeachingMethod).ThenBy(x => x.Name).ToList();
- result.rows.ForEach(x =>
- {
- x.TeacherNames = string.Join(",", teacherList
- .Where(w => w.EducationSchedulingAdjustmentID == x.EducationSchedulingAdjustmentID)
- .Select(w => w.Name));
- x.ToTeacherNames = string.Join(",", toTeacherList
- .Where(w => w.EducationSchedulingAdjustmentID == x.EducationSchedulingAdjustmentID)
- .Select(w => w.Name));
- x.RecordStatusName = statusList.FirstOrDefault(w => w.ID == x.RecordStatus).Name;
- });
- }
- else
- {
- var teacherList = teacherQuery
- .OrderBy(x => x.TeachingMethod).ThenBy(x => x.Name).ToList();
- var toTeacherList = toTeacherQuery
- .OrderBy(x => x.TeachingMethod).ThenBy(x => x.Name).ToList();
- result.rows.ForEach(x =>
- {
- x.TeacherNames = string.Join(",", teacherList
- .Where(w => w.EducationSchedulingAdjustmentID == x.EducationSchedulingAdjustmentID)
- .Select(w => w.Name));
- x.ToTeacherNames = string.Join(",", toTeacherList
- .Where(w => w.EducationSchedulingAdjustmentID == x.EducationSchedulingAdjustmentID)
- .Select(w => w.Name));
- x.RecordStatusName = statusList.FirstOrDefault(w => w.ID == x.RecordStatus).Name;
- });
- }
- return result;
- }
- public List<ScheduleAdjustmentView> GetScheduleAdjustmentViewApproveList(ConfiguretView configuretView, Guid? schoolyearID,
- Guid? coursematerialID, Guid? collegeID, Guid? userID, Guid? classroomID, Guid? applyUserID, DateTime? startTime, DateTime? endTime,
- int? recordStatus)
- {
- return this.GetScheduleAdjustmentViewApproveList(configuretView, schoolyearID, coursematerialID, collegeID,
- userID, classroomID, applyUserID, startTime, endTime, recordStatus, null, null).rows;
- }
- public List<ScheduleAdjustmentView> GetScheduleAdjustmentViewList(IList<Guid> scheduleAdjustmentIDList)
- {
- if (scheduleAdjustmentIDList.Count == 0)
- {
- throw new Exception("请选择需要查询的调课记录。");
- }
- var statusList = this.GetStatusViewList();
- Expression<Func<ES_EducationSchedulingAdjustment, bool>> exp = (x => scheduleAdjustmentIDList.Contains(x.EducationSchedulingAdjustmentID));
- var query = this.EducationSchedulingAdjustmentDAL.GetScheduleAdjustmentViewQueryable(exp, (x => true), (x => true), (x => true));
- var teacherQuery = this.EducationSchedulingAdjustmentDAL.GetEducationSchedulingAdjustmentTeacherQueryable(
- exp, (x => true), (x => true), (x => true));
- var toTeacherQuery = this.EducationSchedulingAdjustmentDAL.GetEducationSchedulingAdjustmentToTeacherQueryable(
- exp, (x => true), (x => true), (x => true));
- query = this.GetQueryByDataRange(query, (x => x.UserID));
- var resultQuery = query.OrderByDescending(x => x.SchoolyearCode)
- .ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
- .ThenBy(x => x.CourseName).ThenBy(x => x.UserName);
- var result = resultQuery.ToList();
- var teacherList = teacherQuery
- .OrderBy(x => x.TeachingMethod).ThenBy(x => x.Name).ToList();
- var toTeacherList = toTeacherQuery
- .OrderBy(x => x.TeachingMethod).ThenBy(x => x.Name).ToList();
- result.ForEach(x =>
- {
- x.TeacherNames = string.Join(",", teacherList
- .Where(w => w.EducationSchedulingAdjustmentID == x.EducationSchedulingAdjustmentID)
- .Select(w => w.Name));
- x.ToTeacherNames = string.Join(",", toTeacherList
- .Where(w => w.EducationSchedulingAdjustmentID == x.EducationSchedulingAdjustmentID)
- .Select(w => w.Name));
- x.RecordStatusName = statusList.FirstOrDefault(w => w.ID == x.RecordStatus).Name;
- });
- return result;
- }
- public List<ScheduleAdjustmentView> GetScheduleAdjustmentViewApproveList(IList<Guid> scheduleAdjustmentIDList)
- {
- if (scheduleAdjustmentIDList.Count == 0)
- {
- throw new Exception("请选择需要查询的调课记录。");
- }
- var statusList = this.GetStatusViewList();
- Expression<Func<ES_EducationSchedulingAdjustment, bool>> exp = (x => scheduleAdjustmentIDList.Contains(x.EducationSchedulingAdjustmentID));
- var query = this.EducationSchedulingAdjustmentDAL.GetScheduleAdjustmentViewQueryable(exp, (x => true), (x => true), (x => true));
- var teacherQuery = this.EducationSchedulingAdjustmentDAL.GetEducationSchedulingAdjustmentTeacherQueryable(
- exp, (x => true), (x => true), (x => true));
- var toTeacherQuery = this.EducationSchedulingAdjustmentDAL.GetEducationSchedulingAdjustmentToTeacherQueryable(
- exp, (x => true), (x => true), (x => true));
- query = this.GetQueryByDataRangeByDepartment(query);
- var resultQuery = query.OrderByDescending(x => x.SchoolyearCode)
- .ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo)
- .ThenBy(x => x.CourseName).ThenBy(x => x.UserName);
- var result = resultQuery.ToList();
- var teacherList = teacherQuery
- .OrderBy(x => x.TeachingMethod).ThenBy(x => x.Name).ToList();
- var toTeacherList = toTeacherQuery
- .OrderBy(x => x.TeachingMethod).ThenBy(x => x.Name).ToList();
- result.ForEach(x =>
- {
- x.TeacherNames = string.Join(",", teacherList
- .Where(w => w.EducationSchedulingAdjustmentID == x.EducationSchedulingAdjustmentID)
- .Select(w => w.Name));
- x.ToTeacherNames = string.Join(",", toTeacherList
- .Where(w => w.EducationSchedulingAdjustmentID == x.EducationSchedulingAdjustmentID)
- .Select(w => w.Name));
- x.RecordStatusName = statusList.FirstOrDefault(w => w.ID == x.RecordStatus).Name;
- });
- return result;
- }
- public void BatchSave(IList<Guid?> educationSchedulingWeekNumIDList, Guid fromUserID, int? toWeekNum, int? toWeekday, Guid? toUserID,
- Guid? toCoursesTimeID, int? toClassroomType, Guid? toClassroom)
- {
- var startStatusID = this.GetStartStatus();
- var endStatusID = this.GetCorrectEndStatus();
- var backpointStatusList = this.GetBackpointStatus();
- var submitedStatusList = this.GetStatusViewList().Where(x => x.ID != startStatusID && x.ID != endStatusID
- && !backpointStatusList.Contains(x.ID)).Select(x => x.ID).ToList();
- var currentSchoolyear = this.SchoolYearServices.Value.GetCurrentSchoolYear();
- var toCourseTime = this.CoursesTimeServices.Value.GetCoursesTime(toCoursesTimeID);
- var weekNumList = this.EducationSchedulingDAL.EducationSchedulingWeekNumRepository.GetList(x =>
- educationSchedulingWeekNumIDList.Contains(x.EducationSchedulingWeekNumID),
- (x => x.ES_EducationScheduling.EM_CoursesTime)).ToList();
- var stopApprovedStatus = this.EducationSchedulingStopServices.Value.GetCorrectEndStatus().Value;
- var stopList = this.EducationSchedulingStopDAL.GetEducationSchedulingWeekNumStopView(x =>
- educationSchedulingWeekNumIDList.Contains(x.EducationSchedulingWeekNumID), stopApprovedStatus).ToList();
- if (weekNumList.Any(x => SchoolYearServices.Value.IsTimePassed(
- currentSchoolyear, x.WeekNum, x.ES_EducationScheduling.Weekday,
- x.ES_EducationScheduling.EM_CoursesTime.StartHour, x.ES_EducationScheduling.EM_CoursesTime.StartMinutes)
- && !stopList.Any(w => w.IsStop && w.EducationSchedulingWeekNumID == x.EducationSchedulingWeekNumID))
- || (
- toCourseTime != null && toWeekNum != null && toWeekday != null &&
- SchoolYearServices.Value.IsTimePassed(
- currentSchoolyear, toWeekNum, toWeekday, toCourseTime.StartHour, toCourseTime.StartMinutes)
- ))
- {
- throw new Exception("调整前后的时间均不能早于当前时间,请核对。");
- }
- var adjustmentQuery = this.EducationSchedulingDAL.GetConflictAdjustmentSchedule(x => educationSchedulingWeekNumIDList.Contains(x.EducationSchedulingWeekNumID),
- submitedStatusList, fromUserID, toWeekNum, toWeekday, toUserID, toCoursesTimeID, toClassroom);
- var adjustmentConflictList = this.EducationSchedulingDAL.GetSelfClassroomConflictQueryable(adjustmentQuery).ToList()
- .Concat(this.EducationSchedulingDAL.GetSelfTeacherConflictQueryable(adjustmentQuery).ToList())
- .Concat(this.EducationSchedulingDAL.GetSelfStudentConflictQueryable(adjustmentQuery).ToList()
- .GroupBy(w => new { w.EducationSchedulingWeekNumID, w.EducationSchedulingAdjustmentID })
- .Select(w => w.FirstOrDefault()).ToList())
- .Concat(this.EducationSchedulingDAL.GetSelfConflictQueryable(adjustmentQuery).ToList())
- .Concat(this.EducationSchedulingDAL.GetClassroomSeatConflictQueryable(adjustmentQuery).ToList())
- .Concat(this.EducationSchedulingDAL.GetClassroomReserveQueryable(adjustmentQuery).ToList())
- .Concat(this.EducationSchedulingDAL.GetClassroomScheduleConflicQueryable(adjustmentQuery).ToList())
- .Concat(this.EducationSchedulingDAL.GetClassroomConflicQueryable(adjustmentQuery).ToList())
- .Concat(this.EducationSchedulingDAL.GetClassroomExcessiveUseQueryable(adjustmentQuery).ToList())
- .Concat(this.EducationSchedulingDAL.GetClassroomAdjustmentConflictQueryable(adjustmentQuery, submitedStatusList).ToList())
- .Concat(this.EducationSchedulingDAL.GetCourseScheduleConflictQueryable(adjustmentQuery).ToList())
- .Concat(this.EducationSchedulingDAL.GetTeacherScheduleConflictQueryable(adjustmentQuery).ToList())
- .Concat(this.EducationSchedulingDAL.GetTeacherConflictQueryable(adjustmentQuery).ToList())
- .Concat(this.EducationSchedulingDAL.GetTeacherAdjustmentConflictQueryable(adjustmentQuery, submitedStatusList).ToList())
- .Concat(this.EducationSchedulingDAL.GetStudentScheduleConflictQueryable(adjustmentQuery).ToList())
- .Concat(this.EducationSchedulingDAL.GetStudentConflictQueryable(adjustmentQuery).ToList())
- .Concat(this.EducationSchedulingDAL.GetStudentAdjustmentConflictQueryable(adjustmentQuery, submitedStatusList).ToList())
- .Concat(this.EducationSchedulingDAL.GetArrangementsQueryable(adjustmentQuery).ToList()).ToList();
- //var adjustmentConflictList = this.EducationSchedulingDAL.GetConflictAdjustmentSchedule(x => educationSchedulingWeekNumIDList.Contains(x.EducationSchedulingWeekNumID),
- // submitedStatusList, fromUserID, toWeekNum, toWeekday, toUserID, toCoursesTimeID, toClassroom).ToList();
- var educationSchedulingWeekNumList = this.EducationSchedulingDAL.EducationSchedulingWeekNumRepository
- .GetList(x => educationSchedulingWeekNumIDList.Contains(x.EducationSchedulingWeekNumID),
- (x => x.ES_EducationScheduling.EM_CoursesTime),
- (x => x.ES_EducationScheduling.EM_EducationSchedulingClass.EM_EducationMissionClass),
- (x => x.ES_EducationScheduling.ES_EducationSchedulingTeacher)).ToList();
- var dateList = SchoolYearServices.Value.GetDateByCoursesTime(currentSchoolyear.SchoolYearID ?? Guid.Empty,
- educationSchedulingWeekNumList.GroupBy(x => new FullCoursesTimeView
- {
- WeekNum = toWeekNum.HasValue ? toWeekNum : x.WeekNum,
- Weekday = toWeekday.HasValue ? toWeekday : x.ES_EducationScheduling.Weekday
- }).Select(x => x.Key).ToList());
-
- var examinationPlanList = ExaminationPlanDAL.GetExaminationPlanView(x => dateList.Contains(x.ExaminationDate ?? DateTime.MinValue) && x.SchoolyearID == currentSchoolyear.SchoolYearID
- && x.RecordStatus == (int)EX_ExaminationPlanStatus.Submitted).ToList();
- var examinationPlanIDList = examinationPlanList.Select(x => x.ExaminationPlanID).ToList();
- var examinationRoomLayoutViewList = ExaminationPlanDAL.GetExaminationRoomLayoutView(x => examinationPlanIDList.Contains((Guid)x.ExaminationPlanID)).ToList();
- examinationPlanList.ForEach(x => x.ExaminationRoomLayoutView = new HashSet<ExaminationRoomLayoutView>(examinationRoomLayoutViewList.Where(y => y.ExaminationPlanID == x.ExaminationPlanID)));
- var firstWeek = currentSchoolyear.FirstWeek.Value.AddDays(1 - (int)currentSchoolyear.FirstWeek.Value.DayOfWeek);
- //学年学期还有问题,应该按照提交的记录找出他们的学年学期
- adjustmentConflictList = adjustmentConflictList.Concat(
- educationSchedulingWeekNumList.Where(x => examinationPlanList.Any(w => SchoolYearServices.Value.GetStartEndTimeByCourseTime(firstWeek, new FullCoursesTimeView
- {
- WeekNum = toWeekNum.HasValue ? toWeekNum : x.WeekNum,
- Weekday = toWeekday.HasValue ? toWeekday : x.ES_EducationScheduling.Weekday,
- CoursesTimeID = toCoursesTimeID.HasValue ? toCoursesTimeID : x.ES_EducationScheduling.CoursesTimeID,
- StartHour = toCoursesTimeID.HasValue ? toCourseTime.StartHour : x.ES_EducationScheduling.EM_CoursesTime.StartHour,
- StartMinute = toCoursesTimeID.HasValue ? toCourseTime.StartMinutes : x.ES_EducationScheduling.EM_CoursesTime.StartMinutes,
- EndHour = toCoursesTimeID.HasValue ? toCourseTime.EndHour : x.ES_EducationScheduling.EM_CoursesTime.EndHour,
- EndMinute = toCoursesTimeID.HasValue ? toCourseTime.EndMinutes : x.ES_EducationScheduling.EM_CoursesTime.EndMinutes
- }).IsOverlap(w.ExaminationDate.Value.Add(w.StartTime.Value), w.ExaminationDate.Value.Add(w.EndTime.Value))
- && w.ExaminationRoomLayoutView.Select(v => (Guid?)v.ClassroomID)
- .Contains((toClassroom.HasValue ? toClassroom : x.ES_EducationScheduling.ClassroomID)))
- ).Select(x => new EducationSchedulingConflictView
- {
- EducationSchedulingWeekNumID = x.EducationSchedulingWeekNumID,
- EducationSchedulingAdjustmentID = null,
- EducationMissionClassName = x.ES_EducationScheduling.EM_EducationSchedulingClass.EM_EducationMissionClass.Name,
- WeekNum = x.WeekNum,
- Weekday = x.ES_EducationScheduling.Weekday,
- StartTimes = x.ES_EducationScheduling.EM_CoursesTime.StartTimes,
- EndTimes = x.ES_EducationScheduling.EM_CoursesTime.EndTimes,
- ClassroomID = x.ES_EducationScheduling.ClassroomID,
- Reason = "教室在该节次安排了考试。"
- }).ToList()).Concat(
- educationSchedulingWeekNumList.Where(x => examinationPlanList.Any(w => SchoolYearServices.Value.GetStartEndTimeByCourseTime(firstWeek, new FullCoursesTimeView
- {
- WeekNum = toWeekNum.HasValue ? toWeekNum : x.WeekNum,
- Weekday = toWeekday.HasValue ? toWeekday : x.ES_EducationScheduling.Weekday,
- CoursesTimeID = toCoursesTimeID.HasValue ? toCoursesTimeID : x.ES_EducationScheduling.CoursesTimeID,
- StartHour = toCoursesTimeID.HasValue ? toCourseTime.StartHour : x.ES_EducationScheduling.EM_CoursesTime.StartHour,
- StartMinute = toCoursesTimeID.HasValue ? toCourseTime.StartMinutes : x.ES_EducationScheduling.EM_CoursesTime.StartMinutes,
- EndHour = toCoursesTimeID.HasValue ? toCourseTime.EndHour : x.ES_EducationScheduling.EM_CoursesTime.EndHour,
- EndMinute = toCoursesTimeID.HasValue ? toCourseTime.EndMinutes : x.ES_EducationScheduling.EM_CoursesTime.EndMinutes
- }).IsOverlap(w.ExaminationDate.Value.Add(w.StartTime.Value), w.ExaminationDate.Value.Add(w.EndTime.Value))
- && w.ExaminationRoomLayoutView
- .SelectMany(v => v.Sys_User).Select(v => (Guid?)v.UserID)
- .Intersect(
- x.ES_EducationScheduling.ES_EducationSchedulingTeacher
- .Select(v => (toUserID.HasValue ? (v.UserID == fromUserID ? toUserID : (Guid?)v.UserID) : (Guid?)v.UserID))
- ).Count() > 0)
- ).Select(x => new EducationSchedulingConflictView
- {
- EducationSchedulingWeekNumID = x.EducationSchedulingWeekNumID,
- EducationSchedulingAdjustmentID = null,
- EducationMissionClassName = x.ES_EducationScheduling.EM_EducationSchedulingClass.EM_EducationMissionClass.Name,
- WeekNum = x.WeekNum,
- Weekday = x.ES_EducationScheduling.Weekday,
- StartTimes = x.ES_EducationScheduling.EM_CoursesTime.StartTimes,
- EndTimes = x.ES_EducationScheduling.EM_CoursesTime.EndTimes,
- ClassroomID = x.ES_EducationScheduling.ClassroomID,
- Reason = "教师在该节次安排了考试。"
- }).ToList()).Concat(
- educationSchedulingWeekNumList.Where(x => examinationPlanList.Any(w => SchoolYearServices.Value.GetStartEndTimeByCourseTime(firstWeek, new FullCoursesTimeView
- {
- WeekNum = toWeekNum.HasValue ? toWeekNum : x.WeekNum,
- Weekday = toWeekday.HasValue ? toWeekday : x.ES_EducationScheduling.Weekday,
- CoursesTimeID = toCoursesTimeID.HasValue ? toCoursesTimeID : x.ES_EducationScheduling.CoursesTimeID,
- StartHour = toCoursesTimeID.HasValue ? toCourseTime.StartHour : x.ES_EducationScheduling.EM_CoursesTime.StartHour,
- StartMinute = toCoursesTimeID.HasValue ? toCourseTime.StartMinutes : x.ES_EducationScheduling.EM_CoursesTime.StartMinutes,
- EndHour = toCoursesTimeID.HasValue ? toCourseTime.EndHour : x.ES_EducationScheduling.EM_CoursesTime.EndHour,
- EndMinute = toCoursesTimeID.HasValue ? toCourseTime.EndMinutes : x.ES_EducationScheduling.EM_CoursesTime.EndMinutes
- }).IsOverlap(w.ExaminationDate.Value.Add(w.StartTime.Value), w.ExaminationDate.Value.Add(w.EndTime.Value))
- && w.ExaminationRoomLayoutView
- .SelectMany(v => v.EX_ExaminationRoomStudent).Select(v => v.UserID)
- .Intersect(x.ES_EducationScheduling.EM_EducationSchedulingClass.CF_Student.Select(v => (Guid?)v.UserID)).Count() > 0)
- ).Select(x => new EducationSchedulingConflictView
- {
- EducationSchedulingWeekNumID = x.EducationSchedulingWeekNumID,
- EducationSchedulingAdjustmentID = null,
- EducationMissionClassName = x.ES_EducationScheduling.EM_EducationSchedulingClass.EM_EducationMissionClass.Name,
- WeekNum = x.WeekNum,
- Weekday = x.ES_EducationScheduling.Weekday,
- StartTimes = x.ES_EducationScheduling.EM_CoursesTime.StartTimes,
- EndTimes = x.ES_EducationScheduling.EM_CoursesTime.EndTimes,
- ClassroomID = x.ES_EducationScheduling.ClassroomID,
- Reason = "学生在该节次安排了考试。"
- }).ToList()).ToList();
- if (adjustmentConflictList.Count > 0)
- {
- var errorMessage = string.Join(";", adjustmentConflictList.Select(x =>
- string.Format("{0}第{1}周星期{2}的{3}-{4}节调整失败,原因:{5}",
- x.EducationMissionClassName, x.WeekNum, WeekDayView.GetWeekdayName(x.Weekday), x.StartTimes, x.EndTimes, x.Reason)
- ));
- throw new Exception(errorMessage);
- }
- if (educationSchedulingWeekNumList.Count != educationSchedulingWeekNumIDList.Count)
- {
- throw new Exception("所选部分排课记录不存在,可能已经被修改,请重新查询排课列表并选择。");
- }
- List<ES_EducationSchedulingAdjustment> insertList = new List<ES_EducationSchedulingAdjustment>();
- List<ES_EducationSchedulingAdjustmentTeacher> fromTeacherInsertList = new List<ES_EducationSchedulingAdjustmentTeacher>();
- List<ES_EducationSchedulingAdjustmentToTeacher> toTeacherInsertList = new List<ES_EducationSchedulingAdjustmentToTeacher>();
- foreach (var educationSchedulingWeekNum in educationSchedulingWeekNumList)
- {
- var scheduleAdjustment = new ES_EducationSchedulingAdjustment();
- {
- scheduleAdjustment.EducationSchedulingAdjustmentID = Guid.NewGuid();
- this.SetNewStatus(scheduleAdjustment);
- scheduleAdjustment.RecordStatus = startStatusID;
- insertList.Add(scheduleAdjustment);
- }
- scheduleAdjustment.EducationMissionClassID = educationSchedulingWeekNum
- .ES_EducationScheduling
- .EM_EducationSchedulingClass
- .EducationMissionClassID;
- scheduleAdjustment.Weekday = educationSchedulingWeekNum
- .ES_EducationScheduling
- .Weekday;
- scheduleAdjustment.CoursesTimeID = educationSchedulingWeekNum
- .ES_EducationScheduling
- .CoursesTimeID;
- scheduleAdjustment.ClassroomTypeID = educationSchedulingWeekNum
- .ES_EducationScheduling
- .EM_EducationSchedulingClass
- .EM_EducationMissionClass
- .ClassroomTypeID;
- scheduleAdjustment.ClassroomID = educationSchedulingWeekNum
- .ES_EducationScheduling
- .ClassroomID;
- scheduleAdjustment.UserID = fromUserID;
- scheduleAdjustment.ToWeekday = toWeekday.HasValue ? toWeekday : educationSchedulingWeekNum
- .ES_EducationScheduling
- .Weekday;
- scheduleAdjustment.ToCoursesTimeID = toCoursesTimeID.HasValue ? toCoursesTimeID : educationSchedulingWeekNum
- .ES_EducationScheduling
- .CoursesTimeID;
- scheduleAdjustment.ToClassroomTypeID = toClassroomType.HasValue ? toClassroomType : educationSchedulingWeekNum
- .ES_EducationScheduling
- .EM_EducationSchedulingClass
- .EM_EducationMissionClass
- .ClassroomTypeID;
- scheduleAdjustment.ToClassroomID = toClassroom.HasValue ? toClassroom : educationSchedulingWeekNum
- .ES_EducationScheduling
- .ClassroomID;
- scheduleAdjustment.ToUserID = toUserID.HasValue ? toUserID : fromUserID;
- scheduleAdjustment.WeekNum = educationSchedulingWeekNum.WeekNum;
- scheduleAdjustment.ToWeekNum = toWeekNum.HasValue ? toWeekNum : educationSchedulingWeekNum.WeekNum;
- foreach (var teacher in educationSchedulingWeekNum.ES_EducationScheduling.ES_EducationSchedulingTeacher)
- {
- var fromTeacher = new ES_EducationSchedulingAdjustmentTeacher();
- fromTeacher.EducationSchedulingAdjustmentTeacherID = Guid.NewGuid();
- fromTeacher.EducationSchedulingAdjustmentID = scheduleAdjustment.EducationSchedulingAdjustmentID;
- fromTeacher.UserID = teacher.UserID;
- fromTeacher.TeachingMethod = teacher.TeachingMethod;
- this.SetNewStatus(fromTeacher);
- fromTeacherInsertList.Add(fromTeacher);
- }
- foreach (var teacher in educationSchedulingWeekNum.ES_EducationScheduling.ES_EducationSchedulingTeacher)
- {
- var toTeacher = new ES_EducationSchedulingAdjustmentToTeacher();
- toTeacher.EducationSchedulingAdjustmentToTeacherID = Guid.NewGuid();
- toTeacher.EducationSchedulingAdjustmentID = scheduleAdjustment.EducationSchedulingAdjustmentID;
- toTeacher.UserID = (teacher.UserID == scheduleAdjustment.UserID && scheduleAdjustment.ToUserID.HasValue) ? scheduleAdjustment.ToUserID : teacher.UserID;
- toTeacher.TeachingMethod = teacher.TeachingMethod;
- this.SetNewStatus(toTeacher);
- toTeacherInsertList.Add(toTeacher);
- }
- }
-
- using (var scope = new TransactionScope())
- {
- UnitOfWork.BulkInsert(insertList);
- UnitOfWork.BulkInsert(fromTeacherInsertList);
- UnitOfWork.BulkInsert(toTeacherInsertList);
- scope.Complete();
- }
- }
- }
- }
|