EvaluationTeacherScoreDAL.cs 41 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599
  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.Common.Students;
  16. namespace EMIS.DataLogic.Common.EvaluationManage
  17. {
  18. public class EvaluationTeacherScoreDAL
  19. {
  20. #region --0.0定义--
  21. public StaffRepository StaffPepository { get; set; }
  22. public UserRepository UserRepository { get; set; }
  23. public MissionClassTeacherRepository MissionClassTeacherRepository { get; set; }
  24. public EducationMissionClassRepository EducationMissionClassRepository { get; set; }
  25. public EvaluationEnter_EM_EvaluationProjectRepository EvaluationEnter_EM_EvaluationProjectRepository { get; set; }
  26. public EvaluationEnterRepository EvaluationEnterRepository { get; set; }
  27. public EvaluationProjectRepository EvaluationProjectRepository { get; set; }
  28. public EvaluationTargetRepository EvaluationTargetRepository { get; set; }
  29. public EvaluationTableRepository EvaluationTableRepository { get; set; }
  30. public VWTotalScore_StudentRankRepository viewStudentRepository { get; set; }
  31. public VWTotalScore_TeacherRankRepository viewTeacherRepository { get; set; }
  32. #endregion
  33. #region 之前的尝试,貌似不太理想
  34. //var lastEvaluation = (from ee in EvaluationEnter_EM_EvaluationProjectRepository.GetList(x => x.EM_EvaluationEnter.StudentUserID != null)
  35. // group ee by new { ee.EM_EvaluationEnter.EducationMissionClassID } into g
  36. // join mmee in EvaluationEnter_EM_EvaluationProjectRepository.GetList(x => x.EM_EvaluationEnter.StudentUserID != null)
  37. // on new { g.Key.EducationMissionClassID, ModifyTime = g.Max(x => x.ModifyTime) } equals new { mmee.EM_EvaluationEnter.EducationMissionClassID, mmee.ModifyTime }
  38. // group mmee by new { mmee.EM_EvaluationEnter.EducationMissionClassID, mmee.ModifyTime } into g
  39. // join miee in EvaluationEnter_EM_EvaluationProjectRepository.GetList(x => x.EM_EvaluationEnter.StudentUserID != null)
  40. // on g.Max(x => x.ID.ToString()) equals miee.ID.ToString()
  41. // select miee
  42. // );
  43. // var sql = (from us in UserRepository.Entities
  44. // join mctr in MissionClassTeacherRepository.Entities
  45. // on us.UserID equals mctr.UserID
  46. // join emcr in EducationMissionClassRepository.Entities
  47. // on mctr.MissionClassID equals emcr.EducationMissionClassID
  48. // join eer in lastEvaluation
  49. // on emcr.EducationMissionClassID equals eer.EM_EvaluationEnter.EducationMissionClassID
  50. // group eer by new {
  51. // us.UserID,
  52. // us.LoginID,
  53. // UserName = us.Name,
  54. // emcr.EducationMissionClassID,
  55. // ClassName = emcr.Name,
  56. // emcr.EM_EducationMission.CF_Department.CollegeID,
  57. // CollegeName = emcr.EM_EducationMission.CF_Department.CF_College.Name,
  58. // emcr.EM_EducationMission.DepartmentID,
  59. // DepartmentName = emcr.EM_EducationMission.CF_Department.Name,
  60. // emcr.CoursematerialID,
  61. // emcr.EM_Coursematerial.CourseName
  62. // } into na
  63. // select new
  64. // {
  65. // UserID = na.Key.UserID,
  66. // TeacherNo = na.Key.LoginID,
  67. // TeacherName = na.Key.UserName,
  68. // EducationMissionClassID = na.Key.EducationMissionClassID,
  69. // EducationMissionClassName = na.Key.ClassName,
  70. // CollegeID = na.Key.CollegeID,
  71. // CollegeName = na.Key.CollegeName,
  72. // DepartmentID = na.Key.DepartmentID,
  73. // DepartmentName = na.Key.DepartmentName,
  74. // CourseID = na.Key.CoursematerialID,
  75. // CourseName = na.Key.CourseName,
  76. // Count = na.Count(),
  77. // TotalScore = na.GroupBy(x => new { x.EM_EvaluationProject.EM_EvaluationTarget.TableID, x.EM_EvaluationProject.EM_EvaluationTarget.EM_EvaluationTable.Weight })
  78. // .Select(x => x.Key.Weight * (x.GroupBy(y => new { y.EM_EvaluationProject.TargetID, y.EM_EvaluationProject.EM_EvaluationTarget.Weight })
  79. // .Select(z => z.Key.Weight * z.Sum(w => (w.EvaluationScore / 100 * w.EM_EvaluationProject.Weight) / z.Key.Weight))
  80. // .Sum()))
  81. // .Sum()
  82. // } into gg
  83. // select new
  84. // {
  85. // TeacherNo = gg.TeacherNo,
  86. // TeacherName = gg.TeacherName,
  87. // EducationMissionClassID = gg.EducationMissionClassID,
  88. // EducationMissionClassName = gg.EducationMissionClassName,
  89. // CollegeID = gg.CollegeID,
  90. // CollegeName = gg.CollegeName,
  91. // DepartmentID = gg.DepartmentID,
  92. // DepartmentName = gg.DepartmentName,
  93. // CourseID = gg.CourseID,
  94. // CourseName = gg.CourseName,
  95. // CommentCount = gg.Count,
  96. // Average = Math.Round((decimal)gg.TotalScore / gg.Count, 2)
  97. // }
  98. // );
  99. // var query = from g in sql
  100. // select new EvaluationTeacherScoreView
  101. // {
  102. // TeacherNo = g.TeacherNo,
  103. // TeacherName = g.TeacherName,
  104. // EducationMissionClassID = g.EducationMissionClassID,
  105. // EducationMissionClassName = g.EducationMissionClassName,
  106. // CollegeID = g.CollegeID,
  107. // CollegeName = g.CollegeName,
  108. // DepartmentID = g.DepartmentID,
  109. // DepartmentName = g.DepartmentName,
  110. // CourseID = g.CourseID,
  111. // CourseName = g.CourseName,
  112. // CommentCount = g.CommentCount,
  113. // Average = g.Average,
  114. // //DepartmentRanking = (from o in sql
  115. // // where o.Average > g.Average
  116. // // where o.DepartmentID == g.DepartmentID
  117. // // select o).Count() + 1,
  118. // //CollegeRanking = (from o in sql
  119. // // where o.Average > g.Average
  120. // // where o.CollegeID == g.CollegeID
  121. // // select o).Count() + 1
  122. // };
  123. // return query;
  124. #endregion
  125. #region 第二次尝试,查询速度不理想
  126. // var sql = (
  127. // from mct in MissionClassTeacherRepository.Entities
  128. // join ee in (
  129. // from etarget in (
  130. // from ee in
  131. // (
  132. // from ee in EvaluationEnterRepository.GetList(expEe)
  133. // join mee in
  134. // (
  135. // from ee in EvaluationEnterRepository.GetList(expEe)
  136. // join mee in
  137. // (
  138. // from ee in EvaluationEnterRepository.GetList(expEe)
  139. // group ee by new { ee.EducationMissionClassID, ee.StaffUserID, ee.StudentUserID } into g
  140. // select new { g.Key.EducationMissionClassID, g.Key.StaffUserID, g.Key.StudentUserID, ModifyTime = g.Max(x => x.ModifyTime) }
  141. // )
  142. // on new { ee.EducationMissionClassID, ee.StaffUserID, ee.StudentUserID, ee.ModifyTime }
  143. // equals new { mee.EducationMissionClassID, mee.StaffUserID, mee.StudentUserID, mee.ModifyTime }
  144. // group ee by new { mee.EducationMissionClassID, mee.StaffUserID, mee.StudentUserID, mee.ModifyTime }
  145. // into g
  146. // select new
  147. // {
  148. // g.Key.EducationMissionClassID,
  149. // g.Key.StaffUserID,
  150. // g.Key.StudentUserID,
  151. // g.Key.ModifyTime,
  152. // EvaluationEnterID = g.Max(x => x.EvaluationEnterID.ToString())
  153. // })
  154. // on ee.EvaluationEnterID.ToString() equals mee.EvaluationEnterID
  155. // join eeep in
  156. // (
  157. // from eeep in EvaluationEnter_EM_EvaluationProjectRepository.Entities
  158. // join ee in EvaluationEnterRepository.GetList(expEe) on eeep.EvaluationEnterID equals ee.EvaluationEnterID
  159. // join meeep in
  160. // (
  161. // from eeep in EvaluationEnter_EM_EvaluationProjectRepository.Entities
  162. // join ee in EvaluationEnterRepository.GetList(expEe) on eeep.EvaluationEnterID equals ee.EvaluationEnterID
  163. // join meeep in
  164. // (
  165. // from eeep in EvaluationEnter_EM_EvaluationProjectRepository.Entities
  166. // join ee in EvaluationEnterRepository.GetList(expEe) on eeep.EvaluationEnterID equals ee.EvaluationEnterID
  167. // group eeep by new { eeep.EvaluationEnterID, eeep.ProjectID } into g
  168. // select new { g.Key.EvaluationEnterID, g.Key.ProjectID, ModifyTime = g.Max(x => x.ModifyTime) }
  169. // ) on new { eeep.EvaluationEnterID, eeep.ProjectID, eeep.ModifyTime }
  170. // equals new { meeep.EvaluationEnterID, meeep.ProjectID, meeep.ModifyTime }
  171. // group eeep by new { eeep.EvaluationEnterID, eeep.ProjectID, eeep.ModifyTime } into g
  172. // select new { g.Key.EvaluationEnterID, g.Key.ProjectID, g.Key.ModifyTime, ID = g.Max(x => x.ID.ToString()) }
  173. // ) on eeep.ID.ToString() equals meeep.ID
  174. // select eeep
  175. // ) on ee.EvaluationEnterID equals eeep.EvaluationEnterID
  176. // select new { EvaluationEnter = ee, eeep.ProjectID, eeep.EvaluationScore })
  177. // join ep in EvaluationProjectRepository.Entities
  178. // on ee.ProjectID equals ep.ProjectID
  179. // join et in EvaluationTargetRepository.Entities
  180. // on ep.TargetID equals et.TargetID
  181. // group new { ee, ep, et } by new {
  182. // TableTypeName=ee.EvaluationEnter.EM_EvaluationTable.EM_EvaluationType.Name,IntTypeName=ee.EvaluationEnter.EM_EvaluationTable.EM_EvaluationIntType.Name,
  183. // ee.EvaluationEnter.EducationMissionClassID, ee.EvaluationEnter.StaffUserID, ee.EvaluationEnter.StudentUserID, ep.TargetID, et.TableID, et.Weight }
  184. // into g
  185. // select new
  186. // {
  187. // g.Key.TableTypeName,
  188. // g.Key.IntTypeName,
  189. // g.Key.EducationMissionClassID,
  190. // g.Key.StaffUserID,
  191. // g.Key.StudentUserID,
  192. // g.Key.TargetID,
  193. // g.Key.TableID,
  194. // g.Key.Weight,
  195. // TargetScore = g.Sum(x => x.ee.EvaluationScore / 100 * x.ep.Weight) / g.Sum(x => x.ep.Weight) * g.Key.Weight
  196. // }
  197. // )
  198. // join etable in EvaluationTableRepository.GetList(expTable) on etarget.TableID equals etable.TableID
  199. // group etarget by new { etarget.TableTypeName, etarget.IntTypeName, etarget.EducationMissionClassID, etarget.StaffUserID, etarget.StudentUserID, etarget.TableID, etable.Weight }
  200. // into g
  201. // select new { g.Key.TableTypeName, g.Key.IntTypeName, g.Key.EducationMissionClassID, g.Key.StaffUserID, g.Key.StudentUserID, g.Key.TableID, TotalScore = g.Sum(x => x.TargetScore) / g.Sum(x => x.Weight) * g.Key.Weight }
  202. // ) on mct.EM_EducationMissionClass.EducationMissionClassID equals ee.EducationMissionClassID
  203. // group ee by new {
  204. // TableTypeName = ee.TableTypeName,
  205. // IntTypeName = ee.IntTypeName,
  206. // TeacherNo = mct.CF_Staff.Sys_User.LoginID,
  207. // TeacherName = mct.CF_Staff.Sys_User.Name,
  208. // EducationMissionClassID = mct.EM_EducationMissionClass.EducationMissionClassID,
  209. // EducationMissionClassName = mct.EM_EducationMissionClass.Name,
  210. // CollegeID = mct.EM_EducationMissionClass.EM_EducationMission.CF_Department.CollegeID,
  211. // CollegeName = mct.EM_EducationMissionClass.EM_EducationMission.CF_Department.CF_College.Name,
  212. // DepartmentID = mct.EM_EducationMissionClass.EM_EducationMission.CF_Department.DepartmentID,
  213. // DepartmentName = mct.EM_EducationMissionClass.EM_EducationMission.CF_Department.Name,
  214. // CourseID = mct.EM_EducationMissionClass.EM_Coursematerial.CoursematerialID,
  215. // CourseName = mct.EM_EducationMissionClass.EM_Coursematerial.CourseName,
  216. // CourseCode = mct.EM_EducationMissionClass.EM_Coursematerial.CourseCode
  217. // } into g
  218. // select new EvaluationTeacherScoreView
  219. // {
  220. // TeacherNo = g.Key.TeacherNo,
  221. // TeacherName = g.Key.TeacherName,
  222. // EducationMissionClassID = g.Key.EducationMissionClassID,
  223. // EducationMissionClassName = g.Key.EducationMissionClassName,
  224. // CollegeID = g.Key.CollegeID,
  225. // CollegeName = g.Key.CollegeName,
  226. // DepartmentID = g.Key.DepartmentID,
  227. // DepartmentName = g.Key.DepartmentName,
  228. // CourseID = g.Key.CourseID,
  229. // CourseName = g.Key.CourseName,
  230. // CourseCode = g.Key.CourseCode,
  231. // EvaluationIntTypeName = g.Key.IntTypeName,
  232. // EvaluationTableTypeName = g.Key.TableTypeName,
  233. // CommentCount = g.Count(),
  234. // Average = Math.Round(g.Average(x => x.TotalScore ?? 0), 2),
  235. // DepartmentRanking = 0,
  236. // CollegeRanking = 0
  237. // }
  238. // );
  239. // var query = (from ee in sql
  240. // select new EvaluationTeacherScoreView
  241. // {
  242. // TeacherNo = ee.TeacherNo,
  243. // TeacherName = ee.TeacherName,
  244. // EducationMissionClassID = ee.EducationMissionClassID,
  245. // EducationMissionClassName = ee.EducationMissionClassName,
  246. // CollegeID = ee.CollegeID,
  247. // CollegeName = ee.CollegeName,
  248. // DepartmentID = ee.DepartmentID,
  249. // DepartmentName = ee.DepartmentName,
  250. // CourseID = ee.CourseID,
  251. // CourseName = ee.CourseName,
  252. // CourseCode = ee.CourseCode,
  253. // EvaluationIntTypeName = ee.EvaluationIntTypeName,
  254. // EvaluationTableTypeName = ee.EvaluationTableTypeName,
  255. // CommentCount = ee.CommentCount,
  256. // Average = ee.Average,
  257. // DepartmentRanking = sql.Where(x => x.Average > ee.Average && x.DepartmentID == ee.DepartmentID).Count() + 1,
  258. // CollegeRanking = sql.Where(x => x.Average > ee.Average && x.CollegeID == ee.CollegeID).Count() + 1
  259. // });
  260. //return query;
  261. #endregion
  262. //1.0查询基本信息
  263. #region 第三次尝试,查询速度不理想
  264. //有了总分字段之后还是查询效率低
  265. //var sql =
  266. // from ee in EvaluationEnterRepository.GetList(expEe)
  267. // join mee in
  268. // (from ee in EvaluationEnterRepository.GetList(expEe)
  269. // join mee in
  270. // (
  271. // from ee in EvaluationEnterRepository.GetList(expEe)
  272. // group ee by new { ee.EducationMissionClassID, ee.StaffUserID, ee.StudentUserID } into g
  273. // select new { g.Key.EducationMissionClassID, g.Key.StaffUserID, g.Key.StudentUserID, ModifyTime = g.Max(x => x.ModifyTime) }
  274. // )
  275. // on new { ee.EducationMissionClassID, ee.StaffUserID, ee.StudentUserID, ee.ModifyTime }
  276. // equals new { mee.EducationMissionClassID, mee.StaffUserID, mee.StudentUserID, mee.ModifyTime }
  277. // group ee by new { mee.EducationMissionClassID, mee.StaffUserID, mee.StudentUserID, mee.ModifyTime }
  278. // into g
  279. // select new
  280. // {
  281. // g.Key.EducationMissionClassID,
  282. // g.Key.StaffUserID,
  283. // g.Key.StudentUserID,
  284. // EvaluationEnterID = g.Max(x => x.EvaluationEnterID.ToString())
  285. // })
  286. // on ee.EvaluationEnterID.ToString() equals mee.EvaluationEnterID
  287. // join mct in MissionClassTeacherRepository.Entities
  288. // on mee.EducationMissionClassID equals mct.EM_EducationMissionClass.EducationMissionClassID
  289. // group ee by new
  290. // {
  291. // TableTypeName = ee.EM_EvaluationTable.EM_EvaluationType.Name,
  292. // IntTypeName = ee.EM_EvaluationTable.EM_EvaluationIntType.Name,
  293. // TeacherNo = mct.CF_Staff.Sys_User.LoginID,
  294. // TeacherName = mct.CF_Staff.Sys_User.Name,
  295. // EducationMissionClassID = mct.EM_EducationMissionClass.EducationMissionClassID,
  296. // EducationMissionClassName = mct.EM_EducationMissionClass.Name,
  297. // CollegeID = mct.EM_EducationMissionClass.EM_EducationMission.CF_Department.CollegeID,
  298. // CollegeName = mct.EM_EducationMissionClass.EM_EducationMission.CF_Department.CF_College.Name,
  299. // DepartmentID = mct.EM_EducationMissionClass.EM_EducationMission.CF_Department.DepartmentID,
  300. // DepartmentName = mct.EM_EducationMissionClass.EM_EducationMission.CF_Department.Name,
  301. // CourseID = mct.EM_EducationMissionClass.EM_Coursematerial.CoursematerialID,
  302. // CourseName = mct.EM_EducationMissionClass.EM_Coursematerial.CourseName,
  303. // CourseCode = mct.EM_EducationMissionClass.EM_Coursematerial.CourseCode
  304. // } into g
  305. // select new EvaluationTeacherScoreView
  306. // {
  307. // TeacherNo = g.Key.TeacherNo,
  308. // TeacherName = g.Key.TeacherName,
  309. // EducationMissionClassID = g.Key.EducationMissionClassID,
  310. // EducationMissionClassName = g.Key.EducationMissionClassName,
  311. // CollegeID = g.Key.CollegeID,
  312. // CollegeName = g.Key.CollegeName,
  313. // DepartmentID = g.Key.DepartmentID,
  314. // DepartmentName = g.Key.DepartmentName,
  315. // CourseID = g.Key.CourseID,
  316. // CourseName = g.Key.CourseName,
  317. // CourseCode = g.Key.CourseCode,
  318. // EvaluationIntTypeName = g.Key.IntTypeName,
  319. // EvaluationTableTypeName = g.Key.TableTypeName,
  320. // CommentCount = g.Count(),
  321. // Average = Math.Round(g.Average(x => x.TotalScore ?? 0), 2),
  322. // DepartmentRanking = 0,
  323. // CollegeRanking = 0
  324. // };
  325. //var query = (from ee in sql
  326. // select new EvaluationTeacherScoreView
  327. // {
  328. // TeacherNo = ee.TeacherNo,
  329. // TeacherName = ee.TeacherName,
  330. // EducationMissionClassID = ee.EducationMissionClassID,
  331. // EducationMissionClassName = ee.EducationMissionClassName,
  332. // CollegeID = ee.CollegeID,
  333. // CollegeName = ee.CollegeName,
  334. // DepartmentID = ee.DepartmentID,
  335. // DepartmentName = ee.DepartmentName,
  336. // CourseID = ee.CourseID,
  337. // CourseName = ee.CourseName,
  338. // CourseCode = ee.CourseCode,
  339. // EvaluationIntTypeName = ee.EvaluationIntTypeName,
  340. // EvaluationTableTypeName = ee.EvaluationTableTypeName,
  341. // CommentCount = ee.CommentCount,
  342. // Average = (decimal)(ee.Average == null ? 0 : ee.Average),
  343. // DepartmentRanking = sql.Where(x => x.Average > ee.Average && x.DepartmentID == ee.DepartmentID).Count() + 1,
  344. // CollegeRanking = sql.Where(x => x.Average > ee.Average && x.CollegeID == ee.CollegeID).Count() + 1
  345. // });
  346. #endregion
  347. public IQueryable<EvaluationTeacherScoreView> GetEvaluationTeacherScoreQuery(Expression<Func<EM_MissionClassTeacher, bool>> expmct, Expression<Func<EM_EvaluationTable, bool>> expTable, Guid? schoolyaerID)
  348. {
  349. var stuquery = from v in viewStudentRepository.Entities
  350. join tbl in EvaluationTableRepository.GetList(expTable)
  351. on v.tableID equals tbl.EvaluationTableID
  352. join mct in MissionClassTeacherRepository.GetList(expmct)
  353. on v.MissionClassTeacherID equals mct.MissionClassTeacherID
  354. select new EvaluationTeacherScoreView
  355. {
  356. UserID = mct.UserID.Value,
  357. TeacherNo = mct.CF_Staff.Sys_User.LoginID,
  358. TeacherName = mct.CF_Staff.Sys_User.Name,
  359. EducationMissionClassID = v.EducationMissionClassID,
  360. EducationMissionClassName = mct.EM_EducationMissionClass.Name,
  361. CollegeID = v.CollegeID,
  362. CollegeName = mct.EM_EducationMissionClass.EM_EducationMission.CF_Department.CF_College.Name,
  363. DepartmentID = v.DepartmentID,
  364. DepartmentName = mct.EM_EducationMissionClass.EM_EducationMission.CF_Department.Name,
  365. CourseID = mct.EM_EducationMissionClass.EM_Coursematerial.CoursematerialID,
  366. CourseName = mct.EM_EducationMissionClass.EM_Coursematerial.CourseName,
  367. CourseCode = mct.EM_EducationMissionClass.EM_Coursematerial.CourseCode,
  368. EvaluationIntTypeName = tbl.EM_EvaluationIntType.Name,
  369. EvaluationTableTypeName = tbl.EM_EvaluationType.Name,
  370. CommentCount = (int)v.stuCount,
  371. Average = Math.Round((decimal)v.allavg, 2),
  372. DepartmentRanking = (int)v.DepartmentRanking,
  373. CollegeRanking = (int)v.CollegeRanking
  374. };
  375. var teaquery = from v in viewTeacherRepository.Entities
  376. join tbl in EvaluationTableRepository.GetList(expTable)
  377. on v.tableID equals tbl.EvaluationTableID
  378. join mct in MissionClassTeacherRepository.GetList(expmct)
  379. on v.MissionClassTeacherID equals mct.MissionClassTeacherID
  380. //on v.EducationMissionClassID equals mct.EM_EducationMissionClass.EducationMissionClassID
  381. select new EvaluationTeacherScoreView
  382. {
  383. UserID = mct.UserID.Value,
  384. TeacherNo = mct.CF_Staff.Sys_User.LoginID,
  385. TeacherName = mct.CF_Staff.Sys_User.Name,
  386. EducationMissionClassID = v.EducationMissionClassID,
  387. EducationMissionClassName = mct.EM_EducationMissionClass.Name,
  388. CollegeID = v.CollegeID,
  389. CollegeName = mct.EM_EducationMissionClass.EM_EducationMission.CF_Department.CF_College.Name,
  390. DepartmentID = v.DepartmentID,
  391. DepartmentName = mct.EM_EducationMissionClass.EM_EducationMission.CF_Department.Name,
  392. CourseID = mct.EM_EducationMissionClass.EM_Coursematerial.CoursematerialID,
  393. CourseName = mct.EM_EducationMissionClass.EM_Coursematerial.CourseName,
  394. CourseCode = mct.EM_EducationMissionClass.EM_Coursematerial.CourseCode,
  395. EvaluationIntTypeName = tbl.EM_EvaluationIntType.Name,
  396. EvaluationTableTypeName = tbl.EM_EvaluationType.Name,
  397. CommentCount = (int)v.teaCount,
  398. Average = Math.Round((decimal)v.allavg, 2),
  399. DepartmentRanking = (int)v.DepartmentRanking,
  400. CollegeRanking = (int)v.CollegeRanking
  401. };
  402. var query = from tbl in EvaluationTableRepository.GetList(expTable)
  403. select new EvaluationTableView
  404. {
  405. Type = tbl.EM_EvaluationType.Name,
  406. EvaluationIntTypeName = tbl.EM_EvaluationIntType.Name
  407. };
  408. if (schoolyaerID != null)//选择学年学期
  409. {
  410. stuquery = from v in viewStudentRepository.Entities
  411. join tbl in EvaluationTableRepository.GetList(expTable)
  412. on v.tableID equals tbl.EvaluationTableID
  413. join mct in MissionClassTeacherRepository.GetList(expmct)
  414. on v.MissionClassTeacherID equals mct.MissionClassTeacherID
  415. //on v.EducationMissionClassID equals mct.EM_EducationMissionClass.EducationMissionClassID
  416. select new EvaluationTeacherScoreView
  417. {
  418. UserID = mct.UserID.Value,
  419. TeacherNo = mct.CF_Staff.Sys_User.LoginID,
  420. TeacherName = mct.CF_Staff.Sys_User.Name,
  421. EducationMissionClassID = v.EducationMissionClassID,
  422. EducationMissionClassName = mct.EM_EducationMissionClass.Name,
  423. CollegeID = v.CollegeID,
  424. CollegeName = mct.EM_EducationMissionClass.EM_EducationMission.CF_Department.CF_College.Name,
  425. DepartmentID = v.DepartmentID,
  426. DepartmentName = mct.EM_EducationMissionClass.EM_EducationMission.CF_Department.Name,
  427. CourseID = mct.EM_EducationMissionClass.EM_Coursematerial.CoursematerialID,
  428. CourseName = mct.EM_EducationMissionClass.EM_Coursematerial.CourseName,
  429. CourseCode = mct.EM_EducationMissionClass.EM_Coursematerial.CourseCode,
  430. EvaluationIntTypeName = tbl.EM_EvaluationIntType.Name,
  431. EvaluationTableTypeName = tbl.EM_EvaluationType.Name,
  432. CommentCount = (int)v.stuCount,
  433. Average = Math.Round((decimal)v.allavg, 2),
  434. DepartmentRanking = (int)v.YearDepartmentRanking,
  435. CollegeRanking = (int)v.YearCollegeRanking
  436. };
  437. teaquery = from v in viewTeacherRepository.Entities
  438. join tbl in EvaluationTableRepository.GetList(expTable)
  439. on v.tableID equals tbl.EvaluationTableID
  440. join mct in MissionClassTeacherRepository.GetList(expmct)
  441. on v.MissionClassTeacherID equals mct.MissionClassTeacherID
  442. //on v.EducationMissionClassID equals mct.EM_EducationMissionClass.EducationMissionClassID
  443. select new EvaluationTeacherScoreView
  444. {
  445. UserID = mct.UserID.Value,
  446. TeacherNo = mct.CF_Staff.Sys_User.LoginID,
  447. TeacherName = mct.CF_Staff.Sys_User.Name,
  448. EducationMissionClassID = v.EducationMissionClassID,
  449. EducationMissionClassName = mct.EM_EducationMissionClass.Name,
  450. CollegeID = v.CollegeID,
  451. CollegeName = mct.EM_EducationMissionClass.EM_EducationMission.CF_Department.CF_College.Name,
  452. DepartmentID = v.DepartmentID,
  453. DepartmentName = mct.EM_EducationMissionClass.EM_EducationMission.CF_Department.Name,
  454. CourseID = mct.EM_EducationMissionClass.EM_Coursematerial.CoursematerialID,
  455. CourseName = mct.EM_EducationMissionClass.EM_Coursematerial.CourseName,
  456. CourseCode = mct.EM_EducationMissionClass.EM_Coursematerial.CourseCode,
  457. EvaluationIntTypeName = tbl.EM_EvaluationIntType.Name,
  458. EvaluationTableTypeName = tbl.EM_EvaluationType.Name,
  459. CommentCount = (int)v.teaCount,
  460. Average = Math.Round((decimal)v.allavg, 2),
  461. DepartmentRanking = (int)v.YearDepartmentRanking,
  462. CollegeRanking = (int)v.YearCollegeRanking
  463. };
  464. }
  465. if (query.ToList().Count() == 1)//选择参评类型
  466. {
  467. stuquery = from v in viewStudentRepository.Entities
  468. join tbl in EvaluationTableRepository.GetList(expTable)
  469. on v.tableID equals tbl.EvaluationTableID
  470. join mct in MissionClassTeacherRepository.GetList(expmct)
  471. on v.MissionClassTeacherID equals mct.MissionClassTeacherID
  472. //on v.EducationMissionClassID equals mct.EM_EducationMissionClass.EducationMissionClassID
  473. select new EvaluationTeacherScoreView
  474. {
  475. UserID = mct.UserID.Value,
  476. TeacherNo = mct.CF_Staff.Sys_User.LoginID,
  477. TeacherName = mct.CF_Staff.Sys_User.Name,
  478. EducationMissionClassID = v.EducationMissionClassID,
  479. EducationMissionClassName = mct.EM_EducationMissionClass.Name,
  480. CollegeID = v.CollegeID,
  481. CollegeName = mct.EM_EducationMissionClass.EM_EducationMission.CF_Department.CF_College.Name,
  482. DepartmentID = v.DepartmentID,
  483. DepartmentName = mct.EM_EducationMissionClass.EM_EducationMission.CF_Department.Name,
  484. CourseID = mct.EM_EducationMissionClass.EM_Coursematerial.CoursematerialID,
  485. CourseName = mct.EM_EducationMissionClass.EM_Coursematerial.CourseName,
  486. CourseCode = mct.EM_EducationMissionClass.EM_Coursematerial.CourseCode,
  487. EvaluationIntTypeName = tbl.EM_EvaluationIntType.Name,
  488. EvaluationTableTypeName = tbl.EM_EvaluationType.Name,
  489. CommentCount = (int)v.stuCount,
  490. Average = Math.Round((decimal)v.allavg, 2),
  491. DepartmentRanking = (int)v.DepartmentIntTypeRanking,
  492. CollegeRanking = (int)v.CollegeIntTypeRanking
  493. };
  494. teaquery = from v in viewTeacherRepository.Entities
  495. join tbl in EvaluationTableRepository.GetList(expTable)
  496. on v.tableID equals tbl.EvaluationTableID
  497. join mct in MissionClassTeacherRepository.GetList(expmct)
  498. on v.MissionClassTeacherID equals mct.MissionClassTeacherID
  499. //on v.EducationMissionClassID equals mct.EM_EducationMissionClass.EducationMissionClassID
  500. select new EvaluationTeacherScoreView
  501. {
  502. UserID = mct.UserID.Value,
  503. TeacherNo = mct.CF_Staff.Sys_User.LoginID,
  504. TeacherName = mct.CF_Staff.Sys_User.Name,
  505. EducationMissionClassID = v.EducationMissionClassID,
  506. EducationMissionClassName = mct.EM_EducationMissionClass.Name,
  507. CollegeID = v.CollegeID,
  508. CollegeName = mct.EM_EducationMissionClass.EM_EducationMission.CF_Department.CF_College.Name,
  509. DepartmentID = v.DepartmentID,
  510. DepartmentName = mct.EM_EducationMissionClass.EM_EducationMission.CF_Department.Name,
  511. CourseID = mct.EM_EducationMissionClass.EM_Coursematerial.CoursematerialID,
  512. CourseName = mct.EM_EducationMissionClass.EM_Coursematerial.CourseName,
  513. CourseCode = mct.EM_EducationMissionClass.EM_Coursematerial.CourseCode,
  514. EvaluationIntTypeName = tbl.EM_EvaluationIntType.Name,
  515. EvaluationTableTypeName = tbl.EM_EvaluationType.Name,
  516. CommentCount = (int)v.teaCount,
  517. Average = Math.Round((decimal)v.allavg, 2),
  518. DepartmentRanking = (int)v.DepartmentIntTypeRanking,
  519. CollegeRanking = (int)v.CollegeIntTypeRanking
  520. };
  521. }
  522. if (schoolyaerID != null && query.ToList().Count() == 1)
  523. {
  524. stuquery = from v in viewStudentRepository.Entities
  525. join tbl in EvaluationTableRepository.GetList(expTable)
  526. on v.tableID equals tbl.EvaluationTableID
  527. join mct in MissionClassTeacherRepository.GetList(expmct)
  528. on v.MissionClassTeacherID equals mct.MissionClassTeacherID
  529. //on v.EducationMissionClassID equals mct.EM_EducationMissionClass.EducationMissionClassID
  530. select new EvaluationTeacherScoreView
  531. {
  532. UserID = mct.UserID.Value,
  533. TeacherNo = mct.CF_Staff.Sys_User.LoginID,
  534. TeacherName = mct.CF_Staff.Sys_User.Name,
  535. EducationMissionClassID = v.EducationMissionClassID,
  536. EducationMissionClassName = mct.EM_EducationMissionClass.Name,
  537. CollegeID = v.CollegeID,
  538. CollegeName = mct.EM_EducationMissionClass.EM_EducationMission.CF_Department.CF_College.Name,
  539. DepartmentID = v.DepartmentID,
  540. DepartmentName = mct.EM_EducationMissionClass.EM_EducationMission.CF_Department.Name,
  541. CourseID = mct.EM_EducationMissionClass.EM_Coursematerial.CoursematerialID,
  542. CourseName = mct.EM_EducationMissionClass.EM_Coursematerial.CourseName,
  543. CourseCode = mct.EM_EducationMissionClass.EM_Coursematerial.CourseCode,
  544. EvaluationIntTypeName = tbl.EM_EvaluationIntType.Name,
  545. EvaluationTableTypeName = tbl.EM_EvaluationType.Name,
  546. CommentCount = (int)v.stuCount,
  547. Average = Math.Round((decimal)v.allavg, 2),
  548. DepartmentRanking = (int)v.YearDepartmentIntRanking,
  549. CollegeRanking = (int)v.YearCollegeIntRanking
  550. };
  551. teaquery = from v in viewTeacherRepository.Entities
  552. join tbl in EvaluationTableRepository.GetList(expTable)
  553. on v.tableID equals tbl.EvaluationTableID
  554. join mct in MissionClassTeacherRepository.GetList(expmct)
  555. on v.MissionClassTeacherID equals mct.MissionClassTeacherID
  556. //on v.EducationMissionClassID equals mct.EM_EducationMissionClass.EducationMissionClassID
  557. select new EvaluationTeacherScoreView
  558. {
  559. UserID = mct.UserID.Value,
  560. TeacherNo = mct.CF_Staff.Sys_User.LoginID,
  561. TeacherName = mct.CF_Staff.Sys_User.Name,
  562. EducationMissionClassID = v.EducationMissionClassID,
  563. EducationMissionClassName = mct.EM_EducationMissionClass.Name,
  564. CollegeID = v.CollegeID,
  565. CollegeName = mct.EM_EducationMissionClass.EM_EducationMission.CF_Department.CF_College.Name,
  566. DepartmentID = v.DepartmentID,
  567. DepartmentName = mct.EM_EducationMissionClass.EM_EducationMission.CF_Department.Name,
  568. CourseID = mct.EM_EducationMissionClass.EM_Coursematerial.CoursematerialID,
  569. CourseName = mct.EM_EducationMissionClass.EM_Coursematerial.CourseName,
  570. CourseCode = mct.EM_EducationMissionClass.EM_Coursematerial.CourseCode,
  571. EvaluationIntTypeName = tbl.EM_EvaluationIntType.Name,
  572. EvaluationTableTypeName = tbl.EM_EvaluationType.Name,
  573. CommentCount = (int)v.teaCount,
  574. Average = Math.Round((decimal)v.allavg, 2),
  575. DepartmentRanking = (int)v.YearDepartmentIntRanking,
  576. CollegeRanking = (int)v.YearCollegeIntRanking
  577. };
  578. }
  579. if (query.FirstOrDefault().Type.Equals("学生评") || query.FirstOrDefault().Type == "学生评")
  580. {
  581. return stuquery;
  582. }
  583. return teaquery;
  584. }
  585. }
  586. }