BachelorSpecialtyStudentCountDAL.cs 27 KB

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