ChargeTotalServices.cs 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379
  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 Bowin.Common.Linq;
  8. using EMIS.ViewModel;
  9. using Bowin.Common.Linq.Entity;
  10. using EMIS.ViewModel.ChargeManage.ChargeTotal;
  11. using EMIS.DataLogic.ChargeManage.ChargeTotal;
  12. using System.Text.RegularExpressions;
  13. using EMIS.CommonLogic.ChargeManage.ChargeSituation;
  14. using EMIS.CommonLogic.StudentManage.StudentStatistics;
  15. namespace EMIS.CommonLogic.ChargeManage.ChargeTotal
  16. {
  17. public class ChargeTotalServices : BaseServices, IChargeTotalServices
  18. {
  19. public ChargeTotalDAL ChargeTotalDAL { get; set; }
  20. public IInSchoolSettingServices InSchoolSettingServices { get; set; }
  21. public IChargeDelayServices IChargeDelayServices { get; set; }
  22. /// <summary>
  23. /// 查询费用统计信息View(以班级信息分组统计)
  24. /// </summary>
  25. /// <param name="configuretView"></param>
  26. /// <param name="collegeID"></param>
  27. /// <param name="yearID"></param>
  28. /// <param name="standardID"></param>
  29. /// <param name="educationID"></param>
  30. /// <param name="learningformID"></param>
  31. /// <param name="learnSystem"></param>
  32. /// <param name="chargeYearID"></param>
  33. /// <param name="chargeProjectID"></param>
  34. /// <param name="inSchoolStatus"></param>
  35. /// <param name="pageIndex"></param>
  36. /// <param name="pageSize"></param>
  37. /// <returns></returns>
  38. public IGridResultSet<ChargeTotalView> GetChargeTotadViewGrid(ConfiguretView configuretView, Guid? collegeID,
  39. int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem,
  40. int? chargeYearID, Guid? chargeProjectID, int? inSchoolStatus, int pageIndex, int pageSize)
  41. {
  42. //查询对应的全部流程环节信息(WorkflowStatusView)
  43. var chargeDelayWorkflowStatusView = IChargeDelayServices.GetStatusViewList();
  44. if (chargeDelayWorkflowStatusView == null || chargeDelayWorkflowStatusView.Count() <= 0)
  45. {
  46. throw new Exception("工作流平台中,费用缓交流程未配置,请核查");
  47. }
  48. //查询缓交申请工作流程结束环节状态ID(通过)
  49. var chargeDelayEndtStatus = IChargeDelayServices.GetCorrectEndStatus();
  50. if (chargeDelayEndtStatus == null)
  51. {
  52. throw new Exception("工作流平台中,费用缓交结束环节流程未配置,请核查");
  53. }
  54. //应收名单
  55. Expression<Func<EC_StudentCharge, bool>> expStudentCharge = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  56. if (chargeYearID.HasValue)
  57. {
  58. expStudentCharge = expStudentCharge.And(x => x.ChargeYear == chargeYearID);
  59. }
  60. if (chargeProjectID.HasValue)
  61. {
  62. expStudentCharge = expStudentCharge.And(x => x.ChargeProjectID == chargeProjectID);
  63. }
  64. //缓交信息
  65. Expression<Func<EC_ChargeDelay, bool>> expChargeDelayPass = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  66. //缓交申请(审核通过)
  67. expChargeDelayPass = expChargeDelayPass.And(x => x.RecordStatus == chargeDelayEndtStatus);
  68. //学生信息
  69. Expression<Func<CF_Student, bool>> expStudent = (x => true);
  70. if (inSchoolStatus != null && inSchoolStatus > -1)
  71. {
  72. var inschoolStatusList = InSchoolSettingServices.GetInschoolStatusList(true);
  73. if (inSchoolStatus == 1)
  74. {
  75. //表示在校
  76. expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
  77. }
  78. if (inSchoolStatus == 0)
  79. {
  80. //不在校
  81. expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
  82. }
  83. }
  84. var query = ChargeTotalDAL.GetChargeTotalView(expStudentCharge, expChargeDelayPass, expStudent);
  85. if (collegeID.HasValue)
  86. {
  87. query = query.Where(x => x.CollegeID == collegeID);
  88. }
  89. if (yearID.HasValue)
  90. {
  91. query = query.Where(x => x.Grade == yearID);
  92. }
  93. if (standardID.HasValue)
  94. {
  95. query = query.Where(x => x.StandardID == standardID);
  96. }
  97. if (educationID.HasValue)
  98. {
  99. query = query.Where(x => x.EducationID == educationID);
  100. }
  101. if (learningformID.HasValue)
  102. {
  103. query = query.Where(x => x.LearningformID == learningformID);
  104. }
  105. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  106. {
  107. var LearnSystems = Convert.ToDecimal(learnSystem);
  108. query = query.Where(x => x.LearnSystem == LearnSystems);
  109. }
  110. //查询条件
  111. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  112. {
  113. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  114. }
  115. return this.GetQueryByDataRangeByCollege(query)
  116. .OrderBy(x => x.ClassNo.Length).ThenBy(x => x.ClassNo)
  117. .ThenByDescending(x => x.Grade).ThenBy(x => x.ChargeProjectStr)
  118. .ThenBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode)
  119. .ToGridResultSet<ChargeTotalView>(pageIndex, pageSize);
  120. }
  121. /// <summary>
  122. /// 查询费用统计信息List(以班级信息、缴费学年、收费项目分组统计)
  123. /// </summary>
  124. /// <param name="configuretView"></param>
  125. /// <param name="collegeID"></param>
  126. /// <param name="yearID"></param>
  127. /// <param name="standardID"></param>
  128. /// <param name="educationID"></param>
  129. /// <param name="learningformID"></param>
  130. /// <param name="learnSystem"></param>
  131. /// <param name="chargeYearID"></param>
  132. /// <param name="chargeProjectID"></param>
  133. /// <param name="inSchoolStatus"></param>
  134. /// <returns></returns>
  135. public List<ChargeTotalView> GetChargeTotalViewList(ConfiguretView configuretView, Guid? collegeID,
  136. int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem,
  137. int? chargeYearID, Guid? chargeProjectID, int? inSchoolStatus)
  138. {
  139. //查询对应的全部流程环节信息(WorkflowStatusView)
  140. var chargeDelayWorkflowStatusView = IChargeDelayServices.GetStatusViewList();
  141. if (chargeDelayWorkflowStatusView == null || chargeDelayWorkflowStatusView.Count() <= 0)
  142. {
  143. throw new Exception("工作流平台中,费用缓交流程未配置,请核查");
  144. }
  145. //查询缓交申请工作流程结束环节状态ID(通过)
  146. var chargeDelayEndtStatus = IChargeDelayServices.GetCorrectEndStatus();
  147. if (chargeDelayEndtStatus == null)
  148. {
  149. throw new Exception("工作流平台中,费用缓交结束环节流程未配置,请核查");
  150. }
  151. //应收名单
  152. Expression<Func<EC_StudentCharge, bool>> expStudentCharge = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  153. if (chargeYearID.HasValue)
  154. {
  155. expStudentCharge = expStudentCharge.And(x => x.ChargeYear == chargeYearID);
  156. }
  157. if (chargeProjectID.HasValue)
  158. {
  159. expStudentCharge = expStudentCharge.And(x => x.ChargeProjectID == chargeProjectID);
  160. }
  161. //缓交信息
  162. Expression<Func<EC_ChargeDelay, bool>> expChargeDelayPass = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  163. //缓交申请(审核通过)
  164. expChargeDelayPass = expChargeDelayPass.And(x => x.RecordStatus == chargeDelayEndtStatus);
  165. //学生信息
  166. Expression<Func<CF_Student, bool>> expStudent = (x => true);
  167. if (inSchoolStatus != null && inSchoolStatus > -1)
  168. {
  169. var inschoolStatusList = InSchoolSettingServices.GetInschoolStatusList(true);
  170. if (inSchoolStatus == 1)
  171. {
  172. //表示在校
  173. expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
  174. }
  175. if (inSchoolStatus == 0)
  176. {
  177. //不在校
  178. expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
  179. }
  180. }
  181. var query = ChargeTotalDAL.GetChargeTotalView(expStudentCharge, expChargeDelayPass, expStudent);
  182. if (collegeID.HasValue)
  183. {
  184. query = query.Where(x => x.CollegeID == collegeID);
  185. }
  186. if (yearID.HasValue)
  187. {
  188. query = query.Where(x => x.Grade == yearID);
  189. }
  190. if (standardID.HasValue)
  191. {
  192. query = query.Where(x => x.StandardID == standardID);
  193. }
  194. if (educationID.HasValue)
  195. {
  196. query = query.Where(x => x.EducationID == educationID);
  197. }
  198. if (learningformID.HasValue)
  199. {
  200. query = query.Where(x => x.LearningformID == learningformID);
  201. }
  202. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  203. {
  204. var LearnSystems = Convert.ToDecimal(learnSystem);
  205. query = query.Where(x => x.LearnSystem == LearnSystems);
  206. }
  207. //查询条件
  208. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  209. {
  210. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  211. }
  212. return this.GetQueryByDataRangeByCollege(query)
  213. .OrderBy(x => x.ClassNo.Length).ThenBy(x => x.ClassNo)
  214. .ThenByDescending(x => x.Grade).ThenBy(x => x.ChargeProjectStr)
  215. .ThenBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode)
  216. .ToList();
  217. }
  218. /// <summary>
  219. /// 统计相应的费用信息(应收总额、实收总额等)
  220. /// </summary>
  221. /// <param name="configuretView"></param>
  222. /// <param name="collegeID"></param>
  223. /// <param name="yearID"></param>
  224. /// <param name="standardID"></param>
  225. /// <param name="educationID"></param>
  226. /// <param name="learningformID"></param>
  227. /// <param name="learnSystem"></param>
  228. /// <param name="chargeYearID"></param>
  229. /// <param name="chargeProjectID"></param>
  230. /// <param name="inSchoolStatus"></param>
  231. /// <param name="pageIndex"></param>
  232. /// <param name="pageSize"></param>
  233. /// <returns></returns>
  234. public ChargeTotalSumView GetTotalView(ConfiguretView configuretView, Guid? collegeID,
  235. int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem,
  236. int? chargeYearID, Guid? chargeProjectID, int? inSchoolStatus, int pageIndex, int pageSize)
  237. {
  238. //查询对应的全部流程环节信息(WorkflowStatusView)
  239. var chargeDelayWorkflowStatusView = IChargeDelayServices.GetStatusViewList();
  240. if (chargeDelayWorkflowStatusView == null || chargeDelayWorkflowStatusView.Count() <= 0)
  241. {
  242. throw new Exception("工作流平台中,费用缓交流程未配置,请核查");
  243. }
  244. //查询缓交申请工作流程结束环节状态ID(通过)
  245. var chargeDelayEndtStatus = IChargeDelayServices.GetCorrectEndStatus();
  246. if (chargeDelayEndtStatus == null)
  247. {
  248. throw new Exception("工作流平台中,费用缓交结束环节流程未配置,请核查");
  249. }
  250. //应收名单
  251. Expression<Func<EC_StudentCharge, bool>> expStudentCharge = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  252. if (chargeYearID.HasValue)
  253. {
  254. expStudentCharge = expStudentCharge.And(x => x.ChargeYear == chargeYearID);
  255. }
  256. if (chargeProjectID.HasValue)
  257. {
  258. expStudentCharge = expStudentCharge.And(x => x.ChargeProjectID == chargeProjectID);
  259. }
  260. //缓交信息
  261. Expression<Func<EC_ChargeDelay, bool>> expChargeDelayPass = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  262. //缓交申请(审核通过)
  263. expChargeDelayPass = expChargeDelayPass.And(x => x.RecordStatus == chargeDelayEndtStatus);
  264. //学生信息
  265. Expression<Func<CF_Student, bool>> expStudent = (x => true);
  266. if (inSchoolStatus != null && inSchoolStatus > -1)
  267. {
  268. var inschoolStatusList = InSchoolSettingServices.GetInschoolStatusList(true);
  269. if (inSchoolStatus == 1)
  270. {
  271. //表示在校
  272. expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
  273. }
  274. if (inSchoolStatus == 0)
  275. {
  276. //不在校
  277. expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
  278. }
  279. }
  280. var query = ChargeTotalDAL.GetChargeTotalView(expStudentCharge, expChargeDelayPass, expStudent);
  281. if (collegeID.HasValue)
  282. {
  283. query = query.Where(x => x.CollegeID == collegeID);
  284. }
  285. if (yearID.HasValue)
  286. {
  287. query = query.Where(x => x.Grade == yearID);
  288. }
  289. if (standardID.HasValue)
  290. {
  291. query = query.Where(x => x.StandardID == standardID);
  292. }
  293. if (educationID.HasValue)
  294. {
  295. query = query.Where(x => x.EducationID == educationID);
  296. }
  297. if (learningformID.HasValue)
  298. {
  299. query = query.Where(x => x.LearningformID == learningformID);
  300. }
  301. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  302. {
  303. var LearnSystems = Convert.ToDecimal(learnSystem);
  304. query = query.Where(x => x.LearnSystem == LearnSystems);
  305. }
  306. //查询条件
  307. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  308. {
  309. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  310. }
  311. var chargeTotalViewList = this.GetQueryByDataRangeByCollege(query).ToList<ChargeTotalView>();
  312. int? chargeCountSum = 0;
  313. decimal? amountSum = 0;
  314. decimal? chargeAmountSum = 0;
  315. decimal? actualAmountSum = 0;
  316. int? delayCountSum = 0;
  317. decimal? delayAmountSum = 0;
  318. int? paymenCountSum = 0;
  319. decimal? paymenAmountSum = 0;
  320. foreach (var chargeTotalView in chargeTotalViewList)
  321. {
  322. chargeCountSum += chargeTotalView.ChargeCount;
  323. amountSum += chargeTotalView.Amount;
  324. chargeAmountSum += chargeTotalView.ChargeAmount;
  325. actualAmountSum += chargeTotalView.ActualAmount;
  326. delayCountSum += chargeTotalView.DelayCount;
  327. delayAmountSum += chargeTotalView.DelayAmount;
  328. paymenCountSum += chargeTotalView.PaymenCount;
  329. paymenAmountSum += chargeTotalView.PaymenAmount;
  330. }
  331. var chargeTotalSumView = new ChargeTotalSumView();
  332. chargeTotalSumView.ChargeCountSum = chargeCountSum;
  333. chargeTotalSumView.AmountSum = amountSum;
  334. chargeTotalSumView.ChargeAmountSum = chargeAmountSum;
  335. chargeTotalSumView.ActualAmountSum = actualAmountSum;
  336. chargeTotalSumView.DelayCountSum = delayCountSum;
  337. chargeTotalSumView.DelayAmountSum = delayAmountSum;
  338. chargeTotalSumView.PaymenCountSum = paymenCountSum;
  339. chargeTotalSumView.PaymenAmountSum = paymenAmountSum;
  340. return chargeTotalSumView;
  341. }
  342. }
  343. }