WorktimeAdjustmentDAL.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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.PaymentManage;
  7. using System.Linq.Expressions;
  8. using EMIS.Entities;
  9. using EMIS.ViewModel.EducationManage;
  10. namespace EMIS.DataLogic.PaymentManage
  11. {
  12. public class WorktimeAdjustmentDAL
  13. {
  14. public CoursesTimeRepository CoursesTimeRepository { get; set; }
  15. public WorktimeAdjustmentRepository WorktimeAdjustmentRepository { get; set; }
  16. public EducationMissionClassRepository EducationMissionClassRepository { get; set; }
  17. public EducationSchedulingTeacherRepository EducationSchedulingTeacherRepository { get; set; }
  18. public EducationMissionRepository EducationMissionRepository { get; set; }
  19. public EducationSchedulingClassRepository EducationSchedulingClassRepository { get; set; }
  20. public EducationSchedulingRepository EducationSchedulingRepository { get; set; }
  21. public SchoolyearRepository SchoolyearRepository { get; set; }
  22. public CoursematerialRepository CoursematerialRepository { get; set; }
  23. public ClassmajorRepository ClassmajorRepository { get; set; }
  24. public GrademajorRepository GrademajorRepository { get; set; }
  25. public FacultymajorRepository FacultymajorRepository { get; set; }
  26. public UserRepository UserRepository { get; set; }
  27. public EducationSchedulingStopRepository EducationSchedulingStopRepository { get; set; }
  28. public EducationSchedulingStopTeacherRepository EducationSchedulingStopTeacherRepository { get; set; }
  29. public EducationSchedulingAdjustmentTeacherRepository EducationSchedulingAdjustmentTeacherRepository { get; set; }
  30. public EducationSchedulingAdjustmentRepository EducationSchedulingAdjustmentRepository { get; set; }
  31. public IQueryable<WorktimeAdjustmentView> GetWorktimeAdjustmentViewQueryable(Expression<Func<TP_WorktimeAdjustment, bool>> exp,
  32. Expression<Func<EM_Coursematerial, bool>> courseExp,
  33. Expression<Func<CF_Schoolyear, bool>> schoolyearExp)
  34. {
  35. var sql = (
  36. from adjust in WorktimeAdjustmentRepository.GetList(exp)
  37. join missionClass in EducationMissionClassRepository.Entities on adjust.EducationMissionClassID equals missionClass.EducationMissionClassID
  38. join classmajor in ClassmajorRepository.Entities on missionClass.MainScheduleClassID equals classmajor.ClassmajorID into dclassmajor
  39. from classmajor in dclassmajor.DefaultIfEmpty()
  40. join grade in GrademajorRepository.Entities on classmajor.GrademajorID equals grade.GrademajorID into dgrade
  41. from grade in dgrade.DefaultIfEmpty()
  42. join faculty in FacultymajorRepository.Entities on grade.FacultymajorID equals faculty.FacultymajorID into dfaculty
  43. from faculty in dfaculty.DefaultIfEmpty()
  44. join mission in EducationMissionRepository.Entities on missionClass.EducationMissionID equals mission.EducationMissionID
  45. join schoolyear in SchoolyearRepository.Entities.Where(schoolyearExp) on mission.SchoolyearID equals schoolyear.SchoolyearID
  46. join course in CoursematerialRepository.Entities.Where(courseExp) on missionClass.CoursematerialID equals course.CoursematerialID
  47. join teacher in UserRepository.Entities on adjust.UserID equals teacher.UserID
  48. select new WorktimeAdjustmentView
  49. {
  50. WorktimeAdjustmentID = adjust.WorktimeAdjustmentID,
  51. SchoolyearID = schoolyear.SchoolyearID,
  52. SchoolyearCode = schoolyear.Code,
  53. WorktimeAdjustmentTypeID = adjust.WorktimeAdjustmentTypeID,
  54. AdjustDate = adjust.AdjustDate,
  55. EducationMissionClassID = adjust.EducationMissionClassID,
  56. EducationMissionClassName = missionClass.Name,
  57. GradeYearID = grade.GradeID,
  58. StandardID = faculty.StandardID,
  59. CollegeID = faculty.CollegeID,
  60. CoursematerialID = missionClass.CoursematerialID,
  61. CourseCode = course.CourseCode,
  62. CourseName = course.CourseName,
  63. UserID = adjust.UserID,
  64. TeacherName = teacher.Name,
  65. Worktime = adjust.Worktime,
  66. CreateTime = adjust.CreateTime
  67. }
  68. );
  69. return sql;
  70. }
  71. public IQueryable<EducationMissionClassComboView> GetEducationMissionClassViewQueryable(
  72. Expression<Func<EM_EducationMissionClass, bool>> exp,
  73. Expression<Func<ES_EducationSchedulingTeacher, bool>> teacherExp, Expression<Func<ES_EducationScheduling, bool>> scheduleExp)
  74. {
  75. var sql = (from scheduling in EducationSchedulingRepository.GetList(scheduleExp)
  76. join scheduleClass in EducationSchedulingClassRepository.Entities on scheduling.EducationSchedulingClassID equals scheduleClass.EducationSchedulingClassID
  77. join missionClass in EducationMissionClassRepository.Entities.Where(exp) on scheduleClass.EducationMissionClassID equals missionClass.EducationMissionClassID
  78. join teacher in EducationSchedulingTeacherRepository.Entities.Where(teacherExp) on scheduling.EducationSchedulingID equals teacher.EducationSchedulingID
  79. select new EducationMissionClassComboView
  80. {
  81. EducationMissionClassID = missionClass.EducationMissionClassID,
  82. Name = missionClass.Name
  83. });
  84. return sql;
  85. }
  86. public IQueryable<WorktimeSchedulingView> GetWorktimeSchedulingViewQueryable(Expression<Func<ES_EducationScheduling, bool>> exp)
  87. {
  88. var sql = (from scheduling in EducationSchedulingRepository.GetList(exp)
  89. join scheduleClass in EducationSchedulingClassRepository.Entities on scheduling.EducationSchedulingClassID equals scheduleClass.EducationSchedulingClassID
  90. join missionClass in EducationMissionClassRepository.Entities on scheduleClass.EducationMissionClassID equals missionClass.EducationMissionClassID
  91. join teacher in EducationSchedulingTeacherRepository.Entities on scheduling.EducationSchedulingID equals teacher.EducationSchedulingID
  92. from weeknum in scheduling.ES_EducationSchedulingWeekNum
  93. join courseTime in CoursesTimeRepository.Entities on scheduling.CoursesTimeID equals courseTime.CoursesTimeID
  94. group courseTime by new
  95. {
  96. missionClass.EducationMissionClassID,
  97. UserID = teacher.UserID,
  98. Weekday = scheduling.Weekday,
  99. WeekNum = weeknum.WeekNum
  100. } into g
  101. select new WorktimeSchedulingView
  102. {
  103. EducationMissionClassID = g.Key.EducationMissionClassID,
  104. UserID = g.Key.UserID,
  105. Weekday = g.Key.Weekday,
  106. WeekNum = g.Key.WeekNum,
  107. Worktime = g.Sum(x => x.EndTimes - x.StartTimes + 1)
  108. }
  109. );
  110. return sql;
  111. }
  112. public IQueryable<WorktimeSchedulingView> GetWorktimeSchedulingViewByStopQueryable(
  113. Expression<Func<ES_EducationSchedulingStop, bool>> exp,
  114. Expression<Func<EM_EducationMission, bool>> missionExp)
  115. {
  116. var sql = (from stop in EducationSchedulingStopRepository.GetList(exp)
  117. join missionClass in EducationMissionClassRepository.Entities on stop.EducationMissionClassID equals missionClass.EducationMissionClassID
  118. join mission in EducationMissionRepository.GetList(missionExp) on missionClass.EducationMissionID equals mission.EducationMissionID
  119. join teacher in EducationSchedulingStopTeacherRepository.Entities on stop.EducationSchedulingStopID equals teacher.EducationSchedulingStopID
  120. join courseTime in CoursesTimeRepository.Entities on stop.CoursesTimeID equals courseTime.CoursesTimeID
  121. group courseTime by new
  122. {
  123. missionClass.EducationMissionClassID,
  124. UserID = teacher.UserID,
  125. Weekday = stop.Weekday,
  126. WeekNum = stop.WeekNum
  127. } into g
  128. select new WorktimeSchedulingView
  129. {
  130. EducationMissionClassID = g.Key.EducationMissionClassID,
  131. UserID = g.Key.UserID,
  132. Weekday = g.Key.Weekday,
  133. WeekNum = g.Key.WeekNum,
  134. Worktime = g.Sum(x => x.EndTimes - x.StartTimes + 1)
  135. });
  136. return sql;
  137. }
  138. public IQueryable<WorktimeSchedulingView> GetWorktimeSchedulingViewByAdjustmentQueryable(
  139. Expression<Func<ES_EducationSchedulingAdjustment, bool>> exp,
  140. Expression<Func<EM_EducationMission, bool>> missionExp)
  141. {
  142. var sql = (from adju in EducationSchedulingAdjustmentRepository.GetList(exp)
  143. join missionClass in EducationMissionClassRepository.Entities on adju.EducationMissionClassID equals missionClass.EducationMissionClassID
  144. join mission in EducationMissionRepository.GetList(missionExp) on missionClass.EducationMissionID equals mission.EducationMissionID
  145. join teacher in EducationSchedulingAdjustmentTeacherRepository.Entities on adju.EducationSchedulingAdjustmentID equals teacher.EducationSchedulingAdjustmentID
  146. join courseTime in CoursesTimeRepository.Entities on adju.CoursesTimeID equals courseTime.CoursesTimeID
  147. group courseTime by new
  148. {
  149. missionClass.EducationMissionClassID,
  150. UserID = teacher.UserID,
  151. Weekday = adju.Weekday,
  152. WeekNum = adju.WeekNum
  153. } into g
  154. select new WorktimeSchedulingView
  155. {
  156. EducationMissionClassID = g.Key.EducationMissionClassID,
  157. UserID = g.Key.UserID,
  158. Weekday = g.Key.Weekday,
  159. WeekNum = g.Key.WeekNum,
  160. Worktime = g.Sum(x => x.EndTimes - x.StartTimes + 1)
  161. });
  162. return sql;
  163. }
  164. }
  165. }