FinalExaminationDAL.cs 40 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Linq.Expressions;
  6. using System.Data.Entity;
  7. using EMIS.DataLogic.Repositories;
  8. using EMIS.ViewModel.ScoreManage;
  9. using EMIS.Entities;
  10. using EMIS.ViewModel.Students;
  11. using EMIS.ViewModel;
  12. using Bowin.Common.Linq;
  13. namespace EMIS.DataLogic.ScoreManage
  14. {
  15. public class FinalExaminationDAL
  16. {
  17. public FinalExaminationRepository finalExaminationRepository { get; set; }
  18. public DepartmentRepository DepartmentRepository { get; set; }
  19. public FinalExaminationStudentRepository FinalExaminationStudentRepository { get; set; }
  20. public UserRepository userRepository { get; set; }
  21. public InSchoolSettingRepository InSchoolSettingRepository { get; set; }
  22. public EducationMissionRepository educationMissionRepository { get; set; }
  23. public SpecialtyPlanRepository specialtyPlanRepository { get; set; }
  24. public OptionalCoursePlanRepository optionalCoursePlanRepository { get; set; }
  25. //public FreeSelectionCousePlanRepository freeSelectionCousePlanRepository { get; set; }
  26. public ClassmajorRepository classmajorRepository { get; set; }
  27. public GrademajorRepository GrademajorRepository { get; set; }
  28. public FacultymajorRepository FacultymajorRepository { get; set; }
  29. public StudentRepository studentRepository { get; set; }
  30. public ClassminorRepository classminorRepository { get; set; }
  31. public EducationMissionClassRepository educationMissionClassRepository { get; set; }
  32. public EducationSchedulingClassRepository educationSchedulingClassRepository { get; set; }
  33. public SubmitedScoreRepository SubmitedScoreRepository { get; set; }
  34. public FinallyScoreRepository FinallyScoreRepository { get; set; }
  35. public ParameterRepository ParameterRepository { get; set; }
  36. public Lazy<ExamsStateSettingDAL> ExamsStateSettingDAL { get; set; }
  37. public Lazy<MisconductDAL> MisconductDAL { get; set; }
  38. public CoursematerialRepository CoursematerialRepository { get; set; }
  39. public ExamsStateSettingRepository ExamsStateSettingRepository { get; set; }
  40. public ExaminationSuspensionRepository examinationSuspensionRepository { get; set; }
  41. /// <summary>
  42. /// 查询期末设定
  43. /// </summary>
  44. /// <param name="exp"></param>
  45. /// <returns></returns>
  46. public IQueryable<FinalExaminationView> GetFinalExaminationViewQueryable(Expression<Func<ER_FinalExamination, bool>> exp)
  47. {
  48. var query = from a in finalExaminationRepository.GetList(exp)
  49. join b in userRepository.Entities on a.CreatorUserID equals b.UserID
  50. into gu
  51. from guser in gu.DefaultIfEmpty()
  52. select new FinalExaminationView
  53. {
  54. FinalExaminationID = a.FinalExaminationID,
  55. SchoolyearID = a.SchoolyearID,
  56. GradeYearID = a.GradeYearID,
  57. SchoolyearCode = a.CF_Schoolyear.Code,
  58. CourseCollegeID = a.CF_Department.CollegeID,
  59. CollegeID = a.CollegeID,
  60. CollegeName = a.CF_College.Name,
  61. DepartmentID = a.DepartmentID,
  62. DepartmentName = a.CF_Department.Name,
  63. ClassName = a.ClassName,
  64. ClassmajorName = a.CF_Classmajor.Name,
  65. ClassmajorCode = a.CF_Classmajor.No,
  66. ClassmajorID = a.ClassmajorID,
  67. CoursematerialID = a.CoursematerialID,
  68. CourseCode = a.EM_Coursematerial.CourseCode,
  69. CourseName = a.EM_Coursematerial.CourseName,
  70. CourseTypeID = a.CourseTypeID,
  71. ExamsCategoryID = a.ExamsCategoryID,
  72. ExaminationModeID = a.ExaminationModeID,
  73. Credit = a.Credit,
  74. //总学时
  75. TotalHours = a.TotalHours,
  76. ExamsDatetime = a.ExamsDatetime,
  77. ResultTypeID = a.ResultTypeID,
  78. CreatorUserID = a.CreatorUserID,
  79. CreatorUserNo = guser.LoginID,
  80. CreatorUserName = guser.Name,
  81. EntryDeadlineTime = a.EntryDeadlineTime,
  82. IsEntry = a.IsEntry ?? false,
  83. StudentCount = a.ER_FinalExaminationStudent.Count,
  84. SAPunlogStudentCount = a.ER_FinalExaminationStudent.Count - a.ER_Score.Count,
  85. ExaminationType = a.ExaminationType,
  86. ApprovalStatus = a.ApprovalStatus,
  87. ScoreFormulaID = a.ScoreFormulaID,
  88. CreditFormulaID = a.CreditFormulaID,
  89. GradePointFormulaID = a.GradePointFormulaID,
  90. Comment = a.Comment,
  91. CreateTime = a.CreateTime,
  92. CreateUserID = a.CreateUserID
  93. };
  94. return query;
  95. }
  96. /// <summary>
  97. /// 生成期末设定,加上总学时
  98. /// </summary>
  99. /// <returns></returns>
  100. public IQueryable<FinalExaminationView> GetEducationMission(Guid? schoolyearID, Expression<Func<EM_EducationMission, bool>> exp, Expression<Func<EM_EducationMissionClass, bool>> educationMissionClassExp)
  101. {
  102. var queryMissionClass = from a in educationMissionRepository.GetList(exp)
  103. from b in a.EM_EducationMissionClass
  104. join emc in educationMissionClassRepository.GetList(educationMissionClassExp) on b.EducationMissionClassID equals emc.EducationMissionClassID
  105. join c in classmajorRepository.Entities on b.MainScheduleClassID equals c.ClassmajorID into dc
  106. from ec in dc.DefaultIfEmpty()
  107. join cm in classminorRepository.Entities on b.MainScheduleClassID equals cm.ClassminorID into dcm
  108. from ecm in dcm.DefaultIfEmpty()
  109. group a by new
  110. {
  111. a.SchoolyearID,
  112. a.EducationMissionID,
  113. GradeYearID = ec == null ? ecm.CF_Grademinor.YearID : ec.CF_Grademajor.GradeID,
  114. StandardID = ec == null ? ecm.CF_Grademinor.StandardID : ec.CF_Grademajor.CF_Facultymajor.StandardID,
  115. a.ClassName,
  116. a.CollegeID,
  117. a.DepartmentID,
  118. b.EM_Coursematerial.CoursematerialID,
  119. b.CourseTypeID,
  120. b.ExaminationModeID,
  121. b.ResultTypeID,
  122. b.EM_EducationMissionClassTeachingSetting.Credit,
  123. //学时
  124. b.EM_EducationMissionClassTeachingSetting.TheoryCourse,
  125. b.EM_EducationMissionClassTeachingSetting.Practicehours,
  126. //b.HandleModeID,
  127. SchoolyearNumID = (ec.ClassmajorID == null ?
  128. //(ecm.ClassminorID == null ? (int?)null : ((int)Math.Floor(((decimal)a.CF_Schoolyear.Value - (decimal)((ecm.CF_Grademinor.YearID * 2 - 1) + (ecm.CF_Grademinor.SchoolcodeID - 1))) / 2) + 1)) :
  129. (int?)null :
  130. ((int)Math.Floor(((decimal)a.CF_Schoolyear.Value - (decimal)((ec.CF_Grademajor.GradeID * 2 - 1) + (ec.CF_Grademajor.SemesterID - 1))) / 2) + 1))
  131. } into g
  132. select new
  133. {
  134. g.Key.SchoolyearID,
  135. g.Key.EducationMissionID,
  136. g.Key.GradeYearID,
  137. g.Key.ClassName,
  138. g.Key.CollegeID,
  139. g.Key.DepartmentID,
  140. g.Key.CoursematerialID,
  141. g.Key.CourseTypeID,
  142. g.Key.ExaminationModeID,
  143. g.Key.ResultTypeID,
  144. g.Key.Credit,
  145. g.Key.StandardID,
  146. //g.Key.HandleModeID,
  147. SchoolyearNumID = (int?)g.Key.SchoolyearNumID,
  148. //总学时
  149. TotalHours = g.Key.TheoryCourse + g.Key.Practicehours,
  150. };
  151. var query = from a in queryMissionClass
  152. join e in finalExaminationRepository.Entities on a.EducationMissionID equals e.EducationMissionID
  153. into gf
  154. from gfinal in gf.DefaultIfEmpty()
  155. where gfinal.EducationMissionID == null && a.SchoolyearID == schoolyearID
  156. select new FinalExaminationView
  157. {
  158. SchoolyearID = a.SchoolyearID,
  159. GradeYearID = a.GradeYearID,
  160. EducationMissionID = a.EducationMissionID,
  161. ClassName = a.ClassName,
  162. DepartmentID = a.DepartmentID,
  163. CoursematerialID = a.CoursematerialID,
  164. CourseTypeID = a.CourseTypeID,
  165. ExaminationModeID = a.ExaminationModeID,
  166. ResultTypeID=a.ResultTypeID,
  167. Credit = a.Credit,
  168. CollegeID = a.CollegeID,
  169. StandardID = a.StandardID,
  170. TotalHours = a.TotalHours,
  171. //HandleModeID=a.HandleModeID
  172. //ClassmajorID = a.MainScheduleClassID
  173. };
  174. return query;
  175. }
  176. /// <summary>
  177. /// 获取学生信息
  178. /// </summary>
  179. /// <param name="finalExaminationID"></param>
  180. /// <returns></returns>
  181. public IQueryable<BaseStudentView> GetFinalExaminationStudentList(Guid? finalExaminationID, Guid? userID)
  182. {
  183. var query = from a in finalExaminationRepository.GetList(x => x.FinalExaminationID == finalExaminationID)
  184. from c in a.ER_FinalExaminationStudent
  185. select new BaseStudentView
  186. {
  187. UserID = c.UserID ?? Guid.Empty,
  188. LoginID = c.CF_Student.Sys_User.LoginID,
  189. UserName = c.CF_Student.Sys_User.Name,
  190. SexID = c.CF_Student.SexID,
  191. IDNumber = c.CF_Student.IDNumber,
  192. StarttermID = c.StarttermID,
  193. InSchoolStatusID = c.CF_Student.InSchoolStatusID,
  194. StudentStatus = c.CF_Student.StudentStatus,
  195. ClassmajorCode = c.CF_Student.CF_Classmajor.No,
  196. ClassmajorName = c.CF_Student.CF_Classmajor.Name,
  197. CoursematerialCode = a.EM_Coursematerial.CourseCode,
  198. CoursematerialName = a.EM_Coursematerial.CourseName,
  199. IsDifferentDynamic = false, //取消教学任务、期末设定中涉及到异动的学生的标红显示功能 2016年11月3日16:08:27
  200. RecordStatus = a.ER_Score.Where(x => x.UserID == c.UserID).FirstOrDefault().RecordStatus,
  201. // IsDifferentDynamic = c.CF_DifferentDynamic.Where(x => x.ApprovalStatus == (int)EMIS.ViewModel.CF_DifferentDynamicStatus.End).Count() > 0 ? true : false
  202. };
  203. if (userID != null)
  204. {
  205. query = from a in finalExaminationRepository.GetList(x => x.FinalExaminationID == finalExaminationID)
  206. from c in a.ER_FinalExaminationStudent.Where(x => x.UserID == userID)
  207. select new BaseStudentView
  208. {
  209. UserID = c.UserID ?? Guid.Empty,
  210. LoginID = c.CF_Student.Sys_User.LoginID,
  211. UserName = c.CF_Student.Sys_User.Name,
  212. SexID = c.CF_Student.SexID,
  213. IDNumber = c.CF_Student.IDNumber,
  214. StarttermID = c.StarttermID,
  215. InSchoolStatusID = c.CF_Student.InSchoolStatusID,
  216. StudentStatus = c.CF_Student.StudentStatus,
  217. ClassmajorCode = c.CF_Student.CF_Classmajor.No,
  218. ClassmajorName = c.CF_Student.CF_Classmajor.Name,
  219. CoursematerialCode = a.EM_Coursematerial.CourseCode,
  220. CoursematerialName = a.EM_Coursematerial.CourseName,
  221. IsDifferentDynamic = false, //取消教学任务、期末设定中涉及到异动的学生的标红显示功能 2016年11月3日16:08:27
  222. RecordStatus = a.ER_Score.Where(x => x.UserID == c.UserID).FirstOrDefault().RecordStatus,
  223. // IsDifferentDynamic = c.CF_DifferentDynamic.Where(x => x.ApprovalStatus == (int)EMIS.ViewModel.CF_DifferentDynamicStatus.End).Count() > 0 ? true : false
  224. };
  225. }
  226. return query;
  227. }
  228. /// <summary>
  229. /// 查询考试设定相关学生明细表,按兵良要求,暂时用于补考设定学生明细导出功能
  230. /// </summary>
  231. /// <param name="exp"></param>
  232. /// <returns></returns>
  233. public IQueryable<ResitStudentView> GetFinalExaminationStudentDetailsList(Expression<Func<ER_FinalExamination, bool>> exp)
  234. {
  235. var query = from a in finalExaminationRepository.GetList(exp)
  236. from c in a.ER_FinalExaminationStudent
  237. select new ResitStudentView
  238. {
  239. SchoolyearID = a.SchoolyearID,
  240. SchoolyearCode = a.CF_Schoolyear.Code,
  241. UserID = c.UserID ?? Guid.Empty,
  242. LoginID = c.CF_Student.Sys_User.LoginID,
  243. UserName = c.CF_Student.Sys_User.Name,
  244. SexID = c.CF_Student.SexID,
  245. Credit=a.Credit,
  246. DepartmentID=a.DepartmentID,
  247. CollegeID=c.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CF_College.CollegeID,
  248. CollegeName=c.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CF_College.Name,
  249. StandardID=c.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID,
  250. ClassName = a.ClassName,
  251. ClassmajorNo = c.CF_Student.CF_Classmajor.No,
  252. ClassmajorName = c.CF_Student.CF_Classmajor.Name,
  253. Year = c.CF_Student.CF_Classmajor.CF_Grademajor.GradeID,
  254. CourseName = a.EM_Coursematerial.CourseName,
  255. CourseCode = a.EM_Coursematerial.CourseCode,
  256. CourseTypeID = a.CourseTypeID,
  257. ExamsCategoryID = a.ExamsCategoryID,
  258. Remark = a.Remark,
  259. };
  260. return query;
  261. }
  262. /// <summary>
  263. /// 获取当前学年学期需要补考的学生,按兵良要求,加上院系所、年级、专业下拉条件
  264. /// </summary>
  265. /// <param name="schoolyearID"></param>
  266. /// <returns></returns>
  267. /// <remarks>
  268. /// 有违纪行为不能参加补考,直接参加毕业清考,补考可以重复生成,每次只生成未有补考记录的数据
  269. /// </remarks>
  270. public IQueryable<ResitStudentView> GetResitFinalExaminationStudent(Guid? schoolyearID)
  271. {
  272. List<int?> resitStatus = ExamsStateSettingDAL.Value.GetResitIDList();
  273. //ER_ExamsStateSetting examsStateSetting = ExamsStateSettingRepository.GetSingle(x => x.ExamsStateID == (int)CF_ExamsState.Suspension);
  274. var query = from fs in FinallyScoreRepository.GetList(x => x.TotalScore < 60 && x.SchoolyearID == schoolyearID && x.ExamsCategoryID == (int)CF_ExamsCategory.FinalExam && resitStatus.Contains(x.ExamsStateID))
  275. join iss in InSchoolSettingRepository.GetList(x => x.IsSelected == true)
  276. on fs.CF_Student.InSchoolStatusID equals iss.InSchoolStatusID
  277. join exam in ExamsStateSettingRepository.GetList(x => x.ResitCategory == (int)CF_ExamsCategory.Resit)
  278. on fs.ExamsStateID equals exam.ExamsStateID
  279. join rfes in FinalExaminationStudentRepository.GetList(x => x.ER_FinalExamination.ExamsCategoryID == (int)CF_ExamsCategory.Resit)
  280. on new { fs.CoursematerialID, fs.UserID, fs.StarttermID } equals new { rfes.ER_FinalExamination.CoursematerialID, rfes.UserID, rfes.StarttermID }
  281. into drfes
  282. from erfes in drfes.Where(x => x.CreateTime > fs.CreateTime).DefaultIfEmpty()
  283. //join ss in SubmitedScoreRepository.GetList(x => misconductStatus.Contains(x.ExamsStateID))
  284. // on new { fs.CoursematerialID, fs.UserID, fs.StarttermID } equals new { ss.CoursematerialID, ss.UserID, ss.StarttermID }
  285. // into dss
  286. //from ess in dss.DefaultIfEmpty()
  287. where erfes.FinalExaminationStudentID == null
  288. //&& ess.SubmitedScoreID == null
  289. select new ResitStudentView
  290. {
  291. UserID = fs.CF_Student.UserID,
  292. Year = fs.CF_Student.CF_Classmajor.CF_Grademajor.GradeID,
  293. CourseCollegeID = fs.CF_Department.CollegeID,
  294. CollegeID = fs.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID,
  295. StandardID = fs.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID,
  296. GrademajorID = fs.CF_Student.CF_Classmajor.GrademajorID,
  297. GrademajorName = fs.CF_Student.CF_Classmajor.CF_Grademajor.Name,
  298. CoursematerialID = fs.CoursematerialID,
  299. DepartmentID = fs.DepartmentID,
  300. CourseName = fs.EM_Coursematerial.CourseName,
  301. CourseTypeID = fs.CourseTypeID,
  302. ExaminationModeID = fs.ExaminationModeID,
  303. SchoolyearNumID = fs.SchoolyearNumID,
  304. StartTermID = fs.StarttermID,
  305. Credit = fs.Credit,
  306. ResultTypeID = fs.ResultTypeID,
  307. ClassmajorID = fs.CF_Student.CF_Classmajor.ClassmajorID,
  308. };
  309. return query;
  310. }
  311. /// <summary>
  312. /// 获取当前学年学期缓考的学生
  313. /// </summary>
  314. /// <param name="schoolyearID"></param>
  315. /// <returns></returns>
  316. /// <remarks>
  317. ///
  318. /// </remarks>
  319. //public IQueryable<ResitStudentView> GetSuspensionStudent(Guid? schoolyearID)
  320. //{
  321. // //List<int?> suspensionStatus = ExamsStateSettingDAL.Value.GetSuspensionIDList();
  322. // int? resitCategory = ExamsStateSettingDAL.Value.GetSuspensionResitCategory();
  323. // var query = from fs in FinallyScoreRepository.GetList(x => x.TotalScore < 60 && x.SchoolyearID == schoolyearID && x.ExamsCategoryID == (int)CF_ExamsCategory.FinalExam && x.ExamsStateID == (int)CF_ExamsState.Suspension)
  324. // join iss in InSchoolSettingRepository.GetList(x => x.IsSelected == true)
  325. // on fs.CF_Student.InSchoolStatusID equals iss.InSchoolStatusID
  326. // //join fi in finalExaminationRepository.Entities
  327. // //on new { fs.ClassName, fs.CoursematerialID, fs.ExamsCategoryID, fs.ExaminationModeID } equals new { fi.ClassName, fi.CoursematerialID, fi.ExamsCategoryID, fi.ExaminationModeID }
  328. // //into a
  329. // //from aa in a.DefaultIfEmpty()
  330. // join exam in ExamsStateSettingRepository.GetList(x => x.ResitCategory == (int)CF_ExamsCategory.DelayExam)
  331. // on fs.ExamsStateID equals exam.ExamsStateID
  332. // join rfes in FinalExaminationStudentRepository.GetList(x => x.ER_FinalExamination.ExamsCategoryID == (int)CF_ExamsCategory.FinalExam && x.ER_FinalExamination.ExaminationType == (int)CF_ExaminationType.ResitExamination)
  333. // on new { fs.CoursematerialID, fs.UserID, fs.StarttermID } equals new { rfes.ER_FinalExamination.CoursematerialID, rfes.UserID, rfes.StarttermID }
  334. // into drfes
  335. // from erfes in drfes.DefaultIfEmpty()
  336. // //join ss in SubmitedScoreRepository.GetList(x => suspensionStatus.Contains(x.ExamsStateID))
  337. // // on new { fs.CoursematerialID, fs.UserID, fs.StarttermID } equals new { ss.CoursematerialID, ss.UserID, ss.StarttermID }
  338. // // into dss
  339. // //from ess in dss.DefaultIfEmpty()
  340. // where erfes.FinalExaminationStudentID == null
  341. // //&& ess.SubmitedScoreID == null
  342. // select new ResitStudentView
  343. // {
  344. // UserID = fs.CF_Student.UserID,
  345. // Year = fs.CF_Student.CF_Classmajor.CF_Grademajor.SchoolyearID,
  346. // CourseCollegeID = fs.CF_Department.CollegeID,
  347. // CollegeID = fs.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID,
  348. // StandardID = fs.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID,
  349. // GrademajorID = fs.CF_Student.CF_Classmajor.GrademajorID,
  350. // GrademajorName = fs.CF_Student.CF_Classmajor.CF_Grademajor.Name,
  351. // CoursematerialID = fs.CoursematerialID,
  352. // DepartmentID = fs.DepartmentID,
  353. // CourseName = fs.EM_Coursematerial.CourseName,
  354. // CourseTypeID = fs.CourseTypeID,
  355. // ExaminationModeID = fs.ExaminationModeID,
  356. // SchoolyearNumID = fs.SchoolyearNumID,
  357. // StartTermID = fs.StarttermID,
  358. // Credit = fs.Credit,
  359. // ResultTypeID = fs.ResultTypeID,
  360. // ClassmajorID = fs.CF_Student.CF_Classmajor.ClassmajorID,
  361. // };
  362. // return query;
  363. //}
  364. /// <summary>
  365. /// 补考设定,加上学时
  366. /// </summary>
  367. /// <param name="schoolyearID"></param>
  368. /// <returns></returns>
  369. public virtual IQueryable<ResitStudentView> GetNotPassStudent(Guid? schoolyearID)
  370. {
  371. List<int?> resitStatus = ExamsStateSettingDAL.Value.GetResitIDList();
  372. var query = from fs in FinallyScoreRepository.GetList(x => (x.TotalScore == null || x.TotalScore < 60) && x.SchoolyearID == schoolyearID && x.ExamsCategoryID == (int)CF_ExamsCategory.FinalExam && resitStatus.Contains(x.ExamsStateID))
  373. from s in studentRepository.Entities.Where(x => fs.UserID == x.UserID)
  374. join iss in InSchoolSettingRepository.GetList(x => x.IsSelected == true)
  375. on s.InSchoolStatusID equals iss.InSchoolStatusID
  376. join exam in ExamsStateSettingRepository.Entities
  377. on fs.ExamsStateID equals exam.ExamsStateID
  378. from erfes in (
  379. from student in FinalExaminationStudentRepository.Entities
  380. from final in finalExaminationRepository.Entities.Where(x => x.FinalExaminationID == student.FinalExaminationID)
  381. where final.CoursematerialID == fs.CoursematerialID
  382. && student.UserID == fs.UserID && student.StarttermID == fs.StarttermID && final.ExamsCategoryID == exam.ResitCategory
  383. && student.CreateTime > fs.CreateTime
  384. select student
  385. ).DefaultIfEmpty()
  386. ////join ss in SubmitedScoreRepository.GetList(x => misconductStatus.Contains(x.ExamsStateID))
  387. //// on new { fs.CoursematerialID, fs.UserID, fs.StarttermID } equals new { ss.CoursematerialID, ss.UserID, ss.StarttermID }
  388. //// into dss
  389. ////from ess in dss.DefaultIfEmpty()
  390. where erfes.FinalExaminationStudentID == null
  391. //&& ess.SubmitedScoreID == null
  392. select new ResitStudentView
  393. {
  394. UserID = fs.CF_Student.UserID,
  395. Year = fs.CF_Student.CF_Classmajor.CF_Grademajor.GradeID,
  396. CourseCollegeID = fs.CF_Department.CollegeID,
  397. CollegeID = fs.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID,
  398. StandardID = fs.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID,
  399. GrademajorID = fs.CF_Student.CF_Classmajor.GrademajorID,
  400. GrademajorName = fs.CF_Student.CF_Classmajor.CF_Grademajor.Name,
  401. CoursematerialID = fs.CoursematerialID,
  402. DepartmentID = fs.DepartmentID,
  403. CourseName = fs.EM_Coursematerial.CourseName,
  404. CourseTypeID = fs.CourseTypeID,
  405. ExaminationModeID = fs.ExaminationModeID,
  406. SchoolyearNumID = fs.SchoolyearNumID,
  407. StartTermID = fs.StarttermID,
  408. Credit = fs.Credit,
  409. //加上学时
  410. TotalHours = fs.TotalHours,
  411. ResultTypeID = fs.ResultTypeID,
  412. ClassmajorID = fs.CF_Student.CF_Classmajor.ClassmajorID,
  413. ExamsCategoryID = exam.ResitCategory,
  414. CreatorUserID = fs.CreatorUserID,
  415. };
  416. return query;
  417. }
  418. /// <summary>
  419. /// 获取需参加毕业清考的学生,加上总学时
  420. /// </summary>
  421. /// <param name="schoolyearID"></param>
  422. /// <returns></returns>
  423. /// <remarks>
  424. /// 不管有没有补考,只要成绩不及格(包括违纪导致的不及格),都将纳入毕业清考,毕业清考可以重复生成,每次只生成未有毕业清考记录的数据
  425. /// </remarks>
  426. public IQueryable<ResitStudentView> GetGraduationExamStudent(int? year)
  427. {
  428. //bool isMisconductCanGraduateExam = true;
  429. //var parameter = ParameterRepository.GetSingle(x => x.ParameterTypeID == (int)CF_ParameterType.IsMisconductCanGraduateExam);
  430. //if (parameter != null)
  431. //{
  432. // isMisconductCanGraduateExam = (parameter.Value == "True");
  433. //}
  434. //List<int?> misconductStatus = ExamsStateSettingDAL.Value.GetMisconductIDList();
  435. //var query = from fs in FinallyScoreRepository.Entities.GroupBy(x => new {
  436. // x.UserID,
  437. // x.CoursematerialID,
  438. // x.DepartmentID,
  439. // x.CF_Department.CollegeID,
  440. // x.CourseTypeID,
  441. // x.ExaminationModeID,
  442. // x.Credit,
  443. // x.ResultTypeID,
  444. // })
  445. // .Select(x => new
  446. // {
  447. // x.Key.UserID,
  448. // x.Key.CoursematerialID,
  449. // x.Key.DepartmentID,
  450. // x.Key.CollegeID,
  451. // x.Key.CourseTypeID,
  452. // x.Key.ExaminationModeID,
  453. // x.Key.Credit,
  454. // x.Key.ResultTypeID,
  455. // TotalScore = x.Max(w => w.TotalScore),
  456. // SchoolyearNumID = x.Max(w => w.SchoolyearNumID),
  457. // StarttermID = x.Max(w => w.StarttermID) })
  458. // .Where(x => x.TotalScore < 60)
  459. // join s in studentRepository.GetList(x => x.CF_Classmajor.CF_Grademajor.SchoolyearID == year)
  460. // on fs.UserID equals s.UserID
  461. // join cm in CoursematerialRepository.Entities on fs.CoursematerialID equals cm.CoursematerialID
  462. // join iss in InSchoolSettingRepository.GetList(x => x.IsSelected == true)
  463. // on s.InSchoolStatusID equals iss.InSchoolStatusID
  464. // //关联补考设定,看看有没有重复生成
  465. // join rfes in FinalExaminationStudentRepository.GetList(x => x.ER_FinalExamination.ExamsCategoryID == (int)CF_ExamsCategory.GraduationExam)
  466. // on new { fs.CoursematerialID, fs.UserID, fs.StarttermID } equals new { rfes.ER_FinalExamination.CoursematerialID, rfes.UserID, rfes.StarttermID }
  467. // into drfes
  468. // from erfes in drfes.DefaultIfEmpty()
  469. // //检查是否有补考违纪行为
  470. // join ss in SubmitedScoreRepository.GetList(x => misconductStatus.Contains(x.ExamsStateID) && x.ExamsCategoryID == (int)CF_ExamsCategory.Resit)
  471. // on new { fs.CoursematerialID, fs.UserID } equals new { ss.CoursematerialID, ss.UserID }
  472. // into dss
  473. // from ess in dss.DefaultIfEmpty()
  474. // where erfes.FinalExaminationStudentID == null && (isMisconductCanGraduateExam || ess.SubmitedScoreID == null)
  475. // select new ResitStudentView
  476. // {
  477. // UserID = s.UserID,
  478. // Year = s.CF_Classmajor.CF_Grademajor.SchoolyearID,
  479. // CourseCollegeID = fs.CollegeID,
  480. // CollegeID = s.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID,
  481. // GrademajorID = s.CF_Classmajor.GrademajorID,
  482. // GrademajorName = s.CF_Classmajor.CF_Grademajor.Name,
  483. // CoursematerialID = fs.CoursematerialID,
  484. // DepartmentID = fs.DepartmentID,
  485. // CourseName = cm.CourseName,
  486. // CourseTypeID = fs.CourseTypeID,
  487. // ExaminationModeID = fs.ExaminationModeID,
  488. // SchoolyearNumID = fs.SchoolyearNumID,
  489. // StartTermID = fs.StarttermID,
  490. // Credit = fs.Credit,
  491. // ResultTypeID = fs.ResultTypeID,
  492. // StandardID = s.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID,
  493. // ClassmajorID = s.CF_Classmajor.ClassmajorID,
  494. // };
  495. List<int?> canGraduatelist = ExamsStateSettingDAL.Value.GetCanGraduateList();
  496. var query = from fs in (
  497. from fs in FinallyScoreRepository.GetList(x => canGraduatelist.Contains(x.ExamsStateID))
  498. join d in DepartmentRepository.Entities on fs.DepartmentID equals d.DepartmentID
  499. join s in studentRepository.GetList(x => x.CF_Classmajor.CF_Grademajor.GradeID == year)
  500. on fs.UserID equals s.UserID
  501. join iss in InSchoolSettingRepository.GetList(x => x.IsSelected == true)
  502. on s.InSchoolStatusID equals iss.InSchoolStatusID
  503. join c in classmajorRepository.Entities on s.ClassmajorID equals c.ClassmajorID
  504. join g in GrademajorRepository.Entities on c.GrademajorID equals g.GrademajorID
  505. join f in FacultymajorRepository.Entities on g.FacultymajorID equals f.FacultymajorID
  506. group fs by new
  507. {
  508. s.UserID,
  509. Year = g.GradeID,
  510. f.CollegeID,
  511. c.ClassmajorID,
  512. g.GrademajorID,
  513. GradeName = g.Name,
  514. f.StandardID,
  515. fs.CoursematerialID,
  516. fs.DepartmentID,
  517. CourseCollegeID = d.CollegeID,
  518. fs.CourseTypeID,
  519. fs.ExaminationModeID,
  520. fs.Credit,
  521. f.LearnSystem,
  522. //总学时
  523. fs.TotalHours,
  524. fs.ResultTypeID,
  525. } into g
  526. select new
  527. {
  528. g.Key.UserID,
  529. g.Key.Year,
  530. g.Key.CollegeID,
  531. g.Key.ClassmajorID,
  532. g.Key.GrademajorID,
  533. g.Key.GradeName,
  534. g.Key.StandardID,
  535. g.Key.CoursematerialID,
  536. g.Key.DepartmentID,
  537. g.Key.CourseCollegeID,
  538. g.Key.CourseTypeID,
  539. g.Key.ExaminationModeID,
  540. g.Key.Credit,
  541. //总学时
  542. g.Key.TotalHours,
  543. g.Key.ResultTypeID,
  544. g.Key.LearnSystem,
  545. TotalScore = g.Max(w => w.TotalScore),
  546. SchoolyearNumID = g.Max(w => w.SchoolyearNumID),
  547. StarttermID = g.Max(w => w.StarttermID),
  548. CreatorUserID = g.Max(w => w.CreatorUserID.ToString()),
  549. })
  550. join cm in CoursematerialRepository.Entities on fs.CoursematerialID equals cm.CoursematerialID
  551. join cu in userRepository.Entities on fs.CreatorUserID equals cu.UserID.ToString()
  552. //关联补考设定,看看有没有重复生成
  553. join rfes in (
  554. from rfes in FinalExaminationStudentRepository.Entities
  555. join rfe in finalExaminationRepository.Entities on rfes.FinalExaminationID equals rfe.FinalExaminationID
  556. where rfe.ExamsCategoryID == (int)CF_ExamsCategory.GraduationExam
  557. select rfes
  558. )
  559. on new { fs.CoursematerialID, UserID = (Guid?)fs.UserID, fs.StarttermID } equals new { rfes.ER_FinalExamination.CoursematerialID, rfes.UserID, rfes.StarttermID }
  560. into drfes
  561. from erfes in drfes.DefaultIfEmpty()
  562. where erfes.FinalExaminationStudentID == null && fs.TotalScore < 60
  563. select new ResitStudentView
  564. {
  565. UserID = fs.UserID,
  566. Year = fs.Year,
  567. CourseCollegeID = fs.CourseCollegeID,
  568. CollegeID = fs.CollegeID,
  569. GrademajorID = fs.GrademajorID,
  570. GrademajorName = fs.GradeName,
  571. CoursematerialID = fs.CoursematerialID,
  572. DepartmentID = fs.DepartmentID,
  573. LearnSystem = fs.LearnSystem,
  574. CourseName = cm.CourseName,
  575. CourseTypeID = fs.CourseTypeID,
  576. ExaminationModeID = fs.ExaminationModeID,
  577. SchoolyearNumID = fs.SchoolyearNumID,
  578. StartTermID = fs.StarttermID,
  579. Credit = fs.Credit,
  580. TotalHours = fs.TotalHours,
  581. ResultTypeID = fs.ResultTypeID,
  582. StandardID = fs.StandardID,
  583. ClassmajorID = fs.ClassmajorID,
  584. CreatorUserID = cu.UserID
  585. };
  586. return query;
  587. }
  588. public IQueryable<ER_FinalExaminationStudent> GetFinalExaminationByResitStudent(Expression<Func<ER_FinalExamination, bool>> exp, IList<Guid?> userIDList)
  589. {
  590. List<int?> resitCategory = new List<int?> { (int)CF_ExamsCategory.Resit, (int)CF_ExamsCategory.GraduationExam };
  591. exp = exp.And(x => resitCategory.Contains(x.ExamsCategoryID));
  592. var maxStartTerm = from rfe in finalExaminationRepository.GetList(exp)
  593. join fe in finalExaminationRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE
  594. && x.ExamsCategoryID == (int)CF_ExamsCategory.FinalExam)
  595. on rfe.CoursematerialID equals fe.CoursematerialID
  596. from fes in fe.ER_FinalExaminationStudent
  597. where userIDList.Contains(fes.UserID)
  598. group fes by new { fes.UserID, fe.CoursematerialID } into g
  599. select new { g.Key.UserID, g.Key.CoursematerialID, StarttermID = g.Max(x => x.StarttermID) };
  600. var query = from fes in FinalExaminationStudentRepository.GetList(x => x.ER_FinalExamination.RecordStatus > (int)SYS_STATUS.UNUSABLE)
  601. join fe in finalExaminationRepository.GetList(x => x.ExamsCategoryID == (int)CF_ExamsCategory.FinalExam)
  602. on fes.FinalExaminationID equals fe.FinalExaminationID
  603. join mst in maxStartTerm
  604. on new { fes.UserID, fe.CoursematerialID, fes.StarttermID }
  605. equals new { mst.UserID, mst.CoursematerialID, mst.StarttermID }
  606. select fes;
  607. return query.Include(x => x.ER_FinalExamination);
  608. }
  609. }
  610. }