Ancora ottimizzazione azioni calcolo/update/display
This commit is contained in:
@@ -171,11 +171,22 @@ namespace MP.SPEC.Components
|
||||
await ReloadBaseData();
|
||||
}
|
||||
|
||||
private string? _lastPadCodXdl;
|
||||
private bool _initialized;
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
if (!lastFilter.Equals(actFilter))
|
||||
// esempio: verifica parametri minimi
|
||||
if (string.IsNullOrEmpty(padCodXdl) || actFilter == null)
|
||||
return;
|
||||
|
||||
if (!_initialized || !lastFilter.Equals(actFilter) || _lastPadCodXdl != padCodXdl)
|
||||
{
|
||||
_initialized = true;
|
||||
|
||||
lastFilter = actFilter.clone();
|
||||
_lastPadCodXdl = padCodXdl;
|
||||
|
||||
await ReloadData();
|
||||
}
|
||||
}
|
||||
@@ -243,6 +254,41 @@ namespace MP.SPEC.Components
|
||||
}
|
||||
}
|
||||
|
||||
protected async Task ReloadData()
|
||||
{
|
||||
isLoading = true;
|
||||
ListRecords = null;
|
||||
|
||||
// ✅ lancia in parallelo
|
||||
var odlTask = UpdateOdlList();
|
||||
|
||||
Task<List<PODLExpModel>> searchTask;
|
||||
|
||||
if (actFilter.ShowKit)
|
||||
{
|
||||
searchTask = MDService.POdlListGetFiltAsync(hasOdl, StatoSel, macchina, reparto, selDtStart, selDtEnd);
|
||||
}
|
||||
else
|
||||
{
|
||||
searchTask = MDService.POdlToKitListGetFiltAsync(hasOdl, StatoSel, macchina, reparto, selDtStart, selDtEnd);
|
||||
}
|
||||
|
||||
// ✅ aspetta tutto insieme
|
||||
await Task.WhenAll(odlTask, searchTask);
|
||||
|
||||
SearchRecords = searchTask.Result;
|
||||
|
||||
totalCount = SearchRecords.Count;
|
||||
|
||||
ListRecords = SearchRecords
|
||||
.Skip(numRecord * (currPage - 1))
|
||||
.Take(numRecord)
|
||||
.ToList();
|
||||
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
#if false
|
||||
protected async Task ReloadData()
|
||||
{
|
||||
ListRecords = null;
|
||||
@@ -262,9 +308,9 @@ namespace MP.SPEC.Components
|
||||
totalCount = SearchRecords.Count;
|
||||
}
|
||||
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
|
||||
//await InvokeAsync(() => StateHasChanged());
|
||||
isLoading = false;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
protected async Task resetSel(bool forceUpdate)
|
||||
{
|
||||
|
||||
@@ -1804,6 +1804,25 @@ namespace MP.SPEC.Data
|
||||
/// </summary>
|
||||
/// <param name="codGruppo"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<MacchineModel>> MacchineGetFiltAsync(string codGruppo)
|
||||
{
|
||||
string keyGrp = codGruppo != "*" ? codGruppo : "ALL";
|
||||
|
||||
string redisKey = $"{Utils.redisMacList}:{keyGrp}";
|
||||
string memKey = $"MACCHINE_MEM:{keyGrp}";
|
||||
|
||||
return await GetOrCreateCachedAsync(
|
||||
operationName: "MacchineGetFiltAsync",
|
||||
memKey: memKey,
|
||||
redisKey: redisKey,
|
||||
// ✅ TTL coerente con il tuo requisito (prima avevi 1 minuto)
|
||||
memoryTtl: TimeSpan.FromMinutes(1),
|
||||
dbFactory: async () =>
|
||||
await dbController.MacchineGetFiltAsync(codGruppo)
|
||||
?? new List<MacchineModel>()
|
||||
);
|
||||
}
|
||||
#if false
|
||||
public async Task<List<MacchineModel>> MacchineGetFiltAsync(string codGruppo)
|
||||
{
|
||||
using var activity = ActivitySource.StartActivity("MacchineGetFiltAsync");
|
||||
@@ -1853,7 +1872,8 @@ namespace MP.SPEC.Data
|
||||
|
||||
LogTrace($"MacchineGetFiltAsync | Read from {source}: {activity?.Duration.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Verifica se la idxMaccSel abbia un codice PATH ricette associato
|
||||
|
||||
Reference in New Issue
Block a user