You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

StuInfoBasicChangeService.cs 8.3 KiB

4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243
  1. using Dapper;
  2. using Learun.DataBase.Repository;
  3. using Learun.Util;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Data;
  7. using System.Text;
  8. namespace Learun.Application.TwoDevelopment.EducationalAdministration
  9. {
  10. /// <summary>
  11. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  12. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  13. /// 创 建:超级管理员
  14. /// 日 期:2019-10-28 11:48
  15. /// 描 述:学籍异动
  16. /// </summary>
  17. public class StuInfoBasicChangeService : RepositoryFactory
  18. {
  19. #region 获取数据
  20. /// <summary>
  21. /// 获取页面显示列表数据
  22. /// <summary>
  23. /// <param name="queryJson">查询参数</param>
  24. /// <returns></returns>
  25. public IEnumerable<StuInfoBasicChangeEntity> GetPageList(Pagination pagination, string queryJson)
  26. {
  27. try
  28. {
  29. var strSql = new StringBuilder();
  30. strSql.Append("SELECT t.* FROM StuInfoBasicChange t ");
  31. strSql.Append(" WHERE 1=1 ");
  32. var queryParam = queryJson.ToJObject();
  33. // 虚拟参数
  34. var dp = new DynamicParameters(new { });
  35. if (!queryParam["StuName"].IsEmpty())
  36. {
  37. dp.Add("StuName", "%" + queryParam["StuName"].ToString() + "%", DbType.String);
  38. strSql.Append(" AND t.StuName Like @StuName ");
  39. }
  40. return this.BaseRepository("CollegeMIS").FindList<StuInfoBasicChangeEntity>(strSql.ToString(), dp, pagination);
  41. }
  42. catch (Exception ex)
  43. {
  44. if (ex is ExceptionEx)
  45. {
  46. throw;
  47. }
  48. else
  49. {
  50. throw ExceptionEx.ThrowServiceException(ex);
  51. }
  52. }
  53. }
  54. /// <summary>
  55. /// 获取StuInfoBasicChange表实体数据
  56. /// <param name="keyValue">主键</param>
  57. /// <summary>
  58. /// <returns></returns>
  59. public StuInfoBasicChangeEntity GetStuInfoBasicChangeEntity(string keyValue)
  60. {
  61. try
  62. {
  63. return this.BaseRepository("CollegeMIS").FindEntity<StuInfoBasicChangeEntity>(keyValue);
  64. }
  65. catch (Exception ex)
  66. {
  67. if (ex is ExceptionEx)
  68. {
  69. throw;
  70. }
  71. else
  72. {
  73. throw ExceptionEx.ThrowServiceException(ex);
  74. }
  75. }
  76. }
  77. #endregion
  78. #region 提交数据
  79. /// <summary>
  80. /// 删除实体数据
  81. /// <param name="keyValue">主键</param>
  82. /// <summary>
  83. /// <returns></returns>
  84. public void DeleteEntity(string keyValue)
  85. {
  86. try
  87. {
  88. this.BaseRepository("CollegeMIS").Delete<StuInfoBasicChangeEntity>(t => t.Id == keyValue);
  89. }
  90. catch (Exception ex)
  91. {
  92. if (ex is ExceptionEx)
  93. {
  94. throw;
  95. }
  96. else
  97. {
  98. throw ExceptionEx.ThrowServiceException(ex);
  99. }
  100. }
  101. }
  102. /// <summary>
  103. /// 保存实体数据(新增、修改)
  104. /// <param name="keyValue">主键</param>
  105. /// <summary>
  106. /// <returns></returns>
  107. public void SaveEntity(string keyValue, StuInfoBasicChangeEntity entity)
  108. {
  109. try
  110. {
  111. if (!string.IsNullOrEmpty(keyValue))
  112. {
  113. entity.Modify(keyValue);
  114. this.BaseRepository("CollegeMIS").Update(entity);
  115. }
  116. else
  117. {
  118. entity.Create();
  119. this.BaseRepository("CollegeMIS").Insert(entity);
  120. }
  121. }
  122. catch (Exception ex)
  123. {
  124. if (ex is ExceptionEx)
  125. {
  126. throw;
  127. }
  128. else
  129. {
  130. throw ExceptionEx.ThrowServiceException(ex);
  131. }
  132. }
  133. }
  134. /// <summary>
  135. /// 审核实体数据
  136. /// <param name="keyValue">主键</param>
  137. /// <summary>
  138. /// <returns></returns>
  139. public void DoCheck(string keyValue)
  140. {
  141. var db = this.BaseRepository("CollegeMIS").BeginTrans();
  142. try
  143. {
  144. var entity = db.FindEntity<StuInfoBasicChangeEntity>(x => x.Id == keyValue);
  145. if (entity != null)
  146. {
  147. //处理数据
  148. if (entity.StuChangeType == "01" || entity.StuChangeType == "02" || entity.StuChangeType == "03") //降级、转班、转专业
  149. {
  150. //改信息;
  151. var classInfoEntity = db.FindEntity<ClassInfoEntity>(x => x.ClassNo == entity.NewClassNo);
  152. if (classInfoEntity != null)
  153. {
  154. db.ExecuteBySql($"update StuInfoBasic set DeptNo='{entity.NewDeptNo}',MajorNo='{entity.NewMajorNo}',ClassNo='{entity.NewClassNo}',Grade='{classInfoEntity.Grade}' where StuNo='{entity.StuNo}' ");
  155. }
  156. }
  157. else if (entity.StuChangeType == "04" || entity.StuChangeType == "05") //退学、休学
  158. {
  159. //改信息;不显示成绩;
  160. db.ExecuteBySql($"update StuInfoBasic set ChangeStatus=1 where StuNo='{entity.StuNo}' ");
  161. }
  162. //修改状态
  163. entity.CheckTime = DateTime.Now;
  164. entity.CheckUserId = LoginUserInfo.Get().account;
  165. entity.CheckStatus = 1;
  166. db.Update(entity);
  167. }
  168. db.Commit();
  169. }
  170. catch (Exception ex)
  171. {
  172. db.Rollback();
  173. if (ex is ExceptionEx)
  174. {
  175. throw;
  176. }
  177. else
  178. {
  179. throw ExceptionEx.ThrowServiceException(ex);
  180. }
  181. }
  182. }
  183. /// <summary>
  184. /// 去审核实体数据
  185. /// <param name="keyValue">主键</param>
  186. /// <summary>
  187. /// <returns></returns>
  188. public void DoUnCheck(string keyValue)
  189. {
  190. var db = this.BaseRepository("CollegeMIS").BeginTrans();
  191. try
  192. {
  193. var entity = db.FindEntity<StuInfoBasicChangeEntity>(x => x.Id == keyValue);
  194. if (entity != null)
  195. {
  196. //处理数据
  197. if (entity.StuChangeType == "01" || entity.StuChangeType == "02" || entity.StuChangeType == "03") //降级、转班、转专业
  198. {
  199. //改信息;
  200. var classInfoEntity = db.FindEntity<ClassInfoEntity>(x => x.ClassNo == entity.ClassNo);
  201. if (classInfoEntity != null)
  202. {
  203. db.ExecuteBySql($"update StuInfoBasic set DeptNo='{entity.DeptNo}',MajorNo='{entity.MajorNo}',ClassNo='{entity.ClassNo}',Grade='{classInfoEntity.Grade}' where StuNo='{entity.StuNo}' ");
  204. }
  205. }
  206. else if (entity.StuChangeType == "04" || entity.StuChangeType == "05") //退学、休学
  207. {
  208. //改信息;显示成绩;
  209. db.ExecuteBySql($"update StuInfoBasic set ChangeStatus=null where StuNo='{entity.StuNo}' ");
  210. }
  211. //修改状态
  212. db.ExecuteBySql("update StuInfoBasicChange set CheckTime=null,CheckUserId=null,CheckStatus=0 where Id='" + keyValue + "' ");
  213. }
  214. db.Commit();
  215. }
  216. catch (Exception ex)
  217. {
  218. db.Rollback();
  219. if (ex is ExceptionEx)
  220. {
  221. throw;
  222. }
  223. else
  224. {
  225. throw ExceptionEx.ThrowServiceException(ex);
  226. }
  227. }
  228. }
  229. #endregion
  230. }
  231. }