using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Linq.Expressions; using EMIS.Entities; using EMIS.Utility; using Bowin.Common.Linq; using Bowin.Common.Linq.Entity; using EMIS.ViewModel; using EMIS.ViewModel.EducationManagement; using EMIS.ViewModel.EducationManage; using EMIS.ViewModel.CacheManage; using EMIS.ViewModel.UniversityManage.ClassroomManage; using EMIS.ViewModel.UniversityManage.TeacherManage; using EMIS.DataLogic.Common.Students; using EMIS.DataLogic.UniversityManage.TeacherManage; using EMIS.DataLogic.RetakeManage; using EMIS.DataLogic.SchedulingManage.SchedulingSettings; using EMIS.DataLogic.SelectCourse; using EMIS.DataLogic.EducationManage; using EMIS.DataLogic.Common.CalendarManage; using EMIS.DataLogic.EducationSchedule; using EMIS.CommonLogic.Students; using EMIS.ViewModel.UniversityManage.SpecialtyClassManage; namespace EMIS.CommonLogic.EducationManagement { public partial class EducationMissionClassServices : BaseServices, IEducationMissionClassServices { public ExecutableMinorPlanDAL ExecutableMinorPlanDAL { get; set; } public RetakePlanDAL RetakePlanDAL { get; set; } public EducationMissionClassDAL educationMissionClassDAL { get; set; } public ClassroomScheduleDAL ClassroomScheduleDAL { get; set; } public SchoolYearDAL schoolYearDAL { get; set; } public IStudentsServices studentServices { get; set; } public Lazy StudentsDAL { get; set; } public Lazy staffDAL { get; set; } public CourseTimeHoursDAL CourseTimeHoursDAL { get; set; } public CoursesTimeDAL coursesTimeDAL { get; set; } public OptionalCourseSettingDAL OptionalCourseSettingDAL { get; set; } public ExecutableFreeSelectionCouseDAL ExecutableFreeSelectionCouseDAL { get; set; } public EducationMissionOpenControlDAL EducationMissionOpenControlDAL { get; set; } /// /// 根据任务班ID查询对应班级 /// /// /// public ClassmajorView GetClassmajorByEducationClassID(Guid? eductionMissionClassID) { Expression> exp = x => true; if (eductionMissionClassID.HasValue) { exp = exp.And(x => x.EducationMissionClassID == eductionMissionClassID); } return educationMissionClassDAL.GetClassmajorByEducationMissionClassID(exp); } //添加学生 public void AddStudentbyEducationMissionClassID(Guid? educationMissionClassID, List userIDs) { try { List stuList = new List(); var queryUserIDList = userIDs.Select(x => (Guid?)x).ToList(); //EM_EducationSchedulingClass educationSchedulingClass = ClassroomScheduleDAL.EducationSchedulingRepository.GetList(x => x.EM_EducationSchedulingClass.EducationMissionClassID == educationMissionClassID); EducationMissionClassView educationMissionClassView = GetEducationMissionClassView(educationMissionClassID); List studentList = GetEducationMissionClassSchedulingStudentViewList(educationMissionClassID); var studentcount = studentList.Where(x => queryUserIDList.Contains(x.UserID)).Count(); if (studentcount > 0) { throw new Exception("抱歉,您添加的学生的数据中已存在学生,请检查!"); } List educationSchedulingClassList = GetEducationSchedulingClassList(educationMissionClassID); EM_EducationSchedulingClass educationSchedulingClass = educationSchedulingClassList.FirstOrDefault(); foreach (var userID in userIDs) { Expression> expression = x => x.UserID == userID; educationSchedulingClass.CF_Student.Add(StudentsDAL.Value.StudentRepository.GetSingle(expression)); } UnitOfWork.Commit(); } catch (Exception) { throw; } } /// /// 查询教师列表 /// /// 查询条件实体 /// 校区ID /// 学院ID /// 教研室ID /// 是否显示照片 /// 页码 /// 显示码 /// public IGridResultSet GetStaffViewGrid(ViewModel.ConfiguretView configuretView, Guid? campusID, Guid? collegeID, Guid? departmentID, int? isPhoto, Guid? userID, int pageIndex, int pageSize) { var query = staffDAL.Value.GetStaffViewQueryable(x => true); if (campusID.HasValue) query = query.Where(x => x.CampusID == campusID); if (collegeID.HasValue) query = query.Where(x => x.CollegeID == collegeID); if (userID.HasValue) query = query.Where(x => x.UserID == userID); if (departmentID.HasValue) query = query.Where(x => x.DepartmentID == departmentID); if (isPhoto > 0) query = query.Where(x => x.PhotoUrl != null && x.PhotoUrl != ""); if (!string.IsNullOrEmpty(configuretView.ConditionValue)) query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue); return query .OrderBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo).ThenBy(x => x.StaffCode.Length).ThenBy(x => x.StaffCode) .ToGridResultSet(pageIndex, pageSize); } public void DeleteStudentbyEducationMissionClassID(Guid? educationMissionClassID, List userIDs) { try { List stuList = new List(); var queryUserIDList = userIDs.Select(x => (Guid?)x).ToList(); //EM_EducationSchedulingClass educationSchedulingClass = ClassroomScheduleDAL.EducationSchedulingRepository.GetList(x => x.EM_EducationSchedulingClass.EducationMissionClassID == educationMissionClassID); //EducationMissionClassView educationMissionClassView = GetEducationMissionClassView(educationMissionClassID); //List studentList = GetEducationMissionClassSchedulingStudentViewList(educationMissionClassID); //var studentcount = studentList.Where(x => queryUserIDList.Contains(x.UserID)).Count(); //if (studentcount > 0) //{ // throw new Exception("抱歉,您添加的学生的数据中已存在学生,请检查!"); //} List educationSchedulingClassList = GetEducationSchedulingClassList(educationMissionClassID); EM_EducationSchedulingClass educationSchedulingClass = educationSchedulingClassList.FirstOrDefault(); foreach (var userID in userIDs) { Expression> expression = x => x.UserID == userID; educationSchedulingClass.CF_Student.Remove(StudentsDAL.Value.StudentRepository.GetSingle(expression)); } UnitOfWork.Commit(); } catch (Exception) { throw; } } /// /// 查询教学任务班 /// /// 查询条件 /// 学年学期ID /// 课程代码 /// 课程名称 /// 排课班级 /// 页数 /// 显示数 /// public Bowin.Common.Linq.Entity.IGridResultSet GetEducationMissionClassViewGrid(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, Guid? schoolyearID, Guid? departmentID, Guid? coursematerialID, int? approvalStatus, int? teachingModeID, Guid? classmajorID, int? gradeYearID, int pageIndex, int pageSize) { bool hasClassmajorFilter = false; Expression> exp = (x => true); Expression> classmajorFilter = x => true; if (campusID.HasValue) { exp = exp.And(x => x.EM_EducationMission.CF_College.CampusID == campusID); } if (collegeID.HasValue) { exp = exp.And(x => x.EM_EducationMission.CF_Department.CollegeID == collegeID); } if (departmentID.HasValue) { exp = exp.And(x => x.EM_EducationMission.DepartmentID == departmentID); } if (gradeYearID.HasValue) { hasClassmajorFilter = true; classmajorFilter = classmajorFilter.And(x => x.CF_Grademajor.GradeID == gradeYearID); } if (classmajorID.HasValue) { hasClassmajorFilter = true; classmajorFilter = classmajorFilter.And(x => x.ClassmajorID == classmajorID); } if (hasClassmajorFilter) { exp = exp.And(w => w.CF_Classmajor.AsQueryable().Any(classmajorFilter)); } if (schoolyearID.HasValue) { exp = exp.And(x => x.EM_EducationMission.SchoolyearID == schoolyearID); } if (coursematerialID.HasValue) { exp = exp.And(x => x.CoursematerialID == coursematerialID); } if (approvalStatus.HasValue) { exp = exp.And(x => x.RecordStatus == approvalStatus); } if (teachingModeID.HasValue) { exp = exp.And(x => x.TeachingModeID == teachingModeID); } var query = educationMissionClassDAL.GetEducationMissionClassViewQueryble(exp); if (!string.IsNullOrEmpty(configuretView.ConditionValue)) query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue); var result = this.GetQueryByDataRangeByCollege(query).OrderByDescending(x => x.SchoolyearCode) .ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo).ThenByDescending(x => x.GradeYearID) .ThenBy(x => x.StandardID).ThenBy(x => x.CourseName).ThenBy(x => x.OrderNo).ThenBy(x => x.Name) .ToGridResultSet(pageIndex, pageSize); var educationMissionClassID = result.rows.Select(x => x.EducationMissionClassID).ToList(); var missionClassTeacherList = educationMissionClassDAL.GetMissionClassTeacherQuery(x => educationMissionClassID.Contains(x.EducationMissionClassID)).ToList(); result.rows.ForEach(x => x.MissionClassTeacherView = new HashSet(missionClassTeacherList.Where(y => y.EducationMissionClassID == x.EducationMissionClassID))); //result.rows.ForEach(x => x.CourseTimeID = new HashSet(missionClassTeacherList.Where(y => y.EducationMissionClassID == x.EducationMissionClassID))); return result; } /// /// 查询教学任务班 /// /// 查询条件 /// 学年学期ID /// 课程代码 /// 课程名称 /// 排课班级 /// public List GetEducationMissionClassViewList(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, Guid? schoolyearID, Guid? departmentID, Guid? coursematerialID, int? approvalStatus, int? teachingModeID, Guid? classmajorID, int? gradeYearID) { bool hasClassmajorFilter = false; Expression> exp = (x => true); Expression> classmajorFilter = x => true; if (campusID.HasValue) { exp = exp.And(x => x.EM_EducationMission.CF_College.CampusID == campusID); } if (collegeID.HasValue) { exp = exp.And(x => x.EM_EducationMission.CF_Department.CollegeID == collegeID); } if (departmentID.HasValue) { exp = exp.And(x => x.EM_EducationMission.DepartmentID == departmentID); } if (gradeYearID.HasValue) { hasClassmajorFilter = true; classmajorFilter = classmajorFilter.And(x => x.CF_Grademajor.GradeID == gradeYearID); } if (classmajorID.HasValue) { hasClassmajorFilter = true; classmajorFilter = classmajorFilter.And(x => x.ClassmajorID == classmajorID); } if (hasClassmajorFilter) { exp = exp.And(w => w.CF_Classmajor.AsQueryable().Any(classmajorFilter)); } if (schoolyearID.HasValue) { exp = exp.And(x => x.EM_EducationMission.SchoolyearID == schoolyearID); } if (coursematerialID.HasValue) { exp = exp.And(x => x.CoursematerialID == coursematerialID); } if (approvalStatus.HasValue) { exp = exp.And(x => x.RecordStatus == approvalStatus); } if (teachingModeID.HasValue) { exp = exp.And(x => x.TeachingModeID == teachingModeID); } var query = educationMissionClassDAL.GetEducationMissionClassViewQueryble(exp); var educationMissionClassID = query.Select(x => x.EducationMissionClassID).ToList(); var missionClassTeacherList = educationMissionClassDAL.GetMissionClassTeacherQuery(x => educationMissionClassID.Contains(x.EducationMissionClassID)).ToList(); if (!string.IsNullOrEmpty(configuretView.ConditionValue)) query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue); var result = this.GetQueryByDataRangeByCollege(query).OrderByDescending(x => x.SchoolyearCode) .ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo).ThenByDescending(x => x.GradeYearID) .ThenBy(x => x.StandardID).ThenBy(x => x.CourseName).ThenBy(x => x.OrderNo).ThenBy(x => x.Name) .ToList(); result.ForEach(x => x.MissionClassTeacherView = new HashSet(missionClassTeacherList.Where(y => y.EducationMissionClassID == x.EducationMissionClassID))); return result; } /// /// 查询教学任务班 /// /// 查询条件 /// 学年学期ID /// 课程代码 /// 课程名称 /// 排课班级 /// 页数 /// 显示数 /// public Bowin.Common.Linq.Entity.IGridResultSet GetEducationMissionClassViewGrid(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, Guid? schoolyearID, int? standardID, Guid? coursematerialID, int? approvalStatus, int? teachingModeID, Guid? classmajorID, int? gradeYearID, Guid? CoursesTimeID, int pageIndex, int pageSize) { bool hasClassmajorFilter = false; Expression> exp = (x => true); Expression> classmajorExp = (x => true); if (campusID.HasValue) { exp = exp.And(x => x.EM_EducationMission.CF_College.CampusID == campusID); } if (collegeID.HasValue) { exp = exp.And(x => x.EM_EducationMission.CF_Department.CollegeID == collegeID); } if (CoursesTimeID.HasValue) { exp = exp.And(x => x.EM_CoursesTime.Any(c => c.CoursesTimeID == CoursesTimeID)); } if (standardID.HasValue) { hasClassmajorFilter = true; classmajorExp = classmajorExp.And(x => x.CF_Grademajor.CF_Facultymajor.StandardID == standardID); } if (gradeYearID.HasValue) { hasClassmajorFilter = true; classmajorExp = classmajorExp.And(x => x.CF_Grademajor.GradeID == gradeYearID); } if (classmajorID.HasValue) { hasClassmajorFilter = true; classmajorExp = classmajorExp.And(x => x.ClassmajorID == classmajorID); } if (hasClassmajorFilter) { exp = exp.And(w => w.CF_Classmajor.AsQueryable().Any(classmajorExp)); } if (schoolyearID.HasValue) { exp = exp.And(x => x.EM_EducationMission.SchoolyearID == schoolyearID); } if (coursematerialID.HasValue) { exp = exp.And(x => x.CoursematerialID == coursematerialID); } if (approvalStatus.HasValue) { exp = exp.And(x => x.RecordStatus == approvalStatus); } if (teachingModeID.HasValue) { exp = exp.And(x => x.TeachingModeID == teachingModeID); } var query = educationMissionClassDAL.GetEducationMissionClassViewQueryble(exp); if (configuretView.Attribute == "TeacherName" && !string.IsNullOrEmpty(configuretView.ConditionValue)) { var educationMissionClassID = query.Select(x => x.EducationMissionClassID).ToList(); //获取查询结果教学任务所有教师 var missionClassTeacherList = educationMissionClassDAL.GetMissionClassTeacherQuery(x => educationMissionClassID.Contains(x.EducationMissionClassID)).ToList(); //按教师姓名条件查询对应教学任务 missionClassTeacherList = missionClassTeacherList.Where(x => x.Name == configuretView.ConditionValue).ToList(); var missionClassIDList = missionClassTeacherList.Select(x => x.EducationMissionClassID).ToList(); //由于教学任务可能有多个教师授课,所以还要再拿筛选后的教学任务在匹配一次教师 missionClassTeacherList = educationMissionClassDAL.GetMissionClassTeacherQuery(x => missionClassIDList.Contains(x.EducationMissionClassID)).ToList(); query = query.Where(x => missionClassIDList.Contains(x.EducationMissionClassID)); var resultQuery = this.GetQueryByDataRangeByDepartment(query).OrderByDescending(x => x.SchoolyearCode) .ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo).ThenByDescending(x => x.GradeYearID) .ThenBy(x => x.StandardID).ThenBy(x => x.CourseName).ThenBy(x => x.OrderNo).ThenBy(x => x.Name); var result = resultQuery.ToGridResultSet(pageIndex, pageSize); result.rows.ForEach(x => x.MissionClassTeacherView = new HashSet(missionClassTeacherList.Where(y => y.EducationMissionClassID == x.EducationMissionClassID))); return result; } else { if (!string.IsNullOrEmpty(configuretView.ConditionValue) && configuretView.Attribute != "TeacherName") query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue); var resultQuery = this.GetQueryByDataRangeByDepartment(query).OrderByDescending(x => x.SchoolyearCode) .ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo).ThenByDescending(x => x.GradeYearID) .ThenBy(x => x.StandardID).ThenBy(x => x.CourseName).ThenBy(x => x.OrderNo).ThenBy(x => x.Name); var result = resultQuery.ToGridResultSet(pageIndex, pageSize); var educationMissionClassID = result.rows.Select(x => x.EducationMissionClassID).ToList(); var missionClassTeacherList = educationMissionClassDAL.GetMissionClassTeacherQuery(x => educationMissionClassID.Contains(x.EducationMissionClassID)).ToList(); result.rows.ForEach(x => x.MissionClassTeacherView = new HashSet(missionClassTeacherList.Where(y => y.EducationMissionClassID == x.EducationMissionClassID))); return result; } } public List GetEducationMissionClassViewList(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, Guid? schoolyearID, int? standardID, Guid? coursematerialID, int? approvalStatus, int? teachingModeID, Guid? classmajorID, int? gradeYearID, int? learningformID, int? education, string LearnSystem, List EducationMissionClassIDList) { bool hasClassmajorFilter = false; Expression> exp = (x => true); Expression> classmajorExp = (x => true); if (EducationMissionClassIDList!=null) { exp = exp.And(x => EducationMissionClassIDList.Contains(x.EducationMissionClassID)); } if (campusID.HasValue) { exp = exp.And(x => x.EM_EducationMission.CF_College.CampusID == campusID); } if (collegeID.HasValue) { exp = exp.And(x => x.EM_EducationMission.CF_Department.CollegeID == collegeID); } if (standardID.HasValue) { hasClassmajorFilter = true; classmajorExp = classmajorExp.And(x => x.CF_Grademajor.CF_Facultymajor.StandardID == standardID); } if (gradeYearID.HasValue) { hasClassmajorFilter = true; classmajorExp = classmajorExp.And(x => x.CF_Grademajor.GradeID == gradeYearID); } if (classmajorID.HasValue) { hasClassmajorFilter = true; classmajorExp = classmajorExp.And(x => x.ClassmajorID == classmajorID); } if (hasClassmajorFilter) { exp = exp.And(w => w.CF_Classmajor.AsQueryable().Any(classmajorExp)); } if (schoolyearID.HasValue) { exp = exp.And(x => x.EM_EducationMission.SchoolyearID == schoolyearID); } if (coursematerialID.HasValue) { exp = exp.And(x => x.CoursematerialID == coursematerialID); } if (approvalStatus.HasValue) { exp = exp.And(x => x.RecordStatus == approvalStatus); } if (teachingModeID.HasValue) { exp = exp.And(x => x.TeachingModeID == teachingModeID); } if (learningformID.HasValue) exp = exp.And(x => x.CF_Classmajor.Any(w => w.CF_Grademajor.CF_Facultymajor.LearningformID == learningformID)); if (!string.IsNullOrEmpty(LearnSystem) && LearnSystem != "-1") { var LearnSystems = Convert.ToDecimal(LearnSystem); exp = exp.And(x => x.CF_Classmajor.Any(w => w.CF_Grademajor.CF_Facultymajor.LearnSystem == LearnSystems)); } if (education.HasValue) { exp = exp.And(x => x.CF_Classmajor.Any(w => w.CF_Grademajor.CF_Facultymajor.EducationID == education.Value)); } var query = educationMissionClassDAL.GetEducationMissionClassViewQueryble(exp); if (configuretView.Attribute == "TeacherName" && !string.IsNullOrEmpty(configuretView.ConditionValue)) { var educationMissionClassID = query.Select(x => x.EducationMissionClassID).ToList(); //获取查询结果教学任务所有教师 var missionClassTeacherList = educationMissionClassDAL.GetMissionClassTeacherQuery(x => educationMissionClassID.Contains(x.EducationMissionClassID)).ToList(); //按教师姓名条件查询对应教学任务 missionClassTeacherList = missionClassTeacherList.Where(x => x.Name == configuretView.ConditionValue).ToList(); var missionClassIDList = missionClassTeacherList.Select(x => x.EducationMissionClassID).ToList(); //由于教学任务可能有多个教师授课,所以还要再拿筛选后的教学任务在匹配一次教师 missionClassTeacherList = educationMissionClassDAL.GetMissionClassTeacherQuery(x => missionClassIDList.Contains(x.EducationMissionClassID)).ToList(); query = query.Where(x => missionClassIDList.Contains(x.EducationMissionClassID)); var resultQuery = this.GetQueryByDataRangeByDepartment(query).OrderByDescending(x => x.SchoolyearCode) .ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo).ThenByDescending(x => x.GradeYearID) .ThenBy(x => x.StandardID).ThenBy(x => x.CourseName).ThenBy(x => x.OrderNo).ThenBy(x => x.Name); var result = resultQuery.ToList(); result.ForEach(x => x.MissionClassTeacherView = new HashSet(missionClassTeacherList.Where(y => y.EducationMissionClassID == x.EducationMissionClassID))); return result; } else { if (!string.IsNullOrEmpty(configuretView.ConditionValue) && configuretView.Attribute != "TeacherName") query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue); var resultQuery = this.GetQueryByDataRangeByDepartment(query).OrderByDescending(x => x.SchoolyearCode) .ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo).ThenByDescending(x => x.GradeYearID) .ThenBy(x => x.StandardID).ThenBy(x => x.CourseName).ThenBy(x => x.OrderNo).ThenBy(x => x.Name); var result = resultQuery.ToList(); var educationMissionClassID = result.Select(x => x.EducationMissionClassID).ToList(); var missionClassTeacherList = educationMissionClassDAL.GetMissionClassTeacherQuery(x => educationMissionClassID.Contains(x.EducationMissionClassID)).ToList(); result.ForEach(x => x.MissionClassTeacherView = new HashSet(missionClassTeacherList.Where(y => y.EducationMissionClassID == x.EducationMissionClassID))); return result; } } /// /// 查询教学任务班 /// /// 查询条件 /// 学年学期ID /// 课程代码 /// 课程名称 /// 排课班级 /// public List GetEducationMissionClassViewList(IList educationMissionClassIDList) { Expression> exp = (x => educationMissionClassIDList.Contains(x.EducationMissionClassID)); var query = educationMissionClassDAL.GetEducationMissionClassViewQueryble(exp); var missionClassTeacherList = educationMissionClassDAL.GetMissionClassTeacherQuery(x => educationMissionClassIDList.Contains(x.EducationMissionClassID)).ToList(); var result = this.GetQueryByDataRangeByCollege(query).OrderByDescending(x => x.SchoolyearCode) .ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo).ThenByDescending(x => x.GradeYearID) .ThenBy(x => x.StandardID).ThenBy(x => x.CourseName).ThenBy(x => x.OrderNo).ThenBy(x => x.Name) .ToList(); var missionClassClassmajorList = educationMissionClassDAL.GetClassmajorQuery(x => educationMissionClassIDList.Contains(x.EducationMissionClassID)).ToList(); result.ForEach(x => x.ClassmajorViewList = new HashSet (missionClassClassmajorList.Where(y => y.CoursematerialID == x.CoursematerialID && y.TeachingModeID == x.TeachingModeID && y.SchoolyearID == x.SchoolyearID))); result.ForEach(x => x.MissionClassTeacherView = new HashSet(missionClassTeacherList.Where(y => y.EducationMissionClassID == x.EducationMissionClassID))); return result; } /// /// 获取任务班信息 /// /// /// public EducationMissionClassView GetEducationMissionClassView(Guid? educationMissionClassID) { return educationMissionClassDAL.GetEducationMissionClassViewQueryble(x => x.EducationMissionClassID == educationMissionClassID).FirstOrDefault(); } /// /// 获取任务班信息 /// /// /// public Entities.EM_EducationMissionClass GetEducationMissionClass(Guid? educationMissionClassID) { return educationMissionClassDAL.EducationMissionClassRepository.GetSingle(x => x.EducationMissionClassID == educationMissionClassID, (x => x.EM_EducationMission), (x => x.CF_Classmajor), (x => x.EM_CoursesTime), (x => x.EM_MissionClassTeacher), (x => x.EM_EducationMissionClassSettings), (x => x.EM_CourseProcess), (x => x.EM_CourseProcess.Select(y => y.EM_CourseProcessTeacher)), (x => x.EM_EducationSchedulingClass), (x => x.EM_EducationMissionClassTeachingSetting), (x => x.CF_Classroom)); } /// /// 保存更新排课序号 /// /// /// public void UpdateEducationMissionClassOrderNo(List educationMissionClassIDs, List orderNos) { try { int i = 0; foreach (var educationMissionClassID in educationMissionClassIDs) { EM_EducationMissionClass educationMissionClass = GetEducationMissionClass(educationMissionClassID); educationMissionClass.OrderNo = orderNos[i]; i++; } UnitOfWork.Commit(); } catch (Exception) { throw; } } /// /// 更新教学任务班信息 /// /// public void UpdateEducationMissionClass(EducationMissionClassView educationMissionClassView) { throw new NotImplementedException(); } /// /// 获取设置周数 /// /// /// public List GetEducationMissionClassSettings(Guid? educationMissionClassID) { List listeducation = new List(); var list = educationMissionClassDAL.GetEducationMissionClassSettingsQueryble(educationMissionClassID); if (list.Count > 0) return list; var educationMissionClass = GetEducationMissionClassView(educationMissionClassID); if (educationMissionClass != null) { for (int i = (int)educationMissionClass.StartWeeklyNum; i <= (int)educationMissionClass.EndWeeklyNum; i++) { listeducation.Add(i.ToString()); } } return listeducation; } /// /// 获取教学任务授课老师 /// /// /// public List GetEducationMissionClassTeacherListViewList(Guid? educationMissionClassID) { return educationMissionClassDAL.GetEducationMissionClassTeacherListViewQueryble().Where(x => x.EducationMissionClassID == educationMissionClassID).OrderBy(x => x.TeachingMethod).ToList(); } /// /// 教学安排 /// /// 实体 /// 选中周次 /// 教师 public void EducationMissionClassUpdate(EducationMissionClassView educationMissionClassView, List weekNumList, List teacherList) { try { if (educationMissionClassView.EducationMissionClassID != null && educationMissionClassView.EducationMissionClassID != Guid.Empty) { EM_EducationMissionClass educationMissionClass = GetEducationMissionClass(educationMissionClassView.EducationMissionClassID); if (educationMissionClass.RecordStatus == (int)EM_EducationMissionClassStatus.Scheduled) { throw new Exception("当前任务班已经排课,无法进行教学安排。"); } if (educationMissionClass.RecordStatus == (int)EM_EducationMissionClassStatus.Submitted) { throw new Exception("当前任务班已经提交,无法进行教学安排。"); } if (educationMissionClassView.ClassroomID != null) { CF_Classroom classroomEntity = educationMissionClassDAL.ClassroomRepository.GetSingle(x => x.ClassroomID == educationMissionClassView.ClassroomID); EM_EducationSchedulingClass educationSchedulingEntity = educationMissionClassDAL.EducationSchedulingClassRepository.GetSingle(x => x.EducationMissionClassID == educationMissionClass.EducationMissionClassID, x => x.CF_Student); int classNum = educationSchedulingEntity.CF_Student.Count(); if (classroomEntity != null && classroomEntity.Totalseating != null && classroomEntity.Totalseating > 0 && classNum > classroomEntity.Totalseating)//教学安排班级人数不能大于选定的教室总座位数 { throw new Exception("该教室总座位数不能小于班级人数。"); } } if (educationMissionClass != null) { educationMissionClass.ClassroomID = educationMissionClassView.ClassroomID; educationMissionClass.ClassroomTypeID = educationMissionClassView.ClassroomTypeID; educationMissionClass.Name = educationMissionClassView.Name;//已提交状态可编辑教学任务名称 SetModifyStatus(educationMissionClass); //添加周次设置表 if (weekNumList.Count > 0) { //删除设置 UnitOfWork.Delete(x => x.EducationMissionClassID == educationMissionClass.EducationMissionClassID); UnitOfWork.Delete(x => x.EducationMissionClassID == educationMissionClass.EducationMissionClassID); foreach (var weekNum in weekNumList) { EM_EducationMissionClassSettings educationMissionClassSettings = new EM_EducationMissionClassSettings(); educationMissionClassSettings.EducationMissionClassSettingsID = Guid.NewGuid(); educationMissionClassSettings.EducationMissionClassID = educationMissionClass.EducationMissionClassID; educationMissionClassSettings.WeeklyNum = weekNum; SetNewStatus(educationMissionClassSettings); UnitOfWork.Add(educationMissionClassSettings); EM_CourseProcess courseProcess = new EM_CourseProcess(); courseProcess.CourseProcessID = Guid.NewGuid(); courseProcess.EducationMissionClassID = educationMissionClass.EducationMissionClassID; courseProcess.Week = weekNum; //周学时改为用户手动修改,不在根据任、限选计划自动修改。 courseProcess.Times = educationMissionClassView.WeeklyHours; courseProcess.ClassroomTypeID = educationMissionClass.ClassroomTypeID; courseProcess.ClassroomID = educationMissionClass.ClassroomID; teacherList.ForEach(x => { var courseProcessTeacher = new EM_CourseProcessTeacher { CourseProcessTeacherID = Guid.NewGuid(), CourseProcessID = courseProcess.CourseProcessID, UserID = x.UserID, TeachType = x.TeachingMethod }; SetNewStatus(courseProcessTeacher); courseProcess.EM_CourseProcessTeacher.Add(courseProcessTeacher); }); SetNewStatus(courseProcess); UnitOfWork.Add(courseProcess); } } if (teacherList.Count == 0) { //删除教师 UnitOfWork.Delete(x => x.MissionClassID == educationMissionClass.EducationMissionClassID); } //添加教师 if (teacherList.Count > 0) { //删除教师 UnitOfWork.Delete(x => x.MissionClassID == educationMissionClass.EducationMissionClassID); foreach (var teacher in teacherList) { EM_MissionClassTeacher missionClassTeacher = new EM_MissionClassTeacher(); missionClassTeacher.MissionClassTeacherID = Guid.NewGuid(); missionClassTeacher.MissionClassID = educationMissionClass.EducationMissionClassID; missionClassTeacher.UserID = teacher.UserID; missionClassTeacher.TeachType = teacher.TeachingMethod; SetNewStatus(missionClassTeacher); UnitOfWork.Add(missionClassTeacher); } } //添加教学任务时间段 if (educationMissionClassView.CourseTimeID != null) { var year = educationMissionClassDAL.GetEducationMissionClassViewQueryble(x => x.EducationMissionClassID == educationMissionClassView.EducationMissionClassID).FirstOrDefault(); var isok = CourseTimeHoursDAL.GetCoursesTimeQueryable(x => x.RecordStatus > (int?)SYS_STATUS.UNUSABLE, w => w.RecordStatus > (int?)SYS_STATUS.UNUSABLE && w.Years == year.GradeYearID).ToList(); if (isok.Count() > 0) { List coursesTime = coursesTimeDAL.coursesTimeRepository.Entities.Where(x => x.CoursesTimeID == educationMissionClassView.CourseTimeID).ToList(); educationMissionClass.EM_CoursesTime = new HashSet(); foreach (var time in coursesTime) { EM_CoursesTime c = time; educationMissionClass.EM_CoursesTime.Add(c); } } } UnitOfWork.Commit(); } } } catch (Exception) { throw; } } public void EducationMissionConjunctionClassAdd(List educationMissionClassIDs) { throw new NotImplementedException(); } /// /// 排课分班 /// /// public void DivideIntoClassesAdd(DivideIntoClassesView divideIntoClassesView) { try { if (divideIntoClassesView.EducationMissionClassID != null && divideIntoClassesView.EducationMissionClassID != Guid.Empty) { EM_EducationMissionClass educationMissionClass = GetEducationMissionClass(divideIntoClassesView.EducationMissionClassID); if (educationMissionClass.RecordStatus == (int)EM_EducationMissionClassStatus.Scheduled) { throw new Exception("当前任务班已经排课,无法分班。"); } if (educationMissionClass.RecordStatus == (int)EM_EducationMissionClassStatus.Submitted) { throw new Exception("当前任务班已经提交,无法分班。"); } if (educationMissionClass != null) { //获取学生 var listStudent = GetEducationMissionClassStudentViewList(educationMissionClass.EducationMissionClassID); int createMissionClassCount; #region 为了兼容以前的旧数据,分班时需要把原任务班的排课班数据重置成新格式 UnitOfWork.RemoveRange(educationMissionClass.EM_EducationSchedulingClass); EM_EducationSchedulingClass newMainEducationSchedulingClass = new EM_EducationSchedulingClass(); newMainEducationSchedulingClass.EducationSchedulingClassID = Guid.NewGuid(); newMainEducationSchedulingClass.EducationMissionClassID = educationMissionClass.EducationMissionClassID; newMainEducationSchedulingClass.TaskGroupName = "1组"; SetNewStatus(newMainEducationSchedulingClass); UnitOfWork.Add(newMainEducationSchedulingClass); #endregion var studentGroup = listStudent.GroupBy(x => x.ClassmajorID).ToList(); if (divideIntoClassesView.OrderType ==true) { educationMissionClass.CF_Classmajor.RemoveWhere(x => x.ClassmajorID != studentGroup[0].Key); educationMissionClass.MainScheduleClassID = studentGroup[0].Key; newMainEducationSchedulingClass.CF_Student = new HashSet(studentGroup[0].Select(x => x)); createMissionClassCount = studentGroup.Count - 1; } else { createMissionClassCount = (divideIntoClassesView.GroupNum ?? 0) - 1; if (divideIntoClassesView.OrderType == false) { listStudent = listStudent.OrderBy(x => x.Sys_User.LoginID).ToList(); } newMainEducationSchedulingClass.CF_Student = new HashSet(listStudent.Take(divideIntoClassesView.StudentNum ?? 0).ToList()); //跳过第一个班的学生 listStudent = listStudent.Skip(divideIntoClassesView.StudentNum ?? 0).ToList(); } for (int i = 0; i < createMissionClassCount; i++) { string groupNum = (i + 2).ToString(); string groupName = "(" + groupNum + ")"; EM_EducationMission newEducationMission = new EM_EducationMission(); if (divideIntoClassesView.IsNotBuildEducationMission) { newEducationMission = educationMissionClass.EM_EducationMission; } else { newEducationMission.EducationMissionID = Guid.NewGuid(); newEducationMission.CollegeID = educationMissionClass.EM_EducationMission.CollegeID; newEducationMission.DepartmentID = educationMissionClass.EM_EducationMission.DepartmentID; newEducationMission.SchoolyearID = educationMissionClass.EM_EducationMission.SchoolyearID; newEducationMission.ClassName = educationMissionClass.EM_EducationMission.ClassName + groupName; SetNewStatus(newEducationMission); UnitOfWork.Add(newEducationMission); } EM_EducationMissionClass newEducationMissionClass = new EM_EducationMissionClass(); newEducationMissionClass.EducationMissionClassID = Guid.NewGuid(); newEducationMissionClass.EducationMissionID = newEducationMission.EducationMissionID; if (divideIntoClassesView.OrderType == true) { newEducationMissionClass.MainScheduleClassID = studentGroup[i + 1].FirstOrDefault().CF_Classmajor.ClassmajorID; } else { newEducationMissionClass.MainScheduleClassID = educationMissionClass.MainScheduleClassID; } newEducationMissionClass.OrderNo = educationMissionClass.OrderNo; newEducationMissionClass.Name = educationMissionClass.Name + groupName; newEducationMissionClass.TeachingModeID = educationMissionClass.TeachingModeID; newEducationMissionClass.OptionalCourseTypeID = educationMissionClass.OptionalCourseTypeID; newEducationMissionClass.ClassroomTypeID = educationMissionClass.ClassroomTypeID; newEducationMissionClass.ClassroomID = educationMissionClass.ClassroomID; newEducationMissionClass.CoursematerialID = educationMissionClass.CoursematerialID; newEducationMissionClass.CourseStructureID = educationMissionClass.CourseStructureID; newEducationMissionClass.CourseCategoryID = educationMissionClass.CourseCategoryID; newEducationMissionClass.CourseTypeID = educationMissionClass.CourseTypeID; newEducationMissionClass.CourseQualityID = educationMissionClass.CourseQualityID; newEducationMissionClass.ExaminationModeID = educationMissionClass.ExaminationModeID; newEducationMissionClass.TeachinglanguageID = educationMissionClass.TeachinglanguageID; newEducationMissionClass.HandleModeID = educationMissionClass.HandleModeID; newEducationMissionClass.IsNeedMaterial = educationMissionClass.IsNeedMaterial; newEducationMissionClass.Remark = educationMissionClass.Remark; newEducationMissionClass.ResultTypeID = educationMissionClass.ResultTypeID; newEducationMissionClass.EM_CoursesTime = educationMissionClass.EM_CoursesTime; SetNewStatus(newEducationMissionClass); newEducationMissionClass.RecordStatus = educationMissionClass.RecordStatus; if (divideIntoClassesView.OrderType == true) { newEducationMissionClass.CF_Classmajor.Add(studentGroup[i + 1].FirstOrDefault().CF_Classmajor); } else { newEducationMissionClass.CF_Classmajor = educationMissionClass.CF_Classmajor; } UnitOfWork.Add(newEducationMissionClass); EM_EducationMissionClassTeachingSetting newEducationMissionClassTeachingSetting = new EM_EducationMissionClassTeachingSetting(); newEducationMissionClassTeachingSetting.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID; newEducationMissionClassTeachingSetting.Credit = educationMissionClass.EM_EducationMissionClassTeachingSetting.Credit; newEducationMissionClassTeachingSetting.TheoryCourse = educationMissionClass.EM_EducationMissionClassTeachingSetting.TheoryCourse; newEducationMissionClassTeachingSetting.Practicehours = educationMissionClass.EM_EducationMissionClassTeachingSetting.Practicehours; newEducationMissionClassTeachingSetting.Trialhours = educationMissionClass.EM_EducationMissionClassTeachingSetting.Trialhours; newEducationMissionClassTeachingSetting.WeeklyNum = educationMissionClass.EM_EducationMissionClassTeachingSetting.WeeklyNum; newEducationMissionClassTeachingSetting.TheoryWeeklyNum = educationMissionClass.EM_EducationMissionClassTeachingSetting.TheoryWeeklyNum; newEducationMissionClassTeachingSetting.PracticeWeeklyNum = educationMissionClass.EM_EducationMissionClassTeachingSetting.PracticeWeeklyNum; newEducationMissionClassTeachingSetting.TrialWeeklyNum = educationMissionClass.EM_EducationMissionClassTeachingSetting.TrialWeeklyNum; newEducationMissionClassTeachingSetting.StartWeeklyNum = educationMissionClass.EM_EducationMissionClassTeachingSetting.StartWeeklyNum; newEducationMissionClassTeachingSetting.EndWeeklyNum = educationMissionClass.EM_EducationMissionClassTeachingSetting.EndWeeklyNum; newEducationMissionClassTeachingSetting.WeeklyHours = educationMissionClass.EM_EducationMissionClassTeachingSetting.WeeklyHours; UnitOfWork.Add(newEducationMissionClassTeachingSetting); //生成任务班设置表 foreach (var educationMissionClassSettings in educationMissionClass.EM_EducationMissionClassSettings.ToList()) { EM_EducationMissionClassSettings newEducationMissionClassSettings = new EM_EducationMissionClassSettings(); newEducationMissionClassSettings.EducationMissionClassSettingsID = Guid.NewGuid(); newEducationMissionClassSettings.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID; newEducationMissionClassSettings.WeeklyNum = educationMissionClassSettings.WeeklyNum; SetNewStatus(newEducationMissionClassSettings); UnitOfWork.Add(newEducationMissionClassSettings); } //生成任课老师 foreach (var educationMissionClassTeacher in educationMissionClass.EM_MissionClassTeacher.ToList()) { EM_MissionClassTeacher newMissionClassTeacher = new EM_MissionClassTeacher(); newMissionClassTeacher.MissionClassTeacherID = Guid.NewGuid(); newMissionClassTeacher.MissionClassID = newEducationMissionClass.EducationMissionClassID; newMissionClassTeacher.UserID = educationMissionClassTeacher.UserID; newMissionClassTeacher.TeachType = educationMissionClassTeacher.TeachType; SetNewStatus(newMissionClassTeacher); UnitOfWork.Add(newMissionClassTeacher); } //生成课程进度 foreach (var courseProcess in educationMissionClass.EM_CourseProcess.ToList()) { EM_CourseProcess newCourseProcess = new EM_CourseProcess(); newCourseProcess.CourseProcessID = Guid.NewGuid(); newCourseProcess.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID; newCourseProcess.Week = courseProcess.Week; newCourseProcess.Times = courseProcess.Times; newCourseProcess.ClassroomTypeID = courseProcess.ClassroomTypeID; newCourseProcess.ClassroomID = courseProcess.ClassroomID; newCourseProcess.EM_CourseProcessTeacher = new HashSet(); courseProcess.EM_CourseProcessTeacher.ToList().ForEach(x => { var newCourseProcessTeacher = new EM_CourseProcessTeacher { CourseProcessTeacherID = Guid.NewGuid(), CourseProcessID = newCourseProcess.CourseProcessID, UserID = x.UserID, TeachType = x.TeachType }; this.SetNewStatus(newCourseProcessTeacher); newCourseProcess.EM_CourseProcessTeacher.Add(newCourseProcessTeacher); }); SetNewStatus(newCourseProcess); UnitOfWork.Add(newCourseProcess); } //生成排课班 EM_EducationSchedulingClass newEducationSchedulingClass = new EM_EducationSchedulingClass(); newEducationSchedulingClass.EducationSchedulingClassID = Guid.NewGuid(); newEducationSchedulingClass.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID; newEducationSchedulingClass.TaskGroupName = groupNum + "组"; SetNewStatus(newEducationSchedulingClass); if (divideIntoClassesView.OrderType == true) { newEducationSchedulingClass.CF_Student = new HashSet(studentGroup[i + 1]); } else { newEducationSchedulingClass.CF_Student = new HashSet(listStudent.Take(divideIntoClassesView.StudentNum ?? 0).ToList()); listStudent = listStudent.Skip(divideIntoClassesView.StudentNum ?? 0).ToList(); } //当运行到最后一次循环,需要把剩余的学生都加入到这个排课班中 if (i == createMissionClassCount - 1 && divideIntoClassesView.OrderType != true) { newEducationSchedulingClass.CF_Student = new HashSet(newEducationSchedulingClass.CF_Student.Concat(listStudent)); } var retakePlanStudentList = newEducationSchedulingClass.CF_Student.SelectMany(x => x.ER_RetakePlanStudent) .Where(x => x.EducationMissionID == educationMissionClass.EducationMissionID).ToList(); retakePlanStudentList.ForEach(x => x.EducationMissionID = newEducationMission.EducationMissionID); UnitOfWork.Add(newEducationSchedulingClass); } educationMissionClass.EM_EducationMission.ClassName += "(1)"; educationMissionClass.Name += "(1)"; UnitOfWork.Commit(); } } } catch (Exception ex) { throw; } } /// /// 分班信息 /// /// /// public DivideIntoClassesView GetDivideIntoClassesView(Guid? educationMissionClassID) { string ClassName = string.Empty; int StudentTotalNum = 0; //学生总数 DivideIntoClassesView divideIntoClassesView = new DivideIntoClassesView(); var listDivideIntoClassesView = educationMissionClassDAL.GetDivideIntoClassesViewQueryable().Where(x => x.EducationMissionClassID == educationMissionClassID).ToList(); foreach (var item in listDivideIntoClassesView) { ClassName = item.ClassName; StudentTotalNum += (int)item.StudentTotalNum; } divideIntoClassesView.ClassName = ClassName; divideIntoClassesView.StudentTotalNum = StudentTotalNum; return divideIntoClassesView; } /// /// 排课班表 /// /// /// public EM_EducationSchedulingClass GetEducationSchedulingClass(Guid? educationSchedulingClassID) { System.Linq.Expressions.Expression> expression = (x => x.EducationSchedulingClassID == educationSchedulingClassID); return educationMissionClassDAL.EducationSchedulingClassRepository.GetSingle(expression, (x => x.CF_Student)); } /// /// 获取排课班学生信息 /// /// 任务班ID /// 按学号顺序进行分组 /// private List GetEducationMissionClassStudentViewList(Guid? educationMissionClassID) { List listStudent = new List(); List listEducationSchedulingClass = GetEducationSchedulingClassList(educationMissionClassID); return listEducationSchedulingClass.SelectMany(x => x.CF_Student).ToList(); } /// /// 获取排课班信息 /// /// public IGridResultSet GetEducationSchedulingClassViewGrid(Guid? educationMissionClassID, int pageIndex, int pageSize) { var query = educationMissionClassDAL.GetEducationSchedulingClassViewQueryable().Where(x => x.EducationMissionClassID == educationMissionClassID); return query.OrderBy(x => x.TaskGroupName).ToGridResultSet(pageIndex, pageSize); } /// /// 获取排课班学生信息 /// /// 排课班ID /// public IGridResultSet GetEducationMissionClassStudentViewGrid(Guid? educationSchedulingClassID, int pageIndex, int pageSize) { return educationMissionClassDAL.GetEducationMissionClassStudentViewQueryable(educationSchedulingClassID).OrderBy(x => x.LoginID).ToGridResultSet(pageIndex, pageSize); } /// /// 获取排课班列表 /// /// /// private List GetEducationSchedulingClassList(Guid? educationMissionClassID) { return educationMissionClassDAL.EducationSchedulingClassRepository .GetList(x => x.EducationMissionClassID == educationMissionClassID, (x => x.CF_Student), (x => x.CF_Student.Select(w => w.Sys_User)), (x => x.CF_Student.Select(w => w.CF_Classmajor)), (x => x.CF_Student.Select(w => w.ER_RetakePlanStudent)) ).ToList(); } /// /// 获取任务班对应的所以排课班学生信息 /// /// /// /// /// public IGridResultSet GetEducationMissionClassSchedulingStudentViewGrid(Guid? educationMissionClassID, int pageIndex, int pageSize) { return educationMissionClassDAL.GetEducationMissionClassSchedulingStudentViewQueryble(educationMissionClassID).OrderBy(x => x.LoginID).ToGridResultSet(pageIndex, pageSize); } /// /// 获取任务班对应的所以排课班学生信息 /// /// /// /// /// public List GetEducationMissionClassSchedulingStudentViewList(Guid? educationMissionClassID) { return educationMissionClassDAL.GetEducationMissionClassSchedulingStudentViewQueryble(educationMissionClassID).OrderBy(x => x.LoginID).ToList(); } /// /// 合班 /// /// /// public void EducationMissionClassConjunctionAdd(EducationMissionClassView educationMissionClassView, List educationMissionClassIDs) { try { var educationMissionClassList = educationMissionClassDAL.EducationMissionClassRepository .GetList(x => educationMissionClassIDs.Contains(x.EducationMissionClassID), (x => x.CF_Classmajor), (x => x.EM_EducationMission), (x => x.EM_EducationMission.ER_FinalExamination.Select(w => w.EM_EducationMission)), (x => x.EM_EducationMission.ER_RetakePlanStudent.Select(w => w.EM_EducationMission)), (x => x.EM_EducationMission.EX_ExaminationPlan.Select(w => w.EM_EducationMission)), (x => x.EM_EducationMissionClassSettings), (x => x.EM_EducationMissionClassTeachingSetting), (x => x.EM_EducationSchedulingClass), (x => x.EM_EducationSchedulingClass.Select(w => w.CF_Student)), (x => x.EM_EducationSchedulingClass.Select(w => w.CF_Student.Select(v => v.ER_RetakePlanStudent))), (x => x.EM_EvaluationSetting), (x => x.EM_EvaluationEnter), (x => x.EM_MissionClassTeacher), (x => x.EM_CourseProcess), (x => x.EM_CoursesTime), (x => x.EM_CourseProcess.Select(y => y.EM_CourseProcessTeacher))).ToList(); EM_EducationMission mainEducationMission = null; EM_EducationMissionClass mainEducationMissionClass = null; int? type = null; // if (educationMissionClassList.Count > 0) { type = educationMissionClassList[0].OptionalCourseTypeID; } foreach (var educationMissionClass in educationMissionClassList) { if (type != null) { if (type == educationMissionClass.OptionalCourseTypeID) { type = educationMissionClass.OptionalCourseTypeID; } else { throw new Exception("不是相同选修类型的任务,不能合班。如限选只能与限选合班"); } } if (educationMissionClass.EducationMissionClassID == educationMissionClassView.EducationMissionClassID) { mainEducationMission = educationMissionClass.EM_EducationMission; mainEducationMissionClass = educationMissionClass; } } if (mainEducationMission == null) { throw new Exception("主要排课任务班数据异常,没有匹配的教学任务。"); } #region 根据主要班级生成新的任务班 string teachingModeName = IdNameExt.GetDictionaryItem(DictionaryItem.CF_TeachingMode.ToString()) .Where(x => x.Value == mainEducationMissionClass.TeachingModeID).Select(x => x.Name).FirstOrDefault(); EM_EducationMission newEducationMission = new EM_EducationMission(); newEducationMission.EducationMissionID = Guid.NewGuid(); newEducationMission.CollegeID = mainEducationMission.CollegeID; newEducationMission.DepartmentID = mainEducationMission.DepartmentID; newEducationMission.SchoolyearID = mainEducationMission.SchoolyearID; string teachingModeString = "(" + teachingModeName + ")"; newEducationMission.ClassName = educationMissionClassView.Name.Replace("-" + teachingModeString, ""); newEducationMission.ClassName = newEducationMission.ClassName.Replace(teachingModeString, ""); SetNewStatus(newEducationMission); UnitOfWork.Add(newEducationMission); #region 将教学任务对应的期末设定指向新的合班后的教学任务,防止学分之类的信息丢失 var finalExaminationList = educationMissionClassList.SelectMany(x => x.EM_EducationMission.ER_FinalExamination).ToList(); finalExaminationList.ForEach(x => x.EducationMissionID = newEducationMission.EducationMissionID); #endregion #region 将教学任务对应的重修名单指向新的合班后的教学任务 var retakePlanStudentList = educationMissionClassList.SelectMany(x => x.EM_EducationMission.ER_RetakePlanStudent).ToList(); retakePlanStudentList.ForEach(x => x.EducationMissionID = newEducationMission.EducationMissionID); #endregion #region 将教学任务对应的考试计划指向新的合班后的教学任务 var examinationPlanList = educationMissionClassList.SelectMany(x => x.EM_EducationMission.EX_ExaminationPlan).ToList(); examinationPlanList.ForEach(x => x.EducationMissionID = newEducationMission.EducationMissionID); #endregion EM_EducationMissionClass newEducationMissionClass = new EM_EducationMissionClass(); newEducationMissionClass.EducationMissionClassID = Guid.NewGuid(); newEducationMissionClass.EducationMissionID = newEducationMission.EducationMissionID; newEducationMissionClass.MainScheduleClassID = mainEducationMissionClass.MainScheduleClassID; newEducationMissionClass.OrderNo = mainEducationMissionClass.OrderNo; newEducationMissionClass.Name = educationMissionClassView.Name; newEducationMissionClass.TeachingModeID = mainEducationMissionClass.TeachingModeID; newEducationMissionClass.OptionalCourseTypeID = mainEducationMissionClass.OptionalCourseTypeID; newEducationMissionClass.ClassroomTypeID = mainEducationMissionClass.ClassroomTypeID; newEducationMissionClass.ClassroomID = mainEducationMissionClass.ClassroomID; newEducationMissionClass.CoursematerialID = mainEducationMissionClass.CoursematerialID; newEducationMissionClass.CourseStructureID = mainEducationMissionClass.CourseStructureID; newEducationMissionClass.CourseCategoryID = mainEducationMissionClass.CourseCategoryID; newEducationMissionClass.CourseTypeID = mainEducationMissionClass.CourseTypeID; newEducationMissionClass.CourseQualityID = mainEducationMissionClass.CourseQualityID; newEducationMissionClass.ExaminationModeID = mainEducationMissionClass.ExaminationModeID; newEducationMissionClass.TeachinglanguageID = mainEducationMissionClass.TeachinglanguageID; newEducationMissionClass.HandleModeID = mainEducationMissionClass.HandleModeID; newEducationMissionClass.IsNeedMaterial = mainEducationMissionClass.IsNeedMaterial; newEducationMissionClass.ResultTypeID = mainEducationMissionClass.ResultTypeID; newEducationMissionClass.Remark = mainEducationMissionClass.Remark; SetNewStatus(newEducationMissionClass); newEducationMissionClass.RecordStatus = (int)EMIS.ViewModel.EM_EducationMissionClassStatus.NotSubmitted; newEducationMissionClass.EM_CoursesTime = mainEducationMissionClass.EM_CoursesTime; newEducationMissionClass.CF_Classmajor = new HashSet(educationMissionClassList .SelectMany(x => x.CF_Classmajor) .GroupBy(x => x.ClassmajorID, (x, y) => y.FirstOrDefault()) .ToList()); UnitOfWork.Add(newEducationMissionClass); #region 将教学任务班对应的教学评价指向新的合班后的教学任务班 var evaluationSettingList = educationMissionClassList.SelectMany(x => x.EM_EvaluationSetting).ToList(); evaluationSettingList.ForEach(x => x.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID); var evaluationEnterList = educationMissionClassList.SelectMany(x => x.EM_EvaluationEnter).ToList(); evaluationEnterList.ForEach(x => x.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID); #endregion EM_EducationMissionClassTeachingSetting newEducationMissionClassTeachingSetting = new EM_EducationMissionClassTeachingSetting(); newEducationMissionClassTeachingSetting.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID; newEducationMissionClassTeachingSetting.Credit = mainEducationMissionClass.EM_EducationMissionClassTeachingSetting.Credit; newEducationMissionClassTeachingSetting.TheoryCourse = mainEducationMissionClass.EM_EducationMissionClassTeachingSetting.TheoryCourse; newEducationMissionClassTeachingSetting.Practicehours = mainEducationMissionClass.EM_EducationMissionClassTeachingSetting.Practicehours; newEducationMissionClassTeachingSetting.Trialhours = mainEducationMissionClass.EM_EducationMissionClassTeachingSetting.Trialhours; newEducationMissionClassTeachingSetting.WeeklyNum = mainEducationMissionClass.EM_EducationMissionClassTeachingSetting.WeeklyNum; newEducationMissionClassTeachingSetting.TheoryWeeklyNum = mainEducationMissionClass.EM_EducationMissionClassTeachingSetting.TheoryWeeklyNum; newEducationMissionClassTeachingSetting.PracticeWeeklyNum = mainEducationMissionClass.EM_EducationMissionClassTeachingSetting.PracticeWeeklyNum; newEducationMissionClassTeachingSetting.TrialWeeklyNum = mainEducationMissionClass.EM_EducationMissionClassTeachingSetting.TrialWeeklyNum; newEducationMissionClassTeachingSetting.StartWeeklyNum = mainEducationMissionClass.EM_EducationMissionClassTeachingSetting.StartWeeklyNum; newEducationMissionClassTeachingSetting.EndWeeklyNum = mainEducationMissionClass.EM_EducationMissionClassTeachingSetting.EndWeeklyNum; newEducationMissionClassTeachingSetting.WeeklyHours = mainEducationMissionClass.EM_EducationMissionClassTeachingSetting.WeeklyHours; UnitOfWork.Add(newEducationMissionClassTeachingSetting); //生成任务班设置表 foreach (var mainEducationMissionClassSettings in mainEducationMissionClass.EM_EducationMissionClassSettings.ToList()) { EM_EducationMissionClassSettings newEducationMissionClassSettings = new EM_EducationMissionClassSettings(); newEducationMissionClassSettings.EducationMissionClassSettingsID = Guid.NewGuid(); newEducationMissionClassSettings.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID; newEducationMissionClassSettings.WeeklyNum = mainEducationMissionClassSettings.WeeklyNum; SetNewStatus(newEducationMissionClassSettings); UnitOfWork.Add(newEducationMissionClassSettings); } //生成任课老师 foreach (var mainMissionClassTeacher in mainEducationMissionClass.EM_MissionClassTeacher.ToList()) { EM_MissionClassTeacher newMissionClassTeacher = new EM_MissionClassTeacher(); newMissionClassTeacher.MissionClassTeacherID = Guid.NewGuid(); newMissionClassTeacher.MissionClassID = newEducationMissionClass.EducationMissionClassID; newMissionClassTeacher.UserID = mainMissionClassTeacher.UserID; newMissionClassTeacher.TeachType = mainMissionClassTeacher.TeachType; SetNewStatus(newMissionClassTeacher); UnitOfWork.Add(newMissionClassTeacher); } //生成课程进度 foreach (var mainCourseProcess in mainEducationMissionClass.EM_CourseProcess.ToList()) { EM_CourseProcess newCourseProcess = new EM_CourseProcess(); newCourseProcess.CourseProcessID = Guid.NewGuid(); newCourseProcess.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID; newCourseProcess.Week = mainCourseProcess.Week; newCourseProcess.Times = mainCourseProcess.Times; newCourseProcess.ClassroomTypeID = mainCourseProcess.ClassroomTypeID; newCourseProcess.ClassroomID = mainCourseProcess.ClassroomID; mainCourseProcess.EM_CourseProcessTeacher.ToList().ForEach(x => { var newCourseProcessTeacher = new EM_CourseProcessTeacher { CourseProcessTeacherID = Guid.NewGuid(), CourseProcessID = newCourseProcess.CourseProcessID, UserID = x.UserID, TeachType = x.TeachType }; this.SetNewStatus(newCourseProcessTeacher); newCourseProcess.EM_CourseProcessTeacher.Add(newCourseProcessTeacher); }); SetNewStatus(newCourseProcess); UnitOfWork.Add(newCourseProcess); } //生成排课班 EM_EducationSchedulingClass newEducationSchedulingClass = new EM_EducationSchedulingClass(); newEducationSchedulingClass.EducationSchedulingClassID = Guid.NewGuid(); newEducationSchedulingClass.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID; newEducationSchedulingClass.TaskGroupName = "1组"; SetNewStatus(newEducationSchedulingClass); //获取主排课班学生 List studentList = educationMissionClassList .SelectMany(x => x.EM_EducationSchedulingClass) .SelectMany(x => x.CF_Student) .GroupBy(x => x.UserID, (x, y) => y.FirstOrDefault()) .ToList(); newEducationSchedulingClass.CF_Student = new HashSet(studentList); UnitOfWork.Add(newEducationSchedulingClass); var allEducationMissionIDList = educationMissionClassList.Select(x => x.EducationMissionID).Distinct().ToList(); //var retakePlanStudentList = newEducationSchedulingClass.CF_Student.SelectMany(x => x.ER_RetakePlanStudent) // .Where(x => allEducationMissionIDList.Contains(x.EducationMissionID)).ToList(); //retakePlanStudentList.ForEach(x => x.EducationMissionID = newEducationMission.EducationMissionID); #endregion #region 将参与合班的教学任务其他的任务班拉到这个合并后的教学任务中 var allEducationMissionClassList = educationMissionClassDAL.EducationMissionClassRepository .GetList(x => allEducationMissionIDList.Contains(x.EducationMissionID) && !educationMissionClassIDs.Contains(x.EducationMissionClassID)) .ToList(); foreach (var otherEducationMissionClass in allEducationMissionClassList) { otherEducationMissionClass.EducationMissionID = newEducationMission.EducationMissionID; } #endregion //删除课程类型 foreach (var id in educationMissionClassIDs) { if (id != mainEducationMissionClass.EducationMissionClassID) { EM_EducationMissionClass EducationMissionClass = GetEducationMissionClass(id); EducationMissionClass.EM_CoursesTime = new HashSet(); } } mainEducationMissionClass.EM_CoursesTime = new HashSet(); UnitOfWork.Remove(x => educationMissionClassIDs.Contains(x.EducationMissionClassID)); UnitOfWork.Remove(x => educationMissionClassIDs.Contains(x.EducationMissionClassID)); UnitOfWork.Remove(x => allEducationMissionIDList.Contains(x.EducationMissionID)); //删除教学任务 UnitOfWork.Commit(); } catch (Exception) { throw; } } /// /// 获取主表对象 /// /// /// public EM_EducationMission GetEducationMission(Guid? educationMissionID) { return educationMissionClassDAL.EducationMissionRepository.GetSingle(x => x.EducationMissionID == educationMissionID); } /// /// 获取学籍班的所有任务班 /// /// 学籍班ID /// public List GetEducationMissionClassList(Guid? educationMissionID) { return educationMissionClassDAL.EducationMissionClassRepository.GetList(x => x.EducationMissionID == educationMissionID, (x => x.EM_EducationSchedulingClass)).ToList(); } /// /// 获取学籍班的所有任务班 /// /// public List GetEducationMissionClassList() { return educationMissionClassDAL.EducationMissionClassRepository.GetList(x => true, (x => x.EM_MissionClassTeacher), (x => x.EM_EducationMissionClassSettings)).ToList(); } /// /// 更新教学任务班表 处理状态 /// /// public void EducationMissionClassUpdate(List educationMissionClassIDs) { try { string massge = string.Empty; var educationMissionClassList = educationMissionClassDAL .GetEducationMissionClass(x => educationMissionClassIDs.Contains(x.EducationMissionClassID)).Distinct().ToList(); var educationMissionIDList = educationMissionClassList.Select(x => x.EducationMissionID).Distinct(); //var courseProcessList = educationMissionClassDAL.GetRelatedCourseProcess(x => educationMissionClassIDs.Contains(x.EducationMissionClassID)) // .ToList(); foreach (var educationMissionClass in educationMissionClassList) { if (educationMissionClass.RecordStatus != (int)EMIS.ViewModel.EM_EducationMissionClassStatus.NotSubmitted) massge += educationMissionClass.Name + "任务班,已提交,不能重复提交。"; if (educationMissionClass.EM_MissionClassTeacher.Count == 0 && !Const.LOCAL_SETTING_MISSIONCLASS_CAN_SUBMIT_NOTEACHER) massge += educationMissionClass.Name + "任务班,未设置授课老师。"; if (educationMissionClass.EM_EducationMissionClassSettings.Count == 0) massge += educationMissionClass.Name + "任务班,未设置授课周次。"; if (educationMissionClass.ClassroomTypeID == null) massge += educationMissionClass.Name + "任务班,未设置教室类型。"; var courseProcessList = educationMissionClassDAL.GetRelatedCourseProcess(x => x.EducationMissionClassID == educationMissionClass.EducationMissionClassID) .ToList(); var hours = courseProcessList.Select(x => x.Times).Sum(); //总学时 int? totalHours = (educationMissionClass.EM_EducationMissionClassTeachingSetting.TheoryCourse ?? 0) + (educationMissionClass.EM_EducationMissionClassTeachingSetting.Practicehours ?? 0); //TODO:兵良说:排课学时要小于等于总学时 2016年10月17日18:48:49 if (hours > totalHours) { massge += educationMissionClass.Name + "任务班,课程进度设置错误,请检查并重新设置后提交。"; } if (!string.IsNullOrEmpty(massge)) massge += ","; } //20161110 MM姐提的要求, 先提交数据检测是否问题,有问题把所有问题反馈回页面让客户进行修改,再重新提交 if (!string.IsNullOrEmpty(massge)) throw new Exception(massge.TrimEnd(',')); foreach (var educationMissionClass in educationMissionClassList) { educationMissionClass.RecordStatus = (int)EMIS.ViewModel.EM_EducationMissionClassStatus.Submitted; } UnitOfWork.Commit(); } catch (Exception) { throw; } } public void UnSubmit(List educationMissionClassIDs) { try { string massge = string.Empty; var educationMissionClassList = educationMissionClassDAL .GetEducationMissionClass(x => educationMissionClassIDs.Contains(x.EducationMissionClassID)).Distinct().ToList(); foreach (var educationMissionClass in educationMissionClassList) { if (educationMissionClass.RecordStatus == (int)EMIS.ViewModel.EM_EducationMissionClassStatus.NotSubmitted) massge += educationMissionClass.Name + "任务班未提交,不能撤销。"; if (educationMissionClass.RecordStatus == (int)EMIS.ViewModel.EM_EducationMissionClassStatus.Scheduled) massge += educationMissionClass.Name + "任务班已排课,不能撤销。"; } if (!string.IsNullOrEmpty(massge)) throw new Exception(massge.TrimEnd(',')); foreach (var educationMissionClass in educationMissionClassList) { educationMissionClass.RecordStatus = (int)EMIS.ViewModel.EM_EducationMissionClassStatus.NotSubmitted; } UnitOfWork.Commit(); } catch (Exception) { throw; } } public void Delete(List educationMissionClassIDs) { try { var educationMissionClassList = this.educationMissionClassDAL.EducationMissionClassRepository .GetList(x => educationMissionClassIDs.Contains(x.EducationMissionClassID), (x => x.CF_Classmajor), (x => x.EM_EducationMission), (x => x.EM_EducationMission.EM_EducationMissionClass), (x => x.EM_EducationSchedulingClass.Select(w => w.ES_EducationScheduling)), (x => x.EM_EducationMissionClassSettings), (x => x.EM_EducationMissionClassTeachingSetting), (x => x.EM_MissionClassTeacher), (x => x.EM_CoursesTime)).ToList(); //先找出教学任务主表ID,若是重修生成的教学任务,更新重修任务时用到 var educationMissionIDList = educationMissionClassList.Select(x => x.EducationMissionID).Distinct().ToList(); var errorList = new List(); foreach (var educationMissionClass in educationMissionClassList) { //任选课生成时就已经排了课,所以即使已排课状态也可以删除 if (educationMissionClass.RecordStatus == (int)EM_EducationMissionClassStatus.Scheduled && !(educationMissionClass.HandleModeID == (int)CF_HandleMode.SelectionCourse && educationMissionClass.OptionalCourseTypeID == (int)CF_CourseSelectType.FreeSelectionCourse)) { errorList.Add("任务班" + educationMissionClass.Name + "包含已排课状态,不能删除"); } } if (errorList.Count > 0) { throw new Exception(string.Join("\n", errorList)); } //由于要兼容合班,因此不能直接以任务班自身的ID去搜索执行计划,必须用学年学期、年级专业、课程这三个条件去找匹配的执行计划来更新状态 var executablePlanList = educationMissionClassDAL.GetRelatedExecutablePlan(x => educationMissionClassIDs.Contains(x.EducationMissionClassID)).ToList(); //先预先找出需要删除的教学任务,逻辑是找出自身教学任务中,没有和自己不同的其他任务班的教学任务 var needDeleteEducationMissionList = (from emc in educationMissionClassList where !emc.EM_EducationMission.EM_EducationMissionClass .Any(x => !educationMissionClassIDs.Contains(x.EducationMissionClassID)) group emc.EM_EducationMission by emc.EM_EducationMission.EducationMissionID into g select g.FirstOrDefault()).ToList(); List educationMissionClassIDList = new List(); var ExecutableMinorPlanList = ExecutableMinorPlanDAL.ExecutableMinorPlanRepository.GetList(x => true,(x=>x.EM_EducationMissionClass)).ToList(); var ExecutableMinorPlanEducationMissionList = ExecutableMinorPlanDAL.GetEducationMissionClassQuerybles().ToList(); foreach (var educationMissionClass in educationMissionClassList) { var ExecutableMinorPlanIDList = ExecutableMinorPlanEducationMissionList.Where(x => x.EducationMissionClassID == educationMissionClass.EducationMissionClassID).Select(x => x.ExecutableMinorPlanID).ToList(); if (ExecutableMinorPlanIDList.Count>0) { var ExecutableMinorPlan = ExecutableMinorPlanList.Where(x => ExecutableMinorPlanIDList.Contains(x.ExecutableMinorPlanID)); foreach (var ExecutableMinor in ExecutableMinorPlan) { ExecutableMinor.EM_EducationMissionClass=new HashSet(); ExecutableMinor.RecordStatus = (int)EM_ExecuteStatus.NotSubmited; } } educationMissionClassIDList.Add(educationMissionClass.EducationMissionClassID); educationMissionClass.EM_CoursesTime = new HashSet(); var educationSchedulingIDList = educationMissionClass.EM_EducationSchedulingClass .SelectMany(x => x.ES_EducationScheduling).Select(x => x.EducationSchedulingID).ToList(); //由于前面已经有拦截必修和限选的排课状态数据,所以这里应该只会包含任选课的排课表,可以放心地删掉 UnitOfWork.Remove(x => educationSchedulingIDList.Contains(x.EducationSchedulingID.Value)); UnitOfWork.Remove(x => educationSchedulingIDList.Contains(x.EducationSchedulingID.Value)); UnitOfWork.Remove(x => educationSchedulingIDList.Contains(x.EducationSchedulingID)); UnitOfWork.RemoveRange(educationMissionClass.EM_CourseProcess); UnitOfWork.RemoveRange(educationMissionClass.EM_EducationSchedulingClass); if (educationMissionClass.HandleModeID == (int)CF_HandleMode.SelectionCourse && educationMissionClass.OptionalCourseTypeID == (int)CF_CourseSelectType.OptionalCourse) UnitOfWork.RemoveRange(educationMissionClass.EM_EducationSchedulingClass); UnitOfWork.RemoveRange(educationMissionClass.EM_EducationMissionClassSettings); UnitOfWork.RemoveRange(educationMissionClass.EM_MissionClassTeacher); UnitOfWork.Remove(educationMissionClass.EM_EducationMissionClassTeachingSetting); UnitOfWork.Remove(educationMissionClass); } //UnitOfWork.Commit(); foreach (var executablePlan in executablePlanList) { executablePlan.RecordStatus = (int)EM_ExecuteStatus.NotSubmited; } //由于任务班会分班合班,无法直接关联,所以现在改为直接找报名学生都不在任务班中的限选设定进行重置 var value = schoolYearDAL.schoolyearRepository.Entities.Where(x => x.IsCurrent == true).FirstOrDefault().Value; var executableOptionalCourseList = OptionalCourseSettingDAL.GetNoMissionClassExecutableOptionalCourse(value, educationMissionClassIDList).ToList(); foreach (var executableOptionalCourse in executableOptionalCourseList) { //要删除的教学任务对应的限选设定,变成取消开班状态 executableOptionalCourse.RecordStatus = (int)EM_SelectCourseResultStatus.CancleCreate; } //任选设定同上,分别是任选设定还要强制删除课程进度及排课 var executableFreeSelectionCourseList = ExecutableFreeSelectionCouseDAL.GetNoMissionClassExecutableFreeSelectionCourse(value, educationMissionClassIDList).ToList(); foreach (var executableFreeSelectionCourse in executableFreeSelectionCourseList) { executableFreeSelectionCourse.RecordStatus = (int)EM_SelectCourseResultStatus.CancleCreate; } //考虑到重修开班时根据授课方式生成多个教学任务班时,只有当教学任务班都删除完时才修改重修计划 var educationMissionIDList1 = educationMissionClassDAL.EducationMissionClassRepository.GetList(x => educationMissionIDList.Contains(x.EducationMissionID)).Select(x => x.EducationMissionID).ToList(); var educationIDList = educationMissionIDList1.Except(educationMissionIDList); //更新重修计划状态和删除重修名单的教学任务主表ID,用教学任务主表ID查询重修名单表, var retakePlan = RetakePlanDAL.RetakePlanRepository.GetList(x => x.ER_RetakePlanStudent.Any(w => educationMissionIDList1.Contains(w.EducationMissionID.Value) && !educationIDList.Contains(w.EducationMissionID.Value)), x => x.ER_RetakePlanStudent).ToList(); if (retakePlan.Count > 0) { //重修计划状态改为已开放 retakePlan.ForEach(x => { x.RecordStatus = (int)EMIS.ViewModel.ER_RetakePlanStatus.Opened; x.ER_RetakePlanStudent.ToList().ForEach(w => w.EducationMissionID = null); }); } foreach (var needDeleteEducationMission in needDeleteEducationMissionList) { UnitOfWork.Remove(needDeleteEducationMission); } UnitOfWork.Commit(); } catch (Exception) { throw; } } public List GetCourseProcessView(Guid educationMissionClassID) { //2016年12月1日15:28:47 //TODO :调整教学任务课程进度统计规则[将原按教学任务获取该教学任务下所对应的教学任务班课程进度信息调整为按对应教学任务班进行统计] //var courseViewList = this.educationMissionClassDAL.GetCourseProcessView(x => x.EducationMissionID == educationMissionID) // .OrderBy(x => x.Week).ToList(); var courseViewList = this.educationMissionClassDAL.GetCourseProcessView(x => x.EducationMissionClassID == educationMissionClassID) .OrderBy(x => x.Week).ToList(); var courseViewTeacherList = this.educationMissionClassDAL.GetCourseProcessTeacherView(x => x.EducationMissionClassID == educationMissionClassID).ToList(); courseViewList.ForEach(x => { x.CourseProcessTeacherViewList = courseViewTeacherList.Where(w => w.CourseProcessID == x.CourseProcessID).ToList(); //x.StaffIDAndTeachTypes = string.Join(",", x.CourseProcessTeacherViewList.Select(w => w.UserID.ToString() + "|" + w.TeacherType.ToString())); //x.StaffNames = string.Join(",", x.CourseProcessTeacherViewList.Select(w => w.Name)); }); return courseViewList; } public List GetCourseProcessTeacherView(Guid courseProcessID) { var courseProcessTeacherQueryable = this.educationMissionClassDAL.GetCourseProcessTeacherViewByCourseProcess(x => x.CourseProcessID == courseProcessID); return courseProcessTeacherQueryable.ToList(); } public void SaveCourseProcessView(EducationMissionClassView educationMissionClassView, IList courseProcessViewList) { var educationMissionClass = educationMissionClassDAL.EducationMissionClassRepository .GetSingle(x => x.EducationMissionClassID == educationMissionClassView.EducationMissionClassID, (x => x.EM_MissionClassTeacher)); if (courseProcessViewList.Count > 0) { if (courseProcessViewList.Select(x => x.Times).Sum() > educationMissionClassView.Totalhours) { throw new Exception("课程进度学时不能超出总学时,请检查调整!"); } } if (educationMissionClass.RecordStatus == (int)EM_EducationMissionClassStatus.Scheduled) { //TODO:已提交的数据不能做编辑操作~ throw new Exception("已排课的任务班不能修改。"); } var groupedCoursesProcessViewList = courseProcessViewList .GroupBy(x => new { x.EducationMissionClassID, x.Week, x.ClassroomID, x.ClassroomTypeID, TeacherKey = string.Join(",", x.CourseProcessTeacherViewList.OrderBy(w => w.UserID).ThenBy(w => w.TeachingMethod) .Select(w => w.UserID.ToString() + "|" + w.TeachingMethod.ToString())) }).Select(x => new { x.Key.EducationMissionClassID, x.Key.Week, x.Key.ClassroomID, x.Key.ClassroomTypeID, x.FirstOrDefault().CourseProcessTeacherViewList, Times = x.Sum(w => w.Times) }).ToList(); this.UnitOfWork.Delete(x => x.EducationMissionClassID == educationMissionClassView.EducationMissionClassID); foreach (var courseProcessView in groupedCoursesProcessViewList) { EM_CourseProcess courseProcess = new EM_CourseProcess(); courseProcess.CourseProcessID = Guid.NewGuid(); courseProcess.EducationMissionClassID = courseProcessView.EducationMissionClassID; courseProcess.Week = courseProcessView.Week; courseProcess.Times = courseProcessView.Times; courseProcess.ClassroomTypeID = courseProcessView.ClassroomTypeID; courseProcess.ClassroomID = courseProcessView.ClassroomID; courseProcess.EM_CourseProcessTeacher = new HashSet(); SetNewStatus(courseProcess); UnitOfWork.Add(courseProcess); courseProcessView.CourseProcessTeacherViewList.ToList().ForEach(x => { UnitOfWork.Add(new EM_CourseProcessTeacher { CourseProcessTeacherID = Guid.NewGuid(), CourseProcessID = courseProcess.CourseProcessID, UserID = x.UserID, TeachType = x.TeachingMethod, RecordStatus = (int)SYS_STATUS.USABLE, CreateTime = courseProcess.CreateTime, CreateUserID = courseProcess.CreateUserID, ModifyTime = courseProcess.ModifyTime, ModifyUserID = courseProcess.ModifyUserID }); }); } var missionClassTeacherList = (from courseProcess in courseProcessViewList from teacher in courseProcess.CourseProcessTeacherViewList group teacher by new { teacher.UserID, teacher.TeachingMethod } into g select g.FirstOrDefault()).ToList(); educationMissionClass.EM_MissionClassTeacher.ToList().ForEach(x => UnitOfWork.Remove(x)); missionClassTeacherList.ForEach(x => { var missionClassTeacher = new EM_MissionClassTeacher { MissionClassTeacherID = Guid.NewGuid(), MissionClassID = educationMissionClass.EducationMissionClassID, UserID = x.UserID, TeachType = x.TeachingMethod }; this.SetNewStatus(missionClassTeacher); this.UnitOfWork.Add(missionClassTeacher); }); this.UnitOfWork.Commit(); } public int GetStudentCount(Guid educationMissionClassID) { var educationSchedulingClass = educationMissionClassDAL .EducationSchedulingClassRepository .GetSingle(x => x.EducationMissionClassID == educationMissionClassID, (x => x.CF_Student)); return educationSchedulingClass.CF_Student.Count; } public IGridResultSet GetAvailableClassroom(ConfiguretView configuretView, Guid collegeID, Guid? buildingID, int? classroomType, int? minSeatCount, int? pageIndex, int? pageSize) { Expression> exp = (x => true); if (buildingID.HasValue) { exp = exp.And(x => x.BuildingsInfoID == buildingID); } var classroomView = ClassroomScheduleDAL.GetAvailableClassroom(collegeID, minSeatCount, exp, classroomType); if (!string.IsNullOrEmpty(configuretView.ConditionValue)) classroomView = classroomView.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue); return classroomView.OrderBy(x => x.BuildingsInfoName) .ThenBy(x => x.Name) .ThenBy(x => x.Totalseating).ToGridResultSet(pageIndex, pageSize); } public List GetEducationMissionClassStatus() { var list = DictionaryHelper.GetDictionaryValue("EM_EducationMissionClassStatus").Select(x => x.Value.ToString()).ToList(); return list; } [Obsolete] public bool Verification(List collegeIDList, List schoolyearIDList) { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); var isOK = true; var query = EducationMissionOpenControlDAL.GetEducationMissionOpenControlViewQueryable(exp).ToList(); int VerificationNum = collegeIDList.Count(); for (int i = 0; i < VerificationNum; i++) { var OpenControl = query.Where(x => x.CollegeID == collegeIDList[i] && x.SchoolyearID == schoolyearIDList[i]).FirstOrDefault(); if (OpenControl!=null) { if (OpenControl.StartDate > System.DateTime.Now || System.DateTime.Now > OpenControl.EndDate.Value.AddDays(1)) { isOK = false; return isOK; } } } return isOK; } public bool CheckEducationMissionClassOpenControl(IList educationMissionClassIDList) { var nowTime = DateTime.Today; var collegeSchoolyearKeyList = this.educationMissionClassDAL.EducationMissionClassRepository.GetList(x => educationMissionClassIDList.Contains(x.EducationMissionClassID)) .GroupBy(x => new { x.EM_EducationMission.SchoolyearID, x.EM_EducationMission.CF_Department.CollegeID }) .Select(x => new { x.Key.SchoolyearID, x.Key.CollegeID }).ToList(); var openControlList = EducationMissionOpenControlDAL.EducationMissionOpenControlRepository .GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && (x.StartDate > nowTime || x.EndDate < nowTime)) .SelectByKeys(collegeSchoolyearKeyList); if (openControlList.Count > 0) { throw new Exception("受教学安排的时间控制,所选教学任务不在可操作时间范围,暂时无法操作。"); } return true; } [Obsolete] public IGridResultSet GetLastCourseEducationMissionClassViewGrid(ConfiguretView configuretView, Guid userID, int? pageIndex, int? pageSize) { Expression> studentExp = (x => x.UserID == userID); var query = this.educationMissionClassDAL.GetLastCourseEducationMissionClassViewQueryable(studentExp); query = query.OrderBy(x => x.CourseCode).ThenBy(x => x.CourseName); return query.ToGridResultSet(pageIndex, pageSize); } } }