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
@@ -24,11 +24,6 @@
/// <returns></returns>
Task<bool> DeleteAsync(MatReqModel model);
/// <summary>
/// Recupera un record MatReq specifico per ID.
/// </summary>
/// <param name="recId">ID dell'MatReq da recuperare</param>
Task<MatReqModel?> GetByIdAsync(int recId);
/// <summary>
/// Recupera gli MatReq filtrati per uno o pù criteri
@@ -45,6 +40,17 @@
/// <param name="entity">Record aggiornato</param>
Task<bool> UpdateAsync(MatReqModel entity);
#endif
/// <summary>
/// Recupera elenco record MatReq dato OrderID.
/// </summary>
/// <param name="orderId">ID dell'Ordine da recuperare</param>
Task<List<MatReqModel>> GetByOrderAsync(int orderId);
/// <summary>
/// Recupera elenco record MatReq dato OrderID.
/// </summary>
/// <param name="orderRowId">ID della OrderRow da recuperare</param>
Task<List<MatReqModel>> GetByOrderRowAsync(int orderRowId);
/// <summary>
/// Riconcilia i fabbisogni x un set di RigheOrdine:
@@ -40,6 +40,32 @@
});
}
/// <inheritdoc />
public async Task<List<MatReqModel>> 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
);
});
}
/// <inheritdoc />
public async Task<List<MatReqModel>> 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
);
});
}
/// <summary>
/// Genera un set di record fabbisogni da un item (RigaOrdine)
/// </summary>
+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
+1 -1
View File
@@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>1.1.2604.1717</Version>
<Version>1.1.2604.1718</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>aspnet-Lux.UI-a758c101-a2f4-4e38-977d-1c4887dbbd50</UserSecretsId>
<Version>1.1.2604.1717</Version>
<Version>1.1.2604.1718</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>LUX - Web Windows MES</i>
<h4>Versione: 1.1.2604.1717</h4>
<h4>Versione: 1.1.2604.1718</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
1.1.2604.1717
1.1.2604.1718
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.1.2604.1717</version>
<version>1.1.2604.1718</version>
<url>http://nexus.steamware.net/repository/SWS/GPW/stable/GPW.UI.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html</changelog>
<mandatory>false</mandatory>