EvaluationGradeControlDAL.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Linq.Expressions;
  5. using System.Text;
  6. using EMIS.Entities;
  7. using EMIS.ViewModel.EvaluationManage.EvaluationSetting;
  8. using EMIS.ViewModel.UniversityManage.SpecialtyClassManage;
  9. using EMIS.DataLogic.Repositories;
  10. namespace EMIS.DataLogic.EvaluationManage.EvaluationSetting
  11. {
  12. public class EvaluationGradeControlDAL
  13. {
  14. public EvaluationGradeControlRepository EvaluationGradeControlRepository { get; set; }
  15. public SchoolyearRepository SchoolyearRepository { get; set; }
  16. public GrademajorRepository GrademajorRepository { get; set; }
  17. public FacultymajorRepository FacultymajorRepository { get; set; }
  18. public ClassmajorRepository ClassmajorRepository { get; set; }
  19. public CollegeRepository CollegeRepository { get; set; }
  20. public CampusRepository CampusRepository { get; set; }
  21. public StudentRepository StudentRepository { get; set; }
  22. public UserRepository UserRepository { get; set; }
  23. /// <summary>
  24. /// 查询对应的年级专业评价控制信息EvaluationGradeControlView
  25. /// </summary>
  26. /// <param name="expEvaluationGradeControl"></param>
  27. /// <returns></returns>
  28. public IQueryable<EvaluationGradeControlView> GetEvaluationGradeControlViewQueryable(Expression<Func<EM_EvaluationGradeControl, bool>> expEvaluationGradeControl)
  29. {
  30. var query = from grct in EvaluationGradeControlRepository.GetList(expEvaluationGradeControl)
  31. join sy in SchoolyearRepository.Entities
  32. on grct.SchoolyearID equals sy.SchoolyearID
  33. join gr in GrademajorRepository.Entities
  34. on grct.GrademajorID equals gr.GrademajorID
  35. join fa in FacultymajorRepository.Entities
  36. on gr.FacultymajorID equals fa.FacultymajorID
  37. join col in CollegeRepository.Entities
  38. on fa.CollegeID equals col.CollegeID
  39. join cam in CampusRepository.Entities
  40. on col.CampusID equals cam.CampusID
  41. join stsy in SchoolyearRepository.Entities
  42. on new { GradeID = gr.GradeID.Value, SemesterID = gr.SemesterID.Value }
  43. equals new { GradeID = stsy.Years, SemesterID = stsy.SchoolcodeID } into tempstsy
  44. from startsy in tempstsy.DefaultIfEmpty()
  45. join grsy in SchoolyearRepository.Entities
  46. on gr.GraduateSchoolyearID equals grsy.SchoolyearID into tempgrsy
  47. from grasy in tempgrsy.DefaultIfEmpty()
  48. select new EvaluationGradeControlView
  49. {
  50. EvaluationGradeControlID = grct.EvaluationGradeControlID,
  51. SchoolyearID = grct.SchoolyearID,
  52. SchoolyearValue = sy.Value,
  53. SchoolyearCode = sy.Code,
  54. GrademajorID = grct.GrademajorID,
  55. GrademajorCode = gr.Code,
  56. GrademajorName = gr.Name,
  57. FacultymajorID = gr.FacultymajorID,
  58. FacultymajorNo = fa.Code,
  59. FacultymajorName = fa.Name,
  60. CollegeID = fa.CollegeID,
  61. CollegeNo = col.No,
  62. CollegeName = col.Name,
  63. CampusID = col.CampusID,
  64. CampusNo = cam.No,
  65. CampusName = cam.Name,
  66. GradeID = gr.GradeID,
  67. SemesterID = gr.SemesterID,
  68. StandardID = fa.StandardID,
  69. EducationID = fa.EducationID,
  70. LearningformID = fa.LearningformID,
  71. LearnSystem = fa.LearnSystem,
  72. StartSchoolyearID = startsy.SchoolyearID,
  73. StartSchoolyearValue = startsy.Value,
  74. StartSchoolyearCode = startsy.Code,
  75. GraduateSchoolyearID = gr.GraduateSchoolyearID,
  76. GraduateSchoolyearValue = grasy.Value,
  77. GraduateSchoolyearCode = grasy.Code,
  78. Number = grct.Number,
  79. StartTime = grct.StartTime,
  80. EndTime = grct.EndTime,
  81. RecordStatus = grct.RecordStatus,
  82. CreateUserID = grct.CreateUserID,
  83. CreateTime = grct.CreateTime,
  84. ModifyUserID = grct.ModifyUserID,
  85. ModifyTime = grct.ModifyTime
  86. };
  87. return query;
  88. }
  89. /// <summary>
  90. /// 查询对应的年级专业评价控制信息EvaluationGradeControlView(统计对应的班级个数、学生人数)
  91. /// </summary>
  92. /// <param name="expEvaluationGradeControl"></param>
  93. /// <param name="expStudent"></param>
  94. /// <returns></returns>
  95. public IQueryable<EvaluationGradeControlView> GetEvaluationGradeControlViewQueryable(Expression<Func<EM_EvaluationGradeControl, bool>> expEvaluationGradeControl, Expression<Func<CF_Student, bool>> expStudent)
  96. {
  97. var query = from grct in EvaluationGradeControlRepository.GetList(expEvaluationGradeControl)
  98. join sy in SchoolyearRepository.Entities
  99. on grct.SchoolyearID equals sy.SchoolyearID
  100. join gr in GrademajorRepository.Entities
  101. on grct.GrademajorID equals gr.GrademajorID
  102. join fa in FacultymajorRepository.Entities
  103. on gr.FacultymajorID equals fa.FacultymajorID
  104. join col in CollegeRepository.Entities
  105. on fa.CollegeID equals col.CollegeID
  106. join cam in CampusRepository.Entities
  107. on col.CampusID equals cam.CampusID
  108. join cl in
  109. (
  110. from cl in ClassmajorRepository.Entities
  111. group cl by cl.GrademajorID into gcl
  112. select new
  113. {
  114. GrademajorID = gcl.Key,
  115. ClassmajorCount = gcl.Count()
  116. }
  117. )
  118. on gr.GrademajorID equals cl.GrademajorID into tempcl
  119. from clgr in tempcl.DefaultIfEmpty()
  120. join sc in
  121. (
  122. from sc in StudentRepository.GetList(expStudent)
  123. group sc by sc.CF_Classmajor.CF_Grademajor.GrademajorID into gstu
  124. select new
  125. {
  126. GrademajorID = gstu.Key,
  127. StudentCount = gstu.Count()
  128. }
  129. )
  130. on gr.GrademajorID equals sc.GrademajorID into tempstu
  131. from grstu in tempstu.DefaultIfEmpty()
  132. join stsy in SchoolyearRepository.Entities
  133. on new { GradeID = gr.GradeID.Value, SemesterID = gr.SemesterID.Value }
  134. equals new { GradeID = stsy.Years, SemesterID = stsy.SchoolcodeID } into tempstsy
  135. from startsy in tempstsy.DefaultIfEmpty()
  136. join grsy in SchoolyearRepository.Entities
  137. on gr.GraduateSchoolyearID equals grsy.SchoolyearID into tempgrsy
  138. from grasy in tempgrsy.DefaultIfEmpty()
  139. join usc in UserRepository.Entities
  140. on grct.CreateUserID equals usc.UserID into tempusc
  141. from uscu in tempusc.DefaultIfEmpty()
  142. join usm in UserRepository.Entities
  143. on grct.ModifyUserID equals usm.UserID into tempusm
  144. from usmu in tempusm.DefaultIfEmpty()
  145. select new EvaluationGradeControlView
  146. {
  147. EvaluationGradeControlID = grct.EvaluationGradeControlID,
  148. SchoolyearID = grct.SchoolyearID,
  149. SchoolyearValue = sy.Value,
  150. SchoolyearCode = sy.Code,
  151. GrademajorID = grct.GrademajorID,
  152. GrademajorCode = gr.Code,
  153. GrademajorName = gr.Name,
  154. FacultymajorID = gr.FacultymajorID,
  155. FacultymajorNo = fa.Code,
  156. FacultymajorName = fa.Name,
  157. CollegeID = fa.CollegeID,
  158. CollegeNo = col.No,
  159. CollegeName = col.Name,
  160. CampusID = col.CampusID,
  161. CampusNo = cam.No,
  162. CampusName = cam.Name,
  163. GradeID = gr.GradeID,
  164. SemesterID = gr.SemesterID,
  165. StandardID = fa.StandardID,
  166. EducationID = fa.EducationID,
  167. LearningformID = fa.LearningformID,
  168. LearnSystem = fa.LearnSystem,
  169. StartSchoolyearID = startsy.SchoolyearID,
  170. StartSchoolyearValue = startsy.Value,
  171. StartSchoolyearCode = startsy.Code,
  172. GraduateSchoolyearID = gr.GraduateSchoolyearID,
  173. GraduateSchoolyearValue = grasy.Value,
  174. GraduateSchoolyearCode = grasy.Code,
  175. ClassmajorCount = clgr.ClassmajorCount == null ? 0 : clgr.ClassmajorCount,
  176. StudentCount = grstu.StudentCount == null ? 0 : grstu.StudentCount,
  177. Number = grct.Number,
  178. StartTime = grct.StartTime,
  179. EndTime = grct.EndTime,
  180. RecordStatus = grct.RecordStatus,
  181. CreateUserID = grct.CreateUserID,
  182. CreateUserName = uscu.Name,
  183. CreateTime = grct.CreateTime,
  184. ModifyUserID = grct.ModifyUserID,
  185. ModifyUserName = usmu.Name,
  186. ModifyTime = grct.ModifyTime
  187. };
  188. return query;
  189. }
  190. /// <summary>
  191. /// 查询年级专业评价控制中未新增的年级专业信息GrademajorView
  192. /// </summary>
  193. /// <param name="expEvaluationGradeControl"></param>
  194. /// <param name="expStudent"></param>
  195. /// <returns></returns>
  196. public IQueryable<GrademajorView> GetGrademajorViewNoAddQueryable(Expression<Func<EM_EvaluationGradeControl, bool>> expEvaluationGradeControl, Expression<Func<CF_Student, bool>> expStudent)
  197. {
  198. var query = from gr in GrademajorRepository.Entities
  199. join fa in FacultymajorRepository.Entities
  200. on gr.FacultymajorID equals fa.FacultymajorID
  201. join col in CollegeRepository.Entities
  202. on fa.CollegeID equals col.CollegeID
  203. join cam in CampusRepository.Entities
  204. on col.CampusID equals cam.CampusID
  205. join sc in
  206. (
  207. from sc in StudentRepository.GetList(expStudent)
  208. group sc by sc.CF_Classmajor.CF_Grademajor.GrademajorID into gstu
  209. select new
  210. {
  211. GrademajorID = gstu.Key,
  212. StudentCount = gstu.Count()
  213. }
  214. )
  215. on gr.GrademajorID equals sc.GrademajorID into tempstu
  216. from grstu in tempstu.DefaultIfEmpty()
  217. join stsy in SchoolyearRepository.Entities
  218. on new { GradeID = gr.GradeID.Value, SemesterID = gr.SemesterID.Value }
  219. equals new { GradeID = stsy.Years, SemesterID = stsy.SchoolcodeID } into tempstsy
  220. from startsy in tempstsy.DefaultIfEmpty()
  221. join grsy in SchoolyearRepository.Entities
  222. on gr.GraduateSchoolyearID equals grsy.SchoolyearID into tempgrsy
  223. from grasy in tempgrsy.DefaultIfEmpty()
  224. join grct in EvaluationGradeControlRepository.GetList(expEvaluationGradeControl)
  225. on gr.GrademajorID equals grct.GrademajorID into tempgrct
  226. from evgrct in tempgrct.DefaultIfEmpty()
  227. where evgrct.EvaluationGradeControlID == null
  228. select new GrademajorView
  229. {
  230. GrademajorID = gr.GrademajorID,
  231. Code = gr.Code,
  232. Name = gr.Name,
  233. Abbreviation = gr.Abbreviation,
  234. FacultymajorID = gr.FacultymajorID,
  235. FacultymajorCode = fa.Code,
  236. FacultymajorName = fa.Name,
  237. CampusID = col.CampusID,
  238. CampusNo = cam.No,
  239. CampusName = cam.Name,
  240. CollegeID = fa.CollegeID,
  241. CollegeCode = col.No,
  242. CollegeName = col.Name,
  243. GradeID = gr.GradeID,
  244. SemesterID = gr.SemesterID,
  245. StandardID = fa.StandardID,
  246. EducationID = fa.EducationID,
  247. LearningformID = fa.LearningformID,
  248. LearnSystem = fa.LearnSystem,
  249. StartSchoolyearID = startsy.SchoolyearID,
  250. StartValue = startsy.Value,
  251. StartSchoolyearCode = startsy.Code,
  252. GraduateSchoolyearID = gr.GraduateSchoolyearID,
  253. GraduateValue = grasy.Value,
  254. GraduateSchoolyearCode = grasy.Code,
  255. Professional = gr.Professional,
  256. StudentCount = grstu.StudentCount == null ? 0 : grstu.StudentCount,
  257. Remark = gr.Remark,
  258. RecordStatus = gr.RecordStatus,
  259. CreateUserID = gr.CreateUserID,
  260. CreateTime = gr.CreateTime,
  261. ModifyUserID = gr.ModifyUserID,
  262. ModifyTime = gr.ModifyTime
  263. };
  264. return query;
  265. }
  266. }
  267. }