MinorGraduationApplyServices.cs 39 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using Bowin.Common.Linq.Entity;
  6. using EMIS.ViewModel.MinorGraduation.MinorGraduationManage;
  7. using EMIS.ViewModel;
  8. using EMIS.CommonLogic.SystemServices;
  9. using EMIS.Entities;
  10. using System.Linq.Expressions;
  11. using Bowin.Common.Linq;
  12. using EMIS.CommonLogic.Students;
  13. using EMIS.DataLogic.MinorGraduation.MinorGraduationManage;
  14. using EMIS.CommonLogic.CalendarManage;
  15. using EMIS.DataLogic.MinorGraduation.MinorGraduationSetting;
  16. using EMIS.Utility;
  17. using EMIS.CommonLogic.StudentManage.StudentStatistics;
  18. namespace EMIS.CommonLogic.MinorGraduation.MinorGraduationManage
  19. {
  20. public class MinorGraduationApplyServices : BaseWorkflowServices<ER_MinorGraduationApply>, IMinorGraduationApplyServices
  21. {
  22. public IInSchoolSettingServices inSchoolStatusSettingServices { get; set; }
  23. public MinorGraduationApplyDAL minorGraduationApplyDAL { get; set; }
  24. public IParameterServices parameterServices { get; set; }
  25. public ISchoolYearServices schoolYearServices { get; set; }
  26. public MinorGraduationConditionPackageDAL minorGraduationConditionPackageDAL { get; set; }
  27. public MinorGraduationConditionDAL minorGraduationConditionDAL { get; set; }
  28. /// <summary>
  29. /// 辅修毕业申请页面
  30. /// </summary>
  31. /// <param name="configuretView"></param>
  32. /// <param name="gradSchoolyearID"></param>
  33. /// <param name="collegeID"></param>
  34. /// <param name="yearID"></param>
  35. /// <param name="standardID"></param>
  36. /// <param name="graduationTypeID"></param>
  37. /// <param name="inSchoolStatus"></param>
  38. /// <param name="graduationResult"></param>
  39. /// <param name="approvalStatus"></param>
  40. /// <param name="pageIndex"></param>
  41. /// <param name="pageSize"></param>
  42. /// <returns></returns>
  43. public IGridResultSet<MinorGraduationApplyView> GetMinorGraduationApplyViewGrid(ConfiguretView configuretView, Guid? gradSchoolyearID,
  44. Guid? collegeID, int? yearID, int? standardID, int? graduationTypeID, int? inSchoolStatus, int? graduationResult, int? approvalStatus, int pageIndex, int pageSize)
  45. {
  46. //结束流程环节ID
  47. var endStatusID = this.GetCorrectEndStatus();
  48. var approveStatusIDList = this.GetApproveStatusViewList()
  49. .Select(x => x.ID).ToList();
  50. var applyStatusList = this.GetStatusViewList();
  51. var applyStatusIDList = applyStatusList.Where(x => x.ID != endStatusID && !approveStatusIDList.Contains(x.ID))
  52. .Select(x => x.ID).ToList();
  53. Expression<Func<ER_MinorGraduationApply, bool>> exp = x => true;
  54. Expression<Func<CF_Student, bool>> expstu = x => true;
  55. exp = exp.And(x => applyStatusIDList.Contains(x.RecordStatus));
  56. if (gradSchoolyearID.HasValue)
  57. {
  58. exp = exp.And(x => x.GraduatingSemesterID == gradSchoolyearID);
  59. }
  60. if (collegeID.HasValue)
  61. {
  62. expstu = expstu.And(x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID);
  63. }
  64. if (standardID.HasValue)
  65. {
  66. expstu = expstu.And(x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID == standardID);
  67. }
  68. if (graduationTypeID.HasValue)
  69. {
  70. //毕业类型
  71. exp = exp.And(x => x.GraduationTypeID == graduationTypeID);
  72. }
  73. if (graduationResult.HasValue)
  74. {
  75. //毕业结论
  76. exp = exp.And(x => x.MinorGraduationResult == graduationResult);
  77. }
  78. if (approvalStatus.HasValue)
  79. {
  80. //审批状态
  81. exp = exp.And(x => x.RecordStatus == approvalStatus);
  82. }
  83. if (inSchoolStatus != null && inSchoolStatus > -1)
  84. {
  85. var inschoolStatusList = inSchoolStatusSettingServices.GetInschoolStatusList(true);
  86. if (inSchoolStatus == 1)
  87. {
  88. //表示在校
  89. expstu = expstu.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
  90. }
  91. if (inSchoolStatus == 0)
  92. {
  93. //不在校
  94. expstu = expstu.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
  95. }
  96. }
  97. if (yearID.HasValue)
  98. {
  99. expstu = expstu.And(x => x.CF_Classmajor.CF_Grademajor.GradeID == yearID);
  100. }
  101. var query = minorGraduationApplyDAL.GetMinorGraduationApplyViewQueryable(exp, expstu);
  102. //查询条件
  103. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  104. {
  105. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  106. }
  107. var result = this.GetQueryByDataRangeByCollege(query)
  108. .OrderByDescending(x => x.GraduatingSemesterValue)
  109. .ThenBy(x => x.ApplySchoolyearCode.Length).ThenByDescending(x => x.ApplySchoolyearCode)
  110. .ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo)
  111. .ToGridResultSet<MinorGraduationApplyView>(pageIndex, pageSize);
  112. result.rows.ForEach(x => x.ApprovalStatusName = applyStatusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
  113. return result;
  114. }
  115. /// <summary>
  116. /// 辅修毕业申请页面(excel)
  117. /// </summary>
  118. /// <param name="configuretView"></param>
  119. /// <param name="gradSchoolyearID"></param>
  120. /// <param name="collegeID"></param>
  121. /// <param name="yearID"></param>
  122. /// <param name="standardID"></param>
  123. /// <param name="graduationTypeID"></param>
  124. /// <param name="inSchoolStatus"></param>
  125. /// <param name="graduationResult"></param>
  126. /// <param name="approvalStatus"></param>
  127. /// <param name="idList"></param>
  128. /// <returns></returns>
  129. public List<MinorGraduationApplyView> GetMinorGraduationApplyViewList(ConfiguretView configuretView, Guid? gradSchoolyearID,
  130. Guid? collegeID, int? yearID, int? standardID, int? graduationTypeID, int? inSchoolStatus, int? graduationResult, int? approvalStatus, List<Guid?> idList)
  131. {
  132. //结束流程环节ID
  133. var endStatusID = this.GetCorrectEndStatus();
  134. var approveStatusIDList = this.GetApproveStatusViewList()
  135. .Select(x => x.ID).ToList();
  136. var applyStatusList = this.GetStatusViewList();
  137. var applyStatusIDList = applyStatusList.Where(x => x.ID != endStatusID && !approveStatusIDList.Contains(x.ID))
  138. .Select(x => x.ID).ToList();
  139. Expression<Func<ER_MinorGraduationApply, bool>> exp = x => true;
  140. Expression<Func<CF_Student, bool>> expstu = x => true;
  141. exp = exp.And(x => applyStatusIDList.Contains(x.RecordStatus));
  142. if (gradSchoolyearID.HasValue)
  143. {
  144. exp = exp.And(x => x.GraduatingSemesterID == gradSchoolyearID);
  145. }
  146. if (collegeID.HasValue)
  147. {
  148. expstu = expstu.And(x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID);
  149. }
  150. if (standardID.HasValue)
  151. {
  152. expstu = expstu.And(x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID == standardID);
  153. }
  154. if (graduationTypeID.HasValue)
  155. {
  156. //毕业类型
  157. exp = exp.And(x => x.GraduationTypeID == graduationTypeID);
  158. }
  159. if (graduationResult.HasValue)
  160. {
  161. //毕业结论
  162. exp = exp.And(x => x.MinorGraduationResult == graduationResult);
  163. }
  164. if (approvalStatus.HasValue)
  165. {
  166. //审批状态
  167. exp = exp.And(x => x.RecordStatus == approvalStatus);
  168. }
  169. if (inSchoolStatus != null && inSchoolStatus > -1)
  170. {
  171. var inschoolStatusList = inSchoolStatusSettingServices.GetInschoolStatusList(true);
  172. if (inSchoolStatus == 1)
  173. {
  174. //表示在校
  175. expstu = expstu.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
  176. }
  177. if (inSchoolStatus == 0)
  178. {
  179. //不在校
  180. expstu = expstu.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
  181. }
  182. }
  183. if (yearID.HasValue)
  184. {
  185. expstu = expstu.And(x => x.CF_Classmajor.CF_Grademajor.GradeID == yearID);
  186. }
  187. if (idList != null && idList.Count > 0)
  188. {
  189. exp = exp.And(x => idList.Contains(x.MinorGraduationApplyID));
  190. }
  191. var query = minorGraduationApplyDAL.GetMinorGraduationApplyViewQueryable(exp, expstu);
  192. //查询条件
  193. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  194. {
  195. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  196. }
  197. var result = this.GetQueryByDataRangeByCollege(query)
  198. .OrderByDescending(x => x.GraduatingSemesterValue)
  199. .ThenBy(x => x.ApplySchoolyearCode.Length).ThenByDescending(x => x.ApplySchoolyearCode)
  200. .ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo)
  201. .ToList();
  202. result.ForEach(x => x.ApprovalStatusName = applyStatusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
  203. return result;
  204. }
  205. /// <summary>
  206. /// 辅修毕业审核页面
  207. /// </summary>
  208. /// <param name="configuretView"></param>
  209. /// <param name="gradSchoolyearID"></param>
  210. /// <param name="collegeID"></param>
  211. /// <param name="yearID"></param>
  212. /// <param name="standardID"></param>
  213. /// <param name="graduationTypeID"></param>
  214. /// <param name="inSchoolStatus"></param>
  215. /// <param name="graduationResult"></param>
  216. /// <param name="approvalStatus"></param>
  217. /// <param name="pageIndex"></param>
  218. /// <param name="pageSize"></param>
  219. /// <returns></returns>
  220. public IGridResultSet<MinorGraduationApplyView> GetMinorGraduationApproveViewGrid(ConfiguretView configuretView, Guid? gradSchoolyearID,
  221. Guid? collegeID, int? yearID, int? standardID, int? graduationTypeID, int? inSchoolStatus, int? graduationResult, int? approvalStatus, int pageIndex, int pageSize)
  222. {
  223. //结束流程环节ID
  224. var endStatusID = this.GetCorrectEndStatus();
  225. var approveStatusIDList = this.GetApproveStatusViewList()
  226. .Select(x => x.ID).ToList();
  227. var applyStatusList = this.GetStatusViewList();
  228. var applyStatusIDList = applyStatusList.Where(x => approveStatusIDList.Contains(x.ID))
  229. .Select(x => x.ID).ToList();
  230. Expression<Func<ER_MinorGraduationApply, bool>> exp = x => true;
  231. Expression<Func<CF_Student, bool>> expstu = x => true;
  232. exp = exp.And(x => applyStatusIDList.Contains(x.RecordStatus));
  233. if (gradSchoolyearID.HasValue)
  234. {
  235. exp = exp.And(x => x.GraduatingSemesterID == gradSchoolyearID);
  236. }
  237. if (collegeID.HasValue)
  238. {
  239. expstu = expstu.And(x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID);
  240. }
  241. if (standardID.HasValue)
  242. {
  243. expstu = expstu.And(x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID == standardID);
  244. }
  245. if (graduationTypeID.HasValue)
  246. {
  247. //毕业类型
  248. exp = exp.And(x => x.GraduationTypeID == graduationTypeID);
  249. }
  250. if (graduationResult.HasValue)
  251. {
  252. //毕业结论
  253. exp = exp.And(x => x.MinorGraduationResult == graduationResult);
  254. }
  255. if (approvalStatus.HasValue)
  256. {
  257. //审批状态
  258. exp = exp.And(x => x.RecordStatus == approvalStatus);
  259. }
  260. if (inSchoolStatus != null && inSchoolStatus > -1)
  261. {
  262. var inschoolStatusList = inSchoolStatusSettingServices.GetInschoolStatusList(true);
  263. if (inSchoolStatus == 1)
  264. {
  265. //表示在校
  266. expstu = expstu.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
  267. }
  268. if (inSchoolStatus == 0)
  269. {
  270. //不在校
  271. expstu = expstu.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
  272. }
  273. }
  274. if (yearID.HasValue)
  275. {
  276. expstu = expstu.And(x => x.CF_Classmajor.CF_Grademajor.GradeID == yearID);
  277. }
  278. var query = minorGraduationApplyDAL.GetMinorGraduationApplyViewQueryable(exp, expstu);
  279. //查询条件
  280. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  281. {
  282. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  283. }
  284. var result = this.GetQueryByDataRangeByCollege(query)
  285. .OrderByDescending(x => x.GraduatingSemesterValue)
  286. .ThenBy(x => x.ApplySchoolyearCode.Length).ThenByDescending(x => x.ApplySchoolyearCode)
  287. .ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo)
  288. .ToGridResultSet<MinorGraduationApplyView>(pageIndex, pageSize);
  289. result.rows.ForEach(x => x.ApprovalStatusName = applyStatusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
  290. return result;
  291. }
  292. /// <summary>
  293. /// 辅修毕业审核页面(excel)
  294. /// </summary>
  295. /// <param name="configuretView"></param>
  296. /// <param name="gradSchoolyearID"></param>
  297. /// <param name="collegeID"></param>
  298. /// <param name="yearID"></param>
  299. /// <param name="standardID"></param>
  300. /// <param name="graduationTypeID"></param>
  301. /// <param name="inSchoolStatus"></param>
  302. /// <param name="graduationResult"></param>
  303. /// <param name="approvalStatus"></param>
  304. /// <param name="idList"></param>
  305. /// <returns></returns>
  306. public List<MinorGraduationApplyView> GetMinorGraduationApproveViewList(ConfiguretView configuretView, Guid? gradSchoolyearID,
  307. Guid? collegeID, int? yearID, int? standardID, int? graduationTypeID, int? inSchoolStatus, int? graduationResult, int? approvalStatus, List<Guid?> idList)
  308. {
  309. //结束流程环节ID
  310. var endStatusID = this.GetCorrectEndStatus();
  311. var approveStatusIDList = this.GetApproveStatusViewList()
  312. .Select(x => x.ID).ToList();
  313. var applyStatusList = this.GetStatusViewList();
  314. var applyStatusIDList = applyStatusList.Where(x =>approveStatusIDList.Contains(x.ID))
  315. .Select(x => x.ID).ToList();
  316. Expression<Func<ER_MinorGraduationApply, bool>> exp = x => true;
  317. Expression<Func<CF_Student, bool>> expstu = x => true;
  318. exp = exp.And(x => applyStatusIDList.Contains(x.RecordStatus));
  319. if (gradSchoolyearID.HasValue)
  320. {
  321. exp = exp.And(x => x.GraduatingSemesterID == gradSchoolyearID);
  322. }
  323. if (collegeID.HasValue)
  324. {
  325. expstu = expstu.And(x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID);
  326. }
  327. if (standardID.HasValue)
  328. {
  329. expstu = expstu.And(x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID == standardID);
  330. }
  331. if (graduationTypeID.HasValue)
  332. {
  333. //毕业类型
  334. exp = exp.And(x => x.GraduationTypeID == graduationTypeID);
  335. }
  336. if (graduationResult.HasValue)
  337. {
  338. //毕业结论
  339. exp = exp.And(x => x.MinorGraduationResult == graduationResult);
  340. }
  341. if (approvalStatus.HasValue)
  342. {
  343. //审批状态
  344. exp = exp.And(x => x.RecordStatus == approvalStatus);
  345. }
  346. if (inSchoolStatus != null && inSchoolStatus > -1)
  347. {
  348. var inschoolStatusList = inSchoolStatusSettingServices.GetInschoolStatusList(true);
  349. if (inSchoolStatus == 1)
  350. {
  351. //表示在校
  352. expstu = expstu.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
  353. }
  354. if (inSchoolStatus == 0)
  355. {
  356. //不在校
  357. expstu = expstu.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
  358. }
  359. }
  360. if (yearID.HasValue)
  361. {
  362. expstu = expstu.And(x => x.CF_Classmajor.CF_Grademajor.GradeID == yearID);
  363. }
  364. if (idList != null && idList.Count > 0)
  365. {
  366. exp = exp.And(x => idList.Contains(x.MinorGraduationApplyID));
  367. }
  368. var query = minorGraduationApplyDAL.GetMinorGraduationApplyViewQueryable(exp, expstu);
  369. //查询条件
  370. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  371. {
  372. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  373. }
  374. var result = this.GetQueryByDataRangeByCollege(query)
  375. .OrderByDescending(x => x.GraduatingSemesterValue)
  376. .ThenBy(x => x.ApplySchoolyearCode.Length).ThenByDescending(x => x.ApplySchoolyearCode)
  377. .ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo)
  378. .ToList();
  379. result.ForEach(x => x.ApprovalStatusName = applyStatusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
  380. return result;
  381. }
  382. public IGridResultSet<MinorGraduationApplyView> GetMinorGraduationListGrid(ConfiguretView configuretView, Guid? gradSchoolyearID,
  383. Guid? collegeID, int? yearID, int? standardID, int? graduationTypeID, int? inSchoolStatus, int? graduationResult, int? approvalStatus, int pageIndex, int pageSize)
  384. {
  385. //结束流程环节ID
  386. var endStatusID = this.GetCorrectEndStatus();
  387. var approveStatusIDList = this.GetApproveStatusViewList()
  388. .Select(x => x.ID).ToList();
  389. var applyStatusList = this.GetStatusViewList();
  390. var applyStatusIDList = applyStatusList.Where(x => x.ID != endStatusID && !approveStatusIDList.Contains(x.ID))
  391. .Select(x => x.ID).ToList();
  392. Expression<Func<ER_MinorGraduationApply, bool>> exp = x => true;
  393. Expression<Func<CF_Student, bool>> expstu = x => true;
  394. if (gradSchoolyearID.HasValue)
  395. {
  396. exp = exp.And(x => x.GraduatingSemesterID == gradSchoolyearID);
  397. }
  398. if (collegeID.HasValue)
  399. {
  400. expstu = expstu.And(x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID);
  401. }
  402. if (standardID.HasValue)
  403. {
  404. expstu = expstu.And(x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID == standardID);
  405. }
  406. if (graduationTypeID.HasValue)
  407. {
  408. //毕业类型
  409. exp = exp.And(x => x.GraduationTypeID == graduationTypeID);
  410. }
  411. if (graduationResult.HasValue)
  412. {
  413. //毕业结论
  414. exp = exp.And(x => x.MinorGraduationResult == graduationResult);
  415. }
  416. if (approvalStatus.HasValue)
  417. {
  418. //审批状态
  419. exp = exp.And(x => x.RecordStatus == approvalStatus);
  420. }
  421. if (inSchoolStatus != null && inSchoolStatus > -1)
  422. {
  423. var inschoolStatusList = inSchoolStatusSettingServices.GetInschoolStatusList(true);
  424. if (inSchoolStatus == 1)
  425. {
  426. //表示在校
  427. expstu = expstu.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
  428. }
  429. if (inSchoolStatus == 0)
  430. {
  431. //不在校
  432. expstu = expstu.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
  433. }
  434. }
  435. if (yearID.HasValue)
  436. {
  437. expstu = expstu.And(x => x.CF_Classmajor.CF_Grademajor.GradeID == yearID);
  438. }
  439. var query = minorGraduationApplyDAL.GetMinorGraduationApplyViewQueryable(exp, expstu);
  440. //查询条件
  441. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  442. {
  443. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  444. }
  445. var result = this.GetQueryByDataRangeByCollege(query)
  446. .OrderByDescending(x => x.GraduatingSemesterValue)
  447. .ThenBy(x => x.ApplySchoolyearCode.Length).ThenByDescending(x => x.ApplySchoolyearCode)
  448. .ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo)
  449. .ToGridResultSet<MinorGraduationApplyView>(pageIndex, pageSize);
  450. result.rows.ForEach(x => x.ApprovalStatusName = applyStatusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
  451. return result;
  452. }
  453. public List<MinorGraduationApplyView> GetMinorGraduationListList(ConfiguretView configuretView, Guid? gradSchoolyearID,
  454. Guid? collegeID, int? yearID, int? standardID, int? graduationTypeID, int? inSchoolStatus, int? graduationResult, int? approvalStatus, List<Guid?> idList)
  455. {
  456. //结束流程环节ID
  457. var endStatusID = this.GetCorrectEndStatus();
  458. var approveStatusIDList = this.GetApproveStatusViewList()
  459. .Select(x => x.ID).ToList();
  460. var applyStatusList = this.GetStatusViewList();
  461. var applyStatusIDList = applyStatusList.Where(x => approveStatusIDList.Contains(x.ID))
  462. .Select(x => x.ID).ToList();
  463. Expression<Func<ER_MinorGraduationApply, bool>> exp = x => true;
  464. Expression<Func<CF_Student, bool>> expstu = x => true;
  465. if (gradSchoolyearID.HasValue)
  466. {
  467. exp = exp.And(x => x.GraduatingSemesterID == gradSchoolyearID);
  468. }
  469. if (collegeID.HasValue)
  470. {
  471. expstu = expstu.And(x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor.CollegeID == collegeID);
  472. }
  473. if (standardID.HasValue)
  474. {
  475. expstu = expstu.And(x => x.CF_Classmajor.CF_Grademajor.CF_Facultymajor.StandardID == standardID);
  476. }
  477. if (graduationTypeID.HasValue)
  478. {
  479. //毕业类型
  480. exp = exp.And(x => x.GraduationTypeID == graduationTypeID);
  481. }
  482. if (graduationResult.HasValue)
  483. {
  484. //毕业结论
  485. exp = exp.And(x => x.MinorGraduationResult == graduationResult);
  486. }
  487. if (approvalStatus.HasValue)
  488. {
  489. //审批状态
  490. exp = exp.And(x => x.RecordStatus == approvalStatus);
  491. }
  492. if (inSchoolStatus != null && inSchoolStatus > -1)
  493. {
  494. var inschoolStatusList = inSchoolStatusSettingServices.GetInschoolStatusList(true);
  495. if (inSchoolStatus == 1)
  496. {
  497. //表示在校
  498. expstu = expstu.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
  499. }
  500. if (inSchoolStatus == 0)
  501. {
  502. //不在校
  503. expstu = expstu.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
  504. }
  505. }
  506. if (yearID.HasValue)
  507. {
  508. expstu = expstu.And(x => x.CF_Classmajor.CF_Grademajor.GradeID == yearID);
  509. }
  510. if (idList != null && idList.Count > 0)
  511. {
  512. exp = exp.And(x => idList.Contains(x.MinorGraduationApplyID));
  513. }
  514. var query = minorGraduationApplyDAL.GetMinorGraduationApplyViewQueryable(exp, expstu);
  515. //查询条件
  516. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  517. {
  518. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  519. }
  520. var result = this.GetQueryByDataRangeByCollege(query)
  521. .OrderByDescending(x => x.GraduatingSemesterValue)
  522. .ThenBy(x => x.ApplySchoolyearCode.Length).ThenByDescending(x => x.ApplySchoolyearCode)
  523. .ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo)
  524. .ToList();
  525. result.ForEach(x => x.ApprovalStatusName = applyStatusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
  526. return result;
  527. }
  528. public void MinorGraduationApplyGenerate(int? yearID)
  529. {
  530. try
  531. {
  532. //查询对应的工作流程环节状态信息View
  533. var approveStatusList = this.GetStatusViewList();
  534. if (approveStatusList == null || approveStatusList.Count() <= 0)
  535. {
  536. throw new Exception("工作流平台中,毕业处理流程未配置,请核查");
  537. }
  538. //查询工作流程开始环节状态
  539. var approveStartStatus = this.GetStartStatus();
  540. if (approveStartStatus == null)
  541. {
  542. throw new Exception("工作流平台中,毕业处理流程开始环节未配置,请核查");
  543. }
  544. //查询设置的毕业学期信息
  545. var graduatingSemesterID = parameterServices.GetParameterValue(CF_ParameterType.GraduationSchoolyear);
  546. if (!string.IsNullOrEmpty(graduatingSemesterID))
  547. {
  548. var schoolYearView = schoolYearServices.GetSchoolYearView(Guid.Parse(graduatingSemesterID));
  549. if (schoolYearView == null)
  550. {
  551. throw new Exception("毕业学期设置有误,请重新设置");
  552. }
  553. //查询当前启用的学年学期View
  554. var currentSchoolYearView = schoolYearServices.GetCurrentSchoolYear();
  555. if (currentSchoolYearView == null)
  556. {
  557. throw new Exception("未设置启用的学年学期,请设置");
  558. }
  559. //在校状态
  560. var inschoolStatusList = inSchoolStatusSettingServices.GetInschoolStatusList(true);
  561. //学生信息
  562. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  563. //表示在校
  564. expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
  565. //毕业学期
  566. Expression<Func<EMIS.Entities.CF_Schoolyear, bool>> expSchoolyear = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  567. //应届、往届毕业
  568. expSchoolyear = expSchoolyear.And(x => x.Value <= schoolYearView.Value);
  569. var studentIDList = minorGraduationApplyDAL.classminorStudentRepository.GetList(x => true).Select(x => x.UserID).ToList();
  570. if (yearID.HasValue)
  571. {
  572. studentIDList = minorGraduationApplyDAL.classminorStudentRepository.GetList(x => x.CF_Classminor.CF_Grademinor.YearID == yearID).Select(x => x.UserID).ToList();
  573. }
  574. //对应的学生信息IDList
  575. //var userIDList = graduationStudentViewList.Select(x => x.UserID).ToList();
  576. //查询对应的毕业申请信息graduationApplyViewList
  577. var minorGraduationApplyViewList = minorGraduationApplyDAL.minorGraduationApplyRepository
  578. .GetList(x => true).ToList();
  579. //匹配对应的条件查询
  580. var dbMinorGraduationApplyViewList = minorGraduationApplyViewList.Where(x => studentIDList.Contains(x.UserID.Value)).ToList();
  581. List<ER_MinorGraduationApply> minorGraduationApplyInList = new List<ER_MinorGraduationApply>();
  582. foreach (var studentID in studentIDList)
  583. {
  584. //根据对应的信息查询毕业申请信息
  585. var minorGraduationApplyView = dbMinorGraduationApplyViewList.Where(x => x.UserID == studentID
  586. && x.GraduatingSemesterID == schoolYearView.SchoolYearID)
  587. .SingleOrDefault();
  588. if (minorGraduationApplyView == null)
  589. {
  590. //新增
  591. ER_MinorGraduationApply minorGraduationApply = new ER_MinorGraduationApply();
  592. minorGraduationApply.MinorGraduationApplyID = Guid.NewGuid();
  593. minorGraduationApply.UserID = studentID;
  594. //默认应届
  595. minorGraduationApply.GraduationTypeID = (int)ER_GraduationType.Fresh;
  596. minorGraduationApply.GraduatingSemesterID = schoolYearView.SchoolYearID;
  597. minorGraduationApply.ApplySchoolyearID = currentSchoolYearView.SchoolYearID;
  598. minorGraduationApply.RecordStatus = approveStartStatus;
  599. minorGraduationApply.MinorGraduationResult = (int)ER_GraduationResult.UnAudit;
  600. SetNewStatus(minorGraduationApply);
  601. minorGraduationApplyInList.Add(minorGraduationApply);
  602. }
  603. else
  604. {
  605. continue;
  606. }
  607. }
  608. UnitOfWork.BulkInsert<ER_MinorGraduationApply>(minorGraduationApplyInList); //批量插入
  609. UnitOfWork.Commit();
  610. }
  611. else
  612. {
  613. throw new Exception("未设置毕业学期,请设置");
  614. }
  615. }
  616. catch (Exception ex)
  617. {
  618. throw new Exception(ex.Message);
  619. }
  620. }
  621. public string MinorGraduationApplySubmit(List<Guid?> minorGraduationApplyIDs, Guid userID, MinorGraduationApplyView minorGraduationApplyView)
  622. {
  623. try
  624. {
  625. //查询工作流程开始环节状态
  626. var startStatusID = this.GetStartStatus();
  627. if (startStatusID == null)
  628. {
  629. throw new Exception("工作流平台中,开始环节流程未配置,请核查");
  630. }
  631. //查询对应的毕业申请信息List
  632. var minorGraduationApplyList = minorGraduationApplyDAL.minorGraduationApplyRepository
  633. .GetList(x => minorGraduationApplyIDs.Contains(x.MinorGraduationApplyID), (x => x.CF_Student)).ToList();
  634. if (minorGraduationApplyList.Any(x => x.CF_Student.StudentType != minorGraduationApplyView.StudentTypeID))
  635. {
  636. throw new Exception("提交的信息中学生类别与毕业公式不匹配,请核查");
  637. }
  638. //查询毕业公式对应的毕业条件信息
  639. var minorGraduationConditionViewList = minorGraduationConditionDAL
  640. .GetMinorGraduationConditionByPackageID(x => x.MinorGraduationConditionPackageID == minorGraduationApplyView.MinorGraduationConditionPackageID);
  641. if (minorGraduationConditionViewList == null || minorGraduationConditionViewList.Count() <= 0)
  642. {
  643. throw new Exception("毕业公式中毕业条件为空,请核查");
  644. }
  645. int success = 0; //成功
  646. int fail = 0; //失败
  647. bool isPass = true; //条件公式验证标识
  648. string tipMessage = null; //提示消息
  649. List<ER_MinorGraduationApply> graduationApplyUpList = new List<ER_MinorGraduationApply>();
  650. List<Guid> needSubmitIDList = new List<Guid>();
  651. List<Guid> needApproveIDList = new List<Guid>();
  652. foreach (var minorGraduationApply in minorGraduationApplyList)
  653. {
  654. foreach (var minorGraduationConditionView in minorGraduationConditionViewList)
  655. {
  656. var retValue = ReflectorHelper.RunMethod(minorGraduationConditionView.MethodFullName, minorGraduationApply.UserID);
  657. if (!(bool)retValue)
  658. {
  659. //表示条件不通过
  660. isPass = false;
  661. minorGraduationApply.MinorGraduationResult = (int)ER_GraduationResult.UnPass;
  662. minorGraduationApply.ApprovalResult = "条件不通过";
  663. //终止循环
  664. break;
  665. }
  666. }
  667. if (isPass)
  668. {
  669. if (minorGraduationApply.RecordStatus == startStatusID)
  670. {
  671. //提交--未提交状态
  672. needSubmitIDList.Add(minorGraduationApply.MinorGraduationApplyID);
  673. }
  674. else
  675. {
  676. //var actionView = this.GetActionView()
  677. // .Where(x => x.Pid == graduationApply.ApprovalStatus).SingleOrDefault();
  678. //提交--不包括开始环节状态的流程状态(如:已退回)
  679. needApproveIDList.Add(minorGraduationApply.MinorGraduationApplyID);
  680. }
  681. minorGraduationApply.MinorGraduationResult = (int)ER_GraduationResult.Graduation;
  682. minorGraduationApply.ApprovalResult = "条件通过";
  683. success++;
  684. }
  685. else
  686. {
  687. fail++;
  688. isPass = true;
  689. }
  690. minorGraduationApply.MinorGraduationConditionPackageID = minorGraduationApplyView.MinorGraduationConditionPackageID;
  691. SetModifyStatus(minorGraduationApply);
  692. graduationApplyUpList.Add(minorGraduationApply);
  693. }
  694. //批量统一提交更新
  695. if (graduationApplyUpList != null && graduationApplyUpList.Count() > 0)
  696. {
  697. UnitOfWork.BatchUpdate<ER_MinorGraduationApply>(graduationApplyUpList);
  698. }
  699. if (needSubmitIDList.Count > 0)
  700. {
  701. this.StartUp(needSubmitIDList, userID, minorGraduationApplyView.Comment);
  702. }
  703. if (needApproveIDList.Count > 0)
  704. {
  705. this.Approve(needApproveIDList, userID, Guid.Empty, minorGraduationApplyView.Comment);
  706. }
  707. if (success > 0 && fail <= 0)
  708. {
  709. tipMessage = success + "条";
  710. }
  711. else
  712. {
  713. tipMessage = success + "条," + fail + "条失败,原因:条件不通过,请查看对应的预审说明";
  714. }
  715. UnitOfWork.Commit();
  716. return tipMessage;
  717. }
  718. catch (Exception ex)
  719. {
  720. throw new Exception(ex.Message);
  721. }
  722. }
  723. public MinorGraduationApplyView GetMinorGraduationApproveView(Guid? minorGraduationApplyID)
  724. {
  725. try
  726. {
  727. var minorGraduationApproveView = minorGraduationApplyDAL.GetMinorGraduationApplyViewQueryable(x => x.MinorGraduationApplyID == minorGraduationApplyID, x => true)
  728. .SingleOrDefault();
  729. return minorGraduationApproveView;
  730. }
  731. catch (Exception ex)
  732. {
  733. throw new Exception(ex.Message);
  734. }
  735. }
  736. public void MinorGraduationApproveConfirm(List<Guid?> minorGraduationApplyIDs, Guid userID, Guid actionID, string comment)
  737. {
  738. try
  739. {
  740. //查询对应的毕业审核信息List
  741. var minorGraduationApplyList = minorGraduationApplyDAL.minorGraduationApplyRepository
  742. .GetList(x => minorGraduationApplyIDs.Contains(x.MinorGraduationApplyID)).ToList();
  743. foreach (var minorGraduationApplyID in minorGraduationApplyIDs)
  744. {
  745. //查询对应的毕业审核信息
  746. var minorGraduationApply = minorGraduationApplyList.Where(x => x.MinorGraduationApplyID == minorGraduationApplyID).SingleOrDefault();
  747. if (minorGraduationApply == null)
  748. {
  749. throw new Exception("数据有误,请核查");
  750. }
  751. }
  752. //审核
  753. this.Approve(minorGraduationApplyIDs.Select(x => x.Value).ToList(), userID, actionID, comment);
  754. }
  755. catch (Exception ex)
  756. {
  757. throw new Exception(ex.Message);
  758. }
  759. }
  760. public void MinorGraduationApplyDelete(List<Guid?> minorGraduationApplyIDList)
  761. {
  762. try
  763. {
  764. UnitOfWork.Delete<ER_MinorGraduationApply>(x => minorGraduationApplyIDList.Contains(x.MinorGraduationApplyID));
  765. }
  766. catch (Exception ex)
  767. {
  768. throw new Exception(ex.Message);
  769. }
  770. }
  771. public void OnApproveEnd(List<Guid> minorGraduationApplyIDList, Guid? userID)
  772. {
  773. //辅修毕业审核通过时执行方法
  774. }
  775. }
  776. }