MinorConditionServices.cs 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.MinorManage.MinorSetting;
  6. using Bowin.Common.Linq.Entity;
  7. using EMIS.ViewModel;
  8. using EMIS.ViewModel.MinorManage.MinorSetting;
  9. using System.Linq.Expressions;
  10. using Bowin.Common.Linq;
  11. using EMIS.Entities;
  12. using EMIS.ViewModel.ScoreManage;
  13. namespace EMIS.CommonLogic.MinorManage.MinorSetting
  14. {
  15. public class MinorConditionServices : BaseServices, IMinorConditionServices
  16. {
  17. public MinorConditionDAL minorConditionDAL { get; set; }
  18. /// <summary>
  19. /// 查询辅修条件列表
  20. /// </summary>
  21. /// <param name="configuretView"></param>
  22. /// <param name="isCurrent"></param>
  23. /// <param name="pageIndex"></param>
  24. /// <param name="pageSize"></param>
  25. /// <returns></returns>
  26. public IGridResultSet<MinorConditionView> MinorConditionViewGrid(ConfiguretView configuretView, int? isCurrent, int pageIndex, int pageSize)
  27. {
  28. Expression<Func<ER_MinorCondition, bool>> exp = (x => true);
  29. if (isCurrent.HasValue)
  30. {
  31. if (isCurrent == 1)
  32. {
  33. exp = exp.And(x => x.RecordStatus >= (int)SYS_STATUS.USABLE);
  34. }
  35. if (isCurrent == 0)
  36. {
  37. exp = exp.And(x => x.RecordStatus <= (int)SYS_STATUS.UNUSABLE);
  38. }
  39. }
  40. var query = minorConditionDAL.GetMinorConditionViewQueryable(exp);
  41. //查询条件
  42. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  43. {
  44. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  45. }
  46. return query.OrderBy(x => x.Title).ToGridResultSet<MinorConditionView>(pageIndex, pageSize);
  47. }
  48. /// <summary>
  49. /// 查询辅修信息(Excel)
  50. /// </summary>
  51. /// <param name="configuretView"></param>
  52. /// <param name="isCurrent"></param>
  53. /// <param name="idList"></param>
  54. /// <returns></returns>
  55. public List<MinorConditionView> GetMinorConditionViewList(ConfiguretView configuretView, int? isCurrent, List<Guid?> idList)
  56. {
  57. //毕业条件
  58. Expression<Func<ER_MinorCondition, bool>> exp = (x => true);
  59. if (isCurrent.HasValue)
  60. {
  61. if (isCurrent == 1)
  62. {
  63. exp = exp.And(x => x.RecordStatus >= (int)SYS_STATUS.USABLE);
  64. }
  65. if (isCurrent == 0)
  66. {
  67. exp = exp.And(x => x.RecordStatus <= (int)SYS_STATUS.UNUSABLE);
  68. }
  69. }
  70. if (idList.Count > 0 && idList != null)
  71. {
  72. exp = exp.And(x => idList.Contains(x.MinorConditionID));
  73. }
  74. var query = minorConditionDAL.GetMinorConditionViewQueryable(exp);
  75. //查询条件
  76. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  77. {
  78. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  79. }
  80. return query.OrderBy(x => x.Title).ToList();
  81. }
  82. /// <summary>
  83. /// 查询辅修条件(根据ID)
  84. /// </summary>
  85. /// <param name="minorConditionID"></param>
  86. /// <returns></returns>
  87. public MinorConditionView GetMinorConditionView(Guid? minorConditionID)
  88. {
  89. try
  90. {
  91. var query = minorConditionDAL
  92. .GetMinorConditionViewQueryable(x => x.MinorConditionID == minorConditionID)
  93. .SingleOrDefault();
  94. return query;
  95. }
  96. catch (Exception ex)
  97. {
  98. throw new Exception(ex.Message);
  99. }
  100. }
  101. /// <summary>
  102. /// 辅修条件编辑(新增、修改)
  103. /// </summary>
  104. /// <param name="minorConditionView"></param>
  105. public void MinorConditionEdit(MinorConditionView minorConditionView)
  106. {
  107. try
  108. {
  109. ER_MinorCondition minorCondition = new ER_MinorCondition();
  110. if (minorConditionView.MinorConditionID == null || minorConditionView.MinorConditionID == Guid.Empty)
  111. {
  112. //新增、复制新增
  113. minorCondition = minorConditionDAL.minorConditionRepository
  114. .GetSingle(x => x.Title == minorConditionView.Title);
  115. if (minorCondition != null)
  116. {
  117. throw new Exception("已存在相同的辅修条件。");
  118. }
  119. minorCondition = new ER_MinorCondition();
  120. minorCondition.MinorConditionID = Guid.NewGuid();
  121. minorCondition.Title = minorConditionView.Title;
  122. minorCondition.RecordStatus = minorConditionView.IsEnable ? 1 : 0;
  123. minorCondition.CreateTime = DateTime.Now;
  124. minorCondition.CreateUserID = EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID;
  125. minorCondition.ModifyTime = DateTime.Now;
  126. minorCondition.ModifyUserID = EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID;
  127. UnitOfWork.Add(minorCondition);
  128. }
  129. else
  130. {
  131. //修改
  132. minorCondition = minorConditionDAL.minorConditionRepository
  133. .GetSingle(x => x.MinorConditionID != minorConditionView.MinorConditionID
  134. && x.Title == minorConditionView.Title && x.MethodFullName == minorConditionView.MethodFullName);
  135. if (minorCondition != null)
  136. {
  137. throw new Exception("已存在相同的辅修条件。");
  138. }
  139. minorCondition = minorConditionDAL.minorConditionRepository
  140. .GetSingle(x => x.MinorConditionID == minorConditionView.MinorConditionID);
  141. if (minorCondition == null)
  142. {
  143. throw new Exception("数据有误,请核查。");
  144. }
  145. minorCondition.Title = minorConditionView.Title;
  146. minorCondition.RecordStatus = minorConditionView.IsEnable ? 1 : 0;
  147. minorCondition.ModifyTime = DateTime.Now;
  148. minorCondition.ModifyUserID = EMIS.Utility.FormValidate.CustomPrincipal.Current.UserID;
  149. }
  150. UnitOfWork.Commit();
  151. }
  152. catch (Exception ex)
  153. {
  154. throw new Exception(ex.Message);
  155. }
  156. }
  157. /// <summary>
  158. /// 辅修条件删除
  159. /// </summary>
  160. /// <param name="minorConditionIDList"></param>
  161. public void MinorConditionDelete(IList<Guid?> minorConditionIDList)
  162. {
  163. try
  164. {
  165. if (minorConditionIDList.Count > 0)
  166. {
  167. UnitOfWork.Delete<ER_MinorCondition>(x => minorConditionIDList.Contains(x.MinorConditionID));
  168. }
  169. }
  170. catch (Exception ex)
  171. {
  172. throw new Exception(ex.Message);
  173. }
  174. }
  175. /// <summary>
  176. /// 成绩全部及格
  177. /// </summary>
  178. /// <param name="userID"></param>
  179. /// <returns></returns>
  180. public bool AllPass(Guid userID)
  181. {
  182. List<StudentScoreView> scoreList = new List<StudentScoreView>();
  183. if (minorConditionDAL.GetAllScore(userID) != null)
  184. {
  185. scoreList = minorConditionDAL.GetAllScore(userID).ToList();
  186. if (scoreList.Any(x => x.TotalScore < 60))
  187. {
  188. return false;
  189. }
  190. }
  191. return true;
  192. }
  193. /// <summary>
  194. /// 没有补考记录
  195. /// </summary>
  196. /// <param name="userID"></param>
  197. /// <returns></returns>
  198. public bool NotResit(Guid userID)
  199. {
  200. List<StudentScoreView> scoreList = new List<StudentScoreView>();
  201. if (minorConditionDAL.GetAllScore(userID) != null)
  202. {
  203. scoreList = minorConditionDAL.GetAllScore(userID).ToList();
  204. if (scoreList.Any(x => x.ExamsCategoryID == (int)CF_ExamsCategory.Resit))
  205. {
  206. return false;
  207. }
  208. }
  209. return true;
  210. }
  211. }
  212. }