using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Linq.Expressions; using Bowin.Common.Linq.Entity; using Bowin.Common.Linq; using EMIS.DataLogic.RetakeManage; using EMIS.Entities; using EMIS.ViewModel; using EMIS.ViewModel.RetakeManage; using EMIS.Utility; using EMIS.CommonLogic.SystemServices; using EMIS.ViewModel.EducationManage; using EMIS.DataLogic.EducationManage; using EMIS.CommonLogic.EducationSchedule; using EMIS.DataLogic.SystemSetting; using EMIS.CommonLogic.RetakeManage.General; using EMIS.ViewModel.UniversityManage.ClassroomManage; using EMIS.DataLogic.EducationSchedule; using System.Transactions; using EMIS.CommonLogic.ScoreManage; using EMIS.CommonLogic.StudentManage.StudentStatistics; namespace EMIS.CommonLogic.RetakeManage.General { public class RetakePlanTaskServices : BaseServices, IRetakePlanTaskServices { public RetakeConditionDAL RetakeConditionDAL { get; set; } public RetakePlanTaskDAL RetakePlanTaskDAL { get; set; } public Lazy IParameterServices { get; set; } public DictionaryItemDAL DictionaryItemDAL { get; set; } public IInSchoolSettingServices InSchoolSettingServices { get; set; } public IRetakeParameterServices IRetakeParameterServices { get; set; } public ClassroomScheduleDAL ClassroomScheduleDAL { get; set; } public Lazy specialityScoreByFinalScoreServices { get; set; } public IRetakePlanStudentApplyServices IRetakePlanStudentApplyServices { get; set; } public RetakePlanResultDAL RetakePlanResultDAL { get; set; } /// /// 查询学生预查信息列表 /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// public IGridResultSet GetRetakePreStudentView(ConfiguretView configuretView, Guid? schoolyearID, Guid? collegeID, Guid? departmentID, int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem, Guid? classmajorID, int? inSchoolStatus, int? examsCategoryID, Guid? coursematerialID, string courseTypeIDs, int pageIndex, int pageSize) { try { //查询对应的预查考试性质List var retakeExamsCatagoryList = IRetakeParameterServices.GetExamsCategoryViewList().Where(x => x.IsSelected).ToList(); if (retakeExamsCatagoryList == null || retakeExamsCatagoryList.Count() <= 0) { throw new Exception("未设置预查考试性质,请设置。"); } //学生最终成绩 Expression> expFinallyScore = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (schoolyearID.HasValue) { //学年学期 expFinallyScore = expFinallyScore.And(x => x.SchoolyearID == schoolyearID); } if (departmentID.HasValue) { //开课教研室 expFinallyScore = expFinallyScore.And(x => x.DepartmentID == departmentID); } if (examsCategoryID.HasValue) { //考试性质 expFinallyScore = expFinallyScore.And(x => x.ExamsCategoryID == examsCategoryID); } if (coursematerialID.HasValue) { //课程信息 expFinallyScore = expFinallyScore.And(x => x.CoursematerialID == coursematerialID); } //查询必修课程类型信息List var isRequiredCourseTypeIDlist = specialityScoreByFinalScoreServices.Value.GetCourseTypeID().ToList(); //课程类型List var courseTypeIDList = new List(); if (!string.IsNullOrEmpty(courseTypeIDs)) { courseTypeIDList = courseTypeIDs.Remove(courseTypeIDs.Length - 1).Split(',') .Where(x => !string.IsNullOrEmpty(x)).Select(x => Convert.ToInt32(x)).ToList(); } expFinallyScore = expFinallyScore.And(x => courseTypeIDList.Contains(x.CourseTypeID.Value)); //学生信息 Expression> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (inSchoolStatus != null && inSchoolStatus > -1) { //在校状态 var inschoolStatusList = InSchoolSettingServices.GetInschoolStatusList(true); if (inSchoolStatus == 1) { //表示在校 expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID)); } if (inSchoolStatus == 0) { //不在校 expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID)); } } if (classmajorID.HasValue) { //班级信息 expStudent = expStudent.And(x => x.ClassmajorID == classmajorID); } //查询对应的重修学年学期 var retakeSchoolyearID = IParameterServices.Value.GetParameterValue(CF_ParameterType.RetakeSchoolyearID); //重修计划 Expression> expRetakePlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (retakeSchoolyearID.HasValue) { //重修学年学期 expRetakePlan = expRetakePlan.And(x => x.SchoolyearID == retakeSchoolyearID); } else { throw new Exception("未设置重修学年学期,请设置。"); } var query = RetakePlanTaskDAL.GetRetakePreStudentView(expFinallyScore, expStudent, expRetakePlan); if (collegeID.HasValue) { //院系所 query = query.Where(x => x.CollegeID == collegeID); } if (yearID.HasValue) { //年级 query = query.Where(x => x.Gradeyear == yearID); } 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); } //条件限定List var retakeConditionList = RetakeConditionDAL.GetRetakeConditionView(x => true).ToList(); foreach (var condition in retakeConditionList) { //条件匹配查询(在此最小、最大不及格门数范围内,当为空时,匹配为全部数据) query = (IQueryable)ReflectorHelper.RunDALMethod(condition.MethodFullName, query); } //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.LoginID.Length) .ThenBy(x => x.LoginID).ThenBy(x => x.SchoolyearCode) .ThenBy(x => x.CourseCode) .ToGridResultSet(pageIndex, pageSize); } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 查询学生预查信息List /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// /// public List GetRetakePreStudentViewList(ConfiguretView configuretView, Guid? schoolyearID, Guid? collegeID, Guid? departmentID, int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem, Guid? classmajorID, int? inSchoolStatus, int? examsCategoryID, Guid? coursematerialID, string courseTypeIDs) { try { //查询对应的预查考试性质List var retakeExamsCatagoryList = IRetakeParameterServices.GetExamsCategoryViewList().Where(x => x.IsSelected).ToList(); if (retakeExamsCatagoryList == null || retakeExamsCatagoryList.Count() <= 0) { throw new Exception("未设置预查考试性质,请设置。"); } //学生最终成绩 Expression> expFinallyScore = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (schoolyearID.HasValue) { //学年学期 expFinallyScore = expFinallyScore.And(x => x.SchoolyearID == schoolyearID); } if (departmentID.HasValue) { //开课教研室 expFinallyScore = expFinallyScore.And(x => x.DepartmentID == departmentID); } if (examsCategoryID.HasValue) { //考试性质 expFinallyScore = expFinallyScore.And(x => x.ExamsCategoryID == examsCategoryID); } if (coursematerialID.HasValue) { //课程信息 expFinallyScore = expFinallyScore.And(x => x.CoursematerialID == coursematerialID); } //查询必修课程类型信息List var isRequiredCourseTypeIDlist = specialityScoreByFinalScoreServices.Value.GetCourseTypeID().ToList(); //课程类型List var courseTypeIDList = new List(); if (!string.IsNullOrEmpty(courseTypeIDs)) { courseTypeIDList = courseTypeIDs.Remove(courseTypeIDs.Length - 1).Split(',') .Where(x => !string.IsNullOrEmpty(x)).Select(x => Convert.ToInt32(x)).ToList(); } expFinallyScore = expFinallyScore.And(x => courseTypeIDList.Contains(x.CourseTypeID.Value)); //学生信息 Expression> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (inSchoolStatus != null && inSchoolStatus > -1) { //在校状态 var inschoolStatusList = InSchoolSettingServices.GetInschoolStatusList(true); if (inSchoolStatus == 1) { //表示在校 expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID)); } if (inSchoolStatus == 0) { //不在校 expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID)); } } if (classmajorID.HasValue) { //班级信息 expStudent = expStudent.And(x => x.ClassmajorID == classmajorID); } //查询对应的重修学年学期 var retakeSchoolyearID = IParameterServices.Value.GetParameterValue(CF_ParameterType.RetakeSchoolyearID); //重修计划 Expression> expRetakePlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (retakeSchoolyearID.HasValue) { //重修学年学期 expRetakePlan = expRetakePlan.And(x => x.SchoolyearID == retakeSchoolyearID); } else { throw new Exception("未设置重修学年学期,请设置。"); } var query = RetakePlanTaskDAL.GetRetakePreStudentView(expFinallyScore, expStudent, expRetakePlan); if (collegeID.HasValue) { //院系所 query = query.Where(x => x.CollegeID == collegeID); } if (yearID.HasValue) { //年级 query = query.Where(x => x.Gradeyear == yearID); } 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); } //条件限定List var retakeConditionList = RetakeConditionDAL.GetRetakeConditionView(x => true).ToList(); foreach (var condition in retakeConditionList) { //条件匹配查询(在此最小、最大不及格门数范围内,当为空时,匹配为全部数据) query = (IQueryable)ReflectorHelper.RunDALMethod(condition.MethodFullName, query); } //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.LoginID.Length) .ThenBy(x => x.LoginID).ThenBy(x => x.SchoolyearCode) .ThenBy(x => x.CourseCode) .ToList(); } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 学生预查重修任务生成 /// /// /// /// public string Generate(List finallyScoreIDList, int? retakeTypeID) { try { //查询对应的重修学年学期 var retakeSchoolyearID = IParameterServices.Value.GetParameterValue(CF_ParameterType.RetakeSchoolyearID); if (retakeSchoolyearID == null) { throw new Exception("未设置重修学年学期,请设置。"); } //查询对应的重修考试性质(此字段需要存到重修计划表中) var retakeExamsCatagoryID = IParameterServices.Value.GetParameterValue(CF_ParameterType.RetakeExamsCatagoryID); if (retakeExamsCatagoryID == null) { throw new Exception("未设置重修考试性质,请设置。"); } //查询对应的重修收费项目 var retakeChargeProjectID = IParameterServices.Value.GetParameterValue(CF_ParameterType.RetakeChargeProjectID); if (retakeChargeProjectID == null) { throw new Exception("未设置重修收费项目,请设置。"); } //查询对应的预查考试性质List var retakeExamsCatagoryList = IRetakeParameterServices.GetExamsCategoryViewList().Where(x => x.IsSelected).ToList(); if (retakeExamsCatagoryList == null || retakeExamsCatagoryList.Count() <= 0) { throw new Exception("未设置预查考试性质,请设置。"); } //查询对应的重修类型ID var retakeTypeView = DictionaryItemDAL.DictionaryItemRepository.Entities .Where(x => x.DictionaryCode == typeof(EMIS.ViewModel.ER_RetakeType).Name && x.Value == retakeTypeID) .SingleOrDefault(); if (retakeTypeView == null) { throw new Exception("重修类型数据有误,请核查。"); } //学生最终成绩 Expression> expFinallyScore = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (finallyScoreIDList == null || finallyScoreIDList.Count() <= 0) { throw new Exception("数据有误,请核查。"); } else { //最终成绩信息ID expFinallyScore = expFinallyScore.And(x => finallyScoreIDList.Contains(x.FinallyScoreID)); } //查询对应的学生预查信息View var retakeStudentPrescanView = RetakePlanTaskDAL.GetRetakePreStudentView(expFinallyScore, x => true, x => true); //重修条件限定List var retakeConditionList = RetakeConditionDAL.GetRetakeConditionView(x => true).ToList(); foreach (var condition in retakeConditionList) { //条件匹配查询(在此最小、最大不及格门数范围内,当为空时,匹配为全部数据) retakeStudentPrescanView = (IQueryable)ReflectorHelper.RunDALMethod(condition.MethodFullName, retakeStudentPrescanView); } //学生预查coursematerialIDList var coursematerialIDList = retakeStudentPrescanView.Where(x => !string.IsNullOrEmpty(x.CoursematerialID.ToString())) .Select(x => x.CoursematerialID).ToList(); //重修计划 Expression> expRetakePlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (retakeSchoolyearID.HasValue) { //重修学年学期 expRetakePlan = expRetakePlan.And(x => x.SchoolyearID == retakeSchoolyearID); } if (retakeExamsCatagoryID.HasValue) { //重修考试性质(目前缺少此字段) } if (retakeTypeID.HasValue) { //重修类型 expRetakePlan = expRetakePlan.And(x => x.RetakeTypeID == retakeTypeID); } if (coursematerialIDList != null || coursematerialIDList.Count() > 0) { //重修计划coursematerialIDList expRetakePlan = expRetakePlan.And(x => coursematerialIDList.Contains(x.CoursematerialID)); } //查询对应的重修计划信息List var retakePlanViewList = RetakePlanTaskDAL.GetRetakePlanTaskView(expRetakePlan).ToList(); //查询对应的重修计划retakePlanIDList var retakePlanIDList = retakePlanViewList.Where(x => !string.IsNullOrEmpty(x.RetakePlanID.ToString())) .Select(x => x.RetakePlanID).ToList(); //学生预查userIDList var userIDList = retakeStudentPrescanView.Where(x => !string.IsNullOrEmpty(x.UserID.ToString())) .Select(x => x.UserID).ToList(); //重修计划名单 Expression> expRetakePlanStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (retakePlanIDList != null || retakePlanIDList.Count() > 0) { //重修计划retakePlanIDList expRetakePlanStudent = expRetakePlanStudent.And(x => retakePlanIDList.Contains(x.RetakePlanID)); } if (userIDList != null || userIDList.Count() > 0) { //重修计划名单userIDList expRetakePlanStudent = expRetakePlanStudent.And(x => userIDList.Contains(x.UserID)); } //查询对应的重修计划名单List var retakePlanStudentViewList = RetakePlanTaskDAL.RetakePlanStudentRepository .GetList(expRetakePlanStudent).ToList(); int success = 0; //成功 int fail = 0; //失败 string tipMessage = null; //提示消息 var retakePlanInList = new List(); //重修计划List var retakePlanSettingInList = new List(); //重修计划设置List var retakePlanTeachingSettingInList = new List(); //重修计划教学设置List var retakePlanStudentInList = new List(); //重修计划学生名单List //学生预查分组信息List(分组条件:课程信息ID、课程类型、课程学分、开课教研室ID、重修类型、重修学年学期) //注:分组后,可级联出各组对应的明细 var retakeStudentListViewGroupList = retakeStudentPrescanView.ToList().GroupBy(x => new { x.CoursematerialID, x.Abbreviation, x.CourseName, x.CourseTypeID, x.CourseTypeDesc, x.CourseCredit, x.DepartmentID }); foreach (var retakeStudentListViewGroup in retakeStudentListViewGroupList) { //验证对应的重修计划信息(由于有分班功能,可存在多个对应的重修计划信息) var retakePlanViewListVerify = retakePlanViewList.Where(x => x.CoursematerialID == retakeStudentListViewGroup.Key.CoursematerialID && x.CourseTypeID == retakeStudentListViewGroup.Key.CourseTypeID && x.Credit == retakeStudentListViewGroup.Key.CourseCredit && x.DepartmentID == retakeStudentListViewGroup.Key.DepartmentID && x.RetakeTypeID == retakeTypeID && x.SchoolyearID == retakeSchoolyearID ).ToList(); if (retakePlanViewListVerify == null || retakePlanViewListVerify.Count() <= 0) { //表示不存在对应的重修计划 ER_RetakePlan retakePlan = new ER_RetakePlan(); retakePlan.RetakePlanID = Guid.NewGuid(); retakePlan.CoursematerialID = retakeStudentListViewGroup.Key.CoursematerialID; retakePlan.RetakeTypeID = retakeTypeID; //重修班级名称 retakePlan.ClassName = (retakeStudentListViewGroup.Key.Abbreviation ?? retakeStudentListViewGroup.Key.CourseName) + "-" + retakeTypeView.Name + "(" + retakeStudentListViewGroup.Key.CourseTypeDesc + (retakeStudentListViewGroup.Key.CourseCredit == 0 ? "0" : string.Format("{0:#.0}", retakeStudentListViewGroup.Key.CourseCredit)) + "学分)"; retakePlan.SchoolyearID = retakeSchoolyearID; retakePlan.CourseTypeID = retakeStudentListViewGroup.Key.CourseTypeID; retakePlan.Credit = retakeStudentListViewGroup.Key.CourseCredit; retakePlan.PeopleNumlower = 0; retakePlan.PeopleNumlimit = 0; retakePlan.IsDivide = false; //重修任务状态默认为未开放 SetNewStatus(retakePlan, (int)ER_RetakePlanStatus.NotOpened); ER_RetakePlanSetting retakePlanSetting = new ER_RetakePlanSetting(); retakePlanSetting.RetakePlanID = retakePlan.RetakePlanID; retakePlanSetting.DepartmentID = retakeStudentListViewGroup.Key.DepartmentID; retakePlanSetting.CourseTypeID = retakeStudentListViewGroup.Key.CourseTypeID; retakePlanSetting.ExaminationModeID = (int)CF_ExaminationMode.WrittenExam; retakePlanSetting.IsSpecialtycore = false; retakePlanSetting.IsCooperation = false; retakePlanSetting.IsRequired = true; retakePlanSetting.IsElective = false; retakePlanSetting.IsNetworkCourse = false; retakePlanSetting.IsMainCourse = false; SetNewStatus(retakePlanSetting); ER_RetakePlanTeachingSetting retakePlanTeachingSetting = new ER_RetakePlanTeachingSetting(); retakePlanTeachingSetting.RetakePlanID = retakePlan.RetakePlanID; retakePlanInList.Add(retakePlan); retakePlanSettingInList.Add(retakePlanSetting); retakePlanTeachingSettingInList.Add(retakePlanTeachingSetting); foreach (var retakeStudentPrescan in retakeStudentListViewGroup.Select(x => x).ToList()) { //对应的重修计划名单 ER_RetakePlanStudent retakePlanStudent = new ER_RetakePlanStudent(); retakePlanStudent.RetakePlanStudentID = Guid.NewGuid(); retakePlanStudent.RetakePlanID = retakePlan.RetakePlanID; retakePlanStudent.UserID = retakeStudentPrescan.UserID.Value; retakePlanStudent.SchoolyearNumID = retakeStudentPrescan.SchoolyearNumID; retakePlanStudent.StarttermID = retakeStudentPrescan.StarttermID; SetNewStatus(retakePlanStudent); retakePlanStudentInList.Add(retakePlanStudent); success++; } } else { //表示存在对应的重修计划 //由于有分班功能,可存在多个对应的重修计划信息,默认将重修计划名单分配到查询结果的各个重修计划中 //查询对应的重修计划retakePlanID(由于有分班功能,可存在多个对应的retakePlanID) var retakePlanIDVerifyList = retakePlanViewListVerify.Select(x => x.RetakePlanID).ToList(); foreach (var retakeStudentPrescan in retakeStudentListViewGroup.Select(x => x).ToList()) { //查询对应的重修计划名单信息 var retakePlanStudentList = retakePlanStudentViewList .Where(x => retakePlanIDVerifyList.Contains(x.RetakePlanID) && x.UserID == retakeStudentPrescan.UserID).ToList(); //分别将对应的重修计划名单添加到对应的重修计划中(由于有分班功能,重修计划名单可存在不同的重修任务中) foreach (var retakePlanIDVerify in retakePlanIDVerifyList) { //验证对应的重修计划名单信息 var retakePlanStudentVerify = retakePlanStudentList .Where(x => x.RetakePlanID == retakePlanIDVerify).SingleOrDefault(); if (retakePlanStudentVerify == null) { //表示不存在对应的重修计划名单 ER_RetakePlanStudent retakePlanStudent = new ER_RetakePlanStudent(); retakePlanStudent.RetakePlanStudentID = Guid.NewGuid(); //存在多个对应的重修计划信息,默认将重修计划名单分配到查询结果的各个重修计划中 retakePlanStudent.RetakePlanID = retakePlanIDVerify; retakePlanStudent.UserID = retakeStudentPrescan.UserID.Value; retakePlanStudent.SchoolyearNumID = retakeStudentPrescan.SchoolyearNumID; retakePlanStudent.StarttermID = retakeStudentPrescan.StarttermID; SetNewStatus(retakePlanStudent); retakePlanStudentInList.Add(retakePlanStudent); success++; } else { //表示存在对应的重修计划名单(数据有误,原因为:同一个学生,不同开课学期修同一门课程) fail++; } } } } } //批量插入 UnitOfWork.BulkInsert(retakePlanInList); UnitOfWork.BulkInsert(retakePlanSettingInList); UnitOfWork.BulkInsert(retakePlanTeachingSettingInList); UnitOfWork.BulkInsert(retakePlanStudentInList); if (success > 0 && fail <= 0) { tipMessage = success + "条"; } else { tipMessage = success + "条," + fail + "条失败,原因:已存在相同的重修任务名单,请检查"; } return tipMessage; } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 查询重修任务信息View /// /// /// /// /// /// /// /// /// /// /// public IGridResultSet GetRetakePlanTaskView(ConfiguretView configuretView, Guid? schoolyearID, Guid? collegeID, Guid? departmentID, Guid? coursematerialID, int? retakeTypeID, int? statusID, int pageIndex, int pageSize) { //重修计划 Expression> expRetakePlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (schoolyearID.HasValue) { //重修学年学期 expRetakePlan = expRetakePlan.And(x => x.SchoolyearID == schoolyearID); } if (coursematerialID.HasValue) { //课程信息 expRetakePlan = expRetakePlan.And(x => x.CoursematerialID == coursematerialID); } if (retakeTypeID.HasValue) { //重修类型 expRetakePlan = expRetakePlan.And(x => x.RetakeTypeID == retakeTypeID); } if (statusID.HasValue) { //重修任务状态 expRetakePlan = expRetakePlan.And(x => x.RecordStatus == statusID); } //查询对应的重修任务信息View var query = RetakePlanTaskDAL.GetRetakePlanTaskView(expRetakePlan); if (collegeID.HasValue) { //开课院系所 query = query.Where(x => x.CourseCollegeID == collegeID); } if (departmentID.HasValue) { //开课教研室 query = query.Where(x => x.DepartmentID == departmentID); } //查询条件() if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.SchoolyearCode.Length) .ThenBy(x => x.SchoolyearCode).ThenBy(x => x.DepartmentCode.Length) .ThenBy(x => x.DepartmentCode).ThenBy(x => x.RetakeTypeID) .ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode) .ThenBy(x => x.CourseTypeID).ThenBy(x => x.ClassName) .ToGridResultSet(pageIndex, pageSize); //查询对应的重修计划IDList var retakePlanIDList = query.Select(x => x.RetakePlanID).ToList(); //查询对应的课程表信息 var schedulingList = RetakePlanTaskDAL.GetSchedulingView(x => retakePlanIDList.Contains(x.RetakePlanID.Value)).ToList(); //查询合并显示的课程表信息 var weekdayTimesList = IRetakePlanStudentApplyServices.GetWeekdayTimesSegmentName(schedulingList); result.rows.ForEach(x => { var list = weekdayTimesList.Where(w => w.ID == x.RetakePlanID); x.WeekdayTimesSegmentName = string.Join(";", list.OrderBy(w => w.Weekday).Select(w => w.WeekdayTimesSegmentName)); x.ClassroomName = schedulingList.Where(w => w.ID == x.RetakePlanID).Select(w => w.ClassroomName).FirstOrDefault(); }); //查询合并显示的任课老师信息 var teacherList = RetakePlanResultDAL.GetRetakePlanTeacherView(x => retakePlanIDList.Contains(x.RetakePlanID)); result.rows.ForEach(x => x.TeacherName = string.Join(",", teacherList.Where(w => w.RetakePlanID == x.RetakePlanID).Select(w => w.TeacherName))); return result; } /// /// 查询重修任务信息List /// /// /// /// /// /// /// /// /// public List GetRetakePlanTaskViewList(ConfiguretView configuretView, Guid? schoolyearID, Guid? collegeID, Guid? departmentID, Guid? coursematerialID, int? retakeTypeID, int? statusID) { //重修计划 Expression> expRetakePlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (schoolyearID.HasValue) { //重修学年学期 expRetakePlan = expRetakePlan.And(x => x.SchoolyearID == schoolyearID); } if (coursematerialID.HasValue) { //课程信息 expRetakePlan = expRetakePlan.And(x => x.CoursematerialID == coursematerialID); } if (retakeTypeID.HasValue) { //重修类型 expRetakePlan = expRetakePlan.And(x => x.RetakeTypeID == retakeTypeID); } if (statusID.HasValue) { //重修任务状态 expRetakePlan = expRetakePlan.And(x => x.RecordStatus == statusID); } //查询对应的重修任务信息View var query = RetakePlanTaskDAL.GetRetakePlanTaskView(expRetakePlan); if (collegeID.HasValue) { //开课院系所 query = query.Where(x => x.CourseCollegeID == collegeID); } if (departmentID.HasValue) { //开课教研室 query = query.Where(x => x.DepartmentID == departmentID); } //查询条件() if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.SchoolyearCode.Length) .ThenBy(x => x.SchoolyearCode).ThenBy(x => x.DepartmentCode.Length) .ThenBy(x => x.DepartmentCode).ThenBy(x => x.RetakeTypeID) .ThenBy(x => x.CourseCode.Length).ThenBy(x => x.CourseCode) .ThenBy(x => x.CourseTypeID).ThenBy(x => x.ClassName) .ToList(); //查询对应的重修计划IDList var retakePlanIDList = query.Select(x => x.RetakePlanID).ToList(); //查询对应的课程表信息 var schedulingList = RetakePlanTaskDAL.GetSchedulingView(x => retakePlanIDList.Contains(x.RetakePlanID.Value)).ToList(); //查询合并显示的课程表信息 var weekdayTimesList = IRetakePlanStudentApplyServices.GetWeekdayTimesSegmentName(schedulingList); result.ForEach(x => { var list = weekdayTimesList.Where(w => w.ID == x.RetakePlanID); x.WeekdayTimesSegmentName = string.Join(";", list.OrderBy(w => w.Weekday).Select(w => w.WeekdayTimesSegmentName)); x.ClassroomName = schedulingList.Where(w => w.ID == x.RetakePlanID).Select(w => w.ClassroomName).FirstOrDefault(); }); //查询合并显示的任课老师信息 var teacherList = RetakePlanResultDAL.GetRetakePlanTeacherView(x => retakePlanIDList.Contains(x.RetakePlanID)); result.ForEach(x => x.TeacherName = string.Join(",", teacherList.Where(w => w.RetakePlanID == x.RetakePlanID).Select(w => w.TeacherName))); return result; } /// /// 查询重修计划相关信息View(含相关设置信息、排课教室等) /// 注:排课明细中目前只支持同一教室的情况 /// /// /// public RetakePlanTaskSettingView GetRetakePlanTaskUpdateView(Guid? RetakePlanID) { var retakePlanTaskSettingView = RetakePlanTaskDAL.GetRetakePlanTaskSettingView(x => x.RetakePlanID == RetakePlanID) .SingleOrDefault(); return retakePlanTaskSettingView; } /// /// 查询重修计划课程表信息List /// /// /// public List GetSchedulingView(Guid? RetakePlanID) { var schedulingList = RetakePlanTaskDAL.GetSchedulingView(x => x.RetakePlanID == RetakePlanID) .OrderBy(x => x.Weekday).ThenBy(x=>x.TimesSegment) .ThenBy(x=>x.StartTimes).ToList(); return schedulingList; } /// /// 查询重修计划任课老师信息List /// /// /// public List GetTeacherListView(Guid? RetakePlanID) { var teacherListView = RetakePlanTaskDAL.GetRetakePlanTeacherViewQueryable(x => x.RetakePlanID == RetakePlanID) .OrderBy(x => x.LoginID.Length).ThenBy(x => x.LoginID) .ThenBy(x => x.TeachingMethod).ToList(); return teacherListView; } /// /// 查询重修计划授课方式信息List /// /// /// public List GetTeachingModeType(Guid? RetakePlanID) { var list = RetakePlanTaskDAL.GetTeachingModeType(x => x.RetakePlanID == RetakePlanID) .Select(x => x.Value ?? 0).ToList(); if (list.Count >= 0) { list.Add((int)EMIS.ViewModel.CF_TeachingMode.Theory); } return list; } /// /// 查询重修计划授课地点信息List /// /// /// public List GetTeachingPlace(Guid? RetakePlanID) { var list = RetakePlanTaskDAL.GetTeachingPlace(x => x.RetakePlanID == RetakePlanID) .Select(x => x.Value ?? 0).ToList(); return list; } /// /// 查询对应的重修计划相关表信息 /// /// /// public ER_RetakePlan GetRetakePlan(Guid? RetakePlanID) { return RetakePlanTaskDAL.RetakePlanRepository.GetSingle(x => x.RetakePlanID == RetakePlanID, (x => x.ER_RetakePlanSetting), (x => x.ER_RetakePlanSettingScheduling), (x => x.ER_RetakePlanStudent), (x => x.ER_RetakePlanTeacher), (x => x.CF_Student), (x => x.ER_RetakePlanSetting.ER_RetakePlanTeachingModeType), (x => x.ER_RetakePlanSetting.ER_RetakePlanTeachingPlace), (x => x.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting)); } /// /// 重修计划修改(排课冲突判断) /// /// /// /// /// /// public bool RetakePlanTaskSet(RetakePlanTaskSettingView RetakePlanTaskSettingView, IList teacherList, IList schedulingList, out int? type) { try { var retakePlan = GetRetakePlan(RetakePlanTaskSettingView.RetakePlanID); //排课明细 if (schedulingList.Where(x => x.CoursesTimeID == null || x.Weekday == null).ToList().Count > 0) { throw new Exception("排课信息不能为空"); } else { //如果IsNeedVerify为false时,不验证冲突 if (RetakePlanTaskSettingView.IsNeedVerify != false) { //判断教师和教室冲突,如果有冲突type返回1,页面js根据type弹出选择框 //用户可选择继续保存或不保存,如果不返回1,弹出一般的错误提示框 foreach (var scheduling in schedulingList) { //教室不为空时,判断教室 if (RetakePlanTaskSettingView.ClassroomID != null) { //重修计划冲突 var repeatExecutableClassroom = RetakePlanTaskDAL .GetRepeatRetakePlanSettingClassroom(scheduling.CoursesTimeID, RetakePlanTaskSettingView.ClassroomID, scheduling.Weekday, RetakePlanTaskSettingView.SchoolyearID, RetakePlanTaskSettingView.StartWeeklyNum, RetakePlanTaskSettingView.EndWeeklyNum) .Where(x => x.ID != RetakePlanTaskSettingView.RetakePlanID).FirstOrDefault(); if (repeatExecutableClassroom != null) { type = 1; throw new Exception(repeatExecutableClassroom.WeekdayName + repeatExecutableClassroom.StartTimes + "时间段教室与重修计划[" + repeatExecutableClassroom.DefaultClassName + "]有冲突"); } //教学任务冲突 var repeatEducationClassroom = RetakePlanTaskDAL .GetRepeatEducationMissionClassroom(scheduling.CoursesTimeID, RetakePlanTaskSettingView.ClassroomID, scheduling.Weekday, RetakePlanTaskSettingView.SchoolyearID, RetakePlanTaskSettingView.StartWeeklyNum, RetakePlanTaskSettingView.EndWeeklyNum).FirstOrDefault(); if (repeatEducationClassroom != null) { type = 1; throw new Exception("检测到排课冲突," + "该重修上课时间段教室与教学任务班[" + repeatEducationClassroom.DefaultClassName + "]有冲突"); } } //重修计划冲突 var repeatExecutableTeacher = RetakePlanTaskDAL .GetRepeatRetakePlanTeacher(teacherList.Select(x => x.UserID).ToList(), scheduling.CoursesTimeID, scheduling.Weekday, RetakePlanTaskSettingView.SchoolyearID, RetakePlanTaskSettingView.StartWeeklyNum, RetakePlanTaskSettingView.EndWeeklyNum) .Where(x => x.ID != RetakePlanTaskSettingView.RetakePlanID).FirstOrDefault(); if (repeatExecutableTeacher != null) { type = 1; throw new Exception("检测到排课冲突," + repeatExecutableTeacher.WeekdayName + repeatExecutableTeacher.StartTimes + "时间段教师与重修计划[" + repeatExecutableTeacher.DefaultClassName + "]有冲突"); } //教学任务冲突 var repeatEducationTeacher = RetakePlanTaskDAL .GetRepeatEducationMissionTeacher(teacherList.Select(x => x.UserID).ToList(), scheduling.CoursesTimeID, scheduling.Weekday, RetakePlanTaskSettingView.SchoolyearID, RetakePlanTaskSettingView.StartWeeklyNum, RetakePlanTaskSettingView.EndWeeklyNum).FirstOrDefault(); if (repeatEducationTeacher != null) { type = 1; throw new Exception("检测到排课冲突," + "该重修上课时间段教师与教学任务班[" + repeatEducationTeacher.DefaultClassName + "]有冲突"); } } } } using (TransactionScope ts = new TransactionScope()) { retakePlan.CoursematerialID = RetakePlanTaskSettingView.CoursematerialID; retakePlan.RetakeTypeID = RetakePlanTaskSettingView.RetakeTypeID; retakePlan.ClassName = RetakePlanTaskSettingView.ClassName; retakePlan.SchoolyearID = RetakePlanTaskSettingView.SchoolyearID; retakePlan.CourseTypeID = RetakePlanTaskSettingView.CourseTypeID ; //retakePlan.Credit = RetakePlanTaskSettingView.Credit; //目前会出现文本框控件禁用时,取值无效 retakePlan.PeopleNumlimit = RetakePlanTaskSettingView.PeopleNumlimit; retakePlan.PeopleNumlower = RetakePlanTaskSettingView.PeopleNumlower; SetModifyStatus(retakePlan); //重修计划设置表 if (retakePlan.ER_RetakePlanSetting == null) { retakePlan.ER_RetakePlanSetting = new ER_RetakePlanSetting(); retakePlan.ER_RetakePlanSetting.RetakePlanID = RetakePlanTaskSettingView.RetakePlanID; this.SetNewStatus(retakePlan.ER_RetakePlanSetting); UnitOfWork.Add(retakePlan.ER_RetakePlanSetting); } else { SetModifyStatus(retakePlan.ER_RetakePlanSetting); UnitOfWork.Update(retakePlan.ER_RetakePlanSetting); } retakePlan.ER_RetakePlanSetting.DepartmentID = RetakePlanTaskSettingView.DepartmentID; retakePlan.ER_RetakePlanSetting.CourseTypeID = RetakePlanTaskSettingView.CourseTypeID; retakePlan.ER_RetakePlanSetting.CourseStructureID = RetakePlanTaskSettingView.CourseStructureID; retakePlan.ER_RetakePlanSetting.CourseCategoryID = RetakePlanTaskSettingView.CourseCategoryID; retakePlan.ER_RetakePlanSetting.CourseQualityID = RetakePlanTaskSettingView.CourseQualityID; retakePlan.ER_RetakePlanSetting.PracticeTypeID = RetakePlanTaskSettingView.PracticeTypeID; retakePlan.ER_RetakePlanSetting.ExaminationModeID = RetakePlanTaskSettingView.ExaminationModeID; retakePlan.ER_RetakePlanSetting.TeachinglanguageID = RetakePlanTaskSettingView.TeachinglanguageID; retakePlan.ER_RetakePlanSetting.CourseFineID = RetakePlanTaskSettingView.CourseFineID; retakePlan.ER_RetakePlanSetting.IsSpecialtycore = RetakePlanTaskSettingView.IsSpecialtycore; retakePlan.ER_RetakePlanSetting.IsCooperation = RetakePlanTaskSettingView.IsCooperation; retakePlan.ER_RetakePlanSetting.IsRequired = RetakePlanTaskSettingView.IsRequired; retakePlan.ER_RetakePlanSetting.IsElective = RetakePlanTaskSettingView.IsElective; retakePlan.ER_RetakePlanSetting.IsNetworkCourse = RetakePlanTaskSettingView.IsNetworkCourse; retakePlan.ER_RetakePlanSetting.IsMainCourse = RetakePlanTaskSettingView.IsMainCourse; retakePlan.ER_RetakePlanSetting.IsNeedMaterial = RetakePlanTaskSettingView.IsNeedMaterial; retakePlan.ER_RetakePlanSetting.Remarks = RetakePlanTaskSettingView.Remarks; //重修计划教学设置表 if (retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting == null) { retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting = new ER_RetakePlanTeachingSetting(); retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.RetakePlanID = RetakePlanTaskSettingView.RetakePlanID; UnitOfWork.Add(retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting); } else { UnitOfWork.Update(retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting); } retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.TheoryCourse = RetakePlanTaskSettingView.TheoryCourse; retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.Practicehours = RetakePlanTaskSettingView.Practicehours; retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.Trialhours = RetakePlanTaskSettingView.Trialhours; retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.WeeklyNum = RetakePlanTaskSettingView.WeeklyNum; retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.TheoryWeeklyNum = RetakePlanTaskSettingView.TheoryWeeklyNum; retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.PracticeWeeklyNum = RetakePlanTaskSettingView.PracticeWeeklyNum; retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.TrialWeeklyNum = RetakePlanTaskSettingView.TrialWeeklyNum; retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.StartWeeklyNum = RetakePlanTaskSettingView.StartWeeklyNum; retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.EndWeeklyNum = RetakePlanTaskSettingView.EndWeeklyNum; retakePlan.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.WeeklyHours = RetakePlanTaskSettingView.WeeklyHours; //重修计划授课方式表 UnitOfWork.Remove(x => x.RetakePlanID == RetakePlanTaskSettingView.RetakePlanID); if (RetakePlanTaskSettingView.TeachingModeID != null) { RetakePlanTaskSettingView.TeachingModeID.ForEach(x => { ER_RetakePlanTeachingModeType teachingModeType = new ER_RetakePlanTeachingModeType { RetakePlanTeachingModeTypeID = Guid.NewGuid(), RetakePlanID = RetakePlanTaskSettingView.RetakePlanID, TeachingModeID = x }; this.SetNewStatus(teachingModeType); this.UnitOfWork.Add(teachingModeType); }); } //重修计划授课地点表 UnitOfWork.Remove(x => x.RetakePlanID == RetakePlanTaskSettingView.RetakePlanID); if (RetakePlanTaskSettingView.TeachingPlaceID != null) { RetakePlanTaskSettingView.TeachingPlaceID.ForEach(x => { ER_RetakePlanTeachingPlace teachingPlace = new ER_RetakePlanTeachingPlace { RetakePlanTeachingPlaceID = Guid.NewGuid(), RetakePlanID = RetakePlanTaskSettingView.RetakePlanID, TeachingPlace = x }; this.SetNewStatus(teachingPlace); this.UnitOfWork.Add(teachingPlace); }); } //重修计划任课教师表 this.UnitOfWork.Delete(x => x.RetakePlanID == RetakePlanTaskSettingView.RetakePlanID); teacherList.ToList().ForEach(x => { var teacher = new ER_RetakePlanTeacher { RetakePlanTeacherID = Guid.NewGuid(), RetakePlanID = RetakePlanTaskSettingView.RetakePlanID, UserID = x.UserID, TeachType = x.TeachingMethod }; this.SetNewStatus(teacher); this.UnitOfWork.Add(teacher); }); //重修计划课程时间表 var distinctSchedulingList = schedulingList.GroupBy(x => new { x.Weekday, x.CoursesTimeID }) .Select(x => new { Weekday = x.Key.Weekday, CoursesTimeID = x.Max(a => a.CoursesTimeID) }).ToList(); this.UnitOfWork.Delete(x => x.RetakePlanID == retakePlan.RetakePlanID); distinctSchedulingList.ToList().ForEach(x => { var scheduling = new ER_RetakePlanSettingScheduling { RetakePlanSettingSchedulingID = Guid.NewGuid(), RetakePlanID = retakePlan.RetakePlanID, ClassroomID = RetakePlanTaskSettingView.ClassroomID, CoursesTimeID = x.CoursesTimeID, Weekday = x.Weekday, }; this.SetNewStatus(scheduling); this.UnitOfWork.Add(scheduling); }); UnitOfWork.Commit(); ts.Complete(); } type = 0; return true; } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 排课冲突检查,列出课程进度中的可选教室 /// /// /// /// /// /// /// /// /// /// /// public IGridResultSet GetAvailableClassroom(ConfiguretView configuretView, Guid? buildingID, string schedulingWeek, int? weekday, Guid courseTimeID, int? classroomTypeID, Guid SchoolYearID, int? pageIndex, int? pageSize) { List schedulingWeekList = Array.ConvertAll(schedulingWeek.Split('-'), s => Convert.ToInt32(s)).ToList(); for (int i = 1; i + schedulingWeekList.Min() < schedulingWeekList.Max(); i++) { schedulingWeekList.Add(i + schedulingWeekList.Min()); } var classroomView = ClassroomScheduleDAL.GetAvailableClassroom(SchoolYearID, schedulingWeekList, weekday.Value, courseTimeID, classroomTypeID > 0 ? classroomTypeID : null); if (buildingID.HasValue) { classroomView = classroomView.Where(x => x.BuildingsInfoID == buildingID); } 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); } /// /// 删除(需要检测是否存在对应的已报名重修计划名单,根据重修计划ID) /// /// public void DeleteRetakePlanTask(IList retakePlanIDsList) { try { var retakePlanViewList = this.RetakePlanTaskDAL.RetakePlanRepository .GetList(x => retakePlanIDsList.Contains(x.RetakePlanID), (x => x.CF_Student)).ToList(); if (retakePlanViewList.Any(x => x.RecordStatus != (int)EMIS.ViewModel.ER_RetakePlanStatus.NotOpened)) { throw new Exception("只能删除未开放状态的重修任务。"); } ////查询对应的重修报名信息List //var retakePlanStudentApplyList = RetakePlanTaskDAL.RetakePlanStudentRepository // .GetList(x => retakePlanIDsList.Contains(x.RetakePlanID), // (x => x.ER_RetakePlan), // (x => x.ER_RetakePlan.CF_Student)) // .Where(x => x.ER_RetakePlan.CF_Student.Any(w => w.UserID == x.UserID)) // .ToList(); //if (retakePlanStudentApplyList.Count() > 0) //{ // throw new Exception("存在对应的已报名重修计划名单。"); //} var retakePlanIDList = retakePlanViewList.Select(x => x.RetakePlanID).Distinct().ToList(); ////删除相应重修计划报名表信息(此句暂时不需要) //retakePlanViewList.ForEach(x => //{ // UnitOfWork.Delete(x, (w => w.CF_Student)); //}); //UnitOfWork.RemoveRange(new HashSet(retakePlanViewList)); UnitOfWork.Remove(x => retakePlanIDList.Contains(x.RetakePlanID)); UnitOfWork.Remove(x => retakePlanIDList.Contains(x.RetakePlanID.Value)); UnitOfWork.Remove(x => retakePlanIDList.Contains(x.RetakePlanID.Value)); UnitOfWork.Remove(x => retakePlanIDList.Contains(x.RetakePlanID)); UnitOfWork.Remove(x => retakePlanIDList.Contains(x.RetakePlanID.Value)); UnitOfWork.Remove(x => retakePlanIDList.Contains(x.RetakePlanID.Value)); UnitOfWork.Remove(x => retakePlanIDList.Contains(x.RetakePlanID)); UnitOfWork.Remove(x => retakePlanIDList.Contains(x.RetakePlanID)); UnitOfWork.Commit(); } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 检测是否存在对应的已报名重修计划名单(根据重修计划ID) /// /// /// public bool IsExistsApplyStudentByRetakePlanID(string retakePlanIDs) { List list = retakePlanIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)) .Select(x => (Guid?)new Guid(x)).ToList(); var retakePlanStudentList = RetakePlanTaskDAL.RetakePlanStudentRepository .GetList(x => list.Contains(x.RetakePlanID), (x => x.ER_RetakePlan), (x => x.ER_RetakePlan.CF_Student)).ToList(); var IsExistslist = retakePlanStudentList.Where(x => x.ER_RetakePlan.CF_Student.Any(w => w.UserID == x.UserID)).ToList(); if (IsExistslist.Count() > 0) { return true; } else { return false; } } /// /// 重修计划取消开放(删除对应的重修计划报名名单) /// /// public void CancleRetakePlanTask(IList RetakePlanIDsList) { try { var retakePlanList = this.RetakePlanTaskDAL.RetakePlanRepository .GetList(x => RetakePlanIDsList.Contains(x.RetakePlanID), (x => x.CF_Student)).ToList(); if (retakePlanList.Any(x => x.RecordStatus != (int)EMIS.ViewModel.ER_RetakePlanStatus.Opened)) { throw new Exception("只能取消已开放状态的重修任务。"); } ////查询对应的重修报名信息List //var retakePlanStudentApplyList = RetakePlanTaskDAL.RetakePlanStudentRepository // .GetList(x => RetakePlanIDsList.Contains(x.RetakePlanID), // (x => x.ER_RetakePlan), // (x => x.ER_RetakePlan.CF_Student)) // .Where(x => x.ER_RetakePlan.CF_Student.Any(w => w.UserID == x.UserID)) // .ToList(); //if (retakePlanStudentApplyList.Count() > 0) //{ // throw new Exception("存在对应的已报名重修计划名单。"); //} //删除对应的重修计划报名名单 retakePlanList.ForEach(x => { UnitOfWork.Delete(x, (w => w.CF_Student)); }); //修改对应的重修计划 UnitOfWork.Update(x => new ER_RetakePlan { RecordStatus = (int)EMIS.ViewModel.ER_RetakePlanStatus.NotOpened }, x => RetakePlanIDsList.Contains(x.RetakePlanID)); UnitOfWork.Commit(); } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 重修计划开放 /// /// public void OpenRetakePlanTask(IList RetakePlanIDsList) { try { var retakeList = this.RetakePlanTaskDAL.RetakePlanRepository .GetList(x => RetakePlanIDsList.Contains(x.RetakePlanID)).ToList(); if (retakeList.Any(x => x.RecordStatus != (int)EMIS.ViewModel.ER_RetakePlanStatus.NotOpened)) { throw new Exception("只能开放未开放状态的重修任务。"); } UnitOfWork.Update(x => new ER_RetakePlan { RecordStatus = (int)EMIS.ViewModel.ER_RetakePlanStatus.Opened }, x => RetakePlanIDsList.Contains(x.RetakePlanID)); UnitOfWork.Commit(); } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 查询对应的重修计划分班信息View /// /// /// public RetakeDivideIntoClassesView GetDivideIntoClassesView(Guid? RetakePlanID) { try { //查询对应的重修计划信息 var retakePlanTaskView = RetakePlanTaskDAL .GetRetakePlanTaskView(x => x.RetakePlanID == RetakePlanID).SingleOrDefault(); RetakeDivideIntoClassesView divideIntoClassesView = new RetakeDivideIntoClassesView(); divideIntoClassesView.ClassName = retakePlanTaskView.ClassName; divideIntoClassesView.StudentTotalNum = retakePlanTaskView.PlanNumber; return divideIntoClassesView; } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 重修任务分班(此分班形式不需分开人数,只做为分多少个任务班的计算参数) /// 注:分多少个任务班,那么各个任务班的人数保持一致 /// /// public void DivideIntoClassesSeparate(RetakeDivideIntoClassesView divideIntoClassesView) { try { if (divideIntoClassesView.RetakePlanID.HasValue && divideIntoClassesView.RetakePlanID != Guid.Empty) { //查询对应的重修计划表相关信息 var retakePlanView = GetRetakePlan(divideIntoClassesView.RetakePlanID); if (retakePlanView != null) { //只能对未开放状态的信息进行分班 if (retakePlanView.RecordStatus != (int)EMIS.ViewModel.ER_RetakePlanStatus.NotOpened) { throw new Exception("只能对未开放状态的信息进行分班。"); } //查询对应的重修计划名单信息List var retakePlanTaskStudentViewList = RetakePlanTaskDAL .GetRetakePlanTaskStudentView(x => x.RetakePlanID == divideIntoClassesView.RetakePlanID, x => x.RetakePlanID == divideIntoClassesView.RetakePlanID, x => true).OrderBy(x => x.LoginID.Length).ThenBy(x => x.LoginID) .Select(x => x.UserID).ToList(); ////查询对应的重修报名信息List //var retakePlanStudentApplyList = RetakePlanTaskDAL.RetakePlanStudentRepository // .GetList(x => x.RetakePlanID == retakePlanView.RetakePlanID, // (x => x.ER_RetakePlan), // (x => x.ER_RetakePlan.CF_Student)) // .Where(x => x.ER_RetakePlan.CF_Student.Any(w => w.UserID == x.UserID)) // .ToList(); //if (retakePlanStudentApplyList.Count() > 0) //{ // throw new Exception("存在对应的已报名重修计划名单。"); //} //任务班数(分班个数) var separateClassCount = divideIntoClassesView.GroupNum ?? 0; ////每班人数 //var classStudentCount = divideIntoClassesView.StudentNum ?? 0; //判断分班的数目 if (separateClassCount <= 1) { throw new Exception("任务班数不能小于等于1。"); } else { using (TransactionScope ts = new TransactionScope()) { for (int i = 0; i < separateClassCount - 1; i++) { ////要分班的名单 //var separateStudentList = retakePlanTaskStudentViewList // .Take(classStudentCount).ToList(); ////未分班名单 //retakePlanTaskStudentViewList = retakePlanTaskStudentViewList // .SkipWhile(x => separateStudentList.Contains(x)).ToList(); //重修计划表 ER_RetakePlan retakePlan = new ER_RetakePlan { RetakePlanID = Guid.NewGuid(), CoursematerialID = retakePlanView.CoursematerialID, RetakeTypeID = retakePlanView.RetakeTypeID, ClassName = retakePlanView.ClassName + "—" + (int)(i + 2) + "班", SchoolyearID = retakePlanView.SchoolyearID, CourseTypeID = retakePlanView.CourseTypeID, Credit = retakePlanView.Credit, PeopleNumlower = retakePlanView.PeopleNumlower, PeopleNumlimit = retakePlanView.PeopleNumlimit, IsDivide = true }; ////查询对应的重修计划名单报名信息 //var applyUserList = retakePlanView.CF_Student // .Where(x => separateStudentList.Contains(x.UserID)).ToList(); //if (applyUserList != null && applyUserList.Count > 0) //{ // retakePlan.CF_Student = new HashSet(applyUserList); //} SetNewStatus(retakePlan); UnitOfWork.Add(retakePlan); //重修计划名单 retakePlanView.ER_RetakePlanStudent.Where(x => retakePlanTaskStudentViewList.Contains(x.UserID)).ToList() .ForEach(x => { ER_RetakePlanStudent retakePlanStudent = new ER_RetakePlanStudent { RetakePlanStudentID = Guid.NewGuid(), RetakePlanID = retakePlan.RetakePlanID, UserID = x.UserID, SchoolyearNumID = x.SchoolyearNumID, StarttermID = x.StarttermID }; SetNewStatus(retakePlanStudent); UnitOfWork.Add(retakePlanStudent); }); //重修计划设置表 ER_RetakePlanSetting retakePlanSetting = new ER_RetakePlanSetting { RetakePlanID = retakePlan.RetakePlanID, DepartmentID = retakePlanView.ER_RetakePlanSetting.DepartmentID, CourseStructureID = retakePlanView.ER_RetakePlanSetting.CourseStructureID, CourseCategoryID = retakePlanView.ER_RetakePlanSetting.CourseCategoryID, CourseTypeID = retakePlanView.ER_RetakePlanSetting.CourseTypeID, CourseQualityID = retakePlanView.ER_RetakePlanSetting.CourseQualityID, PracticeTypeID = retakePlanView.ER_RetakePlanSetting.PracticeTypeID, ExaminationModeID = retakePlanView.ER_RetakePlanSetting.ExaminationModeID, TeachinglanguageID = retakePlanView.ER_RetakePlanSetting.TeachinglanguageID, CourseFineID = retakePlanView.ER_RetakePlanSetting.CourseFineID, IsSpecialtycore = retakePlanView.ER_RetakePlanSetting.IsSpecialtycore, IsCooperation = retakePlanView.ER_RetakePlanSetting.IsCooperation, IsRequired = retakePlanView.ER_RetakePlanSetting.IsRequired, IsElective = retakePlanView.ER_RetakePlanSetting.IsElective, IsNetworkCourse = retakePlanView.ER_RetakePlanSetting.IsNetworkCourse, IsMainCourse = retakePlanView.ER_RetakePlanSetting.IsMainCourse, IsNeedMaterial = retakePlanView.ER_RetakePlanSetting.IsNeedMaterial, Remarks = retakePlanView.ER_RetakePlanSetting.Remarks }; SetNewStatus(retakePlanSetting); UnitOfWork.Add(retakePlanSetting); //重修计划教学设置表 ER_RetakePlanTeachingSetting retakePlanTeachingSetting = new ER_RetakePlanTeachingSetting { RetakePlanID = retakePlan.RetakePlanID, TheoryCourse = retakePlanView.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.TheoryCourse, Practicehours = retakePlanView.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.Practicehours, Trialhours = retakePlanView.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.Trialhours, WeeklyNum = retakePlanView.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.WeeklyNum, TheoryWeeklyNum = retakePlanView.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.TheoryWeeklyNum, PracticeWeeklyNum = retakePlanView.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.PracticeWeeklyNum, TrialWeeklyNum = retakePlanView.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.TrialWeeklyNum, StartWeeklyNum = retakePlanView.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.StartWeeklyNum, EndWeeklyNum = retakePlanView.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.EndWeeklyNum, WeeklyHours = retakePlanView.ER_RetakePlanSetting.ER_RetakePlanTeachingSetting.WeeklyHours }; UnitOfWork.Add(retakePlanTeachingSetting); //重修计划授课方式表 retakePlanView.ER_RetakePlanSetting.ER_RetakePlanTeachingModeType.ToList().ForEach(x => { ER_RetakePlanTeachingModeType teachingModeType = new ER_RetakePlanTeachingModeType { RetakePlanTeachingModeTypeID = Guid.NewGuid(), RetakePlanID = retakePlan.RetakePlanID, TeachingModeID = x.TeachingModeID }; this.SetNewStatus(teachingModeType); this.UnitOfWork.Add(teachingModeType); }); //重修计划授课地点表 retakePlanView.ER_RetakePlanSetting.ER_RetakePlanTeachingPlace.ToList().ForEach(x => { ER_RetakePlanTeachingPlace teachingPlace = new ER_RetakePlanTeachingPlace { RetakePlanTeachingPlaceID = Guid.NewGuid(), RetakePlanID = retakePlan.RetakePlanID, TeachingPlace = x.TeachingPlace }; this.SetNewStatus(teachingPlace); this.UnitOfWork.Add(teachingPlace); }); //重修计划任课老师表 retakePlanView.ER_RetakePlanTeacher.ToList().ForEach(x => { ER_RetakePlanTeacher teacher = new ER_RetakePlanTeacher { RetakePlanTeacherID = Guid.NewGuid(), RetakePlanID = retakePlan.RetakePlanID, UserID = x.UserID, TeachType = x.TeachType }; this.SetNewStatus(teacher); this.UnitOfWork.Add(teacher); }); ////重修计划课程表(由于要判断排课冲突,分班不需添加) //ER_RetakePlanSettingScheduling newRetakePlanSettingScheduling = new ER_RetakePlanSettingScheduling(); //当运行到最后一次循环时需修改原先的重修计划(加上分班后的班号) //把循环中已分配的学生删除(由于需求有变更,此项暂时无效--将相关代码注释) if (i == separateClassCount - 2) { retakePlanView.ClassName = retakePlanView.ClassName + "—" + 1 + "班"; retakePlanView.IsDivide = true; ////删除相应重修计划报名名单 //retakePlanView.CF_Student.RemoveWhere(x => !retakePlanTaskStudentViewList.Contains(x.UserID)); ////删除相应的重修计划名单 //UnitOfWork.Delete(x => !retakePlanTaskStudentViewList.Contains(x.UserID) // && x.RetakePlanID == retakePlanView.RetakePlanID); } } SetModifyStatus(retakePlanView); UnitOfWork.Update(retakePlanView); UnitOfWork.Commit(); ts.Complete(); } } } else { throw new Exception("数据有误,请核查。"); } } else { throw new Exception("数据有误,请核查。"); } } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 查询对应的重修计划名单信息View /// /// /// /// /// public IGridResultSet GetRetakePlanTaskStudentView(Guid? RetakePlanID, int pageIndex, int pageSize) { var query = RetakePlanTaskDAL.GetRetakePlanTaskStudentView(x => x.RetakePlanID == RetakePlanID) .OrderBy(x => x.LoginID.Length).ThenBy(x => x.LoginID); return query.ToGridResultSet(pageIndex, pageSize); } /// /// 查询对应的重修计划名单信息List /// /// /// /// public List GetRetakePlanTaskStudentViewList(ConfiguretView configuretView, Guid? RetakePlanID) { var query = RetakePlanTaskDAL.GetRetakePlanTaskStudentView(x => x.RetakePlanID == RetakePlanID) .OrderBy(x => x.LoginID.Length).ThenBy(x => x.LoginID); return query.ToList(); } /// /// 查询对应的重修计划名单列表(不及格成绩,小于60分) /// 不需排除已在其它相应的重修计划中存在的名单 /// /// /// /// /// /// /// /// /// public IGridResultSet GetStudentView(ConfiguretView configuretView, Guid? retakePlanID, int? gradeYearID, int? standardID, Guid? classmajorID, int? inSchoolStatus, int pageIndex, int pageSize) { try { //查询对应的预查考试性质List var retakeExamsCatagoryList = IRetakeParameterServices.GetExamsCategoryViewList().Where(x => x.IsSelected).ToList(); if (retakeExamsCatagoryList == null || retakeExamsCatagoryList.Count() <= 0) { throw new Exception("未设置预查考试性质,请设置。"); } //查询对应的重修计划相关信息 var retakePlan = RetakePlanTaskDAL.RetakePlanRepository .GetSingle(x => x.RetakePlanID == retakePlanID, x => x.ER_RetakePlanSetting); if (retakePlan == null) { throw new Exception("数据有误,请核查。"); } //学生最终成绩 Expression> expFinallyScore = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (retakePlan.ER_RetakePlanSetting.DepartmentID.HasValue) { //开课教研室 expFinallyScore = expFinallyScore.And(x => x.DepartmentID == retakePlan.ER_RetakePlanSetting.DepartmentID); } if (retakePlan.CoursematerialID.HasValue) { //课程信息 expFinallyScore = expFinallyScore.And(x => x.CoursematerialID == retakePlan.CoursematerialID); } if (retakePlan.CourseTypeID.HasValue) { //课程类型 expFinallyScore = expFinallyScore.And(x => x.CourseTypeID == retakePlan.CourseTypeID); } if (retakePlan.Credit.HasValue) { //课程学分 expFinallyScore = expFinallyScore.And(x => x.Credit == retakePlan.Credit); } //学生信息 Expression> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (inSchoolStatus != null && inSchoolStatus > -1) { //在校状态 var inschoolStatusList = InSchoolSettingServices.GetInschoolStatusList(true); if (inSchoolStatus == 1) { //表示在校 expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID)); } if (inSchoolStatus == 0) { //不在校 expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID)); } } if (classmajorID.HasValue) { //班级信息 expStudent = expStudent.And(x => x.ClassmajorID == classmajorID); } //重修计划 Expression> expRetakePlan = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (retakePlanID.HasValue) { //重修计划ID expRetakePlan = expRetakePlan.And(x => x.RetakePlanID == retakePlanID); } if (retakePlan.CoursematerialID.HasValue) { //课程信息 expRetakePlan = expRetakePlan.And(x => x.CoursematerialID == retakePlan.CoursematerialID); } if (retakePlan.RetakeTypeID.HasValue) { //重修类型 expRetakePlan = expRetakePlan.And(x => x.RetakeTypeID == retakePlan.RetakeTypeID); } if (retakePlan.SchoolyearID.HasValue) { //重修学年学期 expRetakePlan = expRetakePlan.And(x => x.SchoolyearID == retakePlan.SchoolyearID); } if (retakePlan.CourseTypeID.HasValue) { //课程类型 expRetakePlan = expRetakePlan.And(x => x.CourseTypeID == retakePlan.CourseTypeID); } if (retakePlan.Credit.HasValue) { //课程学分 expRetakePlan = expRetakePlan.And(x => x.Credit == retakePlan.Credit); } var query = RetakePlanTaskDAL.GetRetakePreStudentView(expFinallyScore, expStudent, expRetakePlan); if (gradeYearID.HasValue) { //年级 query = query.Where(x => x.Gradeyear == gradeYearID); } if (standardID.HasValue) { //专业名称 query = query.Where(x => x.StandardID == standardID); } //条件限定List var retakeConditionList = RetakeConditionDAL.GetRetakeConditionView(x => true).ToList(); foreach (var condition in retakeConditionList) { //条件匹配查询(在此最小、最大不及格门数范围内,当为空时,匹配为全部数据) query = (IQueryable)ReflectorHelper.RunDALMethod(condition.MethodFullName, query); } //查询条件 if (!string.IsNullOrEmpty(configuretView.ConditionValue)) { query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim()); } return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.LoginID.Length) .ThenBy(x => x.LoginID).ThenBy(x => x.SchoolyearCode) .ThenBy(x => x.CourseCode) .ToGridResultSet(pageIndex, pageSize); } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 重修任务页面添加名单确定 /// /// /// public void AddStudent(Guid? retakePlanID, List finallyScoreIDList) { try { //查询对应的重修计划信息 var retakePlan = RetakePlanTaskDAL.RetakePlanRepository .GetSingle(x => x.RetakePlanID == retakePlanID, x => x.ER_RetakePlanSetting); if (retakePlan == null) { throw new Exception("数据有误,请核查。"); } //查询对应的最终成绩信息(不及格成绩,小于60分) var finallyScoreViewList = RetakePlanTaskDAL.FinallyScoreRepository .GetList(x => finallyScoreIDList.Contains(x.FinallyScoreID)).ToList(); //重修计划名单表 List retakePlanStudentInList = new List(); foreach (var finallyScoreView in finallyScoreViewList) { ER_RetakePlanStudent retakePlanStudent = new ER_RetakePlanStudent(); retakePlanStudent.RetakePlanStudentID = Guid.NewGuid(); retakePlanStudent.RetakePlanID = retakePlanID.Value; retakePlanStudent.UserID = finallyScoreView.UserID.Value; retakePlanStudent.SchoolyearNumID = finallyScoreView.SchoolyearNumID; retakePlanStudent.StarttermID = finallyScoreView.StarttermID; SetNewStatus(retakePlanStudent); retakePlanStudentInList.Add(retakePlanStudent); } UnitOfWork.BulkInsert(retakePlanStudentInList); } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 删除(重修计划名单删除,根据重修计划名单ID) /// /// public void DeleteStudent(IList retakePlanStudentIDsList) { try { //查询对应的重修计划名单信息 var retakePlanStudentViewList = RetakePlanTaskDAL.RetakePlanStudentRepository .GetList(x => retakePlanStudentIDsList.Contains(x.RetakePlanStudentID), (x => x.ER_RetakePlan), (x => x.ER_RetakePlan.CF_Student)).ToList(); if (retakePlanStudentViewList.Any(x => x.ER_RetakePlan.RecordStatus == (int)EMIS.ViewModel.ER_RetakePlanStatus.Generated)) { throw new Exception("不能删除已开班状态的重修任务名单。"); } //查询对应的重修报名信息List var retakePlanStudentApplyList = RetakePlanTaskDAL.RetakePlanStudentRepository .GetList(x => retakePlanStudentIDsList.Contains(x.RetakePlanStudentID), (x => x.ER_RetakePlan), (x => x.ER_RetakePlan.CF_Student)) .Where(x => x.ER_RetakePlan.CF_Student.Any(w => w.UserID == x.UserID)) .ToList(); if (retakePlanStudentApplyList.Count() > 0) { //查询对应的重修计划信息 var retakePlanViewList = retakePlanStudentApplyList .Select(x => x.ER_RetakePlan).Distinct().ToList(); //重修报名表 foreach (var retakePlan in retakePlanViewList) { //查询存在报名名单的重修计划名单对应的userIDList var userIDList = retakePlanStudentApplyList .Where(x => x.RetakePlanID == retakePlan.RetakePlanID) .Select(x => x.UserID).ToList(); retakePlan.CF_Student.RemoveWhere(x => userIDList.Contains(x.UserID)); } //throw new Exception("要删除的重修计划名单已进行重修报名。"); } //重修计划名单表 //UnitOfWork.RemoveRange(new HashSet(retakePlanStudentViewList)); UnitOfWork.Remove(x => retakePlanStudentIDsList.Contains(x.RetakePlanStudentID)); UnitOfWork.Commit(); } catch (Exception ex) { throw new Exception(ex.Message); } } /// /// 检测是否存在对应的已报名重修计划名单(根据重修计划名单ID) /// /// /// public bool IsExistsApplyStudentByRetakePlanStudentID(string retakePlanStudentIDs) { List list = retakePlanStudentIDs.Split(',').Where(x => !string.IsNullOrEmpty(x)) .Select(x => (Guid?)new Guid(x)).ToList(); var retakePlanStudentList = RetakePlanTaskDAL.RetakePlanStudentRepository .GetList(x => list.Contains(x.RetakePlanStudentID), (x => x.ER_RetakePlan), (x => x.ER_RetakePlan.CF_Student)).ToList(); ////查询重修计划名单对应的userIDList //var userIDList = retakePlanStudentList.Select(x => x.UserID).ToList(); var IsExistslist = retakePlanStudentList .Where(x => x.ER_RetakePlan.CF_Student.Any(w => w.UserID == x.UserID)).ToList(); if (IsExistslist.Count() > 0) { return true; } else { return false; } } } }