StudentChangeDAL.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Linq.Expressions;
  5. using System.Text;
  6. using EMIS.Entities;
  7. using EMIS.ViewModel;
  8. using EMIS.ViewModel.StudentManage.StudentChange;
  9. using EMIS.DataLogic.Repositories;
  10. namespace EMIS.DataLogic.StudentManage.StudentChange
  11. {
  12. public class StudentChangeDAL
  13. {
  14. public DifferentDynamicRepository StudentChangeRepository { get; set; }
  15. public StudentRepository StudentRepository { get; set; }
  16. public ClassmajorRepository ClassmajorRepository { get; set; }
  17. public GrademajorRepository GrademajorRepository { get; set; }
  18. public FacultymajorRepository FacultymajorRepository { get; set; }
  19. public CollegeRepository CollegeRepository { get; set; }
  20. public CampusRepository CampusRepository { get; set; }
  21. public SchoolyearRepository SchoolyearRepository { get; set; }
  22. public UserRepository UserRepository { get; set; }
  23. public StudentReportRepository StudentReportRepository { get; set; }
  24. /// <summary>
  25. /// 查询对应的学生异动信息View
  26. /// </summary>
  27. /// <param name="expStudentChange"></param>
  28. /// <returns></returns>
  29. public IQueryable<StudentChangeView> GetStudentChangeViewQueryable(Expression<Func<CF_DifferentDynamic, bool>> expStudentChange)
  30. {
  31. var query = from stuch in StudentChangeRepository.GetList(expStudentChange)
  32. join stu in StudentRepository.Entities
  33. on stuch.UserID equals stu.UserID
  34. join sy in SchoolyearRepository.Entities
  35. on stuch.SchoolyearID equals sy.SchoolyearID
  36. join cl in ClassmajorRepository.Entities
  37. on stu.ClassmajorID equals cl.ClassmajorID
  38. join gr in GrademajorRepository.Entities
  39. on cl.GrademajorID equals gr.GrademajorID
  40. join fa in FacultymajorRepository.Entities
  41. on gr.FacultymajorID equals fa.FacultymajorID
  42. join col in CollegeRepository.Entities
  43. on fa.CollegeID equals col.CollegeID
  44. join cam in CampusRepository.Entities
  45. on col.CampusID equals cam.CampusID
  46. join us in UserRepository.Entities
  47. on stu.UserID equals us.UserID
  48. join stsy in SchoolyearRepository.Entities
  49. on new { SchoolyearID = gr.GradeID.Value, SchoolcodeID = gr.SemesterID.Value }
  50. equals new { SchoolyearID = stsy.Years, SchoolcodeID = stsy.SchoolcodeID } into tempstsy
  51. from startsy in tempstsy.DefaultIfEmpty()
  52. join grsy in SchoolyearRepository.Entities
  53. on gr.GraduateSchoolyearID equals grsy.SchoolyearID into tempgrsy
  54. from grasy in tempgrsy.DefaultIfEmpty()
  55. join rensy in SchoolyearRepository.Entities
  56. on stuch.ReturnSchoolyearID equals rensy.SchoolyearID into temprensy
  57. from rensy in temprensy.DefaultIfEmpty()
  58. join bfcl in ClassmajorRepository.Entities
  59. on stuch.BeforeClassmajorID equals bfcl.ClassmajorID into tempbfcl
  60. from stubfcl in tempbfcl.DefaultIfEmpty()
  61. join afcl in ClassmajorRepository.Entities
  62. on stuch.AfterClassmajorID equals afcl.ClassmajorID into tempafcl
  63. from stuafcl in tempafcl.DefaultIfEmpty()
  64. join sture in StudentReportRepository.Entities
  65. on new { stuch.SchoolyearID, stuch.UserID } equals new { sture.SchoolyearID, sture.UserID } into tempsture
  66. from sturech in tempsture.DefaultIfEmpty()
  67. join crus in UserRepository.Entities
  68. on stuch.CreateUserID equals crus.UserID into tempcrus
  69. from crusch in tempcrus.DefaultIfEmpty()
  70. select new StudentChangeView
  71. {
  72. StudentChangeID = stuch.StudentChangeID,
  73. UserID = stuch.UserID,
  74. StudentNo = us.LoginID,
  75. Name = us.Name,
  76. SexID = stu.SexID,
  77. BirthDate = stu.BirthDate,
  78. NationID = stu.NationID,
  79. PoliticsID = stu.PoliticsID,
  80. InSchoolStatusID = stu.InSchoolStatusID,
  81. StudentStatus = stu.StudentStatus,
  82. GradeID = gr.GradeID,
  83. SemesterID = gr.SemesterID,
  84. StandardID = fa.StandardID,
  85. EducationID = fa.EducationID,
  86. LearningformID = fa.LearningformID,
  87. LearnSystem = fa.LearnSystem,
  88. ClassNum = cl.ClassNum,
  89. ClassmajorID = stu.ClassmajorID,
  90. ClassmajorNo = cl.No,
  91. ClassmajorName = cl.Name,
  92. GrademajorID = cl.GrademajorID,
  93. GrademajorCode = gr.Code,
  94. GrademajorName = gr.Name,
  95. FacultymajorID = gr.FacultymajorID,
  96. FacultymajorCode = fa.Code,
  97. FacultymajorName = fa.Name,
  98. CollegeID = fa.CollegeID,
  99. CollegeNo = col.No,
  100. CollegeName = col.Name,
  101. CampusID = col.CampusID,
  102. CampusCode = cam.No,
  103. CampusName = cam.Name,
  104. StartSchoolyearID = startsy.SchoolyearID,
  105. StartSchoolyearValue = startsy.Value,
  106. StartSchoolyearCode = startsy.Code,
  107. SchoolyearID = sy.SchoolyearID,
  108. SchoolyearValue = sy.Value,
  109. SchoolyearCode = sy.Code,
  110. GraduateSchoolyearID = gr.GraduateSchoolyearID,
  111. GraduateSchoolyearValue = grasy.Value,
  112. GraduateSchoolyearCode = grasy.Code,
  113. ReportStatus = sturech.ReportStatus ?? (int)CF_ReportStatus.WaitReport,
  114. ChangeTypeID = stuch.ChangeTypeID,
  115. BeforeCollegeID = stubfcl.CF_Grademajor.CF_Facultymajor.CollegeID,
  116. BeforeCollegeNo = stubfcl.CF_Grademajor.CF_Facultymajor.CF_College.No,
  117. BeforeCollegeName = stubfcl.CF_Grademajor.CF_Facultymajor.CF_College.Name,
  118. BeforeGradeID = stubfcl.CF_Grademajor.GradeID,
  119. BeforeStandardID = stubfcl.CF_Grademajor.CF_Facultymajor.StandardID,
  120. BeforeEducationID = stubfcl.CF_Grademajor.CF_Facultymajor.EducationID,
  121. BeforeLearningformID = stubfcl.CF_Grademajor.CF_Facultymajor.LearningformID,
  122. BeforeLearnSystem = stubfcl.CF_Grademajor.CF_Facultymajor.LearnSystem,
  123. BeforeClassmajorID = stuch.BeforeClassmajorID,
  124. BeforeClassmajorNo = stubfcl.No,
  125. BeforeClassmajorName = stubfcl.Name,
  126. BeforeInSchoolStatusID = stuch.BeforeInSchoolStatusID,
  127. BeforeStudentStatus = stuch.BeforeStudentStatus,
  128. AfterCollegeID = stuafcl.CF_Grademajor.CF_Facultymajor.CollegeID,
  129. AfterCollegeNo = stuafcl.CF_Grademajor.CF_Facultymajor.CF_College.No,
  130. AfterCollegeName = stuafcl.CF_Grademajor.CF_Facultymajor.CF_College.Name,
  131. AfterGradeID = stuafcl.CF_Grademajor.GradeID,
  132. AfterStandardID = stuafcl.CF_Grademajor.CF_Facultymajor.StandardID,
  133. AfterEducationID = stuafcl.CF_Grademajor.CF_Facultymajor.EducationID,
  134. AfterLearningformID = stuafcl.CF_Grademajor.CF_Facultymajor.LearningformID,
  135. AfterLearnSystem = stuafcl.CF_Grademajor.CF_Facultymajor.LearnSystem,
  136. AfterClassmajorID = stuch.AfterClassmajorID,
  137. AfterClassmajorNo = stuafcl.No,
  138. AfterClassmajorName = stuafcl.Name,
  139. AfterInSchoolStatusID = stuch.AfterInSchoolStatusID,
  140. AfterStudentStatus = stuch.AfterStudentStatus,
  141. ReturnSchoolyearID = stuch.ReturnSchoolyearID,
  142. ReturnSchoolyearValue = rensy.Value,
  143. ReturnSchoolyearCode = rensy.Code,
  144. ChangeApplyTypeID = stuch.ChangeApplyTypeID,
  145. ChangeReasonID = stuch.ChangeReasonID,
  146. ChangeDate = stuch.ChangeDate,
  147. Description = stuch.Description,
  148. ApprovalStatus = stuch.ApprovalStatus,
  149. Remark = stuch.Remark,
  150. RecordStatus = stuch.RecordStatus,
  151. CreateUserID = stuch.CreateUserID,
  152. CreateUserName = crusch.Name,
  153. CreateTime = stuch.CreateTime,
  154. ModifyUserID = stuch.ModifyUserID,
  155. ModifyTime = stuch.ModifyTime
  156. };
  157. return query;
  158. }
  159. /// <summary>
  160. /// 查询对应的学生异动信息View
  161. /// </summary>
  162. /// <param name="expStudentChange"></param>
  163. /// <param name="expStudent"></param>
  164. /// <returns></returns>
  165. public IQueryable<StudentChangeView> GetStudentChangeViewQueryable(Expression<Func<CF_DifferentDynamic, bool>> expStudentChange,
  166. Expression<Func<CF_Student, bool>> expStudent)
  167. {
  168. var query = from stuch in StudentChangeRepository.GetList(expStudentChange)
  169. join stu in StudentRepository.GetList(expStudent)
  170. on stuch.UserID equals stu.UserID
  171. join sy in SchoolyearRepository.Entities
  172. on stuch.SchoolyearID equals sy.SchoolyearID
  173. join cl in ClassmajorRepository.Entities
  174. on stu.ClassmajorID equals cl.ClassmajorID
  175. join gr in GrademajorRepository.Entities
  176. on cl.GrademajorID equals gr.GrademajorID
  177. join fa in FacultymajorRepository.Entities
  178. on gr.FacultymajorID equals fa.FacultymajorID
  179. join col in CollegeRepository.Entities
  180. on fa.CollegeID equals col.CollegeID
  181. join cam in CampusRepository.Entities
  182. on col.CampusID equals cam.CampusID
  183. join us in UserRepository.Entities
  184. on stu.UserID equals us.UserID
  185. join stsy in SchoolyearRepository.Entities
  186. on new { SchoolyearID = gr.GradeID.Value, SchoolcodeID = gr.SemesterID.Value }
  187. equals new { SchoolyearID = stsy.Years, SchoolcodeID = stsy.SchoolcodeID } into tempstsy
  188. from startsy in tempstsy.DefaultIfEmpty()
  189. join grsy in SchoolyearRepository.Entities
  190. on gr.GraduateSchoolyearID equals grsy.SchoolyearID into tempgrsy
  191. from grasy in tempgrsy.DefaultIfEmpty()
  192. join rensy in SchoolyearRepository.Entities
  193. on stuch.ReturnSchoolyearID equals rensy.SchoolyearID into temprensy
  194. from rensy in temprensy.DefaultIfEmpty()
  195. join bfcl in ClassmajorRepository.Entities
  196. on stuch.BeforeClassmajorID equals bfcl.ClassmajorID into tempbfcl
  197. from stubfcl in tempbfcl.DefaultIfEmpty()
  198. join afcl in ClassmajorRepository.Entities
  199. on stuch.AfterClassmajorID equals afcl.ClassmajorID into tempafcl
  200. from stuafcl in tempafcl.DefaultIfEmpty()
  201. join sture in StudentReportRepository.Entities
  202. on new { stuch.SchoolyearID, stuch.UserID } equals new { sture.SchoolyearID, sture.UserID } into tempsture
  203. from sturech in tempsture.DefaultIfEmpty()
  204. join crus in UserRepository.Entities
  205. on stuch.CreateUserID equals crus.UserID into tempcrus
  206. from crusch in tempcrus.DefaultIfEmpty()
  207. select new StudentChangeView
  208. {
  209. StudentChangeID = stuch.StudentChangeID,
  210. UserID = stuch.UserID,
  211. StudentNo = us.LoginID,
  212. Name = us.Name,
  213. SexID = stu.SexID,
  214. BirthDate = stu.BirthDate,
  215. NationID = stu.NationID,
  216. PoliticsID = stu.PoliticsID,
  217. InSchoolStatusID = stu.InSchoolStatusID,
  218. StudentStatus = stu.StudentStatus,
  219. GradeID = gr.GradeID,
  220. SemesterID = gr.SemesterID,
  221. StandardID = fa.StandardID,
  222. EducationID = fa.EducationID,
  223. LearningformID = fa.LearningformID,
  224. LearnSystem = fa.LearnSystem,
  225. ClassNum = cl.ClassNum,
  226. ClassmajorID = stu.ClassmajorID,
  227. ClassmajorNo = cl.No,
  228. ClassmajorName = cl.Name,
  229. GrademajorID = cl.GrademajorID,
  230. GrademajorCode = gr.Code,
  231. GrademajorName = gr.Name,
  232. FacultymajorID = gr.FacultymajorID,
  233. FacultymajorCode = fa.Code,
  234. FacultymajorName = fa.Name,
  235. CollegeID = fa.CollegeID,
  236. CollegeNo = col.No,
  237. CollegeName = col.Name,
  238. CampusID = col.CampusID,
  239. CampusCode = cam.No,
  240. CampusName = cam.Name,
  241. StartSchoolyearID = startsy.SchoolyearID,
  242. StartSchoolyearValue = startsy.Value,
  243. StartSchoolyearCode = startsy.Code,
  244. SchoolyearID = sy.SchoolyearID,
  245. SchoolyearValue = sy.Value,
  246. SchoolyearCode = sy.Code,
  247. GraduateSchoolyearID = gr.GraduateSchoolyearID,
  248. GraduateSchoolyearValue = grasy.Value,
  249. GraduateSchoolyearCode = grasy.Code,
  250. ReportStatus = sturech.ReportStatus ?? (int)CF_ReportStatus.WaitReport,
  251. ChangeTypeID = stuch.ChangeTypeID,
  252. BeforeCollegeID = stubfcl.CF_Grademajor.CF_Facultymajor.CollegeID,
  253. BeforeCollegeNo = stubfcl.CF_Grademajor.CF_Facultymajor.CF_College.No,
  254. BeforeCollegeName = stubfcl.CF_Grademajor.CF_Facultymajor.CF_College.Name,
  255. BeforeGradeID = stubfcl.CF_Grademajor.GradeID,
  256. BeforeStandardID = stubfcl.CF_Grademajor.CF_Facultymajor.StandardID,
  257. BeforeEducationID = stubfcl.CF_Grademajor.CF_Facultymajor.EducationID,
  258. BeforeLearningformID = stubfcl.CF_Grademajor.CF_Facultymajor.LearningformID,
  259. BeforeLearnSystem = stubfcl.CF_Grademajor.CF_Facultymajor.LearnSystem,
  260. BeforeClassmajorID = stuch.BeforeClassmajorID,
  261. BeforeClassmajorNo = stubfcl.No,
  262. BeforeClassmajorName = stubfcl.Name,
  263. BeforeInSchoolStatusID = stuch.BeforeInSchoolStatusID,
  264. BeforeStudentStatus = stuch.BeforeStudentStatus,
  265. AfterCollegeID = stuafcl.CF_Grademajor.CF_Facultymajor.CollegeID,
  266. AfterCollegeNo = stuafcl.CF_Grademajor.CF_Facultymajor.CF_College.No,
  267. AfterCollegeName = stuafcl.CF_Grademajor.CF_Facultymajor.CF_College.Name,
  268. AfterGradeID = stuafcl.CF_Grademajor.GradeID,
  269. AfterStandardID = stuafcl.CF_Grademajor.CF_Facultymajor.StandardID,
  270. AfterEducationID = stuafcl.CF_Grademajor.CF_Facultymajor.EducationID,
  271. AfterLearningformID = stuafcl.CF_Grademajor.CF_Facultymajor.LearningformID,
  272. AfterLearnSystem = stuafcl.CF_Grademajor.CF_Facultymajor.LearnSystem,
  273. AfterClassmajorID = stuch.AfterClassmajorID,
  274. AfterClassmajorNo = stuafcl.No,
  275. AfterClassmajorName = stuafcl.Name,
  276. AfterInSchoolStatusID = stuch.AfterInSchoolStatusID,
  277. AfterStudentStatus = stuch.AfterStudentStatus,
  278. ReturnSchoolyearID = stuch.ReturnSchoolyearID,
  279. ReturnSchoolyearValue = rensy.Value,
  280. ReturnSchoolyearCode = rensy.Code,
  281. ChangeApplyTypeID = stuch.ChangeApplyTypeID,
  282. ChangeReasonID = stuch.ChangeReasonID,
  283. ChangeDate = stuch.ChangeDate,
  284. Description = stuch.Description,
  285. ApprovalStatus = stuch.ApprovalStatus,
  286. Remark = stuch.Remark,
  287. RecordStatus = stuch.RecordStatus,
  288. CreateUserID = stuch.CreateUserID,
  289. CreateUserName = crusch.Name,
  290. CreateTime = stuch.CreateTime,
  291. ModifyUserID = stuch.ModifyUserID,
  292. ModifyTime = stuch.ModifyTime
  293. };
  294. return query;
  295. }
  296. /// <summary>
  297. /// 查询对应的异动统计信息View
  298. /// </summary>
  299. /// <param name="expStudentChange"></param>
  300. /// <returns></returns>
  301. public IQueryable<ChangeTotalView> GetChangeTotalViewQueryable(Expression<Func<CF_DifferentDynamic, bool>> expStudentChange)
  302. {
  303. var query = from stuch in StudentChangeRepository.GetList(expStudentChange)
  304. join stu in StudentRepository.Entities
  305. on stuch.UserID equals stu.UserID
  306. join cl in ClassmajorRepository.Entities
  307. on stu.ClassmajorID equals cl.ClassmajorID
  308. join gr in GrademajorRepository.Entities
  309. on cl.GrademajorID equals gr.GrademajorID
  310. join fa in FacultymajorRepository.Entities
  311. on gr.FacultymajorID equals fa.FacultymajorID
  312. join col in CollegeRepository.Entities
  313. on fa.CollegeID equals col.CollegeID
  314. join cam in CampusRepository.Entities
  315. on col.CampusID equals cam.CampusID
  316. group new { stuch, fa, col, cam } by new
  317. {
  318. CampusID = cam.CampusID,
  319. CampusCode = cam.No,
  320. CampusName = cam.Name,
  321. CollegeID = col.CollegeID,
  322. CollegeNo = col.No,
  323. CollegeName = col.Name,
  324. ChangeTypeID = stuch.ChangeTypeID
  325. } into g
  326. select new ChangeTotalView
  327. {
  328. CampusID = g.Key.CampusID,
  329. CampusCode = g.Key.CampusCode,
  330. CampusName = g.Key.CampusName,
  331. CollegeID = g.Key.CollegeID,
  332. CollegeNo = g.Key.CollegeNo,
  333. CollegeName = g.Key.CollegeName,
  334. ChangeTypeID = g.Key.ChangeTypeID,
  335. ChangeTypeCount = g.Count()
  336. };
  337. return query;
  338. }
  339. }
  340. }