From 40694e5766c666f266c98c509de07d0c724cf6dc Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 26 May 2026 16:37:54 +0200 Subject: [PATCH] Aggiunta hashset x velocizzare ricerca recipes x PODL --- MP.Data/Controllers/MpSpecController.cs | 43 ++++++++++ MP.IOC/MP.IOC.csproj | 2 +- MP.IOC/Resources/ChangeLog.html | 2 +- MP.IOC/Resources/VersNum.txt | 2 +- MP.IOC/Resources/manifest.xml | 2 +- .../Properties/PublishProfiles/IIS01.pubxml | 57 ++++++------- MP.SPEC/Components/ListPODL.razor.cs | 83 +++++++++++++------ MP.SPEC/Data/MpDataService.cs | 38 ++++++++- MP.SPEC/MP.SPEC.csproj | 2 +- MP.SPEC/Resources/ChangeLog.html | 2 +- MP.SPEC/Resources/VersNum.txt | 2 +- MP.SPEC/Resources/manifest.xml | 2 +- 12 files changed, 174 insertions(+), 63 deletions(-) diff --git a/MP.Data/Controllers/MpSpecController.cs b/MP.Data/Controllers/MpSpecController.cs index ddebcdc9..f43b0306 100644 --- a/MP.Data/Controllers/MpSpecController.cs +++ b/MP.Data/Controllers/MpSpecController.cs @@ -1615,6 +1615,49 @@ namespace MP.Data.Controllers return dbResult; } + /// + /// Elenco da tabella Macchine filtro x gruppo + /// + /// + /// + public async Task> MacchineGetFiltAsync(string codGruppo) + { + List dbResult = new List(); + try + { + using (var dbCtx = new MoonProContext(options)) + { + if (codGruppo == "*") + { + dbResult = await dbCtx + .DbSetMacchine + .AsNoTracking() + .OrderBy(x => x.IdxMacchina) + .ToListAsync(); + } + else + { + dbResult = await dbCtx + .DbSetGrp2Macc + .Where(g => g.CodGruppo == codGruppo) + .Join(dbCtx.DbSetMacchine, + g => g.IdxMacchina, + m => m.IdxMacchina, + (g, m) => m + ) + .AsNoTracking() + .OrderBy(x => x.IdxMacchina) + .ToListAsync(); + } + } + } + catch (Exception exc) + { + Log.Error($"Eccezione in MacchineGetFiltAsync{Environment.NewLine}{exc}"); + } + return dbResult; + } + /// /// Elenco id MacchineModel che abbiano dati FLuxLog, nel periodo indicato /// diff --git a/MP.IOC/MP.IOC.csproj b/MP.IOC/MP.IOC.csproj index 272dc386..0fcaf0ac 100644 --- a/MP.IOC/MP.IOC.csproj +++ b/MP.IOC/MP.IOC.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 8.16.2605.1208 + 8.16.2605.2519 diff --git a/MP.IOC/Resources/ChangeLog.html b/MP.IOC/Resources/ChangeLog.html index 755b20eb..55973e10 100644 --- a/MP.IOC/Resources/ChangeLog.html +++ b/MP.IOC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MP-IOC -

Versione: 8.16.2605.1208

+

Versione: 8.16.2605.2519


