StudentsDAL.cs 55 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Bowin.Common.Linq;
  6. using EMIS.Entities;
  7. using EMIS.DataLogic.Repositories;
  8. using EMIS.ViewModel;
  9. using EMIS.ViewModel.SystemView;
  10. using System.Linq.Expressions;
  11. using EMIS.ViewModel.Students;
  12. using System.Data.Entity;
  13. using EMIS.DataLogic.SystemDAL;
  14. namespace EMIS.DataLogic.Common.Students
  15. {
  16. public class StudentsDAL
  17. {
  18. public StudentRepository StudentRepository { get; set; }
  19. public DictionaryDAL DictionaryDAL { get; set; }
  20. public UserRepository UserRepository { get; set; }
  21. public EducationMissionRepository EducationMissionRepository { get; set; }//教学任务班主表
  22. public EducationMissionClassRepository EducationMissionClassRepository { get; set; }
  23. public EducationSchedulingClassRepository EducationSchedulingClassRepository { get; set; }
  24. public ExaminationPlanRepository ExaminationPlanRepository { get; set; }//考场安排
  25. public FinalExaminationRepository FinalExaminationRepository { get; set; } //期末设定
  26. public EvaluationSettingRepository EvaluationSettingRepository { get; set; }//教学评价
  27. public SpecialtyPlanRepository SpecialtyPlanRepository { get; set; }
  28. public StudentsOrderRepository StudentsOrderRepository { get; set; }
  29. public StudentDistributeRepository StudentDistributeRepository { get; set; }
  30. //public StudentProfileRepository StudentProfileRepository { get; set; }
  31. //public StudentContactRepository StudentContactRepository { get; set; }
  32. //public RecruitstudentsRepository RecruitstudentsRepository { get; set; }
  33. //public StudentAccountRepository StudentAccountRepository { get; set; }
  34. public InSchoolSettingRepository InSchoolSettingRepository { get; set; }
  35. public RecruitstudentsRepository RecruitstudentsRepository { get; set; }
  36. public StudentProfileRepository StudentProfileRepository { get; set; }
  37. public ClassmajorRepository ClassmajorRepository { get; set; }
  38. public GrademajorRepository GrademajorRepository { get; set; }
  39. public FacultymajorRepository FacultymajorRepository { get; set; }
  40. public SchoolyearRepository SchoolyearRepository { get; set; }
  41. public StudentReportRepository StudentReportRepository { get; set; }
  42. //public StudentAccountRepository StudentAccountRepository { get; set; }
  43. //public StudentContactRepository StudentContactRepository { get; set; }
  44. public UniversityRepository universityRepository { get; set; }
  45. public UniversityProfileRepository universityProfileRepository { get; set; }
  46. /// <summary>
  47. /// 获取当前学年学期所有学生信息
  48. /// </summary>
  49. /// <param name="filter"></param>
  50. /// <returns></returns>
  51. public IQueryable<StudentsView> GetStudentQueryable(Expression<Func<CF_Student, bool>> filter,
  52. Expression<Func<CF_Classmajor, bool>> classmajorExp = null,
  53. Expression<Func<CF_Grademajor, bool>> grademajorExp = null,
  54. Expression<Func<EM_StudentReport, bool>> reportExp = null)
  55. {
  56. if (classmajorExp == null)
  57. {
  58. classmajorExp = (x => true);
  59. }
  60. if (grademajorExp == null)
  61. {
  62. grademajorExp = (x => true);
  63. }
  64. if (reportExp==null)
  65. {
  66. reportExp = (x => true);
  67. }
  68. var query = from c in StudentRepository.GetList(filter)
  69. join classmajor in ClassmajorRepository.GetList(classmajorExp) on c.ClassmajorID equals classmajor.ClassmajorID
  70. join grade in GrademajorRepository.GetList(grademajorExp) on classmajor.GrademajorID equals grade.GrademajorID
  71. join studentProfile in StudentProfileRepository.Entities on c.UserID equals studentProfile.UserID
  72. into cstudentProfile
  73. from tcstudentProfile in cstudentProfile.DefaultIfEmpty()
  74. join recruitStudent in RecruitstudentsRepository.Entities on c.UserID equals recruitStudent.UserID
  75. into crecruitStudent
  76. from tcrecruitStudent in crecruitStudent.DefaultIfEmpty()
  77. from b in c.EM_StudentReport.AsQueryable().Where(w => w.CF_Schoolyear.IsCurrent == true).DefaultIfEmpty() //当前学年学期的报到情况
  78. select new StudentsView
  79. {
  80. UserID = c.UserID,
  81. LoginID = c.Sys_User.LoginID,
  82. UserName = c.Sys_User.Name,
  83. IDNumber = c.IDNumber,
  84. PhotoUrl = c.PhotoUrl,
  85. IsProofread = c.IsProofread,
  86. IsPhoto = c.PhotoUrl == null ? (int)CF_YesOrNoStatus.No : (int)CF_YesOrNoStatus.Yes,
  87. IsPhotoUrl = c.PhotoUrl == null ? "否" : "是",
  88. StudentCardNo = c.StudentCardNo,
  89. PlanningGraduateDate = c.PlanningGraduateDate,//预计毕业时间
  90. GraduateDate = c.GraduateDate,
  91. EntranceDate = c.CF_Recruitstudents.EntranceDate,
  92. EnteringSchoolYearID = c.CF_Recruitstudents.EnteringSchoolYearID,
  93. EnteringSchoolYearCode = c.CF_Recruitstudents.CF_Schoolyear.Code,
  94. Score = c.CF_Recruitstudents.Score,
  95. ExamineeNum = c.CF_Recruitstudents.ExamineeNum,
  96. AdmissionTicketNo = c.CF_Recruitstudents.AdmissionTicketNo,
  97. Area = c.CF_Recruitstudents.Area,
  98. Placebirth = c.CF_StudentProfile.BornPlace,
  99. CardNo = c.CF_StudentAccount.CardNo,
  100. BankName = c.CF_StudentAccount.BankName,
  101. Territorial = tcrecruitStudent.TerritorialID,
  102. SexID = c.SexID,
  103. ClassMajorID = c.ClassmajorID,
  104. ClassMajorCode = classmajor.No,
  105. ClassMajorName = classmajor.Name,
  106. Grade = grade.GradeID,
  107. StudentStatus = c.StudentStatus,
  108. InSchoolStatusID = c.InSchoolStatusID,
  109. ReportStatusID = b.ReportStatus ?? 1,
  110. UsedName = c.CF_StudentProfile.UsedName,
  111. DirectorName = c.CF_StudentProfile.DirectorName,
  112. BirthDate = c.BirthDate,
  113. Country = c.CF_StudentProfile.Country,
  114. Politics = c.PoliticsID,
  115. Place = c.CF_StudentProfile.Place,
  116. //BornPlace = c.CF_StudentProfile.BornPlace,
  117. Specialty = c.CF_StudentProfile.Specialty,
  118. Height = c.CF_StudentProfile.Height,
  119. Weight = c.CF_StudentProfile.Weight,
  120. Remarks = c.Remark,
  121. GraduationPictureUrl = c.GraduationPictureUrl,
  122. Email = c.CF_StudentContact.Email,
  123. QQ = c.CF_StudentContact.QQ,
  124. Mobile = c.CF_StudentContact.Mobile,
  125. Telephone = c.CF_StudentContact.Telephone,
  126. MicroMsgNo = c.CF_StudentContact.WeChatNum,
  127. ZipCode = c.CF_StudentContact.ZIPCode,
  128. Address = c.CF_StudentContact.Address,
  129. WorkUnit = c.CF_StudentContact.WorkUnit,
  130. HomeAddress = c.CF_StudentContact.HomeAddress,
  131. Recipient = c.CF_StudentContact.Recipient,
  132. Dormitory = c.CF_StudentContact.Dormitory,
  133. LearnSystem = grade.CF_Facultymajor.LearnSystem,
  134. CampusID = grade.CF_Facultymajor.CF_College.CampusID,
  135. SchoolTypeID = grade.CF_Facultymajor.CF_College.CF_Campus.CF_University.CF_UniversityProfile.SchoolTypeID,
  136. CampusName = grade.CF_Facultymajor.CF_College.CF_Campus.Name,
  137. CollegeID = grade.CF_Facultymajor.CollegeID,
  138. CollegeCode = grade.CF_Facultymajor.CF_College.No,
  139. CollegeName = grade.CF_Facultymajor.CF_College.Name,
  140. EducationID = grade.CF_Facultymajor.EducationID,
  141. StandardID = grade.CF_Facultymajor.StandardID,
  142. LearningformID = grade.CF_Facultymajor.LearningformID,
  143. GradeMajorID = classmajor.GrademajorID,
  144. GradeMajorName = grade.Name,
  145. GradeMajorCode = grade.Code,
  146. StudentType = c.StudentType,
  147. CultureModel = c.CF_StudentProfile.CultureModelID,
  148. BloodGroup = tcstudentProfile.BloodGroup,
  149. CertificatesType = c.CertificatesType,
  150. EntranceWay = tcrecruitStudent.EntranceWayID,
  151. ExamineeType = tcrecruitStudent.ExamineeType,
  152. Features = tcrecruitStudent.FeaturesID,
  153. Healthy = tcstudentProfile.HealthStateID,
  154. Nation = c.NationID,
  155. FacultymajorName = grade.CF_Facultymajor.Name,//院系所专业
  156. GraduateCardNo=c.GraduateCardNo,
  157. IsDreamProject = c.CF_StudentProfile.IsDreamProject == true,
  158. Career=c.Career,
  159. ReplaceGraduateNo=c.ReplaceGraduateNo,
  160. LiteracyLevels = c.CF_StudentProfile.LiteracyLevelID,
  161. GraduationResult = c.InSchoolStatusID,
  162. };
  163. return query;
  164. }
  165. public IQueryable<BaseStudentView> GetBaseStudentViewQueryable(Expression<Func<CF_Student, bool>> filter)
  166. {
  167. var query = from c in StudentRepository.GetList(filter)
  168. join studentProfile in StudentProfileRepository.Entities on c.UserID equals studentProfile.UserID
  169. join recruitStudent in RecruitstudentsRepository.Entities on c.UserID equals recruitStudent.UserID
  170. join StudentReport in StudentReportRepository.Entities.Where(w=>w.CF_Schoolyear.IsCurrent==true).DefaultIfEmpty() on c.UserID equals StudentReport.UserID into stur
  171. from stu in stur.DefaultIfEmpty()
  172. //from b in c.EM_StudentReport.AsQueryable().Where(w => w.CF_Schoolyear.IsCurrent == true).DefaultIfEmpty() //当前学年学期的报到情况
  173. select new BaseStudentView
  174. {
  175. UserID = c.UserID,
  176. LoginID = c.Sys_User.LoginID,
  177. UserName = c.Sys_User.Name,
  178. SexID = c.SexID,
  179. IDNumber = c.IDNumber,
  180. InSchoolStatusID = c.InSchoolStatusID,
  181. StudentStatus = c.StudentStatus,
  182. ClassmajorID = c.CF_Classmajor.ClassmajorID,
  183. ClassmajorCode = c.CF_Classmajor.No,
  184. ClassmajorName = c.CF_Classmajor.Name,
  185. GrademajorID = c.CF_Classmajor.GrademajorID,
  186. GrademajorName = c.CF_Classmajor.CF_Grademajor.Name,
  187. CollegeID = c.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID
  188. // GraduateCardNo=c.GraduateCardNo
  189. };
  190. return query;
  191. }
  192. public IQueryable<BaseStudentView> GetInSchoolStudentViewQueryable(Expression<Func<CF_Student, bool>> filter)
  193. {
  194. var query = from c in StudentRepository.GetList(filter)
  195. //from b in c.EM_StudentReport.AsQueryable().Where(w => w.CF_Schoolyear.IsCurrent == true).DefaultIfEmpty() //当前学年学期的报到情况
  196. select new BaseStudentView
  197. {
  198. UserID = c.UserID,
  199. LoginID = c.Sys_User.LoginID,
  200. UserName = c.Sys_User.Name,
  201. SexID = c.SexID,
  202. IDNumber = c.IDNumber,
  203. InSchoolStatusID = c.InSchoolStatusID,
  204. StudentStatus = c.StudentStatus,
  205. ClassmajorID = c.CF_Classmajor.ClassmajorID,
  206. ClassmajorCode = c.CF_Classmajor.No,
  207. ClassmajorName = c.CF_Classmajor.Name,
  208. GrademajorID = c.CF_Classmajor.GrademajorID,
  209. GrademajorName = c.CF_Classmajor.CF_Grademajor.Name,
  210. CollegeID = c.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID
  211. // GraduateCardNo=c.GraduateCardNo
  212. };
  213. return query;
  214. }
  215. public IQueryable<BaseStudentView> GetBaseStudentViewQueryable(Expression<Func<CF_Student, bool>> studentExp,
  216. Expression<Func<CF_Grademajor, bool>> gradeExp, Expression<Func<CF_Facultymajor, bool>> facultyExp)
  217. {
  218. var q = from student in this.GetBaseStudentViewQueryable(studentExp)
  219. join classmajor in ClassmajorRepository.Entities on student.ClassmajorID equals classmajor.ClassmajorID
  220. join grade in GrademajorRepository.Entities.Where(gradeExp) on classmajor.GrademajorID equals grade.GrademajorID
  221. join faculty in FacultymajorRepository.Entities.Where(facultyExp) on grade.FacultymajorID equals faculty.FacultymajorID
  222. select student;
  223. return q;
  224. }
  225. //计算预计毕业设计时间
  226. public StudentsView GetPlanningGraduateDate(Guid GrademajorID)
  227. {
  228. var query = from g in GrademajorRepository.Entities.Where(x => x.GrademajorID == GrademajorID && x.GraduateSchoolyearID != null)
  229. join f in FacultymajorRepository.Entities on g.FacultymajorID equals f.FacultymajorID
  230. join sn in SchoolyearRepository.Entities on new { Value = (int)((g.GradeID * 2 - 1) + (g.SemesterID - 1) + (f.LearnSystem * 2 - 1)) } equals new { Value = (int)sn.Value }
  231. into tsn
  232. from ctsn in tsn.DefaultIfEmpty()
  233. select new StudentsView { PlanningGraduateDate = (DateTime)ctsn.FirstWeek, WeeksNum = ctsn.WeeksNum * 7 };
  234. return query.FirstOrDefault();
  235. }
  236. //计算预计毕业设计时间 方案二 2016年10月25日14:19:25
  237. //public StudentsView GetPlanningGraduate(Guid GrademajorID)
  238. //{
  239. // var query = from g in GrademajorRepository.Entities.Where(x => x.GrademajorID == GrademajorID && x.GraduatingSemesterID != null)
  240. // join f in FacultymajorRepository.Entities on g.FacultymajorID equals f.FacultymajorID
  241. // select new StudentsView { LearnSystem = f.LearnSystem, Years=g.SchoolyearID };
  242. // return query.FirstOrDefault();
  243. //}
  244. public StudentsView GetPlanningGraduate(Guid GrademajorID)
  245. {
  246. var query = from g in GrademajorRepository.Entities.Where(x => x.GrademajorID == GrademajorID && x.GraduateSchoolyearID != null)
  247. join f in FacultymajorRepository.Entities on g.FacultymajorID equals f.FacultymajorID
  248. join s in SchoolyearRepository.Entities on g.GraduateSchoolyearID equals s.SchoolyearID
  249. join d in DictionaryDAL.GetDictionaryItemQuery(typeof(CF_Semester).Name) on s.SchoolcodeID equals d.Value into dv
  250. from d in dv.DefaultIfEmpty()
  251. select new StudentsView {
  252. LearnSystem = f.LearnSystem,
  253. Years = g.GradeID,
  254. Grade = g.GradeID,
  255. PlanningGraduateYear=s.Years,
  256. PlanningGraduateSchoolYearID=g.GraduateSchoolyearID,
  257. PlanningGraduateSchoolCodeID=s.SchoolcodeID,
  258. PlanningGraduateSchoolCode = d.Value,
  259. PlanningGraduateSchoolCodeName = d.Name,
  260. };
  261. return query.FirstOrDefault();
  262. }
  263. public IQueryable<StudentsView> GetPlanningGraduateDictionary()
  264. {
  265. var inSchoolStatusIDList = InSchoolSettingRepository.GetList(x => x.IsSelected == true).Select(w => w.InSchoolStatusID).ToList();//获取选中的在校设定状态、
  266. var query = from a in StudentRepository.GetList(x => inSchoolStatusIDList.Contains(x.InSchoolStatusID))
  267. group a by a.PlanningGraduateDate
  268. into b
  269. select new StudentsView
  270. {
  271. PlanningGraduateDate = b.Key,
  272. //PlanningGraduateStr = b.Key.Value,
  273. };
  274. return query;
  275. }
  276. /// <summary>
  277. /// 获取当前学年学期所有学生信息
  278. /// </summary>
  279. /// <param name="filter"></param>
  280. /// <returns></returns>
  281. public IQueryable<StudentsView> GetStudentForExcel(Expression<Func<CF_Student, bool>> filter,
  282. Expression<Func<CF_Classmajor, bool>> classmajorExp = null,
  283. Expression<Func<CF_Grademajor, bool>> grademajorExp = null,
  284. Expression<Func<EM_StudentReport, bool>> reportExp = null)
  285. {
  286. if (classmajorExp == null)
  287. {
  288. classmajorExp = (x => true);
  289. }
  290. if (grademajorExp == null)
  291. {
  292. grademajorExp = (x => true);
  293. }
  294. if (reportExp == null)
  295. {
  296. reportExp = (x => true);
  297. }
  298. var schoolquery = from uni in universityRepository.Entities
  299. join unip in universityProfileRepository.Entities
  300. on uni.UniversityID equals unip.UniversityID
  301. select new
  302. {
  303. SchoolCode = uni.Code,
  304. SchoolName = uni.Name,
  305. HeadMasterName = unip.HeadMasterName,
  306. };
  307. var query = from c in StudentRepository.GetList(filter)
  308. join classmajor in ClassmajorRepository.GetList(classmajorExp) on c.ClassmajorID equals classmajor.ClassmajorID
  309. join grade in GrademajorRepository.GetList(grademajorExp) on classmajor.GrademajorID equals grade.GrademajorID
  310. join studentProfile in StudentProfileRepository.Entities on c.UserID equals studentProfile.UserID
  311. into cstudentProfile
  312. from tcstudentProfile in cstudentProfile.DefaultIfEmpty()
  313. join recruitStudent in RecruitstudentsRepository.Entities on c.UserID equals recruitStudent.UserID
  314. into crecruitStudent
  315. from tcrecruitStudent in crecruitStudent.DefaultIfEmpty()
  316. from b in c.EM_StudentReport.AsQueryable().Where(w => w.CF_Schoolyear.IsCurrent == true).DefaultIfEmpty() //当前学年学期的报到情况
  317. select new StudentsView
  318. {
  319. UserID = c.UserID,
  320. LoginID = c.Sys_User.LoginID,
  321. UserName = c.Sys_User.Name,
  322. IDNumber = c.IDNumber,
  323. PhotoUrl = c.PhotoUrl,
  324. IsProofread = c.IsProofread,
  325. IsPhoto = c.PhotoUrl == null ? (int)CF_YesOrNoStatus.No : (int)CF_YesOrNoStatus.Yes,
  326. IsPhotoUrl = c.PhotoUrl == null ? "否" : "是",
  327. StudentCardNo = c.StudentCardNo,
  328. PlanningGraduateDate = c.PlanningGraduateDate,//预计毕业时间
  329. EntranceDate = c.CF_Recruitstudents.EntranceDate,
  330. EnteringSchoolYearID = c.CF_Recruitstudents.EnteringSchoolYearID,
  331. EnteringSchoolYearCode = c.CF_Recruitstudents.CF_Schoolyear.Code,
  332. Score = c.CF_Recruitstudents.Score,
  333. ExamineeNum = c.CF_Recruitstudents.ExamineeNum,
  334. AdmissionTicketNo = c.CF_Recruitstudents.AdmissionTicketNo,
  335. Area = c.CF_Recruitstudents.Area,
  336. Placebirth = c.CF_StudentProfile.BornPlace,
  337. CardNo = c.CF_StudentAccount.CardNo,
  338. BankName = c.CF_StudentAccount.BankName,
  339. Territorial = tcrecruitStudent.TerritorialID,
  340. SexID = c.SexID,
  341. ClassMajorID = c.ClassmajorID,
  342. ClassMajorCode = classmajor.No,
  343. ClassMajorName = classmajor.Name,
  344. ClassNum = classmajor.ClassNum,
  345. Grade = grade.GradeID,
  346. StudentStatus = c.StudentStatus,
  347. InSchoolStatusID = c.InSchoolStatusID,
  348. ReportStatusID = b.ReportStatus ?? 1,
  349. UsedName = c.CF_StudentProfile.UsedName,
  350. DirectorName = c.CF_StudentProfile.DirectorName,
  351. BirthDate = c.BirthDate,
  352. Country = c.CF_StudentProfile.Country,
  353. Politics = c.PoliticsID,
  354. Place = c.CF_StudentProfile.Place,
  355. //BornPlace = c.CF_StudentProfile.BornPlace,
  356. Specialty = c.CF_StudentProfile.Specialty,
  357. Height = c.CF_StudentProfile.Height,
  358. Weight = c.CF_StudentProfile.Weight,
  359. Remarks = c.Remark,
  360. GraduationPictureUrl = c.GraduationPictureUrl,
  361. Email = c.CF_StudentContact.Email,
  362. QQ = c.CF_StudentContact.QQ,
  363. Mobile = c.CF_StudentContact.Mobile,
  364. Telephone = c.CF_StudentContact.Telephone,
  365. MicroMsgNo = c.CF_StudentContact.WeChatNum,
  366. ZipCode = c.CF_StudentContact.ZIPCode,
  367. Address = c.CF_StudentContact.Address,
  368. WorkUnit = c.CF_StudentContact.WorkUnit,
  369. HomeAddress = c.CF_StudentContact.HomeAddress,
  370. Recipient = c.CF_StudentContact.Recipient,
  371. Dormitory = c.CF_StudentContact.Dormitory,
  372. LearnSystem = grade.CF_Facultymajor.LearnSystem,
  373. CampusID = grade.CF_Facultymajor.CF_College.CampusID,
  374. SchoolTypeID = grade.CF_Facultymajor.CF_College.CF_Campus.CF_University.CF_UniversityProfile.SchoolTypeID,
  375. CampusName = grade.CF_Facultymajor.CF_College.CF_Campus.Name,
  376. CollegeID = grade.CF_Facultymajor.CollegeID,
  377. CollegeCode = grade.CF_Facultymajor.CF_College.No,
  378. CollegeName = grade.CF_Facultymajor.CF_College.Name,
  379. EducationID = grade.CF_Facultymajor.EducationID,
  380. StandardID = grade.CF_Facultymajor.StandardID,
  381. LearningformID = grade.CF_Facultymajor.LearningformID,
  382. GradeMajorID = classmajor.GrademajorID,
  383. GradeMajorName = grade.Name,
  384. GradeMajorCode = grade.Code,
  385. StudentType = c.StudentType,
  386. CultureModel = c.CF_StudentProfile.CultureModelID,
  387. BloodGroup = tcstudentProfile.BloodGroup,
  388. CertificatesType = c.CertificatesType,
  389. EntranceWay = tcrecruitStudent.EntranceWayID,
  390. ExamineeType = tcrecruitStudent.ExamineeType,
  391. Features = tcrecruitStudent.FeaturesID,
  392. Healthy = tcstudentProfile.HealthStateID,
  393. Nation = c.NationID,
  394. FacultymajorName = grade.CF_Facultymajor.Name,//院系所专业
  395. GraduateCardNo = c.GraduateCardNo,
  396. IsDreamProject = c.CF_StudentProfile.IsDreamProject == true,
  397. Career = c.Career,
  398. SchoolCode = schoolquery.FirstOrDefault().SchoolCode,
  399. SchoolName = schoolquery.FirstOrDefault().SchoolName,
  400. HeadMasterName = schoolquery.FirstOrDefault().HeadMasterName,
  401. GraduationResult = c.InSchoolStatusID
  402. };
  403. return query;
  404. }
  405. #region 5.0 教学任务Add
  406. //教学任务
  407. public IQueryable<StudentRelateCourseView> GetStudentRelateCourseViewQueryable(Expression<Func<CF_Student, bool>> filter)
  408. {
  409. var sql = (from student in StudentRepository.GetList(filter)
  410. join user in UserRepository.Entities on student.UserID equals user.UserID
  411. join classmajor in ClassmajorRepository.Entities on student.ClassmajorID equals classmajor.ClassmajorID
  412. from currentYear in SchoolyearRepository.Entities.Where(x => x.IsCurrent == true)
  413. from schoolyear in SchoolyearRepository.Entities.Where(x => x.Value >= currentYear.Value)
  414. //查出相关的课程
  415. join missionClass in
  416. (
  417. from mission in EducationMissionRepository.Entities
  418. join missionClass in EducationMissionClassRepository.Entities on mission.EducationMissionID equals missionClass.EducationMissionID
  419. from classmajor in missionClass.CF_Classmajor
  420. join schedulingClass in EducationSchedulingClassRepository.Entities on missionClass.EducationMissionClassID equals schedulingClass.EducationMissionClassID
  421. group new { missionClass, schedulingClass }
  422. by new { mission.SchoolyearID, missionClass.CoursematerialID, missionClass.TeachingModeID, classmajor.ClassmajorID, missionClass.OptionalCourseTypeID, missionClass.HandleModeID }
  423. into g
  424. select new
  425. {
  426. g.Key.SchoolyearID,
  427. g.Key.CoursematerialID,
  428. g.Key.ClassmajorID,
  429. g.Key.TeachingModeID,
  430. g.Key.OptionalCourseTypeID,
  431. g.Key.HandleModeID,
  432. SchedulingClassList = g.Select(x => new StudentRelateSchedulingClassView
  433. {
  434. EducationSchedulingClassID = x.schedulingClass.EducationSchedulingClassID,
  435. EducationMissionClassName = x.missionClass.Name,
  436. ClassmajorIDList = x.schedulingClass.CF_Student.Select(w => w.ClassmajorID),
  437. StudentCount = x.schedulingClass.CF_Student.Count(),
  438. MinLoginID = x.schedulingClass.CF_Student.Min(w => w.Sys_User.LoginID),
  439. MaxLoginID = x.schedulingClass.CF_Student.Max(w => w.Sys_User.LoginID)
  440. })
  441. }) on new { SchoolyearID = (Guid?)schoolyear.SchoolyearID, classmajor.ClassmajorID }
  442. equals new { missionClass.SchoolyearID, missionClass.ClassmajorID }
  443. //查已经加入的任务班并排除,防止重复插入
  444. join schedulingClass in
  445. (
  446. from mission in EducationMissionRepository.Entities
  447. join missionClass in EducationMissionClassRepository.Entities on mission.EducationMissionID equals missionClass.EducationMissionID
  448. from classmajor in missionClass.CF_Classmajor
  449. join schedulingClass in EducationSchedulingClassRepository.Entities on missionClass.EducationMissionClassID equals schedulingClass.EducationMissionClassID
  450. from student in schedulingClass.CF_Student
  451. select new { mission.SchoolyearID, missionClass.CoursematerialID, missionClass.TeachingModeID, classmajor.ClassmajorID, missionClass.OptionalCourseTypeID, missionClass.HandleModeID, student.UserID }
  452. ) on new { missionClass.SchoolyearID, missionClass.CoursematerialID, missionClass.TeachingModeID, missionClass.ClassmajorID, missionClass.OptionalCourseTypeID, missionClass.HandleModeID, student.UserID }
  453. equals new { schedulingClass.SchoolyearID, schedulingClass.CoursematerialID, schedulingClass.TeachingModeID, schedulingClass.ClassmajorID, schedulingClass.OptionalCourseTypeID, schedulingClass.HandleModeID, schedulingClass.UserID }
  454. into dschedulingClass
  455. from schedulingClass in dschedulingClass.DefaultIfEmpty()
  456. where schedulingClass.SchoolyearID == null
  457. select new StudentRelateCourseView
  458. {
  459. UserID = student.UserID,
  460. LoginID = user.LoginID,
  461. ClassmajorID = student.ClassmajorID,
  462. SchoolyearID = missionClass.SchoolyearID,
  463. CoursematerialID = missionClass.CoursematerialID,
  464. TeacheModeID = missionClass.TeachingModeID,
  465. OptionalCourseTypeID = missionClass.OptionalCourseTypeID,
  466. HandleModeID = missionClass.HandleModeID,
  467. StudentRelateSchedulingClassViewList = missionClass.SchedulingClassList
  468. });
  469. return sql;
  470. }
  471. public IList<StudentsView> GetEducationSchedulingClassStudentInsert(Expression<Func<CF_Student, bool>> filter)
  472. {
  473. var result = new List<StudentsView>();
  474. var currentSchoolyear = this.SchoolyearRepository.GetSingle(x => x.IsCurrent == true);
  475. //这块只针对必修课,因为只有必修课才会强制必须要上,选修课需要学生自己去报名
  476. #region 情况1:如果找到同班学生,并且该组有学号后于他的人的,加入有学号后于他的第一组
  477. var query1 = from tem in
  478. (from imps in StudentRepository.GetList(filter)
  479. from dsy in SchoolyearRepository.Entities.Where(x => x.IsCurrent == true)
  480. from sy in SchoolyearRepository.Entities.Where(x => x.Value >= dsy.Value)
  481. join c in ClassmajorRepository.Entities on imps.ClassmajorID equals c.ClassmajorID
  482. join u in UserRepository.Entities on imps.UserID equals u.UserID
  483. //找到同班学生学号比自己后的(其实数字来说是大的)最后一个
  484. from su in
  485. (from esc1 in EducationSchedulingClassRepository.Entities
  486. from su1 in esc1.CF_Student
  487. join u1 in UserRepository.Entities on su1.UserID equals u1.UserID
  488. where su1.ClassmajorID == imps.ClassmajorID
  489. group u1 by new { esc1.EducationSchedulingClassID, su1.ClassmajorID } into g1
  490. select new
  491. {
  492. g1.Key.EducationSchedulingClassID,
  493. g1.Key.ClassmajorID,
  494. LoginID = g1.Max(x => x.LoginID)
  495. }
  496. ).Where(x => u.LoginID.CompareTo(x.LoginID) < 0 && x.ClassmajorID == imps.ClassmajorID)
  497. join esc in EducationSchedulingClassRepository.Entities on su.EducationSchedulingClassID equals esc.EducationSchedulingClassID
  498. join emc in EducationMissionClassRepository.Entities on esc.EducationMissionClassID equals emc.EducationMissionClassID
  499. join em in EducationMissionRepository.Entities on
  500. new { emc.EducationMissionID, SchoolyearID = (Guid?)sy.SchoolyearID } equals new { EducationMissionID = (Guid?)em.EducationMissionID, em.SchoolyearID }
  501. where emc.HandleModeID == (int)CF_HandleMode.RequiredCourse
  502. group emc by new { imps.UserID, em.SchoolyearID, c.ClassmajorID, emc.CoursematerialID, emc.TeachingModeID } into g
  503. select new
  504. {
  505. g.Key.UserID,
  506. g.Key.SchoolyearID,
  507. g.Key.ClassmajorID,
  508. g.Key.CoursematerialID,
  509. g.Key.TeachingModeID,
  510. MinName = g.Min(x => x.Name)
  511. }
  512. )
  513. join em in EducationMissionRepository.Entities on tem.SchoolyearID equals em.SchoolyearID
  514. join emc in EducationMissionClassRepository.GetList(x => x.HandleModeID == (int)CF_HandleMode.RequiredCourse)
  515. on new { EducationMissionID = (Guid?)em.EducationMissionID, tem.CoursematerialID, tem.TeachingModeID, Name = tem.MinName }
  516. equals new { emc.EducationMissionID, emc.CoursematerialID, emc.TeachingModeID, emc.Name }
  517. from c in emc.CF_Classmajor.Where(x => x.ClassmajorID == tem.ClassmajorID)
  518. join esc in EducationSchedulingClassRepository.Entities on emc.EducationMissionClassID equals esc.EducationMissionClassID
  519. group esc by new { tem.UserID, em.SchoolyearID, emc.CoursematerialID, emc.TeachingModeID } into g
  520. select new
  521. {
  522. g.Key.UserID,
  523. g.Key.SchoolyearID,
  524. g.Key.CoursematerialID,
  525. g.Key.TeachingModeID,
  526. MinEducationSchedulingClassID = g.Min(x => x.EducationSchedulingClassID.ToString())
  527. };
  528. result.AddRange(query1.ToList().Select(x => new StudentsView { TepTableID = new Guid(x.MinEducationSchedulingClassID), UserID = x.UserID }).ToList());
  529. #endregion
  530. #region 情况2:如果找到同班学生,并且没有学号后于他的人的,加入最后一组
  531. var query2 = from tem in
  532. (from imps in StudentRepository.GetList(filter)
  533. from dsy in SchoolyearRepository.Entities.Where(x => x.IsCurrent == true)
  534. from sy in SchoolyearRepository.Entities.Where(x => x.Value >= dsy.Value)
  535. join c in ClassmajorRepository.Entities on imps.ClassmajorID equals c.ClassmajorID
  536. join u in UserRepository.Entities on imps.UserID equals u.UserID
  537. from emc in c.EM_EducationMissionClass
  538. from esc in emc.EM_EducationSchedulingClass
  539. join em in EducationMissionRepository.Entities
  540. on new { emc.EducationMissionID, SchoolyearID = (Guid?)sy.SchoolyearID }
  541. equals new { EducationMissionID = (Guid?)em.EducationMissionID, em.SchoolyearID }
  542. //找到同班学生学号比自己前的(其实数字来说是小的)最后一个
  543. from su in
  544. (from esc1 in EducationSchedulingClassRepository.Entities
  545. join emc1 in c.EM_EducationMissionClass.AsQueryable() on esc1.EducationMissionClassID equals emc1.EducationMissionClassID
  546. join em1 in EducationMissionRepository.Entities on emc1.EducationMissionID equals em1.EducationMissionID
  547. from su1 in esc1.CF_Student
  548. join u1 in UserRepository.Entities on su1.UserID equals u1.UserID
  549. where su1.ClassmajorID == imps.ClassmajorID && emc1.HandleModeID == (int)CF_HandleMode.RequiredCourse
  550. group u1 by new { su1.ClassmajorID, emc1.CoursematerialID, em1.SchoolyearID, emc1.OptionalCourseTypeID } into g1
  551. select new
  552. {
  553. g1.Key.ClassmajorID,
  554. g1.Key.CoursematerialID,
  555. g1.Key.SchoolyearID,
  556. g1.Key.OptionalCourseTypeID,
  557. LoginID = g1.Max(x => x.LoginID)
  558. }
  559. ).Where(x => u.LoginID.CompareTo(x.LoginID) < 0 && x.ClassmajorID == c.ClassmajorID
  560. && x.CoursematerialID == emc.CoursematerialID && x.OptionalCourseTypeID == emc.OptionalCourseTypeID
  561. && x.SchoolyearID == em.SchoolyearID).DefaultIfEmpty()
  562. where emc.HandleModeID == (int)CF_HandleMode.RequiredCourse && su.ClassmajorID == null
  563. group emc by new { imps.UserID, em.SchoolyearID, c.ClassmajorID, emc.CoursematerialID, emc.TeachingModeID } into g
  564. select new
  565. {
  566. g.Key.UserID,
  567. g.Key.SchoolyearID,
  568. g.Key.ClassmajorID,
  569. g.Key.CoursematerialID,
  570. g.Key.TeachingModeID,
  571. MinName = g.Max(x => x.Name)
  572. }
  573. )
  574. join em in EducationMissionRepository.Entities on tem.SchoolyearID equals em.SchoolyearID
  575. join emc in EducationMissionClassRepository.GetList(x => x.HandleModeID == (int)CF_HandleMode.RequiredCourse)
  576. on new { EducationMissionID = (Guid?)em.EducationMissionID, tem.CoursematerialID, tem.TeachingModeID, Name = tem.MinName }
  577. equals new { emc.EducationMissionID, emc.CoursematerialID, emc.TeachingModeID, emc.Name }
  578. from c in emc.CF_Classmajor.Where(x => x.ClassmajorID == tem.ClassmajorID)
  579. join esc in EducationSchedulingClassRepository.Entities on emc.EducationMissionClassID equals esc.EducationMissionClassID
  580. group esc by new { tem.UserID, em.SchoolyearID, emc.CoursematerialID, emc.TeachingModeID } into g
  581. select new
  582. {
  583. g.Key.UserID,
  584. g.Key.SchoolyearID,
  585. g.Key.CoursematerialID,
  586. g.Key.TeachingModeID,
  587. MinEducationSchedulingClassID = g.Max(x => x.EducationSchedulingClassID.ToString())
  588. };
  589. result.AddRange(query2.ToList().Select(x => new StudentsView { TepTableID = new Guid(x.MinEducationSchedulingClassID), UserID = x.UserID }).ToList());
  590. #endregion
  591. #region 情况3:没有找到同班学生,加入最少人的第一组(这种情况通常有人的组都是另一个班的)
  592. var query3MateMissionClassQuery = (
  593. from ts1 in StudentRepository.GetList(filter)
  594. join tc1 in ClassmajorRepository.Entities on ts1.ClassmajorID equals tc1.ClassmajorID
  595. from temc1 in tc1.EM_EducationMissionClass
  596. join tem1 in EducationMissionRepository.Entities on temc1.EducationMissionID equals tem1.EducationMissionID
  597. join tsy1 in SchoolyearRepository.Entities on tem1.SchoolyearID equals tsy1.SchoolyearID
  598. join tesc1 in EducationSchedulingClassRepository.Entities on temc1.EducationMissionClassID equals tesc1.EducationMissionClassID
  599. from tms1 in tesc1.CF_Student
  600. where temc1.HandleModeID == (int)CF_HandleMode.RequiredCourse
  601. && tsy1.Value >= currentSchoolyear.Value
  602. group tesc1 by new { tc1.ClassmajorID, tsy1.SchoolyearID, temc1.CoursematerialID, temc1.TeachingModeID, temc1.EducationMissionClassID } into g
  603. select g.Key);
  604. var query3MissionClassQuery = (from ts in StudentRepository.GetList(filter)
  605. join tc in ClassmajorRepository.Entities on ts.ClassmajorID equals tc.ClassmajorID
  606. from temc in tc.EM_EducationMissionClass
  607. join tem in EducationMissionRepository.Entities on temc.EducationMissionID equals tem.EducationMissionID
  608. join tsy in SchoolyearRepository.Entities on tem.SchoolyearID equals tsy.SchoolyearID
  609. join memc in query3MateMissionClassQuery
  610. on new { tc.ClassmajorID, tsy.SchoolyearID, temc.CoursematerialID, temc.TeachingModeID }
  611. equals new { memc.ClassmajorID, memc.SchoolyearID, memc.CoursematerialID, memc.TeachingModeID } into dmemc
  612. from memc in dmemc.DefaultIfEmpty()
  613. join tesc in (
  614. from esc in EducationSchedulingClassRepository.Entities
  615. group esc by esc.EducationMissionClassID into g
  616. select new { EducationMissionClassID = g.Key, StudentCount = (int?)g.Sum(x => x.CF_Student.Count) }
  617. ) on temc.EducationMissionClassID equals tesc.EducationMissionClassID
  618. where temc.HandleModeID == (int)CF_HandleMode.RequiredCourse
  619. && tsy.Value >= currentSchoolyear.Value
  620. && memc.EducationMissionClassID == null
  621. group tesc by new { tc.ClassmajorID, tsy.SchoolyearID, temc.CoursematerialID, temc.TeachingModeID } into g
  622. select new
  623. {
  624. g.Key.ClassmajorID,
  625. g.Key.SchoolyearID,
  626. g.Key.CoursematerialID,
  627. g.Key.TeachingModeID,
  628. MinStudentCount = g.Min(x => x.StudentCount ?? 0)
  629. }
  630. );
  631. var query3 = from dd in StudentRepository.GetList(filter)
  632. join tmp in (
  633. from tmp in query3MissionClassQuery
  634. join em in EducationMissionRepository.Entities on tmp.SchoolyearID equals em.SchoolyearID
  635. join emc in EducationMissionClassRepository.Entities
  636. on new { EducationMissionID = (Guid?)em.EducationMissionID, tmp.CoursematerialID, tmp.TeachingModeID }
  637. equals new { emc.EducationMissionID, emc.CoursematerialID, emc.TeachingModeID }
  638. from emccc in emc.CF_Classmajor.Where(x => x.ClassmajorID == tmp.ClassmajorID)
  639. join esc in EducationSchedulingClassRepository.Entities on emc.EducationMissionClassID equals esc.EducationMissionClassID
  640. join mesc in (
  641. from esc in EducationSchedulingClassRepository.Entities
  642. group esc by esc.EducationMissionClassID into g
  643. select new { EducationMissionClassID = g.Key, StudentCount = (int?)g.Sum(x => x.CF_Student.Count) }
  644. ) on emc.EducationMissionClassID equals mesc.EducationMissionClassID
  645. where (mesc.StudentCount ?? 0) == tmp.MinStudentCount
  646. group esc by new { tmp.ClassmajorID, tmp.SchoolyearID, tmp.CoursematerialID, tmp.TeachingModeID } into g
  647. select new {
  648. g.Key.ClassmajorID, g.Key.SchoolyearID, g.Key.CoursematerialID, g.Key.TeachingModeID,
  649. MinEducationSchedulingClassID = g.Min(x => x.EducationSchedulingClassID.ToString())
  650. }
  651. ) on dd.ClassmajorID equals tmp.ClassmajorID
  652. select new
  653. {
  654. dd.UserID,
  655. tmp.SchoolyearID,
  656. tmp.CoursematerialID,
  657. tmp.TeachingModeID,
  658. MinEducationSchedulingClassID = tmp.MinEducationSchedulingClassID
  659. };
  660. result.AddRange(query3.ToList().Select(x => new StudentsView { TepTableID = new Guid(x.MinEducationSchedulingClassID), UserID = x.UserID }).ToList());
  661. #endregion
  662. //var query = from df in DifferentDynamicRepository.GetList(filter)
  663. // join em in EducationMissionRepository.GetList(x => x.CF_Schoolyear.Value >= schoolYearValue)
  664. // on df.CF_Schoolyear.Value >= schoolYearValue equals em.CF_Schoolyear.Value >= schoolYearValue
  665. // join emc in EducationMissionClassRepository.Entities on em.EducationMissionID equals emc.EducationMissionID
  666. // from emccc in emc.CF_Classmajor.Where(x => x.ClassmajorID == df.AfterClassmajorID)
  667. // join eds in EducationSchedulingClassRepository.Entities on emc.EducationMissionClassID equals eds.EducationMissionClassID
  668. // from edscc in eds.CF_Student.Where(x => x.UserID == df.UserID).DefaultIfEmpty()
  669. // where edscc.UserID == null
  670. // && df.AfterClassmajorID != df.ClassmajorID
  671. // select new StudentsView
  672. // {
  673. // TepTableID = eds.EducationSchedulingClassID,
  674. // UserID = df.UserID,
  675. // };
  676. return result;
  677. }
  678. #endregion
  679. #region 6.0 考场安排Add
  680. // 考场安排
  681. public IQueryable<EX_ExaminationPlan> GetExaminationPlanStudentInsert(IList<StudentsView> educationMissionResult)
  682. {
  683. var educationSchedulingClassIDList = educationMissionResult.Select(x => x.TepTableID).Distinct().ToList();
  684. var q = (from esc in EducationSchedulingClassRepository.GetList(x => educationSchedulingClassIDList.Contains(x.EducationSchedulingClassID))
  685. join ep in ExaminationPlanRepository.Entities on esc.EM_EducationMissionClass.EducationMissionID equals ep.EducationMissionID
  686. select ep
  687. );
  688. return q;
  689. }
  690. #endregion
  691. #region 7.0 成绩管理Add
  692. //成绩管理
  693. public IQueryable<StudentsView> GetScoreStudentInsert(Expression<Func<CF_Student, bool>> filter, Expression<Func<EM_EducationMissionClass, bool>> missionClassFilter)
  694. {
  695. //期末设定、补考设定为未开放及可录入状态的才进行学生信息调整
  696. var query = from df in StudentRepository.GetList(filter)
  697. //join c in ClassmajorRepository.Entities on dd.ClassmajorID equals c.ClassmajorID
  698. //join g in GrademajorRepository.Entities on c.ClassmajorID equals g.GrademajorID
  699. from sy in SchoolyearRepository.Entities.Where(x => x.IsCurrent == true)
  700. from em in EducationMissionRepository.Entities.Where(x => x.CF_Schoolyear.Value >= sy.Value)
  701. //on df.CF_Schoolyear.Value >= schoolYearValue equals em.CF_Schoolyear.Value >= schoolYearValue
  702. join emc in EducationMissionClassRepository.Entities.Where(missionClassFilter) on em.EducationMissionID equals emc.EducationMissionID
  703. from emccc in emc.CF_Classmajor.Where(x => x.ClassmajorID == df.ClassmajorID)
  704. from fex in FinalExaminationRepository.Entities.Where(x => (
  705. x.ApprovalStatus == (int)CF_ScoreState.CanInput || x.ApprovalStatus == (int)CF_ScoreState.NoCanInput)
  706. && x.ExaminationType == (int)CF_ExaminationType.FinalExamination && x.CF_Schoolyear.Value >= sy.Value
  707. && x.EducationMissionID == em.EducationMissionID)
  708. //on em.EducationMissionID equals fex.EducationMissionID
  709. from fexcc in fex.ER_FinalExaminationStudent.Where(x => x.UserID == df.UserID).DefaultIfEmpty()
  710. where fexcc.UserID == null
  711. select new StudentsView
  712. {
  713. TepTableID = fex.FinalExaminationID,
  714. UserID = df.UserID,
  715. };
  716. return query;
  717. }
  718. #endregion
  719. #region 8.0 教学评价Add
  720. //教学评价
  721. public IQueryable<StudentsView> GetEvaluationSettingStudentInsert(Expression<Func<CF_Student, bool>> filter)
  722. {
  723. //评价设定为未开放状态才进行学生信息调整
  724. Expression<Func<EM_EvaluationSetting, bool>> exp = x => x.OpenStatus == (int)CF_YesOrNoStatus.No;
  725. var query = from df in StudentRepository.GetList(filter)
  726. //join c in ClassmajorRepository.Entities on dd.ClassmajorID equals c.ClassmajorID
  727. //join g in GrademajorRepository.Entities on c.ClassmajorID equals g.GrademajorID
  728. from sy in SchoolyearRepository.Entities.Where(x => x.IsCurrent == true)
  729. from em in EducationMissionRepository.Entities.Where(x => x.CF_Schoolyear.Value >= sy.Value)
  730. //on df.CF_Schoolyear.Value >= schoolYearValue equals em.CF_Schoolyear.Value >= schoolYearValue
  731. join emc in EducationMissionClassRepository.Entities on em.EducationMissionID equals emc.EducationMissionID
  732. from emccc in emc.CF_Classmajor.Where(x => x.ClassmajorID == df.ClassmajorID)
  733. join eds in EvaluationSettingRepository.GetList(exp) on emc.EducationMissionClassID equals eds.EducationMissionClassID
  734. from edscc in eds.CF_Student.Where(x => x.UserID == df.UserID).DefaultIfEmpty()
  735. where edscc.UserID == null
  736. select new StudentsView
  737. {
  738. TepTableID = eds.EvaluationSettingID,
  739. UserID = df.UserID,
  740. };
  741. return query;
  742. }
  743. #endregion
  744. #region 9.0 学生征订
  745. // 学生征订
  746. public IQueryable<ET_StudentsOrder> GetAddStudentsOrder(Expression<Func<CF_Student, bool>> filter)
  747. {
  748. //学生征订未征订状态的才进行信息调整
  749. Expression<Func<ET_StudentsOrder, bool>> exp =
  750. x => x.IsOrdered == false;//未征订
  751. var query = from s in StudentRepository.GetList(filter)
  752. join biss in InSchoolSettingRepository.Entities.Where(x => x.IsSelected == true) on s.InSchoolStatusID equals biss.InSchoolStatusID
  753. join ac in ClassmajorRepository.Entities on s.ClassmajorID equals ac.ClassmajorID
  754. from sy in SchoolyearRepository.Entities.Where(x => x.IsCurrent == true)
  755. from sp in SpecialtyPlanRepository.Entities.Where(x => x.CF_Schoolyear.Value >= sy.Value
  756. && x.GrademajorID == ac.GrademajorID)
  757. join stdOrd in StudentsOrderRepository.GetList(exp) on sp.SpecialtyPlanID equals stdOrd.SpecialtyPlanID
  758. select stdOrd;
  759. return query;
  760. }
  761. #endregion
  762. #region 10.0 学生发放
  763. // 学生发放
  764. public IQueryable<ET_StudentDistribute> GetAddStudentDistribute(Expression<Func<CF_Student, bool>> filter)
  765. {
  766. //学生发放未发放状态的才进行信息调整
  767. Expression<Func<ET_StudentDistribute, bool>> exp =
  768. x => x.RecordStatus == (int)CF_YesOrNoStatus.No;//未发放
  769. var query = from s in StudentRepository.GetList(filter)
  770. join biss in InSchoolSettingRepository.Entities.Where(x => x.IsSelected == true) on s.InSchoolStatusID equals biss.InSchoolStatusID
  771. join ac in ClassmajorRepository.Entities on s.ClassmajorID equals ac.ClassmajorID
  772. from sy in SchoolyearRepository.Entities.Where(x => x.IsCurrent == true)
  773. from sp in SpecialtyPlanRepository.Entities.Where(x => x.CF_Schoolyear.Value >= sy.Value
  774. && x.GrademajorID == ac.GrademajorID)
  775. //on df.CF_Schoolyear.Value >= schoolYearValue equals sp.CF_Schoolyear.Value >= schoolYearValue
  776. join sd in StudentDistributeRepository.GetList(exp) on (Guid)sp.SpecialtyPlanID equals (Guid)sd.SpecialtyPlanID
  777. select sd;
  778. return query;
  779. }
  780. #endregion
  781. }
  782. }