MinorApplyServices.cs 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355
  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.MinorManage.MinorApply;
  7. using EMIS.ViewModel;
  8. using EMIS.DataLogic.MinorManage.MinorApply;
  9. using System.Linq.Expressions;
  10. using EMIS.Entities;
  11. using Bowin.Common.Linq;
  12. using EMIS.CommonLogic.SystemServices;
  13. using EMIS.DataLogic.MinorManage.MinorClass;
  14. namespace EMIS.CommonLogic.MinorManage.MinorApply
  15. {
  16. public class MinorApplyServices : BaseWorkflowServices<EM_StudentMinorRegist>, IMinorApplyServices
  17. {
  18. public MinorApplyDAL minorApplyDAL { get; set; }
  19. public MinorClassDAL minorClassDAL { get; set; }
  20. /// <summary>
  21. /// 辅修报名审核
  22. /// </summary>
  23. /// <param name="configuretView"></param>
  24. /// <param name="schoolyearID"></param>
  25. /// <param name="collegeID"></param>
  26. /// <param name="yearID"></param>
  27. /// <param name="standardID"></param>
  28. /// <param name="classmajorID"></param>
  29. /// <param name="minorStandardID"></param>
  30. /// <param name="pageIndex"></param>
  31. /// <param name="pageSize"></param>
  32. /// <returns></returns>
  33. public IGridResultSet<MinorApplyView> MinorApplyViewGrid(ConfiguretView configuretView, Guid? schoolyearID, Guid? collegeID, int? yearID, int? standardID, Guid? classmajorID, int? minorStandardID, int? approvalStatus, int pageIndex, int pageSize)
  34. {
  35. //结束流程环节ID
  36. var endStatusID = this.GetCorrectEndStatus();
  37. //审核流程状态IDList
  38. var approveStatusIDList = this.GetApproveStatusViewList()
  39. .Select(x => x.ID).ToList();
  40. var applyStatusList = this.GetStatusViewList();
  41. var applyStatusIDList = applyStatusList.Where(x => x.ID != endStatusID && !approveStatusIDList.Contains(x.ID))
  42. .Select(x => x.ID).ToList();
  43. Expression<Func<EM_StudentMinorRegist, bool>> exp = x => true;
  44. Expression<Func<CF_Classmajor, bool>> expcla = x => true;
  45. Expression<Func<CF_College, bool>> expcol = x => true;
  46. if (schoolyearID.HasValue)
  47. {
  48. exp = exp.And(x => x.SchoolyearID == schoolyearID);
  49. }
  50. if (collegeID.HasValue)
  51. {
  52. expcol = expcol.And(x => x.CollegeID == collegeID);
  53. }
  54. if (yearID.HasValue)
  55. {
  56. expcla = expcla.And(x => x.CF_Grademajor.GradeID == yearID);
  57. }
  58. if (standardID.HasValue)
  59. {
  60. expcla = expcla.And(x => x.CF_Grademajor.CF_Facultymajor.StandardID == standardID);
  61. }
  62. if (classmajorID.HasValue)
  63. {
  64. expcla = expcla.And(x => x.ClassmajorID == classmajorID);
  65. }
  66. if (minorStandardID.HasValue)
  67. {
  68. exp = exp.And(x => x.CF_Grademinor.StandardID == minorStandardID);
  69. }
  70. if (approvalStatus.HasValue && approvalStatus > (int)SYS_STATUS.UNUSABLE)
  71. {
  72. exp = exp.And(x => x.RecordStatus == approvalStatus);
  73. }
  74. var query = minorApplyDAL.GetMinorApplyViewQueryable(exp, expcla, expcol);
  75. //查询条件
  76. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  77. {
  78. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  79. }
  80. var result = this.GetQueryByDataRangeByCollege(query).OrderByDescending(x => x.SchoolyearCode).ThenBy(x => x.GrademajorCode).ThenBy(x => x.GrademinorCode).ThenBy(x => x.LoginID).ToGridResultSet<MinorApplyView>(pageIndex, pageSize);
  81. result.rows.ForEach(x => x.RecordStatusStr = applyStatusList.FirstOrDefault(w => w.ID == x.RecordStatus).Name);
  82. return result;
  83. }
  84. /// <summary>
  85. /// 辅修报名(Excel)
  86. /// </summary>
  87. /// <param name="configuretView"></param>
  88. /// <param name="schoolyearID"></param>
  89. /// <param name="collegeID"></param>
  90. /// <param name="yearID"></param>
  91. /// <param name="standardID"></param>
  92. /// <param name="classmajorID"></param>
  93. /// <param name="minorStandardID"></param>
  94. /// <param name="idList"></param>
  95. /// <returns></returns>
  96. public List<MinorApplyView> GetMinorApplyViewList(ConfiguretView configuretView, Guid? schoolyearID, Guid? collegeID, int? yearID, int? standardID, Guid? classmajorID, int? minorStandardID, int? approvalStatus, List<Guid?> idList)
  97. {
  98. //结束流程环节ID
  99. var endStatusID = this.GetCorrectEndStatus();
  100. //审核流程状态IDList
  101. var approveStatusIDList = this.GetApproveStatusViewList()
  102. .Select(x => x.ID).ToList();
  103. var applyStatusList = this.GetStatusViewList();
  104. var applyStatusIDList = applyStatusList.Where(x => x.ID != endStatusID && !approveStatusIDList.Contains(x.ID))
  105. .Select(x => x.ID).ToList();
  106. Expression<Func<EM_StudentMinorRegist, bool>> exp = x => true;
  107. Expression<Func<CF_Classmajor, bool>> expcla = x => true;
  108. Expression<Func<CF_College, bool>> expcol = x => true;
  109. if (schoolyearID.HasValue)
  110. {
  111. exp = exp.And(x => x.SchoolyearID == schoolyearID);
  112. }
  113. if (collegeID.HasValue)
  114. {
  115. expcol = expcol.And(x => x.CollegeID == collegeID);
  116. }
  117. if (yearID.HasValue)
  118. {
  119. expcla = expcla.And(x => x.CF_Grademajor.GradeID == yearID);
  120. }
  121. if (standardID.HasValue)
  122. {
  123. expcla = expcla.And(x => x.CF_Grademajor.CF_Facultymajor.StandardID == standardID);
  124. }
  125. if (classmajorID.HasValue)
  126. {
  127. expcla = expcla.And(x => x.ClassmajorID == classmajorID);
  128. }
  129. if (minorStandardID.HasValue)
  130. {
  131. exp = exp.And(x => x.CF_Grademinor.StandardID == minorStandardID);
  132. }
  133. if (approvalStatus.HasValue && approvalStatus > (int)SYS_STATUS.UNUSABLE)
  134. {
  135. exp = exp.And(x => x.RecordStatus == approvalStatus);
  136. }
  137. if (idList.Count > 0 && idList != null)
  138. {
  139. exp = exp.And(x => idList.Contains(x.StudentMinorRegistID));
  140. }
  141. var query = minorApplyDAL.GetMinorApplyViewQueryable(exp, expcla, expcol);
  142. //查询条件
  143. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  144. {
  145. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  146. }
  147. var result = this.GetQueryByDataRangeByCollege(query).OrderByDescending(x => x.SchoolyearCode).ThenBy(x => x.GrademajorCode).ThenBy(x => x.GrademinorCode).ThenBy(x => x.LoginID).ToList();
  148. result.ForEach(x => x.RecordStatusStr = applyStatusList.FirstOrDefault(w => w.ID == x.RecordStatus).Name);
  149. return result;
  150. }
  151. public void MinorApplyEdit(MinorApplyView minorApplyView)
  152. {
  153. try
  154. {
  155. EM_StudentMinorRegist studentMinorRegist = new EM_StudentMinorRegist();
  156. if (minorApplyView.StudentMinorRegistID == null || minorApplyView.StudentMinorRegistID == Guid.Empty)
  157. {
  158. //新增、复制新增
  159. studentMinorRegist = minorApplyDAL.studentMinorRegistRepository
  160. .GetSingle(x => x.SchoolyearID == minorApplyView.SchoolyearID && x.UserID == minorApplyView.CollegeID && x.GrademinorID == minorApplyView.GrademinorID);
  161. if (studentMinorRegist != null)
  162. {
  163. throw new Exception("该学生已存在相同学年学期的辅修报名信息。");
  164. }
  165. studentMinorRegist = new EM_StudentMinorRegist();
  166. studentMinorRegist.StudentMinorRegistID = Guid.NewGuid();
  167. studentMinorRegist.GrademinorID = minorApplyView.GrademinorID;
  168. studentMinorRegist.SchoolyearID = minorApplyView.SchoolyearID;
  169. studentMinorRegist.UserID = minorApplyView.UserID;
  170. studentMinorRegist.CreateTime = DateTime.Now;
  171. studentMinorRegist.CreateUserID = EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID;
  172. studentMinorRegist.ModifyTime = DateTime.Now;
  173. studentMinorRegist.ModifyUserID = EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID;
  174. UnitOfWork.Add(studentMinorRegist);
  175. }
  176. else
  177. {
  178. //修改
  179. studentMinorRegist = minorApplyDAL.studentMinorRegistRepository
  180. .GetSingle(x => x.StudentMinorRegistID != minorApplyView.StudentMinorRegistID
  181. && x.SchoolyearID == minorApplyView.SchoolyearID && x.UserID == minorApplyView.CollegeID && x.GrademinorID == minorApplyView.GrademinorID);
  182. if (studentMinorRegist != null)
  183. {
  184. throw new Exception("该学生已存在相同学年学期的辅修报名信息。");
  185. }
  186. studentMinorRegist = minorApplyDAL.studentMinorRegistRepository
  187. .GetSingle(x => x.StudentMinorRegistID == minorApplyView.StudentMinorRegistID);
  188. if (studentMinorRegist == null)
  189. {
  190. throw new Exception("数据有误,请核查。");
  191. }
  192. studentMinorRegist = new EM_StudentMinorRegist();
  193. studentMinorRegist.StudentMinorRegistID = Guid.NewGuid();
  194. studentMinorRegist.GrademinorID = minorApplyView.GrademinorID;
  195. studentMinorRegist.SchoolyearID = minorApplyView.SchoolyearID;
  196. studentMinorRegist.UserID = minorApplyView.UserID;
  197. studentMinorRegist.ModifyTime = DateTime.Now;
  198. studentMinorRegist.ModifyUserID = EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID;
  199. }
  200. UnitOfWork.Commit();
  201. }
  202. catch (Exception ex)
  203. {
  204. throw new Exception(ex.Message);
  205. }
  206. }
  207. /// <summary>
  208. /// 删除
  209. /// </summary>
  210. /// <param name="minorApplyIDList"></param>
  211. public void MinorApplyDelete(IList<Guid?> minorApplyIDList)
  212. {
  213. try
  214. {
  215. if (minorApplyIDList.Count > 0)
  216. {
  217. UnitOfWork.Delete<EM_StudentMinorRegist>(x => minorApplyIDList.Contains(x.StudentMinorRegistID));
  218. }
  219. }
  220. catch (Exception ex)
  221. {
  222. throw new Exception(ex.Message);
  223. }
  224. }
  225. public MinorApplyView GetMinorApplyView(Guid? minorApplyID)
  226. {
  227. try
  228. {
  229. var minorApplyView = minorApplyDAL.GetMinorApplyViewQueryable(x => x.StudentMinorRegistID == minorApplyID, x => true, x => true)
  230. .SingleOrDefault();
  231. return minorApplyView;
  232. }
  233. catch (Exception ex)
  234. {
  235. throw new Exception(ex.Message);
  236. }
  237. }
  238. public void MinorApproveConfirm(List<Guid?> minorApplyIDs, Guid userID, Guid actionID, string comment)
  239. {
  240. try
  241. {
  242. //查询对应的审核信息List
  243. var minorApplyList = minorApplyDAL.studentMinorRegistRepository
  244. .GetList(x => minorApplyIDs.Contains(x.StudentMinorRegistID)).ToList();
  245. var endStatusID = this.GetCorrectEndStatus();
  246. foreach (var minorApplyID in minorApplyIDs)
  247. {
  248. //查询对应的审核信息
  249. var minorApply = minorApplyList.Where(x => x.StudentMinorRegistID == minorApplyID).SingleOrDefault();
  250. if (minorApply == null)
  251. {
  252. throw new Exception("数据有误,请核查");
  253. }
  254. }
  255. //审核
  256. this.Approve(minorApplyIDs.Select(x => x.Value).ToList(), userID, actionID, comment);
  257. }
  258. catch (Exception ex)
  259. {
  260. throw new Exception(ex.Message);
  261. }
  262. }
  263. /// <summary>
  264. /// 查询辅修专业,下拉框用
  265. /// </summary>
  266. /// <param name="configuretView"></param>
  267. /// <returns></returns>
  268. public IGridResultSet<MinorApplyView> GetGrademinorGrid(ConfiguretView configuretView)
  269. {
  270. return null;
  271. }
  272. public void OnApproveEnd(IList<Guid> studentMinorRegistIDList, Guid? userID)
  273. {
  274. try
  275. {
  276. Expression<Func<EM_StudentMinorRegist, bool>> exp = x => true;
  277. Expression<Func<CF_Classmajor, bool>> expcla = x => true;
  278. Expression<Func<CF_College, bool>> expcol = x => true;
  279. if (studentMinorRegistIDList.Count > 0)
  280. {
  281. exp = exp.And(x => studentMinorRegistIDList.Contains(x.StudentMinorRegistID));
  282. }
  283. var query = minorApplyDAL.GetMinorApplyViewQueryable(exp, expcla, expcol).ToList();
  284. foreach (var studentMinor in query)
  285. {
  286. var classMinor = minorClassDAL.classminorRepository.GetSingle(x => x.GrademinorID == studentMinor.GrademinorID && x.RecordStatus == (int)SYS_STATUS.USABLE, (x => x.CF_ClassminorStudent));
  287. if (classMinor == null)
  288. {
  289. return;
  290. }
  291. var classmionrStudent = new CF_ClassminorStudent();
  292. classmionrStudent.ClassminorStudentID = Guid.NewGuid();
  293. classmionrStudent.ClassminorID = classMinor.ClassminorID;
  294. classmionrStudent.UserID = studentMinor.UserID.Value;
  295. SetNewStatus(classmionrStudent);
  296. classMinor.CF_ClassminorStudent.Add(classmionrStudent);
  297. }
  298. UnitOfWork.Commit();
  299. }
  300. catch (Exception)
  301. {
  302. throw;
  303. }
  304. }
  305. }
  306. }