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.
 
 
 
 
 
 

263 lines
8.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. namespace Learun.Application.TwoDevelopment.EducationalAdministration
  9. {
  10. /// <summary>
  11. /// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架
  12. /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司
  13. /// 创 建:超级管理员
  14. /// 日 期:2021-06-01 11:49
  15. /// 描 述:收文报告
  16. /// </summary>
  17. public class DispatchService : RepositoryFactory
  18. {
  19. #region 获取数据
  20. /// <summary>
  21. /// 获取页面显示列表数据
  22. /// </summary>
  23. /// <param name="pagination">分页参数</param>
  24. /// <param name="queryJson">查询参数</param>
  25. /// <returns></returns>
  26. public IEnumerable<DispatchEntity> GetPageList(Pagination pagination, string queryJson)
  27. {
  28. try
  29. {
  30. var strSql = new StringBuilder();
  31. strSql.Append("SELECT ");
  32. strSql.Append(@" * ");
  33. strSql.Append(" FROM Dispatch t ");
  34. strSql.Append(" WHERE 1=1 ");
  35. var queryParam = queryJson.ToJObject();
  36. // 虚拟参数
  37. var dp = new DynamicParameters(new { });
  38. if (!queryParam["keyword"].IsEmpty())
  39. {
  40. dp.Add("keyword", "%" + queryParam["keyword"].ToString() + "%", DbType.String);
  41. strSql.Append(" AND t.DisFrom like @keyword ");
  42. }
  43. string beginDate = queryParam["StartTime"].ToString();
  44. string endDate = queryParam["EndTime"].ToString();
  45. if (!string.IsNullOrEmpty(beginDate) && !string.IsNullOrEmpty(endDate))
  46. {
  47. #region 获取日期(年 月 日)
  48. string bYaer = beginDate.Substring(0, 4);
  49. string bMonth = beginDate.Substring(5, 2);
  50. string bdate = beginDate.Substring(8, 2);
  51. string eYaer = endDate.Substring(0, 4);
  52. string eMonth = endDate.Substring(5, 2);
  53. #endregion
  54. string edate = endDate.Substring(8, 2);
  55. strSql.Append(@" and (t.DisYear BETWEEN '" + bYaer + "' and '" + eYaer + "') " +
  56. "and (t.DisMonth BETWEEN '" + bMonth + "' and '" + eMonth + "') " +
  57. " and (t.DisDay BETWEEN '" + bdate + "' and '" + edate + "') ");
  58. }
  59. if (!queryParam["userId"].IsEmpty())
  60. {
  61. strSql.Append(" AND t.Id Not in(select DisId from DispatchAudit where AuditUser ='" + queryParam["userId"].ToString() + "') ");
  62. }
  63. return this.BaseRepository("CollegeMIS").FindList<DispatchEntity>(strSql.ToString(), dp, pagination);
  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. /// <summary>
  78. /// 获取Dispatch表实体数据
  79. /// </summary>
  80. /// <param name="keyValue">主键</param>
  81. /// <returns></returns>
  82. public DispatchEntity GetDispatchEntity(string keyValue)
  83. {
  84. try
  85. {
  86. return this.BaseRepository("CollegeMIS").FindEntity<DispatchEntity>(keyValue);
  87. }
  88. catch (Exception ex)
  89. {
  90. if (ex is ExceptionEx)
  91. {
  92. throw;
  93. }
  94. else
  95. {
  96. throw ExceptionEx.ThrowServiceException(ex);
  97. }
  98. }
  99. }
  100. /// <summary>
  101. /// 获取主表实体数据
  102. /// </summary>
  103. /// <param name="processId">流程实例ID</param>
  104. /// <returns></returns>
  105. public DispatchEntity GetEntityByProcessId(string processId)
  106. {
  107. try
  108. {
  109. return this.BaseRepository("CollegeMIS").FindEntity<DispatchEntity>(t => t.processId == processId);
  110. }
  111. catch (Exception ex)
  112. {
  113. if (ex is ExceptionEx)
  114. {
  115. throw;
  116. }
  117. else
  118. {
  119. throw ExceptionEx.ThrowServiceException(ex);
  120. }
  121. }
  122. }
  123. #endregion
  124. #region 提交数据
  125. /// <summary>
  126. /// 删除实体数据
  127. /// </summary>
  128. /// <param name="keyValue">主键</param>
  129. public void DeleteEntity(string keyValue)
  130. {
  131. try
  132. {
  133. this.BaseRepository("CollegeMIS").Delete<DispatchEntity>(t => t.Id == keyValue);
  134. }
  135. catch (Exception ex)
  136. {
  137. if (ex is ExceptionEx)
  138. {
  139. throw;
  140. }
  141. else
  142. {
  143. throw ExceptionEx.ThrowServiceException(ex);
  144. }
  145. }
  146. }
  147. /// <summary>
  148. /// 保存实体数据(新增、修改)
  149. /// </summary>
  150. /// <param name="keyValue">主键</param>
  151. /// <param name="entity">实体</param>
  152. /// <returns></returns>
  153. public void SaveEntity(string keyValue, DispatchEntity entity)
  154. {
  155. try
  156. {
  157. if (!string.IsNullOrEmpty(keyValue))
  158. {
  159. entity.Modify(keyValue);
  160. this.BaseRepository("CollegeMIS").Update(entity);
  161. }
  162. else
  163. {
  164. entity.Create();
  165. this.BaseRepository("CollegeMIS").Insert(entity);
  166. }
  167. }
  168. catch (Exception ex)
  169. {
  170. if (ex is ExceptionEx)
  171. {
  172. throw;
  173. }
  174. else
  175. {
  176. throw ExceptionEx.ThrowServiceException(ex);
  177. }
  178. }
  179. }
  180. #endregion
  181. #region 扩展数据
  182. public void ModifyStatus(string keyValue, int pastatus, string processId)
  183. {
  184. try
  185. {
  186. var entity = this.BaseRepository("CollegeMIS").FindEntity<DispatchEntity>(a => a.Id == keyValue);
  187. //entity.CreateUser = RealName;
  188. //entity.CreateTime = DateTime.Now;
  189. entity.processId = processId;
  190. entity.FlowNo = pastatus.ToString();
  191. this.BaseRepository("CollegeMIS").Update(entity);
  192. }
  193. catch (Exception e)
  194. {
  195. if (e is ExceptionEx)
  196. {
  197. throw;
  198. }
  199. else
  200. {
  201. throw ExceptionEx.ThrowServiceException(e);
  202. }
  203. }
  204. }
  205. public void ModifTimeByProcessId(string processId)
  206. {
  207. try
  208. {
  209. var entity = this.BaseRepository("CollegeMIS").FindEntity<DispatchEntity>(a => a.processId == processId);
  210. entity.FlowNo = "2";
  211. this.BaseRepository("CollegeMIS").Update(entity);
  212. }
  213. catch (Exception e)
  214. {
  215. if (e is ExceptionEx)
  216. {
  217. throw;
  218. }
  219. else
  220. {
  221. throw ExceptionEx.ThrowServiceException(e);
  222. }
  223. }
  224. }
  225. public void ModifyStatusByProcessId(int pastatus, string processId)
  226. {
  227. try
  228. {
  229. var entity = this.BaseRepository("CollegeMIS").FindEntity<DispatchEntity>(a => a.processId == processId);
  230. entity.FlowNo = pastatus.ToString();
  231. this.BaseRepository("CollegeMIS").Update(entity);
  232. }
  233. catch (Exception e)
  234. {
  235. if (e is ExceptionEx)
  236. {
  237. throw;
  238. }
  239. else
  240. {
  241. throw ExceptionEx.ThrowServiceException(e);
  242. }
  243. }
  244. }
  245. #endregion
  246. }
  247. }