SpecialityScoreSumDAL.cs 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.ViewModel.ScoreManage;
  6. using System.Linq.Expressions;
  7. using Bowin.Common.Linq;
  8. using EMIS.Entities;
  9. using EMIS.ViewModel;
  10. namespace EMIS.ExtensionLogic.DataLogic.ScoreManage
  11. {
  12. public class SpecialityScoreSumDAL : EMIS.DataLogic.ScoreManage.SpecialityScoreSumDAL
  13. {
  14. /// <summary>
  15. ///
  16. /// </summary>
  17. /// <param name="collegeID"></param>
  18. /// <param name="years"></param>
  19. /// <param name="schoolyearNumID"></param>
  20. /// <param name="schoolcodeID"></param>
  21. /// <param name="classmajorID"></param>
  22. /// <returns></returns>
  23. public override IQueryable<StudentScoreView> GetStudentScoreViewQueryable(Guid? collegeID, int? years, int? schoolyearNumID, int? schoolcodeID, Guid? classmajorID)
  24. {
  25. List<int?> examsStateList = examsStateSettingRepository.GetList(x => x.IsNormal == true).Select(x => x.ExamsStateID).ToList();
  26. Expression<Func<ER_FinallyScore, bool>> exp = (x => true);
  27. if (collegeID.HasValue)
  28. exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID);
  29. if (years.HasValue)
  30. exp = exp.And(x => x.CF_Student.CF_Classmajor.CF_Grademajor.GradeID == years);
  31. if (schoolyearNumID.HasValue)
  32. exp = exp.And(x => x.SchoolyearNumID == schoolyearNumID);
  33. if (schoolcodeID.HasValue)
  34. exp = exp.And(x => (x.CF_Student.CF_Classmajor.CF_Grademajor.SemesterID + (x.StarttermID - 1)) % 2 == schoolcodeID % 2);
  35. if (classmajorID.HasValue)
  36. exp = exp.And(x => x.CF_Student.ClassmajorID == classmajorID);
  37. var query = from x in finallyScoreRepository.GetList(exp, (x => x.CF_Student), (x => x.CF_Student.Sys_User), (x => x.CF_Schoolyear), (x => x.CF_Student.CF_Classmajor.CF_Grademajor.CF_Facultymajor), (x => x.CF_Student.CF_Classmajor))
  38. join ed in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_ExamsState).Name) on x.ExamsStateID equals ed.Value
  39. into ged
  40. from f in ged.DefaultIfEmpty()
  41. join d in DictionaryItemRepository.GetList(x => x.DictionaryCode == "CF_ResultType") on x.ResultTypeID equals d.Value
  42. join rd in ResultTypeDetailRepository.GetList(x => true) on d.Value equals rd.ResultTypeID
  43. into ResultTypeDetail
  44. from Result in ResultTypeDetail.DefaultIfEmpty()
  45. where (Result.ResultTypeDetailID != null &&
  46. ((x.TotalScore <= Result.MaxScore && Result.MinScore <= x.TotalScore && (Result.MaxScoreOperator == "<=" && Result.MinScoreOperator == "<="))
  47. || (x.TotalScore <= Result.MaxScore && Result.MinScore < x.TotalScore && (Result.MaxScoreOperator == "<=" && Result.MinScoreOperator == "<"))
  48. || (x.TotalScore < Result.MaxScore && Result.MinScore < x.TotalScore && (Result.MaxScoreOperator == "<" && Result.MinScoreOperator == "<"))
  49. || (x.TotalScore < Result.MaxScore && Result.MinScore <= x.TotalScore && (Result.MaxScoreOperator == "<" && Result.MinScoreOperator == "<="))
  50. ))
  51. || (Result.ResultTypeDetailID == null)
  52. select new StudentScoreView
  53. {
  54. SchoolyearID = x.SchoolyearID,
  55. SchoolyearCode = x.CF_Schoolyear.Code,
  56. SchoolyearNumID = x.SchoolyearNumID,
  57. ClassName = x.ClassName,
  58. GrademajorID = x.CF_Student.CF_Classmajor.CF_Grademajor.GrademajorID,
  59. GrademajorCode = x.CF_Student.CF_Classmajor.CF_Grademajor.Code,
  60. GrademajorName = x.CF_Student.CF_Classmajor.CF_Grademajor.Name,
  61. ClassmajorID = x.CF_Student.CF_Classmajor.ClassmajorID,
  62. ClassmajorCode = x.CF_Student.CF_Classmajor.No,
  63. ClassmajorName = x.CF_Student.CF_Classmajor.Name,
  64. CollegeID = x.CF_Department.CollegeID,
  65. CollegeName = x.CF_Department.CF_College.Name,
  66. DepartmentID = x.DepartmentID,
  67. DepartmentName = x.CF_Department.Name,
  68. CoursematerialID = x.EM_Coursematerial.CoursematerialID,
  69. CourseCode = x.EM_Coursematerial.CourseCode,
  70. CourseName = x.EM_Coursematerial.CourseName,
  71. CourseTypeID = x.CourseTypeID,
  72. ExamsCategoryID = x.ExamsCategoryID,
  73. ExaminationModeID = x.ExaminationModeID,
  74. Credit = x.Credit ?? 0,
  75. ExamsDatetime = x.ExamsDatetime,
  76. ResultTypeID = x.ResultTypeID,
  77. CreatorUserID = x.CreatorUserID,
  78. EntryDeadlineTime = x.EntryDeadlineTime,
  79. ExaminationType = x.ExaminationType,
  80. StarttermID = x.StarttermID,
  81. UserID = x.UserID,
  82. LoginID = x.CF_Student.Sys_User.LoginID,
  83. UserName = x.CF_Student.Sys_User.Name,
  84. ExamsStateID = x.ExamsStateID,
  85. TotalScore = x.TotalScore,
  86. TotalScoreStr = x.TotalScore < 60 ? "重修" : (examsStateList.Any(w => w.Value == x.ExamsStateID) ? (Result.Name ?? ((double)x.TotalScore).ToString()) : f.Name),
  87. ScoreCredit = x.ScoreCredit ?? 0,
  88. GradePoint = x.GradePoint,
  89. Remarks = x.Remark,
  90. StudentScoreRemark = x.Remark,
  91. CreateTime = x.CreateTime,
  92. CreateUserID = x.CreateUserID,
  93. Pingshi = Math.Round(x.ER_FinallyScoreDetail.Where(q => q.ScoreTypeID == (int)EMIS.ViewModel.CF_ScoreType.Peacetime).FirstOrDefault().Score ?? 0, 0),
  94. Jishu = Math.Round(x.ER_FinallyScoreDetail.Where(q => q.ScoreTypeID == (int)EMIS.ViewModel.CF_ScoreType.Technique).FirstOrDefault().Score ?? 0, 0),
  95. Lilun = Math.Round(x.ER_FinallyScoreDetail.Where(q => q.ScoreTypeID == (int)EMIS.ViewModel.CF_ScoreType.Theoretical).FirstOrDefault().Score ?? 0, 0)
  96. };
  97. return query.OrderByDescending(x => x.SchoolyearCode);
  98. }
  99. }
  100. }