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.
 
 
 
 
 
 

342 lines
11 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.Linq;
  8. using System.Text;
  9. namespace Learun.Application.TwoDevelopment.EducationalAdministration
  10. {
  11. /// <summary>
  12. /// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架
  13. /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司
  14. /// 创 建:超级管理员
  15. /// 日 期:2022-05-18 11:08
  16. /// 描 述:一卡通交易流水
  17. /// </summary>
  18. public class MealCardRunTabService : RepositoryFactory
  19. {
  20. #region 构造函数和属性
  21. private string fieldSql;
  22. /// <summary>
  23. /// 构造方法
  24. /// </summary>
  25. public MealCardRunTabService()
  26. {
  27. fieldSql = @" * ";
  28. }
  29. #endregion
  30. #region 获取数据
  31. public List<MealCardRunTabEntity> GetDept()
  32. {
  33. try
  34. {
  35. string sql = " select distinct DepName from MealCardRunTab order by depname ";
  36. return this.BaseRepository("CollegeMIS").FindList<MealCardRunTabEntity>(sql).ToList();
  37. }
  38. catch (Exception ex)
  39. {
  40. if (ex is ExceptionEx)
  41. {
  42. throw;
  43. }
  44. else
  45. {
  46. throw ExceptionEx.ThrowServiceException(ex);
  47. }
  48. }
  49. }
  50. public List<MealCardRunTabEntity> GetdentiName()
  51. {
  52. try
  53. {
  54. string sql = " select distinct identiName from MealCardRunTab order by identiName ";
  55. return this.BaseRepository("CollegeMIS").FindList<MealCardRunTabEntity>(sql).ToList();
  56. }
  57. catch (Exception ex)
  58. {
  59. if (ex is ExceptionEx)
  60. {
  61. throw;
  62. }
  63. else
  64. {
  65. throw ExceptionEx.ThrowServiceException(ex);
  66. }
  67. }
  68. }
  69. public List<MealCardRunTabEntity> Getflowtype()
  70. {
  71. try
  72. {
  73. string sql = " select distinct flowtype from MealCardRunTab order by flowtype ";
  74. return this.BaseRepository("CollegeMIS").FindList<MealCardRunTabEntity>(sql).ToList();
  75. }
  76. catch (Exception ex)
  77. {
  78. if (ex is ExceptionEx)
  79. {
  80. throw;
  81. }
  82. else
  83. {
  84. throw ExceptionEx.ThrowServiceException(ex);
  85. }
  86. }
  87. }
  88. public List<MealCardRunTabEntity> Getseg()
  89. {
  90. try
  91. {
  92. string sql = " select distinct seg from MealCardRunTab order by seg ";
  93. return this.BaseRepository("CollegeMIS").FindList<MealCardRunTabEntity>(sql).ToList();
  94. }
  95. catch (Exception ex)
  96. {
  97. if (ex is ExceptionEx)
  98. {
  99. throw;
  100. }
  101. else
  102. {
  103. throw ExceptionEx.ThrowServiceException(ex);
  104. }
  105. }
  106. }
  107. /// <summary>
  108. /// 获取列表数据
  109. /// </summary>
  110. /// <param name="queryJson">条件参数</param>
  111. /// <returns></returns>
  112. public IEnumerable<MealCardRunTabEntity> GetList(string queryJson)
  113. {
  114. try
  115. {
  116. //参考写法
  117. //var queryParam = queryJson.ToJObject();
  118. // 虚拟参数
  119. //var dp = new DynamicParameters(new { });
  120. //dp.Add("startTime", queryParam["StartTime"].ToDate(), DbType.DateTime);
  121. var strSql = new StringBuilder();
  122. strSql.Append("SELECT ");
  123. strSql.Append(fieldSql);
  124. strSql.Append(" FROM MealCardRunTab t ");
  125. return this.BaseRepository("CollegeMIS").FindList<MealCardRunTabEntity>(strSql.ToString());
  126. }
  127. catch (Exception ex)
  128. {
  129. if (ex is ExceptionEx)
  130. {
  131. throw;
  132. }
  133. else
  134. {
  135. throw ExceptionEx.ThrowServiceException(ex);
  136. }
  137. }
  138. }
  139. /// <summary>
  140. /// 获取列表分页数据
  141. /// </summary>
  142. /// <param name="pagination">分页参数</param>
  143. /// <param name="queryJson">条件参数</param>
  144. /// <returns></returns>
  145. public IEnumerable<MealCardRunTabEntity> GetPageList(Pagination pagination, string queryJson)
  146. {
  147. try
  148. {
  149. var strSql = new StringBuilder();
  150. strSql.Append("SELECT *");
  151. strSql.Append(" FROM MealCardRunTab t where 1=1");
  152. var queryParam = queryJson.ToJObject();
  153. // 虚拟参数
  154. var dp = new DynamicParameters(new { });
  155. if (!queryParam["accountNo"].IsEmpty())
  156. {
  157. dp.Add("accountNo", "%" + queryParam["accountNo"].ToString() + "%", DbType.String);
  158. strSql.Append(" AND t.accountNo Like @accountNo ");
  159. }
  160. if (!queryParam["accountName"].IsEmpty())
  161. {
  162. dp.Add("accountName", "%" + queryParam["accountName"].ToString() + "%", DbType.String);
  163. strSql.Append(" AND t.accountName Like @accountName ");
  164. }
  165. if (!queryParam["IdentityCardNo"].IsEmpty())
  166. {
  167. var account = LoginUserInfo.Get().account;
  168. if ("System" != account)
  169. {
  170. dp.Add("IdentityCardNo", queryParam["IdentityCardNo"].ToString(), DbType.String);
  171. strSql.Append(" AND t.personId = @IdentityCardNo ");
  172. }
  173. }
  174. if (!queryParam["depName"].IsEmpty())
  175. {
  176. dp.Add("depName", queryParam["depName"].ToString(), DbType.String);
  177. strSql.Append(" AND t.depName = @depName ");
  178. }
  179. if (!queryParam["personId"].IsEmpty())
  180. {
  181. dp.Add("personId", "%" + queryParam["personId"].ToString() + "%", DbType.String);
  182. strSql.Append(" AND t.personId Like @personId ");
  183. }
  184. if (!queryParam["identiName"].IsEmpty())
  185. {
  186. dp.Add("identiName", queryParam["identiName"].ToString(), DbType.String);
  187. strSql.Append(" AND t.identiName = @identiName ");
  188. }
  189. if (!queryParam["flowtype"].IsEmpty())
  190. {
  191. dp.Add("flowtype", queryParam["flowtype"].ToString(), DbType.String);
  192. strSql.Append(" AND t.flowtype = @flowtype ");
  193. }
  194. if (!queryParam["cardNo"].IsEmpty())
  195. {
  196. dp.Add("cardNo", "%" + queryParam["cardNo"].ToString() + "%", DbType.String);
  197. strSql.Append(" AND t.cardNo Like @cardNo ");
  198. }
  199. if (!queryParam["seg"].IsEmpty())
  200. {
  201. dp.Add("seg", queryParam["seg"].ToString(), DbType.String);
  202. strSql.Append(" AND t.seg = @seg ");
  203. }
  204. if (!queryParam["StartTime"].IsEmpty() && !queryParam["EndTime"].IsEmpty())
  205. {
  206. dp.Add("startTime", queryParam["StartTime"].ToDate(), DbType.DateTime);
  207. dp.Add("endTime", queryParam["EndTime"].ToDate(), DbType.DateTime);
  208. strSql.Append(" AND ( t.occurTime >= @startTime AND t.occurTime <= @endTime ) ");
  209. }
  210. return this.BaseRepository("CollegeMIS").FindList<MealCardRunTabEntity>(strSql.ToString(), dp, pagination);
  211. }
  212. catch (Exception ex)
  213. {
  214. if (ex is ExceptionEx)
  215. {
  216. throw;
  217. }
  218. else
  219. {
  220. throw ExceptionEx.ThrowServiceException(ex);
  221. }
  222. }
  223. }
  224. /// <summary>
  225. /// 获取实体数据
  226. /// </summary>
  227. /// <param name="keyValue">主键</param>
  228. /// <returns></returns>
  229. public MealCardRunTabEntity GetEntity(string keyValue)
  230. {
  231. try
  232. {
  233. return this.BaseRepository("CollegeMIS").FindEntity<MealCardRunTabEntity>(keyValue);
  234. }
  235. catch (Exception ex)
  236. {
  237. if (ex is ExceptionEx)
  238. {
  239. throw;
  240. }
  241. else
  242. {
  243. throw ExceptionEx.ThrowServiceException(ex);
  244. }
  245. }
  246. }
  247. #endregion
  248. #region 提交数据
  249. /// <summary>
  250. /// 删除实体数据
  251. /// </summary>
  252. /// <param name="keyValue">主键</param>
  253. public void DeleteEntity(string keyValue)
  254. {
  255. try
  256. {
  257. this.BaseRepository("CollegeMIS").Delete<MealCardRunTabEntity>(t => t.Id == keyValue);
  258. }
  259. catch (Exception ex)
  260. {
  261. if (ex is ExceptionEx)
  262. {
  263. throw;
  264. }
  265. else
  266. {
  267. throw ExceptionEx.ThrowServiceException(ex);
  268. }
  269. }
  270. }
  271. /// <summary>
  272. /// 保存实体数据(新增、修改)
  273. /// <param name="keyValue">主键</param>
  274. /// <param name="entity">实体</param>
  275. /// </summary>
  276. public void SaveEntity(string keyValue, MealCardRunTabEntity entity)
  277. {
  278. try
  279. {
  280. if (!string.IsNullOrEmpty(keyValue))
  281. {
  282. entity.Modify(keyValue);
  283. this.BaseRepository("CollegeMIS").Update(entity);
  284. }
  285. else
  286. {
  287. entity.Create();
  288. this.BaseRepository("CollegeMIS").Insert(entity);
  289. }
  290. }
  291. catch (Exception ex)
  292. {
  293. if (ex is ExceptionEx)
  294. {
  295. throw;
  296. }
  297. else
  298. {
  299. throw ExceptionEx.ThrowServiceException(ex);
  300. }
  301. }
  302. }
  303. #endregion
  304. /// <summary>
  305. /// 获取页面显示列表数据
  306. /// <summary>
  307. /// <param name="queryJson">查询参数</param>
  308. /// <returns></returns>
  309. public IEnumerable<MealCardRunTabEntity> GetListByAccount(string account)
  310. {
  311. try
  312. {
  313. var user = LoginUserInfo.Get();
  314. return this.BaseRepository("CollegeMIS").FindList<MealCardRunTabEntity>(x => x.personId == account && x.accountName == user.realName);
  315. }
  316. catch (Exception ex)
  317. {
  318. if (ex is ExceptionEx)
  319. {
  320. throw;
  321. }
  322. else
  323. {
  324. throw ExceptionEx.ThrowServiceException(ex);
  325. }
  326. }
  327. }
  328. }
  329. }