using YBEE.EQM.Core;
namespace YBEE.EQM.Application;
///
/// 监测特殊学生上报管理服务
///
[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 批量导入
///
/// 上传批量导入文件
///
///
///
[RequestSizeLimit(long.MaxValue)]
[RequestFormLimits(MultipartBodyLengthLimit = long.MaxValue)]
public async Task> 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;
}
///
/// 批量导入监测特殊学生
///
///
///
public async Task Import(ImportExamSpecialStudentInput input)
{
return await _examSpecialStudentService.Import(input);
}
#endregion
#region 创建编辑
///
/// 添加监测特殊学生
///
///
///
public async Task Add(AddExamSpecialStudentInput input)
{
await _examSpecialStudentService.Add(input);
}
///
/// 更新监测特殊学生
///
///
///
public async Task Update(UpdateExamSpecialStudentInput input)
{
await _examSpecialStudentService.Update(input);
}
///
/// 上传特殊学生佐证材料
///
///
///
[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();
addParams.ExamSpecialStudentId = (int)input.SourceId;
addParams.FileId = rfile.Id;
addParams.ThumbFileId = rfile.ThumbResourceFile?.Id;
await _examSpecialStudentService.AddAttachment(addParams);
}
///
/// 删除特殊学生佐证材料
///
///
///
public async Task DelAttachment(DeleteExamSpecialStudentAttachmentInput input)
{
await _examSpecialStudentService.DelAttachment(input);
}
///
/// 删除监测特殊学生
///
///
///
public async Task Del(BaseId input)
{
await _examSpecialStudentService.Del(input);
}
///
/// 清空监测特殊学生
///
///
///
public async Task Clear(ClearExamSpecialStudentInput input)
{
await _examSpecialStudentService.Clear(input);
}
///
/// 导出监测特殊学生上报打印表格
///
///
///
public async Task ExportPrintTable(int examPlanId)
{
var bs = await _examSpecialStudentService.ExportPrintTable(examPlanId);
return new FileContentResult(bs, "application/vnd.openxmlformats-officedocument.wordprocessingml.document")
{
FileDownloadName = "特殊学生明细表.docx"
};
}
#endregion
#region 查询统计
///
/// 分页查询监测特殊学生列表
///
///
///
public async Task> QueryPageList(ExamSpecialStudentPageInput input)
{
return await _examSpecialStudentService.QueryPageList(input);
}
///
/// 获取机构班级特殊学生上报人数统计列表
///
///
///
///
public async Task GetOrgGradeClassStudentCount(int examPlanId, short? sysOrgId = null)
{
return await _examSpecialStudentService.GetOrgGradeClassStudentCount(examPlanId, sysOrgId);
}
///
/// 获取状态数量
///
///
public async Task> QueryStatusCount(ExamSpecialStudentPageInput input)
{
return await _examSpecialStudentService.QueryStatusCount(input);
}
#endregion
//[HttpGet]
//[AllowAnonymous]
//public async Task RefreshFileSize()
//{
// await _examSpecialStudentService.RefreshFileSize();
//}
}