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.
 
 
 
 
 
 

188 lines
6.3 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. using Learun.Application.TwoDevelopment.EducationalAdministration;
  9. namespace Learun.Application.TwoDevelopment.LogisticsManagement
  10. {
  11. /// <summary>
  12. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  13. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  14. /// 创 建:超级管理员
  15. /// 日 期:2020-05-19 12:01
  16. /// 描 述:兵役登记
  17. /// </summary>
  18. public class MSRMilitaryServiceRegistrationService : RepositoryFactory
  19. {
  20. #region 获取数据
  21. /// <summary>
  22. /// 获取页面显示列表数据
  23. /// <summary>
  24. /// <param name="queryJson">查询参数</param>
  25. /// <returns></returns>
  26. public IEnumerable<MSRMilitaryServiceRegistrationEntity> GetPageList(Pagination pagination, string queryJson)
  27. {
  28. try
  29. {
  30. var strSql = new StringBuilder();
  31. strSql.Append("SELECT ");
  32. strSql.Append(@"
  33. t.ID,
  34. t.DeptNo,
  35. t.MajorNo,
  36. t.ClassNo,
  37. t.StuNo,
  38. t.Screenshot,
  39. t.Remark,
  40. t.YearNo
  41. ");
  42. strSql.Append(" FROM MSRMilitaryServiceRegistration t ");
  43. strSql.Append(" WHERE 1=1 ");
  44. var queryParam = queryJson.ToJObject();
  45. // 虚拟参数
  46. var dp = new DynamicParameters(new { });
  47. if (!queryParam["YearNo"].IsEmpty())
  48. {
  49. dp.Add("YearNo", "%" + queryParam["YearNo"].ToString() + "%", DbType.String);
  50. strSql.Append(" AND t.YearNo Like @YearNo ");
  51. }
  52. if (!queryParam["DeptNo"].IsEmpty())
  53. {
  54. dp.Add("DeptNo",queryParam["DeptNo"].ToString(), DbType.String);
  55. strSql.Append(" AND t.DeptNo = @DeptNo ");
  56. }
  57. if (!queryParam["MajorNo"].IsEmpty())
  58. {
  59. dp.Add("MajorNo",queryParam["MajorNo"].ToString(), DbType.String);
  60. strSql.Append(" AND t.MajorNo = @MajorNo ");
  61. }
  62. if (!queryParam["ClassNo"].IsEmpty())
  63. {
  64. dp.Add("ClassNo",queryParam["ClassNo"].ToString(), DbType.String);
  65. strSql.Append(" AND t.ClassNo = @ClassNo ");
  66. }
  67. if (!queryParam["StuNo"].IsEmpty())
  68. {
  69. dp.Add("StuNo",queryParam["StuNo"].ToString(), DbType.String);
  70. strSql.Append(" AND t.StuNo = @StuNo ");
  71. }
  72. return this.BaseRepository("CollegeMIS").FindList<MSRMilitaryServiceRegistrationEntity>(strSql.ToString(),dp, pagination);
  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. /// <summary>
  87. /// 获取MSRMilitaryServiceRegistration表实体数据
  88. /// <param name="keyValue">主键</param>
  89. /// <summary>
  90. /// <returns></returns>
  91. public MSRMilitaryServiceRegistrationEntity GetMSRMilitaryServiceRegistrationEntity(string keyValue)
  92. {
  93. try
  94. {
  95. return this.BaseRepository("CollegeMIS").FindEntity<MSRMilitaryServiceRegistrationEntity>(keyValue);
  96. }
  97. catch (Exception ex)
  98. {
  99. if (ex is ExceptionEx)
  100. {
  101. throw;
  102. }
  103. else
  104. {
  105. throw ExceptionEx.ThrowServiceException(ex);
  106. }
  107. }
  108. }
  109. #endregion
  110. #region 提交数据
  111. /// <summary>
  112. /// 删除实体数据
  113. /// <param name="keyValue">主键</param>
  114. /// <summary>
  115. /// <returns></returns>
  116. public void DeleteEntity(string keyValue)
  117. {
  118. try
  119. {
  120. this.BaseRepository("CollegeMIS").Delete<MSRMilitaryServiceRegistrationEntity>(t=>t.ID == keyValue);
  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 SaveEntity(string keyValue, MSRMilitaryServiceRegistrationEntity entity)
  140. {
  141. try
  142. {
  143. if (!string.IsNullOrEmpty(keyValue))
  144. {
  145. entity.Modify(keyValue);
  146. this.BaseRepository("CollegeMIS").Update(entity);
  147. }
  148. else
  149. {
  150. //获取当前学生的名字、系、专业、班级
  151. var loginUser = LoginUserInfo.Get();
  152. var userEntity = this.BaseRepository("CollegeMIS")
  153. .FindEntity<StuInfoBasicEntity>(a => a.StuNo == loginUser.account);
  154. var aa = Common.GetSemesterAndYear();
  155. entity.StuNo = userEntity?.StuNo;
  156. entity.DeptNo = userEntity?.DeptNo;
  157. entity.MajorNo = userEntity?.MajorNo;
  158. entity.ClassNo = userEntity?.ClassNo;
  159. entity.YearNo = aa.AcademicYearShort;
  160. entity.Create();
  161. this.BaseRepository("CollegeMIS").Insert(entity);
  162. }
  163. }
  164. catch (Exception ex)
  165. {
  166. if (ex is ExceptionEx)
  167. {
  168. throw;
  169. }
  170. else
  171. {
  172. throw ExceptionEx.ThrowServiceException(ex);
  173. }
  174. }
  175. }
  176. #endregion
  177. }
  178. }