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.
 
 
 
 
 
 

264 lines
9.5 KiB

  1. using Dapper;
  2. using Learun.DataBase.Repository;
  3. using Learun.Util;
  4. using Newtonsoft.Json;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Data;
  8. using System.Linq;
  9. using System.Text;
  10. namespace Learun.Application.TwoDevelopment.EducationalAdministration
  11. {
  12. /// <summary>
  13. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  14. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  15. /// 创 建:超级管理员
  16. /// 日 期:2020-01-03 10:10
  17. /// 描 述:取消考试资格
  18. /// </summary>
  19. public class StuCancelExamService : RepositoryFactory
  20. {
  21. #region 获取数据
  22. /// <summary>
  23. /// 获取页面显示列表数据
  24. /// <summary>
  25. /// <param name="queryJson">查询参数</param>
  26. /// <returns></returns>
  27. public IEnumerable<StuCancelExamEntity> GetPageList(Pagination pagination, string queryJson)
  28. {
  29. try
  30. {
  31. var strSql = new StringBuilder();
  32. strSql.Append("SELECT t.* ");
  33. strSql.Append(" FROM StuCancelExam t ");
  34. strSql.Append(" WHERE 1=1 ");
  35. var queryParam = queryJson.ToJObject();
  36. // 虚拟参数
  37. var dp = new DynamicParameters(new { });
  38. if (!queryParam["StuNo"].IsEmpty())
  39. {
  40. dp.Add("StuNo", "%" + queryParam["StuNo"].ToString() + "%", DbType.String);
  41. strSql.Append(" AND t.StuNo Like @StuNo ");
  42. }
  43. if (!queryParam["StuName"].IsEmpty())
  44. {
  45. dp.Add("StuName", "%" + queryParam["StuName"].ToString() + "%", DbType.String);
  46. strSql.Append(" AND t.StuName Like @StuName ");
  47. }
  48. if (!queryParam["LessonNo"].IsEmpty())
  49. {
  50. dp.Add("LessonNo", "%" + queryParam["LessonNo"].ToString() + "%", DbType.String);
  51. strSql.Append(" AND t.LessonNo Like @LessonNo ");
  52. }
  53. if (!queryParam["LessonName"].IsEmpty())
  54. {
  55. dp.Add("LessonName", "%" + queryParam["LessonName"].ToString() + "%", DbType.String);
  56. strSql.Append(" AND t.LessonName Like @LessonName ");
  57. }
  58. return this.BaseRepository("CollegeMIS").FindList<StuCancelExamEntity>(strSql.ToString(), dp, pagination);
  59. }
  60. catch (Exception ex)
  61. {
  62. if (ex is ExceptionEx)
  63. {
  64. throw;
  65. }
  66. else
  67. {
  68. throw ExceptionEx.ThrowServiceException(ex);
  69. }
  70. }
  71. }
  72. /// <summary>
  73. /// 获取页面显示列表数据
  74. /// <summary>
  75. /// <param name="queryJson">查询参数</param>
  76. /// <returns></returns>
  77. public IEnumerable<StuSelectLessonListEntity> GetStudentPageList(Pagination pagination, string queryJson)
  78. {
  79. try
  80. {
  81. var strSql = new StringBuilder();
  82. strSql.Append("select t.SelectId,t.StuNo,t.StuName,t.ClassNo,t.EmpNo from StuSelectLessonList t ");
  83. strSql.Append(" WHERE 1=1 and t.SelectId not in (select c.StuSelectLessonListId from StuCancelExam c ) ");
  84. var queryParam = queryJson.ToJObject();
  85. // 虚拟参数
  86. var dp = new DynamicParameters(new { });
  87. if (!queryParam["AcademicYearNo"].IsEmpty())
  88. {
  89. dp.Add("AcademicYearNo", queryParam["AcademicYearNo"].ToString(), DbType.String);
  90. strSql.Append(" AND t.AcademicYearNo = @AcademicYearNo ");
  91. }
  92. if (!queryParam["Semester"].IsEmpty())
  93. {
  94. dp.Add("Semester", queryParam["Semester"].ToString(), DbType.String);
  95. strSql.Append(" AND t.Semester = @Semester ");
  96. }
  97. if (!queryParam["LessonNo"].IsEmpty())
  98. {
  99. dp.Add("LessonNo", queryParam["LessonNo"].ToString(), DbType.String);
  100. strSql.Append(" AND t.LessonNo = @LessonNo ");
  101. }
  102. return this.BaseRepository("CollegeMIS").FindList<StuSelectLessonListEntity>(strSql.ToString(), dp, pagination);
  103. }
  104. catch (Exception ex)
  105. {
  106. if (ex is ExceptionEx)
  107. {
  108. throw;
  109. }
  110. else
  111. {
  112. throw ExceptionEx.ThrowServiceException(ex);
  113. }
  114. }
  115. }
  116. /// <summary>
  117. /// 获取StuCancelExam表实体数据
  118. /// <param name="keyValue">主键</param>
  119. /// <summary>
  120. /// <returns></returns>
  121. public StuCancelExamEntity GetStuCancelExamEntity(string keyValue)
  122. {
  123. try
  124. {
  125. return this.BaseRepository("CollegeMIS").FindEntity<StuCancelExamEntity>(keyValue);
  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. #endregion
  140. #region 提交数据
  141. /// <summary>
  142. /// 删除实体数据
  143. /// <param name="keyValue">主键</param>
  144. /// <summary>
  145. /// <returns></returns>
  146. public void DeleteEntity(string keyValue)
  147. {
  148. try
  149. {
  150. this.BaseRepository("CollegeMIS").Delete<StuCancelExamEntity>(t => t.Id == keyValue);
  151. }
  152. catch (Exception ex)
  153. {
  154. if (ex is ExceptionEx)
  155. {
  156. throw;
  157. }
  158. else
  159. {
  160. throw ExceptionEx.ThrowServiceException(ex);
  161. }
  162. }
  163. }
  164. /// <summary>
  165. /// 保存实体数据(新增、修改)
  166. /// <param name="keyValue">主键</param>
  167. /// <summary>
  168. /// <returns></returns>
  169. public void SaveEntity(string keyValue, StuCancelExamEntity entity)
  170. {
  171. try
  172. {
  173. if (!string.IsNullOrEmpty(keyValue))
  174. {
  175. entity.Modify(keyValue);
  176. this.BaseRepository("CollegeMIS").Update(entity);
  177. }
  178. else
  179. {
  180. entity.Create();
  181. this.BaseRepository("CollegeMIS").Insert(entity);
  182. }
  183. }
  184. catch (Exception ex)
  185. {
  186. if (ex is ExceptionEx)
  187. {
  188. throw;
  189. }
  190. else
  191. {
  192. throw ExceptionEx.ThrowServiceException(ex);
  193. }
  194. }
  195. }
  196. /// <summary>
  197. /// 确认上报
  198. /// </summary>
  199. /// <param name="dataJson"></param>
  200. /// <returns></returns>
  201. public void SaveApply(string dataJson)
  202. {
  203. var loginInfo = LoginUserInfo.Get();
  204. var data = JsonConvert.DeserializeObject<List<StuSelectLessonListEntity>>(dataJson);
  205. if (data.Any())
  206. {
  207. var db = this.BaseRepository("CollegeMIS").BeginTrans();
  208. try
  209. {
  210. foreach (var item in data)
  211. {
  212. var stuSelectLessonListEntity = db.FindEntity<StuSelectLessonListEntity>(x => x.SelectId == item.SelectId);
  213. if (stuSelectLessonListEntity != null)
  214. {
  215. var model = new StuCancelExamEntity();
  216. model.StuSelectLessonListId = stuSelectLessonListEntity.SelectId;
  217. model.AcademicYearNo = stuSelectLessonListEntity.AcademicYearNo;
  218. model.Semester = stuSelectLessonListEntity.Semester;
  219. model.StuNo = stuSelectLessonListEntity.StuNo;
  220. model.DeptNo = stuSelectLessonListEntity.DeptNo;
  221. model.MajorNo = stuSelectLessonListEntity.MajorNo;
  222. model.ClassNo = stuSelectLessonListEntity.ClassNo;
  223. model.StuName = stuSelectLessonListEntity.StuName;
  224. model.LessonNo = stuSelectLessonListEntity.LessonNo;
  225. model.LessonName = stuSelectLessonListEntity.LessonName;
  226. model.EmpNo = stuSelectLessonListEntity.EmpNo;
  227. model.CheckMark = "0";
  228. model.CreateTime = DateTime.Now;
  229. model.CreateUserId = loginInfo.userId;
  230. model.CreateUserName = loginInfo.realName;
  231. model.Create();
  232. db.Insert(model);
  233. }
  234. }
  235. db.Commit();
  236. }
  237. catch (Exception ex)
  238. {
  239. db.Rollback();
  240. if (ex is ExceptionEx)
  241. {
  242. throw;
  243. }
  244. else
  245. {
  246. throw ExceptionEx.ThrowServiceException(ex);
  247. }
  248. }
  249. }
  250. }
  251. #endregion
  252. }
  253. }