2023-05-18 22:18:40 +04:00
|
|
|
|
using ComputerShopBusinessLogic.OfficePackage;
|
|
|
|
|
using ComputerShopBusinessLogic.OfficePackage.HelperModels;
|
|
|
|
|
using ComputerShopContracts.BindingModels;
|
2023-05-17 14:20:02 +04:00
|
|
|
|
using ComputerShopContracts.BusinessLogicContracts;
|
2023-05-18 22:18:40 +04:00
|
|
|
|
using ComputerShopContracts.StorageContracts;
|
2023-05-17 14:20:02 +04:00
|
|
|
|
using ComputerShopContracts.ViewModels;
|
2023-05-18 22:18:40 +04:00
|
|
|
|
using ComputerShopContracts.SearchModels;
|
2023-05-17 14:20:02 +04:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
2023-05-24 18:51:13 +04:00
|
|
|
|
using ComputerShopDataModels.Enums;
|
2023-05-17 14:20:02 +04:00
|
|
|
|
|
|
|
|
|
namespace ComputerShopBusinessLogic.BusinessLogics
|
|
|
|
|
{
|
2023-05-18 22:18:40 +04:00
|
|
|
|
public class ReportLogic : IReportLogic
|
|
|
|
|
{
|
|
|
|
|
private readonly IComponentStorage _componentStorage;
|
|
|
|
|
private readonly ISupplyStorage _supplyStorage;
|
|
|
|
|
private readonly IAssemblyStorage _assemblyStorage;
|
|
|
|
|
private readonly IEquipmentReceivingStorage _receivingStorage;
|
|
|
|
|
private readonly AbstractSaveToExcel _saveToExcel;
|
|
|
|
|
private readonly AbstractSaveToWord _saveToWord;
|
|
|
|
|
private readonly AbstractSaveToPdf _saveToPdf;
|
|
|
|
|
|
|
|
|
|
public ReportLogic(IComponentStorage componentStorage, IAssemblyStorage assemblyStorage, IEquipmentReceivingStorage receivingStorage, ISupplyStorage supplyStorage, AbstractSaveToExcel saveToExcel, AbstractSaveToWord saveToWord, AbstractSaveToPdf saveToPdf)
|
|
|
|
|
{
|
|
|
|
|
_componentStorage = componentStorage;
|
|
|
|
|
_assemblyStorage = assemblyStorage;
|
|
|
|
|
_receivingStorage = receivingStorage;
|
|
|
|
|
_supplyStorage = supplyStorage;
|
|
|
|
|
_saveToExcel = saveToExcel;
|
|
|
|
|
_saveToWord = saveToWord;
|
|
|
|
|
_saveToPdf = saveToPdf;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<ReportComponentReceivingViewModel> GetComponentReceivings(List<int> ids)
|
|
|
|
|
{
|
|
|
|
|
var result = new List<ReportComponentReceivingViewModel>();
|
2023-05-24 18:51:13 +04:00
|
|
|
|
|
|
|
|
|
var supplies1 = _supplyStorage.GetFullList();
|
|
|
|
|
var recs = _receivingStorage.GetFullList();
|
|
|
|
|
|
2023-05-18 22:18:40 +04:00
|
|
|
|
foreach (int id in ids)
|
|
|
|
|
{
|
|
|
|
|
var component = _componentStorage.GetElement(new ComponentSearchModel()
|
|
|
|
|
{
|
|
|
|
|
Id = id,
|
|
|
|
|
});
|
2023-05-19 18:21:13 +04:00
|
|
|
|
var supplies = _supplyStorage.GetFilteredList(new()
|
|
|
|
|
{
|
|
|
|
|
ComponentId = id
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
var receivings = new List<EquipmentReceivingViewModel>();
|
|
|
|
|
|
|
|
|
|
foreach(var supply in supplies)
|
|
|
|
|
{
|
|
|
|
|
if (supply.ReceivingId.HasValue)
|
|
|
|
|
{
|
|
|
|
|
var receiving = _receivingStorage.GetElement(new() { Id = supply.ReceivingId.Value });
|
2023-05-24 18:51:13 +04:00
|
|
|
|
if (receiving != null && !receivings.Contains(receiving))
|
2023-05-19 18:21:13 +04:00
|
|
|
|
{
|
|
|
|
|
receivings.Add(receiving);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-05-20 01:31:46 +04:00
|
|
|
|
|
|
|
|
|
|
2023-05-19 18:21:13 +04:00
|
|
|
|
var receivingnames = new List<string>();
|
|
|
|
|
foreach (var receiving in receivings)
|
|
|
|
|
{
|
2023-05-24 18:51:13 +04:00
|
|
|
|
receivingnames.Add($"Id: {receiving.Id}. Status: {Enum.GetName(typeof(EquipmentReceivingStatus), receiving.Status)}.");
|
2023-05-19 18:21:13 +04:00
|
|
|
|
}
|
|
|
|
|
if(receivingnames.Count > 0 && component != null)
|
|
|
|
|
{
|
|
|
|
|
result.Add(new()
|
|
|
|
|
{
|
|
|
|
|
ComponentName = component.ComponentName,
|
|
|
|
|
Receivings = receivingnames
|
|
|
|
|
});
|
|
|
|
|
}
|
2023-05-18 22:18:40 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SaveReceivingComponentsToWordFile(ReportBindingModel model)
|
|
|
|
|
{
|
2023-05-19 19:14:48 +04:00
|
|
|
|
if (model.Ids != null)
|
2023-05-19 18:21:13 +04:00
|
|
|
|
_saveToWord.CreateDoc(new WordInfoProvider
|
|
|
|
|
{
|
|
|
|
|
FileName = model.FileName,
|
|
|
|
|
Title = "Список получений по компонентам",
|
|
|
|
|
ComponentReceivings = GetComponentReceivings(model.Ids)
|
|
|
|
|
});
|
2023-05-18 22:18:40 +04:00
|
|
|
|
}
|
|
|
|
|
|
2023-05-24 19:38:01 +04:00
|
|
|
|
public void SaveReceivingComponentsToXmlFile(ReportBindingModel model)
|
2023-05-18 22:18:40 +04:00
|
|
|
|
{
|
2023-05-24 19:38:01 +04:00
|
|
|
|
if (model.Ids != null)
|
|
|
|
|
_saveToExcel.CreateReport(new ExcelInfoProvider
|
|
|
|
|
{
|
|
|
|
|
FileName = model.FileName,
|
|
|
|
|
Title = "Список получений по компонентам",
|
|
|
|
|
ComponentReceivings = GetComponentReceivings(model.Ids)
|
|
|
|
|
});
|
2023-05-18 22:18:40 +04:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<ReportPurchaseReceivingViewModel> GetPurchaseReceiving()
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<ReportPurchaseSupplyViewModel> GetPurchaseSupply()
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SaveOrdersToPdfFile(ReportBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SavePackagesToWordFile(ReportBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void SaveProductComponentToExcelFile(ReportBindingModel model)
|
|
|
|
|
{
|
|
|
|
|
throw new NotImplementedException();
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-05-17 14:20:02 +04:00
|
|
|
|
}
|