ExamSpecialStudentAppService.cs 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170
  1. using YBEE.EQM.Core;
  2. namespace YBEE.EQM.Application;
  3. /// <summary>
  4. /// 监测特殊学生上报管理服务
  5. /// </summary>
  6. [ApiDescriptionSettings(Name = "exam-special-student")]
  7. [Route("exam/special/student")]
  8. public class ExamSpecialStudentAppService : IDynamicApiController
  9. {
  10. private readonly IExamSpecialStudentService _examSpecialStudentService;
  11. private readonly IResourceFileService _resourceFileService;
  12. public ExamSpecialStudentAppService(IExamSpecialStudentService examSpecialStudentService, IResourceFileService resourceFileService)
  13. {
  14. _examSpecialStudentService = examSpecialStudentService;
  15. _resourceFileService = resourceFileService;
  16. }
  17. #region 批量导入
  18. /// <summary>
  19. /// 上传批量导入文件
  20. /// </summary>
  21. /// <param name="input"></param>
  22. /// <returns></returns>
  23. [RequestSizeLimit(long.MaxValue)]
  24. [RequestFormLimits(MultipartBodyLengthLimit = long.MaxValue)]
  25. public async Task<UploadExamDataOutput<UploadExamSpecialStudentOutput>> Upload([FromForm] UploadExamDataInput input)
  26. {
  27. string fileExt = Path.GetExtension(input.File.FileName).ToLower();
  28. if (fileExt != ".xls" && fileExt != ".xlsx")
  29. {
  30. throw Oops.Oh(ErrorCode.E1010);
  31. }
  32. string filePath = Path.Combine(FileUtil.GetTempFileRoot(), $"{Guid.NewGuid()}{fileExt}");
  33. using FileStream fs = File.Create(filePath);
  34. await input.File.CopyToAsync(fs);
  35. await fs.FlushAsync();
  36. fs.Close();
  37. var ret = await _examSpecialStudentService.Upload(filePath, input.ExamPlanId);
  38. return ret;
  39. }
  40. /// <summary>
  41. /// 批量导入监测特殊学生
  42. /// </summary>
  43. /// <param name="input"></param>
  44. /// <returns></returns>
  45. public async Task<int> Import(ImportExamSpecialStudentInput input)
  46. {
  47. return await _examSpecialStudentService.Import(input);
  48. }
  49. #endregion
  50. #region 创建编辑
  51. /// <summary>
  52. /// 添加监测特殊学生
  53. /// </summary>
  54. /// <param name="input"></param>
  55. /// <returns></returns>
  56. public async Task Add(AddExamSpecialStudentInput input)
  57. {
  58. await _examSpecialStudentService.Add(input);
  59. }
  60. /// <summary>
  61. /// 更新监测特殊学生
  62. /// </summary>
  63. /// <param name="input"></param>
  64. /// <returns></returns>
  65. public async Task Update(UpdateExamSpecialStudentInput input)
  66. {
  67. await _examSpecialStudentService.Update(input);
  68. }
  69. /// <summary>
  70. /// 上传特殊学生佐证材料
  71. /// </summary>
  72. /// <param name="input"></param>
  73. /// <returns></returns>
  74. [RequestSizeLimit(1024 * 1024 * 20)]
  75. [RequestFormLimits(MultipartBodyLengthLimit = long.MaxValue)]
  76. public async Task UploadAttachment([FromForm] UploadResourceFileInput input)
  77. {
  78. var rfile = await _resourceFileService.Upload(input);
  79. var addParams = rfile.Adapt<AddAttachmentInput>();
  80. //addParams.SourceId = (int)input.SourceId;
  81. //addParams.FileId = rfile.Id;
  82. //addParams.ThumbFileId = rfile.ThumbResourceFile?.Id;
  83. await _examSpecialStudentService.AddAttachment(addParams);
  84. }
  85. /// <summary>
  86. /// 删除特殊学生佐证材料
  87. /// </summary>
  88. /// <param name="input"></param>
  89. /// <returns></returns>
  90. public async Task DelAttachment(DeleteAttachmentInput input)
  91. {
  92. await _examSpecialStudentService.DelAttachment(input);
  93. }
  94. /// <summary>
  95. /// 删除监测特殊学生
  96. /// </summary>
  97. /// <param name="input"></param>
  98. /// <returns></returns>
  99. public async Task Del(BaseId input)
  100. {
  101. await _examSpecialStudentService.Del(input);
  102. }
  103. /// <summary>
  104. /// 清空监测特殊学生
  105. /// </summary>
  106. /// <param name="input"></param>
  107. /// <returns></returns>
  108. public async Task Clear(ClearExamSpecialStudentInput input)
  109. {
  110. await _examSpecialStudentService.Clear(input);
  111. }
  112. /// <summary>
  113. /// 导出监测特殊学生上报打印表格
  114. /// </summary>
  115. /// <param name="examPlanId"></param>
  116. /// <returns></returns>
  117. public async Task<IActionResult> ExportPrintTable(int examPlanId)
  118. {
  119. var bs = await _examSpecialStudentService.ExportPrintTable(examPlanId);
  120. return new FileContentResult(bs, "application/vnd.openxmlformats-officedocument.wordprocessingml.document")
  121. {
  122. FileDownloadName = "特殊学生明细表.docx"
  123. };
  124. }
  125. #endregion
  126. #region 查询统计
  127. /// <summary>
  128. /// 分页查询监测特殊学生列表
  129. /// </summary>
  130. /// <param name="input"></param>
  131. /// <returns></returns>
  132. public async Task<PageResult<ExamSpecialStudentOutput>> QueryPageList(ExamSpecialStudentPageInput input)
  133. {
  134. return await _examSpecialStudentService.QueryPageList(input);
  135. }
  136. /// <summary>
  137. /// 获取机构班级特殊学生上报人数统计列表
  138. /// </summary>
  139. /// <param name="examPlanId"></param>
  140. /// <param name="sysOrgId"></param>
  141. /// <returns></returns>
  142. public async Task<ExamSpecialStudentCountOutput> GetOrgGradeClassStudentCount(int examPlanId, short? sysOrgId = null)
  143. {
  144. return await _examSpecialStudentService.GetOrgGradeClassStudentCount(examPlanId, sysOrgId);
  145. }
  146. /// <summary>
  147. /// 获取状态数量
  148. /// </summary>
  149. /// <returns></returns>
  150. public async Task<List<StatusCount>> QueryStatusCount(ExamSpecialStudentPageInput input)
  151. {
  152. return await _examSpecialStudentService.QueryStatusCount(input);
  153. }
  154. #endregion
  155. //[HttpGet]
  156. //[AllowAnonymous]
  157. //public async Task RefreshFileSize()
  158. //{
  159. // await _examSpecialStudentService.RefreshFileSize();
  160. //}
  161. }