working excel report

This commit is contained in:
strwbrry1 2024-12-24 18:49:58 +04:00
parent 496d4a0f77
commit 37facf0620
2 changed files with 16 additions and 13 deletions

View File

@ -52,18 +52,19 @@ namespace ProjectPublishing.Reports
CountOut = (int?)null CountOut = (int?)null
}) })
.Union( .Union(
_orderRepository _orderRepository
.ReadOrders() // тут где-то .ReadOrders() // тут где-то
.Where(x => x.OrderDate >= startDate && x.OrderDate <= endDate && x.Materials.Any(y => y.MaterialsId == materialId)) .Where(x => x.OrderDate >= startDate && x.OrderDate <= endDate.AddDays(1) && x.Materials.Any(y => y.MaterialsId == materialId))
.SelectMany(order => order.Materials .SelectMany(order => order.Materials
.Where(m => m.MaterialsId == materialId) .Where(m => m.MaterialsId == materialId)
.Select(m => new { .Select(m => new
MaterialId = m.MaterialsId, {
Date = order.OrderDate, MaterialId = m.MaterialsId,
CountIn = (int?)null, Date = order.OrderDate,
CountOut = (int?)m.Amount CountIn = (int?)null,
}))) CountOut = (int?)m.Amount
.OrderBy(x => x.Date); })))
.OrderBy(x => x.Date);
_logger.LogDebug("Объединенные данные в отчет: {json}", JsonConvert.SerializeObject(data)); _logger.LogDebug("Объединенные данные в отчет: {json}", JsonConvert.SerializeObject(data));
return new List<string[]> { item } return new List<string[]> { item }
.Union( .Union(

View File

@ -87,7 +87,9 @@ WHERE Id=@id";
{ {
using var connection = new NpgsqlConnection(_connectionString.ConnectionString); using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
var querySelect = @" var querySelect = @"
SELECT o.*, ma.MaterialId SELECT o.*,
ma.MaterialId as MaterialsId,
ma.Amount as MaterialsAmount
FROM PrintingOrder o FROM PrintingOrder o
LEFT JOIN OrderMaterials ma ON o.Id = ma.OrderId LEFT JOIN OrderMaterials ma ON o.Id = ma.OrderId
"; // возможно сюда фикс "; // возможно сюда фикс