StudentScoreDAL.cs 6.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.ViewModel.ScoreManage;
  6. using EMIS.Entities;
  7. using System.Linq.Expressions;
  8. namespace EMIS.ExtensionLogic.DataLogic.ScoreManage
  9. {
  10. public class StudentScoreDAL : EMIS.DataLogic.ScoreManage.StudentScoreDAL
  11. {
  12. /// <summary>
  13. /// 已提交成绩
  14. /// </summary>
  15. /// <param name="exp"></param>
  16. /// <returns></returns>
  17. public override IQueryable<StudentScoreView> GetStudentScoreViewQueryable(Expression<Func<ER_SubmitedScore, bool>> exp)
  18. {
  19. List<int?> examsStateList = examsStateSettingRepository.GetList(x => x.IsNormal == true).Select(x => x.ExamsStateID).ToList();
  20. var query = from x in submitedScoreRepository.GetList(exp)
  21. join u in userRepository.Entities on x.CreatorUserID equals u.UserID
  22. into user
  23. from a in user.DefaultIfEmpty()
  24. join ed in DictionaryItemRepository.GetList(x => x.DictionaryCode == "CF_ExamsState") on x.ExamsStateID equals ed.Value
  25. into ged
  26. from f in ged.DefaultIfEmpty()
  27. join d in DictionaryItemRepository.GetList(x => x.DictionaryCode == "CF_ResultType") on x.ResultTypeID equals d.Value
  28. join rd in ResultTypeDetailRepository.GetList(x => true) on d.Value equals rd.ResultTypeID
  29. into ResultTypeDetail
  30. from Result in ResultTypeDetail.DefaultIfEmpty()
  31. where (Result.ResultTypeDetailID != null &&
  32. ((x.TotalScore <= Result.MaxScore && Result.MinScore <= x.TotalScore && (Result.MaxScoreOperator == "<=" && Result.MinScoreOperator == "<="))
  33. || (x.TotalScore <= Result.MaxScore && Result.MinScore < x.TotalScore && (Result.MaxScoreOperator == "<=" && Result.MinScoreOperator == "<"))
  34. || (x.TotalScore < Result.MaxScore && Result.MinScore < x.TotalScore && (Result.MaxScoreOperator == "<" && Result.MinScoreOperator == "<"))
  35. || (x.TotalScore < Result.MaxScore && Result.MinScore <= x.TotalScore && (Result.MaxScoreOperator == "<" && Result.MinScoreOperator == "<="))
  36. ))
  37. || (Result.ResultTypeDetailID == null)
  38. select new StudentScoreView
  39. {
  40. SubmitedScoreID = x.SubmitedScoreID,
  41. SchoolyearID = x.SchoolyearID,
  42. SchoolyearCode = x.CF_Schoolyear.Code,
  43. SchoolyearNumID = x.SchoolyearNumID,
  44. ClassName = x.ClassName,
  45. GrademajorID = x.CF_Student.CF_Classmajor.CF_Grademajor.GrademajorID,
  46. GrademajorCode = x.CF_Student.CF_Classmajor.CF_Grademajor.Code,
  47. GrademajorName = x.CF_Student.CF_Classmajor.CF_Grademajor.Name,
  48. ClassmajorID = x.CF_Student.CF_Classmajor.ClassmajorID,
  49. ClassmajorCode = x.CF_Student.CF_Classmajor.No,
  50. ClassmajorName = x.CF_Student.CF_Classmajor.Name,
  51. CollegeID = x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID,
  52. CollegeName = x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CF_College.Name,
  53. DepartmentID = x.DepartmentID,
  54. DepartmentName = x.CF_Department.Name,
  55. CoursematerialID = x.EM_Coursematerial.CoursematerialID,
  56. CourseCode = x.EM_Coursematerial.CourseCode,
  57. CourseName = x.EM_Coursematerial.CourseName,
  58. CourseTypeID = x.CourseTypeID,
  59. ExamsCategoryID = x.ExamsCategoryID,
  60. ExaminationModeID = x.ExaminationModeID,
  61. Credit = x.Credit ?? 0,
  62. ExamsDatetime = x.ExamsDatetime,
  63. ResultTypeID = x.ResultTypeID,
  64. CreatorUserID = x.CreatorUserID,
  65. CreatorUserCode = a.LoginID,
  66. CreatorUserName = a.Name,
  67. EntryDeadlineTime = x.EntryDeadlineTime,
  68. ExaminationType = x.ExaminationType,
  69. StarttermID = x.StarttermID,
  70. UserID = x.UserID,
  71. LoginID = x.CF_Student.Sys_User.LoginID,
  72. UserName = x.CF_Student.Sys_User.Name,
  73. ExamsStateID = x.ExamsStateID,
  74. TotalScore = x.TotalScore,
  75. //暂时按此种逻辑处理。。后续优化(廖兵良)
  76. //已经优化--20180517李晓林
  77. TotalScoreStr = x.TotalScore < 60 ? "重修" : (examsStateList.Any(w => w.Value == x.ExamsStateID) ? (Result.Name ?? ((double)Math.Round(x.TotalScore.Value, 1)).ToString()) : f.Name),
  78. ScoreCredit = x.ScoreCredit ?? 0,
  79. GradePoint = x.GradePoint,
  80. Remarks = x.Remark,
  81. StudentScoreRemark = x.Remark,
  82. CreateTime = x.CreateTime,
  83. CreateUserID = x.CreateUserID,
  84. TotalHours = x.TotalHours,
  85. Pingshi = x.ER_SubmitedScoreDetail.Where(q => q.ScoreTypeID == (int)EMIS.ViewModel.CF_ScoreType.Peacetime).FirstOrDefault().Score == null ? (decimal?)null : Math.Round(x.ER_SubmitedScoreDetail.Where(q => q.ScoreTypeID == (int)EMIS.ViewModel.CF_ScoreType.Peacetime).FirstOrDefault().Score ?? 0, 0),
  86. Jishu = x.ER_SubmitedScoreDetail.Where(q => q.ScoreTypeID == (int)EMIS.ViewModel.CF_ScoreType.Technique).FirstOrDefault().Score == null ? (decimal?)null : Math.Round(x.ER_SubmitedScoreDetail.Where(q => q.ScoreTypeID == (int)EMIS.ViewModel.CF_ScoreType.Technique).FirstOrDefault().Score ?? 0, 0),
  87. Lilun = x.ER_SubmitedScoreDetail.Where(q => q.ScoreTypeID == (int)EMIS.ViewModel.CF_ScoreType.Theoretical).FirstOrDefault().Score == null ? (decimal?)null : Math.Round(x.ER_SubmitedScoreDetail.Where(q => q.ScoreTypeID == (int)EMIS.ViewModel.CF_ScoreType.Theoretical).FirstOrDefault().Score ?? 0, 0),
  88. HandleModeID = x.HandleModeID,
  89. };
  90. return query;
  91. }
  92. }
  93. }