EducationMissionClassScheduleDAL.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  1. using EMIS.DataLogic.Repositories;
  2. using EMIS.Entities;
  3. using EMIS.ViewModel.EducationManagement;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. using System.Linq.Expressions;
  8. using System.Text;
  9. namespace EMIS.DataLogic.EducationSchedule
  10. {
  11. public class EducationMissionClassScheduleDAL
  12. {
  13. public EducationMissionClassRepository EducationMissionClassRepository { get; set; }
  14. public EducationMissionClassTeachingSettingRepository EducationMissionClassTeachingSettingRepository { get; set; }
  15. public DictionaryItemRepository DictionaryItemRepository { get; set; }
  16. public EducationMissionClassSettingsRepository EducationMissionClassSettingsRepository { get; set; }
  17. public MissionClassTeacherRepository MissionClassTeacherRepository { get; set; }
  18. public EducationSchedulingClassRepository EducationSchedulingClassRepository { get; set; }
  19. public StudentRepository StudentRepository { get; set; }
  20. public UserRepository UserRepository { get; set; }
  21. public ClassmajorRepository ClassmajorRepository { get; set; }
  22. public CourseProcessRepository CourseProcessRepository { get; set; }
  23. public EducationMissionRepository EducationMissionRepository { get; set; }
  24. public ClassroomRepository ClassroomRepository { get; set; }
  25. public CoursesTimeRepository CoursesTimeRepository { get; set; }
  26. public SchoolyearRepository SchoolyearRepository { get; set; }
  27. public GrademajorRepository GrademajorRepository { get; set; }
  28. public FacultymajorRepository FacultymajorRepository { get; set; }
  29. public CollegeRepository CollegeRepository { get; set; }
  30. public CoursematerialRepository CoursematerialRepository { get; set; }
  31. public EducationSchedulingWeekNumRepository EducationSchedulingWeekNumRepository { get; set; }
  32. public EducationSchedulingRepository EducationSchedulingRepository { get; set; }
  33. /// <summary>
  34. /// 查询教学任务班数据
  35. /// </summary>
  36. /// <param name="exp"></param>
  37. /// <returns></returns>
  38. public IQueryable<EducationMissionClassView> GetEducationMissionClassViewQueryble(Expression<Func<EM_EducationMissionClass, bool>> missionClassExp,
  39. Expression<Func<EM_ExecutablePlan, bool>> executablePlanExp, Expression<Func<EM_ExecutableOptionalCourse, bool>> executableOptionalCourseExp,
  40. Expression<Func<EM_ExecutableFreeSelectionCouse, bool>> executableFreeSelectionCourseCourseExp)
  41. {
  42. var query = from missionClass in EducationMissionClassRepository.GetList(missionClassExp)
  43. join mission in EducationMissionRepository.Entities on missionClass.EducationMissionID equals mission.EducationMissionID
  44. join teachSetting in EducationMissionClassTeachingSettingRepository.Entities on missionClass.EducationMissionClassID equals teachSetting.EducationMissionClassID
  45. join classmajor in ClassmajorRepository.Entities on missionClass.MainScheduleClassID equals classmajor.ClassmajorID into dclassmajor
  46. from classmajor in dclassmajor.DefaultIfEmpty()
  47. join grade in GrademajorRepository.Entities on classmajor.GrademajorID equals grade.GrademajorID into dgrade
  48. from grade in dgrade.DefaultIfEmpty()
  49. join faculty in FacultymajorRepository.Entities on grade.FacultymajorID equals faculty.FacultymajorID into dfaculty
  50. from faculty in dfaculty.DefaultIfEmpty()
  51. join college in CollegeRepository.Entities on mission.CollegeID equals college.CollegeID
  52. join schoolyear in SchoolyearRepository.Entities on mission.SchoolyearID equals schoolyear.SchoolyearID
  53. join course in CoursematerialRepository.Entities on missionClass.CoursematerialID equals course.CoursematerialID
  54. join sc in
  55. (
  56. from sc in EducationSchedulingClassRepository.Entities
  57. group sc by sc.EducationMissionClassID into g
  58. select new
  59. {
  60. EducationMissionClassID = g.Key,
  61. ClassNum = g.Sum(x => x.CF_Student.Count())
  62. }
  63. ) on missionClass.EducationMissionClassID equals sc.EducationMissionClassID into dsc
  64. join cp in
  65. (from cp in CourseProcessRepository.Entities
  66. group cp by cp.EducationMissionClassID into g
  67. select new
  68. {
  69. EducationMissionClassID = g.Key,
  70. CourseProcessTimes = g.Sum(x => x.Times)
  71. }) on missionClass.EducationMissionClassID equals cp.EducationMissionClassID into gcp
  72. join week in
  73. (from es in EducationSchedulingRepository.Entities
  74. join ct in CoursesTimeRepository.Entities on es.CoursesTimeID equals ct.CoursesTimeID
  75. from eswn in es.ES_EducationSchedulingWeekNum
  76. group ct by es.EM_EducationSchedulingClass.EducationMissionClassID into g
  77. select new
  78. {
  79. EducationMissionClassID = g.Key,
  80. ScheduledTimes = g.Sum(x => x.EndTimes - x.StartTimes + 1)
  81. }) on missionClass.EducationMissionClassID equals week.EducationMissionClassID into esp
  82. from wgcp in esp.DefaultIfEmpty()
  83. from gccp in gcp.DefaultIfEmpty()
  84. from esc in dsc.DefaultIfEmpty()
  85. join mc in ClassmajorRepository.Entities on missionClass.MainScheduleClassID equals mc.ClassmajorID into dmc
  86. from emc in dmc.DefaultIfEmpty()
  87. select new EducationMissionClassView
  88. {
  89. EducationMissionID = missionClass.EducationMissionID,
  90. EducationMissionClassID = missionClass.EducationMissionClassID,
  91. MainScheduleClassID = missionClass.MainScheduleClassID,
  92. TeachingModeID = missionClass.TeachingModeID ?? 1,
  93. SchoolyearID = missionClass.EM_EducationMission.SchoolyearID,
  94. SchoolyearCode = missionClass.EM_EducationMission.CF_Schoolyear.Code,
  95. Name = missionClass.Name,
  96. CoursematerialID = missionClass.CoursematerialID,
  97. CourseCode = course.CourseCode,
  98. CourseName = course.CourseName,
  99. CampusID = college.CampusID,
  100. CollegeID = college.CollegeID,
  101. CollegeNo = college.No,
  102. CollegeName = college.Name,
  103. DepartmentID = mission.DepartmentID,
  104. DepartmentName = mission.CF_Department.Name,
  105. GrademajorID = classmajor.GrademajorID,
  106. StandardID = faculty.StandardID,
  107. GradeYearID = grade.GradeID,
  108. ClassroomID = missionClass.ClassroomID,
  109. ClassroomName = missionClass.CF_Classroom.Name,
  110. ClassroomTypeID = missionClass.ClassroomTypeID,
  111. CourseStructureID = missionClass.CourseStructureID,
  112. CourseCategoryID = missionClass.CourseCategoryID,
  113. CourseTypeID = missionClass.CourseTypeID,
  114. CourseQualityID = missionClass.CourseQualityID,
  115. ExaminationModeID = missionClass.ExaminationModeID,
  116. TeachinglanguageID = missionClass.TeachinglanguageID,
  117. HandleModeID = missionClass.HandleModeID,
  118. IsNeedMaterial = missionClass.IsNeedMaterial ?? false,
  119. OrderNo = missionClass.OrderNo ?? 0,
  120. SchedulingClassNum = missionClass.EM_EducationSchedulingClass.Count,
  121. ClassNum = (esc.EducationMissionClassID == null ? 0 : esc.ClassNum),
  122. MainScheduleClassGrademajorID = emc.GrademajorID,
  123. MainScheduleClassCollegeID = emc.CF_Grademajor.CF_Facultymajor.CollegeID,
  124. SchedulingClass = missionClass.EM_EducationMission.ClassName,
  125. StartWeeklyNum = teachSetting.StartWeeklyNum,
  126. EndWeeklyNum = teachSetting.EndWeeklyNum,
  127. StartWeeklyNumReserved = missionClass.EM_EducationMissionClassSettings.Min(w => w.WeeklyNum).Value,
  128. EndWeeklyNumReserved = missionClass.EM_EducationMissionClassSettings.Max(w => w.WeeklyNum).Value,
  129. Credit = teachSetting.Credit,
  130. TheoryCourse = teachSetting.TheoryCourse,
  131. Practicehours = teachSetting.Practicehours,
  132. Trialhours = teachSetting.Trialhours,
  133. TheoryWeeklyNum = teachSetting.TheoryWeeklyNum,
  134. PracticeWeeklyNum = teachSetting.PracticeWeeklyNum,
  135. ScheduledTimes = wgcp.ScheduledTimes == null ? 0 : wgcp.ScheduledTimes,
  136. TrialWeeklyNum = teachSetting.TrialWeeklyNum,
  137. WeeklyNum = teachSetting.WeeklyNum,
  138. WeeklyHours = teachSetting.WeeklyHours,
  139. ApprovalStatus = missionClass.RecordStatus,
  140. CourseProcessTimes = gccp.CourseProcessTimes,
  141. CreateTime = missionClass.CreateTime,
  142. CreateUserID = missionClass.CreateUserID,
  143. Remark = missionClass.Remark
  144. };
  145. return query;
  146. }
  147. }
  148. }