123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210 |
- using YBEE.EQM.Core;
- namespace YBEE.EQM.Application;
- /// <summary>
- /// 监测抽样方案管理服务
- /// </summary>
- [ApiDescriptionSettings(Name = "exam-sample")]
- [Route("exam/sample")]
- public class ExamSampleAppService : IDynamicApiController
- {
- private readonly IExamSampleService _examSampleService;
- public ExamSampleAppService(IExamSampleService examSampleService)
- {
- _examSampleService = examSampleService;
- }
- /// <summary>
- /// 添加监测抽样方案
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- public async Task Add(AddExamSampleInput input)
- {
- await _examSampleService.Add(input);
- }
- /// <summary>
- /// 更新监测抽样方案
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- public async Task Update(UpdateExamSampleInput input)
- {
- await _examSampleService.Update(input);
- }
- /// <summary>
- /// 复制抽样方案信息
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- public async Task Duplicate(BaseId input)
- {
- await _examSampleService.Duplicate(input);
- }
- /// <summary>
- /// 删除监测抽样方案
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- public async Task Del(BaseId input)
- {
- await _examSampleService.Del(input);
- }
- /// <summary>
- /// 保存全抽班级ID列表
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- public async Task SaveExamSampleAllClasses(SaveExamSampleAllClasses input)
- {
- await _examSampleService.SaveExamSampleAllClasses(input);
- }
- /// <summary>
- /// 切换全抽班级
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- public async Task SwitchExamSampleAllClass(SwitchExamSampleAllClassInput input)
- {
- await _examSampleService.SwitchExamSampleAllClass(input);
- }
- /// <summary>
- /// 选定方案
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- public async Task SelectSample(BaseId input)
- {
- await _examSampleService.SelectSample(input);
- }
- /// <summary>
- /// 执行抽样
- /// </summary>
- /// <param name="input">抽样方案ID</param>
- /// <returns></returns>
- /// <exception cref="Exception"></exception>
- public async Task ExecuteSample(BaseId input)
- {
- await _examSampleService.ExecuteSample(input);
- }
- /// <summary>
- /// 导出抽样方案存档文件
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- public async Task<IActionResult> ExportToArchived(BaseId input)
- {
- var (fileName, fileBytes) = await _examSampleService.ExportToArchived(input.Id, false);
- return new FileContentResult(fileBytes, "application/octet-stream")
- {
- FileDownloadName = fileName,
- };
- }
- /// <summary>
- /// 导出给印刷厂和网阅机构文件
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- public async Task<IActionResult> ExportToPrintshop(BaseId input)
- {
- var (fileName, fileBytes) = await _examSampleService.ExportToArchived(input.Id, true);
- return new FileContentResult(fileBytes, "application/octet-stream")
- {
- FileDownloadName = fileName,
- };
- }
- /// <summary>
- /// 导出给学校
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- public async Task<IActionResult> ExportToOrg(BaseId input)
- {
- var (fileName, fileBytes) = await _examSampleService.ExportToOrg(input.Id);
- return new FileContentResult(fileBytes, "application/octet-stream")
- {
- FileDownloadName = fileName,
- };
- }
- /// <summary>
- /// 导出抽样统计表
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- public async Task<IActionResult> ExportSampleCount(BaseId input)
- {
- var (fileName, fileBytes) = await _examSampleService.ExportSampleCount(input.Id);
- return new FileContentResult(fileBytes, "application/octet-stream")
- {
- FileDownloadName = fileName,
- };
- }
- /// <summary>
- /// 导出学校抽样统计表
- /// </summary>
- /// <param name="input"></param>
- /// <returns></returns>
- public async Task<IActionResult> ExportSampleCountToOrg(BaseId input)
- {
- var (fileName, fileBytes) = await _examSampleService.ExportSampleCountToOrg(input.Id);
- return new FileContentResult(fileBytes, "application/octet-stream")
- {
- FileDownloadName = fileName,
- };
- }
- /// <summary>
- /// 根据ID获取抽样方案
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public async Task<ExamSampleOutput> GetById([FromQuery][Required] int id)
- {
- return await _examSampleService.GetById(id);
- }
- /// <summary>
- /// 根据监测计划ID获取全部抽样方案
- /// </summary>
- /// <param name="examPlanId"></param>
- /// <returns></returns>
- public async Task<List<ExamSampleOutput>> GetListByExamPlanId([FromQuery][Required] int examPlanId)
- {
- return await _examSampleService.GetListByExamPlanId(examPlanId);
- }
- /// <summary>
- /// 查询已发布抽样
- /// </summary>
- /// <param name="examDataPublishId">监测发布内容ID</param>
- /// <param name="type">抽样数据发布类型</param>
- /// <returns></returns>
- public async Task<ExamSamplePlanOutput> GetByExamDataPublishId([FromQuery][Required] int examDataPublishId, [FromQuery][Required] DataPublishType type)
- {
- return await _examSampleService.GetByExamDataPublishId(examDataPublishId, type);
- }
- /// <summary>
- /// 获取抽样统计表
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public async Task<List<ExamSampleCountOutput>> GetSampleCountListById([FromQuery][Required] int id)
- {
- return await _examSampleService.GetSampleCountListById(id);
- }
- /// <summary>
- /// 获取学校抽样统计表
- /// </summary>
- /// <param name="id"></param>
- /// <returns></returns>
- public async Task<List<ExamSampleCountOutput>> GetOrgSampleCountListById([FromQuery][Required] int id)
- {
- return await _examSampleService.GetOrgSampleCountListById(id);
- }
- }
|