SelectCourseListDAL.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.Repositories;
  6. using EMIS.DataLogic.SystemDAL;
  7. using System.Linq.Expressions;
  8. using EMIS.ViewModel.SelectCourse.SelectCourseResult;
  9. using EMIS.Entities;
  10. using EMIS.DataLogic.Common.CalendarManage;
  11. namespace EMIS.DataLogic.SelectCourse.SelectCourseResult
  12. {
  13. public class SelectCourseListDAL
  14. {
  15. public FinallyScoreRepository FinallyScoreRepository { get; set; }
  16. public StudentRepository StudentRepository { get; set; }
  17. public ClassmajorRepository ClassmajorRepository { get; set; }
  18. public GrademajorRepository GrademajorRepository { get; set; }
  19. public FacultymajorRepository FacultymajorRepository { get; set; }
  20. public SpecialtyRepository SpecialtyRepository { get; set; }
  21. public DictionaryItemRepository DictionaryItemRepository { get; set; }
  22. public SchoolyearRepository schoolyearRepository { get; set; }
  23. public SelectCourseTypeSettingRepository SelectCourseTypeSettingRepository { get; set; }
  24. public SelectCourseOpenControlSettingRepository SelectCourseOpenControlSettingRepository { get; set; }
  25. public Lazy<ParameterDAL> ParamterDAL { get; set; }
  26. public Lazy<SchoolYearDAL> SchoolYearDAL { get; set; }
  27. public CampusRepository campusRepository { get; set; }
  28. public CollegeRepository collegeRepository { get; set; }
  29. public DepartmentRepository departmentRepository { get; set; }
  30. public CoursematerialRepository CoursematerialRepository { get; set; }
  31. public ExecutableOptionalCourseRepository ExecutableOptionalCourseRepository { get; set; }//限选设定
  32. public ExecutableFreeSelectionCouseRepository ExecutableFreeSelectionCouseRepository { get; set; }//任选设定
  33. public OptionalCoursePlanRepository OptionalCoursePlanRepository { get; set; } //限修计划
  34. public FreeSelectionCourseGradeYearSettingRepository FreeSelectionCourseGradeYearSettingRepository { get; set; } //任选控制表
  35. public ExecutableOptionalCourseTeacherRepository ExecutableOptionalCourseTeacherRepository { get; set; } //限选设定任课老师表
  36. public ExecutableOptionalCourseTeachingModeRepository ExecutableOptionalCourseTeachingModeRepository { get; set; } //限选设定授课方式表
  37. public ExecutableOptionalCourseTeachingSettingRepository ExecutableOptionalCourseTeachingSettingRepository { get; set; } //限选设定教学设置表
  38. public ExecutableFreeSelectionCouseTeacherRepository ExecutableFreeSelectionCouseTeacherRepository { get; set; } //任选课程教师表
  39. public ExecutableFreeSelectionCouseTeachingModeRepository ExecutableFreeSelectionCouseTeachingModeRepository { get; set; } //任选设定授课方式表
  40. public ExecutableFreeSelectionCouseTeachingSettingRepository ExecutableFreeSelectionCouseTeachingSettingRepository { get; set; } //任选设定教学设置表
  41. public ExecutableFreeSelectionCouseSpecialtyRepository ExecutableFreeSelectionCouseSpecialtyRepository { get; set; }
  42. public ExecutableFreeSelectionCouseGradeYearRepository ExecutableFreeSelectionCouseGradeYearRepository { get; set; }
  43. public ExecutableFreeSelectionCouseSchedulingRepository ExecutableFreeSelectionCouseSchedulingRepository { get; set; }
  44. public CoursesTimeRepository coursesTimeRepository { get; set; }
  45. public ClassroomRepository ClassroomRepository { get; set; }
  46. public UserRepository UserRepository { get; set; }
  47. /// <summary>
  48. /// 查询选课结果名单,0为限选,1为任选
  49. /// </summary>
  50. /// <param name="eocExp"></param>
  51. /// <param name="efsExp"></param>
  52. /// <returns></returns>
  53. public IQueryable<SelectCourseListView> GetSelectCourseListViewQueryable(Expression<Func<EM_ExecutableOptionalCourse, bool>>
  54. eocExp, Expression<Func<EM_ExecutableFreeSelectionCouse, bool>> efsExp)
  55. {
  56. //1.0 获取限选设定的所有学生数据
  57. var executableOptionalCourseResult = (from eoc in ExecutableOptionalCourseRepository.GetList(eocExp)
  58. from stu in eoc.CF_Student
  59. join user in UserRepository.Entities on stu.UserID equals user.UserID
  60. join cla in ClassmajorRepository.Entities on stu.ClassmajorID equals cla.ClassmajorID
  61. select new SelectCourseListView
  62. {
  63. UserID = user.UserID,
  64. LoginID = user.LoginID,
  65. UserName = user.Name,
  66. ClassMajorID = cla.ClassmajorID,
  67. ClassMajorName = cla.Name,
  68. ClassroomName = "",
  69. ID = eoc.ExecutableOptionalCourseID,
  70. StudentTotalNum = eoc.CF_Student.Count(),
  71. PeopleNumlower = eoc.PeopleNumlower,
  72. PeopleNumlimit = eoc.PeopleNumlimit,
  73. SchoolyearID = eoc.SchoolyearID,
  74. SchoolYearCode = null,
  75. CollegeID = eoc.CF_Grademajor.CF_Facultymajor.CollegeID,
  76. DepartmentID = eoc.DepartmentID,
  77. DepartmentName = eoc.EM_OptionalCoursePlan.CF_Department.Name,
  78. DefaultClassName = eoc.DefaultClassName,
  79. CoursematerialID = eoc.EM_OptionalCoursePlan.CoursematerialID,
  80. CourseCode = eoc.EM_OptionalCoursePlan.EM_Coursematerial.CourseCode,
  81. CourseName = eoc.EM_OptionalCoursePlan.EM_Coursematerial.CourseName,
  82. CourseTypeID = eoc.CourseTypeID,
  83. CourseQualityID = eoc.CourseQualityID,
  84. SelectCourseType = 0,
  85. TheoryCourse = eoc.EM_ExecutableOptionalCourseTeachingSetting.TheoryCourse ?? 0,
  86. Practicehours = eoc.EM_ExecutableOptionalCourseTeachingSetting.Practicehours ?? 0,
  87. Trialhours = eoc.EM_ExecutableOptionalCourseTeachingSetting.Trialhours ?? 0,
  88. Credit = eoc.EM_ExecutableOptionalCourseTeachingSetting.Credit ?? 0,
  89. StartWeeklyNum = eoc.EM_ExecutableOptionalCourseTeachingSetting.StartWeeklyNum ?? 0,
  90. EndWeeklyNum = eoc.EM_ExecutableOptionalCourseTeachingSetting.EndWeeklyNum ?? 0,
  91. SchoolcodeID = eoc.EM_OptionalCoursePlan.SchoolcodeID,
  92. TeacherUserID = null,
  93. TeacherName = "",
  94. RecordStatus = eoc.RecordStatus,
  95. IsOpened = eoc.IsOpened.Value,
  96. });
  97. //2.0 获取任选设定的所有学生数据
  98. var executableFreeSelectionCouseResult = (from efs in ExecutableFreeSelectionCouseRepository.GetList(efsExp)
  99. from stu in efs.CF_Student
  100. join user in UserRepository.Entities on stu.UserID equals user.UserID
  101. join cla in ClassmajorRepository.Entities on stu.ClassmajorID equals cla.ClassmajorID
  102. join Scheduling in
  103. (from sc in ExecutableFreeSelectionCouseSchedulingRepository.Entities
  104. join d in ClassroomRepository.Entities on sc.ClassroomID equals d.ClassroomID
  105. group d by new { sc.ExecutableFreeSelectionCouseID } into g
  106. select new
  107. {
  108. ExecutableFreeSelectionCouseID = g.Key.ExecutableFreeSelectionCouseID,
  109. ClassroomName = g.Select(x => x.Name).FirstOrDefault(),
  110. }) on efs.ExecutableFreeSelectionCouseID equals Scheduling.ExecutableFreeSelectionCouseID
  111. into lj
  112. from Scheduling in lj.DefaultIfEmpty()
  113. select new SelectCourseListView
  114. {
  115. UserID = user.UserID,
  116. LoginID = user.LoginID,
  117. UserName = user.Name,
  118. ClassMajorID = cla.ClassmajorID,
  119. ClassMajorName = cla.Name,
  120. ClassroomName = Scheduling.ClassroomName,
  121. ID = efs.ExecutableFreeSelectionCouseID,
  122. StudentTotalNum = efs.CF_Student.Count(),
  123. PeopleNumlower = efs.PeopleNumlower,
  124. PeopleNumlimit = efs.PeopleNumlimit,
  125. SchoolyearID = efs.SchoolyearID,
  126. SchoolYearCode = null,
  127. CollegeID = efs.CF_Department.CollegeID,
  128. DepartmentID = efs.DepartmentID,
  129. DepartmentName = efs.EM_FreeSelectionCouse.CF_Department.Name,
  130. DefaultClassName = efs.DefaultClassName,
  131. CoursematerialID = efs.EM_FreeSelectionCouse.CoursematerialID,
  132. CourseCode = efs.EM_FreeSelectionCouse.EM_Coursematerial.CourseCode,
  133. CourseName = efs.EM_FreeSelectionCouse.EM_Coursematerial.CourseName,
  134. CourseTypeID = efs.CourseTypeID,
  135. CourseQualityID = efs.CourseQualityID,
  136. SelectCourseType = 1,
  137. TheoryCourse = efs.EM_ExecutableFreeSelectionCouseTeachingSetting.TheoryCourse ?? 0,
  138. Practicehours = efs.EM_ExecutableFreeSelectionCouseTeachingSetting.Practicehours ?? 0,
  139. Trialhours = efs.EM_ExecutableFreeSelectionCouseTeachingSetting.Trialhours ?? 0,
  140. Credit = efs.EM_ExecutableFreeSelectionCouseTeachingSetting.Credit ?? 0,
  141. StartWeeklyNum = efs.EM_ExecutableFreeSelectionCouseTeachingSetting.StartWeeklyNum ?? 0,
  142. EndWeeklyNum = efs.EM_ExecutableFreeSelectionCouseTeachingSetting.EndWeeklyNum ?? 0,
  143. SchoolcodeID = efs.EM_FreeSelectionCouse.SchoolcodeID,
  144. TeacherUserID = null,
  145. TeacherName = "",
  146. RecordStatus = efs.RecordStatus,
  147. IsOpened = true,
  148. });
  149. //3.0 合并限选/任选
  150. var result = from a in executableOptionalCourseResult.Concat(executableFreeSelectionCouseResult)
  151. join s in schoolyearRepository.Entities on a.SchoolyearID equals s.SchoolyearID
  152. select new SelectCourseListView
  153. {
  154. UserID = a.UserID,
  155. LoginID = a.LoginID,
  156. UserName = a.UserName,
  157. ClassMajorID = a.ClassMajorID,
  158. ClassMajorName = a.ClassMajorName,
  159. ClassroomName = a.ClassroomName,
  160. ID = a.ID,
  161. StudentTotalNum = a.StudentTotalNum,
  162. PeopleNumlower = a.PeopleNumlower,
  163. PeopleNumlimit = a.PeopleNumlimit,
  164. SchoolyearID = a.SchoolyearID,
  165. SchoolYearCode = s.Code,
  166. CollegeID = a.CollegeID,
  167. DepartmentID = a.DepartmentID,
  168. DepartmentName = a.DepartmentName,
  169. DefaultClassName = a.DefaultClassName,
  170. CoursematerialID = a.CoursematerialID,
  171. CourseCode = a.CourseCode,
  172. CourseName = a.CourseName,
  173. CourseTypeID = a.CourseTypeID,
  174. CourseQualityID = a.CourseQualityID,
  175. SelectCourseType = a.SelectCourseType,
  176. TheoryCourse = a.TheoryCourse ?? 0,
  177. Practicehours = a.Practicehours ?? 0,
  178. Trialhours = a.Trialhours ?? 0,
  179. Credit = a.Credit ?? 0,
  180. StartWeeklyNum = a.StartWeeklyNum ?? 0,
  181. EndWeeklyNum = a.EndWeeklyNum ?? 0,
  182. SchoolcodeID = a.SchoolcodeID,
  183. TeacherUserID = null,
  184. TeacherName = a.TeacherName,
  185. RecordStatus = a.RecordStatus,
  186. IsOpened = a.IsOpened,
  187. };
  188. return result;
  189. }
  190. }
  191. }