RealtimeDAL.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329
  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. using EMIS.ViewModel;
  10. namespace EMIS.DataLogic.EducationSchedule
  11. {
  12. public class RealtimeDAL
  13. {
  14. public EducationMissionClassRepository EducationMissionClassRepository { get; set; }
  15. public EducationMissionClassTeachingSettingRepository EducationMissionClassTeachingSettingRepository { get; set; }
  16. public DictionaryItemRepository DictionaryItemRepository { get; set; }
  17. public EducationMissionClassSettingsRepository EducationMissionClassSettingsRepository { get; set; }
  18. public MissionClassTeacherRepository MissionClassTeacherRepository { get; set; }
  19. public EducationSchedulingClassRepository EducationSchedulingClassRepository { get; set; }
  20. public StudentRepository StudentRepository { get; set; }
  21. public UserRepository UserRepository { get; set; }
  22. public ClassmajorRepository ClassmajorRepository { get; set; }
  23. public CourseProcessRepository CourseProcessRepository { get; set; }
  24. public EducationMissionRepository EducationMissionRepository { get; set; }
  25. public ClassroomRepository ClassroomRepository { get; set; }
  26. public CoursesTimeRepository CoursesTimeRepository { get; set; }
  27. public EducationSchedulingWeekNumRepository EducationSchedulingWeekNumRepository { get; set; }
  28. public EducationSchedulingRepository EducationSchedulingRepository { get; set; }
  29. public SchoolyearRepository SchoolyearRepository { get; set; }
  30. public GrademajorRepository GrademajorRepository { get; set; }
  31. public FacultymajorRepository FacultymajorRepository { get; set; }
  32. public CollegeRepository CollegeRepository { get; set; }
  33. public CoursematerialRepository CoursematerialRepository { get; set; }
  34. public ClassroomExcessiveUseRepository ClassroomExcessiveUseRepository { get; set; }
  35. public ClassroomExcessiveUseSchedulingRepository ClassroomExcessiveUseSchedulingRepository { get; set; }
  36. public ClassroomExcessiveUseSchedulingWeekNumRepository ClassroomExcessiveUseSchedulingWeekNumRepository { get; set; }
  37. public DepartmentRepository DepartmentRepository { get; set; }
  38. /// <summary>
  39. /// 查询教学任务班数据
  40. /// </summary>
  41. /// <param name="exp"></param>
  42. /// <returns></returns>
  43. public IQueryable<EducationMissionClassView> GetEducationMissionClassViewQueryble(Expression<Func<EM_EducationMissionClass, bool>> missionClassExp,
  44. Expression<Func<ES_EducationScheduling, bool>> exeducationScheduling,
  45. Expression<Func<ES_EducationSchedulingWeekNum, bool>> exducationSchedulingWeekNum,
  46. Expression<Func<ES_ClassroomExcessiveUse, bool>> exexcessiveUse,
  47. Expression<Func<ES_ClassroomExcessiveUseScheduling, bool>> exexcessiveUseScheduling,
  48. Expression<Func<ES_ClassroomExcessiveUseSchedulingWeekNum, bool>> exexcessiveUseSchedulingWeekNum
  49. )
  50. {
  51. var query = (from missionClass in EducationMissionClassRepository.GetList(missionClassExp)
  52. join mission in EducationMissionRepository.Entities on missionClass.EducationMissionID equals mission.EducationMissionID
  53. from dep in DepartmentRepository.Entities.Where(x => x.DepartmentID == mission.DepartmentID)
  54. from opencol in CollegeRepository.Entities.Where(x => x.CollegeID == dep.CollegeID)
  55. join teachSetting in EducationMissionClassTeachingSettingRepository.Entities on missionClass.EducationMissionClassID equals teachSetting.EducationMissionClassID
  56. join classmajor in ClassmajorRepository.Entities on missionClass.MainScheduleClassID equals classmajor.ClassmajorID into dclassmajor
  57. from classmajor in dclassmajor.DefaultIfEmpty()
  58. join grade in GrademajorRepository.Entities on classmajor.GrademajorID equals grade.GrademajorID into dgrade
  59. from grade in dgrade.DefaultIfEmpty()
  60. join faculty in FacultymajorRepository.Entities on grade.FacultymajorID equals faculty.FacultymajorID into dfaculty
  61. from faculty in dfaculty.DefaultIfEmpty()
  62. join college in CollegeRepository.Entities on mission.CollegeID equals college.CollegeID
  63. join schoolyear in SchoolyearRepository.Entities on mission.SchoolyearID equals schoolyear.SchoolyearID
  64. join course in CoursematerialRepository.Entities on missionClass.CoursematerialID equals course.CoursematerialID
  65. join schedulingClass in
  66. (
  67. (from sc in EducationSchedulingClassRepository.Entities
  68. join es in EducationSchedulingRepository.GetList(exeducationScheduling) on sc.EducationSchedulingClassID equals es.EducationSchedulingClassID
  69. join cr in ClassroomRepository.Entities on es.ClassroomID equals cr.ClassroomID
  70. join emt in CoursesTimeRepository.Entities on es.CoursesTimeID equals emt.CoursesTimeID
  71. join esw in EducationSchedulingWeekNumRepository.GetList(exducationSchedulingWeekNum) on es.EducationSchedulingID equals esw.EducationSchedulingID
  72. group sc by new { sc.EducationMissionClassID, esw, es, emt, cr } into g
  73. select new
  74. {
  75. EducationMissionClassID = g.Key.EducationMissionClassID,
  76. ClassNum = g.Sum(x => x.CF_Student.Count()),
  77. Week = g.Key.esw.WeekNum,
  78. WeekDay = g.Key.es.Weekday,
  79. StarTimes = g.Key.emt.StartTimes,
  80. CoursesTimeID = g.Key.emt.CoursesTimeID,
  81. Times = g.Key.emt.StartTimes + "-" + g.Key.emt.EndTimes,
  82. TimesHoure = g.Key.emt.StartHour + ":" + g.Key.emt.StartMinutes + "-" + g.Key.emt.EndHour + ":" + g.Key.emt.EndMinutes,
  83. ClassroomName = g.Key.cr.Name,
  84. ClassroomID = g.Key.cr.ClassroomID
  85. }
  86. )
  87. ) on missionClass.EducationMissionClassID equals schedulingClass.EducationMissionClassID
  88. select new EducationMissionClassView
  89. {
  90. EducationMissionID = missionClass.EducationMissionID,
  91. EducationMissionClassID = missionClass.EducationMissionClassID,
  92. MainScheduleClassID = missionClass.MainScheduleClassID,
  93. TeachingModeID = missionClass.TeachingModeID ?? (int)CF_TeachingMode.Theory,
  94. SchoolyearID = mission.SchoolyearID,
  95. SchoolyearCode = schoolyear.Code,
  96. Name = missionClass.Name,
  97. CoursematerialID = missionClass.CoursematerialID,
  98. CourseCode = course.CourseCode,
  99. CourseName = course.CourseName,
  100. CampusID = college.CampusID,
  101. CollegeID = faculty.CollegeID,
  102. CollegeNo = college.No,
  103. CollegeName = college.Name,
  104. OpenCollegeID = dep.CollegeID,
  105. OpenCollegeNo = opencol.No,
  106. OpenCollegeName = opencol.Name,
  107. DepartmentID = mission.DepartmentID,
  108. DepartmentName = mission.CF_Department.Name,
  109. WeekNum = schedulingClass.Week,
  110. Weekday = schedulingClass.WeekDay,
  111. //CoursesTimeID = schedulingClass.CoursesTimeID,
  112. newCoursesTimeID = schedulingClass.CoursesTimeID,
  113. StarTimes = schedulingClass.StarTimes,
  114. Times = schedulingClass.Times,
  115. TimesHoure = schedulingClass.TimesHoure,
  116. GrademajorID = grade.GrademajorID,
  117. StandardID = faculty.StandardID,
  118. GradeYearID = grade.GradeID,
  119. ClassroomName = schedulingClass.ClassroomName,
  120. ClassroomID = schedulingClass.ClassroomID,
  121. CourseStructureID = missionClass.CourseStructureID,
  122. CourseCategoryID = missionClass.CourseCategoryID,
  123. CourseTypeID = missionClass.CourseTypeID,
  124. CourseQualityID = missionClass.CourseQualityID,
  125. ExaminationModeID = missionClass.ExaminationModeID,
  126. TeachinglanguageID = missionClass.TeachinglanguageID,
  127. HandleModeID = missionClass.HandleModeID,
  128. IsNeedMaterial = missionClass.IsNeedMaterial ?? false,
  129. OrderNo = missionClass.OrderNo ?? 0,
  130. ClassNum = (schedulingClass.EducationMissionClassID == null ? 0 : schedulingClass.ClassNum),
  131. SchedulingClassNum = missionClass.EM_EducationSchedulingClass.Count,
  132. SchedulingClass = mission.ClassName,
  133. StartWeeklyNum = teachSetting.StartWeeklyNum,
  134. EndWeeklyNum = teachSetting.EndWeeklyNum,
  135. StartWeeklyNumReserved = missionClass.EM_EducationMissionClassSettings.Min(w => w.WeeklyNum).Value,
  136. EndWeeklyNumReserved = missionClass.EM_EducationMissionClassSettings.Max(w => w.WeeklyNum).Value,
  137. Credit = teachSetting.Credit,
  138. TheoryCourse = teachSetting.TheoryCourse,
  139. Practicehours = teachSetting.Practicehours,
  140. Trialhours = teachSetting.Trialhours,
  141. TheoryWeeklyNum = teachSetting.TheoryWeeklyNum,
  142. PracticeWeeklyNum = teachSetting.PracticeWeeklyNum,
  143. TrialWeeklyNum = teachSetting.TrialWeeklyNum,
  144. WeeklyNum = teachSetting.WeeklyNum,
  145. WeeklyHours = teachSetting.WeeklyHours,
  146. ApprovalStatus = missionClass.RecordStatus,
  147. CreateTime = missionClass.CreateTime,
  148. CreateUserID = missionClass.CreateUserID,
  149. Remark = missionClass.Remark,
  150. })
  151. .Concat(
  152. from eu in ClassroomExcessiveUseRepository.GetList(exexcessiveUse)
  153. join schoolyear in SchoolyearRepository.Entities on eu.SchoolyearID equals schoolyear.SchoolyearID
  154. join college in CollegeRepository.Entities on eu.CollegeID equals college.CollegeID
  155. join cr in ClassroomRepository.Entities on eu.ClassroomID equals cr.ClassroomID
  156. join eus in ClassroomExcessiveUseSchedulingRepository.GetList(exexcessiveUseScheduling) on eu.ClassroomExcessiveUseID equals eus.ClassroomExcessiveUseID
  157. join emt in CoursesTimeRepository.Entities on eus.CoursesTimeID equals emt.CoursesTimeID
  158. join eusw in ClassroomExcessiveUseSchedulingWeekNumRepository.GetList(exexcessiveUseSchedulingWeekNum) on eus.ClassroomExcessiveUseSchedulingID equals eusw.ClassroomExcessiveUseSchedulingID
  159. select new EducationMissionClassView
  160. {
  161. EducationMissionID = null,
  162. EducationMissionClassID = null,
  163. MainScheduleClassID = null,
  164. TeachingModeID = (int)CF_TeachingMode.Theory,
  165. SchoolyearID = eu.SchoolyearID,
  166. SchoolyearCode = schoolyear.Code,
  167. Name = "教室占用",
  168. CoursematerialID = null,
  169. CourseCode = null,
  170. CourseName = null,
  171. CampusID = college.CampusID,
  172. CollegeID = null,
  173. CollegeNo = null,
  174. CollegeName = null,
  175. OpenCollegeID = eu.CollegeID,
  176. OpenCollegeNo = college.No,
  177. OpenCollegeName = college.Name,
  178. DepartmentID = null,
  179. DepartmentName = null,
  180. WeekNum = eusw.WeekNum,
  181. Weekday = eus.Weekday,
  182. //CoursesTimeID = emt.CoursesTimeID,
  183. newCoursesTimeID = emt.CoursesTimeID,
  184. StarTimes = emt.StartTimes,
  185. Times = emt.StartTimes + "-" + emt.EndTimes,
  186. TimesHoure = emt.StartHour + ":" + emt.StartMinutes + "-" + emt.EndHour + ":" + emt.EndMinutes,
  187. GrademajorID = null,
  188. StandardID = null,
  189. GradeYearID = null,
  190. ClassroomName = cr.Name,
  191. ClassroomID = cr.ClassroomID,
  192. CourseStructureID = null,
  193. CourseCategoryID = null,
  194. CourseTypeID = null,
  195. CourseQualityID = null,
  196. ExaminationModeID = null,
  197. TeachinglanguageID = null,
  198. HandleModeID = null,
  199. IsNeedMaterial = false,
  200. OrderNo = 0,
  201. ClassNum = 0,
  202. SchedulingClassNum = 0,
  203. SchedulingClass = null,
  204. StartWeeklyNum = 0,
  205. EndWeeklyNum = 0,
  206. StartWeeklyNumReserved = 0,
  207. EndWeeklyNumReserved = 0,
  208. Credit = null,
  209. TheoryCourse = null,
  210. Practicehours = null,
  211. Trialhours = null,
  212. TheoryWeeklyNum = null,
  213. PracticeWeeklyNum = null,
  214. TrialWeeklyNum = null,
  215. WeeklyNum = null,
  216. WeeklyHours = null,
  217. ApprovalStatus = null,
  218. CreateTime = null,
  219. CreateUserID = null,
  220. Remark = ""
  221. });
  222. return query.Distinct();
  223. }
  224. public IQueryable<EducationMissionClassView> GetNewEducationMissionClassViewQueryble(Expression<Func<EM_EducationMissionClass, bool>> missionClassExp,
  225. Expression<Func<ES_EducationScheduling, bool>> exeducationScheduling,
  226. Expression<Func<ES_EducationSchedulingWeekNum, bool>> exducationSchedulingWeekNum,
  227. Expression<Func<ES_ClassroomExcessiveUse, bool>> exexcessiveUse,
  228. Expression<Func<ES_ClassroomExcessiveUseScheduling, bool>> exexcessiveUseScheduling,
  229. Expression<Func<ES_ClassroomExcessiveUseSchedulingWeekNum, bool>> exexcessiveUseSchedulingWeekNum,
  230. Expression<Func<CF_Classroom, bool>> exeClassroom,
  231. Expression<Func<EM_CoursesTime, bool>> exeCoursesTime
  232. )
  233. {
  234. var weekNum = from eswn in EducationSchedulingWeekNumRepository.Entities
  235. select eswn.WeekNum.Value;
  236. var weekNumList = weekNum.Distinct();
  237. var basequery = GetEducationMissionClassViewQueryble(missionClassExp, exeducationScheduling, exducationSchedulingWeekNum, exexcessiveUse, exexcessiveUseScheduling, exexcessiveUseSchedulingWeekNum);
  238. var query = from selectroom in (from room in ClassroomRepository.Entities.Where(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE)
  239. from w in weekNumList
  240. from day in DictionaryItemRepository.Entities.Where(x => x.DictionaryCode == "ES_WeekDay")
  241. from cou in CoursesTimeRepository.Entities.Where(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE)
  242. select new
  243. {
  244. room.ClassroomID,
  245. room.Name,
  246. WeekNum = w,
  247. Weekday = day.Value,
  248. cou.CoursesTimeID,
  249. cou.StartTimes,
  250. cou.EndTimes,
  251. cou.StartHour,
  252. cou.StartMinutes,
  253. cou.EndHour,
  254. cou.EndMinutes,
  255. })
  256. from b in basequery.Where(x => x.ClassroomID == selectroom.ClassroomID && x.WeekNum == selectroom.WeekNum && x.Weekday == selectroom.Weekday && x.StarTimes == selectroom.StartTimes).DefaultIfEmpty()
  257. select new EducationMissionClassView
  258. {
  259. EducationMissionID = b.EducationMissionID,
  260. EducationMissionClassID = b.EducationMissionClassID,
  261. MainScheduleClassID = b.MainScheduleClassID,
  262. TeachingModeID = b.TeachingModeID != null ? b.TeachingModeID:(int)CF_TeachingMode.Theory,
  263. SchoolyearID = b.SchoolyearID,
  264. SchoolyearCode = b.SchoolyearCode != null ? b.SchoolyearCode : "",
  265. Name = b.Name != null ? b.Name : "",
  266. CoursematerialID = b.CoursematerialID,
  267. CourseCode = b.CourseCode != null ? b.CourseCode : "",
  268. CourseName = b.CourseName != null ? b.CourseName : "",
  269. CampusID = b.CampusID,
  270. CollegeID = b.CollegeID,
  271. CollegeNo = b.CollegeNo != null ? b.CollegeNo : "",
  272. CollegeName = b.CollegeName != null ? b.CollegeName : "",
  273. OpenCollegeID = b.CollegeID,
  274. OpenCollegeNo = b.OpenCollegeNo != null ? b.OpenCollegeNo : "",
  275. OpenCollegeName = b.OpenCollegeName != null ? b.OpenCollegeName : "",
  276. DepartmentID = b.DepartmentID,
  277. DepartmentName = b.DepartmentName != null ? b.DepartmentName : "",
  278. WeekNum = selectroom.WeekNum,
  279. Weekday = selectroom.Weekday,
  280. newCoursesTimeID = selectroom.CoursesTimeID,
  281. StarTimes = selectroom.StartTimes,
  282. Times = selectroom.StartTimes + "-" + selectroom.EndTimes,
  283. TimesHoure = selectroom.StartHour + ":" + selectroom.StartMinutes + "-" + selectroom.EndHour + ":" + selectroom.EndMinutes,
  284. GrademajorID = b.GrademajorID,
  285. StandardID = b.StandardID,
  286. GradeYearID = b.GradeYearID,
  287. ClassroomName = selectroom.Name,
  288. ClassroomID = selectroom.ClassroomID,
  289. CourseStructureID = b.CourseStructureID,
  290. CourseCategoryID = b.CourseCategoryID,
  291. CourseTypeID = b.CourseTypeID,
  292. CourseQualityID = b.CourseQualityID,
  293. ExaminationModeID = b.ExaminationModeID,
  294. TeachinglanguageID = b.TeachinglanguageID,
  295. HandleModeID = b.HandleModeID,
  296. IsNeedMaterial = b.IsNeedMaterial != null ? b.IsNeedMaterial : false,
  297. OrderNo = b.OrderNo,
  298. ClassNum = b.ClassNum,
  299. SchedulingClassNum = b.SchedulingClassNum,
  300. SchedulingClass = b.SchedulingClass != null ? b.SchedulingClass : "",
  301. StartWeeklyNum = b.StartWeeklyNum,
  302. EndWeeklyNum = b.EndWeeklyNum,
  303. StartWeeklyNumReserved = b.StartWeeklyNumReserved,
  304. EndWeeklyNumReserved = b.EndWeeklyNumReserved,
  305. Credit = b.Credit,
  306. TheoryCourse = b.TheoryCourse,
  307. Practicehours = b.Practicehours,
  308. Trialhours = b.Trialhours,
  309. TheoryWeeklyNum = b.TheoryWeeklyNum,
  310. PracticeWeeklyNum = b.PracticeWeeklyNum,
  311. TrialWeeklyNum = b.TrialWeeklyNum,
  312. WeeklyNum = b.WeeklyNum,
  313. WeeklyHours = b.WeeklyHours,
  314. ApprovalStatus = b.ApprovalStatus,
  315. CreateTime = b.CreateTime,
  316. CreateUserID = b.CreateUserID,
  317. Remark = b.Remark != null ? b.Remark : "",
  318. };
  319. return query;
  320. }
  321. }
  322. }