DepartmentDAL.cs 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  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.ViewModel.UniversityManage.TeacherManage;
  9. using EMIS.DataLogic.Repositories;
  10. namespace EMIS.DataLogic.UniversityManage.AdministrativeOrgan
  11. {
  12. public class DepartmentDAL
  13. {
  14. public DepartmentRepository DepartmentRepository { get; set; }
  15. public DepartmentProfileRepository DepartmentProfileRepository { get; set; }
  16. public CollegeRepository CollegeRepository { get; set; }
  17. public CampusRepository CampusRepository { get; set; }
  18. public UniversityRepository UniversityRepository { get; set; }
  19. public StaffRepository StaffRepository { get; set; }
  20. public StaffProfileRepository StaffProfileRepository { get; set; }
  21. public UserRepository UserRepository { get; set; }
  22. /// <summary>
  23. /// 查询对应的部门信息View
  24. /// </summary>
  25. /// <param name="expDepartment"></param>
  26. /// <returns></returns>
  27. public IQueryable<DepartmentView> GetDepartmentViewQueryable(Expression<Func<CF_Department, bool>> expDepartment)
  28. {
  29. var query = from dep in DepartmentRepository.GetList(expDepartment)
  30. join c in UserRepository.Entities
  31. on dep.CF_DepartmentProfile.DirectorID equals c.UserID into gu
  32. from guic in gu.DefaultIfEmpty()
  33. join d in UserRepository.Entities
  34. on dep.CF_DepartmentProfile.DeputyDirectorID equals d.UserID into gude
  35. from gudeic in gude.DefaultIfEmpty()
  36. join sta in
  37. (
  38. from sta in StaffRepository.Entities
  39. group sta by sta.DepartmentID into stagr
  40. select new
  41. {
  42. DepartmentID = stagr.Key,
  43. StaffCount = stagr.Count()
  44. }
  45. )
  46. on dep.DepartmentID equals sta.DepartmentID into tempsta
  47. from stadep in tempsta.DefaultIfEmpty()
  48. select new DepartmentView
  49. {
  50. DepartmentID = dep.DepartmentID,
  51. No = dep.No,
  52. Name = dep.Name,
  53. SimpleName = dep.SimpleName,
  54. EnglishName = dep.EnglishName,
  55. CampusID = dep.CF_College.CampusID,
  56. CampusNo = dep.CF_College.CF_Campus.No,
  57. CampusName = dep.CF_College.CF_Campus.Name,
  58. CollegeID = dep.CollegeID,
  59. CollegeCode = dep.CF_College.No,
  60. CollegeName = dep.CF_College.Name,
  61. HierarchyID = dep.HierarchyID,
  62. DirectorID = dep.CF_DepartmentProfile.DirectorID,
  63. DirectorName = guic.Name,
  64. DeputyDirectorID = dep.CF_DepartmentProfile.DeputyDirectorID,
  65. DeputyDirectorName = gudeic.Name,
  66. FoundDate = dep.CF_DepartmentProfile.FoundDate,
  67. StaffCount = stadep.StaffCount == null ? 0 : stadep.StaffCount,
  68. Remark = dep.Remark,
  69. RecordStatus = dep.RecordStatus,
  70. CreateUserID = dep.CreateUserID,
  71. CreateTime = dep.CreateTime,
  72. ModifyUserID = dep.ModifyUserID,
  73. ModifyTime = dep.ModifyTime
  74. };
  75. return query;
  76. }
  77. /// <summary>
  78. /// 查询教研室对应的教师信息StaffView
  79. /// </summary>
  80. /// <param name="expDepartment"></param>
  81. /// <returns></returns>
  82. public IQueryable<StaffView> GetStaffViewQueryable(Expression<Func<CF_Department, bool>> expDepartment)
  83. {
  84. var query = from dep in DepartmentRepository.GetList(expDepartment)
  85. join sf in StaffRepository.Entities
  86. on dep.DepartmentID equals sf.DepartmentID
  87. join pr in StaffProfileRepository.Entities
  88. on sf.UserID equals pr.UserID into temppr
  89. from sfpr in temppr.DefaultIfEmpty()
  90. join col in CollegeRepository.Entities
  91. on sf.CollegeID equals col.CollegeID into tempcol
  92. from sfcol in tempcol.DefaultIfEmpty()
  93. join us in UserRepository.Entities
  94. on sf.UserID equals us.UserID
  95. select new StaffView
  96. {
  97. UserID = sf.UserID,
  98. StaffCode = us.LoginID,
  99. Name = us.Name,
  100. UsedName = sfpr.UsedName,
  101. CampusID = sfcol.CampusID,
  102. CampusCode = sfcol.CF_Campus.No,
  103. CampusName = sfcol.CF_Campus.Name,
  104. CollegeID = sf.CollegeID,
  105. CollegeNo = sfcol.No,
  106. CollegeName = sfcol.Name,
  107. DepartmentID = sf.DepartmentID,
  108. DepartmentCode = dep.No,
  109. DepartmentName = dep.Name,
  110. Nationality = sfpr.Nationality,
  111. Place = sfpr.Place,
  112. SexID = sf.SexID,
  113. BirthDate = sf.BirthDate,
  114. NationID = sf.NationID,
  115. PoliticsID = sf.PoliticsID,
  116. CertificatesType = sf.CertificatesType,
  117. CertificatesNum = sf.CertificatesNum,
  118. TeacherTypeID = sf.TeacherTypeID,
  119. IncumbencyState = sf.IncumbencyState,
  120. SituationID = sf.SituationID,
  121. TitleID = sf.TitleID,
  122. LiteracyLevelID = sf.LiteracyLevelID,
  123. LearnPositionID = sf.LearnPositionID,
  124. IsDualTeacher = sf.IsDualTeacher ?? false,
  125. PaymentLevelID = sf.PaymentLevelID,
  126. WorkDate = sf.WorkDate,
  127. ComeSchoolDate = sf.ComeSchoolDate,
  128. Email = sfpr.Email,
  129. ZIPCode = sfpr.ZIPCode,
  130. WeChatNum = sfpr.WeChatNum,
  131. QQ = sfpr.QQ,
  132. Telephone = sfpr.Telephone,
  133. OfficeTelephone = sfpr.OfficeTelephone,
  134. HousePhone = sfpr.HousePhone,
  135. Mobile = sfpr.Mobile,
  136. Speciality = sfpr.Speciality,
  137. HealthStateID = sfpr.HealthStateID,
  138. ReligionID = sfpr.ReligionID,
  139. Account = sfpr.Account,
  140. Residence = sfpr.Residence,
  141. HomeAddress = sfpr.HomeAddress,
  142. Address = sfpr.Address,
  143. NowAddress = sfpr.NowAddress,
  144. PhotoUrl = sf.PhotoUrl,
  145. PhotoHasValue = (sf.PhotoUrl == null || sf.PhotoUrl == "") ? false : true,
  146. Profile = sf.Profile,
  147. Remark = sf.Remark,
  148. RecordStatus = sf.RecordStatus,
  149. CreateUserID = sf.CreateUserID,
  150. CreateTime = sf.CreateTime,
  151. ModifyUserID = sf.ModifyUserID,
  152. ModifyTime = sf.ModifyTime
  153. };
  154. return query;
  155. }
  156. }
  157. }