Создание и заполнение ReportLogic
This commit is contained in:
parent
c98cd8857f
commit
26a817e8c8
@ -10,12 +10,11 @@ namespace FurnitureContracts.BusinessLogicsContracts
|
|||||||
{
|
{
|
||||||
public interface IReportLogic
|
public interface IReportLogic
|
||||||
{
|
{
|
||||||
// List<ReportInterestLessonViewModel> GetInterestLesson(ReportBindingModel model);
|
List<ReportSalesSalonsFurnitureViewModel> GetSalesSalonsFurniture(ReportBindingModel model);
|
||||||
List<ReportSalesSalonsFurnitureViewModel> GetInterestLesson(ReportBindingModel model);
|
|
||||||
|
|
||||||
|
|
||||||
List<ReportSalesSalonViewModel> GetInterests(ReportBindingModel model);
|
List<ReportSalesSalonViewModel> GetSalesSalons(ReportBindingModel model);
|
||||||
List<ReportHeadsetMaterialViewModel> GetDiyMaterial(ReportBindingModel model);
|
List<ReportHeadsetMaterialViewModel> GetHeadsetMaterial(ReportBindingModel model);
|
||||||
|
|
||||||
|
|
||||||
List<ReportFurnitureHeadsetModuleViewModel> GetLessonTask(ReportBindingModel model);
|
List<ReportFurnitureHeadsetModuleViewModel> GetLessonTask(ReportBindingModel model);
|
||||||
@ -29,12 +28,12 @@ namespace FurnitureContracts.BusinessLogicsContracts
|
|||||||
|
|
||||||
void SaveInterestsToPdfFile(ReportBindingModel model);
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -103,7 +103,7 @@ namespace FurnitureFactoryBusinessLogic.BusinessLogic
|
|||||||
{
|
{
|
||||||
throw new ArgumentNullException("Неверно задан идентификатор заказа", nameof(model.OrdersId));
|
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
|
var element = _FurnitureStorage.GetElement(new FurnitureSearchModel
|
||||||
{
|
{
|
||||||
Name = model.Name,
|
Name = model.Name,
|
||||||
|
@ -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<ReportHeadsetMaterialViewModel> GetHeadsetMaterial(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
|
||||||
|
var headsetmodules = _headsetmoduleStorage.GetFilteredList(new HeadsetModuleSearchModel
|
||||||
|
{
|
||||||
|
MasterId = model.MasterId
|
||||||
|
});
|
||||||
|
var headsets = _headsetStorage.GetFullList();
|
||||||
|
var list = new List<ReportHeadsetMaterialViewModel>();
|
||||||
|
|
||||||
|
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<ReportSalesSalonsFurnitureViewModel> GetSalesSalonsFurniture(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
var orders = _orderStorage.GetFilteredList(new OrderSearchModel
|
||||||
|
{
|
||||||
|
ManagerId = model.ManagerId
|
||||||
|
});
|
||||||
|
var furnitures = _furnitureStorage.GetFullList();
|
||||||
|
var list = new List<ReportSalesSalonsFurnitureViewModel>();
|
||||||
|
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<ReportSalesSalonViewModel> 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<ReportSalesSalonViewModel>();
|
||||||
|
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<ReportFurnitureHeadsetModuleViewModel> 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<ReportFurnitureHeadsetModuleViewModel>();
|
||||||
|
|
||||||
|
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)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -6,7 +6,7 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace FurnitureFactoryBusinessLogic.OfficePackage.HelperEnums
|
namespace FurnitureFactoryBusinessLogic.OfficePackage.HelperEnums
|
||||||
{
|
{
|
||||||
public enum ExcelMergeParameters
|
public class ExcelMergeParameters
|
||||||
{
|
{
|
||||||
public string CellFromName { get; set; } = string.Empty;
|
public string CellFromName { get; set; } = string.Empty;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user