GraduationConditionDAL.cs 65 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Linq.Expressions;
  6. using EMIS.DataLogic.Repositories;
  7. using EMIS.ViewModel.GraduationManage.GraduationSetting;
  8. using EMIS.Entities;
  9. using EMIS.ViewModel;
  10. using EMIS.ViewModel.Students;
  11. using EMIS.ViewModel.CultureplanManage.PlanManagement;
  12. using EMIS.ViewModel.ScoreManage;
  13. using EMIS.ViewModel.GraduationManage.GraduationRequirement;
  14. using EMIS.ViewModel.GraduationManage.GraduationManage;
  15. using EMIS.ViewModel.ChargeManage.ArrearsSituation;
  16. using EMIS.ViewModel.EducationManage;
  17. namespace EMIS.DataLogic.GraduationManage.GraduationSetting
  18. {
  19. public class GraduationConditionDAL
  20. {
  21. public GraduationConditionRepository GraduationConditionRepository { get; set; }
  22. public UserRepository UserRepository { get; set; }
  23. public StudentRepository StudentRepository { get; set; }
  24. public ClassmajorRepository ClassmajorRepository { get; set; }
  25. public GrademajorRepository GrademajorRepository { get; set; }
  26. public FacultymajorRepository FacultymajorRepository { get; set; }
  27. public CollegeRepository CollegeRepository { get; set; }
  28. public SpecialtyPlanRepository SpecialtyPlanRepository { get; set; }
  29. public ExecutablePlanRepository ExecutablePlanRepository { get; set; }
  30. public SchoolyearRepository SchoolyearRepository { get; set; }
  31. public CoursematerialRepository CoursematerialRepository { get; set; }
  32. public CourseTypeSelectCourseTypeRepository CourseTypeSelectCourseTypeRepository { get; set; }
  33. public ClubCourseRepository ClubCourseRepository { get; set; }
  34. public FinallyScoreRepository FinallyScoreRepository { get; set; }
  35. public GraduationCourseRepository GraduationCourseRepository { get; set; }
  36. public GraduateDesignCoursematerialRepository GraduateDesignCoursematerialRepository { get; set; }
  37. public GraduationCourseTypeRequirementRepository GraduationCourseTypeRequirementRepository { get; set; }
  38. public GraduationRequirementRepository GraduationRequirementRepository { get; set; }
  39. public GraduationStandardRepository GraduationStandardRepository { get; set; }
  40. public GraduationCourseTypeSettingRepository GraduationCourseTypeSettingRepository { get; set; }
  41. public StudentChargePaymentRepository StudentChargePaymentRepository { get; set; }
  42. public StudentChargeRepository StudentChargeRepository { get; set; }
  43. public PassStudentRepository PassStudentRepository { get; set; }
  44. /// <summary>
  45. /// 查询对应的毕业条件信息View
  46. /// </summary>
  47. /// <param name="exp"></param>
  48. /// <returns></returns>
  49. public IQueryable<GraduationConditionView> GetGraduationConditionQueryable(Expression<Func<ER_GraduationCondition, bool>> exp)
  50. {
  51. var query = from gc in GraduationConditionRepository.GetList(exp)
  52. select new GraduationConditionView
  53. {
  54. GraduationConditionID = gc.GraduationConditionID,
  55. OrderNo = gc.OrderNo,
  56. Title = gc.Title,
  57. MethodFullName = gc.MethodFullName,
  58. IsEnable = gc.RecordStatus.Value > 0 ? true : false,
  59. RecordStatus = gc.RecordStatus,
  60. CreateUserID = gc.CreateUserID,
  61. CreateTime = gc.CreateTime,
  62. ModifyUserID = gc.ModifyUserID,
  63. ModifyTime = gc.ModifyTime
  64. };
  65. return query;
  66. }
  67. /// <summary>
  68. /// 查询对应的学生信息View(BaseStudentView,根据学生信息)
  69. /// </summary>
  70. /// <param name="exp"></param>
  71. /// <returns></returns>
  72. public IQueryable<BaseStudentView> GetBaseStudentViewQueryable(Expression<Func<CF_Student, bool>> exp)
  73. {
  74. var query = from stu in StudentRepository.GetList(exp)
  75. join us in UserRepository.Entities
  76. on stu.UserID equals us.UserID
  77. join cl in ClassmajorRepository.Entities
  78. on stu.ClassmajorID equals cl.ClassmajorID
  79. join gr in GrademajorRepository.Entities
  80. on cl.GrademajorID equals gr.GrademajorID
  81. join fa in FacultymajorRepository.Entities
  82. on gr.FacultymajorID equals fa.FacultymajorID
  83. join col in CollegeRepository.Entities
  84. on fa.CollegeID equals col.CollegeID
  85. select new BaseStudentView
  86. {
  87. UserID = stu.UserID,
  88. LoginID = us.LoginID,
  89. UserName = us.Name,
  90. SexID = stu.SexID,
  91. IDNumber = stu.IDNumber,
  92. ClassmajorID = stu.ClassmajorID,
  93. ClassmajorCode = cl.No,
  94. ClassmajorName = cl.Name,
  95. GrademajorID = cl.GrademajorID,
  96. GrademajorCode = gr.Code,
  97. GrademajorName = gr.Name,
  98. FacultymajorID = gr.FacultymajorID,
  99. FacultymajorCode = fa.Code,
  100. FacultymajorName = fa.Name,
  101. StandardID = fa.StandardID,
  102. CollegeID = fa.CollegeID,
  103. CollegeNo = col.No,
  104. CollegeName = col.Name,
  105. SchoolyearID = gr.GradeID,
  106. SchoolcodeID = gr.SemesterID,
  107. InSchoolStatusID = stu.InSchoolStatusID,
  108. StudentStatus = stu.StudentStatus
  109. };
  110. return query;
  111. }
  112. /// <summary>
  113. /// 查询对应的学生专业计划信息StudentSpecialtyPlanView(根据学生信息)
  114. /// 注:此为普教版本,成教版本暂不考虑
  115. /// 注:由于存在在不同的学年学期参加补考的情况,匹配学生最终成绩时,采用开学学期ID匹配(学年学期暂以执行计划为准)
  116. /// </summary>
  117. /// <param name="expStudent"></param>
  118. /// <returns></returns>
  119. public IQueryable<StudentSpecialtyPlanView> GetStudentSpecialtyPlanViewQueryable(Expression<Func<CF_Student, bool>> expStudent)
  120. {
  121. var query = from sp in SpecialtyPlanRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE)
  122. join stu in this.GetBaseStudentViewQueryable(expStudent)
  123. on sp.GrademajorID equals stu.GrademajorID
  124. join sy in SchoolyearRepository.Entities
  125. on sp.SchoolyearID equals sy.SchoolyearID
  126. join cou in CoursematerialRepository.Entities
  127. on sp.CoursematerialID equals cou.CoursematerialID
  128. select new StudentSpecialtyPlanView
  129. {
  130. UserID = stu.UserID,
  131. SpecialtyPlanID = sp.SpecialtyPlanID,
  132. SchoolyearID = sp.SchoolyearID,
  133. SchoolyearCode = sy.Code,
  134. GrademajorID = sp.GrademajorID,
  135. GrademajorCode = stu.GrademajorCode,
  136. GrademajorName = stu.GrademajorName,
  137. CoursematerialID = sp.CoursematerialID,
  138. CourseCode = cou.CourseCode,
  139. CourseName = cou.CourseName,
  140. CourseTypeID = sp.CourseTypeID,
  141. Credit = sp.EM_SpecialtyPlanTeachingSetting.Credit,
  142. TheoryCourse = sp.EM_SpecialtyPlanTeachingSetting.TheoryCourse,
  143. Practicehours = sp.EM_SpecialtyPlanTeachingSetting.Practicehours,
  144. Trialhours = sp.EM_SpecialtyPlanTeachingSetting.Trialhours,
  145. SchoolyearNumID = (sy.Value - ((stu.SchoolyearID * 2 - 1) + stu.SchoolcodeID - 1)) / 2 + 1,
  146. SchoolcodeID = sy.SchoolcodeID,
  147. StarttermID = sy.Value - ((stu.SchoolyearID * 2 - 1) + stu.SchoolcodeID - 1) + 1,
  148. IsRequired = sp.IsRequired == null ? false : sp.IsRequired.Value,
  149. IsElective = sp.IsElective == null ? false : sp.IsElective.Value,
  150. IsMainCourse = sp.IsMainCourse == null ? false : sp.IsMainCourse.Value,
  151. ResultTypeID = sp.ResultTypeID
  152. };
  153. return query;
  154. }
  155. /// <summary>
  156. /// 查询对应的学生执行计划信息StudentExecutablePlanView(根据学生信息)
  157. /// 注:由于存在在不同的学年学期参加补考的情况,匹配学生最终成绩时,采用开学学期ID匹配(学年学期暂以执行计划为准)
  158. /// </summary>
  159. /// <param name="expStudent"></param>
  160. /// <returns></returns>
  161. public IQueryable<StudentExecutablePlanView> GetStudentExecutablePlanViewQueryable(Expression<Func<CF_Student, bool>> expStudent)
  162. {
  163. var query = from stu in this.GetBaseStudentViewQueryable(expStudent)
  164. join ep in ExecutablePlanRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE)
  165. on stu.GrademajorID equals ep.GrademajorID
  166. join sy in SchoolyearRepository.Entities
  167. on ep.SchoolyearID equals sy.SchoolyearID
  168. join cou in CoursematerialRepository.Entities
  169. on ep.CoursematerialID equals cou.CoursematerialID
  170. select new StudentExecutablePlanView
  171. {
  172. UserID = stu.UserID,
  173. ExecutablePlanID = ep.ExecutablePlanID,
  174. SpecialtyPlanID = ep.SpecialtyPlanID,
  175. SchoolyearID = ep.SchoolyearID,
  176. SchoolyearCode = sy.Code,
  177. GrademajorID = ep.GrademajorID,
  178. GrademajorCode = stu.GrademajorCode,
  179. GrademajorName = stu.GrademajorName,
  180. CoursematerialID = ep.CoursematerialID,
  181. CourseCode = cou.CourseCode,
  182. CourseName = cou.CourseName,
  183. CourseTypeID = ep.CourseTypeID,
  184. Credit = ep.EM_ExecutablePlanTeachingSetting.Credit,
  185. TheoryCourse = ep.EM_ExecutablePlanTeachingSetting.TheoryCourse,
  186. Practicehours = ep.EM_ExecutablePlanTeachingSetting.Practicehours,
  187. Trialhours = ep.EM_ExecutablePlanTeachingSetting.Trialhours,
  188. SchoolyearNumID = (sy.Value - ((stu.SchoolyearID * 2 - 1) + stu.SchoolcodeID - 1)) / 2 + 1,
  189. SchoolcodeID = sy.SchoolcodeID,
  190. StarttermID = sy.Value - ((stu.SchoolyearID * 2 - 1) + stu.SchoolcodeID - 1) + 1,
  191. IsSpecialtycore = ep.EM_ExecutablePlanProfile.IsSpecialtycore == null ? false : ep.EM_ExecutablePlanProfile.IsSpecialtycore.Value,
  192. IsCooperation = ep.EM_ExecutablePlanProfile.IsCooperation == null ? false : ep.EM_ExecutablePlanProfile.IsCooperation.Value,
  193. IsRequired = ep.EM_ExecutablePlanProfile.IsRequired == null ? false : ep.EM_ExecutablePlanProfile.IsRequired.Value,
  194. IsElective = ep.EM_ExecutablePlanProfile.IsElective == null ? false : ep.EM_ExecutablePlanProfile.IsElective.Value,
  195. IsNetworkCourse = ep.EM_ExecutablePlanProfile.IsNetworkCourse == null ? false : ep.EM_ExecutablePlanProfile.IsNetworkCourse.Value,
  196. IsMainCourse = ep.EM_ExecutablePlanProfile.IsMainCourse == null ? false : ep.EM_ExecutablePlanProfile.IsMainCourse.Value,
  197. ResultTypeID = ep.ResultTypeID
  198. };
  199. return query;
  200. }
  201. /// <summary>
  202. /// 查询对应的学生最终成绩信息StudentScoreView(根据学生信息)
  203. /// </summary>
  204. /// <param name="expStudent"></param>
  205. /// <returns></returns>
  206. public IQueryable<StudentScoreView> GetFinallyScoreViewQueryable(Expression<Func<CF_Student, bool>> expStudent)
  207. {
  208. var query = from finsco in FinallyScoreRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE)
  209. join stu in this.GetBaseStudentViewQueryable(expStudent)
  210. on finsco.UserID equals stu.UserID
  211. join sy in SchoolyearRepository.Entities
  212. on finsco.SchoolyearID equals sy.SchoolyearID
  213. join cou in CoursematerialRepository.Entities
  214. on finsco.CoursematerialID equals cou.CoursematerialID
  215. select new StudentScoreView
  216. {
  217. FinallyScoreID = finsco.FinallyScoreID,
  218. SchoolyearID = finsco.SchoolyearID,
  219. SchoolyearCode = sy.Code,
  220. UserID = finsco.UserID,
  221. LoginID = stu.LoginID,
  222. UserName = stu.UserName,
  223. ClassmajorID = stu.ClassmajorID,
  224. ClassmajorCode = stu.ClassmajorCode,
  225. ClassmajorName = stu.ClassmajorName,
  226. GrademajorID = stu.GrademajorID,
  227. GrademajorCode = stu.GrademajorCode,
  228. GrademajorName = stu.GrademajorName,
  229. CoursematerialID = finsco.CoursematerialID,
  230. CourseCode = cou.CourseCode,
  231. CourseName = cou.CourseName,
  232. CourseTypeID = finsco.CourseTypeID,
  233. Credit = finsco.Credit,
  234. TotalHours = finsco.TotalHours,
  235. ExamsCategoryID = finsco.ExamsCategoryID,
  236. ExamsStateID = finsco.ExamsStateID,
  237. TotalScore = finsco.TotalScore,
  238. ScoreCredit = finsco.ScoreCredit,
  239. SchoolyearNumID = finsco.SchoolyearNumID,
  240. StarttermID = finsco.StarttermID,
  241. ResultTypeID = finsco.ResultTypeID,
  242. CreateUserID = finsco.CreateUserID,
  243. CreateTime = finsco.CreateTime
  244. };
  245. return query;
  246. }
  247. /// <summary>
  248. /// 查询对应的学生最终成绩信息StudentScoreView(根据学生信息并且匹配执行计划)
  249. /// 注:学生最终成绩以执行计划为准(左连),未修习成绩默认为0分
  250. /// 注:由于存在在不同的学年学期参加补考的情况,匹配学生最终成绩时,采用开学学期ID匹配(学年学期暂以执行计划为准)
  251. /// 注:匹配暂时不考虑总学时TotalHours
  252. /// 注:此为默认匹配规则(可个性化配置)
  253. /// </summary>
  254. /// <param name="expStudent"></param>
  255. /// <returns></returns>
  256. public virtual IQueryable<StudentScoreView> GetFinallyScoreExecutablePlanViewQueryable(Expression<Func<CF_Student, bool>> expStudent)
  257. {
  258. var studentFinallyScoreList = from finsco in FinallyScoreRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE)
  259. join stu in StudentRepository.GetList(expStudent)
  260. on finsco.UserID equals stu.UserID
  261. select new
  262. {
  263. FinallyScoreID = finsco.FinallyScoreID,
  264. SchoolyearID = finsco.SchoolyearID,
  265. UserID = finsco.UserID,
  266. CoursematerialID = finsco.CoursematerialID,
  267. CourseTypeID = finsco.CourseTypeID,
  268. SchoolyearNumID = finsco.SchoolyearNumID,
  269. StarttermID = finsco.StarttermID,
  270. ResultTypeID = finsco.ResultTypeID,
  271. CreateUserID = finsco.CreateUserID,
  272. Credit = finsco.Credit,
  273. TotalHours = finsco.TotalHours,
  274. ExamsCategoryID = finsco.ExamsCategoryID,
  275. ExamsStateID = finsco.ExamsStateID,
  276. TotalScore = finsco.TotalScore,
  277. ScoreCredit = finsco.ScoreCredit,
  278. GradePoint = finsco.GradePoint,
  279. CreateTime = finsco.CreateTime
  280. };
  281. var query = from stuep in this.GetStudentExecutablePlanViewQueryable(expStudent)
  282. join finsco in studentFinallyScoreList
  283. on
  284. new { UserID = stuep.UserID, StarttermID = stuep.StarttermID, CoursematerialID = stuep.CoursematerialID, CourseTypeID = stuep.CourseTypeID, Credit = stuep.Credit }
  285. equals
  286. new { UserID = finsco.UserID.Value, StarttermID = finsco.StarttermID, CoursematerialID = finsco.CoursematerialID, CourseTypeID = finsco.CourseTypeID, Credit = finsco.Credit }
  287. into tempepfinsco
  288. from epfinsco in tempepfinsco.DefaultIfEmpty()
  289. select new StudentScoreView
  290. {
  291. SchoolyearID = stuep.SchoolyearID,
  292. SchoolyearCode = stuep.SchoolyearCode,
  293. UserID = stuep.UserID,
  294. CoursematerialID = stuep.CoursematerialID,
  295. CourseCode = stuep.CourseCode,
  296. CourseName = stuep.CourseName,
  297. CourseTypeID = stuep.CourseTypeID,
  298. SchoolyearNumID = stuep.SchoolyearNumID,
  299. StarttermID = stuep.StarttermID,
  300. ResultTypeID = stuep.ResultTypeID,
  301. Credit = stuep.Credit,
  302. //TotalHours = stuep.Totalhours,(执行计划总学时类型不对,暂时不处理)
  303. ExamsCategoryID = epfinsco.ExamsCategoryID,
  304. ExamsStateID = epfinsco.ExamsStateID,
  305. TotalScore = epfinsco.TotalScore ?? 0,
  306. ScoreCredit = epfinsco.ScoreCredit ?? 0
  307. };
  308. return query;
  309. }
  310. /// <summary>
  311. /// 查询对应的学生最终成绩信息StudentScoreView(根据学生信息)
  312. /// 注:内连课程类型设置表
  313. /// 不包括俱乐部课程
  314. /// </summary>
  315. /// <param name="expStudent"></param>
  316. /// <param name="expCourseTypeSelectCourseType"></param>
  317. /// <returns></returns>
  318. public IQueryable<StudentScoreView> GetFinallyScoreNoClubViewQueryable(Expression<Func<CF_Student, bool>> expStudent,
  319. Expression<Func<EM_CourseTypeSelectCourseType, bool>> expCourseTypeSelectCourseType)
  320. {
  321. var query = from finsco in FinallyScoreRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE)
  322. join stu in this.GetBaseStudentViewQueryable(expStudent)
  323. on finsco.UserID equals stu.UserID
  324. join couset in CourseTypeSelectCourseTypeRepository.GetList(expCourseTypeSelectCourseType)
  325. on finsco.CourseTypeID equals couset.CourseTypeID
  326. join sy in SchoolyearRepository.Entities
  327. on finsco.SchoolyearID equals sy.SchoolyearID
  328. join cou in CoursematerialRepository.Entities
  329. on finsco.CoursematerialID equals cou.CoursematerialID
  330. join club in ClubCourseRepository.Entities
  331. on finsco.CoursematerialID equals club.CoursematerialID
  332. into tempclub
  333. from scoclub in tempclub.DefaultIfEmpty()
  334. where scoclub.ClubCourseID == null
  335. select new StudentScoreView
  336. {
  337. FinallyScoreID = finsco.FinallyScoreID,
  338. SchoolyearID = finsco.SchoolyearID,
  339. SchoolyearCode = sy.Code,
  340. UserID = finsco.UserID,
  341. LoginID = stu.LoginID,
  342. UserName = stu.UserName,
  343. ClassmajorID = stu.ClassmajorID,
  344. ClassmajorCode = stu.ClassmajorCode,
  345. ClassmajorName = stu.ClassmajorName,
  346. GrademajorID = stu.GrademajorID,
  347. GrademajorCode = stu.GrademajorCode,
  348. GrademajorName = stu.GrademajorName,
  349. CoursematerialID = finsco.CoursematerialID,
  350. CourseCode = cou.CourseCode,
  351. CourseName = cou.CourseName,
  352. CourseTypeID = finsco.CourseTypeID,
  353. Credit = finsco.Credit,
  354. TotalHours = finsco.TotalHours,
  355. ExamsCategoryID = finsco.ExamsCategoryID,
  356. ExamsStateID = finsco.ExamsStateID,
  357. TotalScore = finsco.TotalScore,
  358. ScoreCredit = finsco.ScoreCredit,
  359. SchoolyearNumID = finsco.SchoolyearNumID,
  360. StarttermID = finsco.StarttermID,
  361. ResultTypeID = finsco.ResultTypeID
  362. };
  363. return query;
  364. }
  365. /// <summary>
  366. /// 查询对应的学生最终成绩信息StudentScoreView(根据学生信息)
  367. /// 注:内连课程类型设置表
  368. /// 包含俱乐部课程
  369. /// </summary>
  370. /// <param name="expStudent"></param>
  371. /// <param name="expCourseTypeSelectCourseType"></param>
  372. /// <returns></returns>
  373. public IQueryable<StudentScoreView> GetFinallyScoreViewQueryable(Expression<Func<CF_Student, bool>> expStudent,
  374. Expression<Func<EM_CourseTypeSelectCourseType, bool>> expCourseTypeSelectCourseType)
  375. {
  376. var query = from finsco in FinallyScoreRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE)
  377. join stu in this.GetBaseStudentViewQueryable(expStudent)
  378. on finsco.UserID equals stu.UserID
  379. join couset in CourseTypeSelectCourseTypeRepository.GetList(expCourseTypeSelectCourseType)
  380. on finsco.CourseTypeID equals couset.CourseTypeID
  381. join sy in SchoolyearRepository.Entities
  382. on finsco.SchoolyearID equals sy.SchoolyearID
  383. join cou in CoursematerialRepository.Entities
  384. on finsco.CoursematerialID equals cou.CoursematerialID
  385. select new StudentScoreView
  386. {
  387. FinallyScoreID = finsco.FinallyScoreID,
  388. SchoolyearID = finsco.SchoolyearID,
  389. SchoolyearCode = sy.Code,
  390. UserID = finsco.UserID,
  391. LoginID = stu.LoginID,
  392. UserName = stu.UserName,
  393. ClassmajorID = stu.ClassmajorID,
  394. ClassmajorCode = stu.ClassmajorCode,
  395. ClassmajorName = stu.ClassmajorName,
  396. GrademajorID = stu.GrademajorID,
  397. GrademajorCode = stu.GrademajorCode,
  398. GrademajorName = stu.GrademajorName,
  399. CoursematerialID = finsco.CoursematerialID,
  400. CourseCode = cou.CourseCode,
  401. CourseName = cou.CourseName,
  402. CourseTypeID = finsco.CourseTypeID,
  403. Credit = finsco.Credit,
  404. TotalHours = finsco.TotalHours,
  405. ExamsCategoryID = finsco.ExamsCategoryID,
  406. ExamsStateID = finsco.ExamsStateID,
  407. TotalScore = finsco.TotalScore,
  408. ScoreCredit = finsco.ScoreCredit,
  409. SchoolyearNumID = finsco.SchoolyearNumID,
  410. StarttermID = finsco.StarttermID,
  411. ResultTypeID = finsco.ResultTypeID
  412. };
  413. return query;
  414. }
  415. /// <summary>
  416. /// 查询对应的学生最终成绩学分信息PersonalCreditView(根据学生信息)
  417. /// 注:默认全部为必修课程
  418. /// </summary>
  419. /// <param name="expStudent"></param>
  420. /// <returns></returns>
  421. public IQueryable<PersonalCreditView> GetFinallyScorePersonalCreditViewQueryable(Expression<Func<CF_Student, bool>> expStudent)
  422. {
  423. var query = from finsco in this.GetFinallyScoreViewQueryable(expStudent)
  424. group finsco by new { finsco.UserID, finsco.GrademajorID }
  425. into g
  426. select new PersonalCreditView
  427. {
  428. UserID = g.Key.UserID,
  429. GrademajorID = g.Key.GrademajorID,
  430. CourseCount = g.Count(),
  431. RequiredCredit = g.Sum(x => x.ScoreCredit)
  432. };
  433. return query;
  434. }
  435. /// <summary>
  436. /// 查询对应的学生全部最终成绩信息GraduationScoreTypeCountView(根据学生信息并且区分必修、选修)
  437. /// 注:内连课程类型设置表(未匹配执行计划)
  438. /// 包含俱乐部课程
  439. /// </summary>
  440. /// <param name="expStudent"></param>
  441. /// <returns></returns>
  442. public IQueryable<GraduationScoreTypeCountView> GetFinallyScoreTypeViewQueryable(Expression<Func<CF_Student, bool>> expStudent)
  443. {
  444. var finallyScoreExecutablePlanViewList = from finsco in FinallyScoreRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE)
  445. join stu in StudentRepository.GetList(expStudent)
  446. on finsco.UserID equals stu.UserID
  447. join cou in CoursematerialRepository.Entities
  448. on finsco.CoursematerialID equals cou.CoursematerialID
  449. join cs in CourseTypeSelectCourseTypeRepository.Entities
  450. on finsco.CourseTypeID equals cs.CourseTypeID
  451. into tempcs
  452. from couset in tempcs.DefaultIfEmpty()
  453. select new
  454. {
  455. UserID = finsco.UserID,
  456. CoursematerialID = finsco.CoursematerialID,
  457. CourseCode = cou.CourseCode,
  458. CourseName = cou.CourseName,
  459. CourseTypeID = finsco.CourseTypeID,
  460. TotalScore = finsco.TotalScore ?? 0,
  461. ScoreCredit = finsco.ScoreCredit ?? 0,
  462. IsRequired = couset.IsRequired,
  463. IsOptionalCourse = couset.IsOptionalCourse,
  464. IsFreeSelectionCourse = couset.IsFreeSelectionCourse,
  465. RequiredPass = (couset.IsRequired.Value && finsco.TotalScore >= 60) ? true : false,
  466. RequiredNotPass = (couset.IsRequired.Value && finsco.TotalScore < 60) ? true : false,
  467. OptionalCoursePass = (couset.IsOptionalCourse.Value && finsco.TotalScore >= 60) ? true : false,
  468. OptionalCourseNotPass = (couset.IsOptionalCourse.Value && finsco.TotalScore < 60) ? true : false,
  469. FreeSelectionCoursePass = (couset.IsFreeSelectionCourse.Value && finsco.TotalScore >= 60) ? true : false,
  470. FreeSelectionCourseNotPass = (couset.IsFreeSelectionCourse.Value && finsco.TotalScore < 60) ? true : false
  471. };
  472. //学生最终成绩统计(分必修、选修)--必修及格门数、必修不及格门数、选修及格门数、选修不及格门数、已修学分
  473. var query = from finsco in finallyScoreExecutablePlanViewList
  474. group finsco by finsco.UserID into g
  475. select new GraduationScoreTypeCountView
  476. {
  477. UserID = g.Key.Value,
  478. ExecCourseCount = g.Count(),
  479. RequiredPassCount = g.Count(x => x.RequiredPass),
  480. RequiredNotPassCount = g.Count(x => x.RequiredNotPass),
  481. RequiredNotPassCourseList = g.Where(x => x.RequiredNotPass).Select(x => x.CourseName).ToList(),
  482. OptionalPassCount = g.Count(x => x.OptionalCoursePass) + g.Count(x => x.FreeSelectionCoursePass),
  483. OptionalNotPassCount = g.Count(x => x.OptionalCourseNotPass) + g.Count(x => x.FreeSelectionCourseNotPass),
  484. TotalCredit = g.Sum(x => x.ScoreCredit)
  485. };
  486. return query;
  487. }
  488. /// <summary>
  489. /// 查询对应的学生全部最终成绩信息GraduationScoreTypeCountView(根据学生信息并且区分必修、选修)
  490. /// 注:内连课程类型设置表(匹配执行计划)
  491. /// 包含俱乐部课程
  492. /// </summary>
  493. /// <param name="expStudent"></param>
  494. /// <returns></returns>
  495. public IQueryable<GraduationScoreTypeCountView> GetFinallyScoreTypeExecutablePlanViewQueryable(Expression<Func<CF_Student, bool>> expStudent)
  496. {
  497. var finallyScoreExecutablePlanViewList = from finsco in GetFinallyScoreExecutablePlanViewQueryable(expStudent)
  498. join cs in CourseTypeSelectCourseTypeRepository.Entities
  499. on finsco.CourseTypeID equals cs.CourseTypeID into tempcs
  500. from couset in tempcs.DefaultIfEmpty()
  501. select new
  502. {
  503. UserID = finsco.UserID,
  504. CoursematerialID = finsco.CoursematerialID,
  505. CourseCode = finsco.CourseCode,
  506. CourseName = finsco.CourseName,
  507. CourseTypeID = finsco.CourseTypeID,
  508. TotalScore = finsco.TotalScore ?? 0,
  509. ScoreCredit = finsco.ScoreCredit ?? 0,
  510. IsRequired = couset.IsRequired,
  511. IsOptionalCourse = couset.IsOptionalCourse,
  512. IsFreeSelectionCourse = couset.IsFreeSelectionCourse,
  513. RequiredPass = (couset.IsRequired.Value && finsco.TotalScore >= 60) ? true : false,
  514. RequiredNotPass = (couset.IsRequired.Value && finsco.TotalScore < 60) ? true : false,
  515. OptionalCoursePass = (couset.IsOptionalCourse.Value && finsco.TotalScore >= 60) ? true : false,
  516. OptionalCourseNotPass = (couset.IsOptionalCourse.Value && finsco.TotalScore < 60) ? true : false,
  517. FreeSelectionCoursePass = (couset.IsFreeSelectionCourse.Value && finsco.TotalScore >= 60) ? true : false,
  518. FreeSelectionCourseNotPass = (couset.IsFreeSelectionCourse.Value && finsco.TotalScore < 60) ? true : false
  519. };
  520. //学生最终成绩统计(分必修、选修)--必修及格门数、必修不及格门数、选修及格门数、选修不及格门数、已修学分
  521. var query = from finsco in finallyScoreExecutablePlanViewList
  522. group finsco by finsco.UserID into g
  523. select new GraduationScoreTypeCountView
  524. {
  525. UserID = g.Key.Value,
  526. ExecCourseCount = g.Count(),
  527. RequiredPassCount = g.Count(x => x.RequiredPass),
  528. RequiredNotPassCount = g.Count(x => x.RequiredNotPass),
  529. RequiredNotPassCourseList = g.Where(x => x.RequiredNotPass).Select(x => x.CourseName).ToList(),
  530. OptionalPassCount = g.Count(x => x.OptionalCoursePass) + g.Count(x => x.FreeSelectionCoursePass),
  531. OptionalNotPassCount = g.Count(x => x.OptionalCourseNotPass) + g.Count(x => x.FreeSelectionCourseNotPass),
  532. TotalCredit = g.Sum(x => x.ScoreCredit)
  533. };
  534. return query;
  535. }
  536. /// <summary>
  537. /// 查询对应的毕业学生成绩信息StudentScoreView(根据学生信息)
  538. /// 注:同一学生成绩库中,相同的课程信息只取课程类型最大的学分(只取一门课程,用户ID、课程信息ID分组)
  539. /// </summary>
  540. /// <param name="expStudent"></param>
  541. /// <returns></returns>
  542. public IQueryable<StudentScoreView> GetGradStudentScoreViewQueryable(Expression<Func<CF_Student, bool>> expStudent)
  543. {
  544. var lastScoreList = from stusco in this.GetFinallyScoreViewQueryable(expStudent)
  545. join couset in CourseTypeSelectCourseTypeRepository.Entities
  546. on stusco.CourseTypeID equals couset.CourseTypeID
  547. into tempcouset
  548. from stucouset in tempcouset.DefaultIfEmpty()
  549. join grsco in
  550. (
  551. from finsco in this.GetFinallyScoreViewQueryable(expStudent)
  552. join set in CourseTypeSelectCourseTypeRepository.Entities
  553. on finsco.CourseTypeID equals set.CourseTypeID
  554. into tempset
  555. from couset in tempset.DefaultIfEmpty()
  556. group new { Score = finsco, SelectCourseType = couset }
  557. by new { finsco.UserID, finsco.CoursematerialID }
  558. into g
  559. select new
  560. {
  561. g.Key.UserID,
  562. g.Key.CoursematerialID,
  563. IsRequired = g.Max(x => x.SelectCourseType.IsRequired.Value ? 1 : 0) == 1,
  564. MaxCreateTime = (g.Max(x => x.SelectCourseType.IsRequired.Value ? 1 : 0) == 1)
  565. ? g.Max(x => (x.SelectCourseType.IsRequired.Value) ? x.Score.CreateTime : null)
  566. : g.Max(x => x.Score.CreateTime)
  567. }
  568. )
  569. on
  570. new { UserID = stusco.UserID, CoursematerialID = stusco.CoursematerialID, IsRequired = stucouset.IsRequired.Value, CreateTime = stusco.CreateTime }
  571. equals
  572. new { UserID = grsco.UserID, CoursematerialID = grsco.CoursematerialID, IsRequired = grsco.IsRequired, CreateTime = grsco.MaxCreateTime }
  573. group stusco by new { stusco.UserID, stusco.CoursematerialID, stusco.StarttermID, stusco.CreateTime }
  574. into g
  575. select g.Max(x => x.FinallyScoreID.ToString());
  576. var query = from finsco in this.GetFinallyScoreViewQueryable(expStudent)
  577. join lsl in lastScoreList
  578. on finsco.FinallyScoreID.ToString() equals lsl
  579. select finsco;
  580. return query;
  581. }
  582. /// <summary>
  583. /// 查询对应的毕业学生成绩学分信息PersonalCreditView(根据学生信息)
  584. /// 注:同一学生成绩库中,相同的课程信息只取课程类型最大的学分(只取一门课程,用户ID、课程信息ID分组)
  585. /// </summary>
  586. /// <param name="expStudent"></param>
  587. /// <returns></returns>
  588. public IQueryable<PersonalCreditView> GetGradStudentScoreCreditViewQueryable(Expression<Func<CF_Student, bool>> expStudent)
  589. {
  590. //学分统计
  591. var stuCreditList = from stusco in this.GetGradStudentScoreViewQueryable(expStudent)
  592. join couset in CourseTypeSelectCourseTypeRepository.Entities
  593. on stusco.CourseTypeID equals couset.CourseTypeID
  594. into tempcouset
  595. from stucouset in tempcouset.DefaultIfEmpty()
  596. join grset in GraduationCourseTypeSettingRepository.Entities
  597. on stusco.CourseTypeID equals grset.CourseTypeID
  598. into tempgrset
  599. from stugrset in tempgrset.DefaultIfEmpty()
  600. join club in ClubCourseRepository.Entities
  601. on stusco.CoursematerialID equals club.CoursematerialID
  602. into tempclub
  603. from stuclub in tempclub.DefaultIfEmpty()
  604. group new { stusco, stucouset, stugrset, stuclub } by stusco.UserID into g
  605. select new
  606. {
  607. UserID = g.Key,
  608. //必修学分
  609. RequiredCredit = g.Sum(x => (x.stucouset.IsRequired.Value ? (x.stusco.ScoreCredit ?? 0) : 0)),
  610. //限选学分
  611. OptionalCredit = g.Sum(x => (x.stucouset.IsOptionalCourse.Value ? (x.stusco.ScoreCredit ?? 0) : 0)),
  612. //任选学分
  613. FreeSelectionCredit = g.Sum(x => (x.stucouset.IsFreeSelectionCourse.Value ? (x.stusco.ScoreCredit ?? 0) : 0)),
  614. //方向选修学分
  615. ElectiveCredit = g.Sum(x => (x.stugrset.IsElective.Value ? (x.stusco.ScoreCredit ?? 0) : 0)),
  616. //公共选修学分
  617. ElectivePublicCredit = g.Sum(x => (x.stugrset.IsElectivePublic.Value ? (x.stusco.ScoreCredit ?? 0) : 0)),
  618. //通识教育学分
  619. GeneralEducationCredit = g.Sum(x => (x.stugrset.IsGeneralEducation.Value ? (x.stusco.ScoreCredit ?? 0) : 0)),
  620. //校本学分(不包含俱乐部)
  621. SchoolbasedNoClubCredit = g.Sum(x => ((x.stugrset.IsSchoolbasedCurriculum.Value && x.stuclub.ClubCourseID == null) ? (x.stusco.ScoreCredit ?? 0) : 0)),
  622. //校本学分(只包含俱乐部)
  623. SchoolbasedClubCredit = g.Sum(x => ((x.stugrset.IsSchoolbasedCurriculum.Value && x.stuclub.ClubCourseID != null) ? (x.stusco.ScoreCredit ?? 0) : 0)),
  624. //实践环节学分(不包含俱乐部)
  625. PractiseNoClubCredit = g.Sum(x => ((x.stugrset.IsPractise.Value && x.stuclub.ClubCourseID == null) ? (x.stusco.ScoreCredit ?? 0) : 0)),
  626. //实践环节学分(只包含俱乐部)
  627. PractiseClubCredit = g.Sum(x => ((x.stugrset.IsPractise.Value && x.stuclub.ClubCourseID != null) ? (x.stusco.ScoreCredit ?? 0) : 0))
  628. };
  629. var query = from stu in this.GetBaseStudentViewQueryable(expStudent)
  630. join scl in stuCreditList
  631. on stu.UserID equals scl.UserID into tempscl
  632. from stuscl in tempscl.DefaultIfEmpty()
  633. select new PersonalCreditView
  634. {
  635. UserID = stu.UserID,
  636. StudentNo = stu.LoginID,
  637. UserName = stu.UserName,
  638. SexID = stu.SexID,
  639. InSchoolStatusID = stu.InSchoolStatusID,
  640. StudentStatusID = stu.StudentStatus,
  641. ClassID = stu.ClassmajorID,
  642. ClassNo = stu.ClassmajorCode,
  643. ClassName = stu.ClassmajorName,
  644. GrademajorID = stu.GrademajorID,
  645. GrademajorCode = stu.GrademajorCode,
  646. GrademajorName = stu.GrademajorName,
  647. FacultymajorID = stu.FacultymajorID,
  648. FacultymajorNo = stu.FacultymajorCode,
  649. FacultymajorName = stu.FacultymajorName,
  650. StandardID = stu.StandardID,
  651. CollegeID = stu.CollegeID,
  652. CollegeNo = stu.CollegeNo,
  653. CollegeName = stu.CollegeName,
  654. RequiredCredit = stuscl.RequiredCredit == null ? 0 : stuscl.RequiredCredit,
  655. OptionalCourseCredit = stuscl.OptionalCredit == null ? 0 : stuscl.OptionalCredit,
  656. FreeSelectionCourseCredit = stuscl.FreeSelectionCredit == null ? 0 : stuscl.FreeSelectionCredit,
  657. ElectiveCredit = stuscl.ElectiveCredit == null ? 0 : stuscl.ElectiveCredit,
  658. ElectivePublicCredit = stuscl.ElectivePublicCredit == null ? 0 : stuscl.ElectivePublicCredit,
  659. GeneralEducationCredit = stuscl.GeneralEducationCredit == null ? 0 : stuscl.GeneralEducationCredit,
  660. SchoolbasedNoClubCredit = stuscl.SchoolbasedNoClubCredit == null ? 0 : stuscl.SchoolbasedNoClubCredit,
  661. SchoolbasedClubCredit = stuscl.SchoolbasedClubCredit == null ? 0 : stuscl.SchoolbasedClubCredit,
  662. PractiseNoClubCredit = stuscl.PractiseNoClubCredit == null ? 0 : stuscl.PractiseNoClubCredit,
  663. PractiseClubCredit = stuscl.PractiseClubCredit == null ? 0 : stuscl.PractiseClubCredit
  664. };
  665. return query;
  666. }
  667. /// <summary>
  668. /// 查询对应的毕业设计课程成绩信息StudentScoreView(根据学生信息)
  669. /// 注:根据毕业设计课程设置信息表中课程信息、课程类型进行内联(学分、学时暂时不考虑)
  670. /// </summary>
  671. /// <param name="expStudent"></param>
  672. /// <returns></returns>
  673. public IQueryable<GraduateDesignCourseScoreView> GetGraduateDesignCourseViewQueryable(Expression<Func<CF_Student, bool>> expStudent)
  674. {
  675. var query = from finsco in FinallyScoreRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE)
  676. join gradc in GraduateDesignCoursematerialRepository.Entities
  677. on new { CoursematerialID = finsco.CoursematerialID, CourseTypeID = finsco.CourseTypeID }
  678. equals
  679. new { CoursematerialID = gradc.CoursematerialID, CourseTypeID = gradc.CourseTypeID }
  680. join stu in this.GetBaseStudentViewQueryable(expStudent)
  681. on finsco.UserID equals stu.UserID
  682. join sy in SchoolyearRepository.Entities
  683. on finsco.SchoolyearID equals sy.SchoolyearID
  684. join cou in CoursematerialRepository.Entities
  685. on finsco.CoursematerialID equals cou.CoursematerialID
  686. select new GraduateDesignCourseScoreView
  687. {
  688. FinallyScoreID = finsco.FinallyScoreID,
  689. SchoolyearID = finsco.SchoolyearID,
  690. SchoolyearCode = sy.Code,
  691. UserID = finsco.UserID,
  692. LoginID = stu.LoginID,
  693. UserName = stu.UserName,
  694. ClassmajorID = stu.ClassmajorID,
  695. ClassmajorCode = stu.ClassmajorCode,
  696. ClassmajorName = stu.ClassmajorName,
  697. GrademajorID = stu.GrademajorID,
  698. GrademajorCode = stu.GrademajorCode,
  699. GrademajorName = stu.GrademajorName,
  700. CoursematerialID = finsco.CoursematerialID,
  701. CourseCode = cou.CourseCode,
  702. CourseName = cou.CourseName,
  703. CourseTypeID = finsco.CourseTypeID,
  704. Credit = finsco.Credit,
  705. Totalhours = finsco.TotalHours,
  706. ExamsCategoryID = finsco.ExamsCategoryID,
  707. ExamsStateID = finsco.ExamsStateID,
  708. TotalScore = finsco.TotalScore,
  709. ScoreCredit = finsco.ScoreCredit,
  710. SchoolyearNumID = finsco.SchoolyearNumID,
  711. StarttermID = finsco.StarttermID,
  712. ResultTypeID = finsco.ResultTypeID,
  713. CreateUserID = finsco.CreateUserID,
  714. CreateTime = finsco.CreateTime
  715. };
  716. return query;
  717. }
  718. /// <summary>
  719. /// 查询对应的毕业课程信息GraduationCourseView(根据学生信息)
  720. /// </summary>
  721. /// <param name="expStudent"></param>
  722. /// <returns></returns>
  723. public IQueryable<GraduationCourseView> GetGraduationCourseViewQueryable(Expression<Func<CF_Student, bool>> expStudent)
  724. {
  725. var query = from gc in GraduationCourseRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE)
  726. join stu in this.GetBaseStudentViewQueryable(expStudent)
  727. on gc.GrademajorID equals stu.GrademajorID
  728. join cou in CoursematerialRepository.Entities
  729. on gc.CoursematerialID equals cou.CoursematerialID
  730. select new GraduationCourseView
  731. {
  732. GraduationCourseID = gc.GraduationCourseID,
  733. GrademajorID = stu.GrademajorID,
  734. GrademajorCode = stu.GrademajorCode,
  735. GrademajorName = stu.GrademajorName,
  736. SchoolyearID = stu.SchoolyearID,
  737. SchoolcodeID = stu.SchoolcodeID,
  738. CoursematerialID = gc.CoursematerialID,
  739. CourseCode = cou.CourseCode,
  740. CourseName = cou.CourseName,
  741. CourseTypeID = gc.CourseTypeID,
  742. CourseCredit = gc.CourseCredit
  743. };
  744. return query;
  745. }
  746. /// <summary>
  747. /// 查询对应的类型(课程类型)学分信息CourseTypeRequirementView(根据学生信息)
  748. /// </summary>
  749. /// <param name="expStudent"></param>
  750. /// <returns></returns>
  751. public IQueryable<CourseTypeRequirementView> GetGradCourseTypeRequirementViewQueryable(Expression<Func<CF_Student, bool>> expStudent)
  752. {
  753. var query = from gct in GraduationCourseTypeRequirementRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE)
  754. join stu in this.GetBaseStudentViewQueryable(expStudent)
  755. on gct.GrademajorID equals stu.GrademajorID
  756. join cs in CourseTypeSelectCourseTypeRepository.Entities
  757. on gct.CourseTypeID equals cs.CourseTypeID
  758. into tempcs
  759. from couset in tempcs.DefaultIfEmpty()
  760. join gs in GraduationCourseTypeSettingRepository.Entities
  761. on gct.CourseTypeID equals gs.CourseTypeID
  762. into tempgs
  763. from grset in tempgs.DefaultIfEmpty()
  764. select new CourseTypeRequirementView
  765. {
  766. GraduationCourseTypeRequirementID = gct.GraduationCourseTypeRequirementID,
  767. GrademajorID = gct.GrademajorID,
  768. GrademajorCode = stu.GrademajorCode,
  769. GrademajorName = stu.GrademajorName,
  770. SchoolyearID = stu.SchoolyearID,
  771. SchoolcodeID = stu.SchoolcodeID,
  772. CourseTypeID = gct.CourseTypeID,
  773. IsRequired = couset.IsRequired,
  774. IsOptionalCourse = couset.IsOptionalCourse,
  775. IsFreeSelectionCourse = couset.IsFreeSelectionCourse,
  776. IsElective = grset.IsElective,
  777. IsElectivePublic = grset.IsElectivePublic,
  778. IsGeneralEducation = grset.IsGeneralEducation,
  779. IsSchoolbasedCurriculum = grset.IsSchoolbasedCurriculum,
  780. IsPractise = grset.IsPractise,
  781. TotalCredit = gct.TotalCredit
  782. };
  783. return query;
  784. }
  785. /// <summary>
  786. /// 查询对应的毕业学生课程类型学分信息PersonalCourseTypeCreditView(根据学生信息,用户ID、课程类型分组)
  787. /// </summary>
  788. /// <param name="expStudent"></param>
  789. /// <returns></returns>
  790. public IQueryable<PersonalCourseTypeCreditView> GetGradStudentCourseTypeCreditViewQueryable(Expression<Func<CF_Student, bool>> expStudent)
  791. {
  792. var query = from stusco in this.GetGradStudentScoreViewQueryable(expStudent)
  793. join cs in CourseTypeSelectCourseTypeRepository.Entities
  794. on stusco.CourseTypeID equals cs.CourseTypeID
  795. into tempcs
  796. from couset in tempcs.DefaultIfEmpty()
  797. join gs in GraduationCourseTypeSettingRepository.Entities
  798. on stusco.CourseTypeID equals gs.CourseTypeID
  799. into tempgs
  800. from grset in tempgs.DefaultIfEmpty()
  801. group new { ss = stusco, cs = couset, gs = grset }
  802. by new { stusco.UserID, stusco.GrademajorID, stusco.CourseTypeID } into g
  803. select new PersonalCourseTypeCreditView
  804. {
  805. UserID = g.Key.UserID,
  806. GrademajorID = g.Key.GrademajorID,
  807. CourseTypeID = g.Key.CourseTypeID,
  808. IsRequired = g.Max(x => x.cs.IsRequired.Value ? 1 : 0) == 1,
  809. IsOptionalCourse = g.Max(x => x.cs.IsOptionalCourse.Value ? 1 : 0) == 1,
  810. IsFreeSelectionCourse = g.Max(x => x.cs.IsFreeSelectionCourse.Value ? 1 : 0) == 1,
  811. IsElective = g.Max(x => x.gs.IsElective.Value ? 1 : 0) == 1,
  812. IsElectivePublic = g.Max(x => x.gs.IsElectivePublic.Value ? 1 : 0) == 1,
  813. IsGeneralEducation = g.Max(x => x.gs.IsGeneralEducation.Value ? 1 : 0) == 1,
  814. IsSchoolbasedCurriculum = g.Max(x => x.gs.IsSchoolbasedCurriculum.Value ? 1 : 0) == 1,
  815. IsPractise = g.Max(x => x.gs.IsPractise.Value ? 1 : 0) == 1,
  816. TotalCredit = g.Sum(x => x.ss.ScoreCredit)
  817. };
  818. return query;
  819. }
  820. /// <summary>
  821. /// 查询对应的毕业专业学分信息GrademajorRequirementView
  822. /// </summary>
  823. /// <param name="exp"></param>
  824. /// <returns></returns>
  825. public IQueryable<GrademajorRequirementView> GetGradGrademajorRequirementViewQueryable(Expression<Func<CF_Student, bool>> expStudent)
  826. {
  827. var query = from gsr in GraduationRequirementRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE)
  828. join stu in this.GetBaseStudentViewQueryable(expStudent)
  829. on gsr.GrademajorID equals stu.GrademajorID
  830. select new GrademajorRequirementView
  831. {
  832. GraduationRequirementID = gsr.GraduationRequirementID,
  833. GrademajorID = gsr.GrademajorID,
  834. GrademajorCode = stu.GrademajorCode,
  835. GrademajorName = stu.GrademajorName,
  836. SchoolyearID = stu.SchoolyearID,
  837. SchoolcodeID = stu.SchoolcodeID,
  838. OptionalCourseCredit = gsr.OptionalCourseCredit,
  839. RequiredCredit = gsr.RequiredCredit,
  840. TotalCredit = gsr.TotalCredit
  841. };
  842. return query;
  843. }
  844. /// <summary>
  845. /// 查询对应的毕业标准信息GraduationStandardView
  846. /// </summary>
  847. /// <param name="exp"></param>
  848. /// <returns></returns>
  849. public IQueryable<GraduationStandardView> GetGraduationStandardViewQueryable(Expression<Func<CF_Student, bool>> expStudent)
  850. {
  851. var query = from gs in GraduationStandardRepository.GetList(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE)
  852. join stu in this.GetBaseStudentViewQueryable(expStudent)
  853. on gs.GrademajorID equals stu.GrademajorID
  854. join execnum in
  855. (
  856. //执行计划门数-执行门数
  857. from exec in ExecutablePlanRepository.Entities
  858. group exec by exec.GrademajorID into g
  859. select new
  860. {
  861. GrademajorID = g.Key,
  862. ExecCourseCount = g.Count()
  863. }
  864. )
  865. on stu.GrademajorID equals execnum.GrademajorID
  866. into tempexecnum
  867. from grexecnum in tempexecnum.DefaultIfEmpty()
  868. join execcredit in
  869. (
  870. //执行计划总学分-执行学分
  871. from exec in ExecutablePlanRepository.Entities
  872. group exec by exec.GrademajorID into g
  873. select new
  874. {
  875. GrademajorID = g.Key,
  876. ExecutableCreditTotal = g.Sum(x => x.EM_ExecutablePlanTeachingSetting.Credit.Value)
  877. }
  878. )
  879. on stu.GrademajorID equals execcredit.GrademajorID
  880. into tempexeccredit
  881. from grexeccredit in tempexeccredit.DefaultIfEmpty()
  882. select new GraduationStandardView
  883. {
  884. GraduationStandardID = gs.GraduationStandardID,
  885. GrademajorID = gs.GrademajorID,
  886. GrademajorCode = stu.GrademajorCode,
  887. GrademajorName = stu.GrademajorName,
  888. SchoolyearID = stu.SchoolyearID,
  889. SchoolcodeID = stu.SchoolcodeID,
  890. ExecCourseCount = grexecnum.ExecCourseCount == null ? 0 : grexecnum.ExecCourseCount,
  891. ExecutableCreditTotal = grexeccredit.ExecutableCreditTotal == null ? 0 : grexeccredit.ExecutableCreditTotal,
  892. RequireCourseCount = gs.RequireCourseCount,
  893. GraduationCredit = gs.GraduationCredit
  894. };
  895. return query;
  896. }
  897. /// <summary>
  898. /// 查询对应的学生欠费信息StudentArrearsView(根据学生信息)
  899. /// 注:目前欠费金额的计算不包括通过缓交申请的缓交金额
  900. /// </summary>
  901. /// <param name="expStudent"></param>
  902. /// <returns></returns>
  903. public IQueryable<StudentArrearsView> GetStudentArrearViewQueryable(Expression<Func<CF_Student, bool>> expStudent)
  904. {
  905. var query = from gr in
  906. (
  907. from stu in StudentRepository.GetList(expStudent)
  908. join sc in StudentChargeRepository.Entities
  909. on stu.UserID equals sc.UserID
  910. join stucp in
  911. (
  912. from cp in StudentChargePaymentRepository.Entities
  913. group cp by cp.StudentChargeID into g
  914. select new
  915. {
  916. StudentChargeID = g.Key,
  917. PaymentAmount = g.Sum(x => x.Amount)
  918. }
  919. )
  920. on sc.StudentChargeID equals stucp.StudentChargeID
  921. into tempcp
  922. from schcp in tempcp.DefaultIfEmpty()
  923. select new
  924. {
  925. StudentChargeID = sc.StudentChargeID,
  926. UserID = stu.UserID,
  927. ChargeYear = sc.ChargeYear,
  928. ChargeProjectID = sc.ChargeProjectID,
  929. Amount = sc.Amount,
  930. ChargeAmount = sc.ActualAmount - sc.Amount,
  931. ActualAmount = sc.ActualAmount,
  932. PaymentAmount = schcp.PaymentAmount ?? 0
  933. }
  934. )
  935. group gr by gr.UserID into g
  936. select new StudentArrearsView
  937. {
  938. UserID = g.Key,
  939. Amount = g.Sum(x => x.Amount),
  940. ChargeAmount = g.Sum(x => x.ChargeAmount),
  941. ActualAmount = g.Sum(x => x.ActualAmount),
  942. PaymentAmount = g.Sum(x => x.PaymentAmount),
  943. AmountSum = (g.Sum(x => x.ActualAmount) ?? 0) - g.Sum(x => x.PaymentAmount)
  944. };
  945. return query;
  946. }
  947. /// <summary>
  948. /// 查询对应的学生欠费信息ArrearsListView(根据学生信息)
  949. /// 注:目前欠费金额的计算不包括通过缓交申请的缓交金额
  950. /// </summary>
  951. /// <param name="expStudent"></param>
  952. /// <returns></returns>
  953. public IQueryable<ArrearsListView> GetArrearsListViewQueryable(Expression<Func<CF_Student, bool>> expStudent)
  954. {
  955. var query = from stu in StudentRepository.GetList(expStudent)
  956. join cl in ClassmajorRepository.Entities
  957. on stu.ClassmajorID equals cl.ClassmajorID
  958. join gr in GrademajorRepository.Entities
  959. on cl.GrademajorID equals gr.GrademajorID
  960. join fa in FacultymajorRepository.Entities
  961. on gr.FacultymajorID equals fa.FacultymajorID
  962. join us in UserRepository.Entities
  963. on stu.UserID equals us.UserID
  964. join pass in PassStudentRepository.Entities
  965. on stu.UserID equals pass.UserID
  966. into temppass
  967. from stuPass in temppass.DefaultIfEmpty()
  968. join stugr in this.GetStudentArrearViewQueryable(expStudent)
  969. on stu.UserID equals stugr.UserID
  970. into tempstuch
  971. from grstuch in tempstuch.DefaultIfEmpty()
  972. select new ArrearsListView
  973. {
  974. UserID = stu.UserID,
  975. StudentNo = us.LoginID,
  976. UserName = us.Name,
  977. SexID = stu.SexID,
  978. InSchoolStatus = stu.InSchoolStatusID,
  979. StudentStatus = stu.StudentStatus,
  980. ClassID = stu.ClassmajorID,
  981. ClassNo = cl.No,
  982. ClassName = cl.Name,
  983. GradeMajorID = cl.GrademajorID,
  984. GradeMajorCode = gr.Code,
  985. GrademajorStr = gr.Name,
  986. GradeStr = gr.GradeID,
  987. CollegeID = fa.CollegeID,
  988. CollegeCode = fa.CF_College.No,
  989. CollegeStr = fa.CF_College.Name,
  990. StandardID = fa.StandardID,
  991. EducationID = fa.EducationID,
  992. LearningformID = fa.LearningformID,
  993. LearnSystem = fa.LearnSystem,
  994. Amount = grstuch.Amount ?? 0,
  995. ChargeAmount = grstuch.ChargeAmount ?? 0,
  996. ActualAmount = grstuch.ActualAmount ?? 0,
  997. PaidAmount = grstuch.PaymentAmount ?? 0,
  998. IsArrear = (grstuch.PaymentAmount - (grstuch.ActualAmount ?? 0)) >= 0 ? 0 : 1,
  999. AmountSum = grstuch.AmountSum ?? 0,
  1000. IsControl = stuPass.UserID == null ? 1 : 0
  1001. };
  1002. return query;
  1003. }
  1004. }
  1005. }