ClassroomReserveDAL.cs 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185
  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 ClassroomReserveDAL
  13. {
  14. public ClassroomReserveRepository ClassroomReserveRepository { get; set; }
  15. public ClassroomRepository ClassroomRepository { get; set; }
  16. public CollegeClassroomRepository CollegeClassroomRepository { get; set; }
  17. public UserRepository UserRepository { get; set; }
  18. public DictionaryItemRepository DictionaryItemRepository { get; set; }
  19. /// <summary>
  20. /// 查询教室预留信息ClassroomReserveView(根据教室预留信息、统计排课分配院系个数)
  21. /// </summary>
  22. /// <param name="exp"></param>
  23. /// <returns></returns>
  24. public IQueryable<ClassroomReserveView> GetClassroomReserveViewQueryable(Expression<Func<ES_ClassroomReserve, bool>> exp)
  25. {
  26. var query = from re in ClassroomReserveRepository.GetList(exp)
  27. join cr in ClassroomRepository.Entities
  28. on re.ClassroomID equals cr.ClassroomID
  29. join cc in
  30. (
  31. from cc in CollegeClassroomRepository.Entities
  32. group cc by cc.ClassroomID into gcr
  33. select new
  34. {
  35. ClassroomID = gcr.Key,
  36. ScheduleCollegeCount = gcr.Count()
  37. }
  38. )
  39. on re.ClassroomID equals cc.ClassroomID into tempcc
  40. from colcr in tempcc.DefaultIfEmpty()
  41. join cus in UserRepository.Entities
  42. on re.CreateUserID equals cus.UserID into tempcus
  43. from recus in tempcus.DefaultIfEmpty()
  44. select new ClassroomReserveView
  45. {
  46. ClassroomReserveID = re.ClassroomReserveID,
  47. ClassroomID = cr.ClassroomID,
  48. ClassroomCode = cr.Code,
  49. ClassroomName = cr.Name,
  50. BuildingsInfoID = cr.BuildingsInfoID,
  51. BuildingsInfoCode = cr.CF_BuildingsInfo.Code,
  52. BuildingsInfoName = cr.CF_BuildingsInfo.Name,
  53. CampusID = cr.CF_BuildingsInfo.CampusID,
  54. CampusNo = cr.CF_BuildingsInfo.CF_Campus.No,
  55. CampusName = cr.CF_BuildingsInfo.CF_Campus.Name,
  56. CollegeID = cr.CollegeID,
  57. CollegeCode = cr.CF_College.No,
  58. CollegeName = cr.CF_College.Name,
  59. UnitCategoryID = cr.CF_College.CF_CollegeProfile.UnitCategoryID,
  60. CollegeCampusID = cr.CF_College.CampusID,
  61. CollegeCampusCode = cr.CF_College.CF_Campus.No,
  62. CollegeCampusName = cr.CF_College.CF_Campus.Name,
  63. CF_ClassroomType = cr.CF_ClassroomType,
  64. ClassroomTypeIDList = cr.CF_ClassroomType.Select(x => x.ClassroomType).ToList(),
  65. RoomUseID = cr.RoomUseID,
  66. Totalseating = cr.Totalseating,
  67. Effectiveseating = cr.Effectiveseating,
  68. IsConcurrentUse = cr.IsConcurrentUse ?? false,
  69. IsReserve = re.IsReserved == true ? true : false,
  70. IsAvailable = cr.IsAvailable ?? false,
  71. ScheduleCollegeCount = colcr.ScheduleCollegeCount == null ? 0 : colcr.ScheduleCollegeCount,
  72. RecordStatus = re.RecordStatus,
  73. CreateUserID = re.CreateUserID,
  74. CreateUserName = recus.Name,
  75. CreateTime = re.CreateTime,
  76. ModifyUserID = re.ModifyUserID,
  77. ModifyTime = re.ModifyTime
  78. };
  79. return query;
  80. }
  81. /// <summary>
  82. /// 查询未预留的教室信息ClassroomView
  83. /// </summary>
  84. /// <param name="exp"></param>
  85. /// <returns></returns>
  86. public IQueryable<ClassroomView> GetClassroomViewNoReserveQueryable(Expression<Func<CF_Classroom, bool>> exp)
  87. {
  88. var query = from cr in ClassroomRepository.GetList(exp)
  89. join re in ClassroomReserveRepository.Entities
  90. on cr.ClassroomID equals re.ClassroomID into tempre
  91. from crre in tempre.DefaultIfEmpty()
  92. where crre.ClassroomReserveID == null
  93. select new ClassroomView
  94. {
  95. ClassroomID = cr.ClassroomID,
  96. Code = cr.Code,
  97. Name = cr.Name,
  98. BuildingsInfoID = cr.BuildingsInfoID,
  99. BuildingsInfoCode = cr.CF_BuildingsInfo.Code,
  100. BuildingsInfoName = cr.CF_BuildingsInfo.Name,
  101. CampusID = cr.CF_BuildingsInfo.CampusID,
  102. CampusCode = cr.CF_BuildingsInfo.CF_Campus.No,
  103. CampusName = cr.CF_BuildingsInfo.CF_Campus.Name,
  104. CollegeID = cr.CollegeID,
  105. CollegeCode = cr.CF_College.No,
  106. CollegeName = cr.CF_College.Name,
  107. UnitCategoryID = cr.CF_College.CF_CollegeProfile.UnitCategoryID,
  108. CollegeCampusID = cr.CF_College.CampusID,
  109. CollegeCampusCode = cr.CF_College.CF_Campus.No,
  110. CollegeCampusName = cr.CF_College.CF_Campus.Name,
  111. CF_ClassroomType = cr.CF_ClassroomType,
  112. ClassroomTypeIDList = cr.CF_ClassroomType.Select(x => x.ClassroomType).ToList(),
  113. LayoutTypeID = cr.LayoutTypeID,
  114. RoomUseID = cr.RoomUseID,
  115. FloorLevel = cr.FloorLevel,
  116. Acreage = cr.Acreage,
  117. RowCout = cr.RowCout,
  118. ColumnCount = cr.ColumnCount,
  119. Totalseating = cr.Totalseating,
  120. Effectiveseating = cr.Effectiveseating,
  121. Examinationseating = cr.Examinationseating,
  122. IsWrittenExam = cr.IsWrittenExam ?? false,
  123. IsMachinetest = cr.IsMachinetest ?? false,
  124. IsConcurrentUse = cr.IsConcurrentUse ?? false,
  125. IsAvailable = cr.IsAvailable ?? false,
  126. Remark = cr.Remark,
  127. RecordStatus = cr.RecordStatus,
  128. CreateUserID = cr.CreateUserID,
  129. CreateTime = cr.CreateTime,
  130. ModifyUserID = cr.ModifyUserID,
  131. ModifyTime = cr.ModifyTime
  132. };
  133. return query;
  134. }
  135. /// <summary>
  136. /// 查询教室类型信息ClassroomTypeView
  137. /// </summary>
  138. /// <returns></returns>
  139. public IQueryable<ClassroomTypeView> GetClassroomTypeViewQueryable()
  140. {
  141. var query = from cr in ClassroomRepository.Entities
  142. from crct in cr.CF_ClassroomType
  143. join dicct in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(EMIS.ViewModel.CF_ClassroomType).Name)
  144. on crct.ClassroomType equals dicct.Value
  145. select new ClassroomTypeView
  146. {
  147. ClassroomTypeID = crct.ClassroomTypeID,
  148. ClassroomID = cr.ClassroomID,
  149. ClassroomType = crct.ClassroomType,
  150. ClassroomTypeName = dicct.Name
  151. };
  152. return query;
  153. }
  154. /// <summary>
  155. /// 查询教室类型信息ClassroomTypeView(根据教室信息)
  156. /// </summary>
  157. /// <param name="exp"></param>
  158. /// <returns></returns>
  159. public IQueryable<ClassroomTypeView> GetClassroomTypeViewQueryable(Expression<Func<CF_Classroom, bool>> exp)
  160. {
  161. var query = from cr in ClassroomRepository.GetList(exp)
  162. from crct in cr.CF_ClassroomType
  163. join dicct in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(EMIS.ViewModel.CF_ClassroomType).Name)
  164. on crct.ClassroomType equals dicct.Value
  165. select new ClassroomTypeView
  166. {
  167. ClassroomTypeID = crct.ClassroomTypeID,
  168. ClassroomID = cr.ClassroomID,
  169. ClassroomType = crct.ClassroomType,
  170. ClassroomTypeName = dicct.Name
  171. };
  172. return query;
  173. }
  174. }
  175. }