From f914c28bf87a0864e8b26988f3ab53ee3ecf7331 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 17 Nov 2023 14:20:44 +0100 Subject: [PATCH] Renaming metodi x FluxLogPareto --- MP.Data/Controllers/MpSpecController.cs | 43 +++++++-------- MP.SPEC/Components/FLStatusList.razor.cs | 2 +- MP.SPEC/Data/MpDataService.cs | 70 ++++++++++++------------ MP.SPEC/MP.SPEC.csproj | 2 +- MP.SPEC/Resources/ChangeLog.html | 2 +- MP.SPEC/Resources/VersNum.txt | 2 +- MP.SPEC/Resources/manifest.xml | 2 +- 7 files changed, 61 insertions(+), 62 deletions(-) diff --git a/MP.Data/Controllers/MpSpecController.cs b/MP.Data/Controllers/MpSpecController.cs index 0b7b7aaa..73c17c66 100644 --- a/MP.Data/Controllers/MpSpecController.cs +++ b/MP.Data/Controllers/MpSpecController.cs @@ -611,7 +611,6 @@ namespace MP.Data.Controllers numRecProc += numRec; if (numRec > maxItem) { - List listPeriodi = new List(); switch (valMode) @@ -713,6 +712,27 @@ namespace MP.Data.Controllers return dbResult; } + /// + /// Elenco Gruppi + /// + /// + public List FluxLogPareto(string idxMacchina, DateTime dtFrom, DateTime dtTo) + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetFluxLog + .Where(x => (string.IsNullOrEmpty(idxMacchina) || x.IdxMacchina == idxMacchina) && (dtFrom <= x.dtEvento && x.dtEvento <= dtTo)) + .AsNoTracking() + .GroupBy(x => x.CodFlux) + .Select(g => new ParetoFluxLogDTO() { IdxMacchina = idxMacchina, CodFlux = g.Key, Qty = g.Count() }) + .OrderByDescending(x => x.Qty) + .ToList(); + } + return dbResult; + } + /// /// Stored manutenzione del DB /// @@ -1270,27 +1290,6 @@ namespace MP.Data.Controllers return dbResult; } - /// - /// Elenco Gruppi - /// - /// - public List ParetoFluxLog(string idxMacchina, DateTime dtFrom, DateTime dtTo) - { - List dbResult = new List(); - using (var dbCtx = new MoonProContext(_configuration)) - { - dbResult = dbCtx - .DbSetFluxLog - .Where(x => (string.IsNullOrEmpty(idxMacchina) || x.IdxMacchina == idxMacchina) && (dtFrom <= x.dtEvento && x.dtEvento <= dtTo)) - .AsNoTracking() - .GroupBy(x => x.CodFlux) - .Select(g => new ParetoFluxLogDTO() { IdxMacchina = idxMacchina, CodFlux = g.Key, Qty = g.Count() }) - .OrderByDescending(x => x.Qty) - .ToList(); - } - return dbResult; - } - /// /// Stato prod macchina /// diff --git a/MP.SPEC/Components/FLStatusList.razor.cs b/MP.SPEC/Components/FLStatusList.razor.cs index f25e8b8c..d86c17dc 100644 --- a/MP.SPEC/Components/FLStatusList.razor.cs +++ b/MP.SPEC/Components/FLStatusList.razor.cs @@ -116,7 +116,7 @@ namespace MP.SPEC.Components { idxMaccLast = IdxMaccSel; lastPeriodo = CurrPeriodo; - ListComplete = await MDataServ.ParetoFluxLog(IdxMaccSel, CurrPeriodo.Inizio, CurrPeriodo.Fine); + ListComplete = await MDataServ.FluxLogPareto(IdxMaccSel, CurrPeriodo.Inizio, CurrPeriodo.Fine); TotalCount = ListComplete.Count; TotalRecords = ListComplete.Sum(x => x.Qty); FluxList = ListComplete.Select(x => x.CodFlux).ToList(); diff --git a/MP.SPEC/Data/MpDataService.cs b/MP.SPEC/Data/MpDataService.cs index 509f488a..f4957287 100644 --- a/MP.SPEC/Data/MpDataService.cs +++ b/MP.SPEC/Data/MpDataService.cs @@ -800,6 +800,41 @@ namespace MP.SPEC.Data return result; } + /// + /// Elenco Gruppi + /// + /// + public async Task> FluxLogPareto(string idxMacchina, DateTime dtFrom, DateTime dtTo) + { + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string source = "DB"; + List? result = new List(); + // cerco in redis... + string redKey = $"{Utils.redisParetoFLKey}:{idxMacchina}:{dtFrom:yyyyMMdd}:{dtTo:yyyyMMdd}"; + RedisValue rawData = await redisDb.StringGetAsync(redKey); + if (!string.IsNullOrEmpty($"{rawData}")) + { + result = JsonConvert.DeserializeObject>($"{rawData}"); + source = "REDIS"; + } + else + { + result = await Task.FromResult(dbController.FluxLogPareto(idxMacchina, dtFrom, dtTo)); + // serializzo e salvo... + rawData = JsonConvert.SerializeObject(result); + await redisDb.StringSetAsync(redKey, rawData, getRandTOut(redisLongTimeCache)); + } + if (result == null) + { + result = new List(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"ParetoFluxLog Read from {source}: {ts.TotalMilliseconds}ms"); + return result; + } + /// /// Stored manutenzione del DB /// @@ -1248,41 +1283,6 @@ namespace MP.SPEC.Data return result; } - /// - /// Elenco Gruppi - /// - /// - public async Task> ParetoFluxLog(string idxMacchina, DateTime dtFrom, DateTime dtTo) - { - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - string source = "DB"; - List? result = new List(); - // cerco in redis... - string redKey = $"{Utils.redisParetoFLKey}:{idxMacchina}:{dtFrom:yyyyMMdd}:{dtTo:yyyyMMdd}"; - RedisValue rawData = await redisDb.StringGetAsync(redKey); - if (!string.IsNullOrEmpty($"{rawData}")) - { - result = JsonConvert.DeserializeObject>($"{rawData}"); - source = "REDIS"; - } - else - { - result = await Task.FromResult(dbController.ParetoFluxLog(idxMacchina, dtFrom, dtTo)); - // serializzo e salvo... - rawData = JsonConvert.SerializeObject(result); - await redisDb.StringSetAsync(redKey, rawData, getRandTOut(redisLongTimeCache)); - } - if (result == null) - { - result = new List(); - } - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"ParetoFluxLog Read from {source}: {ts.TotalMilliseconds}ms"); - return result; - } - /// /// Eliminazione record selezionato /// diff --git a/MP.SPEC/MP.SPEC.csproj b/MP.SPEC/MP.SPEC.csproj index e5ed1dd8..b77f0d49 100644 --- a/MP.SPEC/MP.SPEC.csproj +++ b/MP.SPEC/MP.SPEC.csproj @@ -5,7 +5,7 @@ enable enable MP.SPEC - 6.16.2311.1016 + 6.16.2311.1714 diff --git a/MP.SPEC/Resources/ChangeLog.html b/MP.SPEC/Resources/ChangeLog.html index 8d44feee..281f5398 100644 --- a/MP.SPEC/Resources/ChangeLog.html +++ b/MP.SPEC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOSPEC -

Versione: 6.16.2311.1016

+

Versione: 6.16.2311.1714


Note di rilascio:
  • diff --git a/MP.SPEC/Resources/VersNum.txt b/MP.SPEC/Resources/VersNum.txt index e1f886bd..3c587425 100644 --- a/MP.SPEC/Resources/VersNum.txt +++ b/MP.SPEC/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2311.1016 +6.16.2311.1714 diff --git a/MP.SPEC/Resources/manifest.xml b/MP.SPEC/Resources/manifest.xml index a93e69cf..463d50ba 100644 --- a/MP.SPEC/Resources/manifest.xml +++ b/MP.SPEC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2311.1016 + 6.16.2311.1714 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