EvaluationEnterDAL.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270
  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 Bowin.Common.Linq;
  13. using EMIS.ViewModel.EvaluationManage.EvaluationEnter;
  14. using EMIS.Utility;
  15. using EMIS.DataLogic.StudentManage.StudentStatistics;
  16. namespace EMIS.DataLogic.Common.EvaluationManage
  17. {
  18. public class EvaluationEnterDAL
  19. {
  20. public DataRangeDAL DataRangeDAL { get; set; }
  21. public InSchoolSettingDAL InSchoolSettingDAL { get; set; }
  22. public EvaluationSettingRepository EvaluationSettingRepository { get; set; }
  23. public EducationMissionRepository EducationMissionRepository { get; set; }
  24. public MissionClassTeacherRepository MissionClassTeacherRepository { get; set; }
  25. public EvaluationTableRepository EvaluationTableRepository { get; set; }
  26. public EducationSchedulingClassRepository EducationSchedulingClassRepository { get; set; }
  27. public DictionaryDAL DictionaryDAL { get; set; }
  28. public UserRepository UserRepository { get; set; }
  29. public StaffRepository StaffRepository { get; set; }
  30. public StudentRepository StudentRepository { get; set; }
  31. public EducationMissionClassRepository EducationMissionClassRepository { get; set; }
  32. public SpecialtyPlanRepository SpecialtyPlanRepository { get; set; }
  33. public EvaluationTypeRepository evaluationTypeRepository { get; set; }
  34. public EvaluationControlRepository EvaluationControlRepository { get; set; }
  35. public EvaluationEnterRepository EvaluationEnterRepository { get; set; }
  36. public EvaluationProjectRepository EvaluationProjectRepository { get; set; }
  37. public EvaluationTargetRepository EvaluationTargetRepository { get; set; }
  38. public EvaluationNormRepository EvaluationNormRepository { get; set; }
  39. public EvaluationNormDetailRepository EvaluationNormDetailRepository { get; set; }
  40. //public EvaluationNeedDAL evaluationNeedDAL { get; set; }
  41. public EvaluationGradeControlRepository EvaluationGradeControlRepository { get; set; }
  42. public GrademajorRepository GrademajorRepository { get; set; }
  43. public EvaluationEnter_EM_EvaluationProjectRepository EvaluationEnter_EM_EvaluationProjectRepository { get; set; }
  44. // 加载进入评价信息
  45. public IQueryable<EvaluationEnterView> GetEvaluationEnterQuery(Expression<Func<EM_EvaluationSetting, bool>> expEvaluationSetting = null,
  46. Expression<Func<EM_EvaluationEnter, bool>> expEvaluationEnter = null, Expression<Func<EM_EvaluationTable, bool>> expEvaluationTable = null)
  47. {
  48. if (expEvaluationSetting == null)
  49. {
  50. expEvaluationSetting = (x => true);
  51. }
  52. if (expEvaluationEnter == null)
  53. {
  54. expEvaluationEnter = (x => true);
  55. }
  56. if (expEvaluationTable == null)
  57. {
  58. expEvaluationTable = (x => true);
  59. }
  60. var query = from c in EvaluationSettingRepository.GetList(expEvaluationSetting)
  61. from stcontrol in EvaluationTableRepository.Entities.Where(expEvaluationTable)
  62. .Where(x => x.EM_EvaluationIntType.EM_EvaluationTeachingMode.Select(w => w.TeachingModeID)
  63. .Contains(c.EM_EducationMissionClass.TeachingModeID ?? (int)CF_TeachingMode.Theory)).DefaultIfEmpty()
  64. //into tcontrol//评价表评价类型变动、转变成一对多关系、一种评价类型对应多个授课类型
  65. //from stcontrol in tcontrol.DefaultIfEmpty()
  66. join even in EvaluationEnterRepository.GetList(expEvaluationEnter) on new { c.EducationMissionClassID, TableID = (Guid)stcontrol.EvaluationTableID }
  67. equals new { even.EducationMissionClassID, TableID = (Guid)even.EvaluationTableID }
  68. into teven
  69. from cteven in teven.DefaultIfEmpty()
  70. join evcontrol in EvaluationControlRepository.Entities on c.EM_EducationMissionClass.EM_EducationMission.SchoolyearID equals evcontrol.SchoolyearID
  71. into Temevcontrol
  72. from evcontroltab in Temevcontrol.DefaultIfEmpty()
  73. select new EvaluationEnterView
  74. {
  75. EntityCreateTime = cteven.ModifyTime,
  76. CollegeID = c.EM_EducationMissionClass.EM_EducationMission.CollegeID,
  77. DepartmentName = c.EM_EducationMissionClass.EM_EducationMission.CF_Department.Name,
  78. EvaluationTableID = stcontrol.EvaluationTableID,
  79. EvaluationTableName = stcontrol.Name,
  80. EvaluationEnterID = cteven.EvaluationEnterID,
  81. EvaluationSettingID = c.EvaluationSettingID,//评价设置ID
  82. EvaluationIntTypeID = stcontrol.EM_EvaluationIntType.EvaluationIntTypeID,
  83. EvaluationTableTypeName = stcontrol.EM_EvaluationIntType.Name,
  84. EvaluationTypeID = stcontrol.EM_EvaluationType.EvaluationTypeID,//参评类型
  85. EvaluationTypeName = stcontrol.EM_EvaluationType.Name,
  86. EducationMissionClassName = c.EM_EducationMissionClass.Name,
  87. EducationMissionClassID = c.EM_EducationMissionClass.EducationMissionClassID,
  88. EvaluationSettingCode = c.EvaluationSettingCode,
  89. DepartmentID = c.EM_EducationMissionClass.EM_EducationMission.DepartmentID,
  90. SchoolyearID = c.EM_EducationMissionClass.EM_EducationMission.CF_Schoolyear.SchoolyearID,
  91. SchoolyearCode = c.EM_EducationMissionClass.EM_EducationMission.CF_Schoolyear.Code,
  92. CourseName = c.EM_EducationMissionClass.EM_Coursematerial.CourseName,
  93. CourseCode = c.EM_EducationMissionClass.EM_Coursematerial.CourseCode,
  94. LimitMore = stcontrol.EM_EvaluationType.Number,
  95. PhotoUrl = c.EM_EducationMissionClass.EM_MissionClassTeacher.Where(x => x.TeachType == (int)EM_TeachingMethod.Lecturer).FirstOrDefault().CF_Staff.PhotoUrl,
  96. Sys_User = c.EM_EducationMissionClass.EM_MissionClassTeacher.Select(s => s.CF_Staff.Sys_User),
  97. StaffDepartmentID = c.EM_EducationMissionClass.EM_MissionClassTeacher.Select(s => s.CF_Staff.DepartmentID),
  98. IsEvaluation = DateTime.Now > stcontrol.EM_EvaluationType.StartTime && DateTime.Now < stcontrol.EM_EvaluationType.EndTime ? true : false,
  99. EvaluationCount = cteven.EvaluationEnterID == null ? 0 : cteven.EM_EvaluationEnter_EM_EvaluationProject.GroupBy(x => x.ModifyTime).Select(y => y).Count(),
  100. Remark = cteven.Remark,
  101. };
  102. return query;
  103. }
  104. //学生加载进入评价信息
  105. public IQueryable<EvaluationEnterView> GetStudentEvaluationEnterQuery(Expression<Func<EM_EvaluationSetting, bool>> expEvaluationSetting = null,
  106. Expression<Func<EM_EvaluationEnter, bool>> expEvaluationEnter = null, Expression<Func<EM_EvaluationTable, bool>> expEvaluationTable = null,
  107. Expression<Func<EM_EvaluationGradeControl, bool>> expEvaluationGradeControl = null,
  108. Expression<Func<CF_Student, bool>> expStudent = null)
  109. {
  110. if (expEvaluationSetting == null)
  111. {
  112. expEvaluationSetting = (x => true);
  113. }
  114. if (expEvaluationEnter == null)
  115. {
  116. expEvaluationEnter = (x => true);
  117. }
  118. if (expEvaluationTable == null)
  119. {
  120. expEvaluationTable = (x => true);
  121. }
  122. if (expEvaluationGradeControl == null)
  123. {
  124. expEvaluationGradeControl = (x => true);
  125. }
  126. if (expStudent == null)
  127. {
  128. expStudent = (x => true);
  129. }
  130. var query = from c in EvaluationSettingRepository.GetList(expEvaluationSetting)
  131. from stcontrol in EvaluationTableRepository.Entities.Where(expEvaluationTable)
  132. .Where(x => x.EM_EvaluationIntType.EM_EvaluationTeachingMode.Select(w => w.TeachingModeID)
  133. .Contains(c.EM_EducationMissionClass.TeachingModeID ?? (int)CF_TeachingMode.Theory)).DefaultIfEmpty()
  134. //into tcontrol//评价表评价类型变动、转变成一对多关系、一种评价类型对应多个授课类型
  135. //from stcontrol in tcontrol.DefaultIfEmpty()
  136. join even in EvaluationEnterRepository.GetList(expEvaluationEnter)
  137. on new { c.EducationMissionClassID, TableID = (Guid)stcontrol.EvaluationTableID }
  138. equals new { even.EducationMissionClassID, TableID = (Guid)even.EvaluationTableID }
  139. into teven
  140. from cteven in teven.DefaultIfEmpty()
  141. join evcontrol in EvaluationControlRepository.Entities
  142. on c.EM_EducationMissionClass.EM_EducationMission.SchoolyearID equals evcontrol.SchoolyearID into Temevcontrol
  143. from evcontroltab in Temevcontrol.DefaultIfEmpty()
  144. from student in StudentRepository.Entities.Where(expStudent).DefaultIfEmpty()
  145. join grade in GrademajorRepository.Entities on student.CF_Classmajor.CF_Grademajor.GrademajorID equals grade.GrademajorID
  146. join egcontrol in EvaluationGradeControlRepository.Entities
  147. on new { c.EM_EducationMissionClass.EM_EducationMission.SchoolyearID, GrademajorID = grade.GrademajorID }
  148. equals new { egcontrol.SchoolyearID, GrademajorID = (Guid)egcontrol.GrademajorID }
  149. into eg
  150. from e in eg.DefaultIfEmpty()
  151. select new EvaluationEnterView
  152. {
  153. EntityCreateTime = cteven.ModifyTime,
  154. CollegeID = c.EM_EducationMissionClass.EM_EducationMission.CollegeID,
  155. DepartmentName = c.EM_EducationMissionClass.EM_EducationMission.CF_Department.Name,
  156. EvaluationTableID = stcontrol.EvaluationTableID,
  157. EvaluationTableName = stcontrol.Name,
  158. EvaluationEnterID = cteven.EvaluationEnterID,
  159. EvaluationSettingID = c.EvaluationSettingID,//评价设置ID
  160. EvaluationIntTypeID = stcontrol.EM_EvaluationIntType.EvaluationIntTypeID,
  161. EvaluationTableTypeName = stcontrol.EM_EvaluationIntType.Name,
  162. EvaluationTypeID = stcontrol.EM_EvaluationType.EvaluationTypeID,//参评类型
  163. EvaluationTypeName = stcontrol.EM_EvaluationType.Name,
  164. EducationMissionClassName = c.EM_EducationMissionClass.Name,
  165. EducationMissionClassID = c.EM_EducationMissionClass.EducationMissionClassID,
  166. EvaluationSettingCode = c.EvaluationSettingCode,
  167. DepartmentID = c.EM_EducationMissionClass.EM_EducationMission.DepartmentID,
  168. SchoolyearID = c.EM_EducationMissionClass.EM_EducationMission.CF_Schoolyear.SchoolyearID,
  169. SchoolyearCode = c.EM_EducationMissionClass.EM_EducationMission.CF_Schoolyear.Code,
  170. CourseName = c.EM_EducationMissionClass.EM_Coursematerial.CourseName,
  171. CourseCode = c.EM_EducationMissionClass.EM_Coursematerial.CourseCode,
  172. LimitMore = (e.EvaluationGradeControlID == null ? stcontrol.EM_EvaluationType.Number : e.Number),
  173. PhotoUrl = c.EM_EducationMissionClass.EM_MissionClassTeacher.Where(x => x.TeachType == (int)EM_TeachingMethod.Lecturer).FirstOrDefault().CF_Staff.PhotoUrl,
  174. Sys_User = c.EM_EducationMissionClass.EM_MissionClassTeacher.Select(s => s.CF_Staff.Sys_User),
  175. StaffDepartmentID = c.EM_EducationMissionClass.EM_MissionClassTeacher.Select(s => s.CF_Staff.DepartmentID),
  176. IsEvaluation = DateTime.Now > stcontrol.EM_EvaluationType.StartTime && DateTime.Now < stcontrol.EM_EvaluationType.EndTime ? true : false,
  177. IsStudentEvaluation = (e.EvaluationGradeControlID == null ?
  178. (DateTime.Now > stcontrol.EM_EvaluationType.StartTime && DateTime.Now < stcontrol.EM_EvaluationType.EndTime ? true : false)
  179. : (DateTime.Now > e.StartTime && DateTime.Now < e.EndTime ? true : false)),
  180. EvaluationCount = cteven.EvaluationEnterID == null ? 0 : cteven.EM_EvaluationEnter_EM_EvaluationProject.GroupBy(x => x.ModifyTime).Select(y => y).Count(),
  181. Remark = cteven.Remark,
  182. };
  183. return query;
  184. }
  185. // 加载进入评价表头相关信息
  186. public EvaluationEnterView GetEvaluationEnterTitleView(Guid? educationMissionClassID, Guid? evaluationTableID)
  187. {
  188. var Query = from c in EvaluationSettingRepository.GetList(x => x.OpenStatus == (int)CF_YesOrNoStatus.Yes && x.EvaluationTableID == evaluationTableID)
  189. //join f in DictionaryDAL.GetDictionaryItemQuery(typeof(CF_TeachingMode).Name) on c.EM_EvaluationTable.IntType equals f.Value
  190. join emc in EducationMissionClassRepository.GetList(x => x.EducationMissionClassID == educationMissionClassID)
  191. on c.EducationMissionClassID equals emc.EducationMissionClassID into temc
  192. from stemc in temc.DefaultIfEmpty()
  193. join control in EvaluationControlRepository.Entities on stemc.EM_EducationMission.CF_Schoolyear.SchoolyearID equals control.SchoolyearID
  194. into tcontrol
  195. from stcontrol in tcontrol.DefaultIfEmpty()
  196. // join entype in evaluationTypeRepository.Entities on c.EM_EvaluationType.TypeID equals entype.TypeID
  197. // join user in UserRepository.Entities on stcourse.UserID equals user.UserID
  198. select new EvaluationEnterView
  199. {
  200. EvaluationTableID = c.EvaluationTableID,
  201. //EvaluationTableTypeName = f.Name,
  202. EvaluationTypeName = c.EM_EvaluationType.Name,
  203. EducationMissionClassName = c.EM_EducationMissionClass.Name,
  204. EducationMissionClassID = c.EM_EducationMissionClass.EducationMissionClassID,
  205. EvaluationSettingCode = c.EvaluationSettingCode,
  206. CourseName = stemc.EM_Coursematerial.CourseName,
  207. CourseCode = stemc.EM_Coursematerial.CourseCode,
  208. Remark = stemc.EM_EducationMission.CF_Department.Name,
  209. LimitMore = c.EM_EvaluationType.Number,//entype.Number,
  210. Sys_User = stemc.EM_MissionClassTeacher.Select(x => x.CF_Staff.Sys_User)
  211. };
  212. return Query.FirstOrDefault();
  213. }
  214. // 加载进入评价评价项目相关信息
  215. public IQueryable<EvaluationEnterView> GetEvaluationEnterView(Guid? evaluationEnterID, Guid? evaluationTableID)
  216. {
  217. var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  218. //取最大操作时间
  219. var maxModifyTime = (from a in EvaluationEnter_EM_EvaluationProjectRepository.Entities.Where(x => x.EvaluationEnterID == evaluationEnterID)
  220. group new { a } by new { a.ModifyTime } into g
  221. select new { ModifyTime = g.Max(x => x.a.ModifyTime) }).OrderByDescending(x => x.ModifyTime).FirstOrDefault();
  222. var Query = from c in EvaluationEnterRepository.Entities.Where(x => x.EvaluationTableID == evaluationTableID && x.EvaluationEnterID == evaluationEnterID)
  223. join b in EvaluationEnter_EM_EvaluationProjectRepository.Entities.Where(x => x.CreateUserID == curUser.UserID && x.ModifyTime == maxModifyTime.ModifyTime)
  224. on c.EvaluationEnterID equals b.EvaluationEnterID
  225. into tProject
  226. from ctProject in tProject.DefaultIfEmpty()
  227. group new { ctProject } by new { ctProject.ModifyTime, ctProject.EvaluationScore, ctProject.ProjectID } into g
  228. select new EvaluationEnterView
  229. {
  230. EvaluationScore = (decimal)g.Key.EvaluationScore,
  231. ProjectID = g.Key.ProjectID,
  232. ModifyTime = g.Max(x => x.ctProject.ModifyTime)
  233. };
  234. return Query;
  235. }
  236. //这个部门对于的所有教师
  237. public IQueryable<DepartmentStaffView> GetDepartmentStaffViewQueryable(Expression<Func<EM_EducationMissionClass, bool>> exp)
  238. {
  239. var query = from emc in EducationMissionClassRepository.GetList(exp)
  240. from emcTecher in emc.EM_MissionClassTeacher.DefaultIfEmpty()
  241. join staff in StaffRepository.Entities.Where(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE)
  242. on emcTecher.CF_Staff.DepartmentID equals staff.DepartmentID
  243. select new DepartmentStaffView
  244. {
  245. EducationMissionClassID = emc.EducationMissionClassID,
  246. UserID = staff.UserID,
  247. Name = staff.Sys_User.Name,
  248. DepartmentID = staff.DepartmentID,
  249. StaffCode = staff.Sys_User.LoginID
  250. };
  251. return query;
  252. }
  253. }
  254. }