Ancora update x ottimizzazione gestione lista articoli e dati in cache vari
This commit is contained in:
@@ -31,6 +31,7 @@ namespace MP.Core
|
||||
public const string redisKitScore = redisBaseAddr + "Cache:Kit:Score";
|
||||
public const string redisKitTempl = redisBaseAddr + "Cache:Kit:Templ";
|
||||
public const string redisKitWip = redisBaseAddr + "Cache:Kit:Wip";
|
||||
public const string redisIobConf = redisBaseAddr + "Cache:IobConf";
|
||||
public const string redisLinkMenu = redisBaseAddr + "Cache:LinkMenu";
|
||||
public const string redisMacByFlux = redisBaseAddr + "Cache:MacByFlux";
|
||||
|
||||
|
||||
@@ -79,8 +79,8 @@ else
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
<!-- FINE: MODIFICA FLUSSO -->
|
||||
|
||||
<!-- INIZIO: NUOVO DOSSIER -->
|
||||
@if (currRecordClone != null)
|
||||
{
|
||||
@@ -141,9 +141,10 @@ else
|
||||
|
||||
<div class="col-4 pe-0">
|
||||
<div class="input-group input-group-sm">
|
||||
<span class="input-group-text" id="inputGroup-sizing-sm" @onclick="()=> enableEditing()">ARTICOLI</span>
|
||||
|
||||
<select @bind="@currRecordClone.CodArticolo" class="form-select" id="macchina" title="Selezionare l'articolo">
|
||||
<span class="input-group-text" id="inputGroup-sizing-sm" @onclick="()=> enableEditing()">ART.</span>
|
||||
<input type="text" class="form-control" @bind="SearchArt" style="width: 8rem; flex: none;">
|
||||
<SelArticolo @bind-Value="currRecordClone.CodArticolo" SearchVal="@SearchArt" />
|
||||
@* <select @bind="@currRecordClone.CodArticolo" class="form-select" id="macchina" title="Selezionare l'articolo">
|
||||
@if (ListArticoli != null)
|
||||
{
|
||||
foreach (var item in ListArticoli)
|
||||
@@ -158,13 +159,11 @@ else
|
||||
}
|
||||
}
|
||||
}
|
||||
</select>
|
||||
</select> *@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!--FINE PRIMA RIGA-->
|
||||
|
||||
|
||||
<div class="row pt-4">
|
||||
<div class="col-3 pe-0">
|
||||
</div>
|
||||
@@ -186,16 +185,9 @@ else
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
|
||||
|
||||
<!-- FINE: NUOVO DOSSIER -->
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
<div class="row">
|
||||
<div class="d-flex justify justify-content-between">
|
||||
<table class="table table-sm table-striped small">
|
||||
@@ -344,8 +336,3 @@ else
|
||||
</div>
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -222,11 +222,6 @@ namespace MP.SPEC.Components
|
||||
}
|
||||
}
|
||||
|
||||
//prtected bool hasLic
|
||||
//{
|
||||
// get => selAzienda == "GIACOVELLI";
|
||||
//}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await MDService.ConfigResetCache();
|
||||
@@ -234,11 +229,22 @@ namespace MP.SPEC.Components
|
||||
ListStati = await MDService.AnagStatiCommAsync();
|
||||
selAzienda = await MDService.ConfigTryGetAsync("AZIENDA");
|
||||
giacenzeConf = await MDService.ConfigTryGetAsync("SPEC_ShowGiacenze");
|
||||
ListArticoli = await MDService.ArticoliGetSearchAsync(100000, "*", selAzienda, "");
|
||||
#if false
|
||||
ListArticoli = await MDService.ArticoliGetSearchAsync(100000, "*", selAzienda, "");
|
||||
#endif
|
||||
ListMacchine = await MDService.MacchineGetFiltAsync("*");
|
||||
await ReloadData(true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ricerca articoli
|
||||
/// </summary>
|
||||
private string SearchArt = "";
|
||||
/// <summary>
|
||||
/// Num min car x ricerca
|
||||
/// </summary>
|
||||
private int SearchMinChar = 3;
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
if (!lastFilter.Equals(SelFilter))
|
||||
@@ -314,7 +320,9 @@ namespace MP.SPEC.Components
|
||||
|
||||
private DossierModel? currRecordClone = null;
|
||||
|
||||
private List<AnagArticoliModel>? ListArticoli;
|
||||
#if false
|
||||
private List<AnagArticoliModel>? ListArticoli;
|
||||
#endif
|
||||
private List<AnagGruppiModel>? ListGruppiFase;
|
||||
|
||||
private List<MacchineModel>? ListMacchine;
|
||||
|
||||
@@ -166,6 +166,7 @@ namespace MP.SPEC.Components
|
||||
/// <returns></returns>
|
||||
protected bool HasFolderMan(string idxMacc)
|
||||
{
|
||||
#if false
|
||||
bool answ = true;
|
||||
// cerco nella LUT
|
||||
if (MachHasFolderLut.ContainsKey(idxMacc))
|
||||
@@ -182,9 +183,35 @@ namespace MP.SPEC.Components
|
||||
MachHasFolderLut.Add(idxMacc, answ);
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
return answ;
|
||||
#endif
|
||||
return MachHasFolderLut.ContainsKey(idxMacc) ? MachHasFolderLut[idxMacc] : false;
|
||||
}
|
||||
|
||||
|
||||
private async Task ReloadLutData()
|
||||
{
|
||||
if (SearchRecords != null)
|
||||
{
|
||||
foreach (var item in SearchRecords)
|
||||
{
|
||||
string rawVal = "";
|
||||
bool answ = false;
|
||||
var machData = await MDService.MachIobConfAsync(item.IdxMacchina);
|
||||
if (machData.ContainsKey(KeyFolderMan))
|
||||
{
|
||||
rawVal = machData[KeyFolderMan];
|
||||
if (rawVal != null)
|
||||
{
|
||||
bool.TryParse((string)rawVal, out answ);
|
||||
MachHasFolderLut.Add(item.IdxMacchina, answ);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
protected async Task KitToggleDetailAsync(string? selCodArt)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(selCodArt))
|
||||
@@ -359,10 +386,12 @@ namespace MP.SPEC.Components
|
||||
isLoading = true;
|
||||
SearchRecords = await MDService.OdlListGetFilt(currFilter.IsActive, currFilter.SearchVal, currFilter.CodFase, currFilter.CodReparto, currFilter.IdxMacchina, currFilter.DtStart, currFilter.DtEnd);
|
||||
await ReloadPOdlData();
|
||||
await ReloadLutData();
|
||||
totalCount = SearchRecords.Count;
|
||||
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
private Dictionary<int, int> _podlLocalCache = new();
|
||||
private async Task ReloadPOdlData()
|
||||
{
|
||||
@@ -373,7 +402,7 @@ namespace MP.SPEC.Components
|
||||
var tasks = SearchRecords.Select(async odl =>
|
||||
{
|
||||
int podl = 0;
|
||||
var pOdlData = await MDService.POdlGetByOdlAsync(odl.IdxOdl); // Tua nuova versione Async
|
||||
var pOdlData = await MDService.POdlGetByOdlAsync(odl.IdxOdl);
|
||||
if (pOdlData != null)
|
||||
{
|
||||
podl = pOdlData.IdxPromessa;
|
||||
|
||||
@@ -0,0 +1,10 @@
|
||||
<select value="@Value" @onchange="OnSelectionChanged" class="form-select" id="macchina" title="Selezionare l'articolo">
|
||||
<option value="">Seleziona un articolo...</option>
|
||||
@if (ListArticoli != null)
|
||||
{
|
||||
foreach (var item in ListArticoli)
|
||||
{
|
||||
<option value="@item.CodArticolo">@item.CodArticolo | @item.DescArticolo</option>
|
||||
}
|
||||
}
|
||||
</select>
|
||||
@@ -0,0 +1,61 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using MP.Data.DbModels;
|
||||
using MP.SPEC.Data;
|
||||
|
||||
namespace MP.SPEC.Components
|
||||
{
|
||||
public partial class SelArticolo
|
||||
{
|
||||
// Parametri per il Two-Way Data Binding
|
||||
[Parameter]
|
||||
public string Value { get; set; }
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<string> ValueChanged { get; set; }
|
||||
|
||||
// Parametri di filtro
|
||||
[Parameter]
|
||||
public string SearchVal { get; set; } = "";
|
||||
[Parameter]
|
||||
public string SelAzienda { get; set; } = "*";
|
||||
|
||||
[Inject]
|
||||
protected MpDataService MDService { get; set; } = null!;
|
||||
|
||||
private List<AnagArticoliModel>? ListArticoli;
|
||||
|
||||
// Variabili di appoggio per tracciare il cambio dei filtri
|
||||
private string _oldSearchVal = string.Empty;
|
||||
private string _oldSelAzienda = string.Empty;
|
||||
|
||||
private int maxNum = 100;
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await CaricaArticoli();
|
||||
}
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
if (SearchVal != _oldSearchVal || SelAzienda != _oldSelAzienda)
|
||||
{
|
||||
_oldSearchVal = SearchVal;
|
||||
_oldSelAzienda = SelAzienda;
|
||||
|
||||
await CaricaArticoli();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task CaricaArticoli()
|
||||
{
|
||||
ListArticoli = await MDService.ArticoliGetSearchAsync(maxNum, "*", SelAzienda, SearchVal);
|
||||
}
|
||||
|
||||
private async Task OnSelectionChanged(ChangeEventArgs e)
|
||||
{
|
||||
Value = e.Value?.ToString();
|
||||
// Notifica il componente padre della variazione
|
||||
await ValueChanged.InvokeAsync(Value);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1503,50 +1503,55 @@ namespace MP.SPEC.Data
|
||||
/// </summary>
|
||||
/// <param name="IdxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
public Dictionary<string, string> MachIobConf(string IdxMacchina)
|
||||
public async Task<Dictionary<string, string>> MachIobConfAsync(string IdxMacchina)
|
||||
{
|
||||
using var activity = ActivitySource.StartActivity("MachIobConf");
|
||||
string redisKey = Utils.redisIobConf;
|
||||
|
||||
return await GetOrFetchAsync(
|
||||
operationName: "MachIobConfAsync",
|
||||
cacheKey: redisKey,
|
||||
expiration: getRandTOut(redisShortTimeCache),
|
||||
fetchFunc: async () =>
|
||||
{
|
||||
Dictionary<string, string> result = new Dictionary<string, string>();
|
||||
// cerco in redis...
|
||||
string currKey = redHashMpIO($"IOB:{IdxMacchina}:MachIobConfAsync");
|
||||
if (await redisDb.KeyExistsAsync(currKey))
|
||||
{
|
||||
result = (await redisDb.HashGetAllAsync(currKey))
|
||||
.ToDictionary(x => $"{x.Name}", x => $"{x.Value}");
|
||||
}
|
||||
return result;
|
||||
},
|
||||
tagList: [Utils.redisIobConf]
|
||||
);
|
||||
#if false
|
||||
using var activity = ActivitySource.StartActivity("MachIobConfAsync");
|
||||
string source = "DB";
|
||||
Dictionary<string, string> result = new Dictionary<string, string>();
|
||||
// cerco in redis...
|
||||
string currKey = redHashMpIO($"IOB:{IdxMacchina}:MachIobConf");
|
||||
string currKey = redHashMpIO($"IOB:{IdxMacchina}:MachIobConfAsync");
|
||||
try
|
||||
{
|
||||
result = redisDb
|
||||
.HashGetAll(currKey)
|
||||
result = (await redisDb.HashGetAllAsync(currKey))
|
||||
.ToDictionary(x => $"{x.Name}", x => $"{x.Value}");
|
||||
source = "REDIS";
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Errore in MachIobConf{Environment.NewLine}{exc}");
|
||||
Log.Error($"Errore in MachIobConfAsync{Environment.NewLine}{exc}");
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new Dictionary<string, string>();
|
||||
LogTrace($"Init valore default MachIobConf | IdxMacchina: {IdxMacchina}");
|
||||
LogTrace($"Init valore default MachIobConfAsync | IdxMacchina: {IdxMacchina}");
|
||||
}
|
||||
activity?.SetTag("data.source", source);
|
||||
activity?.SetTag("result.count", result.Count);
|
||||
activity?.Stop();
|
||||
LogTrace($"MachIobConf per {IdxMacchina} | {source} | {activity?.Duration.TotalMilliseconds}ms");
|
||||
LogTrace($"MachIobConfAsync per {IdxMacchina} | {source} | {activity?.Duration.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupero singolo recordo info Machine-IOB x TAB (da info registrate IOB-WIN --> MP-IO)
|
||||
/// </summary>
|
||||
/// <param name="IdxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
public string MachIobConfVal(string IdxMacchina, string Key)
|
||||
{
|
||||
string answ = "";
|
||||
var currList = MachIobConf(IdxMacchina);
|
||||
if (currList.ContainsKey(Key))
|
||||
{
|
||||
answ = currList[Key];
|
||||
}
|
||||
return answ;
|
||||
#endif
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<Nullable>enable</Nullable>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>MP.SPEC</RootNamespace>
|
||||
<Version>8.16.2605.2814</Version>
|
||||
<Version>8.16.2605.2816</Version>
|
||||
<UserSecretsId>1800a78a-6ff1-40f9-b490-87fb8bfc1394</UserSecretsId>
|
||||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo MAPOSPEC </i>
|
||||
<h4>Versione: 8.16.2605.2814</h4>
|
||||
<h4>Versione: 8.16.2605.2816</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
8.16.2605.2814
|
||||
8.16.2605.2816
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>8.16.2605.2814</version>
|
||||
<version>8.16.2605.2816</version>
|
||||
<url>https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/MP.SPEC.zip</url>
|
||||
<changelog>https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
@@ -44,6 +44,9 @@ I metodi verranno suddivisi in:
|
||||
- [x] `POdlGetByOdlAsync`
|
||||
- [x] `FluxLogGetLastFiltAsync`
|
||||
- [x] `FluxLogParetoAsync`
|
||||
- [x] `OperatoriGetFiltAsync`
|
||||
- [x] `MacchineRecipeArchiveAsync`
|
||||
- [x] `MacchineRecipeConfAsync`
|
||||
- [ ] `AnagEventiGeneral`
|
||||
- [ ] `AnagEventiGetByMacch`
|
||||
- [ ] `AnagKeyValGetAll`
|
||||
|
||||
Reference in New Issue
Block a user