InschoolOtherStatusDAL.cs 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.Repositories;
  6. using EMIS.DataLogic.Common.CalendarManage;
  7. using EMIS.ViewModel.Students.HighBaseTable;
  8. using System.Linq.Expressions;
  9. using EMIS.Entities;
  10. namespace EMIS.DataLogic.Common.Students.HighBaseTable
  11. {
  12. public class InschoolOtherStatusDAL
  13. {
  14. public InschoolOtherStatusRepository InschoolOtherStatusRepository { get; set; }
  15. public DictionaryItemRepository DictionaryItemRepository { get; set; }
  16. public StudentRepository StudentRepository { get; set; }
  17. public StudentProfileRepository StudentProfileRepository { get; set; }
  18. public ClassmajorRepository ClassmajorRepository { get; set; }
  19. public GrademajorRepository GrademajorRepository { get; set; }
  20. public FacultymajorRepository FacultymajorRepository { get; set; }
  21. public SchoolyearRepository SchoolyearRepository { get; set; }
  22. public RecruitstudentsRepository RecruitstudentsRepository { get; set; }
  23. public InSchoolSettingRepository InSchoolSettingRepository { get; set; }
  24. public EducationTypeSettingRepository EducationTypeSettingRepository { get; set; }
  25. public SchoolYearDAL SchoolYearDAL { get; set; }
  26. public StudentReportRepository StudentReportRepository { get; set; }
  27. /// <summary>
  28. /// 少数民族统计
  29. /// </summary>
  30. /// <returns></returns>
  31. public IQueryable<InschoolOtherStatusView> GetInschoolOtherStatusMinorityCount(int? schoolYear)
  32. {
  33. //var schYear = SchoolYearDAL.GetSchoolYearQueryable(x => x.IsCurrent).FirstOrDefault().Years;
  34. var query = from student in StudentRepository.GetList(x => x.NationID != (int)EMIS.ViewModel.CF_Nation.Han)
  35. join inschool in InSchoolSettingRepository.Entities.Where(x => x.IsSelected == true)
  36. on student.InSchoolStatusID equals inschool.InSchoolStatusID
  37. join profile in StudentProfileRepository.Entities
  38. on student.UserID equals profile.UserID
  39. join clmajor in ClassmajorRepository.Entities on student.ClassmajorID equals clmajor.ClassmajorID
  40. join grmajor in GrademajorRepository.Entities on clmajor.GrademajorID equals grmajor.GrademajorID
  41. join famajor in FacultymajorRepository.Entities on grmajor.FacultymajorID equals famajor.FacultymajorID
  42. join edutype in EducationTypeSettingRepository.Entities on famajor.EducationID equals edutype.EducationID
  43. //join report in
  44. // (
  45. // from report in StudentReportRepository.GetList(x => x.RecordStatus > (int)EMIS.ViewModel.SYS_STATUS.UNUSABLE
  46. // && x.ReportStatusID == (int)EMIS.ViewModel.CF_ReportStatus.Havetoreportforduty)
  47. // join schoolyear in SchoolyearRepository.Entities on report.SchoolyearID equals schoolyear.SchoolyearID
  48. // where schoolyear.Years == schoolYear
  49. // select report.UserID
  50. // ).Distinct() on student.UserID equals report
  51. group student by new
  52. {
  53. student.NationID,
  54. edutype.EducationTypeID,
  55. } into g
  56. select new InschoolOtherStatusView
  57. {
  58. EducationTypeID = g.Key.EducationTypeID,
  59. Nation = g.Key.NationID,
  60. Minority = g.Count()
  61. };
  62. return query;
  63. }
  64. //政治面貌分组统计
  65. public IQueryable<InschoolOtherStatusView> GetInschoolOtherStatusPoliticsCount(Expression<Func<CF_Student, bool>> exp, int? schoolYear)
  66. {
  67. var schYear = SchoolYearDAL.GetSchoolYearQueryable(x => x.IsCurrent).FirstOrDefault().Years;
  68. var query = from student in StudentRepository.GetList(exp)
  69. join inschool in InSchoolSettingRepository.Entities.Where(x => x.IsSelected == true)
  70. on student.InSchoolStatusID equals inschool.InSchoolStatusID
  71. join profile in StudentProfileRepository.Entities on student.UserID equals profile.UserID
  72. join clmajor in ClassmajorRepository.Entities on student.ClassmajorID equals clmajor.ClassmajorID
  73. join grmajor in GrademajorRepository.Entities on clmajor.GrademajorID equals grmajor.GrademajorID
  74. join famajor in FacultymajorRepository.Entities on grmajor.FacultymajorID equals famajor.FacultymajorID
  75. join edutype in EducationTypeSettingRepository.Entities on famajor.EducationID equals edutype.EducationID
  76. //join report in
  77. // (
  78. // from report in StudentReportRepository.GetList(x => x.RecordStatus > (int)EMIS.ViewModel.SYS_STATUS.UNUSABLE
  79. // && x.ReportStatusID == (int)EMIS.ViewModel.CF_ReportStatus.Havetoreportforduty)
  80. // join schoolyear in SchoolyearRepository.Entities on report.SchoolyearID equals schoolyear.SchoolyearID
  81. // where schoolyear.Years == schoolYear
  82. // select report.UserID
  83. // ).Distinct() on student.UserID equals report
  84. group student by new
  85. {
  86. student.PoliticsID,
  87. edutype.EducationTypeID,
  88. } into g
  89. select new InschoolOtherStatusView
  90. {
  91. EducationTypeID = g.Key.EducationTypeID,
  92. Politics = g.Key.PoliticsID,
  93. PoliticsCount = g.Count()
  94. };
  95. return query;
  96. }
  97. }
  98. }