Поправил отчеты
This commit is contained in:
parent
aefbbc4347
commit
af0ea16cb2
@ -1,6 +1,4 @@
|
|||||||
using ITServiceManager.Entities;
|
using ITServiceManager.Repositories;
|
||||||
using ITServiceManager.Repositories;
|
|
||||||
using ITServiceManager.Repositories.Implementations;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace ITServiceManager.Reports;
|
namespace ITServiceManager.Reports;
|
||||||
@ -35,43 +33,25 @@ public class ChartReport
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//private List<(string Caption, double Value)> GetData(DateTime dateTime)
|
|
||||||
//{
|
|
||||||
// return _orderRepository
|
|
||||||
// .ReadOrders() // Получаем все заказы
|
|
||||||
// .Where(order => order.Date.Date == dateTime.Date) // Фильтруем по дате заказа
|
|
||||||
// .SelectMany(order => order.OrderService) // Разворачиваем список услуг в заказах
|
|
||||||
// .GroupBy(service => service.ServiceId, (key, group) => new { ServiceId = key, Count = group.Sum(service => service.Quantity) }) // Группируем по ID услуги и суммируем количество
|
|
||||||
// .Select(group =>
|
|
||||||
// {
|
|
||||||
// var service = _serviceRepository.ReadServiceById(group.ServiceId); // Получаем информацию о услуге по ID
|
|
||||||
// return (service.ServiceType.ToString(), (double)group.Count); // Возвращаем название услуги и ее количество
|
|
||||||
// })
|
|
||||||
// .ToList();
|
|
||||||
//}
|
|
||||||
|
|
||||||
private List<(string Caption, double Value)> GetData(DateTime dateTime)
|
private List<(string Caption, double Value)> GetData(DateTime dateTime)
|
||||||
{
|
{
|
||||||
// Получаем заказы за указанную дату
|
|
||||||
var orders = _orderRepository
|
var orders = _orderRepository
|
||||||
.ReadOrders()
|
.ReadOrders()
|
||||||
.Where(order => order.Date.Date == dateTime.Date) // Фильтруем заказы по дате
|
.Where(order => order.Date.Date == dateTime.Date)
|
||||||
.ToList();
|
.ToList();
|
||||||
|
|
||||||
// Группируем заказы по CompanyId и вычисляем общую сумму затрат
|
|
||||||
var groupedOrders = orders
|
var groupedOrders = orders
|
||||||
.GroupBy(order => order.CompanyId)
|
.GroupBy(order => order.CompanyId)
|
||||||
.Select(group => new
|
.Select(group => new
|
||||||
{
|
{
|
||||||
CompanyId = group.Key,
|
CompanyId = group.Key,
|
||||||
TotalSpent = group.Sum(order => (double)order.Price) // Суммируем стоимость заказов
|
TotalSpent = group.Sum(order => (double)order.Price)
|
||||||
});
|
});
|
||||||
|
|
||||||
// Получаем названия компаний и формируем данные для диаграммы
|
|
||||||
return groupedOrders
|
return groupedOrders
|
||||||
.Select(group =>
|
.Select(group =>
|
||||||
{
|
{
|
||||||
var company = _companyRepository.ReadCompanyById(group.CompanyId); // Получаем информацию о компании
|
var company = _companyRepository.ReadCompanyById(group.CompanyId);
|
||||||
return (Caption: company.Name, Value: group.TotalSpent);
|
return (Caption: company.Name, Value: group.TotalSpent);
|
||||||
})
|
})
|
||||||
.ToList();
|
.ToList();
|
||||||
|
@ -30,7 +30,7 @@ public class DocReport
|
|||||||
}
|
}
|
||||||
if (includeServices)
|
if (includeServices)
|
||||||
{
|
{
|
||||||
builder.AddParagraph("Услуги").AddTable([2400, 2400], GetServices());
|
builder.AddParagraph("Услуги").AddTable([2400, 2400, 2400], GetServices());
|
||||||
}
|
}
|
||||||
if (includeEmployees)
|
if (includeEmployees)
|
||||||
{
|
{
|
||||||
@ -69,10 +69,10 @@ public class DocReport
|
|||||||
private List<string[]> GetServices()
|
private List<string[]> GetServices()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
["Тип услуги", "Описание"],
|
["Название услуги", "Тип услуги", "Описание"],
|
||||||
.. _serviceRepository
|
.. _serviceRepository
|
||||||
.ReadServices()
|
.ReadServices()
|
||||||
.Select(x => new string[] { x.ServiceType.ToString(), x.Description }),
|
.Select(x => new string[] {x.ServiceName, x.ServiceType.ToString(), x.Description }),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,4 @@
|
|||||||
|
using ITServiceManager.Repositories;
|
||||||
using ITServiceManager.Entities;
|
|
||||||
using ITServiceManager.Repositories;
|
|
||||||
using ITServiceManager.Repositories.Implementations;
|
|
||||||
using Microsoft.Extensions.Logging;
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
namespace ITServiceManager.Reports;
|
namespace ITServiceManager.Reports;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user