Note di rilascio:
  • diff --git a/MP.IOC/Resources/VersNum.txt b/MP.IOC/Resources/VersNum.txt index 032d5246..a68d1899 100644 --- a/MP.IOC/Resources/VersNum.txt +++ b/MP.IOC/Resources/VersNum.txt @@ -1 +1 @@ -8.16.2605.1208 +8.16.2605.2519 diff --git a/MP.IOC/Resources/manifest.xml b/MP.IOC/Resources/manifest.xml index c6da8756..324cc6c2 100644 --- a/MP.IOC/Resources/manifest.xml +++ b/MP.IOC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 8.16.2605.1208 + 8.16.2605.2519 https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/MP.IOC.zip https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/ChangeLog.html false diff --git a/MP.RIOC/Properties/PublishProfiles/IIS01.pubxml b/MP.RIOC/Properties/PublishProfiles/IIS01.pubxml index 9278d2ad..6c359c50 100644 --- a/MP.RIOC/Properties/PublishProfiles/IIS01.pubxml +++ b/MP.RIOC/Properties/PublishProfiles/IIS01.pubxml @@ -1,32 +1,33 @@  - - MSDeploy - true - Release - Any CPU - https://iis01.egalware.com/MP/RIOC/ - false - b9188473-f4ae-4f9f-be2d-70edaace0db9 - false - https://iis01.egalware.com:8172/MsDeploy.axd - Default Web Site/MP/RIOC - - false - WMSVC - true - true - jenkins - <_SavePWD>true - <_TargetId>IISWebDeploy - net8.0 - win-x64 - - - - filePath - logs\\.*\.log$ - - + + MSDeploy + true + Release + Any CPU + https://iis01.egalware.com/MP/RIOC/ + false + b9188473-f4ae-4f9f-be2d-70edaace0db9 + false + https://iis01.egalware.com:8172/MsDeploy.axd + Default Web Site/MP/RIOC + + true + WMSVC + true + true + jenkins + <_SavePWD>true + <_TargetId>IISWebDeploy + net8.0 + win-x64 + true + + + + filePath + logs\\.*\.log$ + + \ No newline at end of file diff --git a/MP.SPEC/Components/ListPODL.razor.cs b/MP.SPEC/Components/ListPODL.razor.cs index 6250ead8..66b07d13 100644 --- a/MP.SPEC/Components/ListPODL.razor.cs +++ b/MP.SPEC/Components/ListPODL.razor.cs @@ -168,28 +168,7 @@ namespace MP.SPEC.Components protected override async Task OnInitializedAsync() { - ListStati = await MDService.AnagStatiComm(); - ListArtKit = MDService.ArticoliGetByTipo("KIT", "*"); - string strMachRecipe = await MDService.ConfigTryGetAsync("MachineWithRecipe"); - if (!string.IsNullOrEmpty(strMachRecipe)) - { - bool.TryParse(strMachRecipe, out MachineWithRecipe); - } - string SPEC_PODL_gest = await MDService.ConfigTryGetAsync("SPEC_PODL_gest"); - if (!string.IsNullOrEmpty(SPEC_PODL_gest)) - { - bool.TryParse(SPEC_PODL_gest, out enableStartPODL); - } - string SPEC_ODL_gest = await MDService.ConfigTryGetAsync("SPEC_ODL_gest"); - if (!string.IsNullOrEmpty(SPEC_ODL_gest)) - { - bool.TryParse(SPEC_ODL_gest, out enableStopODL); - } - string SPEC_XODL_sync = await MDService.ConfigTryGetAsync("SPEC_XODL_sync"); - if (!string.IsNullOrEmpty(SPEC_XODL_sync)) - { - bool.TryParse(SPEC_XODL_sync, out enableForceSync); - } + await ReloadBaseData(); } protected override async Task OnParametersSetAsync() @@ -216,10 +195,56 @@ namespace MP.SPEC.Components return idxOdl == 0; } + /// + /// Caricamento dati di base + /// + /// + protected async Task ReloadBaseData() + { + ListRecords = null; + isLoading = true; + + var machines = await MDService.MacchineGetFiltAsync("*"); + + _machinesWithConf = machines + .Where(x => !string.IsNullOrEmpty(x.RecipePath)) + .Select(x => x.IdxMacchina) + .ToHashSet(); + + _machinesWithArch = machines + .Where(x => !string.IsNullOrEmpty(x.RecipeArchivePath)) + .Select(x => x.IdxMacchina) + .ToHashSet(); + + ListStati = await MDService.AnagStatiComm(); + ListArtKit = MDService.ArticoliGetByTipo("KIT", "*"); + string strMachRecipe = await MDService.ConfigTryGetAsync("MachineWithRecipe"); + if (!string.IsNullOrEmpty(strMachRecipe)) + { + bool.TryParse(strMachRecipe, out MachineWithRecipe); + } + string SPEC_PODL_gest = await MDService.ConfigTryGetAsync("SPEC_PODL_gest"); + if (!string.IsNullOrEmpty(SPEC_PODL_gest)) + { + bool.TryParse(SPEC_PODL_gest, out enableStartPODL); + } + string SPEC_ODL_gest = await MDService.ConfigTryGetAsync("SPEC_ODL_gest"); + if (!string.IsNullOrEmpty(SPEC_ODL_gest)) + { + bool.TryParse(SPEC_ODL_gest, out enableStopODL); + } + string SPEC_XODL_sync = await MDService.ConfigTryGetAsync("SPEC_XODL_sync"); + if (!string.IsNullOrEmpty(SPEC_XODL_sync)) + { + bool.TryParse(SPEC_XODL_sync, out enableForceSync); + } + } + protected async Task ReloadData() { ListRecords = null; isLoading = true; + // verifico filtro odl... if (actFilter.ShowKit) { @@ -559,10 +584,15 @@ namespace MP.SPEC.Components /// private bool machineHasRecipeArch(string idxMacchina) { - var recipeArchive = MDService.MacchineRecipeArchive(idxMacchina); - return !string.IsNullOrEmpty(recipeArchive); + return _machinesWithArch.Contains(idxMacchina); + //var recipeArchive = MDService.MacchineRecipeArchive(idxMacchina); + //return !string.IsNullOrEmpty(recipeArchive); } + + private HashSet _machinesWithConf = new(); + private HashSet _machinesWithArch = new(); + /// /// Verifica se la idxMaccSel abbia associata una ricetta (template) /// @@ -570,8 +600,9 @@ namespace MP.SPEC.Components /// private bool machineHasRecipeConf(string idxMacchina) { - var recipePath = MDService.MacchineRecipeConf(idxMacchina); - return !string.IsNullOrEmpty(recipePath); + return _machinesWithConf.Contains(idxMacchina); + //var recipePath = MDService.MacchineRecipeConf(idxMacchina); + //return !string.IsNullOrEmpty(recipePath); } /// diff --git a/MP.SPEC/Data/MpDataService.cs b/MP.SPEC/Data/MpDataService.cs index ebbec626..89945777 100644 --- a/MP.SPEC/Data/MpDataService.cs +++ b/MP.SPEC/Data/MpDataService.cs @@ -1725,7 +1725,43 @@ namespace MP.SPEC.Data activity?.SetTag("data.source", source); activity?.SetTag("result.count", 1); activity?.Stop(); - LogTrace($"MacchineGetAll | Read from {source}: {activity?.Duration.TotalMilliseconds}ms"); + LogTrace($"MacchineGetFilt | Read from {source}: {activity?.Duration.TotalMilliseconds}ms"); + return result; + } + /// + /// Elenco di tutte le macchine filtrate x gruppo + /// + /// + /// + public async Task> MacchineGetFiltAsync(string codGruppo) + { + using var activity = ActivitySource.StartActivity("MacchineGetFilt"); + List? result = new List(); + string source = "DB"; + string keyGrp = codGruppo != "*" ? codGruppo : "ALL"; + string currKey = $"{Utils.redisMacList}:{keyGrp}"; + // cerco in redis dato valore sel idxMaccSel... + RedisValue rawData = await redisDb.StringGetAsync(currKey); + if (rawData.HasValue) + { + result = JsonConvert.DeserializeObject>($"{rawData}"); + source = "REDIS"; + } + else + { + result = await dbController.MacchineGetFiltAsync(codGruppo); + // serializzo e salvo... + rawData = JsonConvert.SerializeObject(result); + await redisDb.StringSetAsync(currKey, rawData, getRandTOut(redisLongTimeCache)); + } + if (result == null) + { + result = new List(); + } + activity?.SetTag("data.source", source); + activity?.SetTag("result.count", 1); + activity?.Stop(); + LogTrace($"MacchineGetFiltAsync | Read from {source}: {activity?.Duration.TotalMilliseconds}ms"); return result; } diff --git a/MP.SPEC/MP.SPEC.csproj b/MP.SPEC/MP.SPEC.csproj index 27d724cd..06d98519 100644 --- a/MP.SPEC/MP.SPEC.csproj +++ b/MP.SPEC/MP.SPEC.csproj @@ -5,7 +5,7 @@ enable enable MP.SPEC - 8.16.2605.2518 + 8.16.2605.2616 1800a78a-6ff1-40f9-b490-87fb8bfc1394 en diff --git a/MP.SPEC/Resources/ChangeLog.html b/MP.SPEC/Resources/ChangeLog.html index 8e00d0ca..68c19573 100644 --- a/MP.SPEC/Resources/ChangeLog.html +++ b/MP.SPEC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOSPEC -

    Versione: 8.16.2605.2518

    +

    Versione: 8.16.2605.2616


    Note di rilascio:
    • diff --git a/MP.SPEC/Resources/VersNum.txt b/MP.SPEC/Resources/VersNum.txt index 16a16eda..418a7c18 100644 --- a/MP.SPEC/Resources/VersNum.txt +++ b/MP.SPEC/Resources/VersNum.txt @@ -1 +1 @@ -8.16.2605.2518 +8.16.2605.2616 diff --git a/MP.SPEC/Resources/manifest.xml b/MP.SPEC/Resources/manifest.xml index 4fce2715..19b26f9f 100644 --- a/MP.SPEC/Resources/manifest.xml +++ b/MP.SPEC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 8.16.2605.2518 + 8.16.2605.2616 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