StudentChangeDAL.cs 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154
  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.Students.HighBaseTable;
  7. using EMIS.ViewModel;
  8. using EMIS.Entities;
  9. namespace EMIS.DataLogic.Common.Students.HighBaseTable
  10. {
  11. public class StudentChangeDAL
  12. {
  13. public StudentChangeRepository StudentChangeRepository { get; set; }
  14. public StudentRepository StudentRepository { get; set; }
  15. public InSchoolSettingRepository InSchoolSettingRepository { get; set; }
  16. public RecruitstudentsRepository RecruitstudentsRepository { get; set; }
  17. public ClassmajorRepository ClassmajorRepository { get; set; }
  18. public GrademajorRepository GrademajorRepository { get; set; }
  19. public FacultymajorRepository FacultymajorRepository { get; set; }
  20. public EducationTypeSettingRepository EducationTypeSettingRepository { get; set; }
  21. public SchoolyearRepository SchoolyearRepository { get; set; }
  22. public StudentReportRepository StudentReportRepository { get; set; }
  23. public GraduationApplyRepository GraduationApplyRepository { get; set; }
  24. public DifferentDynamicRepository DifferentDynamicRepository { get; set; }
  25. public DifferentDynamicTypeInOutSettingRepository DifferentDynamicTypeInOutSettingRepository { get; set; }
  26. public IQueryable<StudentChangeStudentCountView> GetRecruitStudentCount(int year)
  27. {
  28. var q = (
  29. from student in StudentRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE)
  30. join inschool in InSchoolSettingRepository.Entities.Where(x => x.IsSelected == true)
  31. on student.InSchoolStatusID equals inschool.InSchoolStatusID
  32. join classmajor in ClassmajorRepository.Entities on student.ClassmajorID equals classmajor.ClassmajorID
  33. join grade in GrademajorRepository.Entities on classmajor.GrademajorID equals grade.GrademajorID
  34. join faculty in FacultymajorRepository.Entities on grade.FacultymajorID equals faculty.FacultymajorID
  35. join educationType in EducationTypeSettingRepository.Entities on faculty.EducationID equals educationType.EducationID
  36. join recruit in RecruitstudentsRepository.Entities on student.UserID equals recruit.UserID
  37. join schoolyear in SchoolyearRepository.Entities on recruit.EnteringSchoolYearID equals schoolyear.SchoolyearID
  38. //join report in
  39. // (
  40. // from report in StudentReportRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE)
  41. // join schoolyear in SchoolyearRepository.Entities on report.SchoolyearID equals schoolyear.SchoolyearID
  42. // where schoolyear.Years == year
  43. // select report.UserID
  44. // ).Distinct() on student.UserID equals report
  45. where schoolyear.Years == year
  46. group student by educationType.EducationTypeID into g
  47. select new StudentChangeStudentCountView
  48. {
  49. EducationTypeID = g.Key,
  50. StudentCount = g.Sum(x => 1)
  51. }
  52. );
  53. return q;
  54. }
  55. public IQueryable<StudentChangeStudentCountView> GetGraduationStudentCount(int year)
  56. {
  57. var q = (
  58. from student in StudentRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE)
  59. join classmajor in ClassmajorRepository.Entities on student.ClassmajorID equals classmajor.ClassmajorID
  60. join grade in GrademajorRepository.Entities on classmajor.GrademajorID equals grade.GrademajorID
  61. join faculty in FacultymajorRepository.Entities on grade.FacultymajorID equals faculty.FacultymajorID
  62. join educationType in EducationTypeSettingRepository.Entities on faculty.EducationID equals educationType.EducationID
  63. join graduation in GraduationApplyRepository.Entities on student.UserID equals graduation.UserID
  64. join schoolyear in SchoolyearRepository.Entities on graduation.ApplySchoolyearID equals schoolyear.SchoolyearID
  65. where schoolyear.Years == year && student.StudentStatus == (int)CF_StudentStatus.Graduation
  66. group student by educationType.EducationTypeID into g
  67. select new StudentChangeStudentCountView
  68. {
  69. EducationTypeID = g.Key,
  70. StudentCount = g.Sum(x => 1)
  71. }
  72. );
  73. return q;
  74. }
  75. public IQueryable<StudentChangeStudentCountView> GetGraduationOverStudentCount(int year)
  76. {
  77. var q = (
  78. from student in StudentRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE)
  79. join classmajor in ClassmajorRepository.Entities on student.ClassmajorID equals classmajor.ClassmajorID
  80. join grade in GrademajorRepository.Entities on classmajor.GrademajorID equals grade.GrademajorID
  81. join faculty in FacultymajorRepository.Entities on grade.FacultymajorID equals faculty.FacultymajorID
  82. join educationType in EducationTypeSettingRepository.Entities on faculty.EducationID equals educationType.EducationID
  83. join graduation in GraduationApplyRepository.Entities on student.UserID equals graduation.UserID
  84. join schoolyear in SchoolyearRepository.Entities on graduation.ApplySchoolyearID equals schoolyear.SchoolyearID
  85. where schoolyear.Years == year && student.StudentStatus == (int)CF_StudentStatus.Complete
  86. group student by educationType.EducationTypeID into g
  87. select new StudentChangeStudentCountView
  88. {
  89. EducationTypeID = g.Key,
  90. StudentCount = g.Sum(x => 1)
  91. }
  92. );
  93. return q;
  94. }
  95. public IQueryable<HB_StudentChange> GetLastInschoolStudentCount(int year)
  96. {
  97. return StudentChangeRepository.GetList(x => x.Year == (year - 1));
  98. }
  99. public IQueryable<StudentChangeStudentCountView> GetCurrentInschoolStudentCount()
  100. {
  101. var q = (
  102. from student in StudentRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE)
  103. join classmajor in ClassmajorRepository.Entities on student.ClassmajorID equals classmajor.ClassmajorID
  104. join grade in GrademajorRepository.Entities on classmajor.GrademajorID equals grade.GrademajorID
  105. join faculty in FacultymajorRepository.Entities on grade.FacultymajorID equals faculty.FacultymajorID
  106. join educationType in EducationTypeSettingRepository.Entities on faculty.EducationID equals educationType.EducationID
  107. where student.StudentStatus == (int)CF_StudentStatus.Registration
  108. group student by educationType.EducationTypeID into g
  109. select new StudentChangeStudentCountView
  110. {
  111. EducationTypeID = g.Key,
  112. StudentCount = g.Sum(x => 1)
  113. }
  114. );
  115. return q;
  116. }
  117. public IQueryable<StudentChangeDetailStudentCountView> GetStudentChangeCount(int year, int? differentDynamicEndStatusID)
  118. {
  119. var q = (
  120. from change in DifferentDynamicRepository.GetList(x => x.ApprovalStatus == differentDynamicEndStatusID)
  121. join student in StudentRepository.Entities on change.UserID equals student.UserID
  122. join classmajor in ClassmajorRepository.Entities on student.ClassmajorID equals classmajor.ClassmajorID
  123. join grade in GrademajorRepository.Entities on classmajor.GrademajorID equals grade.GrademajorID
  124. join faculty in FacultymajorRepository.Entities on grade.FacultymajorID equals faculty.FacultymajorID
  125. join educationType in EducationTypeSettingRepository.Entities on faculty.EducationID equals educationType.EducationID
  126. join schoolyear in SchoolyearRepository.Entities on change.SchoolyearID equals schoolyear.SchoolyearID
  127. //只有配置表里面有的才会被统计
  128. join inout in DifferentDynamicTypeInOutSettingRepository.Entities on change.ChangeTypeID equals inout.ChangeTypeID
  129. where schoolyear.Years == year
  130. group new { change, inout } by new { educationType.EducationTypeID, change.ChangeTypeID } into g
  131. select new StudentChangeDetailStudentCountView
  132. {
  133. EducationTypeID = g.Key.EducationTypeID,
  134. DifferentDynamicType = g.Key.ChangeTypeID,
  135. StudentInCount = g.Sum(x => (x.change.AfterClassmajorID != null && x.inout.IsIn == true) ? 1 : 0),
  136. StudentOutCount = g.Sum(x => (x.change.AfterClassmajorID == null && x.inout.IsOut == true) ? 1 : 0)
  137. }
  138. );
  139. return q;
  140. }
  141. }
  142. }