PlanApplicationDAL.cs 23 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Linq.Expressions;
  6. using EMIS.Entities;
  7. using EMIS.ViewModel;
  8. using EMIS.ViewModel.CacheManage;
  9. using EMIS.ViewModel.CultureplanManage;
  10. using EMIS.DataLogic.Repositories;
  11. using EMIS.ViewModel.CultureplanManage.PlanManagement;
  12. namespace EMIS.DataLogic.CultureplanManage.PlanManagement
  13. {
  14. public class PlanApplicationDAL
  15. {
  16. public PlanApplicationRepository PlanApplicationRepository { get; set; }
  17. public PlanApplicationTeachingSettingRepository PlanApplicationTeachingSettingRepository { get; set; }
  18. public PlanApplicationTeachingModeTypeRepository PlanApplicationTeachingModeTypeRepository { get; set; }
  19. public PlanApplicationTeachingPlaceRepository PlanApplicationTeachingPlaceRepository { get; set; }
  20. public SchoolyearRepository SchoolyearRepository { get; set; }
  21. public CoursematerialRepository CoursematerialRepository { get; set; }
  22. public DepartmentRepository DepartmentRepository { get; set; }
  23. public GrademajorRepository GrademajorRepository { get; set; }
  24. public FacultymajorRepository FacultymajorRepository { get; set; }
  25. public CollegeRepository CollegeRepository { get; set; }
  26. public CampusRepository CampusRepository { get; set; }
  27. public SpecialtyRepository SpecialtyRepository { get; set; }
  28. public SpecialtyCourseRepository SpecialtyCourseRepository { get; set; }
  29. public SpecialtyCourseTeachingSettingRepository SpecialtyCourseTeachingSettingRepository { get; set; }
  30. public SpecialtyPlanRepository SpecialtyPlanRepository { get; set; }
  31. public SpecialtyPlanTeachingSettingRepository SpecialtyPlanTeachingSettingRepository { get; set; }
  32. public DictionaryItemRepository DictionaryItemRepository { get; set; }
  33. /// <summary>
  34. /// 查询计划申请信息PlanApplicationView
  35. /// 注:普教版本(年级专业)
  36. /// </summary>
  37. /// <param name="exp"></param>
  38. /// <returns></returns>
  39. public IQueryable<PlanApplicationView> GetPlanApplicationViewQueryable(Expression<Func<EM_PlanApplication, bool>> exp)
  40. {
  41. var query = from pa in PlanApplicationRepository.GetList(exp)
  42. join past in PlanApplicationTeachingSettingRepository.Entities
  43. on pa.PlanApplicationID equals past.PlanApplicationID into temppast
  44. from papast in temppast.DefaultIfEmpty()
  45. join sy in SchoolyearRepository.Entities
  46. on pa.SchoolyearID equals sy.SchoolyearID
  47. join cou in CoursematerialRepository.Entities
  48. on pa.CoursematerialID equals cou.CoursematerialID
  49. join dep in DepartmentRepository.Entities
  50. on pa.DepartmentID equals dep.DepartmentID into tempdep
  51. from padep in tempdep.DefaultIfEmpty()
  52. join gr in GrademajorRepository.Entities
  53. on pa.GrademajorID equals gr.GrademajorID
  54. join stsy in SchoolyearRepository.Entities
  55. on new { SchoolyearID = gr.GradeID.Value, SchoolcodeID = gr.SemesterID.Value }
  56. equals new { SchoolyearID = stsy.Years, SchoolcodeID = stsy.SchoolcodeID } into tempstsy
  57. from startsy in tempstsy.DefaultIfEmpty()
  58. join fa in FacultymajorRepository.Entities
  59. on gr.FacultymajorID equals fa.FacultymajorID
  60. join spe in SpecialtyRepository.Entities
  61. on new { StandardID = fa.StandardID, EducationID = fa.EducationID, LearningformID = fa.LearningformID, LearnSystem = fa.LearnSystem }
  62. equals new { StandardID = spe.StandardID, EducationID = spe.EducationID, LearningformID = spe.LearningformID, LearnSystem = spe.LearnSystem }
  63. join dicst in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_Standard).Name)
  64. on fa.StandardID equals dicst.Value into tempst
  65. from fast in tempst.DefaultIfEmpty()
  66. join col in CollegeRepository.Entities
  67. on fa.CollegeID equals col.CollegeID
  68. join cam in CampusRepository.Entities
  69. on col.CampusID equals cam.CampusID
  70. select new PlanApplicationView
  71. {
  72. PlanApplicationID = pa.PlanApplicationID,
  73. SchoolyearID = pa.SchoolyearID,
  74. SchoolyearCode = sy.Code,
  75. YearID = sy.Years,
  76. Value = sy.Value,
  77. SchoolyearNumID = (sy.Value - ((gr.GradeID * 2 - 1) + gr.SemesterID - 1)) / 2 + 1,
  78. SchoolcodeID = sy.SchoolcodeID,
  79. StarttermID = sy.Value - ((gr.GradeID * 2 - 1) + gr.SemesterID - 1) + 1,
  80. GrademajorID = pa.GrademajorID,
  81. GrademajorCode = gr.Code,
  82. GrademajorName = gr.Name,
  83. GradeID = gr.GradeID,
  84. FacultymajorID = gr.FacultymajorID,
  85. FacultymajorCode = fa.Code,
  86. FacultymajorName = fa.Name,
  87. CollegeID = fa.CollegeID,
  88. CollegeCode = col.No,
  89. CollegeName = col.Name,
  90. CampusID = col.CampusID,
  91. CampusNo = cam.No,
  92. CampusName = cam.Name,
  93. StartSchoolyearID = startsy.SchoolyearID,
  94. StartSchoolyearCode = startsy.Code,
  95. StartValue = startsy.Value,
  96. StartSchoolcodeID = gr.SemesterID,
  97. SpecialtyID = spe.SpecialtyID,
  98. StandardID = fa.StandardID,
  99. StandardName = fast.Name,
  100. EducationID = fa.EducationID,
  101. LearningformID = fa.LearningformID,
  102. LearnSystem = fa.LearnSystem,
  103. CoursematerialID = pa.CoursematerialID,
  104. CourseCode = cou.CourseCode,
  105. CourseName = cou.CourseName,
  106. CourseStructureID = pa.CourseStructureID,
  107. CourseCategoryID = pa.CourseCategoryID,
  108. CourseTypeID = pa.CourseTypeID,
  109. CourseQualityID = pa.CourseQualityID,
  110. Credit = papast.Credit ?? 0,
  111. TheoryCourse = papast.TheoryCourse ?? 0,
  112. Practicehours = papast.Practicehours ?? 0,
  113. Trialhours = papast.Trialhours ?? 0,
  114. Totalhours = (papast.TheoryCourse ?? 0) + (papast.Practicehours ?? 0),
  115. TheoryWeeklyNum = papast.TheoryWeeklyNum ?? 0,
  116. PracticeWeeklyNum = papast.PracticeWeeklyNum ?? 0,
  117. TrialWeeklyNum = papast.TrialWeeklyNum ?? 0,
  118. SchoolweeksNum = (papast.TheoryWeeklyNum ?? 0) + (papast.PracticeWeeklyNum ?? 0),
  119. WeeklyHours = papast.WeeklyHours ?? 0,
  120. WeeklyNum = papast.WeeklyNum ?? 0,
  121. StartWeeklyNum = papast.StartWeeklyNum ?? 0,
  122. EndWeeklyNum = papast.EndWeeklyNum ?? 0,
  123. StartEndWeeklyNum = (papast.StartWeeklyNum ?? 0) + "-" + (papast.EndWeeklyNum ?? 0),
  124. DepartmentID = pa.DepartmentID,
  125. DepartmentCode = padep.No,
  126. DepartmentName = padep.Name,
  127. CourseCollegeID = padep.CollegeID,
  128. CourseCollegeCode = padep.CF_College.No,
  129. CourseCollegeName = padep.CF_College.Name,
  130. IsSpecialtycore = pa.IsSpecialtycore ?? false,
  131. IsCooperation = pa.IsCooperation ?? false,
  132. IsRequired = pa.IsRequired ?? false,
  133. IsElective = pa.IsElective ?? false,
  134. IsNetworkCourse = pa.IsNetworkCourse ?? false,
  135. IsMainCourse = pa.IsMainCourse ?? false,
  136. IsNeedMaterial = pa.IsNeedMaterial ?? false,
  137. CourseFineID = pa.CourseFineID,
  138. PracticeTypeID = pa.PracticeTypeID,
  139. TeachinglanguageID = pa.TeachinglanguageID,
  140. ExaminationModeID = pa.ExaminationModeID,
  141. ResultTypeID = pa.ResultTypeID,
  142. HandleModeID = pa.HandleModeID,
  143. TeachingModeIDList = pa.EM_PlanApplicationTeachingModeType.Select(x => x.TeachingModeID).ToList(),
  144. TeachingPlaceIDList = pa.EM_PlanApplicationTeachingPlace.Select(x => x.TeachingPlace).ToList(),
  145. Remark = pa.Remark,
  146. ApprovalStatus = pa.RecordStatus,
  147. RecordStatus = pa.RecordStatus,
  148. CreateUserID = pa.CreateUserID,
  149. CreateTime = pa.CreateTime,
  150. ModifyUserID = pa.ModifyUserID,
  151. ModifyTime = pa.ModifyTime
  152. };
  153. return query;
  154. }
  155. /// <summary>
  156. /// 查询对应的未申请专业课程信息
  157. /// 注:普教版本(年级专业)
  158. /// </summary>
  159. /// <param name="expSpecialtyCourse"></param>
  160. /// <param name="expGrademajor"></param>
  161. /// <param name="expPlanApplication"></param>
  162. /// <param name="expSpecialtyPlan"></param>
  163. /// <returns></returns>
  164. public IQueryable<SpecialtyCourseView> GetSpecialtyCourseViewNoApplyQueryable(Expression<Func<EM_SpecialtyCourse, bool>> expSpecialtyCourse,
  165. Expression<Func<CF_Grademajor, bool>> expGrademajor, Expression<Func<EM_PlanApplication, bool>> expPlanApplication,
  166. Expression<Func<EM_SpecialtyPlan, bool>> expSpecialtyPlan)
  167. {
  168. var query = from sc in SpecialtyCourseRepository.GetList(expSpecialtyCourse)
  169. join spe in SpecialtyRepository.Entities
  170. on sc.SpecialtyID equals spe.SpecialtyID
  171. join fa in FacultymajorRepository.Entities
  172. on new { StandardID = spe.StandardID, EducationID = spe.EducationID, LearningformID = spe.LearningformID, LearnSystem = spe.LearnSystem }
  173. equals new { StandardID = fa.StandardID, EducationID = fa.EducationID, LearningformID = fa.LearningformID, LearnSystem = fa.LearnSystem }
  174. join gr in GrademajorRepository.GetList(expGrademajor)
  175. on fa.FacultymajorID equals gr.FacultymajorID
  176. join dicst in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_Standard).Name)
  177. on spe.StandardID equals dicst.Value into tempst
  178. from spest in tempst.DefaultIfEmpty()
  179. join cou in CoursematerialRepository.Entities
  180. on sc.CoursematerialID equals cou.CoursematerialID
  181. join scts in SpecialtyCourseTeachingSettingRepository.Entities
  182. on sc.SpecialtyCourseID equals scts.SpecialtyCourseID into tempscts
  183. from scscts in tempscts.DefaultIfEmpty()
  184. join dep in DepartmentRepository.Entities
  185. on sc.DepartmentID equals dep.DepartmentID into tempdep
  186. from scdep in tempdep.DefaultIfEmpty()
  187. join col in CollegeRepository.Entities
  188. on scdep.CollegeID equals col.CollegeID into tempcol
  189. from sccol in tempcol.DefaultIfEmpty()
  190. join pa in
  191. (
  192. from pa in PlanApplicationRepository.GetList(expPlanApplication)
  193. join sy in SchoolyearRepository.Entities
  194. on pa.SchoolyearID equals sy.SchoolyearID
  195. join gr in GrademajorRepository.Entities
  196. on pa.GrademajorID equals gr.GrademajorID
  197. join fa in FacultymajorRepository.Entities
  198. on gr.FacultymajorID equals fa.FacultymajorID
  199. join spe in SpecialtyRepository.Entities
  200. on new { StandardID = fa.StandardID, EducationID = fa.EducationID, LearningformID = fa.LearningformID, LearnSystem = fa.LearnSystem }
  201. equals new { StandardID = spe.StandardID, EducationID = spe.EducationID, LearningformID = spe.LearningformID, LearnSystem = spe.LearnSystem }
  202. join past in PlanApplicationTeachingSettingRepository.Entities
  203. on pa.PlanApplicationID equals past.PlanApplicationID into temppast
  204. from papast in temppast.DefaultIfEmpty()
  205. join dep in DepartmentRepository.Entities
  206. on pa.DepartmentID equals dep.DepartmentID into tempdep
  207. from padep in tempdep.DefaultIfEmpty()
  208. select new
  209. {
  210. PlanApplicationID = pa.PlanApplicationID,
  211. SchoolyearNumID = (sy.Value - ((gr.GradeID * 2 - 1) + gr.SemesterID - 1)) / 2 + 1,
  212. SchoolcodeID = sy.SchoolcodeID,
  213. StarttermID = sy.Value - ((gr.GradeID * 2 - 1) + gr.SemesterID - 1) + 1,
  214. SpecialtyID = spe.SpecialtyID,
  215. GrademajorID = pa.GrademajorID,
  216. CoursematerialID = pa.CoursematerialID,
  217. CourseTypeID = pa.CourseTypeID,
  218. Credit = papast.Credit,
  219. DepartmentID = padep.DepartmentID
  220. }
  221. )
  222. on new { GrademajorID = gr.GrademajorID, StarttermID = sc.StarttermID, CoursematerialID = sc.CoursematerialID }
  223. equals new { GrademajorID = pa.GrademajorID.Value, StarttermID = pa.StarttermID, CoursematerialID = pa.CoursematerialID } into temppa
  224. from scpa in temppa.DefaultIfEmpty()
  225. join sp in
  226. (
  227. from sp in SpecialtyPlanRepository.GetList(expSpecialtyPlan)
  228. join sy in SchoolyearRepository.Entities
  229. on sp.SchoolyearID equals sy.SchoolyearID
  230. join gr in GrademajorRepository.Entities
  231. on sp.GrademajorID equals gr.GrademajorID
  232. join fa in FacultymajorRepository.Entities
  233. on gr.FacultymajorID equals fa.FacultymajorID
  234. join spe in SpecialtyRepository.Entities
  235. on new { StandardID = fa.StandardID, EducationID = fa.EducationID, LearningformID = fa.LearningformID, LearnSystem = fa.LearnSystem }
  236. equals new { StandardID = spe.StandardID, EducationID = spe.EducationID, LearningformID = spe.LearningformID, LearnSystem = spe.LearnSystem }
  237. join spst in SpecialtyPlanTeachingSettingRepository.Entities
  238. on sp.SpecialtyPlanID equals spst.SpecialtyPlanID into tempspst
  239. from spspst in tempspst.DefaultIfEmpty()
  240. join dep in DepartmentRepository.Entities
  241. on sp.DepartmentID equals dep.DepartmentID into tempdep
  242. from spdep in tempdep.DefaultIfEmpty()
  243. select new
  244. {
  245. SpecialtyPlanID = sp.SpecialtyPlanID,
  246. SchoolyearNumID = (sy.Value - ((gr.GradeID * 2 - 1) + gr.SemesterID - 1)) / 2 + 1,
  247. SchoolcodeID = sy.SchoolcodeID,
  248. StarttermID = sy.Value - ((gr.GradeID * 2 - 1) + gr.SemesterID - 1) + 1,
  249. SpecialtyID = spe.SpecialtyID,
  250. GrademajorID = sp.GrademajorID,
  251. CoursematerialID = sp.CoursematerialID,
  252. CourseTypeID = sp.CourseTypeID,
  253. Credit = spspst.Credit,
  254. DepartmentID = spdep.DepartmentID
  255. }
  256. )
  257. on new { GrademajorID = gr.GrademajorID, StarttermID = sc.StarttermID, CoursematerialID = sc.CoursematerialID }
  258. equals new { GrademajorID = sp.GrademajorID.Value, StarttermID = sp.StarttermID, CoursematerialID = sp.CoursematerialID } into tempsp
  259. from scsp in tempsp.DefaultIfEmpty()
  260. where scpa.PlanApplicationID == null && scsp.SpecialtyPlanID == null
  261. select new SpecialtyCourseView
  262. {
  263. SpecialtyCourseID = sc.SpecialtyCourseID,
  264. SpecialtyID = sc.SpecialtyID,
  265. StandardID = spe.StandardID,
  266. StandardName = spest.Name,
  267. EducationID = spe.EducationID,
  268. LearningformID = spe.LearningformID,
  269. LearnSystem = spe.LearnSystem,
  270. StarttermID = sc.StarttermID,
  271. CoursematerialID = sc.CoursematerialID,
  272. CourseCode = cou.CourseCode,
  273. CourseName = cou.CourseName,
  274. CourseStructureID = sc.CourseStructureID,
  275. CourseCategoryID = sc.CourseCategoryID,
  276. CourseTypeID = sc.CourseTypeID,
  277. CourseQualityID = sc.CourseQualityID,
  278. Credit = scscts.Credit ?? 0,
  279. TheoryCourse = scscts.TheoryCourse ?? 0,
  280. Practicehours = scscts.Practicehours ?? 0,
  281. Trialhours = scscts.Trialhours ?? 0,
  282. Totalhours = (scscts.TheoryCourse ?? 0) + (scscts.Practicehours ?? 0),
  283. TheoryWeeklyNum = scscts.TheoryWeeklyNum ?? 0,
  284. PracticeWeeklyNum = scscts.PracticeWeeklyNum ?? 0,
  285. TrialWeeklyNum = scscts.TrialWeeklyNum ?? 0,
  286. SchoolweeksNum = (scscts.TheoryWeeklyNum ?? 0) + (scscts.PracticeWeeklyNum ?? 0),
  287. WeeklyHours = scscts.WeeklyHours ?? 0,
  288. WeeklyNum = scscts.WeeklyNum ?? 0,
  289. StartWeeklyNum = scscts.StartWeeklyNum ?? 0,
  290. EndWeeklyNum = scscts.EndWeeklyNum ?? 0,
  291. StartEndWeeklyNum = (scscts.StartWeeklyNum ?? 0) + "-" + (scscts.EndWeeklyNum ?? 0),
  292. DepartmentID = sc.DepartmentID,
  293. DepartmentCode = scdep.No,
  294. DepartmentName = scdep.Name,
  295. CollegeID = scdep.CollegeID,
  296. CollegeCode = sccol.No,
  297. CollegeName = sccol.Name,
  298. IsSpecialtycore = sc.IsSpecialtycore ?? false,
  299. IsCooperation = sc.IsCooperation ?? false,
  300. IsRequired = sc.IsRequired ?? false,
  301. IsElective = sc.IsElective ?? false,
  302. IsNetworkCourse = sc.IsNetworkCourse ?? false,
  303. IsMainCourse = sc.IsMainCourse ?? false,
  304. IsNeedMaterial = sc.IsNeedMaterial ?? false,
  305. CourseFineID = sc.CourseFineID,
  306. PracticeTypeID = sc.PracticeTypeID,
  307. TeachinglanguageID = sc.TeachinglanguageID,
  308. ExaminationModeID = sc.ExaminationModeID,
  309. ResultTypeID = sc.ResultTypeID,
  310. HandleModeID = sc.HandleModeID,
  311. TeachingModeIDList = sc.EM_TeachingModeType.Select(x => x.TeachingModeID).ToList(),
  312. TeachingPlaceIDList = sc.EM_TeachingPlace.Select(x => x.TeachingPlace).ToList(),
  313. IsEnable = sc.IsEnable ?? false,
  314. Remark = sc.Remark,
  315. RecordStatus = sc.RecordStatus,
  316. CreateUserID = sc.CreateUserID,
  317. CreateTime = sc.CreateTime,
  318. ModifyUserID = sc.ModifyUserID,
  319. ModifyTime = sc.ModifyTime
  320. };
  321. return query;
  322. }
  323. /// <summary>
  324. /// 查询计划申请信息对应的授课方式
  325. /// </summary>
  326. /// <param name="exp"></param>
  327. /// <returns></returns>
  328. public IQueryable<int?> GetTeachingModeTypeQueryble(Expression<Func<EM_PlanApplication, bool>> exp)
  329. {
  330. var query = from pa in PlanApplicationRepository.GetList(exp)
  331. join patm in PlanApplicationTeachingModeTypeRepository.Entities
  332. on pa.PlanApplicationID equals patm.PlanApplicationID
  333. join dictm in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_TeachingMode).Name)
  334. on patm.TeachingModeID equals dictm.Value
  335. select dictm.Value;
  336. return query;
  337. }
  338. /// <summary>
  339. /// 查询计划申请信息对应的授课方式
  340. /// </summary>
  341. /// <param name="exp"></param>
  342. /// <returns></returns>
  343. public IQueryable<int?> GetTeachingPlaceQueryble(Expression<Func<EM_PlanApplication, bool>> exp)
  344. {
  345. var query = from pa in PlanApplicationRepository.GetList(exp)
  346. join patp in PlanApplicationTeachingPlaceRepository.Entities
  347. on pa.PlanApplicationID equals patp.PlanApplicationID
  348. join dictp in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(EMIS.ViewModel.EM_TeachingPlace).Name)
  349. on patp.TeachingPlace equals dictp.Value
  350. select dictp.Value;
  351. return query;
  352. }
  353. }
  354. }