GrademajorDAL.cs 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369
  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;
  8. using EMIS.ViewModel.UniversityManage.SpecialtyClassManage;
  9. using EMIS.ViewModel.StudentManage.StudentProfile;
  10. using EMIS.DataLogic.Repositories;
  11. namespace EMIS.DataLogic.UniversityManage.SpecialtyClassManage
  12. {
  13. public class GrademajorDAL
  14. {
  15. public GrademajorRepository GrademajorRepository { get; set; }
  16. public FacultymajorRepository FacultymajorRepository { get; set; }
  17. public ClassmajorRepository ClassmajorRepository { get; set; }
  18. public CollegeRepository CollegeRepository { get; set; }
  19. public CampusRepository CampusRepository { get; set; }
  20. public SchoolyearRepository SchoolyearRepository { get; set; }
  21. public DictionaryItemRepository DictionaryItemRepository { get; set; }
  22. public StudentRepository StudentRepository { get; set; }
  23. public UserRepository UserRepository { get; set; }
  24. /// <summary>
  25. /// 查询对应的年级专业信息View
  26. /// </summary>
  27. /// <param name="exp"></param>
  28. /// <returns></returns>
  29. public IQueryable<GrademajorView> GetGrademajorViwQueryable(Expression<Func<CF_Grademajor, bool>> expGrademajor)
  30. {
  31. var query = from gr in GrademajorRepository.GetList(expGrademajor)
  32. join fa in FacultymajorRepository.Entities
  33. on gr.FacultymajorID equals fa.FacultymajorID
  34. join col in CollegeRepository.Entities
  35. on fa.CollegeID equals col.CollegeID
  36. join cam in CampusRepository.Entities
  37. on col.CampusID equals cam.CampusID
  38. join gy in SchoolyearRepository.Entities
  39. on gr.GraduateSchoolyearID equals gy.SchoolyearID into tempgy
  40. from gdsy in tempgy.DefaultIfEmpty()
  41. select new GrademajorView
  42. {
  43. GrademajorID = gr.GrademajorID,
  44. Code = gr.Code,
  45. Name = gr.Name,
  46. Abbreviation = gr.Abbreviation,
  47. FacultymajorID = gr.FacultymajorID,
  48. FacultymajorCode = fa.Code,
  49. FacultymajorName = fa.Name,
  50. CampusID = col.CampusID,
  51. CampusNo = cam.No,
  52. CampusName = cam.Name,
  53. CollegeID = fa.CollegeID,
  54. CollegeCode = col.No,
  55. CollegeName = col.Name,
  56. GradeID = gr.GradeID,
  57. SemesterID = gr.SemesterID,
  58. StandardID = fa.StandardID,
  59. EducationID = fa.EducationID,
  60. LearningformID = fa.LearningformID,
  61. LearnSystem = fa.LearnSystem,
  62. GraduateSchoolyearID = gr.GraduateSchoolyearID,
  63. GraduateValue = gdsy.Value,
  64. GraduateSchoolyearCode = gdsy.Code,
  65. Professional = gr.Professional,
  66. Remark = gr.Remark,
  67. RecordStatus = gr.RecordStatus,
  68. CreateUserID = gr.CreateUserID,
  69. CreateTime = gr.CreateTime,
  70. ModifyUserID = gr.ModifyUserID,
  71. ModifyTime = gr.ModifyTime
  72. };
  73. return query;
  74. }
  75. /// <summary>
  76. /// 查询对应的年级专业信息View(统计对应的班级个数、学生人数)
  77. /// </summary>
  78. /// <param name="expGrademajor"></param>
  79. /// <param name="expStudent"></param>
  80. /// <returns></returns>
  81. public IQueryable<GrademajorView> GetGrademajorViwQueryable(Expression<Func<CF_Grademajor, bool>> expGrademajor, Expression<Func<CF_Student, bool>> expStudent)
  82. {
  83. var query = from gr in GrademajorRepository.GetList(expGrademajor)
  84. join fa in FacultymajorRepository.Entities
  85. on gr.FacultymajorID equals fa.FacultymajorID
  86. join col in CollegeRepository.Entities
  87. on fa.CollegeID equals col.CollegeID
  88. join cam in CampusRepository.Entities
  89. on col.CampusID equals cam.CampusID
  90. join cl in
  91. (
  92. from cl in ClassmajorRepository.Entities
  93. group cl by cl.GrademajorID into gcl
  94. select new
  95. {
  96. GrademajorID = gcl.Key,
  97. ClassmajorCount = gcl.Count()
  98. }
  99. )
  100. on gr.GrademajorID equals cl.GrademajorID into tempcl
  101. from clgr in tempcl.DefaultIfEmpty()
  102. join sc in
  103. (
  104. from sc in StudentRepository.GetList(expStudent)
  105. group sc by sc.CF_Classmajor.CF_Grademajor.GrademajorID into gstu
  106. select new
  107. {
  108. GrademajorID = gstu.Key,
  109. StudentCount = gstu.Count()
  110. }
  111. )
  112. on gr.GrademajorID equals sc.GrademajorID into tempstu
  113. from grstu in tempstu.DefaultIfEmpty()
  114. select new GrademajorView
  115. {
  116. GrademajorID = gr.GrademajorID,
  117. Code = gr.Code,
  118. Name = gr.Name,
  119. Abbreviation = gr.Abbreviation,
  120. FacultymajorID = gr.FacultymajorID,
  121. FacultymajorCode = fa.Code,
  122. FacultymajorName = fa.Name,
  123. CampusID = col.CampusID,
  124. CampusNo = cam.No,
  125. CampusName = cam.Name,
  126. CollegeID = fa.CollegeID,
  127. CollegeCode = col.No,
  128. CollegeName = col.Name,
  129. GradeID = gr.GradeID,
  130. SemesterID = gr.SemesterID,
  131. StandardID = fa.StandardID,
  132. EducationID = fa.EducationID,
  133. LearningformID = fa.LearningformID,
  134. LearnSystem = fa.LearnSystem,
  135. GraduateSchoolyearID = gr.GraduateSchoolyearID,
  136. GraduateValue = gr.CF_Schoolyear.Value,
  137. GraduateSchoolyearCode = gr.CF_Schoolyear.Code,
  138. Professional = gr.Professional,
  139. ClassmajorCount = clgr.ClassmajorCount == null ? 0 : clgr.ClassmajorCount,
  140. StudentCount = grstu.StudentCount == null ? 0 : grstu.StudentCount,
  141. Remark = gr.Remark,
  142. RecordStatus = gr.RecordStatus,
  143. CreateUserID = gr.CreateUserID,
  144. CreateTime = gr.CreateTime,
  145. ModifyUserID = gr.ModifyUserID,
  146. ModifyTime = gr.ModifyTime
  147. };
  148. return query;
  149. }
  150. /// <summary>
  151. /// 查询对应的年级专业信息GrademajorView(根据班级信息)
  152. /// </summary>
  153. /// <param name="exp"></param>
  154. /// <returns></returns>
  155. public IQueryable<GrademajorView> GetGrademajorViwByClassQueryable(Expression<Func<CF_Classmajor, bool>> expClassmajor)
  156. {
  157. var query = from gr in GrademajorRepository.Entities
  158. join cl in ClassmajorRepository.GetList(expClassmajor)
  159. on gr.GrademajorID equals cl.GrademajorID
  160. join fa in FacultymajorRepository.Entities
  161. on gr.FacultymajorID equals fa.FacultymajorID
  162. join col in CollegeRepository.Entities
  163. on fa.CollegeID equals col.CollegeID
  164. join cam in CampusRepository.Entities
  165. on col.CampusID equals cam.CampusID
  166. select new GrademajorView
  167. {
  168. GrademajorID = gr.GrademajorID,
  169. Code = gr.Code,
  170. Name = gr.Name,
  171. Abbreviation = gr.Abbreviation,
  172. FacultymajorID = gr.FacultymajorID,
  173. FacultymajorCode = fa.Code,
  174. FacultymajorName = fa.Name,
  175. CampusID = col.CampusID,
  176. CampusNo = cam.No,
  177. CampusName = cam.Name,
  178. CollegeID = fa.CollegeID,
  179. CollegeCode = col.No,
  180. CollegeName = col.Name,
  181. GradeID = gr.GradeID,
  182. SemesterID = gr.SemesterID,
  183. StandardID = fa.StandardID,
  184. EducationID = fa.EducationID,
  185. LearningformID = fa.LearningformID,
  186. LearnSystem = fa.LearnSystem,
  187. GraduateSchoolyearID = gr.GraduateSchoolyearID,
  188. GraduateValue = gr.CF_Schoolyear.Value,
  189. GraduateSchoolyearCode = gr.CF_Schoolyear.Code,
  190. Professional = gr.Professional,
  191. Remark = gr.Remark,
  192. RecordStatus = gr.RecordStatus,
  193. CreateUserID = gr.CreateUserID,
  194. CreateTime = gr.CreateTime,
  195. ModifyUserID = gr.ModifyUserID,
  196. ModifyTime = gr.ModifyTime
  197. };
  198. return query;
  199. }
  200. /// <summary>
  201. /// 查询对应的班级信息View(根据年级专业信息,统计各班级信息对应的学生人数)
  202. /// </summary>
  203. /// <param name="expGrademajor"></param>
  204. /// <param name="expStudent"></param>
  205. /// <returns></returns>
  206. public IQueryable<ClassmajorView> GetClassmajorViewQueryable(Expression<Func<CF_Grademajor, bool>> expGrademajor, Expression<Func<CF_Student, bool>> expStudent)
  207. {
  208. var query = from gr in GrademajorRepository.GetList(expGrademajor)
  209. join cl in ClassmajorRepository.Entities
  210. on gr.GrademajorID equals cl.GrademajorID
  211. join fa in FacultymajorRepository.Entities
  212. on gr.FacultymajorID equals fa.FacultymajorID
  213. join col in CollegeRepository.Entities
  214. on fa.CollegeID equals col.CollegeID
  215. join cam in CampusRepository.Entities
  216. on col.CampusID equals cam.CampusID
  217. join sc in
  218. (
  219. from sc in StudentRepository.GetList(expStudent)
  220. group sc by sc.CF_Classmajor.ClassmajorID into g
  221. select new
  222. {
  223. ClassmajorID = g.Key,
  224. StudentCount = g.Count()
  225. })
  226. on cl.ClassmajorID equals sc.ClassmajorID into dsc
  227. from esc in dsc.DefaultIfEmpty()
  228. join c in UserRepository.Entities
  229. on cl.UserID equals c.UserID into gu
  230. from guser in gu.DefaultIfEmpty()
  231. join d in UserRepository.Entities
  232. on cl.AssistantUserID equals d.UserID into ga
  233. from gassis in ga.DefaultIfEmpty()
  234. select new ClassmajorView
  235. {
  236. ClassmajorID = cl.ClassmajorID,
  237. No = cl.No,
  238. Name = cl.Name,
  239. Abbreviation = cl.Abbreviation,
  240. EnglishName = cl.EnglishName,
  241. ClassNum = cl.ClassNum,
  242. FacultymajorID = gr.FacultymajorID,
  243. FacultymajorCode = fa.Code,
  244. FacultymajorName = fa.Name,
  245. GrademajorID = gr.GrademajorID,
  246. GrademajorCode = gr.Code,
  247. GrademajorName = gr.Name,
  248. CampusID = col.CampusID,
  249. CampusNo = cam.No,
  250. CampusName = cam.Name,
  251. CollegeID = fa.CollegeID,
  252. CollegeCode = col.No,
  253. CollegeName = col.Name,
  254. GradeID = gr.GradeID,
  255. SemesterID = gr.SemesterID,
  256. StandardID = fa.StandardID,
  257. EducationID = fa.EducationID,
  258. LearningformID = fa.LearningformID,
  259. LearnSystem = fa.LearnSystem,
  260. GraduateSchoolyearID = gr.GraduateSchoolyearID,
  261. GraduateValue = gr.CF_Schoolyear.Value,
  262. GraduateSchoolyearCode = gr.CF_Schoolyear.Code,
  263. UserID = cl.UserID,
  264. UserName = guser.Name,
  265. AssistantUserID = cl.AssistantUserID,
  266. AssistantUserName = gassis.Name,
  267. Fixedclassroom = cl.Fixedclassroom,
  268. StudentCount = esc.StudentCount == null ? 0 : esc.StudentCount,
  269. Remark = cl.Remark,
  270. RecordStatus = cl.RecordStatus,
  271. CreateUserID = cl.CreateUserID,
  272. CreateTime = cl.CreateTime,
  273. ModifyUserID = cl.ModifyUserID,
  274. ModifyTime = cl.ModifyTime
  275. };
  276. return query;
  277. }
  278. /// <summary>
  279. /// 查询年级专业所对应的学生信息BaseStudentView
  280. /// </summary>
  281. /// <param name="expGrademajor"></param>
  282. /// <param name="exp"></param>
  283. /// <returns></returns>
  284. public IQueryable<StudentBaseView> GetStudentBaseViewQueryable(Expression<Func<CF_Grademajor, bool>> expGrademajor, Expression<Func<CF_Student, bool>> exp)
  285. {
  286. var query = from stu in StudentRepository.GetList(exp)
  287. join cl in ClassmajorRepository.Entities
  288. on stu.ClassmajorID equals cl.ClassmajorID
  289. join gr in GrademajorRepository.GetList(expGrademajor)
  290. on cl.GrademajorID equals gr.GrademajorID
  291. join fa in FacultymajorRepository.Entities
  292. on gr.FacultymajorID equals fa.FacultymajorID
  293. join us in UserRepository.Entities
  294. on stu.UserID equals us.UserID
  295. select new StudentBaseView
  296. {
  297. UserID = stu.UserID,
  298. LoginID = us.LoginID,
  299. UserName = us.Name,
  300. SexID = stu.SexID,
  301. IDNumber = stu.IDNumber,
  302. StudentStatus = stu.StudentStatus,
  303. InSchoolStatusID = stu.InSchoolStatusID,
  304. ClassmajorID = stu.ClassmajorID,
  305. ClassmajorNo = cl.No,
  306. ClassmajorName = cl.Name,
  307. ClassNum = cl.ClassNum == null ? 1 : cl.ClassNum,
  308. GradeID = gr.GradeID,
  309. SemesterID = gr.SemesterID,
  310. GrademajorID = cl.GrademajorID,
  311. GrademajorCode = gr.Code,
  312. GrademajorName = gr.Name,
  313. FacultymajorID = gr.FacultymajorID,
  314. FacultymajorCode = fa.Code,
  315. FacultymajorName = fa.Name
  316. };
  317. return query;
  318. }
  319. /// <summary>
  320. /// 查询年级专业对应的专业名称信息FacultymajorView(去重)
  321. /// </summary>
  322. /// <param name="exp"></param>
  323. /// <returns></returns>
  324. public IQueryable<FacultymajorView> GetStandardViewQueryable(Expression<Func<CF_Grademajor, bool>> exp)
  325. {
  326. var query = from gr in GrademajorRepository.GetList(exp)
  327. join fa in FacultymajorRepository.Entities
  328. on gr.FacultymajorID equals fa.FacultymajorID
  329. join dtstan in DictionaryItemRepository.GetList(x => x.DictionaryCode == DictionaryItem.CF_Standard.ToString())
  330. on fa.StandardID equals dtstan.Value
  331. select new FacultymajorView
  332. {
  333. StandardID = fa.StandardID,
  334. StandardName = dtstan.Name
  335. };
  336. return query.Distinct();
  337. }
  338. /// <summary>
  339. /// 查询年级专业对应的年级信息GrademajorView(去重)
  340. /// </summary>
  341. /// <param name="exp"></param>
  342. /// <returns></returns>
  343. public IQueryable<GrademajorView> GetGradeViewQueryable(Expression<Func<CF_Grademajor, bool>> exp)
  344. {
  345. var query = from gr in GrademajorRepository.GetList(exp)
  346. select new GrademajorView
  347. {
  348. GradeID = gr.GradeID
  349. };
  350. return query.Distinct();
  351. }
  352. }
  353. }