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.
 
 
 
 
 
 

320 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.Text;
  8. namespace Learun.Application.TwoDevelopment.EducationalAdministration
  9. {
  10. /// <summary>
  11. /// 版 本 Learun-ADMS V7.0.6 力软敏捷开发框架
  12. /// Copyright (c) 2013-2020 力软信息技术(苏州)有限公司
  13. /// 创 建:超级管理员
  14. /// 日 期:2022-11-08 11:05
  15. /// 描 述:学生赛事奖励
  16. /// </summary>
  17. public class StudentCompetitionService : 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<StudentCompetitionEntity> GetPageList(Pagination pagination, string queryJson)
  27. {
  28. try
  29. {
  30. var strSql = new StringBuilder();
  31. strSql.Append("SELECT ");
  32. strSql.Append(@"
  33. t.*
  34. ");
  35. strSql.Append(" FROM StudentCompetition t ");
  36. strSql.Append(" WHERE 1=1 ");
  37. var queryParam = queryJson.ToJObject();
  38. // 虚拟参数
  39. var dp = new DynamicParameters(new { });
  40. if (!queryParam["AcademicYearNo"].IsEmpty())
  41. {
  42. dp.Add("AcademicYearNo", queryParam["AcademicYearNo"].ToString(), DbType.String);
  43. strSql.Append(" AND t.AcademicYearNo = @AcademicYearNo ");
  44. }
  45. if (!queryParam["Semester"].IsEmpty())
  46. {
  47. dp.Add("Semester", queryParam["Semester"].ToString(), DbType.String);
  48. strSql.Append(" AND t.Semester = @Semester ");
  49. }
  50. if (!queryParam["StuNo"].IsEmpty())
  51. {
  52. dp.Add("StuNo", "%" + queryParam["StuNo"].ToString() + "%", DbType.String);
  53. strSql.Append(" AND t.StuNo Like @StuNo ");
  54. }
  55. if (!queryParam["StuName"].IsEmpty())
  56. {
  57. dp.Add("StuName", "%" + queryParam["StuName"].ToString() + "%", DbType.String);
  58. strSql.Append(" AND t.StuName Like @StuName ");
  59. }
  60. if (!queryParam["DeptNo"].IsEmpty())
  61. {
  62. dp.Add("DeptNo", queryParam["DeptNo"].ToString(), DbType.String);
  63. strSql.Append(" AND t.DeptNo = @DeptNo ");
  64. }
  65. if (!queryParam["MajorNo"].IsEmpty())
  66. {
  67. dp.Add("MajorNo", queryParam["MajorNo"].ToString(), DbType.String);
  68. strSql.Append(" AND t.MajorNo = @MajorNo ");
  69. }
  70. if (!queryParam["ClassNo"].IsEmpty())
  71. {
  72. dp.Add("ClassNo", queryParam["ClassNo"].ToString(), DbType.String);
  73. strSql.Append(" AND t.ClassNo = @ClassNo ");
  74. }
  75. if (!queryParam["SCName"].IsEmpty())
  76. {
  77. dp.Add("SCName", "%" + queryParam["SCName"].ToString() + "%", DbType.String);
  78. strSql.Append(" AND t.SCName Like @SCName ");
  79. }
  80. if (!queryParam["SCLevel"].IsEmpty())
  81. {
  82. dp.Add("SCLevel",queryParam["SCLevel"].ToString(), DbType.String);
  83. strSql.Append(" AND t.SCLevel = @SCLevel ");
  84. }
  85. if (!queryParam["SCTime"].IsEmpty())
  86. {
  87. dp.Add("SCTime", queryParam["SCTime"].ToDate(), DbType.DateTime);
  88. strSql.Append(" AND t.SCTime = @SCTime ");
  89. }
  90. if (!queryParam["SCType"].IsEmpty())
  91. {
  92. dp.Add("SCType", "%" + queryParam["SCType"].ToString() + "%", DbType.String);
  93. strSql.Append(" AND t.SCType Like @SCType ");
  94. }
  95. if (!queryParam["Unit"].IsEmpty())
  96. {
  97. dp.Add("Unit", "%" + queryParam["Unit"].ToString() + "%", DbType.String);
  98. strSql.Append(" AND t.Unit Like @Unit ");
  99. }
  100. return this.BaseRepository("CollegeMIS").FindList<StudentCompetitionEntity>(strSql.ToString(), dp, pagination);
  101. }
  102. catch (Exception ex)
  103. {
  104. if (ex is ExceptionEx)
  105. {
  106. throw;
  107. }
  108. else
  109. {
  110. throw ExceptionEx.ThrowServiceException(ex);
  111. }
  112. }
  113. }
  114. /// <summary>
  115. /// 获取StudentCompetition表实体数据
  116. /// </summary>
  117. /// <param name="keyValue">主键</param>
  118. /// <returns></returns>
  119. public StudentCompetitionEntity GetStudentCompetitionEntity(string keyValue)
  120. {
  121. try
  122. {
  123. return this.BaseRepository("CollegeMIS").FindEntity<StudentCompetitionEntity>(keyValue);
  124. }
  125. catch (Exception ex)
  126. {
  127. if (ex is ExceptionEx)
  128. {
  129. throw;
  130. }
  131. else
  132. {
  133. throw ExceptionEx.ThrowServiceException(ex);
  134. }
  135. }
  136. }
  137. /// <summary>
  138. /// 获取主表实体数据
  139. /// </summary>
  140. /// <param name="processId">流程实例ID</param>
  141. /// <returns></returns>
  142. public StudentCompetitionEntity GetEntityByProcessId(string processId)
  143. {
  144. try
  145. {
  146. return this.BaseRepository("CollegeMIS").FindEntity<StudentCompetitionEntity>(t => t.processId == processId);
  147. }
  148. catch (Exception ex)
  149. {
  150. if (ex is ExceptionEx)
  151. {
  152. throw;
  153. }
  154. else
  155. {
  156. throw ExceptionEx.ThrowServiceException(ex);
  157. }
  158. }
  159. }
  160. /// <summary>
  161. /// 获取页面显示列表数据
  162. /// </summary>
  163. /// <returns></returns>
  164. public IEnumerable<StudentCompetitionEntity> GetList(string queryJson)
  165. {
  166. try
  167. {
  168. var strSql = new StringBuilder();
  169. strSql.Append("SELECT t.* ");
  170. strSql.Append(" FROM StudentCompetition t ");
  171. strSql.Append(" WHERE 1=1 and t.Status=2 ");
  172. var queryParam = queryJson.ToJObject();
  173. // 虚拟参数
  174. var dp = new DynamicParameters(new { });
  175. if (!queryParam["StuNo"].IsEmpty())
  176. {
  177. dp.Add("StuNo", queryParam["StuNo"].ToString(), DbType.String);
  178. strSql.Append(" AND t.StuNo = @StuNo ");
  179. }
  180. if (!queryParam["StuName"].IsEmpty())
  181. {
  182. dp.Add("StuName", "%" + queryParam["StuName"].ToString() + "%", DbType.String);
  183. strSql.Append(" AND t.StuName Like @StuName ");
  184. }
  185. if (!queryParam["AcademicYearNo"].IsEmpty())
  186. {
  187. dp.Add("AcademicYearNo", queryParam["AcademicYearNo"].ToString(), DbType.String);
  188. strSql.Append(" AND t.AcademicYearNo = @AcademicYearNo ");
  189. }
  190. if (!queryParam["Semester"].IsEmpty())
  191. {
  192. dp.Add("Semester", queryParam["Semester"].ToString(), DbType.String);
  193. strSql.Append(" AND t.Semester = @Semester ");
  194. }
  195. return this.BaseRepository("CollegeMIS").FindList<StudentCompetitionEntity>(strSql.ToString(), dp);
  196. }
  197. catch (Exception ex)
  198. {
  199. if (ex is ExceptionEx)
  200. {
  201. throw;
  202. }
  203. else
  204. {
  205. throw ExceptionEx.ThrowServiceException(ex);
  206. }
  207. }
  208. }
  209. #endregion
  210. #region 提交数据
  211. /// <summary>
  212. /// 删除实体数据
  213. /// </summary>
  214. /// <param name="keyValue">主键</param>
  215. public void DeleteEntity(string keyValue)
  216. {
  217. try
  218. {
  219. this.BaseRepository("CollegeMIS").Delete<StudentCompetitionEntity>(t => t.Id == keyValue);
  220. }
  221. catch (Exception ex)
  222. {
  223. if (ex is ExceptionEx)
  224. {
  225. throw;
  226. }
  227. else
  228. {
  229. throw ExceptionEx.ThrowServiceException(ex);
  230. }
  231. }
  232. }
  233. /// <summary>
  234. /// 保存实体数据(新增、修改)
  235. /// </summary>
  236. /// <param name="keyValue">主键</param>
  237. /// <param name="entity">实体</param>
  238. /// <returns></returns>
  239. public void SaveEntity(string keyValue, StudentCompetitionEntity entity)
  240. {
  241. try
  242. {
  243. if (!string.IsNullOrEmpty(keyValue))
  244. {
  245. entity.Modify(keyValue);
  246. this.BaseRepository("CollegeMIS").Update(entity);
  247. }
  248. else
  249. {
  250. entity.Create();
  251. this.BaseRepository("CollegeMIS").Insert(entity);
  252. }
  253. }
  254. catch (Exception ex)
  255. {
  256. if (ex is ExceptionEx)
  257. {
  258. throw;
  259. }
  260. else
  261. {
  262. throw ExceptionEx.ThrowServiceException(ex);
  263. }
  264. }
  265. }
  266. public void ChangeStatusByProcessId(string processId, int status)
  267. {
  268. try
  269. {
  270. this.BaseRepository("CollegeMIS").ExecuteBySql($"update StudentCompetition set Status='{status}' where processId='{processId}'");
  271. }
  272. catch (Exception ex)
  273. {
  274. if (ex is ExceptionEx)
  275. {
  276. throw;
  277. }
  278. else
  279. {
  280. throw ExceptionEx.ThrowServiceException(ex);
  281. }
  282. }
  283. }
  284. public void ChangeStatusById(string keyValue, int status, string processId)
  285. {
  286. try
  287. {
  288. this.BaseRepository("CollegeMIS").ExecuteBySql($"update StudentCompetition set Status='{status}',processId='{processId}' where Id='{keyValue}'");
  289. }
  290. catch (Exception ex)
  291. {
  292. if (ex is ExceptionEx)
  293. {
  294. throw;
  295. }
  296. else
  297. {
  298. throw ExceptionEx.ThrowServiceException(ex);
  299. }
  300. }
  301. }
  302. #endregion
  303. }
  304. }