FacultymajorDAL.cs 14 KB

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