получение данных для отчета по заявкам
This commit is contained in:
parent
65a22bb3f6
commit
0a00c532db
@ -0,0 +1,35 @@
|
|||||||
|
using CarServiceContracts.BindingModels;
|
||||||
|
using CarServiceContracts.BusinessLogicsContracts;
|
||||||
|
using CarServiceContracts.StorageContracts;
|
||||||
|
using CarServiceContracts.ViewModels;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace CarServiceBusinessLogic.BusinessLogics
|
||||||
|
{
|
||||||
|
public class ReportLogic : IReportLogic
|
||||||
|
{
|
||||||
|
//private readonly ILogger _logger;
|
||||||
|
private readonly IWorkStorage _workStorage;
|
||||||
|
public ReportLogic(/*ILogger logger,*/ IWorkStorage workStorage)
|
||||||
|
{
|
||||||
|
//_logger = logger;
|
||||||
|
_workStorage = workStorage;
|
||||||
|
}
|
||||||
|
public List<ReportWorkWithRequestsViewModel> GetRequestsByWorks(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
return _workStorage.GetWorksWithRequest(new() { SelectedWorksIds = model.SelectedWorks });
|
||||||
|
}
|
||||||
|
public void SaveComponentsToWordFile(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
public void SaveManufactureComponentToExcelFile(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
public void SaveOrdersToPdfFile(ReportBindingModel model)
|
||||||
|
{
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
namespace CarServiceContracts.BindingModels
|
||||||
|
{
|
||||||
|
public class ReportBindingModel
|
||||||
|
{
|
||||||
|
public string FileName { get; set; } = string.Empty;
|
||||||
|
/// <summary>
|
||||||
|
/// Выбранные работы для отчета по заявкам
|
||||||
|
/// </summary>
|
||||||
|
public List<int>? SelectedWorks { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Начало периода для отчета по оплатам
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? DateFrom { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Конец периода для отчета по оплатам
|
||||||
|
/// </summary>
|
||||||
|
public DateTime? DateTo { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
using CarServiceContracts.BindingModels;
|
||||||
|
using CarServiceContracts.ViewModels;
|
||||||
|
|
||||||
|
namespace CarServiceContracts.BusinessLogicsContracts
|
||||||
|
{
|
||||||
|
public interface IReportLogic
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Получение списка заявок по выбранным работам
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
List<ReportWorkWithRequestsViewModel> GetRequestsByWorks(ReportBindingModel model);
|
||||||
|
/// <summary>
|
||||||
|
/// Получение списка оплат за определенный период
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
//List<ReportOrdersViewModel> GetPayments(ReportBindingModel model);
|
||||||
|
/// <summary>
|
||||||
|
/// Сохранение компонент в файл-Word
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model"></param>
|
||||||
|
void SaveComponentsToWordFile(ReportBindingModel model);
|
||||||
|
/// <summary>
|
||||||
|
/// Сохранение компонент с указаеним продуктов в файл-Excel
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model"></param>
|
||||||
|
void SaveManufactureComponentToExcelFile(ReportBindingModel model);
|
||||||
|
/// <summary>
|
||||||
|
/// Сохранение заказов в файл-Pdf
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model"></param>
|
||||||
|
void SaveOrdersToPdfFile(ReportBindingModel model);
|
||||||
|
}
|
||||||
|
}
|
@ -4,5 +4,9 @@
|
|||||||
{
|
{
|
||||||
public int? Id { get; set; }
|
public int? Id { get; set; }
|
||||||
public string? Name { get; set; }
|
public string? Name { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Id выбранных работ
|
||||||
|
/// </summary>
|
||||||
|
public List<int>? SelectedWorksIds { get; set; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,6 +9,7 @@ namespace CarServiceContracts.StorageContracts
|
|||||||
List<WorkViewModel> GetFullList();
|
List<WorkViewModel> GetFullList();
|
||||||
List<WorkViewModel> GetFilteredList(WorkSearchModel model);
|
List<WorkViewModel> GetFilteredList(WorkSearchModel model);
|
||||||
WorkViewModel? GetElement(WorkSearchModel model);
|
WorkViewModel? GetElement(WorkSearchModel model);
|
||||||
|
List<ReportWorkWithRequestsViewModel> GetWorksWithRequest(WorkSearchModel model);
|
||||||
WorkViewModel? Insert(WorkBindingModel model);
|
WorkViewModel? Insert(WorkBindingModel model);
|
||||||
WorkViewModel? Update(WorkBindingModel model);
|
WorkViewModel? Update(WorkBindingModel model);
|
||||||
WorkViewModel? Delete(WorkBindingModel model);
|
WorkViewModel? Delete(WorkBindingModel model);
|
||||||
|
@ -0,0 +1,33 @@
|
|||||||
|
namespace CarServiceContracts.ViewModels
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Модель для получения одной заявки для отчета
|
||||||
|
/// </summary>
|
||||||
|
public class ReportRepairRequestViewModel
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Номер заявки
|
||||||
|
/// </summary>
|
||||||
|
public int RepairRequestId { get; set; }
|
||||||
|
/// <summary>
|
||||||
|
/// Дата создания заявки
|
||||||
|
/// </summary>
|
||||||
|
public DateTime RepairRequestDateCreated { get; set; } = DateTime.Now;
|
||||||
|
/// <summary>
|
||||||
|
/// Имя клиента
|
||||||
|
/// </summary>
|
||||||
|
public string CustomerName { get; set; } = string.Empty;
|
||||||
|
/// <summary>
|
||||||
|
/// Название ТС
|
||||||
|
/// </summary>
|
||||||
|
public string VehicleName { get; set; } = string.Empty;
|
||||||
|
/// <summary>
|
||||||
|
/// Гос. номер
|
||||||
|
/// </summary>
|
||||||
|
public string Plate { get; set; } = string.Empty;
|
||||||
|
/// <summary>
|
||||||
|
/// Количество работ
|
||||||
|
/// </summary>
|
||||||
|
public int WorksCount { get; set; }
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
namespace CarServiceContracts.ViewModels
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Модель для получения всех заявок по работе для отчета
|
||||||
|
/// </summary>
|
||||||
|
public class ReportWorkWithRequestsViewModel
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Название работы
|
||||||
|
/// </summary>
|
||||||
|
public string WorkName { get; set; } = string.Empty;
|
||||||
|
/// <summary>
|
||||||
|
/// Заявки в работе
|
||||||
|
/// </summary>
|
||||||
|
public List<ReportRepairRequestViewModel> RepairRequests { get; set; } = new();
|
||||||
|
}
|
||||||
|
}
|
@ -47,6 +47,46 @@ namespace CarServiceDatabase.Implements
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
public List<ReportWorkWithRequestsViewModel> GetWorksWithRequest(WorkSearchModel model)
|
||||||
|
{
|
||||||
|
if (model.SelectedWorksIds == null)
|
||||||
|
{
|
||||||
|
return new();
|
||||||
|
}
|
||||||
|
using var context = new CarServiceDbContext();
|
||||||
|
return context.Works
|
||||||
|
.Where(w => model.SelectedWorksIds.Contains(w.Id))
|
||||||
|
.Select(w => new ReportWorkWithRequestsViewModel()
|
||||||
|
{
|
||||||
|
WorkName = w.Name,
|
||||||
|
RepairRequests = GetRepairRequestsByWork(model)
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
|
/// <summary>
|
||||||
|
/// Получение списка заявок по выбранной работе
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="model"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
private List<ReportRepairRequestViewModel> GetRepairRequestsByWork(WorkSearchModel model)
|
||||||
|
{
|
||||||
|
using var context = new CarServiceDbContext();
|
||||||
|
return context.WorksInRequest
|
||||||
|
.Include(wir => wir.RepairRequest)
|
||||||
|
.ThenInclude(rr => rr.Vehicle)
|
||||||
|
.ThenInclude(v => v.Customer)
|
||||||
|
.Where(wir => wir.WorkId == model.Id)
|
||||||
|
.Select(wir => new ReportRepairRequestViewModel()
|
||||||
|
{
|
||||||
|
RepairRequestId = wir.RepairRequest.Id,
|
||||||
|
RepairRequestDateCreated = wir.RepairRequest.DateCreated,
|
||||||
|
CustomerName = wir.RepairRequest.Vehicle.Customer.Name,
|
||||||
|
VehicleName = wir.RepairRequest.Vehicle.Name,
|
||||||
|
Plate = wir.RepairRequest.Vehicle.Plate ?? "[отсутствует]",
|
||||||
|
WorksCount = wir.Count
|
||||||
|
})
|
||||||
|
.ToList();
|
||||||
|
}
|
||||||
public WorkViewModel? Insert(WorkBindingModel model)
|
public WorkViewModel? Insert(WorkBindingModel model)
|
||||||
{
|
{
|
||||||
using var context = new CarServiceDbContext();
|
using var context = new CarServiceDbContext();
|
||||||
|
@ -19,6 +19,8 @@ namespace CarServiceView
|
|||||||
var services = new ServiceCollection();
|
var services = new ServiceCollection();
|
||||||
ConfigureServices(services);
|
ConfigureServices(services);
|
||||||
_serviceProvider = services.BuildServiceProvider();
|
_serviceProvider = services.BuildServiceProvider();
|
||||||
|
var _reportLogic = _serviceProvider.GetRequiredService<IReportLogic>();
|
||||||
|
var list = _reportLogic.GetRequestsByWorks(new() { SelectedWorks = new() { 1 } });
|
||||||
Application.Run(_serviceProvider.GetRequiredService<FormItemForRepairTest>());
|
Application.Run(_serviceProvider.GetRequiredService<FormItemForRepairTest>());
|
||||||
}
|
}
|
||||||
private static void ConfigureServices(ServiceCollection services)
|
private static void ConfigureServices(ServiceCollection services)
|
||||||
@ -37,6 +39,7 @@ namespace CarServiceView
|
|||||||
services.AddTransient<IWorkInRequestLogic, WorkInRequestLogic>();
|
services.AddTransient<IWorkInRequestLogic, WorkInRequestLogic>();
|
||||||
services.AddTransient<IWorkLogic, WorkLogic>();
|
services.AddTransient<IWorkLogic, WorkLogic>();
|
||||||
services.AddTransient<IWorkPaymentLogic, WorkPaymentLogic>();
|
services.AddTransient<IWorkPaymentLogic, WorkPaymentLogic>();
|
||||||
|
services.AddTransient<IReportLogic, ReportLogic>();
|
||||||
|
|
||||||
services.AddTransient<IWorkerStorage, WorkerStorage>();
|
services.AddTransient<IWorkerStorage, WorkerStorage>();
|
||||||
services.AddTransient<IWorkStorage, WorkStorage>();
|
services.AddTransient<IWorkStorage, WorkStorage>();
|
||||||
|
Loading…
Reference in New Issue
Block a user