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