add implementation of StorekeeperReportLogic

This commit is contained in:
DavidMakarov 2024-05-28 20:07:35 +04:00
parent 237bf21c93
commit e26de97679
2 changed files with 42 additions and 17 deletions

View File

@ -1,4 +1,6 @@
using FactoryContracts.BindingModels; using FactoryBusinessLogic.OfficePackage;
using FactoryBusinessLogic.OfficePackage.HelperModels;
using FactoryContracts.BindingModels;
using FactoryContracts.BusinessLogicsContracts; using FactoryContracts.BusinessLogicsContracts;
using FactoryContracts.SearchModels; using FactoryContracts.SearchModels;
using FactoryContracts.StoragesContracts; using FactoryContracts.StoragesContracts;
@ -10,10 +12,16 @@ namespace FactoryBusinessLogic.BusinessLogics
{ {
private readonly IMachineStorage _machineStorage; private readonly IMachineStorage _machineStorage;
private readonly IProductStorage _productStorage; private readonly IProductStorage _productStorage;
public StorekeeperReportLogic(IMachineStorage machineStorage, IProductStorage productStorage) private readonly AbstractSaveToWord _saveToWord;
private readonly AbstractSaveToExcel _saveToExcel;
private readonly AbstractSaveToPdf _saveToPdf;
public StorekeeperReportLogic(IMachineStorage machineStorage, IProductStorage productStorage, AbstractSaveToWord saveToWord, AbstractSaveToExcel saveToExcel, AbstractSaveToPdf saveToPdf)
{ {
_machineStorage = machineStorage; _machineStorage = machineStorage;
_productStorage = productStorage; _productStorage = productStorage;
_saveToWord = saveToWord;
_saveToExcel = saveToExcel;
_saveToPdf = saveToPdf;
} }
public List<ProductPlanProductionReportViewModel> GetPlanProductionsByProduct(List<ProductSearchModel> products) public List<ProductPlanProductionReportViewModel> GetPlanProductionsByProduct(List<ProductSearchModel> products)
{ {
@ -24,17 +32,34 @@ namespace FactoryBusinessLogic.BusinessLogics
{ {
return _machineStorage.GetMachinesByPeriod(client, model); return _machineStorage.GetMachinesByPeriod(client, model);
} }
public void SaveMachinesToPdfFile(ReportBindingModel model) public void SaveMachinesToPdfFile(ClientSearchModel client, ReportBindingModel model)
{ {
throw new NotImplementedException(); _saveToPdf.CreateStorekeeperDoc(new StorekeeperPdfInfo
{
FileName = model.FileName,
Title = "Список станков",
DateFrom = model.DateFrom!.Value,
DateTo = model.DateTo!.Value,
Machines = GetMachines(client, model)
});
} }
public void SavePlanProductionsToExcelFile(ReportBindingModel model) public void SavePlanProductionsToExcelFile(ReportBindingModel model, List<ProductSearchModel> products)
{ {
throw new NotImplementedException(); _saveToExcel.CreateStorekeeperReport(new StorekeeperExcelInfo
{
FileName = model.FileName,
Title = "Список планов производств",
ProductPlanProductions = GetPlanProductionsByProduct(products)
});
} }
public void SavePlanProductionsToWordFile(ReportBindingModel model) public void SavePlanProductionsToWordFile(ReportBindingModel model, List<ProductSearchModel> products)
{ {
throw new NotImplementedException(); _saveToWord.CreateStorekeeperDoc(new StorekeeperWordInfo
{
FileName = model.FileName,
Title = "Список планов производств",
ProductPlanProductions = GetPlanProductionsByProduct(products)
});
} }
} }
} }

View File

@ -8,8 +8,8 @@ namespace FactoryContracts.BusinessLogicsContracts
{ {
List<ProductPlanProductionReportViewModel> GetPlanProductionsByProduct(List<ProductSearchModel> products); List<ProductPlanProductionReportViewModel> GetPlanProductionsByProduct(List<ProductSearchModel> products);
List<MachinePeriodReportViewModel> GetMachines(ClientSearchModel client, ReportBindingModel model); List<MachinePeriodReportViewModel> GetMachines(ClientSearchModel client, ReportBindingModel model);
void SavePlanProductionsToWordFile(ReportBindingModel model); void SavePlanProductionsToWordFile(ReportBindingModel model, List<ProductSearchModel> products);
void SavePlanProductionsToExcelFile(ReportBindingModel model); void SavePlanProductionsToExcelFile(ReportBindingModel model, List<ProductSearchModel> products);
void SaveMachinesToPdfFile(ReportBindingModel model); void SaveMachinesToPdfFile(ClientSearchModel client, ReportBindingModel model);
} }
} }