RetakePlanStudentApplyDAL.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372
  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;
  7. using EMIS.ViewModel.RetakeManage;
  8. using EMIS.Entities;
  9. using System.Linq.Expressions;
  10. namespace EMIS.DataLogic.RetakeManage
  11. {
  12. public class RetakePlanStudentApplyDAL
  13. {
  14. public RetakeOpenControlRepository RetakeOpenControlRepository { get; set; }
  15. public RetakeConditionRepository RetakConditionRepository { get; set; }
  16. public RetakeConditionParameterRepository RetakeConditionParameterRepository { get; set; }
  17. public RetakePlanRepository RetakePlanRepository { get; set; }
  18. public RetakePlanStudentRepository RetakePlanStudentRepository { get; set; }
  19. public RetakeExamsCatagoryRepository RetakeExamsCatagoryRepository { get; set; }
  20. public RetakePlanSettingRepository RetakePlanSettingRepository { get; set; }
  21. public RetakePlanTeachingModeTypeRepository RetakePlanTeachingModeTypeRepository { get; set; }
  22. public RetakePlanTeachingPlaceRepository RetakePlanTeachingPlaceRepository { get; set; }
  23. public RetakePlanTeachingSettingRepository RetakePlanTeachingSettingRepository { get; set; }
  24. public RetakePlanSettingSchedulingRepository RetakePlanSettingSchedulingRepository { get; set; }
  25. public StudentRepository StudentRepository { get; set; }
  26. public UserRepository UserRepository { get; set; }
  27. public InSchoolSettingRepository InSchoolSettingRepository { get; set; }
  28. public ParameterRepository ParameterRepository { get; set; }
  29. public CoursematerialRepository CoursematerialRepository { get; set; }
  30. public FinallyScoreRepository FinallyScoreRepository { get; set; }
  31. public ClassmajorRepository ClassmajorRepository { get; set; }
  32. public GrademajorRepository GrademajorRepository { get; set; }
  33. public FacultymajorRepository FacultymajorRepository { get; set; }
  34. public CollegeRepository CollegeRepository { get; set; }
  35. public DepartmentRepository DepartmentRepository { get; set; }
  36. public SchoolyearRepository SchoolyearRepository { get; set; }
  37. public DictionaryItemRepository DictionaryItemRepository { get; set; }
  38. public CoursesTimeRepository coursesTimeRepository { get; set; }
  39. public ClassroomRepository ClassroomRepository { get; set; }
  40. public ExecutableFreeSelectionCouseRepository ExecutableFreeSelectionCouseRepository { get; set; }//任选设定
  41. public ExecutableFreeSelectionCouseTeachingSettingRepository ExecutableFreeSelectionCouseTeachingSettingRepository { get; set; } //任选设定教学设置表
  42. public ExecutableFreeSelectionCouseSchedulingRepository ExecutableFreeSelectionCouseSchedulingRepository { get; set; }
  43. public EducationMissionClassRepository EducationMissionClassRepository { get; set; }
  44. public EducationSchedulingRepository EducationSchedulingRepository { get; set; }
  45. public EducationSchedulingClassRepository EducationSchedulingClassRepository { get; set; }
  46. public EducationSchedulingWeekNumRepository EducationSchedulingWeekNumRepository { get; set; }
  47. /// <summary>
  48. /// 查询进入报名信息View(学生平台,需要关联重修控制表-内联、排除已报名结束的信息)
  49. /// </summary>
  50. /// <param name="expRetakePlan"></param>
  51. /// <param name="expRetakePlanStudent"></param>
  52. /// <returns></returns>
  53. public IQueryable<RetakePlanStudentApplyView> GetRetakePlanStudentApplyView(Expression<Func<ER_RetakePlan, bool>> expRetakePlan,
  54. Expression<Func<ER_RetakePlanStudent, bool>> expRetakePlanStudent)
  55. {
  56. var query = from rePlanStu in RetakePlanStudentRepository.GetList(expRetakePlanStudent)
  57. join rePlan in RetakePlanRepository.GetList(expRetakePlan)
  58. on rePlanStu.RetakePlanID equals rePlan.RetakePlanID
  59. join stu in StudentRepository.Entities
  60. on rePlanStu.UserID equals stu.UserID
  61. join us in UserRepository.Entities
  62. on stu.UserID equals us.UserID
  63. join cl in ClassmajorRepository.Entities
  64. on stu.ClassmajorID equals cl.ClassmajorID
  65. join gr in GrademajorRepository.Entities
  66. on cl.GrademajorID equals gr.GrademajorID
  67. join fa in FacultymajorRepository.Entities
  68. on gr.FacultymajorID equals fa.FacultymajorID
  69. join col in CollegeRepository.Entities
  70. on fa.CollegeID equals col.CollegeID
  71. join sy in SchoolyearRepository.Entities
  72. on rePlan.SchoolyearID equals sy.SchoolyearID
  73. join cou in CoursematerialRepository.Entities
  74. on rePlan.CoursematerialID equals cou.CoursematerialID
  75. join reSet in RetakePlanSettingRepository.Entities
  76. on rePlan.RetakePlanID equals reSet.RetakePlanID
  77. into reSetTemp
  78. from rePlanSet in reSetTemp.DefaultIfEmpty()
  79. join dep in DepartmentRepository.Entities
  80. on rePlanSet.DepartmentID equals dep.DepartmentID
  81. into reDepTemp
  82. from reDep in reDepTemp.DefaultIfEmpty()
  83. join reTeaching in RetakePlanTeachingSettingRepository.Entities
  84. on rePlan.RetakePlanID equals reTeaching.RetakePlanID
  85. into reTeachingTemp
  86. from rePlanTeaching in reTeachingTemp.DefaultIfEmpty()
  87. join reOpenControl in RetakeOpenControlRepository.Entities
  88. on rePlan.SchoolyearID equals reOpenControl.SchoolyearID
  89. where reOpenControl.EndDate >= DateTime.Now
  90. select new RetakePlanStudentApplyView
  91. {
  92. RetakePlanID = rePlan.RetakePlanID,
  93. RetakePlanStudentID = rePlanStu.RetakePlanStudentID,
  94. RetakeTypeID = rePlan.RetakeTypeID,
  95. SchoolyearID = rePlan.SchoolyearID,
  96. SchoolyearCode = sy.Code,
  97. ClassName = rePlan.ClassName,
  98. CoursematerialID = rePlan.CoursematerialID,
  99. CourseCode = cou.CourseCode,
  100. CourseName = cou.CourseName,
  101. DepartmentID = rePlanSet.DepartmentID,
  102. DepartmentCode = reDep.No,
  103. DepartmentName = reDep.Name,
  104. CourseCollegeID = reDep.CollegeID,
  105. CourseCollegeNo = reDep.CF_College.No,
  106. CourseCollegeName = reDep.CF_College.Name,
  107. CourseTypeID = rePlan.CourseTypeID,
  108. Credit = rePlan.Credit ?? 0,
  109. PeopleNumlimit = rePlan.PeopleNumlimit ?? 0,
  110. PeopleNumlower = rePlan.PeopleNumlower ?? 0,
  111. TheoryCourse = rePlanTeaching.TheoryCourse ?? 0,
  112. Practicehours = rePlanTeaching.Practicehours ?? 0,
  113. Trialhours = rePlanTeaching.Trialhours ?? 0,
  114. StartWeeklyNum = rePlanTeaching.StartWeeklyNum,
  115. EndWeeklyNum = rePlanTeaching.EndWeeklyNum,
  116. SchoolyearNumID = rePlanStu.SchoolyearNumID,
  117. StarttermID = rePlanStu.StarttermID,
  118. UserID = rePlanStu.UserID,
  119. LoginID = us.LoginID,
  120. UserName = us.Name,
  121. SexID = stu.SexID,
  122. InSchoolStatusID = stu.InSchoolStatusID,
  123. StudentStatusID = stu.StudentStatus,
  124. ClassmajorID = stu.ClassmajorID,
  125. ClassmajorCode = cl.No,
  126. ClassmajorName = cl.Name,
  127. GrademajorID = cl.GrademajorID,
  128. GrademajorCode = gr.Code,
  129. GrademajorName = gr.Name,
  130. CollegeID = fa.CollegeID,
  131. CollegeNo = col.No,
  132. CollegeName = col.Name,
  133. Gradeyear = gr.GradeID,
  134. StandardID = fa.StandardID,
  135. EducationID = fa.EducationID,
  136. LearningformID = fa.LearningformID,
  137. LearnSystem = fa.LearnSystem,
  138. RecordStatus = rePlan.RecordStatus,
  139. ApplyNumber = rePlan.CF_Student.Count,
  140. RetakeOpenControlID = reOpenControl.RetakeOpenControlID,
  141. StartDate = reOpenControl.StartDate,
  142. EndDate = reOpenControl.EndDate,
  143. CanSelect = true,
  144. ApplyStatus = rePlan.CF_Student.Any(x => x.UserID == rePlanStu.UserID) ? true : false
  145. };
  146. return query;
  147. }
  148. /// <summary>
  149. /// 查询重修课程信息View(学生平台,暂不排除未开放状态的重修计划)
  150. /// </summary>
  151. /// <param name="expRetakePlan"></param>
  152. /// <param name="expRetakePlanStudent"></param>
  153. /// <returns></returns>
  154. public IQueryable<RetakePlanStudentApplyView> GetStudentRetakeCourseView(Expression<Func<ER_RetakePlan, bool>> expRetakePlan,
  155. Expression<Func<ER_RetakePlanStudent, bool>> expRetakePlanStudent)
  156. {
  157. var query = from rePlan in RetakePlanRepository.GetList(expRetakePlan)
  158. from applyStu in rePlan.CF_Student
  159. join rePlanStu in RetakePlanStudentRepository.GetList(expRetakePlanStudent)
  160. on
  161. new { applyStu.UserID, rePlan.RetakePlanID }
  162. equals
  163. new { rePlanStu.UserID, rePlanStu.RetakePlanID }
  164. join stu in StudentRepository.Entities
  165. on rePlanStu.UserID equals stu.UserID
  166. join us in UserRepository.Entities
  167. on stu.UserID equals us.UserID
  168. join cl in ClassmajorRepository.Entities
  169. on stu.ClassmajorID equals cl.ClassmajorID
  170. join gr in GrademajorRepository.Entities
  171. on cl.GrademajorID equals gr.GrademajorID
  172. join fa in FacultymajorRepository.Entities
  173. on gr.FacultymajorID equals fa.FacultymajorID
  174. join col in CollegeRepository.Entities
  175. on fa.CollegeID equals col.CollegeID
  176. join sy in SchoolyearRepository.Entities
  177. on rePlan.SchoolyearID equals sy.SchoolyearID
  178. join cou in CoursematerialRepository.Entities
  179. on rePlan.CoursematerialID equals cou.CoursematerialID
  180. join reSet in RetakePlanSettingRepository.Entities
  181. on rePlan.RetakePlanID equals reSet.RetakePlanID
  182. into reSetTemp
  183. from rePlanSet in reSetTemp.DefaultIfEmpty()
  184. join dep in DepartmentRepository.Entities
  185. on rePlanSet.DepartmentID equals dep.DepartmentID
  186. into reDepTemp
  187. from reDep in reDepTemp.DefaultIfEmpty()
  188. join reTeaching in RetakePlanTeachingSettingRepository.Entities
  189. on rePlan.RetakePlanID equals reTeaching.RetakePlanID
  190. into reTeachingTemp
  191. from rePlanTeaching in reTeachingTemp.DefaultIfEmpty()
  192. select new RetakePlanStudentApplyView
  193. {
  194. RetakePlanID = rePlan.RetakePlanID,
  195. RetakePlanStudentID = rePlanStu.RetakePlanStudentID,
  196. RetakeTypeID = rePlan.RetakeTypeID,
  197. SchoolyearID = rePlan.SchoolyearID,
  198. SchoolyearCode = sy.Code,
  199. ClassName = rePlan.ClassName,
  200. CoursematerialID = rePlan.CoursematerialID,
  201. CourseCode = cou.CourseCode,
  202. CourseName = cou.CourseName,
  203. DepartmentID = rePlanSet.DepartmentID,
  204. DepartmentCode = reDep.No,
  205. DepartmentName = reDep.Name,
  206. CourseCollegeID = reDep.CollegeID,
  207. CourseCollegeNo = reDep.CF_College.No,
  208. CourseCollegeName = reDep.CF_College.Name,
  209. CourseTypeID = rePlan.CourseTypeID,
  210. Credit = rePlan.Credit ?? 0,
  211. PeopleNumlimit = rePlan.PeopleNumlimit ?? 0,
  212. PeopleNumlower = rePlan.PeopleNumlower ?? 0,
  213. TheoryCourse = rePlanTeaching.TheoryCourse ?? 0,
  214. Practicehours = rePlanTeaching.Practicehours ?? 0,
  215. Trialhours = rePlanTeaching.Trialhours ?? 0,
  216. StartWeeklyNum = rePlanTeaching.StartWeeklyNum,
  217. EndWeeklyNum = rePlanTeaching.EndWeeklyNum,
  218. SchoolyearNumID = rePlanStu.SchoolyearNumID,
  219. StarttermID = rePlanStu.StarttermID,
  220. UserID = rePlanStu.UserID,
  221. LoginID = us.LoginID,
  222. UserName = us.Name,
  223. SexID = stu.SexID,
  224. InSchoolStatusID = stu.InSchoolStatusID,
  225. StudentStatusID = stu.StudentStatus,
  226. ClassmajorID = stu.ClassmajorID,
  227. ClassmajorCode = cl.No,
  228. ClassmajorName = cl.Name,
  229. GrademajorID = cl.GrademajorID,
  230. GrademajorCode = gr.Code,
  231. GrademajorName = gr.Name,
  232. CollegeID = fa.CollegeID,
  233. CollegeNo = col.No,
  234. CollegeName = col.Name,
  235. Gradeyear = gr.GradeID,
  236. StandardID = fa.StandardID,
  237. EducationID = fa.EducationID,
  238. LearningformID = fa.LearningformID,
  239. LearnSystem = fa.LearnSystem,
  240. RecordStatus = rePlan.RecordStatus,
  241. ApplyNumber = rePlan.CF_Student.Count,
  242. ApplyStatus = true
  243. };
  244. return query;
  245. }
  246. /// <summary>
  247. /// 检测排课冲突(学生上课冲突)
  248. /// </summary>
  249. /// <param name="UserID"></param>
  250. /// <param name="RetakePlanID"></param>
  251. /// <param name="CoursesTimeID"></param>
  252. /// <param name="Weekday"></param>
  253. /// <param name="SchoolyearID"></param>
  254. /// <param name="StartWeeklyNum"></param>
  255. /// <param name="EndWeeklyNum"></param>
  256. /// <returns></returns>
  257. public IQueryable<RetakePlanSettingSchedulingView> GetRepeatTime(Guid? UserID, Guid? RetakePlanID, Guid? CoursesTimeID,
  258. int? Weekday, Guid? SchoolyearID, int? StartWeeklyNum, int? EndWeeklyNum)
  259. {
  260. var RetakePlan = from a in RetakePlanSettingSchedulingRepository.GetList(x =>
  261. x.CoursesTimeID == CoursesTimeID && x.Weekday == Weekday)
  262. join b in RetakePlanRepository.GetList(x =>
  263. x.SchoolyearID == SchoolyearID
  264. // && x.RecordStatus != (int)EMIS.ViewModel.EM_SelectCourseResultStatus.CancleCreate
  265. //&& x.CF_Student.Any(w => w.UserID == UserID))
  266. ) on a.RetakePlanID equals b.RetakePlanID
  267. from st in b.CF_Student.Where(x => x.UserID == UserID)
  268. join c in coursesTimeRepository.Entities
  269. on a.CoursesTimeID equals c.CoursesTimeID
  270. join d in DictionaryItemRepository.Entities
  271. on
  272. new { c.TimesSegment, DictionaryCode = "CF_TimesSegment" }
  273. equals
  274. new { TimesSegment = d.Value.Value, d.DictionaryCode }
  275. into gbsta
  276. from gicbsta in gbsta.DefaultIfEmpty()
  277. join s in RetakePlanTeachingSettingRepository.GetList(x =>
  278. x.StartWeeklyNum == StartWeeklyNum || x.StartWeeklyNum == EndWeeklyNum ||
  279. x.EndWeeklyNum == StartWeeklyNum || x.EndWeeklyNum == EndWeeklyNum ||
  280. (x.StartWeeklyNum > StartWeeklyNum && x.StartWeeklyNum < EndWeeklyNum) ||
  281. (x.EndWeeklyNum > StartWeeklyNum && x.EndWeeklyNum < EndWeeklyNum)
  282. // x.StartWeeklyNum == StartWeeklyNum || x.StartWeeklyNum == EndWeeklyNum ||
  283. // x.EndWeeklyNum == StartWeeklyNum || x.EndWeeklyNum == EndWeeklyNum ||
  284. //(x.StartWeeklyNum > StartWeeklyNum && x.StartWeeklyNum < EndWeeklyNum) ||
  285. //(x.EndWeeklyNum > StartWeeklyNum && x.EndWeeklyNum < EndWeeklyNum)
  286. ) on b.RetakePlanID equals s.RetakePlanID
  287. select new RetakePlanSettingSchedulingView
  288. {
  289. Type = 1,
  290. DefaultClassName = b.ClassName,
  291. SchedulingID = a.RetakePlanSettingSchedulingID,
  292. ID = a.RetakePlanID,
  293. //CourseCollegeID = a.EM_ExecutableFreeSelectionCouse.CF_Department.CollegeID,
  294. ClassroomID = a.ClassroomID,
  295. //ClassroomName = b.ER_RetakePlanSetting.CF_Classroom.Name,
  296. CoursesTimeID = a.CoursesTimeID,
  297. TimesSegment = c.TimesSegment,
  298. TimesSegmentName = gicbsta.Name,
  299. Weekday = a.Weekday,
  300. };
  301. var FreeSelection = from a in ExecutableFreeSelectionCouseSchedulingRepository.GetList(x =>
  302. x.CoursesTimeID == CoursesTimeID && x.Weekday == Weekday)
  303. join b in ExecutableFreeSelectionCouseRepository.GetList(x =>
  304. x.SchoolyearID == SchoolyearID && x.RecordStatus != (int)EMIS.ViewModel.EM_SelectCourseResultStatus.CancleCreate
  305. ) on a.ExecutableFreeSelectionCouseID equals b.ExecutableFreeSelectionCouseID
  306. from st in b.CF_Student.Where(x => x.UserID == UserID)
  307. join c in coursesTimeRepository.Entities on a.CoursesTimeID equals c.CoursesTimeID
  308. join d in DictionaryItemRepository.Entities on new { c.TimesSegment, DictionaryCode = "CF_TimesSegment" }
  309. equals new { TimesSegment = d.Value.Value, d.DictionaryCode } into gbsta
  310. from gicbsta in gbsta.DefaultIfEmpty()
  311. join s in ExecutableFreeSelectionCouseTeachingSettingRepository.GetList(x =>
  312. x.StartWeeklyNum == StartWeeklyNum || x.StartWeeklyNum == EndWeeklyNum ||
  313. x.EndWeeklyNum == StartWeeklyNum || x.EndWeeklyNum == EndWeeklyNum ||
  314. (x.StartWeeklyNum > StartWeeklyNum && x.StartWeeklyNum < EndWeeklyNum) ||
  315. (x.EndWeeklyNum > StartWeeklyNum && x.EndWeeklyNum < EndWeeklyNum)
  316. ) on b.ExecutableFreeSelectionCouseID equals s.ExecutableFreeSelectionCouseID
  317. select new RetakePlanSettingSchedulingView
  318. {
  319. Type = 2,
  320. DefaultClassName = b.DefaultClassName,
  321. SchedulingID = a.ExecutableFreeSelectionCouseSchedulingID,
  322. ID = a.ExecutableFreeSelectionCouseID,
  323. //CourseCollegeID = a.EM_ExecutableFreeSelectionCouse.CF_Department.CollegeID,
  324. ClassroomID = a.ClassroomID,
  325. //ClassroomName = a.CF_Classroom.Name,
  326. CoursesTimeID = a.CoursesTimeID,
  327. TimesSegment = c.TimesSegment,
  328. TimesSegmentName = gicbsta.Name,
  329. Weekday = a.Weekday,
  330. };
  331. var Education = from schedulingClass in EducationSchedulingClassRepository.GetList(x =>
  332. x.CF_Student.Any(w => w.UserID == UserID))
  333. join scheduling in EducationSchedulingRepository.GetList(x =>
  334. x.CoursesTimeID == CoursesTimeID && x.Weekday == Weekday && x.SchoolyearID == SchoolyearID)
  335. on schedulingClass.EducationSchedulingClassID equals scheduling.EducationSchedulingClassID
  336. join schWeekNum in EducationSchedulingWeekNumRepository.GetList(x =>
  337. x.WeekNum >= StartWeeklyNum && x.WeekNum <= EndWeeklyNum)
  338. on scheduling.EducationSchedulingID equals schWeekNum.EducationSchedulingID
  339. join education in EducationMissionClassRepository.Entities
  340. on schedulingClass.EducationMissionClassID equals education.EducationMissionClassID
  341. select new RetakePlanSettingSchedulingView
  342. {
  343. Type = 3,
  344. DefaultClassName = education.Name,
  345. SchedulingID = scheduling.EducationSchedulingID,
  346. ID = education.EducationMissionClassID,
  347. //CourseCollegeID = null,
  348. ClassroomID = null,
  349. //ClassroomName = "",
  350. CoursesTimeID = null,
  351. TimesSegment = null,
  352. TimesSegmentName = "",
  353. Weekday = null,
  354. };
  355. var query = RetakePlan.Concat(FreeSelection).Concat(Education);
  356. return query;
  357. }
  358. }
  359. }