123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel.EducationManage;
- using EMIS.ViewModel;
- using System.Linq.Expressions;
- using EMIS.Entities;
- using EMIS.DataLogic.EducationManage;
- using EMIS.CommonLogic.SchedulingManage.ScheduleApproval;
- using EMIS.Utility.FormValidate;
- using EMIS.ViewModel.EducationSchedule;
- using EMIS.ViewModel.SchedulingManage.ScheduleApproval;
- namespace EMIS.CommonLogic.EducationManage
- {
- public class EducationSchedulingClassServices : BaseServices, IEducationSchedulingClassServices
- {
- public EducationSchedulingClassDAL EducationSchedulingClassDAL { get; set; }
- public Lazy<ICollegeScheduleApprovalServices> CollegeScheduleApprovalServices { get; set; }
- /// <summary>
- /// 获取完整结构的任务班视图的方法,主要是要组合教师列表和上课周列表
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="exp"></param>
- /// <param name="resultExp"></param>
- /// <param name="dataRangeFunc"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<EducationSchedulingClassScheduleView> GetEducationSchedulingClassView(ConfiguretView configuretView,
- Expression<Func<EM_EducationSchedulingClass, bool>> exp,
- Expression<Func<EducationSchedulingClassScheduleView, bool>> resultExp = null,
- Func<IQueryable<EducationSchedulingClassScheduleView>, Expression<Func<EducationSchedulingClassScheduleView, Guid?>>,
- IQueryable<EducationSchedulingClassScheduleView>> dataRangeFunc = null,
- int? pageIndex = null, int? pageSize = null)
- {
- var educationSchedulingClassViewQueryable = EducationSchedulingClassDAL.GetEducationSchedulingClassViewQueryable(exp);
- var classMajorQueryable = EducationSchedulingClassDAL.GetClassmajorQueryable(exp);
- var teacherViewQueryable = EducationSchedulingClassDAL.GetTeacherViewQueryable(exp);
- var educationMissionClassSettingQueryable = EducationSchedulingClassDAL.GetEducationMissionClassSettingQueryable(exp);
- var courseProcessQueryable = EducationSchedulingClassDAL.GetCourseProcessViewQueryable(exp);
- var courseProcessTeacherQueryable = this.EducationSchedulingClassDAL.GetCourseProcessTeacherViewQueryable(exp);
- if (resultExp != null)
- {
- educationSchedulingClassViewQueryable = educationSchedulingClassViewQueryable.Where(resultExp);
- }
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- educationSchedulingClassViewQueryable = educationSchedulingClassViewQueryable
- .DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
- }
- if (dataRangeFunc != null)
- {
- educationSchedulingClassViewQueryable = dataRangeFunc
- .Invoke(educationSchedulingClassViewQueryable, null);
- }
- IGridResultSet<EducationSchedulingClassScheduleView> result;
- List<EducationMissionClassTeacherListView> teacherViewList;
- List<EM_EducationMissionClassSettings> educationMissionClassSettingList;
- List<EducationMissionClassContainClassView> classMajorList;
- List<CourseProcessView> courseProcessList;
- var startStatus = CollegeScheduleApprovalServices.Value.GetStartStatus();
- var collegeScheduleApprovalViewList = new List<CollegeScheduleApprovalView>();
-
- if (pageIndex.HasValue && pageSize.HasValue)
- {
- result = educationSchedulingClassViewQueryable.OrderBy(x => x.EducationMissionClassOrderNo)
- .ToGridResultSet(pageIndex, pageSize);
- //var isCanApprove = CollegeScheduleApprovalServices.Value.IsCanApprove(collegeStatus.CollegeScheduleStatusID, CustomPrincipal.Current.UserID);
- collegeScheduleApprovalViewList = CollegeScheduleApprovalServices.Value.GetCollegeScheduleApprovalViewList(
- result.rows.GroupBy(x => new { x.CourseCollegeID, x.SchoolYearID })
- .Select(x => new CollegeSchoolyearView { CollegeID = x.Key.CourseCollegeID.Value, SchoolyearID = x.Key.SchoolYearID.Value }).ToList()
- );
- //由于分页后数据量较少,可以考虑用Contains方法在数据库端筛选一下,不分页的情况就不要了
- var educationMissionClassIDList = result.rows.Select(x => x.EducationMissionClassID).ToList();
- teacherViewList = teacherViewQueryable.Where(x => educationMissionClassIDList.Contains(x.EducationMissionClassID)).ToList();
- classMajorList = classMajorQueryable.Where(x => educationMissionClassIDList.Contains(x.EducationMissionClassID)).ToList();
- educationMissionClassSettingList = educationMissionClassSettingQueryable
- .Where(x => educationMissionClassIDList.Contains(x.EducationMissionClassID)).ToList();
- courseProcessList = courseProcessQueryable.Where(x => educationMissionClassIDList.Contains(x.EducationMissionClassID)).ToList();
- var courseProcessTeacherViewList = courseProcessTeacherQueryable.Where(x => educationMissionClassIDList.Contains(x.EducationMissionClassID)).Distinct().ToList();
- courseProcessList.ForEach(x => x.CourseProcessTeacherViewList = courseProcessTeacherViewList.Where(w => w.CourseProcessID == x.CourseProcessID)
- .OrderBy(w => w.TeachingMethod).ThenBy(w => w.Name).ToList());
- }
- else
- {
- var list = educationSchedulingClassViewQueryable.ToList();
- result = new GridResultSet<EducationSchedulingClassScheduleView>() { rows = list, total = list.Count };
- collegeScheduleApprovalViewList = CollegeScheduleApprovalServices.Value.GetCollegeScheduleApprovalViewList(
- result.rows.GroupBy(x => new { x.CourseCollegeID, x.SchoolYearID })
- .Select(x => new CollegeSchoolyearView { CollegeID = x.Key.CourseCollegeID.Value, SchoolyearID = x.Key.SchoolYearID.Value }).ToList()
- );
- teacherViewList = teacherViewQueryable.ToList();
- classMajorList = classMajorQueryable.ToList();
- educationMissionClassSettingList = educationMissionClassSettingQueryable.ToList();
- courseProcessList = courseProcessQueryable.ToList();
- var courseProcessTeacherViewList = courseProcessTeacherQueryable.Distinct().ToList();
- courseProcessList.ForEach(x => x.CourseProcessTeacherViewList = courseProcessTeacherViewList.Where(w => w.CourseProcessID == x.CourseProcessID)
- .OrderBy(w => w.TeachingMethod).ThenBy(w => w.Name).ToList());
- }
- var submitedCollegeScheduleApprovalViewList = collegeScheduleApprovalViewList.Where(x => x.CollegeScheduleStatusID.HasValue).ToList();
- result.rows.ForEach(x =>
- {
- var collegeScheduleApprovalView = submitedCollegeScheduleApprovalViewList.FirstOrDefault(w => w.CollegeID == x.CourseCollegeID && w.SchoolyearID == x.SchoolYearID);
-
- x.TeacherTeachingViewList = teacherViewList
- .Where(w => x.EducationMissionClassID == w.EducationMissionClassID)
- .Select(w => (BaseTeacherTeachingView)w)
- .OrderBy(w => w.TeachingMethod).ThenBy(w => w.Name).ToList();
- x.WeeklyNumList = educationMissionClassSettingList.Where(w => x.EducationMissionClassID == w.EducationMissionClassID)
- .Select(w => w.WeeklyNum).Distinct().ToList();
- x.ClassMajorIDList = classMajorList.Where(w => x.EducationMissionClassID == w.EducationMissionClassID)
- .Select(w => w.ClassMajor.ClassmajorID).Distinct().ToList();
- x.CourseProcessViewList = courseProcessList.Where(w => x.EducationMissionClassID == w.EducationMissionClassID).ToList();
- x.IsCanEdit = x.IsCanEdit && (collegeScheduleApprovalView == null || collegeScheduleApprovalView.RecordStatus == startStatus);
- });
- return result;
- }
- public List<EducationSchedulingClassScheduleView> GetEducationSchedulingClassViewList(Guid schoolYearID, IList<Guid?> collegeIDList)
- {
- return this.GetEducationSchedulingClassView(new ConfiguretView(),
- (x => collegeIDList.Contains(x.EM_EducationMissionClass.EM_EducationMission.CF_Department.CollegeID)
- && x.EM_EducationMissionClass.EM_EducationMission.SchoolyearID == schoolYearID
- && x.EM_EducationMissionClass.RecordStatus != (int)EM_EducationMissionClassStatus.NotSubmitted
- )).rows;
- }
- public List<EducationSchedulingClassStudentView> GetEducationSchedulingClassStudentViewList(Guid schoolYearID, IList<Guid?> collegeIDList)
- {
- return EducationSchedulingClassDAL.GetEducationSchedulingClassStudentViewQueryable((x => collegeIDList.Contains(x.EM_EducationMissionClass.EM_EducationMission.CF_Department.CollegeID)
- && x.EM_EducationMissionClass.EM_EducationMission.SchoolyearID == schoolYearID
- && x.EM_EducationMissionClass.RecordStatus != (int)EM_EducationMissionClassStatus.NotSubmitted
- )).ToList();
- }
- public List<EducationSchedulingClassScheduleView> GetEducationSchedulingClassViewList(Guid schoolYearID, Guid classMajorID)
- {
- return this.GetEducationSchedulingClassView(new ConfiguretView(),
- (x => x.EM_EducationMissionClass.CF_Classmajor.Any(w => w.ClassmajorID == classMajorID)
- && x.EM_EducationMissionClass.EM_EducationMission.SchoolyearID == schoolYearID
- && x.EM_EducationMissionClass.RecordStatus != (int)EM_EducationMissionClassStatus.NotSubmitted), null,
- this.GetQueryByDataRangeByDepartment).rows;
- }
- public List<EducationSchedulingClassScheduleView> GetDepartmentEducationSchedulingClassViewList(Guid schoolYearID, Guid departmentID, IList<int?> handleModeList)
- {
- return this.GetEducationSchedulingClassView(new ConfiguretView(),
- (x => x.EM_EducationMissionClass.EM_EducationMission.DepartmentID == departmentID
- && x.EM_EducationMissionClass.EM_EducationMission.SchoolyearID == schoolYearID
- && handleModeList.Contains(x.EM_EducationMissionClass.HandleModeID)
- && x.EM_EducationMissionClass.RecordStatus != (int)EM_EducationMissionClassStatus.NotSubmitted), null,
- this.GetQueryByDataRangeByDepartment).rows;
- }
- public EducationSchedulingClassScheduleView GetEducationSchedulingClassView(Guid educationSchedulingClassID)
- {
- return this.GetEducationSchedulingClassView(new ConfiguretView(),
- (x => x.EducationSchedulingClassID == educationSchedulingClassID)).rows.FirstOrDefault();
- }
- }
- }
|