MinorGraduationStandardServices.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251
  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;
  7. using EMIS.ViewModel.MinorGraduation.MinorGraduationSetting;
  8. using System.Linq.Expressions;
  9. using EMIS.Entities;
  10. using Bowin.Common.Linq;
  11. using EMIS.DataLogic.MinorGraduation.MinorGraduationSetting;
  12. using EMIS.DataLogic.MinorManage.MinorPlanManage;
  13. namespace EMIS.CommonLogic.MinorGraduation.MinorGraduationSetting
  14. {
  15. public class MinorGraduationStandardServices : BaseServices, IMinorGraduationStandardServices
  16. {
  17. public MinorGraduationStandardDAL minorGraduationStandardDAL { get; set; }
  18. public MinorSpecialtyDAL minorSpecialtyDAL { get; set; }
  19. /// <summary>
  20. /// 辅修毕业要求列表信息
  21. /// </summary>
  22. /// <param name="configuretView"></param>
  23. /// <param name="collegeID"></param>
  24. /// <param name="yearID"></param>
  25. /// <param name="standardID"></param>
  26. /// <param name="pageIndex"></param>
  27. /// <param name="pageSize"></param>
  28. /// <returns></returns>
  29. public IGridResultSet<MinorGraduationStandardView> GetMinorGraduationStandardViewGrid(ConfiguretView configuretView, Guid? collegeID, int? yearID, int? standardID, int pageIndex, int pageSize)
  30. {
  31. Expression<Func<ER_MinorGraduationStandard, bool>> exp = x => true;
  32. if (collegeID.HasValue)
  33. {
  34. exp = exp.And(x => x.CollegeID == collegeID);
  35. }
  36. if (yearID.HasValue)
  37. {
  38. exp = exp.And(x => x.YearID == yearID);
  39. }
  40. if (standardID.HasValue)
  41. {
  42. exp = exp.And(x => x.StandardID == standardID);
  43. }
  44. var query = minorGraduationStandardDAL.GetMinorGraduationStandardView(exp);
  45. //查询条件
  46. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  47. {
  48. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  49. }
  50. return this.GetQueryByDataRangeByCollege(query)
  51. .OrderByDescending(x => x.YearID).OrderBy(x => x.StandardID)
  52. .ToGridResultSet<MinorGraduationStandardView>(pageIndex, pageSize);
  53. }
  54. /// <summary>
  55. /// 辅修毕业要求列表信息(Excel)
  56. /// </summary>
  57. /// <param name="configuretView"></param>
  58. /// <param name="collegeID"></param>
  59. /// <param name="yearID"></param>
  60. /// <param name="standardID"></param>
  61. /// <param name="idList"></param>
  62. /// <returns></returns>
  63. public List<MinorGraduationStandardView> GetMinorGraduationStandardViewList(ConfiguretView configuretView, Guid? collegeID, int? yearID, int? standardID, List<Guid?> idList)
  64. {
  65. Expression<Func<ER_MinorGraduationStandard, bool>> exp = x => true;
  66. if (collegeID.HasValue)
  67. {
  68. exp = exp.And(x => x.CollegeID == collegeID);
  69. }
  70. if (yearID.HasValue)
  71. {
  72. exp = exp.And(x => x.YearID == yearID);
  73. }
  74. if (standardID.HasValue)
  75. {
  76. exp = exp.And(x => x.StandardID == standardID);
  77. }
  78. if (idList != null && idList.Count > 0)
  79. {
  80. exp = exp.And(x => idList.Contains(x.MinorGraduationStandardID));
  81. }
  82. var query = minorGraduationStandardDAL.GetMinorGraduationStandardView(exp);
  83. //查询条件
  84. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  85. {
  86. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  87. }
  88. return this.GetQueryByDataRangeByCollege(query).OrderByDescending(x => x.YearID).OrderBy(x => x.StandardID).ToList();
  89. }
  90. /// <summary>
  91. /// 查询单个辅修毕业要求
  92. /// </summary>
  93. /// <param name="GraduationStandardID"></param>
  94. /// <returns></returns>
  95. public MinorGraduationStandardView GetMinorGraduationStandardView(Guid? minorGraduationStandardID)
  96. {
  97. try
  98. {
  99. var query = minorGraduationStandardDAL.GetMinorGraduationStandardView(x => x.MinorGraduationStandardID == minorGraduationStandardID)
  100. .SingleOrDefault();
  101. return query;
  102. }
  103. catch (Exception ex)
  104. {
  105. throw new Exception(ex.Message);
  106. }
  107. }
  108. /// <summary>
  109. /// 生成
  110. /// </summary>
  111. /// <param name="yearID"></param>
  112. public void MinorGraduationStandardGenerate(int? yearID, Guid? collegeID)
  113. {
  114. try
  115. {
  116. Expression<Func<CF_Grademinor, bool>> exp = x => true;
  117. exp = exp.And(x => x.RecordStatus == (int)CF_GrademinorStatus.Opened || x.RecordStatus == (int)CF_GrademinorStatus.Confirmed);
  118. if (yearID.HasValue)
  119. {
  120. exp = exp.And(x => x.YearID == yearID);
  121. }
  122. if (collegeID.HasValue)
  123. {
  124. exp = exp.And(x => x.CollegeID == collegeID);
  125. }
  126. var grademinorList = minorSpecialtyDAL.GetMinorSpecialtyViewQueryable(exp).ToList();
  127. List<ER_MinorGraduationStandard> minorGraduationStandardList = new List<ER_MinorGraduationStandard>();
  128. var dbminorGraduationStandardList = minorGraduationStandardDAL.GetMinorGraduationStandardView(x => true).ToList();
  129. foreach (var grademinor in grademinorList)
  130. {
  131. if (dbminorGraduationStandardList.Any(x => x.CollegeID == grademinor.CollegeID && x.YearID == grademinor.YearID && x.StandardID == grademinor.StandardID))
  132. {
  133. continue;
  134. }
  135. ER_MinorGraduationStandard minorGraduationStandard = new ER_MinorGraduationStandard();
  136. minorGraduationStandard.MinorGraduationStandardID = Guid.NewGuid();
  137. minorGraduationStandard.CollegeID = grademinor.CollegeID;
  138. minorGraduationStandard.YearID = grademinor.YearID;
  139. minorGraduationStandard.StandardID = grademinor.StandardID;
  140. minorGraduationStandard.GraduationCredit = 0;
  141. SetNewStatus(minorGraduationStandard);
  142. minorGraduationStandardList.Add(minorGraduationStandard);
  143. }
  144. UnitOfWork.BulkInsert(minorGraduationStandardList);
  145. UnitOfWork.Commit();
  146. }
  147. catch (Exception ex)
  148. {
  149. throw new Exception(ex.Message);
  150. }
  151. }
  152. /// <summary>
  153. /// 编辑(新增、修改,业务主键:年级专业ID)
  154. /// </summary>
  155. /// <param name="graduationStandardView"></param>
  156. public void MinorGraduationStandardEdit(MinorGraduationStandardView minorGraduationStandardView)
  157. {
  158. try
  159. {
  160. //查询数据库进行验证
  161. var minorGraduationStandardVerification = minorGraduationStandardDAL.minorGraduationStandardRepository
  162. .GetList(x => x.MinorGraduationStandardID != minorGraduationStandardView.MinorGraduationStandardID
  163. && x.StandardID == minorGraduationStandardView.StandardID && x.YearID == minorGraduationStandardView.YearID)
  164. .SingleOrDefault();
  165. if (minorGraduationStandardVerification == null)
  166. {
  167. //数据有误验证
  168. if (minorGraduationStandardView.MinorGraduationStandardID != Guid.Empty)
  169. {
  170. var minorGraduationStandard = minorGraduationStandardDAL.minorGraduationStandardRepository
  171. .GetList(x => x.MinorGraduationStandardID == minorGraduationStandardView.MinorGraduationStandardID)
  172. .SingleOrDefault();
  173. if (minorGraduationStandard == null)
  174. {
  175. throw new Exception("数据有误,请核查");
  176. }
  177. else
  178. {
  179. //表示修改
  180. minorGraduationStandard.GraduationCredit = minorGraduationStandardView.GraduationCredit;
  181. SetModifyStatus(minorGraduationStandard);
  182. }
  183. }
  184. else
  185. {
  186. //表示新增
  187. ER_MinorGraduationStandard minorGraduationStandard = new ER_MinorGraduationStandard();
  188. minorGraduationStandard.MinorGraduationStandardID = Guid.NewGuid();
  189. minorGraduationStandard.CollegeID = minorGraduationStandardView.CollegeID;
  190. minorGraduationStandard.YearID = minorGraduationStandardView.YearID;
  191. minorGraduationStandard.StandardID = minorGraduationStandardView.StandardID;
  192. minorGraduationStandard.GraduationCredit = minorGraduationStandardView.GraduationCredit;
  193. SetNewStatus(minorGraduationStandard);
  194. UnitOfWork.Add(minorGraduationStandard);
  195. }
  196. }
  197. else
  198. {
  199. throw new Exception("已存在相同的辅修毕业标准,请核查");
  200. }
  201. //事务提交
  202. UnitOfWork.Commit();
  203. }
  204. catch (Exception ex)
  205. {
  206. throw new Exception(ex.Message);
  207. }
  208. }
  209. /// <summary>
  210. /// 删除
  211. /// </summary>
  212. /// <param name="graduationStandardIDs"></param>
  213. /// <returns></returns>
  214. public void MinorGraduationStandardDelete(List<Guid?> minorGraduationStandardIDs)
  215. {
  216. try
  217. {
  218. UnitOfWork.Delete<ER_MinorGraduationStandard>(x => minorGraduationStandardIDs.Contains(x.MinorGraduationStandardID));
  219. }
  220. catch (Exception ex)
  221. {
  222. throw new Exception(ex.Message);
  223. }
  224. }
  225. }
  226. }