GraduationApplyDAL.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  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.GraduationManage.GraduationManage;
  9. using EMIS.ViewModel.CultureplanManage.PlanManagement;
  10. namespace EMIS.ExtensionLogic.CommonDataLogic.GraduationManage
  11. {
  12. public class GraduationApplyDAL : EMIS.DataLogic.GraduationManage.GraduationManage.GraduationApplyDAL
  13. {
  14. public SpecialtyRepository SpecialtyRepository { get; set; }
  15. /// <summary>
  16. /// 查询对应的毕业申请信息View(需查询相关的信息,如:专业计划、执行计划、最终成绩、毕业设计、欠费信息等)
  17. /// 此为成教版本
  18. /// </summary>
  19. /// <param name="expGraduationApply"></param>
  20. /// <param name="expExecutablePlan"></param>
  21. /// <param name="expStudent"></param>
  22. /// <returns></returns>
  23. public override IQueryable<GraduationApplyView> GetGraduationApplyViewQueryable(Expression<Func<ER_GraduationApply, bool>> expGraduationApply,
  24. Expression<Func<EM_ExecutablePlan, bool>> expExecutablePlan, Expression<Func<CF_Student, bool>> expStudent)
  25. {
  26. var query = from ga in GraduationApplyRepository.GetList(expGraduationApply)
  27. join grsy in SchoolyearRepository.Entities
  28. on ga.GraduatingSemesterID equals grsy.SchoolyearID
  29. join apsy in SchoolyearRepository.Entities
  30. on ga.ApplySchoolyearID equals apsy.SchoolyearID
  31. join stu in StudentRepository.GetList(expStudent)
  32. on ga.UserID equals stu.UserID
  33. join cl in ClassmajorRepository.Entities
  34. on stu.ClassmajorID equals cl.ClassmajorID
  35. join gr in GrademajorRepository.Entities
  36. on cl.GrademajorID equals gr.GrademajorID
  37. join fa in FacultymajorRepository.Entities
  38. on gr.FacultymajorID equals fa.FacultymajorID
  39. join ets in EducationTypeSettingRepository.Entities
  40. on fa.EducationID equals ets.EducationID
  41. join col in CollegeRepository.Entities
  42. on fa.CollegeID equals col.CollegeID
  43. join cam in CampusRepository.Entities
  44. on col.CampusID equals cam.CampusID
  45. join us in UserRepository.Entities
  46. on stu.UserID equals us.UserID
  47. join gs in GraduationStandardRepository.Entities
  48. on gr.GrademajorID equals gs.GrademajorID into tempgs
  49. from gags in tempgs.DefaultIfEmpty()
  50. join assistant in UserRepository.Entities
  51. on cl.UserID equals assistant.UserID into tempassistant
  52. from usassistant in tempassistant.DefaultIfEmpty()
  53. join sye in SchoolyearRepository.Entities
  54. on new { SchoolyearID = gr.GradeID.Value, SchoolcodeID = gr.SemesterID.Value }
  55. equals new { SchoolyearID = sye.Years, SchoolcodeID = sye.SchoolcodeID } into tempsyenter
  56. from syenter in tempsyenter.DefaultIfEmpty()
  57. join spe in SpecialtyRepository.Entities
  58. on new { fa.StandardID, fa.EducationID, fa.LearningformID, fa.LearnSystem }
  59. equals new { spe.StandardID, spe.EducationID, spe.LearningformID, spe.LearnSystem }
  60. join spgr in
  61. (
  62. //专业计划(计划门数)
  63. from sp in SpecialtyPlanRepository.Entities
  64. group sp by new { sp.StartSchoolyearID, sp.SpecialtyID } into g
  65. select new
  66. {
  67. StartSchoolyearID = g.Key.StartSchoolyearID,
  68. SpecialtyID = g.Key.SpecialtyID,
  69. PlanCourseCount = g.Count()
  70. }
  71. )
  72. on new { StartSchoolyearID = syenter.SchoolyearID, SpecialtyID = spe.SpecialtyID }
  73. equals new { StartSchoolyearID = spgr.StartSchoolyearID.Value, SpecialtyID = spgr.SpecialtyID.Value } into tempspgr
  74. from gaspgr in tempspgr.DefaultIfEmpty()
  75. join epgr in
  76. (
  77. //执行计划(执行门数)
  78. from ep in ExecutablePlanRepository.GetList(expExecutablePlan)
  79. group ep by ep.GrademajorID into g
  80. select new
  81. {
  82. GrademajorID = g.Key,
  83. ExecCourseCount = g.Count()
  84. }
  85. )
  86. on gr.GrademajorID equals epgr.GrademajorID into tempepgr
  87. from gaepgr in tempepgr.DefaultIfEmpty()
  88. join fsgr in
  89. (
  90. //学生最终成绩(已修门数)
  91. from fs in FinallyScoreRepository.Entities
  92. group fs by fs.UserID into g
  93. select new
  94. {
  95. UserID = g.Key,
  96. FinallyScoreCount = g.Count()
  97. }
  98. )
  99. on stu.UserID equals fsgr.UserID into tempfsgr
  100. from gafsgr in tempfsgr.DefaultIfEmpty()
  101. join gdcgr in
  102. (
  103. //毕业设计课程(毕设成绩)
  104. //根据课程信息、课程类型进行内联(学分、学时暂时不考虑)
  105. from gdc in GraduateDesignCoursematerialRepository.Entities
  106. join cou in CoursematerialRepository.Entities
  107. on gdc.CoursematerialID equals cou.CoursematerialID
  108. join finsco in FinallyScoreRepository.Entities
  109. on new { CoursematerialID = gdc.CoursematerialID, CourseTypeID = gdc.CourseTypeID }
  110. equals new { CoursematerialID = finsco.CoursematerialID, CourseTypeID = finsco.CourseTypeID }
  111. join rtd in ResultTypeDetailRepository.Entities
  112. on gdc.ResultTypeID equals rtd.ResultTypeID into temprtd
  113. from gartd in temprtd.DefaultIfEmpty()
  114. where
  115. //大于等于且小于等于
  116. (
  117. finsco.TotalScore >= gartd.MinScore
  118. && finsco.TotalScore <= gartd.MaxScore
  119. && gartd.MinScoreOperator == "<="
  120. && gartd.MaxScoreOperator == "<="
  121. ) ||
  122. //大于等于且小于
  123. (
  124. finsco.TotalScore >= gartd.MinScore
  125. && finsco.TotalScore < gartd.MaxScore
  126. && gartd.MinScoreOperator == "<="
  127. && gartd.MaxScoreOperator == "<"
  128. ) ||
  129. //大于且小于
  130. (
  131. finsco.TotalScore > gartd.MinScore
  132. && finsco.TotalScore < gartd.MaxScore
  133. && gartd.MinScoreOperator == "<"
  134. && gartd.MaxScoreOperator == "<"
  135. ) ||
  136. //大于且小于等于
  137. (
  138. finsco.TotalScore > gartd.MinScore
  139. && finsco.TotalScore <= gartd.MaxScore
  140. && gartd.MinScoreOperator == "<"
  141. && gartd.MaxScoreOperator == "<="
  142. )
  143. select new
  144. {
  145. UserID = finsco.UserID,
  146. GraduateDesignCoursematerialID = gdc.GraduateDesignCoursematerialID,
  147. GraduateDesignCourseID = gdc.CoursematerialID,
  148. GraduateDesignCourseCode = cou.CourseCode,
  149. GraduateDesignCourseName = cou.CourseName,
  150. GradDesignScoreLevel = gartd.Name,
  151. GradDesignScore = finsco.TotalScore
  152. }
  153. )
  154. on stu.UserID equals gdcgr.UserID into tempgdc
  155. from gagdc in tempgdc.DefaultIfEmpty()
  156. join scgr in
  157. (
  158. //缴费信息(欠费金额)
  159. from sc in StudentChargeRepository.Entities
  160. join scpgr in
  161. (
  162. from scp in StudentChargePaymentRepository.Entities
  163. group scp by scp.StudentChargeID into g
  164. select new
  165. {
  166. StudentChargeID = g.Key,
  167. PaymentAmount = g.Sum(x => x.Amount)
  168. }
  169. )
  170. on sc.StudentChargeID equals scpgr.StudentChargeID into tempscp
  171. from scscp in tempscp.DefaultIfEmpty()
  172. group new { sc, scscp } by sc.UserID into g
  173. select new
  174. {
  175. UserID = g.Key,
  176. //Amount = g.Sum(x => x.sc.Amount ?? 0),
  177. //ChargeAmount = g.Sum(x => (x.sc.ActualAmount ?? 0) - (x.sc.Amount ?? 0)),
  178. //ActualAmount = g.Sum(x => x.sc.ActualAmount ?? 0),
  179. //PaymentAmount = g.Sum(x => x.scscp.PaymentAmount ?? 0),
  180. ArrearAmount = g.Sum(x => x.sc.ActualAmount ?? 0) - g.Sum(x => x.scscp.PaymentAmount ?? 0)
  181. }
  182. )
  183. on stu.UserID equals scgr.UserID into tempscgr
  184. from gascgr in tempscgr.DefaultIfEmpty()
  185. select new GraduationApplyView
  186. {
  187. GraduationApplyID = ga.GraduationApplyID,
  188. UserID = ga.UserID,
  189. StudentNo = us.LoginID,
  190. UserName = us.Name,
  191. ExamineeNum = stu.CF_Recruitstudents.ExamineeNum,
  192. IDNumber = stu.IDNumber,
  193. SexID = stu.SexID,
  194. BirthDate = stu.BirthDate,
  195. NationID = stu.NationID,
  196. PoliticsID = stu.PoliticsID,
  197. EntranceDate = stu.CF_Recruitstudents.EntranceDate,
  198. ZIPCode = stu.CF_StudentContact.ZIPCode,
  199. Telephone = stu.CF_StudentContact.Telephone,
  200. Mobile = stu.CF_StudentContact.Mobile,
  201. Address = stu.CF_StudentContact.Address,
  202. StudentTypeID = stu.StudentType,
  203. InSchoolStatusID = stu.InSchoolStatusID,
  204. StudentStatusID = stu.StudentStatus,
  205. ClassID = stu.ClassmajorID,
  206. ClassNo = cl.No,
  207. ClassName = cl.Name,
  208. GrademajorID = cl.GrademajorID,
  209. GrademajorCode = gr.Code,
  210. GrademajorName = gr.Name,
  211. FacultymajorID = fa.FacultymajorID,
  212. FacultymajorNo = fa.Code,
  213. FacultymajorName = fa.Name,
  214. CollegeID = fa.CollegeID,
  215. CollegeNo = col.No,
  216. CollegeName = col.Name,
  217. CampusID = col.CampusID,
  218. CampusNo = cam.No,
  219. CampusName = cam.Name,
  220. UniversityID = cam.UniversityID,
  221. UniversityCode = cam.CF_University.Code,
  222. UniversityName = cam.CF_University.Name,
  223. SchoolTypeID = cam.CF_University.CF_UniversityProfile.SchoolTypeID,
  224. SchoolyearID = gr.GradeID,
  225. EnteringSchoolYearID = syenter.SchoolyearID,
  226. EnteringSchoolYearCode = syenter.Code,
  227. StandardID = fa.StandardID,
  228. EducationID = fa.EducationID,
  229. EducationCode = ets.EducationCode,
  230. EducationTypeID = ets.EducationTypeID,
  231. LearningformID = fa.LearningformID,
  232. LearnSystem = fa.LearnSystem,
  233. ScienceclassID = fa.ScienceclassID,
  234. GraduationTypeID = ga.GraduationTypeID,
  235. GraduatingSemesterID = ga.GraduatingSemesterID,
  236. GraduatingSemesterCode = grsy.Code,
  237. GraduatingSemesterValue = grsy.Value,
  238. GraduationYear = grsy.Years,
  239. ApplySchoolyearID = ga.ApplySchoolyearID,
  240. ApplySchoolyearCode = apsy.Code,
  241. GraduationConditionPackageID = ga.GraduationConditionPackageID,
  242. Title = ga.ER_GraduationConditionPackage.Title,
  243. BeforeInSchoolStatusID = ga.BeforeInSchoolStatusID,
  244. BeforeStudentStatusID = ga.BeforeStudentStatusID,
  245. PlanCourseCount = gaspgr.PlanCourseCount == null ? 0 : gaspgr.PlanCourseCount,
  246. ExecCourseCount = gaepgr.ExecCourseCount == null ? 0 : gaepgr.ExecCourseCount,
  247. FinallyScoreCount = gafsgr.FinallyScoreCount == null ? 0 : gafsgr.FinallyScoreCount,
  248. GraduateDesignCoursematerialID = gagdc.GraduateDesignCoursematerialID,
  249. GraduateDesignCourseID = gagdc.GraduateDesignCourseID,
  250. GraduateDesignCourseCode = gagdc.GraduateDesignCourseCode,
  251. GraduateDesignCourseName = gagdc.GraduateDesignCourseName,
  252. GradDesignScoreLevel = gagdc.GradDesignScoreLevel == null ? "未录入" : gagdc.GradDesignScoreLevel,
  253. GradDesignScore = gagdc.GradDesignScore,
  254. ArrearAmount = gascgr.ArrearAmount == null ? 0 : gascgr.ArrearAmount,
  255. RequireCourseCount = gags.RequireCourseCount == null ? 0 : gags.RequireCourseCount,
  256. GraduationCredit = gags.GraduationCredit == null ? 0 : gags.GraduationCredit,
  257. ApprovalStatus = ga.ApprovalStatus,
  258. GraduationResult = ga.GraduationResult,
  259. ApprovalResult = ga.ApprovalResult,
  260. GraduateCardNo = stu.GraduateCardNo,
  261. ReplaceGraduateNo = stu.ReplaceGraduateNo,
  262. RecordStatus = ga.RecordStatus,
  263. Remark = ga.Remark,
  264. CreateUserID = ga.CreateUserID,
  265. CreateTime = ga.CreateTime,
  266. ModifyUserID = ga.ModifyUserID,
  267. ModifyTime = ga.ModifyTime
  268. };
  269. return query;
  270. }
  271. /// <summary>
  272. /// 查询毕业申请对应的专业计划信息
  273. /// 此为成教版本
  274. /// </summary>
  275. /// <param name="exp"></param>
  276. /// <returns></returns>
  277. public override IQueryable<SpecialtyPlanView> GetSpecialtyPlanViewQueryable(Expression<Func<ER_GraduationApply, bool>> exp)
  278. {
  279. var query = from ga in GraduationApplyRepository.GetList(exp)
  280. join stu in StudentRepository.Entities
  281. on ga.UserID equals stu.UserID
  282. join cl in ClassmajorRepository.Entities
  283. on stu.ClassmajorID equals cl.ClassmajorID
  284. join gr in GrademajorRepository.Entities
  285. on cl.GrademajorID equals gr.GrademajorID
  286. join fa in FacultymajorRepository.Entities
  287. on gr.FacultymajorID equals fa.FacultymajorID
  288. join col in CollegeRepository.Entities
  289. on fa.CollegeID equals col.CollegeID
  290. join spe in SpecialtyRepository.Entities
  291. on new { fa.StandardID, fa.EducationID, fa.LearningformID, fa.LearnSystem }
  292. equals new { spe.StandardID, spe.EducationID, spe.LearningformID, spe.LearnSystem }
  293. join sye in SchoolyearRepository.Entities
  294. on new { SchoolyearID = gr.GradeID.Value, SchoolcodeID = gr.SemesterID.Value }
  295. equals new { SchoolyearID = sye.Years, SchoolcodeID = sye.SchoolcodeID } into tempsyenter
  296. from syenter in tempsyenter.DefaultIfEmpty()
  297. join sp in SpecialtyPlanRepository.Entities
  298. on new { StartSchoolyearID = syenter.SchoolyearID, SpecialtyID = spe.SpecialtyID }
  299. equals new { StartSchoolyearID = sp.StartSchoolyearID.Value, SpecialtyID = sp.SpecialtyID.Value }
  300. join sy in SchoolyearRepository.Entities
  301. on sp.SchoolyearID equals sy.SchoolyearID
  302. join cou in CoursematerialRepository.Entities
  303. on sp.CoursematerialID equals cou.CoursematerialID
  304. join depcou in DepartmentRepository.Entities
  305. on sp.DepartmentID equals depcou.DepartmentID into tempdepcou
  306. from spdepcou in tempdepcou.DefaultIfEmpty()
  307. select new SpecialtyPlanView
  308. {
  309. SpecialtyPlanID = sp.SpecialtyPlanID,
  310. SchoolyearID = sp.SchoolyearID,
  311. SchoolyearCode = sy.Code,
  312. GrademajorID = sp.GrademajorID,
  313. GrademajorCode = gr.Code,
  314. GrademajorName = gr.Name,
  315. CollegeID = fa.CollegeID,
  316. CollegeCode = col.No,
  317. CollegeName = col.Name,
  318. CoursematerialID = sp.CoursematerialID,
  319. CourseCode = cou.CourseCode,
  320. CourseName = cou.CourseName,
  321. CourseStructureID = sp.CourseStructureID,
  322. CourseCategoryID = sp.CourseCategoryID,
  323. CourseTypeID = sp.CourseTypeID,
  324. CourseQualityID = sp.CourseQualityID,
  325. ResultTypeID = sp.ResultTypeID,
  326. PracticeTypeID = sp.PracticeTypeID,
  327. ExaminationModeID = sp.ExaminationModeID,
  328. TeachinglanguageID = sp.TeachinglanguageID,
  329. CourseFineID = sp.CourseFineID,
  330. IsSpecialtycore = sp.IsSpecialtycore ?? false,
  331. IsCooperation = sp.IsCooperation ?? false,
  332. IsRequired = sp.IsRequired ?? false,
  333. IsElective = sp.IsElective ?? false,
  334. IsNetworkCourse = sp.IsNetworkCourse ?? false,
  335. IsMainCourse = sp.IsMainCourse ?? false,
  336. Credit = sp.EM_SpecialtyPlanTeachingSetting.Credit ?? 0,
  337. TheoryCourse = sp.EM_SpecialtyPlanTeachingSetting.TheoryCourse ?? 0,
  338. Practicehours = sp.EM_SpecialtyPlanTeachingSetting.Practicehours ?? 0,
  339. Trialhours = sp.EM_SpecialtyPlanTeachingSetting.Trialhours ?? 0,
  340. Totalhours = (sp.EM_SpecialtyPlanTeachingSetting.TheoryCourse ?? 0) + (sp.EM_SpecialtyPlanTeachingSetting.Practicehours ?? 0),
  341. SchoolyearNumID = (sy.Value - ((gr.GradeID * 2 - 1) + gr.SemesterID - 1)) / 2 + 1,
  342. SchoolcodeID = sy.SchoolcodeID,
  343. StarttermID = sy.Value - ((gr.GradeID * 2 - 1) + gr.SemesterID - 1) + 1,
  344. DepartmentID = sp.DepartmentID,
  345. DepartmentCode = spdepcou.No,
  346. DepartmentName = spdepcou.Name,
  347. HandleModeID = sp.HandleModeID,
  348. Remark = sp.Remark,
  349. RecordStatus = sp.RecordStatus,
  350. CreateUserID = sp.CreateUserID,
  351. CreateTime = sp.CreateTime,
  352. ModifyUserID = sp.ModifyUserID,
  353. ModifyTime = sp.ModifyTime
  354. };
  355. return query;
  356. }
  357. }
  358. }