AdultEducationMissionClassDAL.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197
  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 AdultEducationMissionClassDAL
  17. {
  18. //public FreeSelectionCousePlanRepository freeSelectionCousePlanRepository { get; set; }
  19. public EducationMissionClassRepository educationMissionClassRepository { get; set; }
  20. public EducationMissionClassTeachingSettingRepository EducationMissionClassTeachingSettingRepository { get; set; }
  21. public EducationMissionRepository EducationMissionRepository { get; set; }
  22. public DictionaryItemRepository dictionaryItemRepository { get; set; }
  23. public EducationMissionClassSettingsRepository educationMissionClassSettingsRepository { get; set; }
  24. public MissionClassTeacherRepository missionClassTeacherRepository { get; set; }
  25. public EducationSchedulingClassRepository educationSchedulingClassRepository { get; set; }
  26. public StudentRepository studentRepository { get; set; }
  27. public UserRepository userRepository { get; set; }
  28. public ClassmajorRepository ClassmajorRepository { get; set; }
  29. public CourseProcessRepository CourseProcessRepository { get; set; }
  30. public EducationMissionRepository educationMissionRepository { get; set; }
  31. public EducationSchedulingRepository educationSchedulingRepository { get; set; }
  32. public ClassroomRepository ClassroomRepository { get; set; }
  33. public InSchoolSettingRepository inSchoolSettingRepository { get; set; }
  34. public CollegeScheduleStatusRepository CollegeScheduleStatusRepository { get; set; }
  35. public CoursesTimeRepository coursesTimeRepository { get; set; }
  36. public GrademajorRepository GrademajorRepository { get; set; }
  37. public FacultymajorRepository FacultymajorRepository { get; set; }
  38. public CollegeRepository CollegeRepository { get; set; }
  39. public DepartmentRepository DepartmentRepository { get; set; }
  40. public SchoolyearRepository SchoolyearRepository { get; set; }
  41. public CoursematerialRepository CoursematerialRepository { get; set; }
  42. public Lazy<CollegeDAL> CollegeDAL { get; set; }
  43. public EducationMissionExamTimeRepository EducationMissionExamTimeRepository { get; set; }
  44. /// <summary>
  45. /// 查询教学任务班数据
  46. /// </summary>
  47. /// <param name="exp"></param>
  48. /// <returns></returns>
  49. public IQueryable<EducationMissionImportClassView> GetEducationMissionClassViewQueryble(Expression<Func<EM_EducationMissionClass, bool>> missionClassExp, Expression<Func<CF_Classmajor, bool>> classmajorFilter)
  50. {
  51. TimeSpan s = new TimeSpan();
  52. DateTime d = new DateTime();
  53. //媚姐说:教学任务的查询不要过滤教学任务中没有在校学生
  54. //var inSchoolStatusIDList = inSchoolSettingRepository.GetList(x => x.IsSelected == true).Select(w => w.InSchoolStatusID).ToList();//获取选中的在校设定状态、
  55. //var inSchoolStatusIDList = inSchoolSettingRepository.GetList(x =>true).Select(w => w.InSchoolStatusID).ToList();//获取选中的在校设定状态、
  56. var query = from missionClass in educationMissionClassRepository.GetList(missionClassExp)
  57. join mission in EducationMissionRepository.Entities on missionClass.EducationMissionID equals mission.EducationMissionID
  58. join teachSetting in EducationMissionClassTeachingSettingRepository.Entities on missionClass.EducationMissionClassID equals teachSetting.EducationMissionClassID
  59. join classmajor in ClassmajorRepository.GetList(classmajorFilter) on missionClass.MainScheduleClassID equals classmajor.ClassmajorID
  60. //into dclassmajor
  61. //from classmajor in dclassmajor.DefaultIfEmpty()
  62. join grade in GrademajorRepository.Entities on classmajor.GrademajorID equals grade.GrademajorID into dgrade
  63. from grade in dgrade.DefaultIfEmpty()
  64. join faculty in FacultymajorRepository.Entities on grade.FacultymajorID equals faculty.FacultymajorID into dfaculty
  65. from faculty in dfaculty.DefaultIfEmpty()
  66. join department in DepartmentRepository.Entities on mission.DepartmentID equals department.DepartmentID
  67. join college in CollegeRepository.Entities on department.CollegeID equals college.CollegeID
  68. join schoolyear in SchoolyearRepository.Entities on mission.SchoolyearID equals schoolyear.SchoolyearID
  69. join course in CoursematerialRepository.Entities on missionClass.CoursematerialID equals course.CoursematerialID
  70. join schedulingClass in
  71. (
  72. from sc in educationSchedulingClassRepository.Entities
  73. group sc by sc.EducationMissionClassID into g
  74. select new
  75. {
  76. EducationMissionClassID = g.Key,
  77. ClassNum = g.Sum(x => x.CF_Student.Count())
  78. }
  79. ) on missionClass.EducationMissionClassID equals schedulingClass.EducationMissionClassID into dschedulingClass
  80. from schedulingClass in dschedulingClass.DefaultIfEmpty()
  81. join courseProcess in
  82. (from cp in CourseProcessRepository.Entities
  83. group cp by cp.EducationMissionClassID into g
  84. select new
  85. {
  86. EducationMissionClassID = g.Key,
  87. CourseProcessTimes = g.Sum(x => x.Times)
  88. }) on missionClass.EducationMissionClassID equals courseProcess.EducationMissionClassID into dcourseProcess
  89. from courseProcess in dcourseProcess.DefaultIfEmpty()
  90. join status in CollegeScheduleStatusRepository.Entities
  91. on new { missionClass.EM_EducationMission.CollegeID, missionClass.EM_EducationMission.SchoolyearID }
  92. equals new { status.CollegeID, status.SchoolyearID }
  93. into dstatus
  94. from status in dstatus.DefaultIfEmpty()
  95. from courseTime in missionClass.EM_CoursesTime.DefaultIfEmpty()
  96. join examtime in EducationMissionExamTimeRepository.Entities on missionClass.EducationMissionID equals examtime.EducationMissionID into dexamtime
  97. from examtime in dexamtime.DefaultIfEmpty()
  98. select new EducationMissionImportClassView
  99. {
  100. EndTime = examtime.EndTime ?? s,
  101. StarTime = examtime.StartTime ?? s,
  102. ExamDate = examtime.ExamDate ?? d,
  103. TimeID = courseTime.TimesSegment,
  104. StartHour = courseTime.StartHour,
  105. StartMinutes = courseTime.StartMinutes,
  106. EndHour = courseTime.EndHour,
  107. EndMinutes = courseTime.EndMinutes,
  108. CourseTimeID = courseTime.CoursesTimeID,
  109. EducationMissionID = missionClass.EducationMissionID,
  110. EducationMissionClassID = missionClass.EducationMissionClassID,
  111. TeachingModeID = missionClass.TeachingModeID ?? 1,
  112. SchoolyearID = missionClass.EM_EducationMission.SchoolyearID,
  113. SchoolyearCode = missionClass.EM_EducationMission.CF_Schoolyear.Code,
  114. Name = missionClass.Name,
  115. CoursematerialID = missionClass.CoursematerialID,
  116. CourseCode = course.CourseCode,
  117. CourseName = course.CourseName,
  118. CampusID = college.CampusID,
  119. ClassmajorCollegeID = mission.CollegeID,
  120. //兵良哥说院系所对应的是教学任务的院系所字段
  121. CollegeID = mission.CollegeID,
  122. CollegeNo = mission.CF_College.No,
  123. CollegeName =mission.CF_College.Name,
  124. //CollegeID = department.CollegeID,
  125. //CollegeNo = college.No,
  126. //CollegeName = college.Name,
  127. DepartmentID = mission.DepartmentID,
  128. DepartmentName = department.Name,
  129. GrademajorID = grade.GrademajorID,
  130. StandardID = faculty.StandardID,
  131. GradeYearID = grade.GradeID,
  132. ClassroomID = missionClass.ClassroomID,
  133. ClassroomName = missionClass.CF_Classroom.Name,
  134. ClassroomTypeID = missionClass.ClassroomTypeID,
  135. CourseStructureID = missionClass.CourseStructureID,
  136. CourseCategoryID = missionClass.CourseCategoryID,
  137. CourseTypeID = missionClass.CourseTypeID,
  138. CourseQualityID = missionClass.CourseQualityID,
  139. ExaminationModeID = missionClass.ExaminationModeID,
  140. TeachinglanguageID = missionClass.TeachinglanguageID,
  141. HandleModeID = missionClass.HandleModeID,
  142. IsNeedMaterial = missionClass.IsNeedMaterial ?? false,
  143. OrderNo = missionClass.OrderNo ?? 0,
  144. SchedulingClassNum = missionClass.EM_EducationSchedulingClass.Count,
  145. ClassNum = (schedulingClass.EducationMissionClassID == null ? 0 : schedulingClass.ClassNum),
  146. MainScheduleClassID = missionClass.MainScheduleClassID,
  147. MainScheduleClassGrademajorID = classmajor.GrademajorID,
  148. MainScheduleClassCollegeID = faculty.CollegeID,
  149. SchedulingClass = mission.ClassName,
  150. StartWeeklyNum = teachSetting.StartWeeklyNum,
  151. EndWeeklyNum = teachSetting.EndWeeklyNum,
  152. StartWeeklyNumReserved = missionClass.EM_EducationMissionClassSettings.Min(w => w.WeeklyNum).Value,
  153. EndWeeklyNumReserved = missionClass.EM_EducationMissionClassSettings.Max(w => w.WeeklyNum).Value,
  154. Credit = teachSetting.Credit,
  155. TheoryCourse = teachSetting.TheoryCourse,
  156. Practicehours = teachSetting.Practicehours,
  157. Trialhours = teachSetting.Trialhours,
  158. TheoryWeeklyNum = teachSetting.TheoryWeeklyNum,
  159. PracticeWeeklyNum = teachSetting.PracticeWeeklyNum,
  160. TrialWeeklyNum = teachSetting.TrialWeeklyNum,
  161. WeeklyNum = teachSetting.WeeklyNum,
  162. WeeklyHours = teachSetting.WeeklyHours,
  163. ApprovalStatus = missionClass.RecordStatus,
  164. CourseProcessTimes = courseProcess.CourseProcessTimes,
  165. CreateTime = missionClass.CreateTime,
  166. CreateUserID = missionClass.CreateUserID,
  167. ResultTypeID=missionClass.ResultTypeID,
  168. Remark = missionClass.Remark,
  169. IsCollegeScheduleSubmitted = (status.RecordStatus == (int)ES_CollegeScheduleStatusCode.Submited)
  170. };
  171. return query;
  172. }
  173. public List<MissionClassTeacherView> GetMissionClassTeacherQuery(Expression<Func<EM_EducationMissionClass, bool>> exp)
  174. {
  175. var query = (from emc in educationMissionClassRepository.GetList(exp)
  176. from tec in emc.EM_MissionClassTeacher
  177. select new MissionClassTeacherView
  178. {
  179. UserID = tec.CF_Staff.UserID,
  180. EducationMissionClassID = emc.EducationMissionClassID,
  181. Name = tec.CF_Staff.Sys_User.Name
  182. });
  183. return query.Distinct().ToList();
  184. }
  185. public IQueryable<EM_CourseProcess> GetRelatedCourseProcess(Expression<Func<EM_EducationMissionClass, bool>> exp)
  186. {
  187. var query = (from emc in educationMissionClassRepository.GetList(exp)
  188. // from remc in emc.EM_EducationMission.EM_EducationMissionClass
  189. from cp in emc.EM_CourseProcess
  190. select cp).Include(x => x.EM_EducationMissionClass);
  191. return query;
  192. }
  193. }
  194. }