ExecutableMinorPlanDAL.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  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.EducationManage;
  7. using EMIS.Entities;
  8. using System.Linq.Expressions;
  9. using EMIS.ViewModel;
  10. using System.Data.Entity;
  11. namespace EMIS.DataLogic.EducationManage
  12. {
  13. public class ExecutableMinorPlanDAL
  14. {
  15. public ExecutableMinorPlanRepository ExecutableMinorPlanRepository { get; set; }
  16. public ExecutableMinorPlanTeachingSettingRepository ExecutableMinorPlanTeachingSettingRepository { get; set; }
  17. public ExecutableMinorPlanTeachingModeTypeRepository ExecutableMinorPlanTeachingModeTypeRepository { get; set; }
  18. public ExecutableMinorPlanTeachingPlaceRepository ExecutableMinorPlanTeachingPlaceRepository { get; set; }
  19. public MinorPlanRepository MinorPlanRepository { get; set; }
  20. public StudentRepository StudentRepository { get; set; }
  21. public GrademinorRepository GrademinorRepository { get; set; }
  22. public InSchoolSettingRepository inSchoolSettingRepository { get; set; }
  23. public DictionaryItemRepository dictionaryItemRepository { get; set; }
  24. public EducationMissionClassRepository educationMissionClassRepository { get; set; }
  25. public ClassminorRepository ClassminorRepository { get; set; }
  26. public ClassminorStudentRepository ClassminorStudentRepository { get; set; }
  27. public IQueryable<ExecutableMinorPlanView> GetExecutableMinorPlanView(Expression<Func<EM_ExecutableMinorPlan, bool>> exp)
  28. {
  29. var inSchoolStatusIDList = inSchoolSettingRepository.GetList(x => x.IsSelected == true).Select(w => w.InSchoolStatusID).ToList();//获取选中的在校设定状态、
  30. var graduatingSemester = EMIS.Utility.Const.LOCAL_SETTING_ENTRANCESEMESTERID;
  31. if (graduatingSemester == null)
  32. {
  33. throw new Exception("入学学期(春季、上学期、秋季、下学期)未配置,请检查");
  34. }
  35. var SchoolcodeID = Convert.ToInt32(graduatingSemester);
  36. var query = (from emp in ExecutableMinorPlanRepository.GetList(exp)
  37. join mp in MinorPlanRepository.Entities on emp.MinorPlanID equals mp.MinorPlanID
  38. join gs in
  39. (
  40. from g in GrademinorRepository.Entities
  41. from c in g.CF_Classminor
  42. from s in c.CF_ClassminorStudent
  43. join student in StudentRepository.GetList(x => inSchoolStatusIDList.Contains(x.InSchoolStatusID)) on s.UserID equals student.UserID
  44. group s by g.GrademinorID into g
  45. select new
  46. {
  47. GrademinorID = g.Key,
  48. StudentCount = g.Count()
  49. }
  50. ) on mp.GrademinorID equals gs.GrademinorID into dgs
  51. from egs in dgs.DefaultIfEmpty()
  52. join dict in dictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_CourseType).Name)
  53. on emp.CourseTypeID equals dict.Value into ddict
  54. from edict in ddict.DefaultIfEmpty()
  55. select new ExecutableMinorPlanView
  56. {
  57. ExecutableMinorPlanID = emp.ExecutableMinorPlanID,
  58. MinorPlanID = emp.MinorPlanID,
  59. CampusID = emp.CF_College.CampusID,
  60. CollegeID = emp.CF_College.CollegeID,
  61. CollegeCode = emp.CF_College.No,
  62. CollegeName = emp.CF_College.Name,
  63. YearID = mp.CF_Grademinor.YearID,
  64. StandardID = emp.StandardID,
  65. CoursematerialID = emp.CoursematerialID,
  66. CourseCode = emp.EM_Coursematerial.CourseCode,
  67. CourseName = emp.EM_Coursematerial.CourseName,
  68. IsNeedMaterial = emp.IsNeedMaterial ?? false,
  69. DepartmentID = emp.DepartmentID,
  70. DepartmentName = emp.CF_Department.Name,
  71. CourseStructureID = emp.CourseStructureID,
  72. CourseCategoryID = emp.CourseCategoryID,
  73. CourseTypeID = emp.CourseTypeID,
  74. CourseTypeName = edict.Name,
  75. CourseQualityID = emp.CourseQualityID,
  76. PracticeTypeID = emp.PracticeTypeID,
  77. ExaminationModeID = emp.ExaminationModeID,
  78. TeachinglanguageID = emp.TeachinglanguageID,
  79. CourseFineID = emp.CourseFineID,
  80. IsSpecialtycore = emp.IsSpecialtycore ?? false,
  81. IsCooperation = emp.IsCooperation ?? false,
  82. IsRequired = emp.IsRequired ?? false,
  83. IsElective = emp.IsElective ?? false,
  84. IsNetworkCourse = emp.IsNetworkCourse ?? false,
  85. IsMainCourse = emp.IsMainCourse ?? false,
  86. Credit = emp.EM_ExecutableMinorPlanTeachingSetting.Credit,
  87. Totalhours = (emp.EM_ExecutableMinorPlanTeachingSetting.TheoryCourse ?? 0) + (emp.EM_ExecutableMinorPlanTeachingSetting.Practicehours ?? 0),
  88. TheoryCourse = emp.EM_ExecutableMinorPlanTeachingSetting.TheoryCourse,
  89. Practicehours = emp.EM_ExecutableMinorPlanTeachingSetting.Practicehours,
  90. Trialhours = emp.EM_ExecutableMinorPlanTeachingSetting.Trialhours,
  91. SchoolweeksNum = (emp.EM_ExecutableMinorPlanTeachingSetting.TheoryWeeklyNum ?? 0) + (emp.EM_ExecutableMinorPlanTeachingSetting.PracticeWeeklyNum ?? 0),
  92. WeeklyNum = emp.EM_ExecutableMinorPlanTeachingSetting.WeeklyNum,
  93. TheoryWeeklyNum = emp.EM_ExecutableMinorPlanTeachingSetting.TheoryWeeklyNum,
  94. PracticeWeeklyNum = emp.EM_ExecutableMinorPlanTeachingSetting.PracticeWeeklyNum,
  95. TrialWeeklyNum = emp.EM_ExecutableMinorPlanTeachingSetting.TrialWeeklyNum,
  96. StartWeeklyNum = emp.EM_ExecutableMinorPlanTeachingSetting.StartWeeklyNum,
  97. EndWeeklyNum = emp.EM_ExecutableMinorPlanTeachingSetting.EndWeeklyNum,
  98. WeeklyHours = emp.EM_ExecutableMinorPlanTeachingSetting.WeeklyHours,
  99. SchoolcodeID = emp.CF_Schoolyear.SchoolcodeID,
  100. SchoolyearNumID = emp.CF_Schoolyear.Years - mp.CF_Grademinor.YearID + 1,
  101. SchoolyearID = emp.CF_Schoolyear.SchoolyearID,
  102. SchoolcodeStr = emp.CF_Schoolyear.Code,
  103. StarttermID = emp.CF_Schoolyear.Value - ((mp.CF_Grademinor.YearID * 2 - 1) + SchoolcodeID - 1) + 1,
  104. HandleModeID = emp.HandleModeID,
  105. PeopleNumber = egs.GrademinorID == null ? 0 : egs.StudentCount,
  106. ResultTypeID = emp.ResultTypeID,
  107. Remark = emp.Remarks,
  108. RecordStatus = emp.RecordStatus,
  109. CreateUserID = emp.CreateUserID,
  110. CreateTime = emp.CreateTime
  111. });
  112. return query;
  113. }
  114. public IQueryable<EM_EducationMissionClass> GetEducationMissionClassByExecutablePlanID(IList<Guid?> executablePlanIDList)
  115. {
  116. var inSchoolStatusIDList = inSchoolSettingRepository.GetList(x => x.IsSelected == true).Select(w => w.InSchoolStatusID).ToList();//获取选中的在校设定状态、
  117. var q = (from ep in ExecutableMinorPlanRepository.GetList(x => executablePlanIDList.Contains(x.ExecutableMinorPlanID))
  118. join mp in MinorPlanRepository.Entities on ep.MinorPlanID equals mp.MinorPlanID
  119. join c in ClassminorRepository.Entities on mp.GrademinorID equals c.GrademinorID
  120. join emc in educationMissionClassRepository.Entities on
  121. new
  122. {
  123. ep.SchoolyearID,
  124. ep.CoursematerialID,
  125. ep.HandleModeID
  126. } equals new
  127. {
  128. emc.EM_EducationMission.SchoolyearID,
  129. emc.CoursematerialID,
  130. emc.HandleModeID
  131. }
  132. from emcc in emc.CF_Classmajor
  133. where c.ClassminorID == emcc.ClassmajorID
  134. select emc)
  135. .Include(x => x.EM_EducationMission)
  136. .Include(x => x.CF_Classmajor)
  137. .Include(x => x.EM_EducationSchedulingClass.Select(w => w.CF_Student));
  138. return q;
  139. }
  140. /// <summary>
  141. /// 根据辅修专业课程获取授课方式
  142. /// </summary>
  143. /// <param name="specialtyCourseID"></param>
  144. /// <returns></returns>
  145. public List<string> GetTeachingModeTypeQueryble(Guid? ExecutableMinorPlanID)
  146. {
  147. var query = from a in ExecutableMinorPlanTeachingModeTypeRepository.Entities.Where(x => x.ExecutableMinorPlanID == ExecutableMinorPlanID)
  148. join b in dictionaryItemRepository.Entities on new { a.TeachingModeID, DictionaryCode = DictionaryItem.CF_TeachingMode.ToString() }
  149. equals new { TeachingModeID = b.Value, b.DictionaryCode }
  150. select b.Value.Value.ToString();
  151. return query.ToList();
  152. }
  153. /// <summary>
  154. /// 根据辅修专业课程获取授课地点
  155. /// </summary>
  156. /// <param name="specialtyCourseID"></param>
  157. /// <returns></returns>
  158. public List<string> GetTeachingPlaceQueryble(Guid? ExecutableMinorPlanID)
  159. {
  160. var query = from a in ExecutableMinorPlanTeachingPlaceRepository.Entities.Where(x => x.ExecutableMinorPlanID == ExecutableMinorPlanID)
  161. join b in dictionaryItemRepository.Entities on new { a.TeachingPlace, DictionaryCode = DictionaryItem.EM_TeachingPlace.ToString() }
  162. equals new { TeachingPlace = b.Value, b.DictionaryCode }
  163. select b.Value.Value.ToString();
  164. return query.ToList();
  165. }
  166. /// <summary>
  167. /// 根据辅修专业课程获取授课地点
  168. /// </summary>
  169. /// <param name="specialtyCourseID"></param>
  170. /// <returns></returns>
  171. public List<ExecutableMinorPlanView> GetEducationMissionClassQuerybles()
  172. {
  173. var query = (from a in ExecutableMinorPlanRepository.Entities
  174. from b in a.EM_EducationMissionClass
  175. select new ExecutableMinorPlanView
  176. {
  177. EducationMissionClassID=b.EducationMissionClassID,
  178. ExecutableMinorPlanID=a.ExecutableMinorPlanID
  179. });
  180. return query.ToList();
  181. }
  182. }
  183. }