using System; using System.Collections.Generic; using System.Linq; using System.Text; using EMIS.DataLogic.MinorManage.MinorPlanManage; using Bowin.Common.Linq.Entity; using EMIS.ViewModel.MinorManage.MinorPlanManage; using EMIS.ViewModel; using System.Linq.Expressions; using EMIS.Entities; using Bowin.Common.Linq; using EMIS.ViewModel.UniversityManage.SpecialtyClassManage; using EMIS.DataLogic.Common.CalendarManage; namespace EMIS.CommonLogic.MinorManage.MinorPlanManage { public class MinorSpecialtyPlanServices : BaseServices, IMinorSpecialtyPlanServices { public MinorSpecialtyPlanDAL MinorSpecialtyPlanDAL { get; set; } public SchoolYearDAL schoolYearDAL { get; set; } public MinorPlanApplyDAL MinorPlanApplyDAL { get; set; } public IGridResultSet GetMinorSpecialtyViewGrid(ConfiguretView configuretView, Guid? schoolYearID, Guid? CollegeID, int? yearID, int? standardID, Guid? CoursematerialID, int? SchoolyearNumID, int? SchoolcodeID, int pageIndex, int pageSize) { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (yearID.HasValue) exp = exp.And(x => x.CF_Grademinor.YearID == yearID); if (standardID.HasValue) exp = exp.And(x => x.CF_Grademinor.StandardID == standardID); if (CollegeID.HasValue) exp = exp.And(x => x.CF_Grademinor.CollegeID == CollegeID); if (schoolYearID.HasValue) exp = exp.And(x => x.SchoolyearID == schoolYearID); if (CoursematerialID.HasValue) exp = exp.And(x => x.CoursematerialID == CoursematerialID); if (SchoolcodeID.HasValue) exp = exp.And(x => x.CF_Schoolyear.SchoolcodeID == SchoolcodeID); var query = MinorSpecialtyPlanDAL.GetMinorSpecialtyPlanViewQueryable(exp); if (SchoolyearNumID.HasValue) query = query.Where(x => x.SchoolyearNumID == SchoolyearNumID); if (!string.IsNullOrEmpty(configuretView.ConditionValue)) query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue); var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.StandardID).ThenBy(x => x.SchoolcodeStr) .ToGridResultSet(pageIndex, pageSize); return result; } public IGridResultSet GetMinorSpecialtyViewByMinorSpecialtyIDGrid(Guid? minorSpecialtyID, int pageIndex, int pageSize) { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE && x.GrademinorID == minorSpecialtyID); var query = MinorSpecialtyPlanDAL.GetMinorSpecialtyPlanViewQueryable(exp); var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.StandardID).ThenBy(x => x.SchoolcodeStr) .ToGridResultSet(pageIndex, pageSize); return result; } public List GetMinorSpecialtyViewList(ConfiguretView configuretView, Guid? schoolYearID, Guid? CollegeID, int? yearID, int? standardID, Guid? CoursematerialID, int? SchoolyearNumID, int? SchoolcodeID, List MinorPlanIDList) { Expression> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE); if (MinorPlanIDList != null) exp = exp.And(x => MinorPlanIDList.Contains(x.MinorPlanID)); if (yearID.HasValue) exp = exp.And(x => x.CF_Grademinor.YearID == yearID); if (standardID.HasValue) exp = exp.And(x => x.CF_Grademinor.StandardID == standardID); if (CollegeID.HasValue) exp = exp.And(x => x.CF_Grademinor.CollegeID == CollegeID); if (schoolYearID.HasValue) exp = exp.And(x => x.SchoolyearID == schoolYearID); if (CoursematerialID.HasValue) exp = exp.And(x => x.CoursematerialID == CoursematerialID); if (SchoolcodeID.HasValue) exp = exp.And(x => x.CF_Schoolyear.SchoolcodeID == SchoolcodeID); var query = MinorSpecialtyPlanDAL.GetMinorSpecialtyPlanViewQueryable(exp); if (SchoolyearNumID.HasValue) query = query.Where(x => x.SchoolyearNumID == SchoolyearNumID); if (!string.IsNullOrEmpty(configuretView.ConditionValue)) query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue); return this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.StandardID).ThenBy(x => x.SchoolcodeStr).ToList(); } public MinorSpecialtyPlanView GetMinorSpecialtyView(Guid? MinorPlanID) { Expression> exp = (x => x.MinorPlanID == MinorPlanID); var query = MinorSpecialtyPlanDAL.GetMinorSpecialtyPlanViewQueryable(exp).FirstOrDefault(); return query; } /// /// 获取辅修计划信息 /// /// 辅修计划ID /// public Entities.EM_MinorPlan GetMinorPlan(Guid? MinorPlanID) { //查询条件 Expression> exp = (x => x.MinorPlanID == MinorPlanID); return MinorSpecialtyPlanDAL.MinorPlanRepository.GetSingle(exp, (x => x.CF_Department), (x => x.EM_Coursematerial), (x => x.EM_MinorPlanTeachingSetting)); } /// /// 辅修计划设置表 /// /// 辅修计划ID /// public EM_MinorPlanTeachingSetting GetMinorPlanTeachingSetting(Guid? MinorPlanID) { //查询条件 Expression> exp = (x => x.MinorPlanID == MinorPlanID); return MinorSpecialtyPlanDAL.MinorPlanTeachingSettingRepository.GetSingle(exp); } /// /// 根据专业课程获取授课方式 /// /// 辅修课程 /// public List GetTeachingModeType(Guid? MinorPlanID) { return MinorSpecialtyPlanDAL.GetTeachingModeTypeQueryble(MinorPlanID); } /// /// 根据专业课程获取授课地点 /// /// 辅修课程ID /// public List GetTeachingPlace(Guid? MinorPlanID) { return MinorSpecialtyPlanDAL.GetTeachingPlaceQueryble(MinorPlanID); } /// /// 获取未使用的课程 /// /// /// /// /// /// public IGridResultSet StandardAndMinorSpecialtyCourseViewGrid(int? yearID, int? standardID, int pageIndex, int pageSize) { Expression> exp = (x => x.IsEnable == true); var query = MinorSpecialtyPlanDAL.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 IList GetStandardIDList(ConfiguretView configuretView, int? yearID) { Expression> exp = (x => true); if(yearID.HasValue){ exp = exp.And(x => x.YearID == yearID); } var query = MinorSpecialtyPlanDAL.GetStandardView(exp); if (!string.IsNullOrEmpty(configuretView.ConditionValue)) query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue); return query.Distinct().ToList(); } public void MinorSpecialtyCourseEdit(MinorSpecialtyPlanView minorSpecialtyPlanView) { EM_MinorPlan MinorPlan = null; EM_MinorPlanTeachingSetting MinorPlanTeachingSetting = null; MinorPlan = GetMinorPlan(minorSpecialtyPlanView.MinorPlanID); MinorPlanTeachingSetting = GetMinorPlanTeachingSetting(minorSpecialtyPlanView.MinorPlanID); MinorPlan.ResultTypeID = minorSpecialtyPlanView.ResultTypeID; MinorPlan.Remarks = minorSpecialtyPlanView.Remarks; SetModifyStatus(MinorPlan); MinorPlanTeachingSetting.Credit = minorSpecialtyPlanView.Credit; MinorPlanTeachingSetting.TheoryCourse = minorSpecialtyPlanView.TheoryCourse; MinorPlanTeachingSetting.Practicehours = minorSpecialtyPlanView.Practicehours; MinorPlanTeachingSetting.Trialhours = minorSpecialtyPlanView.Trialhours; MinorPlanTeachingSetting.WeeklyNum = minorSpecialtyPlanView.WeeklyNum; MinorPlanTeachingSetting.TheoryWeeklyNum = minorSpecialtyPlanView.TheoryWeeklyNum; MinorPlanTeachingSetting.PracticeWeeklyNum = minorSpecialtyPlanView.PracticeWeeklyNum; MinorPlanTeachingSetting.TrialWeeklyNum = minorSpecialtyPlanView.TrialWeeklyNum; MinorPlanTeachingSetting.StartWeeklyNum = minorSpecialtyPlanView.StartWeeklyNum; MinorPlanTeachingSetting.EndWeeklyNum = minorSpecialtyPlanView.EndWeeklyNum; MinorPlanTeachingSetting.WeeklyHours = minorSpecialtyPlanView.WeeklyHours; UnitOfWork.Update(MinorPlanTeachingSetting); if (minorSpecialtyPlanView.TeachingModeID != null) { UnitOfWork.Delete(x => x.MinorPlanID == MinorPlan.MinorPlanID); foreach (var i in minorSpecialtyPlanView.TeachingModeID) { EM_MinorPlanTeachingModeType MinorPlanTeachingModeType = new EM_MinorPlanTeachingModeType(); MinorPlanTeachingModeType.MinorPlanTeachingModeTypeID = Guid.NewGuid(); MinorPlanTeachingModeType.MinorPlanID = MinorPlan.MinorPlanID; MinorPlanTeachingModeType.TeachingModeID = i; SetNewStatus(MinorPlanTeachingModeType); UnitOfWork.Add(MinorPlanTeachingModeType); } } if (minorSpecialtyPlanView.TeachingPlaceID != null) { UnitOfWork.Delete(x => x.MinorPlanID == MinorPlan.MinorPlanID); foreach (var i in minorSpecialtyPlanView.TeachingPlaceID) { EM_MinorPlanTeachingPlace MinorPlanTeachingPlace = new EM_MinorPlanTeachingPlace(); MinorPlanTeachingPlace.MinorPlanTeachingPlaceID = Guid.NewGuid(); MinorPlanTeachingPlace.MinorPlanID = MinorPlan.MinorPlanID; MinorPlanTeachingPlace.TeachingPlace = i; SetNewStatus(MinorPlanTeachingPlace); UnitOfWork.Add(MinorPlanTeachingPlace); } } UnitOfWork.Commit(); } public void MinorPlanAdd(MinorSpecialtyPlanView minorPlanApplyView, List minorSpecialCourseViewList) { 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 Grademinor = MinorSpecialtyPlanDAL.GrademinorRepository.GetList(x => x.YearID == minorPlanApplyView.YearID && x.StandardID == minorPlanApplyView.StandardID).FirstOrDefault(); 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(); 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_MinorPlan MinorPlan = new EM_MinorPlan(); MinorPlan.MinorPlanID = Guid.NewGuid(); MinorPlan.MinorPlanApplicationID = null; MinorPlan.GrademinorID = Grademinor.GrademinorID; MinorPlan.SchoolyearID = courseSchoolyear.SchoolyearID; MinorPlan.DepartmentID = specialtyCourse.DepartmentID; MinorPlan.CoursematerialID = specialtyCourse.CoursematerialID; MinorPlan.CourseStructureID = specialtyCourse.CourseStructureID; MinorPlan.CourseCategoryID = specialtyCourse.CourseCategoryID; MinorPlan.CourseTypeID = specialtyCourse.CourseTypeID; MinorPlan.CourseQualityID = specialtyCourse.CourseQualityID; MinorPlan.PracticeTypeID = specialtyCourse.PracticeTypeID; MinorPlan.ExaminationModeID = specialtyCourse.ExaminationModeID; MinorPlan.CourseFineID = specialtyCourse.CourseFineID; MinorPlan.IsSpecialtycore = specialtyCourse.IsSpecialtycore; MinorPlan.IsCooperation = specialtyCourse.IsCooperation; MinorPlan.IsRequired = specialtyCourse.IsRequired; MinorPlan.IsElective = specialtyCourse.IsElective; MinorPlan.IsNetworkCourse = specialtyCourse.IsNetworkCourse; MinorPlan.IsMainCourse = specialtyCourse.IsMainCourse; MinorPlan.TeachinglanguageID = specialtyCourse.TeachinglanguageID; MinorPlan.HandleModeID = specialtyCourse.HandleModeID; MinorPlan.IsNeedMaterial = specialtyCourse.IsNeedMaterial; MinorPlan.ResultTypeID = specialtyCourse.ResultTypeID; MinorPlan.Remarks = minorPlanApplyView.Remarks; SetNewStatus(MinorPlan); insertList.Add(MinorPlan); EM_MinorPlanTeachingSetting MinorPlanTeachingSetting = new EM_MinorPlanTeachingSetting(); MinorPlanTeachingSetting.MinorPlanID = MinorPlan.MinorPlanID; MinorPlanTeachingSetting.Credit = specialtyCourse.Credit; MinorPlanTeachingSetting.TheoryCourse = specialtyCourse.TheoryCourse; MinorPlanTeachingSetting.Practicehours = specialtyCourse.Practicehours; MinorPlanTeachingSetting.Trialhours = specialtyCourse.Trialhours; MinorPlanTeachingSetting.WeeklyNum = specialtyCourse.WeeklyNum; MinorPlanTeachingSetting.TheoryWeeklyNum = specialtyCourse.TheoryWeeklyNum; MinorPlanTeachingSetting.PracticeWeeklyNum = specialtyCourse.PracticeWeeklyNum; MinorPlanTeachingSetting.TrialWeeklyNum = specialtyCourse.TrialWeeklyNum; MinorPlanTeachingSetting.StartWeeklyNum = specialtyCourse.StartWeeklyNum; MinorPlanTeachingSetting.EndWeeklyNum = specialtyCourse.EndWeeklyNum; MinorPlanTeachingSetting.WeeklyHours = specialtyCourse.WeeklyHours; insertSettingList.Add(MinorPlanTeachingSetting); minorSpecialCourseTeachModeTypeList.Where(x => x.MinorCourseID == specialtyCourse.MinorCourseID).ToList().ForEach(x => { EM_MinorPlanTeachingModeType specialtyTeachingModeType = new EM_MinorPlanTeachingModeType(); specialtyTeachingModeType.MinorPlanTeachingModeTypeID = Guid.NewGuid(); specialtyTeachingModeType.MinorPlanID = MinorPlan.MinorPlanID; specialtyTeachingModeType.TeachingModeID = x.TeachingModeID; this.SetNewStatus(specialtyTeachingModeType); insertTeachingModeTypeList.Add(specialtyTeachingModeType); }); minorSpecialCourseTeachPlaceList.Where(x => x.MinorCourseID == specialtyCourse.MinorCourseID).ToList().ForEach(x => { EM_MinorPlanTeachingPlace specialtyTeachingPlace = new EM_MinorPlanTeachingPlace(); specialtyTeachingPlace.MinorPlanTeachingPlaceID = Guid.NewGuid(); specialtyTeachingPlace.MinorPlanID = MinorPlan.MinorPlanID; specialtyTeachingPlace.TeachingPlace = x.TeachingPlace; this.SetNewStatus(specialtyTeachingPlace); insertTeachingPlaceList.Add(specialtyTeachingPlace); }); } UnitOfWork.BulkInsert(insertList); UnitOfWork.BulkInsert(insertSettingList); UnitOfWork.BulkInsert(insertTeachingModeTypeList); UnitOfWork.BulkInsert(insertTeachingPlaceList); } public bool MinorPlanDelete(List MinorPlanIDList) { try { if (MinorPlanIDList.Count > 0) { UnitOfWork.Delete(x => MinorPlanIDList.Contains(x.MinorPlanID)); UnitOfWork.Delete(x => MinorPlanIDList.Contains(x.MinorPlanID)); UnitOfWork.Delete(x => MinorPlanIDList.Contains(x.MinorPlanID)); UnitOfWork.Delete(x => MinorPlanIDList.Contains(x.MinorPlanID)); } return true; } catch (Exception) { throw; } } } }