MinorGraduationConditionServices.cs 9.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239
  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.MinorGraduationSetting;
  7. using EMIS.ViewModel;
  8. using System.Linq.Expressions;
  9. using EMIS.Entities;
  10. using Bowin.Common.Linq;
  11. using EMIS.DataLogic.MinorGraduation.MinorGraduationSetting;
  12. using EMIS.CommonLogic.ChargeManage.ArrearsSituation;
  13. namespace EMIS.CommonLogic.MinorGraduation.MinorGraduationSetting
  14. {
  15. public class MinorGraduationConditionServices : BaseServices, IMinorGraduationConditionServices
  16. {
  17. public MinorGraduationConditionDAL minorGraduationConditionDAL { get; set; }
  18. public MinorGraduationStandardDAL minorGraduationStandardDAL { get; set; }
  19. public IArrearsListServices arrearsListServices { get; set; }
  20. /// <summary>
  21. /// 查询辅修条件
  22. /// </summary>
  23. /// <param name="configuretView"></param>
  24. /// <param name="isCurrent"></param>
  25. /// <param name="pageIndex"></param>
  26. /// <param name="pageSize"></param>
  27. /// <returns></returns>
  28. public IGridResultSet<MinorGraduationConditionView> GetMinorGraduationConditionViewGrid(ConfiguretView configuretView, int? isCurrent, int pageIndex, int pageSize)
  29. {
  30. //辅修毕业条件
  31. Expression<Func<ER_MinorGraduationCondition, bool>> exp = (x => true);
  32. if (isCurrent.HasValue)
  33. {
  34. if (isCurrent == 1)
  35. {
  36. exp = exp.And(x => x.RecordStatus >= (int)SYS_STATUS.USABLE);
  37. }
  38. if (isCurrent == 0)
  39. {
  40. exp = exp.And(x => x.RecordStatus <= (int)SYS_STATUS.UNUSABLE);
  41. }
  42. }
  43. var query = minorGraduationConditionDAL.GetMinorGraduationConditionQueryable(exp);
  44. //查询条件
  45. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  46. {
  47. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  48. }
  49. return query.OrderBy(x => x.Title.Length).OrderBy(x => x.Title).ToGridResultSet<MinorGraduationConditionView>(pageIndex, pageSize);
  50. }
  51. public List<MinorGraduationConditionView> GetGraduationViewList(ConfiguretView configuretView, int? isCurrent, List<Guid?> idList)
  52. {
  53. //毕业条件
  54. Expression<Func<ER_MinorGraduationCondition, bool>> exp = (x => true);
  55. if (isCurrent.HasValue)
  56. {
  57. if (isCurrent == 1)
  58. {
  59. exp = exp.And(x => x.RecordStatus >= (int)SYS_STATUS.USABLE);
  60. }
  61. if (isCurrent == 0)
  62. {
  63. exp = exp.And(x => x.RecordStatus <= (int)SYS_STATUS.UNUSABLE);
  64. }
  65. }
  66. if (idList != null && idList.Count > 0)
  67. {
  68. exp = exp.And(x => idList.Contains(x.MinorGraduationConditionID));
  69. }
  70. var query = minorGraduationConditionDAL.GetMinorGraduationConditionQueryable(exp);
  71. //查询条件
  72. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  73. {
  74. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  75. }
  76. return query.OrderBy(x => x.Title.Length).OrderBy(x => x.Title).ToList();
  77. }
  78. /// <summary>
  79. /// 查询单个辅修条件
  80. /// </summary>
  81. /// <param name="minorGraduationConditionID"></param>
  82. /// <returns></returns>
  83. public MinorGraduationConditionView GetMinorGraduationConditionView(Guid? minorGraduationConditionID)
  84. {
  85. try
  86. {
  87. var query = minorGraduationConditionDAL
  88. .GetMinorGraduationConditionQueryable(x => x.MinorGraduationConditionID == minorGraduationConditionID)
  89. .SingleOrDefault();
  90. return query;
  91. }
  92. catch (Exception ex)
  93. {
  94. throw new Exception(ex.Message);
  95. }
  96. }
  97. /// <summary>
  98. /// 编辑
  99. /// </summary>
  100. /// <param name="graduationConditionView"></param>
  101. public void MinorGraduationConditionEdit(MinorGraduationConditionView minorGraduationConditionView)
  102. {
  103. try
  104. {
  105. //查询数据库进行验证
  106. var minorGraduationConditionVerification = minorGraduationConditionDAL.minorGraduationConditionRepository
  107. .GetList(x => x.MinorGraduationConditionID != minorGraduationConditionView.MinorGraduationConditionID
  108. && x.Title == minorGraduationConditionView.Title)
  109. .SingleOrDefault();
  110. if (minorGraduationConditionVerification == null)
  111. {
  112. //数据有误验证
  113. if (minorGraduationConditionVerification.MinorGraduationConditionID != Guid.Empty)
  114. {
  115. var graduationCondition = minorGraduationConditionDAL.minorGraduationConditionRepository
  116. .GetList(x => x.MinorGraduationConditionID == minorGraduationConditionView.MinorGraduationConditionID)
  117. .SingleOrDefault();
  118. if (graduationCondition == null)
  119. {
  120. throw new Exception("数据有误,请核查");
  121. }
  122. else
  123. {
  124. //表示修改
  125. graduationCondition.Title = minorGraduationConditionView.Title;
  126. graduationCondition.RecordStatus = minorGraduationConditionView.IsEnable ? (int)SYS_STATUS.USABLE : (int)SYS_STATUS.UNUSABLE;
  127. SetModifyStatus(graduationCondition);
  128. }
  129. }
  130. else
  131. {
  132. //表示新增
  133. ER_MinorGraduationCondition minorGraduationCondition = new ER_MinorGraduationCondition();
  134. minorGraduationCondition.MinorGraduationConditionID = Guid.NewGuid();
  135. minorGraduationCondition.Title = minorGraduationConditionView.Title;
  136. minorGraduationCondition.MethodFullName = minorGraduationConditionView.MethodFullName;
  137. SetNewStatus(minorGraduationConditionView);
  138. UnitOfWork.Add(minorGraduationConditionView);
  139. }
  140. }
  141. else
  142. {
  143. throw new Exception("已存在相同条件名称的辅修毕业条件,请核查");
  144. }
  145. //事务提交
  146. UnitOfWork.Commit();
  147. }
  148. catch (Exception ex)
  149. {
  150. throw new Exception(ex.Message);
  151. }
  152. }
  153. /// <summary>
  154. /// 所学学分达到专业要求学分
  155. /// </summary>
  156. /// <param name="userID"></param>
  157. /// <returns></returns>
  158. public bool PassGraduationCredit(Guid? userID)
  159. {
  160. try
  161. {
  162. var minorGraduationStandard = minorGraduationStandardDAL.GetMinorGraduationStandardViewByUserID(userID);
  163. if (minorGraduationStandard.FirstOrDefault() == null)
  164. {
  165. throw new Exception("未设置学生所在辅修专业的辅修专业标准");
  166. }
  167. else {
  168. var graduationCredit = minorGraduationStandard.FirstOrDefault().GraduationCredit;
  169. var studentScore = minorGraduationConditionDAL.GetFinallyScoreViewQueryableByUserID(userID);
  170. var scoreCredit = studentScore.Sum(x => x.ScoreCredit);
  171. if (scoreCredit != null && scoreCredit >= graduationCredit)
  172. {
  173. return true;
  174. }
  175. }
  176. return false;
  177. }
  178. catch (Exception)
  179. {
  180. throw;
  181. }
  182. }
  183. /// <summary>
  184. /// 没有欠费
  185. /// </summary>
  186. /// <param name="userID"></param>
  187. /// <returns></returns>
  188. public bool NotArrearManage(Guid? userID)
  189. {
  190. try
  191. {
  192. var arrearListView = arrearsListServices.GetArrearListView(userID);
  193. if (arrearListView == null)
  194. {
  195. return true;
  196. }
  197. else
  198. {
  199. return false;
  200. }
  201. }
  202. catch (Exception ex)
  203. {
  204. throw new Exception(ex.Message);
  205. }
  206. }
  207. /// <summary>
  208. /// 无条件(测试)
  209. /// </summary>
  210. /// <param name="userID"></param>
  211. /// <returns></returns>
  212. public bool NotCondition(Guid? userID)
  213. {
  214. return true;
  215. }
  216. }
  217. }