ExaminationSubjectDAL.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  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.ExaminationApply;
  7. using System.Linq.Expressions;
  8. using EMIS.Entities;
  9. using EMIS.ViewModel.Students;
  10. using EMIS.ViewModel;
  11. namespace EMIS.DataLogic.ExaminationApply
  12. {
  13. public class ExaminationSubjectDAL
  14. {
  15. public ExaminationRegistrationRepository examinationRegistrationRepository { get; set; }
  16. public ExaminationProjectRepository examinationProjectRepository { get; set; }
  17. public ExaminationProjectFeeRepository examinationProjectFeeRepository { get; set; }
  18. public ExaminationProjectFeeTypeRepository examinationProjectFeeTypeRepository { get; set; }
  19. public ExaminationBatchProjectRepository examinationBatchProjectRepository { get; set; }
  20. public ExaminationBatchRepository examinationBatchRepository { get; set; }
  21. public ExaminationRegistrationConfirmRepository examinationRegistrationConfirmRepository { get; set; }
  22. public ExaminationBatchProjectControlRepository examinationBatchProjectControlRepository { get; set; }
  23. public ExaminationBatchProjectPersonControlRepository examinationBatchProjectPersonControlRepository { get; set; }
  24. public ExaminationTypeRepository examinationTypeRepository { get; set; }
  25. public SchoolyearRepository SchoolyearRepository { get; set; }
  26. public ClassmajorRepository classmajorRepository { get; set; }
  27. public GrademajorRepository grademajorRepository { get; set; }
  28. public FacultymajorRepository facultymajorRepository { get; set; }
  29. public StudentRepository studentRepository { get; set; }
  30. public StudentProfileRepository studentProfileRepository { get; set; }
  31. public RecruitstudentsRepository recruitstudentsRepository { get; set; }
  32. public DictionaryItemRepository dictionaryItemRepository { get; set; }
  33. public SchoolyearRepository schoolyearRepository { get; set; }
  34. public CollegeRepository collegeRepository { get; set; }
  35. public CampusRepository campusRepository { get; set; }
  36. public UniversityRepository universityRepository { get; set; }
  37. public WechatPayListRepository wechatPayListRepository { get; set; }
  38. public ExaminationProjectSubjectRepository examinationProjectSubjectRepository { get; set; }
  39. public IQueryable<StudentListView> GetStudentListView(Expression<Func<EX_ExaminationRegistration, bool>> erexp, Expression<Func<EX_ExaminationProject, bool>> epexp,
  40. Expression<Func<EX_ExaminationBatchProject, bool>> ebpexp, Expression<Func<CF_Student, bool>> stuexp)
  41. {
  42. var currentSchoolyear = schoolyearRepository.Entities.Where(x => x.IsCurrent == true).FirstOrDefault();
  43. var query = from regist in examinationRegistrationRepository.GetList(erexp)
  44. from wplr in wechatPayListRepository.Entities.Where(x => x.ExaminationRegistrationID == regist.ExaminationRegistrationID).DefaultIfEmpty()
  45. from batchProject in examinationBatchProjectRepository.Entities.Where(ebpexp).Where(x => regist.ExaminationBatchProjectID == x.ExaminationBatchProjectID)
  46. from feeType in examinationProjectFeeTypeRepository.Entities.Where(x => regist.ExaminationProjectFeeTypeID == x.ExaminationProjectFeeTypeID)
  47. from fee in examinationProjectFeeRepository.Entities.Where(x => feeType.ExaminationProjectFeeID == x.ExaminationProjectFeeID)
  48. from personalControl in examinationBatchProjectPersonControlRepository.Entities.Where(x => x.ExaminationBatchProjectID == regist.ExaminationBatchProjectID
  49. && x.ExaminationProjectFeeID == feeType.ExaminationProjectFeeID && x.UserID == regist.UserID).DefaultIfEmpty()
  50. from batchControl in examinationBatchProjectControlRepository.Entities.Where(x => x.ExaminationBatchProjectID == regist.ExaminationBatchProjectID
  51. && x.ExaminationProjectFeeID == feeType.ExaminationProjectFeeID && x.SchoolyearID == null && x.StandardID == null && x.CollegeID == null).DefaultIfEmpty()
  52. //join ebpcr in examinationBatchProjectControlRepository.Entities
  53. //on new { err.ExaminationBatchProjectID, epft.ExaminationProjectFeeID } equals new { ebpcr.ExaminationBatchProjectID, ebpcr.ExaminationProjectFeeID }
  54. //into gebpcr
  55. //from ebpcr in gebpcr.DefaultIfEmpty()
  56. from project in examinationProjectRepository.Entities.Where(epexp).Where(x => batchProject.ExaminationProjectID == x.ExaminationProjectID)
  57. from type in examinationTypeRepository.Entities.Where(x => project.ExaminationTypeID == x.ExaminationTypeID)
  58. from batch in examinationBatchRepository.Entities.Where(x => batchProject.ExaminationBatchID == x.ExaminationBatchID)
  59. from schoolyear in SchoolyearRepository.Entities.Where(x => batch.SchoolyearID == x.SchoolyearID)
  60. from confirm in examinationRegistrationConfirmRepository.Entities.Where(x => regist.ExaminationRegistrationConfirmID == x.ExaminationRegistrationConfirmID)
  61. .DefaultIfEmpty()
  62. from student in studentRepository.Entities.Where(stuexp).Where(x => regist.UserID == x.UserID)
  63. from classmajor in classmajorRepository.Entities.Where(x => student.ClassmajorID == x.ClassmajorID)
  64. from grade in grademajorRepository.Entities.Where(x => classmajor.GrademajorID == x.GrademajorID)
  65. from gradeYear in schoolyearRepository.Entities.Where(x => x.SchoolcodeID == grade.SchoolcodeID && x.Years == grade.SchoolyearID).DefaultIfEmpty()
  66. from faculty in facultymajorRepository.Entities.Where(x => grade.FacultymajorID == x.FacultymajorID)
  67. from collegeControl in examinationBatchProjectControlRepository.Entities.Where(x => x.ExaminationBatchProjectID == regist.ExaminationBatchProjectID
  68. && x.ExaminationProjectFeeID == feeType.ExaminationProjectFeeID && x.SchoolyearID == grade.SchoolyearID && x.StandardID == faculty.StandardID
  69. && x.CollegeID == faculty.CollegeID).DefaultIfEmpty()
  70. select new StudentListView
  71. {
  72. ExaminationRegistrationID = regist.ExaminationRegistrationID,
  73. SchoolyearID = batch.SchoolyearID,
  74. SchoolyearCode = schoolyear.Code,
  75. ExaminationProjectFeeID = feeType.ExaminationProjectFeeID,
  76. ExaminationProjectFeeName = fee.Name,
  77. ExaminationProjectFeeTypeID = regist.ExaminationProjectFeeTypeID,
  78. ExaminationBatchProjectID = batchProject.ExaminationBatchProjectID,
  79. ExaminationBatchID = batchProject.ExaminationBatchID,
  80. ExaminationBatchName = batch.Name,
  81. ExaminationTypeID = project.ExaminationTypeID,
  82. ExaminationTypeName = type.Name,
  83. ExaminationProjectID = batchProject.ExaminationProjectID,
  84. ExaminationProjectName = project.Name,
  85. ExaminationLevelID = project.ExaminationLevelID,
  86. Value = feeType.FeeTypeID,
  87. FeeTypeID = feeType.FeeTypeID,
  88. Fee = feeType.Fee,
  89. PayFee = regist.Fee,
  90. ClassmajorID = classmajor.ClassmajorID,
  91. ClassmajorName = classmajor.Name,
  92. ClassmajorNo = classmajor.No,
  93. UserID = regist.UserID,
  94. UserName = student.Sys_User.Name,
  95. Sex = student.Sex,
  96. CertificatesType = student.CertificatesType,
  97. IDNumber = student.IDNumber,
  98. CollegeID = grade.CF_Facultymajor.CollegeID,
  99. CollegeName = grade.CF_Facultymajor.CF_College.Name,
  100. StudentNo = student.StudentCardNo,
  101. ExaminationRegistrationConfirmID = confirm.ExaminationRegistrationConfirmID,
  102. ExaminationRegistrationConfirmNo = confirm.No,
  103. Remark = regist.Remark,
  104. RefundReason = regist.RefundReason,
  105. RecordStatus = regist.RecordStatus,
  106. StartDate = personalControl != null ? personalControl.StartDate : batchProject.StartDate,
  107. EndDate = personalControl != null ? personalControl.EndDate : batchProject.EndDate,
  108. SchoolyearNumID = gradeYear == null ? null : ((currentSchoolyear.Value - gradeYear.Value - (currentSchoolyear.SchoolcodeID == grade.SchoolcodeID ? 0 : 1)) / 2 + 1),
  109. SchoolAreaID = grade.SchoolAreaID,
  110. OrderID = wplr.OrderID,
  111. WechatOrderID = wplr.WechatOrderID,
  112. RefundOrderID = wplr.RefundOrderID,
  113. IsOnlinePay = (personalControl.IsOnlinePay ?? (collegeControl.IsOnlinePay ?? batchControl.IsOnlinePay)) ?? false,
  114. PayForm = wplr.PayForm,
  115. PayUrl = wplr.PayUrl
  116. };
  117. return query;
  118. }
  119. public IQueryable<StudentsView> GetStudentQueryableByRegistration(Expression<Func<EX_ExaminationRegistration, bool>> erexp)
  120. {
  121. var query = from exrr in examinationRegistrationRepository.GetList(erexp)
  122. join c in studentRepository.Entities
  123. on exrr.UserID equals c.UserID
  124. join classmajor in classmajorRepository.Entities on c.ClassmajorID equals classmajor.ClassmajorID
  125. join grade in grademajorRepository.Entities on classmajor.GrademajorID equals grade.GrademajorID
  126. join studentProfile in studentProfileRepository.Entities on c.UserID equals studentProfile.UserID
  127. into cstudentProfile
  128. from tcstudentProfile in cstudentProfile.DefaultIfEmpty()
  129. join recruitStudent in recruitstudentsRepository.Entities on c.UserID equals recruitStudent.UserID
  130. into crecruitStudent
  131. from tcrecruitStudent in crecruitStudent.DefaultIfEmpty()
  132. select new StudentsView
  133. {
  134. UserID = c.UserID,
  135. LoginID = c.Sys_User.LoginID,
  136. StudentNo = c.StudentCardNo,
  137. UserName = c.Sys_User.Name,
  138. IDNumber = c.IDNumber,
  139. PhotoUrl = c.PhotoUrl,
  140. IsProofread = c.IsProofread,
  141. IsPhoto = c.PhotoUrl == null ? (int)CF_YesOrNoStatus.No : (int)CF_YesOrNoStatus.Yes,
  142. IsPhotoUrl = c.PhotoUrl == null ? "否" : "是",
  143. StudentCardNo = c.StudentCardNo,
  144. PlanningGraduateDate = c.PlanningGraduateDate,//预计毕业时间
  145. EntranceDate = c.CF_Recruitstudents.EntranceDate,
  146. EnteringSchoolYearID = c.CF_Recruitstudents.EnteringSchoolYearID,
  147. EnteringSchoolYearCode = c.CF_Recruitstudents.CF_Schoolyear.Code,
  148. Score = c.CF_Recruitstudents.Score,
  149. ExamineeNum = c.CF_Recruitstudents.ExamineeNum,
  150. AdmissionTicketNo = c.CF_Recruitstudents.AdmissionTicketNo,
  151. Area = c.CF_Recruitstudents.Area,
  152. Placebirth = c.CF_Recruitstudents.PlaceBirth,
  153. CardNo = c.CF_StudentAccount.CardNo,
  154. BankName = c.CF_StudentAccount.BankName,
  155. Territorial = tcrecruitStudent.Territorial,
  156. Sex = c.Sex,
  157. ClassMajorID = c.ClassmajorID,
  158. ClassMajorCode = classmajor.No,
  159. ClassMajorName = classmajor.Name,
  160. Grade = grade.SchoolyearID,
  161. StudentStatus = c.StudentStatus,
  162. InSchoolStatusID = c.InSchoolStatusID,
  163. UsedName = c.CF_StudentProfile.UsedName,
  164. DirectorName = c.CF_StudentProfile.DirectorName,
  165. BirthDate = c.CF_StudentProfile.BirthDate,
  166. Country = c.CF_StudentProfile.Country,
  167. Politics = c.CF_StudentProfile.Politics,
  168. Place = c.CF_StudentProfile.Place,
  169. //BornPlace = c.CF_StudentProfile.BornPlace,
  170. Specialty = c.CF_StudentProfile.Specialty,
  171. Height = c.CF_StudentProfile.Height,
  172. Weight = c.CF_StudentProfile.Weight,
  173. Remarks = c.CF_StudentProfile.Remarks,
  174. GraduationPictureUrl = c.CF_StudentProfile.GraduationPictureUrl,
  175. Email = c.CF_StudentContact.Email,
  176. QQ = c.CF_StudentContact.QQ,
  177. Mobile = c.CF_StudentContact.Mobile,
  178. Telephone = c.CF_StudentContact.Telephone,
  179. MicroMsgNo = c.CF_StudentContact.MicroMsgNo,
  180. ZipCode = c.CF_StudentContact.Zipcode,
  181. Address = c.CF_StudentContact.Address,
  182. WorkUnit = c.CF_StudentContact.WorkUnit,
  183. HomeAddress = c.CF_StudentContact.HomeAddress,
  184. Recipient = c.CF_StudentContact.Recipient,
  185. Dormitory = c.CF_StudentContact.Dormitory,
  186. LearnSystem = grade.CF_Facultymajor.LearnSystem,
  187. CampusID = grade.CF_Facultymajor.CF_College.CampusID,
  188. SchoolTypeID = grade.CF_Facultymajor.CF_College.CF_Campus.CF_University.CF_UniversityProfile.SchoolTypeID,
  189. CampusName = grade.CF_Facultymajor.CF_College.CF_Campus.Name,
  190. CollegeID = grade.CF_Facultymajor.CollegeID,
  191. CollegeCode = grade.CF_Facultymajor.CF_College.No,
  192. CollegeName = grade.CF_Facultymajor.CF_College.Name,
  193. EducationID = grade.CF_Facultymajor.EducationID,
  194. StandardID = grade.CF_Facultymajor.StandardID,
  195. LearningformID = grade.CF_Facultymajor.LearningformID,
  196. GradeMajorID = classmajor.GrademajorID,
  197. GradeMajorName = grade.Name,
  198. GradeMajorCode = grade.Code,
  199. StudentType = c.StudentType,
  200. CultureModel = c.CultureModel,
  201. BloodGroup = tcstudentProfile.BloodGroup,
  202. CertificatesType = c.CertificatesType,
  203. EntranceWay = tcrecruitStudent.EntranceWay,
  204. ExamineeType = tcrecruitStudent.ExamineeType,
  205. Features = tcrecruitStudent.Features,
  206. Healthy = tcstudentProfile.Healthy,
  207. Nation = tcstudentProfile.Nation,
  208. FacultymajorName = grade.CF_Facultymajor.Name,//院系所专业
  209. GraduateCardNo = c.GraduateCardNo,
  210. GraduateDate = c.GraduateDate,
  211. IsDreamProject = c.IsDreamProject == true,
  212. Career = c.Career,
  213. ReplaceGraduateNo = c.ReplaceGraduateNo,
  214. LiteracyLevels = c.CF_StudentProfile.LiteracyLevels,
  215. SchoolAreaID = grade.SchoolAreaID,
  216. };
  217. return query;
  218. }
  219. public IQueryable<StudentListForExportView> GetStudentListForExport(Expression<Func<EX_ExaminationRegistration, bool>> erexp, Expression<Func<EX_ExaminationProject, bool>> epexp,
  220. Expression<Func<EX_ExaminationBatchProject, bool>> ebpexp, Expression<Func<CF_Student, bool>> stuexp)
  221. {
  222. var currentSchoolyear = schoolyearRepository.Entities.Where(x => x.IsCurrent == true).FirstOrDefault();
  223. var query = from err in examinationRegistrationRepository.GetList(erexp)
  224. join ebpr in examinationBatchProjectRepository.GetList(ebpexp)
  225. on err.ExaminationBatchProjectID equals ebpr.ExaminationBatchProjectID
  226. join epft in examinationProjectFeeTypeRepository.Entities
  227. on err.ExaminationProjectFeeTypeID equals epft.ExaminationProjectFeeTypeID
  228. join epf in examinationProjectFeeRepository.Entities
  229. on epft.ExaminationProjectFeeID equals epf.ExaminationProjectFeeID
  230. join epr in examinationProjectRepository.GetList(epexp)
  231. on ebpr.ExaminationProjectID equals epr.ExaminationProjectID
  232. join etr in examinationTypeRepository.Entities
  233. on epr.ExaminationTypeID equals etr.ExaminationTypeID
  234. join ebr in examinationBatchRepository.Entities
  235. on ebpr.ExaminationBatchID equals ebr.ExaminationBatchID
  236. join sch in SchoolyearRepository.Entities
  237. on ebr.SchoolyearID equals sch.SchoolyearID
  238. join ercr in examinationRegistrationConfirmRepository.Entities
  239. on err.ExaminationRegistrationConfirmID equals ercr.ExaminationRegistrationConfirmID
  240. into dercr
  241. from ercr in dercr.DefaultIfEmpty()
  242. join stu in studentRepository.GetList(stuexp)
  243. on err.UserID equals stu.UserID
  244. join recruitStudent in recruitstudentsRepository.Entities on stu.UserID equals recruitStudent.UserID
  245. into crecruitStudent
  246. from tcrecruitStudent in crecruitStudent.DefaultIfEmpty()
  247. join studentProfile in studentProfileRepository.Entities on stu.UserID equals studentProfile.UserID
  248. into cstudentProfile
  249. from tcstudentProfile in cstudentProfile.DefaultIfEmpty()
  250. join cla in classmajorRepository.Entities
  251. on stu.ClassmajorID equals cla.ClassmajorID
  252. join gra in grademajorRepository.Entities
  253. on cla.GrademajorID equals gra.GrademajorID
  254. into dgra
  255. from gra in dgra.DefaultIfEmpty()
  256. join fac in facultymajorRepository.Entities
  257. on gra.FacultymajorID equals fac.FacultymajorID
  258. into dfac
  259. from fac in dfac.DefaultIfEmpty()
  260. join col in collegeRepository.Entities
  261. on fac.CollegeID equals col.CollegeID
  262. into dcol
  263. from col in dcol.DefaultIfEmpty()
  264. join campus in campusRepository.Entities
  265. on col.CampusID equals campus.CampusID
  266. into dcampus
  267. from campus in dcampus.DefaultIfEmpty()
  268. join uni in universityRepository.Entities
  269. on campus.UniversityID equals uni.UniversityID
  270. into duni
  271. from uni in duni.DefaultIfEmpty()
  272. select new StudentListForExportView
  273. {
  274. SchoolAreaID = gra.SchoolAreaID,
  275. ExaminationRegistrationID = err.ExaminationRegistrationID,
  276. ExaminationTypeID = epr.ExaminationTypeID,
  277. ExaminationTypeName = etr.Name,
  278. ExaminationLevelID = epr.ExaminationLevelID,
  279. Year = gra.SchoolyearID,
  280. CollegeID = fac.CollegeID,
  281. CollegeName = col.Name,
  282. StandardID = fac.StandardID,
  283. StudentNo = stu.StudentCardNo,
  284. UserID = err.UserID,
  285. UserName = stu.Sys_User.Name,
  286. Sex = stu.Sex,
  287. IDNumber = stu.IDNumber,
  288. QQ = stu.CF_StudentContact.QQ,
  289. Email = stu.CF_StudentContact.Email,
  290. PhoneNumber = stu.CF_StudentContact.Mobile,
  291. BirthDate = stu.CF_StudentProfile.BirthDate,
  292. Nation = stu.CF_StudentProfile.Nation,
  293. EducationID = fac.EducationID,
  294. Residence = stu.CF_StudentProfile.Place,
  295. HomeAddress = stu.CF_StudentContact.HomeAddress,
  296. Mobile = stu.CF_StudentContact.Mobile,
  297. ExaminationProjectID = ebpr.ExaminationProjectID,
  298. ExaminationProjectName = epr.Name,
  299. Fee = epft.Fee,
  300. PayFee = err.Fee,
  301. RegistrDate = err.CreateTime,
  302. RecordStatus = err.RecordStatus,
  303. Remark = err.Remark,
  304. Politics = stu.CF_StudentProfile.Politics,
  305. Address = stu.CF_StudentContact.Address,
  306. WorkPlace = stu.CF_StudentContact.WorkUnit,
  307. SchoolyearID = ebr.SchoolyearID,
  308. SchoolyearCode = sch.Code,
  309. ExaminationProjectFeeID = epft.ExaminationProjectFeeID,
  310. ExaminationProjectFeeName = epf.Name,
  311. ExaminationProjectFeeTypeID = err.ExaminationProjectFeeTypeID,
  312. ExaminationBatchID = ebpr.ExaminationBatchID,
  313. ExaminationBatchName = ebr.Name,
  314. Value = epft.FeeTypeID,
  315. FeeTypeID = epft.FeeTypeID,
  316. ClassmajorID = cla.ClassmajorID,
  317. ClassmajorName = cla.Name,
  318. ClassmajorNo = cla.No,
  319. CertificatesType = stu.CertificatesType,
  320. ExaminationRegistrationConfirmID = ercr.ExaminationRegistrationConfirmID,
  321. ExaminationRegistrationConfirmNo = ercr.No,
  322. StartDate = ebpr.StartDate,
  323. EndDate = ebpr.EndDate,
  324. SchoolyearNumID = ((currentSchoolyear.Value - gra.CF_Schoolyear.Value - (currentSchoolyear.SchoolcodeID == gra.SchoolcodeID ? 0 : 1)) / 2 + 1),
  325. ExamineeNum = stu.CF_Recruitstudents.ExamineeNum,
  326. PhotoUrl = stu.PhotoUrl,
  327. SchoolCode = uni.Code,
  328. SchoolName = uni.Name,
  329. LearnSystem = gra.CF_Facultymajor.LearnSystem,
  330. LearningformID = gra.CF_Facultymajor.LearningformID,
  331. EntranceDate = stu.CF_Recruitstudents.EntranceDate,
  332. PlanningGraduateDate = stu.PlanningGraduateDate,//预计毕业时间
  333. GraduationResult = stu.InSchoolStatusID,
  334. CampusName = campus.Name,
  335. ClassmajorCode = cla.No,
  336. };
  337. return query;
  338. }
  339. public IQueryable<ExaminationRegistrationPayView> GetExaminationRegistrationPayViewQueryable(Expression<Func<EX_ExaminationRegistration, bool>> regExp)
  340. {
  341. var sql = (from regist in examinationRegistrationRepository.GetList(regExp)
  342. from pay in wechatPayListRepository.Entities.Where(x => x.ExaminationRegistrationID == regist.ExaminationRegistrationID).DefaultIfEmpty()
  343. select new ExaminationRegistrationPayView
  344. {
  345. WechatPayListID = pay.WechatPayListID,
  346. ExaminationRegistrationID = regist.ExaminationRegistrationID,
  347. Fee = regist.Fee,
  348. OrderID = pay.OrderID,
  349. WechatOrderID = pay.WechatOrderID,
  350. RefundOrderID = pay.RefundOrderID,
  351. RefundTotal = pay.RefundTotal,
  352. RecordStatus = regist.RecordStatus
  353. });
  354. return sql;
  355. }
  356. }
  357. }