123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334 |
- 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<MinorSpecialtyPlanView> GetMinorSpecialtyViewGrid(ConfiguretView configuretView, Guid? schoolYearID, Guid? CollegeID, int? yearID, int? standardID, Guid? CoursematerialID, int? SchoolyearNumID, int? SchoolcodeID, int pageIndex, int pageSize)
- {
- Expression<Func<EM_MinorPlan, bool>> 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<MinorSpecialtyPlanView>(pageIndex, pageSize);
- return result;
- }
- public IGridResultSet<MinorSpecialtyPlanView> GetMinorSpecialtyViewByMinorSpecialtyIDGrid(Guid? minorSpecialtyID, int pageIndex, int pageSize)
- {
- Expression<Func<EM_MinorPlan, bool>> 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<MinorSpecialtyPlanView>(pageIndex, pageSize);
- return result;
- }
- public List<MinorSpecialtyPlanView> GetMinorSpecialtyViewList(ConfiguretView configuretView, Guid? schoolYearID, Guid? CollegeID, int? yearID, int? standardID, Guid? CoursematerialID, int? SchoolyearNumID, int? SchoolcodeID, List<Guid?> MinorPlanIDList)
- {
- Expression<Func<EM_MinorPlan, bool>> 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<Func<EM_MinorPlan, bool>> exp = (x => x.MinorPlanID == MinorPlanID);
- var query = MinorSpecialtyPlanDAL.GetMinorSpecialtyPlanViewQueryable(exp).FirstOrDefault();
- return query;
- }
- /// <summary>
- /// 获取辅修计划信息
- /// </summary>
- /// <param name="MinorPlanID">辅修计划ID</param>
- /// <returns></returns>
- public Entities.EM_MinorPlan GetMinorPlan(Guid? MinorPlanID)
- {
- //查询条件
- Expression<Func<EM_MinorPlan, bool>> exp = (x => x.MinorPlanID == MinorPlanID);
- return MinorSpecialtyPlanDAL.MinorPlanRepository.GetSingle(exp, (x => x.CF_Department), (x => x.EM_Coursematerial), (x => x.EM_MinorPlanTeachingSetting));
- }
- /// <summary>
- /// 辅修计划设置表
- /// </summary>
- /// <param name="MinorPlanID">辅修计划ID</param>
- /// <returns></returns>
- public EM_MinorPlanTeachingSetting GetMinorPlanTeachingSetting(Guid? MinorPlanID)
- {
- //查询条件
- Expression<Func<EM_MinorPlanTeachingSetting, bool>> exp = (x => x.MinorPlanID == MinorPlanID);
- return MinorSpecialtyPlanDAL.MinorPlanTeachingSettingRepository.GetSingle(exp);
- }
- /// <summary>
- /// 根据专业课程获取授课方式
- /// </summary>
- /// <param name="MinorCourseID">辅修课程</param>
- /// <returns></returns>
- public List<string> GetTeachingModeType(Guid? MinorPlanID)
- {
- return MinorSpecialtyPlanDAL.GetTeachingModeTypeQueryble(MinorPlanID);
- }
- /// <summary>
- /// 根据专业课程获取授课地点
- /// </summary>
- /// <param name="MinorCourseID">辅修课程ID</param>
- /// <returns></returns>
- public List<string> GetTeachingPlace(Guid? MinorPlanID)
- {
- return MinorSpecialtyPlanDAL.GetTeachingPlaceQueryble(MinorPlanID);
- }
- /// <summary>
- /// 获取未使用的课程
- /// </summary>
- /// <param name="yearID"></param>
- /// <param name="standardID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<MinorPlanApplyView> StandardAndMinorSpecialtyCourseViewGrid(int? yearID, int? standardID, int pageIndex, int pageSize)
- {
- Expression<Func<EM_MinorCourse, bool>> 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<MinorPlanApplyView>(pageIndex, pageSize);
- }
- public IList<MinorSpecialtyPlanView> GetStandardIDList(ConfiguretView configuretView, int? yearID)
- {
- Expression<Func<CF_Grademinor, bool>> 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<EM_MinorPlanTeachingModeType>(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<EM_MinorPlanTeachingPlace>(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<MinorSpecialtyPlanView> 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<EM_MinorPlan> insertList = new List<EM_MinorPlan>();
- List<EM_MinorPlanTeachingSetting> insertSettingList = new List<EM_MinorPlanTeachingSetting>();
- List<EM_MinorPlanTeachingModeType> insertTeachingModeTypeList = new List<EM_MinorPlanTeachingModeType>();
- List<EM_MinorPlanTeachingPlace> insertTeachingPlaceList = new List<EM_MinorPlanTeachingPlace>();
- 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<Guid?> MinorPlanIDList)
- {
- try
- {
- if (MinorPlanIDList.Count > 0)
- {
- UnitOfWork.Delete<EM_MinorPlanTeachingSetting>(x => MinorPlanIDList.Contains(x.MinorPlanID));
- UnitOfWork.Delete<EM_MinorPlanTeachingModeType>(x => MinorPlanIDList.Contains(x.MinorPlanID));
- UnitOfWork.Delete<EM_MinorPlanTeachingPlace>(x => MinorPlanIDList.Contains(x.MinorPlanID));
- UnitOfWork.Delete<EM_MinorPlan>(x => MinorPlanIDList.Contains(x.MinorPlanID));
- }
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- }
- }
|