EvaluationSettingDAL.cs 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507
  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.EducationManagement;
  13. using Bowin.Common.Linq;
  14. using EMIS.DataLogic.UniversityManage.TeacherManage;
  15. namespace EMIS.DataLogic.Common.EvaluationManage
  16. {
  17. public class EvaluationSettingDAL
  18. {
  19. public EvaluationSettingRepository EvaluationSettingRepository { get; set; }
  20. public EducationMissionRepository EducationMissionRepository { get; set; }
  21. public EvaluationTeachingModeRepository EvaluationTeachingModeRepository { get; set; }
  22. public MissionClassTeacherRepository MissionClassTeacherRepository { get; set; }
  23. public EvaluationTableRepository EvaluationTableRepository { get; set; }
  24. public EducationSchedulingClassRepository EducationSchedulingClassRepository { get; set; }
  25. public DictionaryDAL DictionaryDAL { get; set; }
  26. public UserRepository UserRepository { get; set; }
  27. public StaffRepository StaffRepository { get; set; }
  28. public StudentRepository StudentRepository { get; set; }
  29. public Lazy<StaffDAL> staffDAL { get; set; }
  30. public EducationMissionClassRepository EducationMissionClassRepository { get; set; }
  31. public SpecialtyPlanRepository SpecialtyPlanRepository { get; set; }
  32. public EvaluationTypeRepository evaluationTypeRepository { get; set; }
  33. public EvaluationTableDAL EvaluationTableDAL { get; set; }
  34. //public FreeSelectionCousePlanRepository freeSelectionCousePlanRepository { get; set; }
  35. public DepartmentRepository DepartmentRepository { get; set; }
  36. public EvaluationEnterRepository evaluationEnterRepository { get; set; }
  37. public ExecutablePlanRepository ExecutablePlanRepository { get; set; }
  38. public DictionaryItemRepository dictionaryItemRepository { get; set; }
  39. public OptionalCoursePlanRepository optionalCoursePlanRepository { get; set; }
  40. public EducationMissionClassSettingsRepository educationMissionClassSettingsRepository { get; set; }
  41. public IQueryable<EvaluationSettingView> GetEvaluationSettingQuery(Expression<Func<EM_EvaluationSetting, bool>> filter)
  42. {
  43. List<int> intTypeList = new List<int>(); //生成评价表中已启用、并且存在的授课方式
  44. var evaluationTabList = EvaluationTableRepository.GetList(x => x.IsEnabled == true, (w => w.EM_EvaluationIntType))
  45. .Select(s => new
  46. {
  47. s.EM_EvaluationIntType.EvaluationIntTypeID
  48. });
  49. var IntTypeIDList = evaluationTabList.Select(w => w.EvaluationIntTypeID).ToList();
  50. EvaluationTeachingModeRepository.GetList(x => IntTypeIDList.Contains((Guid)x.EvaluationIntTypeID))
  51. .Select(w => w.TeachingModeID).ToList().ForEach(p => { intTypeList.Add(p.Value); });
  52. var query = from c in EvaluationSettingRepository.GetList(filter)
  53. join course in EducationMissionClassRepository.GetList(w => intTypeList.Contains(w.TeachingModeID ?? (int)CF_TeachingMode.Theory))
  54. on c.EducationMissionClassID equals course.EducationMissionClassID
  55. from stcontrol in EvaluationTableRepository.Entities.Where(x => x.IsEnabled == true
  56. && x.EM_EvaluationIntType.EM_EvaluationTeachingMode.Select(w => w.TeachingModeID).Contains(course.TeachingModeID ?? (int)CF_TeachingMode.Theory)).DefaultIfEmpty()
  57. select new EvaluationSettingView
  58. {
  59. EvaluationSettingID = c.EvaluationSettingID,
  60. EvaluationSettingCode = c.EvaluationSettingCode,
  61. OpenStatus = (int)c.OpenStatus,
  62. OpenStatusName = (int)c.OpenStatus == (int)CF_YesOrNoStatus.Yes ? "是" : "否",
  63. EvaluationIntTypeID = stcontrol.EM_EvaluationIntType.EvaluationIntTypeID,
  64. EvaluationTableTypeName = stcontrol.EM_EvaluationIntType.Name,
  65. Remark = c.Remark,
  66. CoursematerialID = course.CoursematerialID,
  67. EvaluationTypeName = c.EM_EvaluationTable.EM_EvaluationType.Name,
  68. EducationMissionClassID = c.EducationMissionClassID,
  69. EducationMissionClassName = c.EM_EducationMissionClass.Name,
  70. SchoolyearID = course.EM_EducationMission.CF_Schoolyear.SchoolyearID,
  71. SchoolyearCode = course.EM_EducationMission.CF_Schoolyear.Code,
  72. CourseName = course.EM_Coursematerial.CourseName,
  73. CourseCode = course.EM_Coursematerial.CourseCode,
  74. //CourseTypeID =
  75. // Sys_User = c.EM_EducationMissionClass.EM_MissionClassTeacher.Select(s => s.CF_Staff.Sys_User),
  76. DepartmentID = course.EM_EducationMission.CF_Department.DepartmentID,
  77. CollegeID = course.EM_EducationMission.CF_College.CollegeID,
  78. CollegeName = course.EM_EducationMission.CF_College.Name,
  79. CampusID = course.EM_EducationMission.CF_College.CampusID,
  80. EntityCreateTime = c.CreateTime,
  81. StaffCount = c.CF_Staff.Count,
  82. StudentCount = c.CF_Student.Count
  83. };
  84. return query.Distinct();
  85. }
  86. //2.0 查询同行
  87. public List<CF_Staff> GetEvaluationByStaff(Guid? educationMissionClassID, List<CF_Staff> StaffList)
  88. {
  89. var staffIDList = StaffList.Select(x => x.UserID).ToList();
  90. var q = (
  91. from staff in ((
  92. from missionClass in EducationMissionClassRepository.GetList(x => x.EducationMissionClassID == educationMissionClassID)
  93. join mission in EducationMissionRepository.Entities on missionClass.EducationMissionID equals mission.EducationMissionID
  94. join staff in StaffRepository.Entities on mission.DepartmentID equals staff.DepartmentID
  95. where !staffIDList.Contains(staff.UserID)
  96. select staff
  97. )
  98. .Concat(
  99. from missionClass in EducationMissionClassRepository.GetList(x => x.EducationMissionClassID == educationMissionClassID)
  100. join mission in EducationMissionRepository.Entities on missionClass.EducationMissionID equals mission.EducationMissionID
  101. join otherMission in EducationMissionRepository.Entities on mission.SchoolyearID equals otherMission.SchoolyearID
  102. join otherClass in EducationMissionClassRepository.Entities on
  103. new { EducationMissionID = (Guid?)otherMission.EducationMissionID, missionClass.CoursematerialID }
  104. equals new { otherClass.EducationMissionID, otherClass.CoursematerialID }
  105. join otherTeacher in MissionClassTeacherRepository.Entities on otherClass.EducationMissionClassID equals otherTeacher.MissionClassID
  106. join staff in StaffRepository.Entities on otherTeacher.UserID equals staff.UserID
  107. where !staffIDList.Contains(staff.UserID)
  108. select staff
  109. ))
  110. group staff by staff.UserID into g
  111. select g.FirstOrDefault()
  112. ).ToList();
  113. return q.ToList();
  114. }
  115. //3.0 查询学生
  116. public List<CF_Student> GetEvaluationByStudent(Guid? educationMissionClassID)
  117. {
  118. var query = from a in EducationSchedulingClassRepository.GetList(x => x.EducationMissionClassID == educationMissionClassID)
  119. from c in a.CF_Student
  120. join b in UserRepository.Entities
  121. on c.UserID equals b.UserID
  122. select new EducationMissionClassStudentView
  123. {
  124. UserID = b.UserID,
  125. LoginID = b.LoginID,
  126. Name = b.Name
  127. };
  128. var user = query.Select(x => x.UserID);
  129. var studentList = StudentRepository.GetList(x => user.Contains(x.UserID)).ToList();
  130. return studentList;
  131. }
  132. //4.0 学生明細信息
  133. public IQueryable<EvaluationSettingDetailView> GetEvaluationSettingStudentDetailQuery(Guid? evaluationSettingID)
  134. {
  135. var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  136. bool isStudent = curUser.IsStudent;//获取当前用户是否是学生
  137. var evaluationSettingQuery = EvaluationSettingRepository.GetList(x => x.OpenStatus == (int)CF_YesOrNoStatus.Yes);
  138. Guid? typeID = evaluationTypeRepository.Entities.Where(w => w.IsStudent == true).FirstOrDefault().EvaluationTypeID;
  139. EM_EvaluationSetting evaluationSettingEntity = EvaluationSettingRepository.Entities.Where(x => x.EvaluationSettingID == evaluationSettingID).FirstOrDefault();
  140. //var tableEntity = EvaluationTableRepository.Entities.Where(x => x.IsEnabled == true && x.TypeID == typeID && x.IntType == teachingModeID);
  141. var courseQuery = EducationMissionClassRepository.Entities.Where(x => x.EducationMissionClassID == evaluationSettingEntity.EducationMissionClassID)
  142. .Select(s => new
  143. {
  144. TeachingModeID = s.TeachingModeID == null ? (int)EM_EvaluationTableType.Theory : s.TeachingModeID,
  145. s.EducationMissionClassID,
  146. s.EM_EducationMission.CF_Schoolyear,
  147. s.EM_EducationMission.CF_Department,
  148. s.EM_Coursematerial
  149. });
  150. EM_EvaluationTable tableEntity = EvaluationTableRepository.Entities.Where(x => x.IsEnabled == true && x.EvaluationTypeID == typeID).FirstOrDefault();
  151. //var TypeEntity = evaluationTypeRepository.Entities.Where(x => x.Name == "学生评" && x.IsStudent == true).FirstOrDefault();
  152. var query = from c in EvaluationSettingRepository.GetList(x => x.EvaluationSettingID == evaluationSettingID)
  153. join d in DictionaryDAL.GetDictionaryItemQuery(typeof(CF_YesOrNoStatus).Name) on c.OpenStatus equals d.Value
  154. join course in courseQuery on c.EducationMissionClassID equals course.EducationMissionClassID
  155. from user in c.CF_Student
  156. from f in EvaluationTableRepository.Entities.Where(x => x.IsEnabled == true
  157. && x.EvaluationTypeID == typeID
  158. && x.EM_EvaluationIntType.EM_EvaluationTeachingMode.Select(w => w.TeachingModeID).Contains(course.TeachingModeID)).DefaultIfEmpty()
  159. select new EvaluationSettingDetailView
  160. {
  161. EvaluationTypeName = "学生评",
  162. EvaluationTableName = f.Name,
  163. EducationMissionClassName = user.CF_Classmajor.Name,
  164. SchoolyearCode = course.CF_Schoolyear.Code,
  165. CourseCode = course.EM_Coursematerial.CourseCode,
  166. CourseName = course.EM_Coursematerial.CourseName,
  167. UserName = user.Sys_User.Name,
  168. UserID = user.Sys_User.UserID,
  169. LoginID = user.Sys_User.LoginID,
  170. Sys_User = c.EM_EducationMissionClass.EM_MissionClassTeacher.Select(s => s.CF_Staff.Sys_User)
  171. };
  172. return query;
  173. }
  174. //5.0 教职工明細信息
  175. public IQueryable<EvaluationSettingDetailView> GetEvaluationSettingStaffDetailQuery(Guid? evaluationSettingID)
  176. {
  177. var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  178. bool isStudent = curUser.IsStudent;//获取当前用户是否是学生
  179. Guid? typeID = evaluationTypeRepository.Entities.Where(w => w.IsStudent == false && w.IsStudent == true).FirstOrDefault().EvaluationTypeID;
  180. var courseQuery = EducationMissionClassRepository.Entities
  181. .Select(s => new
  182. {
  183. TeachingModeID = s.TeachingModeID == null ? (int)CF_TeachingMode.Theory : s.TeachingModeID,
  184. s.EducationMissionClassID,
  185. s.EM_EducationMission.CF_Schoolyear,
  186. s.EM_EducationMission.CF_Department,
  187. s.EM_Coursematerial
  188. });
  189. // var TypeEntity = evaluationTypeRepository.Entities.Where(x => x.Name == "同行评").FirstOrDefault();
  190. var query = from c in EvaluationSettingRepository.GetList(x => x.EvaluationSettingID == evaluationSettingID)
  191. join d in DictionaryDAL.GetDictionaryItemQuery(typeof(CF_YesOrNoStatus).Name) on c.OpenStatus equals d.Value
  192. join course in courseQuery on c.EducationMissionClassID equals course.EducationMissionClassID
  193. from user in c.CF_Staff
  194. from f in EvaluationTableRepository.Entities.Where(x => x.IsEnabled == true
  195. && x.EvaluationTypeID == typeID
  196. && x.EM_EvaluationIntType.EM_EvaluationTeachingMode.Select(w => w.TeachingModeID).Contains(course.TeachingModeID)).DefaultIfEmpty()
  197. select new EvaluationSettingDetailView
  198. {
  199. DepartmentName = user.CF_Department.Name,
  200. EvaluationTypeName = "同行评",
  201. EvaluationTableName = f.Name,
  202. UserID = user.Sys_User.UserID,
  203. EducationMissionClassName = c.EM_EducationMissionClass.Name,
  204. SchoolyearCode = course.CF_Schoolyear.Code,
  205. CourseCode = course.EM_Coursematerial.CourseCode,
  206. CourseName = course.EM_Coursematerial.CourseName,
  207. Name = user.Sys_User.Name,
  208. StaffCode = user.Sys_User.LoginID,
  209. Sys_User = c.EM_EducationMissionClass.EM_MissionClassTeacher.Select(s => s.CF_Staff.Sys_User)
  210. };
  211. return query;
  212. }
  213. //6.0 查询 教学任务班对应的评价表
  214. public IList<EvaluationSettingView> GetEvaluationTableQuery(IList<EvaluationSettingView> educationMissionLsit, bool isStudt)
  215. {
  216. var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  217. bool isStudent = curUser.IsStudent;//获取当前用户是否是学生
  218. Guid? typeID = isStudent == true ? evaluationTypeRepository.Entities.Where(w => w.IsStudent == true).FirstOrDefault().EvaluationTypeID : evaluationTypeRepository.Entities.Where(w => w.IsStudent == false && w.IsStudent == true).FirstOrDefault().EvaluationTypeID;
  219. var educationMissionIDs = educationMissionLsit.Select(x => x.EducationMissionClassID);
  220. //获取已提交的教学任务班
  221. var courseQuery = EducationMissionClassRepository.Entities.Where(x => educationMissionIDs.Contains(x.EducationMissionClassID) && x.RecordStatus == (int)CF_ApprovalStatus.Submitted)
  222. .Select(s => new
  223. {
  224. s.EducationMissionClassID,
  225. s.EM_Coursematerial,
  226. TeachingModeID = s.TeachingModeID == null ? (int)EM_EvaluationTableType.Theory : s.TeachingModeID
  227. });
  228. var querytable = EvaluationTableRepository.GetList(x => x.IsEnabled == true && x.EvaluationTypeID == typeID);
  229. var query = from c in courseQuery
  230. //join aa in EvaluationTableRepository.GetList(x => x.IsEnabled == true) on c.TeachingModeID equals aa.IntType
  231. join ent in EvaluationSettingRepository.Entities on c.EducationMissionClassID equals ent.EducationMissionClassID
  232. into tent
  233. from ctent in tent.DefaultIfEmpty()
  234. where ctent == null
  235. group new { c } by new { c.EducationMissionClassID, CourseCode = c.EM_Coursematerial.CourseCode } into g
  236. select new EvaluationSettingView
  237. {
  238. EducationMissionClassID = g.Key.EducationMissionClassID,
  239. //EvaluationTableTypeID = g.Key.IntType,//参评类型为空、默认理论
  240. EvaluationTableID = Guid.Empty,
  241. IsStudent = isStudent == true ? (int)CF_YesOrNoStatus.Yes : (int)CF_YesOrNoStatus.No //是否适用学生
  242. ,
  243. EvaluationTypeID = Guid.Empty,
  244. CourseCode = g.Key.CourseCode
  245. };
  246. return query.ToList();
  247. }
  248. //7.0 查询 该学年学期下对应的教学任务班
  249. public IQueryable<EducationMissionClassView> GetCreateInventoryQuery(Guid schoolyearID)
  250. {
  251. List<int> intTypeList = new List<int>(); //生成评价表中已启用、并且存在的授课方式
  252. var evaluationTabList = EvaluationTableRepository.GetList(x => x.IsEnabled == true, (w => w.EM_EvaluationIntType))
  253. .Select(s => new
  254. {
  255. s.EM_EvaluationIntType.EvaluationIntTypeID
  256. });
  257. var IntTypeIDList = evaluationTabList.Select(w => w.EvaluationIntTypeID).ToList();
  258. EvaluationTeachingModeRepository.GetList(x => IntTypeIDList.Contains((Guid)x.EvaluationIntTypeID))
  259. .Select(w => w.TeachingModeID).ToList().ForEach(p => { intTypeList.Add(p.Value); });
  260. Expression<Func<EM_EducationMissionClass, bool>> exp = x => x.EM_EducationMission.SchoolyearID == schoolyearID
  261. && x.RecordStatus != (int)EM_EducationMissionClassStatus.NotSubmitted
  262. && intTypeList.Contains(x.TeachingModeID ?? (int)CF_TeachingMode.Theory);
  263. //TODO:调整评价生成、提取教学任务班中排除未提交状态的数据。
  264. var query = from a in EducationMissionClassRepository.GetList(exp)
  265. from SchedulingClass in a.EM_EducationSchedulingClass.DefaultIfEmpty()
  266. join b in EvaluationSettingRepository.Entities on a.EducationMissionClassID equals b.EducationMissionClassID
  267. into tb
  268. from ctb in tb.DefaultIfEmpty()
  269. where ctb == null //如果不存在、那么生成
  270. select new EducationMissionClassView
  271. {
  272. EducationMissionID = a.EducationMissionID,
  273. EducationMissionClassID = a.EducationMissionClassID,
  274. MainScheduleClassID = a.MainScheduleClassID,
  275. TeachingModeID = a.TeachingModeID == null ? (int)CF_TeachingMode.Theory : (int)a.TeachingModeID,//如果授课方式为空、那么默认理论
  276. SchoolyearID = a.EM_EducationMission.SchoolyearID,
  277. SchoolyearCode = a.EM_EducationMission.CF_Schoolyear.Code,
  278. Name = a.Name,
  279. CoursematerialID = a.EM_Coursematerial.CoursematerialID,
  280. CourseCode = a.EM_Coursematerial.CourseCode,
  281. CourseName = a.EM_Coursematerial.CourseName,
  282. DepartmentID = a.EM_EducationMission.DepartmentID,
  283. ClassroomID = a.ClassroomID,
  284. ClassroomTypeID = a.ClassroomTypeID,
  285. ApprovalStatus = a.RecordStatus,
  286. CreateTime = a.CreateTime,
  287. CreateUserID = a.CreateUserID,
  288. Remark = a.Remark,
  289. CF_Student = SchedulingClass.CF_Student,
  290. CF_Staff = a.EM_MissionClassTeacher.Select(x => x.CF_Staff)
  291. };
  292. return query;
  293. }
  294. #region 8.0 教学任务班ID、加载评价表
  295. public IList<EvaluationTableView> GetTableByEducationMissionClassID(Guid? educationMissionClassID)
  296. {
  297. var courseQuery = EducationMissionClassRepository.Entities.Where(x => x.EducationMissionClassID == educationMissionClassID && x.RecordStatus == (int)CF_ApprovalStatus.Submitted)
  298. .Select(s => new
  299. {
  300. s.EducationMissionClassID,
  301. TeachingModeID = s.TeachingModeID == null ? (int)EM_EvaluationTableType.Theory : s.TeachingModeID
  302. });
  303. var query = from a in courseQuery
  304. join aa in EvaluationTableRepository.GetList(x => x.IsEnabled == true) on a.TeachingModeID equals aa.RecordStatus
  305. join bb in evaluationTypeRepository.Entities on aa.EvaluationTypeID equals bb.EvaluationTypeID
  306. select new EvaluationSettingView
  307. {
  308. EvaluationTableID = aa.EvaluationTableID
  309. };
  310. var tableList = EvaluationTableDAL.GetEvaluationTableQueryable(w => query.Select(x => x.EvaluationTableID).Contains(w.EvaluationTableID));//获取评价表
  311. return tableList.ToList();
  312. }
  313. #endregion
  314. #region 9.0加载选取教师|学生信息
  315. //5.0 教职工明細信息
  316. public IQueryable<EvaluationSettingDetailView> GetEvaluationSettingStaffDetailList(Guid? evaluationSettingID)
  317. {
  318. var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  319. EM_EvaluationSetting evaluationSettingEntity = EvaluationSettingRepository.Entities.Where(x => x.EvaluationSettingID == evaluationSettingID).FirstOrDefault();
  320. var staffQuery = staffDAL.Value.GetStaffViewQueryable(x => x.CF_Department.DepartmentID == EducationMissionClassRepository.Entities.Where(w => w.EducationMissionClassID == evaluationSettingEntity.EducationMissionClassID).FirstOrDefault().EM_EducationMission.CF_Department.DepartmentID);//获取所有教师
  321. bool isStudent = curUser.IsStudent;//获取当前用户是否是学生
  322. Guid? typeID = evaluationTypeRepository.Entities.Where(w => w.IsStudent == false && w.IsStudent == true).FirstOrDefault().EvaluationTypeID;
  323. var courseQuery = from eds in EducationMissionClassRepository.Entities
  324. from tech in eds.EM_MissionClassTeacher
  325. join staff in staffQuery on eds.EM_EducationMission.CF_Department.DepartmentID equals staff.DepartmentID
  326. into user
  327. from staffuser in user.DefaultIfEmpty()
  328. where staffuser.UserID != tech.CF_Staff.Sys_User.UserID
  329. select new
  330. {
  331. TeachingModeID = eds.TeachingModeID == null ? (int)EM_EvaluationTableType.Theory : eds.TeachingModeID,
  332. eds.EducationMissionClassID,
  333. eds.EM_EducationMission.CF_Schoolyear,
  334. eds.EM_EducationMission.CF_Department,
  335. eds.EM_Coursematerial,
  336. eds.EM_MissionClassTeacher,
  337. Teacher = staffuser
  338. };
  339. // var TypeEntity = evaluationTypeRepository.Entities.Where(x => x.Name == "同行评").FirstOrDefault();
  340. var query = from c in EvaluationSettingRepository.GetList(x => x.EvaluationSettingID == evaluationSettingID)
  341. join d in DictionaryDAL.GetDictionaryItemQuery(typeof(CF_YesOrNoStatus).Name) on c.OpenStatus equals d.Value
  342. join course in courseQuery on (Guid)c.EducationMissionClassID equals (Guid)course.EducationMissionClassID
  343. from f in EvaluationTableRepository.Entities.Where(x => x.IsEnabled == true
  344. && x.EvaluationTypeID == typeID
  345. && x.EM_EvaluationIntType.EM_EvaluationTeachingMode.Select(w => w.TeachingModeID).Contains(course.TeachingModeID)).DefaultIfEmpty()
  346. select new EvaluationSettingDetailView
  347. {
  348. DepartmentName = course.CF_Department.Name,
  349. EvaluationTypeName = "同行评",
  350. EvaluationTableName = f.Name,
  351. UserID = course.Teacher.UserID,
  352. EducationMissionClassName = c.EM_EducationMissionClass.Name,
  353. SchoolyearCode = course.CF_Schoolyear.Code,
  354. CourseCode = course.EM_Coursematerial.CourseCode,
  355. CourseName = course.EM_Coursematerial.CourseName,
  356. Name = course.Teacher.Name,
  357. StaffCode = course.Teacher.StaffCode,
  358. Sys_User = c.EM_EducationMissionClass.EM_MissionClassTeacher.Select(s => s.CF_Staff.Sys_User)
  359. };
  360. return query;
  361. }
  362. //4.0 学生明細信息
  363. public IQueryable<EvaluationSettingDetailView> GetEvaluationSettingStudentDetailList(Guid? evaluationSettingID)
  364. {
  365. var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  366. bool isStudent = curUser.IsStudent;//获取当前用户是否是学生
  367. var evaluationSettingQuery = EvaluationSettingRepository.GetList(x => x.OpenStatus == (int)CF_YesOrNoStatus.Yes);
  368. Guid? typeID = evaluationTypeRepository.Entities.Where(w => w.IsStudent == true).FirstOrDefault().EvaluationTypeID;
  369. EM_EvaluationSetting evaluationSettingEntity = EvaluationSettingRepository.Entities.Where(x => x.EvaluationSettingID == evaluationSettingID).FirstOrDefault();
  370. //var tableEntity = EvaluationTableRepository.Entities.Where(x => x.IsEnabled == true && x.TypeID == typeID && x.IntType == teachingModeID);
  371. var courseQuery = EducationMissionClassRepository.Entities.Where(x => x.EducationMissionClassID == evaluationSettingEntity.EducationMissionClassID)
  372. .Select(s => new
  373. {
  374. TeachingModeID = s.TeachingModeID == null ? (int)EM_EvaluationTableType.Theory : s.TeachingModeID,
  375. s.EducationMissionClassID,
  376. s.EM_EducationMission.CF_Schoolyear,
  377. s.EM_EducationMission.CF_Department,
  378. s.EM_Coursematerial,
  379. s.EM_EducationSchedulingClass
  380. });
  381. EM_EvaluationTable tableEntity = EvaluationTableRepository.Entities.Where(x => x.IsEnabled == true && x.EvaluationTypeID == typeID).FirstOrDefault();
  382. //var TypeEntity = evaluationTypeRepository.Entities.Where(x => x.Name == "学生评" && x.IsStudent == true).FirstOrDefault();
  383. var query = from c in EvaluationSettingRepository.GetList(x => x.EvaluationSettingID == evaluationSettingID)
  384. join d in DictionaryDAL.GetDictionaryItemQuery(typeof(CF_YesOrNoStatus).Name) on c.OpenStatus equals d.Value
  385. join course in courseQuery on c.EducationMissionClassID equals course.EducationMissionClassID
  386. from edshed in course.EM_EducationSchedulingClass
  387. from user in edshed.CF_Student
  388. from f in EvaluationTableRepository.Entities.Where(x => x.IsEnabled == true
  389. && x.EvaluationTypeID == typeID
  390. && x.EM_EvaluationIntType.EM_EvaluationTeachingMode.Select(w => w.TeachingModeID).Contains(course.TeachingModeID)).DefaultIfEmpty()
  391. select new EvaluationSettingDetailView
  392. {
  393. EvaluationTypeName = "学生评",
  394. EvaluationTableName = f.Name,
  395. EducationMissionClassName = user.CF_Classmajor.Name,
  396. SchoolyearCode = course.CF_Schoolyear.Code,
  397. CourseCode = course.EM_Coursematerial.CourseCode,
  398. CourseName = course.EM_Coursematerial.CourseName,
  399. UserName = user.Sys_User.Name,
  400. UserID = user.Sys_User.UserID,
  401. LoginID = user.Sys_User.LoginID,
  402. Sys_User = c.EM_EducationMissionClass.EM_MissionClassTeacher.Select(s => s.CF_Staff.Sys_User)
  403. };
  404. return query;
  405. }
  406. //这个部门对于的所有教师
  407. public List<EvaluationSettingMissionClassTeacherView> GetMissionClassTeacherViewQueryable(Expression<Func<EM_MissionClassTeacher, bool>> exp)
  408. {
  409. var query = from emc in MissionClassTeacherRepository.GetList(exp)
  410. select new EvaluationSettingMissionClassTeacherView
  411. {
  412. EducationMissionClassID = emc.MissionClassID,
  413. UserID = emc.CF_Staff.UserID,
  414. Name = emc.CF_Staff.Sys_User.Name,
  415. LoginID = emc.CF_Staff.Sys_User.LoginID
  416. };
  417. return query.ToList();
  418. }
  419. #endregion
  420. public IQueryable<EducationMissionClassView> GetEducationMissionClassQuery(Guid schoolyearID)
  421. {
  422. List<int> intTypeList = new List<int>(); //生成评价表中已启用、并且存在的授课方式
  423. var evaluationTabList = EvaluationTableRepository.GetList(x => x.IsEnabled == true, (w => w.EM_EvaluationIntType))
  424. .Select(s => new
  425. {
  426. s.EM_EvaluationIntType.EvaluationIntTypeID
  427. });
  428. var IntTypeIDList = evaluationTabList.Select(w => w.EvaluationIntTypeID).ToList();
  429. EvaluationTeachingModeRepository.GetList(x => IntTypeIDList.Contains((Guid)x.EvaluationIntTypeID))
  430. .Select(w => w.TeachingModeID).ToList().ForEach(p => { intTypeList.Add(p.Value); });
  431. Expression<Func<EM_EducationMissionClass, bool>> exp = x => x.EM_EducationMission.SchoolyearID == schoolyearID
  432. && intTypeList.Contains(x.TeachingModeID ?? (int)CF_TeachingMode.Theory);
  433. //TODO:调整评价生成、提取教学任务班中排除未提交状态的数据。
  434. var query = from a in EducationMissionClassRepository.GetList(exp)
  435. from SchedulingClass in a.EM_EducationSchedulingClass.DefaultIfEmpty()
  436. join b in EvaluationSettingRepository.Entities on a.EducationMissionClassID equals b.EducationMissionClassID
  437. into tb
  438. from ctb in tb.DefaultIfEmpty()
  439. where ctb == null //如果不存在、那么生成
  440. select new EducationMissionClassView
  441. {
  442. EducationMissionID = a.EducationMissionID,
  443. EducationMissionClassID = a.EducationMissionClassID,
  444. MainScheduleClassID = a.MainScheduleClassID,
  445. TeachingModeID = a.TeachingModeID == null ? (int)CF_TeachingMode.Theory : (int)a.TeachingModeID,//如果授课方式为空、那么默认理论
  446. SchoolyearID = a.EM_EducationMission.SchoolyearID,
  447. SchoolyearCode = a.EM_EducationMission.CF_Schoolyear.Code,
  448. Name = a.Name,
  449. CoursematerialID = a.EM_Coursematerial.CoursematerialID,
  450. CourseCode = a.EM_Coursematerial.CourseCode,
  451. CourseName = a.EM_Coursematerial.CourseName,
  452. DepartmentID = a.EM_EducationMission.DepartmentID,
  453. ClassroomID = a.ClassroomID,
  454. ClassroomTypeID = a.ClassroomTypeID,
  455. ApprovalStatus = a.RecordStatus,
  456. CreateTime = a.CreateTime,
  457. CreateUserID = a.CreateUserID,
  458. Remark = a.Remark,
  459. CF_Student = SchedulingClass.CF_Student,
  460. CF_Staff = a.EM_MissionClassTeacher.Select(x => x.CF_Staff)
  461. };
  462. return query;
  463. }
  464. }
  465. }