EducationSchedulingClassDAL.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.Repositories;
  6. using EMIS.ViewModel.EducationManage;
  7. using System.Linq.Expressions;
  8. using EMIS.Entities;
  9. using EMIS.DataLogic.Common.Students;
  10. namespace EMIS.DataLogic.EducationManage
  11. {
  12. public class EducationSchedulingClassDAL
  13. {
  14. public EducationSchedulingClassRepository EducationSchedulingClassRepository { get; set; }
  15. public EducationMissionClassRepository EducationMissionClassRepository { get; set; }
  16. public EducationMissionRepository EducationMissionRepository { get; set; }
  17. public EducationMissionClassTeachingSettingRepository EducationMissionClassTeachingSettingRepository { get; set; }
  18. public CoursematerialRepository CoursematerialRepository { get; set; }
  19. public DepartmentRepository DepartmentRepository { get; set; }
  20. public CollegePriorityRepository CollegePriorityRepository { get; set; }
  21. public ClassroomRepository ClassroomRepository { get; set; }
  22. public EducationSchedulingRepository EducationSchedulingRepository { get; set; }
  23. public CoursesTimeRepository CoursesTimeRepository { get; set; }
  24. public CollegeScheduleStatusRepository CollegeScheduleStatusRepository { get; set; }
  25. //public FreeSelectionCousePlanRepository FreeSelectionCousePlanRepository { get; set; }
  26. public Lazy<EducationMissionClassDAL> EducationMissionClassDAL { get; set; }
  27. public IQueryable<EducationSchedulingClassScheduleView> GetEducationSchedulingClassViewQueryable(
  28. Expression<Func<EM_EducationSchedulingClass, bool>> exp)
  29. {
  30. var nowDate = DateTime.Today;
  31. var sql = (from esc in EducationSchedulingClassRepository.GetList(exp)
  32. join emc in EducationMissionClassRepository.Entities on esc.EducationMissionClassID equals emc.EducationMissionClassID
  33. join em in EducationMissionRepository.Entities on emc.EducationMissionID equals em.EducationMissionID
  34. join emcts in EducationMissionClassTeachingSettingRepository.Entities on emc.EducationMissionClassID equals emcts.EducationMissionClassID
  35. join cm in CoursematerialRepository.Entities on emc.CoursematerialID equals cm.CoursematerialID
  36. join d in DepartmentRepository.Entities on em.DepartmentID equals d.DepartmentID
  37. join c in ClassroomRepository.Entities on emc.ClassroomID equals c.ClassroomID into dc
  38. from ec in dc.DefaultIfEmpty()
  39. join cp in CollegePriorityRepository.GetList(x => x.StartDate <= nowDate && x.EndDate >= nowDate)
  40. on d.CollegeID equals cp.CollegeID into dcp
  41. from ecp in dcp.DefaultIfEmpty()
  42. join css in CollegeScheduleStatusRepository.Entities on new { em.SchoolyearID, d.CollegeID } equals new { css.SchoolyearID, css.CollegeID } into dcss
  43. from css in dcss.DefaultIfEmpty()
  44. join esh in
  45. (
  46. from es in EducationSchedulingRepository.Entities
  47. join ct in CoursesTimeRepository.Entities on es.CoursesTimeID equals ct.CoursesTimeID
  48. from esw in es.ES_EducationSchedulingWeekNum
  49. group ct by es.EducationSchedulingClassID into g
  50. select new { EducationSchedulingClassID = g.Key, Hours = g.Sum(x => x.EndTimes - x.StartTimes + 1) }
  51. ) on esc.EducationSchedulingClassID equals esh.EducationSchedulingClassID into desh
  52. from esh in desh.DefaultIfEmpty()
  53. select new EducationSchedulingClassScheduleView
  54. {
  55. StartWeeklyNum = emc.EM_EducationMissionClassSettings.Min(w => w.WeeklyNum).Value,
  56. EndWeeklyNum = emc.EM_EducationMissionClassSettings.Max(w => w.WeeklyNum).Value,
  57. EducationSchedulingClassID = esc.EducationSchedulingClassID,
  58. EducationMissionClassID = esc.EducationMissionClassID,
  59. EducationMissionClassName = emc.Name,
  60. TeachingModeID = emc.TeachingModeID,
  61. EducationMissionClassOrderNo = emc.OrderNo,
  62. CoursematerialID = emc.CoursematerialID,
  63. DepartmentID = em.DepartmentID,
  64. CoursematerialName = cm.CourseName,
  65. CourseTypeID = emc.CourseTypeID,
  66. WeekTimes = emcts.WeeklyNum,
  67. WeeklyHours = emcts.WeeklyHours,
  68. CollegeID = em.CollegeID,
  69. CourseCollegeID = em.CF_Department.CollegeID,
  70. SchoolYearID = em.SchoolyearID,
  71. OptionalCourseTypeID = emc.OptionalCourseTypeID,
  72. ClassroomID = emc.ClassroomID,
  73. ClassroomName = ec.Name,
  74. ClassroomTypeID = emc.ClassroomTypeID,
  75. TaskGroupName = esc.TaskGroupName,
  76. ExecutablePlanCourseTime = (emc.EM_CourseProcess.Sum(x => x.Times) ?? 0),
  77. RemainCourseTime = (emc.EM_CourseProcess.Sum(x => x.Times) ?? 0) - esh.Hours,
  78. StudentNum = esc.CF_Student.Count(),
  79. IsCanEdit = ecp.CollegePriorityID != null,
  80. CollegeApproveStatusID = css.RecordStatus
  81. }
  82. );
  83. return sql;
  84. }
  85. public IQueryable<EducationMissionClassTeacherListView> GetTeacherViewQueryable(
  86. Expression<Func<EM_EducationSchedulingClass, bool>> exp)
  87. {
  88. var q = (from esc in EducationSchedulingClassRepository.GetList(exp)
  89. from mct in esc.EM_EducationMissionClass.EM_MissionClassTeacher
  90. select new EducationMissionClassTeacherListView
  91. {
  92. MissionClassTeacherID = mct.MissionClassTeacherID,
  93. EducationMissionClassID = esc.EducationMissionClassID,
  94. UserID = mct.CF_Staff.UserID,
  95. LoginID = mct.CF_Staff.Sys_User.LoginID,
  96. Name = mct.CF_Staff.Sys_User.Name,
  97. CollegeID = mct.CF_Staff.CollegeID,
  98. CollegeName = mct.CF_Staff.CF_College.Name,
  99. BirthDate = mct.CF_Staff.BirthDate,
  100. TeacherType = mct.CF_Staff.TeacherTypeID,
  101. IncumbencyState = mct.CF_Staff.IncumbencyState,
  102. Title = mct.CF_Staff.TitleID,
  103. TeachingMethod = mct.TeachType
  104. }).Distinct();
  105. return q;
  106. }
  107. public IQueryable<EM_EducationMissionClassSettings> GetEducationMissionClassSettingQueryable(
  108. Expression<Func<EM_EducationSchedulingClass, bool>> exp)
  109. {
  110. var q = (from esc in EducationSchedulingClassRepository.GetList(exp)
  111. from emcs in esc.EM_EducationMissionClass.EM_EducationMissionClassSettings
  112. select emcs);
  113. return q;
  114. }
  115. public IQueryable<EducationMissionClassContainClassView> GetClassmajorQueryable(
  116. Expression<Func<EM_EducationSchedulingClass, bool>> exp)
  117. {
  118. var q = (from esc in EducationSchedulingClassRepository.GetList(exp)
  119. from cm in esc.EM_EducationMissionClass.CF_Classmajor
  120. select new EducationMissionClassContainClassView
  121. {
  122. EducationMissionClassID = esc.EM_EducationMissionClass.EducationMissionClassID,
  123. ClassMajor = cm
  124. });
  125. return q;
  126. }
  127. public IQueryable<CF_Student> GetStudentQueryable(
  128. Expression<Func<EM_EducationSchedulingClass, bool>> exp)
  129. {
  130. var q = (from esc in EducationSchedulingClassRepository.GetList(exp)
  131. from s in esc.CF_Student
  132. select s);
  133. return q;
  134. }
  135. public IQueryable<CourseProcessView> GetCourseProcessViewQueryable(Expression<Func<EM_EducationSchedulingClass, bool>> exp)
  136. {
  137. var q = (from esc in EducationSchedulingClassRepository.GetList(exp)
  138. join cp in EducationMissionClassDAL.Value.GetCourseProcessView(x => true)
  139. on esc.EducationMissionClassID equals cp.EducationMissionClassID
  140. select cp).Distinct();
  141. return q;
  142. }
  143. public IQueryable<CourseProcessTeacherView> GetCourseProcessTeacherViewQueryable(Expression<Func<EM_EducationSchedulingClass, bool>> exp)
  144. {
  145. var q = (from esc in EducationSchedulingClassRepository.GetList(exp)
  146. join cp in EducationMissionClassDAL.Value.GetCourseProcessView(x => true)
  147. on esc.EducationMissionClassID equals cp.EducationMissionClassID
  148. join cpt in EducationMissionClassDAL.Value.GetCourseProcessTeacherView(x => true)
  149. on cp.CourseProcessID equals cpt.CourseProcessID
  150. select cpt).Distinct();
  151. return q;
  152. }
  153. public IQueryable<EducationSchedulingClassStudentView> GetEducationSchedulingClassStudentViewQueryable(Expression<Func<EM_EducationSchedulingClass, bool>> exp)
  154. {
  155. var q = (from schedulingClass in EducationSchedulingClassRepository.GetList(exp)
  156. from student in schedulingClass.CF_Student
  157. select new EducationSchedulingClassStudentView
  158. {
  159. EducationSchedulingClassID = schedulingClass.EducationSchedulingClassID,
  160. UserID = student.UserID,
  161. Name = student.Sys_User.Name
  162. });
  163. return q;
  164. }
  165. }
  166. }