RealtimeServices.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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 Bowin.Common.Linq;
  8. using Bowin.Common.Linq.Entity;
  9. using EMIS.ViewModel;
  10. using EMIS.DataLogic.EducationManage;
  11. using EMIS.DataLogic.EducationSchedule;
  12. using EMIS.DataLogic.SchedulingManage.SchedulingSettings;
  13. using EMIS.ViewModel.EducationManagement;
  14. using Bowin.Common.Utility;
  15. using EMIS.Utility;
  16. using Bowin.Common.DataTime;
  17. using EMIS.DataLogic.Repositories;
  18. using EMIS.ViewModel.CacheManage;
  19. using EMIS.ViewModel.SchedulingManage.SchedulingSettings;
  20. using EMIS.DataLogic;
  21. using EMIS.ViewModel.EducationManage;
  22. using System.Data.Entity;
  23. namespace EMIS.CommonLogic.EducationSchedule
  24. {
  25. public class RealtimeServices : BaseServices, IRealtimeServices
  26. {
  27. public RealtimeDAL RealtimeDAL { get; set; }
  28. public EducationMissionClassDAL educationMissionClassDAL { get; set; }
  29. /// <summary>
  30. /// 列表信息查询
  31. /// </summary>
  32. /// <param name="configuretView"></param>
  33. /// <param name="collegeID"></param>
  34. /// <param name="schoolyearID"></param>
  35. /// <param name="WeekNum"></param>
  36. /// <param name="WeekDay"></param>
  37. /// <param name="Times"></param>
  38. /// <param name="ClassroomID"></param>
  39. /// <param name="pageIndex"></param>
  40. /// <param name="pageSize"></param>
  41. /// <returns></returns>
  42. public IGridResultSet<EducationMissionClassView> GetEducationMissionClassScheduleViewGrid(ConfiguretView configuretView,
  43. Guid? collegeID, Guid? openCollegeID, Guid? schoolyearID, int? WeekNum, int? WeekDay, Guid? Times, Guid? ClassroomID, int pageIndex, int pageSize)
  44. {
  45. Expression<Func<EM_EducationMissionClass, bool>> exp = (x => true);
  46. Expression<Func<ES_EducationScheduling, bool>> exeducationScheduling = (x => true);
  47. Expression<Func<ES_EducationSchedulingWeekNum, bool>> exducationSchedulingWeekNum = (x => true);
  48. Expression<Func<ES_ClassroomExcessiveUse, bool>> exexcessiveUse = (x => true);
  49. Expression<Func<ES_ClassroomExcessiveUseScheduling, bool>> exexcessiveUseScheduling = (x => true);
  50. Expression<Func<ES_ClassroomExcessiveUseSchedulingWeekNum, bool>> exexcessiveUseSchedulingWeekNum = (x => true);
  51. Expression<Func<CF_Classroom, bool>> exeClassroom = (x => true);
  52. Expression<Func<EM_CoursesTime, bool>> exeCoursesTime = (x => true);
  53. if (openCollegeID.HasValue)
  54. {
  55. exp = exp.And(x => x.EM_EducationMission.CF_Department.CollegeID == openCollegeID);
  56. exexcessiveUse = exexcessiveUse.And(x => x.CollegeID == openCollegeID);
  57. }
  58. if (collegeID.HasValue)
  59. {
  60. exp = exp.And(x => x.EM_EducationMission.CollegeID == collegeID);
  61. }
  62. if (schoolyearID.HasValue)
  63. {
  64. exp = exp.And(x => x.EM_EducationMission.SchoolyearID == schoolyearID);
  65. exexcessiveUse = exexcessiveUse.And(x => x.SchoolyearID == schoolyearID);
  66. }
  67. if (WeekNum.HasValue)
  68. {
  69. exducationSchedulingWeekNum = exducationSchedulingWeekNum.And(x => x.WeekNum == WeekNum);
  70. exexcessiveUseSchedulingWeekNum = exexcessiveUseSchedulingWeekNum.And(x => x.WeekNum == WeekNum);
  71. }
  72. if (WeekDay.HasValue)
  73. {
  74. exeducationScheduling = exeducationScheduling.And(x => x.Weekday == WeekDay);
  75. exexcessiveUseScheduling = exexcessiveUseScheduling.And(x => x.Weekday == WeekDay);
  76. }
  77. if (Times.HasValue)
  78. {
  79. exeducationScheduling = exeducationScheduling.And(x => x.CoursesTimeID == Times);
  80. exexcessiveUseScheduling = exexcessiveUseScheduling.And(x => x.CoursesTimeID == Times);
  81. }
  82. if (ClassroomID.HasValue)
  83. {
  84. exeducationScheduling = exeducationScheduling.And(x => x.ClassroomID == ClassroomID);
  85. exexcessiveUse = exexcessiveUse.And(x => x.ClassroomID == ClassroomID);
  86. }
  87. var query = RealtimeDAL.GetEducationMissionClassViewQueryble(exp, exeducationScheduling, exducationSchedulingWeekNum,
  88. exexcessiveUse, exexcessiveUseScheduling, exexcessiveUseSchedulingWeekNum);
  89. //if (openCollegeID.HasValue)
  90. //{
  91. // query = query.Where(x => x.OpenCollegeID == openCollegeID || x.OpenCollegeID == null);
  92. //}
  93. //if (collegeID.HasValue)
  94. //{
  95. // query = query.Where(x => x.CollegeID == collegeID || x.CollegeID == null);
  96. //}
  97. //if (schoolyearID.HasValue)
  98. //{
  99. // query = query.Where(x => x.SchoolyearID == schoolyearID || x.SchoolyearID == null);
  100. //}
  101. //if (WeekNum.HasValue)
  102. //{
  103. // query = query.Where(x => x.WeekNum == WeekNum);
  104. //}
  105. //if (WeekDay.HasValue)
  106. //{
  107. // query = query.Where(x => x.Weekday == WeekDay);
  108. //}
  109. //if (Times.HasValue)
  110. //{
  111. // query = query.Where(x => x.newCoursesTimeID == Times);
  112. //}
  113. //if (ClassroomID.HasValue)
  114. //{
  115. // query = query.Where(x => x.ClassroomID == ClassroomID);
  116. //}
  117. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  118. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  119. var resultQuery = query.OrderBy(x => x.ClassroomName)
  120. .ThenBy(x => x.WeekNum).ThenBy(x => x.Weekday).ThenBy(x => x.StarTimes);
  121. var result = resultQuery.ToGridResultSet<EducationMissionClassView>(pageIndex, pageSize);
  122. var educationMissionClassID = result.rows.Select(x => x.EducationMissionClassID).ToList();
  123. var missionClassTeacherList = educationMissionClassDAL.GetEducationSchedulingTeacherQuery(x => educationMissionClassID.Contains(x.EducationMissionClassID)).ToList();
  124. result.rows.ForEach(x => x.MissionClassTeacherView = new HashSet<MissionClassTeacherView>(missionClassTeacherList.Where(y => y.EducationMissionClassID == x.EducationMissionClassID && y.WeekNum == x.WeekNum && y.Weekday == x.Weekday && y.StarTimes == x.StarTimes)));
  125. return result;
  126. }
  127. public IGridResultSet<EducationMissionClassView> GetEducationMissionClassScheduleViewGridGT(ConfiguretView configuretView,
  128. Guid? collegeID, Guid? openCollegeID, Guid? schoolyearID, int? WeekNum, int? WeekDay, Guid? Times, Guid? ClassroomID, int pageIndex, int pageSize)
  129. {
  130. Expression<Func<EM_EducationMissionClass, bool>> exp = (x => true);
  131. Expression<Func<ES_EducationScheduling, bool>> exeducationScheduling = (x => true);
  132. Expression<Func<ES_EducationSchedulingWeekNum, bool>> exducationSchedulingWeekNum = (x => true);
  133. Expression<Func<ES_ClassroomExcessiveUse, bool>> exexcessiveUse = (x => true);
  134. Expression<Func<ES_ClassroomExcessiveUseScheduling, bool>> exexcessiveUseScheduling = (x => true);
  135. Expression<Func<ES_ClassroomExcessiveUseSchedulingWeekNum, bool>> exexcessiveUseSchedulingWeekNum = (x => true);
  136. Expression<Func<CF_Classroom, bool>> exeClassroom = (x => true);
  137. Expression<Func<EM_CoursesTime, bool>> exeCoursesTime = (x => true);
  138. if (openCollegeID.HasValue)
  139. {
  140. exp = exp.And(x => x.EM_EducationMission.CF_Department.CollegeID == openCollegeID);
  141. exexcessiveUse = exexcessiveUse.And(x => x.CollegeID == openCollegeID);
  142. }
  143. if (collegeID.HasValue)
  144. {
  145. exp = exp.And(x => x.EM_EducationMission.CollegeID == collegeID);
  146. }
  147. if (schoolyearID.HasValue)
  148. {
  149. exp = exp.And(x => x.EM_EducationMission.SchoolyearID == schoolyearID);
  150. exexcessiveUse = exexcessiveUse.And(x => x.SchoolyearID == schoolyearID);
  151. }
  152. //if (WeekNum.HasValue)
  153. //{
  154. // exducationSchedulingWeekNum = exducationSchedulingWeekNum.And(x => x.WeekNum == WeekNum);
  155. // exexcessiveUseSchedulingWeekNum = exexcessiveUseSchedulingWeekNum.And(x => x.WeekNum == WeekNum);
  156. //}
  157. //if(WeekDay.HasValue)
  158. //{
  159. // exeducationScheduling = exeducationScheduling.And(x => x.Weekday == WeekDay);
  160. // exexcessiveUseScheduling = exexcessiveUseScheduling.And(x => x.Weekday == WeekDay);
  161. //}
  162. //if(Times.HasValue)
  163. //{
  164. // exeducationScheduling = exeducationScheduling.And(x => x.CoursesTimeID == Times);
  165. // exexcessiveUseScheduling = exexcessiveUseScheduling.And(x => x.CoursesTimeID == Times);
  166. //}
  167. //if (ClassroomID.HasValue)
  168. //{
  169. // exeducationScheduling = exeducationScheduling.And(x => x.ClassroomID == ClassroomID);
  170. // exexcessiveUse = exexcessiveUse.And(x => x.ClassroomID == ClassroomID);
  171. //}
  172. var query = RealtimeDAL.GetNewEducationMissionClassViewQueryble(exp, exeducationScheduling, exducationSchedulingWeekNum,
  173. exexcessiveUse, exexcessiveUseScheduling, exexcessiveUseSchedulingWeekNum, exeClassroom, exeCoursesTime);
  174. //if (openCollegeID.HasValue)
  175. //{
  176. // query = query.Where(x => x.OpenCollegeID == openCollegeID || x.OpenCollegeID == null);
  177. //}
  178. //if (collegeID.HasValue)
  179. //{
  180. // query = query.Where(x => x.CollegeID == collegeID || x.CollegeID == null);
  181. //}
  182. //if (schoolyearID.HasValue)
  183. //{
  184. // query = query.Where(x => x.SchoolyearID == schoolyearID || x.SchoolyearID == null);
  185. //}
  186. if (WeekNum.HasValue)
  187. {
  188. query = query.Where(x => x.WeekNum == WeekNum);
  189. }
  190. if (WeekDay.HasValue)
  191. {
  192. query = query.Where(x => x.Weekday == WeekDay);
  193. }
  194. if (Times.HasValue)
  195. {
  196. query = query.Where(x => x.newCoursesTimeID == Times);
  197. }
  198. if (ClassroomID.HasValue)
  199. {
  200. query = query.Where(x => x.ClassroomID == ClassroomID);
  201. }
  202. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  203. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  204. var resultQuery = query.OrderBy(x => x.ClassroomName)
  205. .ThenBy(x => x.WeekNum).ThenBy(x => x.Weekday).ThenBy(x => x.StarTimes);
  206. var result = resultQuery.ToGridResultSet<EducationMissionClassView>(pageIndex, pageSize);
  207. var educationMissionClassID = result.rows.Select(x => x.EducationMissionClassID).ToList();
  208. var missionClassTeacherList = educationMissionClassDAL.GetEducationSchedulingTeacherQuery(x => educationMissionClassID.Contains(x.EducationMissionClassID)).ToList();
  209. result.rows.ForEach(x => x.MissionClassTeacherView = new HashSet<MissionClassTeacherView>(missionClassTeacherList.Where(y => y.EducationMissionClassID == x.EducationMissionClassID && y.WeekNum == x.WeekNum && y.Weekday == x.Weekday && y.StarTimes == x.StarTimes)));
  210. return result;
  211. }
  212. /// <summary>
  213. /// 查询对应的实时课表信息List
  214. /// </summary>
  215. /// <param name="configuretView"></param>
  216. /// <param name="collegeID"></param>
  217. /// <param name="schoolyearID"></param>
  218. /// <param name="WeekNum"></param>
  219. /// <param name="WeekDay"></param>
  220. /// <param name="Times"></param>
  221. /// <param name="ClassroomID"></param>
  222. /// <returns></returns>
  223. public List<EducationMissionClassView> GetEducationMissionClassScheduleViewGridForExcel(ConfiguretView configuretView,
  224. Guid? collegeID, Guid? openCollegeID, Guid? schoolyearID, int? WeekNum, int? WeekDay, Guid? Times, Guid? ClassroomID)
  225. {
  226. Expression<Func<EM_EducationMissionClass, bool>> exp = (x => true);
  227. Expression<Func<ES_EducationScheduling, bool>> exeducationScheduling = (x => true);
  228. Expression<Func<ES_EducationSchedulingWeekNum, bool>> exducationSchedulingWeekNum = (x => true);
  229. Expression<Func<ES_ClassroomExcessiveUse, bool>> exexcessiveUse = (x => true);
  230. Expression<Func<ES_ClassroomExcessiveUseScheduling, bool>> exexcessiveUseScheduling = (x => true);
  231. Expression<Func<ES_ClassroomExcessiveUseSchedulingWeekNum, bool>> exexcessiveUseSchedulingWeekNum = (x => true);
  232. Expression<Func<CF_Classroom, bool>> exeClassroom = (x => true);
  233. Expression<Func<EM_CoursesTime, bool>> exeCoursesTime = (x => true);
  234. if (openCollegeID.HasValue)
  235. {
  236. exp = exp.And(x => x.EM_EducationMission.CF_Department.CollegeID == openCollegeID);
  237. exexcessiveUse = exexcessiveUse.And(x => x.CollegeID == openCollegeID);
  238. }
  239. if (collegeID.HasValue)
  240. {
  241. exp = exp.And(x => x.EM_EducationMission.CollegeID == collegeID);
  242. }
  243. if (schoolyearID.HasValue)
  244. {
  245. exp = exp.And(x => x.EM_EducationMission.SchoolyearID == schoolyearID);
  246. exexcessiveUse = exexcessiveUse.And(x => x.SchoolyearID == schoolyearID);
  247. }
  248. if (WeekNum.HasValue)
  249. {
  250. exducationSchedulingWeekNum = exducationSchedulingWeekNum.And(x => x.WeekNum == WeekNum);
  251. exexcessiveUseSchedulingWeekNum = exexcessiveUseSchedulingWeekNum.And(x => x.WeekNum == WeekNum);
  252. }
  253. if (WeekDay.HasValue)
  254. {
  255. exeducationScheduling = exeducationScheduling.And(x => x.Weekday == WeekDay);
  256. exexcessiveUseScheduling = exexcessiveUseScheduling.And(x => x.Weekday == WeekDay);
  257. }
  258. if (Times.HasValue)
  259. {
  260. exeducationScheduling = exeducationScheduling.And(x => x.CoursesTimeID == Times);
  261. exexcessiveUseScheduling = exexcessiveUseScheduling.And(x => x.CoursesTimeID == Times);
  262. exeCoursesTime = exeCoursesTime.And(x => x.CoursesTimeID == Times);
  263. }
  264. if (ClassroomID.HasValue)
  265. {
  266. exeducationScheduling = exeducationScheduling.And(x => x.ClassroomID == ClassroomID);
  267. exexcessiveUse = exexcessiveUse.And(x => x.ClassroomID == ClassroomID);
  268. exeClassroom = exeClassroom.And(x => x.ClassroomID == ClassroomID);
  269. }
  270. var query =
  271. //RealtimeDAL.GetNewEducationMissionClassViewQueryble(exp, exeducationScheduling, exducationSchedulingWeekNum,
  272. //exexcessiveUse, exexcessiveUseScheduling, exexcessiveUseSchedulingWeekNum, exeClassroom, exeCoursesTime);
  273. RealtimeDAL.GetEducationMissionClassViewQueryble(exp, exeducationScheduling, exducationSchedulingWeekNum,
  274. exexcessiveUse, exexcessiveUseScheduling, exexcessiveUseSchedulingWeekNum);
  275. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  276. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue);
  277. var resultQuery = query.OrderBy(x => x.ClassroomName)
  278. .ThenBy(x => x.WeekNum).ThenBy(x => x.Weekday).ThenBy(x => x.Times).ThenBy(x => x.TimesHoure);
  279. var result = resultQuery.ToList();
  280. var educationMissionClassID = result.Select(x => x.EducationMissionClassID).ToList();
  281. var missionClassTeacherList = educationMissionClassDAL.GetEducationSchedulingTeacherQuery(x => educationMissionClassID.Contains(x.EducationMissionClassID)).ToList();
  282. result.ForEach(x => x.MissionClassTeacherView = new HashSet<MissionClassTeacherView>(missionClassTeacherList.Where(y => y.EducationMissionClassID == x.EducationMissionClassID && y.WeekNum == x.WeekNum && y.Weekday == x.Weekday && y.StarTimes == x.StarTimes)));
  283. return result.ToList();
  284. }
  285. }
  286. }