EducationSchedulingDAL.cs 163 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227
  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.EducationSchedule;
  7. using System.Linq.Expressions;
  8. using EMIS.Entities;
  9. using EMIS.ViewModel.EducationManage;
  10. using EMIS.DataLogic.EducationManage;
  11. using EMIS.ViewModel.CalendarManage;
  12. using EMIS.ViewModel;
  13. using EMIS.DataLogic.Common.CalendarManage;
  14. using EMIS.DataLogic.UniversityManage.ClassroomManage;
  15. using EMIS.ViewModel.UniversityManage.ClassroomManage;
  16. using Bowin.Common.Utility;
  17. using EMIS.ViewModel.EducationManagement;
  18. namespace EMIS.DataLogic.EducationSchedule
  19. {
  20. public class EducationSchedulingDAL
  21. {
  22. public ClassroomRepository ClassroomRepository { get; set; }
  23. public ClassroomReserveRepository ClassroomReserveRepository { get; set; }
  24. public ClassroomExcessiveUseRepository ClassroomExcessiveUseRepository { get; set; }
  25. public ClassroomExcessiveUseSchedulingRepository ClassroomExcessiveUseSchedulingRepository { get; set; }
  26. public ClassroomExcessiveUseSchedulingWeekNumRepository ClassroomExcessiveUseSchedulingWeekNumRepository { get; set; }
  27. public ClassroomScheduleSettingRepository ClassroomScheduleSettingRepository { get; set; }
  28. public ClassmajorScheduleSettingRepository ClassmajorScheduleSettingRepository { get; set; }
  29. public CourseScheduleSettingRepository CourseScheduleSettingRepository { get; set; }
  30. public EducationSchedulingAdjustmentRepository EducationSchedulingAdjustmentRepository { get; set; }
  31. public EducationSchedulingAdjustmentToTeacherRepository EducationSchedulingAdjustmentToTeacherRepository { get; set; }
  32. public EducationSchedulingStopRepository EducationSchedulingStopRepository { get; set; }
  33. public EducationSchedulingStopTeacherRepository EducationSchedulingStopTeacherRepository { get; set; }
  34. public SchoolyearRepository SchoolyearRepository { get; set; }
  35. public CoursematerialRepository CoursematerialRepository { get; set; }
  36. public EducationSchedulingRepository EducationSchedulingRepository { get; set; }
  37. public EducationSchedulingTeacherRepository EducationSchedulingTeacherRepository { get; set; }
  38. public EducationSchedulingClassRepository EducationSchedulingClassRepository { get; set; }
  39. public EducationSchedulingWeekNumRepository EducationSchedulingWeekNumRepository { get; set; }
  40. public EducationMissionClassRepository EducationMissionClassRepository { get; set; }
  41. public EducationMissionRepository EducationMissionRepository { get; set; }
  42. public MissionClassTeacherRepository MissionClassTeacherRepository { get; set; }
  43. public StaffRepository StaffRepository { get; set; }
  44. public TeacherScheduleSettingRepository TeacherScheduleSettingRepository { get; set; }
  45. public CollegePriorityRepository CollegePriorityRepository { get; set; }
  46. public CollegeScheduleStatusRepository CollegeScheduleStatusRepository { get; set; }
  47. public UserRepository UserRepository { get; set; }
  48. public ArrangementsRepository ArrangementsRepository { get; set; }
  49. public ExaminationPlanRepository ExaminationPlanRepository { get; set; }
  50. public CoursesTimeRepository CoursesTimeRepository { get; set; }
  51. public Lazy<EducationSchedulingClassDAL> EducationSchedulingClassDAL { get; set; }
  52. public Lazy<EducationMissionClassDAL> EducationMissionClassDAL { get; set; }
  53. public Lazy<CoursesTimeDAL> CoursesTimeDAL { get; set; }
  54. public Lazy<ClassroomScheduleDAL> ClassroomScheduleDAL { get; set; }
  55. public IQueryable<EducationSchedulingView> GetEducationSchedulingViewQueryable(Expression<Func<ES_EducationScheduling, bool>> exp)
  56. {
  57. var nowDate = DateTime.Today;
  58. var q = (from es in EducationSchedulingRepository.GetList(exp)
  59. join esc in EducationSchedulingClassDAL.Value.GetEducationSchedulingClassViewQueryable(x => true)
  60. on es.EducationSchedulingClassID equals esc.EducationSchedulingClassID
  61. select new EducationSchedulingView
  62. {
  63. EducationSchedulingID = es.EducationSchedulingID,
  64. SchoolyearID = es.SchoolyearID,
  65. SchoolyearCode = es.CF_Schoolyear.Code,
  66. CoursematerialID = esc.CoursematerialID,
  67. CoursematerialName = esc.CoursematerialName,
  68. TeachingModeID = es.EM_EducationSchedulingClass.EM_EducationMissionClass.TeachingModeID,
  69. EducationSchedulingClassID = es.EducationSchedulingClassID,
  70. TaskGroupName = es.EM_EducationSchedulingClass.TaskGroupName,
  71. EducationMissionClassID = es.EM_EducationSchedulingClass.EducationMissionClassID,
  72. EducationMissionClassName = es.EM_EducationSchedulingClass.EM_EducationMissionClass.Name,
  73. Weekday = es.Weekday,
  74. CoursesTimeID = es.CoursesTimeID,
  75. CoursesTime = new ViewModel.CalendarManage.BaseWorkTimeView
  76. {
  77. StartTimes = es.EM_CoursesTime.StartTimes,
  78. EndTimes = es.EM_CoursesTime.EndTimes,
  79. TimesSegment = es.EM_CoursesTime.TimesSegment,
  80. StartHour = es.EM_CoursesTime.StartHour,
  81. StartMinutes = es.EM_CoursesTime.StartMinutes,
  82. EndHour = es.EM_CoursesTime.EndHour,
  83. EndMinutes = es.EM_CoursesTime.EndMinutes,
  84. },
  85. ClassroomTypeID = es.EM_EducationSchedulingClass.EM_EducationMissionClass.ClassroomTypeID,
  86. ClassroomID = es.ClassroomID,
  87. ClassroomName = es.CF_Classroom.Name,
  88. RecordStatus = es.RecordStatus,
  89. CreateUserID = es.CreateUserID,
  90. CreateTime = es.CreateTime,
  91. ModifyUserID = es.ModifyUserID,
  92. ModifyTime = es.ModifyTime,
  93. CollegeID = es.EM_EducationSchedulingClass.EM_EducationMissionClass.EM_EducationMission.CollegeID,
  94. CourseCollegeID = es.EM_EducationSchedulingClass.EM_EducationMissionClass.EM_EducationMission.CF_Department.CollegeID,
  95. StudentCount = es.EM_EducationSchedulingClass.CF_Student.Count(),
  96. IsCanEdit = esc.IsCanEdit
  97. });
  98. return q;
  99. }
  100. public IQueryable<EducationSchedulingWeekNumView> GetEducationSchedulingWeekNumViewQueryable(Expression<Func<ES_EducationSchedulingWeekNum, bool>> exp)
  101. {
  102. var nowDate = DateTime.Today;
  103. var q = (from weekNum in EducationSchedulingWeekNumRepository.GetList(exp)
  104. from scheduling in EducationSchedulingRepository.Entities.Where(x => x.EducationSchedulingID == weekNum.EducationSchedulingID)
  105. from schedulingClass in EducationSchedulingClassRepository.Entities.Where(x => x.EducationSchedulingClassID == scheduling.EducationSchedulingClassID)
  106. from stop in EducationSchedulingStopRepository.Entities.Where(x => x.EducationMissionClassID == schedulingClass.EducationMissionClassID
  107. && x.Weekday == scheduling.Weekday && x.CoursesTimeID == scheduling.CoursesTimeID && x.ClassroomID == scheduling.ClassroomID
  108. && x.WeekNum == weekNum.WeekNum).DefaultIfEmpty()
  109. where stop.EducationSchedulingStopID == null
  110. select new EducationSchedulingWeekNumView
  111. {
  112. EducationSchedulingWeekNumID = weekNum.EducationSchedulingWeekNumID,
  113. EducationSchedulingID = scheduling.EducationSchedulingID,
  114. SchoolyearID = scheduling.SchoolyearID,
  115. EducationMissionClassID = schedulingClass.EducationMissionClassID,
  116. WeekNum = weekNum.WeekNum,
  117. Weekday = scheduling.Weekday,
  118. CoursesTimeID = scheduling.CoursesTimeID,
  119. ClassroomID = scheduling.ClassroomID
  120. });
  121. return q;
  122. }
  123. public IQueryable<EM_EducationMissionClassSettings> GetEducationMissionClassSettingQueryable(
  124. Expression<Func<ES_EducationScheduling, bool>> exp)
  125. {
  126. var q = (from es in EducationSchedulingRepository.GetList(exp)
  127. from emcs in es.EM_EducationSchedulingClass.EM_EducationMissionClass.EM_EducationMissionClassSettings
  128. select emcs);
  129. return q;
  130. }
  131. public IQueryable<ES_EducationSchedulingWeekNum> GetEducationMissionWeekNumQueryable(
  132. Expression<Func<ES_EducationScheduling, bool>> exp)
  133. {
  134. return this.EducationSchedulingRepository.GetList(exp).SelectMany(x => x.ES_EducationSchedulingWeekNum);
  135. }
  136. public IQueryable<EducationSchedulingTeacherListView> GetTeacherViewQueryable(
  137. Expression<Func<ES_EducationScheduling, bool>> exp)
  138. {
  139. var q = (from es in EducationSchedulingRepository.GetList(exp)
  140. from s in es.ES_EducationSchedulingTeacher
  141. orderby new { TeachingMethod = (s.TeachingMethod ?? 0), s.CF_Staff.Sys_User.Name }
  142. select new EducationSchedulingTeacherListView
  143. {
  144. EducationSchedulingID = es.EducationSchedulingID,
  145. UserID = s.CF_Staff.UserID,
  146. LoginID = s.CF_Staff.Sys_User.LoginID,
  147. Name = s.CF_Staff.Sys_User.Name,
  148. CollegeID = s.CF_Staff.CollegeID,
  149. CollegeName = s.CF_Staff.CF_College.Name,
  150. BirthDate = s.CF_Staff.BirthDate,
  151. TeacherType = s.CF_Staff.TeacherTypeID,
  152. IncumbencyState = s.CF_Staff.IncumbencyState,
  153. Title = s.CF_Staff.TitleID,
  154. TeachingMethod = (s.TeachingMethod ?? 0)
  155. });
  156. return q;
  157. }
  158. public IQueryable<EducationMissionClassContainClassView> GetClassmajorQueryable(
  159. Expression<Func<ES_EducationScheduling, bool>> exp)
  160. {
  161. var q = (from es in EducationSchedulingRepository.GetList(exp)
  162. from cm in es.EM_EducationSchedulingClass.EM_EducationMissionClass.CF_Classmajor
  163. select new EducationMissionClassContainClassView
  164. {
  165. EducationMissionClassID = es.EM_EducationSchedulingClass.EM_EducationMissionClass.EducationMissionClassID,
  166. ClassMajor = cm
  167. });
  168. return q;
  169. }
  170. public IQueryable<CourseProcessView> GetCourseProcessQueryable(
  171. Expression<Func<ES_EducationScheduling, bool>> exp)
  172. {
  173. var q = (from es in EducationSchedulingRepository.GetList(exp)
  174. join esc in EducationSchedulingClassDAL.Value.EducationSchedulingClassRepository.Entities on es.EducationSchedulingClassID equals esc.EducationSchedulingClassID
  175. join cp in this.EducationMissionClassDAL.Value.GetCourseProcessView(x => true)
  176. on esc.EducationMissionClassID equals cp.EducationMissionClassID
  177. select cp);
  178. return q;
  179. }
  180. public IQueryable<CourseProcessTeacherView> GetCourseProcessTeacherViewQueryable(
  181. Expression<Func<ES_EducationScheduling, bool>> exp)
  182. {
  183. var q = (from es in EducationSchedulingRepository.GetList(exp)
  184. join esc in EducationSchedulingClassDAL.Value.EducationSchedulingClassRepository.Entities on es.EducationSchedulingClassID equals esc.EducationSchedulingClassID
  185. join cp in this.EducationMissionClassDAL.Value.GetCourseProcessView(x => true)
  186. on esc.EducationMissionClassID equals cp.EducationMissionClassID
  187. join cpt in this.EducationMissionClassDAL.Value.GetCourseProcessTeacherView(x => true)
  188. on cp.CourseProcessID equals cpt.CourseProcessID
  189. select cpt);
  190. return q;
  191. }
  192. public IQueryable<ScheduleAdjustmentEditView> GetScheduleAdjustmentViewQueryable(Expression<Func<CF_Staff, bool>> staffExp,
  193. Expression<Func<ES_EducationScheduling, bool>> educationSchedulingExp, Expression<Func<EM_EducationMissionClass, bool>> missionClassExp,
  194. Expression<Func<ES_EducationSchedulingWeekNum, bool>> weeknumExp,
  195. int stopApproveStatus)
  196. {
  197. var curDate = DateTime.Today;
  198. var curTime = DateTime.Now;
  199. //DateTime.Parse("2019-05-07 12:00:00");
  200. var curSchoolyear = SchoolyearRepository.GetSingle(x => x.IsCurrent == true);
  201. var firstWeek = curSchoolyear.FirstWeek.AddDays(1 - (int)curSchoolyear.FirstWeek.DayOfWeek);
  202. var nowWeekNum = (curDate.Subtract(firstWeek).Days + 7) / 7;
  203. var nowWeekday = (int)curDate.DayOfWeek == 0 ? 7 : (int)curDate.DayOfWeek;
  204. var futureWeekNumList = new List<int?>();
  205. var nowAndFutureWeekNumList = new List<int?>();
  206. var beforeWeekdayList = new List<int?>();
  207. var beforeCourseTimeList = new List<Guid?>();
  208. var coursesTimeList = CoursesTimeDAL.Value.GetCoursesTimeQueryable(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE)
  209. .OrderBy(x => x.StartHour).ToList();
  210. for (int i = (nowWeekNum + 1); i <= curSchoolyear.WeeksNum; i++)
  211. {
  212. futureWeekNumList.Add(i);
  213. }
  214. nowAndFutureWeekNumList = new List<int?> { nowWeekNum }.Concat(futureWeekNumList).ToList();
  215. for (int i = 1; i < nowWeekday; i++)
  216. {
  217. beforeWeekdayList.Add(i == 7 ? 0 : i);
  218. }
  219. foreach (var coursesTime in coursesTimeList)
  220. {
  221. if (new TimeSpan(coursesTime.StartHour ?? 0, coursesTime.StartMinutes ?? 0, 0)
  222. .CompareTo(new TimeSpan(curTime.Hour, curTime.Minute, curTime.Second)) <= 0)
  223. {
  224. beforeCourseTimeList.Add(coursesTime.CoursesTimeID);
  225. }
  226. }
  227. var q = (from s in StaffRepository.GetList(staffExp) //如当天是星期4,对于星期1-3,读取当周以后周次的排课
  228. from tes in s.ES_EducationSchedulingTeacher
  229. join es in EducationSchedulingRepository.GetList(educationSchedulingExp).Where(x => beforeWeekdayList.Contains(x.Weekday)
  230. && x.SchoolyearID == curSchoolyear.SchoolyearID)
  231. on tes.EducationSchedulingID equals es.EducationSchedulingID
  232. join eswn in EducationSchedulingWeekNumRepository.Entities.Where(weeknumExp)
  233. .Where(x => futureWeekNumList.Contains(x.WeekNum)) on es.EducationSchedulingID equals eswn.EducationSchedulingID
  234. join esc in EducationSchedulingClassRepository.Entities on es.EducationSchedulingClassID equals esc.EducationSchedulingClassID
  235. join emc in EducationMissionClassRepository.Entities.Where(missionClassExp) on esc.EducationMissionClassID equals emc.EducationMissionClassID
  236. join c in CoursematerialRepository.Entities on emc.CoursematerialID equals c.CoursematerialID
  237. select new ScheduleAdjustmentEditView
  238. {
  239. EducationSchedulingID = es.EducationSchedulingID,
  240. EducationSchedulingWeekNumID = eswn.EducationSchedulingWeekNumID,
  241. EducationMissionClassID = emc.EducationMissionClassID,
  242. SchoolyearID = es.SchoolyearID,
  243. EducationMissionClassName = es.EM_EducationSchedulingClass.EM_EducationMissionClass.Name,
  244. CoursematerialID = emc.CoursematerialID,
  245. CourseCode = c.CourseCode,
  246. CourseName = c.CourseName,
  247. EducationMissionClassStartWeekNum = (nowWeekNum > 1) ? nowWeekNum : 1,
  248. EducationMissionClassEndWeekNum = es.CF_Schoolyear.WeeksNum,
  249. WeekNum = eswn.WeekNum,
  250. Weekday = es.Weekday,
  251. TimesSegment = es.EM_CoursesTime.TimesSegment,
  252. CoursesTimeID = es.CoursesTimeID,
  253. StartHour = es.EM_CoursesTime.StartHour,
  254. StartMinutes = es.EM_CoursesTime.StartMinutes,
  255. EndHour = es.EM_CoursesTime.EndHour,
  256. EndMinutes = es.EM_CoursesTime.EndMinutes,
  257. ClassroomTypeID = emc.ClassroomTypeID,
  258. ClassroomID = es.ClassroomID,
  259. ClassroomName = es.CF_Classroom.Name,
  260. CollegeName = es.EM_EducationSchedulingClass.EM_EducationMissionClass.EM_EducationMission.CF_College.Name
  261. }).Concat( //如当天是星期4,排课也是星期4,对于当前时间之前的节次的课,读取当周以后周次的排课
  262. (from s in StaffRepository.GetList(staffExp)
  263. from tes in s.ES_EducationSchedulingTeacher
  264. join es in EducationSchedulingRepository.GetList(educationSchedulingExp)
  265. .Where(x => x.Weekday == nowWeekday && beforeCourseTimeList.Contains(x.CoursesTimeID)
  266. && x.SchoolyearID == curSchoolyear.SchoolyearID)
  267. on tes.EducationSchedulingID equals es.EducationSchedulingID
  268. join eswn in EducationSchedulingWeekNumRepository.Entities.Where(weeknumExp)
  269. .Where(x => futureWeekNumList.Contains(x.WeekNum)) on es.EducationSchedulingID equals eswn.EducationSchedulingID
  270. join esc in EducationSchedulingClassRepository.Entities on es.EducationSchedulingClassID equals esc.EducationSchedulingClassID
  271. join emc in EducationMissionClassRepository.Entities.Where(missionClassExp) on esc.EducationMissionClassID equals emc.EducationMissionClassID
  272. join c in CoursematerialRepository.Entities on emc.CoursematerialID equals c.CoursematerialID
  273. select new ScheduleAdjustmentEditView
  274. {
  275. EducationSchedulingID = es.EducationSchedulingID,
  276. EducationSchedulingWeekNumID = eswn.EducationSchedulingWeekNumID,
  277. EducationMissionClassID = emc.EducationMissionClassID,
  278. SchoolyearID = es.SchoolyearID,
  279. EducationMissionClassName = es.EM_EducationSchedulingClass.EM_EducationMissionClass.Name,
  280. CoursematerialID = emc.CoursematerialID,
  281. CourseCode = c.CourseCode,
  282. CourseName = c.CourseName,
  283. EducationMissionClassStartWeekNum = (nowWeekNum > 1) ? nowWeekNum : 1,
  284. EducationMissionClassEndWeekNum = es.CF_Schoolyear.WeeksNum,
  285. WeekNum = eswn.WeekNum,
  286. Weekday = es.Weekday,
  287. TimesSegment = es.EM_CoursesTime.TimesSegment,
  288. CoursesTimeID = es.CoursesTimeID,
  289. StartHour = es.EM_CoursesTime.StartHour,
  290. StartMinutes = es.EM_CoursesTime.StartMinutes,
  291. EndHour = es.EM_CoursesTime.EndHour,
  292. EndMinutes = es.EM_CoursesTime.EndMinutes,
  293. ClassroomTypeID = emc.ClassroomTypeID,
  294. ClassroomID = es.ClassroomID,
  295. ClassroomName = es.CF_Classroom.Name,
  296. CollegeName = es.EM_EducationSchedulingClass.EM_EducationMissionClass.EM_EducationMission.CF_College.Name
  297. })
  298. ).Concat( //如当天是星期4,对于星期5-日,读取当周及当周以后周次的排课
  299. (from s in StaffRepository.GetList(staffExp)
  300. from tes in s.ES_EducationSchedulingTeacher
  301. join es in EducationSchedulingRepository.GetList(educationSchedulingExp)
  302. .Where(x => !beforeWeekdayList.Contains(x.Weekday) && x.Weekday != nowWeekday
  303. && x.SchoolyearID == curSchoolyear.SchoolyearID)
  304. on tes.EducationSchedulingID equals es.EducationSchedulingID
  305. join eswn in EducationSchedulingWeekNumRepository.Entities.Where(weeknumExp)
  306. .Where(x => nowAndFutureWeekNumList.Contains(x.WeekNum)) on es.EducationSchedulingID equals eswn.EducationSchedulingID
  307. join esc in EducationSchedulingClassRepository.Entities on es.EducationSchedulingClassID equals esc.EducationSchedulingClassID
  308. join emc in EducationMissionClassRepository.Entities.Where(missionClassExp) on esc.EducationMissionClassID equals emc.EducationMissionClassID
  309. join c in CoursematerialRepository.Entities on emc.CoursematerialID equals c.CoursematerialID
  310. select new ScheduleAdjustmentEditView
  311. {
  312. EducationSchedulingID = es.EducationSchedulingID,
  313. EducationSchedulingWeekNumID = eswn.EducationSchedulingWeekNumID,
  314. EducationMissionClassID = emc.EducationMissionClassID,
  315. SchoolyearID = es.SchoolyearID,
  316. EducationMissionClassName = es.EM_EducationSchedulingClass.EM_EducationMissionClass.Name,
  317. CoursematerialID = emc.CoursematerialID,
  318. CourseCode = c.CourseCode,
  319. CourseName = c.CourseName,
  320. EducationMissionClassStartWeekNum = (nowWeekNum > 1) ? nowWeekNum : 1,
  321. EducationMissionClassEndWeekNum = es.CF_Schoolyear.WeeksNum,
  322. WeekNum = eswn.WeekNum,
  323. Weekday = es.Weekday,
  324. TimesSegment = es.EM_CoursesTime.TimesSegment,
  325. CoursesTimeID = es.CoursesTimeID,
  326. StartHour = es.EM_CoursesTime.StartHour,
  327. StartMinutes = es.EM_CoursesTime.StartMinutes,
  328. EndHour = es.EM_CoursesTime.EndHour,
  329. EndMinutes = es.EM_CoursesTime.EndMinutes,
  330. ClassroomTypeID = emc.ClassroomTypeID,
  331. ClassroomID = es.ClassroomID,
  332. ClassroomName = es.CF_Classroom.Name,
  333. CollegeName = es.EM_EducationSchedulingClass.EM_EducationMissionClass.EM_EducationMission.CF_College.Name
  334. })
  335. ).Concat( //如当天是星期4,排课也是星期4,对于当前时间之后的节次的课,读取当周及当周以后周次的排课
  336. (from s in StaffRepository.GetList(staffExp)
  337. from tes in s.ES_EducationSchedulingTeacher
  338. join es in EducationSchedulingRepository.GetList(educationSchedulingExp)
  339. .Where(x => x.Weekday == nowWeekday && !beforeCourseTimeList.Contains(x.CoursesTimeID)
  340. && x.SchoolyearID == curSchoolyear.SchoolyearID)
  341. on tes.EducationSchedulingID equals es.EducationSchedulingID
  342. join eswn in EducationSchedulingWeekNumRepository.Entities.Where(weeknumExp)
  343. .Where(x => nowAndFutureWeekNumList.Contains(x.WeekNum)) on es.EducationSchedulingID equals eswn.EducationSchedulingID
  344. join esc in EducationSchedulingClassRepository.Entities on es.EducationSchedulingClassID equals esc.EducationSchedulingClassID
  345. join emc in EducationMissionClassRepository.Entities.Where(missionClassExp) on esc.EducationMissionClassID equals emc.EducationMissionClassID
  346. join c in CoursematerialRepository.Entities on emc.CoursematerialID equals c.CoursematerialID
  347. select new ScheduleAdjustmentEditView
  348. {
  349. EducationSchedulingID = es.EducationSchedulingID,
  350. EducationSchedulingWeekNumID = eswn.EducationSchedulingWeekNumID,
  351. EducationMissionClassID = emc.EducationMissionClassID,
  352. SchoolyearID = es.SchoolyearID,
  353. EducationMissionClassName = es.EM_EducationSchedulingClass.EM_EducationMissionClass.Name,
  354. CoursematerialID = emc.CoursematerialID,
  355. CourseCode = c.CourseCode,
  356. CourseName = c.CourseName,
  357. EducationMissionClassStartWeekNum = (nowWeekNum > 1) ? nowWeekNum : 1,
  358. EducationMissionClassEndWeekNum = es.CF_Schoolyear.WeeksNum,
  359. WeekNum = eswn.WeekNum,
  360. Weekday = es.Weekday,
  361. TimesSegment = es.EM_CoursesTime.TimesSegment,
  362. CoursesTimeID = es.CoursesTimeID,
  363. StartHour = es.EM_CoursesTime.StartHour,
  364. StartMinutes = es.EM_CoursesTime.StartMinutes,
  365. EndHour = es.EM_CoursesTime.EndHour,
  366. EndMinutes = es.EM_CoursesTime.EndMinutes,
  367. ClassroomTypeID = emc.ClassroomTypeID,
  368. ClassroomID = es.ClassroomID,
  369. ClassroomName = es.CF_Classroom.Name,
  370. CollegeName = es.EM_EducationSchedulingClass.EM_EducationMissionClass.EM_EducationMission.CF_College.Name
  371. })
  372. ).Concat(
  373. (from s in StaffRepository.GetList(staffExp) //如当天是星期4,对于星期1-3,读取当周及当周以前停课的排课
  374. from tes in s.ES_EducationSchedulingTeacher
  375. join es in EducationSchedulingRepository.GetList(educationSchedulingExp).Where(x => beforeWeekdayList.Contains(x.Weekday)
  376. && x.SchoolyearID == curSchoolyear.SchoolyearID)
  377. on tes.EducationSchedulingID equals es.EducationSchedulingID
  378. join eswn in EducationSchedulingWeekNumRepository.Entities.Where(weeknumExp)
  379. .Where(x => !futureWeekNumList.Contains(x.WeekNum)) on es.EducationSchedulingID equals eswn.EducationSchedulingID
  380. join esc in EducationSchedulingClassRepository.Entities on es.EducationSchedulingClassID equals esc.EducationSchedulingClassID
  381. join emc in EducationMissionClassRepository.Entities.Where(missionClassExp) on esc.EducationMissionClassID equals emc.EducationMissionClassID
  382. join c in CoursematerialRepository.Entities on emc.CoursematerialID equals c.CoursematerialID
  383. from stop in EducationSchedulingStopRepository.Entities.Where(x => x.RecordStatus == stopApproveStatus
  384. && x.EducationMissionClassID == emc.EducationMissionClassID && x.CoursesTimeID == es.CoursesTimeID
  385. && x.Weekday == es.Weekday && x.ClassroomID == es.ClassroomID
  386. && x.WeekNum == eswn.WeekNum
  387. && x.ES_EducationSchedulingStopTeacher.Count() == (
  388. from est in EducationSchedulingTeacherRepository.Entities
  389. .Where(w => w.EducationSchedulingID == es.EducationSchedulingID)
  390. from esst in EducationSchedulingStopTeacherRepository.Entities
  391. .Where(w => w.EducationSchedulingStopID == x.EducationSchedulingStopID
  392. && w.UserID == est.UserID && w.TeachingMethod == est.TeachingMethod)
  393. select esst).Count())
  394. select new ScheduleAdjustmentEditView
  395. {
  396. EducationSchedulingID = es.EducationSchedulingID,
  397. EducationSchedulingWeekNumID = eswn.EducationSchedulingWeekNumID,
  398. EducationMissionClassID = emc.EducationMissionClassID,
  399. SchoolyearID = es.SchoolyearID,
  400. EducationMissionClassName = es.EM_EducationSchedulingClass.EM_EducationMissionClass.Name,
  401. CoursematerialID = emc.CoursematerialID,
  402. CourseCode = c.CourseCode,
  403. CourseName = c.CourseName,
  404. EducationMissionClassStartWeekNum = (nowWeekNum > 1) ? nowWeekNum : 1,
  405. EducationMissionClassEndWeekNum = es.CF_Schoolyear.WeeksNum,
  406. WeekNum = eswn.WeekNum,
  407. Weekday = es.Weekday,
  408. TimesSegment = es.EM_CoursesTime.TimesSegment,
  409. CoursesTimeID = es.CoursesTimeID,
  410. StartHour = es.EM_CoursesTime.StartHour,
  411. StartMinutes = es.EM_CoursesTime.StartMinutes,
  412. EndHour = es.EM_CoursesTime.EndHour,
  413. EndMinutes = es.EM_CoursesTime.EndMinutes,
  414. ClassroomTypeID = emc.ClassroomTypeID,
  415. ClassroomID = es.ClassroomID,
  416. ClassroomName = es.CF_Classroom.Name,
  417. CollegeName = es.EM_EducationSchedulingClass.EM_EducationMissionClass.EM_EducationMission.CF_College.Name
  418. })
  419. ).Concat( //如当天是星期4,排课也是星期4,对于当前时间之前的节次的课,读取当周及当周以前停课的排课
  420. (from s in StaffRepository.GetList(staffExp)
  421. from tes in s.ES_EducationSchedulingTeacher
  422. join es in EducationSchedulingRepository.GetList(educationSchedulingExp)
  423. .Where(x => x.Weekday == nowWeekday
  424. //&& beforeCourseTimeList.Contains(x.CoursesTimeID)
  425. && x.SchoolyearID == curSchoolyear.SchoolyearID)
  426. on tes.EducationSchedulingID equals es.EducationSchedulingID
  427. join eswn in EducationSchedulingWeekNumRepository.Entities.Where(weeknumExp)
  428. .Where(x => !futureWeekNumList.Contains(x.WeekNum)) on es.EducationSchedulingID equals eswn.EducationSchedulingID
  429. join esc in EducationSchedulingClassRepository.Entities on es.EducationSchedulingClassID equals esc.EducationSchedulingClassID
  430. join emc in EducationMissionClassRepository.Entities.Where(missionClassExp) on esc.EducationMissionClassID equals emc.EducationMissionClassID
  431. join c in CoursematerialRepository.Entities on emc.CoursematerialID equals c.CoursematerialID
  432. from stop in
  433. EducationSchedulingStopRepository.Entities.Where(x => x.RecordStatus == stopApproveStatus
  434. && x.EducationMissionClassID == emc.EducationMissionClassID && x.CoursesTimeID == es.CoursesTimeID
  435. && x.Weekday == es.Weekday && x.ClassroomID == es.ClassroomID
  436. && x.WeekNum == eswn.WeekNum
  437. && x.ES_EducationSchedulingStopTeacher.Count() == (
  438. from est in EducationSchedulingTeacherRepository.Entities
  439. .Where(w => w.EducationSchedulingID == es.EducationSchedulingID)
  440. from esst in EducationSchedulingStopTeacherRepository.Entities
  441. .Where(w => w.EducationSchedulingStopID == x.EducationSchedulingStopID
  442. && w.UserID == est.UserID && w.TeachingMethod == est.TeachingMethod)
  443. select esst).Count())
  444. select new ScheduleAdjustmentEditView
  445. {
  446. EducationSchedulingID = es.EducationSchedulingID,
  447. EducationSchedulingWeekNumID = eswn.EducationSchedulingWeekNumID,
  448. EducationMissionClassID = emc.EducationMissionClassID,
  449. SchoolyearID = es.SchoolyearID,
  450. EducationMissionClassName = es.EM_EducationSchedulingClass.EM_EducationMissionClass.Name,
  451. CoursematerialID = emc.CoursematerialID,
  452. CourseCode = c.CourseCode,
  453. CourseName = c.CourseName,
  454. EducationMissionClassStartWeekNum = (nowWeekNum > 1) ? nowWeekNum : 1,
  455. EducationMissionClassEndWeekNum = es.CF_Schoolyear.WeeksNum,
  456. WeekNum = eswn.WeekNum,
  457. Weekday = es.Weekday,
  458. TimesSegment = es.EM_CoursesTime.TimesSegment,
  459. CoursesTimeID = es.CoursesTimeID,
  460. StartHour = es.EM_CoursesTime.StartHour,
  461. StartMinutes = es.EM_CoursesTime.StartMinutes,
  462. EndHour = es.EM_CoursesTime.EndHour,
  463. EndMinutes = es.EM_CoursesTime.EndMinutes,
  464. ClassroomTypeID = emc.ClassroomTypeID,
  465. ClassroomID = es.ClassroomID,
  466. ClassroomName = es.CF_Classroom.Name,
  467. CollegeName = es.EM_EducationSchedulingClass.EM_EducationMissionClass.EM_EducationMission.CF_College.Name
  468. })
  469. ).Concat( //如当天是星期4,排课也是星期5-日,读取当周以前停课的排课(不包括当周)
  470. (from s in StaffRepository.GetList(staffExp)
  471. from tes in s.ES_EducationSchedulingTeacher
  472. join es in EducationSchedulingRepository.GetList(educationSchedulingExp)
  473. .Where(x => !beforeWeekdayList.Contains(x.Weekday) && x.Weekday != nowWeekday
  474. && x.SchoolyearID == curSchoolyear.SchoolyearID)
  475. on tes.EducationSchedulingID equals es.EducationSchedulingID
  476. join eswn in EducationSchedulingWeekNumRepository.Entities.Where(weeknumExp)
  477. .Where(x => !nowAndFutureWeekNumList.Contains(x.WeekNum)) on es.EducationSchedulingID equals eswn.EducationSchedulingID
  478. join esc in EducationSchedulingClassRepository.Entities on es.EducationSchedulingClassID equals esc.EducationSchedulingClassID
  479. join emc in EducationMissionClassRepository.Entities.Where(missionClassExp) on esc.EducationMissionClassID equals emc.EducationMissionClassID
  480. join c in CoursematerialRepository.Entities on emc.CoursematerialID equals c.CoursematerialID
  481. from stop in
  482. EducationSchedulingStopRepository.Entities.Where(x => x.RecordStatus == stopApproveStatus
  483. && x.EducationMissionClassID == emc.EducationMissionClassID && x.CoursesTimeID == es.CoursesTimeID
  484. && x.Weekday == es.Weekday && x.ClassroomID == es.ClassroomID
  485. && x.WeekNum == eswn.WeekNum
  486. && x.ES_EducationSchedulingStopTeacher.Count() == (
  487. from est in EducationSchedulingTeacherRepository.Entities
  488. .Where(w => w.EducationSchedulingID == es.EducationSchedulingID)
  489. from esst in EducationSchedulingStopTeacherRepository.Entities
  490. .Where(w => w.EducationSchedulingStopID == x.EducationSchedulingStopID
  491. && w.UserID == est.UserID && w.TeachingMethod == est.TeachingMethod)
  492. select esst).Count())
  493. select new ScheduleAdjustmentEditView
  494. {
  495. EducationSchedulingID = es.EducationSchedulingID,
  496. EducationSchedulingWeekNumID = eswn.EducationSchedulingWeekNumID,
  497. EducationMissionClassID = emc.EducationMissionClassID,
  498. SchoolyearID = es.SchoolyearID,
  499. EducationMissionClassName = es.EM_EducationSchedulingClass.EM_EducationMissionClass.Name,
  500. CoursematerialID = emc.CoursematerialID,
  501. CourseCode = c.CourseCode,
  502. CourseName = c.CourseName,
  503. EducationMissionClassStartWeekNum = (nowWeekNum > 1) ? nowWeekNum : 1,
  504. EducationMissionClassEndWeekNum = es.CF_Schoolyear.WeeksNum,
  505. WeekNum = eswn.WeekNum,
  506. Weekday = es.Weekday,
  507. TimesSegment = es.EM_CoursesTime.TimesSegment,
  508. CoursesTimeID = es.CoursesTimeID,
  509. StartHour = es.EM_CoursesTime.StartHour,
  510. StartMinutes = es.EM_CoursesTime.StartMinutes,
  511. EndHour = es.EM_CoursesTime.EndHour,
  512. EndMinutes = es.EM_CoursesTime.EndMinutes,
  513. ClassroomTypeID = emc.ClassroomTypeID,
  514. ClassroomID = es.ClassroomID,
  515. ClassroomName = es.CF_Classroom.Name,
  516. CollegeName = es.EM_EducationSchedulingClass.EM_EducationMissionClass.EM_EducationMission.CF_College.Name
  517. })
  518. ).Concat( //当前学期之后的学期的记录,没有限制
  519. (from s in StaffRepository.GetList(staffExp)
  520. from tes in s.ES_EducationSchedulingTeacher
  521. join es in EducationSchedulingRepository.GetList(educationSchedulingExp)
  522. on tes.EducationSchedulingID equals es.EducationSchedulingID
  523. join eswn in EducationSchedulingWeekNumRepository.Entities.Where(weeknumExp)
  524. .Where(x => !nowAndFutureWeekNumList.Contains(x.WeekNum)) on es.EducationSchedulingID equals eswn.EducationSchedulingID
  525. join esc in EducationSchedulingClassRepository.Entities on es.EducationSchedulingClassID equals esc.EducationSchedulingClassID
  526. join emc in EducationMissionClassRepository.Entities.Where(missionClassExp) on esc.EducationMissionClassID equals emc.EducationMissionClassID
  527. join c in CoursematerialRepository.Entities on emc.CoursematerialID equals c.CoursematerialID
  528. join sy in SchoolyearRepository.Entities on es.SchoolyearID equals sy.SchoolyearID
  529. where sy.Value > curSchoolyear.Value
  530. select new ScheduleAdjustmentEditView
  531. {
  532. EducationSchedulingID = es.EducationSchedulingID,
  533. EducationSchedulingWeekNumID = eswn.EducationSchedulingWeekNumID,
  534. EducationMissionClassID = emc.EducationMissionClassID,
  535. SchoolyearID = es.SchoolyearID,
  536. EducationMissionClassName = es.EM_EducationSchedulingClass.EM_EducationMissionClass.Name,
  537. CoursematerialID = emc.CoursematerialID,
  538. CourseCode = c.CourseCode,
  539. CourseName = c.CourseName,
  540. EducationMissionClassStartWeekNum = (nowWeekNum > 1) ? nowWeekNum : 1,
  541. EducationMissionClassEndWeekNum = es.CF_Schoolyear.WeeksNum,
  542. WeekNum = eswn.WeekNum,
  543. Weekday = es.Weekday,
  544. TimesSegment = es.EM_CoursesTime.TimesSegment,
  545. CoursesTimeID = es.CoursesTimeID,
  546. StartHour = es.EM_CoursesTime.StartHour,
  547. StartMinutes = es.EM_CoursesTime.StartMinutes,
  548. EndHour = es.EM_CoursesTime.EndHour,
  549. EndMinutes = es.EM_CoursesTime.EndMinutes,
  550. ClassroomTypeID = emc.ClassroomTypeID,
  551. ClassroomID = es.ClassroomID,
  552. ClassroomName = es.CF_Classroom.Name,
  553. CollegeName = es.EM_EducationSchedulingClass.EM_EducationMissionClass.EM_EducationMission.CF_College.Name
  554. })
  555. );
  556. return q;
  557. }
  558. public IQueryable<ScheduleStopEditView> GetScheduleStopViewQueryable(Expression<Func<CF_Staff, bool>> staffExp,
  559. Expression<Func<ES_EducationScheduling, bool>> educationSchedulingExp, Expression<Func<EM_EducationMissionClass, bool>> missionClassExp,
  560. Expression<Func<ES_EducationSchedulingWeekNum, bool>> weeknumExp,
  561. int stopApproveStatus)
  562. {
  563. var curDate = DateTime.Today;
  564. var curTime = DateTime.Now;
  565. var curSchoolyear = SchoolyearRepository.GetSingle(x => x.IsCurrent == true);
  566. var firstWeek = curSchoolyear.FirstWeek.AddDays(1 - (int)curSchoolyear.FirstWeek.DayOfWeek);
  567. var nowWeekNum = (curDate.Subtract(firstWeek).Days + 7) / 7;
  568. var nowWeekday = (int)curDate.DayOfWeek == 0 ? 7 : (int)curDate.DayOfWeek;
  569. var futureWeekNumList = new List<int?>();
  570. var nowAndFutureWeekNumList = new List<int?>();
  571. var beforeWeekdayList = new List<int?>();
  572. var beforeCourseTimeList = new List<Guid?>();
  573. var coursesTimeList = CoursesTimeDAL.Value.GetCoursesTimeQueryable(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE)
  574. .OrderBy(x => x.StartHour).ToList();
  575. for (int i = (nowWeekNum + 1); i <= curSchoolyear.WeeksNum; i++)
  576. {
  577. futureWeekNumList.Add(i);
  578. }
  579. nowAndFutureWeekNumList = new List<int?> { nowWeekNum }.Concat(futureWeekNumList).ToList();
  580. for (int i = 1; i < nowWeekday; i++)
  581. {
  582. beforeWeekdayList.Add(i == 7 ? 0 : i);
  583. }
  584. foreach (var coursesTime in coursesTimeList)
  585. {
  586. if (new TimeSpan(coursesTime.StartHour ?? 0, coursesTime.StartMinutes ?? 0, 0)
  587. .CompareTo(new TimeSpan(curTime.Hour, curTime.Minute, curTime.Second)) <= 0)
  588. {
  589. beforeCourseTimeList.Add(coursesTime.CoursesTimeID);
  590. }
  591. }
  592. var adjustmentQuery = (from s in StaffRepository.GetList(staffExp) //如当天是星期4,对于星期1-3,读取当周以后周次的排课
  593. from tes in s.ES_EducationSchedulingTeacher
  594. join es in EducationSchedulingRepository.GetList(educationSchedulingExp).Where(x => beforeWeekdayList.Contains(x.Weekday)
  595. && x.SchoolyearID == curSchoolyear.SchoolyearID)
  596. on tes.EducationSchedulingID equals es.EducationSchedulingID
  597. join eswn in EducationSchedulingWeekNumRepository.Entities.Where(weeknumExp)
  598. .Where(x => futureWeekNumList.Contains(x.WeekNum)) on es.EducationSchedulingID equals eswn.EducationSchedulingID
  599. join esc in EducationSchedulingClassRepository.Entities on es.EducationSchedulingClassID equals esc.EducationSchedulingClassID
  600. join emc in EducationMissionClassRepository.Entities.Where(missionClassExp) on esc.EducationMissionClassID equals emc.EducationMissionClassID
  601. join c in CoursematerialRepository.Entities on emc.CoursematerialID equals c.CoursematerialID
  602. select new ScheduleAdjustmentEditView
  603. {
  604. EducationSchedulingID = es.EducationSchedulingID,
  605. EducationSchedulingWeekNumID = eswn.EducationSchedulingWeekNumID,
  606. EducationMissionClassID = emc.EducationMissionClassID,
  607. SchoolyearID = es.SchoolyearID,
  608. EducationMissionClassName = es.EM_EducationSchedulingClass.EM_EducationMissionClass.Name,
  609. CoursematerialID = emc.CoursematerialID,
  610. CourseCode = c.CourseCode,
  611. CourseName = c.CourseName,
  612. EducationMissionClassStartWeekNum = (nowWeekNum > 1) ? nowWeekNum : 1,
  613. EducationMissionClassEndWeekNum = es.CF_Schoolyear.WeeksNum,
  614. WeekNum = eswn.WeekNum,
  615. Weekday = es.Weekday,
  616. TimesSegment = es.EM_CoursesTime.TimesSegment,
  617. CoursesTimeID = es.CoursesTimeID,
  618. StartHour = es.EM_CoursesTime.StartHour,
  619. StartMinutes = es.EM_CoursesTime.StartMinutes,
  620. EndHour = es.EM_CoursesTime.EndHour,
  621. EndMinutes = es.EM_CoursesTime.EndMinutes,
  622. ClassroomTypeID = emc.ClassroomTypeID,
  623. ClassroomID = es.ClassroomID,
  624. ClassroomName = es.CF_Classroom.Name,
  625. CollegeName = es.EM_EducationSchedulingClass.EM_EducationMissionClass.EM_EducationMission.CF_College.Name
  626. }).Concat( //如当天是星期4,排课也是星期4,对于当前时间之前的节次的课,读取当周以后周次的排课
  627. (from s in StaffRepository.GetList(staffExp)
  628. from tes in s.ES_EducationSchedulingTeacher
  629. join es in EducationSchedulingRepository.GetList(educationSchedulingExp)
  630. .Where(x => x.Weekday == nowWeekday && beforeCourseTimeList.Contains(x.CoursesTimeID)
  631. && x.SchoolyearID == curSchoolyear.SchoolyearID)
  632. on tes.EducationSchedulingID equals es.EducationSchedulingID
  633. join eswn in EducationSchedulingWeekNumRepository.Entities.Where(weeknumExp)
  634. .Where(x => futureWeekNumList.Contains(x.WeekNum)) on es.EducationSchedulingID equals eswn.EducationSchedulingID
  635. join esc in EducationSchedulingClassRepository.Entities on es.EducationSchedulingClassID equals esc.EducationSchedulingClassID
  636. join emc in EducationMissionClassRepository.Entities.Where(missionClassExp) on esc.EducationMissionClassID equals emc.EducationMissionClassID
  637. join c in CoursematerialRepository.Entities on emc.CoursematerialID equals c.CoursematerialID
  638. select new ScheduleAdjustmentEditView
  639. {
  640. EducationSchedulingID = es.EducationSchedulingID,
  641. EducationSchedulingWeekNumID = eswn.EducationSchedulingWeekNumID,
  642. EducationMissionClassID = emc.EducationMissionClassID,
  643. SchoolyearID = es.SchoolyearID,
  644. EducationMissionClassName = es.EM_EducationSchedulingClass.EM_EducationMissionClass.Name,
  645. CoursematerialID = emc.CoursematerialID,
  646. CourseCode = c.CourseCode,
  647. CourseName = c.CourseName,
  648. EducationMissionClassStartWeekNum = (nowWeekNum > 1) ? nowWeekNum : 1,
  649. EducationMissionClassEndWeekNum = es.CF_Schoolyear.WeeksNum,
  650. WeekNum = eswn.WeekNum,
  651. Weekday = es.Weekday,
  652. TimesSegment = es.EM_CoursesTime.TimesSegment,
  653. CoursesTimeID = es.CoursesTimeID,
  654. StartHour = es.EM_CoursesTime.StartHour,
  655. StartMinutes = es.EM_CoursesTime.StartMinutes,
  656. EndHour = es.EM_CoursesTime.EndHour,
  657. EndMinutes = es.EM_CoursesTime.EndMinutes,
  658. ClassroomTypeID = emc.ClassroomTypeID,
  659. ClassroomID = es.ClassroomID,
  660. ClassroomName = es.CF_Classroom.Name,
  661. CollegeName = es.EM_EducationSchedulingClass.EM_EducationMissionClass.EM_EducationMission.CF_College.Name
  662. })
  663. ).Concat( //如当天是星期4,对于星期5-日,读取当周及当周以后周次的排课
  664. (from s in StaffRepository.GetList(staffExp)
  665. from tes in s.ES_EducationSchedulingTeacher
  666. join es in EducationSchedulingRepository.GetList(educationSchedulingExp)
  667. .Where(x => !beforeWeekdayList.Contains(x.Weekday) && x.Weekday != nowWeekday
  668. && x.SchoolyearID == curSchoolyear.SchoolyearID)
  669. on tes.EducationSchedulingID equals es.EducationSchedulingID
  670. join eswn in EducationSchedulingWeekNumRepository.Entities.Where(weeknumExp)
  671. .Where(x => nowAndFutureWeekNumList.Contains(x.WeekNum)) on es.EducationSchedulingID equals eswn.EducationSchedulingID
  672. join esc in EducationSchedulingClassRepository.Entities on es.EducationSchedulingClassID equals esc.EducationSchedulingClassID
  673. join emc in EducationMissionClassRepository.Entities.Where(missionClassExp) on esc.EducationMissionClassID equals emc.EducationMissionClassID
  674. join c in CoursematerialRepository.Entities on emc.CoursematerialID equals c.CoursematerialID
  675. select new ScheduleAdjustmentEditView
  676. {
  677. EducationSchedulingID = es.EducationSchedulingID,
  678. EducationSchedulingWeekNumID = eswn.EducationSchedulingWeekNumID,
  679. EducationMissionClassID = emc.EducationMissionClassID,
  680. SchoolyearID = es.SchoolyearID,
  681. EducationMissionClassName = es.EM_EducationSchedulingClass.EM_EducationMissionClass.Name,
  682. CoursematerialID = emc.CoursematerialID,
  683. CourseCode = c.CourseCode,
  684. CourseName = c.CourseName,
  685. EducationMissionClassStartWeekNum = (nowWeekNum > 1) ? nowWeekNum : 1,
  686. EducationMissionClassEndWeekNum = es.CF_Schoolyear.WeeksNum,
  687. WeekNum = eswn.WeekNum,
  688. Weekday = es.Weekday,
  689. TimesSegment = es.EM_CoursesTime.TimesSegment,
  690. CoursesTimeID = es.CoursesTimeID,
  691. StartHour = es.EM_CoursesTime.StartHour,
  692. StartMinutes = es.EM_CoursesTime.StartMinutes,
  693. EndHour = es.EM_CoursesTime.EndHour,
  694. EndMinutes = es.EM_CoursesTime.EndMinutes,
  695. ClassroomTypeID = emc.ClassroomTypeID,
  696. ClassroomID = es.ClassroomID,
  697. ClassroomName = es.CF_Classroom.Name,
  698. CollegeName = es.EM_EducationSchedulingClass.EM_EducationMissionClass.EM_EducationMission.CF_College.Name
  699. })
  700. ).Concat( //如当天是星期4,排课也是星期4,对于当前时间之后的节次的课,读取当周及当周以后周次的排课
  701. (from s in StaffRepository.GetList(staffExp)
  702. from tes in s.ES_EducationSchedulingTeacher
  703. join es in EducationSchedulingRepository.GetList(educationSchedulingExp)
  704. .Where(x => x.Weekday == nowWeekday && !beforeCourseTimeList.Contains(x.CoursesTimeID)
  705. && x.SchoolyearID == curSchoolyear.SchoolyearID)
  706. on tes.EducationSchedulingID equals es.EducationSchedulingID
  707. join eswn in EducationSchedulingWeekNumRepository.Entities.Where(weeknumExp)
  708. .Where(x => nowAndFutureWeekNumList.Contains(x.WeekNum)) on es.EducationSchedulingID equals eswn.EducationSchedulingID
  709. join esc in EducationSchedulingClassRepository.Entities on es.EducationSchedulingClassID equals esc.EducationSchedulingClassID
  710. join emc in EducationMissionClassRepository.Entities.Where(missionClassExp) on esc.EducationMissionClassID equals emc.EducationMissionClassID
  711. join c in CoursematerialRepository.Entities on emc.CoursematerialID equals c.CoursematerialID
  712. select new ScheduleAdjustmentEditView
  713. {
  714. EducationSchedulingID = es.EducationSchedulingID,
  715. EducationSchedulingWeekNumID = eswn.EducationSchedulingWeekNumID,
  716. EducationMissionClassID = emc.EducationMissionClassID,
  717. SchoolyearID = es.SchoolyearID,
  718. EducationMissionClassName = es.EM_EducationSchedulingClass.EM_EducationMissionClass.Name,
  719. CoursematerialID = emc.CoursematerialID,
  720. CourseCode = c.CourseCode,
  721. CourseName = c.CourseName,
  722. EducationMissionClassStartWeekNum = (nowWeekNum > 1) ? nowWeekNum : 1,
  723. EducationMissionClassEndWeekNum = es.CF_Schoolyear.WeeksNum,
  724. WeekNum = eswn.WeekNum,
  725. Weekday = es.Weekday,
  726. TimesSegment = es.EM_CoursesTime.TimesSegment,
  727. CoursesTimeID = es.CoursesTimeID,
  728. StartHour = es.EM_CoursesTime.StartHour,
  729. StartMinutes = es.EM_CoursesTime.StartMinutes,
  730. EndHour = es.EM_CoursesTime.EndHour,
  731. EndMinutes = es.EM_CoursesTime.EndMinutes,
  732. ClassroomTypeID = emc.ClassroomTypeID,
  733. ClassroomID = es.ClassroomID,
  734. ClassroomName = es.CF_Classroom.Name,
  735. CollegeName = es.EM_EducationSchedulingClass.EM_EducationMissionClass.EM_EducationMission.CF_College.Name
  736. })
  737. ).Concat( //当前学期之后的学期的记录,没有限制
  738. (from s in StaffRepository.GetList(staffExp)
  739. from tes in s.ES_EducationSchedulingTeacher
  740. join es in EducationSchedulingRepository.GetList(educationSchedulingExp)
  741. on tes.EducationSchedulingID equals es.EducationSchedulingID
  742. join eswn in EducationSchedulingWeekNumRepository.Entities.Where(weeknumExp)
  743. .Where(x => !nowAndFutureWeekNumList.Contains(x.WeekNum)) on es.EducationSchedulingID equals eswn.EducationSchedulingID
  744. join esc in EducationSchedulingClassRepository.Entities on es.EducationSchedulingClassID equals esc.EducationSchedulingClassID
  745. join emc in EducationMissionClassRepository.Entities.Where(missionClassExp) on esc.EducationMissionClassID equals emc.EducationMissionClassID
  746. join c in CoursematerialRepository.Entities on emc.CoursematerialID equals c.CoursematerialID
  747. join sy in SchoolyearRepository.Entities on es.SchoolyearID equals sy.SchoolyearID
  748. where sy.Value > curSchoolyear.Value
  749. select new ScheduleAdjustmentEditView
  750. {
  751. EducationSchedulingID = es.EducationSchedulingID,
  752. EducationSchedulingWeekNumID = eswn.EducationSchedulingWeekNumID,
  753. EducationMissionClassID = emc.EducationMissionClassID,
  754. SchoolyearID = es.SchoolyearID,
  755. EducationMissionClassName = es.EM_EducationSchedulingClass.EM_EducationMissionClass.Name,
  756. CoursematerialID = emc.CoursematerialID,
  757. CourseCode = c.CourseCode,
  758. CourseName = c.CourseName,
  759. EducationMissionClassStartWeekNum = (nowWeekNum > 1) ? nowWeekNum : 1,
  760. EducationMissionClassEndWeekNum = es.CF_Schoolyear.WeeksNum,
  761. WeekNum = eswn.WeekNum,
  762. Weekday = es.Weekday,
  763. TimesSegment = es.EM_CoursesTime.TimesSegment,
  764. CoursesTimeID = es.CoursesTimeID,
  765. StartHour = es.EM_CoursesTime.StartHour,
  766. StartMinutes = es.EM_CoursesTime.StartMinutes,
  767. EndHour = es.EM_CoursesTime.EndHour,
  768. EndMinutes = es.EM_CoursesTime.EndMinutes,
  769. ClassroomTypeID = emc.ClassroomTypeID,
  770. ClassroomID = es.ClassroomID,
  771. ClassroomName = es.CF_Classroom.Name,
  772. CollegeName = es.EM_EducationSchedulingClass.EM_EducationMissionClass.EM_EducationMission.CF_College.Name
  773. })
  774. );
  775. var q = (from adjust in adjustmentQuery
  776. from stopTeacher in
  777. (
  778. from stop in EducationSchedulingStopRepository.Entities.Where(x => x.EducationMissionClassID == adjust.EducationMissionClassID
  779. && x.WeekNum == adjust.WeekNum && x.Weekday == adjust.Weekday && x.CoursesTimeID == adjust.CoursesTimeID)
  780. from stopTeacher in EducationSchedulingStopTeacherRepository.Entities.Where(x => x.EducationSchedulingStopID == stop.EducationSchedulingStopID)
  781. from schedulingTeacher in EducationSchedulingTeacherRepository.Entities.Where(x => x.UserID == stopTeacher.UserID
  782. && x.EducationSchedulingID == adjust.EducationSchedulingID)
  783. select schedulingTeacher
  784. ).DefaultIfEmpty()
  785. where stopTeacher.EducationSchedulingTeacherID == null
  786. select new ScheduleStopEditView
  787. {
  788. EducationSchedulingID = adjust.EducationSchedulingID,
  789. EducationSchedulingWeekNumID = adjust.EducationSchedulingWeekNumID,
  790. EducationMissionClassID = adjust.EducationMissionClassID,
  791. SchoolyearID = adjust.SchoolyearID,
  792. EducationMissionClassName = adjust.EducationMissionClassName,
  793. CoursematerialID = adjust.CoursematerialID,
  794. CourseCode = adjust.CourseCode,
  795. CourseName = adjust.CourseName,
  796. EducationMissionClassStartWeekNum = adjust.EducationMissionClassStartWeekNum,
  797. EducationMissionClassEndWeekNum = adjust.EducationMissionClassEndWeekNum,
  798. WeekNum = adjust.WeekNum,
  799. Weekday = adjust.Weekday,
  800. TimesSegment = adjust.TimesSegment,
  801. CoursesTimeID = adjust.CoursesTimeID,
  802. StartHour = adjust.StartHour,
  803. StartMinutes = adjust.StartMinutes,
  804. EndHour = adjust.EndHour,
  805. EndMinutes = adjust.EndMinutes,
  806. ClassroomTypeID = adjust.ClassroomTypeID,
  807. ClassroomID = adjust.ClassroomID,
  808. ClassroomName = adjust.ClassroomName,
  809. CollegeName = adjust.CollegeName
  810. });
  811. return q;
  812. }
  813. public IQueryable<EducationSchedulingStopView> GetEducationSchedulingStopViewQueryable(Expression<Func<CF_Staff, bool>> staffExp,
  814. Expression<Func<ES_EducationScheduling, bool>> educationSchedulingExp)
  815. {
  816. var q = (from s in StaffRepository.GetList(staffExp)
  817. from tes in s.ES_EducationSchedulingTeacher
  818. join es in EducationSchedulingRepository.GetList(educationSchedulingExp)
  819. on tes.EducationSchedulingID equals es.EducationSchedulingID
  820. join esc in EducationSchedulingClassRepository.Entities on es.EducationSchedulingClassID equals esc.EducationSchedulingClassID
  821. join emc in EducationMissionClassRepository.Entities on esc.EducationMissionClassID equals emc.EducationMissionClassID
  822. select new EducationSchedulingStopView
  823. {
  824. SchoolyearID = es.SchoolyearID,
  825. EducationMissionClassID = emc.EducationMissionClassID,
  826. EducationMissionClassName = es.EM_EducationSchedulingClass.EM_EducationMissionClass.Name,
  827. Weekday = es.Weekday,
  828. CoursesTimeID = es.CoursesTimeID,
  829. ClassroomID = es.ClassroomID,
  830. ClassroomName = es.CF_Classroom.Name
  831. });
  832. return q;
  833. }
  834. /// <summary>
  835. /// 调课时,获取指定星期几的可用课程时间
  836. /// </summary>
  837. /// <param name="schoolyearID">学年学期</param>
  838. /// <param name="weekday">星期几</param>
  839. /// <param name="weekNumList">查找哪些周次</param>
  840. /// <param name="educationSchedulingID">需要调课的课程安排ID</param>
  841. /// <returns></returns>
  842. public IQueryable<CoursesTimeView> GetNotUseCoursesTime(Guid schoolyearID, int weekday, IList<Guid> teacherList, int? weekNum, Guid educationSchedulingWeekNumID)
  843. {
  844. var q = (
  845. from ct in this.CoursesTimeDAL.Value.GetCoursesTimeQueryable(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE)
  846. join esct in (
  847. from es in this.EducationSchedulingRepository.GetList(x => x.SchoolyearID == schoolyearID
  848. && x.Weekday == weekday)
  849. from escs in es.ES_EducationSchedulingTeacher
  850. from escstudent in es.EM_EducationSchedulingClass.CF_Student
  851. join cstudent in
  852. (
  853. from eswn in EducationSchedulingWeekNumRepository.GetList(x => x.EducationSchedulingWeekNumID == educationSchedulingWeekNumID)
  854. from es in EducationSchedulingRepository.Entities.Where(x => x.EducationSchedulingID == eswn.EducationSchedulingID)
  855. from s in es.EM_EducationSchedulingClass.CF_Student
  856. select s
  857. ) on escstudent.UserID equals cstudent.UserID into dcstudent
  858. from ecstudent in dcstudent.DefaultIfEmpty()
  859. where es.ES_EducationSchedulingWeekNum.Any(x => weekNum == x.WeekNum && x.EducationSchedulingWeekNumID != educationSchedulingWeekNumID)
  860. && (teacherList.Contains(escs.UserID ?? Guid.Empty) || ecstudent.UserID != null)
  861. select es
  862. ) on ct.CoursesTimeID equals esct.CoursesTimeID into desct
  863. from eesct in desct.DefaultIfEmpty()
  864. where eesct.EducationSchedulingID == null
  865. select ct
  866. );
  867. return q;
  868. }
  869. /// <summary>
  870. /// 调课时,获取指定具体节次的可用教室
  871. /// </summary>
  872. /// <param name="schoolyearID">学年学期</param>
  873. /// <param name="weekday">星期几</param>
  874. /// <param name="coursesTimeID">节次</param>
  875. /// <param name="weekNumList">查找哪些周次</param>
  876. /// <param name="educationSchedulingID">需要调课的课程安排ID</param>
  877. /// <returns></returns>
  878. public IQueryable<ClassroomView> GetNotUseClassroomForAdjustment(Guid schoolyearID, int weekday, Guid coursesTimeID, int classroomTypeID,
  879. IList<int?> weekNumList, Guid educationSchedulingID)
  880. {
  881. var educationScheduling = this.GetEducationSchedulingViewQueryable(x => x.EducationSchedulingID == educationSchedulingID)
  882. .FirstOrDefault();
  883. if (educationScheduling == null)
  884. {
  885. throw new Exception("处理异常,无法查询当前排课的信息。");
  886. }
  887. var educationSchedulingClass = this.EducationSchedulingClassDAL.Value.GetEducationSchedulingClassViewQueryable(x => x.EducationSchedulingClassID == educationScheduling.EducationSchedulingClassID)
  888. .FirstOrDefault();
  889. if (educationSchedulingClass == null)
  890. {
  891. throw new Exception("处理异常,无法查询当前排课的信息。");
  892. }
  893. var studentList = this.EducationSchedulingClassDAL.Value.GetStudentQueryable(x => x.EducationSchedulingClassID == educationScheduling.EducationSchedulingClassID)
  894. .ToList();
  895. return this.ClassroomScheduleDAL.Value.GetAvailableClassroomForAdjustmentNew(
  896. schoolyearID, weekNumList, weekday, coursesTimeID, educationSchedulingID, studentList.Count, classroomTypeID);
  897. }
  898. public IQueryable<TeacherIsOnWorkResultView> CheckTeacherIsOnWork(Expression<Func<ES_EducationScheduling, bool>> schedulingExp,
  899. Expression<Func<CF_Staff, bool>> staffExp)
  900. {
  901. var staffQueryable = (from es in this.EducationSchedulingRepository.GetList(schedulingExp)
  902. join s in this.StaffRepository.GetList(staffExp) on true equals true
  903. select new { UserID = s.UserID, es.Weekday, es.CoursesTimeID });
  904. var teacherIsOnWork = (from tss in this.TeacherScheduleSettingRepository.Entities
  905. join wt in staffQueryable on new { tss.UserID, tss.Weekday, tss.CoursesTimeID }
  906. equals new { UserID = (Guid?)wt.UserID, wt.Weekday, wt.CoursesTimeID }
  907. where tss.IsOnWork == false
  908. select new TeacherIsOnWorkResultView {
  909. UserID = tss.UserID ?? Guid.Empty,
  910. Name = tss.CF_Staff.Sys_User.Name,
  911. Weekday = tss.Weekday,
  912. Times = tss.EM_CoursesTime.StartTimes
  913. })
  914. .OrderBy(x => x.Name).ThenBy(x => (x.Weekday == 0 ? 7 : x.Weekday))
  915. .ThenBy(x => x.Times);
  916. return teacherIsOnWork;
  917. }
  918. public IQueryable<TeacherIsBusyView> CheckTeacherIsBusy(Expression<Func<ES_EducationScheduling, bool>> schedulingExp,
  919. Expression<Func<CF_Staff, bool>> staffExp)
  920. {
  921. var teacherIsBusyQuery = (from es in this.EducationSchedulingRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE)
  922. from escs in es.ES_EducationSchedulingTeacher
  923. from eswn in es.ES_EducationSchedulingWeekNum
  924. join wt in
  925. (
  926. (from es in this.EducationSchedulingRepository.GetList(schedulingExp)
  927. from eswn in es.ES_EducationSchedulingWeekNum
  928. join s in this.StaffRepository.GetList(staffExp) on true equals true
  929. select new { es.EducationSchedulingClassID, es.SchoolyearID, UserID = s.UserID, es.Weekday, es.CoursesTimeID, eswn.WeekNum })
  930. ) on new { es.SchoolyearID, escs.UserID, es.Weekday, es.CoursesTimeID, eswn.WeekNum }
  931. equals new { wt.SchoolyearID, UserID = (Guid?)wt.UserID, wt.Weekday, wt.CoursesTimeID, wt.WeekNum }
  932. where es.EducationSchedulingClassID != wt.EducationSchedulingClassID
  933. group new { es, escs } by new
  934. {
  935. es.Weekday,
  936. es.EM_CoursesTime.StartTimes,
  937. escs.UserID,
  938. escs.CF_Staff.Sys_User.Name,
  939. } into g
  940. select new TeacherIsBusyView
  941. {
  942. UserID = g.Key.UserID ?? Guid.Empty,
  943. Name = g.Key.Name,
  944. Weekday = g.Key.Weekday,
  945. Times = g.Key.StartTimes
  946. });
  947. return teacherIsBusyQuery;
  948. }
  949. public void CheckTeacherIsAvailable(Expression<Func<ES_EducationScheduling, bool>> schedulingExp,
  950. Expression<Func<CF_Staff, bool>> staffExp)
  951. {
  952. var teacherIsOnWork = (from tss in this.TeacherScheduleSettingRepository.Entities
  953. join wt in
  954. (
  955. (from es in this.EducationSchedulingRepository.GetList(schedulingExp)
  956. from s in this.StaffRepository.GetList(staffExp)
  957. select new { UserID = s.UserID, es.Weekday, es.CoursesTimeID })
  958. ) on new { tss.UserID, tss.Weekday, tss.CoursesTimeID }
  959. equals new { UserID = (Guid?)wt.UserID, wt.Weekday, wt.CoursesTimeID }
  960. where tss.IsOnWork == false
  961. select new { tss.UserID, tss.CF_Staff.Sys_User.Name, tss.Weekday, tss.EM_CoursesTime.StartTimes, tss.EM_CoursesTime.EndTimes })
  962. .OrderBy(x => x.Name).ThenBy(x => (x.Weekday == 0 ? 7 : x.Weekday))
  963. .ThenBy(x => x.StartTimes)
  964. .ToList();
  965. if (teacherIsOnWork.Count > 0)
  966. {
  967. var notAvailableTeacherMessage = "";
  968. teacherIsOnWork.ForEach(x => notAvailableTeacherMessage += string.Format("任务班在{1}第{2}节课有课,但教师{0}在该节次不能排课。\n",
  969. x.Name,
  970. WeekHelper.WeekDictionary[x.Weekday ?? 0],
  971. (x.StartTimes == x.EndTimes) ? x.StartTimes.ToString() : x.StartTimes.ToString() + "-" + x.EndTimes.ToString()));
  972. throw new Exception(notAvailableTeacherMessage);
  973. }
  974. var teacherIsBusyQuery = (from es in this.EducationSchedulingRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE)
  975. from escs in es.ES_EducationSchedulingTeacher
  976. from eswn in es.ES_EducationSchedulingWeekNum
  977. join wt in
  978. (
  979. (from es in this.EducationSchedulingRepository.GetList(schedulingExp)
  980. from eswn in es.ES_EducationSchedulingWeekNum
  981. from s in this.StaffRepository.GetList(staffExp)
  982. select new { es.EducationSchedulingClassID, es.SchoolyearID, UserID = s.UserID, es.Weekday, es.CoursesTimeID, eswn.WeekNum })
  983. ) on new { es.SchoolyearID, escs.CF_Staff.UserID, es.Weekday, es.CoursesTimeID, eswn.WeekNum }
  984. equals new { wt.SchoolyearID, wt.UserID, wt.Weekday, wt.CoursesTimeID, wt.WeekNum }
  985. where es.EducationSchedulingClassID != wt.EducationSchedulingClassID
  986. select new { es.EducationSchedulingID, escs.UserID, escs.CF_Staff.Sys_User.Name, eswn.WeekNum });
  987. }
  988. public IQueryable<EducationSchedulingConflictView> GetConflictAdjustmentSchedule(Expression<Func<ES_EducationSchedulingWeekNum, bool>> exp,
  989. IList<int?> adjustmentSubmitedStatusList, Guid fromUserID, int? toWeekNum, int? toWeekday, Guid? toUserID, Guid? toCoursesTimeID,
  990. Guid? toClassroom)
  991. {
  992. var adjustSql = (from weekNum in EducationSchedulingWeekNumRepository.GetList(exp)
  993. from scheduling in EducationSchedulingRepository.Entities.Where(x => x.EducationSchedulingID == weekNum.EducationSchedulingID)
  994. from schedulingClass in EducationSchedulingClassRepository.Entities.Where(x => x.EducationSchedulingClassID == scheduling.EducationSchedulingClassID)
  995. from missionClass in EducationMissionClassRepository.Entities.Where(x => x.EducationMissionClassID == schedulingClass.EducationMissionClassID)
  996. from teacher in EducationSchedulingTeacherRepository.Entities.Where(x => x.EducationSchedulingID == scheduling.EducationSchedulingID)
  997. from schoolyear in SchoolyearRepository.Entities.Where(x => x.SchoolyearID == scheduling.SchoolyearID)
  998. from course in CoursematerialRepository.Entities.Where(x => x.CoursematerialID == missionClass.CoursematerialID)
  999. from courseTime in CoursesTimeDAL.Value.coursesTimeRepository.Entities
  1000. .Where(x => x.CoursesTimeID == (toCoursesTimeID.HasValue ? toCoursesTimeID : scheduling.CoursesTimeID))
  1001. from classroom in ClassroomRepository.Entities
  1002. .Where(x => x.ClassroomID == (toClassroom.HasValue ? toClassroom : scheduling.ClassroomID))
  1003. from user in UserRepository.Entities
  1004. .Where(x => x.UserID == ((teacher.UserID == fromUserID) ? (toUserID.HasValue ? toUserID : teacher.UserID) : teacher.UserID))
  1005. select new EducationSchedulingConflictView
  1006. {
  1007. EducationSchedulingWeekNumID = weekNum.EducationSchedulingWeekNumID,
  1008. EducationSchedulingAdjustmentID = null,
  1009. SchoolyearID = scheduling.SchoolyearID,
  1010. SchoolyearCode = schoolyear.Code,
  1011. EducationSchedulingClassID = scheduling.EducationSchedulingClassID,
  1012. EducationMissionClassName = missionClass.Name,
  1013. CoursematerialID = missionClass.CoursematerialID,
  1014. CourseName = course.CourseName,
  1015. WeekNum = toWeekNum.HasValue ? toWeekNum : weekNum.WeekNum,
  1016. Weekday = toWeekday.HasValue ? toWeekday : scheduling.Weekday,
  1017. CoursesTime = toCoursesTimeID.HasValue ? toCoursesTimeID : scheduling.CoursesTimeID,
  1018. StartTimes = courseTime.StartTimes,
  1019. EndTimes = courseTime.EndTimes,
  1020. ClassroomID = toClassroom.HasValue ? toClassroom : scheduling.ClassroomID,
  1021. ClassroomName = classroom.Name,
  1022. StudentNum = schedulingClass.CF_Student.Count,
  1023. UserID = (teacher.UserID == fromUserID) ? (toUserID.HasValue ? toUserID : teacher.UserID) : teacher.UserID,
  1024. UserName = user.Name,
  1025. Reason = ""
  1026. });
  1027. //return GetConflictAdjustmentSchedule(adjustSql, adjustmentSubmitedStatusList);
  1028. return adjustSql;
  1029. }
  1030. public IQueryable<EducationSchedulingConflictView> GetConflictAdjustmentSchedule(Expression<Func<ES_EducationSchedulingAdjustment, bool>> exp,
  1031. IList<int?> adjustmentSubmitedStatusList)
  1032. {
  1033. var adjustSql = (from adjust in EducationSchedulingAdjustmentRepository.GetList(exp)
  1034. from missionClass in EducationMissionClassRepository.Entities.Where(x =>
  1035. x.EducationMissionClassID == adjust.EducationMissionClassID)
  1036. from mission in EducationMissionRepository.Entities.Where(x => x.EducationMissionID == missionClass.EducationMissionID)
  1037. from schedulingClass in EducationSchedulingClassRepository.Entities.Where(x =>
  1038. x.EducationMissionClassID == missionClass.EducationMissionClassID)
  1039. from teacher in EducationSchedulingAdjustmentToTeacherRepository.Entities.Where(x =>
  1040. x.EducationSchedulingAdjustmentID == adjust.EducationSchedulingAdjustmentID)
  1041. from schoolyear in SchoolyearRepository.Entities.Where(x => x.SchoolyearID == mission.SchoolyearID)
  1042. from course in CoursematerialRepository.Entities.Where(x => x.CoursematerialID == missionClass.CoursematerialID)
  1043. from courseTime in CoursesTimeDAL.Value.coursesTimeRepository.Entities.Where(x => x.CoursesTimeID == adjust.ToCoursesTimeID)
  1044. from classroom in ClassroomRepository.Entities.Where(x => x.ClassroomID == adjust.ToClassroomID)
  1045. from user in UserRepository.Entities.Where(x => x.UserID == teacher.UserID)
  1046. from weekNum in (
  1047. from scheduling in EducationSchedulingRepository.Entities.Where(x =>
  1048. x.EducationSchedulingClassID == schedulingClass.EducationSchedulingClassID
  1049. && x.SchoolyearID == mission.SchoolyearID && x.Weekday == adjust.Weekday && x.CoursesTimeID == adjust.CoursesTimeID)
  1050. from weekNum in EducationSchedulingWeekNumRepository.Entities.Where(x => x.EducationSchedulingID == scheduling.EducationSchedulingID
  1051. && x.WeekNum == adjust.WeekNum)
  1052. select weekNum).DefaultIfEmpty()
  1053. select new EducationSchedulingConflictView
  1054. {
  1055. EducationSchedulingWeekNumID = weekNum.EducationSchedulingWeekNumID,
  1056. EducationSchedulingAdjustmentID = adjust.EducationSchedulingAdjustmentID,
  1057. SchoolyearID = mission.SchoolyearID,
  1058. SchoolyearCode = schoolyear.Code,
  1059. EducationSchedulingClassID = schedulingClass.EducationSchedulingClassID,
  1060. EducationMissionClassName = missionClass.Name,
  1061. CoursematerialID = missionClass.CoursematerialID,
  1062. CourseName = course.CourseName,
  1063. WeekNum = adjust.ToWeekNum,
  1064. Weekday = adjust.ToWeekday,
  1065. CoursesTime = adjust.ToCoursesTimeID,
  1066. StartTimes = courseTime.StartTimes,
  1067. EndTimes = courseTime.EndTimes,
  1068. ClassroomID = adjust.ToClassroomID,
  1069. ClassroomName = classroom.Name,
  1070. StudentNum = schedulingClass.CF_Student.Count,
  1071. UserID = teacher.UserID,
  1072. UserName = user.Name,
  1073. Reason = ""
  1074. });
  1075. //return GetConflictAdjustmentSchedule(adjustSql, adjustmentSubmitedStatusList);
  1076. return adjustSql;
  1077. }
  1078. public IQueryable<EducationSchedulingConflictView> GetSelfClassroomConflictQueryable(IQueryable<EducationSchedulingConflictView> adjustSql)
  1079. {
  1080. var selfClassroomConflictSql = (from adjust in adjustSql
  1081. group adjust by new { adjust.WeekNum, adjust.Weekday, adjust.CoursesTime, adjust.UserID, adjust.ClassroomID } into g
  1082. where g.Count() > 1
  1083. select g).SelectMany(x => x)
  1084. .Select(x => new EducationSchedulingConflictView
  1085. {
  1086. EducationSchedulingWeekNumID = x.EducationSchedulingWeekNumID,
  1087. EducationSchedulingAdjustmentID = x.EducationSchedulingAdjustmentID,
  1088. SchoolyearID = x.SchoolyearID,
  1089. SchoolyearCode = x.SchoolyearCode,
  1090. EducationSchedulingClassID = x.EducationSchedulingClassID,
  1091. EducationMissionClassName = x.EducationMissionClassName,
  1092. CoursematerialID = x.CoursematerialID,
  1093. CourseName = x.CourseName,
  1094. WeekNum = x.WeekNum,
  1095. Weekday = x.Weekday,
  1096. CoursesTime = x.CoursesTime,
  1097. StartTimes = x.StartTimes,
  1098. EndTimes = x.EndTimes,
  1099. ClassroomID = x.ClassroomID,
  1100. ClassroomName = x.ClassroomName,
  1101. StudentNum = x.StudentNum,
  1102. UserID = x.UserID,
  1103. UserName = x.UserName,
  1104. Reason = "和其他提交的数据存在教室冲突。"
  1105. });
  1106. return selfClassroomConflictSql;
  1107. }
  1108. public IQueryable<EducationSchedulingConflictView> GetSelfConflictQueryable(IQueryable<EducationSchedulingConflictView> adjustSql)
  1109. {
  1110. var result = (from adjust in adjustSql
  1111. group adjust by new { adjust.EducationSchedulingWeekNumID, adjust.UserID } into g
  1112. where g.Count() > 1
  1113. select g).SelectMany(x => x)
  1114. .Select(x => new EducationSchedulingConflictView
  1115. {
  1116. EducationSchedulingWeekNumID = x.EducationSchedulingWeekNumID,
  1117. EducationSchedulingAdjustmentID = x.EducationSchedulingAdjustmentID,
  1118. SchoolyearID = x.SchoolyearID,
  1119. SchoolyearCode = x.SchoolyearCode,
  1120. EducationSchedulingClassID = x.EducationSchedulingClassID,
  1121. EducationMissionClassName = x.EducationMissionClassName,
  1122. CoursematerialID = x.CoursematerialID,
  1123. CourseName = x.CourseName,
  1124. WeekNum = x.WeekNum,
  1125. Weekday = x.Weekday,
  1126. CoursesTime = x.CoursesTime,
  1127. StartTimes = x.StartTimes,
  1128. EndTimes = x.EndTimes,
  1129. ClassroomID = x.ClassroomID,
  1130. ClassroomName = x.ClassroomName,
  1131. StudentNum = x.StudentNum,
  1132. UserID = x.UserID,
  1133. UserName = x.UserName,
  1134. Reason = "涉及了对同一节课的重复调动。"
  1135. });
  1136. return result;
  1137. }
  1138. public IQueryable<EducationSchedulingConflictView> GetSelfTeacherConflictQueryable(IQueryable<EducationSchedulingConflictView> adjustSql)
  1139. {
  1140. var selfTeacherConflictSql = (from adjust in adjustSql
  1141. group adjust by new { adjust.WeekNum, adjust.Weekday, adjust.CoursesTime, adjust.UserID } into g
  1142. where g.Count() > 1
  1143. select g).SelectMany(x => x)
  1144. .Select(x => new EducationSchedulingConflictView
  1145. {
  1146. EducationSchedulingWeekNumID = x.EducationSchedulingWeekNumID,
  1147. EducationSchedulingAdjustmentID = x.EducationSchedulingAdjustmentID,
  1148. SchoolyearID = x.SchoolyearID,
  1149. SchoolyearCode = x.SchoolyearCode,
  1150. EducationSchedulingClassID = x.EducationSchedulingClassID,
  1151. EducationMissionClassName = x.EducationMissionClassName,
  1152. CoursematerialID = x.CoursematerialID,
  1153. CourseName = x.CourseName,
  1154. WeekNum = x.WeekNum,
  1155. Weekday = x.Weekday,
  1156. CoursesTime = x.CoursesTime,
  1157. StartTimes = x.StartTimes,
  1158. EndTimes = x.EndTimes,
  1159. ClassroomID = x.ClassroomID,
  1160. ClassroomName = x.ClassroomName,
  1161. StudentNum = x.StudentNum,
  1162. UserID = x.UserID,
  1163. UserName = x.UserName,
  1164. Reason = "和其他提交的数据存在教师冲突。"
  1165. });
  1166. return selfTeacherConflictSql;
  1167. }
  1168. public IQueryable<EducationSchedulingConflictView> GetSelfStudentConflictQueryable(IQueryable<EducationSchedulingConflictView> adjustSql)
  1169. {
  1170. var selfStudentConflictSql = (from adjust in adjustSql
  1171. from schedulingClass in EducationSchedulingClassRepository.Entities
  1172. .Where(x => x.EducationSchedulingClassID == adjust.EducationSchedulingClassID)
  1173. from student in schedulingClass.CF_Student
  1174. group adjust by new { adjust.WeekNum, adjust.Weekday, adjust.CoursesTime, adjust.UserID, StudentUserID = student.UserID } into g
  1175. where g.Count() > 1
  1176. select g).SelectMany(x => x)
  1177. .Select(x => new EducationSchedulingConflictView
  1178. {
  1179. EducationSchedulingWeekNumID = x.EducationSchedulingWeekNumID,
  1180. EducationSchedulingAdjustmentID = x.EducationSchedulingAdjustmentID,
  1181. SchoolyearID = x.SchoolyearID,
  1182. SchoolyearCode = x.SchoolyearCode,
  1183. EducationSchedulingClassID = x.EducationSchedulingClassID,
  1184. EducationMissionClassName = x.EducationMissionClassName,
  1185. CoursematerialID = x.CoursematerialID,
  1186. CourseName = x.CourseName,
  1187. WeekNum = x.WeekNum,
  1188. Weekday = x.Weekday,
  1189. CoursesTime = x.CoursesTime,
  1190. StartTimes = x.StartTimes,
  1191. EndTimes = x.EndTimes,
  1192. ClassroomID = x.ClassroomID,
  1193. ClassroomName = x.ClassroomName,
  1194. StudentNum = x.StudentNum,
  1195. UserID = x.UserID,
  1196. UserName = x.UserName,
  1197. Reason = "和其他提交的数据存在学生冲突。"
  1198. });
  1199. return selfStudentConflictSql;
  1200. }
  1201. public IQueryable<EducationSchedulingConflictView> GetClassroomSeatConflictQueryable(IQueryable<EducationSchedulingConflictView> adjustSql)
  1202. {
  1203. var query = (from adjust in adjustSql
  1204. from classroom in ClassroomRepository.Entities.Where(x => x.ClassroomID == adjust.ClassroomID)
  1205. where (classroom.Totalseating ?? 0) != 0 && classroom.Totalseating < adjust.StudentNum
  1206. select new EducationSchedulingConflictView
  1207. {
  1208. EducationSchedulingWeekNumID = adjust.EducationSchedulingWeekNumID,
  1209. EducationSchedulingAdjustmentID = adjust.EducationSchedulingAdjustmentID,
  1210. SchoolyearID = adjust.SchoolyearID,
  1211. SchoolyearCode = adjust.SchoolyearCode,
  1212. EducationSchedulingClassID = adjust.EducationSchedulingClassID,
  1213. EducationMissionClassName = adjust.EducationMissionClassName,
  1214. CoursematerialID = adjust.CoursematerialID,
  1215. CourseName = adjust.CourseName,
  1216. WeekNum = adjust.WeekNum,
  1217. Weekday = adjust.Weekday,
  1218. CoursesTime = adjust.CoursesTime,
  1219. StartTimes = adjust.StartTimes,
  1220. EndTimes = adjust.EndTimes,
  1221. ClassroomID = adjust.ClassroomID,
  1222. ClassroomName = adjust.ClassroomName,
  1223. StudentNum = adjust.StudentNum,
  1224. UserID = adjust.UserID,
  1225. UserName = adjust.UserName,
  1226. Reason = "教室坐席数量不足。"
  1227. }
  1228. );
  1229. return query;
  1230. }
  1231. public IQueryable<EducationSchedulingConflictView> GetClassroomReserveQueryable(IQueryable<EducationSchedulingConflictView> adjustSql)
  1232. {
  1233. var query = (
  1234. from adjust in adjustSql
  1235. from reserve in ClassroomReserveRepository.Entities.Where(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE
  1236. && x.IsReserved == true && x.ClassroomID == adjust.ClassroomID)
  1237. select new EducationSchedulingConflictView
  1238. {
  1239. EducationSchedulingWeekNumID = adjust.EducationSchedulingWeekNumID,
  1240. EducationSchedulingAdjustmentID = adjust.EducationSchedulingAdjustmentID,
  1241. SchoolyearID = adjust.SchoolyearID,
  1242. SchoolyearCode = adjust.SchoolyearCode,
  1243. EducationSchedulingClassID = adjust.EducationSchedulingClassID,
  1244. EducationMissionClassName = adjust.EducationMissionClassName,
  1245. CoursematerialID = adjust.CoursematerialID,
  1246. CourseName = adjust.CourseName,
  1247. WeekNum = adjust.WeekNum,
  1248. Weekday = adjust.Weekday,
  1249. CoursesTime = adjust.CoursesTime,
  1250. StartTimes = adjust.StartTimes,
  1251. EndTimes = adjust.EndTimes,
  1252. ClassroomID = adjust.ClassroomID,
  1253. ClassroomName = adjust.ClassroomName,
  1254. StudentNum = adjust.StudentNum,
  1255. UserID = adjust.UserID,
  1256. UserName = adjust.UserName,
  1257. Reason = "教室已被预留。"
  1258. }
  1259. );
  1260. return query;
  1261. }
  1262. public IQueryable<EducationSchedulingConflictView> GetClassroomScheduleConflicQueryable(IQueryable<EducationSchedulingConflictView> adjustSql)
  1263. {
  1264. var query = (
  1265. from adjust in adjustSql
  1266. from scheduleSet in ClassroomScheduleSettingRepository.Entities.Where(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE
  1267. && x.IsOnWork == false && x.ClassroomID == adjust.ClassroomID && x.Weekday == adjust.Weekday
  1268. && x.CoursesTimeID == adjust.CoursesTime)
  1269. select new EducationSchedulingConflictView
  1270. {
  1271. EducationSchedulingWeekNumID = adjust.EducationSchedulingWeekNumID,
  1272. EducationSchedulingAdjustmentID = adjust.EducationSchedulingAdjustmentID,
  1273. SchoolyearID = adjust.SchoolyearID,
  1274. SchoolyearCode = adjust.SchoolyearCode,
  1275. EducationSchedulingClassID = adjust.EducationSchedulingClassID,
  1276. EducationMissionClassName = adjust.EducationMissionClassName,
  1277. CoursematerialID = adjust.CoursematerialID,
  1278. CourseName = adjust.CourseName,
  1279. WeekNum = adjust.WeekNum,
  1280. Weekday = adjust.Weekday,
  1281. CoursesTime = adjust.CoursesTime,
  1282. StartTimes = adjust.StartTimes,
  1283. EndTimes = adjust.EndTimes,
  1284. ClassroomID = adjust.ClassroomID,
  1285. ClassroomName = adjust.ClassroomName,
  1286. StudentNum = adjust.StudentNum,
  1287. UserID = adjust.UserID,
  1288. UserName = adjust.UserName,
  1289. Reason = "教室不在可排时段内。"
  1290. }
  1291. );
  1292. return query;
  1293. }
  1294. public IQueryable<EducationSchedulingConflictView> GetClassroomConflicQueryable(IQueryable<EducationSchedulingConflictView> adjustSql)
  1295. {
  1296. var query = (
  1297. from adjust in adjustSql
  1298. from classroom in ClassroomRepository.Entities.Where(x => x.ClassroomID == adjust.ClassroomID)
  1299. from scheduling in EducationSchedulingRepository.Entities.Where(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE
  1300. && x.ClassroomID == adjust.ClassroomID && x.Weekday == adjust.Weekday && x.CoursesTimeID == adjust.CoursesTime
  1301. && x.SchoolyearID == adjust.SchoolyearID)
  1302. from weekNum in EducationSchedulingWeekNumRepository.Entities.Where(x => x.EducationSchedulingID == scheduling.EducationSchedulingID
  1303. && adjust.WeekNum == x.WeekNum && x.EducationSchedulingWeekNumID != adjust.EducationSchedulingWeekNumID)
  1304. where classroom.IsConcurrentUse != true
  1305. select new EducationSchedulingConflictView
  1306. {
  1307. EducationSchedulingWeekNumID = adjust.EducationSchedulingWeekNumID,
  1308. EducationSchedulingAdjustmentID = adjust.EducationSchedulingAdjustmentID,
  1309. SchoolyearID = adjust.SchoolyearID,
  1310. SchoolyearCode = adjust.SchoolyearCode,
  1311. EducationSchedulingClassID = adjust.EducationSchedulingClassID,
  1312. EducationMissionClassName = adjust.EducationMissionClassName,
  1313. CoursematerialID = adjust.CoursematerialID,
  1314. CourseName = adjust.CourseName,
  1315. WeekNum = adjust.WeekNum,
  1316. Weekday = adjust.Weekday,
  1317. CoursesTime = adjust.CoursesTime,
  1318. StartTimes = adjust.StartTimes,
  1319. EndTimes = adjust.EndTimes,
  1320. ClassroomID = adjust.ClassroomID,
  1321. ClassroomName = adjust.ClassroomName,
  1322. StudentNum = adjust.StudentNum,
  1323. UserID = adjust.UserID,
  1324. UserName = adjust.UserName,
  1325. Reason = "教室已被其他课程使用。"
  1326. }
  1327. );
  1328. return query;
  1329. }
  1330. public IQueryable<EducationSchedulingConflictView> GetClassroomExcessiveUseQueryable(IQueryable<EducationSchedulingConflictView> adjustSql)
  1331. {
  1332. var query = (
  1333. from adjust in adjustSql
  1334. from classroom in ClassroomRepository.Entities.Where(x => x.ClassroomID == adjust.ClassroomID)
  1335. from excessiveUse in ClassroomExcessiveUseRepository.Entities.Where(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE
  1336. && x.ClassroomID == classroom.ClassroomID && x.SchoolyearID == adjust.SchoolyearID)
  1337. from scheduling in ClassroomExcessiveUseSchedulingRepository.Entities.Where(x => x.ClassroomExcessiveUseID == excessiveUse.ClassroomExcessiveUseID
  1338. && x.Weekday == adjust.Weekday && x.CoursesTimeID == adjust.CoursesTime)
  1339. from weekNum in ClassroomExcessiveUseSchedulingWeekNumRepository.Entities.Where(x => x.ClassroomExcessiveUseSchedulingID == scheduling.ClassroomExcessiveUseSchedulingID
  1340. && x.WeekNum == adjust.WeekNum)
  1341. where classroom.IsConcurrentUse != true
  1342. select new EducationSchedulingConflictView
  1343. {
  1344. EducationSchedulingWeekNumID = adjust.EducationSchedulingWeekNumID,
  1345. EducationSchedulingAdjustmentID = adjust.EducationSchedulingAdjustmentID,
  1346. SchoolyearID = adjust.SchoolyearID,
  1347. SchoolyearCode = adjust.SchoolyearCode,
  1348. EducationSchedulingClassID = adjust.EducationSchedulingClassID,
  1349. EducationMissionClassName = adjust.EducationMissionClassName,
  1350. CoursematerialID = adjust.CoursematerialID,
  1351. CourseName = adjust.CourseName,
  1352. WeekNum = adjust.WeekNum,
  1353. Weekday = adjust.Weekday,
  1354. CoursesTime = adjust.CoursesTime,
  1355. StartTimes = adjust.StartTimes,
  1356. EndTimes = adjust.EndTimes,
  1357. ClassroomID = adjust.ClassroomID,
  1358. ClassroomName = adjust.ClassroomName,
  1359. StudentNum = adjust.StudentNum,
  1360. UserID = adjust.UserID,
  1361. UserName = adjust.UserName,
  1362. Reason = "教室已被占用。"
  1363. }
  1364. );
  1365. return query;
  1366. }
  1367. public IQueryable<EducationSchedulingConflictView> GetClassroomAdjustmentConflictQueryable(IQueryable<EducationSchedulingConflictView> adjustSql,
  1368. IList<int?> adjustmentSubmitedStatusList)
  1369. {
  1370. var query = (
  1371. from adjust in adjustSql
  1372. from classroom in ClassroomRepository.Entities.Where(x => x.ClassroomID == adjust.ClassroomID)
  1373. from other in EducationSchedulingAdjustmentRepository.Entities.Where(x =>
  1374. adjustmentSubmitedStatusList.Contains(x.RecordStatus) && x.ToClassroomID == adjust.ClassroomID
  1375. && x.ToWeekday == adjust.Weekday && x.ToCoursesTimeID == adjust.CoursesTime && x.ToWeekNum == adjust.WeekNum
  1376. && x.EducationSchedulingAdjustmentID != adjust.EducationSchedulingAdjustmentID)
  1377. where classroom.IsConcurrentUse != true
  1378. select new EducationSchedulingConflictView
  1379. {
  1380. EducationSchedulingWeekNumID = adjust.EducationSchedulingWeekNumID,
  1381. EducationSchedulingAdjustmentID = adjust.EducationSchedulingAdjustmentID,
  1382. SchoolyearID = adjust.SchoolyearID,
  1383. SchoolyearCode = adjust.SchoolyearCode,
  1384. EducationSchedulingClassID = adjust.EducationSchedulingClassID,
  1385. EducationMissionClassName = adjust.EducationMissionClassName,
  1386. CoursematerialID = adjust.CoursematerialID,
  1387. CourseName = adjust.CourseName,
  1388. WeekNum = adjust.WeekNum,
  1389. Weekday = adjust.Weekday,
  1390. CoursesTime = adjust.CoursesTime,
  1391. StartTimes = adjust.StartTimes,
  1392. EndTimes = adjust.EndTimes,
  1393. ClassroomID = adjust.ClassroomID,
  1394. ClassroomName = adjust.ClassroomName,
  1395. StudentNum = adjust.StudentNum,
  1396. UserID = adjust.UserID,
  1397. UserName = adjust.UserName,
  1398. Reason = "教室已被其他人申请调课占用。"
  1399. }
  1400. );
  1401. return query;
  1402. }
  1403. public IQueryable<EducationSchedulingConflictView> GetCourseScheduleConflictQueryable(IQueryable<EducationSchedulingConflictView> adjustSql)
  1404. {
  1405. var query = (from adjust in adjustSql
  1406. from scheduleSet in CourseScheduleSettingRepository.Entities.Where(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE
  1407. && x.IsOnWork == false && x.CoursematerialID == adjust.CoursematerialID && x.Weekday == adjust.Weekday
  1408. && x.CoursesTimeID == adjust.CoursesTime)
  1409. select new EducationSchedulingConflictView
  1410. {
  1411. EducationSchedulingWeekNumID = adjust.EducationSchedulingWeekNumID,
  1412. EducationSchedulingAdjustmentID = adjust.EducationSchedulingAdjustmentID,
  1413. SchoolyearID = adjust.SchoolyearID,
  1414. SchoolyearCode = adjust.SchoolyearCode,
  1415. EducationSchedulingClassID = adjust.EducationSchedulingClassID,
  1416. EducationMissionClassName = adjust.EducationMissionClassName,
  1417. CoursematerialID = adjust.CoursematerialID,
  1418. CourseName = adjust.CourseName,
  1419. WeekNum = adjust.WeekNum,
  1420. Weekday = adjust.Weekday,
  1421. CoursesTime = adjust.CoursesTime,
  1422. StartTimes = adjust.StartTimes,
  1423. EndTimes = adjust.EndTimes,
  1424. ClassroomID = adjust.ClassroomID,
  1425. ClassroomName = adjust.ClassroomName,
  1426. StudentNum = adjust.StudentNum,
  1427. UserID = adjust.UserID,
  1428. UserName = adjust.UserName,
  1429. Reason = "课程不在可排时段内。"
  1430. });
  1431. return query;
  1432. }
  1433. public IQueryable<EducationSchedulingConflictView> GetTeacherScheduleConflictQueryable(IQueryable<EducationSchedulingConflictView> adjustSql)
  1434. {
  1435. var query = (from adjust in adjustSql
  1436. from scheduleSet in TeacherScheduleSettingRepository.Entities.Where(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE
  1437. && x.IsOnWork == false && x.UserID == adjust.UserID && x.Weekday == adjust.Weekday
  1438. && x.CoursesTimeID == adjust.CoursesTime)
  1439. select new EducationSchedulingConflictView
  1440. {
  1441. EducationSchedulingWeekNumID = adjust.EducationSchedulingWeekNumID,
  1442. EducationSchedulingAdjustmentID = adjust.EducationSchedulingAdjustmentID,
  1443. SchoolyearID = adjust.SchoolyearID,
  1444. SchoolyearCode = adjust.SchoolyearCode,
  1445. EducationSchedulingClassID = adjust.EducationSchedulingClassID,
  1446. EducationMissionClassName = adjust.EducationMissionClassName,
  1447. CoursematerialID = adjust.CoursematerialID,
  1448. CourseName = adjust.CourseName,
  1449. WeekNum = adjust.WeekNum,
  1450. Weekday = adjust.Weekday,
  1451. CoursesTime = adjust.CoursesTime,
  1452. StartTimes = adjust.StartTimes,
  1453. EndTimes = adjust.EndTimes,
  1454. ClassroomID = adjust.ClassroomID,
  1455. ClassroomName = adjust.ClassroomName,
  1456. StudentNum = adjust.StudentNum,
  1457. UserID = adjust.UserID,
  1458. UserName = adjust.UserName,
  1459. Reason = "教师不在可排时段内。"
  1460. });
  1461. return query;
  1462. }
  1463. public IQueryable<EducationSchedulingConflictView> GetTeacherConflictQueryable(IQueryable<EducationSchedulingConflictView> adjustSql)
  1464. {
  1465. var query = (
  1466. from adjust in adjustSql
  1467. from scheduling in EducationSchedulingRepository.Entities.Where(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE
  1468. && x.ES_EducationSchedulingTeacher.Any(w => w.UserID == adjust.UserID) && x.Weekday == adjust.Weekday
  1469. && x.CoursesTimeID == adjust.CoursesTime && x.SchoolyearID == adjust.SchoolyearID)
  1470. from weekNum in EducationSchedulingWeekNumRepository.Entities.Where(x => x.EducationSchedulingID == scheduling.EducationSchedulingID
  1471. && adjust.WeekNum == x.WeekNum && x.EducationSchedulingWeekNumID != adjust.EducationSchedulingWeekNumID)
  1472. select new EducationSchedulingConflictView
  1473. {
  1474. EducationSchedulingWeekNumID = adjust.EducationSchedulingWeekNumID,
  1475. EducationSchedulingAdjustmentID = adjust.EducationSchedulingAdjustmentID,
  1476. SchoolyearID = adjust.SchoolyearID,
  1477. SchoolyearCode = adjust.SchoolyearCode,
  1478. EducationSchedulingClassID = adjust.EducationSchedulingClassID,
  1479. EducationMissionClassName = adjust.EducationMissionClassName,
  1480. CoursematerialID = adjust.CoursematerialID,
  1481. CourseName = adjust.CourseName,
  1482. WeekNum = adjust.WeekNum,
  1483. Weekday = adjust.Weekday,
  1484. CoursesTime = adjust.CoursesTime,
  1485. StartTimes = adjust.StartTimes,
  1486. EndTimes = adjust.EndTimes,
  1487. ClassroomID = adjust.ClassroomID,
  1488. ClassroomName = adjust.ClassroomName,
  1489. StudentNum = adjust.StudentNum,
  1490. UserID = adjust.UserID,
  1491. UserName = adjust.UserName,
  1492. Reason = "教师在该时段有课。"
  1493. });
  1494. return query;
  1495. }
  1496. public IQueryable<EducationSchedulingConflictView> GetTeacherAdjustmentConflictQueryable(IQueryable<EducationSchedulingConflictView> adjustSql,
  1497. IList<int?> adjustmentSubmitedStatusList)
  1498. {
  1499. //有BUG,课程调整缺少学年学期的判断
  1500. var query = (
  1501. from adjust in adjustSql
  1502. from other in EducationSchedulingAdjustmentRepository.Entities.Where(x => x.ToUserID == adjust.UserID
  1503. && x.ToWeekNum == adjust.WeekNum && x.ToWeekday == adjust.Weekday && x.ToCoursesTimeID == adjust.CoursesTime
  1504. && adjustmentSubmitedStatusList.Contains(x.RecordStatus)
  1505. && x.EducationSchedulingAdjustmentID != adjust.EducationSchedulingAdjustmentID)
  1506. select new EducationSchedulingConflictView
  1507. {
  1508. EducationSchedulingWeekNumID = adjust.EducationSchedulingWeekNumID,
  1509. EducationSchedulingAdjustmentID = adjust.EducationSchedulingAdjustmentID,
  1510. SchoolyearID = adjust.SchoolyearID,
  1511. SchoolyearCode = adjust.SchoolyearCode,
  1512. EducationSchedulingClassID = adjust.EducationSchedulingClassID,
  1513. EducationMissionClassName = adjust.EducationMissionClassName,
  1514. CoursematerialID = adjust.CoursematerialID,
  1515. CourseName = adjust.CourseName,
  1516. WeekNum = adjust.WeekNum,
  1517. Weekday = adjust.Weekday,
  1518. CoursesTime = adjust.CoursesTime,
  1519. StartTimes = adjust.StartTimes,
  1520. EndTimes = adjust.EndTimes,
  1521. ClassroomID = adjust.ClassroomID,
  1522. ClassroomName = adjust.ClassroomName,
  1523. StudentNum = adjust.StudentNum,
  1524. UserID = adjust.UserID,
  1525. UserName = adjust.UserName,
  1526. Reason = "教师该时段已被其他人申请调课占用。"
  1527. }
  1528. );
  1529. return query;
  1530. }
  1531. public IQueryable<EducationSchedulingConflictView> GetStudentScheduleConflictQueryable(IQueryable<EducationSchedulingConflictView> adjustSql)
  1532. {
  1533. var query = (from adjust in adjustSql
  1534. from schedulingClass in EducationSchedulingClassRepository.Entities.Where(x => x.EducationSchedulingClassID == adjust.EducationSchedulingClassID)
  1535. from student in schedulingClass.CF_Student
  1536. from scheduleSet in ClassmajorScheduleSettingRepository.Entities.Where(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE
  1537. && x.IsOnWork == false && x.ClassmajorID == student.ClassmajorID && x.Weekday == adjust.Weekday
  1538. && x.CoursesTimeID == adjust.CoursesTime)
  1539. select new EducationSchedulingConflictView
  1540. {
  1541. EducationSchedulingWeekNumID = adjust.EducationSchedulingWeekNumID,
  1542. EducationSchedulingAdjustmentID = adjust.EducationSchedulingAdjustmentID,
  1543. SchoolyearID = adjust.SchoolyearID,
  1544. SchoolyearCode = adjust.SchoolyearCode,
  1545. EducationSchedulingClassID = adjust.EducationSchedulingClassID,
  1546. EducationMissionClassName = adjust.EducationMissionClassName,
  1547. CoursematerialID = adjust.CoursematerialID,
  1548. CourseName = adjust.CourseName,
  1549. WeekNum = adjust.WeekNum,
  1550. Weekday = adjust.Weekday,
  1551. CoursesTime = adjust.CoursesTime,
  1552. StartTimes = adjust.StartTimes,
  1553. EndTimes = adjust.EndTimes,
  1554. ClassroomID = adjust.ClassroomID,
  1555. ClassroomName = adjust.ClassroomName,
  1556. StudentNum = adjust.StudentNum,
  1557. UserID = adjust.UserID,
  1558. UserName = adjust.UserName,
  1559. Reason = "学生的班级不在可排时段内。"
  1560. });
  1561. return query;
  1562. }
  1563. public IQueryable<EducationSchedulingConflictView> GetStudentConflictQueryable(IQueryable<EducationSchedulingConflictView> adjustSql)
  1564. {
  1565. var query = (
  1566. from adjust in adjustSql
  1567. from schedulingClass in EducationSchedulingClassRepository.Entities.Where(x => x.EducationSchedulingClassID == adjust.EducationSchedulingClassID)
  1568. from student in schedulingClass.CF_Student
  1569. from scheduling in EducationSchedulingRepository.Entities.Where(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE
  1570. && x.Weekday == adjust.Weekday && x.CoursesTimeID == adjust.CoursesTime && x.SchoolyearID == adjust.SchoolyearID)
  1571. from weekNum in EducationSchedulingWeekNumRepository.Entities.Where(x => x.EducationSchedulingID == scheduling.EducationSchedulingID
  1572. && adjust.WeekNum == x.WeekNum && x.EducationSchedulingWeekNumID != adjust.EducationSchedulingWeekNumID)
  1573. from otherClass in EducationSchedulingClassRepository.Entities.Where(x => x.EducationSchedulingClassID == scheduling.EducationSchedulingClassID)
  1574. from otherStudent in otherClass.CF_Student.AsQueryable().Where(x => x.UserID == student.UserID)
  1575. group adjust by adjust.EducationSchedulingWeekNumID into g
  1576. select g.FirstOrDefault() into result
  1577. select new EducationSchedulingConflictView
  1578. {
  1579. EducationSchedulingWeekNumID = result.EducationSchedulingWeekNumID,
  1580. EducationSchedulingAdjustmentID = result.EducationSchedulingAdjustmentID,
  1581. SchoolyearID = result.SchoolyearID,
  1582. SchoolyearCode = result.SchoolyearCode,
  1583. EducationSchedulingClassID = result.EducationSchedulingClassID,
  1584. EducationMissionClassName = result.EducationMissionClassName,
  1585. CoursematerialID = result.CoursematerialID,
  1586. CourseName = result.CourseName,
  1587. WeekNum = result.WeekNum,
  1588. Weekday = result.Weekday,
  1589. CoursesTime = result.CoursesTime,
  1590. StartTimes = result.StartTimes,
  1591. EndTimes = result.EndTimes,
  1592. ClassroomID = result.ClassroomID,
  1593. ClassroomName = result.ClassroomName,
  1594. StudentNum = result.StudentNum,
  1595. UserID = result.UserID,
  1596. UserName = result.UserName,
  1597. Reason = "学生在该时段有课。"
  1598. });
  1599. return query;
  1600. }
  1601. public IQueryable<EducationSchedulingConflictView> GetStudentAdjustmentConflictQueryable(IQueryable<EducationSchedulingConflictView> adjustSql,
  1602. IList<int?> adjustmentSubmitedStatusList)
  1603. {
  1604. var query = (
  1605. from adjust in adjustSql
  1606. from schedulingClass in EducationSchedulingClassRepository.Entities.Where(x => x.EducationSchedulingClassID == adjust.EducationSchedulingClassID)
  1607. from student in schedulingClass.CF_Student
  1608. from other in EducationSchedulingAdjustmentRepository.Entities.Where(x =>
  1609. adjustmentSubmitedStatusList.Contains(x.RecordStatus) && x.ToUserID == adjust.UserID
  1610. && x.ToWeekday == adjust.Weekday && x.ToCoursesTimeID == adjust.CoursesTime && x.ToWeekNum == adjust.WeekNum
  1611. && x.EducationSchedulingAdjustmentID != adjust.EducationSchedulingAdjustmentID)
  1612. from otherClass in EducationSchedulingClassRepository.Entities.Where(x => x.EducationMissionClassID == other.EducationMissionClassID)
  1613. from otherStudent in otherClass.CF_Student.AsQueryable().Where(x => x.UserID == student.UserID)
  1614. group adjust by adjust.EducationSchedulingWeekNumID into g
  1615. select g.FirstOrDefault() into result
  1616. select new EducationSchedulingConflictView
  1617. {
  1618. EducationSchedulingWeekNumID = result.EducationSchedulingWeekNumID,
  1619. EducationSchedulingAdjustmentID = result.EducationSchedulingAdjustmentID,
  1620. SchoolyearID = result.SchoolyearID,
  1621. SchoolyearCode = result.SchoolyearCode,
  1622. EducationSchedulingClassID = result.EducationSchedulingClassID,
  1623. EducationMissionClassName = result.EducationMissionClassName,
  1624. CoursematerialID = result.CoursematerialID,
  1625. CourseName = result.CourseName,
  1626. WeekNum = result.WeekNum,
  1627. Weekday = result.Weekday,
  1628. CoursesTime = result.CoursesTime,
  1629. StartTimes = result.StartTimes,
  1630. EndTimes = result.EndTimes,
  1631. ClassroomID = result.ClassroomID,
  1632. ClassroomName = result.ClassroomName,
  1633. StudentNum = result.StudentNum,
  1634. UserID = result.UserID,
  1635. UserName = result.UserName,
  1636. Reason = "学生该时段已被其他人申请调课占用。"
  1637. }
  1638. );
  1639. return query;
  1640. }
  1641. //private IQueryable<EducationSchedulingConflictView> GetConflictAdjustmentSchedule(IQueryable<EducationSchedulingConflictView> adjustSql,
  1642. // IList<int?> adjustmentSubmitedStatusList)
  1643. //{
  1644. // var selfClassroomConflictSql = (from adjust in adjustSql
  1645. // group adjust by new { adjust.WeekNum, adjust.Weekday, adjust.CoursesTime, adjust.ClassroomID } into g
  1646. // where g.Count() > 1
  1647. // select g).SelectMany(x => x)
  1648. // .Select(x => new EducationSchedulingConflictView
  1649. // {
  1650. // EducationSchedulingWeekNumID = x.EducationSchedulingWeekNumID,
  1651. // EducationSchedulingAdjustmentID = x.EducationSchedulingAdjustmentID,
  1652. // SchoolyearID = x.SchoolyearID,
  1653. // SchoolyearCode = x.SchoolyearCode,
  1654. // EducationSchedulingClassID = x.EducationSchedulingClassID,
  1655. // EducationMissionClassName = x.EducationMissionClassName,
  1656. // CoursematerialID = x.CoursematerialID,
  1657. // CourseName = x.CourseName,
  1658. // WeekNum = x.WeekNum,
  1659. // Weekday = x.Weekday,
  1660. // CoursesTime = x.CoursesTime,
  1661. // StartTimes = x.StartTimes,
  1662. // EndTimes = x.EndTimes,
  1663. // ClassroomID = x.ClassroomID,
  1664. // ClassroomName = x.ClassroomName,
  1665. // StudentNum = x.StudentNum,
  1666. // UserID = x.UserID,
  1667. // UserName = x.UserName,
  1668. // Reason = "和其他提交的数据存在教室冲突。"
  1669. // });
  1670. // var selfTeacherConflictSql = (from adjust in adjustSql
  1671. // group adjust by new { adjust.WeekNum, adjust.Weekday, adjust.CoursesTime, adjust.UserID } into g
  1672. // where g.Count() > 1
  1673. // select g).SelectMany(x => x)
  1674. // .Select(x => new EducationSchedulingConflictView
  1675. // {
  1676. // EducationSchedulingWeekNumID = x.EducationSchedulingWeekNumID,
  1677. // EducationSchedulingAdjustmentID = x.EducationSchedulingAdjustmentID,
  1678. // SchoolyearID = x.SchoolyearID,
  1679. // SchoolyearCode = x.SchoolyearCode,
  1680. // EducationSchedulingClassID = x.EducationSchedulingClassID,
  1681. // EducationMissionClassName = x.EducationMissionClassName,
  1682. // CoursematerialID = x.CoursematerialID,
  1683. // CourseName = x.CourseName,
  1684. // WeekNum = x.WeekNum,
  1685. // Weekday = x.Weekday,
  1686. // CoursesTime = x.CoursesTime,
  1687. // StartTimes = x.StartTimes,
  1688. // EndTimes = x.EndTimes,
  1689. // ClassroomID = x.ClassroomID,
  1690. // ClassroomName = x.ClassroomName,
  1691. // StudentNum = x.StudentNum,
  1692. // UserID = x.UserID,
  1693. // UserName = x.UserName,
  1694. // Reason = "和其他提交的数据存在教师冲突。"
  1695. // });
  1696. // var selfStudentConflictSql = (from adjust in adjustSql
  1697. // from schedulingClass in EducationSchedulingClassRepository.Entities
  1698. // .Where(x => x.EducationSchedulingClassID == adjust.EducationSchedulingClassID)
  1699. // from student in schedulingClass.CF_Student
  1700. // group adjust by new { adjust.WeekNum, adjust.Weekday, adjust.CoursesTime, student.UserID } into g
  1701. // where g.Count() > 1
  1702. // select g).SelectMany(x => x)
  1703. // .GroupBy(x => new { x.EducationSchedulingWeekNumID, x.EducationSchedulingAdjustmentID })
  1704. // .Select(x => x.FirstOrDefault())
  1705. // .Select(x => new EducationSchedulingConflictView
  1706. // {
  1707. // EducationSchedulingWeekNumID = x.EducationSchedulingWeekNumID,
  1708. // EducationSchedulingAdjustmentID = x.EducationSchedulingAdjustmentID,
  1709. // SchoolyearID = x.SchoolyearID,
  1710. // SchoolyearCode = x.SchoolyearCode,
  1711. // EducationSchedulingClassID = x.EducationSchedulingClassID,
  1712. // EducationMissionClassName = x.EducationMissionClassName,
  1713. // CoursematerialID = x.CoursematerialID,
  1714. // CourseName = x.CourseName,
  1715. // WeekNum = x.WeekNum,
  1716. // Weekday = x.Weekday,
  1717. // CoursesTime = x.CoursesTime,
  1718. // StartTimes = x.StartTimes,
  1719. // EndTimes = x.EndTimes,
  1720. // ClassroomID = x.ClassroomID,
  1721. // ClassroomName = x.ClassroomName,
  1722. // StudentNum = x.StudentNum,
  1723. // UserID = x.UserID,
  1724. // UserName = x.UserName,
  1725. // Reason = "和其他提交的数据存在教师冲突。"
  1726. // });
  1727. // var classroomConflictSql = (from adjust in adjustSql
  1728. // from classroom in ClassroomRepository.Entities.Where(x => x.ClassroomID == adjust.ClassroomID)
  1729. // where (classroom.Totalseating ?? 0) != 0 && classroom.Totalseating < adjust.StudentNum
  1730. // select new EducationSchedulingConflictView
  1731. // {
  1732. // EducationSchedulingWeekNumID = adjust.EducationSchedulingWeekNumID,
  1733. // EducationSchedulingAdjustmentID = adjust.EducationSchedulingAdjustmentID,
  1734. // SchoolyearID = adjust.SchoolyearID,
  1735. // SchoolyearCode = adjust.SchoolyearCode,
  1736. // EducationSchedulingClassID = adjust.EducationSchedulingClassID,
  1737. // EducationMissionClassName = adjust.EducationMissionClassName,
  1738. // CoursematerialID = adjust.CoursematerialID,
  1739. // CourseName = adjust.CourseName,
  1740. // WeekNum = adjust.WeekNum,
  1741. // Weekday = adjust.Weekday,
  1742. // CoursesTime = adjust.CoursesTime,
  1743. // StartTimes = adjust.StartTimes,
  1744. // EndTimes = adjust.EndTimes,
  1745. // ClassroomID = adjust.ClassroomID,
  1746. // ClassroomName = adjust.ClassroomName,
  1747. // StudentNum = adjust.StudentNum,
  1748. // UserID = adjust.UserID,
  1749. // UserName = adjust.UserName,
  1750. // Reason = "教室坐席数量不足。"
  1751. // }
  1752. // ).Concat(
  1753. // from adjust in adjustSql
  1754. // from reserve in ClassroomReserveRepository.Entities.Where(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE
  1755. // && x.IsReserved == true && x.ClassroomID == adjust.ClassroomID)
  1756. // select new EducationSchedulingConflictView
  1757. // {
  1758. // EducationSchedulingWeekNumID = adjust.EducationSchedulingWeekNumID,
  1759. // EducationSchedulingAdjustmentID = adjust.EducationSchedulingAdjustmentID,
  1760. // SchoolyearID = adjust.SchoolyearID,
  1761. // SchoolyearCode = adjust.SchoolyearCode,
  1762. // EducationSchedulingClassID = adjust.EducationSchedulingClassID,
  1763. // EducationMissionClassName = adjust.EducationMissionClassName,
  1764. // CoursematerialID = adjust.CoursematerialID,
  1765. // CourseName = adjust.CourseName,
  1766. // WeekNum = adjust.WeekNum,
  1767. // Weekday = adjust.Weekday,
  1768. // CoursesTime = adjust.CoursesTime,
  1769. // StartTimes = adjust.StartTimes,
  1770. // EndTimes = adjust.EndTimes,
  1771. // ClassroomID = adjust.ClassroomID,
  1772. // ClassroomName = adjust.ClassroomName,
  1773. // StudentNum = adjust.StudentNum,
  1774. // UserID = adjust.UserID,
  1775. // UserName = adjust.UserName,
  1776. // Reason = "教室已被预留。"
  1777. // }
  1778. // ).Concat(
  1779. // from adjust in adjustSql
  1780. // from scheduleSet in ClassroomScheduleSettingRepository.Entities.Where(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE
  1781. // && x.IsOnWork == false && x.ClassroomID == adjust.ClassroomID && x.Weekday == adjust.Weekday
  1782. // && x.CoursesTimeID == x.CoursesTimeID)
  1783. // select new EducationSchedulingConflictView
  1784. // {
  1785. // EducationSchedulingWeekNumID = adjust.EducationSchedulingWeekNumID,
  1786. // EducationSchedulingAdjustmentID = adjust.EducationSchedulingAdjustmentID,
  1787. // SchoolyearID = adjust.SchoolyearID,
  1788. // SchoolyearCode = adjust.SchoolyearCode,
  1789. // EducationSchedulingClassID = adjust.EducationSchedulingClassID,
  1790. // EducationMissionClassName = adjust.EducationMissionClassName,
  1791. // CoursematerialID = adjust.CoursematerialID,
  1792. // CourseName = adjust.CourseName,
  1793. // WeekNum = adjust.WeekNum,
  1794. // Weekday = adjust.Weekday,
  1795. // CoursesTime = adjust.CoursesTime,
  1796. // StartTimes = adjust.StartTimes,
  1797. // EndTimes = adjust.EndTimes,
  1798. // ClassroomID = adjust.ClassroomID,
  1799. // ClassroomName = adjust.ClassroomName,
  1800. // StudentNum = adjust.StudentNum,
  1801. // UserID = adjust.UserID,
  1802. // UserName = adjust.UserName,
  1803. // Reason = "教室不在可排时段内。"
  1804. // }
  1805. // ).Concat(
  1806. // from adjust in adjustSql
  1807. // from classroom in ClassroomRepository.Entities.Where(x => x.ClassroomID == adjust.ClassroomID)
  1808. // from scheduling in EducationSchedulingRepository.Entities.Where(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE
  1809. // && x.ClassroomID == adjust.ClassroomID && x.Weekday == adjust.Weekday && x.CoursesTimeID == adjust.CoursesTime
  1810. // && x.SchoolyearID == adjust.SchoolyearID)
  1811. // from weekNum in EducationSchedulingWeekNumRepository.Entities.Where(x => x.EducationSchedulingID == scheduling.EducationSchedulingID
  1812. // && adjust.WeekNum == x.WeekNum && x.EducationSchedulingWeekNumID != adjust.EducationSchedulingWeekNumID)
  1813. // where classroom.IsConcurrentUse != true
  1814. // select new EducationSchedulingConflictView
  1815. // {
  1816. // EducationSchedulingWeekNumID = adjust.EducationSchedulingWeekNumID,
  1817. // EducationSchedulingAdjustmentID = adjust.EducationSchedulingAdjustmentID,
  1818. // SchoolyearID = adjust.SchoolyearID,
  1819. // SchoolyearCode = adjust.SchoolyearCode,
  1820. // EducationSchedulingClassID = adjust.EducationSchedulingClassID,
  1821. // EducationMissionClassName = adjust.EducationMissionClassName,
  1822. // CoursematerialID = adjust.CoursematerialID,
  1823. // CourseName = adjust.CourseName,
  1824. // WeekNum = adjust.WeekNum,
  1825. // Weekday = adjust.Weekday,
  1826. // CoursesTime = adjust.CoursesTime,
  1827. // StartTimes = adjust.StartTimes,
  1828. // EndTimes = adjust.EndTimes,
  1829. // ClassroomID = adjust.ClassroomID,
  1830. // ClassroomName = adjust.ClassroomName,
  1831. // StudentNum = adjust.StudentNum,
  1832. // UserID = adjust.UserID,
  1833. // UserName = adjust.UserName,
  1834. // Reason = "教室已被其他课程使用。"
  1835. // }
  1836. // ).Concat(
  1837. // from adjust in adjustSql
  1838. // from classroom in ClassroomRepository.Entities.Where(x => x.ClassroomID == adjust.ClassroomID)
  1839. // from excessiveUse in ClassroomExcessiveUseRepository.Entities.Where(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE
  1840. // && x.ClassroomID == classroom.ClassroomID && x.SchoolyearID == adjust.SchoolyearID)
  1841. // from scheduling in ClassroomExcessiveUseSchedulingRepository.Entities.Where(x => x.ClassroomExcessiveUseID == excessiveUse.ClassroomExcessiveUseID
  1842. // && x.Weekday == adjust.Weekday && x.CoursesTimeID == adjust.CoursesTime)
  1843. // from weekNum in ClassroomExcessiveUseSchedulingWeekNumRepository.Entities.Where(x => x.ClassroomExcessiveUseSchedulingID == scheduling.ClassroomExcessiveUseSchedulingID
  1844. // && x.WeekNum == adjust.WeekNum)
  1845. // where classroom.IsConcurrentUse != true
  1846. // select new EducationSchedulingConflictView
  1847. // {
  1848. // EducationSchedulingWeekNumID = adjust.EducationSchedulingWeekNumID,
  1849. // EducationSchedulingAdjustmentID = adjust.EducationSchedulingAdjustmentID,
  1850. // SchoolyearID = adjust.SchoolyearID,
  1851. // SchoolyearCode = adjust.SchoolyearCode,
  1852. // EducationSchedulingClassID = adjust.EducationSchedulingClassID,
  1853. // EducationMissionClassName = adjust.EducationMissionClassName,
  1854. // CoursematerialID = adjust.CoursematerialID,
  1855. // CourseName = adjust.CourseName,
  1856. // WeekNum = adjust.WeekNum,
  1857. // Weekday = adjust.Weekday,
  1858. // CoursesTime = adjust.CoursesTime,
  1859. // StartTimes = adjust.StartTimes,
  1860. // EndTimes = adjust.EndTimes,
  1861. // ClassroomID = adjust.ClassroomID,
  1862. // ClassroomName = adjust.ClassroomName,
  1863. // StudentNum = adjust.StudentNum,
  1864. // UserID = adjust.UserID,
  1865. // UserName = adjust.UserName,
  1866. // Reason = "教室已被占用。"
  1867. // }
  1868. // ).Concat(
  1869. // from adjust in adjustSql
  1870. // from classroom in ClassroomRepository.Entities.Where(x => x.ClassroomID == adjust.ClassroomID)
  1871. // from other in EducationSchedulingAdjustmentRepository.Entities.Where(x =>
  1872. // adjustmentSubmitedStatusList.Contains(x.RecordStatus) && x.ToClassroomID == adjust.ClassroomID
  1873. // && x.ToWeekday == adjust.Weekday && x.ToCoursesTimeID == adjust.CoursesTime && x.ToWeekNum == adjust.WeekNum
  1874. // && x.EducationSchedulingAdjustmentID != adjust.EducationSchedulingAdjustmentID)
  1875. // where classroom.IsConcurrentUse != true
  1876. // select new EducationSchedulingConflictView
  1877. // {
  1878. // EducationSchedulingWeekNumID = adjust.EducationSchedulingWeekNumID,
  1879. // EducationSchedulingAdjustmentID = adjust.EducationSchedulingAdjustmentID,
  1880. // SchoolyearID = adjust.SchoolyearID,
  1881. // SchoolyearCode = adjust.SchoolyearCode,
  1882. // EducationSchedulingClassID = adjust.EducationSchedulingClassID,
  1883. // EducationMissionClassName = adjust.EducationMissionClassName,
  1884. // CoursematerialID = adjust.CoursematerialID,
  1885. // CourseName = adjust.CourseName,
  1886. // WeekNum = adjust.WeekNum,
  1887. // Weekday = adjust.Weekday,
  1888. // CoursesTime = adjust.CoursesTime,
  1889. // StartTimes = adjust.StartTimes,
  1890. // EndTimes = adjust.EndTimes,
  1891. // ClassroomID = adjust.ClassroomID,
  1892. // ClassroomName = adjust.ClassroomName,
  1893. // StudentNum = adjust.StudentNum,
  1894. // UserID = adjust.UserID,
  1895. // UserName = adjust.UserName,
  1896. // Reason = "教室已被其他人申请调课占用。"
  1897. // }
  1898. // );
  1899. // var courseConflictSql = (from adjust in adjustSql
  1900. // from scheduleSet in CourseScheduleSettingRepository.Entities.Where(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE
  1901. // && x.IsOnWork == false && x.CoursematerialID == adjust.CoursematerialID && x.Weekday == adjust.Weekday
  1902. // && x.CoursesTimeID == x.CoursesTimeID)
  1903. // select new EducationSchedulingConflictView
  1904. // {
  1905. // EducationSchedulingWeekNumID = adjust.EducationSchedulingWeekNumID,
  1906. // EducationSchedulingAdjustmentID = adjust.EducationSchedulingAdjustmentID,
  1907. // SchoolyearID = adjust.SchoolyearID,
  1908. // SchoolyearCode = adjust.SchoolyearCode,
  1909. // EducationSchedulingClassID = adjust.EducationSchedulingClassID,
  1910. // EducationMissionClassName = adjust.EducationMissionClassName,
  1911. // CoursematerialID = adjust.CoursematerialID,
  1912. // CourseName = adjust.CourseName,
  1913. // WeekNum = adjust.WeekNum,
  1914. // Weekday = adjust.Weekday,
  1915. // CoursesTime = adjust.CoursesTime,
  1916. // StartTimes = adjust.StartTimes,
  1917. // EndTimes = adjust.EndTimes,
  1918. // ClassroomID = adjust.ClassroomID,
  1919. // ClassroomName = adjust.ClassroomName,
  1920. // StudentNum = adjust.StudentNum,
  1921. // UserID = adjust.UserID,
  1922. // UserName = adjust.UserName,
  1923. // Reason = "课程不在可排时段内。"
  1924. // });
  1925. // var teacherConflictSql = (from adjust in adjustSql
  1926. // from scheduleSet in TeacherScheduleSettingRepository.Entities.Where(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE
  1927. // && x.IsOnWork == false && x.UserID == adjust.UserID && x.Weekday == adjust.Weekday
  1928. // && x.CoursesTimeID == x.CoursesTimeID)
  1929. // select new EducationSchedulingConflictView
  1930. // {
  1931. // EducationSchedulingWeekNumID = adjust.EducationSchedulingWeekNumID,
  1932. // EducationSchedulingAdjustmentID = adjust.EducationSchedulingAdjustmentID,
  1933. // SchoolyearID = adjust.SchoolyearID,
  1934. // SchoolyearCode = adjust.SchoolyearCode,
  1935. // EducationSchedulingClassID = adjust.EducationSchedulingClassID,
  1936. // EducationMissionClassName = adjust.EducationMissionClassName,
  1937. // CoursematerialID = adjust.CoursematerialID,
  1938. // CourseName = adjust.CourseName,
  1939. // WeekNum = adjust.WeekNum,
  1940. // Weekday = adjust.Weekday,
  1941. // CoursesTime = adjust.CoursesTime,
  1942. // StartTimes = adjust.StartTimes,
  1943. // EndTimes = adjust.EndTimes,
  1944. // ClassroomID = adjust.ClassroomID,
  1945. // ClassroomName = adjust.ClassroomName,
  1946. // StudentNum = adjust.StudentNum,
  1947. // UserID = adjust.UserID,
  1948. // UserName = adjust.UserName,
  1949. // Reason = "教师不在可排时段内。"
  1950. // }).Concat(
  1951. // from adjust in adjustSql
  1952. // from scheduling in EducationSchedulingRepository.Entities.Where(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE
  1953. // && x.ES_EducationSchedulingTeacher.Any(w => w.UserID == adjust.UserID) && x.Weekday == adjust.Weekday
  1954. // && x.CoursesTimeID == adjust.CoursesTime && x.SchoolyearID == adjust.SchoolyearID)
  1955. // from weekNum in EducationSchedulingWeekNumRepository.Entities.Where(x => x.EducationSchedulingID == scheduling.EducationSchedulingID
  1956. // && adjust.WeekNum == x.WeekNum && x.EducationSchedulingWeekNumID != adjust.EducationSchedulingWeekNumID)
  1957. // select new EducationSchedulingConflictView
  1958. // {
  1959. // EducationSchedulingWeekNumID = adjust.EducationSchedulingWeekNumID,
  1960. // EducationSchedulingAdjustmentID = adjust.EducationSchedulingAdjustmentID,
  1961. // SchoolyearID = adjust.SchoolyearID,
  1962. // SchoolyearCode = adjust.SchoolyearCode,
  1963. // EducationSchedulingClassID = adjust.EducationSchedulingClassID,
  1964. // EducationMissionClassName = adjust.EducationMissionClassName,
  1965. // CoursematerialID = adjust.CoursematerialID,
  1966. // CourseName = adjust.CourseName,
  1967. // WeekNum = adjust.WeekNum,
  1968. // Weekday = adjust.Weekday,
  1969. // CoursesTime = adjust.CoursesTime,
  1970. // StartTimes = adjust.StartTimes,
  1971. // EndTimes = adjust.EndTimes,
  1972. // ClassroomID = adjust.ClassroomID,
  1973. // ClassroomName = adjust.ClassroomName,
  1974. // StudentNum = adjust.StudentNum,
  1975. // UserID = adjust.UserID,
  1976. // UserName = adjust.UserName,
  1977. // Reason = "教师在该时段有课。"
  1978. // }).Concat(
  1979. // from adjust in adjustSql
  1980. // from other in EducationSchedulingAdjustmentRepository.Entities.Where(x =>
  1981. // adjustmentSubmitedStatusList.Contains(x.RecordStatus) && x.ToUserID == adjust.UserID
  1982. // && x.ToWeekday == adjust.Weekday && x.ToCoursesTimeID == adjust.CoursesTime && x.ToWeekNum == adjust.WeekNum
  1983. // && x.EducationSchedulingAdjustmentID != adjust.EducationSchedulingAdjustmentID)
  1984. // select new EducationSchedulingConflictView
  1985. // {
  1986. // EducationSchedulingWeekNumID = adjust.EducationSchedulingWeekNumID,
  1987. // EducationSchedulingAdjustmentID = adjust.EducationSchedulingAdjustmentID,
  1988. // SchoolyearID = adjust.SchoolyearID,
  1989. // SchoolyearCode = adjust.SchoolyearCode,
  1990. // EducationSchedulingClassID = adjust.EducationSchedulingClassID,
  1991. // EducationMissionClassName = adjust.EducationMissionClassName,
  1992. // CoursematerialID = adjust.CoursematerialID,
  1993. // CourseName = adjust.CourseName,
  1994. // WeekNum = adjust.WeekNum,
  1995. // Weekday = adjust.Weekday,
  1996. // CoursesTime = adjust.CoursesTime,
  1997. // StartTimes = adjust.StartTimes,
  1998. // EndTimes = adjust.EndTimes,
  1999. // ClassroomID = adjust.ClassroomID,
  2000. // ClassroomName = adjust.ClassroomName,
  2001. // StudentNum = adjust.StudentNum,
  2002. // UserID = adjust.UserID,
  2003. // UserName = adjust.UserName,
  2004. // Reason = "教师该时段已被其他人申请调课占用。"
  2005. // }
  2006. // );
  2007. // var studentConflictSql = (from adjust in adjustSql
  2008. // from schedulingClass in EducationSchedulingClassRepository.Entities.Where(x => x.EducationSchedulingClassID == adjust.EducationSchedulingClassID)
  2009. // from student in schedulingClass.CF_Student
  2010. // from scheduleSet in ClassmajorScheduleSettingRepository.Entities.Where(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE
  2011. // && x.IsOnWork == false && x.ClassmajorID == student.ClassmajorID && x.Weekday == adjust.Weekday
  2012. // && x.CoursesTimeID == x.CoursesTimeID)
  2013. // select new EducationSchedulingConflictView
  2014. // {
  2015. // EducationSchedulingWeekNumID = adjust.EducationSchedulingWeekNumID,
  2016. // EducationSchedulingAdjustmentID = adjust.EducationSchedulingAdjustmentID,
  2017. // SchoolyearID = adjust.SchoolyearID,
  2018. // SchoolyearCode = adjust.SchoolyearCode,
  2019. // EducationSchedulingClassID = adjust.EducationSchedulingClassID,
  2020. // EducationMissionClassName = adjust.EducationMissionClassName,
  2021. // CoursematerialID = adjust.CoursematerialID,
  2022. // CourseName = adjust.CourseName,
  2023. // WeekNum = adjust.WeekNum,
  2024. // Weekday = adjust.Weekday,
  2025. // CoursesTime = adjust.CoursesTime,
  2026. // StartTimes = adjust.StartTimes,
  2027. // EndTimes = adjust.EndTimes,
  2028. // ClassroomID = adjust.ClassroomID,
  2029. // ClassroomName = adjust.ClassroomName,
  2030. // StudentNum = adjust.StudentNum,
  2031. // UserID = adjust.UserID,
  2032. // UserName = adjust.UserName,
  2033. // Reason = "学生的班级不在可排时段内。"
  2034. // }).Concat(
  2035. // from adjust in adjustSql
  2036. // from schedulingClass in EducationSchedulingClassRepository.Entities.Where(x => x.EducationSchedulingClassID == adjust.EducationSchedulingClassID)
  2037. // from student in schedulingClass.CF_Student
  2038. // from scheduling in EducationSchedulingRepository.Entities.Where(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE
  2039. // && x.Weekday == adjust.Weekday && x.CoursesTimeID == adjust.CoursesTime && x.SchoolyearID == adjust.SchoolyearID)
  2040. // from weekNum in EducationSchedulingWeekNumRepository.Entities.Where(x => x.EducationSchedulingID == scheduling.EducationSchedulingID
  2041. // && adjust.WeekNum == x.WeekNum && x.EducationSchedulingWeekNumID != adjust.EducationSchedulingWeekNumID)
  2042. // from otherClass in EducationSchedulingClassRepository.Entities.Where(x => x.EducationSchedulingClassID == scheduling.EducationSchedulingClassID)
  2043. // from otherStudent in otherClass.CF_Student.AsQueryable().Where(x => x.UserID == student.UserID)
  2044. // group adjust by adjust.EducationSchedulingWeekNumID into g
  2045. // select g.FirstOrDefault() into result
  2046. // select new EducationSchedulingConflictView
  2047. // {
  2048. // EducationSchedulingWeekNumID = result.EducationSchedulingWeekNumID,
  2049. // EducationSchedulingAdjustmentID = result.EducationSchedulingAdjustmentID,
  2050. // SchoolyearID = result.SchoolyearID,
  2051. // SchoolyearCode = result.SchoolyearCode,
  2052. // EducationSchedulingClassID = result.EducationSchedulingClassID,
  2053. // EducationMissionClassName = result.EducationMissionClassName,
  2054. // CoursematerialID = result.CoursematerialID,
  2055. // CourseName = result.CourseName,
  2056. // WeekNum = result.WeekNum,
  2057. // Weekday = result.Weekday,
  2058. // CoursesTime = result.CoursesTime,
  2059. // StartTimes = result.StartTimes,
  2060. // EndTimes = result.EndTimes,
  2061. // ClassroomID = result.ClassroomID,
  2062. // ClassroomName = result.ClassroomName,
  2063. // StudentNum = result.StudentNum,
  2064. // UserID = result.UserID,
  2065. // UserName = result.UserName,
  2066. // Reason = "学生在该时段有课。"
  2067. // }).Concat(
  2068. // from adjust in adjustSql
  2069. // from schedulingClass in EducationSchedulingClassRepository.Entities.Where(x => x.EducationSchedulingClassID == adjust.EducationSchedulingClassID)
  2070. // from student in schedulingClass.CF_Student
  2071. // from other in EducationSchedulingAdjustmentRepository.Entities.Where(x =>
  2072. // adjustmentSubmitedStatusList.Contains(x.RecordStatus) && x.ToUserID == adjust.UserID
  2073. // && x.ToWeekday == adjust.Weekday && x.ToCoursesTimeID == adjust.CoursesTime && x.ToWeekNum == adjust.WeekNum
  2074. // && x.EducationSchedulingAdjustmentID != adjust.EducationSchedulingAdjustmentID)
  2075. // from otherClass in EducationSchedulingClassRepository.Entities.Where(x => x.EducationMissionClassID == other.EducationMissionClassID)
  2076. // from otherStudent in otherClass.CF_Student.AsQueryable().Where(x => x.UserID == student.UserID)
  2077. // group adjust by adjust.EducationSchedulingWeekNumID into g
  2078. // select g.FirstOrDefault() into result
  2079. // select new EducationSchedulingConflictView
  2080. // {
  2081. // EducationSchedulingWeekNumID = result.EducationSchedulingWeekNumID,
  2082. // EducationSchedulingAdjustmentID = result.EducationSchedulingAdjustmentID,
  2083. // SchoolyearID = result.SchoolyearID,
  2084. // SchoolyearCode = result.SchoolyearCode,
  2085. // EducationSchedulingClassID = result.EducationSchedulingClassID,
  2086. // EducationMissionClassName = result.EducationMissionClassName,
  2087. // CoursematerialID = result.CoursematerialID,
  2088. // CourseName = result.CourseName,
  2089. // WeekNum = result.WeekNum,
  2090. // Weekday = result.Weekday,
  2091. // CoursesTime = result.CoursesTime,
  2092. // StartTimes = result.StartTimes,
  2093. // EndTimes = result.EndTimes,
  2094. // ClassroomID = result.ClassroomID,
  2095. // ClassroomName = result.ClassroomName,
  2096. // StudentNum = result.StudentNum,
  2097. // UserID = result.UserID,
  2098. // UserName = result.UserName,
  2099. // Reason = "学生该时段已被其他人申请调课占用。"
  2100. // }
  2101. // );
  2102. // return selfClassroomConflictSql.Concat(selfTeacherConflictSql).Concat(classroomConflictSql).Concat(courseConflictSql).Concat(teacherConflictSql).Concat(studentConflictSql);
  2103. //}
  2104. public IQueryable<EducationSchedulingConflictView> GetArrangementsQueryable(IQueryable<EducationSchedulingConflictView> adjustSql)
  2105. {
  2106. var query = from adjust in adjustSql
  2107. from a in ArrangementsRepository.Entities.Where(x => x.CoursesTimeID == adjust.CoursesTime && x.Weekday == adjust.Weekday && !x.IsOnWork.Value)
  2108. select new EducationSchedulingConflictView
  2109. {
  2110. EducationSchedulingWeekNumID = adjust.EducationSchedulingWeekNumID,
  2111. EducationSchedulingAdjustmentID = adjust.EducationSchedulingAdjustmentID,
  2112. SchoolyearID = adjust.SchoolyearID,
  2113. SchoolyearCode = adjust.SchoolyearCode,
  2114. EducationSchedulingClassID = adjust.EducationSchedulingClassID,
  2115. EducationMissionClassName = adjust.EducationMissionClassName,
  2116. CoursematerialID = adjust.CoursematerialID,
  2117. CourseName = adjust.CourseName,
  2118. WeekNum = adjust.WeekNum,
  2119. Weekday = adjust.Weekday,
  2120. CoursesTime = adjust.CoursesTime,
  2121. StartTimes = adjust.StartTimes,
  2122. EndTimes = adjust.EndTimes,
  2123. ClassroomID = adjust.ClassroomID,
  2124. ClassroomName = adjust.ClassroomName,
  2125. StudentNum = adjust.StudentNum,
  2126. UserID = adjust.UserID,
  2127. UserName = adjust.UserName,
  2128. Reason = "周工作时间节次为不可用。"
  2129. };
  2130. return query;
  2131. }
  2132. }
  2133. }