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.

AllocationService.cs 5.4 KiB

4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  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.AssetManagementSystem
  9. {
  10. /// <summary>
  11. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  12. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  13. /// 创 建:超级管理员
  14. /// 日 期:2019-09-11 10:23
  15. /// 描 述:资产调拨
  16. /// </summary>
  17. public class AllocationService : RepositoryFactory
  18. {
  19. #region 获取数据
  20. /// <summary>
  21. /// 获取页面显示列表数据
  22. /// <summary>
  23. /// <param name="queryJson">查询参数</param>
  24. /// <returns></returns>
  25. public IEnumerable<Ass_AllocationEntity> GetPageList(Pagination pagination, string queryJson)
  26. {
  27. try
  28. {
  29. var strSql = new StringBuilder();
  30. strSql.Append("SELECT ");
  31. strSql.Append(@"
  32. t.ALID,
  33. t.ALLocation,
  34. t.ALLocationIn,
  35. t.ALStatus,
  36. t.ALDate,
  37. t.ALRemark,
  38. t.ALProcessId
  39. ");
  40. strSql.Append(" FROM Ass_Allocation t ");
  41. strSql.Append(" WHERE 1=1 ");
  42. var queryParam = queryJson.ToJObject();
  43. // 虚拟参数
  44. var dp = new DynamicParameters(new { });
  45. return this.BaseRepository().FindList<Ass_AllocationEntity>(strSql.ToString(), dp, pagination);
  46. }
  47. catch (Exception ex)
  48. {
  49. if (ex is ExceptionEx)
  50. {
  51. throw;
  52. }
  53. else
  54. {
  55. throw ExceptionEx.ThrowServiceException(ex);
  56. }
  57. }
  58. }
  59. /// <summary>
  60. /// 获取Ass_Allocation表实体数据
  61. /// <param name="keyValue">主键</param>
  62. /// <summary>
  63. /// <returns></returns>
  64. public Ass_AllocationEntity GetAss_AllocationEntity(string keyValue)
  65. {
  66. try
  67. {
  68. return this.BaseRepository().FindEntity<Ass_AllocationEntity>(keyValue);
  69. }
  70. catch (Exception ex)
  71. {
  72. if (ex is ExceptionEx)
  73. {
  74. throw;
  75. }
  76. else
  77. {
  78. throw ExceptionEx.ThrowServiceException(ex);
  79. }
  80. }
  81. }
  82. /// <summary>
  83. /// 获取主表实体数据
  84. /// <param name="processId">流程实例ID</param>
  85. /// <summary>
  86. /// <returns></returns>
  87. public Ass_AllocationEntity GetEntityByProcessId(string processId)
  88. {
  89. try
  90. {
  91. return this.BaseRepository().FindEntity<Ass_AllocationEntity>(t => t.ALProcessId == processId);
  92. }
  93. catch (Exception ex)
  94. {
  95. if (ex is ExceptionEx)
  96. {
  97. throw;
  98. }
  99. else
  100. {
  101. throw ExceptionEx.ThrowServiceException(ex);
  102. }
  103. }
  104. }
  105. #endregion
  106. #region 提交数据
  107. /// <summary>
  108. /// 删除实体数据
  109. /// <param name="keyValue">主键</param>
  110. /// <summary>
  111. /// <returns></returns>
  112. public void DeleteEntity(string keyValue)
  113. {
  114. try
  115. {
  116. this.BaseRepository().Delete<Ass_AllocationEntity>(t => t.ALID == keyValue);
  117. }
  118. catch (Exception ex)
  119. {
  120. if (ex is ExceptionEx)
  121. {
  122. throw;
  123. }
  124. else
  125. {
  126. throw ExceptionEx.ThrowServiceException(ex);
  127. }
  128. }
  129. }
  130. /// <summary>
  131. /// 保存实体数据(新增、修改)
  132. /// <param name="keyValue">主键</param>
  133. /// <summary>
  134. /// <returns></returns>
  135. public void SaveEntity(string keyValue, Ass_AllocationEntity entity)
  136. {
  137. try
  138. {
  139. if (!string.IsNullOrEmpty(keyValue))
  140. {
  141. entity.Modify(keyValue);
  142. this.BaseRepository().Update(entity);
  143. }
  144. else
  145. {
  146. entity.Create();
  147. this.BaseRepository().Insert(entity);
  148. }
  149. }
  150. catch (Exception ex)
  151. {
  152. if (ex is ExceptionEx)
  153. {
  154. throw;
  155. }
  156. else
  157. {
  158. throw ExceptionEx.ThrowServiceException(ex);
  159. }
  160. }
  161. }
  162. #endregion
  163. #region 扩展数据
  164. public void ModifyStatus(string keyValue, int pastatus, string processId)
  165. {
  166. throw new NotImplementedException();
  167. }
  168. public void ModifyStatusByProcessId(int pastatus, string processId)
  169. {
  170. throw new NotImplementedException();
  171. }
  172. public void ModifTimeByProcessId(string processId)
  173. {
  174. this.BaseRepository("CollegeMIS")
  175. .ExecuteBySql($"UPDATE dbo.LC_hetong SET OperationTime =GETDATE() WHERE LC_ID='{processId}'");
  176. }
  177. #endregion
  178. }
  179. }