ClassroomDAL.cs 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  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.ClassroomManage;
  9. using EMIS.DataLogic.Repositories;
  10. namespace EMIS.DataLogic.UniversityManage.ClassroomManage
  11. {
  12. public class ClassroomDAL
  13. {
  14. public ClassroomRepository ClassroomRepository { get; set; }
  15. public ClassroomTypeRepository ClassroomTypeRepository { get; set; }
  16. public BuildingsInfoRepository BuildingsInfoRepository { get; set; }
  17. public CollegeRepository CollegeRepository { get; set; }
  18. public ClassroomReserveRepository ClassroomReserveRepository { get; set; }
  19. public CollegeClassroomRepository CollegeClassroomRepository { get; set; }
  20. public DictionaryItemRepository DictionaryItemRepository { get; set; }
  21. public ClassroomTypeRepository classroomTypeRepository { get; set; }
  22. /// <summary>
  23. /// 查询教室信息View(关联排课中教室预留信息、统计排课分配的院系个数)
  24. /// </summary>
  25. /// <param name="expClassroom"></param>
  26. /// <returns></returns>
  27. public IQueryable<ClassroomView> GetClassroomViewQueryable(Expression<Func<CF_Classroom, bool>> expClassroom)
  28. {
  29. var query = from cr in ClassroomRepository.GetList(expClassroom)
  30. join re in ClassroomReserveRepository.Entities
  31. on cr.ClassroomID equals re.ClassroomID into tempre
  32. from crre in tempre.DefaultIfEmpty()
  33. join cc in
  34. (
  35. from cc in CollegeClassroomRepository.Entities
  36. group cc by cc.ClassroomID into gcr
  37. select new
  38. {
  39. ClassroomID = gcr.Key,
  40. ScheduleCollegeCount = gcr.Count()
  41. }
  42. )
  43. on cr.ClassroomID equals cc.ClassroomID into tempcc
  44. from colcr in tempcc.DefaultIfEmpty()
  45. select new ClassroomView
  46. {
  47. ClassroomID = cr.ClassroomID,
  48. Code = cr.Code,
  49. Name = 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. CampusCode = 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. LayoutTypeID = cr.LayoutTypeID,
  66. RoomUseID = cr.RoomUseID,
  67. FloorLevel = cr.FloorLevel,
  68. Acreage = cr.Acreage,
  69. RowCout = cr.RowCout,
  70. ColumnCount = cr.ColumnCount,
  71. Totalseating = cr.Totalseating,
  72. Effectiveseating = cr.Effectiveseating,
  73. Examinationseating = cr.Examinationseating,
  74. IsWrittenExam = cr.IsWrittenExam ?? false,
  75. IsMachinetest = cr.IsMachinetest ?? false,
  76. IsConcurrentUse = cr.IsConcurrentUse ?? false,
  77. IsReserve = crre.IsReserved == true ? true : false,
  78. IsAvailable = cr.IsAvailable ?? false,
  79. ScheduleCollegeCount = colcr.ScheduleCollegeCount == null ? 0 : colcr.ScheduleCollegeCount,
  80. Remark = cr.Remark,
  81. RecordStatus = cr.RecordStatus,
  82. CreateUserID = cr.CreateUserID,
  83. CreateTime = cr.CreateTime,
  84. ModifyUserID = cr.ModifyUserID,
  85. ModifyTime = cr.ModifyTime
  86. };
  87. return query;
  88. }
  89. /// <summary>
  90. /// 查询教室信息对应的排课分配院系所信息(根据教室信息)
  91. /// </summary>
  92. /// <param name="expClassroom"></param>
  93. /// <returns></returns>
  94. public IQueryable<ClassroomView> GetClassroomCollegeViewQueryable(Expression<Func<CF_Classroom, bool>> expClassroom)
  95. {
  96. var query = from cr in ClassroomRepository.GetList(expClassroom)
  97. join re in ClassroomReserveRepository.Entities
  98. on cr.ClassroomID equals re.ClassroomID into tempre
  99. from crre in tempre.DefaultIfEmpty()
  100. join colcr in CollegeClassroomRepository.Entities
  101. on cr.ClassroomID equals colcr.ClassroomID
  102. join col in CollegeRepository.Entities
  103. on colcr.CollegeID equals col.CollegeID
  104. select new ClassroomView
  105. {
  106. ClassroomID = cr.ClassroomID,
  107. Code = cr.Code,
  108. Name = cr.Name,
  109. BuildingsInfoID = cr.BuildingsInfoID,
  110. BuildingsInfoCode = cr.CF_BuildingsInfo.Code,
  111. BuildingsInfoName = cr.CF_BuildingsInfo.Name,
  112. CampusID = cr.CF_BuildingsInfo.CampusID,
  113. CampusCode = cr.CF_BuildingsInfo.CF_Campus.No,
  114. CampusName = cr.CF_BuildingsInfo.CF_Campus.Name,
  115. CollegeID = colcr.CollegeID,
  116. CollegeCode = col.No,
  117. CollegeName = col.Name,
  118. UnitCategoryID = col.CF_CollegeProfile.UnitCategoryID,
  119. CollegeCampusID = col.CampusID,
  120. CollegeCampusCode = col.CF_Campus.No,
  121. CollegeCampusName = col.CF_Campus.Name,
  122. CF_ClassroomType = cr.CF_ClassroomType,
  123. ClassroomTypeIDList = cr.CF_ClassroomType.Select(x => x.ClassroomType).ToList(),
  124. LayoutTypeID = cr.LayoutTypeID,
  125. RoomUseID = cr.RoomUseID,
  126. FloorLevel = cr.FloorLevel,
  127. Acreage = cr.Acreage,
  128. RowCout = cr.RowCout,
  129. ColumnCount = cr.ColumnCount,
  130. Totalseating = cr.Totalseating,
  131. Effectiveseating = cr.Effectiveseating,
  132. Examinationseating = cr.Examinationseating,
  133. IsWrittenExam = cr.IsWrittenExam ?? false,
  134. IsMachinetest = cr.IsMachinetest ?? false,
  135. IsConcurrentUse = cr.IsConcurrentUse ?? false,
  136. IsReserve = crre.IsReserved == true ? true : false,
  137. IsAvailable = cr.IsAvailable ?? false,
  138. Remark = cr.Remark,
  139. RecordStatus = cr.RecordStatus,
  140. CreateUserID = cr.CreateUserID,
  141. CreateTime = cr.CreateTime,
  142. ModifyUserID = cr.ModifyUserID,
  143. ModifyTime = cr.ModifyTime
  144. };
  145. return query;
  146. }
  147. /// <summary>
  148. /// 查询对应的教室类型信息(根据教室信息ID)
  149. /// </summary>
  150. /// <param name="classroomID"></param>
  151. /// <returns></returns>
  152. public List<int> GetClassroomModeTypeQueryble(Guid? classroomID)
  153. {
  154. var query = from a in ClassroomTypeRepository.Entities.Where(x => x.ClassroomID == classroomID)
  155. join b in DictionaryItemRepository.Entities
  156. on new { ClassroomType = a.ClassroomType, DictionaryCode = DictionaryItem.CF_ClassroomType.ToString() }
  157. equals new { ClassroomType = b.Value, DictionaryCode = b.DictionaryCode }
  158. select b.Value.Value;
  159. return query.ToList();
  160. }
  161. }
  162. }