ChargeDelayServices.cs 31 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.ChargeManage.ChargeSituation;
  6. using EMIS.ViewModel.ChargeManage.ChargeSituation;
  7. using System.Linq.Expressions;
  8. using EMIS.Entities;
  9. using Bowin.Common.Linq.Entity;
  10. using Bowin.Common.Linq;
  11. using EMIS.CommonLogic.SystemServices;
  12. using EMIS.ViewModel;
  13. using EMIS.ViewModel.WorkflowManage;
  14. using EMIS.CommonLogic.StudentManage.StudentStatistics;
  15. namespace EMIS.CommonLogic.ChargeManage.ChargeSituation
  16. {
  17. public class ChargeDelayServices : BaseWorkflowServices<EC_ChargeDelay>, IChargeDelayServices
  18. {
  19. public ChargeDelayDAL chargeDelayDAL { get; set; }
  20. public StudentChargeDAL studentChargeDAL { get; set; }
  21. public IInSchoolSettingServices InSchoolSettingServices { 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="chargeDelayStatus"></param>
  36. /// <param name="pageIndex"></param>
  37. /// <param name="pageSize"></param>
  38. /// <returns></returns>
  39. public IGridResultSet<ChargeDelayView> GetChargeDelayList(ConfiguretView configuretView, Guid? collegeID, int? yearID, int? standardID, int? educationID,
  40. int? learningformID, string learnSystem, int? chargeYearID, Guid? chargeProjectID, int? inSchoolStatus, int? chargeDelayStatus, int pageIndex, int pageSize)
  41. {
  42. var approveStatusList = this.GetStatusViewList();
  43. Expression<Func<EC_ChargeDelay, bool>> expChargeDelay = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  44. if (chargeDelayStatus.HasValue)
  45. {
  46. expChargeDelay = expChargeDelay.And(x => x.RecordStatus == chargeDelayStatus);
  47. }
  48. Expression<Func<EC_StudentCharge, bool>> expStudentCharge = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  49. if (chargeYearID.HasValue)
  50. {
  51. expStudentCharge = expStudentCharge.And(x => x.ChargeYear == chargeYearID);
  52. }
  53. if (chargeProjectID.HasValue)
  54. {
  55. expStudentCharge = expStudentCharge.And(x => x.ChargeProjectID == chargeProjectID);
  56. }
  57. Expression<Func<CF_Student, bool>> expStudent = (x => true);
  58. if (inSchoolStatus != null && inSchoolStatus > -1)
  59. {
  60. var inschoolStatusList = InSchoolSettingServices.GetInschoolStatusList(true);
  61. if (inSchoolStatus == 1)
  62. {
  63. expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
  64. }
  65. if (inSchoolStatus == 0)
  66. {
  67. expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
  68. }
  69. }
  70. var query = chargeDelayDAL.GetChargeDelayQueryAble(expChargeDelay, expStudentCharge, expStudent);
  71. if (collegeID.HasValue)
  72. {
  73. query = query.Where(x => x.CollegeID == collegeID);
  74. }
  75. if (yearID.HasValue)
  76. {
  77. query = query.Where(x => x.GradeStr == yearID);
  78. }
  79. if (standardID.HasValue)
  80. {
  81. query = query.Where(x => x.StandardID == standardID);
  82. }
  83. if (educationID.HasValue)
  84. {
  85. query = query.Where(x => x.EducationID == educationID);
  86. }
  87. if (learningformID.HasValue)
  88. {
  89. query = query.Where(x => x.LearningformID == learningformID);
  90. }
  91. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  92. {
  93. var LearnSystems = Convert.ToDecimal(learnSystem);
  94. query = query.Where(x => x.LearnSystem == LearnSystems);
  95. }
  96. //查询条件
  97. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  98. {
  99. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  100. }
  101. var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo).ThenBy(x => x.ChargeProjectStr)
  102. .ThenByDescending(x => x.ChargeYear).ThenBy(x => x.RecordStatus).ThenBy(x => x.CreateTime).ToGridResultSet<ChargeDelayView>(pageIndex, pageSize);
  103. result.rows.ForEach(x => x.RecordStatusName = approveStatusList.FirstOrDefault(w => w.ID == x.RecordStatus).Name);
  104. return result;
  105. }
  106. /// <summary>
  107. /// 查询缓交名单信息List
  108. /// </summary>
  109. /// <param name="configuretView"></param>
  110. /// <param name="collegeID"></param>
  111. /// <param name="yearID"></param>
  112. /// <param name="standardID"></param>
  113. /// <param name="educationID"></param>
  114. /// <param name="learningformID"></param>
  115. /// <param name="learnSystem"></param>
  116. /// <param name="chargeYearID"></param>
  117. /// <param name="chargeProjectID"></param>
  118. /// <param name="inSchoolStatus"></param>
  119. /// <param name="chargeDelayStatus"></param>
  120. /// <returns></returns>
  121. public List<ChargeDelayView> GetChargeDelayList(ConfiguretView configuretView, Guid? collegeID,
  122. int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem,
  123. int? chargeYearID, Guid? chargeProjectID, int? inSchoolStatus, int? chargeDelayStatus)
  124. {
  125. //查询对应的工作流程环节状态信息View
  126. var approveStatusList = this.GetStatusViewList();
  127. //缓交名单
  128. Expression<Func<EC_ChargeDelay, bool>> expChargeDelay = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  129. if (chargeDelayStatus.HasValue)
  130. {
  131. //审批状态
  132. expChargeDelay = expChargeDelay.And(x => x.RecordStatus == chargeDelayStatus);
  133. }
  134. //应收名单
  135. Expression<Func<EC_StudentCharge, bool>> expStudentCharge = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  136. if (chargeYearID.HasValue)
  137. {
  138. //缴费学年
  139. expStudentCharge = expStudentCharge.And(x => x.ChargeYear == chargeYearID);
  140. }
  141. if (chargeProjectID.HasValue)
  142. {
  143. //收费项目
  144. expStudentCharge = expStudentCharge.And(x => x.ChargeProjectID == chargeProjectID);
  145. }
  146. //学生信息
  147. Expression<Func<CF_Student, bool>> expStudent = (x => true);
  148. if (inSchoolStatus != null && inSchoolStatus > -1)
  149. {
  150. //在校状态
  151. var inschoolStatusList = InSchoolSettingServices.GetInschoolStatusList(true);
  152. if (inSchoolStatus == 1)
  153. {
  154. //表示在校
  155. expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
  156. }
  157. if (inSchoolStatus == 0)
  158. {
  159. //不在校
  160. expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
  161. }
  162. }
  163. var query = chargeDelayDAL.GetChargeDelayQueryAble(expChargeDelay, expStudentCharge, expStudent);
  164. if (collegeID.HasValue)
  165. {
  166. query = query.Where(x => x.CollegeID == collegeID);
  167. }
  168. if (yearID.HasValue)
  169. {
  170. query = query.Where(x => x.GradeStr == yearID);
  171. }
  172. if (standardID.HasValue)
  173. {
  174. query = query.Where(x => x.StandardID == standardID);
  175. }
  176. if (educationID.HasValue)
  177. {
  178. query = query.Where(x => x.EducationID == educationID);
  179. }
  180. if (learningformID.HasValue)
  181. {
  182. query = query.Where(x => x.LearningformID == learningformID);
  183. }
  184. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  185. {
  186. var LearnSystems = Convert.ToDecimal(learnSystem);
  187. query = query.Where(x => x.LearnSystem == LearnSystems);
  188. }
  189. //查询条件
  190. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  191. {
  192. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  193. }
  194. var result = this.GetQueryByDataRangeByCollege(query).OrderBy(x => x.StudentNo.Length)
  195. .ThenBy(x => x.StudentNo).ThenBy(x => x.ChargeProjectStr)
  196. .ThenByDescending(x => x.ChargeYear).ThenBy(x => x.RecordStatus)
  197. .ThenBy(x => x.CreateTime)
  198. .ToList();
  199. result.ForEach(x => x.RecordStatusName = approveStatusList.FirstOrDefault(w => w.ID == x.RecordStatus).Name);
  200. return result;
  201. }
  202. /// <summary>
  203. /// 查询应收名单中对应的缴交信息View(对应的缴交信息全部查询,左联-待缓交金额、已缓交金额)
  204. /// </summary>
  205. /// <param name="userID"></param>
  206. /// <param name="chargeYearID"></param>
  207. /// <param name="chargeProjectID"></param>
  208. /// <returns></returns>
  209. public ChargeDelayView GetChargeDelayStandardView(Guid? userID, int? chargeYearID, Guid? chargeProjectID)
  210. {
  211. try
  212. {
  213. //查询对应的应收名单信息
  214. var studentCharge = chargeDelayDAL.StudentChargeRepository
  215. .GetList(x => x.UserID == userID
  216. && x.ChargeYear == chargeYearID
  217. && x.ChargeProjectID == chargeProjectID).SingleOrDefault();
  218. if (studentCharge == null)
  219. {
  220. throw new Exception("对应的应收名单不存在,请核查");
  221. }
  222. //应收名单
  223. Expression<Func<EC_StudentCharge, bool>> expStudentCharge = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  224. expStudentCharge = expStudentCharge.And(x => x.StudentChargeID == studentCharge.StudentChargeID);
  225. //查询对应的全部流程环节信息(WorkflowStatusView)
  226. var chargeDelayWorkflowStatusView = this.GetStatusViewList();
  227. if (chargeDelayWorkflowStatusView == null || chargeDelayWorkflowStatusView.Count() <= 0)
  228. {
  229. throw new Exception("工作流平台中,费用缓交流程未配置,请核查");
  230. }
  231. //查询缓交申请工作流程开始环节状态
  232. var chargeDelayStartStatus = this.GetStartStatus();
  233. if (chargeDelayStartStatus == null)
  234. {
  235. throw new Exception("工作流平台中,费用缓交开始环节流程未配置,请核查");
  236. }
  237. //缓交申请流程中的ID(包含未提交、待审核)
  238. var applyStatusList = this.GetStartApproveStatusList();
  239. //缓交申请(流程中)
  240. Expression<Func<EC_ChargeDelay, bool>> expChargeDelayApply = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  241. expChargeDelayApply = expChargeDelayApply.And(x => x.StudentChargeID == studentCharge.StudentChargeID);
  242. expChargeDelayApply = expChargeDelayApply.And(x => applyStatusList.Contains(x.RecordStatus));
  243. //查询缓交申请工作流程结束环节状态
  244. var chargeDelayEndtStatus = this.GetCorrectEndStatus();
  245. if (chargeDelayEndtStatus == null)
  246. {
  247. throw new Exception("工作流平台中,费用缓交结束环节流程未配置,请核查");
  248. }
  249. //缓交申请(审核通过)
  250. Expression<Func<EC_ChargeDelay, bool>> expChargeDelayPass = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  251. expChargeDelayPass = expChargeDelayPass.And(x => x.StudentChargeID == studentCharge.StudentChargeID);
  252. expChargeDelayPass = expChargeDelayPass.And(x => x.RecordStatus == chargeDelayEndtStatus);
  253. //查询对应的缴交信息View(对应的缴交信息全部查询,左联-待缓交金额、已缓交金额)
  254. var chargeDelayView = studentChargeDAL.GetStudentChargeChargeDelayView(expStudentCharge, expChargeDelayApply, expChargeDelayPass)
  255. .SingleOrDefault();
  256. return chargeDelayView;
  257. }
  258. catch (Exception ex)
  259. {
  260. throw new Exception(ex.Message);
  261. }
  262. }
  263. /// <summary>
  264. /// 查询对应的缓交名单信息View(根据缓交信息)
  265. /// </summary>
  266. /// <param name="chargeDelayID"></param>
  267. /// <returns></returns>
  268. public ChargeDelayView GetChargeDelayView(Guid? chargeDelayID)
  269. {
  270. var query = chargeDelayDAL.GetChargeDelayQueryAble(x => x.ChargeDelayID == chargeDelayID).SingleOrDefault();
  271. return query;
  272. }
  273. /// <summary>
  274. /// 查询对应的缓交名单信息View(对应的应收名单信息全部查询,左联-待缓交金额、已缓交金额)
  275. /// </summary>
  276. /// <param name="chargeDelayID"></param>
  277. /// <returns></returns>
  278. public ChargeDelayView GetChargeDelayEditView(Guid? chargeDelayID)
  279. {
  280. try
  281. {
  282. //查询对应的缓交名单信息
  283. var chargeDelay = chargeDelayDAL.ChargeDelayRepository
  284. .GetList(x => x.ChargeDelayID == chargeDelayID).SingleOrDefault();
  285. if (chargeDelay == null)
  286. {
  287. throw new Exception("对应的缓交名单信息不存在,请核查");
  288. }
  289. //缓交名单
  290. Expression<Func<EC_ChargeDelay, bool>> expChargeDelay = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  291. expChargeDelay = expChargeDelay.And(x => x.ChargeDelayID == chargeDelayID);
  292. //查询对应的全部流程环节信息(WorkflowStatusView)
  293. var chargeDelayWorkflowStatusView = this.GetStatusViewList();
  294. if (chargeDelayWorkflowStatusView == null || chargeDelayWorkflowStatusView.Count() <= 0)
  295. {
  296. throw new Exception("工作流平台中,费用缓交流程未配置,请核查");
  297. }
  298. //查询缓交申请工作流程开始环节状态
  299. var chargeDelayStartStatus = this.GetStartStatus();
  300. if (chargeDelayStartStatus == null)
  301. {
  302. throw new Exception("工作流平台中,费用缓交开始环节流程未配置,请核查");
  303. }
  304. //缓交申请流程中的ID(未提交、待审核)
  305. var applyStatusList = this.GetStartApproveStatusList();
  306. //缓交申请(流程中)
  307. Expression<Func<EC_ChargeDelay, bool>> expChargeDelayApply = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  308. expChargeDelayApply = expChargeDelayApply.And(x => x.StudentChargeID == chargeDelay.StudentChargeID);
  309. expChargeDelayApply = expChargeDelayApply.And(x => applyStatusList.Contains(x.RecordStatus));
  310. //查询缓交申请工作流程结束环节状态
  311. var chargeDelayEndtStatus = this.GetCorrectEndStatus();
  312. if (chargeDelayEndtStatus == null)
  313. {
  314. throw new Exception("工作流平台中,费用缓交结束环节流程未配置,请核查");
  315. }
  316. //缓交申请(审核通过)
  317. Expression<Func<EC_ChargeDelay, bool>> expChargeDelayPass = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  318. expChargeDelayPass = expChargeDelayPass.And(x => x.StudentChargeID == chargeDelay.StudentChargeID);
  319. expChargeDelayPass = expChargeDelayPass.And(x => x.RecordStatus == chargeDelayEndtStatus);
  320. //查询对应的缴交信息View(对应的应收名单信息全部查询,左联-待缓交金额、已缓交金额)
  321. var chargeDelayView = chargeDelayDAL.GetChargeDelayQueryView(expChargeDelay, expChargeDelayApply, expChargeDelayPass)
  322. .SingleOrDefault();
  323. return chargeDelayView;
  324. }
  325. catch (Exception ex)
  326. {
  327. throw new Exception(ex.Message);
  328. }
  329. }
  330. /// <summary>
  331. /// 编辑(申请、修改)
  332. /// 同时对相应的缓交信息进行验证(缓交金额需在可缓交金额范围内)
  333. /// </summary>
  334. /// <param name="chargeDelayView"></param>
  335. public void ChaegeDelayEdit(ChargeDelayView chargeDelayView)
  336. {
  337. try
  338. {
  339. //注:可通过缓交申请表单来获取相关缓交信息(目前暂时不采用此种方式)
  340. //查询缓交申请工作流程开始环节状态
  341. var chargeDelayStartStatus = this.GetStartStatus();
  342. if (chargeDelayStartStatus == null)
  343. {
  344. throw new Exception("工作流平台中,费用缓交开始环节流程未配置,请核查");
  345. }
  346. if (chargeDelayView.ChargeDelayID == null || chargeDelayView.ChargeDelayID == Guid.Empty)
  347. {
  348. //申请
  349. var chargeDelayStandardView = this.GetChargeDelayStandardView(chargeDelayView.UserID,
  350. chargeDelayView.ChargeYear, chargeDelayView.ChargeProjectID);
  351. if (chargeDelayStandardView == null)
  352. {
  353. throw new Exception("数据有误,请核查");
  354. }
  355. //缓交金额需在可缓交金额范围内
  356. if (chargeDelayStandardView.DelayAmount > chargeDelayStandardView.CanDelayAmount)
  357. {
  358. throw new Exception("缓交金额不能大于可缓交金额,请核查");
  359. }
  360. else
  361. {
  362. EC_ChargeDelay newChargeDelay = new EC_ChargeDelay();
  363. newChargeDelay.ChargeDelayID = Guid.NewGuid();
  364. newChargeDelay.StudentChargeID = chargeDelayStandardView.StudentChargeID;
  365. newChargeDelay.DelayAmount = chargeDelayView.DelayAmount;
  366. newChargeDelay.DelayPercent = chargeDelayView.DelayPercent;
  367. newChargeDelay.Reason = chargeDelayView.Reason;
  368. SetNewStatus(newChargeDelay, chargeDelayStartStatus.Value);
  369. UnitOfWork.Add(newChargeDelay);
  370. }
  371. }
  372. else
  373. {
  374. //修改(只能对未开始流程的信息进行修改-未提交)
  375. if (chargeDelayView.RecordStatus != chargeDelayStartStatus)
  376. {
  377. throw new Exception("只能对未提交状态的信息进行修改");
  378. }
  379. //缓交金额需在可缓交金额范围内
  380. if (chargeDelayView.DelayAmount > chargeDelayView.CanDelayAmount)
  381. {
  382. throw new Exception("缓交金额不能大于可缓交金额,请核查");
  383. }
  384. else
  385. {
  386. //查询对应的缓交信息
  387. var chargeDelay = chargeDelayDAL.ChargeDelayRepository
  388. .GetList(x => x.ChargeDelayID == chargeDelayView.ChargeDelayID).SingleOrDefault();
  389. chargeDelay.DelayAmount = chargeDelayView.DelayAmount;
  390. chargeDelay.DelayPercent = chargeDelayView.DelayPercent;
  391. chargeDelay.Reason = chargeDelayView.Reason;
  392. SetModifyStatus(chargeDelay);
  393. }
  394. }
  395. UnitOfWork.Commit();
  396. }
  397. catch (Exception ex)
  398. {
  399. throw new Exception(ex.Message);
  400. }
  401. }
  402. /// <summary>
  403. /// 删除
  404. /// </summary>
  405. /// <param name="chargeDelayIDs"></param>
  406. /// <returns></returns>
  407. public bool ChargeDelayDelete(List<Guid> chargeDelayIDs)
  408. {
  409. try
  410. {
  411. //查询缓交申请工作流程开始环节状态
  412. var chargeDelayStartStatus = this.GetStartStatus();
  413. if (chargeDelayStartStatus == null)
  414. {
  415. throw new Exception("工作流平台中,费用缓交开始环节流程未配置,请核查");
  416. }
  417. //查询对应的缓交信息流程状态ID
  418. var recordStatusList = chargeDelayDAL.ChargeDelayRepository.GetList(x => chargeDelayIDs.Contains(x.ChargeDelayID))
  419. .Select(x => x.RecordStatus).ToList();
  420. foreach (var recordStatus in recordStatusList)
  421. {
  422. if (recordStatus != chargeDelayStartStatus)
  423. {
  424. throw new Exception("只能对未提交状态的信息进行删除");
  425. }
  426. }
  427. UnitOfWork.Delete<EC_ChargeDelay>(x => chargeDelayIDs.Contains(x.ChargeDelayID));
  428. UnitOfWork.Commit();
  429. return true;
  430. }
  431. catch (Exception ex)
  432. {
  433. throw new Exception(ex.Message);
  434. }
  435. }
  436. /// <summary>
  437. /// 提交
  438. /// </summary>
  439. /// <param name="chargeDelayIDs"></param>
  440. /// <param name="userID"></param>
  441. /// <param name="comment"></param>
  442. /// <returns></returns>
  443. public string SubmitChargeDelay(List<Guid> chargeDelayIDs, Guid userID, string comment)
  444. {
  445. try
  446. {
  447. //查询缓交申请工作流程开始环节状态
  448. var startStatusID = this.GetStartStatus();
  449. if (startStatusID == null)
  450. {
  451. throw new Exception("工作流平台中,费用缓交开始环节流程未配置,请核查");
  452. }
  453. //查询对应的缓交信息List
  454. var chargeDelayList = chargeDelayDAL.ChargeDelayRepository
  455. .GetList(x => chargeDelayIDs.Contains(x.ChargeDelayID)).ToList();
  456. int success = 0; //成功
  457. int fail = 0; //失败
  458. string tipMessage = null; //提示消息
  459. var submitIDList = new List<Guid>();
  460. foreach (var chargeDelay in chargeDelayList)
  461. {
  462. if (chargeDelay.RecordStatus == startStatusID)
  463. {
  464. submitIDList.Add(chargeDelay.ChargeDelayID);
  465. success++;
  466. }
  467. else
  468. {
  469. fail++;
  470. }
  471. }
  472. this.StartUp(submitIDList, userID, comment);
  473. if (success > 0 && fail <= 0)
  474. {
  475. tipMessage = success + "条";
  476. }
  477. else
  478. {
  479. tipMessage = success + "条," + fail + "条失败,原因:选择提交的数据有误,请检查";
  480. }
  481. return tipMessage;
  482. }
  483. catch (Exception ex)
  484. {
  485. throw new Exception(ex.Message);
  486. }
  487. }
  488. /// <summary>
  489. /// 审核(可批量)
  490. /// </summary>
  491. /// <param name="chargeDelayIDs"></param>
  492. /// <param name="userID"></param>
  493. /// <param name="actionID"></param>
  494. /// <param name="comment"></param>
  495. public void ApproveChargeDelay(List<Guid?> chargeDelayIDs, Guid userID, Guid actionID, string comment)
  496. {
  497. try
  498. {
  499. //查询对应的缓交信息List
  500. var chargeDelayList = chargeDelayDAL.ChargeDelayRepository
  501. .GetList(x => chargeDelayIDs.Contains(x.ChargeDelayID)).ToList();
  502. var apprveIDList = new List<Guid>();
  503. foreach (var chargeDelayID in chargeDelayIDs)
  504. {
  505. //查询对应的缓交信息
  506. var chargeDelay = chargeDelayList.Where(x => x.ChargeDelayID == chargeDelayID).SingleOrDefault();
  507. if (chargeDelay == null)
  508. {
  509. throw new Exception("数据有误,请核查");
  510. }
  511. apprveIDList.Add(chargeDelay.ChargeDelayID);
  512. }
  513. //审核
  514. this.Approve(apprveIDList, userID, actionID, comment);
  515. }
  516. catch (Exception ex)
  517. {
  518. throw new Exception(ex.Message);
  519. }
  520. }
  521. /// <summary>
  522. /// 查询对应的缓交名单信息View(学生平台)
  523. /// </summary>
  524. /// <param name="configuretView"></param>
  525. /// <param name="userID"></param>
  526. /// <param name="chargeYearID"></param>
  527. /// <param name="chargeProjectID"></param>
  528. /// <param name="chargeDelayStatus"></param>
  529. /// <param name="pageIndex"></param>
  530. /// <param name="pageSize"></param>
  531. /// <returns></returns>
  532. public IGridResultSet<ChargeDelayView> GetStudentChargeDelayViewGrid(ConfiguretView configuretView, Guid userID, int? chargeYearID,
  533. Guid? chargeProjectID, int? chargeDelayStatus, int pageIndex, int pageSize)
  534. {
  535. //查询对应的工作流程环节状态信息View
  536. var approveStatusList = this.GetStatusViewList();
  537. //缓交名单
  538. Expression<Func<EC_ChargeDelay, bool>> expChargeDelay = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  539. if (chargeDelayStatus.HasValue)
  540. {
  541. //审批状态
  542. expChargeDelay = expChargeDelay.And(x => x.RecordStatus == chargeDelayStatus);
  543. }
  544. //应收名单
  545. Expression<Func<EC_StudentCharge, bool>> expStudentCharge = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  546. //用户信息ID
  547. expStudentCharge = expStudentCharge.And(x => x.UserID == userID);
  548. if (chargeYearID.HasValue)
  549. {
  550. //缴费学年
  551. expStudentCharge = expStudentCharge.And(x => x.ChargeYear == chargeYearID);
  552. }
  553. if (chargeProjectID.HasValue)
  554. {
  555. //收费项目
  556. expStudentCharge = expStudentCharge.And(x => x.ChargeProjectID == chargeProjectID);
  557. }
  558. //学生信息
  559. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  560. //学生信息ID
  561. expStudent = expStudent.And(x => x.UserID == userID);
  562. var query = chargeDelayDAL.GetChargeDelayQueryAble(expChargeDelay, expStudentCharge, expStudent);
  563. //查询条件
  564. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  565. {
  566. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  567. }
  568. var result = query.OrderBy(x => x.ChargeProjectStr).ThenByDescending(x => x.ChargeYear)
  569. .ThenBy(x => x.RecordStatus).ThenBy(x => x.CreateTime)
  570. .ToGridResultSet<ChargeDelayView>(pageIndex, pageSize);
  571. result.rows.ForEach(x => x.RecordStatusName = approveStatusList.FirstOrDefault(w => w.ID == x.RecordStatus).Name);
  572. return result;
  573. }
  574. /// <summary>
  575. /// 查询对应的缓交名单信息List(学生平台)
  576. /// </summary>
  577. /// <param name="configuretView"></param>
  578. /// <param name="userID"></param>
  579. /// <param name="chargeYearID"></param>
  580. /// <param name="chargeProjectID"></param>
  581. /// <param name="chargeDelayStatus"></param>
  582. /// <returns></returns>
  583. public List<ChargeDelayView> GetStudentChargeDelayViewList(ConfiguretView configuretView, Guid userID, int? chargeYearID,
  584. Guid? chargeProjectID, int? chargeDelayStatus)
  585. {
  586. //查询对应的工作流程环节状态信息View
  587. var approveStatusList = this.GetStatusViewList();
  588. //缓交名单
  589. Expression<Func<EC_ChargeDelay, bool>> expChargeDelay = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  590. if (chargeDelayStatus.HasValue)
  591. {
  592. //审批状态
  593. expChargeDelay = expChargeDelay.And(x => x.RecordStatus == chargeDelayStatus);
  594. }
  595. //应收名单
  596. Expression<Func<EC_StudentCharge, bool>> expStudentCharge = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  597. //用户信息ID
  598. expStudentCharge = expStudentCharge.And(x => x.UserID == userID);
  599. if (chargeYearID.HasValue)
  600. {
  601. //缴费学年
  602. expStudentCharge = expStudentCharge.And(x => x.ChargeYear == chargeYearID);
  603. }
  604. if (chargeProjectID.HasValue)
  605. {
  606. //收费项目
  607. expStudentCharge = expStudentCharge.And(x => x.ChargeProjectID == chargeProjectID);
  608. }
  609. //学生信息
  610. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  611. //学生信息ID
  612. expStudent = expStudent.And(x => x.UserID == userID);
  613. var query = chargeDelayDAL.GetChargeDelayQueryAble(expChargeDelay, expStudentCharge, expStudent);
  614. //查询条件
  615. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  616. {
  617. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  618. }
  619. var result = query.OrderBy(x => x.ChargeProjectStr).ThenByDescending(x => x.ChargeYear)
  620. .ThenBy(x => x.RecordStatus).ThenBy(x => x.CreateTime)
  621. .ToList();
  622. result.ForEach(x => x.RecordStatusName = approveStatusList.FirstOrDefault(w => w.ID == x.RecordStatus).Name);
  623. return result;
  624. }
  625. }
  626. }