EducationMissionClassDAL.cs 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646
  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.EducationManagement;
  7. using System.Linq.Expressions;
  8. using EMIS.Entities;
  9. using EMIS.DataLogic.CultureplanManage.PlanManagement;
  10. using System.Data.Entity;
  11. using EMIS.ViewModel.EducationManage;
  12. using EMIS.ViewModel;
  13. using EMIS.DataLogic.UniversityManage.AdministrativeOrgan;
  14. using EMIS.ViewModel.UniversityManage.AdministrativeOrgan;
  15. using EMIS.ViewModel.UniversityManage.SpecialtyClassManage;
  16. namespace EMIS.DataLogic.EducationManage
  17. {
  18. public partial class EducationMissionClassDAL
  19. {
  20. public EducationMissionClassRepository EducationMissionClassRepository { get; set; }
  21. public EducationMissionClassTeachingSettingRepository EducationMissionClassTeachingSettingRepository { get; set; }
  22. public ExecutableOptionalCourseRepository ExecutableOptionalCourseRepository { get; set; }
  23. public ExecutableFreeSelectionCouseRepository ExecutableFreeSelectionCouseRepository { get; set; }
  24. public ExecutablePlanRepository ExecutablePlanRepository { get; set; }
  25. public DepartmentRepository DepartmentRepository { get; set; }
  26. public DictionaryItemRepository DictionaryItemRepository { get; set; }
  27. public EducationMissionClassSettingsRepository EducationMissionClassSettingsRepository { get; set; }
  28. public MissionClassTeacherRepository MissionClassTeacherRepository { get; set; }
  29. public EducationSchedulingClassRepository EducationSchedulingClassRepository { get; set; }
  30. public StudentRepository StudentRepository { get; set; }
  31. public UserRepository UserRepository { get; set; }
  32. public ClassmajorRepository ClassmajorRepository { get; set; }
  33. public CourseProcessRepository CourseProcessRepository { get; set; }
  34. public EducationMissionRepository EducationMissionRepository { get; set; }
  35. public EducationSchedulingRepository EducationSchedulingRepository { get; set; }
  36. public ClassroomRepository ClassroomRepository { get; set; }
  37. public InSchoolSettingRepository InSchoolSettingRepository { get; set; }
  38. public CollegeScheduleStatusRepository CollegeScheduleStatusRepository { get; set; }
  39. public CoursesTimeRepository CoursesTimeRepository { get; set; }
  40. public SchoolyearRepository SchoolyearRepository { get; set; }
  41. public GrademajorRepository GrademajorRepository { get; set; }
  42. public FacultymajorRepository FacultymajorRepository { get; set; }
  43. public CollegeRepository CollegeRepository { get; set; }
  44. public CoursematerialRepository CoursematerialRepository { get; set; }
  45. public RetakePlanStudentRepository RetakePlanStudentRepository { get; set; }
  46. public EducationSchedulingTeacherRepository EducationSchedulingTeacherRepository { get; set; }
  47. public EducationSchedulingWeekNumRepository EducationSchedulingWeekNumRepository { get; set; }
  48. public Lazy<CollegeDAL> CollegeDAL { get; set; }
  49. /// <summary>
  50. /// 查询教学任务班数据
  51. /// </summary>
  52. /// <param name="exp"></param>
  53. /// <returns></returns>
  54. public IQueryable<EducationMissionClassView> GetEducationMissionClassViewQueryble(Expression<Func<EM_EducationMissionClass, bool>> missionClassExp)
  55. {
  56. //媚姐说:教学任务的查询不要过滤教学任务中没有在校学生
  57. //var inSchoolStatusIDList = inSchoolSettingRepository.GetList(x => x.IsSelected == true).Select(w => w.InSchoolStatusID).ToList();//获取选中的在校设定状态、
  58. var inSchoolStatusIDList = InSchoolSettingRepository.GetList(x => true).Select(w => w.InSchoolStatusID).ToList();//获取选中的在校设定状态、
  59. var query = from missionClass in EducationMissionClassRepository.GetList(missionClassExp)
  60. from mission in EducationMissionRepository.Entities.Where(x => missionClass.EducationMissionID == x.EducationMissionID)
  61. from department in DepartmentRepository.Entities.Where(x => mission.DepartmentID == x.DepartmentID)
  62. from teachSetting in EducationMissionClassTeachingSettingRepository.Entities.Where(x => missionClass.EducationMissionClassID == x.EducationMissionClassID)
  63. from classmajor in ClassmajorRepository.Entities.Where(x => missionClass.MainScheduleClassID == x.ClassmajorID).DefaultIfEmpty()
  64. from grade in GrademajorRepository.Entities.Where(x => classmajor.GrademajorID == x.GrademajorID).DefaultIfEmpty()
  65. from faculty in FacultymajorRepository.Entities.Where(x => grade.FacultymajorID == x.FacultymajorID).DefaultIfEmpty()
  66. from college in CollegeRepository.Entities.Where(x => department.CollegeID == x.CollegeID)
  67. from schoolyear in SchoolyearRepository.Entities.Where(x => mission.SchoolyearID == x.SchoolyearID)
  68. from course in CoursematerialRepository.Entities.Where(x => missionClass.CoursematerialID == x.CoursematerialID)
  69. from schedulingClass in
  70. (
  71. from sc in EducationSchedulingClassRepository.Entities
  72. group sc by sc.EducationMissionClassID into g
  73. select new
  74. {
  75. EducationMissionClassID = g.Key,
  76. ClassNum = g.Sum(x => x.CF_Student.Where(p => inSchoolStatusIDList.Contains(p.InSchoolStatusID)).Count())
  77. }
  78. ).Where(x => missionClass.EducationMissionClassID == x.EducationMissionClassID).DefaultIfEmpty()
  79. from gccp in
  80. (from cp in CourseProcessRepository.Entities
  81. group cp by cp.EducationMissionClassID into g
  82. select new
  83. {
  84. EducationMissionClassID = g.Key,
  85. CourseProcessTimes = g.Sum(x => x.Times),
  86. WeeklyHours=g.Select(x=>x.Times).FirstOrDefault()
  87. }).Where(x => missionClass.EducationMissionClassID == x.EducationMissionClassID).DefaultIfEmpty()
  88. from emc in ClassmajorRepository.Entities.Where(x => missionClass.MainScheduleClassID == x.ClassmajorID).DefaultIfEmpty()
  89. from ecss in CollegeScheduleStatusRepository.Entities.Where(x => missionClass.EM_EducationMission.CollegeID == x.CollegeID
  90. && missionClass.EM_EducationMission.SchoolyearID == x.SchoolyearID).DefaultIfEmpty()
  91. select new EducationMissionClassView
  92. {
  93. EducationMissionID = missionClass.EducationMissionID,
  94. EducationMissionClassID = missionClass.EducationMissionClassID,
  95. TeachingModeID = missionClass.TeachingModeID ?? 1,
  96. SchoolyearID = missionClass.EM_EducationMission.SchoolyearID,
  97. YearID = missionClass.EM_EducationMission.CF_Schoolyear.Years,
  98. SchoolyearCode = missionClass.EM_EducationMission.CF_Schoolyear.Code,
  99. Name = missionClass.Name,
  100. CoursematerialID = missionClass.CoursematerialID,
  101. CourseCode = course.CourseCode,
  102. CourseNameAb = course.Abbreviation,
  103. CourseName = course.CourseName,
  104. CampusID = college.CampusID,
  105. CollegeID = college.CollegeID,
  106. CollegeNo = college.No,
  107. CollegeName = college.Name,
  108. DepartmentID = department.DepartmentID,
  109. DepartmentCode = department.No,
  110. DepartmentName = department.Name,
  111. GrademajorID = grade.GrademajorID,
  112. GrademajorCode = grade.Code,
  113. GrademajorName = grade.Name,
  114. StandardID = faculty.StandardID,
  115. LearnSystem = faculty.LearnSystem,
  116. EducationID = faculty.EducationID,
  117. LearningformID = faculty.LearningformID,
  118. GradeYearID = grade.GradeID,
  119. ClassroomID = missionClass.ClassroomID,
  120. ClassroomCode = missionClass.CF_Classroom.Code,
  121. ClassroomName = missionClass.CF_Classroom.Name,
  122. ClassroomTypeID = missionClass.ClassroomTypeID,
  123. CourseStructureID = missionClass.CourseStructureID,
  124. CourseCategoryID = missionClass.CourseCategoryID,
  125. CourseTypeID = missionClass.CourseTypeID,
  126. CourseQualityID = missionClass.CourseQualityID,
  127. ExaminationModeID = missionClass.ExaminationModeID,
  128. TeachinglanguageID = missionClass.TeachinglanguageID,
  129. HandleModeID = missionClass.HandleModeID,
  130. IsNeedMaterial = missionClass.IsNeedMaterial ?? false,
  131. OrderNo = missionClass.OrderNo ?? 0,
  132. SchedulingClassNum = missionClass.EM_EducationSchedulingClass.Count,
  133. ClassNum = (schedulingClass.EducationMissionClassID == null ? 0 : schedulingClass.ClassNum),
  134. MainScheduleClassID = missionClass.MainScheduleClassID,
  135. MainScheduleClassGrademajorID = emc.GrademajorID,
  136. MainScheduleClassCollegeID = faculty.CollegeID,
  137. SchedulingClass = missionClass.EM_EducationMission.ClassName,
  138. StartWeeklyNum = teachSetting.StartWeeklyNum,
  139. EndWeeklyNum = teachSetting.EndWeeklyNum,
  140. StartWeeklyNumReserved = missionClass.EM_EducationMissionClassSettings.Min(w => w.WeeklyNum).Value,
  141. EndWeeklyNumReserved = missionClass.EM_EducationMissionClassSettings.Max(w => w.WeeklyNum).Value,
  142. Credit = teachSetting.Credit,
  143. TheoryCourse = teachSetting.TheoryCourse,
  144. Practicehours = teachSetting.Practicehours,
  145. Trialhours = teachSetting.Trialhours,
  146. TheoryWeeklyNum = teachSetting.TheoryWeeklyNum,
  147. PracticeWeeklyNum = teachSetting.PracticeWeeklyNum,
  148. TrialWeeklyNum = teachSetting.TrialWeeklyNum,
  149. WeeklyNum = teachSetting.WeeklyNum,
  150. WeeklyHours = gccp.WeeklyHours == null ? teachSetting.WeeklyHours : gccp.WeeklyHours,
  151. ApprovalStatus = missionClass.RecordStatus,
  152. CourseProcessTimes = gccp.CourseProcessTimes,
  153. CreateTime = missionClass.CreateTime,
  154. CreateUserID = missionClass.CreateUserID,
  155. ResultTypeID=missionClass.ResultTypeID,
  156. Remark = missionClass.Remark,
  157. IsCollegeScheduleSubmitted = (ecss.RecordStatus == (int)ES_CollegeScheduleStatusCode.Submited)
  158. };
  159. return query;
  160. }
  161. /// <summary>
  162. /// 查询任务班
  163. /// </summary>
  164. /// <param name="exp"></param>
  165. /// <returns></returns>
  166. public IQueryable<EM_EducationMissionClass> GetEducationMissionClass(Expression<Func<EM_EducationMissionClass, bool>> exp)
  167. {
  168. var query = (from emc in EducationMissionClassRepository.GetList(exp)
  169. //join remc in educationMissionClassRepository.Entities
  170. // on emc.EducationMissionID equals remc.EducationMissionID
  171. select emc)
  172. .Include(x => x.EM_EducationMissionClassTeachingSetting)
  173. .Include(x => x.EM_EducationMission)
  174. .Include(x => x.EM_MissionClassTeacher)
  175. .Include(x => x.EM_EducationMissionClassSettings)
  176. .Include(x => x.EM_EducationSchedulingClass);
  177. return query;
  178. }
  179. /// <summary>
  180. /// 根据教学任务班查找班级信息
  181. /// </summary>
  182. /// <param name="exp"></param>
  183. /// <returns></returns>
  184. public ClassmajorView GetClassmajorByEducationMissionClassID(Expression<Func<EM_EducationMissionClass, bool>> exp)
  185. {
  186. var query = from emc in EducationMissionClassRepository.GetList(exp)
  187. from cla in emc.CF_Classmajor
  188. select new ClassmajorView
  189. {
  190. ClassmajorID = cla.ClassmajorID,
  191. GrademajorID = cla.GrademajorID,
  192. CollegeID = emc.CF_Classroom.CollegeID
  193. };
  194. return query.FirstOrDefault();
  195. }
  196. /// <summary>
  197. /// 通过传入教学任务班的查询条件,得到所有和它们相关的执行计划
  198. /// </summary>
  199. /// <param name="exp"></param>
  200. /// <returns></returns>
  201. public IQueryable<EM_ExecutablePlan> GetRelatedExecutablePlan(Expression<Func<EM_EducationMissionClass, bool>> exp)
  202. {
  203. var query = (from emc in EducationMissionClassRepository.GetList(exp)
  204. from emccc in emc.CF_Classmajor
  205. join ep in ExecutablePlanRepository.Entities
  206. on new { emc.EM_EducationMission.SchoolyearID, emccc.GrademajorID, emc.CoursematerialID, emc.HandleModeID }
  207. equals new { ep.SchoolyearID, ep.GrademajorID, ep.CoursematerialID, ep.HandleModeID }
  208. select ep).Distinct();
  209. return query;
  210. }
  211. public List<MissionClassTeacherView> GetMissionClassTeacherQuery(Expression<Func<EM_EducationMissionClass, bool>> exp)
  212. {
  213. var query = (from emc in EducationMissionClassRepository.GetList(exp)
  214. from tec in emc.EM_MissionClassTeacher
  215. select new MissionClassTeacherView
  216. {
  217. UserID = tec.CF_Staff.UserID,
  218. EducationMissionClassID = emc.EducationMissionClassID,
  219. Name = tec.CF_Staff.Sys_User.Name,
  220. TeachingMethod=tec.TeachType
  221. });
  222. return query.OrderBy(x=>x.EducationMissionClassID).OrderBy(x=>x.TeachingMethod).ToList();
  223. }
  224. /// <summary>
  225. /// 获取排课对应的老师
  226. /// </summary>
  227. /// <param name="exp"></param>
  228. /// <returns></returns>
  229. public List<MissionClassTeacherView> GetEducationSchedulingTeacherQuery(Expression<Func<EM_EducationSchedulingClass, bool>> exp)
  230. {
  231. var query = (from escr in EducationSchedulingClassRepository.GetList(exp)
  232. from esr in EducationSchedulingRepository.Entities.Where(x => x.EducationSchedulingClassID == escr.EducationSchedulingClassID)
  233. from eswnr in EducationSchedulingWeekNumRepository.Entities.Where(x => x.EducationSchedulingID == esr.EducationSchedulingID)
  234. from tec in EducationSchedulingTeacherRepository.Entities.Where(x => x.EducationSchedulingID == esr.EducationSchedulingID)
  235. from cou in CoursesTimeRepository.Entities.Where(x => x.CoursesTimeID == esr.CoursesTimeID && x.RecordStatus > (int?)SYS_STATUS.UNUSABLE)
  236. select new MissionClassTeacherView
  237. {
  238. UserID = tec.CF_Staff.UserID,
  239. EducationMissionClassID = escr.EducationMissionClassID,
  240. Name = tec.CF_Staff.Sys_User.Name,
  241. TeachingMethod = tec.TeachingMethod,
  242. Weekday = esr.Weekday,
  243. WeekNum = eswnr.WeekNum,
  244. StarTimes = cou.StartTimes,
  245. CoursesTimeID = esr.CoursesTimeID,
  246. });
  247. return query.OrderBy(x => x.EducationMissionClassID).OrderBy(x => x.TeachingMethod).Distinct().ToList();
  248. }
  249. public List<ClassView> GetClassmajorQuery(Expression<Func<EM_EducationMissionClass, bool>> exp)
  250. {
  251. var query = (from emc in EducationMissionClassRepository.GetList(exp)
  252. from classjor in emc.CF_Classmajor
  253. select new ClassView
  254. {
  255. ClassmajorID = classjor.ClassmajorID,
  256. SchoolyearID = emc.EM_EducationMission.SchoolyearID,
  257. CoursematerialID = emc.CoursematerialID,
  258. TeachingModeID = emc.TeachingModeID ?? 0,
  259. ClassmajorName = classjor.Name
  260. });
  261. return query.ToList();
  262. }
  263. /// <summary>
  264. /// 根据专业课程获取授课方式
  265. /// </summary>
  266. /// <param name="specialtyCourseID"></param>
  267. /// <returns></returns>
  268. public List<string> GetEducationMissionClassSettingsQueryble(Guid? educationMissionClassID)
  269. {
  270. var query = from a in EducationMissionClassRepository.Entities
  271. join b in EducationMissionClassSettingsRepository.Entities
  272. on a.EducationMissionClassID equals b.EducationMissionClassID
  273. where a.EducationMissionClassID == educationMissionClassID
  274. select b.WeeklyNum.Value.ToString();
  275. return query.ToList();
  276. }
  277. /// <summary>
  278. /// 获取任务班授课老师
  279. /// </summary>
  280. /// <param name="educationMissionClassID"></param>
  281. /// <returns></returns>
  282. public IQueryable<EducationMissionClassTeacherListView> GetEducationMissionClassTeacherListViewQueryble()
  283. {
  284. var query = from a in EducationMissionClassRepository.Entities
  285. join b in MissionClassTeacherRepository.Entities
  286. on a.EducationMissionClassID equals b.MissionClassID
  287. select new EducationMissionClassTeacherListView
  288. {
  289. MissionClassTeacherID = b.MissionClassTeacherID,
  290. EducationMissionClassID = a.EducationMissionClassID,
  291. UserID = b.CF_Staff.UserID,
  292. LoginID = b.CF_Staff.Sys_User.LoginID,
  293. Name = b.CF_Staff.Sys_User.Name,
  294. CollegeID = b.CF_Staff.CF_College.CollegeID,
  295. CollegeName = b.CF_Staff.CF_College.Name,
  296. Sex = b.CF_Staff.SexID,
  297. DepartmentID = b.CF_Staff.DepartmentID,
  298. DepartmentName = b.CF_Staff.CF_Department.Name,
  299. BirthDate = b.CF_Staff.BirthDate,
  300. TeacherType = b.CF_Staff.TeacherTypeID,
  301. IncumbencyState = b.CF_Staff.IncumbencyState,
  302. Title = b.CF_Staff.TitleID,
  303. TeachingMethod = b.TeachType,
  304. };
  305. return query;
  306. }
  307. /// <summary>
  308. /// 获取分班信息
  309. /// </summary>
  310. /// <returns></returns>
  311. public IQueryable<DivideIntoClassesView> GetDivideIntoClassesViewQueryable()
  312. {
  313. var inschoolStatus = InSchoolSettingRepository.GetList(w => w.IsSelected == true).Select(s => s.InSchoolStatusID).ToList();
  314. var query = from a in EducationMissionClassRepository.Entities
  315. from b in a.EM_EducationSchedulingClass
  316. select new DivideIntoClassesView
  317. {
  318. EducationMissionClassID = a.EducationMissionClassID,
  319. ClassName = a.Name,
  320. StudentTotalNum = b.CF_Student.Where(x => inschoolStatus.Contains(x.InSchoolStatusID)).Count(),
  321. StudentNum = 0,
  322. GroupNum = 0
  323. };
  324. return query;
  325. }
  326. /// <summary>
  327. /// 获取排课班
  328. /// </summary>
  329. /// <returns></returns>
  330. public IQueryable<EducationSchedulingClassView> GetEducationSchedulingClassViewQueryable()
  331. {
  332. var query = from a in EducationMissionClassRepository.Entities
  333. join b in EducationSchedulingClassRepository.Entities on a.EducationMissionClassID equals b.EducationMissionClassID
  334. into gscr
  335. from gScheduling in gscr.DefaultIfEmpty()
  336. select new EducationSchedulingClassView
  337. {
  338. EducationSchedulingClassID = gScheduling.EducationSchedulingClassID,
  339. EducationMissionClassID = a.EducationMissionClassID,
  340. TaskGroupName = gScheduling.TaskGroupName,
  341. StudentNum = gScheduling.CF_Student.Count
  342. };
  343. return query;
  344. }
  345. /// <summary>
  346. /// 获取排课班学生信息
  347. /// </summary>
  348. /// <param name="educationSchedulingClassID"></param>
  349. /// <returns></returns>
  350. public IQueryable<EducationMissionClassStudentView> GetEducationMissionClassStudentViewQueryable(Guid? educationSchedulingClassID)
  351. {
  352. var query = from a in EducationSchedulingClassRepository.GetList(x => x.EducationSchedulingClassID == educationSchedulingClassID)
  353. from c in a.CF_Student
  354. join b in UserRepository.Entities
  355. on c.UserID equals b.UserID
  356. select new EducationMissionClassStudentView
  357. {
  358. UserID = b.UserID,
  359. LoginID = b.LoginID,
  360. Name = b.Name
  361. };
  362. return query;
  363. }
  364. /// <summary>
  365. /// 查询任务班对应的排课班所以学生
  366. /// </summary>
  367. /// <param name="educationMissionClassID">任务班ID</param>
  368. /// <returns></returns>
  369. public IQueryable<EducationMissionClassStudentView> GetEducationMissionClassSchedulingStudentViewQueryble(Guid? educationMissionClassID)
  370. {
  371. //该状态下的学生、表示在线状态学生 2016年12月13日16:11:14
  372. //PS:MM姐:优化执行计划及教学任务的功能,执行计划的人数统计及提交生成教学任务时,过滤非“在校”状态的学生
  373. var inSchoolStatusIDList = InSchoolSettingRepository.GetList(x => x.IsSelected == true).Select(w => w.InSchoolStatusID).ToList();//获取选中的在校设定状态、
  374. var query = from a in EducationSchedulingClassRepository.GetList(x => x.EducationMissionClassID == educationMissionClassID)
  375. from c in a.CF_Student.Where(p => inSchoolStatusIDList.Contains(p.InSchoolStatusID))
  376. join b in UserRepository.Entities
  377. on c.UserID equals b.UserID
  378. select new EducationMissionClassStudentView
  379. {
  380. UserID = b.UserID,
  381. LoginID = b.LoginID,
  382. Name = b.Name,
  383. ClassName = c.CF_Classmajor.Name,
  384. StudentStatus = c.StudentStatus
  385. };
  386. return query;
  387. }
  388. /// <summary>
  389. /// 查询任务班对应的排课班所有学生(查询多个任务班,暂时用在判断在选课结果页面开班时,是否与教学任务页面对应的任务班有重复学生)
  390. /// </summary>
  391. /// <param name="educationMissionClassIDs">任务班ID</param>
  392. /// <returns></returns>
  393. public IQueryable<EducationMissionClassStudentView> GetEducationMissionClassSchedulingStudentViewQueryble(List<Guid> educationMissionClassIDs)
  394. {
  395. var inSchoolStatusIDList = InSchoolSettingRepository.GetList(x => x.IsSelected == true).Select(w => w.InSchoolStatusID).ToList();//获取选中的在校设定状态、
  396. var query = from a in EducationSchedulingClassRepository.GetList(x => educationMissionClassIDs.Contains(x.EducationSchedulingClassID))
  397. from c in a.CF_Student.Where(p => inSchoolStatusIDList.Contains(p.InSchoolStatusID))
  398. join b in UserRepository.Entities
  399. on c.UserID equals b.UserID
  400. select new EducationMissionClassStudentView
  401. {
  402. UserID = b.UserID,
  403. LoginID = b.LoginID,
  404. Name = b.Name,
  405. ClassName = c.CF_Classmajor.Name
  406. };
  407. return query;
  408. }
  409. public IQueryable<EducationMissionView> GetEducationMissionView(Expression<Func<EM_EducationMission, bool>> exp)
  410. {
  411. var queryEducationMission = from a in EducationMissionRepository
  412. .GetList(exp)
  413. from b in a.EM_EducationMissionClass
  414. select new EducationMissionView
  415. {
  416. //TeachingModeID = b.TeachingModeID,
  417. EducationMissionID = a.EducationMissionID,
  418. ClassName = a.ClassName,
  419. SchoolyearCode = a.CF_Schoolyear.Code,
  420. };
  421. return queryEducationMission;
  422. }
  423. public IQueryable<CourseProcessView> GetCourseProcessView(Expression<Func<EM_EducationMissionClass, bool>> exp)
  424. {
  425. //var query = (from em in educationMissionRepository.GetList(exp)
  426. // from emc in em.EM_EducationMissionClass
  427. // from cp in emc.EM_CourseProcess
  428. var query = (from emc in EducationMissionClassRepository.GetList(exp)
  429. from cp in emc.EM_CourseProcess
  430. select new CourseProcessView
  431. {
  432. CourseProcessID = cp.CourseProcessID,
  433. TeachingModeID = emc.TeachingModeID,
  434. CollegeID = emc.EM_EducationMission.CollegeID,
  435. CourseCollegeID = emc.EM_EducationMission.CF_Department.CollegeID,
  436. EducationMissionClassID = emc.EducationMissionClassID,
  437. EducationMissionClassName = emc.Name,
  438. Week = cp.Week,
  439. Times = cp.Times,
  440. ClassroomTypeID = cp.ClassroomTypeID,
  441. ClassroomID = cp.ClassroomID,
  442. ClassroomName = cp.CF_Classroom.Name,
  443. RecordStatus = cp.RecordStatus,
  444. CreateTime = cp.CreateTime,
  445. CreateUserID = cp.CreateUserID,
  446. ModifyTime = cp.ModifyTime,
  447. ModifyUserID = cp.ModifyUserID
  448. });
  449. return query;
  450. }
  451. public IQueryable<CourseProcessTeacherView> GetCourseProcessTeacherView(Expression<Func<EM_EducationMissionClass, bool>> exp)
  452. {
  453. var query = (from emc in EducationMissionClassRepository.GetList(exp)
  454. from cp in emc.EM_CourseProcess
  455. from cpt in cp.EM_CourseProcessTeacher
  456. orderby cpt.TeachType,cpt.CF_Staff.Sys_User.Name
  457. select new CourseProcessTeacherView
  458. {
  459. CourseProcessTeacherID = cpt.CourseProcessTeacherID,
  460. CourseProcessID = cpt.CourseProcessID,
  461. EducationMissionClassID = cp.EducationMissionClassID,
  462. SchoolyearID = cp.EM_EducationMissionClass.EM_EducationMission.SchoolyearID,
  463. UserID = cpt.CF_Staff.UserID,
  464. LoginID = cpt.CF_Staff.Sys_User.LoginID,
  465. Name = cpt.CF_Staff.Sys_User.Name,
  466. CollegeID = cpt.CF_Staff.CF_College.CollegeID,
  467. CollegeName = cpt.CF_Staff.CF_College.Name,
  468. Sex = cpt.CF_Staff.SexID,
  469. DepartmentID = cpt.CF_Staff.DepartmentID,
  470. DepartmentName = cpt.CF_Staff.CF_Department.Name,
  471. BirthDate = cpt.CF_Staff.BirthDate,
  472. TeacherType = cpt.CF_Staff.TeacherTypeID,
  473. IncumbencyState = cpt.CF_Staff.IncumbencyState,
  474. Title = cpt.CF_Staff.TitleID,
  475. TeachingMethod = cpt.TeachType
  476. });
  477. return query;
  478. }
  479. public IQueryable<CourseProcessTeacherView> GetCourseProcessTeacherViewByCourseProcess(Expression<Func<EM_CourseProcess, bool>> exp)
  480. {
  481. var query = (from cp in CourseProcessRepository.GetList(exp)
  482. from cpt in cp.EM_CourseProcessTeacher
  483. orderby cpt.TeachType, cpt.CF_Staff.Sys_User.Name
  484. select new CourseProcessTeacherView
  485. {
  486. CourseProcessTeacherID = cpt.CourseProcessTeacherID,
  487. CourseProcessID = cpt.CourseProcessID,
  488. EducationMissionClassID = cp.EducationMissionClassID,
  489. SchoolyearID = cp.EM_EducationMissionClass.EM_EducationMission.SchoolyearID,
  490. UserID = cpt.CF_Staff.UserID,
  491. LoginID = cpt.CF_Staff.Sys_User.LoginID,
  492. Name = cpt.CF_Staff.Sys_User.Name,
  493. CollegeID = cpt.CF_Staff.CF_College.CollegeID,
  494. CollegeName = cpt.CF_Staff.CF_College.Name,
  495. Sex = cpt.CF_Staff.SexID,
  496. DepartmentID = cpt.CF_Staff.DepartmentID,
  497. DepartmentName = cpt.CF_Staff.CF_Department.Name,
  498. BirthDate = cpt.CF_Staff.BirthDate,
  499. TeacherType = cpt.CF_Staff.TeacherTypeID,
  500. IncumbencyState = cpt.CF_Staff.IncumbencyState,
  501. Title = cpt.CF_Staff.TitleID,
  502. TeachingMethod = cpt.TeachType
  503. });
  504. return query;
  505. }
  506. public IQueryable<EM_CourseProcess> GetRelatedCourseProcess(Expression<Func<EM_EducationMissionClass, bool>> exp)
  507. {
  508. var query = (from emc in EducationMissionClassRepository.GetList(exp)
  509. // from remc in emc.EM_EducationMission.EM_EducationMissionClass
  510. from cp in emc.EM_CourseProcess
  511. select cp).Include(x => x.EM_EducationMissionClass);
  512. return query;
  513. }
  514. public IQueryable<CollegeView> GetSchedulingSubmittedCollege(List<Guid?> educationMissionClassIDList)
  515. {
  516. var query = (from emc in EducationMissionClassRepository.GetList(x => educationMissionClassIDList.Contains(x.EducationMissionClassID))
  517. join cs in CollegeScheduleStatusRepository.Entities on new { emc.EM_EducationMission.CollegeID, emc.EM_EducationMission.SchoolyearID }
  518. equals new { cs.CollegeID, cs.SchoolyearID }
  519. join c in CollegeDAL.Value.GetCollegeViewQueryable(x => true) on cs.CollegeID equals c.CollegeID
  520. where cs.RecordStatus == (int)ES_CollegeScheduleStatusCode.Submited
  521. select c);
  522. return query;
  523. }
  524. [Obsolete]
  525. public IQueryable<EducationMissionClassView> GetLastCourseEducationMissionClassViewQueryable(Expression<Func<CF_Student, bool>> studentExp)
  526. {
  527. var missionClassIDQueryable = (from missionClass in EducationMissionClassRepository.Entities
  528. from mission in EducationMissionRepository.Entities.Where(x => x.EducationMissionID == missionClass.EducationMissionID)
  529. from schoolyear in SchoolyearRepository.Entities.Where(x => x.SchoolyearID == mission.SchoolyearID)
  530. from schedulingClass in EducationSchedulingClassRepository.Entities.Where(x => x.EducationMissionClassID == missionClass.EducationMissionClassID)
  531. from student in schedulingClass.CF_Student.AsQueryable().Where(studentExp)
  532. group new { missionClass, schoolyear } by missionClass.CoursematerialID into g
  533. select
  534. g.OrderByDescending(x => x.schoolyear.Value)
  535. .ThenBy(x => x.missionClass.TeachingModeID)
  536. .Select(x => x.missionClass.EducationMissionClassID)
  537. .FirstOrDefault()
  538. );
  539. var missionClassViewQueryable = this.GetEducationMissionClassViewQueryble(x => true);
  540. var query = (from view in missionClassViewQueryable
  541. from temp in missionClassIDQueryable
  542. .Where(x => x == view.EducationMissionClassID)
  543. select view);
  544. return query;
  545. }
  546. [Obsolete]
  547. public IQueryable<LastCourseStarttermView> GetLastCourseStarttermViewQueryable()
  548. {
  549. var query = (from missionClass in EducationMissionClassRepository.Entities
  550. from mission in EducationMissionRepository.Entities.Where(x => x.EducationMissionID == missionClass.EducationMissionID)
  551. from setting in EducationMissionClassTeachingSettingRepository.Entities.Where(x => x.EducationMissionClassID == missionClass.EducationMissionClassID)
  552. from schoolyear in SchoolyearRepository.Entities.Where(x => x.SchoolyearID == mission.SchoolyearID)
  553. from classmajor in missionClass.CF_Classmajor
  554. from student in classmajor.CF_Student
  555. from grade in GrademajorRepository.Entities.Where(x => x.GrademajorID == classmajor.GrademajorID)
  556. from gradeSchoolyear in SchoolyearRepository.Entities.Where(x => x.Years == grade.GradeID && x.SchoolcodeID == grade.SemesterID)
  557. from temp in
  558. (
  559. from missionClass1 in EducationMissionClassRepository.Entities
  560. from mission1 in EducationMissionRepository.Entities.Where(x => x.EducationMissionID == missionClass1.EducationMissionID)
  561. from schoolyear1 in SchoolyearRepository.Entities.Where(x => x.SchoolyearID == mission1.SchoolyearID)
  562. from classmajor1 in missionClass1.CF_Classmajor
  563. from student1 in classmajor1.CF_Student
  564. group new { student1.UserID, missionClass1.CoursematerialID, SchoolyearValue = schoolyear1.Value }
  565. by new { student1.UserID, missionClass1.CoursematerialID } into g
  566. select new { UserID = g.Key.UserID, CoursematerialID = g.Key.CoursematerialID, MaxSchoolyearValue = g.Max(x => x.SchoolyearValue) })
  567. .Where(x => x.CoursematerialID == missionClass.CoursematerialID && x.MaxSchoolyearValue == schoolyear.Value
  568. && x.UserID == student.UserID)
  569. from retake in RetakePlanStudentRepository.Entities.Where(x => x.EducationMissionID == mission.EducationMissionID).DefaultIfEmpty()
  570. select new
  571. {
  572. SchoolyearID = mission.SchoolyearID,
  573. SchoolyearNumID = ((schoolyear.Value - gradeSchoolyear.Value) / 2) + 1,
  574. CoursematerialID = missionClass.CoursematerialID,
  575. DepartmentID = mission.DepartmentID,
  576. ClassName = mission.ClassName,
  577. CourseTypeID = missionClass.CourseTypeID,
  578. ExaminationModeID = missionClass.ExaminationModeID,
  579. HandleModeID = missionClass.HandleModeID,
  580. Credit = setting.Credit,
  581. TotalHours = (setting.TheoryCourse ?? 0) + (setting.Practicehours ?? 0),
  582. ResultTypeID = missionClass.ResultTypeID,
  583. StarttermID = (schoolyear.Value - gradeSchoolyear.Value + 1),
  584. UserID = student.UserID,
  585. IsRetake = retake.RetakePlanStudentID != null
  586. } into s
  587. select new LastCourseStarttermView
  588. {
  589. SchoolyearID = s.SchoolyearID,
  590. SchoolyearNumID = s.SchoolyearNumID,
  591. CoursematerialID = s.CoursematerialID,
  592. DepartmentID = s.DepartmentID,
  593. ClassName = s.ClassName,
  594. CourseTypeID = s.CourseTypeID,
  595. ExaminationModeID = s.ExaminationModeID,
  596. HandleModeID = s.HandleModeID,
  597. Credit = s.Credit,
  598. TotalHours = s.TotalHours,
  599. ResultTypeID = s.ResultTypeID,
  600. StarttermID = s.StarttermID,
  601. UserID = s.UserID,
  602. IsRetake = s.IsRetake
  603. }
  604. );
  605. return query;
  606. }
  607. }
  608. }