DegreeConditionDAL.cs 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Linq.Expressions;
  5. using System.Text;
  6. using EMIS.DataLogic.Repositories;
  7. using EMIS.Entities;
  8. using EMIS.ViewModel;
  9. using EMIS.ViewModel.DegreeManage.DegreeSetting;
  10. using EMIS.ViewModel.EducationManage;
  11. namespace EMIS.DataLogic.DegreeManage.DegreeSetting
  12. {
  13. public class DegreeConditionDAL
  14. {
  15. public DegreeConditionRepository DegreeConditionRepository { get; set; }
  16. public LevelScoreRepository LevelScoreRepository { get; set; }
  17. public ExaminationSubjectRepository ExaminationSubjectRepository { get; set; }
  18. public SchoolyearRepository SchoolyearRepository { get; set; }
  19. public UserRepository UserRepository { get; set; }
  20. public StudentRepository StudentRepository { get; set; }
  21. public ClassmajorRepository ClassmajorRepository { get; set; }
  22. public GrademajorRepository GrademajorRepository { get; set; }
  23. public FacultymajorRepository FacultymajorRepository { get; set; }
  24. public CollegeRepository CollegeRepository { get; set; }
  25. public DegreeForeignLanguageRepository DegreeForeignLanguageRepository { get; set; }
  26. public ExecutablePlanRepository ExecutablePlanRepository { get; set; }
  27. public ExecutablePlanProfileRepository ExecutablePlanProfileRepository { get; set; }
  28. public ExecutablePlanTeachingSettingRepository ExecutablePlanTeachingSettingRepository { get; set; }
  29. public CoursematerialRepository CoursematerialRepository { get; set; }
  30. public FinallyScoreRepository FinallyScoreRepository { get; set; }
  31. /// <summary>
  32. /// 查询对应的学位条件信息View
  33. /// </summary>
  34. /// <param name="exp"></param>
  35. /// <returns></returns>
  36. public IQueryable<DegreeConditionView> GetDegreeConditionViewQueryable(Expression<Func<ER_DegreeCondition, bool>> exp)
  37. {
  38. var query = from dc in DegreeConditionRepository.GetList(exp)
  39. select new DegreeConditionView
  40. {
  41. DegreeConditionID = dc.DegreeConditionID,
  42. OrderNo = dc.OrderNo,
  43. Title = dc.Title,
  44. MethodFullName = dc.MethodFullName,
  45. IsEnable = dc.RecordStatus.Value > 0 ? true : false,
  46. RecordStatus = dc.RecordStatus,
  47. CreateUserID = dc.CreateUserID,
  48. CreateTime = dc.CreateTime,
  49. ModifyUserID = dc.ModifyUserID,
  50. ModifyTime = dc.ModifyTime
  51. };
  52. return query;
  53. }
  54. /// <summary>
  55. /// 查询对应的学位外语成绩信息DegreeForeignLanguageScoreView(根据学生信息)
  56. /// 注:同一学生、同一考试科目,以最新的考试日期对应的成绩信息作为最终成绩(只取最终成绩,用户ID、考试科目ID分组)
  57. /// 注:根据学位外语设置信息进行内联
  58. /// </summary>
  59. /// <param name="expStudent"></param>
  60. /// <returns></returns>
  61. public IQueryable<DegreeForeignLanguageScoreView> GetDegreeForeignLanguageScoreViewQueryable(Expression<Func<CF_Student, bool>> expStudent)
  62. {
  63. var query = from stu in StudentRepository.GetList(expStudent)
  64. join ls in LevelScoreRepository.Entities
  65. on stu.UserID equals ls.UserID
  66. join dl in DegreeForeignLanguageRepository.Entities
  67. on ls.ExaminationSubjectID equals dl.ExaminationSubjectID
  68. join examsub in ExaminationSubjectRepository.Entities
  69. on ls.ExaminationSubjectID equals examsub.ExaminationSubjectID
  70. join sy in SchoolyearRepository.Entities
  71. on ls.SchoolyearID equals sy.SchoolyearID
  72. join cl in ClassmajorRepository.Entities
  73. on stu.ClassmajorID equals cl.ClassmajorID
  74. join gr in GrademajorRepository.Entities
  75. on cl.GrademajorID equals gr.GrademajorID
  76. join fa in FacultymajorRepository.Entities
  77. on gr.FacultymajorID equals fa.FacultymajorID
  78. join col in CollegeRepository.Entities
  79. on fa.CollegeID equals col.CollegeID
  80. join us in UserRepository.Entities
  81. on stu.UserID equals us.UserID
  82. join finls in
  83. (
  84. from stu in StudentRepository.GetList(expStudent)
  85. join levsco in LevelScoreRepository.Entities
  86. on stu.UserID equals levsco.UserID
  87. group new { stu, levsco } by new { stu.UserID, levsco.ExaminationSubjectID } into grls
  88. select new
  89. {
  90. UserID = grls.Key.UserID,
  91. ExaminationSubjectID = grls.Key.ExaminationSubjectID,
  92. ExaminationDate = grls.Max(x => x.levsco.ExaminationDate)
  93. }
  94. )
  95. on new { UserID = stu.UserID, ExaminationSubjectID = ls.ExaminationSubjectID, ExaminationDate = ls.ExaminationDate }
  96. equals
  97. new { UserID = finls.UserID, ExaminationSubjectID = finls.ExaminationSubjectID, ExaminationDate = finls.ExaminationDate }
  98. select new DegreeForeignLanguageScoreView
  99. {
  100. LevelScoreID = ls.LevelScoreID,
  101. SchoolyearID = ls.SchoolyearID,
  102. SchoolyearCode = sy.Code,
  103. ExaminationSubjectID = ls.ExaminationSubjectID,
  104. ExaminationSubjectName = examsub.Name,
  105. UserID = stu.UserID,
  106. StudentNo = us.LoginID,
  107. UserName = us.Name,
  108. SexID = stu.SexID,
  109. IDNumber = stu.IDNumber,
  110. InSchoolStatusID = stu.InSchoolStatusID,
  111. StudentStatusID = stu.StudentStatus,
  112. YearID = gr.GradeID,
  113. StandardID = fa.StandardID,
  114. EducationID = fa.EducationID,
  115. LearningformID = fa.LearningformID,
  116. LearnSystem = fa.LearnSystem,
  117. ClassmajorID = stu.ClassmajorID,
  118. ClassmajorCode = cl.No,
  119. ClassmajorName = cl.Name,
  120. GrademajorID = cl.GrademajorID,
  121. GrademajorCode = gr.Code,
  122. GrademajorName = gr.Name,
  123. FacultymajorID = gr.FacultymajorID,
  124. FacultymajorCode = fa.Code,
  125. FacultymajorName = fa.Name,
  126. CollegeID = fa.CollegeID,
  127. CollegeNo = col.No,
  128. CollegeName = col.Name,
  129. ScoreNo = ls.ScoreNo,
  130. ExaminationDate = ls.ExaminationDate,
  131. //ValidDate = ls.ValidDate,
  132. TotalScore = ls.TotalScore,
  133. ApprovalStatus = ls.ApprovalStatus,
  134. PassScore = dl.PassScore,
  135. Remark = ls.Remark,
  136. RecordStatus = ls.RecordStatus,
  137. CreateUserID = ls.CreateUserID,
  138. CreateTime = ls.CreateTime,
  139. ModifyUserID = ls.ModifyUserID,
  140. ModifyTime = ls.ModifyTime
  141. };
  142. return query;
  143. }
  144. /// <summary>
  145. /// 查询对应的学生学位课程执行计划信息StudentExecutablePlanView(根据学生信息,只查询相应的学位课程信息)
  146. /// 注:由于存在在不同的学年学期参加补考的情况,匹配学生最终成绩时,采用开学学期ID匹配(学年学期暂以执行计划为准)
  147. /// </summary>
  148. /// <param name="expStudent"></param>
  149. /// <returns></returns>
  150. public IQueryable<StudentExecutablePlanView> GetStudentDegreeCourseExecutablePlanViewQueryable(Expression<Func<CF_Student, bool>> expStudent)
  151. {
  152. var query = from stu in StudentRepository.GetList(expStudent)
  153. join cl in ClassmajorRepository.Entities
  154. on stu.ClassmajorID equals cl.ClassmajorID
  155. join gr in GrademajorRepository.Entities
  156. on cl.GrademajorID equals gr.GrademajorID
  157. join ep in ExecutablePlanRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE)
  158. on gr.GrademajorID equals ep.GrademajorID
  159. join sy in SchoolyearRepository.Entities
  160. on ep.SchoolyearID equals sy.SchoolyearID
  161. join cou in CoursematerialRepository.Entities
  162. on ep.CoursematerialID equals cou.CoursematerialID
  163. join pf in ExecutablePlanProfileRepository.Entities
  164. on ep.ExecutablePlanID equals pf.ExecutablePlanID into temppf
  165. from eppro in temppf.DefaultIfEmpty()
  166. join st in ExecutablePlanTeachingSettingRepository.Entities
  167. on ep.ExecutablePlanID equals st.ExecutablePlanID into tempst
  168. from epst in tempst.DefaultIfEmpty()
  169. where eppro.IsMainCourse == true
  170. select new StudentExecutablePlanView
  171. {
  172. UserID = stu.UserID,
  173. ExecutablePlanID = ep.ExecutablePlanID,
  174. SpecialtyPlanID = ep.SpecialtyPlanID,
  175. SchoolyearID = ep.SchoolyearID,
  176. SchoolyearCode = sy.Code,
  177. GrademajorID = ep.GrademajorID,
  178. GrademajorCode = gr.Code,
  179. GrademajorName = gr.Name,
  180. CoursematerialID = ep.CoursematerialID,
  181. CourseCode = cou.CourseCode,
  182. CourseName = cou.CourseName,
  183. CourseTypeID = ep.CourseTypeID,
  184. Credit = epst.Credit,
  185. TheoryCourse = epst.TheoryCourse,
  186. Practicehours = epst.Practicehours,
  187. Trialhours = epst.Trialhours,
  188. SchoolyearNumID = (sy.Value - ((gr.GradeID * 2 - 1) + gr.SemesterID - 1)) / 2 + 1,
  189. SchoolcodeID = sy.SchoolcodeID,
  190. StarttermID = sy.Value - ((gr.GradeID * 2 - 1) + gr.SemesterID - 1) + 1,
  191. IsSpecialtycore = eppro.IsSpecialtycore == null ? false : eppro.IsSpecialtycore.Value,
  192. IsCooperation = eppro.IsCooperation == null ? false : eppro.IsCooperation.Value,
  193. IsRequired = eppro.IsRequired == null ? false : eppro.IsRequired.Value,
  194. IsElective = eppro.IsElective == null ? false : eppro.IsElective.Value,
  195. IsNetworkCourse = eppro.IsNetworkCourse == null ? false : eppro.IsNetworkCourse.Value,
  196. IsMainCourse = eppro.IsMainCourse == null ? false : eppro.IsMainCourse.Value,
  197. ResultTypeID = ep.ResultTypeID
  198. };
  199. return query;
  200. }
  201. /// <summary>
  202. /// 查询对应的学生最终成绩信息DegreeFinallyScoreView(根据学位申请信息匹配学位课程执行计划,只查询相应的学位课程成绩信息)
  203. /// 注:学生学位课程最终成绩以学位课程执行计划为准(左连),未修习成绩默认为0分
  204. /// 注:由于存在在不同的学年学期参加补考的情况,匹配学生最终成绩时,采用开学学期ID匹配
  205. /// 注:成绩为空时,学年学期以执行计划为准,否则以最终成绩为准
  206. /// 注:匹配暂时不考虑总学时TotalHours
  207. /// </summary>
  208. /// <param name="expStudent"></param>
  209. /// <returns></returns>
  210. public IQueryable<DegreeFinallyScoreView> GetDegreeCourseFinallyScoreExecutablePlanViewQueryable(Expression<Func<CF_Student, bool>> expStudent)
  211. {
  212. var query = from stu in StudentRepository.GetList(expStudent)
  213. join us in UserRepository.Entities
  214. on stu.UserID equals us.UserID
  215. join cl in ClassmajorRepository.Entities
  216. on stu.ClassmajorID equals cl.ClassmajorID
  217. join gr in GrademajorRepository.Entities
  218. on cl.GrademajorID equals gr.GrademajorID
  219. join ep in ExecutablePlanRepository.Entities
  220. on gr.GrademajorID equals ep.GrademajorID
  221. join sy in SchoolyearRepository.Entities
  222. on ep.SchoolyearID equals sy.SchoolyearID
  223. join cou in CoursematerialRepository.Entities
  224. on ep.CoursematerialID equals cou.CoursematerialID
  225. join pf in ExecutablePlanProfileRepository.Entities
  226. on ep.ExecutablePlanID equals pf.ExecutablePlanID into temppf
  227. from eppro in temppf.DefaultIfEmpty()
  228. join st in ExecutablePlanTeachingSettingRepository.Entities
  229. on ep.ExecutablePlanID equals st.ExecutablePlanID into tempst
  230. from epst in tempst.DefaultIfEmpty()
  231. join epfinsco in
  232. (
  233. from stu in StudentRepository.GetList(expStudent)
  234. join finsco in FinallyScoreRepository.Entities
  235. on stu.UserID equals finsco.UserID
  236. join finsy in SchoolyearRepository.Entities
  237. on finsco.SchoolyearID equals finsy.SchoolyearID
  238. select new
  239. {
  240. FinallyScoreID = finsco.FinallyScoreID,
  241. SchoolyearID = finsco.SchoolyearID,
  242. SchoolyearCode = finsy.Code,
  243. ClassName = finsco.ClassName,
  244. ExaminationTypeID = finsco.ExaminationType,
  245. UserID = finsco.UserID,
  246. CoursematerialID = finsco.CoursematerialID,
  247. CourseTypeID = finsco.CourseTypeID,
  248. SchoolyearNumID = finsco.SchoolyearNumID,
  249. StarttermID = finsco.StarttermID,
  250. ResultTypeID = finsco.ResultTypeID,
  251. CreateUserID = finsco.CreateUserID,
  252. Credit = finsco.Credit,
  253. TotalHours = finsco.TotalHours,
  254. ExamsCategoryID = finsco.ExamsCategoryID,
  255. ExamsStateID = finsco.ExamsStateID,
  256. TotalScore = finsco.TotalScore,
  257. ScoreCredit = finsco.ScoreCredit,
  258. GradePoint = finsco.GradePoint,
  259. Remark = finsco.Remark,
  260. CreateTime = finsco.CreateTime
  261. }
  262. )
  263. on
  264. new { UserID = stu.UserID, StarttermID = (sy.Value - ((gr.GradeID * 2 - 1) + gr.SemesterID - 1) + 1), CoursematerialID = ep.CoursematerialID, CourseTypeID = ep.CourseTypeID, Credit = epst.Credit }
  265. equals
  266. new { UserID = epfinsco.UserID.Value, StarttermID = epfinsco.StarttermID, CoursematerialID = epfinsco.CoursematerialID, CourseTypeID = epfinsco.CourseTypeID, Credit = epfinsco.Credit }
  267. into tempepfinsco
  268. from epfinsco in tempepfinsco.DefaultIfEmpty()
  269. where eppro.IsMainCourse == true
  270. select new DegreeFinallyScoreView
  271. {
  272. FinallyScoreID = epfinsco.FinallyScoreID,
  273. SchoolyearID = epfinsco.SchoolyearID,
  274. SchoolyearCode = epfinsco.FinallyScoreID == null ? sy.Code : epfinsco.SchoolyearCode,
  275. ClassName = epfinsco.ClassName,
  276. ExaminationTypeID = epfinsco.ExaminationTypeID,
  277. ExaminationModeID = eppro.ExaminationModeID,
  278. CoursematerialID = ep.CoursematerialID,
  279. CourseCode = cou.CourseCode,
  280. CourseName = cou.CourseName,
  281. CourseTypeID = ep.CourseTypeID,
  282. IsMainCourse = eppro.IsMainCourse == null ? false : eppro.IsMainCourse.Value,
  283. Credit = epst.Credit,
  284. TheoryCourse = epst.TheoryCourse,
  285. Practicehours = epst.Practicehours,
  286. Trialhours = epst.Trialhours,
  287. Totalhours = (epst.TheoryCourse ?? 0) + (epst.Practicehours ?? 0),
  288. ResultTypeID = ep.ResultTypeID,
  289. DepartmentID = ep.DepartmentID,
  290. SchoolyearNumID = (sy.Value - ((gr.GradeID * 2 - 1) + gr.SemesterID - 1)) / 2 + 1,
  291. SchoolcodeID = sy.SchoolcodeID,
  292. StarttermID = sy.Value - ((gr.GradeID * 2 - 1) + gr.SemesterID - 1) + 1,
  293. UserID = stu.UserID,
  294. LoginID = us.LoginID,
  295. UserName = us.Name,
  296. ClassmajorID = stu.ClassmajorID,
  297. ClassmajorCode = cl.No,
  298. ClassmajorName = cl.Name,
  299. GrademajorID = cl.GrademajorID,
  300. GrademajorCode = gr.Code,
  301. GrademajorName = gr.Name,
  302. ExamsCategoryID = epfinsco.ExamsCategoryID == null ? (int)CF_ExamsCategory.FinalExam : epfinsco.ExamsCategoryID,
  303. ExamsStateID = epfinsco.ExamsStateID == null ? (int)CF_ExamsState.NormalExams : epfinsco.ExamsStateID,
  304. TotalScore = epfinsco.TotalScore ?? 0,
  305. ScoreCredit = epfinsco.ScoreCredit ?? 0,
  306. GradePoint = epfinsco.GradePoint ?? 0,
  307. Remark = epfinsco.Remark,
  308. CreateTime = epfinsco.CreateTime
  309. };
  310. return query;
  311. }
  312. }
  313. }