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.

MealCardRunTabService.cs 12 KiB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349
  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. var IsPhone = "";
  163. if (!queryParam["IsPhone"].IsEmpty())
  164. {
  165. IsPhone = queryParam["IsPhone"].ToString();
  166. if (IsPhone == "0")
  167. {
  168. var accountName = queryParam["accountName"].ToString();
  169. if (accountName != "超级管理员")
  170. {
  171. dp.Add("accountName", queryParam["accountName"].ToString(), DbType.String);
  172. strSql.Append(" AND t.accountName = @accountName ");
  173. }
  174. }
  175. }
  176. else
  177. {
  178. dp.Add("accountName", "%" + queryParam["accountName"].ToString() + "%", DbType.String);
  179. strSql.Append(" AND t.accountName Like @accountName ");
  180. }
  181. }
  182. if (!queryParam["depName"].IsEmpty())
  183. {
  184. dp.Add("depName", queryParam["depName"].ToString(), DbType.String);
  185. strSql.Append(" AND t.depName = @depName ");
  186. }
  187. if (!queryParam["personId"].IsEmpty())
  188. {
  189. dp.Add("personId", "%" + queryParam["personId"].ToString() + "%", DbType.String);
  190. strSql.Append(" AND t.personId Like @personId ");
  191. }
  192. if (!queryParam["identiName"].IsEmpty())
  193. {
  194. dp.Add("identiName", queryParam["identiName"].ToString(), DbType.String);
  195. strSql.Append(" AND t.identiName = @identiName ");
  196. }
  197. if (!queryParam["flowtype"].IsEmpty())
  198. {
  199. dp.Add("flowtype", queryParam["flowtype"].ToString(), DbType.String);
  200. strSql.Append(" AND t.flowtype = @flowtype ");
  201. }
  202. if (!queryParam["cardNo"].IsEmpty())
  203. {
  204. dp.Add("cardNo", "%" + queryParam["cardNo"].ToString() + "%", DbType.String);
  205. strSql.Append(" AND t.cardNo Like @cardNo ");
  206. }
  207. if (!queryParam["seg"].IsEmpty())
  208. {
  209. dp.Add("seg", queryParam["seg"].ToString(), DbType.String);
  210. strSql.Append(" AND t.seg = @seg ");
  211. }
  212. if (!queryParam["StartTime"].IsEmpty() && !queryParam["EndTime"].IsEmpty())
  213. {
  214. dp.Add("startTime", queryParam["StartTime"].ToDate(), DbType.DateTime);
  215. dp.Add("endTime", queryParam["EndTime"].ToDate(), DbType.DateTime);
  216. strSql.Append(" AND ( t.occurTime >= @startTime AND t.occurTime <= @endTime ) ");
  217. }
  218. return this.BaseRepository("CollegeMIS").FindList<MealCardRunTabEntity>(strSql.ToString(), dp, pagination);
  219. }
  220. catch (Exception ex)
  221. {
  222. if (ex is ExceptionEx)
  223. {
  224. throw;
  225. }
  226. else
  227. {
  228. throw ExceptionEx.ThrowServiceException(ex);
  229. }
  230. }
  231. }
  232. /// <summary>
  233. /// 获取实体数据
  234. /// </summary>
  235. /// <param name="keyValue">主键</param>
  236. /// <returns></returns>
  237. public MealCardRunTabEntity GetEntity(string keyValue)
  238. {
  239. try
  240. {
  241. return this.BaseRepository("CollegeMIS").FindEntity<MealCardRunTabEntity>(keyValue);
  242. }
  243. catch (Exception ex)
  244. {
  245. if (ex is ExceptionEx)
  246. {
  247. throw;
  248. }
  249. else
  250. {
  251. throw ExceptionEx.ThrowServiceException(ex);
  252. }
  253. }
  254. }
  255. #endregion
  256. #region 提交数据
  257. /// <summary>
  258. /// 删除实体数据
  259. /// </summary>
  260. /// <param name="keyValue">主键</param>
  261. public void DeleteEntity(string keyValue)
  262. {
  263. try
  264. {
  265. this.BaseRepository("CollegeMIS").Delete<MealCardRunTabEntity>(t => t.Id == keyValue);
  266. }
  267. catch (Exception ex)
  268. {
  269. if (ex is ExceptionEx)
  270. {
  271. throw;
  272. }
  273. else
  274. {
  275. throw ExceptionEx.ThrowServiceException(ex);
  276. }
  277. }
  278. }
  279. /// <summary>
  280. /// 保存实体数据(新增、修改)
  281. /// <param name="keyValue">主键</param>
  282. /// <param name="entity">实体</param>
  283. /// </summary>
  284. public void SaveEntity(string keyValue, MealCardRunTabEntity entity)
  285. {
  286. try
  287. {
  288. if (!string.IsNullOrEmpty(keyValue))
  289. {
  290. entity.Modify(keyValue);
  291. this.BaseRepository("CollegeMIS").Update(entity);
  292. }
  293. else
  294. {
  295. entity.Create();
  296. this.BaseRepository("CollegeMIS").Insert(entity);
  297. }
  298. }
  299. catch (Exception ex)
  300. {
  301. if (ex is ExceptionEx)
  302. {
  303. throw;
  304. }
  305. else
  306. {
  307. throw ExceptionEx.ThrowServiceException(ex);
  308. }
  309. }
  310. }
  311. #endregion
  312. /// <summary>
  313. /// 获取页面显示列表数据
  314. /// <summary>
  315. /// <param name="queryJson">查询参数</param>
  316. /// <returns></returns>
  317. public IEnumerable<MealCardRunTabEntity> GetListByAccount(string account)
  318. {
  319. try
  320. {
  321. var user = LoginUserInfo.Get();
  322. return this.BaseRepository("CollegeMIS").FindList<MealCardRunTabEntity>(x => x.personId == account && x.accountName == user.realName);
  323. }
  324. catch (Exception ex)
  325. {
  326. if (ex is ExceptionEx)
  327. {
  328. throw;
  329. }
  330. else
  331. {
  332. throw ExceptionEx.ThrowServiceException(ex);
  333. }
  334. }
  335. }
  336. }
  337. }