EvaluationRecordDAL.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.Repositories;
  6. using System.Linq.Expressions;
  7. using EMIS.Entities;
  8. using EMIS.ViewModel.EvaluationManage;
  9. using EMIS.DataLogic.SystemDAL;
  10. using EMIS.ViewModel;
  11. using EMIS.ViewModel.EducationManage;
  12. using EMIS.ViewModel.EvaluationManage.EvaluationEnter;
  13. namespace EMIS.DataLogic.Common.EvaluationManage
  14. {
  15. public class EvaluationRecordDAL
  16. {
  17. #region --0.0定义--
  18. public EvaluationSettingRepository EvaluationSettingRepository { get; set; }
  19. public EducationMissionRepository EducationMissionRepository { get; set; }
  20. public MissionClassTeacherRepository MissionClassTeacherRepository { get; set; }
  21. public EvaluationTableRepository EvaluationTableRepository { get; set; }
  22. public EducationSchedulingClassRepository EducationSchedulingClassRepository { get; set; }
  23. public DictionaryDAL DictionaryDAL { get; set; }
  24. public UserRepository UserRepository { get; set; }
  25. public StaffRepository StaffRepository { get; set; }
  26. public StudentRepository StudentRepository { get; set; }
  27. public EducationMissionClassRepository EducationMissionClassRepository { get; set; }
  28. public SpecialtyPlanRepository SpecialtyPlanRepository { get; set; }
  29. public EvaluationTypeRepository evaluationTypeRepository { get; set; }
  30. public EvaluationControlRepository EvaluationControlRepository { get; set; }
  31. public EvaluationEnterRepository EvaluationEnterRepository { get; set; }
  32. public EvaluationProjectRepository EvaluationProjectRepository { get; set; }
  33. public EvaluationTargetRepository EvaluationTargetRepository { get; set; }
  34. public EvaluationNormRepository EvaluationNormRepository { get; set; }
  35. public EvaluationNormDetailRepository EvaluationNormDetailRepository { get; set; }
  36. public EvaluationEnter_EM_EvaluationProjectRepository EvaluationEnter_EM_EvaluationProjectRepository { get; set; }
  37. public ClassmajorRepository ClassmajorRepository { get; set; }
  38. #endregion
  39. public IQueryable<EvaluationRecordView> GetEvaluationRecordQuery()
  40. {
  41. //var linqStr = EvaluationEnterRepository.Entities.ToList();
  42. var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  43. bool isStudent = curUser.IsStudent;//获取当前用户是否是学生
  44. //Guid? typeID = isStudent == true ? evaluationTypeRepository.Entities.Where(w => w.IsStudent == true).FirstOrDefault().TypeID : evaluationTypeRepository.Entities.Where(w => w.IsStudent == false && w.IsDefault == true).FirstOrDefault().TypeID;
  45. var query = from c in EvaluationSettingRepository.GetList(x => x.OpenStatus == (int)CF_YesOrNoStatus.Yes)
  46. join f in DictionaryDAL.GetDictionaryItemQuery(typeof(CF_TeachingMode).Name) on c.EM_EducationMissionClass.TeachingModeID equals f.Value
  47. join emc in EducationMissionClassRepository.Entities on c.EducationMissionClassID equals emc.EducationMissionClassID into temc
  48. from stemc in temc.DefaultIfEmpty()
  49. join cla in ClassmajorRepository.Entities on stemc.MainScheduleClassID equals cla.ClassmajorID into dcla
  50. from ecla in dcla.DefaultIfEmpty()
  51. from stcontrol in EvaluationTableRepository.Entities.Where(x => x.IsEnabled == true
  52. && x.EM_EvaluationIntType.EM_EvaluationTeachingMode.Select(w => w.TeachingModeID).Contains(c.EM_EducationMissionClass.TeachingModeID)).DefaultIfEmpty()
  53. join even in EvaluationEnterRepository.Entities on new { c.EducationMissionClassID, TableID = (Guid)stcontrol.EvaluationTableID } equals new { even.EducationMissionClassID, TableID = (Guid)even.EvaluationTableID }
  54. into teven
  55. from cteven in teven.DefaultIfEmpty()
  56. join sfuser in UserRepository.Entities on cteven.StaffUserID equals sfuser.UserID
  57. into bsfuser
  58. from tbsfuser in bsfuser.DefaultIfEmpty()
  59. join sduser in UserRepository.Entities on cteven.StudentUserID equals sduser.UserID
  60. into bsduser
  61. from tbsduser in bsduser.DefaultIfEmpty()
  62. select new EvaluationRecordView
  63. {
  64. //staffID=c.EM_EducationMissionClass.EM_MissionClassTeacher.
  65. CampusID =stemc.EM_EducationMission.CF_College.CampusID,
  66. Grade = ecla.CF_Grademajor.GradeID,
  67. StandardID = ecla.CF_Grademajor.CF_Facultymajor.StandardID,
  68. CollegeID = ecla.CF_Grademajor.CF_Facultymajor.CollegeID,
  69. EvaluationTableID = stcontrol.EvaluationTableID,
  70. EvaluationTableNo = stcontrol.Code,
  71. EvaluationEnterID = cteven.EvaluationEnterID,
  72. EvaluationIntTypeID = stcontrol.EvaluationIntTypeID,
  73. EvaluationTableTypeName = stcontrol.EM_EvaluationIntType.Name, //评价类型
  74. EvaluationTypeName = stcontrol.EM_EvaluationType.Name,
  75. EvaluationTypeID = stcontrol.EvaluationTypeID,
  76. EducationMissionClassName = c.EM_EducationMissionClass.Name,
  77. EducationMissionClassID = c.EM_EducationMissionClass.EducationMissionClassID,
  78. EvaluationSettingCode = c.EvaluationSettingCode,
  79. EvaluationCount = cteven.EvaluationEnterID == null ? 0 : cteven.EM_EvaluationEnter_EM_EvaluationProject.GroupBy(x => x.ModifyTime).Select(y => y).Count(),
  80. LimitMore = (int)stcontrol.EM_EvaluationType.Number,
  81. SchoolyearID = stemc.EM_EducationMission.CF_Schoolyear.SchoolyearID,
  82. year=stemc.EM_EducationMission.CF_Schoolyear.Years,
  83. SchoolyearCode = stemc.EM_EducationMission.CF_Schoolyear.Code,
  84. Sys_User = c.EM_EducationMissionClass.EM_MissionClassTeacher.Select(s => s.CF_Staff.Sys_User),
  85. EvaluationCode = tbsfuser.LoginID == null ? tbsduser.LoginID : tbsfuser.LoginID,
  86. EvaluationName = tbsfuser.Name == null ? tbsduser.Name : tbsfuser.Name,
  87. EvaluationTableName = stcontrol.Name,
  88. //EvaluationTableTypeID = stcontrol.EM_EvaluationType.TypeID,
  89. EvaluationTableTypeID = stcontrol.EvaluationIntTypeID,
  90. CourseName = stemc.EM_Coursematerial.CourseName,
  91. CourseCode = stemc.EM_Coursematerial.CourseCode,
  92. LearningformID = ecla.CF_Grademajor.CF_Facultymajor.LearningformID,
  93. LearnSystem = ecla.CF_Grademajor.CF_Facultymajor.LearnSystem,
  94. EducationID = ecla.CF_Grademajor.CF_Facultymajor.EducationID,
  95. };
  96. return query.Where(x => x.EvaluationCode != null);
  97. }
  98. /// <summary>
  99. /// 读取参评类型信息
  100. /// </summary>
  101. /// <param name="exp"></param>
  102. /// <returns></returns>
  103. public IQueryable<EvaluationTypeView> GetEvaluationTypeQueryable(Expression<Func<EM_EvaluationTable, bool>> exp)
  104. {
  105. var query = from c in EvaluationTableRepository.GetList(exp)
  106. join
  107. a in evaluationTypeRepository.Entities on c.EvaluationTypeID equals a.EvaluationTypeID
  108. select new EvaluationTypeView
  109. {
  110. TypeID = a.EvaluationTypeID,
  111. //Code = a.Code,
  112. Name = a.Name,
  113. IsStudent = a.IsStudent.Value,
  114. Student = (a.IsStudent.HasValue && a.IsStudent == true) ? "是" : "否",
  115. IsDefault = a.IsStudent.Value,
  116. Default = (a.IsStudent.HasValue && a.IsStudent == true) ? "是" : "否",
  117. StartTime = a.StartTime,
  118. EndTime = a.EndTime,
  119. Number = a.Number,
  120. Remark = a.Remark,
  121. CreateUserID = a.CreateUserID,
  122. CreateTime = a.CreateTime
  123. };
  124. return query;
  125. }
  126. public IQueryable<EvaluationRecordView> GetEvaluationRecordQuery(Expression<Func<EM_EvaluationSetting, bool>> filter)
  127. {
  128. //var linqStr = EvaluationEnterRepository.Entities.ToList();
  129. var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  130. bool isStudent = curUser.IsStudent;//获取当前用户是否是学生
  131. //Guid? typeID = isStudent == true ? evaluationTypeRepository.Entities.Where(w => w.IsStudent == true).FirstOrDefault().TypeID : evaluationTypeRepository.Entities.Where(w => w.IsStudent == false && w.IsDefault == true).FirstOrDefault().TypeID;
  132. var query =
  133. from c in EvaluationSettingRepository.GetList(filter)
  134. join f in DictionaryDAL.GetDictionaryItemQuery(typeof(CF_TeachingMode).Name) on c.EM_EducationMissionClass.TeachingModeID equals f.Value
  135. join emc in EducationMissionClassRepository.Entities on c.EducationMissionClassID equals emc.EducationMissionClassID into temc
  136. from stemc in temc.DefaultIfEmpty()
  137. join classmajor in ClassmajorRepository.Entities on stemc.MainScheduleClassID equals classmajor.ClassmajorID into dclassmajor
  138. from classmajor in dclassmajor.DefaultIfEmpty()
  139. from stcontrol in EvaluationTableRepository.Entities.Where(x => x.IsEnabled == true
  140. && x.EM_EvaluationIntType.EM_EvaluationTeachingMode.Select(w => w.TeachingModeID).Contains(c.EM_EducationMissionClass.TeachingModeID)).DefaultIfEmpty()
  141. join even in EvaluationEnterRepository.Entities on new { c.EducationMissionClassID, TableID = (Guid)stcontrol.EvaluationTableID } equals new { even.EducationMissionClassID, TableID = (Guid)even.EvaluationTableID }
  142. into teven
  143. from cteven in teven.DefaultIfEmpty()
  144. join sfuser in UserRepository.Entities on cteven.StaffUserID equals sfuser.UserID
  145. into bsfuser
  146. from tbsfuser in bsfuser.DefaultIfEmpty()
  147. join sduser in UserRepository.Entities on cteven.StudentUserID equals sduser.UserID
  148. into bsduser
  149. from tbsduser in bsduser.DefaultIfEmpty()
  150. select new EvaluationRecordView
  151. {
  152. //ClassID=stemc.EM_ExecutablePlan.CF_Grademajor.CF_Classmajor
  153. CampusID = classmajor.CF_Grademajor.CF_Facultymajor.CF_College.CampusID,
  154. StandardID = classmajor.CF_Grademajor.CF_Facultymajor.StandardID,
  155. CollegeID = classmajor.CF_Grademajor.CF_Facultymajor.CollegeID,
  156. EvaluationTableID = stcontrol.EvaluationTableID,
  157. EvaluationEnterID = cteven.EvaluationEnterID,
  158. EvaluationTableTypeName = stcontrol.EM_EvaluationIntType.Name, //评价类型
  159. EvaluationTypeName = stcontrol.EM_EvaluationType.Name,
  160. EvaluationTypeID = stcontrol.EvaluationTypeID,
  161. EducationMissionClassName = c.EM_EducationMissionClass.Name,
  162. EducationMissionClassID = c.EM_EducationMissionClass.EducationMissionClassID,
  163. EvaluationSettingCode = c.EvaluationSettingCode,
  164. EvaluationCount = cteven.EvaluationEnterID == null ? 0 : cteven.EM_EvaluationEnter_EM_EvaluationProject.GroupBy(x => x.ModifyTime).Select(y => y).Count(),
  165. LimitMore = (int)stcontrol.EM_EvaluationType.Number,
  166. SchoolyearID = stemc.EM_EducationMission.CF_Schoolyear.SchoolyearID,
  167. SchoolyearCode = stemc.EM_EducationMission.CF_Schoolyear.Code,
  168. Sys_User = c.EM_EducationMissionClass.EM_MissionClassTeacher.Select(s => s.CF_Staff.Sys_User),
  169. EvaluationCode = tbsfuser.LoginID == null ? tbsduser.LoginID : tbsfuser.LoginID,
  170. EvaluationName = tbsfuser.Name == null ? tbsduser.Name : tbsfuser.Name,
  171. EvaluationTableName = stcontrol.Name,
  172. EvaluationTableTypeID = stcontrol.EM_EvaluationType.EvaluationTypeID,
  173. CourseName = stemc.EM_Coursematerial.CourseName,
  174. CourseCode = stemc.EM_Coursematerial.CourseCode,
  175. };
  176. return query.Where(x => x.EvaluationCode != null);
  177. }
  178. }
  179. }