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.
 
 
 
 
 
 

229 line
8.4 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-03-01 17:26
  15. /// 描 述:教材征订管理
  16. /// </summary>
  17. public class TextBookSolSubService : 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<TextBookSolSubEntity> 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 TextBookSolSub t ");
  36. strSql.Append(" WHERE 1=1 ");
  37. var queryParam = queryJson.ToJObject();
  38. // 虚拟参数
  39. var dp = new DynamicParameters(new { });
  40. if (!queryParam["StartTime"].IsEmpty() && !queryParam["EndTime"].IsEmpty())
  41. {
  42. dp.Add("startTime", queryParam["StartTime"].ToDate(), DbType.DateTime);
  43. dp.Add("endTime", queryParam["EndTime"].ToDate(), DbType.DateTime);
  44. strSql.Append(" AND ( t.CreateTime >= @startTime AND t.CreateTime <= @endTime ) ");
  45. }
  46. if (!queryParam["DeptNo"].IsEmpty())
  47. {
  48. dp.Add("DeptNo", queryParam["DeptNo"].ToString(), DbType.String);
  49. strSql.Append(" AND t.DeptNo = @DeptNo ");
  50. }
  51. if (!queryParam["MajorNo"].IsEmpty())
  52. {
  53. dp.Add("MajorNo", queryParam["MajorNo"].ToString(), DbType.String);
  54. strSql.Append(" AND t.MajorNo = @MajorNo ");
  55. }
  56. if (!queryParam["LessonNo"].IsEmpty())
  57. {
  58. dp.Add("LessonNo", queryParam["LessonNo"].ToString(), DbType.String);
  59. strSql.Append(" AND t.LessonNo = @LessonNo ");
  60. }
  61. if (!queryParam["AcademicYearNo"].IsEmpty())
  62. {
  63. dp.Add("AcademicYearNo", queryParam["AcademicYearNo"].ToString(), DbType.String);
  64. strSql.Append(" AND t.AcademicYearNo = @AcademicYearNo ");
  65. }
  66. if (!queryParam["Semester"].IsEmpty())
  67. {
  68. dp.Add("Semester", queryParam["Semester"].ToString(), DbType.String);
  69. strSql.Append(" AND t.Semester = @Semester ");
  70. }
  71. if (!queryParam["PublishNo"].IsEmpty())
  72. {
  73. dp.Add("PublishNo", "%" + queryParam["PublishNo"].ToString() + "%", DbType.String);
  74. strSql.Append(" AND t.PublishNo Like @PublishNo ");
  75. }
  76. return this.BaseRepository("CollegeMIS").FindList<TextBookSolSubEntity>(strSql.ToString(), dp, pagination);
  77. }
  78. catch (Exception ex)
  79. {
  80. if (ex is ExceptionEx)
  81. {
  82. throw;
  83. }
  84. else
  85. {
  86. throw ExceptionEx.ThrowServiceException(ex);
  87. }
  88. }
  89. }
  90. /// <summary>
  91. /// 获取TextBookSolSub表实体数据
  92. /// </summary>
  93. /// <param name="keyValue">主键</param>
  94. /// <returns></returns>
  95. public TextBookSolSubEntity GetTextBookSolSubEntity(string keyValue)
  96. {
  97. try
  98. {
  99. return this.BaseRepository("CollegeMIS").FindEntity<TextBookSolSubEntity>(keyValue);
  100. }
  101. catch (Exception ex)
  102. {
  103. if (ex is ExceptionEx)
  104. {
  105. throw;
  106. }
  107. else
  108. {
  109. throw ExceptionEx.ThrowServiceException(ex);
  110. }
  111. }
  112. }
  113. /// <summary>
  114. /// 获取页面显示列表数据
  115. /// </summary>
  116. /// <param name="pagination">查询参数</param>
  117. /// <param name="queryJson">查询参数</param>
  118. /// <returns></returns>
  119. public IEnumerable<TextBookSolSubEntity> GetStatistics(Pagination pagination, string queryJson)
  120. {
  121. try
  122. {
  123. var strSql = new StringBuilder();
  124. strSql.Append(@"select t.AcademicYearNo,t.Semester,tbi.PublishNo,t.TextBookName,t.Edition,t.Price,
  125. t.FirstAuthor,t.OtherAuthor,tbi.Impression,tbi.TextBookType,tbi.TextBookNature,tbi.IsWorkBook,tbi.IsTeachConsult,tbi.Pubdate,tbi.Publisher,sum(OrderNum) as DGNum
  126. ");
  127. strSql.Append(" from TextBookSolSub t left join TextBookInfo tbi on tbi. PublishNo =t.PublishNo ");
  128. strSql.Append(" where 1=1 ");
  129. var queryParam = queryJson.ToJObject();
  130. // 虚拟参数
  131. if (!queryParam["AcademicYearNo"].IsEmpty())
  132. {
  133. strSql.Append(" AND t.AcademicYearNo = " + queryParam["AcademicYearNo"].ToString() + " ");
  134. }
  135. if (!queryParam["Semester"].IsEmpty())
  136. {
  137. strSql.Append(" AND t.Semester = " + queryParam["Semester"].ToString() + " ");
  138. }
  139. if (!queryParam["TextBookName"].IsEmpty())
  140. {
  141. strSql.Append(" AND t.TextBookName like '%" + queryParam["TextBookName"].ToString() + "%' ");
  142. }
  143. strSql.Append(@" Group By t.AcademicYearNo,t.Semester,tbi.PublishNo,t.TextBookName,t.Edition,t.Price,
  144. t.FirstAuthor,t.OtherAuthor,tbi.Impression,tbi.TextBookType,tbi.TextBookNature,tbi.IsWorkBook,tbi.IsTeachConsult,tbi.Pubdate,tbi.Publisher
  145. ");
  146. return this.BaseRepository("CollegeMIS").FindList<TextBookSolSubEntity>(strSql.ToString(), pagination);
  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. #endregion
  161. #region 提交数据
  162. /// <summary>
  163. /// 删除实体数据
  164. /// </summary>
  165. /// <param name="keyValue">主键</param>
  166. public void DeleteEntity(string keyValue)
  167. {
  168. try
  169. {
  170. this.BaseRepository("CollegeMIS").Delete<TextBookSolSubEntity>(t => t.ID == keyValue);
  171. }
  172. catch (Exception ex)
  173. {
  174. if (ex is ExceptionEx)
  175. {
  176. throw;
  177. }
  178. else
  179. {
  180. throw ExceptionEx.ThrowServiceException(ex);
  181. }
  182. }
  183. }
  184. /// <summary>
  185. /// 保存实体数据(新增、修改)
  186. /// </summary>
  187. /// <param name="keyValue">主键</param>
  188. /// <param name="entity">实体</param>
  189. public void SaveEntity(string keyValue, TextBookSolSubEntity entity)
  190. {
  191. try
  192. {
  193. if (!string.IsNullOrEmpty(keyValue))
  194. {
  195. entity.Modify(keyValue);
  196. this.BaseRepository("CollegeMIS").Update(entity);
  197. }
  198. else
  199. {
  200. entity.Create();
  201. this.BaseRepository("CollegeMIS").Insert(entity);
  202. }
  203. }
  204. catch (Exception ex)
  205. {
  206. if (ex is ExceptionEx)
  207. {
  208. throw;
  209. }
  210. else
  211. {
  212. throw ExceptionEx.ThrowServiceException(ex);
  213. }
  214. }
  215. }
  216. #endregion
  217. }
  218. }