From 7fe2bb284bb5b8cb29629f270a4ffd72b50913ac Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 17 Apr 2026 18:06:25 +0200 Subject: [PATCH] Aggiunta metodi x recupero REST degli ordini fabbisogni --- .../Services/Warehouse/IMatReqService.cs | 16 +++-- .../Services/Warehouse/MatReqService.cs | 26 +++++++ Lux.API/Controllers/ReportController.cs | 71 +++++++++++++++++-- Lux.API/Lux.API.csproj | 2 +- Lux.UI/Lux.UI.csproj | 2 +- Resources/ChangeLog.html | 2 +- Resources/VersNum.txt | 2 +- Resources/manifest.xml | 2 +- 8 files changed, 109 insertions(+), 14 deletions(-) diff --git a/EgwCoreLib.Lux.Data/Services/Warehouse/IMatReqService.cs b/EgwCoreLib.Lux.Data/Services/Warehouse/IMatReqService.cs index 2afcdd91..15d08f60 100644 --- a/EgwCoreLib.Lux.Data/Services/Warehouse/IMatReqService.cs +++ b/EgwCoreLib.Lux.Data/Services/Warehouse/IMatReqService.cs @@ -24,11 +24,6 @@ /// Task DeleteAsync(MatReqModel model); - /// - /// Recupera un record MatReq specifico per ID. - /// - /// ID dell'MatReq da recuperare - Task GetByIdAsync(int recId); /// /// Recupera gli MatReq filtrati per uno o pù criteri @@ -45,6 +40,17 @@ /// Record aggiornato Task UpdateAsync(MatReqModel entity); #endif + /// + /// Recupera elenco record MatReq dato OrderID. + /// + /// ID dell'Ordine da recuperare + Task> GetByOrderAsync(int orderId); + + /// + /// Recupera elenco record MatReq dato OrderID. + /// + /// ID della OrderRow da recuperare + Task> GetByOrderRowAsync(int orderRowId); /// /// Riconcilia i fabbisogni x un set di RigheOrdine: diff --git a/EgwCoreLib.Lux.Data/Services/Warehouse/MatReqService.cs b/EgwCoreLib.Lux.Data/Services/Warehouse/MatReqService.cs index 7a633496..a5a7bfc0 100644 --- a/EgwCoreLib.Lux.Data/Services/Warehouse/MatReqService.cs +++ b/EgwCoreLib.Lux.Data/Services/Warehouse/MatReqService.cs @@ -40,6 +40,32 @@ }); } + /// + public async Task> GetByOrderAsync(int orderId) + { + return await TraceAsync($"{_className}.GetByOrderAsync", async (activity) => + { + return await GetOrSetCacheAsync( + $"{_redisBaseKey}:{_className}:ByOrd", + async () => await _repo.GetFiltAsync(orderId, null, null, null), + UltraLongCache + ); + }); + } + + /// + public async Task> GetByOrderRowAsync(int orderRowId) + { + return await TraceAsync($"{_className}.GetByOrderRowAsync", async (activity) => + { + return await GetOrSetCacheAsync( + $"{_redisBaseKey}:{_className}:ByOrdRow", + async () => await _repo.GetFiltAsync(null, orderRowId, null, null), + UltraLongCache + ); + }); + } + /// /// Genera un set di record fabbisogni da un item (RigaOrdine) /// diff --git a/Lux.API/Controllers/ReportController.cs b/Lux.API/Controllers/ReportController.cs index 25606377..ac236367 100644 --- a/Lux.API/Controllers/ReportController.cs +++ b/Lux.API/Controllers/ReportController.cs @@ -1,6 +1,7 @@ using EgwCoreLib.Lux.Data.DbModel.Sales; using EgwCoreLib.Lux.Data.Services.Catalog; using EgwCoreLib.Lux.Data.Services.Sales; +using EgwCoreLib.Lux.Data.Services.Warehouse; namespace Lux.API.Controllers { @@ -17,11 +18,13 @@ namespace Lux.API.Controllers public ReportController( IOfferService offService, IOrderService ordService, - ITemplateService tplService) + ITemplateService tplService, + IMatReqService mrService) { _offService = offService; _ordService = ordService; _tplService = tplService; + _mrService = mrService; // Configurazione serializzatore JSON per risolvere errore di loop circolare JSSettings = new JsonSerializerSettings() { @@ -48,7 +51,7 @@ namespace Lux.API.Controllers var offData = await _offService.GetByIdAsync(id); sw.Stop(); - Log.Info($"Offert | {id} | {sw.Elapsed.TotalMilliseconds:N3} ms"); + Log.Debug($"Offert | {id} | {sw.Elapsed.TotalMilliseconds:N3} ms"); return Ok(offData); } /// @@ -66,7 +69,7 @@ namespace Lux.API.Controllers var ordData = await _ordService.GetByIdAsync(id, false); sw.Stop(); - Log.Info($"Order | {id} | {sw.Elapsed.TotalMilliseconds:N3} ms"); + Log.Debug($"Order | {id} | {sw.Elapsed.TotalMilliseconds:N3} ms"); return Ok(ordData); } @@ -85,10 +88,69 @@ namespace Lux.API.Controllers var ordData = await _tplService.GetByIdAsync(id); sw.Stop(); - Log.Info($"Template | {id} | {sw.Elapsed.TotalMilliseconds:N3} ms"); + Log.Debug($"Template | {id} | {sw.Elapsed.TotalMilliseconds:N3} ms"); return Ok(ordData); } + /// + /// Chiamata GET: riceve un elenco di righe MatReq x un ordine intero + /// GET: api/report/matreq-sale-ord/45 + /// + /// id univoco + /// + [HttpGet("matreq-sale-ord/{id}")] + public async Task MatReqSaleOrder(int id) + { + Stopwatch sw = new Stopwatch(); + sw.Start(); + // recupera dal DB l'offerta con le righe relative + var ordData = await _mrService.GetByOrderAsync(id); + + sw.Stop(); + Log.Debug($"MatReqSaleOrder | {id} | {sw.Elapsed.TotalMilliseconds:N3} ms"); + return Ok(ordData); + } + + /// + /// Chiamata GET: riceve un elenco di righe MatReq x una riga ordine + /// GET: api/report/matreq-sale-ord/45 + /// + /// id univoco + /// + [HttpGet("matreq-sale-ord-row/{id}")] + public async Task MatReqSaleOrderRow(int id) + { + Stopwatch sw = new Stopwatch(); + sw.Start(); + // recupera dal DB l'offerta con le righe relative + var ordData = await _mrService.GetByOrderRowAsync(id); + + sw.Stop(); + Log.Debug($"MatReqSaleOrderRow | {id} | {sw.Elapsed.TotalMilliseconds:N3} ms"); + return Ok(ordData); + } + +#if false + /// + /// Chiamata GET: riceve TemplateID, restituisce Json Template (catalogo) + righe + /// GET: api/report/matreq-buy-ord/1 + /// + /// id univoco + /// + [HttpGet("matreq-buy-ord/{id}")] + public async Task MatReqBuyOrder(int id) + { + Stopwatch sw = new Stopwatch(); + sw.Start(); + // recupera dal DB l'offerta con le righe relative + var ordData = await _tplService.GetByIdAsync(id); + + sw.Stop(); + Log.Info($"Template | {id} | {sw.Elapsed.TotalMilliseconds:N3} ms"); + return Ok(ordData); + } +#endif + /// /// Chiamata GET: riceve ELENCO Offerte dato periodo /// GET: api/report/offert-list/?from=2026-01-01&to=2026-04-01 @@ -129,6 +191,7 @@ namespace Lux.API.Controllers private IOfferService _offService; private IOrderService _ordService; private ITemplateService _tplService; + private IMatReqService _mrService; private JsonSerializerSettings JSSettings; #endregion Private Fields diff --git a/Lux.API/Lux.API.csproj b/Lux.API/Lux.API.csproj index bebd0a81..9ba84cfe 100644 --- a/Lux.API/Lux.API.csproj +++ b/Lux.API/Lux.API.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 1.1.2604.1717 + 1.1.2604.1718 diff --git a/Lux.UI/Lux.UI.csproj b/Lux.UI/Lux.UI.csproj index 1fb58630..58c806b7 100644 --- a/Lux.UI/Lux.UI.csproj +++ b/Lux.UI/Lux.UI.csproj @@ -5,7 +5,7 @@ enable enable aspnet-Lux.UI-a758c101-a2f4-4e38-977d-1c4887dbbd50 - 1.1.2604.1717 + 1.1.2604.1718 diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index 36cd1903..52a13def 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ LUX - Web Windows MES -

Versione: 1.1.2604.1717

+

Versione: 1.1.2604.1718


Note di rilascio:
  • diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index fbfe52a2..d6959ed0 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -1.1.2604.1717 +1.1.2604.1718 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index c573603a..a9dda7ed 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 1.1.2604.1717 + 1.1.2604.1718 http://nexus.steamware.net/repository/SWS/GPW/stable/GPW.UI.zip http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html false