123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using Bowin.Common.Linq;
- using System.Linq.Expressions;
- using EMIS.Entities;
- using EMIS.ViewModel.EducationManagement;
- using EMIS.DataLogic.EducationManage;
- using Bowin.Common.Linq.Entity;
- using EMIS.DataLogic.EducationSchedule;
- using EMIS.ViewModel;
- using EMIS.DataLogic.SchedulingManage.SchedulingSettings;
- namespace EMIS.CommonLogic.EducationSchedule
- {
- public class EducationMissionClassScheduleServices : BaseServices, IEducationMissionClassScheduleServices
- {
- public EducationMissionClassDAL educationMissionClassDAL { get; set; }
- public EducationMissionClassScheduleDAL educationMissionClassScheduleDAL { get; set; }
- public CollegePriorityDAL collegePriorityDAL { get; set; }
- /// <summary>
- /// 无数据范围限制
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="campusID"></param>
- /// <param name="collegeID"></param>
- /// <param name="schoolyearID"></param>
- /// <param name="departmentID"></param>
- /// <param name="coursematerialID"></param>
- /// <param name="approvalStatus"></param>
- /// <param name="teachingModeID"></param>
- /// <param name="grademajorID"></param>
- /// <param name="gradeYearID"></param>
- /// <param name="StandardID"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public Bowin.Common.Linq.Entity.IGridResultSet<ViewModel.EducationManagement.EducationMissionClassView> GetEducationMissionClassScheduleViewGrid(ViewModel.ConfiguretView configuretView, Guid? campusID, Guid? collegeID, Guid? schoolyearID, Guid? departmentID, Guid? coursematerialID, int? approvalStatus, int? teachingModeID, Guid? grademajorID, int? gradeYearID, int? StandardID, int pageIndex, int pageSize)
- {
- Expression<Func<EM_EducationMissionClass, bool>> exp = (x => true);
- Expression<Func<EM_ExecutablePlan, bool>> executablePlanExp = (x => true);
- Expression<Func<EM_ExecutableOptionalCourse, bool>> executableOptionalCourseExp = (x => true);
- Expression<Func<EM_ExecutableFreeSelectionCouse, bool>> executableFreeSelectionCourseCourseExp = (x => true);
- //if(StandardID.HasValue)
- //{
- // executablePlanExp = executablePlanExp.And(x => x.CF_Grademajor.CF_Facultymajor.StandardID == StandardID);
- //}
- if (campusID.HasValue)
- {
- exp = exp.And(x => x.EM_EducationMission.CF_College.CampusID == campusID);
- }
- if (collegeID.HasValue)
- {
- exp = exp.And(x => x.EM_EducationMission.CollegeID == collegeID);
- }
- if (departmentID.HasValue)
- {
- exp = exp.And(x => x.EM_EducationMission.DepartmentID == departmentID);
- }
- //if (gradeYearID.HasValue)
- //{
- // //exp = exp.And(x => x.EM_ExecutablePlan.CF_Grademajor.SchoolyearID == gradeYearID);
- // executablePlanExp = executablePlanExp.And(x => x.CF_Grademajor.SchoolyearID == gradeYearID);
- // executableOptionalCourseExp = executableOptionalCourseExp.And(x => x.CF_Grademajor.SchoolyearID == gradeYearID);
- //}
- //if (grademajorID.HasValue)
- //{
- // //exp = exp.And(x => x.EM_ExecutablePlan.GrademajorID == grademajorID);
- // executablePlanExp = executablePlanExp.And(x => x.GrademajorID == grademajorID);
- // executableOptionalCourseExp = executableOptionalCourseExp.And(x => x.GrademajorID == grademajorID);
- //}
- if (schoolyearID.HasValue)
- {
- exp = exp.And(x => x.EM_EducationMission.SchoolyearID == schoolyearID);
- }
- if (coursematerialID.HasValue)
- {
- exp = exp.And(x => x.CoursematerialID == coursematerialID);
- executablePlanExp = executablePlanExp.And(x => x.CoursematerialID == coursematerialID);
- executableOptionalCourseExp = executableOptionalCourseExp.And(x => x.EM_OptionalCoursePlan.CoursematerialID == coursematerialID);
- executableFreeSelectionCourseCourseExp = executableFreeSelectionCourseCourseExp.And(x => x.EM_FreeSelectionCouse.CoursematerialID == coursematerialID);
- }
- if (approvalStatus.HasValue)
- {
- exp = exp.And(x => x.RecordStatus == approvalStatus);
- }
- if (teachingModeID.HasValue)
- {
- exp = exp.And(x => x.TeachingModeID == teachingModeID);
- }
- var query = educationMissionClassScheduleDAL.GetEducationMissionClassViewQueryble(exp, executablePlanExp,
- executableOptionalCourseExp, executableFreeSelectionCourseCourseExp);
- if (StandardID.HasValue)
- {
- query = query.Where(x => x.StandardID == StandardID);
- }
- if (grademajorID.HasValue)
- {
- query = query.Where(x => x.GrademajorID == grademajorID);
- }
- if (gradeYearID.HasValue)
- {
- query = query.Where(x => x.GradeYearID == gradeYearID);
- }
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- }
- query = this.GetQueryByDataRangeByCollege(query);
- var result = query.OrderByDescending(x => x.SchoolyearCode)
- .ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo).ThenByDescending(x => x.GradeYearID)
- .ThenBy(x => x.StandardID).ThenBy(x => x.CourseName).ThenBy(x => x.OrderNo).ThenBy(x => x.Name)
- .ToGridResultSet<EducationMissionClassView>(pageIndex, pageSize);
- var educationMissionClassID = result.rows.Select(x => x.EducationMissionClassID).ToList();
- var missionClassTeacherList = educationMissionClassDAL.GetMissionClassTeacherQuery(x => educationMissionClassID.Contains(x.EducationMissionClassID)).ToList();
- result.rows.ForEach(x => x.MissionClassTeacherView = new HashSet<MissionClassTeacherView>(missionClassTeacherList.Where(y => y.EducationMissionClassID == x.EducationMissionClassID)));
- return result;
- }
- public List<EducationMissionClassView> GetEducationMissionClassScheduleViewList(ViewModel.ConfiguretView configuretView, Guid? campusID, Guid? collegeID, Guid? schoolyearID, Guid? departmentID, Guid? coursematerialID, int? approvalStatus, int? teachingModeID, Guid? grademajorID, int? gradeYearID)
- {
- Expression<Func<EM_EducationMissionClass, bool>> exp = (x => true);
- Expression<Func<EM_ExecutablePlan, bool>> executablePlanExp = (x => true);
- Expression<Func<EM_ExecutableOptionalCourse, bool>> executableOptionalCourseExp = (x => true);
- Expression<Func<EM_ExecutableFreeSelectionCouse, bool>> executableFreeSelectionCourseCourseExp = (x => true);
- if (campusID.HasValue)
- {
- exp = exp.And(x => x.EM_EducationMission.CF_College.CampusID == campusID);
- }
- if (collegeID.HasValue)
- {
- exp = exp.And(x => x.EM_EducationMission.CollegeID == collegeID);
- }
- if (departmentID.HasValue)
- {
- exp = exp.And(x => x.EM_EducationMission.DepartmentID == departmentID);
- }
- if (gradeYearID.HasValue)
- {
- //exp = exp.And(x => x.EM_ExecutablePlan.CF_Grademajor.SchoolyearID == gradeYearID);
- executablePlanExp = executablePlanExp.And(x => x.CF_Grademajor.GradeID == gradeYearID);
- executableOptionalCourseExp = executableOptionalCourseExp.And(x => x.CF_Grademajor.GradeID == gradeYearID);
- }
- if (grademajorID.HasValue)
- {
- //exp = exp.And(x => x.EM_ExecutablePlan.GrademajorID == grademajorID);
- executablePlanExp = executablePlanExp.And(x => x.GrademajorID == grademajorID);
- executableOptionalCourseExp = executableOptionalCourseExp.And(x => x.GrademajorID == grademajorID);
- }
- if (schoolyearID.HasValue)
- {
- exp = exp.And(x => x.EM_EducationMission.SchoolyearID == schoolyearID);
- }
- if (coursematerialID.HasValue)
- {
- exp = exp.And(x => x.CoursematerialID == coursematerialID);
- executablePlanExp = executablePlanExp.And(x => x.CoursematerialID == coursematerialID);
- executableOptionalCourseExp = executableOptionalCourseExp.And(x => x.EM_OptionalCoursePlan.CoursematerialID == coursematerialID);
- executableFreeSelectionCourseCourseExp = executableFreeSelectionCourseCourseExp.And(x => x.EM_FreeSelectionCouse.CoursematerialID == coursematerialID);
- }
- if (approvalStatus.HasValue)
- {
- exp = exp.And(x => x.RecordStatus == approvalStatus);
- }
- if (teachingModeID.HasValue)
- {
- exp = exp.And(x => x.TeachingModeID == teachingModeID);
- }
- var query = educationMissionClassScheduleDAL.GetEducationMissionClassViewQueryble(exp, executablePlanExp,
- executableOptionalCourseExp, executableFreeSelectionCourseCourseExp);
- var educationMissionClassID = query.Select(x => x.EducationMissionClassID).ToList();
- var missionClassTeacherList = educationMissionClassDAL.GetMissionClassTeacherQuery(x => educationMissionClassID.Contains(x.EducationMissionClassID)).ToList();
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- }
- query = this.GetQueryByDataRangeByCollege(query);
- var result = this.GetQueryByDataRangeByCollege(query).OrderByDescending(x => x.SchoolyearCode)
- .ThenBy(x => x.CollegeNo.Length).ThenBy(x => x.CollegeNo).ThenByDescending(x => x.GradeYearID)
- .ThenBy(x => x.StandardID).ThenBy(x => x.CourseName).ThenBy(x => x.OrderNo).ThenBy(x => x.Name)
- .ToList();
- result.ForEach(x => x.MissionClassTeacherView = new HashSet<MissionClassTeacherView>(missionClassTeacherList.Where(y => y.EducationMissionClassID == x.EducationMissionClassID)));
- return result;
- }
- public void Delete(List<Guid?> educationMissionClassIDs)
- {
- #region 检查课表是否已提交
- var submittedCollege = this.educationMissionClassDAL.GetSchedulingSubmittedCollege(educationMissionClassIDs).ToList();
- if (submittedCollege.Count != 0)
- {
- string collegeNameString = string.Join("、", submittedCollege.Select(x => x.Name));
- throw new Exception(collegeNameString + "的课表已经提交并形成正式课表,因此无法撤销。");
- }
- #endregion
- #region 根据教学任务、删除排课未提交状态的相关信息
- var educationSchedulingClassList = this.educationMissionClassDAL.EducationSchedulingClassRepository
- .GetList(x => educationMissionClassIDs.Contains(x.EM_EducationMissionClass.EducationMissionClassID)).Select(w => w.EducationSchedulingClassID)
- .ToList();
- var educationSchedulingList = this.educationMissionClassDAL.EducationSchedulingRepository
- .GetList(x => educationSchedulingClassList.Contains(x.EM_EducationSchedulingClass.EducationSchedulingClassID)
- , (x => x.ES_EducationSchedulingTeacher), (x => x.ES_EducationSchedulingWeekNum))
- .ToList();
- foreach (var educationScheduling in educationSchedulingList)
- {
- UnitOfWork.Delete<ES_EducationSchedulingTeacher>(x => x.EducationSchedulingID == educationScheduling.EducationSchedulingID);
- UnitOfWork.Delete<ES_EducationSchedulingWeekNum>(x => x.EducationSchedulingID == educationScheduling.EducationSchedulingID);
- UnitOfWork.Delete<ES_EducationScheduling>(x => x.EducationSchedulingID == educationScheduling.EducationSchedulingID);
- }
- var educationMissionClassList = educationMissionClassDAL.EducationMissionClassRepository.GetList(x => educationMissionClassIDs.Contains(x.EducationMissionClassID)).ToList();
- educationMissionClassList.ForEach(x =>
- {
- x.RecordStatus = (int)EM_EducationMissionClassStatus.Submitted;
- UnitOfWork.Update(x);
- });
- #endregion
- UnitOfWork.Commit();
- }
- }
- }
|