From 7c8ee74ec7f7577cb6e33f65d350ab8731cfacaa Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 9 Nov 2022 15:00:25 +0100 Subject: [PATCH] Aggiunto display idx di ODL/PODL --- MP.Data/Controllers/MpSpecController.cs | 25 ++++++++ MP.SPEC/Components/ListODL.razor | 6 +- MP.SPEC/Components/ListODL.razor.cs | 11 ++++ MP.SPEC/Components/ListPODL.razor | 4 ++ MP.SPEC/Data/MpDataService.cs | 82 ++++++++++++++++++++++++- MP.SPEC/MP.SPEC.csproj | 2 +- MP.SPEC/Resources/ChangeLog.html | 2 +- MP.SPEC/Resources/VersNum.txt | 2 +- MP.SPEC/Resources/manifest.xml | 2 +- 9 files changed, 130 insertions(+), 6 deletions(-) diff --git a/MP.Data/Controllers/MpSpecController.cs b/MP.Data/Controllers/MpSpecController.cs index 8292b9e3..77e8779d 100644 --- a/MP.Data/Controllers/MpSpecController.cs +++ b/MP.Data/Controllers/MpSpecController.cs @@ -859,6 +859,31 @@ namespace MP.Data.Controllers await Task.Delay(1); return dbResult; } + /// + /// Recupero PODL da IdxOdl + /// + /// + /// + public PODLModel PODL_getByOdl(int idxODL) + { + PODLModel dbResult = new PODLModel(); + using (var dbCtx = new MoonProContext(_configuration)) + { + try + { + dbResult = dbCtx + .DbSetPODL + .AsNoTracking() + .Where(x => x.IdxOdl == idxODL) + .FirstOrDefault(); + } + catch (Exception exc) + { + Log.Error($"Eccezione durante PODL_getByOdl{Environment.NewLine}{exc}"); + } + } + return dbResult; + } /// /// Avvio setup ODL da PODL diff --git a/MP.SPEC/Components/ListODL.razor b/MP.SPEC/Components/ListODL.razor index ed2e24d7..d8630ebb 100644 --- a/MP.SPEC/Components/ListODL.razor +++ b/MP.SPEC/Components/ListODL.razor @@ -36,6 +36,7 @@ else } + Cod Articolo Fase Macchina @@ -48,7 +49,6 @@ else @foreach (var record in ListRecords) { - @if (isCurrOdl) { @@ -59,6 +59,10 @@ else } + +
ODL @($"{record.IdxOdl:000000}")
+
PODL @($"{getPodl(record.IdxOdl):000000}")
+ @record.CodArticolo
@record.ArticoloNav.DescArticolo
diff --git a/MP.SPEC/Components/ListODL.razor.cs b/MP.SPEC/Components/ListODL.razor.cs index f93b41fc..6f11213c 100644 --- a/MP.SPEC/Components/ListODL.razor.cs +++ b/MP.SPEC/Components/ListODL.razor.cs @@ -253,6 +253,17 @@ namespace MP.SPEC.Components } } + protected int getPodl(int idxOdl) + { + int answ = 0; + var pOdlData = MDService.PODL_getByOdl(idxOdl); + if (pOdlData != null) + { + answ = pOdlData.IdxPromessa; + } + return answ; + } + private bool hideSpenta { get; set; } = false; /// diff --git a/MP.SPEC/Components/ListPODL.razor b/MP.SPEC/Components/ListPODL.razor index 6b87bbb8..b4f7bbc5 100644 --- a/MP.SPEC/Components/ListPODL.razor +++ b/MP.SPEC/Components/ListPODL.razor @@ -22,6 +22,7 @@ else } + Cod Articolo Fase Macchina @@ -51,6 +52,9 @@ else } + +
PODL @($"{record.IdxPromessa:000000}")
+ @record.CodArticolo
@record.ArticoloNav.DescArticolo
diff --git a/MP.SPEC/Data/MpDataService.cs b/MP.SPEC/Data/MpDataService.cs index f421d23a..25041a13 100644 --- a/MP.SPEC/Data/MpDataService.cs +++ b/MP.SPEC/Data/MpDataService.cs @@ -845,7 +845,83 @@ namespace MP.SPEC.Data /// public async Task PODL_getByKey(int idxPODL) { - return await dbController.PODL_getByKey(idxPODL); + PODLModel result = new PODLModel(); + if (idxPODL != 0) + { + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string readType = "DB"; + string currKey = $"{redisPOdlByPOdl}:{idxPODL}"; + // cerco in redis dato valore sel macchina... + RedisValue rawData = redisDb.StringGet(currKey); + if (rawData.HasValue) + { + result = JsonConvert.DeserializeObject($"{rawData}"); + readType = "REDIS"; + } + else + { + result = await dbController.PODL_getByKey(idxPODL); + // serializzo e salvo... + rawData = JsonConvert.SerializeObject(result); + redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache)); + } + if (result == null) + { + result = new PODLModel(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"PODL_getByKey | Read from {readType}: {ts.TotalMilliseconds}ms"); + } + else + { + Log.Debug("Errore IdxPODL = 0"); + } + return result; + } + + /// + /// Recupero PODL da IdxODL + /// + /// + /// + public PODLModel PODL_getByOdl(int idxODL) + { + PODLModel result = new PODLModel(); + if (idxODL != 0) + { + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string readType = "DB"; + string currKey = $"{redisPOdlByOdl}:{idxODL}"; + // cerco in redis dato valore sel macchina... + RedisValue rawData = redisDb.StringGet(currKey); + if (rawData.HasValue) + { + result = JsonConvert.DeserializeObject($"{rawData}"); + readType = "REDIS"; + } + else + { + result = dbController.PODL_getByOdl(idxODL); + // serializzo e salvo... + rawData = JsonConvert.SerializeObject(result); + redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache)); + } + if (result == null) + { + result = new PODLModel(); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"PODL_getByOdl | Read from {readType}: {ts.TotalMilliseconds}ms"); + } + else + { + Log.Debug("Errore IdxODL = 0"); + } + return result; } /// @@ -1036,6 +1112,10 @@ namespace MP.SPEC.Data private const string redisPOdlList = redisBaseAddr + "SPEC:Cache:POdlList"; + private const string redisPOdlByPOdl = redisBaseAddr + "SPEC:Cache:POdlByPOdl"; + + private const string redisPOdlByOdl = redisBaseAddr + "SPEC:Cache:POdlByOdl"; + private const string redisStatoCom = redisBaseAddr + "SPEC:Cache:StatoCom"; private const string redisTipoArt = redisBaseAddr + "SPEC:Cache:TipoArt"; diff --git a/MP.SPEC/MP.SPEC.csproj b/MP.SPEC/MP.SPEC.csproj index 223c84e8..f403ad81 100644 --- a/MP.SPEC/MP.SPEC.csproj +++ b/MP.SPEC/MP.SPEC.csproj @@ -5,7 +5,7 @@ enable enable MP.SPEC - 6.16.2211.709 + 6.16.2211.914 diff --git a/MP.SPEC/Resources/ChangeLog.html b/MP.SPEC/Resources/ChangeLog.html index bf5ac8e9..cbfc18d7 100644 --- a/MP.SPEC/Resources/ChangeLog.html +++ b/MP.SPEC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOSPEC -

Versione: 6.16.2211.709

+

Versione: 6.16.2211.914


Note di rilascio:
  • diff --git a/MP.SPEC/Resources/VersNum.txt b/MP.SPEC/Resources/VersNum.txt index 400b37d7..c36d170c 100644 --- a/MP.SPEC/Resources/VersNum.txt +++ b/MP.SPEC/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2211.709 +6.16.2211.914 diff --git a/MP.SPEC/Resources/manifest.xml b/MP.SPEC/Resources/manifest.xml index f185a31b..568eb950 100644 --- a/MP.SPEC/Resources/manifest.xml +++ b/MP.SPEC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2211.709 + 6.16.2211.914 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