RetakePlanResultDAL.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382
  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;
  7. using EMIS.ViewModel.RetakeManage;
  8. using EMIS.Entities;
  9. using System.Linq.Expressions;
  10. namespace EMIS.DataLogic.RetakeManage
  11. {
  12. public class RetakePlanResultDAL
  13. {
  14. public RetakeConditionRepository RetakConditionRepository { get; set; }
  15. public RetakeConditionParameterRepository RetakeConditionParameterRepository { get; set; }
  16. public RetakePlanRepository RetakePlanRepository { get; set; }
  17. public RetakePlanStudentRepository RetakePlanStudentRepository { get; set; }
  18. public RetakeExamsCatagoryRepository RetakeExamsCatagoryRepository { get; set; }
  19. public RetakePlanSettingRepository RetakePlanSettingRepository { get; set; }
  20. public RetakePlanTeachingModeTypeRepository RetakePlanTeachingModeTypeRepository { get; set; }
  21. public RetakePlanTeachingPlaceRepository RetakePlanTeachingPlaceRepository { get; set; }
  22. public RetakePlanTeachingSettingRepository RetakePlanTeachingSettingRepository { get; set; }
  23. public StudentRepository StudentRepository { get; set; }
  24. public UserRepository UserRepository { get; set; }
  25. public InSchoolSettingRepository InSchoolSettingRepository { get; set; }
  26. public ParameterRepository ParameterRepository { get; set; }
  27. public CoursematerialRepository CoursematerialRepository { get; set; }
  28. public FinallyScoreRepository FinallyScoreRepository { get; set; }
  29. public ClassmajorRepository ClassmajorRepository { get; set; }
  30. public GrademajorRepository GrademajorRepository { get; set; }
  31. public FacultymajorRepository FacultymajorRepository { get; set; }
  32. public CollegeRepository CollegeRepository { get; set; }
  33. public DepartmentRepository DepartmentRepository { get; set; }
  34. public ClassroomRepository ClassroomRepository { get; set; }
  35. public SchoolyearRepository SchoolyearRepository { get; set; }
  36. public DictionaryItemRepository DictionaryItemRepository { get; set; }
  37. public CoursesTimeRepository coursesTimeRepository { get; set; }
  38. public RetakePlanSettingSchedulingRepository RetakePlanSettingSchedulingRepository { get; set; }
  39. public RetakePlanTeacherRepository RetakePlanTeacherRepository { get; set; }
  40. /// <summary>
  41. /// 查询重修班级信息View(统计已报人数,根据重修计划相关信息)
  42. /// </summary>
  43. /// <param name="expRetakePlan"></param>
  44. /// <returns></returns>
  45. public IQueryable<RetakePlanTaskView> GetRetakePlanResultTaskView(Expression<Func<ER_RetakePlan, bool>> expRetakePlan)
  46. {
  47. var query = from rePlan in RetakePlanRepository.GetList(expRetakePlan)
  48. join cou in CoursematerialRepository.Entities
  49. on rePlan.CoursematerialID equals cou.CoursematerialID
  50. join sy in SchoolyearRepository.Entities
  51. on rePlan.SchoolyearID equals sy.SchoolyearID
  52. join reStu in
  53. (
  54. from stu in RetakePlanStudentRepository.Entities
  55. group stu by stu.RetakePlanID into g
  56. select new
  57. {
  58. RetakePlanID = g.Key,
  59. PlanNumber = g.Count()
  60. }
  61. )
  62. on rePlan.RetakePlanID equals reStu.RetakePlanID
  63. into reStuTemp
  64. from rePlanStu in reStuTemp.DefaultIfEmpty()
  65. join reSet in RetakePlanSettingRepository.Entities
  66. on rePlan.RetakePlanID equals reSet.RetakePlanID
  67. into reSetTemp
  68. from rePlanSet in reSetTemp.DefaultIfEmpty()
  69. join dep in DepartmentRepository.Entities
  70. on rePlanSet.DepartmentID equals dep.DepartmentID
  71. into reDepTemp
  72. from reDep in reDepTemp.DefaultIfEmpty()
  73. join reTeaching in RetakePlanTeachingSettingRepository.Entities
  74. on rePlan.RetakePlanID equals reTeaching.RetakePlanID
  75. into reTeachingTemp
  76. from rePlanTeaching in reTeachingTemp.DefaultIfEmpty()
  77. select new RetakePlanTaskView
  78. {
  79. RetakePlanID = rePlan.RetakePlanID,
  80. SchoolyearID = rePlan.SchoolyearID,
  81. SchoolyearCode = sy.Code,
  82. RetakeTypeID = rePlan.RetakeTypeID,
  83. ClassName = rePlan.ClassName,
  84. CoursematerialID = rePlan.CoursematerialID,
  85. CourseCode = cou.CourseCode,
  86. CourseName = cou.CourseName,
  87. DepartmentID = rePlanSet.DepartmentID,
  88. DepartmentCode = reDep.No,
  89. DepartmentName = reDep.Name,
  90. CourseCollegeID = reDep.CF_College.CollegeID,
  91. CourseCollegeNo = reDep.CF_College.No,
  92. CourseCollegeName = reDep.CF_College.Name,
  93. CourseTypeID = rePlan.CourseTypeID,
  94. Credit = rePlan.Credit ?? 0,
  95. PeopleNumlimit = rePlan.PeopleNumlimit ?? 0,
  96. PeopleNumlower = rePlan.PeopleNumlower ?? 0,
  97. TheoryCourse = rePlanTeaching.TheoryCourse ?? 0,
  98. Practicehours = rePlanTeaching.Practicehours ?? 0,
  99. Trialhours = rePlanTeaching.Trialhours ?? 0,
  100. StartWeeklyNum = rePlanTeaching.StartWeeklyNum,
  101. EndWeeklyNum = rePlanTeaching.EndWeeklyNum,
  102. PlanNumber = rePlanStu != null ? rePlanStu.PlanNumber : 0,
  103. ApplyNumber = rePlan.CF_Student.Count,
  104. RecordStatus = rePlan.RecordStatus
  105. };
  106. return query;
  107. }
  108. /// <summary>
  109. /// 查询重修班级对应的报名名单信息View(已报名,根据重修计划相关信息)
  110. /// </summary>
  111. /// <param name="expRetakePlan"></param>
  112. /// <returns></returns>
  113. public IQueryable<RetakeStudentListView> GetRetakePlanResultView(Expression<Func<ER_RetakePlan, bool>> expRetakePlan)
  114. {
  115. var query = from rePlan in RetakePlanRepository.GetList(expRetakePlan)
  116. from applyStu in rePlan.CF_Student
  117. join rePlanStu in RetakePlanStudentRepository.Entities
  118. on
  119. new { applyStu.UserID, rePlan.RetakePlanID }
  120. equals
  121. new { rePlanStu.UserID, rePlanStu.RetakePlanID }
  122. join stu in StudentRepository.Entities
  123. on rePlanStu.UserID equals stu.UserID
  124. join us in UserRepository.Entities
  125. on stu.UserID equals us.UserID
  126. join cl in ClassmajorRepository.Entities
  127. on stu.ClassmajorID equals cl.ClassmajorID
  128. join gr in GrademajorRepository.Entities
  129. on cl.GrademajorID equals gr.GrademajorID
  130. join fa in FacultymajorRepository.Entities
  131. on gr.FacultymajorID equals fa.FacultymajorID
  132. join col in CollegeRepository.Entities
  133. on fa.CollegeID equals col.CollegeID
  134. join sy in SchoolyearRepository.Entities
  135. on rePlan.SchoolyearID equals sy.SchoolyearID
  136. join cou in CoursematerialRepository.Entities
  137. on rePlan.CoursematerialID equals cou.CoursematerialID
  138. join reSet in RetakePlanSettingRepository.Entities
  139. on rePlan.RetakePlanID equals reSet.RetakePlanID
  140. into reSetTemp
  141. from rePlanSet in reSetTemp.DefaultIfEmpty()
  142. join dep in DepartmentRepository.Entities
  143. on rePlanSet.DepartmentID equals dep.DepartmentID
  144. into reDepTemp
  145. from reDep in reDepTemp.DefaultIfEmpty()
  146. select new RetakeStudentListView
  147. {
  148. RetakePlanID = rePlan.RetakePlanID,
  149. RetakePlanStudentID = rePlanStu.RetakePlanStudentID,
  150. RetakeTypeID = rePlan.RetakeTypeID,
  151. SchoolyearID = rePlan.SchoolyearID,
  152. SchoolyearCode = sy.Code,
  153. ClassName = rePlan.ClassName,
  154. CoursematerialID = rePlan.CoursematerialID,
  155. CourseCode = cou.CourseCode,
  156. CourseName = cou.CourseName,
  157. DepartmentID = rePlanSet.DepartmentID,
  158. DepartmentCode = reDep.No,
  159. DepartmentName = reDep.Name,
  160. CourseTypeID = rePlan.CourseTypeID,
  161. CourseCredit = rePlan.Credit ?? 0,
  162. SchoolyearNumID = rePlanStu.SchoolyearNumID,
  163. StarttermID = rePlanStu.StarttermID,
  164. UserID = rePlanStu.UserID,
  165. LoginID = us.LoginID,
  166. UserName = us.Name,
  167. SexID = stu.SexID,
  168. InSchoolStatusID = stu.InSchoolStatusID,
  169. StudentStatusID = stu.StudentStatus,
  170. ClassmajorID = stu.ClassmajorID,
  171. ClassmajorCode = cl.No,
  172. ClassmajorName = cl.Name,
  173. GrademajorID = cl.GrademajorID,
  174. GrademajorCode = gr.Code,
  175. GrademajorName = gr.Name,
  176. CollegeID = fa.CollegeID,
  177. CollegeNo = col.No,
  178. CollegeName = col.Name,
  179. Gradeyear = gr.GradeID,
  180. StandardID = fa.StandardID,
  181. EducationID = fa.EducationID,
  182. LearningformID = fa.LearningformID,
  183. LearnSystem = fa.LearnSystem,
  184. RecordStatus = rePlan.RecordStatus,
  185. ApplyStatus = rePlan.CF_Student.Any(x => x.UserID == rePlanStu.UserID) ? true : false
  186. };
  187. return query;
  188. }
  189. /// <summary>
  190. /// 查询重修班级对应的报名名单信息View(已报名,根据重修计划相关信息、学生信息)
  191. /// </summary>
  192. /// <param name="expRetakePlan"></param>
  193. /// <param name="expStudent"></param>
  194. /// <returns></returns>
  195. public IQueryable<RetakeStudentListView> GetRetakePlanResultStudentView(Expression<Func<ER_RetakePlan, bool>> expRetakePlan,
  196. Expression<Func<CF_Student, bool>> expStudent)
  197. {
  198. var query = from rePlan in RetakePlanRepository.GetList(expRetakePlan)
  199. from applyStu in rePlan.CF_Student
  200. join rePlanStu in RetakePlanStudentRepository.Entities
  201. on
  202. new { applyStu.UserID, rePlan.RetakePlanID }
  203. equals
  204. new { rePlanStu.UserID, rePlanStu.RetakePlanID }
  205. join stu in StudentRepository.GetList(expStudent)
  206. on rePlanStu.UserID equals stu.UserID
  207. join us in UserRepository.Entities
  208. on stu.UserID equals us.UserID
  209. join cl in ClassmajorRepository.Entities
  210. on stu.ClassmajorID equals cl.ClassmajorID
  211. join gr in GrademajorRepository.Entities
  212. on cl.GrademajorID equals gr.GrademajorID
  213. join fa in FacultymajorRepository.Entities
  214. on gr.FacultymajorID equals fa.FacultymajorID
  215. join col in CollegeRepository.Entities
  216. on fa.CollegeID equals col.CollegeID
  217. join sy in SchoolyearRepository.Entities
  218. on rePlan.SchoolyearID equals sy.SchoolyearID
  219. join cou in CoursematerialRepository.Entities
  220. on rePlan.CoursematerialID equals cou.CoursematerialID
  221. join reSet in RetakePlanSettingRepository.Entities
  222. on rePlan.RetakePlanID equals reSet.RetakePlanID
  223. into reSetTemp
  224. from rePlanSet in reSetTemp.DefaultIfEmpty()
  225. join dep in DepartmentRepository.Entities
  226. on rePlanSet.DepartmentID equals dep.DepartmentID
  227. into reDepTemp
  228. from reDep in reDepTemp.DefaultIfEmpty()
  229. select new RetakeStudentListView
  230. {
  231. RetakePlanID = rePlan.RetakePlanID,
  232. RetakePlanStudentID = rePlanStu.RetakePlanStudentID,
  233. RetakeTypeID = rePlan.RetakeTypeID,
  234. SchoolyearID = rePlan.SchoolyearID,
  235. SchoolyearCode = sy.Code,
  236. ClassName = rePlan.ClassName,
  237. CoursematerialID = rePlan.CoursematerialID,
  238. CourseCode = cou.CourseCode,
  239. CourseName = cou.CourseName,
  240. DepartmentID = rePlanSet.DepartmentID,
  241. DepartmentCode = reDep.No,
  242. DepartmentName = reDep.Name,
  243. CourseTypeID = rePlan.CourseTypeID,
  244. CourseCredit = rePlan.Credit ?? 0,
  245. SchoolyearNumID = rePlanStu.SchoolyearNumID,
  246. StarttermID = rePlanStu.StarttermID,
  247. UserID = rePlanStu.UserID,
  248. LoginID = us.LoginID,
  249. UserName = us.Name,
  250. SexID = stu.SexID,
  251. InSchoolStatusID = stu.InSchoolStatusID,
  252. StudentStatusID = stu.StudentStatus,
  253. ClassmajorID = stu.ClassmajorID,
  254. ClassmajorCode = cl.No,
  255. ClassmajorName = cl.Name,
  256. GrademajorID = cl.GrademajorID,
  257. GrademajorCode = gr.Code,
  258. GrademajorName = gr.Name,
  259. CollegeID = fa.CollegeID,
  260. CollegeNo = col.No,
  261. CollegeName = col.Name,
  262. Gradeyear = gr.GradeID,
  263. StandardID = fa.StandardID,
  264. EducationID = fa.EducationID,
  265. LearningformID = fa.LearningformID,
  266. LearnSystem = fa.LearnSystem,
  267. RecordStatus = rePlan.RecordStatus,
  268. ApplyStatus = rePlan.CF_Student.Any(x => x.UserID == rePlanStu.UserID) ? true : false
  269. };
  270. return query;
  271. }
  272. /// <summary>
  273. /// 查询重修班级对应的未报名名单信息View(未报名,根据重修计划相关信息)
  274. /// </summary>
  275. /// <param name="expRetakePlan"></param>
  276. /// <returns></returns>
  277. public IQueryable<RetakeStudentListView> GetRetakePlanResultTaskStudentView(Expression<Func<ER_RetakePlan, bool>> expRetakePlan)
  278. {
  279. var query = from rePlan in RetakePlanRepository.GetList(expRetakePlan)
  280. join rePlanStu in RetakePlanStudentRepository.Entities
  281. on rePlan.RetakePlanID equals rePlanStu.RetakePlanID
  282. join stu in StudentRepository.Entities
  283. on rePlanStu.UserID equals stu.UserID
  284. join us in UserRepository.Entities
  285. on stu.UserID equals us.UserID
  286. join cl in ClassmajorRepository.Entities
  287. on stu.ClassmajorID equals cl.ClassmajorID
  288. join gr in GrademajorRepository.Entities
  289. on cl.GrademajorID equals gr.GrademajorID
  290. join fa in FacultymajorRepository.Entities
  291. on gr.FacultymajorID equals fa.FacultymajorID
  292. join col in CollegeRepository.Entities
  293. on fa.CollegeID equals col.CollegeID
  294. join sy in SchoolyearRepository.Entities
  295. on rePlan.SchoolyearID equals sy.SchoolyearID
  296. join cou in CoursematerialRepository.Entities
  297. on rePlan.CoursematerialID equals cou.CoursematerialID
  298. join reSet in RetakePlanSettingRepository.Entities
  299. on rePlan.RetakePlanID equals reSet.RetakePlanID
  300. into reSetTemp
  301. from rePlanSet in reSetTemp.DefaultIfEmpty()
  302. join dep in DepartmentRepository.Entities
  303. on rePlanSet.DepartmentID equals dep.DepartmentID
  304. into reDepTemp
  305. from reDep in reDepTemp.DefaultIfEmpty()
  306. where !rePlan.CF_Student.Contains(stu)
  307. select new RetakeStudentListView
  308. {
  309. RetakePlanID = rePlan.RetakePlanID,
  310. RetakePlanStudentID = rePlanStu.RetakePlanStudentID,
  311. RetakeTypeID = rePlan.RetakeTypeID,
  312. SchoolyearID = rePlan.SchoolyearID,
  313. SchoolyearCode = sy.Code,
  314. ClassName = rePlan.ClassName,
  315. CoursematerialID = rePlan.CoursematerialID,
  316. CourseCode = cou.CourseCode,
  317. CourseName = cou.CourseName,
  318. DepartmentID = rePlanSet.DepartmentID,
  319. DepartmentCode = reDep.No,
  320. DepartmentName = reDep.Name,
  321. CourseTypeID = rePlan.CourseTypeID,
  322. CourseCredit = rePlan.Credit ?? 0,
  323. SchoolyearNumID = rePlanStu.SchoolyearNumID,
  324. StarttermID = rePlanStu.StarttermID,
  325. UserID = rePlanStu.UserID,
  326. LoginID = us.LoginID,
  327. UserName = us.Name,
  328. SexID = stu.SexID,
  329. InSchoolStatusID = stu.InSchoolStatusID,
  330. StudentStatusID = stu.StudentStatus,
  331. ClassmajorID = stu.ClassmajorID,
  332. ClassmajorCode = cl.No,
  333. ClassmajorName = cl.Name,
  334. GrademajorID = cl.GrademajorID,
  335. GrademajorCode = gr.Code,
  336. GrademajorName = gr.Name,
  337. CollegeID = fa.CollegeID,
  338. CollegeNo = col.No,
  339. CollegeName = col.Name,
  340. Gradeyear = gr.GradeID,
  341. StandardID = fa.StandardID,
  342. EducationID = fa.EducationID,
  343. LearningformID = fa.LearningformID,
  344. LearnSystem = fa.LearnSystem,
  345. RecordStatus = rePlan.RecordStatus,
  346. ApplyStatus = rePlan.CF_Student.Any(x => x.UserID == rePlanStu.UserID) ? true : false
  347. };
  348. return query;
  349. }
  350. /// <summary>
  351. /// 查询重修计划对应的任课教师信息
  352. /// </summary>
  353. /// <param name="exp"></param>
  354. /// <returns></returns>
  355. public IQueryable<RetakePlanTaskView> GetRetakePlanTeacherView(Expression<Func<ER_RetakePlan, bool>> exp)
  356. {
  357. var query = from plan in RetakePlanRepository.GetList(exp)
  358. join teacher in RetakePlanTeacherRepository.Entities
  359. on plan.RetakePlanID equals teacher.RetakePlanID into tmp
  360. from teacher in tmp.DefaultIfEmpty()
  361. select new RetakePlanTaskView
  362. {
  363. RetakePlanID = plan.RetakePlanID,
  364. TeacherName = teacher.CF_Staff.Sys_User.Name,
  365. TeacherUserID = teacher.UserID,
  366. TeacherUserCode = teacher.CF_Staff.StaffCode,
  367. };
  368. return query;
  369. }
  370. }
  371. }