CollegeClassroomDAL.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Linq.Expressions;
  6. using EMIS.Entities;
  7. using EMIS.ViewModel.SchedulingManage.SchedulingSettings;
  8. using EMIS.ViewModel.UniversityManage.ClassroomManage;
  9. using EMIS.DataLogic.Repositories;
  10. namespace EMIS.DataLogic.SchedulingManage.SchedulingSettings
  11. {
  12. public class CollegeClassroomDAL
  13. {
  14. public CollegeClassroomRepository CollegeClassroomRepository { get; set; }
  15. public CollegeRepository CollegeRepository { get; set; }
  16. public CampusRepository CampusRepository { get; set; }
  17. public ClassroomRepository ClassroomRepository { get; set; }
  18. public ClassroomReserveRepository ClassroomReserveRepository { get; set; }
  19. /// <summary>
  20. /// 查询院系教室信息CollegeClassroomView(关联排课中教室预留信息)
  21. /// </summary>
  22. /// <param name="exp"></param>
  23. /// <returns></returns>
  24. public IQueryable<CollegeClassroomView> GetCollegeClassroomViewQueryable(Expression<Func<ES_CollegeClassroom, bool>> exp)
  25. {
  26. var query = from colcr in CollegeClassroomRepository.GetList(exp)
  27. join col in CollegeRepository.Entities
  28. on colcr.CollegeID equals col.CollegeID
  29. join cam in CampusRepository.Entities
  30. on col.CampusID equals cam.CampusID
  31. join cr in ClassroomRepository.Entities
  32. on colcr.ClassroomID equals cr.ClassroomID
  33. join re in ClassroomReserveRepository.Entities
  34. on cr.ClassroomID equals re.ClassroomID into tempre
  35. from crre in tempre.DefaultIfEmpty()
  36. select new CollegeClassroomView
  37. {
  38. CollegeClassroomID = colcr.CollegeClassroomID,
  39. CollegeID = colcr.CollegeID,
  40. CollegeNo = col.No,
  41. CollegeName = col.Name,
  42. UnitCategoryID = col.CF_CollegeProfile.UnitCategoryID,
  43. CollegeCampusID = col.CampusID,
  44. CollegeCampusNo = cam.No,
  45. CollegeCampusName = cam.Name,
  46. ClassroomID = colcr.ClassroomID,
  47. ClassroomCode = cr.Code,
  48. ClassroomName = cr.Name,
  49. ClassroomCollegeID = cr.CollegeID,
  50. ClassroomCollegeNo = cr.CF_College.No,
  51. ClassroomCollegeName = cr.CF_College.Name,
  52. BuildingsInfoID = cr.BuildingsInfoID,
  53. BuildingsInfoCode = cr.CF_BuildingsInfo.Code,
  54. BuildingsInfoName = cr.CF_BuildingsInfo.Name,
  55. CampusID = cr.CF_BuildingsInfo.CampusID,
  56. CampusNo = cr.CF_BuildingsInfo.CF_Campus.No,
  57. CampusName = cr.CF_BuildingsInfo.CF_Campus.Name,
  58. CF_ClassroomType = cr.CF_ClassroomType,
  59. ClassroomTypeIDList = cr.CF_ClassroomType.Select(x => x.ClassroomType).ToList(),
  60. RoomUseID = cr.RoomUseID,
  61. Totalseating = cr.Totalseating,
  62. Effectiveseating = cr.Effectiveseating,
  63. IsConcurrentUse = cr.IsConcurrentUse ?? false,
  64. IsReserve = crre.IsReserved == true ? true : false,
  65. IsAvailable = cr.IsAvailable ?? false,
  66. RecordStatus = colcr.RecordStatus,
  67. CreateUserID = colcr.CreateUserID,
  68. CreateTime = colcr.CreateTime,
  69. ModifyUserID = colcr.ModifyUserID,
  70. ModifyTime = colcr.ModifyTime
  71. };
  72. return query;
  73. }
  74. /// <summary>
  75. /// 查询院系教室中未新增的教室信息ClassroomView
  76. /// </summary>
  77. /// <param name="expClassroom"></param>
  78. /// <param name="expCollegeClassroom"></param>
  79. /// <returns></returns>
  80. public IQueryable<ClassroomView> GetClassroomViewNoAddQueryable(Expression<Func<CF_Classroom, bool>> expClassroom,
  81. Expression<Func<ES_CollegeClassroom, bool>> expCollegeClassroom)
  82. {
  83. var query = from cr in ClassroomRepository.GetList(expClassroom)
  84. join re in ClassroomReserveRepository.Entities
  85. on cr.ClassroomID equals re.ClassroomID into tempre
  86. from crre in tempre.DefaultIfEmpty()
  87. join cc in CollegeClassroomRepository.GetList(expCollegeClassroom)
  88. on cr.ClassroomID equals cc.ClassroomID into tempcc
  89. from colcr in tempcc.DefaultIfEmpty()
  90. where colcr.CollegeClassroomID == null
  91. select new ClassroomView
  92. {
  93. ClassroomID = cr.ClassroomID,
  94. Code = cr.Code,
  95. Name = cr.Name,
  96. BuildingsInfoID = cr.BuildingsInfoID,
  97. BuildingsInfoCode = cr.CF_BuildingsInfo.Code,
  98. BuildingsInfoName = cr.CF_BuildingsInfo.Name,
  99. CampusID = cr.CF_BuildingsInfo.CampusID,
  100. CampusCode = cr.CF_BuildingsInfo.CF_Campus.No,
  101. CampusName = cr.CF_BuildingsInfo.CF_Campus.Name,
  102. CollegeID = cr.CollegeID,
  103. CollegeCode = cr.CF_College.No,
  104. CollegeName = cr.CF_College.Name,
  105. LayoutTypeID = cr.LayoutTypeID,
  106. CF_ClassroomType = cr.CF_ClassroomType,
  107. RoomUseID = cr.RoomUseID,
  108. FloorLevel = cr.FloorLevel,
  109. Acreage = cr.Acreage,
  110. RowCout = cr.RowCout,
  111. ColumnCount = cr.ColumnCount,
  112. Totalseating = cr.Totalseating,
  113. Effectiveseating = cr.Effectiveseating,
  114. Examinationseating = cr.Examinationseating,
  115. IsWrittenExam = cr.IsWrittenExam ?? false,
  116. IsMachinetest = cr.IsMachinetest ?? false,
  117. IsConcurrentUse = cr.IsConcurrentUse ?? false,
  118. IsReserve = crre.IsReserved == true ? true : false,
  119. IsAvailable = cr.IsAvailable ?? false,
  120. Remark = cr.Remark,
  121. RecordStatus = cr.RecordStatus,
  122. CreateUserID = cr.CreateUserID,
  123. CreateTime = cr.CreateTime,
  124. ModifyUserID = cr.ModifyUserID,
  125. ModifyTime = cr.ModifyTime
  126. };
  127. return query;
  128. }
  129. /// <summary>
  130. /// 查询未新增的院系教室信息CollegeClassroomView(关联排课中教室预留信息)
  131. /// 注:交叉连接(暂时无效,有问题)
  132. /// </summary>
  133. /// <param name="expCollege"></param>
  134. /// <param name="expClassroom"></param>
  135. /// <returns></returns>
  136. public IQueryable<CollegeClassroomView> GetCollegeClassroomViewNoAddQueryable(Expression<Func<CF_College, bool>> expCollege,
  137. Expression<Func<CF_Classroom, bool>> expClassroom)
  138. {
  139. //var crossJoinQuery = CollegeRepository.GetList(expCollege)
  140. // .SelectMany(x => ClassroomRepository.Entities
  141. // .Select(c => new { CollegeID = x.CollegeID, ClassroomID = c.ClassroomID }));
  142. var crossJoinQuery = from col in CollegeRepository.GetList(expCollege)
  143. from cr in ClassroomRepository.Entities
  144. select new
  145. {
  146. CollegeID = col.CollegeID,
  147. ClassroomID = cr.ClassroomID
  148. };
  149. var query = from crosscc in crossJoinQuery
  150. join cc in CollegeClassroomRepository.Entities
  151. on new { CollegeID = crosscc.CollegeID, ClassroomID = crosscc.ClassroomID }
  152. equals new { CollegeID = cc.CollegeID.Value, ClassroomID = cc.ClassroomID.Value } into tempcc
  153. from colcr in tempcc.DefaultIfEmpty()
  154. join col in CollegeRepository.GetList(expCollege)
  155. on crosscc.CollegeID equals col.CollegeID
  156. join cam in CampusRepository.Entities
  157. on col.CampusID equals cam.CampusID
  158. join cr in ClassroomRepository.GetList(expClassroom)
  159. on crosscc.ClassroomID equals cr.ClassroomID
  160. join re in ClassroomReserveRepository.Entities
  161. on cr.ClassroomID equals re.ClassroomID into tempre
  162. from crre in tempre.DefaultIfEmpty()
  163. where colcr.CollegeClassroomID == null
  164. select new CollegeClassroomView
  165. {
  166. CollegeClassroomID = Guid.NewGuid(),
  167. CollegeID = col.CollegeID,
  168. CollegeNo = col.No,
  169. CollegeName = col.Name,
  170. UnitCategoryID = col.CF_CollegeProfile.UnitCategoryID,
  171. CollegeCampusID = col.CampusID,
  172. CollegeCampusNo = cam.No,
  173. CollegeCampusName = cam.Name,
  174. ClassroomID = cr.ClassroomID,
  175. ClassroomCode = cr.Code,
  176. ClassroomName = cr.Name,
  177. ClassroomCollegeID = cr.CollegeID,
  178. ClassroomCollegeNo = cr.CF_College.No,
  179. ClassroomCollegeName = cr.CF_College.Name,
  180. BuildingsInfoID = cr.BuildingsInfoID,
  181. BuildingsInfoCode = cr.CF_BuildingsInfo.Code,
  182. BuildingsInfoName = cr.CF_BuildingsInfo.Name,
  183. CampusID = cr.CF_BuildingsInfo.CampusID,
  184. CampusNo = cr.CF_BuildingsInfo.CF_Campus.No,
  185. CampusName = cr.CF_BuildingsInfo.CF_Campus.Name,
  186. CF_ClassroomType = cr.CF_ClassroomType,
  187. ClassroomTypeIDList = cr.CF_ClassroomType.Select(x => x.ClassroomType).ToList(),
  188. RoomUseID = cr.RoomUseID,
  189. Totalseating = cr.Totalseating,
  190. Effectiveseating = cr.Effectiveseating,
  191. IsConcurrentUse = cr.IsConcurrentUse ?? false,
  192. IsReserve = crre.IsReserved == true ? true : false,
  193. IsAvailable = cr.IsAvailable ?? false
  194. };
  195. return query;
  196. }
  197. }
  198. }