using System; using System.Collections.Generic; using System.Linq; using System.Linq.Expressions; using System.Text; using System.Transactions; using Bowin.Common.Linq; using Bowin.Common.Linq.Entity; using EMIS.Utility; using EMIS.Entities; using EMIS.ViewModel; using EMIS.ViewModel.EducationManagement; using EMIS.ViewModel.CultureplanManage.PlanManagement; namespace EMIS.ExtensionLogic.CommonLogic.EducationManage { public class ExecutablePlanServices : EMIS.CommonLogic.EducationManage.ExecutablePlanServices { /// /// 编辑(新增、修改,业务主键:学年学期ID、年级专业ID、课程信息ID) /// 注:关联对应的专业计划、刷新相关的教学任务信息 /// 注:区分普教版本(年级专业)、成教版本(入学学年学期、专业信息) /// 注:此为成教版本(入学学年学期、专业信息) /// 注:此版本学生人数小于等于0时,不可提交,但由于有异动的情况,需进一步优化逻辑(对教学任务班学生名单进行判断) /// /// public override void ExecutablePlanEdit(ExecutablePlanView executablePlanView) { try { //查询对应的课程信息 var coursematerial = ExecutablePlanDAL.CoursematerialRepository.GetList(x => x.CoursematerialID == executablePlanView.CoursematerialID).SingleOrDefault(); if (coursematerial == null) { throw new Exception("课程信息不存在,请检查。"); } //查询对应的年级专业信息 var grademajor = ExecutablePlanDAL.GrademajorRepository .GetList(x => x.GrademajorID == executablePlanView.GrademajorID).SingleOrDefault(); if (grademajor == null) { throw new Exception("年级专业信息不存在,请检查。"); } //查询年级专业对应的专业信息 var specialty = ExecutablePlanDAL.GetSpecialtyQueryable(x => x.GrademajorID == executablePlanView.GrademajorID).SingleOrDefault(); if (specialty == null) { throw new Exception("年级专业对应的专业信息不存在,请检查。"); } //查询年级专业对应的入学学年学期信息 var startSchoolyear = ExecutablePlanDAL.SchoolyearRepository.GetList(x => x.Years == grademajor.GradeID && x.SchoolcodeID == grademajor.SemesterID).SingleOrDefault(); if (startSchoolyear == null) { throw new Exception("年级专业对应的入学学年学期信息不存在,请检查。"); } //查询年级专业对应的毕业学年学期信息 var graduatingSemester = ExecutablePlanDAL.SchoolyearRepository.GetList(x => x.SchoolyearID == grademajor.GraduateSchoolyearID).SingleOrDefault(); if (graduatingSemester == null) { throw new Exception("年级专业对应的毕业学年学期信息不存在,请检查。"); } //查询对应的学年学期信息 var schoolyear = ExecutablePlanDAL.SchoolyearRepository.GetList(x => x.SchoolyearID == executablePlanView.SchoolyearID).SingleOrDefault(); if (schoolyear == null) { throw new Exception("学年学期信息不存在,请检查。"); } if (schoolyear.Value < startSchoolyear.Value) { throw new Exception("学年学期小于入学学年学期,请检查。"); } if (schoolyear.Value > graduatingSemester.Value) { throw new Exception("学年学期大于毕业学年学期,请检查。"); } //查询数据库进行验证 var executablePlanVerify = ExecutablePlanDAL.ExecutablePlanRepository .GetList(x => x.ExecutablePlanID != executablePlanView.ExecutablePlanID && x.SchoolyearID == executablePlanView.SchoolyearID && x.GrademajorID == executablePlanView.GrademajorID && x.CoursematerialID == executablePlanView.CoursematerialID).SingleOrDefault(); if (executablePlanVerify == null) { if (executablePlanView.TeachingModeIDList == null || executablePlanView.TeachingModeIDList.Count() <= 0) { throw new Exception("请选择至少一种授课方式,请检查。"); } //查询对应的专业计划信息(业务主键:学年学期ID、入学学年学期ID、专业信息ID、课程信息ID) var specialtyPlan = ExecutablePlanDAL.SpecialtyPlanRepository .GetList(x => x.SchoolyearID == executablePlanView.SchoolyearID && x.StartSchoolyearID == startSchoolyear.SchoolyearID && x.SpecialtyID == specialty.SpecialtyID && x.CoursematerialID == executablePlanView.CoursematerialID).SingleOrDefault(); List newExecutablePlanInList = new List(); List newExecutablePlanUpList = new List(); List newProfileInList = new List(); List newProfileUpList = new List(); List newEPTeachingSettingInList = new List(); List newEPTeachingSettingUpList = new List(); List newEPTeachingModeTypeInList = new List(); List newEPTeachingPlaceInList = new List(); List executablePlanTMDelList = new List(); List executablePlanTPDelList = new List(); List newEducationMissionInList = new List(); List newEducationMissionUpList = new List(); List newEducationMissionClassInList = new List(); List newEducationMissionClassUpList = new List(); List newEduTeachingSettingInList = new List(); List newEduTeachingSettingUpList = new List(); List newEducationSchedulingClassInList = new List(); List newEduSettingsInList = new List(); List newCourseProcessInList = new List(); //数据有误验证 if (executablePlanView.ExecutablePlanID != Guid.Empty) { var executablePlan = ExecutablePlanDAL.ExecutablePlanRepository .GetList(x => x.ExecutablePlanID == executablePlanView.ExecutablePlanID, (x => x.EM_ExecutablePlanProfile), (x => x.EM_ExecutablePlanTeachingSetting)).SingleOrDefault(); if (executablePlan == null) { throw new Exception("数据有误,请核查。"); } else { //表示修改 executablePlan.SourceTypeID = executablePlanView.SourceTypeID; executablePlan.DefaultClassName = coursematerial.CourseName + "-" + grademajor.Name; if (specialtyPlan == null) { executablePlan.SpecialtyPlanID = null; } else { executablePlan.SpecialtyPlanID = specialtyPlan.SpecialtyPlanID; } executablePlan.SchoolyearID = executablePlanView.SchoolyearID; executablePlan.GrademajorID = executablePlanView.GrademajorID; executablePlan.CoursematerialID = executablePlanView.CoursematerialID; executablePlan.CourseStructureID = executablePlanView.CourseStructureID; executablePlan.CourseCategoryID = executablePlanView.CourseCategoryID; executablePlan.CourseTypeID = executablePlanView.CourseTypeID; executablePlan.CourseQualityID = executablePlanView.CourseQualityID; executablePlan.DepartmentID = executablePlanView.DepartmentID; if (executablePlanView.PlanTypeID == (int)EM_PlanType.Outside) { executablePlan.IsNeedMaterial = executablePlanView.IsNeedMaterial; } executablePlan.ResultTypeID = executablePlanView.ResultTypeID; executablePlan.HandleModeID = executablePlanView.HandleModeID; SetModifyStatus(executablePlan); newExecutablePlanUpList.Add(executablePlan); if (executablePlan.EM_ExecutablePlanProfile == null) { var newProfile = new EM_ExecutablePlanProfile(); newProfile.ExecutablePlanID = executablePlan.ExecutablePlanID; newProfile.IsSpecialtycore = executablePlanView.IsSpecialtycore; newProfile.IsCooperation = executablePlanView.IsCooperation; newProfile.IsRequired = executablePlanView.IsRequired; newProfile.IsElective = executablePlanView.IsElective; newProfile.IsNetworkCourse = executablePlanView.IsNetworkCourse; newProfile.IsMainCourse = executablePlanView.IsMainCourse; newProfile.CourseFineID = executablePlanView.CourseFineID; newProfile.PracticeTypeID = executablePlanView.PracticeTypeID; newProfile.TeachinglanguageID = executablePlanView.TeachinglanguageID; newProfile.ExaminationModeID = executablePlanView.ExaminationModeID; SetNewStatus(newProfile); newProfileInList.Add(newProfile); } else { if (executablePlanView.PlanTypeID == (int)EM_PlanType.Outside) { executablePlan.EM_ExecutablePlanProfile.IsSpecialtycore = executablePlanView.IsSpecialtycore; executablePlan.EM_ExecutablePlanProfile.IsCooperation = executablePlanView.IsCooperation; executablePlan.EM_ExecutablePlanProfile.IsRequired = executablePlanView.IsRequired; executablePlan.EM_ExecutablePlanProfile.IsElective = executablePlanView.IsElective; executablePlan.EM_ExecutablePlanProfile.IsNetworkCourse = executablePlanView.IsNetworkCourse; executablePlan.EM_ExecutablePlanProfile.IsMainCourse = executablePlanView.IsMainCourse; executablePlan.EM_ExecutablePlanProfile.CourseFineID = executablePlanView.CourseFineID; executablePlan.EM_ExecutablePlanProfile.PracticeTypeID = executablePlanView.PracticeTypeID; executablePlan.EM_ExecutablePlanProfile.TeachinglanguageID = executablePlanView.TeachinglanguageID; executablePlan.EM_ExecutablePlanProfile.ExaminationModeID = executablePlanView.ExaminationModeID; } SetModifyStatus(executablePlan.EM_ExecutablePlanProfile); newProfileUpList.Add(executablePlan.EM_ExecutablePlanProfile); } if (executablePlan.EM_ExecutablePlanTeachingSetting == null) { var newEPTeachingSetting = new EM_ExecutablePlanTeachingSetting(); newEPTeachingSetting.ExecutablePlanID = executablePlan.ExecutablePlanID; newEPTeachingSetting.Credit = executablePlanView.Credit; newEPTeachingSetting.TheoryCourse = executablePlanView.TheoryCourse; newEPTeachingSetting.Practicehours = executablePlanView.Practicehours; newEPTeachingSetting.Trialhours = executablePlanView.Trialhours; newEPTeachingSetting.TheoryWeeklyNum = executablePlanView.TheoryWeeklyNum; newEPTeachingSetting.PracticeWeeklyNum = executablePlanView.PracticeWeeklyNum; newEPTeachingSetting.TrialWeeklyNum = executablePlanView.TrialWeeklyNum; newEPTeachingSetting.WeeklyHours = executablePlanView.WeeklyHours; newEPTeachingSetting.WeeklyNum = executablePlanView.WeeklyNum; newEPTeachingSetting.StartWeeklyNum = executablePlanView.StartWeeklyNum; newEPTeachingSetting.EndWeeklyNum = executablePlanView.EndWeeklyNum; newEPTeachingSettingInList.Add(newEPTeachingSetting); } else { if (executablePlanView.PlanTypeID == (int)EM_PlanType.Outside) { executablePlan.EM_ExecutablePlanTeachingSetting.Credit = executablePlanView.Credit; executablePlan.EM_ExecutablePlanTeachingSetting.TheoryCourse = executablePlanView.TheoryCourse; executablePlan.EM_ExecutablePlanTeachingSetting.Practicehours = executablePlanView.Practicehours; executablePlan.EM_ExecutablePlanTeachingSetting.Trialhours = executablePlanView.Trialhours; } executablePlan.EM_ExecutablePlanTeachingSetting.TheoryWeeklyNum = executablePlanView.TheoryWeeklyNum; executablePlan.EM_ExecutablePlanTeachingSetting.PracticeWeeklyNum = executablePlanView.PracticeWeeklyNum; executablePlan.EM_ExecutablePlanTeachingSetting.TrialWeeklyNum = executablePlanView.TrialWeeklyNum; executablePlan.EM_ExecutablePlanTeachingSetting.WeeklyHours = executablePlanView.WeeklyHours; executablePlan.EM_ExecutablePlanTeachingSetting.WeeklyNum = executablePlanView.WeeklyNum; executablePlan.EM_ExecutablePlanTeachingSetting.StartWeeklyNum = executablePlanView.StartWeeklyNum; executablePlan.EM_ExecutablePlanTeachingSetting.EndWeeklyNum = executablePlanView.EndWeeklyNum; newEPTeachingSettingUpList.Add(executablePlan.EM_ExecutablePlanTeachingSetting); } if (executablePlanView.TeachingModeIDList != null && executablePlanView.TeachingModeIDList.Count() > 0) { executablePlanTMDelList.Add(executablePlan.ExecutablePlanID); foreach (var newModeType in executablePlanView.TeachingModeIDList.ToList()) { var newEPTeachingModeType = new EM_ExecutablePlanTeachingModeType(); newEPTeachingModeType.ExecutablePlanTeachingModeTypeID = Guid.NewGuid(); newEPTeachingModeType.ExecutablePlanID = executablePlan.ExecutablePlanID; newEPTeachingModeType.TeachingModeID = newModeType; this.SetNewStatus(newEPTeachingModeType); newEPTeachingModeTypeInList.Add(newEPTeachingModeType); } } else { executablePlanTMDelList.Add(executablePlan.ExecutablePlanID); } if (executablePlanView.TeachingPlaceIDList != null && executablePlanView.TeachingPlaceIDList.Count() > 0) { executablePlanTPDelList.Add(executablePlan.ExecutablePlanID); foreach (var newPlace in executablePlanView.TeachingPlaceIDList.ToList()) { var newEPTeachingPlace = new EM_ExecutablePlanTeachingPlace(); newEPTeachingPlace.ExecutablePlanTeachingPlaceID = Guid.NewGuid(); newEPTeachingPlace.ExecutablePlanID = executablePlan.ExecutablePlanID; newEPTeachingPlace.TeachingPlace = newPlace; this.SetNewStatus(newEPTeachingPlace); newEPTeachingPlaceInList.Add(newEPTeachingPlace); } } else { executablePlanTPDelList.Add(executablePlan.ExecutablePlanID); } //对应的教学任务信息更新(根据业务主键:学年学期ID、课程信息ID、班级信息ID、排课任务班ID或教学任务班ID) //注:由于相关业务主键冗余,目前不允许修改相关业务主键 //教学任务班生成规则如下: //1、对应的授课方式为必选项且可多选; //2、课程信息对应的上课类型为空时,默认只生成一种类型的教学任务班(授课方式为最小Value授课方式); //3、以上课类型为标准,匹配对应的授课方式来生成教学任务班; //4、根据授课方式与上课类型查询是否分班情况,存在分班情况,则生成对应的教学任务班; //5、对应的授课方式存在分班情况时,默认生成成绩合并录入形式的教学任务班(同一条教学任务); //6、年级专业对应的计划范围不于等于0时,不生成对应的教学任务班(无法生成); //7、年级专业对应的学生人数小于等于0时,不生成对应的教学任务班(成教版本有此逻辑); //8、如对应的年级专业有多个班级,都生成对应的教学任务班(只取在校状态为在校的学生信息); if (executablePlan.RecordStatus == (int)EM_ExecuteStatus.Submited) { //年级专业 Expression> expGrademajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expGrademajor = expGrademajor.And(x => x.GrademajorID == executablePlanView.GrademajorID); //查询对应的班级范围信息classmajorList var classmajorList = ExecutablePlanDAL.GetClassmajorRangeQueryable(expGrademajor).ToList(); //执行计划对应的计划范围判断 if (classmajorList != null && classmajorList.Count() > 0) { //查询对应的学生范围信息studentList var studentList = ExecutablePlanDAL.GetStudentRangeQueryable(expGrademajor).ToList(); //执行计划对应的学生范围判断 if (studentList != null && studentList.Count() > 0) { //查询对应在校状态IDList var inschoolStatusList = InSchoolSettingServices.Value.GetInschoolStatusList(true); //查询对应的课程信息中授课方式分班信息List var separateModeTypeList = ExecutablePlanDAL.GetSeparateModeTypeQueryble(x => x.CoursematerialID == executablePlanView.CoursematerialID).ToList(); //查询授课方式teachingModeList var teachingModeList = DictionaryHelper.GetDictionaryValue(EMIS.ViewModel.DictionaryItem.CF_TeachingMode).ToList(); //查询执行计划中授课方式及对应的上课类型中的授课方式(匹配上课类型) var minTeachingModeID = executablePlanView.TeachingModeIDList .Where(x => !separateModeTypeList.Contains(x)).OrderBy(x => x).FirstOrDefault(); List teachingModeIDList = new List(); if (minTeachingModeID != null) { teachingModeIDList.Add(minTeachingModeID); teachingModeIDList = teachingModeIDList.Concat(executablePlanView.TeachingModeIDList .Where(x => separateModeTypeList.Contains(x))).GroupBy(x => x).Select(x => x.Key).ToList(); } else { teachingModeIDList = executablePlanView.TeachingModeIDList .Where(x => separateModeTypeList.Contains(x)).GroupBy(x => x).Select(x => x.Key).ToList(); } //查询对应的授课方式信息List(匹配上课类型) var epTeachingModeList = teachingModeList.Where(x => teachingModeIDList.Contains(x.Value)).ToList(); //执行计划 Expression> expExecutablePlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); expExecutablePlan = expExecutablePlan.And(x => x.ExecutablePlanID == executablePlanView.ExecutablePlanID); //查询对应的教学任务班信息(业务主键:学年学期ID、课程信息ID、班级信息ID、排课任务班ID或教学任务班ID) var educationMissionClassList = ExecutablePlanDAL.GetEducationMissionClassQueryable(expExecutablePlan).ToList(); foreach (var classmajor in classmajorList) { //查询班级信息对应的教学任务班信息List var educlList = educationMissionClassList.Where(x => x.CF_Classmajor .Any(w => w.ClassmajorID == classmajor.ClassmajorID)).ToList(); if (educlList != null && educlList.Count() > 0) { //表示存在对应的教学任务班 //根据教学任务ID对educlList进行分组 var edugrList = educlList.GroupBy(x => x.EducationMissionID).ToList(); //根据授课方式对educlList进行分组 var tmgrList = educlList.GroupBy(x => x.TeachingModeID).ToList(); if (edugrList.Count() > 1 && tmgrList.Count() > 1) { //表示对应的教学任务班存在分班且成绩分开录入、授课方式多种情况 //目前此种数据有误,在生成期末设定时有问题(这里暂不处理) throw new Exception("对应的教学任务班中存在分班且成绩分开录入、授课方式多种的信息(请删除后,再保存),请核查。"); } else if (edugrList.Count() > 1 && epTeachingModeList.Count() > 1) { //表示对应的教学任务班存在分班且成绩分开录入、授课方式只有一种情况,不可再生成多种授课方式的教学任务班信息 //目前此种数据有误,在生成期末设定时有问题 throw new Exception("对应的教学任务班中存在分班且成绩分开录入的信息,不可再生成多种授课方式的教学任务班信息(请删除后,再保存),请核查。"); } else if (tmgrList.Count() == 1 && epTeachingModeList.Count() == 1) { //表示对应的教学任务班只存在一种授课方式信息(含分班且成绩合并或分开录入) //同时生成的教学任务班信息授课方式只有一种的情况(直接修改) foreach (var educl in educlList) { if (!newEducationMissionUpList.Any(x => x.EducationMissionID == educl.EducationMissionID)) { educl.EM_EducationMission.ClassName = coursematerial.CourseName + "-" + classmajor.Name; educl.EM_EducationMission.SchoolyearID = executablePlanView.SchoolyearID; educl.EM_EducationMission.CollegeID = executablePlanView.CollegeID; educl.EM_EducationMission.DepartmentID = executablePlanView.DepartmentID; SetModifyStatus(educl.EM_EducationMission); newEducationMissionUpList.Add(educl.EM_EducationMission); } if (!newEducationMissionClassUpList.Any(x => x.EducationMissionClassID == educl.EducationMissionClassID)) { educl.OptionalCourseTypeID = executablePlanView.SourceTypeID; educl.CoursematerialID = executablePlanView.CoursematerialID; educl.CourseStructureID = executablePlanView.CourseStructureID; educl.CourseCategoryID = executablePlanView.CourseCategoryID; educl.CourseTypeID = executablePlanView.CourseTypeID; educl.CourseQualityID = executablePlanView.CourseQualityID; educl.IsNeedMaterial = executablePlanView.IsNeedMaterial; educl.TeachinglanguageID = executablePlanView.TeachinglanguageID; educl.ExaminationModeID = executablePlanView.ExaminationModeID; educl.ResultTypeID = executablePlanView.ResultTypeID; educl.HandleModeID = executablePlanView.HandleModeID; educl.TeachingModeID = epTeachingModeList[0].Value; SetModifyStatus(educl); newEducationMissionClassUpList.Add(educl); } if (!newEduTeachingSettingUpList.Any(x => x.EducationMissionClassID == educl.EducationMissionClassID)) { educl.EM_EducationMissionClassTeachingSetting.Credit = executablePlanView.Credit; educl.EM_EducationMissionClassTeachingSetting.TheoryCourse = executablePlanView.TheoryCourse; educl.EM_EducationMissionClassTeachingSetting.Practicehours = executablePlanView.Practicehours; educl.EM_EducationMissionClassTeachingSetting.Trialhours = executablePlanView.Trialhours; //if (educl.RecordStatus != (int)EM_EducationMissionClassStatus.Submitted || educl.RecordStatus != (int)EM_EducationMissionClassStatus.Scheduled) //{ // //暂不考虑 // educl.EM_EducationMissionClassTeachingSetting.TheoryWeeklyNum = executablePlanView.TheoryWeeklyNum; // educl.EM_EducationMissionClassTeachingSetting.PracticeWeeklyNum = executablePlanView.PracticeWeeklyNum; // educl.EM_EducationMissionClassTeachingSetting.TrialWeeklyNum = executablePlanView.TrialWeeklyNum; // educl.EM_EducationMissionClassTeachingSetting.WeeklyHours = executablePlanView.WeeklyHours; // educl.EM_EducationMissionClassTeachingSetting.WeeklyNum = executablePlanView.WeeklyNum; // educl.EM_EducationMissionClassTeachingSetting.StartWeeklyNum = executablePlanView.StartWeeklyNum; // educl.EM_EducationMissionClassTeachingSetting.EndWeeklyNum = executablePlanView.EndWeeklyNum; //} newEduTeachingSettingUpList.Add(educl.EM_EducationMissionClassTeachingSetting); } } } else { //表示无论分班与否,成绩都是合并录入的情况(同一个教学任务ID) //表示可根据执行计划中匹配上课类型后的授课方式进行增加、修改对应的教学任务班信息 foreach (var educl in educlList) { //修改 if (!newEducationMissionUpList.Any(x => x.EducationMissionID == educl.EducationMissionID)) { educl.EM_EducationMission.ClassName = coursematerial.CourseName + "-" + classmajor.Name; educl.EM_EducationMission.SchoolyearID = executablePlanView.SchoolyearID; educl.EM_EducationMission.CollegeID = executablePlanView.CollegeID; educl.EM_EducationMission.DepartmentID = executablePlanView.DepartmentID; SetModifyStatus(educl.EM_EducationMission); newEducationMissionUpList.Add(educl.EM_EducationMission); } if (!newEducationMissionClassUpList.Any(x => x.EducationMissionClassID == educl.EducationMissionClassID)) { educl.OptionalCourseTypeID = executablePlanView.SourceTypeID; educl.CoursematerialID = executablePlanView.CoursematerialID; educl.CourseStructureID = executablePlanView.CourseStructureID; educl.CourseCategoryID = executablePlanView.CourseCategoryID; educl.CourseTypeID = executablePlanView.CourseTypeID; educl.CourseQualityID = executablePlanView.CourseQualityID; educl.IsNeedMaterial = executablePlanView.IsNeedMaterial; educl.TeachinglanguageID = executablePlanView.TeachinglanguageID; educl.ExaminationModeID = executablePlanView.ExaminationModeID; educl.ResultTypeID = executablePlanView.ResultTypeID; educl.HandleModeID = executablePlanView.HandleModeID; SetModifyStatus(educl); newEducationMissionClassUpList.Add(educl); } if (!newEduTeachingSettingUpList.Any(x => x.EducationMissionClassID == educl.EducationMissionClassID)) { educl.EM_EducationMissionClassTeachingSetting.Credit = executablePlanView.Credit; educl.EM_EducationMissionClassTeachingSetting.TheoryCourse = executablePlanView.TheoryCourse; educl.EM_EducationMissionClassTeachingSetting.Practicehours = executablePlanView.Practicehours; educl.EM_EducationMissionClassTeachingSetting.Trialhours = executablePlanView.Trialhours; //if (educl.RecordStatus != (int)EM_EducationMissionClassStatus.Submitted || educl.RecordStatus != (int)EM_EducationMissionClassStatus.Scheduled) //{ // //暂不考虑 // educl.EM_EducationMissionClassTeachingSetting.TheoryWeeklyNum = executablePlanView.TheoryWeeklyNum; // educl.EM_EducationMissionClassTeachingSetting.PracticeWeeklyNum = executablePlanView.PracticeWeeklyNum; // educl.EM_EducationMissionClassTeachingSetting.TrialWeeklyNum = executablePlanView.TrialWeeklyNum; // educl.EM_EducationMissionClassTeachingSetting.WeeklyHours = executablePlanView.WeeklyHours; // educl.EM_EducationMissionClassTeachingSetting.WeeklyNum = executablePlanView.WeeklyNum; // educl.EM_EducationMissionClassTeachingSetting.StartWeeklyNum = executablePlanView.StartWeeklyNum; // educl.EM_EducationMissionClassTeachingSetting.EndWeeklyNum = executablePlanView.EndWeeklyNum; //} newEduTeachingSettingUpList.Add(educl.EM_EducationMissionClassTeachingSetting); } } //将执行计划中匹配上课类型后的授课方式与对应的教学任务班的授课方式进行对比 var educltmList = tmgrList.Select(x => x.Key).ToList(); var newTeachingModeList = epTeachingModeList.Where(x => !educltmList.Contains(x.Value)).ToList(); foreach (var newTeachingMode in newTeachingModeList) { //新增 var newEducationMissionClass = new EM_EducationMissionClass(); newEducationMissionClass.EducationMissionClassID = Guid.NewGuid(); newEducationMissionClass.EducationMissionID = edugrList[0].Key; newEducationMissionClass.MainScheduleClassID = classmajor.ClassmajorID; newEducationMissionClass.OptionalCourseTypeID = executablePlanView.SourceTypeID; newEducationMissionClass.OrderNo = classmajor.ClassNum ?? 1; newEducationMissionClass.Name = coursematerial.CourseName + "-" + classmajor.Name + "-(" + newTeachingMode.Name + ")"; newEducationMissionClass.CoursematerialID = executablePlanView.CoursematerialID; newEducationMissionClass.CourseStructureID = executablePlanView.CourseStructureID; newEducationMissionClass.CourseCategoryID = executablePlanView.CourseCategoryID; newEducationMissionClass.CourseTypeID = executablePlanView.CourseTypeID; newEducationMissionClass.CourseQualityID = executablePlanView.CourseQualityID; newEducationMissionClass.ClassroomTypeID = null; newEducationMissionClass.ClassroomID = null; newEducationMissionClass.IsNeedMaterial = executablePlanView.IsNeedMaterial; newEducationMissionClass.TeachinglanguageID = executablePlanView.TeachinglanguageID; newEducationMissionClass.ExaminationModeID = executablePlanView.ExaminationModeID; newEducationMissionClass.ResultTypeID = executablePlanView.ResultTypeID; newEducationMissionClass.HandleModeID = executablePlanView.HandleModeID; newEducationMissionClass.TeachingModeID = newTeachingMode.Value; newEducationMissionClass.Remark = coursematerial.CourseName + "-" + classmajor.Name + "-(" + newTeachingMode.Name + ")"; SetNewStatus(newEducationMissionClass, (int)EM_EducationMissionClassStatus.NotSubmitted); newEducationMissionClassInList.Add(newEducationMissionClass); var newEduTeachingSetting = new EM_EducationMissionClassTeachingSetting(); newEduTeachingSetting.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID; newEduTeachingSetting.Credit = executablePlanView.Credit; newEduTeachingSetting.TheoryCourse = executablePlanView.TheoryCourse; newEduTeachingSetting.Practicehours = executablePlanView.Practicehours; newEduTeachingSetting.Trialhours = executablePlanView.Trialhours; newEduTeachingSetting.TheoryWeeklyNum = executablePlanView.TheoryWeeklyNum; newEduTeachingSetting.PracticeWeeklyNum = executablePlanView.PracticeWeeklyNum; newEduTeachingSetting.TrialWeeklyNum = executablePlanView.TrialWeeklyNum; newEduTeachingSetting.WeeklyHours = executablePlanView.WeeklyHours; newEduTeachingSetting.WeeklyNum = executablePlanView.WeeklyNum; newEduTeachingSetting.StartWeeklyNum = executablePlanView.StartWeeklyNum; newEduTeachingSetting.EndWeeklyNum = executablePlanView.EndWeeklyNum; newEduTeachingSettingInList.Add(newEduTeachingSetting); newEducationMissionClass.CF_Classmajor = new HashSet(); newEducationMissionClass.CF_Classmajor.Add(classmajor); var newEducationSchedulingClass = new EM_EducationSchedulingClass(); newEducationSchedulingClass.EducationSchedulingClassID = Guid.NewGuid(); newEducationSchedulingClass.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID; newEducationSchedulingClass.TaskGroupName = "1组"; newEducationSchedulingClass.Remark = classmajor.Name; SetNewStatus(newEducationSchedulingClass); newEducationSchedulingClassInList.Add(newEducationSchedulingClass); newEducationSchedulingClass.CF_Student = new HashSet(); var newStudent = studentList.Where(x => x.ClassmajorID == classmajor.ClassmajorID && inschoolStatusList.Contains(x.InSchoolStatusID)).ToList(); newStudent.ForEach(x => newEducationSchedulingClass.CF_Student.Add(x)); for (int i = 0; i < executablePlanView.EndWeeklyNum; i++) { var newEduSettings = new EM_EducationMissionClassSettings(); newEduSettings.EducationMissionClassSettingsID = Guid.NewGuid(); newEduSettings.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID; newEduSettings.WeeklyNum = i + 1; SetNewStatus(newEduSettings); newEduSettingsInList.Add(newEduSettings); var newCourseProcess = new EM_CourseProcess(); newCourseProcess.CourseProcessID = Guid.NewGuid(); newCourseProcess.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID; newCourseProcess.Week = i + 1; newCourseProcess.Times = executablePlanView.WeeklyHours; newCourseProcessInList.Add(newCourseProcess); } } } } else { //表示不存在对应的教学任务班(新增) var newEducationMission = new EM_EducationMission(); newEducationMission.EducationMissionID = Guid.NewGuid(); newEducationMission.ClassName = coursematerial.CourseName + "-" + classmajor.Name; newEducationMission.SchoolyearID = executablePlanView.SchoolyearID; newEducationMission.CollegeID = executablePlanView.CollegeID; newEducationMission.DepartmentID = executablePlanView.DepartmentID; SetNewStatus(newEducationMission); newEducationMissionInList.Add(newEducationMission); foreach (var epTeachingMode in epTeachingModeList) { var newEducationMissionClass = new EM_EducationMissionClass(); newEducationMissionClass.EducationMissionClassID = Guid.NewGuid(); newEducationMissionClass.EducationMissionID = newEducationMission.EducationMissionID; newEducationMissionClass.MainScheduleClassID = classmajor.ClassmajorID; newEducationMissionClass.OptionalCourseTypeID = executablePlanView.SourceTypeID; newEducationMissionClass.OrderNo = classmajor.ClassNum ?? 1; newEducationMissionClass.Name = coursematerial.CourseName + "-" + classmajor.Name + "-(" + epTeachingMode.Name + ")"; newEducationMissionClass.CoursematerialID = executablePlanView.CoursematerialID; newEducationMissionClass.CourseStructureID = executablePlanView.CourseStructureID; newEducationMissionClass.CourseCategoryID = executablePlanView.CourseCategoryID; newEducationMissionClass.CourseTypeID = executablePlanView.CourseTypeID; newEducationMissionClass.CourseQualityID = executablePlanView.CourseQualityID; newEducationMissionClass.ClassroomTypeID = null; newEducationMissionClass.ClassroomID = null; newEducationMissionClass.IsNeedMaterial = executablePlanView.IsNeedMaterial; newEducationMissionClass.TeachinglanguageID = executablePlanView.TeachinglanguageID; newEducationMissionClass.ExaminationModeID = executablePlanView.ExaminationModeID; newEducationMissionClass.ResultTypeID = executablePlanView.ResultTypeID; newEducationMissionClass.HandleModeID = executablePlanView.HandleModeID; newEducationMissionClass.TeachingModeID = epTeachingMode.Value; newEducationMissionClass.Remark = coursematerial.CourseName + "-" + classmajor.Name + "-(" + epTeachingMode.Name + ")"; SetNewStatus(newEducationMissionClass, (int)EM_EducationMissionClassStatus.NotSubmitted); newEducationMissionClassInList.Add(newEducationMissionClass); var newEduTeachingSetting = new EM_EducationMissionClassTeachingSetting(); newEduTeachingSetting.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID; newEduTeachingSetting.Credit = executablePlanView.Credit; newEduTeachingSetting.TheoryCourse = executablePlanView.TheoryCourse; newEduTeachingSetting.Practicehours = executablePlanView.Practicehours; newEduTeachingSetting.Trialhours = executablePlanView.Trialhours; newEduTeachingSetting.TheoryWeeklyNum = executablePlanView.TheoryWeeklyNum; newEduTeachingSetting.PracticeWeeklyNum = executablePlanView.PracticeWeeklyNum; newEduTeachingSetting.TrialWeeklyNum = executablePlanView.TrialWeeklyNum; newEduTeachingSetting.WeeklyHours = executablePlanView.WeeklyHours; newEduTeachingSetting.WeeklyNum = executablePlanView.WeeklyNum; newEduTeachingSetting.StartWeeklyNum = executablePlanView.StartWeeklyNum; newEduTeachingSetting.EndWeeklyNum = executablePlanView.EndWeeklyNum; newEduTeachingSettingInList.Add(newEduTeachingSetting); newEducationMissionClass.CF_Classmajor = new HashSet(); newEducationMissionClass.CF_Classmajor.Add(classmajor); var newEducationSchedulingClass = new EM_EducationSchedulingClass(); newEducationSchedulingClass.EducationSchedulingClassID = Guid.NewGuid(); newEducationSchedulingClass.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID; newEducationSchedulingClass.TaskGroupName = "1组"; newEducationSchedulingClass.Remark = classmajor.Name; SetNewStatus(newEducationSchedulingClass); newEducationSchedulingClassInList.Add(newEducationSchedulingClass); newEducationSchedulingClass.CF_Student = new HashSet(); var newStudent = studentList.Where(x => x.ClassmajorID == classmajor.ClassmajorID && inschoolStatusList.Contains(x.InSchoolStatusID)).ToList(); newStudent.ForEach(x => newEducationSchedulingClass.CF_Student.Add(x)); for (int i = 0; i < executablePlanView.EndWeeklyNum; i++) { var newEduSettings = new EM_EducationMissionClassSettings(); newEduSettings.EducationMissionClassSettingsID = Guid.NewGuid(); newEduSettings.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID; newEduSettings.WeeklyNum = i + 1; SetNewStatus(newEduSettings); newEduSettingsInList.Add(newEduSettings); var newCourseProcess = new EM_CourseProcess(); newCourseProcess.CourseProcessID = Guid.NewGuid(); newCourseProcess.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID; newCourseProcess.Week = i + 1; newCourseProcess.Times = executablePlanView.WeeklyHours; newCourseProcessInList.Add(newCourseProcess); } } } } } else { //表示执行计划对应的学生范围不存在(小于等于0) //throw new Exception("执行计划对应的学生范围不存在(小于等于0),请核查。"); } } else { //表示执行计划对应的计划范围不存在(小于等于0) //throw new Exception("执行计划对应的计划范围不存在(小于等于0),请核查。"); } } else { //表示未提交 //暂不考虑对相关教学任务信息的处理 } } } else { //表示新增 var newExecutablePlan = new EM_ExecutablePlan(); newExecutablePlan.ExecutablePlanID = Guid.NewGuid(); newExecutablePlan.SourceTypeID = executablePlanView.SourceTypeID; newExecutablePlan.DefaultClassName = coursematerial.CourseName + "-" + grademajor.Name; if (specialtyPlan == null) { newExecutablePlan.SpecialtyPlanID = null; } else { newExecutablePlan.SpecialtyPlanID = specialtyPlan.SpecialtyPlanID; } newExecutablePlan.SchoolyearID = executablePlanView.SchoolyearID; newExecutablePlan.GrademajorID = executablePlanView.GrademajorID; newExecutablePlan.CoursematerialID = executablePlanView.CoursematerialID; newExecutablePlan.CourseStructureID = executablePlanView.CourseStructureID; newExecutablePlan.CourseCategoryID = executablePlanView.CourseCategoryID; newExecutablePlan.CourseTypeID = executablePlanView.CourseTypeID; newExecutablePlan.CourseQualityID = executablePlanView.CourseQualityID; newExecutablePlan.DepartmentID = executablePlanView.DepartmentID; newExecutablePlan.IsNeedMaterial = executablePlanView.IsNeedMaterial; newExecutablePlan.ResultTypeID = executablePlanView.ResultTypeID; newExecutablePlan.HandleModeID = executablePlanView.HandleModeID; newExecutablePlan.Remark = executablePlanView.Remark; SetNewStatus(newExecutablePlan, (int)EM_ExecuteStatus.NotSubmited); newExecutablePlanInList.Add(newExecutablePlan); var newProfile = new EM_ExecutablePlanProfile(); newProfile.ExecutablePlanID = newExecutablePlan.ExecutablePlanID; newProfile.IsSpecialtycore = executablePlanView.IsSpecialtycore; newProfile.IsCooperation = executablePlanView.IsCooperation; newProfile.IsRequired = executablePlanView.IsRequired; newProfile.IsElective = executablePlanView.IsElective; newProfile.IsNetworkCourse = executablePlanView.IsNetworkCourse; newProfile.IsMainCourse = executablePlanView.IsMainCourse; newProfile.CourseFineID = executablePlanView.CourseFineID; newProfile.PracticeTypeID = executablePlanView.PracticeTypeID; newProfile.TeachinglanguageID = executablePlanView.TeachinglanguageID; newProfile.ExaminationModeID = executablePlanView.ExaminationModeID; SetNewStatus(newProfile); newProfileInList.Add(newProfile); var newEPTeachingSetting = new EM_ExecutablePlanTeachingSetting(); newEPTeachingSetting.ExecutablePlanID = newExecutablePlan.ExecutablePlanID; newEPTeachingSetting.Credit = executablePlanView.Credit; newEPTeachingSetting.TheoryCourse = executablePlanView.TheoryCourse; newEPTeachingSetting.Practicehours = executablePlanView.Practicehours; newEPTeachingSetting.Trialhours = executablePlanView.Trialhours; newEPTeachingSetting.TheoryWeeklyNum = executablePlanView.TheoryWeeklyNum; newEPTeachingSetting.PracticeWeeklyNum = executablePlanView.PracticeWeeklyNum; newEPTeachingSetting.TrialWeeklyNum = executablePlanView.TrialWeeklyNum; newEPTeachingSetting.WeeklyHours = executablePlanView.WeeklyHours; newEPTeachingSetting.WeeklyNum = executablePlanView.WeeklyNum; newEPTeachingSetting.StartWeeklyNum = executablePlanView.StartWeeklyNum; newEPTeachingSetting.EndWeeklyNum = executablePlanView.EndWeeklyNum; newEPTeachingSettingInList.Add(newEPTeachingSetting); if (executablePlanView.TeachingModeIDList != null && executablePlanView.TeachingModeIDList.Count() > 0) { foreach (var newModeType in executablePlanView.TeachingModeIDList.ToList()) { var newEPTeachingModeType = new EM_ExecutablePlanTeachingModeType(); newEPTeachingModeType.ExecutablePlanTeachingModeTypeID = Guid.NewGuid(); newEPTeachingModeType.ExecutablePlanID = newExecutablePlan.ExecutablePlanID; newEPTeachingModeType.TeachingModeID = newModeType; this.SetNewStatus(newEPTeachingModeType); newEPTeachingModeTypeInList.Add(newEPTeachingModeType); } } if (executablePlanView.TeachingPlaceIDList != null && executablePlanView.TeachingPlaceIDList.Count() > 0) { foreach (var newPlace in executablePlanView.TeachingPlaceIDList.ToList()) { var newEPTeachingPlace = new EM_ExecutablePlanTeachingPlace(); newEPTeachingPlace.ExecutablePlanTeachingPlaceID = Guid.NewGuid(); newEPTeachingPlace.ExecutablePlanID = newExecutablePlan.ExecutablePlanID; newEPTeachingPlace.TeachingPlace = newPlace; this.SetNewStatus(newEPTeachingPlace); newEPTeachingPlaceInList.Add(newEPTeachingPlace); } } //对应的教学任务信息更新(根据业务主键:学年学期ID、课程信息ID、班级信息ID、排课任务班ID或教学任务班ID) //注:由于相关业务主键冗余,目前不允许修改相关业务主键 //暂不考虑对相关教学任务信息的处理 } //事务提交 //UnitOfWork.Commit(); using (TransactionScope ts = new TransactionScope()) { //删除 UnitOfWork.Delete(x => executablePlanTPDelList.Contains(x.ExecutablePlanID)); UnitOfWork.Delete(x => executablePlanTMDelList.Contains(x.ExecutablePlanID)); //批量插入 UnitOfWork.BulkInsert(newExecutablePlanInList); UnitOfWork.BulkInsert(newProfileInList); UnitOfWork.BulkInsert(newEPTeachingSettingInList); UnitOfWork.BulkInsert(newEPTeachingModeTypeInList); UnitOfWork.BulkInsert(newEPTeachingPlaceInList); //批量统一提交更新 if (newExecutablePlanUpList != null && newExecutablePlanUpList.Count() > 0) { UnitOfWork.BatchUpdate(newExecutablePlanUpList); } //批量统一提交更新 if (newProfileUpList != null && newProfileUpList.Count() > 0) { UnitOfWork.BatchUpdate(newProfileUpList); } //批量统一提交更新 if (newEPTeachingSettingUpList != null && newEPTeachingSettingUpList.Count() > 0) { UnitOfWork.BatchUpdate(newEPTeachingSettingUpList); } //批量插入 UnitOfWork.BulkInsert(newEducationMissionInList); UnitOfWork.BulkInsert(newEducationMissionClassInList); UnitOfWork.BulkInsert(newEduTeachingSettingInList); UnitOfWork.BulkInsert(newEducationMissionClassInList, (x => x.CF_Classmajor)); UnitOfWork.BulkInsert(newEducationSchedulingClassInList); UnitOfWork.BulkInsert(newEducationSchedulingClassInList, (x => x.CF_Student)); UnitOfWork.BulkInsert(newEduSettingsInList); UnitOfWork.BulkInsert(newCourseProcessInList); //批量统一提交更新 if (newEducationMissionUpList != null && newEducationMissionUpList.Count() > 0) { UnitOfWork.BatchUpdate(newEducationMissionUpList); } //批量统一提交更新 if (newEducationMissionClassUpList != null && newEducationMissionClassUpList.Count() > 0) { UnitOfWork.BatchUpdate(newEducationMissionClassUpList); } //批量统一提交更新 if (newEduTeachingSettingUpList != null && newEduTeachingSettingUpList.Count() > 0) { UnitOfWork.BatchUpdate(newEduTeachingSettingUpList); } ts.Complete(); } } else { throw new Exception("已存在相同的执行计划信息(学年学期、年级专业、课程信息唯一),请核查。"); } } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 根据专业计划信息批量新增 /// 注:区分普教版本(年级专业)、成教版本(入学学年学期、专业信息) /// 注:此为成教版本(入学学年学期、专业信息) /// 注:此版本学生人数小于等于0时,不可生成对应的执行计划 /// /// /// /// public override string ExecutablePlanBatchAdd(List specialtyPlanViewList, ExecutablePlanView executablePlanView) { try { //查询专业计划对应的年级专业grademajorIDList var grademajorIDList = specialtyPlanViewList.Select(x => x.GrademajorID).Distinct().ToList(); //查询对应的执行计划信息executablePlanList(暂时只匹配年级专业ID) var executablePlanList = ExecutablePlanDAL.ExecutablePlanRepository .GetList(x => grademajorIDList.Contains(x.GrademajorID), (x => x.EM_ExecutablePlanTeachingSetting)).ToList(); int success = 0; //成功 int fail = 0; //失败 string tipMessage = null; //提示消息 List newExecutablePlanInList = new List(); List newProfileInList = new List(); List newTeachingSettingInList = new List(); List newTeachingModeTypeInList = new List(); List newTeachingPlaceInList = new List(); foreach (var specialtyPlanView in specialtyPlanViewList) { //判断对应的学年学期信息 if (specialtyPlanView.Value < specialtyPlanView.StartValue) { //表示学年学期小于入学学年学期 fail++; } else { if (specialtyPlanView.Value > specialtyPlanView.GraduatingSemesterValue) { //表示学年学期大于毕业学年学期 fail++; } else { //判断对应的学生人数 if (specialtyPlanView.StudentCount <= 0) { //表示学生人数小于等于0 fail++; } else { //查询对应的执行计划信息(根据业务主键:学年学期ID、年级专业ID、课程信息ID) var executablePlan = executablePlanList.Where(x => x.SchoolyearID == specialtyPlanView.SchoolyearID && x.GrademajorID == specialtyPlanView.GrademajorID && x.CoursematerialID == specialtyPlanView.CoursematerialID).SingleOrDefault(); if (executablePlan == null) { //表示新增 var newExecutablePlan = new EM_ExecutablePlan(); newExecutablePlan.ExecutablePlanID = Guid.NewGuid(); //来源专业计划默认为必修课 newExecutablePlan.SourceTypeID = (int)EM_SourceType.RequiredCourse; newExecutablePlan.DefaultClassName = specialtyPlanView.CourseName + "-" + specialtyPlanView.GrademajorName; newExecutablePlan.SpecialtyPlanID = specialtyPlanView.SpecialtyPlanID; newExecutablePlan.SchoolyearID = specialtyPlanView.SchoolyearID; newExecutablePlan.GrademajorID = specialtyPlanView.GrademajorID; newExecutablePlan.CoursematerialID = specialtyPlanView.CoursematerialID; newExecutablePlan.CourseStructureID = specialtyPlanView.CourseStructureID; newExecutablePlan.CourseCategoryID = specialtyPlanView.CourseCategoryID; newExecutablePlan.CourseTypeID = specialtyPlanView.CourseTypeID; newExecutablePlan.CourseQualityID = specialtyPlanView.CourseQualityID; newExecutablePlan.DepartmentID = specialtyPlanView.DepartmentID; newExecutablePlan.IsNeedMaterial = specialtyPlanView.IsNeedMaterial; newExecutablePlan.ResultTypeID = specialtyPlanView.ResultTypeID; newExecutablePlan.HandleModeID = specialtyPlanView.HandleModeID; newExecutablePlan.Remark = specialtyPlanView.Remark; SetNewStatus(newExecutablePlan, (int)EM_ExecuteStatus.NotSubmited); newExecutablePlanInList.Add(newExecutablePlan); var newProfile = new EM_ExecutablePlanProfile(); newProfile.ExecutablePlanID = newExecutablePlan.ExecutablePlanID; newProfile.IsSpecialtycore = specialtyPlanView.IsSpecialtycore; newProfile.IsCooperation = specialtyPlanView.IsCooperation; newProfile.IsRequired = specialtyPlanView.IsRequired; newProfile.IsElective = specialtyPlanView.IsElective; newProfile.IsNetworkCourse = specialtyPlanView.IsNetworkCourse; newProfile.IsMainCourse = specialtyPlanView.IsMainCourse; newProfile.CourseFineID = specialtyPlanView.CourseFineID; newProfile.PracticeTypeID = specialtyPlanView.PracticeTypeID; newProfile.TeachinglanguageID = specialtyPlanView.TeachinglanguageID; newProfile.ExaminationModeID = specialtyPlanView.ExaminationModeID; SetNewStatus(newProfile); newProfileInList.Add(newProfile); var newTeachingSetting = new EM_ExecutablePlanTeachingSetting(); newTeachingSetting.ExecutablePlanID = newExecutablePlan.ExecutablePlanID; newTeachingSetting.Credit = specialtyPlanView.Credit; newTeachingSetting.TheoryCourse = specialtyPlanView.TheoryCourse; newTeachingSetting.Practicehours = specialtyPlanView.Practicehours; newTeachingSetting.Trialhours = specialtyPlanView.Trialhours; newTeachingSetting.TheoryWeeklyNum = specialtyPlanView.TheoryWeeklyNum; newTeachingSetting.PracticeWeeklyNum = specialtyPlanView.PracticeWeeklyNum; newTeachingSetting.TrialWeeklyNum = specialtyPlanView.TrialWeeklyNum; newTeachingSetting.WeeklyHours = specialtyPlanView.WeeklyHours; newTeachingSetting.WeeklyNum = specialtyPlanView.WeeklyNum; newTeachingSetting.StartWeeklyNum = specialtyPlanView.StartWeeklyNum; newTeachingSetting.EndWeeklyNum = specialtyPlanView.EndWeeklyNum; newTeachingSettingInList.Add(newTeachingSetting); if (specialtyPlanView.TeachingModeIDList != null && specialtyPlanView.TeachingModeIDList.Count() > 0) { foreach (var newModeType in specialtyPlanView.TeachingModeIDList.ToList()) { var newTeachingModeType = new EM_ExecutablePlanTeachingModeType(); newTeachingModeType.ExecutablePlanTeachingModeTypeID = Guid.NewGuid(); newTeachingModeType.ExecutablePlanID = newExecutablePlan.ExecutablePlanID; newTeachingModeType.TeachingModeID = newModeType; this.SetNewStatus(newTeachingModeType); newTeachingModeTypeInList.Add(newTeachingModeType); } } if (specialtyPlanView.TeachingPlaceIDList != null && specialtyPlanView.TeachingPlaceIDList.Count() > 0) { foreach (var newPlace in specialtyPlanView.TeachingPlaceIDList.ToList()) { var newTeachingPlace = new EM_ExecutablePlanTeachingPlace(); newTeachingPlace.ExecutablePlanTeachingPlaceID = Guid.NewGuid(); newTeachingPlace.ExecutablePlanID = newExecutablePlan.ExecutablePlanID; newTeachingPlace.TeachingPlace = newPlace; this.SetNewStatus(newTeachingPlace); newTeachingPlaceInList.Add(newTeachingPlace); } } success++; } else { //表示已存在相同的执行计划信息 fail++; } } } } } //事务提交 using (TransactionScope ts = new TransactionScope()) { //批量插入 UnitOfWork.BulkInsert(newExecutablePlanInList); UnitOfWork.BulkInsert(newProfileInList); UnitOfWork.BulkInsert(newTeachingSettingInList); UnitOfWork.BulkInsert(newTeachingModeTypeInList); UnitOfWork.BulkInsert(newTeachingPlaceInList); ts.Complete(); } if (success > 0 && fail <= 0) { tipMessage = success + "条"; } else { tipMessage = success + "条,失败" + fail + "条,原因:学生人数等于0、学年学期小于入学学年学期、学年学期大于毕业学年学期或已存在相同的执行计划信息,请检查"; } return tipMessage; } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 查询对应的未新增专业计划信息SpecialtyPlanView /// 注:区分普教版本(年级专业)、成教版本(入学学年学期、专业信息) /// 注:此为成教版本(入学学年学期、专业信息) /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// public override IGridResultSet GetSpecialtyPlanViewNoAddGrid(ConfiguretView configuretView, Guid? schoolyearID, Guid? campusID, Guid? collegeID, int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem, Guid? grademajorID, Guid? coursematerialID, int? teachingModeID, int? handleModeID, int pageIndex, int pageSize) { //年级专业 Expression> expGrademajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (yearID.HasValue) { expGrademajor = expGrademajor.And(x => x.GradeID == yearID); } if (grademajorID.HasValue) { expGrademajor = expGrademajor.And(x => x.GrademajorID == grademajorID); } //专业计划 Expression> expSpecialtyPlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (schoolyearID.HasValue) { expSpecialtyPlan = expSpecialtyPlan.And(x => x.SchoolyearID == schoolyearID); } if (coursematerialID.HasValue) { expSpecialtyPlan = expSpecialtyPlan.And(x => x.CoursematerialID == coursematerialID); } if (handleModeID.HasValue) { expSpecialtyPlan = expSpecialtyPlan.And(x => x.HandleModeID == handleModeID); } //学生信息 Expression> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); //执行计划 Expression> expExecutablePlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (schoolyearID.HasValue) { expExecutablePlan = expExecutablePlan.And(x => x.SchoolyearID == schoolyearID); } if (grademajorID.HasValue) { expExecutablePlan = expExecutablePlan.And(x => x.GrademajorID == grademajorID); } if (coursematerialID.HasValue) { expExecutablePlan = expExecutablePlan.And(x => x.CoursematerialID == coursematerialID); } var query = ExecutablePlanDAL.GetAdultSpecialtyPlanViewNoAddQueryable(expGrademajor, expSpecialtyPlan, expStudent, expExecutablePlan); if (campusID.HasValue) { query = query.Where(x => x.CampusID == campusID); } if (collegeID.HasValue) { query = query.Where(x => x.CollegeID == collegeID); } if (standardID.HasValue) { query = query.Where(x => x.StandardID == standardID); } if (educationID.HasValue) { query = query.Where(x => x.EducationID == educationID); } if (learningformID.HasValue) { query = query.Where(x => x.LearningformID == learningformID); } if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1") { var LearnSystems = Convert.ToDecimal(learnSystem); query = query.Where(x => x.LearnSystem == LearnSystems); } if (teachingModeID.HasValue) { //授课方式 query = query.Where(x => x.TeachingModeIDList.Contains(teachingModeID)); } //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return this.GetQueryByDataRangeByCollege(query) .OrderBy(x => x.GrademajorCode.Length).ThenBy(x => x.GrademajorCode) .ThenBy(x => x.Value).ThenBy(x => x.CourseTypeID) .ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode) .ToGridResultSet(pageIndex, pageSize); } /// /// 查询对应的未新增专业计划信息List /// 注:区分普教版本(年级专业)、成教版本(入学学年学期、专业信息) /// 注:此为成教版本(入学学年学期、专业信息) /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// public override IList GetSpecialtyPlanViewNoAddList(ConfiguretView configuretView, Guid? schoolyearID, Guid? campusID, Guid? collegeID, int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem, Guid? grademajorID, Guid? coursematerialID, int? teachingModeID, int? handleModeID) { //年级专业 Expression> expGrademajor = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (yearID.HasValue) { expGrademajor = expGrademajor.And(x => x.GradeID == yearID); } if (grademajorID.HasValue) { expGrademajor = expGrademajor.And(x => x.GrademajorID == grademajorID); } //专业计划 Expression> expSpecialtyPlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (schoolyearID.HasValue) { expSpecialtyPlan = expSpecialtyPlan.And(x => x.SchoolyearID == schoolyearID); } if (coursematerialID.HasValue) { expSpecialtyPlan = expSpecialtyPlan.And(x => x.CoursematerialID == coursematerialID); } if (handleModeID.HasValue) { expSpecialtyPlan = expSpecialtyPlan.And(x => x.HandleModeID == handleModeID); } //学生信息 Expression> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); //执行计划 Expression> expExecutablePlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (schoolyearID.HasValue) { expExecutablePlan = expExecutablePlan.And(x => x.SchoolyearID == schoolyearID); } if (grademajorID.HasValue) { expExecutablePlan = expExecutablePlan.And(x => x.GrademajorID == grademajorID); } if (coursematerialID.HasValue) { expExecutablePlan = expExecutablePlan.And(x => x.CoursematerialID == coursematerialID); } var query = ExecutablePlanDAL.GetAdultSpecialtyPlanViewNoAddQueryable(expGrademajor, expSpecialtyPlan, expStudent, expExecutablePlan); if (campusID.HasValue) { query = query.Where(x => x.CampusID == campusID); } if (collegeID.HasValue) { query = query.Where(x => x.CollegeID == collegeID); } if (standardID.HasValue) { query = query.Where(x => x.StandardID == standardID); } if (educationID.HasValue) { query = query.Where(x => x.EducationID == educationID); } if (learningformID.HasValue) { query = query.Where(x => x.LearningformID == learningformID); } if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1") { var LearnSystems = Convert.ToDecimal(learnSystem); query = query.Where(x => x.LearnSystem == LearnSystems); } if (teachingModeID.HasValue) { //授课方式 query = query.Where(x => x.TeachingModeIDList.Contains(teachingModeID)); } //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return this.GetQueryByDataRangeByCollege(query) .OrderBy(x => x.GrademajorCode.Length).ThenBy(x => x.GrademajorCode) .ThenBy(x => x.Value).ThenBy(x => x.CourseTypeID) .ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode).ToList(); } /// /// 执行计划提交 /// 注:刷新相关的教学任务信息 /// 注:区分普教版本(年级专业)、成教版本(入学学年学期、专业信息) /// 注:此为成教版本(入学学年学期、专业信息) /// 注:此版本学生人数小于等于0时,不可提交,但由于有异动的情况,需进一步优化逻辑(对教学任务班学生名单进行判断) /// /// /// public override string ExecutablePlanSubmit(List executablePlanIDList) { try { //教学任务班生成规则如下: //1、对应的授课方式为必选项且可多选; //2、课程信息对应的上课类型为空时,默认只生成一种类型的教学任务班(授课方式为最小Value授课方式); //3、以上课类型为标准,匹配对应的授课方式来生成教学任务班; //4、根据授课方式与上课类型查询是否分班情况,存在分班情况,则生成对应的教学任务班; //5、对应的授课方式存在分班情况时,默认生成成绩合并录入形式的教学任务班(同一条教学任务); //6、年级专业对应的计划范围不于等于0时,不生成对应的教学任务班(无法生成); //7、年级专业对应的学生人数小于等于0时,不生成对应的教学任务班(成教版本有此逻辑); //8、如对应的年级专业有多个班级,都生成对应的教学任务班(只取在校状态为在校的学生信息); //查询对应的执行计划信息executablePlanViewList var executablePlanViewList = ExecutablePlanDAL.GetExecutablePlanViewQueryable(x => executablePlanIDList.Contains(x.ExecutablePlanID)).ToList(); //查询对应的年级专业IDList var grademajorIDList = executablePlanViewList.Select(x => x.GrademajorID).Distinct().ToList(); //查询对应的班级范围信息classmajorList var classmajorList = ExecutablePlanDAL.GetClassmajorRangeQueryable(x => grademajorIDList.Contains(x.GrademajorID)).ToList(); //查询对应的学生范围信息studentList var studentList = ExecutablePlanDAL.GetStudentRangeQueryable(x => grademajorIDList.Contains(x.GrademajorID)).ToList(); //查询对应在校状态IDList var inschoolStatusList = InSchoolSettingServices.Value.GetInschoolStatusList(true); //查询对应的教学任务班信息(业务主键:学年学期ID、课程信息ID、班级信息ID、教学任务班ID或排课任务班ID) var educationMissionClassList = ExecutablePlanDAL.GetEducationMissionClassQueryable(x => executablePlanIDList.Contains(x.ExecutablePlanID)).ToList(); //查询授课方式teachingModeList var teachingModeList = DictionaryHelper.GetDictionaryValue(EMIS.ViewModel.DictionaryItem.CF_TeachingMode).ToList(); int success = 0; //成功 int fail = 0; //失败 bool isEpPass = true; //提交成功判断标识 string tipMessage = null; //提示消息 List newEducationMissionInList = new List(); List newEducationMissionUpList = new List(); List newEducationMissionClassInList = new List(); List newEducationMissionClassUpList = new List(); List newEduTeachingSettingInList = new List(); List newEduTeachingSettingUpList = new List(); List newEducationSchedulingClassInList = new List(); List newEduSettingsInList = new List(); List newCourseProcessInList = new List(); List executablePlanIDUpList = new List(); foreach (var executablePlanView in executablePlanViewList) { //执行计划对应的授课方式判断 if (executablePlanView.TeachingModeIDList != null && executablePlanView.TeachingModeIDList.Count() > 0) { //查询对应的班级范围信息epClassmajorList var epClassmajorList = classmajorList.Where(x => x.GrademajorID == executablePlanView.GrademajorID).ToList(); //执行计划对应的计划范围判断 if (epClassmajorList != null && epClassmajorList.Count() > 0) { //查询对应的班级信息epClassmajorIDList var epClassmajorIDList = epClassmajorList.Select(x => x.ClassmajorID).ToList(); //查询对应的学生范围信息studentList var epStudentList = studentList.Where(x => epClassmajorIDList.Contains(x.ClassmajorID.Value)).ToList(); //执行计划对应的学生范围判断 if (epStudentList != null && epStudentList.Count() > 0) { //查询对应的课程信息中授课方式分班信息List var separateModeTypeList = ExecutablePlanDAL.GetSeparateModeTypeQueryble(x => x.CoursematerialID == executablePlanView.CoursematerialID).ToList(); //查询执行计划中授课方式及对应的上课类型中的授课方式(匹配上课类型) var minTeachingModeID = executablePlanView.TeachingModeIDList .Where(x => !separateModeTypeList.Contains(x)).OrderBy(x => x).FirstOrDefault(); List teachingModeIDList = new List(); if (minTeachingModeID != null) { teachingModeIDList.Add(minTeachingModeID); teachingModeIDList = teachingModeIDList.Concat(executablePlanView.TeachingModeIDList .Where(x => separateModeTypeList.Contains(x))).GroupBy(x => x).Select(x => x.Key).ToList(); } else { teachingModeIDList = executablePlanView.TeachingModeIDList .Where(x => separateModeTypeList.Contains(x)).GroupBy(x => x).Select(x => x.Key).ToList(); } //查询对应的授课方式信息List(匹配上课类型) var epTeachingModeList = teachingModeList.Where(x => teachingModeIDList.Contains(x.Value)).ToList(); //查询对应的教学任务信息(业务主键:学年学期ID、课程信息ID、班级信息ID、排课任务班ID或教学任务班ID) var epEducationMissionClassList = educationMissionClassList .Where(x => x.EM_EducationMission.SchoolyearID == executablePlanView.SchoolyearID && x.CoursematerialID == executablePlanView.CoursematerialID && x.CF_Classmajor.Any(w => epClassmajorIDList.Contains(w.ClassmajorID))).ToList(); foreach (var classmajor in epClassmajorList) { //查询班级信息对应的教学任务班信息List var educlList = epEducationMissionClassList.Where(x => x.CF_Classmajor .Any(w => w.ClassmajorID == classmajor.ClassmajorID)).ToList(); if (educlList != null && educlList.Count() > 0) { //表示存在对应的教学任务班 //根据教学任务ID对educlList进行分组 var edugrList = educlList.GroupBy(x => x.EducationMissionID).ToList(); //根据授课方式对educlList进行分组 var tmgrList = educlList.GroupBy(x => x.TeachingModeID).ToList(); if (edugrList.Count() > 1 && tmgrList.Count() > 1) { //表示对应的教学任务班存在分班且成绩分开录入、授课方式多种情况 //目前此种数据有误,在生成期末设定时有问题(这里暂不处理) isEpPass = false; //终止此循环,提交下一个执行计划信息 break; } else if (edugrList.Count() > 1 && epTeachingModeList.Count() > 1) { //表示对应的教学任务班存在分班且成绩分开录入、授课方式只有一种情况,不可再生成多种授课方式的教学任务班信息 //目前此种数据有误,在生成期末设定时有问题 isEpPass = false; //终止此循环,提交下一个执行计划信息 break; } else if (tmgrList.Count() == 1 && epTeachingModeList.Count() == 1) { //表示对应的教学任务班只存在一种授课方式信息(含分班且成绩合并或分开录入) //同时生成的教学任务班信息授课方式只有一种的情况(直接修改) foreach (var educl in educlList) { if (!newEducationMissionUpList.Any(x => x.EducationMissionID == educl.EducationMissionID)) { educl.EM_EducationMission.ClassName = executablePlanView.CourseName + "-" + classmajor.Name; educl.EM_EducationMission.SchoolyearID = executablePlanView.SchoolyearID; educl.EM_EducationMission.CollegeID = executablePlanView.CollegeID; educl.EM_EducationMission.DepartmentID = executablePlanView.DepartmentID; SetModifyStatus(educl.EM_EducationMission); newEducationMissionUpList.Add(educl.EM_EducationMission); } if (!newEducationMissionClassUpList.Any(x => x.EducationMissionClassID == educl.EducationMissionClassID)) { educl.OptionalCourseTypeID = executablePlanView.SourceTypeID; educl.CoursematerialID = executablePlanView.CoursematerialID; educl.CourseStructureID = executablePlanView.CourseStructureID; educl.CourseCategoryID = executablePlanView.CourseCategoryID; educl.CourseTypeID = executablePlanView.CourseTypeID; educl.CourseQualityID = executablePlanView.CourseQualityID; educl.IsNeedMaterial = executablePlanView.IsNeedMaterial; educl.TeachinglanguageID = executablePlanView.TeachinglanguageID; educl.ExaminationModeID = executablePlanView.ExaminationModeID; educl.ResultTypeID = executablePlanView.ResultTypeID; educl.HandleModeID = executablePlanView.HandleModeID; educl.TeachingModeID = epTeachingModeList[0].Value; SetModifyStatus(educl); newEducationMissionClassUpList.Add(educl); } if (!newEduTeachingSettingUpList.Any(x => x.EducationMissionClassID == educl.EducationMissionClassID)) { educl.EM_EducationMissionClassTeachingSetting.Credit = executablePlanView.Credit; educl.EM_EducationMissionClassTeachingSetting.TheoryCourse = executablePlanView.TheoryCourse; educl.EM_EducationMissionClassTeachingSetting.Practicehours = executablePlanView.Practicehours; educl.EM_EducationMissionClassTeachingSetting.Trialhours = executablePlanView.Trialhours; //if (educl.RecordStatus != (int)EM_EducationMissionClassStatus.Submitted || educl.RecordStatus != (int)EM_EducationMissionClassStatus.Scheduled) //{ // //暂不考虑 // educl.EM_EducationMissionClassTeachingSetting.TheoryWeeklyNum = executablePlanView.TheoryWeeklyNum; // educl.EM_EducationMissionClassTeachingSetting.PracticeWeeklyNum = executablePlanView.PracticeWeeklyNum; // educl.EM_EducationMissionClassTeachingSetting.TrialWeeklyNum = executablePlanView.TrialWeeklyNum; // educl.EM_EducationMissionClassTeachingSetting.WeeklyHours = executablePlanView.WeeklyHours; // educl.EM_EducationMissionClassTeachingSetting.WeeklyNum = executablePlanView.WeeklyNum; // educl.EM_EducationMissionClassTeachingSetting.StartWeeklyNum = executablePlanView.StartWeeklyNum; // educl.EM_EducationMissionClassTeachingSetting.EndWeeklyNum = executablePlanView.EndWeeklyNum; //} newEduTeachingSettingUpList.Add(educl.EM_EducationMissionClassTeachingSetting); } } } else { //表示无论分班与否,成绩都是合并录入的情况(同一个教学任务ID) //表示可根据执行计划中匹配上课类型后的授课方式进行增加、修改对应的教学任务班信息 foreach (var educl in educlList) { //修改 if (!newEducationMissionUpList.Any(x => x.EducationMissionID == educl.EducationMissionID)) { educl.EM_EducationMission.ClassName = executablePlanView.CourseName + "-" + classmajor.Name; educl.EM_EducationMission.SchoolyearID = executablePlanView.SchoolyearID; educl.EM_EducationMission.CollegeID = executablePlanView.CollegeID; educl.EM_EducationMission.DepartmentID = executablePlanView.DepartmentID; SetModifyStatus(educl.EM_EducationMission); newEducationMissionUpList.Add(educl.EM_EducationMission); } if (!newEducationMissionClassUpList.Any(x => x.EducationMissionClassID == educl.EducationMissionClassID)) { educl.OptionalCourseTypeID = executablePlanView.SourceTypeID; educl.CoursematerialID = executablePlanView.CoursematerialID; educl.CourseStructureID = executablePlanView.CourseStructureID; educl.CourseCategoryID = executablePlanView.CourseCategoryID; educl.CourseTypeID = executablePlanView.CourseTypeID; educl.CourseQualityID = executablePlanView.CourseQualityID; educl.IsNeedMaterial = executablePlanView.IsNeedMaterial; educl.TeachinglanguageID = executablePlanView.TeachinglanguageID; educl.ExaminationModeID = executablePlanView.ExaminationModeID; educl.ResultTypeID = executablePlanView.ResultTypeID; educl.HandleModeID = executablePlanView.HandleModeID; SetModifyStatus(educl); newEducationMissionClassUpList.Add(educl); } if (!newEduTeachingSettingUpList.Any(x => x.EducationMissionClassID == educl.EducationMissionClassID)) { educl.EM_EducationMissionClassTeachingSetting.Credit = executablePlanView.Credit; educl.EM_EducationMissionClassTeachingSetting.TheoryCourse = executablePlanView.TheoryCourse; educl.EM_EducationMissionClassTeachingSetting.Practicehours = executablePlanView.Practicehours; educl.EM_EducationMissionClassTeachingSetting.Trialhours = executablePlanView.Trialhours; //if (educl.RecordStatus != (int)EM_EducationMissionClassStatus.Submitted || educl.RecordStatus != (int)EM_EducationMissionClassStatus.Scheduled) //{ // //暂不考虑 // educl.EM_EducationMissionClassTeachingSetting.TheoryWeeklyNum = executablePlanView.TheoryWeeklyNum; // educl.EM_EducationMissionClassTeachingSetting.PracticeWeeklyNum = executablePlanView.PracticeWeeklyNum; // educl.EM_EducationMissionClassTeachingSetting.TrialWeeklyNum = executablePlanView.TrialWeeklyNum; // educl.EM_EducationMissionClassTeachingSetting.WeeklyHours = executablePlanView.WeeklyHours; // educl.EM_EducationMissionClassTeachingSetting.WeeklyNum = executablePlanView.WeeklyNum; // educl.EM_EducationMissionClassTeachingSetting.StartWeeklyNum = executablePlanView.StartWeeklyNum; // educl.EM_EducationMissionClassTeachingSetting.EndWeeklyNum = executablePlanView.EndWeeklyNum; //} newEduTeachingSettingUpList.Add(educl.EM_EducationMissionClassTeachingSetting); } } //将执行计划中匹配上课类型后的授课方式与对应的教学任务班的授课方式进行对比 var educltmList = tmgrList.Select(x => x.Key).ToList(); var newTeachingModeList = epTeachingModeList.Where(x => !educltmList.Contains(x.Value)).ToList(); foreach (var newTeachingMode in newTeachingModeList) { //新增 var newEducationMissionClass = new EM_EducationMissionClass(); newEducationMissionClass.EducationMissionClassID = Guid.NewGuid(); newEducationMissionClass.EducationMissionID = edugrList[0].Key; newEducationMissionClass.MainScheduleClassID = classmajor.ClassmajorID; newEducationMissionClass.OptionalCourseTypeID = executablePlanView.SourceTypeID; newEducationMissionClass.OrderNo = classmajor.ClassNum ?? 1; newEducationMissionClass.Name = executablePlanView.CourseName + "-" + classmajor.Name + "-(" + newTeachingMode.Name + ")"; newEducationMissionClass.CoursematerialID = executablePlanView.CoursematerialID; newEducationMissionClass.CourseStructureID = executablePlanView.CourseStructureID; newEducationMissionClass.CourseCategoryID = executablePlanView.CourseCategoryID; newEducationMissionClass.CourseTypeID = executablePlanView.CourseTypeID; newEducationMissionClass.CourseQualityID = executablePlanView.CourseQualityID; newEducationMissionClass.ClassroomTypeID = null; newEducationMissionClass.ClassroomID = null; newEducationMissionClass.IsNeedMaterial = executablePlanView.IsNeedMaterial; newEducationMissionClass.TeachinglanguageID = executablePlanView.TeachinglanguageID; newEducationMissionClass.ExaminationModeID = executablePlanView.ExaminationModeID; newEducationMissionClass.ResultTypeID = executablePlanView.ResultTypeID; newEducationMissionClass.HandleModeID = executablePlanView.HandleModeID; newEducationMissionClass.TeachingModeID = newTeachingMode.Value; newEducationMissionClass.Remark = executablePlanView.CourseName + "-" + classmajor.Name + "-(" + newTeachingMode.Name + ")"; SetNewStatus(newEducationMissionClass, (int)EM_EducationMissionClassStatus.NotSubmitted); newEducationMissionClassInList.Add(newEducationMissionClass); var newEduTeachingSetting = new EM_EducationMissionClassTeachingSetting(); newEduTeachingSetting.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID; newEduTeachingSetting.Credit = executablePlanView.Credit; newEduTeachingSetting.TheoryCourse = executablePlanView.TheoryCourse; newEduTeachingSetting.Practicehours = executablePlanView.Practicehours; newEduTeachingSetting.Trialhours = executablePlanView.Trialhours; newEduTeachingSetting.TheoryWeeklyNum = executablePlanView.TheoryWeeklyNum; newEduTeachingSetting.PracticeWeeklyNum = executablePlanView.PracticeWeeklyNum; newEduTeachingSetting.TrialWeeklyNum = executablePlanView.TrialWeeklyNum; newEduTeachingSetting.WeeklyHours = executablePlanView.WeeklyHours; newEduTeachingSetting.WeeklyNum = executablePlanView.WeeklyNum; newEduTeachingSetting.StartWeeklyNum = executablePlanView.StartWeeklyNum; newEduTeachingSetting.EndWeeklyNum = executablePlanView.EndWeeklyNum; newEduTeachingSettingInList.Add(newEduTeachingSetting); newEducationMissionClass.CF_Classmajor = new HashSet(); newEducationMissionClass.CF_Classmajor.Add(classmajor); var newEducationSchedulingClass = new EM_EducationSchedulingClass(); newEducationSchedulingClass.EducationSchedulingClassID = Guid.NewGuid(); newEducationSchedulingClass.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID; newEducationSchedulingClass.TaskGroupName = "1组"; newEducationSchedulingClass.Remark = classmajor.Name; SetNewStatus(newEducationSchedulingClass); newEducationSchedulingClassInList.Add(newEducationSchedulingClass); newEducationSchedulingClass.CF_Student = new HashSet(); var newStudent = studentList.Where(x => x.ClassmajorID == classmajor.ClassmajorID && inschoolStatusList.Contains(x.InSchoolStatusID)).ToList(); newStudent.ForEach(x => newEducationSchedulingClass.CF_Student.Add(x)); for (int i = 0; i < executablePlanView.EndWeeklyNum; i++) { var newEduSettings = new EM_EducationMissionClassSettings(); newEduSettings.EducationMissionClassSettingsID = Guid.NewGuid(); newEduSettings.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID; newEduSettings.WeeklyNum = i + 1; SetNewStatus(newEduSettings); newEduSettingsInList.Add(newEduSettings); var newCourseProcess = new EM_CourseProcess(); newCourseProcess.CourseProcessID = Guid.NewGuid(); newCourseProcess.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID; newCourseProcess.Week = i + 1; newCourseProcess.Times = executablePlanView.WeeklyHours; newCourseProcessInList.Add(newCourseProcess); } } } } else { //表示不存在对应的教学任务班(新增) var newEducationMission = new EM_EducationMission(); newEducationMission.EducationMissionID = Guid.NewGuid(); newEducationMission.ClassName = executablePlanView.CourseName + "-" + classmajor.Name; newEducationMission.SchoolyearID = executablePlanView.SchoolyearID; newEducationMission.CollegeID = executablePlanView.CollegeID; newEducationMission.DepartmentID = executablePlanView.DepartmentID; SetNewStatus(newEducationMission); newEducationMissionInList.Add(newEducationMission); foreach (var epTeachingMode in epTeachingModeList) { var newEducationMissionClass = new EM_EducationMissionClass(); newEducationMissionClass.EducationMissionClassID = Guid.NewGuid(); newEducationMissionClass.EducationMissionID = newEducationMission.EducationMissionID; newEducationMissionClass.MainScheduleClassID = classmajor.ClassmajorID; newEducationMissionClass.OptionalCourseTypeID = executablePlanView.SourceTypeID; newEducationMissionClass.OrderNo = classmajor.ClassNum ?? 1; newEducationMissionClass.Name = executablePlanView.CourseName + "-" + classmajor.Name + "-(" + epTeachingMode.Name + ")"; newEducationMissionClass.CoursematerialID = executablePlanView.CoursematerialID; newEducationMissionClass.CourseStructureID = executablePlanView.CourseStructureID; newEducationMissionClass.CourseCategoryID = executablePlanView.CourseCategoryID; newEducationMissionClass.CourseTypeID = executablePlanView.CourseTypeID; newEducationMissionClass.CourseQualityID = executablePlanView.CourseQualityID; newEducationMissionClass.ClassroomTypeID = null; newEducationMissionClass.ClassroomID = null; newEducationMissionClass.IsNeedMaterial = executablePlanView.IsNeedMaterial; newEducationMissionClass.TeachinglanguageID = executablePlanView.TeachinglanguageID; newEducationMissionClass.ExaminationModeID = executablePlanView.ExaminationModeID; newEducationMissionClass.ResultTypeID = executablePlanView.ResultTypeID; newEducationMissionClass.HandleModeID = executablePlanView.HandleModeID; newEducationMissionClass.TeachingModeID = epTeachingMode.Value; newEducationMissionClass.Remark = executablePlanView.CourseName + "-" + classmajor.Name + "-(" + epTeachingMode.Name + ")"; SetNewStatus(newEducationMissionClass, (int)EM_EducationMissionClassStatus.NotSubmitted); newEducationMissionClassInList.Add(newEducationMissionClass); var newEduTeachingSetting = new EM_EducationMissionClassTeachingSetting(); newEduTeachingSetting.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID; newEduTeachingSetting.Credit = executablePlanView.Credit; newEduTeachingSetting.TheoryCourse = executablePlanView.TheoryCourse; newEduTeachingSetting.Practicehours = executablePlanView.Practicehours; newEduTeachingSetting.Trialhours = executablePlanView.Trialhours; newEduTeachingSetting.TheoryWeeklyNum = executablePlanView.TheoryWeeklyNum; newEduTeachingSetting.PracticeWeeklyNum = executablePlanView.PracticeWeeklyNum; newEduTeachingSetting.TrialWeeklyNum = executablePlanView.TrialWeeklyNum; newEduTeachingSetting.WeeklyHours = executablePlanView.WeeklyHours; newEduTeachingSetting.WeeklyNum = executablePlanView.WeeklyNum; newEduTeachingSetting.StartWeeklyNum = executablePlanView.StartWeeklyNum; newEduTeachingSetting.EndWeeklyNum = executablePlanView.EndWeeklyNum; newEduTeachingSettingInList.Add(newEduTeachingSetting); newEducationMissionClass.CF_Classmajor = new HashSet(); newEducationMissionClass.CF_Classmajor.Add(classmajor); var newEducationSchedulingClass = new EM_EducationSchedulingClass(); newEducationSchedulingClass.EducationSchedulingClassID = Guid.NewGuid(); newEducationSchedulingClass.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID; newEducationSchedulingClass.TaskGroupName = "1组"; newEducationSchedulingClass.Remark = classmajor.Name; SetNewStatus(newEducationSchedulingClass); newEducationSchedulingClassInList.Add(newEducationSchedulingClass); newEducationSchedulingClass.CF_Student = new HashSet(); var newStudent = studentList.Where(x => x.ClassmajorID == classmajor.ClassmajorID && inschoolStatusList.Contains(x.InSchoolStatusID)).ToList(); newStudent.ForEach(x => newEducationSchedulingClass.CF_Student.Add(x)); for (int i = 0; i < executablePlanView.EndWeeklyNum; i++) { var newEduSettings = new EM_EducationMissionClassSettings(); newEduSettings.EducationMissionClassSettingsID = Guid.NewGuid(); newEduSettings.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID; newEduSettings.WeeklyNum = i + 1; SetNewStatus(newEduSettings); newEduSettingsInList.Add(newEduSettings); var newCourseProcess = new EM_CourseProcess(); newCourseProcess.CourseProcessID = Guid.NewGuid(); newCourseProcess.EducationMissionClassID = newEducationMissionClass.EducationMissionClassID; newCourseProcess.Week = i + 1; newCourseProcess.Times = executablePlanView.WeeklyHours; newCourseProcessInList.Add(newCourseProcess); } } } } } else { //表示执行计划对应的学生范围不存在(小于等于0) isEpPass = false; } } else { //表示执行计划对应的计划范围不存在(小于等于0) isEpPass = false; } } else { //表示执行计划对应的授课方式为空 isEpPass = false; } if (isEpPass) { //表示提交成功 executablePlanIDUpList.Add(executablePlanView.ExecutablePlanID); success++; } else { //表示提交失败 fail++; isEpPass = true; } } //更新提交成功的执行计划的状态 var newExecutablePlanUpList = ExecutablePlanDAL.ExecutablePlanRepository .GetList(x => executablePlanIDUpList.Contains(x.ExecutablePlanID)).ToList(); newExecutablePlanUpList.ForEach(x => { x.RecordStatus = (int)EM_ExecuteStatus.Submited; SetModifyStatus(x); }); using (TransactionScope ts = new TransactionScope()) { //批量插入 UnitOfWork.BulkInsert(newEducationMissionInList); UnitOfWork.BulkInsert(newEducationMissionClassInList); UnitOfWork.BulkInsert(newEduTeachingSettingInList); UnitOfWork.BulkInsert(newEducationMissionClassInList, (x => x.CF_Classmajor)); UnitOfWork.BulkInsert(newEducationSchedulingClassInList); UnitOfWork.BulkInsert(newEducationSchedulingClassInList, (x => x.CF_Student)); UnitOfWork.BulkInsert(newEduSettingsInList); UnitOfWork.BulkInsert(newCourseProcessInList); //批量统一提交更新 if (newEducationMissionUpList != null && newEducationMissionUpList.Count() > 0) { UnitOfWork.BatchUpdate(newEducationMissionUpList); } //批量统一提交更新 if (newEducationMissionClassUpList != null && newEducationMissionClassUpList.Count() > 0) { UnitOfWork.BatchUpdate(newEducationMissionClassUpList); } //批量统一提交更新 if (newEduTeachingSettingUpList != null && newEduTeachingSettingUpList.Count() > 0) { UnitOfWork.BatchUpdate(newEduTeachingSettingUpList); } //批量统一提交更新 if (newExecutablePlanUpList != null && newExecutablePlanUpList.Count() > 0) { UnitOfWork.BatchUpdate(newExecutablePlanUpList); } ts.Complete(); } if (success > 0 && fail <= 0) { tipMessage = success + "条"; } else { //暂时不提示此消息(存在分班且成绩分开录入同时授课方式多种或存在分班且成绩分开录入同时生成多种授课方式的教学任务班信息(请删除后,再提交)) tipMessage = success + "条,失败" + fail + "条,原因:数据有误,请检查(授课方式为空、执行计划范围为0或学生人数为0)"; } return tipMessage; } catch (Exception ex) { throw new Exception(ex.Message); } } } }