ExecutablePlanDAL.cs 65 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Data.Entity;
  6. using System.Linq.Expressions;
  7. using EMIS.Entities;
  8. using EMIS.ViewModel;
  9. using EMIS.ViewModel.EducationManagement;
  10. using EMIS.ViewModel.UniversityManage.SpecialtyClassManage;
  11. using EMIS.ViewModel.Students;
  12. using EMIS.ViewModel.CultureplanManage.PlanManagement;
  13. using EMIS.DataLogic.Repositories;
  14. using EMIS.ViewModel.Cultureplan;
  15. using EMIS.DataLogic.Common.Cultureplan;
  16. using EMIS.ViewModel.EducationManage;
  17. namespace EMIS.DataLogic.EducationManage
  18. {
  19. public class ExecutablePlanDAL
  20. {
  21. public ExecutablePlanRepository ExecutablePlanRepository { get; set; }
  22. public ExecutablePlanProfileRepository ExecutablePlanProfileRepository { get; set; }
  23. public ExecutablePlanTeachingSettingRepository ExecutablePlanTeachingSettingRepository { get; set; }
  24. public ExecutablePlanTeachingModeTypeRepository ExecutablePlanTeachingModeTypeRepository { get; set; }
  25. public ExecutablePlanTeachingPlaceRepository ExecutablePlanTeachingPlaceRepository { get; set; }
  26. public SchoolyearRepository SchoolyearRepository { get; set; }
  27. public CoursematerialRepository CoursematerialRepository { get; set; }
  28. public ClassGroupingRepository ClassGroupingRepository { get; set; }
  29. public ClassGroupingSettingsRepository ClassGroupingSettingsRepository { get; set; }
  30. public DepartmentRepository DepartmentRepository { get; set; }
  31. public GrademajorRepository GrademajorRepository { get; set; }
  32. public ClassmajorRepository ClassmajorRepository { get; set; }
  33. public StudentRepository StudentRepository { get; set; }
  34. public UserRepository UserRepository { get; set; }
  35. public FacultymajorRepository FacultymajorRepository { get; set; }
  36. public CollegeRepository CollegeRepository { get; set; }
  37. public CampusRepository CampusRepository { get; set; }
  38. public SpecialtyRepository SpecialtyRepository { get; set; }
  39. public SpecialtyPlanRepository SpecialtyPlanRepository { get; set; }
  40. public SpecialtyPlanTeachingSettingRepository SpecialtyPlanTeachingSettingRepository { get; set; }
  41. public EducationMissionRepository EducationMissionRepository { get; set; }
  42. public EducationMissionClassRepository EducationMissionClassRepository { get; set; }
  43. public EducationMissionClassTeachingSettingRepository EducationMissionClassTeachingSettingRepository { get; set; }
  44. public EducationSchedulingClassRepository EducationSchedulingClassRepository { get; set; }
  45. public DictionaryItemRepository DictionaryItemRepository { get; set; }
  46. public RetakePlanStudentRepository RetakePlanStudentRepository { get; set; }
  47. public Lazy<CoursematerialDAL> CoursematerialDAL { get; set; }
  48. /// <summary>
  49. /// 查询执行计划信息ExecutablePlanView
  50. /// </summary>
  51. /// <param name="exp"></param>
  52. /// <returns></returns>
  53. public IQueryable<ExecutablePlanView> GetExecutablePlanViewQueryable(Expression<Func<EM_ExecutablePlan, bool>> exp)
  54. {
  55. var query = from ep in ExecutablePlanRepository.GetList(exp)
  56. join eppr in ExecutablePlanProfileRepository.Entities
  57. on ep.ExecutablePlanID equals eppr.ExecutablePlanID into tempeppr
  58. from epeppr in tempeppr.DefaultIfEmpty()
  59. join epst in ExecutablePlanTeachingSettingRepository.Entities
  60. on ep.ExecutablePlanID equals epst.ExecutablePlanID into tempepst
  61. from epepst in tempepst.DefaultIfEmpty()
  62. join sy in SchoolyearRepository.Entities
  63. on ep.SchoolyearID equals sy.SchoolyearID
  64. join cou in CoursematerialRepository.Entities
  65. on ep.CoursematerialID equals cou.CoursematerialID
  66. join cg in ClassGroupingRepository.Entities
  67. on cou.ClassGroupingID equals cg.ClassGroupingID into tempcg
  68. from coucg in tempcg.DefaultIfEmpty()
  69. join dep in DepartmentRepository.Entities
  70. on ep.DepartmentID equals dep.DepartmentID into tempdep
  71. from epdep in tempdep.DefaultIfEmpty()
  72. join gr in GrademajorRepository.Entities
  73. on ep.GrademajorID equals gr.GrademajorID
  74. join stsy in SchoolyearRepository.Entities
  75. on new { SchoolyearID = gr.GradeID.Value, SchoolcodeID = gr.SemesterID.Value }
  76. equals new { SchoolyearID = stsy.Years, SchoolcodeID = stsy.SchoolcodeID } into tempstsy
  77. from startsy in tempstsy.DefaultIfEmpty()
  78. join fa in FacultymajorRepository.Entities
  79. on gr.FacultymajorID equals fa.FacultymajorID
  80. join spe in SpecialtyRepository.Entities
  81. on new { StandardID = fa.StandardID, EducationID = fa.EducationID, LearningformID = fa.LearningformID, LearnSystem = fa.LearnSystem }
  82. equals new { StandardID = spe.StandardID, EducationID = spe.EducationID, LearningformID = spe.LearningformID, LearnSystem = spe.LearnSystem }
  83. join dicst in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_Standard).Name)
  84. on fa.StandardID equals dicst.Value into tempst
  85. from fast in tempst.DefaultIfEmpty()
  86. join col in CollegeRepository.Entities
  87. on fa.CollegeID equals col.CollegeID
  88. join cam in CampusRepository.Entities
  89. on col.CampusID equals cam.CampusID
  90. select new ExecutablePlanView
  91. {
  92. ExecutablePlanID = ep.ExecutablePlanID,
  93. SourceTypeID = ep.SourceTypeID,
  94. DefaultClassName = ep.DefaultClassName,
  95. SpecialtyPlanID = ep.SpecialtyPlanID,
  96. SchoolyearID = ep.SchoolyearID,
  97. SchoolyearCode = sy.Code,
  98. YearID = sy.Years,
  99. Value = sy.Value,
  100. SchoolyearNumID = (sy.Value - ((gr.GradeID * 2 - 1) + gr.SemesterID - 1)) / 2 + 1,
  101. SchoolcodeID = sy.SchoolcodeID,
  102. StarttermID = sy.Value - ((gr.GradeID * 2 - 1) + gr.SemesterID - 1) + 1,
  103. GrademajorID = ep.GrademajorID,
  104. GrademajorCode = gr.Code,
  105. GrademajorName = gr.Name,
  106. GradeID = gr.GradeID,
  107. FacultymajorID = gr.FacultymajorID,
  108. FacultymajorCode = fa.Code,
  109. FacultymajorName = fa.Name,
  110. CollegeID = fa.CollegeID,
  111. CollegeCode = col.No,
  112. CollegeName = col.Name,
  113. CampusID = col.CampusID,
  114. CampusNo = cam.No,
  115. CampusName = cam.Name,
  116. StartSchoolyearID = startsy.SchoolyearID,
  117. StartSchoolyearCode = startsy.Code,
  118. StartValue = startsy.Value,
  119. StartSchoolcodeID = gr.SemesterID,
  120. GraduatingSemesterID = gr.GraduateSchoolyearID,
  121. SpecialtyID = spe.SpecialtyID,
  122. StandardID = fa.StandardID,
  123. StandardName = fast.Name,
  124. EducationID = fa.EducationID,
  125. LearningformID = fa.LearningformID,
  126. LearnSystem = fa.LearnSystem,
  127. CoursematerialID = ep.CoursematerialID,
  128. CourseCode = cou.CourseCode,
  129. CourseName = cou.CourseName,
  130. ClassGroupingID = cou.ClassGroupingID,
  131. ClassGroupingName = coucg.ClassName,
  132. CourseStructureID = ep.CourseStructureID,
  133. CourseCategoryID = ep.CourseCategoryID,
  134. CourseTypeID = ep.CourseTypeID,
  135. CourseQualityID = ep.CourseQualityID,
  136. Credit = epepst.Credit ?? 0,
  137. TheoryCourse = epepst.TheoryCourse ?? 0,
  138. Practicehours = epepst.Practicehours ?? 0,
  139. Trialhours = epepst.Trialhours ?? 0,
  140. Totalhours = (epepst.TheoryCourse ?? 0) + (epepst.Practicehours ?? 0),
  141. TheoryWeeklyNum = epepst.TheoryWeeklyNum ?? 0,
  142. PracticeWeeklyNum = epepst.PracticeWeeklyNum ?? 0,
  143. TrialWeeklyNum = epepst.TrialWeeklyNum ?? 0,
  144. SchoolweeksNum = (epepst.TheoryWeeklyNum ?? 0) + (epepst.PracticeWeeklyNum ?? 0),
  145. WeeklyHours = epepst.WeeklyHours ?? 0,
  146. WeeklyNum = epepst.WeeklyNum ?? 0,
  147. StartWeeklyNum = epepst.StartWeeklyNum ?? 0,
  148. EndWeeklyNum = epepst.EndWeeklyNum ?? 0,
  149. StartEndWeeklyNum = (epepst.StartWeeklyNum ?? 0) + "-" + (epepst.EndWeeklyNum ?? 0),
  150. DepartmentID = ep.DepartmentID,
  151. DepartmentCode = epdep.No,
  152. DepartmentName = epdep.Name,
  153. CourseCollegeID = epdep.CollegeID,
  154. CourseCollegeCode = epdep.CF_College.No,
  155. CourseCollegeName = epdep.CF_College.Name,
  156. IsSpecialtycore = epeppr.IsSpecialtycore ?? false,
  157. IsCooperation = epeppr.IsCooperation ?? false,
  158. IsRequired = epeppr.IsRequired ?? false,
  159. IsElective = epeppr.IsElective ?? false,
  160. IsNetworkCourse = epeppr.IsNetworkCourse ?? false,
  161. IsMainCourse = epeppr.IsMainCourse ?? false,
  162. IsNeedMaterial = ep.IsNeedMaterial ?? false,
  163. CourseFineID = epeppr.CourseFineID,
  164. PracticeTypeID = epeppr.PracticeTypeID,
  165. TeachinglanguageID = epeppr.TeachinglanguageID,
  166. ExaminationModeID = epeppr.ExaminationModeID,
  167. ResultTypeID = ep.ResultTypeID,
  168. HandleModeID = ep.HandleModeID,
  169. TeachingModeIDList = ep.EM_ExecutablePlanTeachingModeType.Select(x => x.TeachingModeID).ToList(),
  170. TeachingPlaceIDList = ep.EM_ExecutablePlanTeachingPlace.Select(x => x.TeachingPlace).ToList(),
  171. PlanTypeID = ep.SpecialtyPlanID == null ? (int)EM_PlanType.Outside : (int)EM_PlanType.Inside,
  172. ExecuteStatus = ep.RecordStatus,
  173. Remark = ep.Remark,
  174. RecordStatus = ep.RecordStatus,
  175. CreateUserID = ep.CreateUserID,
  176. CreateTime = ep.CreateTime,
  177. ModifyUserID = ep.ModifyUserID,
  178. ModifyTime = ep.ModifyTime
  179. };
  180. return query;
  181. }
  182. /// <summary>
  183. /// 查询执行计划信息ExecutablePlanView(统计对应的计划范围、学生人数)
  184. /// </summary>
  185. /// <param name="expExecutablePlan"></param>
  186. /// <param name="expStudent"></param>
  187. /// <returns></returns>
  188. public IQueryable<ExecutablePlanView> GetExecutablePlanViewQueryable(Expression<Func<EM_ExecutablePlan, bool>> expExecutablePlan,
  189. Expression<Func<CF_Student, bool>> expStudent)
  190. {
  191. var query = from ep in ExecutablePlanRepository.GetList(expExecutablePlan)
  192. join eppr in ExecutablePlanProfileRepository.Entities
  193. on ep.ExecutablePlanID equals eppr.ExecutablePlanID into tempeppr
  194. from epeppr in tempeppr.DefaultIfEmpty()
  195. join epst in ExecutablePlanTeachingSettingRepository.Entities
  196. on ep.ExecutablePlanID equals epst.ExecutablePlanID into tempepst
  197. from epepst in tempepst.DefaultIfEmpty()
  198. join sy in SchoolyearRepository.Entities
  199. on ep.SchoolyearID equals sy.SchoolyearID
  200. join cou in CoursematerialRepository.Entities
  201. on ep.CoursematerialID equals cou.CoursematerialID
  202. join cg in ClassGroupingRepository.Entities
  203. on cou.ClassGroupingID equals cg.ClassGroupingID into tempcg
  204. from coucg in tempcg.DefaultIfEmpty()
  205. join dep in DepartmentRepository.Entities
  206. on ep.DepartmentID equals dep.DepartmentID into tempdep
  207. from epdep in tempdep.DefaultIfEmpty()
  208. join gr in GrademajorRepository.Entities
  209. on ep.GrademajorID equals gr.GrademajorID
  210. join stsy in SchoolyearRepository.Entities
  211. on new { SchoolyearID = gr.GradeID.Value, SchoolcodeID = gr.SemesterID.Value }
  212. equals new { SchoolyearID = stsy.Years, SchoolcodeID = stsy.SchoolcodeID } into tempstsy
  213. from startsy in tempstsy.DefaultIfEmpty()
  214. join fa in FacultymajorRepository.Entities
  215. on gr.FacultymajorID equals fa.FacultymajorID
  216. join spe in SpecialtyRepository.Entities
  217. on new { StandardID = fa.StandardID, EducationID = fa.EducationID, LearningformID = fa.LearningformID, LearnSystem = fa.LearnSystem }
  218. equals new { StandardID = spe.StandardID, EducationID = spe.EducationID, LearningformID = spe.LearningformID, LearnSystem = spe.LearnSystem }
  219. join dicst in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_Standard).Name)
  220. on fa.StandardID equals dicst.Value into tempst
  221. from fast in tempst.DefaultIfEmpty()
  222. join col in CollegeRepository.Entities
  223. on fa.CollegeID equals col.CollegeID
  224. join cam in CampusRepository.Entities
  225. on col.CampusID equals cam.CampusID
  226. join pr in
  227. (
  228. from cl in ClassmajorRepository.Entities
  229. group cl by cl.GrademajorID into gpr
  230. select new
  231. {
  232. GrademajorID = gpr.Key,
  233. PlanRange = gpr.Count()
  234. }
  235. )
  236. on gr.GrademajorID equals pr.GrademajorID into temppr
  237. from grpr in temppr.DefaultIfEmpty()
  238. join stu in
  239. (
  240. from stu in StudentRepository.GetList(expStudent)
  241. group stu by stu.CF_Classmajor.CF_Grademajor.GrademajorID into gstu
  242. select new
  243. {
  244. GrademajorID = gstu.Key,
  245. StudentCount = gstu.Count()
  246. }
  247. )
  248. on gr.GrademajorID equals stu.GrademajorID into tempstu
  249. from grstu in tempstu.DefaultIfEmpty()
  250. select new ExecutablePlanView
  251. {
  252. ExecutablePlanID = ep.ExecutablePlanID,
  253. SourceTypeID = ep.SourceTypeID,
  254. DefaultClassName = ep.DefaultClassName,
  255. SpecialtyPlanID = ep.SpecialtyPlanID,
  256. SchoolyearID = ep.SchoolyearID,
  257. SchoolyearCode = sy.Code,
  258. YearID = sy.Years,
  259. Value = sy.Value,
  260. SchoolyearNumID = (sy.Value - ((gr.GradeID * 2 - 1) + gr.SemesterID - 1)) / 2 + 1,
  261. SchoolcodeID = sy.SchoolcodeID,
  262. StarttermID = sy.Value - ((gr.GradeID * 2 - 1) + gr.SemesterID - 1) + 1,
  263. GrademajorID = ep.GrademajorID,
  264. GrademajorCode = gr.Code,
  265. GrademajorName = gr.Name,
  266. GradeID = gr.GradeID,
  267. FacultymajorID = gr.FacultymajorID,
  268. FacultymajorCode = fa.Code,
  269. FacultymajorName = fa.Name,
  270. CollegeID = fa.CollegeID,
  271. CollegeCode = col.No,
  272. CollegeName = col.Name,
  273. CampusID = col.CampusID,
  274. CampusNo = cam.No,
  275. CampusName = cam.Name,
  276. StartSchoolyearID = startsy.SchoolyearID,
  277. StartSchoolyearCode = startsy.Code,
  278. StartValue = startsy.Value,
  279. StartSchoolcodeID = gr.SemesterID,
  280. GraduatingSemesterID = gr.GraduateSchoolyearID,
  281. SpecialtyID = spe.SpecialtyID,
  282. StandardID = fa.StandardID,
  283. StandardName = fast.Name,
  284. EducationID = fa.EducationID,
  285. LearningformID = fa.LearningformID,
  286. LearnSystem = fa.LearnSystem,
  287. CoursematerialID = ep.CoursematerialID,
  288. CourseCode = cou.CourseCode,
  289. CourseName = cou.CourseName,
  290. ClassGroupingID = cou.ClassGroupingID,
  291. ClassGroupingName = coucg.ClassName,
  292. CourseStructureID = ep.CourseStructureID,
  293. CourseCategoryID = ep.CourseCategoryID,
  294. CourseTypeID = ep.CourseTypeID,
  295. CourseQualityID = ep.CourseQualityID,
  296. Credit = epepst.Credit ?? 0,
  297. TheoryCourse = epepst.TheoryCourse ?? 0,
  298. Practicehours = epepst.Practicehours ?? 0,
  299. Trialhours = epepst.Trialhours ?? 0,
  300. Totalhours = (epepst.TheoryCourse ?? 0) + (epepst.Practicehours ?? 0),
  301. TheoryWeeklyNum = epepst.TheoryWeeklyNum ?? 0,
  302. PracticeWeeklyNum = epepst.PracticeWeeklyNum ?? 0,
  303. TrialWeeklyNum = epepst.TrialWeeklyNum ?? 0,
  304. SchoolweeksNum = (epepst.TheoryWeeklyNum ?? 0) + (epepst.PracticeWeeklyNum ?? 0),
  305. WeeklyHours = epepst.WeeklyHours ?? 0,
  306. WeeklyNum = epepst.WeeklyNum ?? 0,
  307. StartWeeklyNum = epepst.StartWeeklyNum ?? 0,
  308. EndWeeklyNum = epepst.EndWeeklyNum ?? 0,
  309. StartEndWeeklyNum = (epepst.StartWeeklyNum ?? 0) + "-" + (epepst.EndWeeklyNum ?? 0),
  310. DepartmentID = ep.DepartmentID,
  311. DepartmentCode = epdep.No,
  312. DepartmentName = epdep.Name,
  313. CourseCollegeID = epdep.CollegeID,
  314. CourseCollegeCode = epdep.CF_College.No,
  315. CourseCollegeName = epdep.CF_College.Name,
  316. IsSpecialtycore = epeppr.IsSpecialtycore ?? false,
  317. IsCooperation = epeppr.IsCooperation ?? false,
  318. IsRequired = epeppr.IsRequired ?? false,
  319. IsElective = epeppr.IsElective ?? false,
  320. IsNetworkCourse = epeppr.IsNetworkCourse ?? false,
  321. IsMainCourse = epeppr.IsMainCourse ?? false,
  322. IsNeedMaterial = ep.IsNeedMaterial ?? false,
  323. CourseFineID = epeppr.CourseFineID,
  324. PracticeTypeID = epeppr.PracticeTypeID,
  325. TeachinglanguageID = epeppr.TeachinglanguageID,
  326. ExaminationModeID = epeppr.ExaminationModeID,
  327. ResultTypeID = ep.ResultTypeID,
  328. HandleModeID = ep.HandleModeID,
  329. TeachingModeIDList = ep.EM_ExecutablePlanTeachingModeType.Select(x => x.TeachingModeID).ToList(),
  330. TeachingPlaceIDList = ep.EM_ExecutablePlanTeachingPlace.Select(x => x.TeachingPlace).ToList(),
  331. PlanRange = grpr.PlanRange == null ? 0 : grpr.PlanRange,
  332. StudentCount = grstu.StudentCount == null ? 0 : grstu.StudentCount,
  333. PlanTypeID = ep.SpecialtyPlanID == null ? (int)EM_PlanType.Outside : (int)EM_PlanType.Inside,
  334. ExecuteStatus = ep.RecordStatus,
  335. Remark = ep.Remark,
  336. RecordStatus = ep.RecordStatus,
  337. CreateUserID = ep.CreateUserID,
  338. CreateTime = ep.CreateTime,
  339. ModifyUserID = ep.ModifyUserID,
  340. ModifyTime = ep.ModifyTime
  341. };
  342. return query;
  343. }
  344. /// <summary>
  345. /// 查询对应的未新增专业计划信息(统计对应的学生人数)
  346. /// 注:普教版本(年级专业)
  347. /// </summary>
  348. /// <param name="expSpecialtyPlan"></param>
  349. /// <param name="expGrademajor"></param>
  350. /// <param name="expStudent"></param>
  351. /// <param name="expExecutablePlan"></param>
  352. /// <returns></returns>
  353. public IQueryable<SpecialtyPlanView> GetSpecialtyPlanViewNoAddQueryable(Expression<Func<EM_SpecialtyPlan, bool>> expSpecialtyPlan,
  354. Expression<Func<CF_Grademajor, bool>> expGrademajor, Expression<Func<CF_Student, bool>> expStudent,
  355. Expression<Func<EM_ExecutablePlan, bool>> expExecutablePlan)
  356. {
  357. var query = from sp in SpecialtyPlanRepository.GetList(expSpecialtyPlan)
  358. join spst in SpecialtyPlanTeachingSettingRepository.Entities
  359. on sp.SpecialtyPlanID equals spst.SpecialtyPlanID into tempspst
  360. from spspst in tempspst.DefaultIfEmpty()
  361. join sy in SchoolyearRepository.Entities
  362. on sp.SchoolyearID equals sy.SchoolyearID
  363. join cou in CoursematerialRepository.Entities
  364. on sp.CoursematerialID equals cou.CoursematerialID
  365. join dep in DepartmentRepository.Entities
  366. on sp.DepartmentID equals dep.DepartmentID into tempdep
  367. from spdep in tempdep.DefaultIfEmpty()
  368. join gr in GrademajorRepository.GetList(expGrademajor)
  369. on sp.GrademajorID equals gr.GrademajorID
  370. join stsy in SchoolyearRepository.Entities
  371. on new { SchoolyearID = gr.GradeID.Value, SchoolcodeID = gr.SemesterID.Value }
  372. equals new { SchoolyearID = stsy.Years, SchoolcodeID = stsy.SchoolcodeID } into tempstsy
  373. from startsy in tempstsy.DefaultIfEmpty()
  374. join grsy in SchoolyearRepository.Entities
  375. on gr.GraduateSchoolyearID equals grsy.SchoolyearID into tempgrsy
  376. from gradsy in tempgrsy.DefaultIfEmpty()
  377. join fa in FacultymajorRepository.Entities
  378. on gr.FacultymajorID equals fa.FacultymajorID
  379. join spe in SpecialtyRepository.Entities
  380. on new { StandardID = fa.StandardID, EducationID = fa.EducationID, LearningformID = fa.LearningformID, LearnSystem = fa.LearnSystem }
  381. equals new { StandardID = spe.StandardID, EducationID = spe.EducationID, LearningformID = spe.LearningformID, LearnSystem = spe.LearnSystem }
  382. join dicst in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_Standard).Name)
  383. on fa.StandardID equals dicst.Value into tempst
  384. from fast in tempst.DefaultIfEmpty()
  385. join col in CollegeRepository.Entities
  386. on fa.CollegeID equals col.CollegeID
  387. join cam in CampusRepository.Entities
  388. on col.CampusID equals cam.CampusID
  389. join stu in
  390. (
  391. from stu in StudentRepository.GetList(expStudent)
  392. join cl in ClassmajorRepository.Entities
  393. on stu.ClassmajorID equals cl.ClassmajorID
  394. join gr in GrademajorRepository.GetList(expGrademajor)
  395. on cl.GrademajorID equals gr.GrademajorID
  396. group new { stu, gr } by gr.GrademajorID into gstu
  397. select new
  398. {
  399. GrademajorID = gstu.Key,
  400. StudentCount = gstu.Count()
  401. }
  402. )
  403. on gr.GrademajorID equals stu.GrademajorID into tempstu
  404. from grstu in tempstu.DefaultIfEmpty()
  405. join ep in
  406. (
  407. from ep in ExecutablePlanRepository.GetList(expExecutablePlan)
  408. join eppr in ExecutablePlanProfileRepository.Entities
  409. on ep.ExecutablePlanID equals eppr.ExecutablePlanID into tempeppr
  410. from epeppr in tempeppr.DefaultIfEmpty()
  411. join epst in ExecutablePlanTeachingSettingRepository.Entities
  412. on ep.ExecutablePlanID equals epst.ExecutablePlanID into tempepst
  413. from epepst in tempepst.DefaultIfEmpty()
  414. select new
  415. {
  416. ExecutablePlanID = ep.ExecutablePlanID,
  417. SpecialtyPlanID = ep.SpecialtyPlanID,
  418. SchoolyearID = ep.SchoolyearID,
  419. GrademajorID = ep.GrademajorID,
  420. CoursematerialID = ep.CoursematerialID,
  421. CourseTypeID = ep.CourseTypeID,
  422. Credit = epepst.Credit,
  423. DepartmentID = ep.DepartmentID,
  424. HandleModeID = ep.HandleModeID
  425. }
  426. )
  427. on new { SchoolyearID = sp.SchoolyearID, GrademajorID = sp.GrademajorID, CoursematerialID = sp.CoursematerialID }
  428. equals new { SchoolyearID = ep.SchoolyearID, GrademajorID = ep.GrademajorID, CoursematerialID = ep.CoursematerialID } into tempep
  429. from spep in tempep.DefaultIfEmpty()
  430. where spep.ExecutablePlanID == null
  431. select new SpecialtyPlanView
  432. {
  433. SpecialtyPlanID = sp.SpecialtyPlanID,
  434. PlanApplicationID = sp.PlanApplicationID,
  435. SchoolyearID = sp.SchoolyearID,
  436. SchoolyearCode = sy.Code,
  437. YearID = sy.Years,
  438. Value = sy.Value,
  439. SchoolyearNumID = (sy.Value - ((gr.GradeID * 2 - 1) + gr.SemesterID - 1)) / 2 + 1,
  440. SchoolcodeID = sy.SchoolcodeID,
  441. StarttermID = sy.Value - ((gr.GradeID * 2 - 1) + gr.SemesterID - 1) + 1,
  442. GrademajorID = sp.GrademajorID,
  443. GrademajorCode = gr.Code,
  444. GrademajorName = gr.Name,
  445. GradeID = gr.GradeID,
  446. FacultymajorID = gr.FacultymajorID,
  447. FacultymajorCode = fa.Code,
  448. FacultymajorName = fa.Name,
  449. CollegeID = fa.CollegeID,
  450. CollegeCode = col.No,
  451. CollegeName = col.Name,
  452. CampusID = col.CampusID,
  453. CampusNo = cam.No,
  454. CampusName = cam.Name,
  455. StartSchoolyearID = startsy.SchoolyearID,
  456. StartSchoolyearCode = startsy.Code,
  457. StartValue = startsy.Value,
  458. StartSchoolcodeID = gr.SemesterID,
  459. GraduatingSemesterID = gr.GraduateSchoolyearID,
  460. GraduatingSemesterCode = gradsy.Code,
  461. GraduatingSemesterValue = gradsy.Value,
  462. SpecialtyID = spe.SpecialtyID,
  463. StandardID = fa.StandardID,
  464. StandardName = fast.Name,
  465. EducationID = fa.EducationID,
  466. LearningformID = fa.LearningformID,
  467. LearnSystem = fa.LearnSystem,
  468. CoursematerialID = sp.CoursematerialID,
  469. CourseCode = cou.CourseCode,
  470. CourseName = cou.CourseName,
  471. CourseStructureID = sp.CourseStructureID,
  472. CourseCategoryID = sp.CourseCategoryID,
  473. CourseTypeID = sp.CourseTypeID,
  474. CourseQualityID = sp.CourseQualityID,
  475. Credit = spspst.Credit ?? 0,
  476. TheoryCourse = spspst.TheoryCourse ?? 0,
  477. Practicehours = spspst.Practicehours ?? 0,
  478. Trialhours = spspst.Trialhours ?? 0,
  479. Totalhours = (spspst.TheoryCourse ?? 0) + (spspst.Practicehours ?? 0),
  480. TheoryWeeklyNum = spspst.TheoryWeeklyNum ?? 0,
  481. PracticeWeeklyNum = spspst.PracticeWeeklyNum ?? 0,
  482. TrialWeeklyNum = spspst.TrialWeeklyNum ?? 0,
  483. SchoolweeksNum = (spspst.TheoryWeeklyNum ?? 0) + (spspst.PracticeWeeklyNum ?? 0),
  484. WeeklyHours = spspst.WeeklyHours ?? 0,
  485. WeeklyNum = spspst.WeeklyNum ?? 0,
  486. StartWeeklyNum = spspst.StartWeeklyNum ?? 0,
  487. EndWeeklyNum = spspst.EndWeeklyNum ?? 0,
  488. StartEndWeeklyNum = (spspst.StartWeeklyNum ?? 0) + "-" + (spspst.EndWeeklyNum ?? 0),
  489. DepartmentID = sp.DepartmentID,
  490. DepartmentCode = spdep.No,
  491. DepartmentName = spdep.Name,
  492. CourseCollegeID = spdep.CollegeID,
  493. CourseCollegeCode = spdep.CF_College.No,
  494. CourseCollegeName = spdep.CF_College.Name,
  495. IsSpecialtycore = sp.IsSpecialtycore ?? false,
  496. IsCooperation = sp.IsCooperation ?? false,
  497. IsRequired = sp.IsRequired ?? false,
  498. IsElective = sp.IsElective ?? false,
  499. IsNetworkCourse = sp.IsNetworkCourse ?? false,
  500. IsMainCourse = sp.IsMainCourse ?? false,
  501. IsNeedMaterial = sp.IsNeedMaterial ?? false,
  502. CourseFineID = sp.CourseFineID,
  503. PracticeTypeID = sp.PracticeTypeID,
  504. TeachinglanguageID = sp.TeachinglanguageID,
  505. ExaminationModeID = sp.ExaminationModeID,
  506. ResultTypeID = sp.ResultTypeID,
  507. HandleModeID = sp.HandleModeID,
  508. TeachingModeIDList = sp.EM_SpecialtyPlanTeachingModeType.Select(x => x.TeachingModeID).ToList(),
  509. TeachingPlaceIDList = sp.EM_SpecialtyPlanTeachingPlace.Select(x => x.TeachingPlace).ToList(),
  510. StudentCount = grstu.StudentCount == null ? 0 : grstu.StudentCount,
  511. Remark = sp.Remark,
  512. RecordStatus = sp.RecordStatus,
  513. CreateUserID = sp.CreateUserID,
  514. CreateTime = sp.CreateTime,
  515. ModifyUserID = sp.ModifyUserID,
  516. ModifyTime = sp.ModifyTime
  517. };
  518. return query;
  519. }
  520. /// <summary>
  521. /// 查询对应的未新增专业计划信息(统计对应的学生人数)
  522. /// 注:成教版本(入学学年学期、专业信息)
  523. /// </summary>
  524. /// <param name="expGrademajor"></param>
  525. /// <param name="expSpecialtyPlan"></param>
  526. /// <param name="expStudent"></param>
  527. /// <param name="expExecutablePlan"></param>
  528. /// <returns></returns>
  529. public IQueryable<SpecialtyPlanView> GetAdultSpecialtyPlanViewNoAddQueryable(Expression<Func<CF_Grademajor, bool>> expGrademajor,
  530. Expression<Func<EM_SpecialtyPlan, bool>> expSpecialtyPlan, Expression<Func<CF_Student, bool>> expStudent,
  531. Expression<Func<EM_ExecutablePlan, bool>> expExecutablePlan)
  532. {
  533. var query = from gr in GrademajorRepository.GetList(expGrademajor)
  534. join startsy in SchoolyearRepository.Entities
  535. on new { GradeID = gr.GradeID.Value, StartSchoolcodeID = gr.SemesterID.Value }
  536. equals new { GradeID = startsy.Years, StartSchoolcodeID = startsy.SchoolcodeID }
  537. join grsy in SchoolyearRepository.Entities
  538. on gr.GraduateSchoolyearID equals grsy.SchoolyearID into tempgrsy
  539. from gradsy in tempgrsy.DefaultIfEmpty()
  540. join fa in FacultymajorRepository.Entities
  541. on gr.FacultymajorID equals fa.FacultymajorID
  542. join spe in SpecialtyRepository.Entities
  543. on new { StandardID = fa.StandardID, EducationID = fa.EducationID, LearningformID = fa.LearningformID, LearnSystem = fa.LearnSystem }
  544. equals new { StandardID = spe.StandardID, EducationID = spe.EducationID, LearningformID = spe.LearningformID, LearnSystem = spe.LearnSystem }
  545. join dicst in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_Standard).Name)
  546. on fa.StandardID equals dicst.Value into tempst
  547. from fast in tempst.DefaultIfEmpty()
  548. join col in CollegeRepository.Entities
  549. on fa.CollegeID equals col.CollegeID
  550. join cam in CampusRepository.Entities
  551. on col.CampusID equals cam.CampusID
  552. join sp in SpecialtyPlanRepository.GetList(expSpecialtyPlan)
  553. on new { StartSchoolyearID = startsy.SchoolyearID, SpecialtyID = spe.SpecialtyID }
  554. equals new { StartSchoolyearID = sp.StartSchoolyearID.Value, SpecialtyID = sp.SpecialtyID.Value }
  555. join spst in SpecialtyPlanTeachingSettingRepository.Entities
  556. on sp.SpecialtyPlanID equals spst.SpecialtyPlanID into tempspst
  557. from spspst in tempspst.DefaultIfEmpty()
  558. join sy in SchoolyearRepository.Entities
  559. on sp.SchoolyearID equals sy.SchoolyearID
  560. join cou in CoursematerialRepository.Entities
  561. on sp.CoursematerialID equals cou.CoursematerialID
  562. join dep in DepartmentRepository.Entities
  563. on sp.DepartmentID equals dep.DepartmentID into tempdep
  564. from spdep in tempdep.DefaultIfEmpty()
  565. join stu in
  566. (
  567. from stu in StudentRepository.GetList(expStudent)
  568. join cl in ClassmajorRepository.Entities
  569. on stu.ClassmajorID equals cl.ClassmajorID
  570. join gr in GrademajorRepository.GetList(expGrademajor)
  571. on cl.GrademajorID equals gr.GrademajorID
  572. group new { stu, gr } by gr.GrademajorID into gstu
  573. select new
  574. {
  575. GrademajorID = gstu.Key,
  576. StudentCount = gstu.Count()
  577. }
  578. )
  579. on gr.GrademajorID equals stu.GrademajorID into tempstu
  580. from grstu in tempstu.DefaultIfEmpty()
  581. join ep in
  582. (
  583. from ep in ExecutablePlanRepository.GetList(expExecutablePlan)
  584. join eppr in ExecutablePlanProfileRepository.Entities
  585. on ep.ExecutablePlanID equals eppr.ExecutablePlanID into tempeppr
  586. from epeppr in tempeppr.DefaultIfEmpty()
  587. join epst in ExecutablePlanTeachingSettingRepository.Entities
  588. on ep.ExecutablePlanID equals epst.ExecutablePlanID into tempepst
  589. from epepst in tempepst.DefaultIfEmpty()
  590. select new
  591. {
  592. ExecutablePlanID = ep.ExecutablePlanID,
  593. SpecialtyPlanID = ep.SpecialtyPlanID,
  594. SchoolyearID = ep.SchoolyearID,
  595. GrademajorID = ep.GrademajorID,
  596. CoursematerialID = ep.CoursematerialID,
  597. CourseTypeID = ep.CourseTypeID,
  598. Credit = epepst.Credit,
  599. DepartmentID = ep.DepartmentID,
  600. HandleModeID = ep.HandleModeID
  601. }
  602. )
  603. on new { SchoolyearID = sp.SchoolyearID, GrademajorID = gr.GrademajorID, CoursematerialID = sp.CoursematerialID }
  604. equals new { SchoolyearID = ep.SchoolyearID, GrademajorID = ep.GrademajorID.Value, CoursematerialID = ep.CoursematerialID } into tempep
  605. from spep in tempep.DefaultIfEmpty()
  606. where spep.ExecutablePlanID == null
  607. select new SpecialtyPlanView
  608. {
  609. SpecialtyPlanID = sp.SpecialtyPlanID,
  610. PlanApplicationID = sp.PlanApplicationID,
  611. SchoolyearID = sp.SchoolyearID,
  612. SchoolyearCode = sy.Code,
  613. YearID = sy.Years,
  614. Value = sy.Value,
  615. SchoolyearNumID = (sy.Value - ((gr.GradeID * 2 - 1) + gr.SemesterID - 1)) / 2 + 1,
  616. SchoolcodeID = sy.SchoolcodeID,
  617. StarttermID = sy.Value - ((gr.GradeID * 2 - 1) + gr.SemesterID - 1) + 1,
  618. GrademajorID = gr.GrademajorID,
  619. GrademajorCode = gr.Code,
  620. GrademajorName = gr.Name,
  621. GradeID = gr.GradeID,
  622. FacultymajorID = gr.FacultymajorID,
  623. FacultymajorCode = fa.Code,
  624. FacultymajorName = fa.Name,
  625. CollegeID = fa.CollegeID,
  626. CollegeCode = col.No,
  627. CollegeName = col.Name,
  628. CampusID = col.CampusID,
  629. CampusNo = cam.No,
  630. CampusName = cam.Name,
  631. StartSchoolyearID = sp.StartSchoolyearID,
  632. StartSchoolyearCode = startsy.Code,
  633. StartValue = startsy.Value,
  634. StartSchoolcodeID = gr.SemesterID,
  635. GraduatingSemesterID = gr.GraduateSchoolyearID,
  636. GraduatingSemesterCode = gradsy.Code,
  637. GraduatingSemesterValue = gradsy.Value,
  638. SpecialtyID = sp.SpecialtyID,
  639. StandardID = fa.StandardID,
  640. StandardName = fast.Name,
  641. EducationID = fa.EducationID,
  642. LearningformID = fa.LearningformID,
  643. LearnSystem = fa.LearnSystem,
  644. CoursematerialID = sp.CoursematerialID,
  645. CourseCode = cou.CourseCode,
  646. CourseName = cou.CourseName,
  647. CourseStructureID = sp.CourseStructureID,
  648. CourseCategoryID = sp.CourseCategoryID,
  649. CourseTypeID = sp.CourseTypeID,
  650. CourseQualityID = sp.CourseQualityID,
  651. Credit = spspst.Credit ?? 0,
  652. TheoryCourse = spspst.TheoryCourse ?? 0,
  653. Practicehours = spspst.Practicehours ?? 0,
  654. Trialhours = spspst.Trialhours ?? 0,
  655. Totalhours = (spspst.TheoryCourse ?? 0) + (spspst.Practicehours ?? 0),
  656. TheoryWeeklyNum = spspst.TheoryWeeklyNum ?? 0,
  657. PracticeWeeklyNum = spspst.PracticeWeeklyNum ?? 0,
  658. TrialWeeklyNum = spspst.TrialWeeklyNum ?? 0,
  659. SchoolweeksNum = (spspst.TheoryWeeklyNum ?? 0) + (spspst.PracticeWeeklyNum ?? 0),
  660. WeeklyHours = spspst.WeeklyHours ?? 0,
  661. WeeklyNum = spspst.WeeklyNum ?? 0,
  662. StartWeeklyNum = spspst.StartWeeklyNum ?? 0,
  663. EndWeeklyNum = spspst.EndWeeklyNum ?? 0,
  664. StartEndWeeklyNum = (spspst.StartWeeklyNum ?? 0) + "-" + (spspst.EndWeeklyNum ?? 0),
  665. DepartmentID = sp.DepartmentID,
  666. DepartmentCode = spdep.No,
  667. DepartmentName = spdep.Name,
  668. CourseCollegeID = spdep.CollegeID,
  669. CourseCollegeCode = spdep.CF_College.No,
  670. CourseCollegeName = spdep.CF_College.Name,
  671. IsSpecialtycore = sp.IsSpecialtycore ?? false,
  672. IsCooperation = sp.IsCooperation ?? false,
  673. IsRequired = sp.IsRequired ?? false,
  674. IsElective = sp.IsElective ?? false,
  675. IsNetworkCourse = sp.IsNetworkCourse ?? false,
  676. IsMainCourse = sp.IsMainCourse ?? false,
  677. IsNeedMaterial = sp.IsNeedMaterial ?? false,
  678. CourseFineID = sp.CourseFineID,
  679. PracticeTypeID = sp.PracticeTypeID,
  680. TeachinglanguageID = sp.TeachinglanguageID,
  681. ExaminationModeID = sp.ExaminationModeID,
  682. ResultTypeID = sp.ResultTypeID,
  683. HandleModeID = sp.HandleModeID,
  684. TeachingModeIDList = sp.EM_SpecialtyPlanTeachingModeType.Select(x => x.TeachingModeID).ToList(),
  685. TeachingPlaceIDList = sp.EM_SpecialtyPlanTeachingPlace.Select(x => x.TeachingPlace).ToList(),
  686. StudentCount = grstu.StudentCount == null ? 0 : grstu.StudentCount,
  687. Remark = sp.Remark,
  688. RecordStatus = sp.RecordStatus,
  689. CreateUserID = sp.CreateUserID,
  690. CreateTime = sp.CreateTime,
  691. ModifyUserID = sp.ModifyUserID,
  692. ModifyTime = sp.ModifyTime
  693. };
  694. return query;
  695. }
  696. /// <summary>
  697. /// 查询对应的计划范围信息(根据执行计划信息,统计各班级信息对应的学生人数)
  698. /// </summary>
  699. /// <param name="expExecutablePlan"></param>
  700. /// <param name="expStudent"></param>
  701. /// <returns></returns>
  702. public IQueryable<ClassmajorView> GetPlanRangeViewQueryable(Expression<Func<EM_ExecutablePlan, bool>> expExecutablePlan,
  703. Expression<Func<CF_Student, bool>> expStudent)
  704. {
  705. var query = from ep in ExecutablePlanRepository.GetList(expExecutablePlan)
  706. join gr in GrademajorRepository.Entities
  707. on ep.GrademajorID equals gr.GrademajorID
  708. join cl in ClassmajorRepository.Entities
  709. on gr.GrademajorID equals cl.GrademajorID
  710. join fa in FacultymajorRepository.Entities
  711. on gr.FacultymajorID equals fa.FacultymajorID
  712. join col in CollegeRepository.Entities
  713. on fa.CollegeID equals col.CollegeID
  714. join sc in
  715. (
  716. from stu in StudentRepository.GetList(expStudent)
  717. group stu by stu.CF_Classmajor.ClassmajorID into gstu
  718. select new
  719. {
  720. ClassmajorID = gstu.Key,
  721. StudentCount = gstu.Count()
  722. })
  723. on cl.ClassmajorID equals sc.ClassmajorID into tempsc
  724. from clsc in tempsc.DefaultIfEmpty()
  725. join us in UserRepository.Entities
  726. on cl.UserID equals us.UserID into tempus
  727. from clus in tempus.DefaultIfEmpty()
  728. join au in UserRepository.Entities
  729. on cl.AssistantUserID equals au.UserID into tempau
  730. from clau in tempau.DefaultIfEmpty()
  731. select new ClassmajorView
  732. {
  733. ClassmajorID = cl.ClassmajorID,
  734. No = cl.No,
  735. Name = cl.Name,
  736. Abbreviation = cl.Abbreviation,
  737. EnglishName = cl.EnglishName,
  738. ClassNum = cl.ClassNum ?? 1,
  739. FacultymajorID = gr.FacultymajorID,
  740. FacultymajorCode = fa.Code,
  741. FacultymajorName = fa.Name,
  742. GrademajorID = gr.GrademajorID,
  743. GrademajorCode = gr.Code,
  744. GrademajorName = gr.Name,
  745. CampusID = col.CampusID,
  746. CampusNo = col.CF_Campus.No,
  747. CampusName = col.CF_Campus.Name,
  748. CollegeID = fa.CollegeID,
  749. CollegeCode = col.No,
  750. CollegeName = col.Name,
  751. GradeID = gr.GradeID,
  752. SemesterID = gr.SemesterID,
  753. StandardID = fa.StandardID,
  754. EducationID = fa.EducationID,
  755. LearningformID = fa.LearningformID,
  756. LearnSystem = fa.LearnSystem,
  757. GraduateSchoolyearID = gr.GraduateSchoolyearID,
  758. GraduateValue = gr.CF_Schoolyear.Value,
  759. GraduateSchoolyearCode = gr.CF_Schoolyear.Code,
  760. UserID = cl.UserID,
  761. UserName = clus.Name,
  762. AssistantUserID = cl.AssistantUserID,
  763. AssistantUserName = clau.Name,
  764. Fixedclassroom = cl.Fixedclassroom,
  765. StudentCount = clsc.StudentCount == null ? 0 : clsc.StudentCount,
  766. Remark = cl.Remark,
  767. RecordStatus = cl.RecordStatus,
  768. CreateUserID = cl.CreateUserID,
  769. CreateTime = cl.CreateTime,
  770. ModifyUserID = cl.ModifyUserID,
  771. ModifyTime = cl.ModifyTime
  772. };
  773. return query;
  774. }
  775. /// <summary>
  776. /// 查询执行计划对应的学生信息BaseStudentView(根据执行计划信息、学生信息)
  777. /// </summary>
  778. /// <param name="expExecutablePlan"></param>
  779. /// <param name="expStudent"></param>
  780. /// <returns></returns>
  781. public IQueryable<BaseStudentView> GetBaseStudentViewQueryable(Expression<Func<EM_ExecutablePlan, bool>> expExecutablePlan,
  782. Expression<Func<CF_Student, bool>> expStudent)
  783. {
  784. var query = from ep in ExecutablePlanRepository.GetList(expExecutablePlan)
  785. join gr in GrademajorRepository.Entities
  786. on ep.GrademajorID equals gr.GrademajorID
  787. join fa in FacultymajorRepository.Entities
  788. on gr.FacultymajorID equals fa.FacultymajorID
  789. join col in CollegeRepository.Entities
  790. on fa.CollegeID equals col.CollegeID
  791. join cl in ClassmajorRepository.Entities
  792. on gr.GrademajorID equals cl.GrademajorID
  793. join stu in StudentRepository.GetList(expStudent)
  794. on cl.ClassmajorID equals stu.ClassmajorID
  795. join us in UserRepository.Entities
  796. on stu.UserID equals us.UserID
  797. select new BaseStudentView
  798. {
  799. UserID = stu.UserID,
  800. LoginID = us.LoginID,
  801. UserName = us.Name,
  802. SexID = stu.SexID,
  803. IDNumber = stu.IDNumber,
  804. StudentStatus = stu.StudentStatus,
  805. InSchoolStatusID = stu.InSchoolStatusID,
  806. ClassmajorID = stu.ClassmajorID,
  807. ClassmajorCode = cl.No,
  808. ClassmajorName = cl.Name,
  809. ClassNum = cl.ClassNum == null ? 1 : cl.ClassNum,
  810. SchoolyearID = gr.GradeID,
  811. GrademajorID = cl.GrademajorID,
  812. GrademajorCode = gr.Code,
  813. GrademajorName = gr.Name,
  814. FacultymajorID = gr.FacultymajorID,
  815. FacultymajorCode = fa.Code,
  816. FacultymajorName = fa.Name,
  817. CollegeID = fa.CollegeID,
  818. CollegeNo = col.No,
  819. CollegeName = col.Name
  820. };
  821. return query;
  822. }
  823. /// <summary>
  824. /// 查询执行计划信息对应的授课方式
  825. /// </summary>
  826. /// <param name="exp"></param>
  827. /// <returns></returns>
  828. public IQueryable<int?> GetTeachingModeTypeQueryble(Expression<Func<EM_ExecutablePlan, bool>> exp)
  829. {
  830. var query = from ep in ExecutablePlanRepository.GetList(exp)
  831. join eptm in ExecutablePlanTeachingModeTypeRepository.Entities
  832. on ep.ExecutablePlanID equals eptm.ExecutablePlanID
  833. join dictm in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_TeachingMode).Name)
  834. on eptm.TeachingModeID equals dictm.Value
  835. select dictm.Value;
  836. return query;
  837. }
  838. /// <summary>
  839. /// 查询执行计划信息对应的授课方式
  840. /// </summary>
  841. /// <param name="exp"></param>
  842. /// <returns></returns>
  843. public IQueryable<int?> GetTeachingPlaceQueryble(Expression<Func<EM_ExecutablePlan, bool>> exp)
  844. {
  845. var query = from ep in ExecutablePlanRepository.GetList(exp)
  846. join eptp in ExecutablePlanTeachingPlaceRepository.Entities
  847. on ep.ExecutablePlanID equals eptp.ExecutablePlanID
  848. join dictp in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(EMIS.ViewModel.EM_TeachingPlace).Name)
  849. on eptp.TeachingPlace equals dictp.Value
  850. select dictp.Value;
  851. return query;
  852. }
  853. /// <summary>
  854. /// 查询对应的专业信息CF_Specialty(根据年级专业信息)
  855. /// </summary>
  856. /// <param name="expGrademajor"></param>
  857. /// <returns></returns>
  858. public IQueryable<CF_Specialty> GetSpecialtyQueryable(Expression<Func<CF_Grademajor, bool>> expGrademajor)
  859. {
  860. var query = from gr in GrademajorRepository.GetList(expGrademajor)
  861. join fa in FacultymajorRepository.Entities
  862. on gr.FacultymajorID equals fa.FacultymajorID
  863. join spe in SpecialtyRepository.Entities
  864. on new { StandardID = fa.StandardID, EducationID = fa.EducationID, LearningformID = fa.LearningformID, LearnSystem = fa.LearnSystem }
  865. equals new { StandardID = spe.StandardID, EducationID = spe.EducationID, LearningformID = spe.LearningformID, LearnSystem = spe.LearnSystem }
  866. select spe;
  867. return query;
  868. }
  869. /// <summary>
  870. /// 查询年级专业对应的班级范围信息(根据年级专业信息)
  871. /// </summary>
  872. /// <param name="expGrademajor"></param>
  873. /// <returns></returns>
  874. public IQueryable<CF_Classmajor> GetClassmajorRangeQueryable(Expression<Func<CF_Grademajor, bool>> expGrademajor)
  875. {
  876. var query = from gr in GrademajorRepository.GetList(expGrademajor)
  877. join cl in ClassmajorRepository.Entities
  878. on gr.GrademajorID equals cl.GrademajorID
  879. select cl;
  880. return query;
  881. }
  882. /// <summary>
  883. /// 查询年级专业对应的学生范围信息(根据年级专业信息,不区分在校、非在校)
  884. /// </summary>
  885. /// <param name="expGrademajor"></param>
  886. /// <param name="expStudent"></param>
  887. /// <returns></returns>
  888. public IQueryable<CF_Student> GetStudentRangeQueryable(Expression<Func<CF_Grademajor, bool>> expGrademajor)
  889. {
  890. var query = from gr in GrademajorRepository.GetList(expGrademajor)
  891. join cl in ClassmajorRepository.Entities
  892. on gr.GrademajorID equals cl.GrademajorID
  893. join stu in StudentRepository.Entities
  894. on cl.ClassmajorID equals stu.ClassmajorID
  895. select stu;
  896. return query;
  897. }
  898. /// <summary>
  899. /// 查询年级专业对应的学生范围信息(根据年级专业信息、学生信息)
  900. /// </summary>
  901. /// <param name="expGrademajor"></param>
  902. /// <param name="expStudent"></param>
  903. /// <returns></returns>
  904. public IQueryable<CF_Student> GetStudentRangeQueryable(Expression<Func<CF_Grademajor, bool>> expGrademajor,
  905. Expression<Func<CF_Student, bool>> expStudent)
  906. {
  907. var query = from gr in GrademajorRepository.GetList(expGrademajor)
  908. join cl in ClassmajorRepository.Entities
  909. on gr.GrademajorID equals cl.GrademajorID
  910. join stu in StudentRepository.GetList(expStudent)
  911. on cl.ClassmajorID equals stu.ClassmajorID
  912. select stu;
  913. return query;
  914. }
  915. /// <summary>
  916. /// 查询对应的教学任务班信息EM_EducationMissionClass(根据执行计划信息)
  917. /// </summary>
  918. /// <param name="expExecutablePlan"></param>
  919. /// <returns></returns>
  920. public IQueryable<EM_EducationMissionClass> GetEducationMissionClassQueryable(Expression<Func<EM_ExecutablePlan, bool>> exp)
  921. {
  922. var query = (
  923. from ep in ExecutablePlanRepository.GetList(exp)
  924. join gr in GrademajorRepository.Entities
  925. on ep.GrademajorID equals gr.GrademajorID
  926. join cl in ClassmajorRepository.Entities
  927. on gr.GrademajorID equals cl.GrademajorID
  928. join educl in EducationMissionClassRepository.Entities
  929. on new { SchoolyearID = ep.SchoolyearID, CoursematerialID = ep.CoursematerialID }
  930. equals new { SchoolyearID = educl.EM_EducationMission.SchoolyearID, CoursematerialID = educl.CoursematerialID }
  931. from edu_cl in educl.CF_Classmajor
  932. where cl.ClassmajorID == edu_cl.ClassmajorID
  933. select educl
  934. )
  935. .Include(x => x.EM_EducationMission)
  936. .Include(x => x.EM_EducationMissionClassTeachingSetting)
  937. .Include(x => x.CF_Classmajor)
  938. .Include(x => x.EM_EducationSchedulingClass)
  939. .Include(x => x.EM_EducationSchedulingClass.Select(s => s.CF_Student))
  940. .Include(x => x.EM_EducationMissionClassSettings)
  941. .Include(x => x.EM_MissionClassTeacher)
  942. .Include(x => x.EM_CourseProcess);
  943. return query;
  944. }
  945. /// <summary>
  946. /// 查询课程信息中授课方式分班信息(根据课程信息)
  947. /// </summary>
  948. /// <param name="expCoursematerial"></param>
  949. /// <returns></returns>
  950. public IQueryable<int?> GetSeparateModeTypeQueryble(Expression<Func<EM_Coursematerial, bool>> expCoursematerial)
  951. {
  952. var query = from cou in CoursematerialRepository.GetList(expCoursematerial)
  953. join cg in ClassGroupingRepository.Entities
  954. on cou.ClassGroupingID equals cg.ClassGroupingID
  955. join cgst in ClassGroupingSettingsRepository.Entities
  956. on cg.ClassGroupingID equals cgst.ClassGroupingID
  957. join dictm in DictionaryItemRepository.GetList(x => x.DictionaryCode == typeof(CF_TeachingMode).Name)
  958. on cgst.TeachingModeID equals dictm.Value
  959. select dictm.Value;
  960. return query;
  961. }
  962. /// <summary>
  963. ///
  964. /// </summary>
  965. /// <param name="studentExp"></param>
  966. /// <returns></returns>
  967. public IQueryable<CoursematerialView> GetLastCoursematerialViewQueryable(Expression<Func<CF_Student, bool>> studentExp)
  968. {
  969. var courseQuery = CoursematerialDAL.Value.GetCoursematerialViewQueryable(x => true);
  970. var query = (from plan in ExecutablePlanRepository.Entities
  971. from schoolyear in SchoolyearRepository.Entities.Where(x => x.SchoolyearID == plan.SchoolyearID)
  972. from classmajor in ClassmajorRepository.Entities.Where(x => x.GrademajorID == plan.GrademajorID)
  973. from student in StudentRepository.Entities.Where(x => x.ClassmajorID == classmajor.ClassmajorID)
  974. .Where(studentExp)
  975. from course in courseQuery.Where(x => x.CoursematerialID == plan.CoursematerialID)
  976. group new { course, schoolyear } by plan.CoursematerialID into g
  977. select g.OrderByDescending(x => x.schoolyear.Value)
  978. .Select(x => x.course)
  979. .FirstOrDefault()
  980. );
  981. return query;
  982. }
  983. /// <summary>
  984. ///
  985. /// </summary>
  986. /// <returns></returns>
  987. public IQueryable<LastCourseStarttermView> GetLastCourseStarttermViewQueryable()
  988. {
  989. var query = (from plan in ExecutablePlanRepository.Entities
  990. from profile in ExecutablePlanProfileRepository.Entities.Where(x => x.ExecutablePlanID == plan.ExecutablePlanID)
  991. from setting in ExecutablePlanTeachingSettingRepository.Entities.Where(x => x.ExecutablePlanID == plan.ExecutablePlanID)
  992. from schoolyear in SchoolyearRepository.Entities.Where(x => x.SchoolyearID == plan.SchoolyearID)
  993. from classmajor in ClassmajorRepository.Entities.Where(x => x.GrademajorID == plan.GrademajorID)
  994. from student in classmajor.CF_Student
  995. from grade in GrademajorRepository.Entities.Where(x => x.GrademajorID == classmajor.GrademajorID)
  996. from gradeSchoolyear in SchoolyearRepository.Entities.Where(x => x.Years == grade.GradeID && x.SchoolcodeID == grade.SemesterID)
  997. from temp in
  998. (
  999. from plan1 in ExecutablePlanRepository.Entities
  1000. from schoolyear1 in SchoolyearRepository.Entities.Where(x => x.SchoolyearID == plan1.SchoolyearID)
  1001. from classmajor1 in ClassmajorRepository.Entities.Where(x => x.GrademajorID == plan1.GrademajorID)
  1002. from student1 in classmajor1.CF_Student
  1003. group new { student1.UserID, plan1.CoursematerialID, SchoolyearValue = schoolyear1.Value }
  1004. by new { student1.UserID, plan1.CoursematerialID } into g
  1005. select new { UserID = g.Key.UserID, CoursematerialID = g.Key.CoursematerialID, MaxSchoolyearValue = g.Max(x => x.SchoolyearValue) })
  1006. .Where(x => x.CoursematerialID == plan.CoursematerialID && x.MaxSchoolyearValue == schoolyear.Value
  1007. && x.UserID == student.UserID)
  1008. select new
  1009. {
  1010. SchoolyearID = plan.SchoolyearID,
  1011. SchoolyearNumID = ((schoolyear.Value - gradeSchoolyear.Value) / 2) + 1,
  1012. CoursematerialID = plan.CoursematerialID,
  1013. DepartmentID = plan.DepartmentID,
  1014. ClassName = plan.DefaultClassName,
  1015. CourseTypeID = plan.CourseTypeID,
  1016. ExaminationModeID = profile.ExaminationModeID,
  1017. HandleModeID = plan.HandleModeID,
  1018. Credit = setting.Credit,
  1019. TotalHours = (setting.TheoryCourse ?? 0) + (setting.Practicehours ?? 0),
  1020. ResultTypeID = plan.ResultTypeID,
  1021. StarttermID = (schoolyear.Value - gradeSchoolyear.Value + 1),
  1022. UserID = student.UserID
  1023. } into s
  1024. select new LastCourseStarttermView
  1025. {
  1026. SchoolyearID = s.SchoolyearID,
  1027. SchoolyearNumID = s.SchoolyearNumID,
  1028. CoursematerialID = s.CoursematerialID,
  1029. DepartmentID = s.DepartmentID,
  1030. ClassName = s.ClassName,
  1031. CourseTypeID = s.CourseTypeID,
  1032. ExaminationModeID = s.ExaminationModeID,
  1033. HandleModeID = s.HandleModeID,
  1034. Credit = s.Credit,
  1035. TotalHours = s.TotalHours,
  1036. ResultTypeID = s.ResultTypeID,
  1037. StarttermID = s.StarttermID,
  1038. UserID = s.UserID
  1039. }
  1040. );
  1041. return query;
  1042. }
  1043. }
  1044. }