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.

TeacherRetireService.cs 6.8 KiB

4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205
  1. using Dapper;
  2. using Learun.Application.TwoDevelopment.EducationalAdministration;
  3. using Learun.DataBase.Repository;
  4. using Learun.Util;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Data;
  8. using System.Text;
  9. namespace Learun.Application.TwoDevelopment.PersonnelManagement
  10. {
  11. /// <summary>
  12. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  13. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  14. /// 创 建:超级管理员
  15. /// 日 期:2019-03-19 14:27
  16. /// 描 述:退休教职工
  17. /// </summary>
  18. public class TeacherRetireService : RepositoryFactory
  19. {
  20. #region 获取数据
  21. /// <summary>
  22. /// 获取页面显示列表数据
  23. /// <summary>
  24. /// <param name="queryJson">查询参数</param>
  25. /// <returns></returns>
  26. public IEnumerable<TeacherRetireEntity> GetPageList(Pagination pagination, string queryJson)
  27. {
  28. try
  29. {
  30. var admsdb = this.BaseRepository("CollegeMIS").getDbConnection().Database;
  31. var strSql = new StringBuilder();
  32. strSql.Append("SELECT t.* ");
  33. strSql.Append(" FROM TeacherRetire t left join " + admsdb + ".dbo.EmpInfo e on t.EID=e.EmpId ");
  34. strSql.Append(" WHERE 1=1 ");
  35. var queryParam = queryJson.ToJObject();
  36. // 虚拟参数
  37. var dp = new DynamicParameters(new { });
  38. if (!queryParam["StartTime"].IsEmpty() && !queryParam["EndTime"].IsEmpty())
  39. {
  40. dp.Add("startTime", queryParam["StartTime"].ToDate(), DbType.DateTime);
  41. dp.Add("endTime", queryParam["EndTime"].ToDate(), DbType.DateTime);
  42. strSql.Append(" AND ( t.TRTime >= @startTime AND t.TRTime <= @endTime ) ");
  43. }
  44. if (!queryParam["EName"].IsEmpty())
  45. {
  46. dp.Add("EName", "%" + queryParam["EName"].ToString() + "%", DbType.String);
  47. strSql.Append(" AND e.EmpName like @EName ");
  48. }
  49. return this.BaseRepository().FindList<TeacherRetireEntity>(strSql.ToString(), dp, pagination);
  50. }
  51. catch (Exception ex)
  52. {
  53. if (ex is ExceptionEx)
  54. {
  55. throw;
  56. }
  57. else
  58. {
  59. throw ExceptionEx.ThrowServiceException(ex);
  60. }
  61. }
  62. }
  63. /// <summary>
  64. /// 获取TeacherRetire表实体数据
  65. /// <param name="keyValue">主键</param>
  66. /// <summary>
  67. /// <returns></returns>
  68. public TeacherRetireEntity GetTeacherRetireEntity(string keyValue)
  69. {
  70. try
  71. {
  72. return this.BaseRepository().FindEntity<TeacherRetireEntity>(keyValue);
  73. }
  74. catch (Exception ex)
  75. {
  76. if (ex is ExceptionEx)
  77. {
  78. throw;
  79. }
  80. else
  81. {
  82. throw ExceptionEx.ThrowServiceException(ex);
  83. }
  84. }
  85. }
  86. #endregion
  87. #region 提交数据
  88. /// <summary>
  89. /// 删除实体数据
  90. /// <param name="keyValue">主键</param>
  91. /// <summary>
  92. /// <returns></returns>
  93. public void DeleteEntity(string keyValue)
  94. {
  95. var db = this.BaseRepository();
  96. db.BeginTrans();
  97. try
  98. {
  99. var entity = db.FindEntity<TeacherRetireEntity>(keyValue);
  100. if (entity != null)
  101. {
  102. //更新教师信息
  103. var empInfoEntity = this.BaseRepository("CollegeMIS").FindEntity<EmpInfoEntity>(x => x.EmpId == entity.EID);
  104. if (empInfoEntity != null)
  105. {
  106. empInfoEntity.IsInActiveStatus = entity.EStatus;
  107. this.BaseRepository("CollegeMIS").Update(empInfoEntity);
  108. }
  109. //人事异动
  110. db.Delete<TeacherChangeEntity>(x => x.EmpId == entity.EID && x.ChangeType == "01");
  111. db.Delete(entity);
  112. }
  113. db.Commit();
  114. }
  115. catch (Exception ex)
  116. {
  117. db.Rollback();
  118. if (ex is ExceptionEx)
  119. {
  120. throw;
  121. }
  122. else
  123. {
  124. throw ExceptionEx.ThrowServiceException(ex);
  125. }
  126. }
  127. }
  128. /// <summary>
  129. /// 保存实体数据(新增、修改)
  130. /// <param name="keyValue">主键</param>
  131. /// <summary>
  132. /// <returns></returns>
  133. public void SaveEntity(string keyValue, TeacherRetireEntity entity)
  134. {
  135. var db = this.BaseRepository();
  136. db.BeginTrans();
  137. try
  138. {
  139. if (!string.IsNullOrEmpty(keyValue))
  140. {
  141. entity.Modify(keyValue);
  142. db.Update(entity);
  143. }
  144. else
  145. {
  146. entity.Create();
  147. db.Insert(entity);
  148. }
  149. //人事异动
  150. var tcEntity = db.FindEntity<TeacherChangeEntity>(x => x.EmpId == entity.EID && x.ChangeType == "01");
  151. if (tcEntity == null)
  152. {
  153. var tcModel = new TeacherChangeEntity()
  154. {
  155. EmpId = entity.EID,
  156. ChangeTime = DateTime.Now,
  157. ChangeType = "01"
  158. };
  159. tcModel.Create();
  160. db.Insert(tcModel);
  161. }
  162. else
  163. {
  164. tcEntity.ChangeTime = DateTime.Now;
  165. tcEntity.Modify(tcEntity.Id);
  166. db.Update(tcEntity);
  167. }
  168. db.Commit();
  169. //更新教师信息
  170. var empInfoEntity = this.BaseRepository("CollegeMIS").FindEntity<EmpInfoEntity>(x => x.EmpId == entity.EID);
  171. if (empInfoEntity != null)
  172. {
  173. empInfoEntity.IsInActiveStatus = "6";
  174. this.BaseRepository("CollegeMIS").Update(empInfoEntity);
  175. }
  176. }
  177. catch (Exception ex)
  178. {
  179. db.Rollback();
  180. if (ex is ExceptionEx)
  181. {
  182. throw;
  183. }
  184. else
  185. {
  186. throw ExceptionEx.ThrowServiceException(ex);
  187. }
  188. }
  189. }
  190. #endregion
  191. }
  192. }