StudentEducationMissionClassDAL.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  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.EducationManagement;
  7. using System.Linq.Expressions;
  8. using EMIS.Entities;
  9. using EMIS.DataLogic.CultureplanManage.PlanManagement;
  10. using System.Data.Entity;
  11. using EMIS.ViewModel.EducationManage;
  12. using EMIS.ViewModel;
  13. using EMIS.DataLogic.UniversityManage.AdministrativeOrgan;
  14. namespace EMIS.DataLogic.EducationManage
  15. {
  16. public class StudentEducationMissionClassDAL
  17. {
  18. public EducationMissionClassRepository EducationMissionClassRepository { get; set; }
  19. public EducationMissionClassTeachingSettingRepository EducationMissionClassTeachingSettingRepository { get; set; }
  20. public DepartmentRepository DepartmentRepository { get; set; }
  21. public DictionaryItemRepository DictionaryItemRepository { get; set; }
  22. public EducationMissionClassSettingsRepository EducationMissionClassSettingsRepository { get; set; }
  23. public MissionClassTeacherRepository MissionClassTeacherRepository { get; set; }
  24. public EducationSchedulingClassRepository EducationSchedulingClassRepository { get; set; }
  25. public StudentRepository StudentRepository { get; set; }
  26. public UserRepository UserRepository { get; set; }
  27. public ClassmajorRepository ClassmajorRepository { get; set; }
  28. public CourseProcessRepository CourseProcessRepository { get; set; }
  29. public EducationMissionRepository EducationMissionRepository { get; set; }
  30. public EducationSchedulingRepository EducationSchedulingRepository { get; set; }
  31. public ClassroomRepository ClassroomRepository { get; set; }
  32. public InSchoolSettingRepository InSchoolSettingRepository { get; set; }
  33. public CollegeScheduleStatusRepository CollegeScheduleStatusRepository { get; set; }
  34. public SchoolyearRepository SchoolyearRepository { get; set; }
  35. public GrademajorRepository GrademajorRepository { get; set; }
  36. public FacultymajorRepository FacultymajorRepository { get; set; }
  37. public CollegeRepository CollegeRepository { get; set; }
  38. public CoursematerialRepository CoursematerialRepository { get; set; }
  39. public Lazy<CollegeDAL> CollegeDAL { get; set; }
  40. /// <summary>
  41. /// 查询教学任务班数据
  42. /// </summary>
  43. /// <param name="exp"></param>
  44. /// <returns></returns>
  45. public IQueryable<EducationMissionClassView> GetEducationMissionClassViewQueryble(Expression<Func<EM_EducationMissionClass, bool>> missionClassExp,
  46. Expression<Func<EM_ExecutablePlan, bool>> executablePlanExp, Expression<Func<EM_ExecutableOptionalCourse, bool>> executableOptionalCourseExp,
  47. Expression<Func<EM_ExecutableFreeSelectionCouse, bool>> executableFreeSelectionCourseCourseExp)
  48. {
  49. var inSchoolStatusIDList = InSchoolSettingRepository.GetList(x => x.IsSelected == true).Select(w => w.InSchoolStatusID).ToList();//获取选中的在校设定状态、
  50. var query = from missionClass in EducationMissionClassRepository.GetList(missionClassExp)
  51. join mission in EducationMissionRepository.Entities on missionClass.EducationMissionID equals mission.EducationMissionID
  52. join department in DepartmentRepository.Entities on mission.DepartmentID equals department.DepartmentID
  53. join teachSetting in EducationMissionClassTeachingSettingRepository.Entities on missionClass.EducationMissionClassID equals teachSetting.EducationMissionClassID
  54. join classmajor in ClassmajorRepository.Entities on missionClass.MainScheduleClassID equals classmajor.ClassmajorID
  55. join grade in GrademajorRepository.Entities on classmajor.GrademajorID equals grade.GrademajorID
  56. join faculty in FacultymajorRepository.Entities on grade.FacultymajorID equals faculty.FacultymajorID
  57. join college in CollegeRepository.Entities on department.CollegeID equals college.CollegeID
  58. join schoolyear in SchoolyearRepository.Entities on mission.SchoolyearID equals schoolyear.SchoolyearID
  59. join course in CoursematerialRepository.Entities on missionClass.CoursematerialID equals course.CoursematerialID
  60. join sc in
  61. (
  62. from sc in EducationSchedulingClassRepository.Entities
  63. group sc by sc.EducationMissionClassID into g
  64. select new
  65. {
  66. EducationMissionClassID = g.Key,
  67. ClassNum = g.Sum(x => x.CF_Student.Where(p => inSchoolStatusIDList.Contains(p.InSchoolStatusID)).Count())
  68. }
  69. ) on missionClass.EducationMissionClassID equals sc.EducationMissionClassID into dsc
  70. join cp in
  71. (from cp in CourseProcessRepository.Entities
  72. group cp by cp.EducationMissionClassID into g
  73. select new
  74. {
  75. EducationMissionClassID = g.Key,
  76. CourseProcessTimes = g.Sum(x => x.Times)
  77. }) on missionClass.EducationMissionClassID equals cp.EducationMissionClassID into gcp
  78. from gccp in gcp.DefaultIfEmpty()
  79. from esc in dsc.DefaultIfEmpty()
  80. join mc in ClassmajorRepository.Entities on missionClass.MainScheduleClassID equals mc.ClassmajorID into dmc
  81. from emc in dmc.DefaultIfEmpty()
  82. join css in CollegeScheduleStatusRepository.Entities
  83. on new { missionClass.EM_EducationMission.CollegeID, missionClass.EM_EducationMission.SchoolyearID }
  84. equals new { css.CollegeID, css.SchoolyearID }
  85. into dcss
  86. from ecss in dcss.DefaultIfEmpty()
  87. select new EducationMissionClassView
  88. {
  89. EducationMissionID = missionClass.EducationMissionID,
  90. EducationMissionClassID = missionClass.EducationMissionClassID,
  91. TeachingModeID = missionClass.TeachingModeID ?? 1,
  92. SchoolyearID = missionClass.EM_EducationMission.SchoolyearID,
  93. SchoolyearCode = missionClass.EM_EducationMission.CF_Schoolyear.Code,
  94. Name = missionClass.Name,
  95. CoursematerialID = missionClass.CoursematerialID,
  96. CourseCode = course.CourseCode,
  97. CourseName = course.CourseName,
  98. CampusID = college.CampusID,
  99. CollegeID = department.CollegeID,
  100. CollegeNo = college.No,
  101. CollegeName = college.Name,
  102. DepartmentID = department.DepartmentID,
  103. DepartmentName = department.Name,
  104. GrademajorID = grade.GrademajorID,
  105. StandardID = faculty.StandardID,
  106. GradeYearID = grade.GradeID,
  107. ClassroomID = missionClass.ClassroomID,
  108. ClassroomName = missionClass.CF_Classroom.Name,
  109. ClassroomTypeID = missionClass.ClassroomTypeID,
  110. CourseStructureID = missionClass.CourseStructureID,
  111. CourseCategoryID = missionClass.CourseCategoryID,
  112. CourseTypeID = missionClass.CourseTypeID,
  113. CourseQualityID = missionClass.CourseQualityID,
  114. ExaminationModeID = missionClass.ExaminationModeID,
  115. TeachinglanguageID = missionClass.TeachinglanguageID,
  116. HandleModeID = missionClass.HandleModeID,
  117. IsNeedMaterial = missionClass.IsNeedMaterial ?? false,
  118. OrderNo = missionClass.OrderNo ?? 0,
  119. SchedulingClassNum = missionClass.EM_EducationSchedulingClass.Count,
  120. ClassNum = (esc.EducationMissionClassID == null ? 0 : esc.ClassNum),
  121. MainScheduleClassID = missionClass.MainScheduleClassID,
  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. TrialWeeklyNum = teachSetting.TrialWeeklyNum,
  136. WeeklyNum = teachSetting.WeeklyNum,
  137. WeeklyHours = teachSetting.WeeklyHours,
  138. ApprovalStatus = missionClass.RecordStatus,
  139. CourseProcessTimes = gccp.CourseProcessTimes,
  140. CreateTime = missionClass.CreateTime,
  141. CreateUserID = missionClass.CreateUserID,
  142. Remark = missionClass.Remark,
  143. IsCollegeScheduleSubmitted = (ecss.RecordStatus == (int)ES_CollegeScheduleStatusCode.Submited)
  144. };
  145. return query;
  146. }
  147. }
  148. }