ExamAbsentReplaceAppService.cs 5.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. using YBEE.EQM.Core;
  2. namespace YBEE.EQM.Application;
  3. /// <summary>
  4. /// 缺测替补管理服务
  5. /// </summary>
  6. [ApiDescriptionSettings(Name = "exam-absent-replace")]
  7. [Route("exam/absent/replace")]
  8. public class ExamAbsentReplaceAppService : IDynamicApiController
  9. {
  10. private readonly IExamAbsentReplaceService _examAbsentReplaceService;
  11. private readonly IResourceFileService _resourceFileService;
  12. public ExamAbsentReplaceAppService(IExamAbsentReplaceService examAbsentReplaceService, IResourceFileService resourceFileService)
  13. {
  14. _examAbsentReplaceService = examAbsentReplaceService;
  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<UploadExamAbsentReplaceOutput>> 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 _examAbsentReplaceService.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(ImportExamAbsentReplaceInput input)
  46. {
  47. return await _examAbsentReplaceService.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(AddExamAbsentReplaceInput input)
  57. {
  58. await _examAbsentReplaceService.Add(input);
  59. }
  60. /// <summary>
  61. /// 更新监测缺测替补
  62. /// </summary>
  63. /// <param name="input"></param>
  64. /// <returns></returns>
  65. public async Task Update(UpdateExamAbsentReplaceInput input)
  66. {
  67. await _examAbsentReplaceService.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 _examAbsentReplaceService.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 _examAbsentReplaceService.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 _examAbsentReplaceService.Del(input);
  102. }
  103. /// <summary>
  104. /// 清空监测缺测替补
  105. /// </summary>
  106. /// <param name="input"></param>
  107. /// <returns></returns>
  108. public async Task Clear(ClearExamAbsentReplaceInput input)
  109. {
  110. await _examAbsentReplaceService.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 _examAbsentReplaceService.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<ExamAbsentReplaceOutput>> QueryPageList(ExamAbsentReplacePageInput input)
  133. {
  134. return await _examAbsentReplaceService.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<ExamAbsentReplaceCountOutput> GetOrgGradeClassStudentCount(int examPlanId, short? sysOrgId = null)
  143. {
  144. return await _examAbsentReplaceService.GetOrgGradeClassStudentCount(examPlanId, sysOrgId);
  145. }
  146. /// <summary>
  147. /// 获取状态数量
  148. /// </summary>
  149. /// <returns></returns>
  150. public async Task<List<StatusCount>> QueryStatusCount(ExamAbsentReplacePageInput input)
  151. {
  152. return await _examAbsentReplaceService.QueryStatusCount(input);
  153. }
  154. #endregion
  155. }