ExecutableFreeSelectionCouseDAL.cs 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.Repositories;
  6. using EMIS.ViewModel.SelectCourse;
  7. using System.Linq.Expressions;
  8. using EMIS.Entities;
  9. using EMIS.ViewModel;
  10. using EMIS.ViewModel.EnrollManage.SpecialtyManage;
  11. using EMIS.ViewModel.EducationManagement;
  12. namespace EMIS.DataLogic.SelectCourse
  13. {
  14. public class ExecutableFreeSelectionCouseDAL
  15. {
  16. public ExecutableFreeSelectionCouseRepository ExecutableFreeSelectionCouseRepository { get; set; }
  17. public ExecutableFreeSelectionCouseSchedulingRepository ExecutableFreeSelectionCouseSchedulingRepository { get; set; }
  18. public ExecutableFreeSelectionCouseTeachingSettingRepository ExecutableFreeSelectionCouseTeachingSettingRepository { get; set; }
  19. public ExecutableFreeSelectionCouseTeacherRepository ExecutableFreeSelectionCouseTeacherRepository { get; set; }
  20. public FreeSelectionCouseApplyRepository FreeSelectionCouseApplyRepository { get; set; }
  21. public FreeSelectionCouseApplySchedulingRepository FreeSelectionCouseApplySchedulingRepository { get; set; }
  22. public FreeSelectionCouseApplyTeachingSettingRepository FreeSelectionCouseApplyTeachingSettingRepository { get; set; }
  23. public FreeSelectionCouseApplyTeacherRepository FreeSelectionCouseApplyTeacherRepository { get; set; }
  24. public ExecutableFreeSelectionCouseRepository FreeSelectionCousePlanRepository { get; set; }
  25. public SpecialtyRepository SpecialtyRepository { get; set; }
  26. public Lazy<FreeSelectionCourseDAL> FreeSelectionCourseDAL { get; set; }
  27. public DepartmentRepository DepartmentRepository { get; set; }
  28. public DictionaryItemRepository DictionaryItemRepository { get; set; }
  29. public CoursesTimeRepository coursesTimeRepository { get; set; }
  30. public EducationSchedulingRepository EducationSchedulingRepository { get; set; }
  31. public EducationSchedulingWeekNumRepository EducationSchedulingWeekNumRepository { get; set; }
  32. public EducationSchedulingTeacherRepository EducationSchedulingTeacherRepository { get; set; }
  33. public EducationMissionRepository EducationMissionRepository { get; set; }
  34. public EducationMissionClassRepository EducationMissionClassRepository { get; set; }
  35. public EducationSchedulingClassRepository EducationSchedulingClassRepository { get; set; }
  36. public ClassroomRepository ClassroomRepository { get; set; }
  37. /// <summary>
  38. /// 查询所有计划申请表记录
  39. /// </summary>
  40. /// <param name="exp"></param>
  41. /// <returns></returns>
  42. public IQueryable<ExecutableFreeSelectionCouseView> GetExecutableFreeSelectionCouseViewQueryable(Expression<Func<EM_ExecutableFreeSelectionCouse, bool>> exp)
  43. {
  44. var query = from a in ExecutableFreeSelectionCouseRepository.GetList(exp)
  45. join b in ExecutableFreeSelectionCouseTeachingSettingRepository.Entities on a.ExecutableFreeSelectionCouseID equals b.ExecutableFreeSelectionCouseID
  46. join c in FreeSelectionCourseDAL.Value.GetFreeSelectionCourseViewQueryable(x => true) on a.FreeSelectionCouseID equals c.FreeSelectionCouseID
  47. //join se in
  48. // (from a in ExecutableFreeSelectionCouseSchedulingRepository.Entities
  49. // group a by new { a.ExecutableFreeSelectionCouseID, a.ClassroomID } into g
  50. // select new { ExecutableFreeSelectionCouseID = g.Key.ExecutableFreeSelectionCouseID, ClassroomID = g.Key.ClassroomID }
  51. // ) on a.ExecutableFreeSelectionCouseID equals se.ExecutableFreeSelectionCouseID
  52. //join se in ExecutableFreeSelectionCouseSchedulingRepository.Entities on a.ExecutableFreeSelectionCouseID equals se.ExecutableFreeSelectionCouseID
  53. join d in DepartmentRepository.Entities on a.DepartmentID equals d.DepartmentID into dd
  54. from ed in dd.DefaultIfEmpty()
  55. //join di in DictionaryItemRepository.GetList(x => x.DictionaryCode == "ES_WeekDay")
  56. //on se.Weekday equals di.Value into gs
  57. //from di in gs.DefaultIfEmpty()
  58. join Scheduling in
  59. (from sc in ExecutableFreeSelectionCouseSchedulingRepository.Entities
  60. //join b in coursesTimeRepository.Entities on sc.CoursesTimeID equals b.CoursesTimeID
  61. //join c in DictionaryItemRepository.Entities on new { b.TimesSegment, DictionaryCode = "CF_TimesSegment" }
  62. //equals new { TimesSegment = c.Value.Value, c.DictionaryCode } into gbsta
  63. //from gicbsta in gbsta.DefaultIfEmpty()
  64. join d in ClassroomRepository.Entities on sc.ClassroomID equals d.ClassroomID
  65. group d by new { sc.ExecutableFreeSelectionCouseID } into g
  66. select new
  67. {
  68. ExecutableFreeSelectionCouseID = g.Key.ExecutableFreeSelectionCouseID,
  69. ClassroomName = g.Select(x => x.Name).FirstOrDefault(),
  70. }) on a.ExecutableFreeSelectionCouseID equals Scheduling.ExecutableFreeSelectionCouseID
  71. into lj
  72. from Scheduling in lj.DefaultIfEmpty()
  73. select new ExecutableFreeSelectionCouseView
  74. {
  75. ExecutableFreeSelectionCouseID = a.ExecutableFreeSelectionCouseID,
  76. FreeSelectionCouseID = a.FreeSelectionCouseID,
  77. //FreeSelectionCouseNo = a.EM_FreeSelectionCouse.No,
  78. DefaultClassName = a.DefaultClassName,
  79. SchoolyearID = a.SchoolyearID,
  80. SchoolyearCode = a.CF_Schoolyear.Code,
  81. SchoolyearName = a.CF_Schoolyear.Code,
  82. CourseCode = c.CourseCode,
  83. CourseName = c.CourseName,
  84. CourseStructureID = a.CourseStructureID,
  85. //CourseStructureName = c.CourseStructureName,
  86. CourseCategoryID = a.CourseCategoryID,
  87. //CourseCategoryName = c.CourseCategoryName,
  88. CourseTypeID = a.CourseTypeID,
  89. //CourseTypeName = c.CourseTypeName,
  90. CourseQualityID = a.CourseQualityID,
  91. //CourseQualityName = c.CourseQualityName,
  92. DepartmentID = a.DepartmentID,
  93. DepartmentName = ed.Name,
  94. CollegeID = ed.CollegeID,
  95. CollegeName = ed.CF_College.Name,
  96. ExaminationModeID = a.ExaminationModeID,
  97. //ExaminationModeName = a.ExaminationModeName,
  98. TeachinglanguageID = a.TeachinglanguageID,
  99. //TeachinglanguageName = a.TeachinglanguageName,
  100. PeopleNumlimit = a.PeopleNumlimit,
  101. PeopleNumlower = a.PeopleNumlower,
  102. IsOpened = a.IsOpened == true,
  103. HandleModeID = a.HandleModeID,
  104. SchoolyearNumID = c.SchoolyearNumID,
  105. SchoolyearNumName = c.SchoolyearNumName,
  106. SchoolcodeID = c.SchoolcodeID,
  107. SchoolcodeName = c.SchoolcodeName,
  108. PracticeTypeID = a.PracticeTypeID,
  109. //StarttermID = c.StarttermID,
  110. //StarttermName = c.StarttermName,
  111. IsEnable = c.IsEnable,
  112. Credit = b.Credit.Value,
  113. TheoryCourse = b.TheoryCourse,
  114. Practicehours = b.Practicehours,
  115. Trialhours = b.Trialhours,
  116. WeeklyHours = b.WeeklyHours,
  117. WeeklyNum = b.WeeklyNum,
  118. TheoryWeeklyNum = b.TheoryWeeklyNum,
  119. PracticeWeeklyNum = b.PracticeWeeklyNum,
  120. TrialWeeklyNum = b.TrialWeeklyNum,
  121. StartWeeklyNum = b.StartWeeklyNum,
  122. EndWeeklyNum = b.EndWeeklyNum,
  123. IsNeedMaterial = (bool)a.IsNeedMaterial,
  124. IsNeedMaterialName = a.IsNeedMaterial == true ? "是" : "否",
  125. //CoursesTimeID = se.CoursesTimeID,
  126. //CoursesTimeName = se.EM_CoursesTime.StartHour.ToString() + ":" + se.EM_CoursesTime.StartMinutes.ToString() + "-" + se.EM_CoursesTime.EndHour.ToString() + ":" + se.EM_CoursesTime.EndMinutes.ToString(),
  127. //ClassroomID = se.ClassroomID,
  128. ClassroomID = a.EM_ExecutableFreeSelectionCouseScheduling.FirstOrDefault() != null ? a.EM_ExecutableFreeSelectionCouseScheduling.FirstOrDefault().ClassroomID : null,
  129. //ClassroomName =a.EM_ExecutableFreeSelectionCouseScheduling.FirstOrDefault() != null ? a.EM_ExecutableFreeSelectionCouseScheduling.FirstOrDefault().CF_Classroom.Name : null ,
  130. ClassroomName = Scheduling.ClassroomName,
  131. //Weekday = se.Weekday,
  132. //WeekdayName = di.Name,
  133. CreateUserID = a.CreateUserID,
  134. CreateTime = a.CreateTime,
  135. ResultTypeID=a.ResultTypeID,
  136. Remarks = a.Remarks,
  137. RecordStatus = a.RecordStatus
  138. };
  139. return query;
  140. }
  141. public IQueryable<ExecutableFreeSelectionCouseTeacherListView> GetExecutableFreeSelectionCouseTeacherViewQueryable(Expression<Func<EM_ExecutableFreeSelectionCouse, bool>> exp)
  142. {
  143. var q = (from fsca in ExecutableFreeSelectionCouseRepository.GetList(exp)
  144. from fscas in fsca.EM_ExecutableFreeSelectionCouseTeacher
  145. select new ExecutableFreeSelectionCouseTeacherListView
  146. {
  147. ExecutableFreeSelectionCouseID = fsca.ExecutableFreeSelectionCouseID,
  148. UserID = fscas.CF_Staff.UserID,
  149. LoginID = fscas.CF_Staff.Sys_User.LoginID,
  150. Name = fscas.CF_Staff.Sys_User.Name,
  151. CollegeID = fscas.CF_Staff.CollegeID,
  152. CollegeName = fscas.CF_Staff.CF_College.Name,
  153. BirthDate = fscas.CF_Staff.BirthDate,
  154. TeacherType = fscas.CF_Staff.TeacherTypeID,
  155. IncumbencyState = fscas.CF_Staff.IncumbencyState,
  156. Title = fscas.CF_Staff.TitleID,
  157. TeachingMethod = fscas.TeachingMethod
  158. });
  159. return q;
  160. }
  161. public IQueryable<SpecialtyView> GetExecutableFreeSelectionCouseSpecialtyViewQueryable(Expression<Func<EM_ExecutableFreeSelectionCouse, bool>> exp)
  162. {
  163. var q = (from fsca in ExecutableFreeSelectionCouseRepository.GetList(exp)
  164. from fssp in fsca.EM_ExecutableFreeSelectionCouseSpecialty
  165. join spec in SpecialtyRepository.Entities on fssp.SpecialtyID equals spec.SpecialtyID
  166. join b in DictionaryItemRepository.GetList(x => x.DictionaryCode == DictionaryItem.CF_Standard.ToString())
  167. on spec.StandardID equals b.Value
  168. into gs
  169. from gstandard in gs.DefaultIfEmpty()
  170. select new SpecialtyView
  171. {
  172. //ExecutableFreeSelectionCouseID = fsca.ExecutableFreeSelectionCouseID,
  173. SpecialtyID = spec.SpecialtyID,
  174. StandardID = fssp.CF_Specialty.StandardID,
  175. StandardCode = gstandard.Code,
  176. StandardName = gstandard.Name,
  177. LearnSystem = spec.LearnSystem,
  178. ScienceclassID = spec.ScienceclassID,
  179. LearningformID = spec.LearningformID,
  180. EducationID = spec.EducationID,
  181. PropertyID = spec.PropertyID,
  182. StandardTitle = spec.StandardTitle,
  183. StandardLevel = spec.StandardLevel,
  184. Remark = spec.Remark,
  185. });
  186. return q;
  187. }
  188. public IQueryable<Sys_DictionaryItem> GetTeachingModeType(Expression<Func<EM_ExecutableFreeSelectionCouse, bool>> exp)
  189. {
  190. var query = from fsc in ExecutableFreeSelectionCouseRepository.GetList(exp)
  191. from fsctm in fsc.EM_ExecutableFreeSelectionCouseTeachingMode
  192. join ditm in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_TeachingMode).Name)
  193. on fsctm.TeachingModeID equals ditm.Value
  194. into dditm
  195. from editm in dditm.DefaultIfEmpty()
  196. select editm;
  197. return query;
  198. }
  199. public IQueryable<Sys_DictionaryItem> GetGradeYear(Expression<Func<EM_ExecutableFreeSelectionCouse, bool>> exp)
  200. {
  201. var query = from fsc in ExecutableFreeSelectionCouseRepository.GetList(exp)
  202. from fscagy in fsc.EM_ExecutableFreeSelectionCouseGradeYear
  203. join ditm in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_TeachingMode).Name)
  204. on fscagy.GradeYear equals ditm.Value
  205. into dditm
  206. from editm in dditm.DefaultIfEmpty()
  207. select editm;
  208. return query;
  209. }
  210. public IQueryable<ExecutableFreeSelectionCouseSchedulingView> GetSchedulingView(Expression<Func<EM_ExecutableFreeSelectionCouseScheduling, bool>> exp)
  211. {
  212. //var query = (from em in educationMissionRepository.GetList(exp)
  213. // from emc in em.EM_EducationMissionClass
  214. // from cp in emc.EM_CourseProcess
  215. var query = (from a in ExecutableFreeSelectionCouseSchedulingRepository.GetList(exp)
  216. join b in coursesTimeRepository.Entities on a.CoursesTimeID equals b.CoursesTimeID
  217. join c in DictionaryItemRepository.Entities on new { b.TimesSegment, DictionaryCode = "CF_TimesSegment" }
  218. equals new { TimesSegment = c.Value.Value, c.DictionaryCode } into gbsta
  219. from gicbsta in gbsta.DefaultIfEmpty()
  220. select new ExecutableFreeSelectionCouseSchedulingView
  221. {
  222. SchedulingID = a.ExecutableFreeSelectionCouseSchedulingID,
  223. ID = a.ExecutableFreeSelectionCouseID,
  224. CourseCollegeID = a.EM_ExecutableFreeSelectionCouse.CF_Department.CollegeID,
  225. ClassroomID = a.ClassroomID,
  226. ClassroomName = a.CF_Classroom.Name,
  227. CoursesTimeID = a.CoursesTimeID,
  228. TimesSegment = b.TimesSegment,
  229. TimesSegmentName = gicbsta.Name,
  230. StartTimes = b.StartTimes,
  231. EndTimes = b.EndTimes,
  232. Weekday = a.Weekday,
  233. RecordStatus = a.RecordStatus,
  234. CreateTime = a.CreateTime,
  235. CreateUserID = a.CreateUserID,
  236. ModifyTime = a.ModifyTime,
  237. ModifyUserID = a.ModifyUserID
  238. });
  239. return query;
  240. }
  241. //任选设定判断教室冲突
  242. public IQueryable<ExecutableFreeSelectionCouseSchedulingView> GetRepeatExecutableFreeSelectionCouseClassroom(Guid? CoursesTimeID, Guid? ClassroomID, int? Weekday, Guid? SchoolyearID, int? StartWeeklyNum, int? EndWeeklyNum)
  243. {
  244. var query = from a in ExecutableFreeSelectionCouseSchedulingRepository.GetList(x => x.CoursesTimeID == CoursesTimeID && x.ClassroomID == ClassroomID && x.Weekday == Weekday && x.CF_Classroom.IsConcurrentUse != true)
  245. join b in ExecutableFreeSelectionCouseRepository.GetList(x => x.SchoolyearID == SchoolyearID) on a.ExecutableFreeSelectionCouseID equals b.ExecutableFreeSelectionCouseID
  246. join c in coursesTimeRepository.Entities on a.CoursesTimeID equals c.CoursesTimeID
  247. join d in DictionaryItemRepository.Entities on new { c.TimesSegment, DictionaryCode = "CF_TimesSegment" }
  248. equals new { TimesSegment = d.Value.Value, d.DictionaryCode } into gbsta
  249. from gicbsta in gbsta.DefaultIfEmpty()
  250. join s in ExecutableFreeSelectionCouseTeachingSettingRepository.GetList(x =>
  251. (x.StartWeeklyNum >= StartWeeklyNum && StartWeeklyNum <= x.EndWeeklyNum) ||
  252. (x.StartWeeklyNum >= EndWeeklyNum && EndWeeklyNum <= x.EndWeeklyNum) ||
  253. (StartWeeklyNum <= x.StartWeeklyNum && x.StartWeeklyNum <= EndWeeklyNum) ||
  254. (StartWeeklyNum <= x.EndWeeklyNum && x.EndWeeklyNum <= EndWeeklyNum)
  255. ) on b.ExecutableFreeSelectionCouseID equals s.ExecutableFreeSelectionCouseID
  256. select new ExecutableFreeSelectionCouseSchedulingView
  257. {
  258. DefaultClassName = b.DefaultClassName,
  259. SchedulingID = a.ExecutableFreeSelectionCouseSchedulingID,
  260. ID = a.ExecutableFreeSelectionCouseID,
  261. CourseCollegeID = a.EM_ExecutableFreeSelectionCouse.CF_Department.CollegeID,
  262. ClassroomID = a.ClassroomID,
  263. ClassroomName = a.CF_Classroom.Name,
  264. CoursesTimeID = a.CoursesTimeID,
  265. TimesSegment = c.TimesSegment,
  266. TimesSegmentName = gicbsta.Name,
  267. StartTimes=c.StartTimes,
  268. EndTimes = c.EndTimes,
  269. Weekday = a.Weekday,
  270. RecordStatus = b.RecordStatus,
  271. CreateTime = b.CreateTime,
  272. CreateUserID = b.CreateUserID,
  273. ModifyTime = b.ModifyTime,
  274. ModifyUserID = b.ModifyUserID
  275. };
  276. return query;
  277. }
  278. //任选申判断教室冲突
  279. public IQueryable<ExecutableFreeSelectionCouseSchedulingView> GetRepeatFreeSelectionCouseApplyClassroom(Guid? CoursesTimeID, Guid? ClassroomID, int? Weekday, Guid? SchoolyearID, int? StartWeeklyNum, int? EndWeeklyNum, int? ApprovalStatus)
  280. {
  281. var query = from a in FreeSelectionCouseApplySchedulingRepository.GetList(x => x.CoursesTimeID == CoursesTimeID && x.ClassroomID == ClassroomID && x.Weekday == Weekday && x.CF_Classroom.IsConcurrentUse != true)
  282. join b in FreeSelectionCouseApplyRepository.GetList(x => x.SchoolyearID == SchoolyearID && x.ApprovalStatus != ApprovalStatus) on a.FreeSelectionCouseApplyID equals b.FreeSelectionCouseApplyID
  283. join c in coursesTimeRepository.Entities on a.CoursesTimeID equals c.CoursesTimeID
  284. join d in DictionaryItemRepository.Entities on new { c.TimesSegment, DictionaryCode = "CF_TimesSegment" }
  285. equals new { TimesSegment = d.Value.Value, d.DictionaryCode } into gbsta
  286. from gicbsta in gbsta.DefaultIfEmpty()
  287. join s in FreeSelectionCouseApplyTeachingSettingRepository.GetList(x =>
  288. (x.StartWeeklyNum >= StartWeeklyNum && StartWeeklyNum <= x.EndWeeklyNum) ||
  289. (x.StartWeeklyNum >= EndWeeklyNum && EndWeeklyNum <= x.EndWeeklyNum) ||
  290. (StartWeeklyNum <= x.StartWeeklyNum && x.StartWeeklyNum <= EndWeeklyNum) ||
  291. (StartWeeklyNum <= x.EndWeeklyNum && x.EndWeeklyNum <= EndWeeklyNum)
  292. ) on b.FreeSelectionCouseApplyID equals s.FreeSelectionCouseApplyID
  293. select new ExecutableFreeSelectionCouseSchedulingView
  294. {
  295. DefaultClassName = b.DefaultClassName,
  296. SchedulingID = a.FreeSelectionCouseApplySchedulingID,
  297. ID = a.FreeSelectionCouseApplyID,
  298. CourseCollegeID = a.EM_FreeSelectionCouseApply.CF_Department.CollegeID,
  299. ClassroomID = a.ClassroomID,
  300. ClassroomName = a.CF_Classroom.Name,
  301. CoursesTimeID = a.CoursesTimeID,
  302. TimesSegment = c.TimesSegment,
  303. TimesSegmentName = gicbsta.Name,
  304. Weekday = a.Weekday,
  305. StartTimes=c.StartTimes,
  306. EndTimes = c.EndTimes,
  307. RecordStatus = b.RecordStatus,
  308. CreateTime = b.CreateTime,
  309. CreateUserID = b.CreateUserID,
  310. ModifyTime = b.ModifyTime,
  311. ModifyUserID = b.ModifyUserID
  312. };
  313. return query;
  314. }
  315. //任选设定判断教师冲突
  316. public IQueryable<ExecutableFreeSelectionCouseSchedulingView> GetRepeatExecutableFreeSelectionCouseTeacher(List<Guid> UserIDList, Guid? CoursesTimeID, int? Weekday, Guid? SchoolyearID, int? StartWeeklyNum, int? EndWeeklyNum)
  317. {
  318. var query = from a in ExecutableFreeSelectionCouseSchedulingRepository.GetList(x => x.CoursesTimeID == CoursesTimeID && x.Weekday == Weekday)
  319. join b in ExecutableFreeSelectionCouseRepository.GetList(x => x.SchoolyearID == SchoolyearID) on a.ExecutableFreeSelectionCouseID equals b.ExecutableFreeSelectionCouseID
  320. join c in coursesTimeRepository.Entities on a.CoursesTimeID equals c.CoursesTimeID
  321. join d in DictionaryItemRepository.Entities on new { c.TimesSegment, DictionaryCode = "CF_TimesSegment" }
  322. equals new { TimesSegment = d.Value.Value, d.DictionaryCode } into gbsta
  323. from gicbsta in gbsta.DefaultIfEmpty()
  324. join e in ExecutableFreeSelectionCouseTeacherRepository.GetList(x => UserIDList.Contains(x.UserID.Value)) on b.ExecutableFreeSelectionCouseID equals e.ExecutableFreeSelectionCouseID
  325. join s in ExecutableFreeSelectionCouseTeachingSettingRepository.GetList(x =>
  326. (x.StartWeeklyNum >= StartWeeklyNum && StartWeeklyNum <= x.EndWeeklyNum) ||
  327. (x.StartWeeklyNum >= EndWeeklyNum && EndWeeklyNum <= x.EndWeeklyNum) ||
  328. (StartWeeklyNum <= x.StartWeeklyNum && x.StartWeeklyNum <= EndWeeklyNum) ||
  329. (StartWeeklyNum <= x.EndWeeklyNum && x.EndWeeklyNum <= EndWeeklyNum)
  330. ) on b.ExecutableFreeSelectionCouseID equals s.ExecutableFreeSelectionCouseID
  331. select new ExecutableFreeSelectionCouseSchedulingView
  332. {
  333. DefaultClassName = b.DefaultClassName,
  334. SchedulingID = a.ExecutableFreeSelectionCouseSchedulingID,
  335. ID = a.ExecutableFreeSelectionCouseID,
  336. CourseCollegeID = a.EM_ExecutableFreeSelectionCouse.CF_Department.CollegeID,
  337. ClassroomID = a.ClassroomID,
  338. ClassroomName = a.CF_Classroom.Name,
  339. CoursesTimeID = a.CoursesTimeID,
  340. TimesSegment = c.TimesSegment,
  341. TimesSegmentName = gicbsta.Name,
  342. StartTimes = c.StartTimes,
  343. EndTimes = c.EndTimes,
  344. Weekday = a.Weekday,
  345. RecordStatus = b.RecordStatus,
  346. CreateTime = b.CreateTime,
  347. CreateUserID = b.CreateUserID,
  348. ModifyTime = b.ModifyTime,
  349. ModifyUserID = b.ModifyUserID
  350. };
  351. return query;
  352. }
  353. //任选申请判断教师冲突
  354. public IQueryable<ExecutableFreeSelectionCouseSchedulingView> GetRepeatFreeSelectionCouseApplyTeacher(List<Guid> UserIDList, Guid? CoursesTimeID, int? Weekday, Guid? SchoolyearID, int? StartWeeklyNum, int? EndWeeklyNum, int? ApprovalStatus)
  355. {
  356. var query = from a in FreeSelectionCouseApplySchedulingRepository.GetList(x => x.CoursesTimeID == CoursesTimeID && x.Weekday == Weekday && x.CF_Classroom.IsConcurrentUse != true)
  357. join b in FreeSelectionCouseApplyRepository.GetList(x => x.SchoolyearID == SchoolyearID && x.ApprovalStatus != ApprovalStatus) on a.FreeSelectionCouseApplyID equals b.FreeSelectionCouseApplyID
  358. join c in coursesTimeRepository.Entities on a.CoursesTimeID equals c.CoursesTimeID
  359. join d in DictionaryItemRepository.Entities on new { c.TimesSegment, DictionaryCode = "CF_TimesSegment" }
  360. equals new { TimesSegment = d.Value.Value, d.DictionaryCode } into gbsta
  361. from gicbsta in gbsta.DefaultIfEmpty()
  362. join e in FreeSelectionCouseApplyTeacherRepository.GetList(x => UserIDList.Contains(x.UserID.Value)) on b.FreeSelectionCouseApplyID equals e.FreeSelectionCouseApplyID
  363. join s in FreeSelectionCouseApplyTeachingSettingRepository.GetList(x =>
  364. (x.StartWeeklyNum >= StartWeeklyNum && StartWeeklyNum <= x.EndWeeklyNum) ||
  365. (x.StartWeeklyNum >= EndWeeklyNum && EndWeeklyNum <= x.EndWeeklyNum) ||
  366. (StartWeeklyNum <= x.StartWeeklyNum && x.StartWeeklyNum <= EndWeeklyNum) ||
  367. (StartWeeklyNum <= x.EndWeeklyNum && x.EndWeeklyNum <= EndWeeklyNum)
  368. ) on b.FreeSelectionCouseApplyID equals s.FreeSelectionCouseApplyID
  369. select new ExecutableFreeSelectionCouseSchedulingView
  370. {
  371. DefaultClassName = b.DefaultClassName,
  372. SchedulingID = a.FreeSelectionCouseApplySchedulingID,
  373. ID = a.FreeSelectionCouseApplyID,
  374. CourseCollegeID = a.EM_FreeSelectionCouseApply.CF_Department.CollegeID,
  375. ClassroomID = a.ClassroomID,
  376. ClassroomName = a.CF_Classroom.Name,
  377. CoursesTimeID = a.CoursesTimeID,
  378. TimesSegment = c.TimesSegment,
  379. TimesSegmentName = gicbsta.Name,
  380. StartTimes = c.StartTimes,
  381. EndTimes = c.EndTimes,
  382. Weekday = a.Weekday,
  383. RecordStatus = b.RecordStatus,
  384. CreateTime = b.CreateTime,
  385. CreateUserID = b.CreateUserID,
  386. ModifyTime = b.ModifyTime,
  387. ModifyUserID = b.ModifyUserID
  388. };
  389. return query;
  390. }
  391. //教学任务判断教室冲突
  392. public IQueryable<ExecutableFreeSelectionCouseSchedulingView> GetRepeatEducationMissionClassroom(Guid? CoursesTimeID, Guid? ClassroomID, int? Weekday, Guid? SchoolyearID, int? StartWeeklyNum, int? EndWeeklyNum)
  393. {
  394. var query = from a in EducationSchedulingRepository.GetList(x => x.CoursesTimeID == CoursesTimeID && x.ClassroomID == ClassroomID && x.Weekday == Weekday && x.CF_Classroom.IsConcurrentUse != true && x.SchoolyearID == SchoolyearID)
  395. join b in coursesTimeRepository.Entities on a.CoursesTimeID equals b.CoursesTimeID
  396. join s in EducationSchedulingWeekNumRepository.GetList(x =>
  397. (x.WeekNum >= StartWeeklyNum && x.WeekNum <= EndWeeklyNum)
  398. ) on a.EducationSchedulingID equals s.EducationSchedulingID
  399. join e in EducationSchedulingClassRepository.Entities on a.EducationSchedulingClassID equals e.EducationSchedulingClassID
  400. join f in EducationMissionClassRepository.Entities on e.EducationMissionClassID equals f.EducationMissionClassID
  401. select new ExecutableFreeSelectionCouseSchedulingView
  402. {
  403. DefaultClassName = f.Name,
  404. };
  405. return query;
  406. }
  407. //教学任务判断教师冲突
  408. public IQueryable<ExecutableFreeSelectionCouseSchedulingView> GetRepeatEducationMissionTeacher(List<Guid> UserIDList, Guid? CoursesTimeID, int? Weekday, Guid? SchoolyearID, int? StartWeeklyNum, int? EndWeeklyNum)
  409. {
  410. var query = from a in EducationSchedulingRepository.GetList(x => x.CoursesTimeID == CoursesTimeID && x.Weekday == Weekday && x.SchoolyearID == SchoolyearID)
  411. join b in EducationSchedulingTeacherRepository.GetList(x => UserIDList.Contains(x.UserID.Value)) on a.EducationSchedulingID equals b.EducationSchedulingID
  412. join s in EducationSchedulingWeekNumRepository.GetList(x =>
  413. (x.WeekNum >= StartWeeklyNum && x.WeekNum <= EndWeeklyNum)
  414. ) on a.EducationSchedulingID equals s.EducationSchedulingID
  415. join e in EducationSchedulingClassRepository.Entities on a.EducationSchedulingClassID equals e.EducationSchedulingClassID
  416. join f in EducationMissionClassRepository.Entities on e.EducationMissionClassID equals f.EducationMissionClassID
  417. select new ExecutableFreeSelectionCouseSchedulingView
  418. {
  419. DefaultClassName = f.Name,
  420. };
  421. return query;
  422. }
  423. public IQueryable<EM_ExecutableFreeSelectionCouse> GetNoMissionClassExecutableFreeSelectionCourse(int? schoolyearValue, List<Guid> educationMissionClassIDList)
  424. {
  425. var q = (from freeSelection in ExecutableFreeSelectionCouseRepository.GetList(x => x.RecordStatus == (int)EMIS.ViewModel.EM_SelectCourseResultStatus.Created &&
  426. x.CF_Schoolyear.Value >= schoolyearValue)
  427. join missionClass in
  428. (
  429. from missionClass in EducationMissionClassRepository.GetList(x => x.HandleModeID == (int)CF_HandleMode.SelectionCourse && x.OptionalCourseTypeID == (int)CF_CourseSelectType.FreeSelectionCourse && !educationMissionClassIDList.Contains(x.EducationMissionClassID))
  430. join mission in EducationMissionRepository.Entities on missionClass.EducationMissionID equals mission.EducationMissionID
  431. from schedulingClass in missionClass.EM_EducationSchedulingClass
  432. from student in schedulingClass.CF_Student
  433. from freeSelection in student.EM_ExecutableFreeSelectionCouse
  434. .Where(x => x.SchoolyearID == mission.SchoolyearID
  435. && x.EM_FreeSelectionCouse.CoursematerialID == missionClass.CoursematerialID)
  436. group freeSelection by freeSelection.ExecutableFreeSelectionCouseID into g
  437. select new { ExecutableFreeSelectionCouseID = g.Key }
  438. )
  439. on freeSelection.ExecutableFreeSelectionCouseID equals missionClass.ExecutableFreeSelectionCouseID into dmissionClass
  440. from missionClass in dmissionClass.DefaultIfEmpty()
  441. where missionClass.ExecutableFreeSelectionCouseID == null
  442. select freeSelection);
  443. return q;
  444. }
  445. }
  446. }