GraduateCardApproveServices.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Linq.Expressions;
  6. using System.Transactions;
  7. using Bowin.Common.Linq;
  8. using Bowin.Common.Linq.Entity;
  9. using EMIS.Entities;
  10. using EMIS.ViewModel;
  11. using EMIS.ViewModel.WorkflowManage;
  12. using EMIS.ViewModel.GraduationManage.GraduateCardManage;
  13. using EMIS.DataLogic.GraduationManage.GraduateCardManage;
  14. using EMIS.CommonLogic.SystemServices;
  15. using EMIS.CommonLogic.StudentManage.StudentStatistics;
  16. namespace EMIS.CommonLogic.GraduationManage.GraduateCardManage
  17. {
  18. public class GraduateCardApproveServices : BaseWorkflowServices<ER_GraduateCardApply>, IGraduateCardApproveServices
  19. {
  20. public GraduateCardApplyDAL GraduateCardApplyDAL { get; set; }
  21. public Lazy<IInSchoolSettingServices> InSchoolSettingServices { get; set; }
  22. /// <summary>
  23. /// 查询去向审核信息View
  24. /// </summary>
  25. /// <param name="configuretView"></param>
  26. /// <param name="gradSchoolyearID"></param>
  27. /// <param name="campusID"></param>
  28. /// <param name="collegeID"></param>
  29. /// <param name="yearID"></param>
  30. /// <param name="standardID"></param>
  31. /// <param name="educationID"></param>
  32. /// <param name="learningformID"></param>
  33. /// <param name="learnSystem"></param>
  34. /// <param name="graduationTypeID"></param>
  35. /// <param name="inSchoolStatus"></param>
  36. /// <param name="needCardResult"></param>
  37. /// <param name="approvalStatus"></param>
  38. /// <param name="pageIndex"></param>
  39. /// <param name="pageSize"></param>
  40. /// <returns></returns>
  41. public IGridResultSet<GraduateCardApplyView> GetGraduateCardApproveViewGrid(ConfiguretView configuretView, Guid? gradSchoolyearID,
  42. Guid? campusID, Guid? collegeID, int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem,
  43. int? graduationTypeID, int? inSchoolStatus, int? needCardResult, int? approvalStatus, int pageIndex, int pageSize)
  44. {
  45. var approveStatusList = this.GetApproveStatusViewList();
  46. var approveStatusIDList = approveStatusList.Select(x => x.ID).ToList();
  47. //去向申请
  48. Expression<Func<ER_GraduateCardApply, bool>> expGraduateCardApply = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  49. expGraduateCardApply = expGraduateCardApply.And(x => approveStatusIDList.Contains(x.ApprovalStatus));
  50. if (gradSchoolyearID.HasValue)
  51. {
  52. //毕业学期(实际的毕业学期)
  53. expGraduateCardApply = expGraduateCardApply.And(x => x.GraduatingSemesterID == gradSchoolyearID);
  54. }
  55. if (graduationTypeID.HasValue)
  56. {
  57. //毕业类型
  58. expGraduateCardApply = expGraduateCardApply.And(x => x.GraduationTypeID == graduationTypeID);
  59. }
  60. if (needCardResult.HasValue)
  61. {
  62. //去向结论
  63. expGraduateCardApply = expGraduateCardApply.And(x => x.NeedCardResult == needCardResult);
  64. }
  65. if (approvalStatus.HasValue)
  66. {
  67. //审批状态
  68. expGraduateCardApply = expGraduateCardApply.And(x => x.ApprovalStatus == approvalStatus);
  69. }
  70. //学生信息
  71. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  72. if (inSchoolStatus != null && inSchoolStatus > -1)
  73. {
  74. var inschoolStatusList = InSchoolSettingServices.Value.GetInschoolStatusList(true);
  75. if (inSchoolStatus == 1)
  76. {
  77. //表示在校
  78. expStudent = expStudent.And(x => inschoolStatusList.Contains(x.InSchoolStatusID));
  79. }
  80. if (inSchoolStatus == 0)
  81. {
  82. //不在校
  83. expStudent = expStudent.And(x => !inschoolStatusList.Contains(x.InSchoolStatusID));
  84. }
  85. }
  86. var query = GraduateCardApplyDAL.GetGraduateCardApplyViewQueryable(expGraduateCardApply, expStudent);
  87. if (campusID.HasValue)
  88. {
  89. query = query.Where(x => x.CampusID == campusID);
  90. }
  91. if (collegeID.HasValue)
  92. {
  93. query = query.Where(x => x.CollegeID == collegeID);
  94. }
  95. if (yearID.HasValue)
  96. {
  97. query = query.Where(x => x.SchoolyearID == yearID);
  98. }
  99. if (standardID.HasValue)
  100. {
  101. query = query.Where(x => x.StandardID == standardID);
  102. }
  103. if (educationID.HasValue)
  104. {
  105. query = query.Where(x => x.EducationID == educationID);
  106. }
  107. if (learningformID.HasValue)
  108. {
  109. query = query.Where(x => x.LearningformID == learningformID);
  110. }
  111. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  112. {
  113. var LearnSystems = Convert.ToDecimal(learnSystem);
  114. query = query.Where(x => x.LearnSystem == LearnSystems);
  115. }
  116. //查询条件
  117. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  118. {
  119. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  120. }
  121. var result = this.GetQueryByDataRangeByCollege(query)
  122. .OrderBy(x => x.ClassNo.Length).ThenBy(x => x.ClassNo)
  123. .ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo)
  124. .ThenBy(x => x.GraduatingSemesterValue)
  125. .ToGridResultSet<GraduateCardApplyView>(pageIndex, pageSize);
  126. result.rows.ForEach(x => x.ApprovalStatusName = approveStatusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
  127. return result;
  128. }
  129. /// <summary>
  130. /// 查询去向审核信息List
  131. /// </summary>
  132. /// <param name="configuretView"></param>
  133. /// <param name="gradSchoolyearID"></param>
  134. /// <param name="campusID"></param>
  135. /// <param name="collegeID"></param>
  136. /// <param name="yearID"></param>
  137. /// <param name="standardID"></param>
  138. /// <param name="educationID"></param>
  139. /// <param name="learningformID"></param>
  140. /// <param name="learnSystem"></param>
  141. /// <param name="graduationTypeID"></param>
  142. /// <param name="inSchoolStatus"></param>
  143. /// <param name="needCardResult"></param>
  144. /// <param name="approvalStatus"></param>
  145. /// <returns></returns>
  146. public IList<GraduateCardApplyView> GetGraduateCardApproveViewList(ConfiguretView configuretView, Guid? gradSchoolyearID,
  147. Guid? campusID, Guid? collegeID, int? yearID, int? standardID, int? educationID, int? learningformID, string learnSystem,
  148. int? graduationTypeID, int? inSchoolStatus, int? needCardResult, int? approvalStatus)
  149. {
  150. var approveStatusList = this.GetApproveStatusViewList();
  151. var approveStatusIDList = approveStatusList.Select(x => x.ID).ToList();
  152. //去向申请
  153. Expression<Func<ER_GraduateCardApply, bool>> expGraduateCardApply = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  154. expGraduateCardApply = expGraduateCardApply.And(x => approveStatusIDList.Contains(x.ApprovalStatus));
  155. if (gradSchoolyearID.HasValue)
  156. {
  157. //毕业学期(实际的毕业学期)
  158. expGraduateCardApply = expGraduateCardApply.And(x => x.GraduatingSemesterID == gradSchoolyearID);
  159. }
  160. if (graduationTypeID.HasValue)
  161. {
  162. //毕业类型
  163. expGraduateCardApply = expGraduateCardApply.And(x => x.GraduationTypeID == graduationTypeID);
  164. }
  165. if (needCardResult.HasValue)
  166. {
  167. //去向结论
  168. expGraduateCardApply = expGraduateCardApply.And(x => x.NeedCardResult == needCardResult);
  169. }
  170. if (approvalStatus.HasValue)
  171. {
  172. //审批状态
  173. expGraduateCardApply = expGraduateCardApply.And(x => x.ApprovalStatus == approvalStatus);
  174. }
  175. //学生信息
  176. Expression<Func<CF_Student, bool>> expStudent = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  177. if (inSchoolStatus != null && inSchoolStatus > -1)
  178. {
  179. var inschoolStatusList = InSchoolSettingServices.Value.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 = GraduateCardApplyDAL.GetGraduateCardApplyViewQueryable(expGraduateCardApply, expStudent);
  192. if (campusID.HasValue)
  193. {
  194. query = query.Where(x => x.CampusID == campusID);
  195. }
  196. if (collegeID.HasValue)
  197. {
  198. query = query.Where(x => x.CollegeID == collegeID);
  199. }
  200. if (yearID.HasValue)
  201. {
  202. query = query.Where(x => x.SchoolyearID == yearID);
  203. }
  204. if (standardID.HasValue)
  205. {
  206. query = query.Where(x => x.StandardID == standardID);
  207. }
  208. if (educationID.HasValue)
  209. {
  210. query = query.Where(x => x.EducationID == educationID);
  211. }
  212. if (learningformID.HasValue)
  213. {
  214. query = query.Where(x => x.LearningformID == learningformID);
  215. }
  216. if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
  217. {
  218. var LearnSystems = Convert.ToDecimal(learnSystem);
  219. query = query.Where(x => x.LearnSystem == LearnSystems);
  220. }
  221. //查询条件
  222. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  223. {
  224. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  225. }
  226. var result = this.GetQueryByDataRangeByCollege(query)
  227. .OrderBy(x => x.ClassNo.Length).ThenBy(x => x.ClassNo)
  228. .ThenBy(x => x.StudentNo.Length).ThenBy(x => x.StudentNo)
  229. .ThenBy(x => x.GraduatingSemesterValue)
  230. .ToList();
  231. result.ForEach(x => x.ApprovalStatusName = approveStatusList.FirstOrDefault(w => w.ID == x.ApprovalStatus).Name);
  232. return result;
  233. }
  234. /// <summary>
  235. /// 查询对应的去向审核信息GraduateCardApplyView
  236. /// </summary>
  237. /// <param name="graduateCardApplyID"></param>
  238. /// <returns></returns>
  239. public GraduateCardApplyView GetGraduateCardApproveView(Guid? graduateCardApplyID)
  240. {
  241. try
  242. {
  243. var graduateCardApplyView = GraduateCardApplyDAL.GetGraduateCardApplyViewQueryable(x => x.GraduateCardApplyID == graduateCardApplyID)
  244. .SingleOrDefault();
  245. return graduateCardApplyView;
  246. }
  247. catch (Exception ex)
  248. {
  249. throw new Exception(ex.Message);
  250. }
  251. }
  252. /// <summary>
  253. /// 查询对应的流程环节动作List(ActionView)
  254. /// </summary>
  255. /// <param name="formID"></param>
  256. /// <param name="userID"></param>
  257. /// <returns></returns>
  258. public List<ActionView> GetAuditingActionView(Guid formID, Guid userID)
  259. {
  260. throw new NotImplementedException();
  261. }
  262. /// <summary>
  263. /// 删除
  264. /// </summary>
  265. /// <param name="graduateCardApplyIDs"></param>
  266. /// <returns></returns>
  267. public bool GraduateCardApproveDelete(List<Guid?> graduateCardApplyIDs)
  268. {
  269. try
  270. {
  271. using (TransactionScope ts = new TransactionScope())
  272. {
  273. UnitOfWork.Delete<ER_GraduateCardApplyAttachment>(x => graduateCardApplyIDs.Contains(x.GraduateCardApplyID));
  274. UnitOfWork.Delete<ER_GraduateCardApply>(x => graduateCardApplyIDs.Contains(x.GraduateCardApplyID));
  275. ts.Complete();
  276. return true;
  277. }
  278. }
  279. catch (Exception)
  280. {
  281. throw;
  282. }
  283. }
  284. /// <summary>
  285. /// 审核确定(批量)
  286. /// </summary>
  287. /// <param name="graduateCardApplyIDs"></param>
  288. /// <param name="userID"></param>
  289. /// <param name="actionID"></param>
  290. /// <param name="comment"></param>
  291. public void GraduateCardApproveConfirm(List<Guid?> graduateCardApplyIDs, Guid userID, Guid actionID, string comment)
  292. {
  293. throw new NotImplementedException();
  294. }
  295. }
  296. }