using YBEE.EQM.Core; namespace YBEE.EQM.Application; /// /// 高中模拟划线成绩管理服务 /// [ApiDescriptionSettings(Name = "ncee-score")] [Route("ncee/score")] public class NceeScoreAppService : IDynamicApiController { private readonly INceeScoreService _nceeScoreService; public NceeScoreAppService(INceeScoreService nceeScoreService) { _nceeScoreService = nceeScoreService; } /// /// 上传成绩(仅原始分,适用于五区联考) /// /// /// [AllowAnonymous] [RequestSizeLimit(long.MaxValue)] [RequestFormLimits(MultipartBodyLengthLimit = long.MaxValue)] public async Task UploadOnlyRawScore([FromForm] UploadNceeScoreInput 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(); await _nceeScoreService.UploadOnlyRawScore(filePath, input.NceePlanId); } /// /// 上传成绩(带转换分和等级,适用于六校联考) /// /// /// [AllowAnonymous] [RequestSizeLimit(long.MaxValue)] [RequestFormLimits(MultipartBodyLengthLimit = long.MaxValue)] public async Task UploadWithConvertScore([FromForm] UploadNceeScoreInput 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(); await _nceeScoreService.UploadWithConvertScore(filePath, input.NceePlanId); } /// /// 上传未选科原始成绩(适用于高一未选科) /// /// /// [AllowAnonymous] [RequestSizeLimit(long.MaxValue)] [RequestFormLimits(MultipartBodyLengthLimit = long.MaxValue)] public async Task UploadNoDirectionCourse([FromForm] UploadNceeScoreInput 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(); await _nceeScoreService.UploadNoDirectionCourse(filePath, input.NceePlanId); } /// /// 执行模拟划线 /// /// /// [AllowAnonymous] public async Task Execute([FromQuery][Required] int nceePlanId) { await _nceeScoreService.Execute(nceePlanId); } }