CourseGradeDAL.cs 9.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.ViewModel.Students;
  6. using EMIS.ViewModel;
  7. namespace EMIS.ExtensionLogic.DataLogic.StudentSystem.MyGrade
  8. {
  9. public class CourseGradeDAL : EMIS.DataLogic.StudentSystem.MyGrade.CourseGradeDAL
  10. {
  11. public override IList<CourseGradeView> GetStudentCourseGrade(Guid UserID)
  12. {
  13. List<int?> examsStateList = examsStateSettingRepository.GetList(x => x.IsNormal == true).Select(x => x.ExamsStateID).ToList();
  14. var query = from fina in ScoreRepository.Entities
  15. join student in StudentRepository.Entities
  16. on fina.UserID equals student.UserID
  17. join courseColour in CourseTypeSelectCourseTypeRepository.Entities
  18. on fina.CourseTypeID equals courseColour.CourseTypeID
  19. into colour
  20. from cc in colour.DefaultIfEmpty()
  21. join isClub in ClubCourseRepository.Entities
  22. on fina.EM_Coursematerial.CoursematerialID equals isClub.CoursematerialID
  23. into club
  24. from clu in club.DefaultIfEmpty()
  25. join ed in DictionaryItemRepository.GetList(x => x.DictionaryCode == "CF_ExamsState")
  26. on fina.ExamsStateID equals ed.Value
  27. into ged
  28. from f in ged.DefaultIfEmpty()
  29. join d in DictionaryItemRepository.GetList(x => x.DictionaryCode == "CF_ResultType")
  30. on fina.ResultTypeID equals d.Value
  31. join rd in ResultTypeDetailRepository.GetList(x => true)
  32. on d.Value equals rd.ResultTypeID
  33. into ResultTypeDetail
  34. from Result in ResultTypeDetail.DefaultIfEmpty()
  35. where ((Result.ResultTypeDetailID != null &&
  36. (
  37. (fina.TotalScore <= Result.MaxScore && Result.MinScore <= fina.TotalScore && (Result.MaxScoreOperator == "<=" && Result.MinScoreOperator == "<="))
  38. || (fina.TotalScore <= Result.MaxScore && Result.MinScore < fina.TotalScore && (Result.MaxScoreOperator == "<=" && Result.MinScoreOperator == "<"))
  39. || (fina.TotalScore < Result.MaxScore && Result.MinScore < fina.TotalScore && (Result.MaxScoreOperator == "<" && Result.MinScoreOperator == "<"))
  40. || (fina.TotalScore < Result.MaxScore && Result.MinScore <= fina.TotalScore && (Result.MaxScoreOperator == "<" && Result.MinScoreOperator == "<="))
  41. )
  42. )
  43. || (Result.ResultTypeDetailID == null))
  44. && (fina.UserID == UserID)
  45. orderby new { fina.StarttermID, fina.CourseTypeID, fina.EM_Coursematerial.CourseName }
  46. select new CourseGradeView()
  47. {
  48. Club = clu.ClubCourseID,
  49. CourseTypeColour = cc.CourseTypeColour,
  50. UserID = fina.UserID,
  51. CourseName = fina.EM_Coursematerial.CourseName,
  52. TotalScore = fina.TotalScore,
  53. //暂时按此种逻辑处理。。后续优化(廖兵良)
  54. //已经优化--20180517李晓林
  55. TotalScoreStr = fina.TotalScore < 60 ? "重修":(examsStateList.Any(w => w.Value == fina.ExamsStateID) ? (Result.Name ?? ((double)Math.Round(fina.TotalScore.Value, 1)).ToString()) : f.Name),
  56. ScoreCredit = fina.ScoreCredit,
  57. CoursematerialID = fina.CoursematerialID,
  58. SchoolyearNumID = fina.SchoolyearNumID,
  59. SchoolyearID = fina.SchoolyearID,
  60. PlanningGraduateDate = student.PlanningGraduateDate,
  61. StarttermID = fina.StarttermID
  62. };
  63. return query.ToList();
  64. }
  65. /// <summary>
  66. /// 获取已提交成绩
  67. /// </summary>
  68. /// <param name="CoursematerialID"></param>
  69. /// <param name="SchoolyearID"></param>
  70. /// <param name="UserID"></param>
  71. public override IList<SubmitedScoreView> GetSubmitedScoreList(Guid? CoursematerialID, int? StartTermID, Guid? UserID)
  72. {
  73. int examsState = (int)CF_ExamsState.NormalExams;
  74. var query = from submited in SubmitedScoreRepository.Entities
  75. join coursetype in DictionaryItemRepository.Entities
  76. on new { CourseTypeID = submited.CourseTypeID, DictionaryCode = typeof(CF_CourseType).Name }
  77. equals new { CourseTypeID = coursetype.Value, coursetype.DictionaryCode }
  78. into courseTypedata
  79. from courseTypetb in courseTypedata.DefaultIfEmpty()
  80. join examscategory in DictionaryItemRepository.Entities
  81. on new { CourseTypeID = submited.ExamsCategoryID, DictionaryCode = typeof(CF_ExamsCategory).Name }
  82. equals new { CourseTypeID = examscategory.Value, examscategory.DictionaryCode }
  83. into examsCategorydata
  84. from examsCategorytb in examsCategorydata.DefaultIfEmpty()
  85. join examsstate in DictionaryItemRepository.Entities
  86. on new { CourseTypeID = submited.ExamsStateID, DictionaryCode = typeof(CF_ExamsState).Name }
  87. equals new { CourseTypeID = examsstate.Value, examsstate.DictionaryCode }
  88. into examsStatedata
  89. from examsStatetb in examsStatedata.DefaultIfEmpty()
  90. join opera in UserRepository.Entities on submited.CreatorUserID equals opera.UserID
  91. join d in DictionaryItemRepository.GetList(x => x.DictionaryCode == "CF_ResultType") on submited.ResultTypeID equals d.Value
  92. join rd in ResultTypeDetailRepository.GetList(x => true) on d.Value equals rd.ResultTypeID
  93. into ResultTypeDetail
  94. from Result in ResultTypeDetail.DefaultIfEmpty()
  95. where (
  96. (Result.ResultTypeDetailID != null &&
  97. (
  98. (submited.TotalScore <= Result.MaxScore && Result.MinScore <= submited.TotalScore && (Result.MaxScoreOperator == "<=" && Result.MinScoreOperator == "<="))
  99. || (submited.TotalScore <= Result.MaxScore && Result.MinScore < submited.TotalScore && (Result.MaxScoreOperator == "<=" && Result.MinScoreOperator == "<"))
  100. || (submited.TotalScore < Result.MaxScore && Result.MinScore < submited.TotalScore && (Result.MaxScoreOperator == "<" && Result.MinScoreOperator == "<"))
  101. || (submited.TotalScore < Result.MaxScore && Result.MinScore <= submited.TotalScore && (Result.MaxScoreOperator == "<" && Result.MinScoreOperator == "<="))
  102. )
  103. )
  104. || (Result.ResultTypeDetailID == null)
  105. )
  106. && submited.CoursematerialID == CoursematerialID && submited.StarttermID == StartTermID && submited.UserID == UserID
  107. select new SubmitedScoreView
  108. {
  109. SubmitedScoreID = submited.SubmitedScoreID,
  110. UserID = submited.UserID,
  111. LoginID = submited.CF_Student.Sys_User.LoginID,
  112. UserName = submited.CF_Student.Sys_User.Name,
  113. SchoolyearID = submited.SchoolyearID,
  114. SchoolyearCode = submited.CF_Schoolyear.Code,
  115. Schoolyear = submited.CF_Schoolyear.Years,
  116. CourseName = submited.EM_Coursematerial.CourseName,
  117. CourseCode = submited.EM_Coursematerial.CourseCode,
  118. TotalScore = submited.TotalScore,
  119. //暂时按此种逻辑处理。。后续优化(廖兵良)
  120. TotalScoreStr = submited.TotalScore < 60 ? "重修" : ((submited.ExamsStateID == examsState || submited.ExamsStateID == 10) ? (Result.Name ?? ((double)Math.Round(submited.TotalScore.Value, 1)).ToString()) : examsStatetb.Name),
  121. ScoreCredit = submited.ScoreCredit,
  122. CoursetypeName = courseTypetb.Name,
  123. CreateTime = submited.CreateTime,
  124. OperaUser = opera.Name,
  125. ExamsCategoryName = examsCategorytb.Name,
  126. ExamsStateName = examsStatetb.Name,
  127. CoursematerialID = submited.CoursematerialID,
  128. StarttermID = submited.StarttermID,
  129. Remarks = submited.Remark,
  130. StudentScoreRemark = submited.Remark,
  131. };
  132. return query.ToList();
  133. }
  134. }
  135. }