ExaminationPlanDAL.cs 43 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Data.Entity;
  5. using System.Text;
  6. using EMIS.DataLogic.Repositories;
  7. using EMIS.ViewModel.ExaminationManage;
  8. using System.Linq.Expressions;
  9. using EMIS.Entities;
  10. using EMIS.ViewModel;
  11. using EMIS.ViewModel.UniversityManage.TeacherManage;
  12. using EMIS.ViewModel.Students;
  13. using EMIS.DataLogic.Common.Students;
  14. using EMIS.DataLogic.ScoreManage;
  15. using EMIS.DataLogic.Common.CalendarManage;
  16. using EMIS.ViewModel.EducationSchedule;
  17. using EMIS.DataLogic.UniversityManage.TeacherManage;
  18. namespace EMIS.DataLogic.ExaminationManage
  19. {
  20. public class ExaminationPlanDAL
  21. {
  22. public ExaminationPlanRepository ExaminationPlanRepository { get; set; }
  23. public ExaminationRoomLayoutRepository ExaminationRoomLayoutRepository { get; set; }
  24. public ExaminationModeSettingRepository ExaminationModeSettingRepository { get; set; }
  25. public EducationMissionRepository EducationMissionRepository { get; set; }
  26. public EducationMissionExamTimeRepository EducationMissionExamTimeRepository { get; set; }
  27. public EducationMissionClassRepository EducationMissionClassRepository { get; set; }
  28. public ExecutablePlanRepository ExecutablePlanRepository { get; set; }
  29. public ExecutablePlanProfileRepository ExecutablePlanProfileRepository { get; set; }
  30. public SpecialtyPlanRepository SpecialtyPlanRepository { get; set; }
  31. public SpecialtyCourseRepository SpecialtyCourseRepository { get; set; }
  32. public CoursematerialRepository CoursematerialRepository { get; set; }
  33. public StudentRepository StudentRepository { get; set; }
  34. public SchoolyearRepository SchoolyearRepository { get; set; }
  35. public ClassroomRepository ClassroomRepository { get; set; }
  36. public ClassmajorRepository ClassmajorRepository { get; set; }
  37. public GrademajorRepository GrademajorRepository { get; set; }
  38. public StaffRepository staffRepository { get; set; }
  39. public EducationSchedulingClassRepository educationSchedulingClassRepository { get; set; }
  40. public EducationSchedulingRepository educationSchedulingRepository { get; set; }
  41. public EducationSchedulingWeekNumRepository educationSchedulingWeekNumRepository { get; set; }
  42. public UserRepository userRepository { get; set; }
  43. public StaffDAL StaffDAL { get; set; }
  44. public StudentsDAL StudentsDAL { get; set; }
  45. public Lazy<FinalExaminationDAL> FinalExaminationDAL { get; set; }
  46. public IQueryable<ExaminationPlanView> GetExaminationPlanView(Expression<Func<EX_ExaminationPlan, bool>> examinationPlanExpression)
  47. {
  48. var inschool = StudentsDAL.InSchoolSettingRepository.Entities.Where(x => x.IsSelected == true).Select(x => x.InSchoolStatusID).ToList();
  49. var q = (from ep in ExaminationPlanRepository.GetList(examinationPlanExpression)
  50. join epg in (
  51. from ep in ExaminationPlanRepository.GetList(examinationPlanExpression)
  52. join emc in EducationMissionClassRepository.Entities on ep.EducationMissionID equals emc.EducationMissionID
  53. join escr in educationSchedulingClassRepository.Entities on emc.EducationMissionClassID equals escr.EducationMissionClassID
  54. join esr in educationSchedulingRepository.Entities on escr.EducationSchedulingClassID equals esr.EducationSchedulingClassID
  55. join eswnr in educationSchedulingWeekNumRepository.Entities on esr.EducationSchedulingID equals eswnr.EducationSchedulingID
  56. group new {ep,eswnr}
  57. by ep.ExaminationPlanID
  58. into gep
  59. select new {
  60. gep.Key,
  61. WeekNum = gep.Max(x => x.eswnr.WeekNum)
  62. }
  63. )
  64. on ep.ExaminationPlanID equals epg.Key into week
  65. from epg in week.DefaultIfEmpty()
  66. join em in EducationMissionRepository.Entities on ep.EducationMissionID equals em.EducationMissionID into dem
  67. from eem in dem.DefaultIfEmpty()
  68. select new ExaminationPlanView
  69. {
  70. ExaminationPlanID = ep.ExaminationPlanID,
  71. SchoolyearID = ep.SchoolyearID,
  72. SchoolyearCode = ep.CF_Schoolyear.Code,
  73. CampusID = ep.CF_College.CampusID,
  74. CampusName = ep.CF_College.CF_Campus.Name,
  75. CollegeID = ep.CollegeID,
  76. CollegeName = ep.CF_College.Name,
  77. CoursematerialID = ep.CoursematerialID,
  78. CoursematerialName = ep.EM_Coursematerial.CourseName,
  79. ExaminationModeID = ep.ExaminationModeID,
  80. ExaminationStyleID = ep.ExaminationStyleID,
  81. ExamsCategoryID = ep.ExamsCategoryID,
  82. EducationMissionID = ep.EducationMissionID,
  83. ClassName = ep.ClassName,
  84. ExaminationDate = ep.ExaminationDate,
  85. CF_Classroom = ep.EX_ExaminationRoomLayout.Select(x => x.CF_Classroom),
  86. StartTime = ep.StartTime,
  87. EndTime = ep.EndTime,
  88. CourseEndWeekNum = epg.WeekNum,
  89. MaxWeekNum = eem.EM_EducationMissionExamWeekNum.Max(x => x.WeeklyNum),
  90. WeekNum = eem.EM_EducationMissionExamWeekNum,
  91. MissionStudentCount = ep.CF_Student.Count(x => inschool.Contains(x.InSchoolStatusID)),
  92. StudentCount = ep.EX_ExaminationRoomLayout.Sum(x => x.EX_ExaminationRoomStudent.Count()),
  93. RecordStatus = ep.RecordStatus,
  94. CreateUserID = ep.CreateUserID,
  95. CreateTime = ep.CreateTime,
  96. ModifyUserID = ep.ModifyUserID,
  97. ModifyTime = ep.ModifyTime
  98. });
  99. return q;
  100. }
  101. public IQueryable<ExaminationPlanGdssView> GetExaminationPlanGdssView(Expression<Func<EX_ExaminationPlan, bool>> examinationPlanExpression)
  102. {
  103. var q = (from plan in GetExaminationPlanView(examinationPlanExpression)
  104. from layout in ExaminationRoomLayoutRepository.Entities.Where(x => x.ExaminationPlanID == plan.ExaminationPlanID)
  105. .Take(1).DefaultIfEmpty()
  106. from classroom in ClassroomRepository.Entities.Where(x => x.ClassroomID == layout.ClassroomID).DefaultIfEmpty()
  107. select new ExaminationPlanGdssView
  108. {
  109. ExaminationPlanID = plan.ExaminationPlanID,
  110. SchoolyearID = plan.SchoolyearID,
  111. SchoolyearCode = plan.SchoolyearCode,
  112. CampusID = plan.CampusID,
  113. CampusName = plan.CampusName,
  114. CollegeID = plan.CollegeID,
  115. CollegeName = plan.CollegeName,
  116. CoursematerialID = plan.CoursematerialID,
  117. CoursematerialName = plan.CoursematerialName,
  118. ExaminationModeID = plan.ExaminationModeID,
  119. ExaminationStyleID = plan.ExaminationStyleID,
  120. ExamsCategoryID = plan.ExamsCategoryID,
  121. EducationMissionID = plan.EducationMissionID,
  122. ClassName = plan.ClassName,
  123. ExaminationDate = plan.ExaminationDate,
  124. CF_Classroom = plan.CF_Classroom,
  125. BuildingsInfoID = classroom.BuildingsInfoID,
  126. ClassroomID = classroom.ClassroomID,
  127. StudentOrderType = layout.StudentOrderType,
  128. StartTime = plan.StartTime,
  129. EndTime = plan.EndTime,
  130. CourseEndWeekNum = plan.CourseEndWeekNum,
  131. MaxWeekNum = plan.MaxWeekNum,
  132. WeekNum = plan.WeekNum,
  133. MissionStudentCount = plan.MissionStudentCount,
  134. StudentCount = plan.StudentCount,
  135. RecordStatus = plan.RecordStatus,
  136. CreateUserID = plan.CreateUserID,
  137. CreateTime = plan.CreateTime,
  138. ModifyUserID = plan.ModifyUserID,
  139. ModifyTime = plan.ModifyTime
  140. });
  141. return q;
  142. }
  143. public IQueryable<ExaminationPlanView> GetExaminationPlanViewForAdult(Expression<Func<EX_ExaminationPlan, bool>> examinationPlanExpression)
  144. {
  145. var inschool = StudentsDAL.InSchoolSettingRepository.Entities.Where(x => x.IsSelected == true).Select(x => x.InSchoolStatusID).ToList();
  146. var q = (from ep in ExaminationPlanRepository.GetList(examinationPlanExpression)
  147. join epg in
  148. (
  149. from ep in ExaminationPlanRepository.GetList(examinationPlanExpression)
  150. join emc in EducationMissionClassRepository.Entities on ep.EducationMissionID equals emc.EducationMissionID
  151. join escr in educationSchedulingClassRepository.Entities on emc.EducationMissionClassID equals escr.EducationMissionClassID
  152. join esr in educationSchedulingRepository.Entities on escr.EducationSchedulingClassID equals esr.EducationSchedulingClassID
  153. join eswnr in educationSchedulingWeekNumRepository.Entities on esr.EducationSchedulingID equals eswnr.EducationSchedulingID
  154. group new { ep, eswnr }
  155. by ep.ExaminationPlanID
  156. into gep
  157. select new
  158. {
  159. gep.Key,
  160. WeekNum = gep.Max(x => x.eswnr.WeekNum)
  161. }
  162. )
  163. on ep.ExaminationPlanID equals epg.Key into week
  164. from epg in week.DefaultIfEmpty()
  165. join em in EducationMissionRepository.Entities on ep.EducationMissionID equals em.EducationMissionID into dem
  166. from eem in dem.DefaultIfEmpty()
  167. join erlr in ExaminationRoomLayoutRepository.Entities
  168. on ep.ExaminationPlanID equals erlr.ExaminationPlanID into erlem
  169. from derlr in erlem.DefaultIfEmpty()
  170. select new ExaminationPlanView
  171. {
  172. ExaminationPlanID = ep.ExaminationPlanID,
  173. SchoolyearID = ep.SchoolyearID,
  174. SchoolyearCode = ep.CF_Schoolyear.Code,
  175. CampusID = ep.CF_College.CampusID,
  176. CampusName = ep.CF_College.CF_Campus.Name,
  177. CollegeID = ep.CollegeID,
  178. CollegeName = ep.CF_College.Name,
  179. CoursematerialID = ep.CoursematerialID,
  180. CoursematerialName = ep.EM_Coursematerial.CourseName,
  181. ExaminationModeID = ep.ExaminationModeID,
  182. ExaminationStyleID = ep.ExaminationStyleID,
  183. ExamsCategoryID = ep.ExamsCategoryID,
  184. EducationMissionID = ep.EducationMissionID,
  185. ClassName = ep.ClassName,
  186. ExaminationDate = ep.ExaminationDate,
  187. CF_Classroom = ep.EX_ExaminationRoomLayout.Select(x => x.CF_Classroom),
  188. staffUser = derlr.CF_Staff.Select(x => x.Sys_User),
  189. StartTime = ep.StartTime,
  190. EndTime = ep.EndTime,
  191. CourseEndWeekNum = epg.WeekNum,
  192. MaxWeekNum = eem.EM_EducationMissionExamWeekNum.Max(x => x.WeeklyNum),
  193. WeekNum = eem.EM_EducationMissionExamWeekNum,
  194. MissionStudentCount = ep.CF_Student.Count(x => inschool.Contains(x.InSchoolStatusID)),
  195. StudentCount = ep.EX_ExaminationRoomLayout.Sum(x => x.EX_ExaminationRoomStudent.Count()),
  196. RecordStatus = ep.RecordStatus,
  197. CreateUserID = ep.CreateUserID,
  198. CreateTime = ep.CreateTime,
  199. ModifyUserID = ep.ModifyUserID,
  200. ModifyTime = ep.ModifyTime
  201. });
  202. return q;
  203. }
  204. public IQueryable<ExaminationRoomLayoutView> GetExaminationRoomLayoutView(Expression<Func<EX_ExaminationRoomLayout, bool>> examinationRoomLayoutExpression)
  205. {
  206. var q = (from erl in ExaminationRoomLayoutRepository.GetList(examinationRoomLayoutExpression)
  207. select new ExaminationRoomLayoutView
  208. {
  209. ExaminationRoomLayoutID = erl.ExaminationRoomLayoutID,
  210. ExaminationPlanID = erl.ExaminationPlanID.Value,
  211. ClassroomID = erl.ClassroomID,
  212. ClassroomName = erl.CF_Classroom.Name,
  213. Totalseating = erl.CF_Classroom.Totalseating,
  214. Examinationseating = erl.CF_Classroom.Examinationseating,
  215. RowSpacing = erl.RowSpacing,
  216. ColumnSpacing = erl.ColumnSpacing,
  217. StudentOrderType = erl.StudentOrderType,
  218. StudentNum=erl.EX_ExaminationRoomStudent.Count(),
  219. Sys_User = erl.CF_Staff.Select(x => x.Sys_User),
  220. IsSubmitted = erl.EX_ExaminationPlan.RecordStatus == (int)CF_ApprovalStatus.Submitted,
  221. EX_ExaminationRoomStudent = erl.EX_ExaminationRoomStudent,
  222. RecordStatus = erl.RecordStatus,
  223. CreateTime = erl.CreateTime,
  224. CreateUserID = erl.CreateUserID,
  225. ModifyTime = erl.ModifyTime,
  226. ModifyUserID = erl.ModifyUserID
  227. });
  228. return q;
  229. }
  230. public IQueryable<StaffView> GetExaminationTeacherView(Expression<Func<EX_ExaminationRoomLayout, bool>> examinationRoomLayoutExpression,
  231. Expression<Func<CF_Staff, bool>> staffExpression)
  232. {
  233. var q = (from erl in ExaminationRoomLayoutRepository.GetList(examinationRoomLayoutExpression)
  234. from s in erl.CF_Staff
  235. join sv in StaffDAL.GetStaffViewQueryable(staffExpression) on s.UserID equals sv.UserID
  236. select sv);
  237. return q;
  238. }
  239. public IQueryable<StudentsView> GetExaminationStudentView(Expression<Func<EX_ExaminationRoomLayout, bool>> examinationRoomLayoutExpression,
  240. Expression<Func<CF_Student, bool>> studentExpression)
  241. {
  242. var q = (from erl in ExaminationRoomLayoutRepository.GetList(examinationRoomLayoutExpression)
  243. from s in erl.EX_ExaminationRoomStudent
  244. join sv in StudentsDAL.GetStudentQueryable(studentExpression, (x => true), (x => true)) on s.UserID equals sv.UserID
  245. select sv);
  246. return q;
  247. }
  248. public IQueryable<ExaminationRoomStudentView> GetExaminationRoomStudentView(Expression<Func<EX_ExaminationRoomLayout, bool>> examinationRoomLayoutExpression)
  249. {
  250. var q = (from erl in ExaminationRoomLayoutRepository.GetList(examinationRoomLayoutExpression)
  251. from s in erl.EX_ExaminationRoomStudent
  252. select new ExaminationRoomStudentView
  253. {
  254. ExaminationRoomStudentID = s.ExaminationRoomStudentID,
  255. ExaminationRoomLayoutID = s.ExaminationRoomLayoutID,
  256. UserID = s.UserID,
  257. LoginID = s.CF_Student.Sys_User.LoginID,
  258. Name = s.CF_Student.Sys_User.Name,
  259. Row = s.Row,
  260. Column = s.Column,
  261. Remark = s.Remark,
  262. RecordStatus = s.RecordStatus,
  263. CreateTime = s.CreateTime,
  264. CreateUserID = s.CreateUserID,
  265. ModifyTime = s.ModifyTime,
  266. ModifyUserID = s.ModifyUserID
  267. });
  268. return q;
  269. }
  270. public virtual IQueryable<ExaminationPlanView> GetExaminationPlanByEducationMission(Expression<Func<EM_EducationMission, bool>> educationMissionExpression, Expression<Func<EM_EducationMissionClass, bool>> emcExp)
  271. {
  272. var missionClassQuery = (
  273. from emc in EducationMissionClassRepository.GetList(emcExp)
  274. join cm in CoursematerialRepository.Entities on emc.CoursematerialID equals cm.CoursematerialID
  275. join ems in ExaminationModeSettingRepository.GetList(x => x.IsGeneratePlan == false)
  276. on emc.ExaminationModeID equals ems.ExaminationModeID into dems
  277. from eems in dems.DefaultIfEmpty()
  278. where emc.RecordStatus != (int)EM_EducationMissionClassStatus.NotSubmitted
  279. && eems.ExaminationModeSettingID == null && emc.HandleModeID == (int)CF_HandleMode.RequiredCourse
  280. group emc by new {
  281. emc.EducationMissionID,
  282. emc.CoursematerialID,
  283. cm.CourseName,
  284. emc.ExaminationModeID
  285. } into g
  286. select g.Key
  287. );
  288. var q = (from em in EducationMissionRepository.GetList(educationMissionExpression)
  289. join c in missionClassQuery
  290. on em.EducationMissionID equals c.EducationMissionID
  291. join ep in ExaminationPlanRepository.Entities
  292. on em.EducationMissionID equals ep.EducationMissionID into dep
  293. from eep in dep.DefaultIfEmpty()
  294. join emet in EducationMissionExamTimeRepository.Entities on em.EducationMissionID equals emet.EducationMissionID into demet
  295. from eemet in demet.DefaultIfEmpty()
  296. where eep.EducationMissionID == null
  297. select new ExaminationPlanView
  298. {
  299. //ExaminationPlanID = Guid.NewGuid(),
  300. SchoolyearID = em.SchoolyearID,
  301. CollegeID = em.CollegeID,
  302. CoursematerialID = c.CoursematerialID,
  303. ExaminationModeID = c.ExaminationModeID,
  304. ExaminationStyleID = (int)EX_ExaminationStyle.CloseBook,
  305. EducationMissionID = em.EducationMissionID,
  306. ClassName = em.ClassName,
  307. ExaminationDate = (eemet.EducationMissionExamTimeID != null) ? eemet.ExamDate : null,
  308. StartTime = (eemet.EducationMissionExamTimeID != null) ? eemet.StartTime : null,
  309. EndTime = (eemet.EducationMissionExamTimeID != null) ? eemet.EndTime : null,
  310. Students = em.EM_EducationMissionClass.FirstOrDefault().EM_EducationSchedulingClass.SelectMany(x => x.CF_Student)
  311. });
  312. return q;
  313. }
  314. public IQueryable<ExaminationPlanView> GetExaminationPlanByResitStudent(Guid? schoolyearID, Guid? currentSchoolyearID)
  315. {
  316. var resitStudent = FinalExaminationDAL.Value.GetNotPassStudent(schoolyearID);
  317. var q = (from rs in resitStudent
  318. from s in StudentRepository.Entities.Where(x => x.UserID == rs.UserID)
  319. from eep in
  320. (
  321. from ep in ExaminationPlanRepository.Entities.Where(x => x.SchoolyearID == currentSchoolyearID
  322. && x.CollegeID == rs.CollegeID && x.CoursematerialID == rs.CoursematerialID && x.ExaminationModeID == rs.ExaminationModeID
  323. && x.ExamsCategoryID == (int?)CF_ExamsCategory.Resit)
  324. from eps in ep.CF_Student.Where(x => x.UserID == rs.UserID)
  325. select eps
  326. ).DefaultIfEmpty()
  327. where eep.UserID == null
  328. group new { ResitStudent = rs, Students = s } by new
  329. {
  330. rs.Year,
  331. rs.CollegeID,
  332. rs.GrademajorID,
  333. rs.GrademajorName,
  334. rs.CoursematerialID,
  335. rs.DepartmentID,
  336. rs.CourseName,
  337. rs.CourseTypeID,
  338. rs.ExaminationModeID,
  339. rs.StartTermID,
  340. rs.Credit,
  341. rs.ResultTypeID
  342. } into g
  343. select new ExaminationPlanView
  344. {
  345. //ExaminationPlanID = Guid.NewGuid(),
  346. SchoolyearID = currentSchoolyearID,
  347. CollegeID = g.Key.CollegeID,
  348. CoursematerialID = g.Key.CoursematerialID,
  349. ExaminationModeID = g.Key.ExaminationModeID,
  350. ExaminationStyleID = (int)EX_ExaminationStyle.CloseBook,
  351. Students = g.Select(x => x.Students),
  352. ClassName = g.Key.CourseName + " - " + g.Key.GrademajorName + "-补考"
  353. });
  354. return q;
  355. }
  356. public IQueryable<ExaminationPlanView> GetExaminationPlanByResitExamination(Guid? currentSchoolyearID)
  357. {
  358. var resitExaminationStudent = (
  359. from student in FinalExaminationDAL.Value.FinalExaminationStudentRepository.Entities
  360. from exam in FinalExaminationDAL.Value.finalExaminationRepository.Entities.Where(x => x.FinalExaminationID == student.FinalExaminationID
  361. && x.SchoolyearID == currentSchoolyearID
  362. && x.ExamsCategoryID != (int)CF_ExamsCategory.GraduationExam
  363. && x.ExaminationType == (int)CF_ExaminationType.ResitExamination)
  364. select new { student.UserID, exam.FinalExaminationID, exam.CollegeID, exam.CoursematerialID, exam.ExaminationModeID }
  365. );
  366. var q = (
  367. from resit in resitExaminationStudent
  368. from course in CoursematerialRepository.Entities.Where(x => x.CoursematerialID == resit.CoursematerialID)
  369. from student in StudentRepository.Entities.Where(x => x.UserID == resit.UserID)
  370. from classmajor in ClassmajorRepository.Entities.Where(x => x.ClassmajorID == student.ClassmajorID)
  371. from grade in GrademajorRepository.Entities.Where(x => x.GrademajorID == classmajor.GrademajorID)
  372. from plan in student.EX_ExaminationPlan.
  373. Where(x => x.SchoolyearID == currentSchoolyearID
  374. && x.CollegeID == resit.CollegeID
  375. && x.CoursematerialID == resit.CoursematerialID
  376. && x.ExaminationModeID == resit.ExaminationModeID
  377. && x.ExamsCategoryID == (int)CF_ExamsCategory.Resit).DefaultIfEmpty()
  378. where plan.ExaminationPlanID == null
  379. group student by new
  380. {
  381. //resit.FinalExaminationID,
  382. resit.CollegeID,
  383. resit.CoursematerialID,
  384. resit.ExaminationModeID,
  385. ClassName = course.CourseName + " - " + grade.Name + "-补考"
  386. } into g
  387. select new ExaminationPlanView
  388. {
  389. SchoolyearID = currentSchoolyearID,
  390. CollegeID = g.Key.CollegeID,
  391. CoursematerialID = g.Key.CoursematerialID,
  392. ExaminationModeID = g.Key.ExaminationModeID,
  393. ExaminationStyleID = (int)EX_ExaminationStyle.CloseBook,
  394. Students = g.Select(x => x),
  395. ClassName = g.Key.ClassName
  396. }
  397. );
  398. return q;
  399. }
  400. public IQueryable<ExaminationPlanView> GetExaminationPlanByGraduateExamStudent(int? yearID, Guid? collegeID, int? standardID, decimal? learnSystem, Guid? currentSchoolyearID)
  401. {
  402. var resitStudent = FinalExaminationDAL.Value.GetGraduationExamStudent(yearID);
  403. if (collegeID.HasValue) //院系所
  404. resitStudent = resitStudent.Where(x => x.CollegeID == collegeID);
  405. if (yearID.HasValue && yearID != -1) //年级
  406. resitStudent = resitStudent.Where(x => x.Year == yearID);
  407. if (standardID.HasValue) //专业
  408. resitStudent = resitStudent.Where(x => x.StandardID == standardID);
  409. //if (classmajorID.HasValue)
  410. // resitStudent = resitStudent.Where(x => x.ClassmajorID == classmajorID);
  411. if (learnSystem.HasValue && learnSystem != -1)
  412. resitStudent = resitStudent.Where(x => x.LearnSystem == learnSystem);
  413. var q = (from rs in resitStudent
  414. from s in StudentRepository.Entities.Where(x => x.UserID == rs.UserID)
  415. from eep in (
  416. from ep in ExaminationPlanRepository.Entities.Where(x =>
  417. x.SchoolyearID == currentSchoolyearID && x.CollegeID == rs.CollegeID && x.CoursematerialID == rs.CoursematerialID
  418. && x.ExaminationModeID == rs.ExaminationModeID && x.ExamsCategoryID == (int?)CF_ExamsCategory.GraduationExam)
  419. from eps in ep.CF_Student
  420. where eps.UserID == rs.UserID
  421. select eps
  422. ).DefaultIfEmpty()
  423. where eep.UserID == null
  424. group new { ResitStudent = rs, Students = s } by new
  425. {
  426. rs.Year,
  427. rs.CollegeID,
  428. rs.GrademajorID,
  429. rs.GrademajorName,
  430. rs.CoursematerialID,
  431. rs.DepartmentID,
  432. rs.CourseName,
  433. rs.CourseTypeID,
  434. rs.ExaminationModeID,
  435. rs.StartTermID,
  436. rs.Credit,
  437. rs.ResultTypeID
  438. } into g
  439. select new ExaminationPlanView
  440. {
  441. //ExaminationPlanID = Guid.NewGuid(),
  442. SchoolyearID = currentSchoolyearID,
  443. CollegeID = g.Key.CollegeID,
  444. CoursematerialID = g.Key.CoursematerialID,
  445. ExaminationModeID = g.Key.ExaminationModeID,
  446. ExaminationStyleID = (int)EX_ExaminationStyle.CloseBook,
  447. Students = g.Select(x => x.Students),
  448. ClassName = g.Key.CourseName + " - " + g.Key.GrademajorName + "-毕业补考"
  449. });
  450. return q;
  451. }
  452. public IQueryable<ExaminationPlanView> GetExaminationPlanByGraduateExamination(Guid? currentSchoolyearID)
  453. {
  454. var graduateExaminationStudent = FinalExaminationDAL.Value.FinalExaminationStudentRepository.GetList(x =>
  455. x.ER_FinalExamination.SchoolyearID == currentSchoolyearID
  456. && x.ER_FinalExamination.ExamsCategoryID == (int)CF_ExamsCategory.GraduationExam);
  457. var q = (
  458. from fs in graduateExaminationStudent
  459. join s in StudentRepository.Entities on fs.UserID equals s.UserID
  460. from ep in s.EX_ExaminationPlan.
  461. Where(x => x.SchoolyearID == currentSchoolyearID
  462. && x.CollegeID == fs.ER_FinalExamination.CollegeID
  463. && x.CoursematerialID == fs.ER_FinalExamination.CoursematerialID
  464. && x.ExaminationModeID == fs.ER_FinalExamination.ExaminationModeID
  465. && x.ExamsCategoryID == fs.ER_FinalExamination.ExamsCategoryID).DefaultIfEmpty()
  466. where ep.ExaminationPlanID == null
  467. group s by new
  468. {
  469. fs.FinalExaminationID,
  470. fs.ER_FinalExamination.CollegeID,
  471. fs.ER_FinalExamination.CoursematerialID,
  472. fs.ER_FinalExamination.ExaminationModeID,
  473. fs.ER_FinalExamination.ClassName
  474. } into g
  475. select new ExaminationPlanView
  476. {
  477. SchoolyearID = currentSchoolyearID,
  478. CollegeID = g.Key.CollegeID,
  479. CoursematerialID = g.Key.CoursematerialID,
  480. ExaminationModeID = g.Key.ExaminationModeID,
  481. ExaminationStyleID = (int)EX_ExaminationStyle.CloseBook,
  482. Students = g.Select(x => x),
  483. ClassName = g.Key.ClassName
  484. }
  485. );
  486. return q;
  487. }
  488. public IQueryable<StudentsView> GetAvailableStudentView(Expression<Func<EX_ExaminationPlan, bool>> examinationPlanExpression,
  489. Expression<Func<CF_Student, bool>> studentExp)
  490. {
  491. var q = (
  492. from ep in ExaminationPlanRepository.GetList(examinationPlanExpression)
  493. from eps in ep.CF_Student
  494. join s in StudentsDAL.GetStudentQueryable(studentExp, (x => true), (x => true)) on eps.UserID equals s.UserID
  495. join nas in
  496. (
  497. from epm in ExaminationPlanRepository.GetList(examinationPlanExpression)
  498. join erl in ExaminationRoomLayoutRepository.Entities on true equals true
  499. where erl.EX_ExaminationPlan.ExaminationDate == epm.ExaminationDate
  500. && erl.EX_ExaminationPlan.EndTime >= epm.StartTime && erl.EX_ExaminationPlan.StartTime <= epm.EndTime
  501. from s in erl.EX_ExaminationRoomStudent
  502. select s
  503. ) on eps.UserID equals nas.UserID into dnas
  504. from enas in dnas.DefaultIfEmpty()
  505. where enas.UserID == null
  506. select s
  507. );
  508. return q;
  509. }
  510. public IQueryable<StudentConflictView> GetConflictStudentView(Expression<Func<EX_ExaminationPlan, bool>> examinationPlanExp,
  511. DateTime? date, TimeSpan? startTime, TimeSpan? endTime)
  512. {
  513. var q = (
  514. from ep in ExaminationPlanRepository.GetList(examinationPlanExp)
  515. from erl in ep.EX_ExaminationRoomLayout
  516. from ers in erl.EX_ExaminationRoomStudent
  517. join erlt in
  518. (
  519. from erlt1 in ExaminationRoomLayoutRepository.Entities
  520. from erst1 in erlt1.EX_ExaminationRoomStudent
  521. select new
  522. {
  523. UserID = erst1.UserID,
  524. ExaminationPlanID = erlt1.EX_ExaminationPlan.ExaminationPlanID,
  525. ExaminationPlanName = erlt1.EX_ExaminationPlan.ClassName,
  526. erlt1.EX_ExaminationPlan.ExaminationDate,
  527. erlt1.EX_ExaminationPlan.StartTime,
  528. erlt1.EX_ExaminationPlan.EndTime
  529. }
  530. ) on ers.UserID equals erlt.UserID
  531. where ep.ExaminationPlanID != erlt.ExaminationPlanID && erlt.ExaminationDate == date
  532. && erlt.EndTime >= startTime && erlt.StartTime <= endTime
  533. select new StudentConflictView
  534. {
  535. UserID = ers.CF_Student.UserID,
  536. Name = ers.CF_Student.Sys_User.Name,
  537. ExaminationPlanID = erlt.ExaminationPlanID,
  538. ExaminationPlanName = erlt.ExaminationPlanName,
  539. StartTime = erlt.StartTime,
  540. EndTime = erlt.EndTime
  541. }
  542. );
  543. return q;
  544. }
  545. public IQueryable<AdultExaminationPlanExportView> GetAdultExaminationPlanExportView(Expression<Func<EX_ExaminationPlan, bool>> examinationPlanExpression)
  546. {
  547. var inschool = StudentsDAL.InSchoolSettingRepository.Entities.Where(x => x.IsSelected == true).Select(x => x.InSchoolStatusID).ToList();
  548. var query = (from plan in ExaminationPlanRepository.GetList(examinationPlanExpression)
  549. join schoolyear in SchoolyearRepository.Entities on plan.SchoolyearID equals schoolyear.SchoolyearID
  550. join course in CoursematerialRepository.Entities on plan.CoursematerialID equals course.CoursematerialID
  551. join mission in EducationMissionRepository.Entities on plan.EducationMissionID equals mission.EducationMissionID into dmission
  552. from emission in dmission.DefaultIfEmpty()
  553. join layout in ExaminationRoomLayoutRepository.Entities on plan.ExaminationPlanID equals layout.ExaminationPlanID into dlayout
  554. from elayout in dlayout.DefaultIfEmpty()
  555. join classroom in ClassroomRepository.Entities on elayout.ClassroomID equals classroom.ClassroomID into dclassroom
  556. from eclassroom in dclassroom.DefaultIfEmpty()
  557. select new AdultExaminationPlanExportView
  558. {
  559. SchoolyearCode = schoolyear.Code,
  560. CoursematerialID = plan.CoursematerialID,
  561. CoursematerialName = course.CourseName,
  562. ClassName = plan.ClassName,
  563. MissionStudentCount = plan.CF_Student.Count(x => inschool.Contains(x.InSchoolStatusID)),
  564. MaxExaminationWeekNum = emission.EM_EducationMissionExamWeekNum.Max(x => x.WeeklyNum),
  565. StudentCount = (elayout.ExaminationRoomLayoutID == null ? 0 : elayout.EX_ExaminationRoomStudent.Count()),
  566. ExamsCategoryID = plan.ExamsCategoryID,
  567. ExaminationModeID = plan.ExaminationModeID,
  568. ExaminationWeekNumList = emission.EM_EducationMissionExamWeekNum.Select(x => x.WeeklyNum),
  569. ExaminationDate = plan.ExaminationDate,
  570. StartTime = plan.StartTime,
  571. EndTime = plan.EndTime,
  572. ClassroomID = elayout.ClassroomID,
  573. ClassroomName = eclassroom.Name,
  574. Sys_User = elayout.CF_Staff.Select(x => x.Sys_User)
  575. });
  576. return query;
  577. }
  578. /// <summary>
  579. /// 获取学生信息
  580. /// </summary>
  581. /// <param name="finalExaminationID"></param>
  582. /// <returns></returns>
  583. public IQueryable<BaseStudentView> GetExaminationPlanStudentList(Guid examinationPlanID)
  584. {
  585. var query = from a in ExaminationPlanRepository.GetList(x => x.ExaminationPlanID == examinationPlanID)
  586. from c in a.CF_Student
  587. select new BaseStudentView
  588. {
  589. UserID = c.UserID,
  590. LoginID = c.Sys_User.LoginID,
  591. UserName = c.Sys_User.Name,
  592. SexID = c.SexID,
  593. IDNumber = c.IDNumber,
  594. StudentStatus = c.StudentStatus,
  595. InSchoolStatusID = c.InSchoolStatusID,
  596. ClassmajorName = c.CF_Classmajor.Name,
  597. CoursematerialName = a.EM_Coursematerial.CourseName
  598. };
  599. return query;
  600. }
  601. /// <summary>
  602. /// 获取所有除了已排进该排考计划的在校学生
  603. /// </summary>
  604. /// <param name="examinationPlanID"></param>
  605. /// <returns></returns>
  606. public IQueryable<StudentsView> GetGdssStudentListView(Guid? examinationPlanID, Expression<Func<CF_Student, bool>> exp)
  607. {
  608. var inschool = StudentsDAL.InSchoolSettingRepository.Entities.Where(x => x.IsSelected == true).Select(x => x.InSchoolStatusID).ToList();
  609. var userIDList = from ep in ExaminationPlanRepository.GetList(x => x.ExaminationPlanID == examinationPlanID)
  610. from epstu in ep.CF_Student
  611. select new
  612. {
  613. epstu.UserID,
  614. };
  615. var query = from c in StudentRepository.GetList(exp).Where(x => inschool.Contains(x.InSchoolStatusID))
  616. where !userIDList.Select(x => x.UserID).ToList().Contains(c.UserID)
  617. select new StudentsView
  618. {
  619. UserID = c.UserID,
  620. LoginID = c.Sys_User.LoginID,
  621. UserName = c.Sys_User.Name,
  622. IDNumber = c.IDNumber,
  623. PhotoUrl = c.PhotoUrl,
  624. IsProofread = c.IsProofread,
  625. IsPhoto = c.PhotoUrl == null ? (int)CF_YesOrNoStatus.No : (int)CF_YesOrNoStatus.Yes,
  626. IsPhotoUrl = c.PhotoUrl == null ? "否" : "是",
  627. StudentCardNo = c.StudentCardNo,
  628. PlanningGraduateDate = c.PlanningGraduateDate,//预计毕业时间
  629. EntranceDate = c.CF_Recruitstudents.EntranceDate,
  630. EnteringSchoolYearID = c.CF_Recruitstudents.EnteringSchoolYearID,
  631. EnteringSchoolYearCode = c.CF_Recruitstudents.CF_Schoolyear.Code,
  632. Score = c.CF_Recruitstudents.Score,
  633. ExamineeNum = c.CF_Recruitstudents.ExamineeNum,
  634. AdmissionTicketNo = c.CF_Recruitstudents.AdmissionTicketNo,
  635. Area = c.CF_Recruitstudents.Area,
  636. Placebirth = c.CF_StudentProfile.BornPlace,
  637. CardNo = c.CF_StudentAccount.CardNo,
  638. BankName = c.CF_StudentAccount.BankName,
  639. SexID = c.SexID,
  640. ClassMajorID = c.ClassmajorID,
  641. StudentStatus = c.StudentStatus,
  642. InSchoolStatusID = c.InSchoolStatusID,
  643. UsedName = c.CF_StudentProfile.UsedName,
  644. DirectorName = c.CF_StudentProfile.DirectorName,
  645. BirthDate = c.BirthDate,
  646. Country = c.CF_StudentProfile.Country,
  647. Politics = c.PoliticsID,
  648. Place = c.CF_StudentProfile.Place,
  649. //BornPlace = c.CF_StudentProfile.BornPlace,
  650. Specialty = c.CF_StudentProfile.Specialty,
  651. Height = c.CF_StudentProfile.Height,
  652. Weight = c.CF_StudentProfile.Weight,
  653. Remarks = c.Remark,
  654. GraduationPictureUrl = c.GraduationPictureUrl,
  655. Email = c.CF_StudentContact.Email,
  656. QQ = c.CF_StudentContact.QQ,
  657. Mobile = c.CF_StudentContact.Mobile,
  658. Telephone = c.CF_StudentContact.Telephone,
  659. MicroMsgNo = c.CF_StudentContact.WeChatNum,
  660. ZipCode = c.CF_StudentContact.ZIPCode,
  661. Address = c.CF_StudentContact.Address,
  662. WorkUnit = c.CF_StudentContact.WorkUnit,
  663. HomeAddress = c.CF_StudentContact.HomeAddress,
  664. Recipient = c.CF_StudentContact.Recipient,
  665. Dormitory = c.CF_StudentContact.Dormitory,
  666. StudentType = c.StudentType,
  667. CultureModel = c.CF_StudentProfile.CultureModelID,
  668. CertificatesType = c.CertificatesType,
  669. GraduateCardNo = c.GraduateCardNo,
  670. GraduateDate = c.GraduateDate,
  671. IsDreamProject = c.CF_StudentProfile.IsDreamProject == true,
  672. Career = c.Career,
  673. ReplaceGraduateNo = c.ReplaceGraduateNo,
  674. LiteracyLevels = c.CF_StudentProfile.LiteracyLevelID,
  675. ClassMajorName = c.CF_Classmajor.Name,
  676. ClassMajorCode = c.CF_Classmajor.No,
  677. };
  678. return query;
  679. }
  680. public IQueryable<StudentAndCourseForExcelView> GetStudentAndCourseList(List<Guid?> schedulingID, List<Guid?> userID)
  681. {
  682. var query = from scheduling in educationSchedulingRepository.Entities.Where(x => schedulingID.Contains(x.EducationSchedulingID))
  683. from escr in educationSchedulingClassRepository.Entities.Where(x => x.EducationSchedulingClassID == scheduling.EducationSchedulingClassID)
  684. from stu in escr.CF_Student.Where(x => userID.Contains(x.UserID))
  685. from user in userRepository.Entities.Where(x => x.UserID == stu.UserID)
  686. select new StudentAndCourseForExcelView
  687. {
  688. UserID = user.UserID,
  689. UserName = user.Name,
  690. LoginID = user.LoginID,
  691. CollegeID = user.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID,
  692. CollegeName = user.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CF_College.Name,
  693. ClassmajorID = user.CF_Student.CF_Classmajor.ClassmajorID,
  694. ClassmajorName = user.CF_Student.CF_Classmajor.Name,
  695. CourseID = escr.EM_EducationMissionClass.CoursematerialID,
  696. CourseName = escr.EM_EducationMissionClass.EM_Coursematerial.CourseName
  697. };
  698. return query;
  699. }
  700. }
  701. }