123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170 |
- using YBEE.EQM.Core;
- namespace YBEE.EQM.Application;
- /// <summary>
- /// 监测特殊学生上报管理服务
- /// </summary>
- [ApiDescriptionSettings(Name = "exam-special-student")]
- [Route("exam/special/student")]
- public class ExamSpecialStudentAppService : IDynamicApiController
- {
- private readonly IExamSpecialStudentService _examSpecialStudentService;
- private readonly IResourceFileService _resourceFileService;
- public ExamSpecialStudentAppService(IExamSpecialStudentService examSpecialStudentService, IResourceFileService resourceFileService)
- {
- _examSpecialStudentService = examSpecialStudentService;
- _resourceFileService = resourceFileService;
- }
- #region 批量导入
- /// <summary>
- /// 上传批量导入文件
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- [RequestSizeLimit(long.MaxValue)]
- [RequestFormLimits(MultipartBodyLengthLimit = long.MaxValue)]
- public async Task<UploadExamDataOutput<UploadExamSpecialStudentOutput>> Upload([FromForm] UploadExamDataInput input)
- {
- string fileExt = Path.GetExtension(input.File.FileName).ToLower();
- if (fileExt != ".xls" && fileExt != ".xlsx")
- {
- throw Oops.Oh(ErrorCode.E1010);
- }
- string filePath = Path.Combine(FileUtil.GetTempFileRoot(), $"{Guid.NewGuid()}{fileExt}");
- using FileStream fs = File.Create(filePath);
- await input.File.CopyToAsync(fs);
- await fs.FlushAsync();
- fs.Close();
- var ret = await _examSpecialStudentService.Upload(filePath, input.ExamPlanId);
- return ret;
- }
- /// <summary>
- /// 批量导入监测特殊学生
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- public async Task<int> Import(ImportExamSpecialStudentInput input)
- {
- return await _examSpecialStudentService.Import(input);
- }
- #endregion
- #region 创建编辑
- /// <summary>
- /// 添加监测特殊学生
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- public async Task Add(AddExamSpecialStudentInput input)
- {
- await _examSpecialStudentService.Add(input);
- }
- /// <summary>
- /// 更新监测特殊学生
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- public async Task Update(UpdateExamSpecialStudentInput input)
- {
- await _examSpecialStudentService.Update(input);
- }
- /// <summary>
- /// 上传特殊学生佐证材料
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- [RequestSizeLimit(1024 * 1024 * 20)]
- [RequestFormLimits(MultipartBodyLengthLimit = long.MaxValue)]
- public async Task UploadAttachment([FromForm] UploadResourceFileInput input)
- {
- var rfile = await _resourceFileService.Upload(input);
- var addParams = rfile.Adapt<AddExamSpecialStudentAttachmentInput>();
- addParams.ExamSpecialStudentId = (int)input.SourceId;
- addParams.FileId = rfile.Id;
- addParams.ThumbFileId = rfile.ThumbResourceFile?.Id;
- await _examSpecialStudentService.AddAttachment(addParams);
- }
- /// <summary>
- /// 删除特殊学生佐证材料
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- public async Task DelAttachment(DeleteExamSpecialStudentAttachmentInput input)
- {
- await _examSpecialStudentService.DelAttachment(input);
- }
- /// <summary>
- /// 删除监测特殊学生
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- public async Task Del(BaseId input)
- {
- await _examSpecialStudentService.Del(input);
- }
- /// <summary>
- /// 清空监测特殊学生
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- public async Task Clear(ClearExamSpecialStudentInput input)
- {
- await _examSpecialStudentService.Clear(input);
- }
- /// <summary>
- /// 导出监测特殊学生上报打印表格
- /// </summary>
- /// <param name="examPlanId"></param>
- /// <returns></returns>
- public async Task<IActionResult> ExportPrintTable(int examPlanId)
- {
- var bs = await _examSpecialStudentService.ExportPrintTable(examPlanId);
- return new FileContentResult(bs, "application/vnd.openxmlformats-officedocument.wordprocessingml.document")
- {
- FileDownloadName = "特殊学生明细表.docx"
- };
- }
- #endregion
- #region 查询统计
- /// <summary>
- /// 分页查询监测特殊学生列表
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- public async Task<PageResult<ExamSpecialStudentOutput>> QueryPageList(ExamSpecialStudentPageInput input)
- {
- return await _examSpecialStudentService.QueryPageList(input);
- }
- /// <summary>
- /// 获取机构班级特殊学生上报人数统计列表
- /// </summary>
- /// <param name="examPlanId"></param>
- /// <param name="sysOrgId"></param>
- /// <returns></returns>
- public async Task<ExamSpecialStudentCountOutput> GetOrgGradeClassStudentCount(int examPlanId, short? sysOrgId = null)
- {
- return await _examSpecialStudentService.GetOrgGradeClassStudentCount(examPlanId, sysOrgId);
- }
- /// <summary>
- /// 获取状态数量
- /// </summary>
- /// <returns></returns>
- public async Task<List<StatusCount>> QueryStatusCount(ExamSpecialStudentPageInput input)
- {
- return await _examSpecialStudentService.QueryStatusCount(input);
- }
- #endregion
- //[HttpGet]
- //[AllowAnonymous]
- //public async Task RefreshFileSize()
- //{
- // await _examSpecialStudentService.RefreshFileSize();
- //}
- }
|