Aggiunta metodi x recupero REST degli ordini fabbisogni

This commit is contained in:
Samuele Locatelli
2026-04-17 18:06:25 +02:00
parent 87f9e25692
commit 7fe2bb284b
8 changed files with 109 additions and 14 deletions
+67 -4
View File
@@ -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);
}
/// <summary>
@@ -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);
}
/// <summary>
/// Chiamata GET: riceve un elenco di righe MatReq x un ordine intero
/// GET: api/report/matreq-sale-ord/45
/// </summary>
/// <param name="id">id univoco</param>
/// <returns></returns>
[HttpGet("matreq-sale-ord/{id}")]
public async Task<IActionResult> 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);
}
/// <summary>
/// Chiamata GET: riceve un elenco di righe MatReq x una riga ordine
/// GET: api/report/matreq-sale-ord/45
/// </summary>
/// <param name="id">id univoco</param>
/// <returns></returns>
[HttpGet("matreq-sale-ord-row/{id}")]
public async Task<IActionResult> 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
/// <summary>
/// Chiamata GET: riceve TemplateID, restituisce Json Template (catalogo) + righe
/// GET: api/report/matreq-buy-ord/1
/// </summary>
/// <param name="id">id univoco</param>
/// <returns></returns>
[HttpGet("matreq-buy-ord/{id}")]
public async Task<IActionResult> 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
/// <summary>
/// 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