CampusDAL.cs 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181
  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.UniversityManage.AdministrativeOrgan;
  8. using EMIS.DataLogic.Repositories;
  9. namespace EMIS.DataLogic.UniversityManage.AdministrativeOrgan
  10. {
  11. public class CampusDAL
  12. {
  13. public CampusRepository CampusRepository { get; set; }
  14. public CampusProfileRepository CampusProfileRepository { get; set; }
  15. public CollegeRepository CollegeRepository { get; set; }
  16. public DepartmentRepository DepartmentRepository { get; set; }
  17. public StaffRepository StaffRepository { get; set; }
  18. public FacultymajorRepository FacultymajorRepository { get; set; }
  19. public UserRepository UserRepository { get; set; }
  20. /// <summary>
  21. /// 查询对应的校区信息View
  22. /// </summary>
  23. /// <param name="expCampus"></param>
  24. /// <returns></returns>
  25. public IQueryable<CampusView> GetCampusViewQueryable(Expression<Func<CF_Campus, bool>> expCampus)
  26. {
  27. var query = from a in CampusRepository.GetList(expCampus)
  28. join c in UserRepository.Entities
  29. on a.CF_CampusProfile.Generalsuper equals c.UserID into gg
  30. from gGeneralsuper in gg.DefaultIfEmpty()
  31. join d in UserRepository.Entities
  32. on a.CF_CampusProfile.Recruitstudents equals d.UserID into gr
  33. from gRecruitstudents in gr.DefaultIfEmpty()
  34. join e in UserRepository.Entities
  35. on a.CF_CampusProfile.Placesuper equals e.UserID into gp
  36. from gPlacesuper in gp.DefaultIfEmpty()
  37. join f in UserRepository.Entities
  38. on a.CF_CampusProfile.Teachingsuper equals f.UserID into gt
  39. from gTeachingsuper in gt.DefaultIfEmpty()
  40. join g in UserRepository.Entities
  41. on a.CF_CampusProfile.Studentcharge equals g.UserID into gsc
  42. from gStudentcharge in gsc.DefaultIfEmpty()
  43. join col in
  44. (
  45. from col in CollegeRepository.Entities
  46. group col by col.CampusID into colgr
  47. select new
  48. {
  49. CampusID = colgr.Key,
  50. CollegeCount = colgr.Count()
  51. }
  52. )
  53. on a.CampusID equals col.CampusID into tempcol
  54. from colcam in tempcol.DefaultIfEmpty()
  55. select new CampusView
  56. {
  57. CampusID = a.CampusID,
  58. UniversityID = a.UniversityID,
  59. No = a.No,
  60. Name = a.Name,
  61. SimpleName = a.SimpleName,
  62. EnglishName = a.EnglishName,
  63. UniversityCode = a.CF_University.Code,
  64. UniversityName = a.CF_University.Name,
  65. Generalsuper = a.CF_CampusProfile.Generalsuper,
  66. GeneralsuperName = gGeneralsuper.Name,
  67. Recruitstudents = a.CF_CampusProfile.Recruitstudents,
  68. RecruitstudentsName = gRecruitstudents.Name,
  69. Placesuper = a.CF_CampusProfile.Placesuper,
  70. PlacesuperName = gPlacesuper.Name,
  71. Teachingsuper = a.CF_CampusProfile.Teachingsuper,
  72. TeachingsuperName = gTeachingsuper.Name,
  73. Studentcharge = a.CF_CampusProfile.Studentcharge,
  74. StudentchargeName = gStudentcharge.Name,
  75. ZIPCode = a.CF_CampusProfile.ZIPCode,
  76. Officephone = a.CF_CampusProfile.Officephone,
  77. FAX = a.CF_CampusProfile.FAX,
  78. Email = a.CF_CampusProfile.Email,
  79. Evolution = a.CF_CampusProfile.Evolution,
  80. CollegeCount = colcam.CollegeCount == null ? 0 : colcam.CollegeCount,
  81. Remark = a.Remark,
  82. RecordStatus = a.RecordStatus,
  83. CreateUserID = a.CreateUserID,
  84. CreateTime = a.CreateTime,
  85. ModifyUserID = a.ModifyUserID,
  86. ModifyTime = a.ModifyTime
  87. };
  88. return query;
  89. }
  90. /// <summary>
  91. /// 查询对应的院系所信息View(统计教研室数、教师人数、院系专业数)
  92. /// </summary>
  93. /// <param name="expCampus"></param>
  94. /// <returns></returns>
  95. public IQueryable<CollegeView> GetCollegeViewQueryable(Expression<Func<CF_Campus, bool>> expCampus)
  96. {
  97. var query = from cam in CampusRepository.GetList(expCampus)
  98. join col in CollegeRepository.Entities
  99. on cam.CampusID equals col.CampusID
  100. join pm in UserRepository.Entities
  101. on col.CF_CollegeProfile.PoliticalManager equals pm.UserID into temppm
  102. from pmus in temppm.DefaultIfEmpty()
  103. join am in UserRepository.Entities
  104. on col.CF_CollegeProfile.AdministrativeManager equals am.UserID into tempam
  105. from amus in tempam.DefaultIfEmpty()
  106. join dep in
  107. (
  108. from dep in DepartmentRepository.Entities
  109. group dep by dep.CollegeID into depgr
  110. select new
  111. {
  112. CollegeID = depgr.Key,
  113. DepartmentCount = depgr.Count()
  114. }
  115. )
  116. on col.CollegeID equals dep.CollegeID into tempdep
  117. from depcol in tempdep.DefaultIfEmpty()
  118. join sta in
  119. (
  120. from sta in StaffRepository.Entities
  121. group sta by sta.CollegeID into stagr
  122. select new
  123. {
  124. CollegeID = stagr.Key,
  125. StaffCount = stagr.Count()
  126. }
  127. )
  128. on col.CollegeID equals sta.CollegeID into tempsta
  129. from stacol in tempsta.DefaultIfEmpty()
  130. join fa in
  131. (
  132. from fa in FacultymajorRepository.Entities
  133. group fa by fa.CollegeID into fagr
  134. select new
  135. {
  136. CollegeID = fagr.Key,
  137. FacultymajorCount = fagr.Count()
  138. }
  139. )
  140. on col.CollegeID equals fa.CollegeID into tempfa
  141. from facol in tempfa.DefaultIfEmpty()
  142. select new CollegeView
  143. {
  144. CollegeID = col.CollegeID,
  145. No = col.No,
  146. Name = col.Name,
  147. SimpleName = col.SimpleName,
  148. EnglishName = col.EnglishName,
  149. CampusID = col.CampusID,
  150. CampusNo = cam.No,
  151. CampusName = cam.Name,
  152. PoliticalManager = col.CF_CollegeProfile.PoliticalManager,
  153. PoliticalManagerName = pmus.Name,
  154. AdministrativeManager = col.CF_CollegeProfile.AdministrativeManager,
  155. AdministrativeManagerName = amus.Name,
  156. UnitCategoryID = col.CF_CollegeProfile.UnitCategoryID,
  157. CollegeTypeID = col.CF_CollegeProfile.CollegeTypeID,
  158. CollegeCategoryID = col.CF_CollegeProfile.CollegeCategoryID,
  159. RunByCategoryID = col.CF_CollegeProfile.RunByCategoryID,
  160. FoundDate = col.CF_CollegeProfile.FoundDate,
  161. Officephone = col.CF_CollegeProfile.Officephone,
  162. DepartmentCount = depcol.DepartmentCount == null ? 0 : depcol.DepartmentCount,
  163. StaffCount = stacol.StaffCount == null ? 0 : stacol.StaffCount,
  164. FacultymajorCount = facol.FacultymajorCount == null ? 0 : facol.FacultymajorCount,
  165. Remark = col.Remark,
  166. RecordStatus = col.RecordStatus,
  167. CreateUserID = col.CreateUserID,
  168. CreateTime = col.CreateTime,
  169. ModifyUserID = col.ModifyUserID,
  170. ModifyTime = col.ModifyTime
  171. };
  172. return query;
  173. }
  174. }
  175. }