GraduationStandardDAL.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Linq.Expressions;
  5. using System.Text;
  6. using EMIS.Entities;
  7. using EMIS.DataLogic.Repositories;
  8. using EMIS.ViewModel.CultureplanManage.PlanManagement;
  9. using EMIS.ViewModel.GraduationManage.GraduationSetting;
  10. namespace EMIS.ExtensionLogic.CommonDataLogic.GraduationManage
  11. {
  12. public class GraduationStandardDAL : EMIS.DataLogic.GraduationManage.GraduationSetting.GraduationStandardDAL
  13. {
  14. public SpecialtyRepository SpecialtyRepository { get; set; }
  15. /// <summary>
  16. /// 查询对应的毕业标准信息View(门数、各类型学分统计:专业计划、执行计划)
  17. /// 注:由于学分制实行的程度不同,目前只对专业计划进行统计
  18. /// 此为成教版本
  19. /// </summary>
  20. /// <param name="expGraduationStandard"></param>
  21. /// <param name="expExecutablePlan"></param>
  22. /// <param name="expStudent"></param>
  23. /// <returns></returns>
  24. public override IQueryable<GraduationStandardView> GetGraduationStandardViewQueryable(Expression<Func<ER_GraduationStandard, bool>> expGraduationStandard,
  25. Expression<Func<EM_ExecutablePlan, bool>> expExecutablePlan, Expression<Func<CF_Student, bool>> expStudent)
  26. {
  27. var query = from gs in GraduationStandardRepository.GetList(expGraduationStandard)
  28. join gr in GrademajorRepository.Entities
  29. on gs.GrademajorID equals gr.GrademajorID
  30. join fa in FacultymajorRepository.Entities
  31. on gr.FacultymajorID equals fa.FacultymajorID
  32. join col in CollegeRepository.Entities
  33. on fa.CollegeID equals col.CollegeID
  34. join cam in CampusRepository.Entities
  35. on col.CampusID equals cam.CampusID
  36. join spe in SpecialtyRepository.Entities
  37. on new { fa.StandardID, fa.EducationID, fa.LearningformID, fa.LearnSystem }
  38. equals new { spe.StandardID, spe.EducationID, spe.LearningformID, spe.LearnSystem }
  39. join sye in SchoolyearRepository.Entities
  40. on new { SchoolyearID = gr.GradeID.Value, SchoolcodeID = gr.SemesterID.Value }
  41. equals new { SchoolyearID = sye.Years, SchoolcodeID = sye.SchoolcodeID } into tempsyenter
  42. from syenter in tempsyenter.DefaultIfEmpty()
  43. join stugr in
  44. (
  45. //年级专业对应的学生人数(区分在校、非在校)
  46. from stu in StudentRepository.GetList(expStudent)
  47. join cl in ClassmajorRepository.Entities
  48. on stu.ClassmajorID equals cl.ClassmajorID
  49. group cl by cl.GrademajorID into g
  50. select new
  51. {
  52. GrademajorID = g.Key,
  53. StudentCount = g.Count()
  54. }
  55. )
  56. on gr.GrademajorID equals stugr.GrademajorID into tempstugr
  57. from gsstugr in tempstugr.DefaultIfEmpty()
  58. join spgr in
  59. (
  60. //专业计划(计划门数、计划学分、必修、限选、任选学分统计)
  61. from spct in
  62. (
  63. from sp in SpecialtyPlanRepository.Entities
  64. join ct in CourseTypeSelectCourseTypeRepository.Entities
  65. on sp.CourseTypeID equals ct.CourseTypeID into tempct
  66. from spct in tempct.DefaultIfEmpty()
  67. select new
  68. {
  69. StartSchoolyearID = sp.StartSchoolyearID,
  70. SpecialtyID = sp.SpecialtyID,
  71. CourseTypeID = sp.CourseTypeID,
  72. Credit = sp.EM_SpecialtyPlanTeachingSetting.Credit ?? 0,
  73. IsRequired = spct.IsRequired ?? true,
  74. IsOptionalCourse = spct.IsOptionalCourse ?? false,
  75. IsFreeSelectionCourse = spct.IsFreeSelectionCourse ?? false,
  76. }
  77. )
  78. group spct by new { spct.StartSchoolyearID, spct.SpecialtyID } into g
  79. select new
  80. {
  81. StartSchoolyearID = g.Key.StartSchoolyearID,
  82. SpecialtyID = g.Key.SpecialtyID,
  83. PlanCourseCount = g.Count(),
  84. SpecialtyRequireCreditTotal = g.Sum(x => x.IsRequired ? x.Credit : 0),
  85. OptionalCreditTotal = g.Sum(x => x.IsOptionalCourse ? x.Credit : 0),
  86. FreeSelectionCreditTotal = g.Sum(x => x.IsFreeSelectionCourse ? x.Credit : 0),
  87. SpecialtyCreditTotal = g.Sum(x => x.Credit)
  88. }
  89. )
  90. on new { StartSchoolyearID = syenter.SchoolyearID, SpecialtyID = spe.SpecialtyID }
  91. equals new { StartSchoolyearID = spgr.StartSchoolyearID.Value, SpecialtyID = spgr.SpecialtyID.Value } into tempspgr
  92. from gsspgr in tempspgr.DefaultIfEmpty()
  93. join epgr in
  94. (
  95. //执行计划(执行门数、执行学分)
  96. from ep in ExecutablePlanRepository.GetList(expExecutablePlan)
  97. join ct in CourseTypeSelectCourseTypeRepository.Entities
  98. on ep.CourseTypeID equals ct.CourseTypeID into tempct
  99. from epct in tempct.DefaultIfEmpty()
  100. group ep by ep.GrademajorID into g
  101. select new
  102. {
  103. GrademajorID = g.Key,
  104. ExecCourseCount = g.Count(),
  105. ExecutableCreditTotal = g.Sum(x => x.EM_ExecutablePlanTeachingSetting.Credit ?? 0)
  106. }
  107. )
  108. on gr.GrademajorID equals epgr.GrademajorID into tempepgr
  109. from gsepgr in tempepgr.DefaultIfEmpty()
  110. select new GraduationStandardView
  111. {
  112. GraduationStandardID = gs.GraduationStandardID,
  113. GrademajorID = gs.GrademajorID,
  114. GrademajorCode = gr.Code,
  115. GrademajorName = gr.Name,
  116. FacultymajorID = fa.FacultymajorID,
  117. FacultymajorNo = fa.Code,
  118. FacultymajorName = fa.Name,
  119. CollegeID = fa.CollegeID,
  120. CollegeNo = col.No,
  121. CollegeName = col.Name,
  122. CampusID = col.CampusID,
  123. CampusNo = cam.No,
  124. CampusName = cam.Name,
  125. SchoolyearID = gr.GradeID,
  126. SchoolcodeID = gr.SemesterID,
  127. EnteringSchoolYearID = syenter.SchoolyearID,
  128. EnteringSchoolYearCode = syenter.Code,
  129. GraduatingSemesterID = gr.CF_Schoolyear.SchoolyearID,
  130. GraduatingSemesterCode = gr.CF_Schoolyear.Code,
  131. StandardID = fa.StandardID,
  132. EducationID = fa.EducationID,
  133. LearningformID = fa.LearningformID,
  134. LearnSystem = fa.LearnSystem,
  135. StudentCount = gsstugr.StudentCount == null ? 0 : gsstugr.StudentCount,
  136. PlanCourseCount = gsspgr.PlanCourseCount == null ? 0 : gsspgr.PlanCourseCount,
  137. SpecialtyRequireCreditTotal = gsspgr.SpecialtyRequireCreditTotal == null ? 0 : gsspgr.SpecialtyRequireCreditTotal,
  138. OptionalCreditTotal = gsspgr.OptionalCreditTotal == null ? 0 : gsspgr.OptionalCreditTotal,
  139. FreeSelectionCreditTotal = gsspgr.FreeSelectionCreditTotal == null ? 0 : gsspgr.FreeSelectionCreditTotal,
  140. SpecialtyCreditTotal = gsspgr.SpecialtyCreditTotal == null ? 0 : gsspgr.SpecialtyCreditTotal,
  141. ExecCourseCount = gsepgr.ExecCourseCount == null ? 0 : gsepgr.ExecCourseCount,
  142. ExecutableCreditTotal = gsepgr.ExecutableCreditTotal == null ? 0 : gsepgr.ExecutableCreditTotal,
  143. RequireCourseCount = gs.RequireCourseCount,
  144. GraduationCredit = gs.GraduationCredit,
  145. RecordStatus = gs.RecordStatus,
  146. CreateUserID = gs.CreateUserID,
  147. CreateTime = gs.CreateTime,
  148. ModifyUserID = gs.ModifyUserID,
  149. ModifyTime = gs.ModifyTime
  150. };
  151. return query;
  152. }
  153. /// <summary>
  154. /// 查询毕业标准对应的专业计划信息
  155. /// 此为成教版本
  156. /// </summary>
  157. /// <param name="exp"></param>
  158. /// <returns></returns>
  159. public override IQueryable<SpecialtyPlanView> GetSpecialtyPlanViewQueryable(Expression<Func<ER_GraduationStandard, bool>> exp)
  160. {
  161. var query = from gs in GraduationStandardRepository.GetList(exp)
  162. join gr in GrademajorRepository.Entities
  163. on gs.GrademajorID equals gr.GrademajorID
  164. join fa in FacultymajorRepository.Entities
  165. on gr.FacultymajorID equals fa.FacultymajorID
  166. join col in CollegeRepository.Entities
  167. on fa.CollegeID equals col.CollegeID
  168. join spe in SpecialtyRepository.Entities
  169. on new { fa.StandardID, fa.EducationID, fa.LearningformID, fa.LearnSystem }
  170. equals new { spe.StandardID, spe.EducationID, spe.LearningformID, spe.LearnSystem }
  171. join sye in SchoolyearRepository.Entities
  172. on new { SchoolyearID = gr.GradeID.Value, SchoolcodeID = gr.SemesterID.Value }
  173. equals new { SchoolyearID = sye.Years, SchoolcodeID = sye.SchoolcodeID } into tempsyenter
  174. from syenter in tempsyenter.DefaultIfEmpty()
  175. join sp in SpecialtyPlanRepository.Entities
  176. on new { StartSchoolyearID = syenter.SchoolyearID, SpecialtyID = spe.SpecialtyID }
  177. equals new { StartSchoolyearID = sp.StartSchoolyearID.Value, SpecialtyID = sp.SpecialtyID.Value }
  178. join sy in SchoolyearRepository.Entities
  179. on sp.SchoolyearID equals sy.SchoolyearID
  180. join cou in CoursematerialRepository.Entities
  181. on sp.CoursematerialID equals cou.CoursematerialID
  182. join depcou in DepartmentRepository.Entities
  183. on sp.DepartmentID equals depcou.DepartmentID into tempdepcou
  184. from spdepcou in tempdepcou.DefaultIfEmpty()
  185. select new SpecialtyPlanView
  186. {
  187. SpecialtyPlanID = sp.SpecialtyPlanID,
  188. SchoolyearID = sp.SchoolyearID,
  189. SchoolyearCode = sy.Code,
  190. GrademajorID = gr.GrademajorID,
  191. GrademajorCode = gr.Code,
  192. GrademajorName = gr.Name,
  193. CollegeID = fa.CollegeID,
  194. CollegeCode = col.No,
  195. CollegeName = col.Name,
  196. CoursematerialID = sp.CoursematerialID,
  197. CourseCode = cou.CourseCode,
  198. CourseName = cou.CourseName,
  199. CourseStructureID = sp.CourseStructureID,
  200. CourseCategoryID = sp.CourseCategoryID,
  201. CourseTypeID = sp.CourseTypeID,
  202. CourseQualityID = sp.CourseQualityID,
  203. ResultTypeID = sp.ResultTypeID,
  204. PracticeTypeID = sp.PracticeTypeID,
  205. ExaminationModeID = sp.ExaminationModeID,
  206. TeachinglanguageID = sp.TeachinglanguageID,
  207. CourseFineID = sp.CourseFineID,
  208. IsSpecialtycore = sp.IsSpecialtycore ?? false,
  209. IsCooperation = sp.IsCooperation ?? false,
  210. IsRequired = sp.IsRequired ?? false,
  211. IsElective = sp.IsElective ?? false,
  212. IsNetworkCourse = sp.IsNetworkCourse ?? false,
  213. IsMainCourse = sp.IsMainCourse ?? false,
  214. Credit = sp.EM_SpecialtyPlanTeachingSetting.Credit ?? 0,
  215. TheoryCourse = sp.EM_SpecialtyPlanTeachingSetting.TheoryCourse ?? 0,
  216. Practicehours = sp.EM_SpecialtyPlanTeachingSetting.Practicehours ?? 0,
  217. Trialhours = sp.EM_SpecialtyPlanTeachingSetting.Trialhours ?? 0,
  218. Totalhours = (sp.EM_SpecialtyPlanTeachingSetting.TheoryCourse ?? 0) + (sp.EM_SpecialtyPlanTeachingSetting.Practicehours ?? 0),
  219. SchoolyearNumID = (sy.Value - ((gr.GradeID * 2 - 1) + gr.SemesterID - 1)) / 2 + 1,
  220. SchoolcodeID = sy.SchoolcodeID,
  221. StarttermID = sy.Value - ((gr.GradeID * 2 - 1) + gr.SemesterID - 1) + 1,
  222. DepartmentID = sp.DepartmentID,
  223. DepartmentCode = spdepcou.No,
  224. DepartmentName = spdepcou.Name,
  225. HandleModeID = sp.HandleModeID,
  226. Remark = sp.Remark,
  227. RecordStatus = sp.RecordStatus,
  228. CreateUserID = sp.CreateUserID,
  229. CreateTime = sp.CreateTime,
  230. ModifyUserID = sp.ModifyUserID,
  231. ModifyTime = sp.ModifyTime
  232. };
  233. return query;
  234. }
  235. }
  236. }