CollegeDAL.cs 22 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Linq.Expressions;
  5. using System.Text;
  6. using EMIS.Entities;
  7. using EMIS.ViewModel;
  8. using EMIS.ViewModel.UniversityManage.AdministrativeOrgan;
  9. using EMIS.ViewModel.UniversityManage.SpecialtyClassManage;
  10. using EMIS.ViewModel.UniversityManage.TeacherManage;
  11. using EMIS.DataLogic.Repositories;
  12. namespace EMIS.DataLogic.UniversityManage.AdministrativeOrgan
  13. {
  14. public class CollegeDAL
  15. {
  16. public CollegeRepository CollegeRepository { get; set; }
  17. public CollegeProfileRepository CollegeProfileRepository { get; set; }
  18. public CampusRepository CampusRepository { get; set; }
  19. public DepartmentRepository DepartmentRepository { get; set; }
  20. public FacultymajorRepository FacultymajorRepository { get; set; }
  21. public GrademajorRepository GrademajorRepository { get; set; }
  22. public StaffRepository StaffRepository { get; set; }
  23. public StaffProfileRepository StaffProfileRepository { get; set; }
  24. public StudentRepository StudentRepository { get; set; }
  25. public UserRepository UserRepository { get; set; }
  26. public DictionaryItemRepository DictionaryItemRepository { get; set; }
  27. /// <summary>
  28. /// 查询对应的院系所信息CollegeView
  29. /// </summary>
  30. /// <returns></returns>
  31. public IQueryable<CollegeView> GetCollegeViewQueryable()
  32. {
  33. var query = from col in CollegeRepository.Entities
  34. join cam in CampusRepository.Entities
  35. on col.CampusID equals cam.CampusID
  36. join pm in UserRepository.Entities
  37. on col.CF_CollegeProfile.PoliticalManager equals pm.UserID into temppm
  38. from pmus in temppm.DefaultIfEmpty()
  39. join am in UserRepository.Entities
  40. on col.CF_CollegeProfile.AdministrativeManager equals am.UserID into tempam
  41. from amus in tempam.DefaultIfEmpty()
  42. select new CollegeView
  43. {
  44. CollegeID = col.CollegeID,
  45. No = col.No,
  46. Name = col.Name,
  47. SimpleName = col.SimpleName,
  48. EnglishName = col.EnglishName,
  49. CampusID = col.CampusID,
  50. CampusNo = cam.No,
  51. CampusName = cam.Name,
  52. PoliticalManager = col.CF_CollegeProfile.PoliticalManager,
  53. PoliticalManagerName = pmus.Name,
  54. AdministrativeManager = col.CF_CollegeProfile.AdministrativeManager,
  55. AdministrativeManagerName = amus.Name,
  56. UnitCategoryID = col.CF_CollegeProfile.UnitCategoryID,
  57. CollegeTypeID = col.CF_CollegeProfile.CollegeTypeID,
  58. CollegeCategoryID = col.CF_CollegeProfile.CollegeCategoryID,
  59. RunByCategoryID = col.CF_CollegeProfile.RunByCategoryID,
  60. FoundDate = col.CF_CollegeProfile.FoundDate,
  61. Officephone = col.CF_CollegeProfile.Officephone,
  62. Remark = col.Remark,
  63. RecordStatus = col.RecordStatus,
  64. CreateUserID = col.CreateUserID,
  65. CreateTime = col.CreateTime,
  66. ModifyUserID = col.ModifyUserID,
  67. ModifyTime = col.ModifyTime
  68. };
  69. return query;
  70. }
  71. /// <summary>
  72. /// 查询对应的院系所信息CollegeView(统计对应的教研室数、教师人数、院系专业数)
  73. /// </summary>
  74. /// <param name="expCollege"></param>
  75. /// <returns></returns>
  76. public IQueryable<CollegeView> GetCollegeViewQueryable(Expression<Func<CF_College, bool>> expCollege)
  77. {
  78. var query = from col in CollegeRepository.GetList(expCollege)
  79. join cam in CampusRepository.Entities
  80. on col.CampusID equals cam.CampusID
  81. join pm in UserRepository.Entities
  82. on col.CF_CollegeProfile.PoliticalManager equals pm.UserID into temppm
  83. from pmus in temppm.DefaultIfEmpty()
  84. join am in UserRepository.Entities
  85. on col.CF_CollegeProfile.AdministrativeManager equals am.UserID into tempam
  86. from amus in tempam.DefaultIfEmpty()
  87. join dep in
  88. (
  89. from dep in DepartmentRepository.Entities
  90. group dep by dep.CollegeID into depgr
  91. select new
  92. {
  93. CollegeID = depgr.Key,
  94. DepartmentCount = depgr.Count()
  95. }
  96. )
  97. on col.CollegeID equals dep.CollegeID into tempdep
  98. from depcol in tempdep.DefaultIfEmpty()
  99. join sta in
  100. (
  101. from sta in StaffRepository.Entities
  102. group sta by sta.CollegeID into stagr
  103. select new
  104. {
  105. CollegeID = stagr.Key,
  106. StaffCount = stagr.Count()
  107. }
  108. )
  109. on col.CollegeID equals sta.CollegeID into tempsta
  110. from stacol in tempsta.DefaultIfEmpty()
  111. join fa in
  112. (
  113. from fa in FacultymajorRepository.Entities
  114. group fa by fa.CollegeID into fagr
  115. select new
  116. {
  117. CollegeID = fagr.Key,
  118. FacultymajorCount = fagr.Count()
  119. }
  120. )
  121. on col.CollegeID equals fa.CollegeID into tempfa
  122. from facol in tempfa.DefaultIfEmpty()
  123. select new CollegeView
  124. {
  125. CollegeID = col.CollegeID,
  126. No = col.No,
  127. Name = col.Name,
  128. SimpleName = col.SimpleName,
  129. EnglishName = col.EnglishName,
  130. CampusID = col.CampusID,
  131. CampusNo = cam.No,
  132. CampusName = cam.Name,
  133. PoliticalManager = col.CF_CollegeProfile.PoliticalManager,
  134. PoliticalManagerName = pmus.Name,
  135. AdministrativeManager = col.CF_CollegeProfile.AdministrativeManager,
  136. AdministrativeManagerName = amus.Name,
  137. UnitCategoryID = col.CF_CollegeProfile.UnitCategoryID,
  138. CollegeTypeID = col.CF_CollegeProfile.CollegeTypeID,
  139. CollegeCategoryID = col.CF_CollegeProfile.CollegeCategoryID,
  140. RunByCategoryID = col.CF_CollegeProfile.RunByCategoryID,
  141. FoundDate = col.CF_CollegeProfile.FoundDate,
  142. Officephone = col.CF_CollegeProfile.Officephone,
  143. DepartmentCount = depcol.DepartmentCount == null ? 0 : depcol.DepartmentCount,
  144. StaffCount = stacol.StaffCount == null ? 0 : stacol.StaffCount,
  145. FacultymajorCount = facol.FacultymajorCount == null ? 0 : facol.FacultymajorCount,
  146. Remark = col.Remark,
  147. RecordStatus = col.RecordStatus,
  148. CreateUserID = col.CreateUserID,
  149. CreateTime = col.CreateTime,
  150. ModifyUserID = col.ModifyUserID,
  151. ModifyTime = col.ModifyTime
  152. };
  153. return query;
  154. }
  155. /// <summary>
  156. /// 查询对应的院系所信息CollegeView(只显示院、系、部类别的院系所)
  157. /// </summary>
  158. /// <param name="expCollege"></param>
  159. /// <returns></returns>
  160. public IQueryable<CollegeView> GetOnlyCollegeViewQueryable(Expression<Func<CF_College, bool>> expCollege)
  161. {
  162. var query = from col in CollegeRepository.GetList(expCollege)
  163. join cam in CampusRepository.Entities
  164. on col.CampusID equals cam.CampusID
  165. where col.CF_CollegeProfile.UnitCategoryID == (int)CF_UnitCategory.College
  166. select new CollegeView
  167. {
  168. CollegeID = col.CollegeID,
  169. No = col.No,
  170. Name = col.Name,
  171. SimpleName = col.SimpleName,
  172. EnglishName = col.EnglishName,
  173. CampusID = col.CampusID,
  174. CampusNo = cam.No,
  175. CampusName = cam.Name,
  176. UnitCategoryID = col.CF_CollegeProfile.UnitCategoryID,
  177. CollegeTypeID = col.CF_CollegeProfile.CollegeTypeID,
  178. CollegeCategoryID = col.CF_CollegeProfile.CollegeCategoryID,
  179. RunByCategoryID = col.CF_CollegeProfile.RunByCategoryID,
  180. FoundDate = col.CF_CollegeProfile.FoundDate,
  181. Officephone = col.CF_CollegeProfile.Officephone,
  182. Remark = col.Remark,
  183. RecordStatus = col.RecordStatus,
  184. CreateUserID = col.CreateUserID,
  185. CreateTime = col.CreateTime,
  186. ModifyUserID = col.ModifyUserID,
  187. ModifyTime = col.ModifyTime
  188. };
  189. return query;
  190. }
  191. /// <summary>
  192. /// 查询对应的教研室信息CollegeView(统计对应的教师人数)
  193. /// </summary>
  194. /// <param name="expCollege"></param>
  195. /// <returns></returns>
  196. public IQueryable<DepartmentView> GetDepartmentViewQueryable(Expression<Func<CF_College, bool>> expCollege)
  197. {
  198. var query = from col in CollegeRepository.GetList(expCollege)
  199. join dep in DepartmentRepository.Entities
  200. on col.CollegeID equals dep.CollegeID
  201. join c in UserRepository.Entities
  202. on dep.CF_DepartmentProfile.DirectorID equals c.UserID into gu
  203. from guic in gu.DefaultIfEmpty()
  204. join d in UserRepository.Entities
  205. on dep.CF_DepartmentProfile.DeputyDirectorID equals d.UserID into gude
  206. from gudeic in gude.DefaultIfEmpty()
  207. join sta in
  208. (
  209. from sta in StaffRepository.Entities
  210. group sta by sta.DepartmentID into stagr
  211. select new
  212. {
  213. DepartmentID = stagr.Key,
  214. StaffCount = stagr.Count()
  215. }
  216. )
  217. on dep.DepartmentID equals sta.DepartmentID into tempsta
  218. from stadep in tempsta.DefaultIfEmpty()
  219. select new DepartmentView
  220. {
  221. DepartmentID = dep.DepartmentID,
  222. No = dep.No,
  223. Name = dep.Name,
  224. SimpleName = dep.SimpleName,
  225. EnglishName = dep.EnglishName,
  226. CampusID = col.CampusID,
  227. CampusNo = col.CF_Campus.No,
  228. CampusName = col.CF_Campus.Name,
  229. CollegeID = dep.CollegeID,
  230. CollegeCode = col.No,
  231. CollegeName = col.Name,
  232. HierarchyID = dep.HierarchyID,
  233. DirectorID = dep.CF_DepartmentProfile.DirectorID,
  234. DirectorName = guic.Name,
  235. DeputyDirectorID = dep.CF_DepartmentProfile.DeputyDirectorID,
  236. DeputyDirectorName = gudeic.Name,
  237. FoundDate = dep.CF_DepartmentProfile.FoundDate,
  238. StaffCount = stadep.StaffCount == null ? 0 : stadep.StaffCount,
  239. Remark = dep.Remark,
  240. RecordStatus = dep.RecordStatus,
  241. CreateUserID = dep.CreateUserID,
  242. CreateTime = dep.CreateTime,
  243. ModifyUserID = dep.ModifyUserID,
  244. ModifyTime = dep.ModifyTime
  245. };
  246. return query;
  247. }
  248. /// <summary>
  249. /// 查询对应的教师信息StaffView
  250. /// </summary>
  251. /// <param name="expCollege"></param>
  252. /// <returns></returns>
  253. public IQueryable<StaffView> GetStaffViewQueryable(Expression<Func<CF_College, bool>> expCollege)
  254. {
  255. var query = from col in CollegeRepository.GetList(expCollege)
  256. join sf in StaffRepository.Entities
  257. on col.CollegeID equals sf.CollegeID
  258. join pr in StaffProfileRepository.Entities
  259. on sf.UserID equals pr.UserID into temppr
  260. from sfpr in temppr.DefaultIfEmpty()
  261. join dep in DepartmentRepository.Entities
  262. on sf.DepartmentID equals dep.DepartmentID into tempdep
  263. from sfdep in tempdep.DefaultIfEmpty()
  264. join us in UserRepository.Entities
  265. on sf.UserID equals us.UserID
  266. select new StaffView
  267. {
  268. UserID = sf.UserID,
  269. StaffCode = us.LoginID,
  270. Name = us.Name,
  271. UsedName = sfpr.UsedName,
  272. CampusID = col.CampusID,
  273. CampusCode = col.CF_Campus.No,
  274. CampusName = col.CF_Campus.Name,
  275. CollegeID = sf.CollegeID,
  276. CollegeNo = col.No,
  277. CollegeName = col.Name,
  278. DepartmentID = sf.DepartmentID,
  279. DepartmentCode = sfdep.No,
  280. DepartmentName = sfdep.Name,
  281. Nationality = sfpr.Nationality,
  282. Place = sfpr.Place,
  283. SexID = sf.SexID,
  284. BirthDate = sf.BirthDate,
  285. NationID = sf.NationID,
  286. PoliticsID = sf.PoliticsID,
  287. CertificatesType = sf.CertificatesType,
  288. CertificatesNum = sf.CertificatesNum,
  289. TeacherTypeID = sf.TeacherTypeID,
  290. IncumbencyState = sf.IncumbencyState,
  291. SituationID = sf.SituationID,
  292. TitleID = sf.TitleID,
  293. LiteracyLevelID = sf.LiteracyLevelID,
  294. LearnPositionID = sf.LearnPositionID,
  295. IsDualTeacher = sf.IsDualTeacher ?? false,
  296. PaymentLevelID = sf.PaymentLevelID,
  297. WorkDate = sf.WorkDate,
  298. ComeSchoolDate = sf.ComeSchoolDate,
  299. Email = sfpr.Email,
  300. ZIPCode = sfpr.ZIPCode,
  301. WeChatNum = sfpr.WeChatNum,
  302. QQ = sfpr.QQ,
  303. Telephone = sfpr.Telephone,
  304. OfficeTelephone = sfpr.OfficeTelephone,
  305. HousePhone = sfpr.HousePhone,
  306. Mobile = sfpr.Mobile,
  307. Speciality = sfpr.Speciality,
  308. HealthStateID = sfpr.HealthStateID,
  309. ReligionID = sfpr.ReligionID,
  310. Account = sfpr.Account,
  311. Residence = sfpr.Residence,
  312. HomeAddress = sfpr.HomeAddress,
  313. Address = sfpr.Address,
  314. NowAddress = sfpr.NowAddress,
  315. PhotoUrl = sf.PhotoUrl,
  316. PhotoHasValue = (sf.PhotoUrl == null || sf.PhotoUrl == "") ? false : true,
  317. Profile = sf.Profile,
  318. Remark = sf.Remark,
  319. RecordStatus = sf.RecordStatus,
  320. CreateUserID = sf.CreateUserID,
  321. CreateTime = sf.CreateTime,
  322. ModifyUserID = sf.ModifyUserID,
  323. ModifyTime = sf.ModifyTime
  324. };
  325. return query;
  326. }
  327. /// <summary>
  328. /// 查询对应的院系专业信息FacultymajorView(统计对应的年级专业数、学生人数)
  329. /// </summary>
  330. /// <param name="expCollege"></param>
  331. /// <param name="expStudent"></param>
  332. /// <returns></returns>
  333. public IQueryable<FacultymajorView> GetFacultymajorViewQueryable(Expression<Func<CF_College, bool>> expCollege, Expression<Func<CF_Student, bool>> expStudent)
  334. {
  335. var query = from col in CollegeRepository.GetList(expCollege)
  336. join fa in FacultymajorRepository.Entities
  337. on col.CollegeID equals fa.CollegeID
  338. join dicst in DictionaryItemRepository.GetList(x => x.DictionaryCode == DictionaryItem.CF_Standard.ToString())
  339. on fa.StandardID equals dicst.Value into tempst
  340. from standard in tempst.DefaultIfEmpty()
  341. join gr in
  342. (
  343. from gr in GrademajorRepository.Entities
  344. group gr by gr.FacultymajorID into ggr
  345. select new
  346. {
  347. FacultymajorID = ggr.Key,
  348. GrademajorCount = ggr.Count()
  349. }
  350. )
  351. on fa.FacultymajorID equals gr.FacultymajorID into tempgr
  352. from grfa in tempgr.DefaultIfEmpty()
  353. join sc in
  354. (
  355. from sc in StudentRepository.GetList(expStudent)
  356. group sc by sc.CF_Classmajor.CF_Grademajor.FacultymajorID into gstu
  357. select new
  358. {
  359. FacultymajorID = gstu.Key,
  360. StudentCount = gstu.Count()
  361. }
  362. )
  363. on fa.FacultymajorID equals sc.FacultymajorID into tempstu
  364. from stufa in tempstu.DefaultIfEmpty()
  365. select new FacultymajorView
  366. {
  367. FacultymajorID = fa.FacultymajorID,
  368. Code = fa.Code,
  369. Name = fa.Name,
  370. Abbreviation = fa.Abbreviation,
  371. EnglishName = fa.EnglishName,
  372. NameCode = fa.Name + fa.Code,
  373. CampusID = col.CampusID,
  374. CampusNo = col.CF_Campus.No,
  375. CampusName = col.CF_Campus.Name,
  376. CollegeID = fa.CollegeID,
  377. CollegeCode = col.No,
  378. CollegeName = col.Name,
  379. StandardID = fa.StandardID,
  380. StandardName = standard.Name,
  381. EducationID = fa.EducationID,
  382. LearningformID = fa.LearningformID,
  383. LearnSystem = fa.LearnSystem,
  384. ScienceclassID = fa.ScienceclassID,
  385. LearningstyleID = fa.LearningstyleID,
  386. LearnPositionID = fa.LearnPositionID,
  387. TeacherIdentification = fa.TeacherIdentification,
  388. SetTime = fa.SetTime,
  389. GrademajorCount = grfa.GrademajorCount == null ? 0 : grfa.GrademajorCount,
  390. StudentCount = stufa.StudentCount == null ? 0 : stufa.StudentCount,
  391. Remark = fa.Remark,
  392. RecordStatus = fa.RecordStatus,
  393. CreateUserID = fa.CreateUserID,
  394. CreateTime = fa.CreateTime,
  395. ModifyUserID = fa.ModifyUserID,
  396. ModifyTime = fa.ModifyTime
  397. };
  398. return query;
  399. }
  400. }
  401. }