diff --git a/MP.Core/Utils.cs b/MP.Core/Utils.cs index 318b63c9..07d3d6f9 100644 --- a/MP.Core/Utils.cs +++ b/MP.Core/Utils.cs @@ -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"; diff --git a/MP.SPEC/Components/ListDossiers.razor b/MP.SPEC/Components/ListDossiers.razor index 8b233bdc..a497db87 100644 --- a/MP.SPEC/Components/ListDossiers.razor +++ b/MP.SPEC/Components/ListDossiers.razor @@ -79,8 +79,8 @@ else } - + @if (currRecordClone != null) { @@ -141,9 +141,10 @@ else
- ARTICOLI - - + + @* + *@
- -
@@ -186,16 +185,9 @@ else
} - - - - - - -
@@ -344,8 +336,3 @@ else } - - - - - diff --git a/MP.SPEC/Components/ListDossiers.razor.cs b/MP.SPEC/Components/ListDossiers.razor.cs index fb2caf8c..778e8cb9 100644 --- a/MP.SPEC/Components/ListDossiers.razor.cs +++ b/MP.SPEC/Components/ListDossiers.razor.cs @@ -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); } + /// + /// Ricerca articoli + /// + private string SearchArt = ""; + /// + /// Num min car x ricerca + /// + 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? ListArticoli; +#if false + private List? ListArticoli; +#endif private List? ListGruppiFase; private List? ListMacchine; diff --git a/MP.SPEC/Components/ListODL.razor.cs b/MP.SPEC/Components/ListODL.razor.cs index 7347ec53..dac1a05d 100644 --- a/MP.SPEC/Components/ListODL.razor.cs +++ b/MP.SPEC/Components/ListODL.razor.cs @@ -166,6 +166,7 @@ namespace MP.SPEC.Components /// 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 _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; diff --git a/MP.SPEC/Components/SelArticolo.razor b/MP.SPEC/Components/SelArticolo.razor new file mode 100644 index 00000000..996f21b6 --- /dev/null +++ b/MP.SPEC/Components/SelArticolo.razor @@ -0,0 +1,10 @@ + \ No newline at end of file diff --git a/MP.SPEC/Components/SelArticolo.razor.cs b/MP.SPEC/Components/SelArticolo.razor.cs new file mode 100644 index 00000000..dd26d88b --- /dev/null +++ b/MP.SPEC/Components/SelArticolo.razor.cs @@ -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 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? 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); + } + } +} \ No newline at end of file diff --git a/MP.SPEC/Data/MpDataService.cs b/MP.SPEC/Data/MpDataService.cs index 64bf7064..cab5679e 100644 --- a/MP.SPEC/Data/MpDataService.cs +++ b/MP.SPEC/Data/MpDataService.cs @@ -1503,50 +1503,55 @@ namespace MP.SPEC.Data /// /// /// - public Dictionary MachIobConf(string IdxMacchina) + public async Task> 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 result = new Dictionary(); + // 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 result = new Dictionary(); // 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(); - 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; - } - - /// - /// Recupero singolo recordo info Machine-IOB x TAB (da info registrate IOB-WIN --> MP-IO) - /// - /// - /// - public string MachIobConfVal(string IdxMacchina, string Key) - { - string answ = ""; - var currList = MachIobConf(IdxMacchina); - if (currList.ContainsKey(Key)) - { - answ = currList[Key]; - } - return answ; +#endif } /// diff --git a/MP.SPEC/MP.SPEC.csproj b/MP.SPEC/MP.SPEC.csproj index 89bc4b9e..374536c4 100644 --- a/MP.SPEC/MP.SPEC.csproj +++ b/MP.SPEC/MP.SPEC.csproj @@ -5,7 +5,7 @@ enable enable MP.SPEC - 8.16.2605.2814 + 8.16.2605.2816 1800a78a-6ff1-40f9-b490-87fb8bfc1394 en diff --git a/MP.SPEC/Resources/ChangeLog.html b/MP.SPEC/Resources/ChangeLog.html index 4a3ba3b7..cd4875b2 100644 --- a/MP.SPEC/Resources/ChangeLog.html +++ b/MP.SPEC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOSPEC -

Versione: 8.16.2605.2814

+

Versione: 8.16.2605.2816


Note di rilascio:
  • diff --git a/MP.SPEC/Resources/VersNum.txt b/MP.SPEC/Resources/VersNum.txt index 6454cfbd..d0d2d8ea 100644 --- a/MP.SPEC/Resources/VersNum.txt +++ b/MP.SPEC/Resources/VersNum.txt @@ -1 +1 @@ -8.16.2605.2814 +8.16.2605.2816 diff --git a/MP.SPEC/Resources/manifest.xml b/MP.SPEC/Resources/manifest.xml index 8c6b95c1..964f1191 100644 --- a/MP.SPEC/Resources/manifest.xml +++ b/MP.SPEC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 8.16.2605.2814 + 8.16.2605.2816 https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/MP.SPEC.zip https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/ChangeLog.html false diff --git a/Refactor_Plan.md b/Refactor_Plan.md index b39f393f..59363611 100644 --- a/Refactor_Plan.md +++ b/Refactor_Plan.md @@ -44,6 +44,9 @@ I metodi verranno suddivisi in: - [x] `POdlGetByOdlAsync` - [x] `FluxLogGetLastFiltAsync` - [x] `FluxLogParetoAsync` +- [x] `OperatoriGetFiltAsync` +- [x] `MacchineRecipeArchiveAsync` +- [x] `MacchineRecipeConfAsync` - [ ] `AnagEventiGeneral` - [ ] `AnagEventiGetByMacch` - [ ] `AnagKeyValGetAll`