ArrearsListServices.cs 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512
  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.ArrearsSituation;
  11. using EMIS.DataLogic.ChargeManage.ArrearsSituation;
  12. using System.Text.RegularExpressions;
  13. using EMIS.CommonLogic.ChargeManage.ChargeSituation;
  14. using EMIS.CommonLogic.StudentManage.StudentStatistics;
  15. namespace EMIS.CommonLogic.ChargeManage.ArrearsSituation
  16. {
  17. public class ArrearsListServices : BaseServices, IArrearsListServices
  18. {
  19. public ArrearsListDAL ArrearsListDAL { 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="isArrear"></param>
  33. /// <param name="isControl"></param>
  34. /// <param name="inSchoolStatus"></param>
  35. /// <param name="pageIndex"></param>
  36. /// <param name="pageSize"></param>
  37. /// <returns></returns>
  38. public IGridResultSet<ArrearsListView> GetArrearListViewGrid(ConfiguretView configuretView, Guid? collegeID, int? yearID,
  39. int? standardID, int? educationID, int? learningformID, string learnSystem, int? isArrear,
  40. int? isControl, 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 chargeDelayEndStatus = IChargeDelayServices.GetCorrectEndStatus();
  50. if (chargeDelayEndStatus == null)
  51. {
  52. throw new Exception("工作流平台中,费用缓交结束环节流程未配置,请核查");
  53. }
  54. //应收名单
  55. Expression<Func<EC_StudentCharge, bool>> expStudentCharge = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  56. //缓交信息
  57. Expression<Func<EC_ChargeDelay, bool>> expChargeDelayPass = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  58. //缓交申请(审核通过)
  59. expChargeDelayPass = expChargeDelayPass.And(x => x.RecordStatus == chargeDelayEndStatus);
  60. //学生信息
  61. Expression<Func<CF_Student, bool>> expStudent = (x => true);
  62. if (inSchoolStatus != null && inSchoolStatus > -1)
  63. {
  64. var inschoolStatusList = InSchoolSettingServices.GetInschoolStatusList(true);
  65. if (inSchoolStatus == 1)
  66. {
  67. //表示在校
  68. expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
  69. }
  70. if (inSchoolStatus == 0)
  71. {
  72. //不在校
  73. expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
  74. }
  75. }
  76. var query = ArrearsListDAL.GetArrearListView(expStudentCharge, expChargeDelayPass, expStudent);
  77. //欠费状态
  78. if (isArrear.HasValue)
  79. {
  80. if (isArrear.Value == (int)CF_GeneralPurpose.IsYes)
  81. {
  82. query = query.Where(x => x.IsArrear == (int)CF_GeneralPurpose.IsYes);
  83. }
  84. if (isArrear.Value == (int)CF_GeneralPurpose.IsNo)
  85. {
  86. query = query.Where(x => x.IsArrear == (int)CF_GeneralPurpose.IsNo);
  87. }
  88. }
  89. //登录控制
  90. if (isControl.HasValue)
  91. {
  92. if (isControl.Value == (int)CF_GeneralPurpose.IsYes)
  93. {
  94. query = query.Where(x => x.IsControl == (int)CF_GeneralPurpose.IsYes);
  95. }
  96. if (isControl.Value == (int)CF_GeneralPurpose.IsNo)
  97. {
  98. query = query.Where(x => x.IsControl == (int)CF_GeneralPurpose.IsNo);
  99. }
  100. }
  101. if (collegeID.HasValue)
  102. {
  103. query = query.Where(x => x.CollegeID == collegeID);
  104. }
  105. if (yearID.HasValue)
  106. {
  107. query = query.Where(x => x.GradeStr == yearID);
  108. }
  109. if (standardID.HasValue)
  110. {
  111. query = query.Where(x => x.StandardID == standardID);
  112. }
  113. if (educationID.HasValue)
  114. {
  115. query = query.Where(x => x.EducationID == educationID);
  116. }
  117. if (learningformID.HasValue)
  118. {
  119. query = query.Where(x => x.LearningformID == learningformID);
  120. }
  121. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  122. {
  123. var LearnSystems = Convert.ToDecimal(learnSystem);
  124. query = query.Where(x => x.LearnSystem == LearnSystems);
  125. }
  126. //查询条件
  127. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  128. {
  129. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  130. }
  131. return this.GetQueryByDataRangeByCollege(query)
  132. .OrderBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo)
  133. .ThenBy(x => x.ClassNo.Length).ThenBy(x => x.ClassNo)
  134. .ThenBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode)
  135. .ToGridResultSet<ArrearsListView>(pageIndex, pageSize);
  136. }
  137. /// <summary>
  138. /// 查询欠费名单信息View(左连对应的缴费控制信息表)
  139. /// </summary>
  140. /// <param name="configuretView"></param>
  141. /// <param name="collegeID"></param>
  142. /// <param name="yearID"></param>
  143. /// <param name="standardID"></param>
  144. /// <param name="educationID"></param>
  145. /// <param name="learningformID"></param>
  146. /// <param name="learnSystem"></param>
  147. /// <param name="isArrear"></param>
  148. /// <param name="isControl"></param>
  149. /// <param name="inSchoolStatus"></param>
  150. /// <param name="pageIndex"></param>
  151. /// <param name="pageSize"></param>
  152. /// <returns></returns>
  153. public IGridResultSet<ArrearsListView> GetArrearListViewGridForAdult(ConfiguretView configuretView, Guid? collegeID, int? yearID,
  154. int? standardID, int? educationID, int? learningformID, string learnSystem, int? isArrear,
  155. int? isControl, int? inSchoolStatus, int pageIndex, int pageSize)
  156. {
  157. //查询对应的全部流程环节信息(WorkflowStatusView)
  158. var chargeDelayWorkflowStatusView = IChargeDelayServices.GetStatusViewList();
  159. if (chargeDelayWorkflowStatusView == null || chargeDelayWorkflowStatusView.Count() <= 0)
  160. {
  161. throw new Exception("工作流平台中,费用缓交流程未配置,请核查");
  162. }
  163. //查询缓交申请工作流程结束环节状态ID(通过)
  164. var chargeDelayEndStatus = IChargeDelayServices.GetCorrectEndStatus();
  165. if (chargeDelayEndStatus == null)
  166. {
  167. throw new Exception("工作流平台中,费用缓交结束环节流程未配置,请核查");
  168. }
  169. //应收名单
  170. Expression<Func<EC_StudentCharge, bool>> expStudentCharge = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  171. //缓交信息
  172. Expression<Func<EC_ChargeDelay, bool>> expChargeDelayPass = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  173. //缓交申请(审核通过)
  174. expChargeDelayPass = expChargeDelayPass.And(x => x.RecordStatus == chargeDelayEndStatus);
  175. //学生信息
  176. Expression<Func<CF_Student, bool>> expStudent = (x => true);
  177. if (inSchoolStatus != null && inSchoolStatus > -1)
  178. {
  179. var inschoolStatusList = InSchoolSettingServices.GetInschoolStatusList(true);
  180. if (inSchoolStatus == 1)
  181. {
  182. //表示在校
  183. expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
  184. }
  185. if (inSchoolStatus == 0)
  186. {
  187. //不在校
  188. expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
  189. }
  190. }
  191. var query = ArrearsListDAL.GetArrearListView(expStudentCharge, expChargeDelayPass, expStudent);
  192. //欠费状态
  193. if (isArrear.HasValue)
  194. {
  195. if (isArrear.Value == (int)CF_GeneralPurpose.IsYes)
  196. {
  197. query = query.Where(x => x.IsArrear == (int)CF_GeneralPurpose.IsYes);
  198. }
  199. if (isArrear.Value == (int)CF_GeneralPurpose.IsNo)
  200. {
  201. query = query.Where(x => x.IsArrear == (int)CF_GeneralPurpose.IsNo);
  202. }
  203. }
  204. //登录控制
  205. if (isControl.HasValue)
  206. {
  207. if (isControl.Value == (int)CF_GeneralPurpose.IsYes)
  208. {
  209. query = query.Where(x => x.IsControl == (int)CF_GeneralPurpose.IsYes);
  210. }
  211. if (isControl.Value == (int)CF_GeneralPurpose.IsNo)
  212. {
  213. query = query.Where(x => x.IsControl == (int)CF_GeneralPurpose.IsNo);
  214. }
  215. }
  216. if (collegeID.HasValue)
  217. {
  218. query = query.Where(x => x.CollegeID == collegeID);
  219. }
  220. if (yearID.HasValue)
  221. {
  222. query = query.Where(x => x.GradeStr == yearID);
  223. }
  224. if (standardID.HasValue)
  225. {
  226. query = query.Where(x => x.StandardID == standardID);
  227. }
  228. if (educationID.HasValue)
  229. {
  230. query = query.Where(x => x.EducationID == educationID);
  231. }
  232. if (learningformID.HasValue)
  233. {
  234. query = query.Where(x => x.LearningformID == learningformID);
  235. }
  236. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  237. {
  238. var LearnSystems = Convert.ToDecimal(learnSystem);
  239. query = query.Where(x => x.LearnSystem == LearnSystems);
  240. }
  241. //查询条件
  242. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  243. {
  244. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  245. }
  246. query = query.Where(x => x.AmountSum > 0);
  247. return this.GetQueryByDataRangeByCollege(query)
  248. .OrderBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo)
  249. .ThenBy(x => x.ClassNo.Length).ThenBy(x => x.ClassNo)
  250. .ThenBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode)
  251. .ToGridResultSet<ArrearsListView>(pageIndex, pageSize);
  252. }
  253. /// <summary>
  254. /// 查询欠费名单信息List(左连对应的缴费控制信息表)
  255. /// </summary>
  256. /// <param name="configuretView"></param>
  257. /// <param name="collegeID"></param>
  258. /// <param name="yearID"></param>
  259. /// <param name="standardID"></param>
  260. /// <param name="educationID"></param>
  261. /// <param name="learningformID"></param>
  262. /// <param name="learnSystem"></param>
  263. /// <param name="isArrear"></param>
  264. /// <param name="isControl"></param>
  265. /// <param name="inSchoolStatus"></param>
  266. /// <returns></returns>
  267. public List<ArrearsListView> GetArrearsListViewList(ConfiguretView configuretView, Guid? collegeID, int? yearID,
  268. int? standardID, int? educationID, int? learningformID, string learnSystem, int? isArrear,
  269. int? isControl, int? inSchoolStatus)
  270. {
  271. //查询对应的全部流程环节信息(WorkflowStatusView)
  272. var chargeDelayWorkflowStatusView = IChargeDelayServices.GetStatusViewList();
  273. if (chargeDelayWorkflowStatusView == null || chargeDelayWorkflowStatusView.Count() <= 0)
  274. {
  275. throw new Exception("工作流平台中,费用缓交流程未配置,请核查");
  276. }
  277. //查询缓交申请工作流程结束环节状态ID(通过)
  278. var chargeDelayEndStatus = IChargeDelayServices.GetCorrectEndStatus();
  279. if (chargeDelayEndStatus == null)
  280. {
  281. throw new Exception("工作流平台中,费用缓交结束环节流程未配置,请核查");
  282. }
  283. //应收名单
  284. Expression<Func<EC_StudentCharge, bool>> expStudentCharge = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  285. //缓交信息
  286. Expression<Func<EC_ChargeDelay, bool>> expChargeDelayPass = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  287. //缓交申请(审核通过)
  288. expChargeDelayPass = expChargeDelayPass.And(x => x.RecordStatus == chargeDelayEndStatus);
  289. //学生信息
  290. Expression<Func<CF_Student, bool>> expStudent = (x => true);
  291. if (inSchoolStatus != null && inSchoolStatus > -1)
  292. {
  293. var inschoolStatusList = InSchoolSettingServices.GetInschoolStatusList(true);
  294. if (inSchoolStatus == 1)
  295. {
  296. //表示在校
  297. expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
  298. }
  299. if (inSchoolStatus == 0)
  300. {
  301. //不在校
  302. expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
  303. }
  304. }
  305. var query = ArrearsListDAL.GetArrearListView(expStudentCharge, expChargeDelayPass, expStudent);
  306. //欠费状态
  307. if (isArrear.HasValue)
  308. {
  309. if (isArrear.Value == (int)CF_GeneralPurpose.IsYes)
  310. {
  311. query = query.Where(x => x.IsArrear == (int)CF_GeneralPurpose.IsYes);
  312. }
  313. if (isArrear.Value == (int)CF_GeneralPurpose.IsNo)
  314. {
  315. query = query.Where(x => x.IsArrear == (int)CF_GeneralPurpose.IsNo);
  316. }
  317. }
  318. //登录控制
  319. if (isControl.HasValue)
  320. {
  321. if (isControl.Value == (int)CF_GeneralPurpose.IsYes)
  322. {
  323. query = query.Where(x => x.IsControl == (int)CF_GeneralPurpose.IsYes);
  324. }
  325. if (isControl.Value == (int)CF_GeneralPurpose.IsNo)
  326. {
  327. query = query.Where(x => x.IsControl == (int)CF_GeneralPurpose.IsNo);
  328. }
  329. }
  330. if (collegeID.HasValue)
  331. {
  332. query = query.Where(x => x.CollegeID == collegeID);
  333. }
  334. if (yearID.HasValue)
  335. {
  336. query = query.Where(x => x.GradeStr == yearID);
  337. }
  338. if (standardID.HasValue)
  339. {
  340. query = query.Where(x => x.StandardID == standardID);
  341. }
  342. if (educationID.HasValue)
  343. {
  344. query = query.Where(x => x.EducationID == educationID);
  345. }
  346. if (learningformID.HasValue)
  347. {
  348. query = query.Where(x => x.LearningformID == learningformID);
  349. }
  350. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  351. {
  352. var LearnSystems = Convert.ToDecimal(learnSystem);
  353. query = query.Where(x => x.LearnSystem == LearnSystems);
  354. }
  355. //查询条件
  356. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  357. {
  358. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  359. }
  360. return this.GetQueryByDataRangeByCollege(query)
  361. .OrderBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo)
  362. .ThenBy(x => x.ClassNo.Length).ThenBy(x => x.ClassNo)
  363. .ThenBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode)
  364. .ToList();
  365. }
  366. /// <summary>
  367. /// 查询对应的欠费信息ArrearsListView(根据用户信息ID)
  368. /// </summary>
  369. /// <param name="userID"></param>
  370. /// <returns></returns>
  371. public ArrearsListView GetArrearListView(Guid? userID)
  372. {
  373. try
  374. {
  375. //查询缓交申请工作流程结束环节状态ID(通过)
  376. var chargeDelayEndStatus = IChargeDelayServices.GetCorrectEndStatus();
  377. if (chargeDelayEndStatus == null)
  378. {
  379. throw new Exception("工作流平台中,费用缓交结束环节流程未配置,请核查");
  380. }
  381. //应收名单
  382. Expression<Func<EC_StudentCharge, bool>> expStudentCharge = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  383. //userID
  384. expStudentCharge = expStudentCharge.And(x => x.UserID == userID);
  385. //缓交信息
  386. Expression<Func<EC_ChargeDelay, bool>> expChargeDelayPass = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  387. //缓交申请(审核通过)
  388. expChargeDelayPass = expChargeDelayPass.And(x => x.RecordStatus == chargeDelayEndStatus);
  389. var arrearsListView = ArrearsListDAL.GetArrearListViewAble(expStudentCharge, expChargeDelayPass)
  390. .SingleOrDefault();
  391. return arrearsListView;
  392. }
  393. catch (Exception ex)
  394. {
  395. throw new Exception(ex.Message);
  396. }
  397. }
  398. /// <summary>
  399. /// 放行(个性化控制登录)
  400. /// </summary>
  401. /// <param name="userIDList"></param>
  402. public void Pass(List<Guid?> userIDList)
  403. {
  404. try
  405. {
  406. //控制放行信息
  407. Expression<Func<EC_PassStudent, bool>> exp = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  408. exp = exp.And(x => userIDList.Contains(x.UserID));
  409. //查询控制放行信息
  410. var passStudentViewList = ArrearsListDAL.GetPassStudentView(exp);
  411. List<EC_PassStudent> passStudentInList = new List<EC_PassStudent>();
  412. foreach (var userID in userIDList)
  413. {
  414. //查询对应的控制放行信息
  415. var passStudentView = passStudentViewList.Where(x=>x.UserID == userID).SingleOrDefault();
  416. if (passStudentView == null)
  417. {
  418. EC_PassStudent passStudent = new EC_PassStudent();
  419. passStudent.PassStudentID = Guid.NewGuid();
  420. passStudent.UserID = userID;
  421. passStudent.Remark = "放行(个性化允许登录,不受欠费控制)";
  422. SetNewStatus(passStudent, (int)SYS_STATUS.USABLE);
  423. passStudentInList.Add(passStudent);
  424. }
  425. else
  426. {
  427. throw new Exception("数据有误,请核查");
  428. }
  429. }
  430. //批量插入
  431. UnitOfWork.BulkInsert(passStudentInList);
  432. UnitOfWork.Commit();
  433. }
  434. catch (Exception ex)
  435. {
  436. throw new Exception(ex.Message);
  437. }
  438. }
  439. /// <summary>
  440. /// 控制(个性化控制登录)
  441. /// </summary>
  442. /// <param name="userIDList"></param>
  443. public void Control(List<Guid?> userIDList)
  444. {
  445. try
  446. {
  447. UnitOfWork.Delete<EC_PassStudent>(x => userIDList.Contains(x.UserID));
  448. UnitOfWork.Commit();
  449. }
  450. catch (Exception ex)
  451. {
  452. throw new Exception(ex.Message);
  453. }
  454. }
  455. }
  456. }