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.
 
 
 
 
 
 

262 lines
10 KiB

  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}',MoveType ='{entity.StuChangeType}',MoveStatus='1' where StuNo='{entity.StuNo}' ");
  155. }
  156. }
  157. else if (entity.StuChangeType == "04" || entity.StuChangeType == "05" || entity.StuChangeType == "06") //退学、休学、转校
  158. {
  159. //改信息;不显示成绩;
  160. db.ExecuteBySql($"update StuInfoBasic set ChangeStatus=1,MoveType ='{entity.StuChangeType}',MoveStatus='1' where StuNo='{entity.StuNo}' ");
  161. }
  162. //2023.3.20新增复学的异动类型
  163. else if (entity.StuChangeType == "07") //复学
  164. {
  165. //改信息;
  166. var classInfoEntity = db.FindEntity<ClassInfoEntity>(x => x.ClassNo == entity.NewClassNo);
  167. if (classInfoEntity != null)
  168. {
  169. db.ExecuteBySql($"update StuInfoBasic set DeptNo='{entity.NewDeptNo}',MajorNo='{entity.NewMajorNo}',ClassNo='{entity.NewClassNo}',Grade='{classInfoEntity.Grade}',MoveType ='{entity.StuChangeType}',MoveStatus='0',ChangeStatus=0 where StuNo='{entity.StuNo}' ");
  170. }
  171. }
  172. //修改状态
  173. entity.CheckTime = DateTime.Now;
  174. entity.CheckUserId = LoginUserInfo.Get().account;
  175. entity.CheckStatus = 1;
  176. db.Update(entity);
  177. }
  178. db.Commit();
  179. }
  180. catch (Exception ex)
  181. {
  182. db.Rollback();
  183. if (ex is ExceptionEx)
  184. {
  185. throw;
  186. }
  187. else
  188. {
  189. throw ExceptionEx.ThrowServiceException(ex);
  190. }
  191. }
  192. }
  193. /// <summary>
  194. /// 去审核实体数据
  195. /// <param name="keyValue">主键</param>
  196. /// <summary>
  197. /// <returns></returns>
  198. public void DoUnCheck(string keyValue)
  199. {
  200. var db = this.BaseRepository("CollegeMIS").BeginTrans();
  201. try
  202. {
  203. var entity = db.FindEntity<StuInfoBasicChangeEntity>(x => x.Id == keyValue);
  204. if (entity != null)
  205. {
  206. //处理数据
  207. if (entity.StuChangeType == "01" || entity.StuChangeType == "02" || entity.StuChangeType == "03") //降级、转班、转专业
  208. {
  209. //改信息;
  210. var classInfoEntity = db.FindEntity<ClassInfoEntity>(x => x.ClassNo == entity.ClassNo);
  211. if (classInfoEntity != null)
  212. {
  213. db.ExecuteBySql($"update StuInfoBasic set DeptNo='{entity.DeptNo}',MajorNo='{entity.MajorNo}',ClassNo='{entity.ClassNo}',Grade='{classInfoEntity.Grade}',MoveType =null,MoveStatus=null where StuNo='{entity.StuNo}' ");
  214. }
  215. }
  216. else if (entity.StuChangeType == "04" || entity.StuChangeType == "05" || entity.StuChangeType == "06") //退学、休学、转校
  217. {
  218. //改信息;显示成绩;
  219. db.ExecuteBySql($"update StuInfoBasic set ChangeStatus=null,MoveType =null,MoveStatus=null where StuNo='{entity.StuNo}' ");
  220. }
  221. //复学
  222. else if (entity.StuChangeType == "07")
  223. {
  224. //改信息;
  225. var classInfoEntity = db.FindEntity<ClassInfoEntity>(x => x.ClassNo == entity.ClassNo);
  226. if (classInfoEntity != null)
  227. {
  228. db.ExecuteBySql($"update StuInfoBasic set DeptNo='{entity.DeptNo}',MajorNo='{entity.MajorNo}',ClassNo='{entity.ClassNo}',Grade='{classInfoEntity.Grade}',ChangeStatus='{entity.ChangeStatus}',MoveType ='{entity.MoveType}',MoveStatus='{entity.MoveStatus}' where StuNo='{entity.StuNo}' ");
  229. }
  230. }
  231. //修改状态
  232. db.ExecuteBySql("update StuInfoBasicChange set CheckTime=null,CheckUserId=null,CheckStatus=0 where Id='" + keyValue + "' ");
  233. }
  234. db.Commit();
  235. }
  236. catch (Exception ex)
  237. {
  238. db.Rollback();
  239. if (ex is ExceptionEx)
  240. {
  241. throw;
  242. }
  243. else
  244. {
  245. throw ExceptionEx.ThrowServiceException(ex);
  246. }
  247. }
  248. }
  249. #endregion
  250. }
  251. }