From 26a817e8c85468b52b3b7cb0a0455c888b1d59dc Mon Sep 17 00:00:00 2001 From: FLARJ <122087628+FLARJ@users.noreply.github.com> Date: Sun, 9 Apr 2023 01:09:11 +0400 Subject: [PATCH] =?UTF-8?q?=D0=A1=D0=BE=D0=B7=D0=B4=D0=B0=D0=BD=D0=B8?= =?UTF-8?q?=D0=B5=20=D0=B8=20=D0=B7=D0=B0=D0=BF=D0=BE=D0=BB=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20ReportLogic?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../BusinessLogicsContracts/IReportLogic.cs | 13 +- .../BusinessLogic/FurnitureLogic.cs | 2 +- .../BusinessLogic/ReportLogic.cs | 271 ++++++++++++++++++ .../HelperModels/ExcelMergeParameters.cs | 2 +- 4 files changed, 279 insertions(+), 9 deletions(-) create mode 100644 FurnitureFactory/FurnitureFactoryBusinessLogic/BusinessLogic/ReportLogic.cs diff --git a/FurnitureFactory/FurnitureContracts/BusinessLogicsContracts/IReportLogic.cs b/FurnitureFactory/FurnitureContracts/BusinessLogicsContracts/IReportLogic.cs index ac911d4..8f3f597 100644 --- a/FurnitureFactory/FurnitureContracts/BusinessLogicsContracts/IReportLogic.cs +++ b/FurnitureFactory/FurnitureContracts/BusinessLogicsContracts/IReportLogic.cs @@ -10,12 +10,11 @@ namespace FurnitureContracts.BusinessLogicsContracts { public interface IReportLogic { - // List GetInterestLesson(ReportBindingModel model); - List GetInterestLesson(ReportBindingModel model); + List GetSalesSalonsFurniture(ReportBindingModel model); - List GetInterests(ReportBindingModel model); - List GetDiyMaterial(ReportBindingModel model); + List GetSalesSalons(ReportBindingModel model); + List GetHeadsetMaterial(ReportBindingModel model); List GetLessonTask(ReportBindingModel model); @@ -29,12 +28,12 @@ namespace FurnitureContracts.BusinessLogicsContracts void SaveInterestsToPdfFile(ReportBindingModel model); - void SaveDiyMaterialToWordFile(ReportBindingModel model); + void SaveHeadsetMaterialToWordFile(ReportBindingModel model); - void SaveDiyMaterialToExcelFile(ReportBindingModel model); + void SaveHeadsetMaterialToExcelFile(ReportBindingModel model); - void SaveLessonTaskToPdfFile(ReportBindingModel model); + void SaveFurnitureHeadsetModuleToPdfFile(ReportBindingModel model); } } diff --git a/FurnitureFactory/FurnitureFactoryBusinessLogic/BusinessLogic/FurnitureLogic.cs b/FurnitureFactory/FurnitureFactoryBusinessLogic/BusinessLogic/FurnitureLogic.cs index 644e7b9..6c5121d 100644 --- a/FurnitureFactory/FurnitureFactoryBusinessLogic/BusinessLogic/FurnitureLogic.cs +++ b/FurnitureFactory/FurnitureFactoryBusinessLogic/BusinessLogic/FurnitureLogic.cs @@ -103,7 +103,7 @@ namespace FurnitureFactoryBusinessLogic.BusinessLogic { throw new ArgumentNullException("Неверно задан идентификатор заказа", nameof(model.OrdersId)); } - _logger.LogInformation("Furniture. Titel:{Name}.ProductId{ProductId}.MasterId:{MasterId}. Id: {Id}", model.Name, model.OrdersId, model.MasterId, model.Id); + _logger.LogInformation("Furniture. Titel:{Name}.OrderId{OrderId}.MasterId:{MasterId}. Id: {Id}", model.Name, model.OrdersId, model.MasterId, model.Id); var element = _FurnitureStorage.GetElement(new FurnitureSearchModel { Name = model.Name, diff --git a/FurnitureFactory/FurnitureFactoryBusinessLogic/BusinessLogic/ReportLogic.cs b/FurnitureFactory/FurnitureFactoryBusinessLogic/BusinessLogic/ReportLogic.cs new file mode 100644 index 0000000..b4bc9c1 --- /dev/null +++ b/FurnitureFactory/FurnitureFactoryBusinessLogic/BusinessLogic/ReportLogic.cs @@ -0,0 +1,271 @@ +using FurnitureContracts.SearchModels; +using FurnitureContracts.StoragesContracts; +using FurnitureContracts.ViewModel; +using FurnitureFactoryBusinessLogic.OfficePackage; +using FurnitureFactoryBusinessLogic.OfficePackage.Implements; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using FurnitureContracts.BindingModels; +using FurnitureContracts.BusinessLogicsContracts; +using FurnitureFactoryBusinessLogic.OfficePackage.HelperModels; + +namespace FurnitureFactoryBusinessLogic.BusinessLogic +{ + public class ReportLogic : IReportLogic + { + private readonly ISalesSalonsStorage _interestStorage; + private readonly IMaterialStorage _materialStorage; + private readonly IOrdersStorage _orderStorage; + private readonly IHeadsetStorage _headsetStorage; + private readonly IHeadsetModuleStorage _headsetmoduleStorage; + private readonly IFurnitureStorage _furnitureStorage; + + private readonly AbstractSaveToExcelMaster _saveToExcelMaster; + + private readonly AbstractSaveToWordMaster _saveToWordMaster; + + private readonly AbstractSaveToPdfMaster _saveToPdfMaster; + + private readonly AbstractSaveToExcelManager _saveToExcelManager; + + private readonly AbstractSaveToWordManager _saveToWordManager; + + private readonly AbstractSaveToPdfManager _saveToPdfManager; + + public ReportLogic(ISalesSalonsStorage salessalonStorage, IMaterialStorage materialStorage, IOrdersStorage orderStorage, IHeadsetStorage headsetStorage, IHeadsetModuleStorage headsetmoduleStorage, IFurnitureStorage furnitureStorage, AbstractSaveToExcelMaster saveToExcelMaster, AbstractSaveToWordMaster saveToWordMaster, AbstractSaveToPdfMaster saveToPdfMaster, AbstractSaveToExcelManager saveToExcelManager, AbstractSaveToWordManager saveToWordManager, AbstractSaveToPdfManager saveToPdfManager) + { + _interestStorage = salessalonStorage; + _materialStorage = materialStorage; + _orderStorage = orderStorage; + _headsetStorage = headsetStorage; + _headsetmoduleStorage = headsetmoduleStorage; + _furnitureStorage = furnitureStorage; + _saveToExcelMaster = saveToExcelMaster; + _saveToWordMaster = saveToWordMaster; + _saveToPdfMaster = saveToPdfMaster; + _saveToExcelManager = saveToExcelManager; + _saveToWordManager = saveToWordManager; + _saveToPdfManager = saveToPdfManager; + } + + + + + + public List GetHeadsetMaterial(ReportBindingModel model) + { + + var headsetmodules = _headsetmoduleStorage.GetFilteredList(new HeadsetModuleSearchModel + { + MasterId = model.MasterId + }); + var headsets = _headsetStorage.GetFullList(); + var list = new List(); + + foreach (MaterialViewModel material in model.Materials) + { + var record = new ReportHeadsetMaterialViewModel + { + Title = material.Name + }; + foreach (HeadsetModuleViewModel headsetmodule in headsetmodules) + { + if (headsetmodule.HeadsetModuleMaterial.ContainsKey(material.Id)) + { + foreach (HeadsetViewModel headset in headsets) + { + if (headset.HeadsetModuleId == headsetmodule.Id) + record.Headsets.Add(headset.Title); + } + } + } + list.Add(record); + } + return list; + } + + public List GetSalesSalonsFurniture(ReportBindingModel model) + { + var orders = _orderStorage.GetFilteredList(new OrderSearchModel + { + ManagerId = model.ManagerId + }); + var furnitures = _furnitureStorage.GetFullList(); + var list = new List(); + foreach (SalesSalonsViewModel salessalons in model.SalesSalons) + { + var record = new ReportSalesSalonsFurnitureViewModel + { + Name = salessalons.Name + }; + foreach (OrdersViewModel order in orders) + { + if (order.OrdersSalesSalons.ContainsKey(salessalons.Id)) + { + foreach (FurnitureViewModel furniture in furnitures) + { + if (furniture.OrdersId == order.Id) + { + record.Furniture.Add(furniture.Name); + } + } + } + } + list.Add(record); + } + return list; + } + + public List GetSalesSalons(ReportBindingModel model) + { + var salessalons = _interestStorage.GetFilteredList(new SalesSalonsSearchModel + { + ManagerId = model.ManagerId + }); + var orders = _orderStorage.GetFilteredList(new OrderSearchModel + { + ManagerId = model.ManagerId, + DateFrom = model.DateFrom, + DateTo = model.DateTo + }); + var headsets = _headsetStorage.GetFilteredList(new HeadsetSearchModel + { + ManagerId = model.ManagerId, + }); + var list = new List(); + foreach (OrdersViewModel order in orders) + { + + foreach (HeadsetViewModel headset in headsets) + { + + foreach (int salessalonOrder in order.OrdersSalesSalons.Keys) + { + if (headset.HeadsetSalesSalons.ContainsKey(salessalonOrder)) + { + list.Add(new ReportSalesSalonViewModel + { + SalesSalonTitle = salessalons.FirstOrDefault(x => x.Id == salessalonOrder).ToString(), + OrderTitle = order.Title, + DateCreateOrder = order.Date, + HeadsetTitle = headset.Title, + }); + } + + } + } + + } + + return list; + } + + public List GetLessonTask(ReportBindingModel model) + { + + var headsetmodules = _headsetmoduleStorage.GetFilteredList(new HeadsetModuleSearchModel + { + MasterId = model.MasterId, + DateFrom = model.DateFrom, + DateTo = model.DateTo + }); + var furnitures = _furnitureStorage.GetFilteredList(new FurnitureSearchModel + { + MasterId = model.MasterId, + DateFrom = model.DateFrom, + DateTo = model.DateTo + }); + var list = new List(); + + foreach (HeadsetModuleViewModel headsetmodule in headsetmodules) + { + + foreach (FurnitureViewModel furniture in furnitures) + { + + foreach (int materialHeadsetModule in headsetmodule.HeadsetModuleMaterial.Keys) + { + if (furniture.FurnitureMaterials.ContainsKey(materialHeadsetModule)) + { + list.Add(new ReportFurnitureHeadsetModuleViewModel + { + TitleFurniture = furniture.Name, + TitleHeadsetModule = headsetmodule.Name, + }); + break; + } + + } + } + + + } + return list; + } + + public void SaveHeadsetMaterialToExcelFile(ReportBindingModel model) + { + _saveToExcelMaster.CreateReport(new ExcelInfoMaster + { + FileName = model.FileName, + Title = "Список гарнитуров по материалам", + HeadsetMaterials = GetHeadsetMaterial(model) + }); + } + + public void SaveHeadsetMaterialToWordFile(ReportBindingModel model) + { + _saveToWordMaster.CreateDoc(new WordInfoMaster + { + FileName = model.FileName, + Title = "Список гарнитуров по материалам", + HeadsetMaterials = GetHeadsetMaterial(model) + }); + } + + public void SaveInterestLessonToExcelFile(ReportBindingModel model) + { + _saveToExcelManager.CreateReport(new ExcelInfoManager + { + FileName = model.FileName, + Title = "Список мебели по салонам продаж", + SalesSalonsFurniture = GetSalesSalonsFurniture(model) + }); + } + + public void SaveInterestLessonToWordFile(ReportBindingModel model) + { + _saveToWordManager.CreateDoc(new WordInfoManager + { + FileName = model.FileName, + Title = "Список мебели по салонам продаж", + SalesSalonsFurniture = GetSalesSalonsFurniture(model) + }); + } + + public void SaveInterestsToPdfFile(ReportBindingModel model) + { + _saveToPdfManager.CreateDoc(new PdfInfoManager + { + FileName = model.FileName, + Title = "Список салонов продаж", + SalesSalons = GetSalesSalons(model) + }); + } + + public void SaveFurnitureHeadsetModuleToPdfFile(ReportBindingModel model) + { + _saveToPdfMaster.CreateDoc(new PdfInfoMaster + { + FileName = model.FileName, + Title = "Список модулей гарнитур и мебели со сохожими материалами", + DateFrom = DateTime.SpecifyKind(model.DateFrom!.Value, DateTimeKind.Utc), + DateTo = DateTime.SpecifyKind(model.DateTo!.Value, DateTimeKind.Utc), + FurnitureHeadsetModule = GetLessonTask(model) + }); + } + } +} diff --git a/FurnitureFactory/FurnitureFactoryBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs b/FurnitureFactory/FurnitureFactoryBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs index b6150b2..92fe18f 100644 --- a/FurnitureFactory/FurnitureFactoryBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs +++ b/FurnitureFactory/FurnitureFactoryBusinessLogic/OfficePackage/HelperModels/ExcelMergeParameters.cs @@ -6,7 +6,7 @@ using System.Threading.Tasks; namespace FurnitureFactoryBusinessLogic.OfficePackage.HelperEnums { - public enum ExcelMergeParameters + public class ExcelMergeParameters { public string CellFromName { get; set; } = string.Empty;