ChargeStandardDAL.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259
  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.UniversityManage.SpecialtyClassManage;
  8. using EMIS.ViewModel.ChargeManage.ChargeSituation;
  9. using EMIS.DataLogic.Common.Students;
  10. using EMIS.DataLogic.Repositories;
  11. using EMIS.ViewModel.Students;
  12. namespace EMIS.DataLogic.ChargeManage.ChargeSituation
  13. {
  14. public class ChargeStandardDAL
  15. {
  16. public DictionaryItemRepository dictionaryItemRepository { get; set; }
  17. public ChargeProjectRepository ChargeProjectRepository { get; set; }
  18. public ChargeStandardRepository ChargeStandardRepository { get; set; }
  19. public SchoolyearRepository SchoolyearRepository { get; set; }
  20. public CollegeRepository CollegeRepository { get; set; }
  21. public FacultymajorRepository FacultymajorRepository { get; set; }
  22. public GrademajorRepository GrademajorRepository { get; set; }
  23. public StudentRepository StudentRepository { get; set; }
  24. public UserRepository UserRepository { get; set; }
  25. public ClassmajorRepository ClassmajorRepository { get; set; }
  26. public StudentChargePaymentRepository StudentChargePaymentRepository { get; set; }
  27. public StudentChargeRepository StudentChargeRepository { get; set; }
  28. public InSchoolSettingRepository InSchoolSetingRepository { get; set; }
  29. /// <summary>
  30. /// 查询收费标准信息(全部在校状态学生)
  31. /// </summary>
  32. /// <param name="expChargeStandard"></param>
  33. /// <param name="expStudent"></param>
  34. /// <returns></returns>
  35. public IQueryable<ChargeStandardView> GetChargeStandarViewQueryAble(Expression<Func<EC_ChargeStandard, bool>> expChargeStandard, Expression<Func<CF_Student, bool>> expStudent)
  36. {
  37. var query = from ch in ChargeStandardRepository.GetList(expChargeStandard)
  38. join pr in ChargeProjectRepository.Entities
  39. on ch.ChargeProjectID equals pr.ChargeProjectID
  40. join sctoal in
  41. (
  42. from stu in StudentRepository.GetList(expStudent)
  43. join cl in ClassmajorRepository.Entities
  44. on stu.ClassmajorID equals cl.ClassmajorID
  45. group cl by cl.GrademajorID into g
  46. select new
  47. {
  48. GrademajorID = (Guid?)g.Key,
  49. StudentCount = g.Count()
  50. }
  51. )
  52. on ch.GrademajorID equals sctoal.GrademajorID
  53. into chtemp
  54. from chsc in chtemp.DefaultIfEmpty()
  55. join sc in
  56. (
  57. from stuch in StudentChargeRepository.Entities
  58. join stu in StudentRepository.Entities
  59. on stuch.UserID equals stu.UserID
  60. join cl in ClassmajorRepository.Entities
  61. on stu.ClassmajorID equals cl.ClassmajorID
  62. join ch in ChargeStandardRepository.Entities
  63. on
  64. new { cl.GrademajorID, stuch.ChargeProjectID, stuch.ChargeYear }
  65. equals
  66. new { ch.GrademajorID, ch.ChargeProjectID, ch.ChargeYear }
  67. into temp
  68. from stuchcre in temp.DefaultIfEmpty()
  69. group stuchcre by stuchcre.ChargeStandardID into g
  70. select new
  71. {
  72. ChargeStandardID = (Guid?)g.Key,
  73. StudentChargeCount = g.Count()
  74. }
  75. )
  76. on ch.ChargeStandardID equals sc.ChargeStandardID
  77. into stuchtemp
  78. from stuch in stuchtemp.DefaultIfEmpty()
  79. join gr in GrademajorRepository.Entities
  80. on ch.GrademajorID equals gr.GrademajorID
  81. join fa in FacultymajorRepository.Entities
  82. on gr.FacultymajorID equals fa.FacultymajorID
  83. select new ChargeStandardView
  84. {
  85. ChargeStandardID = ch.ChargeStandardID,
  86. GrademajorID = ch.GrademajorID,
  87. GradeMajorCode = gr.Code,
  88. GrademajorStr = gr.Name,
  89. ChargeProjectID = ch.ChargeProjectID,
  90. ChargeProjectStr = pr.Name,
  91. ChargeYear = ch.ChargeYear,
  92. Amount = ch.Amount,
  93. CollegeID = fa.CollegeID,
  94. CollegeCode = fa.CF_College.No,
  95. CollegeStr = fa.CF_College.Name,
  96. GradeStr = gr.GradeID,
  97. StandardID = fa.StandardID,
  98. EducationID = fa.EducationID,
  99. LearningformID = fa.LearningformID,
  100. LearnSystem = fa.LearnSystem,
  101. StudentChargeCount = stuch.StudentChargeCount == null ? 0 : stuch.StudentChargeCount,
  102. StudentCount = chsc.StudentCount == null ? 0 : chsc.StudentCount
  103. };
  104. return query;
  105. }
  106. /// <summary>
  107. /// 根据缴费学年、收费项目查询年级专业信息(全部在校状态学生)
  108. /// </summary>
  109. /// <param name="exp"></param>
  110. /// <returns></returns>
  111. public IQueryable<GrademajorView> GetGradeMajorViewQueryAble(Expression<Func<EC_ChargeStandard, bool>> expChargeStandard, Expression<Func<CF_Student, bool>> expStudent)
  112. {
  113. //注:年级专业与以学生信息表对应的年级专业统计要左连接(防止学生人数为0时,查询不出年级专业信息)
  114. var query = from gr in GrademajorRepository.Entities
  115. join sc in
  116. (
  117. from stu in StudentRepository.GetList(expStudent)
  118. join cl in ClassmajorRepository.Entities
  119. on stu.ClassmajorID equals cl.ClassmajorID
  120. group cl by cl.GrademajorID into g
  121. select new
  122. {
  123. GrademajorID = (Guid)g.Key,
  124. StudentCount = g.Count()
  125. }
  126. )
  127. on gr.GrademajorID equals sc.GrademajorID into grtemp
  128. from grsc in grtemp.DefaultIfEmpty()
  129. join ch in ChargeStandardRepository.GetList(expChargeStandard)
  130. on gr.GrademajorID equals ch.GrademajorID into chtemp
  131. from chsc in chtemp.DefaultIfEmpty()
  132. join fa in FacultymajorRepository.Entities
  133. on gr.FacultymajorID equals fa.FacultymajorID
  134. where chsc.ChargeStandardID == null
  135. select new GrademajorView
  136. {
  137. GrademajorID = gr.GrademajorID,
  138. Code = gr.Code,
  139. Name = gr.Name,
  140. Abbreviation = gr.Abbreviation,
  141. GradeID = gr.GradeID,
  142. SemesterID = gr.SemesterID,
  143. FacultymajorID = fa.FacultymajorID,
  144. FacultymajorCode = fa.Code,
  145. FacultymajorName = fa.Name,
  146. EducationID = fa.EducationID,
  147. LearningformID = fa.LearningformID,
  148. LearnSystem = fa.LearnSystem,
  149. StandardID = fa.StandardID,
  150. CollegeID = fa.CF_College.CollegeID,
  151. CollegeName = fa.CF_College.Name,
  152. CollegeCode = fa.CF_College.No,
  153. GraduateSchoolyearID = gr.GraduateSchoolyearID,
  154. GraduateValue = gr.CF_Schoolyear.Value,
  155. GraduateSchoolyearCode = gr.CF_Schoolyear.Code,
  156. Professional = gr.Professional,
  157. StudentCount = grsc.StudentCount == null ? 0 : grsc.StudentCount
  158. };
  159. return query;
  160. }
  161. /// <summary>
  162. /// 查询年级专业对应的各在校状态学生信息
  163. /// </summary>
  164. /// <param name="expGrademajor"></param>
  165. /// <param name="expStudent"></param>
  166. /// <returns></returns>
  167. public IQueryable<StudentsView> GetGradeMajorStudentViewQueryAble(Expression<Func<CF_Grademajor, bool>> expGrademajor, Expression<Func<CF_Student, bool>> expStudent)
  168. {
  169. var query = from gr in GrademajorRepository.GetList(expGrademajor)
  170. join cl in ClassmajorRepository.Entities
  171. on gr.GrademajorID equals cl.GrademajorID
  172. join stu in StudentRepository.GetList(expStudent)
  173. on cl.ClassmajorID equals stu.ClassmajorID
  174. join us in UserRepository.Entities
  175. on stu.UserID equals us.UserID
  176. select new StudentsView
  177. {
  178. UserID = stu.UserID,
  179. LoginID = us.LoginID,
  180. UserName = us.Name,
  181. SexID = stu.SexID,
  182. InSchoolStatusID = stu.InSchoolStatusID,
  183. StudentStatus = stu.StudentStatus,
  184. GradeMajorID = gr.GrademajorID,
  185. GradeMajorCode = gr.Code,
  186. GradeMajorName = gr.Name,
  187. ClassMajorID = cl.ClassmajorID,
  188. ClassMajorCode = cl.No,
  189. ClassMajorName = cl.Name
  190. };
  191. return query;
  192. }
  193. /// <summary>
  194. /// 查询应收名单信息(根据应收名单、年级专业查询)
  195. /// </summary>
  196. /// <param name="expStudentCharge"></param>
  197. /// <param name="expGrademajor"></param>
  198. /// <returns></returns>
  199. public IQueryable<StudentChargeView> GetGradeMajorStudentChargeViewQueryAble(Expression<Func<EC_StudentCharge, bool>> expStudentCharge, Expression<Func<CF_Grademajor, bool>> expGrademajor)
  200. {
  201. var query = from sc in StudentChargeRepository.GetList(expStudentCharge)
  202. join pr in ChargeProjectRepository.Entities
  203. on sc.ChargeProjectID equals pr.ChargeProjectID
  204. join stu in StudentRepository.Entities
  205. on sc.UserID equals stu.UserID
  206. join us in UserRepository.Entities
  207. on stu.UserID equals us.UserID
  208. join cl in ClassmajorRepository.Entities
  209. on stu.ClassmajorID equals cl.ClassmajorID
  210. join gr in GrademajorRepository.GetList(expGrademajor)
  211. on cl.GrademajorID equals gr.GrademajorID
  212. join fa in FacultymajorRepository.Entities
  213. on gr.FacultymajorID equals fa.FacultymajorID
  214. select new StudentChargeView
  215. {
  216. StudentChargeID = sc.StudentChargeID,
  217. UserID = us.UserID,
  218. StudentNo = us.LoginID,
  219. UserName = us.Name,
  220. SexID = stu.SexID,
  221. InSchoolStatusID = stu.InSchoolStatusID,
  222. StudentStatusID = stu.StudentStatus,
  223. ClassID = cl.ClassmajorID,
  224. ClassNo = cl.No,
  225. ClassName = cl.Name,
  226. GradeMajorID = gr.GrademajorID,
  227. GradeMajorCode = gr.Code,
  228. GradeMajoyStr = gr.Name,
  229. GradeStr = gr.GradeID,
  230. CollegeID = fa.CF_College.CollegeID,
  231. CollegeCode = fa.CF_College.No,
  232. CollegeStr = fa.CF_College.Name,
  233. StandardID = fa.StandardID,
  234. EducationID = fa.EducationID,
  235. LearningformID = fa.LearningformID,
  236. LearnSystem = fa.LearnSystem,
  237. ChargeYear = sc.ChargeYear,
  238. ChargeProjectID = pr.ChargeProjectID,
  239. ChargeProjectStr = pr.Name,
  240. Amount = sc.Amount,
  241. //ActualAmount = sc.Amount, //通过计算得出
  242. ChargeTag = sc.ChargeTag,
  243. Remark = sc.Remark
  244. };
  245. return query;
  246. }
  247. }
  248. }