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.
 
 
 
 
 
 

223 lines
7.5 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. using Learun.Application.TwoDevelopment.EducationalAdministration;
  9. namespace Learun.Application.TwoDevelopment.LogisticsManagement
  10. {
  11. /// <summary>
  12. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  13. /// Copyright (c) 2013-2018 北京泉江科技有限公司
  14. /// 创 建:超级管理员
  15. /// 日 期:2020-05-19 11:37
  16. /// 描 述:心理预约管理
  17. /// </summary>
  18. public class APAppointmentPsychologistService : RepositoryFactory
  19. {
  20. #region 获取数据
  21. /// <summary>
  22. /// 获取页面显示列表数据
  23. /// <summary>
  24. /// <param name="queryJson">查询参数</param>
  25. /// <returns></returns>
  26. public IEnumerable<APAppointmentPsychologistEntity> GetPageList(Pagination pagination, string queryJson)
  27. {
  28. try
  29. {
  30. var strSql = new StringBuilder();
  31. strSql.Append("SELECT ");
  32. strSql.Append(@"
  33. t.PID,
  34. t.PStuNo,
  35. t.PDeptNo,
  36. t.PMajorNo,
  37. t.PClassNo,
  38. t.PTime,
  39. t.PEmpNo,
  40. t.PAgreee,
  41. t.Remark
  42. ");
  43. strSql.Append(" FROM APAppointmentPsychologist t ");
  44. strSql.Append(" WHERE 1=1 ");
  45. var queryParam = queryJson.ToJObject();
  46. // 虚拟参数
  47. var dp = new DynamicParameters(new { });
  48. if (!queryParam["StartTime"].IsEmpty() && !queryParam["EndTime"].IsEmpty())
  49. {
  50. dp.Add("startTime", queryParam["StartTime"].ToDate(), DbType.DateTime);
  51. dp.Add("endTime", queryParam["EndTime"].ToDate(), DbType.DateTime);
  52. strSql.Append(" AND ( t.PTime >= @startTime AND t.PTime <= @endTime ) ");
  53. }
  54. if (!queryParam["PDeptNo"].IsEmpty())
  55. {
  56. dp.Add("PDeptNo", queryParam["PDeptNo"].ToString(), DbType.String);
  57. strSql.Append(" AND t.PDeptNo = @PDeptNo ");
  58. }
  59. if (!queryParam["PMajorNo"].IsEmpty())
  60. {
  61. dp.Add("PMajorNo", queryParam["PMajorNo"].ToString(), DbType.String);
  62. strSql.Append(" AND t.PMajorNo = @PMajorNo ");
  63. }
  64. if (!queryParam["PClassNo"].IsEmpty())
  65. {
  66. dp.Add("PClassNo", queryParam["PClassNo"].ToString(), DbType.String);
  67. strSql.Append(" AND t.PClassNo = @PClassNo ");
  68. }
  69. if (!queryParam["PEmpNo"].IsEmpty())
  70. {
  71. dp.Add("PEmpNo", queryParam["PEmpNo"].ToString(), DbType.String);
  72. strSql.Append(" AND t.PEmpNo = @PEmpNo ");
  73. }
  74. if (!queryParam["PTime"].IsEmpty())
  75. {
  76. dp.Add("PTime", queryParam["PTime"].ToString(), DbType.String);
  77. strSql.Append(" AND t.PTime = @PTime ");
  78. }
  79. if (!queryParam["PStuNo"].IsEmpty())
  80. {
  81. dp.Add("PStuNo", queryParam["PStuNo"].ToString(), DbType.String);
  82. strSql.Append(" AND t.PStuNo = @PStuNo ");
  83. }
  84. return this.BaseRepository("CollegeMIS").FindList<APAppointmentPsychologistEntity>(strSql.ToString(), dp, pagination);
  85. }
  86. catch (Exception ex)
  87. {
  88. if (ex is ExceptionEx)
  89. {
  90. throw;
  91. }
  92. else
  93. {
  94. throw ExceptionEx.ThrowServiceException(ex);
  95. }
  96. }
  97. }
  98. /// <summary>
  99. /// 获取APAppointmentPsychologist表实体数据
  100. /// <param name="keyValue">主键</param>
  101. /// <summary>
  102. /// <returns></returns>
  103. public APAppointmentPsychologistEntity GetAPAppointmentPsychologistEntity(string keyValue)
  104. {
  105. try
  106. {
  107. return this.BaseRepository("CollegeMIS").FindEntity<APAppointmentPsychologistEntity>(keyValue);
  108. }
  109. catch (Exception ex)
  110. {
  111. if (ex is ExceptionEx)
  112. {
  113. throw;
  114. }
  115. else
  116. {
  117. throw ExceptionEx.ThrowServiceException(ex);
  118. }
  119. }
  120. }
  121. #endregion
  122. #region 提交数据
  123. /// <summary>
  124. /// 删除实体数据
  125. /// <param name="keyValue">主键</param>
  126. /// <summary>
  127. /// <returns></returns>
  128. public void DeleteEntity(string keyValue)
  129. {
  130. try
  131. {
  132. this.BaseRepository("CollegeMIS").Delete<APAppointmentPsychologistEntity>(t => t.PID == keyValue);
  133. }
  134. catch (Exception ex)
  135. {
  136. if (ex is ExceptionEx)
  137. {
  138. throw;
  139. }
  140. else
  141. {
  142. throw ExceptionEx.ThrowServiceException(ex);
  143. }
  144. }
  145. }
  146. /// <summary>
  147. /// 通过预约
  148. /// <param name="keyValue">主键</param>
  149. /// <summary>
  150. /// <returns></returns>
  151. public void SuccessAppointment(string keyValue)
  152. {
  153. try
  154. {
  155. var sql = $"UPDATE dbo.APAppointmentPsychologist SET PAgreee='true' WHERE PID='{keyValue}'";
  156. this.BaseRepository("CollegeMIS").ExecuteBySql(sql);
  157. }
  158. catch (Exception ex)
  159. {
  160. if (ex is ExceptionEx)
  161. {
  162. throw;
  163. }
  164. else
  165. {
  166. throw ExceptionEx.ThrowServiceException(ex);
  167. }
  168. }
  169. }
  170. /// <summary>
  171. /// 保存实体数据(新增、修改)
  172. /// <param name="keyValue">主键</param>
  173. /// <summary>
  174. /// <returns></returns>
  175. public void SaveEntity(string keyValue, APAppointmentPsychologistEntity entity)
  176. {
  177. try
  178. {
  179. if (!string.IsNullOrEmpty(keyValue))
  180. {
  181. entity.Modify(keyValue);
  182. this.BaseRepository("CollegeMIS").Update(entity);
  183. }
  184. else
  185. {
  186. //获取当前学生的名字、系、专业、班级
  187. var loginUser = LoginUserInfo.Get();
  188. var userEntity = this.BaseRepository("CollegeMIS")
  189. .FindEntity<StuInfoBasicEntity>(a => a.StuNo == loginUser.account);
  190. entity.PStuNo = userEntity?.StuNo;
  191. entity.PDeptNo = userEntity?.DeptNo;
  192. entity.PMajorNo = userEntity?.MajorNo;
  193. entity.PClassNo = userEntity?.ClassNo;
  194. entity.Create();
  195. this.BaseRepository("CollegeMIS").Insert(entity);
  196. }
  197. }
  198. catch (Exception ex)
  199. {
  200. if (ex is ExceptionEx)
  201. {
  202. throw;
  203. }
  204. else
  205. {
  206. throw ExceptionEx.ThrowServiceException(ex);
  207. }
  208. }
  209. }
  210. #endregion
  211. }
  212. }