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.
 
 
 
 
 
 

373 lines
13 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-Ultimate V7.0.0 数字化智慧校园
  13. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  14. /// 创 建:超级管理员
  15. /// 日 期:2019-06-18 10:08
  16. /// 描 述:学生奖励管理
  17. /// </summary>
  18. public class StuEncourgementService : RepositoryFactory
  19. {
  20. #region 获取数据
  21. /// <summary>
  22. /// 获取页面显示列表数据
  23. /// <summary>
  24. /// <param name="queryJson">查询参数</param>
  25. /// <returns></returns>
  26. public IEnumerable<StuEncourgementEntity> 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 StuEncourgement t ");
  34. strSql.Append(" WHERE 1=1 ");
  35. var queryParam = queryJson.ToJObject();
  36. // 虚拟参数
  37. var dp = new DynamicParameters(new { });
  38. if (!queryParam["AcademicYearNo"].IsEmpty())
  39. {
  40. dp.Add("AcademicYearNo", queryParam["AcademicYearNo"].ToString(), DbType.String);
  41. strSql.Append(" AND t.AcademicYearNo = @AcademicYearNo ");
  42. }
  43. if (!queryParam["Semester"].IsEmpty())
  44. {
  45. dp.Add("Semester", queryParam["Semester"].ToString(), DbType.String);
  46. strSql.Append(" AND t.Semester = @Semester ");
  47. }
  48. if (!queryParam["StuName"].IsEmpty())
  49. {
  50. dp.Add("StuName", "%" + queryParam["StuName"].ToString() + "%", DbType.String);
  51. strSql.Append(" AND t.StuName Like @StuName ");
  52. }
  53. if (!queryParam["StuNo"].IsEmpty())
  54. {
  55. dp.Add("StuNo", "%" + queryParam["StuNo"].ToString() + "%", DbType.String);
  56. strSql.Append(" AND t.StuNo Like @StuNo ");
  57. }
  58. if (!queryParam["Sex"].IsEmpty())
  59. {
  60. dp.Add("Sex", queryParam["Sex"].ToString(), DbType.String);
  61. strSql.Append(" AND t.Sex = @Sex ");
  62. }
  63. if (!queryParam["DeptNo"].IsEmpty())
  64. {
  65. dp.Add("DeptNo", queryParam["DeptNo"].ToString(), DbType.String);
  66. strSql.Append(" AND t.DeptNo = @DeptNo ");
  67. }
  68. if (!queryParam["MajorNo"].IsEmpty())
  69. {
  70. dp.Add("MajorNo", queryParam["MajorNo"].ToString(), DbType.String);
  71. strSql.Append(" AND t.MajorNo = @MajorNo ");
  72. }
  73. if (!queryParam["ClassNo"].IsEmpty())
  74. {
  75. dp.Add("ClassNo", queryParam["ClassNo"].ToString(), DbType.String);
  76. strSql.Append(" AND t.ClassNo = @ClassNo ");
  77. }
  78. if (!queryParam["EncourgeName"].IsEmpty())
  79. {
  80. dp.Add("EncourgeName", "%" + queryParam["EncourgeName"].ToString() + "%", DbType.String);
  81. strSql.Append(" AND t.EncourgeName Like @EncourgeName ");
  82. }
  83. if (!queryParam["StartTime"].IsEmpty() && !queryParam["EndTime"].IsEmpty())
  84. {
  85. dp.Add("startTime", queryParam["StartTime"].ToDate(), DbType.DateTime);
  86. dp.Add("endTime", queryParam["EndTime"].ToDate(), DbType.DateTime);
  87. strSql.Append(" AND ( t.EncourgeDate >= @startTime AND t.EncourgeDate <= @endTime ) ");
  88. }
  89. return this.BaseRepository("CollegeMIS").FindList<StuEncourgementEntity>(strSql.ToString(), dp, pagination);
  90. }
  91. catch (Exception ex)
  92. {
  93. if (ex is ExceptionEx)
  94. {
  95. throw;
  96. }
  97. else
  98. {
  99. throw ExceptionEx.ThrowServiceException(ex);
  100. }
  101. }
  102. }
  103. /// <summary>
  104. /// 获取页面显示列表数据
  105. /// <summary>
  106. /// <param name="queryJson">查询参数</param>
  107. /// <returns></returns>
  108. public IEnumerable<StuEncourgementEntity> GetPageList(string queryJson)
  109. {
  110. try
  111. {
  112. var strSql = new StringBuilder();
  113. strSql.Append("SELECT ");
  114. strSql.Append(@" * ");
  115. strSql.Append(" FROM StuEncourgement t ");
  116. strSql.Append(" WHERE 1=1 ");
  117. var queryParam = queryJson.ToJObject();
  118. // 虚拟参数
  119. var dp = new DynamicParameters(new { });
  120. if (!queryParam["AcademicYearNo"].IsEmpty())
  121. {
  122. dp.Add("AcademicYearNo", queryParam["AcademicYearNo"].ToString(), DbType.String);
  123. strSql.Append(" AND t.AcademicYearNo = @AcademicYearNo ");
  124. }
  125. if (!queryParam["Semester"].IsEmpty())
  126. {
  127. dp.Add("Semester", queryParam["Semester"].ToString(), DbType.String);
  128. strSql.Append(" AND t.Semester = @Semester ");
  129. }
  130. if (!queryParam["StuName"].IsEmpty())
  131. {
  132. dp.Add("StuName", "%" + queryParam["StuName"].ToString() + "%", DbType.String);
  133. strSql.Append(" AND t.StuName Like @StuName ");
  134. }
  135. if (!queryParam["StuNo"].IsEmpty())
  136. {
  137. dp.Add("StuNo", "%" + queryParam["StuNo"].ToString() + "%", DbType.String);
  138. strSql.Append(" AND t.StuNo Like @StuNo ");
  139. }
  140. if (!queryParam["Sex"].IsEmpty())
  141. {
  142. dp.Add("Sex", queryParam["Sex"].ToString(), DbType.String);
  143. strSql.Append(" AND t.Sex = @Sex ");
  144. }
  145. if (!queryParam["DeptNo"].IsEmpty())
  146. {
  147. dp.Add("DeptNo", queryParam["DeptNo"].ToString(), DbType.String);
  148. strSql.Append(" AND t.DeptNo = @DeptNo ");
  149. }
  150. if (!queryParam["MajorNo"].IsEmpty())
  151. {
  152. dp.Add("MajorNo", queryParam["MajorNo"].ToString(), DbType.String);
  153. strSql.Append(" AND t.MajorNo = @MajorNo ");
  154. }
  155. if (!queryParam["ClassNo"].IsEmpty())
  156. {
  157. dp.Add("ClassNo", queryParam["ClassNo"].ToString(), DbType.String);
  158. strSql.Append(" AND t.ClassNo = @ClassNo ");
  159. }
  160. if (!queryParam["Grade"].IsEmpty())
  161. {
  162. dp.Add("Grade", queryParam["Grade"].ToString(), DbType.String);
  163. strSql.Append(" AND t.Grade = @Grade ");
  164. }
  165. return this.BaseRepository("CollegeMIS").FindList<StuEncourgementEntity>(strSql.ToString(), dp);
  166. }
  167. catch (Exception ex)
  168. {
  169. if (ex is ExceptionEx)
  170. {
  171. throw;
  172. }
  173. else
  174. {
  175. throw ExceptionEx.ThrowServiceException(ex);
  176. }
  177. }
  178. }
  179. public IEnumerable<StuEncourgementEntity> GetAllList()
  180. {
  181. try
  182. {
  183. return this.BaseRepository("CollegeMIS").FindList<StuEncourgementEntity>();
  184. }
  185. catch (Exception ex)
  186. {
  187. if (ex is ExceptionEx)
  188. {
  189. throw;
  190. }
  191. else
  192. {
  193. throw ExceptionEx.ThrowServiceException(ex);
  194. }
  195. }
  196. }
  197. /// <summary>
  198. /// 获取StuEncourgement表实体数据
  199. /// <param name="keyValue">主键</param>
  200. /// <summary>
  201. /// <returns></returns>
  202. public StuEncourgementEntity GetStuEncourgementEntity(string keyValue)
  203. {
  204. try
  205. {
  206. var keyvalue = Convert.ToInt32(keyValue);
  207. return this.BaseRepository("CollegeMIS").FindEntity<StuEncourgementEntity>(keyvalue);
  208. }
  209. catch (Exception ex)
  210. {
  211. if (ex is ExceptionEx)
  212. {
  213. throw;
  214. }
  215. else
  216. {
  217. throw ExceptionEx.ThrowServiceException(ex);
  218. }
  219. }
  220. }
  221. #endregion
  222. #region 提交数据
  223. /// <summary>
  224. /// 删除实体数据
  225. /// <param name="keyValue">主键</param>
  226. /// <summary>
  227. /// <returns></returns>
  228. public void DeleteEntity(string keyValue)
  229. {
  230. try
  231. {
  232. var keyvalue = Convert.ToInt32(keyValue);
  233. this.BaseRepository("CollegeMIS").Delete<StuEncourgementEntity>(t => t.ID == 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. /// <summary>
  248. /// 保存实体数据(新增、修改)
  249. /// <param name="keyValue">主键</param>
  250. /// <summary>
  251. /// <returns></returns>
  252. public void SaveEntity(string keyValue, StuEncourgementEntity entity)
  253. {
  254. try
  255. {
  256. if (!string.IsNullOrEmpty(keyValue))
  257. {
  258. entity.Modify(keyValue);
  259. this.BaseRepository("CollegeMIS").Update(entity);
  260. }
  261. else
  262. {
  263. entity.Create();
  264. this.BaseRepository("CollegeMIS").Insert(entity);
  265. }
  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. #endregion
  280. #region 扩展数据
  281. /// <summary>
  282. /// 获取学年学期列表
  283. /// </summary>
  284. /// <returns></returns>
  285. public IEnumerable<WebHelper.YearGrade> GetAcademicAndSemesterList()
  286. {
  287. try
  288. {
  289. var aa = this.BaseRepository("CollegeMIS").FindList<StuEncourgementEntity>();
  290. var aaa = aa.GroupBy(x => new { x.AcademicYearNo, x.Semester }).Select(x => new WebHelper.YearGrade()
  291. {
  292. text = string.Format("{0}学年第{1}学期", x.Key.AcademicYearNo, x.Key.Semester),
  293. value = string.Format("{0},{1}", x.Key.AcademicYearNo, x.Key.Semester)
  294. });
  295. return aaa;
  296. }
  297. catch (Exception ex)
  298. {
  299. if (ex is ExceptionEx)
  300. {
  301. throw;
  302. }
  303. else
  304. {
  305. throw ExceptionEx.ThrowServiceException(ex);
  306. }
  307. }
  308. }
  309. /// <summary>
  310. /// 获取页面显示列表数据
  311. /// <summary>
  312. /// <param name="queryJson">查询参数</param>
  313. /// <returns></returns>
  314. public IEnumerable<StuEncourgementEntity> GetEncourgementListByStuNo(string acdemic, string semester, string stuNo)
  315. {
  316. try
  317. {
  318. var result = this.BaseRepository("CollegeMIS").FindList<StuEncourgementEntity>(x => x.AcademicYearNo == acdemic && x.Semester == semester && x.StuNo == stuNo);
  319. return result;
  320. }
  321. catch (Exception ex)
  322. {
  323. if (ex is ExceptionEx)
  324. {
  325. throw;
  326. }
  327. else
  328. {
  329. throw ExceptionEx.ThrowServiceException(ex);
  330. }
  331. }
  332. }
  333. /// <summary>
  334. /// 获取页面显示列表数据
  335. /// <summary>
  336. /// <param name="queryJson">查询参数</param>
  337. /// <returns></returns>
  338. public IEnumerable<StuEncourgementEntity> GetEncourgementListByStuNo(string stuNo)
  339. {
  340. try
  341. {
  342. var result = this.BaseRepository("CollegeMIS").FindList<StuEncourgementEntity>(x => x.StuNo == stuNo);
  343. return result;
  344. }
  345. catch (Exception ex)
  346. {
  347. if (ex is ExceptionEx)
  348. {
  349. throw;
  350. }
  351. else
  352. {
  353. throw ExceptionEx.ThrowServiceException(ex);
  354. }
  355. }
  356. }
  357. #endregion
  358. }
  359. }