JuniorSpecialtyStudentCountDAL.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336
  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 EMIS.ViewModel.EnrollManage.SpecialtyManage;
  9. using EMIS.ViewModel.Students;
  10. namespace EMIS.DataLogic.Common.Students.HighBaseTable
  11. {
  12. public class JuniorSpecialtyStudentCountDAL
  13. {
  14. public DictionaryItemRepository DictionaryItemRepository { get; set; }
  15. public StudentRepository StudentRepository { get; set; }
  16. public StudentProfileRepository StudentProfileRepository { get; set; }
  17. public ClassmajorRepository ClassmajorRepository { get; set; }
  18. public GrademajorRepository GrademajorRepository { get; set; }
  19. public FacultymajorRepository FacultymajorRepository { get; set; }
  20. public SpecialtyRepository SpecialtyRepository { 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 GraduationApplyRepository GraduationApplyRepository { get; set; }
  27. public StudentReportRepository StudentReportRepository { get; set; }
  28. public IQueryable<JuniorSpecialtyStudentCountView> GetStudent()
  29. {
  30. var query = from student in StudentRepository.GetList(x => true)
  31. join clmajor in ClassmajorRepository.Entities on student.ClassmajorID equals clmajor.ClassmajorID
  32. join grmajor in GrademajorRepository.Entities on clmajor.GrademajorID equals grmajor.GrademajorID
  33. join famajor in FacultymajorRepository.Entities on grmajor.FacultymajorID equals famajor.FacultymajorID
  34. //join special in SpecialtyRepository.Entities on new { famajor.StandardID, famajor.EducationID, famajor.LearnSystem, famajor.LearningformID }
  35. //equals new { special.StandardID, special.EducationID, special.LearnSystem, special.LearningformID }
  36. join edutype in EducationTypeSettingRepository.GetList(x => x.EducationTypeID == (int)EMIS.ViewModel.CF_EducationType.Special) on famajor.EducationID equals edutype.EducationID
  37. group student by new
  38. {
  39. //student.Sex,
  40. //edutype.EducationTypeID,
  41. //special.SpecialtyID,
  42. //famajor.TeacherIdentification,
  43. famajor.StandardID,
  44. famajor.EducationID,
  45. famajor.LearnSystem,
  46. famajor.LearningformID
  47. } into g
  48. select new JuniorSpecialtyStudentCountView
  49. {
  50. //SpecialtyID = special.SpecialtyID,
  51. StandardID = g.Key.StandardID,
  52. EducationID = g.Key.EducationID,
  53. LearningformID = g.Key.LearningformID,
  54. LearnSystem = g.Key.LearnSystem,
  55. };
  56. return query.Distinct();
  57. }
  58. public IQueryable<JuniorSpecialtyStudentCountView> GetInschoolCount(int? schoolYear)
  59. {
  60. var schYear = SchoolYearDAL.GetSchoolYearQueryable(x => x.IsCurrent).FirstOrDefault();
  61. var query = from student in StudentRepository.Entities
  62. join inschool in InSchoolSettingRepository.Entities.Where(x => x.IsSelected == true)
  63. on student.InSchoolStatusID equals inschool.InSchoolStatusID
  64. join profile in StudentProfileRepository.Entities on student.UserID equals profile.UserID
  65. join recruit in RecruitstudentsRepository.Entities on student.UserID equals recruit.UserID
  66. join clmajor in ClassmajorRepository.Entities on student.ClassmajorID equals clmajor.ClassmajorID
  67. join grmajor in GrademajorRepository.Entities on clmajor.GrademajorID equals grmajor.GrademajorID
  68. join famajor in FacultymajorRepository.Entities on grmajor.FacultymajorID equals famajor.FacultymajorID
  69. //join special in SpecialtyRepository.Entities on new { famajor.StandardID, famajor.EducationID, famajor.LearnSystem, famajor.LearningformID }
  70. //equals new { special.StandardID, special.EducationID, special.LearnSystem, special.LearningformID }
  71. join edutype in EducationTypeSettingRepository.GetList(x => x.EducationTypeID == (int)EMIS.ViewModel.CF_EducationType.Special) on famajor.EducationID equals edutype.EducationID
  72. join grayear in SchoolyearRepository.Entities on new { SchoolcodeID = grmajor.SemesterID.Value, Years = grmajor.GradeID.Value } equals new { grayear.SchoolcodeID, grayear.Years }
  73. //join report in
  74. // (
  75. // from report in StudentReportRepository.GetList(x => x.RecordStatus > (int)EMIS.ViewModel.SYS_STATUS.UNUSABLE
  76. // && x.ReportStatusID == (int)EMIS.ViewModel.CF_ReportStatus.Havetoreportforduty)
  77. // join schoolyear in SchoolyearRepository.Entities on report.SchoolyearID equals schoolyear.SchoolyearID
  78. // where schoolyear.Years == schoolYear
  79. // select report.UserID
  80. // ).Distinct() on student.UserID equals report
  81. group student by new
  82. {
  83. student.SexID,
  84. edutype.EducationTypeID,
  85. //special.SpecialtyID,
  86. famajor.TeacherIdentification,
  87. famajor.StandardID,
  88. famajor.EducationID,
  89. famajor.LearnSystem,
  90. famajor.LearningformID,
  91. SchoolyearNumID = ((schYear.Value - (schYear.SchoolcodeID == grmajor.SemesterID ? 0 : 1)) - grayear.Value) / 2 + 1
  92. } into g
  93. select new JuniorSpecialtyStudentCountView
  94. {
  95. Sex = g.Key.SexID,
  96. //SpecialtyID = g.Key.SpecialtyID,
  97. SchoolyearNumID = g.Key.SchoolyearNumID,
  98. StandardID = g.Key.StandardID,
  99. EducationID = g.Key.EducationID,
  100. LearnSystem = g.Key.LearnSystem,
  101. LearningformID = g.Key.LearningformID,
  102. EducationTypeID = g.Key.EducationTypeID,
  103. InschoolCount = g.Count()
  104. };
  105. return query;
  106. }
  107. //招生数
  108. public IQueryable<JuniorSpecialtyStudentCountView> GetRecruitCount(int? schoolYear)
  109. {
  110. //var schYear = SchoolYearDAL.GetSchoolYearQueryable(x => x.IsCurrent).FirstOrDefault().Years;
  111. var query = from student in StudentRepository.Entities
  112. join inschool in InSchoolSettingRepository.Entities.Where(x => x.IsSelected == true)
  113. on student.InSchoolStatusID equals inschool.InSchoolStatusID
  114. join profile in StudentProfileRepository.Entities on student.UserID equals profile.UserID
  115. join recruit in RecruitstudentsRepository.Entities on student.UserID equals recruit.UserID
  116. join clmajor in ClassmajorRepository.Entities on student.ClassmajorID equals clmajor.ClassmajorID
  117. join grmajor in GrademajorRepository.Entities on clmajor.GrademajorID equals grmajor.GrademajorID
  118. join famajor in FacultymajorRepository.Entities on grmajor.FacultymajorID equals famajor.FacultymajorID
  119. //join special in SpecialtyRepository.Entities on new { famajor.StandardID, famajor.EducationID, famajor.LearnSystem, famajor.LearningformID }
  120. //equals new { special.StandardID, special.EducationID, special.LearnSystem, special.LearningformID }
  121. join edutype in EducationTypeSettingRepository.GetList(x => x.EducationTypeID == (int)EMIS.ViewModel.CF_EducationType.Special) on famajor.EducationID equals edutype.EducationID
  122. join entyear in SchoolyearRepository.GetList(x => x.Years == schoolYear) on recruit.EnteringSchoolYearID equals entyear.SchoolyearID
  123. group student by new
  124. {
  125. student.SexID,
  126. edutype.EducationTypeID,
  127. //special.SpecialtyID,
  128. famajor.TeacherIdentification,
  129. famajor.StandardID,
  130. famajor.EducationID,
  131. famajor.LearnSystem,
  132. famajor.LearningformID
  133. } into g
  134. select new JuniorSpecialtyStudentCountView
  135. {
  136. Sex = g.Key.SexID,
  137. //SpecialtyID = g.Key.SpecialtyID,
  138. StandardID = g.Key.StandardID,
  139. EducationID = g.Key.EducationID,
  140. LearnSystem = g.Key.LearnSystem,
  141. LearningformID = g.Key.LearningformID,
  142. EducationTypeID = g.Key.EducationTypeID,
  143. RecruitCount = g.Count()
  144. };
  145. return query;
  146. }
  147. //春季招生数,普教需要
  148. public IQueryable<JuniorSpecialtyStudentCountView> SpringRecruitCount(int? schoolYear)
  149. {
  150. //var schYear = SchoolYearDAL.GetSchoolYearQueryable(x => x.IsCurrent).FirstOrDefault().Years;
  151. var query = from student in StudentRepository.Entities
  152. join inschool in InSchoolSettingRepository.Entities.Where(x => x.IsSelected == true)
  153. on student.InSchoolStatusID equals inschool.InSchoolStatusID
  154. join profile in StudentProfileRepository.Entities on student.UserID equals profile.UserID
  155. join recruit in RecruitstudentsRepository.Entities on student.UserID equals recruit.UserID
  156. join clmajor in ClassmajorRepository.Entities on student.ClassmajorID equals clmajor.ClassmajorID
  157. join grmajor in GrademajorRepository.Entities on clmajor.GrademajorID equals grmajor.GrademajorID
  158. join famajor in FacultymajorRepository.Entities on grmajor.FacultymajorID equals famajor.FacultymajorID
  159. //join special in SpecialtyRepository.Entities on new { famajor.StandardID, famajor.EducationID, famajor.LearnSystem, famajor.LearningformID }
  160. //equals new { special.StandardID, special.EducationID, special.LearnSystem, special.LearningformID }
  161. join edutype in EducationTypeSettingRepository.GetList(x => x.EducationTypeID == (int)EMIS.ViewModel.CF_EducationType.Special) on famajor.EducationID equals edutype.EducationID
  162. join entyear in SchoolyearRepository.GetList(x => x.Years == schoolYear && x.SchoolcodeID == (int)EMIS.ViewModel.CF_Semester.Spring) on recruit.EnteringSchoolYearID equals entyear.SchoolyearID
  163. group student by new
  164. {
  165. student.SexID,
  166. edutype.EducationTypeID,
  167. //special.SpecialtyID,
  168. famajor.TeacherIdentification,
  169. famajor.StandardID,
  170. famajor.EducationID,
  171. famajor.LearnSystem,
  172. famajor.LearningformID
  173. } into g
  174. select new JuniorSpecialtyStudentCountView
  175. {
  176. Sex = g.Key.SexID,
  177. //SpecialtyID = g.Key.SpecialtyID,
  178. StandardID = g.Key.StandardID,
  179. EducationID = g.Key.EducationID,
  180. LearnSystem = g.Key.LearnSystem,
  181. LearningformID = g.Key.LearningformID,
  182. EducationTypeID = g.Key.EducationTypeID,
  183. SpringRecruitCount = g.Count()
  184. };
  185. return query;
  186. }
  187. //预计毕业数
  188. public IQueryable<JuniorSpecialtyStudentCountView> PlanGraduationCount(int? schoolYear)
  189. {
  190. //var schYear = SchoolYearDAL.GetSchoolYearQueryable(x => x.IsCurrent).FirstOrDefault().Years;
  191. var query = from student in StudentRepository.Entities
  192. join inschool in InSchoolSettingRepository.Entities.Where(x => x.IsSelected == true)
  193. on student.InSchoolStatusID equals inschool.InSchoolStatusID
  194. join profile in StudentProfileRepository.Entities on student.UserID equals profile.UserID
  195. join recruit in RecruitstudentsRepository.Entities on student.UserID equals recruit.UserID
  196. join clmajor in ClassmajorRepository.Entities on student.ClassmajorID equals clmajor.ClassmajorID
  197. join grmajor in GrademajorRepository.Entities on clmajor.GrademajorID equals grmajor.GrademajorID
  198. join famajor in FacultymajorRepository.Entities on grmajor.FacultymajorID equals famajor.FacultymajorID
  199. join edutype in EducationTypeSettingRepository.GetList(x => x.EducationTypeID == (int)EMIS.ViewModel.CF_EducationType.Special) on famajor.EducationID equals edutype.EducationID
  200. //年级专业毕业学年等于当前学年
  201. join grayear in SchoolyearRepository.GetList(x => x.Years == schoolYear) on grmajor.GraduateSchoolyearID equals grayear.SchoolyearID
  202. group student by new
  203. {
  204. student.SexID,
  205. edutype.EducationTypeID,
  206. //special.SpecialtyID,
  207. famajor.TeacherIdentification,
  208. famajor.StandardID,
  209. famajor.EducationID,
  210. famajor.LearnSystem,
  211. famajor.LearningformID
  212. } into g
  213. select new JuniorSpecialtyStudentCountView
  214. {
  215. Sex = g.Key.SexID,
  216. //SpecialtyID = g.Key.SpecialtyID,
  217. StandardID = g.Key.StandardID,
  218. EducationID = g.Key.EducationID,
  219. LearnSystem = g.Key.LearnSystem,
  220. LearningformID = g.Key.LearningformID,
  221. EducationTypeID = g.Key.EducationTypeID,
  222. PlanGraduationCount = g.Count()
  223. };
  224. return query;
  225. }
  226. //应届毕业生数,上一学年毕业的学生,并且为正常的预计毕业学期(如3年制的学生,从入学学期到毕业刚好6个学期)
  227. public IQueryable<JuniorSpecialtyStudentCountView> GetGraduatingCount(int? schoolYear)
  228. {
  229. var query = from student in StudentRepository.GetList(x => x.StudentStatus == (int)EMIS.ViewModel.CF_StudentStatus.Graduation)
  230. join recruit in RecruitstudentsRepository.Entities on student.UserID equals recruit.UserID
  231. join clmajor in ClassmajorRepository.Entities on student.ClassmajorID equals clmajor.ClassmajorID
  232. join grmajor in GrademajorRepository.Entities on clmajor.GrademajorID equals grmajor.GrademajorID
  233. join famajor in FacultymajorRepository.Entities on grmajor.FacultymajorID equals famajor.FacultymajorID
  234. join enteringSchoolYear in SchoolyearRepository.Entities on recruit.EnteringSchoolYearID equals enteringSchoolYear.SchoolyearID
  235. join edutype in EducationTypeSettingRepository.GetList(x => x.EducationTypeID == (int)EMIS.ViewModel.CF_EducationType.Special) on famajor.EducationID equals edutype.EducationID
  236. join gradApply in
  237. (
  238. from graduationApply in GraduationApplyRepository.Entities
  239. join schoolyear in SchoolyearRepository.Entities on graduationApply.ApplySchoolyearID equals schoolyear.SchoolyearID
  240. group schoolyear by new { graduationApply.UserID, schoolyear.Years } into g
  241. select new { UserID = g.Key.UserID.Value, graduationYear = g.Max(x => x.Years), schoolYearValue = g.Max(x => x.Value) }
  242. ) on new
  243. {
  244. student.UserID,
  245. schoolYear = schoolYear.Value,
  246. schoolYearValue = enteringSchoolYear.Value + (int)(famajor.LearnSystem * 2) - 1
  247. } equals new
  248. {
  249. gradApply.UserID,
  250. schoolYear = gradApply.graduationYear + 1,
  251. gradApply.schoolYearValue
  252. }
  253. group student by new
  254. {
  255. student.SexID,
  256. edutype.EducationTypeID,
  257. //special.SpecialtyID,
  258. famajor.TeacherIdentification,
  259. famajor.StandardID,
  260. famajor.EducationID,
  261. famajor.LearnSystem,
  262. famajor.LearningformID
  263. } into g
  264. select new JuniorSpecialtyStudentCountView
  265. {
  266. Sex = g.Key.SexID,
  267. //SpecialtyID = g.Key.SpecialtyID,
  268. StandardID = g.Key.StandardID,
  269. EducationID = g.Key.EducationID,
  270. LearnSystem = g.Key.LearnSystem,
  271. LearningformID = g.Key.LearningformID,
  272. EducationTypeID = g.Key.EducationTypeID,
  273. GraduatingCount = g.Count()
  274. };
  275. return query;
  276. }
  277. //毕业数,上一学年毕业的学生数,学籍状态为毕业,并且最后一次毕业申请是上一年
  278. public IQueryable<JuniorSpecialtyStudentCountView> GetGraduationCount(int? schoolYear)
  279. {
  280. var query = from student in StudentRepository.GetList(x => x.StudentStatus == (int)EMIS.ViewModel.CF_StudentStatus.Graduation)
  281. //join profile in StudentProfileRepository.Entities on student.UserID equals profile.UserID
  282. //join recruit in RecruitstudentsRepository.Entities on student.UserID equals recruit.UserID
  283. join clmajor in ClassmajorRepository.Entities on student.ClassmajorID equals clmajor.ClassmajorID
  284. join grmajor in GrademajorRepository.Entities on clmajor.GrademajorID equals grmajor.GrademajorID
  285. join famajor in FacultymajorRepository.Entities on grmajor.FacultymajorID equals famajor.FacultymajorID
  286. //join special in SpecialtyRepository.Entities on new { famajor.StandardID, famajor.EducationID, famajor.LearnSystem, famajor.LearningformID }
  287. //equals new { special.StandardID, special.EducationID, special.LearnSystem, special.LearningformID }
  288. join edutype in EducationTypeSettingRepository.GetList(x => x.EducationTypeID == (int)EMIS.ViewModel.CF_EducationType.Special) on famajor.EducationID equals edutype.EducationID
  289. //最后一次毕业申请是上一年
  290. //join gradApply in GraduationApplyRepository.Entities on student.UserID equals gradApply.UserID
  291. //join grayear in SchoolyearRepository.GetList(x => x.Years == schoolYear - 1) on gradApply.SchoolyearID equals grayear.SchoolyearID
  292. join gradApply in
  293. (
  294. from graduationApply in GraduationApplyRepository.Entities
  295. join schoolyear in SchoolyearRepository.Entities on graduationApply.ApplySchoolyearID equals schoolyear.SchoolyearID
  296. group schoolyear by new { graduationApply.UserID, schoolyear.Years } into g
  297. select new { UserID = g.Key.UserID.Value, graduationYear = g.Max(x => x.Years) }
  298. ) on new { student.UserID, schoolYear = schoolYear.Value } equals new { gradApply.UserID, schoolYear = gradApply.graduationYear + 1 }
  299. group student by new
  300. {
  301. student.SexID,
  302. edutype.EducationTypeID,
  303. //special.SpecialtyID,
  304. famajor.TeacherIdentification,
  305. famajor.StandardID,
  306. famajor.EducationID,
  307. famajor.LearnSystem,
  308. famajor.LearningformID
  309. } into g
  310. select new JuniorSpecialtyStudentCountView
  311. {
  312. Sex = g.Key.SexID,
  313. //SpecialtyID = g.Key.SpecialtyID,
  314. StandardID = g.Key.StandardID,
  315. EducationID = g.Key.EducationID,
  316. LearnSystem = g.Key.LearnSystem,
  317. LearningformID = g.Key.LearningformID,
  318. EducationTypeID = g.Key.EducationTypeID,
  319. GraduationCount = g.Count()
  320. };
  321. return query;
  322. }
  323. }
  324. }