ExamSampleAppService.cs 6.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  1. using YBEE.EQM.Core;
  2. namespace YBEE.EQM.Application;
  3. /// <summary>
  4. /// 监测抽样方案管理服务
  5. /// </summary>
  6. [ApiDescriptionSettings(Name = "exam-sample")]
  7. [Route("exam/sample")]
  8. public class ExamSampleAppService : IDynamicApiController
  9. {
  10. private readonly IExamSampleService _examSampleService;
  11. public ExamSampleAppService(IExamSampleService examSampleService)
  12. {
  13. _examSampleService = examSampleService;
  14. }
  15. /// <summary>
  16. /// 添加监测抽样方案
  17. /// </summary>
  18. /// <param name="input"></param>
  19. /// <returns></returns>
  20. public async Task Add(AddExamSampleInput input)
  21. {
  22. await _examSampleService.Add(input);
  23. }
  24. /// <summary>
  25. /// 更新监测抽样方案
  26. /// </summary>
  27. /// <param name="input"></param>
  28. /// <returns></returns>
  29. public async Task Update(UpdateExamSampleInput input)
  30. {
  31. await _examSampleService.Update(input);
  32. }
  33. /// <summary>
  34. /// 复制抽样方案信息
  35. /// </summary>
  36. /// <param name="input"></param>
  37. /// <returns></returns>
  38. public async Task Duplicate(BaseId input)
  39. {
  40. await _examSampleService.Duplicate(input);
  41. }
  42. /// <summary>
  43. /// 删除监测抽样方案
  44. /// </summary>
  45. /// <param name="input"></param>
  46. /// <returns></returns>
  47. public async Task Del(BaseId input)
  48. {
  49. await _examSampleService.Del(input);
  50. }
  51. /// <summary>
  52. /// 保存全抽班级ID列表
  53. /// </summary>
  54. /// <param name="input"></param>
  55. /// <returns></returns>
  56. public async Task SaveExamSampleAllClasses(SaveExamSampleAllClasses input)
  57. {
  58. await _examSampleService.SaveExamSampleAllClasses(input);
  59. }
  60. /// <summary>
  61. /// 切换全抽班级
  62. /// </summary>
  63. /// <param name="input"></param>
  64. /// <returns></returns>
  65. public async Task SwitchExamSampleAllClass(SwitchExamSampleAllClassInput input)
  66. {
  67. await _examSampleService.SwitchExamSampleAllClass(input);
  68. }
  69. /// <summary>
  70. /// 选定方案
  71. /// </summary>
  72. /// <param name="input"></param>
  73. /// <returns></returns>
  74. public async Task SelectSample(BaseId input)
  75. {
  76. await _examSampleService.SelectSample(input);
  77. }
  78. /// <summary>
  79. /// 执行抽样
  80. /// </summary>
  81. /// <param name="input">抽样方案ID</param>
  82. /// <returns></returns>
  83. /// <exception cref="Exception"></exception>
  84. public async Task ExecuteSample(BaseId input)
  85. {
  86. await _examSampleService.ExecuteSample(input);
  87. }
  88. /// <summary>
  89. /// 导出抽样方案存档文件
  90. /// </summary>
  91. /// <param name="input"></param>
  92. /// <returns></returns>
  93. public async Task<IActionResult> ExportToArchived(BaseId input)
  94. {
  95. var (fileName, fileBytes) = await _examSampleService.ExportToArchived(input.Id, false);
  96. return new FileContentResult(fileBytes, "application/octet-stream")
  97. {
  98. FileDownloadName = fileName,
  99. };
  100. }
  101. /// <summary>
  102. /// 导出给印刷厂和网阅机构文件
  103. /// </summary>
  104. /// <param name="input"></param>
  105. /// <returns></returns>
  106. public async Task<IActionResult> ExportToPrintshop(BaseId input)
  107. {
  108. var (fileName, fileBytes) = await _examSampleService.ExportToArchived(input.Id, true);
  109. return new FileContentResult(fileBytes, "application/octet-stream")
  110. {
  111. FileDownloadName = fileName,
  112. };
  113. }
  114. /// <summary>
  115. /// 导出给学校
  116. /// </summary>
  117. /// <param name="input"></param>
  118. /// <returns></returns>
  119. public async Task<IActionResult> ExportToOrg(BaseId input)
  120. {
  121. var (fileName, fileBytes) = await _examSampleService.ExportToOrg(input.Id);
  122. return new FileContentResult(fileBytes, "application/octet-stream")
  123. {
  124. FileDownloadName = fileName,
  125. };
  126. }
  127. /// <summary>
  128. /// 导出抽样统计表
  129. /// </summary>
  130. /// <param name="input"></param>
  131. /// <returns></returns>
  132. public async Task<IActionResult> ExportSampleCount(BaseId input)
  133. {
  134. var (fileName, fileBytes) = await _examSampleService.ExportSampleCount(input.Id);
  135. return new FileContentResult(fileBytes, "application/octet-stream")
  136. {
  137. FileDownloadName = fileName,
  138. };
  139. }
  140. /// <summary>
  141. /// 导出学校抽样统计表
  142. /// </summary>
  143. /// <param name="input"></param>
  144. /// <returns></returns>
  145. public async Task<IActionResult> ExportSampleCountToOrg(BaseId input)
  146. {
  147. var (fileName, fileBytes) = await _examSampleService.ExportSampleCountToOrg(input.Id);
  148. return new FileContentResult(fileBytes, "application/octet-stream")
  149. {
  150. FileDownloadName = fileName,
  151. };
  152. }
  153. /// <summary>
  154. /// 根据ID获取抽样方案
  155. /// </summary>
  156. /// <param name="id"></param>
  157. /// <returns></returns>
  158. public async Task<ExamSampleOutput> GetById([FromQuery][Required] int id)
  159. {
  160. return await _examSampleService.GetById(id);
  161. }
  162. /// <summary>
  163. /// 根据监测计划ID获取全部抽样方案
  164. /// </summary>
  165. /// <param name="examPlanId"></param>
  166. /// <returns></returns>
  167. public async Task<List<ExamSampleOutput>> GetListByExamPlanId([FromQuery][Required] int examPlanId)
  168. {
  169. return await _examSampleService.GetListByExamPlanId(examPlanId);
  170. }
  171. /// <summary>
  172. /// 查询已发布抽样
  173. /// </summary>
  174. /// <param name="examDataPublishId">监测发布内容ID</param>
  175. /// <param name="type">抽样数据发布类型</param>
  176. /// <returns></returns>
  177. public async Task<ExamSamplePlanOutput> GetByExamDataPublishId([FromQuery][Required] int examDataPublishId, [FromQuery][Required] DataPublishType type)
  178. {
  179. return await _examSampleService.GetByExamDataPublishId(examDataPublishId, type);
  180. }
  181. /// <summary>
  182. /// 获取抽样统计表
  183. /// </summary>
  184. /// <param name="id"></param>
  185. /// <returns></returns>
  186. public async Task<List<ExamSampleCountOutput>> GetSampleCountListById([FromQuery][Required] int id)
  187. {
  188. return await _examSampleService.GetSampleCountListById(id);
  189. }
  190. /// <summary>
  191. /// 获取学校抽样统计表
  192. /// </summary>
  193. /// <param name="id"></param>
  194. /// <returns></returns>
  195. public async Task<List<ExamSampleCountOutput>> GetOrgSampleCountListById([FromQuery][Required] int id)
  196. {
  197. return await _examSampleService.GetOrgSampleCountListById(id);
  198. }
  199. }