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.
 
 
 
 
 
 

392 line
14 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-17 14:54
  16. /// 描 述:学生处分管理
  17. /// </summary>
  18. public class StuPunishmentService : RepositoryFactory
  19. {
  20. #region 获取数据
  21. /// <summary>
  22. /// 获取页面显示列表数据
  23. /// <summary>
  24. /// <param name="queryJson">查询参数</param>
  25. /// <returns></returns>
  26. public IEnumerable<StuPunishmentEntity> GetPageList(Pagination pagination, string queryJson)
  27. {
  28. try
  29. {
  30. var strSql = new StringBuilder();
  31. strSql.Append("SELECT t.* ");
  32. strSql.Append(" FROM StuPunishment t ");
  33. strSql.Append(" WHERE 1=1 ");
  34. var queryParam = queryJson.ToJObject();
  35. // 虚拟参数
  36. var dp = new DynamicParameters(new { });
  37. if (!queryParam["AcademicYearNo"].IsEmpty())
  38. {
  39. dp.Add("AcademicYearNo", queryParam["AcademicYearNo"].ToString(), DbType.String);
  40. strSql.Append(" AND t.AcademicYearNo = @AcademicYearNo ");
  41. }
  42. if (!queryParam["Semester"].IsEmpty())
  43. {
  44. dp.Add("Semester", queryParam["Semester"].ToString(), DbType.String);
  45. strSql.Append(" AND t.Semester = @Semester ");
  46. }
  47. if (!queryParam["StuName"].IsEmpty())
  48. {
  49. dp.Add("StuName", "%" + queryParam["StuName"].ToString() + "%", DbType.String);
  50. strSql.Append(" AND t.StuName Like @StuName ");
  51. }
  52. if (!queryParam["StuNo"].IsEmpty())
  53. {
  54. dp.Add("StuNo", "%" + queryParam["StuNo"].ToString() + "%", DbType.String);
  55. strSql.Append(" AND t.StuNo Like @StuNo ");
  56. }
  57. if (!queryParam["DeptNo"].IsEmpty())
  58. {
  59. dp.Add("DeptNo", queryParam["DeptNo"].ToString(), DbType.String);
  60. strSql.Append(" AND t.DeptNo = @DeptNo ");
  61. }
  62. if (!queryParam["MajorNo"].IsEmpty())
  63. {
  64. dp.Add("MajorNo", queryParam["MajorNo"].ToString(), DbType.String);
  65. strSql.Append(" AND t.MajorNo = @MajorNo ");
  66. }
  67. if (!queryParam["ClassNo"].IsEmpty())
  68. {
  69. dp.Add("ClassNo", queryParam["ClassNo"].ToString(), DbType.String);
  70. strSql.Append(" AND t.ClassNo = @ClassNo ");
  71. }
  72. if (!queryParam["PunishNo"].IsEmpty())
  73. {
  74. dp.Add("PunishNo", queryParam["PunishNo"].ToString(), DbType.String);
  75. strSql.Append(" AND t.PunishNo = @PunishNo ");
  76. }
  77. if (!queryParam["StartTime"].IsEmpty() && !queryParam["EndTime"].IsEmpty())
  78. {
  79. dp.Add("startTime", queryParam["StartTime"].ToDate(), DbType.DateTime);
  80. dp.Add("endTime", queryParam["EndTime"].ToDate(), DbType.DateTime);
  81. strSql.Append(" AND ( t.PunishDate >= @startTime AND t.PunishDate <= @endTime ) ");
  82. }
  83. return this.BaseRepository("CollegeMIS").FindList<StuPunishmentEntity>(strSql.ToString(), dp, pagination);
  84. }
  85. catch (Exception ex)
  86. {
  87. if (ex is ExceptionEx)
  88. {
  89. throw;
  90. }
  91. else
  92. {
  93. throw ExceptionEx.ThrowServiceException(ex);
  94. }
  95. }
  96. }
  97. /// <summary>
  98. /// 获取页面显示列表数据
  99. /// <summary>
  100. /// <param name="queryJson">查询参数</param>
  101. /// <returns></returns>
  102. public IEnumerable<StuPunishmentEntity> GetPageList(string queryJson)
  103. {
  104. try
  105. {
  106. var strSql = new StringBuilder();
  107. strSql.Append("SELECT t.* ");
  108. strSql.Append(" FROM StuPunishment t ");
  109. strSql.Append(" WHERE 1=1 ");
  110. var queryParam = queryJson.ToJObject();
  111. // 虚拟参数
  112. var dp = new DynamicParameters(new { });
  113. if (!queryParam["AcademicYearNo"].IsEmpty())
  114. {
  115. dp.Add("AcademicYearNo", queryParam["AcademicYearNo"].ToString(), DbType.String);
  116. strSql.Append(" AND t.AcademicYearNo = @AcademicYearNo ");
  117. }
  118. if (!queryParam["Semester"].IsEmpty())
  119. {
  120. dp.Add("Semester", queryParam["Semester"].ToString(), DbType.String);
  121. strSql.Append(" AND t.Semester = @Semester ");
  122. }
  123. if (!queryParam["StuName"].IsEmpty())
  124. {
  125. dp.Add("StuName", "%" + queryParam["StuName"].ToString() + "%", DbType.String);
  126. strSql.Append(" AND t.StuName Like @StuName ");
  127. }
  128. if (!queryParam["StuNo"].IsEmpty())
  129. {
  130. dp.Add("StuNo", "%" + queryParam["StuNo"].ToString() + "%", DbType.String);
  131. strSql.Append(" AND t.StuNo Like @StuNo ");
  132. }
  133. if (!queryParam["DeptNo"].IsEmpty())
  134. {
  135. dp.Add("DeptNo", queryParam["DeptNo"].ToString(), DbType.String);
  136. strSql.Append(" AND t.DeptNo = @DeptNo ");
  137. }
  138. if (!queryParam["MajorNo"].IsEmpty())
  139. {
  140. dp.Add("MajorNo", queryParam["MajorNo"].ToString(), DbType.String);
  141. strSql.Append(" AND t.MajorNo = @MajorNo ");
  142. }
  143. if (!queryParam["ClassNo"].IsEmpty())
  144. {
  145. dp.Add("ClassNo", queryParam["ClassNo"].ToString(), DbType.String);
  146. strSql.Append(" AND t.ClassNo = @ClassNo ");
  147. }
  148. return this.BaseRepository("CollegeMIS").FindList<StuPunishmentEntity>(strSql.ToString(), dp);
  149. }
  150. catch (Exception ex)
  151. {
  152. if (ex is ExceptionEx)
  153. {
  154. throw;
  155. }
  156. else
  157. {
  158. throw ExceptionEx.ThrowServiceException(ex);
  159. }
  160. }
  161. }
  162. public IEnumerable<StuPunishmentEntity> GetAllList()
  163. {
  164. try
  165. {
  166. return this.BaseRepository("CollegeMIS").FindList<StuPunishmentEntity>();
  167. }
  168. catch (Exception ex)
  169. {
  170. if (ex is ExceptionEx)
  171. {
  172. throw;
  173. }
  174. else
  175. {
  176. throw ExceptionEx.ThrowServiceException(ex);
  177. }
  178. }
  179. }
  180. /// <summary>
  181. /// 获取StuPunishment表实体数据
  182. /// <param name="keyValue">主键</param>
  183. /// <summary>
  184. /// <returns></returns>
  185. public StuPunishmentEntity GetStuPunishmentEntity(string keyValue)
  186. {
  187. try
  188. {
  189. var keyvalue = Convert.ToInt32(keyValue);
  190. return this.BaseRepository("CollegeMIS").FindEntity<StuPunishmentEntity>(keyvalue);
  191. }
  192. catch (Exception ex)
  193. {
  194. if (ex is ExceptionEx)
  195. {
  196. throw;
  197. }
  198. else
  199. {
  200. throw ExceptionEx.ThrowServiceException(ex);
  201. }
  202. }
  203. }
  204. #endregion
  205. #region 提交数据
  206. /// <summary>
  207. /// 删除实体数据
  208. /// <param name="keyValue">主键</param>
  209. /// <summary>
  210. /// <returns></returns>
  211. public void DeleteEntity(string keyValue)
  212. {
  213. try
  214. {
  215. var keyvalue = Convert.ToInt32(keyValue);
  216. this.BaseRepository("CollegeMIS").Delete<StuPunishmentEntity>(t => t.Id == keyvalue);
  217. }
  218. catch (Exception ex)
  219. {
  220. if (ex is ExceptionEx)
  221. {
  222. throw;
  223. }
  224. else
  225. {
  226. throw ExceptionEx.ThrowServiceException(ex);
  227. }
  228. }
  229. }
  230. /// <summary>
  231. /// 保存实体数据(新增、修改)
  232. /// <param name="keyValue">主键</param>
  233. /// <summary>
  234. /// <returns></returns>
  235. public void SaveEntity(string keyValue, StuPunishmentEntity entity)
  236. {
  237. try
  238. {
  239. if (!string.IsNullOrEmpty(keyValue))
  240. {
  241. entity.Modify(keyValue);
  242. this.BaseRepository("CollegeMIS").Update(entity);
  243. }
  244. else
  245. {
  246. entity.Create();
  247. this.BaseRepository("CollegeMIS").Insert(entity);
  248. }
  249. }
  250. catch (Exception ex)
  251. {
  252. if (ex is ExceptionEx)
  253. {
  254. throw;
  255. }
  256. else
  257. {
  258. throw ExceptionEx.ThrowServiceException(ex);
  259. }
  260. }
  261. }
  262. #endregion
  263. #region 扩展数据
  264. /// <summary>
  265. /// 获取学年学期列表
  266. /// </summary>
  267. /// <returns></returns>
  268. public IEnumerable<WebHelper.YearGrade> GetAcademicAndSemesterList()
  269. {
  270. try
  271. {
  272. var aa = this.BaseRepository("CollegeMIS").FindList<StuPunishmentEntity>();
  273. var aaa = aa.GroupBy(x => new { x.AcademicYearNo, x.Semester }).Select(x => new WebHelper.YearGrade()
  274. {
  275. text = string.Format("{0}学年第{1}学期", x.Key.AcademicYearNo, x.Key.Semester),
  276. value = string.Format("{0},{1}", x.Key.AcademicYearNo, x.Key.Semester)
  277. });
  278. return aaa;
  279. }
  280. catch (Exception ex)
  281. {
  282. if (ex is ExceptionEx)
  283. {
  284. throw;
  285. }
  286. else
  287. {
  288. throw ExceptionEx.ThrowServiceException(ex);
  289. }
  290. }
  291. }
  292. /// <summary>
  293. /// 获取页面显示列表数据
  294. /// <summary>
  295. /// <param name="queryJson">查询参数</param>
  296. /// <returns></returns>
  297. public IEnumerable<StuPunishmentEntity> GetPunishmentListByStuNo(string acdemic, string semester, string stuNo)
  298. {
  299. try
  300. {
  301. var result = this.BaseRepository("CollegeMIS").FindList<StuPunishmentEntity>(x => x.AcademicYearNo == acdemic && x.Semester == semester && x.StuNo == stuNo);
  302. return result;
  303. }
  304. catch (Exception ex)
  305. {
  306. if (ex is ExceptionEx)
  307. {
  308. throw;
  309. }
  310. else
  311. {
  312. throw ExceptionEx.ThrowServiceException(ex);
  313. }
  314. }
  315. }
  316. /// <summary>
  317. /// 获取页面显示列表数据
  318. /// <summary>
  319. /// <param name="queryJson">查询参数</param>
  320. /// <returns></returns>
  321. public IEnumerable<StuPunishmentEntity> GetPunishmentListByStuNo(string stuNo)
  322. {
  323. try
  324. {
  325. var result = this.BaseRepository("CollegeMIS").FindList<StuPunishmentEntity>(x => x.StuNo == stuNo);
  326. return result;
  327. }
  328. catch (Exception ex)
  329. {
  330. if (ex is ExceptionEx)
  331. {
  332. throw;
  333. }
  334. else
  335. {
  336. throw ExceptionEx.ThrowServiceException(ex);
  337. }
  338. }
  339. }
  340. /// <summary>
  341. /// 解除处分
  342. /// <param name="keyValue">主键</param>
  343. /// <summary>
  344. /// <returns></returns>
  345. public void DoCancelPunish(string keyValue, bool status)
  346. {
  347. try
  348. {
  349. var keyvalue = Convert.ToInt32(keyValue);
  350. if (status)
  351. {
  352. //解除处分
  353. this.BaseRepository("CollegeMIS").ExecuteBySql("update StuPunishment set IsCancelPunish=1,CancelPunishDate='" + DateTime.Now + "' where Id= " + keyValue);
  354. }
  355. else
  356. {
  357. //取消解除处分
  358. this.BaseRepository("CollegeMIS").ExecuteBySql("update StuPunishment set IsCancelPunish=0,CancelPunishDate=null where Id= " + keyValue);
  359. }
  360. }
  361. catch (Exception ex)
  362. {
  363. if (ex is ExceptionEx)
  364. {
  365. throw;
  366. }
  367. else
  368. {
  369. throw ExceptionEx.ThrowServiceException(ex);
  370. }
  371. }
  372. }
  373. #endregion
  374. }
  375. }