GraduateCardListServices.cs 13 KB

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