using System; using System.Collections.Generic; using System.Linq; using System.Text; using Bowin.Common.Linq.Entity; using EMIS.ViewModel.MinorManage.MinorPlanManage; using EMIS.ViewModel; using EMIS.CommonLogic.SystemServices; using EMIS.Entities; using System.Linq.Expressions; using Bowin.Common.Linq; using EMIS.DataLogic.MinorManage.MinorPlanManage; using EMIS.DataLogic.Common.CalendarManage; namespace EMIS.CommonLogic.MinorManage.MinorPlanManage { public class MinorPlanApplyServices : BaseWorkflowServices, IMinorPlanApplyServices { public MinorPlanApplyDAL MinorPlanApplyDAL{get;set;} public SchoolYearDAL schoolYearDAL { get; set; } public IGridResultSet GetMinorPlanApplyViewGrid(ConfiguretView configuretView, int? yearID, int? standardID, Guid? collegeID, int? approvalStatus, int pageIndex, int pageSize) { var statusList = this.GetStatusViewList(); Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (yearID.HasValue) exp = exp.And(x => x.YearID == yearID); if (standardID.HasValue) exp = exp.And(x => x.StandardID == standardID); if (collegeID.HasValue) exp = exp.And(x => x.CollegeID == collegeID); if (approvalStatus.HasValue) exp = exp.And(x => x.RecordStatus == approvalStatus); var query = MinorPlanApplyDAL.GetMinorPlanApplyViewQueryable(exp); if (!string.IsNullOrEmpty(configuretView.ConditionValue)) query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue); var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x=>x.SchoolyearCode).ThenBy(x => x.YearID).ThenBy(x=>x.StandardID).ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo) .ThenByDescending(x => x.CreateTime).ToGridResultSet(pageIndex, pageSize); result.rows.ForEach(x => x.ApprovalStatusName = statusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name); return result; } public List GetMinorPlanApplyViewList(ConfiguretView configuretView, int? yearID, int? standardID, Guid? collegeID, int? approvalStatus, List GradeMinorApplicationIDList) { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (GradeMinorApplicationIDList != null) exp = exp.And(x => GradeMinorApplicationIDList.Contains(x.GradeMinorApplicationID)); if (yearID.HasValue) exp = exp.And(x => x.YearID == yearID); if (standardID.HasValue) exp = exp.And(x => x.StandardID == standardID); if (collegeID.HasValue) exp = exp.And(x => x.CollegeID == collegeID); if (approvalStatus.HasValue) exp = exp.And(x => x.RecordStatus == approvalStatus); var query = MinorPlanApplyDAL.GetMinorPlanApplyViewQueryable(exp); if (!string.IsNullOrEmpty(configuretView.ConditionValue)) query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue); return this.GetQueryByDataRangeByCollege(query).OrderByDescending(x => x.YearID).ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo) .ThenByDescending(x => x.StandardID).ThenByDescending(x => x.CreateTime).ToList(); } public IGridResultSet StandardAndMinorSpecialtyCourseViewGrid(int? yearID, int? standardID, int pageIndex, int pageSize) { Expression> exp = (x => x.IsEnable==true); var query = MinorPlanApplyDAL.StandardAndMinorSpecialtyCourseView(exp, yearID); if (standardID.HasValue) { query = query.Where(x => x.StandardID == standardID); } return this.GetQueryByDataRangeByCollege(query) .OrderBy(x => x.SchoolyearNumID).ThenBy(x => x.CourseCode) .ToGridResultSet(pageIndex, pageSize); } public IGridResultSet existStandardAndMinorSpecialtyCourseViewGrid(Guid? GradeMinorApplicationID, int pageIndex, int pageSize) { Expression> exp = (x => x.GradeMinorApplicationID==GradeMinorApplicationID); var query = MinorPlanApplyDAL.existStandardAndMinorSpecialtyCourseView(exp); return this.GetQueryByDataRangeByCollege(query) .OrderBy(x => x.StarttermID).ThenBy(x => x.CourseCode) .ToGridResultSet(pageIndex, pageSize); } public void MinorPlanAdd(MinorPlanApplyView minorPlanApplyView, List minorSpecialCourseViewList) { try { var existGrademinorApplication = MinorPlanApplyDAL.GrademinorApplicationRepository.GetList(x => x.YearID == minorPlanApplyView.YearID && x.StandardID == minorPlanApplyView.StandardID).FirstOrDefault(); if (existGrademinorApplication!=null) { throw new Exception(minorPlanApplyView.YearID+"级"+minorPlanApplyView.StandardName+"的辅修申请已存在。"); } var graduatingSemester = EMIS.Utility.Const.LOCAL_SETTING_ENTRANCESEMESTERID; if (graduatingSemester == null) { throw new Exception("入学学期(春季、上学期、秋季、下学期)未配置,请检查"); } var SchoolcodeID = Convert.ToInt32(graduatingSemester); var schoolYearList = this.schoolYearDAL.schoolyearRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList(); var minorSpecialCourseIDList = minorSpecialCourseViewList.Select(x => x.MinorCourseID).ToList(); var minorSpecialCourseTeachModeTypeList = MinorPlanApplyDAL.MinorCourseTeachingModeTypeRepository.GetList(x => minorSpecialCourseIDList.Contains(x.MinorCourseID)).ToList(); var minorSpecialCourseTeachPlaceList = MinorPlanApplyDAL.MinorCourseTeachingPlaceRepository.GetList(x => minorSpecialCourseIDList.Contains(x.MinorCourseID)).ToList(); var nowSchoolYear = schoolYearList.Where(x => x.IsCurrent == true).FirstOrDefault(); CF_GrademinorApplication GrademinorApplication = new CF_GrademinorApplication(); GrademinorApplication.GradeMinorApplicationID = Guid.NewGuid(); GrademinorApplication.SchoolyearID = nowSchoolYear.SchoolyearID; GrademinorApplication.CollegeID = minorPlanApplyView.CollegeID; GrademinorApplication.StandardID = minorPlanApplyView.StandardID; GrademinorApplication.YearID = minorPlanApplyView.YearID; GrademinorApplication.StudentLimit = minorPlanApplyView.StudentLimit; SetNewStatus(GrademinorApplication); UnitOfWork.Add(GrademinorApplication); UnitOfWork.Commit(); List insertList = new List(); List insertSettingList = new List(); List insertTeachingModeTypeList = new List(); List insertTeachingPlaceList = new List(); foreach (var specialtyCourse in minorSpecialCourseViewList) { var startSchoolyear = schoolYearList.FirstOrDefault(x => x.Years == minorPlanApplyView.YearID && x.SchoolcodeID == SchoolcodeID); if (startSchoolyear == null) { throw new Exception("未能匹配到学年学期,请设置学年学期。"); } var courseSchoolyear = schoolYearList.FirstOrDefault(x => x.Value == (startSchoolyear.Value + ((specialtyCourse.SchoolyearNumID - 1) * 2) + (specialtyCourse.SchoolcodeID == SchoolcodeID ? 0 : 1))); if (courseSchoolyear == null) { throw new Exception("课程" + specialtyCourse.CourseName + "的开课学年学期尚未设置,请先前往校历管理设置相应的学年学期。"); } EM_MinorPlanApplication MinorPlanApplication = new EM_MinorPlanApplication(); MinorPlanApplication.MinorPlanApplicationID = Guid.NewGuid(); MinorPlanApplication.GrademinorApplicationID = GrademinorApplication.GradeMinorApplicationID; MinorPlanApplication.StarttermID = specialtyCourse.StarttermID; MinorPlanApplication.DepartmentID = specialtyCourse.DepartmentID; MinorPlanApplication.CoursematerialID = specialtyCourse.CoursematerialID; MinorPlanApplication.CourseStructureID = specialtyCourse.CourseStructureID; MinorPlanApplication.CourseCategoryID = specialtyCourse.CourseCategoryID; MinorPlanApplication.CourseTypeID = specialtyCourse.CourseTypeID; MinorPlanApplication.CourseQualityID = specialtyCourse.CourseQualityID; MinorPlanApplication.PracticeTypeID = specialtyCourse.PracticeTypeID; MinorPlanApplication.ExaminationModeID = specialtyCourse.ExaminationModeID; MinorPlanApplication.CourseFineID = specialtyCourse.CourseFineID; MinorPlanApplication.IsSpecialtycore = specialtyCourse.IsSpecialtycore; MinorPlanApplication.IsCooperation = specialtyCourse.IsCooperation; MinorPlanApplication.IsRequired = specialtyCourse.IsRequired; MinorPlanApplication.IsElective = specialtyCourse.IsElective; MinorPlanApplication.IsNetworkCourse = specialtyCourse.IsNetworkCourse; MinorPlanApplication.IsMainCourse = specialtyCourse.IsMainCourse; MinorPlanApplication.TeachinglanguageID = specialtyCourse.TeachinglanguageID; MinorPlanApplication.HandleModeID = specialtyCourse.HandleModeID; MinorPlanApplication.IsNeedMaterial = specialtyCourse.IsNeedMaterial; MinorPlanApplication.ResultTypeID = specialtyCourse.ResultTypeID; MinorPlanApplication.Remarks = minorPlanApplyView.Remarks; SetNewStatus(MinorPlanApplication); insertList.Add(MinorPlanApplication); EM_MinorPlanApplicationTeachingSetting MinorPlanApplicationTeachingSetting = new EM_MinorPlanApplicationTeachingSetting(); MinorPlanApplicationTeachingSetting.MinorPlanApplicationID = MinorPlanApplication.MinorPlanApplicationID; MinorPlanApplicationTeachingSetting.Credit = specialtyCourse.Credit; MinorPlanApplicationTeachingSetting.TheoryCourse = specialtyCourse.TheoryCourse; MinorPlanApplicationTeachingSetting.Practicehours = specialtyCourse.Practicehours; MinorPlanApplicationTeachingSetting.Trialhours = specialtyCourse.Trialhours; MinorPlanApplicationTeachingSetting.WeeklyNum = specialtyCourse.WeeklyNum; MinorPlanApplicationTeachingSetting.TheoryWeeklyNum = specialtyCourse.TheoryWeeklyNum; MinorPlanApplicationTeachingSetting.PracticeWeeklyNum = specialtyCourse.PracticeWeeklyNum; MinorPlanApplicationTeachingSetting.TrialWeeklyNum = specialtyCourse.TrialWeeklyNum; MinorPlanApplicationTeachingSetting.StartWeeklyNum = specialtyCourse.StartWeeklyNum; MinorPlanApplicationTeachingSetting.EndWeeklyNum = specialtyCourse.EndWeeklyNum; MinorPlanApplicationTeachingSetting.WeeklyHours = specialtyCourse.WeeklyHours; insertSettingList.Add(MinorPlanApplicationTeachingSetting); minorSpecialCourseTeachModeTypeList.Where(x => x.MinorCourseID == specialtyCourse.MinorCourseID).ToList().ForEach(x => { EM_MinorPlanApplicationTeachingModeType specialtyTeachingModeType = new EM_MinorPlanApplicationTeachingModeType(); specialtyTeachingModeType.MinorPlanApplicationTeachingModeTypeID = Guid.NewGuid(); specialtyTeachingModeType.MinorPlanApplicationID = MinorPlanApplication.MinorPlanApplicationID; specialtyTeachingModeType.TeachingModeID = x.TeachingModeID; this.SetNewStatus(specialtyTeachingModeType); insertTeachingModeTypeList.Add(specialtyTeachingModeType); }); minorSpecialCourseTeachPlaceList.Where(x => x.MinorCourseID == specialtyCourse.MinorCourseID).ToList().ForEach(x => { EM_MinorPlanApplicationTeachingPlace specialtyTeachingPlace = new EM_MinorPlanApplicationTeachingPlace(); specialtyTeachingPlace.MinorPlanApplicationTeachingPlaceID = Guid.NewGuid(); specialtyTeachingPlace.MinorPlanApplicationID = MinorPlanApplication.MinorPlanApplicationID; specialtyTeachingPlace.TeachingPlace = x.TeachingPlace; this.SetNewStatus(specialtyTeachingPlace); insertTeachingPlaceList.Add(specialtyTeachingPlace); }); } UnitOfWork.BulkInsert(insertList); UnitOfWork.BulkInsert(insertSettingList); UnitOfWork.BulkInsert(insertTeachingModeTypeList); UnitOfWork.BulkInsert(insertTeachingPlaceList); } catch (Exception) { throw; } } public void MinorPlanEdit(MinorPlanApplyView minorPlanApplyView, List minorSpecialCourseViewList) { try { var existGrademinorApplication = MinorPlanApplyDAL.GrademinorApplicationRepository.GetList(x => x.YearID == minorPlanApplyView.YearID && x.StandardID == minorPlanApplyView.StandardID && x.GradeMinorApplicationID != minorPlanApplyView.GradeMinorApplicationID).FirstOrDefault(); if (existGrademinorApplication != null) { throw new Exception(minorPlanApplyView.YearID + "级" + minorPlanApplyView.StandardName + "的辅修申请已存在。"); } var graduatingSemester = EMIS.Utility.Const.LOCAL_SETTING_ENTRANCESEMESTERID; if (graduatingSemester == null) { throw new Exception("入学学期(春季、上学期、秋季、下学期)未配置,请检查"); } var SchoolcodeID = Convert.ToInt32(graduatingSemester); var schoolYearList = this.schoolYearDAL.schoolyearRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList(); var GrademinorApplication = MinorPlanApplyDAL.GrademinorApplicationRepository.GetList(x => x.GradeMinorApplicationID == minorPlanApplyView.GradeMinorApplicationID).FirstOrDefault(); var minorSpecialCourseIDList = minorSpecialCourseViewList.Select(x => x.MinorCourseID).ToList(); var MinorPlanApplicationIDList = MinorPlanApplyDAL.MinorPlanApplicationRepository.GetList(x => x.GrademinorApplicationID == minorPlanApplyView.GradeMinorApplicationID).Select(x => x.MinorPlanApplicationID).ToList(); var minorSpecialCourseTeachModeTypeList = MinorPlanApplyDAL.MinorCourseTeachingModeTypeRepository.GetList(x => minorSpecialCourseIDList.Contains(x.MinorCourseID)).ToList(); var minorSpecialCourseTeachPlaceList = MinorPlanApplyDAL.MinorCourseTeachingPlaceRepository.GetList(x => minorSpecialCourseIDList.Contains(x.MinorCourseID)).ToList(); var minorSpecialCourseList=MinorPlanApplyDAL.MinorCourseRepository.GetList(x=>minorSpecialCourseIDList.Contains(x.MinorCourseID)); var nowSchoolYear = schoolYearList.Where(x => x.IsCurrent == true).FirstOrDefault(); var isother = minorSpecialCourseList.Where(x => x.StandardID != minorPlanApplyView.StandardID).FirstOrDefault(); if (isother!=null) { throw new Exception("所选课程中有其他专业的课程请重新选择"); } if (MinorPlanApplicationIDList.Count>0) { UnitOfWork.Delete(x =>MinorPlanApplicationIDList.Contains(x.MinorPlanApplicationID)); UnitOfWork.Delete(x => MinorPlanApplicationIDList.Contains((Guid)x.MinorPlanApplicationID)); UnitOfWork.Delete(x => MinorPlanApplicationIDList.Contains((Guid)x.MinorPlanApplicationID)); UnitOfWork.Delete(x => MinorPlanApplicationIDList.Contains(x.MinorPlanApplicationID)); } if (GrademinorApplication != null) { CF_GrademinorApplication GrademinorApplications = GrademinorApplication; GrademinorApplications.StudentLimit = minorPlanApplyView.StudentLimit; GrademinorApplications.CollegeID = minorPlanApplyView.CollegeID; SetModifyStatus(GrademinorApplication); UnitOfWork.Commit(); List insertList = new List(); List insertSettingList = new List(); List insertTeachingModeTypeList = new List(); List insertTeachingPlaceList = new List(); foreach (var specialtyCourse in minorSpecialCourseViewList) { var startSchoolyear = schoolYearList.FirstOrDefault(x => x.Years == minorPlanApplyView.YearID && x.SchoolcodeID == SchoolcodeID); if (startSchoolyear == null) { throw new Exception("未能匹配到学年学期,请设置学年学期。"); } var courseSchoolyear = schoolYearList.FirstOrDefault(x => x.Value == (startSchoolyear.Value + ((specialtyCourse.SchoolyearNumID - 1) * 2) + (specialtyCourse.SchoolcodeID == SchoolcodeID ? 0 : 1))); if (courseSchoolyear == null) { throw new Exception("课程" + specialtyCourse.CourseName + "的开课学年学期尚未设置,请先前往校历管理设置相应的学年学期。"); } EM_MinorPlanApplication MinorPlanApplication = new EM_MinorPlanApplication(); MinorPlanApplication.MinorPlanApplicationID = Guid.NewGuid(); MinorPlanApplication.GrademinorApplicationID = minorPlanApplyView.GradeMinorApplicationID; MinorPlanApplication.StarttermID = specialtyCourse.StarttermID; MinorPlanApplication.DepartmentID = specialtyCourse.DepartmentID; MinorPlanApplication.CoursematerialID = specialtyCourse.CoursematerialID; MinorPlanApplication.CourseStructureID = specialtyCourse.CourseStructureID; MinorPlanApplication.CourseCategoryID = specialtyCourse.CourseCategoryID; MinorPlanApplication.CourseTypeID = specialtyCourse.CourseTypeID; MinorPlanApplication.CourseQualityID = specialtyCourse.CourseQualityID; MinorPlanApplication.PracticeTypeID = specialtyCourse.PracticeTypeID; MinorPlanApplication.ExaminationModeID = specialtyCourse.ExaminationModeID; MinorPlanApplication.CourseFineID = specialtyCourse.CourseFineID; MinorPlanApplication.IsSpecialtycore = specialtyCourse.IsSpecialtycore; MinorPlanApplication.IsCooperation = specialtyCourse.IsCooperation; MinorPlanApplication.IsRequired = specialtyCourse.IsRequired; MinorPlanApplication.IsElective = specialtyCourse.IsElective; MinorPlanApplication.IsNetworkCourse = specialtyCourse.IsNetworkCourse; MinorPlanApplication.IsMainCourse = specialtyCourse.IsMainCourse; MinorPlanApplication.TeachinglanguageID = specialtyCourse.TeachinglanguageID; MinorPlanApplication.HandleModeID = specialtyCourse.HandleModeID; MinorPlanApplication.IsNeedMaterial = specialtyCourse.IsNeedMaterial; MinorPlanApplication.ResultTypeID = specialtyCourse.ResultTypeID; MinorPlanApplication.Remarks = minorPlanApplyView.Remarks; SetNewStatus(MinorPlanApplication); insertList.Add(MinorPlanApplication); EM_MinorPlanApplicationTeachingSetting MinorPlanApplicationTeachingSetting = new EM_MinorPlanApplicationTeachingSetting(); MinorPlanApplicationTeachingSetting.MinorPlanApplicationID = MinorPlanApplication.MinorPlanApplicationID; MinorPlanApplicationTeachingSetting.Credit = specialtyCourse.Credit; MinorPlanApplicationTeachingSetting.TheoryCourse = specialtyCourse.TheoryCourse; MinorPlanApplicationTeachingSetting.Practicehours = specialtyCourse.Practicehours; MinorPlanApplicationTeachingSetting.Trialhours = specialtyCourse.Trialhours; MinorPlanApplicationTeachingSetting.WeeklyNum = specialtyCourse.WeeklyNum; MinorPlanApplicationTeachingSetting.TheoryWeeklyNum = specialtyCourse.TheoryWeeklyNum; MinorPlanApplicationTeachingSetting.PracticeWeeklyNum = specialtyCourse.PracticeWeeklyNum; MinorPlanApplicationTeachingSetting.TrialWeeklyNum = specialtyCourse.TrialWeeklyNum; MinorPlanApplicationTeachingSetting.StartWeeklyNum = specialtyCourse.StartWeeklyNum; MinorPlanApplicationTeachingSetting.EndWeeklyNum = specialtyCourse.EndWeeklyNum; MinorPlanApplicationTeachingSetting.WeeklyHours = specialtyCourse.WeeklyHours; insertSettingList.Add(MinorPlanApplicationTeachingSetting); minorSpecialCourseTeachModeTypeList.Where(x => x.MinorCourseID == specialtyCourse.MinorCourseID).ToList().ForEach(x => { EM_MinorPlanApplicationTeachingModeType specialtyTeachingModeType = new EM_MinorPlanApplicationTeachingModeType(); specialtyTeachingModeType.MinorPlanApplicationTeachingModeTypeID = Guid.NewGuid(); specialtyTeachingModeType.MinorPlanApplicationID = MinorPlanApplication.MinorPlanApplicationID; specialtyTeachingModeType.TeachingModeID = x.TeachingModeID; this.SetNewStatus(specialtyTeachingModeType); insertTeachingModeTypeList.Add(specialtyTeachingModeType); }); minorSpecialCourseTeachPlaceList.Where(x => x.MinorCourseID == specialtyCourse.MinorCourseID).ToList().ForEach(x => { EM_MinorPlanApplicationTeachingPlace specialtyTeachingPlace = new EM_MinorPlanApplicationTeachingPlace(); specialtyTeachingPlace.MinorPlanApplicationTeachingPlaceID = Guid.NewGuid(); specialtyTeachingPlace.MinorPlanApplicationID = MinorPlanApplication.MinorPlanApplicationID; specialtyTeachingPlace.TeachingPlace = x.TeachingPlace; this.SetNewStatus(specialtyTeachingPlace); insertTeachingPlaceList.Add(specialtyTeachingPlace); }); } UnitOfWork.BulkInsert(insertList); UnitOfWork.BulkInsert(insertSettingList); UnitOfWork.BulkInsert(insertTeachingModeTypeList); UnitOfWork.BulkInsert(insertTeachingPlaceList); } else { CF_GrademinorApplication GrademinorApplications = new CF_GrademinorApplication() ; GrademinorApplications.GradeMinorApplicationID = Guid.NewGuid(); GrademinorApplications.SchoolyearID = nowSchoolYear.SchoolyearID; GrademinorApplications.CollegeID = minorPlanApplyView.CollegeID; GrademinorApplications.StandardID = minorPlanApplyView.StandardID; GrademinorApplications.YearID = minorPlanApplyView.YearID; GrademinorApplications.StudentLimit = minorPlanApplyView.StudentLimit; SetNewStatus(GrademinorApplications); UnitOfWork.Add(GrademinorApplications); UnitOfWork.Commit(); List insertList = new List(); List insertSettingList = new List(); List insertTeachingModeTypeList = new List(); List insertTeachingPlaceList = new List(); foreach (var specialtyCourse in minorSpecialCourseViewList) { var startSchoolyear = schoolYearList.FirstOrDefault(x => x.Years == minorPlanApplyView.YearID && x.SchoolcodeID == SchoolcodeID); if (startSchoolyear == null) { throw new Exception("未能匹配到学年学期,请设置学年学期。"); } var courseSchoolyear = schoolYearList.FirstOrDefault(x => x.Value == (startSchoolyear.Value + ((specialtyCourse.SchoolyearNumID - 1) * 2) + (specialtyCourse.SchoolcodeID == SchoolcodeID ? 0 : 1))); if (courseSchoolyear == null) { throw new Exception("课程" + specialtyCourse.CourseName + "的开课学年学期尚未设置,请先前往校历管理设置相应的学年学期。"); } EM_MinorPlanApplication MinorPlanApplication = new EM_MinorPlanApplication(); MinorPlanApplication.MinorPlanApplicationID = Guid.NewGuid(); MinorPlanApplication.GrademinorApplicationID = GrademinorApplications.GradeMinorApplicationID; MinorPlanApplication.StarttermID = specialtyCourse.StarttermID; MinorPlanApplication.DepartmentID = specialtyCourse.DepartmentID; MinorPlanApplication.CoursematerialID = specialtyCourse.CoursematerialID; MinorPlanApplication.CourseStructureID = specialtyCourse.CourseStructureID; MinorPlanApplication.CourseCategoryID = specialtyCourse.CourseCategoryID; MinorPlanApplication.CourseTypeID = specialtyCourse.CourseTypeID; MinorPlanApplication.CourseQualityID = specialtyCourse.CourseQualityID; MinorPlanApplication.PracticeTypeID = specialtyCourse.PracticeTypeID; MinorPlanApplication.ExaminationModeID = specialtyCourse.ExaminationModeID; MinorPlanApplication.CourseFineID = specialtyCourse.CourseFineID; MinorPlanApplication.IsSpecialtycore = specialtyCourse.IsSpecialtycore; MinorPlanApplication.IsCooperation = specialtyCourse.IsCooperation; MinorPlanApplication.IsRequired = specialtyCourse.IsRequired; MinorPlanApplication.IsElective = specialtyCourse.IsElective; MinorPlanApplication.IsNetworkCourse = specialtyCourse.IsNetworkCourse; MinorPlanApplication.IsMainCourse = specialtyCourse.IsMainCourse; MinorPlanApplication.TeachinglanguageID = specialtyCourse.TeachinglanguageID; MinorPlanApplication.HandleModeID = specialtyCourse.HandleModeID; MinorPlanApplication.IsNeedMaterial = specialtyCourse.IsNeedMaterial; MinorPlanApplication.ResultTypeID = specialtyCourse.ResultTypeID; MinorPlanApplication.Remarks = minorPlanApplyView.Remarks; SetNewStatus(MinorPlanApplication); insertList.Add(MinorPlanApplication); EM_MinorPlanApplicationTeachingSetting MinorPlanApplicationTeachingSetting = new EM_MinorPlanApplicationTeachingSetting(); MinorPlanApplicationTeachingSetting.MinorPlanApplicationID = MinorPlanApplication.MinorPlanApplicationID; MinorPlanApplicationTeachingSetting.Credit = specialtyCourse.Credit; MinorPlanApplicationTeachingSetting.TheoryCourse = specialtyCourse.TheoryCourse; MinorPlanApplicationTeachingSetting.Practicehours = specialtyCourse.Practicehours; MinorPlanApplicationTeachingSetting.Trialhours = specialtyCourse.Trialhours; MinorPlanApplicationTeachingSetting.WeeklyNum = specialtyCourse.WeeklyNum; MinorPlanApplicationTeachingSetting.TheoryWeeklyNum = specialtyCourse.TheoryWeeklyNum; MinorPlanApplicationTeachingSetting.PracticeWeeklyNum = specialtyCourse.PracticeWeeklyNum; MinorPlanApplicationTeachingSetting.TrialWeeklyNum = specialtyCourse.TrialWeeklyNum; MinorPlanApplicationTeachingSetting.StartWeeklyNum = specialtyCourse.StartWeeklyNum; MinorPlanApplicationTeachingSetting.EndWeeklyNum = specialtyCourse.EndWeeklyNum; MinorPlanApplicationTeachingSetting.WeeklyHours = specialtyCourse.WeeklyHours; insertSettingList.Add(MinorPlanApplicationTeachingSetting); minorSpecialCourseTeachModeTypeList.Where(x => x.MinorCourseID == specialtyCourse.MinorCourseID).ToList().ForEach(x => { EM_MinorPlanApplicationTeachingModeType specialtyTeachingModeType = new EM_MinorPlanApplicationTeachingModeType(); specialtyTeachingModeType.MinorPlanApplicationTeachingModeTypeID = Guid.NewGuid(); specialtyTeachingModeType.MinorPlanApplicationID = MinorPlanApplication.MinorPlanApplicationID; specialtyTeachingModeType.TeachingModeID = x.TeachingModeID; this.SetNewStatus(specialtyTeachingModeType); insertTeachingModeTypeList.Add(specialtyTeachingModeType); }); minorSpecialCourseTeachPlaceList.Where(x => x.MinorCourseID == specialtyCourse.MinorCourseID).ToList().ForEach(x => { EM_MinorPlanApplicationTeachingPlace specialtyTeachingPlace = new EM_MinorPlanApplicationTeachingPlace(); specialtyTeachingPlace.MinorPlanApplicationTeachingPlaceID = Guid.NewGuid(); specialtyTeachingPlace.MinorPlanApplicationID = MinorPlanApplication.MinorPlanApplicationID; specialtyTeachingPlace.TeachingPlace = x.TeachingPlace; this.SetNewStatus(specialtyTeachingPlace); insertTeachingPlaceList.Add(specialtyTeachingPlace); }); } UnitOfWork.BulkInsert(insertList); UnitOfWork.BulkInsert(insertSettingList); UnitOfWork.BulkInsert(insertTeachingModeTypeList); UnitOfWork.BulkInsert(insertTeachingPlaceList); } } catch (Exception) { throw; } } public MinorPlanApplyView GetMinorPlanApplyView(Guid? GradeMinorApplicationIDs) { Expression> exp = (x => x.GradeMinorApplicationID == GradeMinorApplicationIDs); var MinorApplication = MinorPlanApplyDAL.GetMinorPlanApplyViewQueryable(exp).FirstOrDefault(); return MinorApplication; } /// /// 复制年级 /// /// /// public string SpecialtyPlanCopyByGrade(MinorPlanApplyView minorPlanApplyView) { try { var graduatingSemester = EMIS.Utility.Const.LOCAL_SETTING_ENTRANCESEMESTERID; if (graduatingSemester == null) { throw new Exception("入学学期(春季、上学期、秋季、下学期)未配置,请检查"); } var SchoolcodeID = Convert.ToInt32(graduatingSemester); var specialtyCourseList = MinorPlanApplyDAL.MinorCourseRepository.GetList(x => true).ToList(); var schoolYearList = this.schoolYearDAL.schoolyearRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE).ToList(); var nowSchoolYear = schoolYearList.Where(x => x.IsCurrent == true).FirstOrDefault(); //找复制源的辅修专业 var sourceList = MinorPlanApplyDAL.GrademinorApplicationRepository.GetList(x => x.YearID == minorPlanApplyView.GrademajorBeForeYear).ToList(); if (minorPlanApplyView.BeForeCollegeID.HasValue) { sourceList = sourceList.Where(x => x.CollegeID == minorPlanApplyView.BeForeCollegeID).ToList(); } List sourceIDList=new List(); foreach(var sourceID in sourceList) { Guid? ID= sourceID.GradeMinorApplicationID; sourceIDList.Add(ID); } //找复制源的辅修计划 var sourceCourseList = MinorPlanApplyDAL.MinorPlanApplicationRepository.GetList(x => sourceIDList.Contains(x.GrademinorApplicationID)).ToList(); var sourceCourseIDList = sourceCourseList.Select(x => x.MinorPlanApplicationID).ToList(); var minorSpecialCourseTeachingSettingList = MinorPlanApplyDAL.MinorPlanApplicationTeachingSettingRepository.GetList(x => sourceCourseIDList.Contains((Guid)x.MinorPlanApplicationID)).ToList(); var minorSpecialCourseTeachModeTypeList = MinorPlanApplyDAL.MinorPlanApplicationTeachingModeTypeRepository.GetList(x => sourceCourseIDList.Contains((Guid)x.MinorPlanApplicationID)).ToList(); var minorSpecialCourseTeachPlaceList = MinorPlanApplyDAL.MinorPlanApplicationTeachingPlaceRepository.GetList(x => sourceCourseIDList.Contains((Guid)x.MinorPlanApplicationID)).ToList(); //找复制源的专业计划 //找到目标辅修专业 var targetList = MinorPlanApplyDAL.GrademinorApplicationRepository.GetList(x => x.YearID == minorPlanApplyView.GrademajorAfterYear).ToList(); int existCount = 0; int copyCount = 0; foreach (var source in sourceList) { var isCanCopy = targetList.Where(x => x.StandardID == source.StandardID).FirstOrDefault(); if (isCanCopy!=null) { existCount = existCount+1; } else { CF_GrademinorApplication GrademinorApplication = new CF_GrademinorApplication(); GrademinorApplication.GradeMinorApplicationID = Guid.NewGuid(); GrademinorApplication.SchoolyearID = nowSchoolYear.SchoolyearID; GrademinorApplication.CollegeID = source.CollegeID; GrademinorApplication.StandardID = source.StandardID; GrademinorApplication.YearID = minorPlanApplyView.GrademajorAfterYear; GrademinorApplication.StudentLimit = source.StudentLimit; SetNewStatus(GrademinorApplication); UnitOfWork.Add(GrademinorApplication); copyCount = copyCount +1; List insertList = new List(); List insertSettingList = new List(); List insertTeachingModeTypeList = new List(); List insertTeachingPlaceList = new List(); #region 插入数据到列表中,准备批量插入 foreach (var specialtyCourse in sourceCourseList) { if (specialtyCourse.GrademinorApplicationID == source.GradeMinorApplicationID) { var startSchoolyear = schoolYearList.FirstOrDefault(x => x.Years == minorPlanApplyView.GrademajorAfterYear && x.SchoolcodeID == SchoolcodeID); if (startSchoolyear == null) { throw new Exception("未能匹配到学年学期,请设置学年学期。"); } var courseSchoolyear = schoolYearList.FirstOrDefault(x => x.Value == (startSchoolyear.Value + specialtyCourse.StarttermID - 1)); if (courseSchoolyear == null) { throw new Exception("课程" + specialtyCourse.EM_Coursematerial.CourseName + "的开课学年学期尚未设置,请先前往校历管理设置相应的学年学期。"); } EM_MinorPlanApplication MinorPlanApplication = new EM_MinorPlanApplication(); MinorPlanApplication.MinorPlanApplicationID = Guid.NewGuid(); MinorPlanApplication.GrademinorApplicationID = GrademinorApplication.GradeMinorApplicationID; MinorPlanApplication.StarttermID = specialtyCourse.StarttermID; MinorPlanApplication.DepartmentID = specialtyCourse.DepartmentID; MinorPlanApplication.CoursematerialID = specialtyCourse.CoursematerialID; MinorPlanApplication.CourseStructureID = specialtyCourse.CourseStructureID; MinorPlanApplication.CourseCategoryID = specialtyCourse.CourseCategoryID; MinorPlanApplication.CourseTypeID = specialtyCourse.CourseTypeID; MinorPlanApplication.CourseQualityID = specialtyCourse.CourseQualityID; MinorPlanApplication.PracticeTypeID = specialtyCourse.PracticeTypeID; MinorPlanApplication.ExaminationModeID = specialtyCourse.ExaminationModeID; MinorPlanApplication.CourseFineID = specialtyCourse.CourseFineID; MinorPlanApplication.IsSpecialtycore = specialtyCourse.IsSpecialtycore; MinorPlanApplication.IsCooperation = specialtyCourse.IsCooperation; MinorPlanApplication.IsRequired = specialtyCourse.IsRequired; MinorPlanApplication.IsElective = specialtyCourse.IsElective; MinorPlanApplication.IsNetworkCourse = specialtyCourse.IsNetworkCourse; MinorPlanApplication.IsMainCourse = specialtyCourse.IsMainCourse; MinorPlanApplication.TeachinglanguageID = specialtyCourse.TeachinglanguageID; MinorPlanApplication.HandleModeID = minorPlanApplyView.HandleModeID; MinorPlanApplication.IsNeedMaterial = minorPlanApplyView.IsNeedMaterial; MinorPlanApplication.ResultTypeID = specialtyCourse.ResultTypeID; MinorPlanApplication.Remarks = minorPlanApplyView.Remarks; SetNewStatus(MinorPlanApplication); insertList.Add(MinorPlanApplication); var minorSpecialCourseTeachingSetting = minorSpecialCourseTeachingSettingList.Where(x => x.MinorPlanApplicationID == specialtyCourse.MinorPlanApplicationID).FirstOrDefault(); EM_MinorPlanApplicationTeachingSetting MinorPlanApplicationTeachingSetting = new EM_MinorPlanApplicationTeachingSetting(); MinorPlanApplicationTeachingSetting.MinorPlanApplicationID = MinorPlanApplication.MinorPlanApplicationID; MinorPlanApplicationTeachingSetting.Credit = minorSpecialCourseTeachingSetting.Credit; MinorPlanApplicationTeachingSetting.TheoryCourse = minorSpecialCourseTeachingSetting.TheoryCourse; MinorPlanApplicationTeachingSetting.Practicehours = minorSpecialCourseTeachingSetting.Practicehours; MinorPlanApplicationTeachingSetting.Trialhours = minorSpecialCourseTeachingSetting.Trialhours; MinorPlanApplicationTeachingSetting.WeeklyNum = minorSpecialCourseTeachingSetting.WeeklyNum; MinorPlanApplicationTeachingSetting.TheoryWeeklyNum = minorSpecialCourseTeachingSetting.TheoryWeeklyNum; MinorPlanApplicationTeachingSetting.PracticeWeeklyNum = minorSpecialCourseTeachingSetting.PracticeWeeklyNum; MinorPlanApplicationTeachingSetting.TrialWeeklyNum = minorSpecialCourseTeachingSetting.TrialWeeklyNum; MinorPlanApplicationTeachingSetting.StartWeeklyNum = minorSpecialCourseTeachingSetting.StartWeeklyNum; MinorPlanApplicationTeachingSetting.EndWeeklyNum = minorSpecialCourseTeachingSetting.EndWeeklyNum; MinorPlanApplicationTeachingSetting.WeeklyHours = minorSpecialCourseTeachingSetting.WeeklyHours; insertSettingList.Add(MinorPlanApplicationTeachingSetting); minorSpecialCourseTeachModeTypeList.Where(x => x.MinorPlanApplicationID == specialtyCourse.MinorPlanApplicationID).ToList().ForEach(x => { EM_MinorPlanApplicationTeachingModeType specialtyTeachingModeType = new EM_MinorPlanApplicationTeachingModeType(); specialtyTeachingModeType.MinorPlanApplicationTeachingModeTypeID = Guid.NewGuid(); specialtyTeachingModeType.MinorPlanApplicationID = MinorPlanApplication.MinorPlanApplicationID; specialtyTeachingModeType.TeachingModeID = x.TeachingModeID; this.SetNewStatus(specialtyTeachingModeType); insertTeachingModeTypeList.Add(specialtyTeachingModeType); }); minorSpecialCourseTeachPlaceList.Where(x => x.MinorPlanApplicationID == specialtyCourse.MinorPlanApplicationID).ToList().ForEach(x => { EM_MinorPlanApplicationTeachingPlace specialtyTeachingPlace = new EM_MinorPlanApplicationTeachingPlace(); specialtyTeachingPlace.MinorPlanApplicationTeachingPlaceID = Guid.NewGuid(); specialtyTeachingPlace.MinorPlanApplicationID = MinorPlanApplication.MinorPlanApplicationID; specialtyTeachingPlace.TeachingPlace = x.TeachingPlace; this.SetNewStatus(specialtyTeachingPlace); insertTeachingPlaceList.Add(specialtyTeachingPlace); }); } } #endregion UnitOfWork.BulkInsert(insertList); UnitOfWork.BulkInsert(insertSettingList); UnitOfWork.BulkInsert(insertTeachingModeTypeList); UnitOfWork.BulkInsert(insertTeachingPlaceList); UnitOfWork.Commit(); } } string Success = ""; if (existCount == 0) { Success = "复制成功,一共复制了" + copyCount + "条。"; } else { Success = "复制成功,一共复制了" + copyCount + "条,有" + existCount+"条已存在没有复制。"; } return Success; } catch (Exception) { throw; } } /// /// 删除 /// /// /// public bool GradeMinorApplicationDelete(List ids) { try { if (ids.Count > 0) { var MinorPlanApplicationIDList = MinorPlanApplyDAL.MinorPlanApplicationRepository.GetList(x => ids.Contains(x.GrademinorApplicationID)).Select(x => x.MinorPlanApplicationID).ToList(); if (MinorPlanApplicationIDList.Count > 0) { UnitOfWork.Delete(x => MinorPlanApplicationIDList.Contains((Guid)x.MinorPlanApplicationID)); UnitOfWork.Delete(x => MinorPlanApplicationIDList.Contains((Guid)x.MinorPlanApplicationID)); UnitOfWork.Delete(x => MinorPlanApplicationIDList.Contains(x.MinorPlanApplicationID)); UnitOfWork.Delete(x => MinorPlanApplicationIDList.Contains(x.MinorPlanApplicationID)); } UnitOfWork.Delete(x => ids.Contains(x.GradeMinorApplicationID)); } return true; } catch (Exception) { throw; } } public int GetStandardID_MinorPlanApplication_MinorSpecialtyPlanCount(List ids) { return MinorPlanApplyDAL.GetStandardID_MinorPlanApplication_MinorSpecialtyPlan(ids); } /// /// 提交申请 /// /// 计划申请ID /// 提交人 /// 备注 public void SubmitPlanApplicationApply(List GradeMinorApplicationIDs, Guid userID, List status, string comment = "") { //在计划申请提交时验证课程的专业计划有无重复 if (GradeMinorApplicationIDs.Count > 0) { var startStatus = this.GetStartStatus(); var backPointStatusList = this.GetBackpointStatus(); var MinorPlanApplyList = MinorPlanApplyDAL.GetMinorPlanApplyViewQueryable (x => GradeMinorApplicationIDs.Contains(x.GradeMinorApplicationID)).ToList(); var wrongStatusList = MinorPlanApplyList.Where(x => x.ApprovalStatus != startStatus && !backPointStatusList.Contains(x.ApprovalStatus)).ToList(); if (wrongStatusList.Count > 0) { throw new Exception("只能处理未提交和已退回的记录,请检查选择的项。"); } var duplicatePlanList = MinorPlanApplyDAL .GetDuplicateSpecialtyPlanApplyView(x => GradeMinorApplicationIDs.Contains(x.GradeMinorApplicationID)).ToList(); var submitList = MinorPlanApplyList.Where(x => x.ApprovalStatus == (int)startStatus).Select(x => (Guid)x.GradeMinorApplicationID).ToList(); var resubmitList = MinorPlanApplyList.Where(x => backPointStatusList.Contains(x.ApprovalStatus) && !submitList.Contains((Guid)x.GradeMinorApplicationID)).Select(x => (Guid)x.GradeMinorApplicationID).ToList(); if (duplicatePlanList.Count > 0) { throw new Exception(string.Join(";", duplicatePlanList.Select(x => x.YearID + "年" + x.StandardName + "专业已经有辅修专业计划,不能重复生成。"))); } try { StartUp(submitList, userID, comment); Approve(resubmitList, userID, Guid.Empty, comment); } catch (Exception) { throw; } } } } }