FreeSelectionCoursePlanDAL.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.Repositories;
  6. using EMIS.ViewModel.SelectCourse;
  7. using System.Linq.Expressions;
  8. using EMIS.Entities;
  9. using EMIS.ViewModel;
  10. using EMIS.ViewModel.EnrollManage.SpecialtyManage;
  11. namespace EMIS.DataLogic.SelectCourse
  12. {
  13. public class FreeSelectionCoursePlanDAL
  14. {
  15. public FreeSelectionCouseApplyRepository FreeSelectionCouseApplyRepository { get; set; }
  16. public FreeSelectionCouseApplySchedulingRepository FreeSelectionCouseApplySchedulingRepository { get; set; }
  17. public FreeSelectionCouseApplyTeachingSettingRepository FreeSelectionCouseApplyTeachingSettingRepository { get; set; }
  18. public ExecutableFreeSelectionCouseRepository FreeSelectionCousePlanRepository { get; set; }
  19. public SpecialtyRepository SpecialtyRepository { get; set; }
  20. public Lazy<FreeSelectionCourseDAL> FreeSelectionCourseDAL { get; set; }
  21. public DepartmentRepository DepartmentRepository { get; set; }
  22. public DictionaryItemRepository DictionaryItemRepository { get; set; }
  23. public CoursesTimeRepository coursesTimeRepository { get; set; }
  24. public ClassroomRepository ClassroomRepository { get; set; }
  25. /// <summary>
  26. /// 查询所有计划申请表记录
  27. /// </summary>
  28. /// <param name="exp"></param>
  29. /// <returns></returns>
  30. public IQueryable<FreeSelectionCourseApplyView> GetFreeSelectionCourseApplyViewQueryable(Expression<Func<EM_FreeSelectionCouseApply, bool>> exp)
  31. {
  32. var query = from a in FreeSelectionCouseApplyRepository.GetList(exp)
  33. join b in FreeSelectionCouseApplyTeachingSettingRepository.Entities on a.FreeSelectionCouseApplyID equals b.FreeSelectionCouseApplyID
  34. join c in FreeSelectionCourseDAL.Value.GetFreeSelectionCourseViewQueryable(x => true) on a.FreeSelectionCouseID equals c.FreeSelectionCouseID
  35. //join e in DictionaryItemRepository.Entities on new { a.ApprovalStatus, DictionaryCode = DictionaryItem.EM_FreeSelectionCouseApplyStatu1s.ToString() } equals new { ApprovalStatus = e.Value, e.DictionaryCode }
  36. //into gas
  37. //from gApprovalStatus in gas.DefaultIfEmpty()
  38. join d in DepartmentRepository.Entities on a.DepartmentID equals d.DepartmentID into dd
  39. from ed in dd.DefaultIfEmpty()
  40. //join se in
  41. // (from a in FreeSelectionCouseApplySchedulingRepository.Entities
  42. // group a by new { a.FreeSelectionCouseApplyID, a.ClassroomID } into g
  43. // select new { FreeSelectionCouseApplyID = g.Key.FreeSelectionCouseApplyID, ClassroomID = g.Key.ClassroomID }
  44. // ) on a.FreeSelectionCouseApplyID equals se.FreeSelectionCouseApplyID
  45. //join se in FreeSelectionCouseApplySchedulingRepository.Entities on a.FreeSelectionCouseApplyID equals se.FreeSelectionCouseApplyID
  46. //join di in DictionaryItemRepository.GetList(x => x.DictionaryCode == "ES_WeekDay")
  47. //on se.Weekday equals di.Value into gs
  48. //from di in gs.DefaultIfEmpty()
  49. join Scheduling in
  50. (from sc in FreeSelectionCouseApplySchedulingRepository.Entities
  51. //join b in coursesTimeRepository.Entities on sc.CoursesTimeID equals b.CoursesTimeID
  52. //join c in DictionaryItemRepository.Entities on new { b.TimesSegment, DictionaryCode = "CF_TimesSegment" }
  53. //equals new { TimesSegment = c.Value.Value, c.DictionaryCode } into gbsta
  54. //from gicbsta in gbsta.DefaultIfEmpty()
  55. join d in ClassroomRepository.Entities on sc.ClassroomID equals d.ClassroomID
  56. group d by new { sc.FreeSelectionCouseApplyID } into g
  57. select new
  58. {
  59. ExecutableFreeSelectionCouseID = g.Key.FreeSelectionCouseApplyID,
  60. ClassroomName = g.Select(x => x.Name).FirstOrDefault(),
  61. }) on a.FreeSelectionCouseApplyID equals Scheduling.ExecutableFreeSelectionCouseID
  62. into lj
  63. from Scheduling in lj.DefaultIfEmpty()
  64. select new FreeSelectionCourseApplyView
  65. {
  66. FreeSelectionCouseApplyID = a.FreeSelectionCouseApplyID,
  67. FreeSelectionCouseID = a.FreeSelectionCouseID,
  68. //FreeSelectionCouseNo = a.EM_FreeSelectionCouse.No,
  69. DefaultClassName = a.DefaultClassName,
  70. SchoolyearID = a.SchoolyearID,
  71. SchoolyearCode = a.CF_Schoolyear.Code,
  72. CourseCode = c.CourseCode,
  73. CourseName = c.CourseName,
  74. CourseStructureID = a.CourseStructureID,
  75. //CourseStructureName = c.CourseStructureName,
  76. CourseCategoryID = a.CourseCategoryID,
  77. //CourseCategoryName = c.CourseCategoryName,
  78. CourseTypeID = a.CourseTypeID,
  79. //CourseTypeName = c.CourseTypeName,
  80. CourseQualityID = a.CourseQualityID,
  81. //CourseQualityName = c.CourseQualityName,
  82. DepartmentID = a.DepartmentID,
  83. DepartmentName = ed.Name,
  84. CollegeID = ed.CollegeID,
  85. CollegeName = ed.CF_College.Name,
  86. ExaminationModeID = a.ExaminationModeID,
  87. //ExaminationModeName = a.ExaminationModeName,
  88. TeachinglanguageID = a.TeachinglanguageID,
  89. //TeachinglanguageName = a.TeachinglanguageName,
  90. PeopleNumlimit = a.PeopleNumlimit,
  91. PeopleNumlower = a.PeopleNumlower,
  92. IsOpened = a.IsOpened == true,
  93. HandleModeID = a.HandleModeID,
  94. SchoolyearNumID = c.SchoolyearNumID,
  95. SchoolyearNumName = c.SchoolyearNumName,
  96. SchoolcodeID = c.SchoolcodeID,
  97. SchoolcodeName = c.SchoolcodeName,
  98. //StarttermID = c.StarttermID,
  99. //StarttermName = c.StarttermName,
  100. IsEnable = c.IsEnable,
  101. Credit = c.Credit,
  102. TheoryCourse = b.TheoryCourse,
  103. Practicehours = b.Practicehours,
  104. Trialhours = b.Trialhours,
  105. WeeklyHours = b.WeeklyHours,
  106. WeeklyNum = b.WeeklyNum,
  107. TheoryWeeklyNum = b.TheoryWeeklyNum,
  108. PracticeWeeklyNum = b.PracticeWeeklyNum,
  109. TrialWeeklyNum = b.TrialWeeklyNum,
  110. StartWeeklyNum = b.StartWeeklyNum,
  111. EndWeeklyNum = b.EndWeeklyNum,
  112. IsNeedMaterial = (bool)a.IsNeedMaterial,
  113. IsNeedMaterialName = a.IsNeedMaterial == true ? "是" : "否",
  114. ApprovalStatus = a.ApprovalStatus,
  115. //CoursesTimeID = se.CoursesTimeID,
  116. //CoursesTimeName = se.EM_CoursesTime.StartHour.ToString() + ":" + se.EM_CoursesTime.StartMinutes.ToString() + "-" + se.EM_CoursesTime.EndHour.ToString() + ":" + se.EM_CoursesTime.EndMinutes.ToString(),
  117. //ClassroomID = se.ClassroomID,
  118. ClassroomID = a.EM_FreeSelectionCouseApplyScheduling.FirstOrDefault() != null ? a.EM_FreeSelectionCouseApplyScheduling.FirstOrDefault().ClassroomID : null,
  119. ClassroomName = Scheduling.ClassroomName,
  120. //ClassroomName = se.CF_Classroom.Name,
  121. //Weekday = se.Weekday,
  122. //WeekdayName = di.Name,
  123. CreateUserID = a.CreateUserID,
  124. CreateTime = a.CreateTime,
  125. ResultTypeID=a.ResultTypeID,
  126. Remarks = a.Remarks
  127. };
  128. return query;
  129. }
  130. public IQueryable<FreeSelectionCourseApplyTeacherListView> GetFreeSelectionCourseApplyTeacherViewQueryable(Expression<Func<EM_FreeSelectionCouseApply, bool>> exp)
  131. {
  132. var q = (from fsca in FreeSelectionCouseApplyRepository.GetList(exp)
  133. from fscas in fsca.EM_FreeSelectionCouseApplyTeacher
  134. select new FreeSelectionCourseApplyTeacherListView
  135. {
  136. FreeSelectionCourseApplyID = fsca.FreeSelectionCouseApplyID,
  137. UserID = fscas.CF_Staff.UserID,
  138. LoginID = fscas.CF_Staff.Sys_User.LoginID,
  139. Name = fscas.CF_Staff.Sys_User.Name,
  140. CollegeID = fscas.CF_Staff.CollegeID,
  141. CollegeName = fscas.CF_Staff.CF_College.Name,
  142. BirthDate = fscas.CF_Staff.BirthDate,
  143. TeacherType = fscas.CF_Staff.TeacherTypeID,
  144. IncumbencyState = fscas.CF_Staff.IncumbencyState,
  145. Title = fscas.CF_Staff.TitleID,
  146. TeachingMethod = fscas.TeachingMethod
  147. });
  148. return q;
  149. }
  150. public IQueryable<SpecialtyView> GetFreeSelectionCourseApplySpecialtyViewQueryable(Expression<Func<EM_FreeSelectionCouseApply, bool>> exp)
  151. {
  152. var q = (from fsca in FreeSelectionCouseApplyRepository.GetList(exp)
  153. from fssp in fsca.EM_FreeSelectionCouseApplySpecialty
  154. join spec in SpecialtyRepository.Entities
  155. on fssp.SpecialtyID equals spec.SpecialtyID
  156. join b in DictionaryItemRepository.GetList(x => x.DictionaryCode == DictionaryItem.CF_Standard.ToString())
  157. on spec.StandardID equals b.Value
  158. into gs
  159. from gstandard in gs.DefaultIfEmpty()
  160. select new SpecialtyView
  161. {
  162. //FreeSelectionCourseApplyID = fsca.FreeSelectionCouseApplyID,
  163. SpecialtyID = spec.SpecialtyID,
  164. StandardID = fssp.CF_Specialty.StandardID,
  165. StandardCode = gstandard.Code,
  166. StandardName = gstandard.Name,
  167. LearnSystem = spec.LearnSystem,
  168. ScienceclassID = spec.ScienceclassID,
  169. LearningformID = spec.LearningformID,
  170. EducationID = spec.EducationID,
  171. PropertyID = spec.PropertyID,
  172. StandardTitle = spec.StandardTitle,
  173. StandardLevel = spec.StandardLevel,
  174. Remark = spec.Remark,
  175. });
  176. return q;
  177. }
  178. /// <summary>
  179. /// 查询任选设定的具体上课时间,选课结果页面查询
  180. /// </summary>
  181. /// <param name="efsExp"></param>
  182. /// <returns></returns>
  183. public IQueryable<ExecutableFreeSelectionCouseSchedulingView> GetScheduling(Expression<Func<EM_FreeSelectionCouseApply, bool>> efsExp)
  184. {
  185. var query = from a in FreeSelectionCouseApplyRepository.GetList(efsExp)
  186. join b in FreeSelectionCouseApplySchedulingRepository.Entities on a.FreeSelectionCouseApplyID equals b.FreeSelectionCouseApplyID
  187. //join c in ExecutableFreeSelectionCouseTeachingSettingRepository.Entities on a.ExecutableFreeSelectionCouseID equals c.ExecutableFreeSelectionCouseID
  188. join c in coursesTimeRepository.Entities on b.CoursesTimeID equals c.CoursesTimeID
  189. join d in DictionaryItemRepository.Entities on new { c.TimesSegment, DictionaryCode = "CF_TimesSegment" }
  190. equals new { TimesSegment = d.Value.Value, d.DictionaryCode } into gbsta
  191. from d in gbsta.DefaultIfEmpty()
  192. //join e in DictionaryItemRepository.Entities on new { b.Weekday, DictionaryCode = "ES_WeekDay" }
  193. //equals new { Weekday = e.Value, e.DictionaryCode } into gbsta1
  194. //from e in gbsta1.DefaultIfEmpty()
  195. select new ExecutableFreeSelectionCouseSchedulingView
  196. {
  197. SchoolyearID = a.SchoolyearID,
  198. DefaultClassName = a.DefaultClassName,
  199. SchedulingID = b.FreeSelectionCouseApplySchedulingID,
  200. ID = a.FreeSelectionCouseApplyID,
  201. CourseCollegeID = a.CF_Department.CollegeID,
  202. ClassroomID = b.ClassroomID,
  203. ClassroomName = b.CF_Classroom.Name,
  204. CoursesTimeID = b.CoursesTimeID,
  205. Weekday = b.Weekday,
  206. TimesSegmentName = d.Name,
  207. StartTimes = c.StartTimes,
  208. EndTimes = c.EndTimes
  209. //StartWeeklyNum = c.StartWeeklyNum,
  210. //EndWeeklyNum = c.EndWeeklyNum
  211. };
  212. return query;
  213. }
  214. /// <summary>
  215. /// 查询所有计划确认表记录
  216. /// </summary>
  217. /// <param name="exp"></param>
  218. /// <returns></returns>
  219. public IQueryable<FreeSelectionCourseApplyView> GetFreeSelectionCoursePlanViewQueryable(Expression<Func<EM_ExecutableFreeSelectionCouse, bool>> exp)
  220. {
  221. var query = from a in FreeSelectionCousePlanRepository.GetList(exp)
  222. join c in FreeSelectionCourseDAL.Value.GetFreeSelectionCourseViewQueryable(x => true) on a.FreeSelectionCouseID equals c.FreeSelectionCouseID
  223. join d in DepartmentRepository.Entities on c.DepartmentID equals d.DepartmentID into dd
  224. from ed in dd.DefaultIfEmpty()
  225. select new FreeSelectionCourseApplyView
  226. {
  227. FreeSelectionCouseApplyID = a.ExecutableFreeSelectionCouseID,
  228. FreeSelectionCouseID = a.FreeSelectionCouseID,
  229. //FreeSelectionCouseNo = a.EM_FreeSelectionCouse.No,
  230. DefaultClassName = a.DefaultClassName,
  231. SchoolyearID = a.SchoolyearID,
  232. SchoolyearCode = a.CF_Schoolyear.Code,
  233. CourseCode = c.CourseCode,
  234. CourseName = c.CourseName,
  235. CourseStructureID = a.CourseStructureID,
  236. //CourseStructureName = a.CourseStructureName,
  237. CourseCategoryID = a.CourseCategoryID,
  238. //CourseCategoryName = a.CourseCategoryName,
  239. CourseTypeID = a.CourseTypeID,
  240. //CourseTypeName = c.CourseTypeName,
  241. CourseQualityID = a.CourseQualityID,
  242. //CourseQualityName = a.CourseQualityName,
  243. DepartmentID = a.DepartmentID,
  244. //DepartmentName = a.DepartmentName,
  245. CollegeID = ed.CollegeID,
  246. CollegeName = ed.CF_College.Name,
  247. ExaminationModeID = c.ExaminationModeID,
  248. //ExaminationModeName = c.ExaminationModeName,
  249. TeachinglanguageID = c.TeachinglanguageID,
  250. //TeachinglanguageName = c.TeachinglanguageName,
  251. SchoolyearNumID = c.SchoolyearNumID,
  252. SchoolyearNumName = c.SchoolyearNumName,
  253. SchoolcodeID = c.SchoolcodeID,
  254. SchoolcodeName = c.SchoolcodeName,
  255. StarttermID = c.StarttermID,
  256. StarttermName = c.StarttermName,
  257. IsEnable = c.IsEnable,
  258. Credit = c.Credit,
  259. TheoryCourse = c.TheoryCourse,
  260. Practicehours = c.Practicehours,
  261. Trialhours = c.Trialhours,
  262. WeeklyNum = c.WeeklyNum,
  263. TheoryWeeklyNum = c.TheoryWeeklyNum,
  264. PracticeWeeklyNum = c.PracticeWeeklyNum,
  265. TrialWeeklyNum = c.TrialWeeklyNum,
  266. StartWeeklyNum = c.StartWeeklyNum,
  267. EndWeeklyNum = c.EndWeeklyNum,
  268. IsNeedMaterial = (bool)a.IsNeedMaterial,
  269. IsNeedMaterialName = a.IsNeedMaterial == true ? "是" : "否",
  270. CreateUserID = a.CreateUserID,
  271. CreateTime = a.CreateTime,
  272. Remarks = a.Remarks
  273. };
  274. return query;
  275. }
  276. public IQueryable<FreeSelectionCoursePlanTeacherListView> GetFreeSelectionCoursePlanTeacherViewQueryable(Expression<Func<EM_ExecutableFreeSelectionCouse, bool>> exp)
  277. {
  278. var q = (from fscp in FreeSelectionCousePlanRepository.GetList(exp)
  279. from fscps in fscp.EM_ExecutableFreeSelectionCouseTeacher
  280. select new FreeSelectionCoursePlanTeacherListView
  281. {
  282. FreeSelectionCoursePlanID = fscp.ExecutableFreeSelectionCouseID,
  283. UserID = fscps.CF_Staff.UserID,
  284. LoginID = fscps.CF_Staff.Sys_User.LoginID,
  285. Name = fscps.CF_Staff.Sys_User.Name,
  286. CollegeID = fscps.CF_Staff.CollegeID,
  287. CollegeName = fscps.CF_Staff.CF_College.Name,
  288. BirthDate = fscps.CF_Staff.BirthDate,
  289. TeacherType = fscps.CF_Staff.TeacherTypeID,
  290. IncumbencyState = fscps.CF_Staff.IncumbencyState,
  291. Title = fscps.CF_Staff.TitleID,
  292. TeachingMethod = fscps.TeachingMethod
  293. });
  294. return q;
  295. }
  296. public IQueryable<Sys_DictionaryItem> GetTeachingModeType(Expression<Func<EM_FreeSelectionCouseApply, bool>> exp)
  297. {
  298. var query = from fsc in FreeSelectionCouseApplyRepository.GetList(exp)
  299. from fsctm in fsc.EM_FreeSelectionCouseApplyTeachingMode
  300. join ditm in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_TeachingMode).Name)
  301. on fsctm.TeachingModeID equals ditm.Value
  302. into dditm
  303. from editm in dditm.DefaultIfEmpty()
  304. select editm;
  305. return query;
  306. }
  307. public IQueryable<Sys_DictionaryItem> GetGradeYear(Expression<Func<EM_FreeSelectionCouseApply, bool>> exp)
  308. {
  309. var query = from fsc in FreeSelectionCouseApplyRepository.GetList(exp)
  310. from fscagy in fsc.EM_FreeSelectionCouseApplyGradeYear
  311. join ditm in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_TeachingMode).Name)
  312. on fscagy.GradeYear equals ditm.Value
  313. into dditm
  314. from editm in dditm.DefaultIfEmpty()
  315. select editm;
  316. return query;
  317. }
  318. public IQueryable<ExecutableFreeSelectionCouseSchedulingView> GetSchedulingView(Expression<Func<EM_FreeSelectionCouseApplyScheduling, bool>> exp)
  319. {
  320. //var query = (from em in educationMissionRepository.GetList(exp)
  321. // from emc in em.EM_EducationMissionClass
  322. // from cp in emc.EM_CourseProcess
  323. var query = (from a in FreeSelectionCouseApplySchedulingRepository.GetList(exp)
  324. join b in coursesTimeRepository.Entities on a.CoursesTimeID equals b.CoursesTimeID
  325. join c in DictionaryItemRepository.Entities on new { b.TimesSegment, DictionaryCode = "CF_TimesSegment" }
  326. equals new { TimesSegment = c.Value.Value, c.DictionaryCode } into gbsta
  327. from gicbsta in gbsta.DefaultIfEmpty()
  328. select new ExecutableFreeSelectionCouseSchedulingView
  329. {
  330. SchedulingID = a.FreeSelectionCouseApplySchedulingID,
  331. ID = a.FreeSelectionCouseApplyID,
  332. CourseCollegeID = a.EM_FreeSelectionCouseApply.CF_Department.CollegeID,
  333. ClassroomID = a.ClassroomID,
  334. ClassroomName = a.CF_Classroom.Name,
  335. CoursesTimeID = a.CoursesTimeID,
  336. StartTimes = b.StartTimes,
  337. EndTimes = b.EndTimes,
  338. TimesSegment = b.TimesSegment,
  339. TimesSegmentName = gicbsta.Name,
  340. Weekday = a.Weekday,
  341. RecordStatus = a.RecordStatus,
  342. CreateTime = a.CreateTime,
  343. CreateUserID = a.CreateUserID,
  344. ModifyTime = a.ModifyTime,
  345. ModifyUserID = a.ModifyUserID
  346. });
  347. return query;
  348. }
  349. }
  350. }