FacultymajorDAL.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298
  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 FacultymajorDAL
  14. {
  15. public FacultymajorRepository FacultymajorRepository { get; set; }
  16. public CollegeRepository CollegeRepository { get; set; }
  17. public CampusRepository CampusRepository { get; set; }
  18. public GrademajorRepository GrademajorRepository { get; set; }
  19. public ClassmajorRepository ClassmajorRepository { get; set; }
  20. public StudentRepository StudentRepository { get; set; }
  21. public UserRepository UserRepository { get; set; }
  22. public SpecialtyRepository SpecialtyRepository { get; set; }
  23. public DictionaryItemRepository DictionaryItemRepository { get; set; }
  24. /// <summary>
  25. /// 查询对应的院系专业信息View
  26. /// </summary>
  27. /// <param name="expFacultymajor"></param>
  28. /// <returns></returns>
  29. public IQueryable<FacultymajorView> GetFacultymajorViewQueryable(Expression<Func<CF_Facultymajor, bool>> expFacultymajor)
  30. {
  31. var query = from fa in FacultymajorRepository.GetList(expFacultymajor)
  32. join col in CollegeRepository.Entities
  33. on fa.CollegeID equals col.CollegeID
  34. join cam in CampusRepository.Entities
  35. on col.CampusID equals cam.CampusID
  36. join dicst in DictionaryItemRepository.GetList(x => x.DictionaryCode == DictionaryItem.CF_Standard.ToString())
  37. on fa.StandardID equals dicst.Value into tempst
  38. from standard in tempst.DefaultIfEmpty()
  39. select new FacultymajorView
  40. {
  41. FacultymajorID = fa.FacultymajorID,
  42. Code = fa.Code,
  43. Name = fa.Name,
  44. Abbreviation = fa.Abbreviation,
  45. EnglishName = fa.EnglishName,
  46. NameCode = fa.Name + fa.Code,
  47. CampusID = col.CampusID,
  48. CampusNo = cam.No,
  49. CampusName = cam.Name,
  50. CollegeID = fa.CollegeID,
  51. CollegeCode = col.No,
  52. CollegeName = col.Name,
  53. StandardID = fa.StandardID,
  54. StandardName = standard.Name,
  55. EducationID = fa.EducationID,
  56. LearningformID = fa.LearningformID,
  57. LearnSystem = fa.LearnSystem,
  58. ScienceclassID = fa.ScienceclassID,
  59. LearningstyleID = fa.LearningstyleID,
  60. LearnPositionID = fa.LearnPositionID,
  61. TeacherIdentification = fa.TeacherIdentification,
  62. SetTime = fa.SetTime,
  63. Remark = fa.Remark,
  64. RecordStatus = fa.RecordStatus,
  65. CreateUserID = fa.CreateUserID,
  66. CreateTime = fa.CreateTime,
  67. ModifyUserID = fa.ModifyUserID,
  68. ModifyTime = fa.ModifyTime
  69. };
  70. return query;
  71. }
  72. /// <summary>
  73. /// 查询对应的院系专业信息View(统计对应的年级专业数、学生人数)
  74. /// </summary>
  75. /// <param name="expFacultymajor"></param>
  76. /// <param name="expStudent"></param>
  77. /// <returns></returns>
  78. public IQueryable<FacultymajorView> GetFacultymajorViewQueryable(Expression<Func<CF_Facultymajor, bool>> expFacultymajor, Expression<Func<CF_Student, bool>> expStudent)
  79. {
  80. var query = from fa in FacultymajorRepository.GetList(expFacultymajor)
  81. join col in CollegeRepository.Entities
  82. on fa.CollegeID equals col.CollegeID
  83. join cam in CampusRepository.Entities
  84. on col.CampusID equals cam.CampusID
  85. join dicst in DictionaryItemRepository.GetList(x => x.DictionaryCode == DictionaryItem.CF_Standard.ToString())
  86. on fa.StandardID equals dicst.Value into tempst
  87. from standard in tempst.DefaultIfEmpty()
  88. join gr in
  89. (
  90. from gr in GrademajorRepository.Entities
  91. group gr by gr.FacultymajorID into ggr
  92. select new
  93. {
  94. FacultymajorID = ggr.Key,
  95. GrademajorCount = ggr.Count()
  96. }
  97. )
  98. on fa.FacultymajorID equals gr.FacultymajorID into tempgr
  99. from grfa in tempgr.DefaultIfEmpty()
  100. join sc in
  101. (
  102. from sc in StudentRepository.GetList(expStudent)
  103. group sc by sc.CF_Classmajor.CF_Grademajor.FacultymajorID into gstu
  104. select new
  105. {
  106. FacultymajorID = gstu.Key,
  107. StudentCount = gstu.Count()
  108. }
  109. )
  110. on fa.FacultymajorID equals sc.FacultymajorID into tempstu
  111. from stufa in tempstu.DefaultIfEmpty()
  112. select new FacultymajorView
  113. {
  114. FacultymajorID = fa.FacultymajorID,
  115. Code = fa.Code,
  116. Name = fa.Name,
  117. Abbreviation = fa.Abbreviation,
  118. EnglishName = fa.EnglishName,
  119. NameCode = fa.Name + fa.Code,
  120. CampusID = col.CampusID,
  121. CampusNo = cam.No,
  122. CampusName = cam.Name,
  123. CollegeID = fa.CollegeID,
  124. CollegeCode = col.No,
  125. CollegeName = col.Name,
  126. StandardID = fa.StandardID,
  127. StandardName = standard.Name,
  128. EducationID = fa.EducationID,
  129. LearningformID = fa.LearningformID,
  130. LearnSystem = fa.LearnSystem,
  131. ScienceclassID = fa.ScienceclassID,
  132. LearningstyleID = fa.LearningstyleID,
  133. LearnPositionID = fa.LearnPositionID,
  134. TeacherIdentification = fa.TeacherIdentification,
  135. SetTime = fa.SetTime,
  136. GrademajorCount = grfa.GrademajorCount == null ? 0 : grfa.GrademajorCount,
  137. StudentCount = stufa.StudentCount == null ? 0 : stufa.StudentCount,
  138. Remark = fa.Remark,
  139. RecordStatus = fa.RecordStatus,
  140. CreateUserID = fa.CreateUserID,
  141. CreateTime = fa.CreateTime,
  142. ModifyUserID = fa.ModifyUserID,
  143. ModifyTime = fa.ModifyTime
  144. };
  145. return query;
  146. }
  147. /// <summary>
  148. /// 查询对应的年级专业信息View(根据院系专业信息,统计各年级专业对应的学生人数)
  149. /// </summary>
  150. /// <param name="expFacultymajor"></param>
  151. /// <param name="expStudent"></param>
  152. /// <returns></returns>
  153. public IQueryable<GrademajorView> GetGrademajorViwQueryable(Expression<Func<CF_Facultymajor, bool>> expFacultymajor, Expression<Func<CF_Student, bool>> expStudent)
  154. {
  155. var query = from fa in FacultymajorRepository.GetList(expFacultymajor)
  156. join col in CollegeRepository.Entities
  157. on fa.CollegeID equals col.CollegeID
  158. join cam in CampusRepository.Entities
  159. on col.CampusID equals cam.CampusID
  160. join gr in GrademajorRepository.Entities
  161. on fa.FacultymajorID equals gr.FacultymajorID
  162. join sc in
  163. (
  164. from sc in StudentRepository.GetList(expStudent)
  165. group sc by sc.CF_Classmajor.CF_Grademajor.GrademajorID into g
  166. select new
  167. {
  168. GrademajorID = g.Key,
  169. StudentCount = g.Count()
  170. }
  171. )
  172. on gr.GrademajorID equals sc.GrademajorID into dsc
  173. from esc in dsc.DefaultIfEmpty()
  174. select new GrademajorView
  175. {
  176. GrademajorID = gr.GrademajorID,
  177. Code = gr.Code,
  178. Name = gr.Name,
  179. Abbreviation = gr.Abbreviation,
  180. FacultymajorID = gr.FacultymajorID,
  181. FacultymajorCode = fa.Code,
  182. FacultymajorName = fa.Name,
  183. CampusID = col.CampusID,
  184. CampusNo = cam.No,
  185. CampusName = cam.Name,
  186. CollegeID = fa.CollegeID,
  187. CollegeCode = col.No,
  188. CollegeName = col.Name,
  189. GradeID = gr.GradeID,
  190. SemesterID = gr.SemesterID,
  191. StandardID = fa.StandardID,
  192. EducationID = fa.EducationID,
  193. LearningformID = fa.LearningformID,
  194. LearnSystem = fa.LearnSystem,
  195. GraduateSchoolyearID = gr.GraduateSchoolyearID,
  196. GraduateValue = gr.CF_Schoolyear.Value,
  197. GraduateSchoolyearCode = gr.CF_Schoolyear.Code,
  198. Professional = gr.Professional,
  199. StudentCount = esc.StudentCount == null ? 0 : esc.StudentCount,
  200. Remark = gr.Remark,
  201. RecordStatus = gr.RecordStatus,
  202. CreateUserID = gr.CreateUserID,
  203. CreateTime = gr.CreateTime,
  204. ModifyUserID = gr.ModifyUserID,
  205. ModifyTime = gr.ModifyTime
  206. };
  207. return query;
  208. }
  209. /// <summary>
  210. /// 查询院系专业所对应的学生信息StudentBaseView
  211. /// </summary>
  212. /// <param name="expFacultymajor"></param>
  213. /// <param name="exp"></param>
  214. /// <returns></returns>
  215. public IQueryable<StudentBaseView> GetStudentBaseViewQueryable(Expression<Func<CF_Facultymajor, bool>> expFacultymajor, Expression<Func<CF_Student, bool>> exp)
  216. {
  217. var query = from stu in StudentRepository.GetList(exp)
  218. join cl in ClassmajorRepository.Entities
  219. on stu.ClassmajorID equals cl.ClassmajorID
  220. join gr in GrademajorRepository.Entities
  221. on cl.GrademajorID equals gr.GrademajorID
  222. join fa in FacultymajorRepository.GetList(expFacultymajor)
  223. on gr.FacultymajorID equals fa.FacultymajorID
  224. join us in UserRepository.Entities
  225. on stu.UserID equals us.UserID
  226. select new StudentBaseView
  227. {
  228. UserID = stu.UserID,
  229. LoginID = us.LoginID,
  230. UserName = us.Name,
  231. SexID = stu.SexID,
  232. IDNumber = stu.IDNumber,
  233. StudentStatus = stu.StudentStatus,
  234. InSchoolStatusID = stu.InSchoolStatusID,
  235. ClassmajorID = stu.ClassmajorID,
  236. ClassmajorNo = cl.No,
  237. ClassmajorName = cl.Name,
  238. ClassNum = cl.ClassNum == null ? 1 : cl.ClassNum,
  239. GradeID = gr.GradeID,
  240. SemesterID = gr.SemesterID,
  241. GrademajorID = cl.GrademajorID,
  242. GrademajorCode = gr.Code,
  243. GrademajorName = gr.Name,
  244. FacultymajorID = gr.FacultymajorID,
  245. FacultymajorCode = fa.Code,
  246. FacultymajorName = fa.Name
  247. };
  248. return query;
  249. }
  250. /// <summary>
  251. /// 查询院系专业对应的专业信息
  252. /// </summary>
  253. /// <param name="exp"></param>
  254. /// <returns></returns>
  255. public IQueryable<FacultymajorView> GetStandardViewQueryable(Expression<Func<CF_Facultymajor, bool>> exp)
  256. {
  257. var query = from fa in FacultymajorRepository.GetList(exp)
  258. join col in CollegeRepository.Entities
  259. on fa.CollegeID equals col.CollegeID
  260. join dtstan in DictionaryItemRepository.GetList(x => x.DictionaryCode == DictionaryItem.CF_Standard.ToString())
  261. on fa.StandardID equals dtstan.Value
  262. select new FacultymajorView
  263. {
  264. StandardID = fa.StandardID,
  265. StandardName = dtstan.Name
  266. };
  267. return query.Distinct();
  268. }
  269. /// <summary>
  270. /// 查询院系专业对应的学制
  271. /// </summary>
  272. /// <param name="exp"></param>
  273. /// <returns></returns>
  274. public IQueryable<FacultymajorView> GetLearnSystemViewQueryable(Expression<Func<CF_Facultymajor, bool>> exp)
  275. {
  276. var query = from fa in FacultymajorRepository.GetList(exp)
  277. select new FacultymajorView
  278. {
  279. LearnSystem = fa.LearnSystem,
  280. };
  281. return query.Distinct();
  282. }
  283. }
  284. }