RecruitSpecialtyDAL.cs 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314
  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.EnrollManage.SpecialtyManage;
  10. using EMIS.DataLogic.Repositories;
  11. namespace EMIS.DataLogic.EnrollManage.SpecialtyManage
  12. {
  13. public class RecruitSpecialtyDAL
  14. {
  15. public RecruitSpecialtyRepository recruitSpecialtyRepository { get; set; }
  16. public CollegeRepository collegeRepository { get; set; }
  17. public SpecialtyApplyRepository specialtyApplyRepository { get; set; }
  18. public SpecialtyRepository specialtyRepository { get; set; }
  19. public SpecialtyClassSettingRepository SpecialtyClassSettingRepository { get; set; }
  20. public DictionaryItemRepository dictionaryItemRepository { get; set; }
  21. public FacultymajorRepository facultymajorRepository { get; set; }
  22. public GrademajorRepository grademajorRepository { get; set; }
  23. public ClassmajorRepository classmajorRepository { get; set; }
  24. public SchoolyearRepository schoolyearRepository { get; set; }
  25. public EducationTypeSettingRepository educationTypeSettingRepository { get; set; }
  26. /// <summary>
  27. /// 查询招生专业信息View
  28. /// </summary>
  29. /// <param name="exp"></param>
  30. /// <returns></returns>
  31. public IQueryable<RecruitSpecialtyView> GetRecruitSpecialtyViewQueryable(Expression<Func<CF_RecruitSpecialty, bool>> exp)
  32. {
  33. var query = from rs in recruitSpecialtyRepository.GetList(exp)
  34. join sp in specialtyRepository.Entities
  35. on rs.SpecialtyID equals sp.SpecialtyID
  36. join sc in SpecialtyClassSettingRepository.Entities
  37. on rs.SpecialtyID equals sc.SpecialtyID into tempsc
  38. from spcs in tempsc.DefaultIfEmpty()
  39. join dicst in dictionaryItemRepository.GetList(x => x.DictionaryCode == DictionaryItem.CF_Standard.ToString())
  40. on sp.StandardID equals dicst.Value into tempst
  41. from standard in tempst.DefaultIfEmpty()
  42. select new RecruitSpecialtyView
  43. {
  44. RecruitSpecialtyID = rs.RecruitSpecialtyID,
  45. SpecialtyApplyID = rs.SpecialtyApplyID,
  46. CollegeID = rs.CollegeID,
  47. CollegeNo = rs.CF_College.No,
  48. CollegeName = rs.CF_College.Name,
  49. CampusID = rs.CF_College.CampusID,
  50. CampusCode = rs.CF_College.CF_Campus.No,
  51. CampusName = rs.CF_College.CF_Campus.Name,
  52. SpecialtyID = rs.SpecialtyID,
  53. StandardID = sp.StandardID,
  54. StandardCode = standard.Code,
  55. StandardName = standard.Name,
  56. EducationID = sp.EducationID,
  57. LearningformID = sp.LearningformID,
  58. LearnSystem = sp.LearnSystem,
  59. ScienceclassID = sp.ScienceclassID,
  60. PropertyID = sp.PropertyID,
  61. StandardTitle = sp.StandardTitle,
  62. StandardLevel = sp.StandardLevel,
  63. GradeID = rs.GradeID,
  64. SemesterID = rs.SemesterID,
  65. ApprovalStatus = rs.ApprovalStatus,
  66. ClassNumber = spcs.ClassNumber ?? 1,
  67. isGenerated = rs.isGenerated ?? false,
  68. RecordStatus = rs.RecordStatus,
  69. Remark = rs.Remark,
  70. CreateUserID = rs.CreateUserID,
  71. CreateTime = rs.CreateTime,
  72. ModifyUserID = rs.ModifyUserID,
  73. ModifyTime = rs.ModifyTime
  74. };
  75. return query;
  76. }
  77. /// <summary>
  78. /// 查询招生专业中未新增的专业信息SpecialtyView
  79. /// </summary>
  80. /// <param name="expSpecialty"></param>
  81. /// <param name="expRecruitSpecialty"></param>
  82. /// <returns></returns>
  83. public IQueryable<SpecialtyView> GetSpecialtyViewNoAddQueryable(Expression<Func<CF_Specialty, bool>> expSpecialty, Expression<Func<CF_RecruitSpecialty, bool>> expRecruitSpecialty)
  84. {
  85. var query = from sp in specialtyRepository.GetList(expSpecialty)
  86. join stdic in dictionaryItemRepository.GetList(x => x.DictionaryCode == DictionaryItem.CF_Standard.ToString())
  87. on sp.StandardID equals stdic.Value into tempstdic
  88. from standard in tempstdic.DefaultIfEmpty()
  89. join rs in recruitSpecialtyRepository.GetList(expRecruitSpecialty)
  90. on sp.SpecialtyID equals rs.SpecialtyID into temprs
  91. from rsp in temprs.DefaultIfEmpty()
  92. where rsp.RecruitSpecialtyID == null
  93. select new SpecialtyView
  94. {
  95. SpecialtyID = sp.SpecialtyID,
  96. StandardID = sp.StandardID,
  97. StandardCode = standard.Code,
  98. StandardName = standard.Name,
  99. EducationID = sp.EducationID,
  100. LearningformID = sp.LearningformID,
  101. LearnSystem = sp.LearnSystem,
  102. ScienceclassID = sp.ScienceclassID,
  103. PropertyID = sp.PropertyID,
  104. StandardTitle = sp.StandardTitle,
  105. StandardLevel = sp.StandardLevel,
  106. RecordStatus = sp.RecordStatus,
  107. Remark = sp.Remark,
  108. CreateUserID = sp.CreateUserID,
  109. CreateTime = sp.CreateTime,
  110. ModifyUserID = sp.ModifyUserID,
  111. ModifyTime = sp.ModifyTime,
  112. };
  113. return query;
  114. }
  115. /// <summary>
  116. /// 根据招生专业信息查询对应的院系专业信息(业务主键:专业ID(Value)、培养层次、学习形式、学制、院系所ID)
  117. /// </summary>
  118. /// <param name="expRecruitSpecialty"></param>
  119. /// <returns></returns>
  120. public IQueryable<RecruitSpecialtyClassView> GetFacultymajorByRecruitSpecialty(Expression<Func<CF_RecruitSpecialty, bool>> expRecruitSpecialty)
  121. {
  122. var query = from rs in recruitSpecialtyRepository.GetList(expRecruitSpecialty)
  123. join col in collegeRepository.Entities
  124. on rs.CollegeID equals col.CollegeID
  125. join sp in specialtyRepository.Entities
  126. on rs.SpecialtyID equals sp.SpecialtyID
  127. join fa in facultymajorRepository.Entities
  128. on new { sp.StandardID, sp.EducationID, sp.LearningformID, sp.LearnSystem, rs.CollegeID }
  129. equals new { fa.StandardID, fa.EducationID, fa.LearningformID, fa.LearnSystem, fa.CollegeID }
  130. select new RecruitSpecialtyClassView
  131. {
  132. RecruitSpecialtyID = rs.RecruitSpecialtyID,
  133. CollegeID = rs.CollegeID,
  134. CollegeNo = col.No,
  135. CollegeName = col.Name,
  136. GradeID = rs.GradeID,
  137. SpecialtyID = rs.SpecialtyID,
  138. StandardID = fa.StandardID,
  139. EducationID = fa.EducationID,
  140. LearningformID = fa.LearningformID,
  141. LearnSystem = fa.LearnSystem,
  142. FacultymajorID = fa.FacultymajorID,
  143. FacultymajorCode = fa.Code,
  144. FacultymajorName = fa.Name,
  145. isGenerated = rs.isGenerated ?? false
  146. };
  147. return query;
  148. }
  149. /// <summary>
  150. /// 根据招生专业信息、院系专业信息查询对应的年级专业信息(业务主键:院系专业ID、年级)
  151. /// </summary>
  152. /// <param name="expRecruitSpecialty"></param>
  153. /// <param name="expFacultymajor"></param>
  154. /// <returns></returns>
  155. public IQueryable<RecruitSpecialtyClassView> GetGrademajorByRecruitSpecialty(Expression<Func<CF_RecruitSpecialty, bool>> expRecruitSpecialty,
  156. Expression<Func<CF_Facultymajor, bool>> expFacultymajor)
  157. {
  158. var query = from rs in recruitSpecialtyRepository.GetList(expRecruitSpecialty)
  159. join col in collegeRepository.Entities
  160. on rs.CollegeID equals col.CollegeID
  161. join sp in specialtyRepository.Entities
  162. on rs.SpecialtyID equals sp.SpecialtyID
  163. join fa in facultymajorRepository.GetList(expFacultymajor)
  164. on new { sp.StandardID, sp.EducationID, sp.LearningformID, sp.LearnSystem, rs.CollegeID }
  165. equals new { fa.StandardID, fa.EducationID, fa.LearningformID, fa.LearnSystem, fa.CollegeID }
  166. join gr in grademajorRepository.Entities
  167. on new { FacultymajorID = fa.FacultymajorID, GradeID = rs.GradeID, SemesterID = rs.SemesterID }
  168. equals new { FacultymajorID = gr.FacultymajorID.Value, GradeID = gr.GradeID, SemesterID = gr.SemesterID }
  169. select new RecruitSpecialtyClassView
  170. {
  171. RecruitSpecialtyID = rs.RecruitSpecialtyID,
  172. CollegeID = rs.CollegeID,
  173. CollegeNo = col.No,
  174. CollegeName = col.Name,
  175. GradeID = rs.GradeID,
  176. SpecialtyID = rs.SpecialtyID,
  177. StandardID = fa.StandardID,
  178. EducationID = fa.EducationID,
  179. LearningformID = fa.LearningformID,
  180. LearnSystem = fa.LearnSystem,
  181. FacultymajorID = fa.FacultymajorID,
  182. FacultymajorCode = fa.Code,
  183. FacultymajorName = fa.Name,
  184. GrademajorID = gr.GrademajorID,
  185. GrademajorCode = gr.Code,
  186. GrademajorName = gr.Name,
  187. SemesterID = rs.SemesterID,
  188. isGenerated = rs.isGenerated ?? false
  189. };
  190. return query;
  191. }
  192. /// <summary>
  193. /// 根据招生专业信息、院系专业信息、年级专业信息查询对应的班级信息(业务主键:年级专业ID)
  194. /// </summary>
  195. /// <param name="expRecruitSpecialty"></param>
  196. /// <param name="expFacultymajor"></param>
  197. /// <param name="expGrademajor"></param>
  198. /// <returns></returns>
  199. public IQueryable<RecruitSpecialtyClassView> GetClassmajorByRecruitSpecialty(Expression<Func<CF_RecruitSpecialty, bool>> expRecruitSpecialty,
  200. Expression<Func<CF_Facultymajor, bool>> expFacultymajor, Expression<Func<CF_Grademajor, bool>> expGrademajor)
  201. {
  202. var query = from rs in recruitSpecialtyRepository.GetList(expRecruitSpecialty)
  203. join col in collegeRepository.Entities
  204. on rs.CollegeID equals col.CollegeID
  205. join sp in specialtyRepository.Entities
  206. on rs.SpecialtyID equals sp.SpecialtyID
  207. join fa in facultymajorRepository.GetList(expFacultymajor)
  208. on new { sp.StandardID, sp.EducationID, sp.LearningformID, sp.LearnSystem, rs.CollegeID }
  209. equals new { fa.StandardID, fa.EducationID, fa.LearningformID, fa.LearnSystem, fa.CollegeID }
  210. join gr in grademajorRepository.GetList(expGrademajor)
  211. on new { FacultymajorID = fa.FacultymajorID, GradeID = rs.GradeID, SemesterID = rs.SemesterID }
  212. equals new { FacultymajorID = gr.FacultymajorID.Value, GradeID = gr.GradeID, SemesterID = gr.SemesterID }
  213. join cl in classmajorRepository.Entities
  214. on gr.GrademajorID equals cl.GrademajorID
  215. select new RecruitSpecialtyClassView
  216. {
  217. RecruitSpecialtyID = rs.RecruitSpecialtyID,
  218. CollegeID = rs.CollegeID,
  219. CollegeNo = col.No,
  220. CollegeName = col.Name,
  221. GradeID = rs.GradeID,
  222. SpecialtyID = rs.SpecialtyID,
  223. StandardID = fa.StandardID,
  224. EducationID = fa.EducationID,
  225. LearningformID = fa.LearningformID,
  226. LearnSystem = fa.LearnSystem,
  227. FacultymajorID = fa.FacultymajorID,
  228. FacultymajorCode = fa.Code,
  229. FacultymajorName = fa.Name,
  230. GrademajorID = gr.GrademajorID,
  231. GrademajorCode = gr.Code,
  232. GrademajorName = gr.Name,
  233. SemesterID = rs.SemesterID,
  234. ClassmajorID = cl.ClassmajorID,
  235. ClassmajorNo = cl.No,
  236. ClassmajorName = cl.Name,
  237. isGenerated = rs.isGenerated ?? false
  238. };
  239. return query;
  240. }
  241. /// <summary>
  242. /// 根据院系所、学制查询对应的院系专业信息当前MaxCode(院系所、学制分组查询)
  243. /// </summary>
  244. /// <param name="expFacultymajor"></param>
  245. /// <returns></returns>
  246. public IQueryable<FacultymajorView> GetFacultymajorMaxCodeByCollegeLearnSystem(Expression<Func<CF_Facultymajor, bool>> expFacultymajor)
  247. {
  248. var query = from fa in facultymajorRepository.GetList(expFacultymajor)
  249. group fa by new { fa.CollegeID, fa.LearnSystem } into g
  250. select new FacultymajorView
  251. {
  252. CollegeID = g.Key.CollegeID,
  253. LearnSystem = g.Key.LearnSystem,
  254. Code = g.Max(x => x.Code)
  255. };
  256. return query;
  257. }
  258. /// <summary>
  259. /// 根据院系所、年级查询对应的年级专业信息当前MaxCode(院系所、年级分组查询)
  260. /// </summary>
  261. /// <param name="expGrademajor"></param>
  262. /// <returns></returns>
  263. public IQueryable<GrademajorView> GetGrademajorMaxCodeByCollegeSchoolyear(Expression<Func<CF_Grademajor, bool>> expGrademajor)
  264. {
  265. var query = from gr in grademajorRepository.GetList(expGrademajor)
  266. join fa in facultymajorRepository.Entities
  267. on gr.FacultymajorID equals fa.FacultymajorID
  268. group gr by new { fa.CollegeID, gr.GradeID } into g
  269. select new GrademajorView
  270. {
  271. CollegeID = g.Key.CollegeID,
  272. GradeID = g.Key.GradeID,
  273. Code = g.Max(x => x.Code)
  274. };
  275. return query;
  276. }
  277. /// <summary>
  278. /// 根据年级专业查询对应的班级信息当前MaxCode(年级专业分组查询)
  279. /// </summary>
  280. /// <param name="expClassmajor"></param>
  281. /// <returns></returns>
  282. public IQueryable<ClassmajorView> GetClassmajorMaxCodeByGrademajor(Expression<Func<CF_Classmajor, bool>> expClassmajor)
  283. {
  284. var query = from cl in classmajorRepository.GetList(expClassmajor)
  285. group cl by new { cl.GrademajorID, cl.CF_Grademajor.GradeID, cl.CF_Grademajor.CF_Facultymajor.CollegeID } into g
  286. select new ClassmajorView
  287. {
  288. GrademajorID = g.Key.GrademajorID,
  289. CollegeID = g.Key.CollegeID,
  290. GradeID = g.Key.GradeID,
  291. No = g.Max(x => x.No)
  292. };
  293. return query;
  294. }
  295. }
  296. }