jj
This commit is contained in:
parent
224f955899
commit
ed19ff8837
@ -5,6 +5,8 @@ public class PrintingHouseOrders
|
|||||||
public int PrintingHouseId { get; set; }
|
public int PrintingHouseId { get; set; }
|
||||||
public int OrderId { get; set; }
|
public int OrderId { get; set; }
|
||||||
public int Count { get; set; }
|
public int Count { get; set; }
|
||||||
|
|
||||||
|
public string OrderInfo { get; set; }
|
||||||
public static PrintingHouseOrders CreateEntity(int id, int orderId, int count)
|
public static PrintingHouseOrders CreateEntity(int id, int orderId, int count)
|
||||||
{
|
{
|
||||||
return new PrintingHouseOrders { PrintingHouseId = id, OrderId = orderId, Count = count };
|
return new PrintingHouseOrders { PrintingHouseId = id, OrderId = orderId, Count = count };
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using Unity;
|
using Unity;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
|
using Publication.Entites.Enums;
|
||||||
|
|
||||||
namespace Publication.Entites;
|
namespace Publication.Entites;
|
||||||
|
|
||||||
@ -22,7 +23,7 @@ public class PrintingHouses
|
|||||||
public int MaterialsId { get; set; }
|
public int MaterialsId { get; set; }
|
||||||
|
|
||||||
[DisplayName("Материалы")]
|
[DisplayName("Материалы")]
|
||||||
public string MaterialName { get; set; } = string.Empty;
|
public TypeMaterials MaterialName { get; set; }
|
||||||
|
|
||||||
[DisplayName("Название")]
|
[DisplayName("Название")]
|
||||||
public DateTime Date { get; set; }
|
public DateTime Date { get; set; }
|
||||||
@ -32,7 +33,7 @@ public class PrintingHouses
|
|||||||
|
|
||||||
[DisplayName("Заказы")]
|
[DisplayName("Заказы")]
|
||||||
public string Orders => printingHouseOrder != null ?
|
public string Orders => printingHouseOrder != null ?
|
||||||
string.Join(", ", printingHouseOrder.Select(x => $"{x.} {x.Count}")) : string.Empty;
|
string.Join(", ", printingHouseOrder.Select(x => $"{x.OrderInfo} {x.Count}")) : string.Empty;
|
||||||
|
|
||||||
public static PrintingHouses CreateEntity(int id, string title, string phone, string address,int materialsId, IEnumerable<PrintingHouseOrders> printingHouseOrders)
|
public static PrintingHouses CreateEntity(int id, string title, string phone, string address,int materialsId, IEnumerable<PrintingHouseOrders> printingHouseOrders)
|
||||||
{
|
{
|
||||||
|
@ -4,6 +4,7 @@ using Npgsql;
|
|||||||
using Publication.Entites;
|
using Publication.Entites;
|
||||||
using Dapper;
|
using Dapper;
|
||||||
using Unity;
|
using Unity;
|
||||||
|
using static System.Runtime.InteropServices.JavaScript.JSType;
|
||||||
|
|
||||||
namespace Publication.Repositories.Implementations;
|
namespace Publication.Repositories.Implementations;
|
||||||
|
|
||||||
@ -76,16 +77,32 @@ public class PrintingHouseRepository : IPrintingHouseRepository
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
using var connection = new NpgsqlConnection(connectionRepository.GetConnection);
|
using var connection = new NpgsqlConnection(connectionRepository.GetConnection);
|
||||||
var querySelect = @"SELECT ph.*, pho.OrderId, pho.Count, mt.material AS MaterialName
|
var querySelect = @"SELECT ph.*, pho.OrderId, pho.Count, mt.material, Orders.description AS OrderInfo,
|
||||||
|
|
||||||
FROM PrintingHouses ph
|
FROM PrintingHouses ph
|
||||||
INNER JOIN PrintingHouseOrders pho ON pho.PrintingHouseId = ph.Id
|
INNER JOIN PrintingHouseOrders pho ON pho.PrintingHouseId = ph.Id
|
||||||
INNER JOIN Material mt ON ph.materialsId = mt.Id";
|
INNER JOIN Material mt ON ph.materialsId = mt.Id
|
||||||
var printingHouses = connection.Query<TempPrintingHouseOrders>(querySelect);
|
INNER JOIN Orders ON Orders.id = pho.orderid";
|
||||||
|
var printingHousesDict = new Dictionary<int, List<PrintingHouseOrders>>();
|
||||||
|
var printingHouses = connection.Query<PrintingHouses, PrintingHouseOrders, PrintingHouses>(querySelect,
|
||||||
|
(printingHouses, printingHouseOrders) =>
|
||||||
|
{
|
||||||
|
if (!printingHousesDict.TryGetValue(printingHouses.Id, out var pr))
|
||||||
|
{
|
||||||
|
pr = [];
|
||||||
|
printingHousesDict.Add(printingHouses.Id, pr);
|
||||||
|
}
|
||||||
|
pr.Add(printingHouseOrders);
|
||||||
|
return printingHouses;
|
||||||
|
}, splitOn: "OrderId", param: new { dateForm, dateTo, productID });
|
||||||
logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(printingHouses));
|
logger.LogDebug("Полученные объекты: {json}", JsonConvert.SerializeObject(printingHouses));
|
||||||
return printingHouses.GroupBy(x => x.Id, y => y,
|
|
||||||
(key, value) => PrintingHouses.CreateEntity(value.First(),
|
|
||||||
value.Select(z => PrintingHouseOrders.CreateEntity(z.Id, z.OrderId, z.Count)))).ToList();
|
|
||||||
|
|
||||||
|
return printingHousesDict.Select(x =>
|
||||||
|
{
|
||||||
|
var ph = printingHouses.First(y => y.Id == x.Key);
|
||||||
|
ph.SetPrintingHouseOrder(x.Value);
|
||||||
|
return ph;
|
||||||
|
}).ToArray();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user