SOCDAL.cs 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.ViewModel.DQPSystem;
  6. using System.Linq.Expressions;
  7. using EMIS.Entities;
  8. using EMIS.DataLogic.Repositories;
  9. using EMIS.ViewModel.EducationManagement;
  10. using EMIS.ViewModel;
  11. using EMIS.ViewModel.EducationManage;
  12. using EMIS.ViewModel.Students;
  13. using Bowin.Common.Linq;
  14. using EMIS.DataLogic.UniversityManage.AdministrativeOrgan;
  15. using EMIS.ViewModel.UniversityManage.SpecialtyClassManage;
  16. using EMIS.ViewModel.UniversityManage.AdministrativeOrgan;
  17. namespace EMIS.DataLogic.DQPSystem
  18. {
  19. public partial class SOCDAL
  20. {
  21. public SOCRepository SOCRepository { get; set; }
  22. public SOCDetailRepository SOCDetailRepository { get; set; }
  23. public SOCDetailAttachmentRepository SOCDetailAttachmentRepository { get; set; }
  24. public SOCTemplateRepository SOCTemplateRepository { get; set; }
  25. public SchoolyearRepository schoolyearRepository { get; set; }
  26. public CoursematerialRepository coursematerialRepository { get; set; }
  27. public EducationMissionClassRepository educationMissionClassRepository { get; set; }
  28. public EducationMissionRepository educationMissionRepository { get; set; }
  29. public ClassmajorRepository classmajorRepository { get; set; }
  30. public GrademajorRepository grademajorRepository { get; set; }
  31. public StudentRepository studentRepository { get; set; }
  32. public EducationSchedulingClassRepository educationSchedulingClassRepository { get; set; }
  33. public CollegeDAL CollegeDAL { get; set; }
  34. public CollegeRepository collegeRepository { get; set; }
  35. public IQueryable<SOCView> GetSOCViewQueryable(Expression<Func<DQP_SOC, bool>> exp, Guid? userID)
  36. {
  37. var query = from soc in SOCRepository.GetList(exp)
  38. join year in schoolyearRepository.Entities
  39. on soc.SchoolyearID equals year.SchoolyearID
  40. into sch
  41. from gsch in sch.DefaultIfEmpty()
  42. join cou in coursematerialRepository.Entities
  43. on soc.CoursematerialID equals cou.CoursematerialID
  44. into cmr
  45. from gcmr in cmr.DefaultIfEmpty()
  46. join edu in educationMissionRepository.Entities
  47. on soc.EducationMissionID equals edu.EducationMissionID
  48. into gedu
  49. from edu in gedu.DefaultIfEmpty()
  50. select new SOCView
  51. {
  52. SOCID = soc.SOCID,
  53. EducationMissionID = soc.EducationMissionID,
  54. EducationMissionName = edu.ClassName,
  55. SchoolyearID = soc.SchoolyearID,
  56. SchoolyearCode = gsch.Code,
  57. CoursematerialID = gcmr.CoursematerialID,
  58. CourseCode = gcmr.CourseCode,
  59. CourseName = gcmr.CourseName,
  60. StudentCount = soc.CF_Student.Count,
  61. //soc.DQP_SOCStaff.FirstOrDefault(x => x.UserID == userID).CF_Student.Count,
  62. HandleModeID = soc.HandleModeID,
  63. DepartmentID = soc.DepartmentID,
  64. Credit = soc.Credit,
  65. OptionalCourseTypeID = soc.OptionalCourseTypeID,
  66. };
  67. if (userID != null)
  68. {
  69. query = from soc in SOCRepository.GetList(exp).Where(x => x.DQP_SOCStaff.Any(y => y.UserID == userID))
  70. join year in schoolyearRepository.Entities
  71. on soc.SchoolyearID equals year.SchoolyearID
  72. into sch
  73. from gsch in sch.DefaultIfEmpty()
  74. join cou in coursematerialRepository.Entities
  75. on soc.CoursematerialID equals cou.CoursematerialID
  76. into cmr
  77. from gcmr in cmr.DefaultIfEmpty()
  78. join edu in educationMissionRepository.Entities
  79. on soc.EducationMissionID equals edu.EducationMissionID
  80. into gedu
  81. from edu in gedu.DefaultIfEmpty()
  82. select new SOCView
  83. {
  84. SOCID = soc.SOCID,
  85. EducationMissionID = soc.EducationMissionID,
  86. EducationMissionName = edu.ClassName,
  87. SchoolyearID = soc.SchoolyearID,
  88. SchoolyearCode = gsch.Code,
  89. CoursematerialID = gcmr.CoursematerialID,
  90. CourseCode = gcmr.CourseCode,
  91. CourseName = gcmr.CourseName,
  92. StudentCount = soc.CF_Student.Count,
  93. //soc.DQP_SOCStaff.FirstOrDefault(x => x.UserID == userID).CF_Student.Count,
  94. HandleModeID = soc.HandleModeID,
  95. DepartmentID = soc.DepartmentID,
  96. Credit = soc.Credit,
  97. OptionalCourseTypeID = soc.OptionalCourseTypeID,
  98. };
  99. }
  100. return query;
  101. }
  102. public IQueryable<SOCDetailView> GetSOCDetailViewQueryable(Expression<Func<DQP_SOCDetail, bool>> exp)
  103. {
  104. var query = from detail in SOCDetailRepository.GetList(exp)
  105. join edu in educationMissionRepository.Entities
  106. on detail.DQP_SOC.EducationMissionID equals edu.EducationMissionID
  107. into dedu
  108. from edu in dedu.DefaultIfEmpty()
  109. select new SOCDetailView
  110. {
  111. SOCDetailID = detail.SOCDetailID,
  112. EducationMissionID = detail.DQP_SOC.EducationMissionID,
  113. EducationMissionName = edu.ClassName,
  114. SOCID = detail.SOCID,
  115. SchoolyearID = detail.DQP_SOC.SchoolyearID,
  116. SchoolyearCode = detail.DQP_SOC.CF_Schoolyear.Code,
  117. CoursematerialID = detail.DQP_SOC.CoursematerialID,
  118. CourseCode = detail.DQP_SOC.EM_Coursematerial.CourseCode,
  119. CourseName = detail.DQP_SOC.EM_Coursematerial.CourseName,
  120. Name = detail.Name,
  121. Weight = detail.Weight,
  122. Credit = detail.Credit,
  123. Description = detail.Description,
  124. IsGroup = detail.IsGroup,
  125. IsGroupin = detail.IsGroup.Value,
  126. StartTime = detail.StartTime,
  127. EndTime = detail.EndTime,
  128. Attachment = detail.DQP_SOCDetailAttachment,
  129. GroupCount = detail.DQP_SOCDetailGroup.Count(),
  130. StudentCount = detail.DQP_SOC.CF_Student.Count,
  131. };
  132. return query;
  133. }
  134. /// <summary>
  135. /// 生成当前学年学期,登录人是主讲的
  136. /// </summary>
  137. /// <param name="schoolyearID"></param>
  138. /// <param name="userID"></param>
  139. /// <returns></returns>
  140. public IQueryable<SOCGenerateView> GetSOCGenerateViewQueryble(Guid? schoolyearID, Guid? userID)
  141. {
  142. var query = from emr in educationMissionRepository.GetList(x => x.SchoolyearID == schoolyearID)
  143. join emcr in educationMissionClassRepository.GetList(x => x.EM_MissionClassTeacher.Any(y => y.UserID == userID && y.TeachType == (int)EM_TeachingMethod.Lecturer) && x.RecordStatus != (int)EM_EducationMissionClassStatus.NotSubmitted)
  144. on emr.EducationMissionID equals emcr.EducationMissionID
  145. from cla in emcr.CF_Classmajor
  146. join gra in grademajorRepository.Entities
  147. on cla.GrademajorID equals gra.GrademajorID
  148. into ggra
  149. from gra in ggra.DefaultIfEmpty()
  150. join sch in schoolyearRepository.Entities
  151. on emr.SchoolyearID equals sch.SchoolyearID
  152. into gsch
  153. from sch in gsch.DefaultIfEmpty()
  154. group emr
  155. by new
  156. {
  157. emr.EducationMissionID,
  158. emcr.HandleModeID,
  159. emcr.OptionalCourseTypeID,
  160. emcr.CoursematerialID,
  161. emr.DepartmentID,
  162. emr.SchoolyearID,
  163. sch.Value,
  164. yearID = gra.GradeID,
  165. gra.SemesterID,
  166. emr.EM_EducationMissionClass.FirstOrDefault().EM_EducationMissionClassTeachingSetting.Credit,
  167. }
  168. into gemr
  169. //join emc in educationMissionClassRepository.GetList(x => x.RecordStatus != (int)EM_EducationMissionClassStatus.NotSubmitted)
  170. //on gemr.Key.EducationMissionID equals emc.EducationMissionID
  171. //join sche in educationSchedulingClassRepository.Entities
  172. //on emc.EducationMissionClassID equals sche.EducationMissionClassID
  173. select new SOCGenerateView
  174. {
  175. EducationMissionID = gemr.Key.EducationMissionID,
  176. HandleModeID = gemr.Key.HandleModeID,
  177. OptionalCourseTypeID = gemr.Key.OptionalCourseTypeID,
  178. SchoolyearNumID = (gemr.Key.Value - ((gemr.Key.yearID * 2 - 1) + gemr.Key.SemesterID - 1))/2 + 1,
  179. SchoolcodeID = gemr.Key.SemesterID,
  180. SOCView = new SOCView
  181. {
  182. SchoolyearID = gemr.Key.SchoolyearID,
  183. DepartmentID = gemr.Key.DepartmentID,
  184. CoursematerialID = gemr.Key.CoursematerialID,
  185. Credit = gemr.Key.Credit,
  186. },
  187. };
  188. //var query = from emr in educationMissionRepository.GetList(x => x.SchoolyearID == schoolyearID)
  189. // join emcr in educationMissionClassRepository.GetList(x => x.EM_MissionClassTeacher.Any(y => y.UserID == userID) && x.RecordStatus != (int)EM_EducationMissionClassStatus.NotSubmitted)
  190. // on emr.EducationMissionID equals emcr.EducationMissionID
  191. // from cla in emcr.CF_Classmajor
  192. // join gra in grademajorRepository.Entities
  193. // on cla.GrademajorID equals gra.GrademajorID
  194. // join sch in schoolyearRepository.Entities
  195. // on emr.SchoolyearID equals sch.SchoolyearID
  196. // //group emr
  197. // //by new { emr.EducationMissionID, emcr.HandleModeID, emcr.OptionalCourseTypeID, gra.FacultymajorID, emcr.CoursematerialID,
  198. // // emr.DepartmentID, emr.SchoolyearID, sch.Value, yearID = gra.SchoolyearID, gra.SchoolcodeID }
  199. // // into gemr
  200. // select new {
  201. // emr.EducationMissionID,
  202. // emcr.CoursematerialID,
  203. // emr.DepartmentID,
  204. // gra.FacultymajorID,
  205. // emcr.HandleModeID,
  206. // emcr.OptionalCourseTypeID,
  207. // gra.SchoolcodeID,
  208. // SchoolyearNumID = (sch.Value - ((gra.SchoolyearID * 2 - 1) + gra.SchoolcodeID - 1)) / 2 + 1,
  209. // emr.SchoolyearID,
  210. // }into ggemr
  211. // join soctem in SOCTemplateRepository.GetList(x => x.RecordStatus == (int)SYS_STATUS.USABLE)
  212. // on new { ggemr.CoursematerialID, ggemr.DepartmentID }
  213. // //, ggemr.SchoolcodeID, ggemr.SchoolyearNumID, ggemr.FacultymajorID, ggemr.HandleModeID
  214. // equals new { soctem.CoursematerialID, soctem.DepartmentID }
  215. // //, soctem.SchoolcodeID, soctem.SchoolyearNumID, soctem.FacultymajorID, soctem.HandleModeID
  216. // where (ggemr.SchoolcodeID == soctem.SchoolcodeID || soctem.SchoolcodeID == null)
  217. // && (ggemr.SchoolyearNumID == soctem.SchoolyearNumID || soctem.SchoolyearNumID == null)
  218. // && (ggemr.FacultymajorID == soctem.FacultymajorID || soctem.FacultymajorID == null)
  219. // && (ggemr.HandleModeID == soctem.HandleModeID || soctem.HandleModeID == null)
  220. // group ggemr
  221. // by new {ggemr.SchoolyearID, soctem.SOCTemplateID }
  222. // into gsoc
  223. // join soc in SOCTemplateRepository.GetList(x => x.RecordStatus == (int)SYS_STATUS.USABLE)
  224. // on gsoc.Key.SOCTemplateID equals soc.SOCTemplateID
  225. // //join edumr in educationMissionRepository.Entities
  226. // //on ggemr.EducationMissionID equals edumr.EducationMissionID
  227. // //join edumcr in educationMissionClassRepository.Entities
  228. // //on edumr.EducationMissionID equals edumcr.EducationMissionID
  229. // //join sche in educationSchedulingClassRepository.Entities
  230. // //on edumcr.EducationMissionClassID equals sche.EducationMissionClassID
  231. // select new SOCGenerateView
  232. // {
  233. // HandleModeID = soc.HandleModeID,
  234. // OptionalCourseTypeID = soc.OptionalCourseTypeID,
  235. // FacultymajorID = soc.FacultymajorID,
  236. // SOCTemplateID = soc.SOCTemplateID,
  237. // SchoolyearNumID = soc.SchoolyearNumID,
  238. // SchoolcodeID = soc.SchoolcodeID,
  239. // SOCView = new SOCView
  240. // {
  241. // SchoolyearID = gsoc.Key.SchoolyearID,
  242. // DepartmentID = soc.DepartmentID,
  243. // CoursematerialID = soc.CoursematerialID,
  244. // Credit = soc.Credit
  245. // },
  246. // //SOCDetailViewList = soctem.DQP_SOCTemplateDetail.Select(x => new SOCDetailView
  247. // //{
  248. // // Name = x.Name,
  249. // // Weight = x.Weight,
  250. // // Credit = x.Credit,
  251. // // Description = x.Description,
  252. // // IsGroup = x.IsGroup,
  253. // // AttachmentList = x.DQP_SOCTemplateDetailAttachment.Select(y => new SOCDetailAttachmentView
  254. // // {
  255. // // Name = y.Name,
  256. // // Url = y.Url,
  257. // // })
  258. // //}),
  259. // //MissionClassTeacherViewList = edumcr.EM_MissionClassTeacher.Select(x => new MissionClassTeacherView
  260. // //{
  261. // // UserID = x.UserID,
  262. // // TeachingMethod = x.TeachType,
  263. // //}),
  264. // //StudentList = sche.CF_Student,
  265. // //ClassmajorList = edumcr.CF_Classmajor,
  266. // };
  267. return query;
  268. }
  269. public IQueryable<SOCGenerateView> GetEducationMissionMassageByID(Expression<Func<EM_EducationMission, bool>> exp)
  270. {
  271. var query = from em in educationMissionRepository.GetList(exp)
  272. join emc in educationMissionClassRepository.GetList(x => x.RecordStatus != (int)EM_EducationMissionClassStatus.NotSubmitted)
  273. on em.EducationMissionID equals emc.EducationMissionID
  274. join sche in educationSchedulingClassRepository.Entities
  275. on emc.EducationMissionClassID equals sche.EducationMissionClassID
  276. select new SOCGenerateView
  277. {
  278. HandleModeID = emc.HandleModeID,
  279. OptionalCourseTypeID = emc.OptionalCourseTypeID,
  280. EducationMissionID = emc.EducationMissionID,
  281. SOCView = new SOCView
  282. {
  283. SchoolyearID = em.SchoolyearID,
  284. DepartmentID = em.DepartmentID,
  285. CoursematerialID = emc.CoursematerialID,
  286. },
  287. MissionClassTeacherViewList = emc.EM_MissionClassTeacher.Where(x => x.TeachType == (int)EM_TeachingMethod.Lecturer).Select(x => new MissionClassTeacherView
  288. {
  289. UserID = x.UserID,
  290. TeachingMethod = x.TeachType,
  291. }),
  292. ClassmajorList = emc.CF_Classmajor,
  293. StudentList = sche.CF_Student,
  294. };
  295. return query;
  296. }
  297. public List<CF_Student> GetStudentByTeacher(Expression<Func<EM_EducationMission, bool>> exp, Guid? userID, Guid? coursematerialID)
  298. {
  299. var query = from em in educationMissionRepository.GetList(exp)
  300. join emc in educationMissionClassRepository.GetList(x => x.EM_MissionClassTeacher.Any(y => y.UserID == userID)
  301. && x.RecordStatus != (int)EM_EducationMissionClassStatus.NotSubmitted && x.CoursematerialID == coursematerialID)
  302. on em.EducationMissionID equals emc.EducationMissionID
  303. join sche in educationSchedulingClassRepository.Entities
  304. on emc.EducationMissionClassID equals sche.EducationMissionClassID
  305. select new SOCGenerateView
  306. {
  307. StudentList = sche.CF_Student,
  308. };
  309. return query.SelectMany(x => x.StudentList).ToList();
  310. }
  311. public IQueryable<SOCGenerateView> GetSOCTemplateForSOCGenerate(Expression<Func<DQP_SOCTemplate, bool>> exp)
  312. {
  313. var query = from soc in SOCTemplateRepository.GetList(exp)
  314. select new SOCGenerateView
  315. {
  316. SOCTemplateID = soc.SOCTemplateID,
  317. SOCDetailViewList = soc.DQP_SOCTemplateDetail.Select(x => new SOCDetailView
  318. {
  319. Name = x.Name,
  320. Weight = x.Weight,
  321. Credit = x.Credit,
  322. Description = x.Description,
  323. IsGroup = x.IsGroup,
  324. AttachmentList = x.DQP_SOCTemplateDetailAttachment.Select(y => new SOCDetailAttachmentView
  325. {
  326. Name = y.Name,
  327. Url = y.Url,
  328. })
  329. }),
  330. };
  331. return query;
  332. }
  333. public IOrderedQueryable<FileUploadView> GetSOCDetailAttachmentView(Expression<Func<DQP_SOCDetail, bool>> exp)
  334. {
  335. var tableName = typeof(DQP_SOCDetailAttachment).Name;
  336. var sql = (from @group in SOCDetailRepository.GetList(exp)
  337. from attachment in @group.DQP_SOCDetailAttachment
  338. orderby attachment.CreateTime descending
  339. select new FileUploadView
  340. {
  341. FileID = attachment.SOCDetailAttachmentID,
  342. FileName = attachment.Name,
  343. FileUrl = attachment.Url,
  344. FormID = attachment.SOCDetailID,
  345. TableName = tableName
  346. });
  347. return (IOrderedQueryable<FileUploadView>)sql;
  348. }
  349. /// <summary>
  350. /// 获取学生信息
  351. /// </summary>
  352. /// <param name="finalExaminationID"></param>
  353. /// <returns></returns>
  354. public IQueryable<BaseStudentView> GetSOCStudentList(Guid? SOCID)
  355. {
  356. var curUser = EMIS.Utility.FormValidate.CustomPrincipal.Current;
  357. var query = from a in SOCRepository.GetList(x => x.SOCID == SOCID)
  358. from c in a.DQP_SOCStaff.FirstOrDefault(x => x.UserID == curUser.UserID).CF_Student
  359. select new BaseStudentView
  360. {
  361. UserID = c.UserID,
  362. LoginID = c.Sys_User.LoginID,
  363. UserName = c.Sys_User.Name,
  364. SexID = c.SexID,
  365. IDNumber = c.IDNumber,
  366. InSchoolStatusID = c.InSchoolStatusID,
  367. StudentStatus = c.StudentStatus,
  368. ClassmajorCode = c.CF_Classmajor.No,
  369. ClassmajorName = c.CF_Classmajor.Name,
  370. };
  371. return query;
  372. }
  373. public IQueryable<CollegeView> GetCollegeViewList(Expression<Func<DQP_SOC, bool>> exp, Expression<Func<CF_Staff, bool>> staffExp)
  374. {
  375. var query = from soc in SOCRepository.Entities.Where(exp)
  376. from teacher in soc.DQP_SOCStaff
  377. from staff in StaffRepository.Entities.Where(staffExp).Where(x => x.UserID == teacher.UserID)
  378. from em in educationMissionRepository.Entities.Where(x => x.EducationMissionID == soc.EducationMissionID)
  379. from col in collegeRepository.Entities.Where(x => x.CollegeID == em.CollegeID)
  380. select new CollegeView
  381. {
  382. CollegeID = col.CollegeID,
  383. No = col.No,
  384. Name = col.Name,
  385. SimpleName = col.SimpleName,
  386. EnglishName = col.EnglishName,
  387. CampusID = col.CampusID,
  388. Remark = col.Remark,
  389. RecordStatus = col.RecordStatus,
  390. CreateUserID = col.CreateUserID,
  391. CreateTime = col.CreateTime,
  392. ModifyUserID = col.ModifyUserID,
  393. ModifyTime = col.ModifyTime
  394. };
  395. return query.Distinct();
  396. }
  397. public IQueryable<ClassmajorView> GetClassmajorViewList(Expression<Func<DQP_SOC, bool>> exp, Expression<Func<CF_Staff, bool>> staffExp, Expression<Func<CF_Classmajor, bool>> classExp)
  398. {
  399. var query = from soc in SOCRepository.Entities.Where(exp)
  400. from teacher in soc.DQP_SOCStaff
  401. from staff in StaffRepository.Entities.Where(staffExp).Where(x => x.UserID == teacher.UserID)
  402. from em in educationMissionRepository.Entities.Where(x => x.EducationMissionID == soc.EducationMissionID)
  403. from emc in educationMissionClassRepository.Entities.Where(x => x.EducationMissionID == em.EducationMissionID)
  404. from cl in classmajorRepository.Entities.Where(classExp).Where(x => x.ClassmajorID == emc.MainScheduleClassID)
  405. select new ClassmajorView
  406. {
  407. ClassmajorID = cl.ClassmajorID,
  408. No = cl.No,
  409. Name = cl.Name,
  410. Abbreviation = cl.Abbreviation,
  411. EnglishName = cl.EnglishName,
  412. ClassNum = cl.ClassNum,
  413. UserID = cl.UserID,
  414. Fixedclassroom = cl.Fixedclassroom,
  415. Remark = cl.Remark,
  416. RecordStatus = cl.RecordStatus,
  417. CreateUserID = cl.CreateUserID,
  418. CreateTime = cl.CreateTime,
  419. ModifyUserID = cl.ModifyUserID,
  420. ModifyTime = cl.ModifyTime
  421. };
  422. return query.Distinct();
  423. }
  424. }
  425. }