diff --git a/CompanyManagment.App.Contracts/RollCall/IRollCallApplication.cs b/CompanyManagment.App.Contracts/RollCall/IRollCallApplication.cs index bdff1e85..31960578 100644 --- a/CompanyManagment.App.Contracts/RollCall/IRollCallApplication.cs +++ b/CompanyManagment.App.Contracts/RollCall/IRollCallApplication.cs @@ -131,6 +131,16 @@ namespace CompanyManagment.App.Contracts.RollCall Task> GetCaseHistoryTitles(long workshopId,RollCallCaseHistorySearchModel searchModel); Task> GetCaseHistoryDetails(long workshopId, string titleId, RollCallCaseHistorySearchModel searchModel); + + Task DownloadCaseHistoryExcel(long workshopId, string titleId, + RollCallCaseHistorySearchModel searchModel); + } + + public class RollCallCaseHistoryExcelDto + { + public byte[] Bytes { get; set; } + public string FileName { get; set; } + public string MimeType { get; set; } } public class RollCallCaseHistoryDetail diff --git a/CompanyManagment.Application/RollCallApplication.cs b/CompanyManagment.Application/RollCallApplication.cs index 7f145407..1397b15b 100644 --- a/CompanyManagment.Application/RollCallApplication.cs +++ b/CompanyManagment.Application/RollCallApplication.cs @@ -16,6 +16,7 @@ using Company.Domain.LeaveAgg; using Company.Domain.RollCallAgg; using Company.Domain.RollCallAgg.DomainService; using Company.Domain.RollCallEmployeeAgg; +using Company.Domain.WorkshopAgg; using CompanyManagment.App.Contracts.Checkout; using CompanyManagment.App.Contracts.Employee; using CompanyManagment.App.Contracts.RollCall; @@ -34,8 +35,9 @@ public class RollCallApplication : IRollCallApplication private readonly ICustomizeWorkshopSettingsRepository _customizeWorkshopSettingsRepository; private readonly ICustomizeWorkshopEmployeeSettingsRepository _customizeWorkshopEmployeeSettingsRepository; private readonly ICustomizeCheckoutTempRepository _customizeCheckoutTempRepository; + private readonly IWorkshopRepository _workshopRepository; - public RollCallApplication(IRollCallRepository rollCallRepository, IRollCallEmployeeRepository rollCallEmployeeRepository, IEmployeeRepository employeeRepository, ILeaveRepository leaveRepository, ICustomizeCheckoutRepository customizeCheckoutRepository, ICheckoutRepository checkoutRepository, IRollCallDomainService rollCallDomainService, ICustomizeWorkshopSettingsRepository customizeWorkshopSettingsRepository, ICustomizeWorkshopEmployeeSettingsRepository customizeWorkshopEmployeeSettingsRepository, ICustomizeCheckoutTempRepository customizeCheckoutTempRepository) + public RollCallApplication(IRollCallRepository rollCallRepository, IRollCallEmployeeRepository rollCallEmployeeRepository, IEmployeeRepository employeeRepository, ILeaveRepository leaveRepository, ICustomizeCheckoutRepository customizeCheckoutRepository, ICheckoutRepository checkoutRepository, IRollCallDomainService rollCallDomainService, ICustomizeWorkshopSettingsRepository customizeWorkshopSettingsRepository, ICustomizeWorkshopEmployeeSettingsRepository customizeWorkshopEmployeeSettingsRepository, ICustomizeCheckoutTempRepository customizeCheckoutTempRepository, IWorkshopRepository workshopRepository) { _rollCallRepository = rollCallRepository; _rollCallEmployeeRepository = rollCallEmployeeRepository; @@ -47,7 +49,8 @@ public class RollCallApplication : IRollCallApplication _customizeWorkshopSettingsRepository = customizeWorkshopSettingsRepository; _customizeWorkshopEmployeeSettingsRepository = customizeWorkshopEmployeeSettingsRepository; _customizeCheckoutTempRepository = customizeCheckoutTempRepository; - } + _workshopRepository = workshopRepository; + } public OperationResult Create(CreateRollCall command) { @@ -869,4 +872,13 @@ public class RollCallApplication : IRollCallApplication { return await _rollCallRepository.GetCaseHistoryDetails(workshopId, titleId, searchModel); } + + public async Task DownloadCaseHistoryExcel(long workshopId, string titleId, + RollCallCaseHistorySearchModel searchModel) + { + var data = await _rollCallRepository + .GetCaseHistoryDetails(workshopId, titleId, searchModel); + var workshopFullName = _workshopRepository.(workshopId); + byte[] excelBytes = RollCallExcelGenerator.CaseHistoryExcelForOneDay(data); + } } \ No newline at end of file diff --git a/ServiceHost/Areas/Client/Controllers/RollCall/RollCallCaseHistoryController.cs b/ServiceHost/Areas/Client/Controllers/RollCall/RollCallCaseHistoryController.cs index 5bbf6c70..fc22ec04 100644 --- a/ServiceHost/Areas/Client/Controllers/RollCall/RollCallCaseHistoryController.cs +++ b/ServiceHost/Areas/Client/Controllers/RollCall/RollCallCaseHistoryController.cs @@ -1,6 +1,7 @@ using _0_Framework.Application; using CompanyManagement.Infrastructure.Excel.RollCall; using CompanyManagment.App.Contracts.RollCall; +using CompanyManagment.App.Contracts.Workshop; using Microsoft.AspNetCore.Mvc; using ServiceHost.BaseControllers; @@ -10,11 +11,12 @@ public class RollCallCaseHistoryController : ClientBaseController { private readonly IRollCallApplication _rollCallApplication; private readonly long _workshopId; - + private readonly IWorkshopApplication _workshopApplication; public RollCallCaseHistoryController(IRollCallApplication rollCallApplication, - IAuthHelper authHelper) + IAuthHelper authHelper, IWorkshopApplication workshopApplication) { _rollCallApplication = rollCallApplication; + _workshopApplication = workshopApplication; _workshopId = authHelper.GetWorkshopId(); } @@ -93,16 +95,17 @@ public class RollCallCaseHistoryController : ClientBaseController } } - // [HttpGet("excel")] - // public async Task GetDownload(string titleId,RollCallCaseHistorySearchModel searchModel) - // { - // var data = await _rollCallApplication.GetCaseHistoryDetails(_workshopId, titleId, searchModel); - // byte[] excelBytes = RollCallExcelGenerator.CaseHistoryExcelForOneDay(data); - // return File(excelBytes, - // "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet", - // $"{workshopFullName} - {caseHistoryRollCallExcelForOneDay.DayOfWeekFa}،{caseHistoryRollCallExcelForOneDay.DateFa}.xlsx"); - // - // } + [HttpGet("excel")] + public async Task GetDownload(string titleId, RollCallCaseHistorySearchModel searchModel) + { + var res =await _rollCallApplication.DownloadCaseHistoryExcel(_workshopId, titleId, searchModel); + + + return File(res.Bytes, + res.MimeType, + res.FileName); + + } // [HttpGet("edit")] // public ActionResult<> GetEditDetails(string date,long employeeId)