From 44c98a29d9826e4fe2ed27d4df66bb60141b92d1 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 10 Apr 2025 19:51:33 +0200 Subject: [PATCH] Ancora update x test KIT --- MP.Core/Utils.cs | 1 + MP.Data/Controllers/MpSpecController.cs | 26 ++++++++ MP.Data/DbModels/TksScoreModel.cs | 45 +++++++++++++ MP.Data/MoonProContext.cs | 1 + MP.SPEC/Components/GestKitPodl.razor.cs | 7 --- MP.SPEC/Components/GestKitVerif.razor.cs | 7 --- .../{ => ProdKit}/GestKitPodl.razor | 0 .../{Composer.razor => KitComposer.razor} | 4 +- ...Composer.razor.cs => KitComposer.razor.cs} | 11 ++-- .../{PodlMan.razor => KitPodlMan.razor} | 0 .../{PodlMan.razor.cs => KitPodlMan.razor.cs} | 2 +- .../KitVerify.razor} | 63 ++++++++++++++----- MP.SPEC/Components/ProdKit/KitVerify.razor.cs | 41 ++++++++++++ MP.SPEC/Components/ProdKit/Manager.razor | 6 +- MP.SPEC/Components/ProdKit/Manager.razor.cs | 12 ++++ MP.SPEC/Data/MpDataService.cs | 39 +++++++++++- 16 files changed, 225 insertions(+), 40 deletions(-) create mode 100644 MP.Data/DbModels/TksScoreModel.cs delete mode 100644 MP.SPEC/Components/GestKitPodl.razor.cs delete mode 100644 MP.SPEC/Components/GestKitVerif.razor.cs rename MP.SPEC/Components/{ => ProdKit}/GestKitPodl.razor (100%) rename MP.SPEC/Components/ProdKit/{Composer.razor => KitComposer.razor} (97%) rename MP.SPEC/Components/ProdKit/{Composer.razor.cs => KitComposer.razor.cs} (94%) rename MP.SPEC/Components/ProdKit/{PodlMan.razor => KitPodlMan.razor} (100%) rename MP.SPEC/Components/ProdKit/{PodlMan.razor.cs => KitPodlMan.razor.cs} (99%) rename MP.SPEC/Components/{GestKitVerif.razor => ProdKit/KitVerify.razor} (69%) create mode 100644 MP.SPEC/Components/ProdKit/KitVerify.razor.cs diff --git a/MP.Core/Utils.cs b/MP.Core/Utils.cs index ca50ee3f..e0ed333b 100644 --- a/MP.Core/Utils.cs +++ b/MP.Core/Utils.cs @@ -71,6 +71,7 @@ namespace MP.Core public const string redisXdlData = redisBaseAddr + "Cache:XDL:"; public const string redisKitInst = redisBaseAddr + "Cache:Kit:Inst"; + public const string redisKitScore = redisBaseAddr + "Cache:Kit:Score"; public const string redisKitTempl = redisBaseAddr + "Cache:Kit:Templ"; public const string redisKitWip = redisBaseAddr + "Cache:Kit:Wip"; diff --git a/MP.Data/Controllers/MpSpecController.cs b/MP.Data/Controllers/MpSpecController.cs index ef16c1e0..4bb499fc 100644 --- a/MP.Data/Controllers/MpSpecController.cs +++ b/MP.Data/Controllers/MpSpecController.cs @@ -1790,6 +1790,32 @@ namespace MP.Data.Controllers return fatto; } + /// + /// Punteggio compatibilità KIT per KeyFilt indicato + /// + /// + /// + /// + public List TksScore(string KeyFilt, int MaxResult) + { + List dbResult = new List(); + if (!string.IsNullOrEmpty(KeyFilt)) + { + using (var dbCtx = new MoonProContext(_configuration)) + { + var pKeyFilt = new SqlParameter("@KeyFilt", KeyFilt); + var pMaxRes = new SqlParameter("@maxResult", MaxResult); + + dbResult = dbCtx + .DbSetTksScore + .FromSqlRaw("EXEC stp_TKS_Search @KeyFilt, @maxResult", pKeyFilt, pMaxRes) + .AsNoTracking() + .ToList(); + } + } + return dbResult; + } + /// /// Elenco Vocabolario (completo) /// diff --git a/MP.Data/DbModels/TksScoreModel.cs b/MP.Data/DbModels/TksScoreModel.cs new file mode 100644 index 00000000..d19b49eb --- /dev/null +++ b/MP.Data/DbModels/TksScoreModel.cs @@ -0,0 +1,45 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +// +// This is here so CodeMaid doesn't reorganize this document +// +namespace MP.Data.DbModels +{ + /// + /// Classe gestione item risposta selezione stored ricerca compatibilità KIT + /// + public class TksScoreModel + { + #region Public Properties + + /// + /// Codice Articolo Parent + /// + [Key, MaxLength(50)] + public string CodArtParent { get; set; } = ""; + + /// + /// Numero Cicli Associati + /// + public int ChildFound { get; set; } = 0; + + /// + /// Score Cicli Associati + /// + public double ChildScore { get; set; } = 0; + /// + /// Score complessivo + /// + public double TotalScore { get; set; } = 0; + + + + #endregion Public Properties + } +} diff --git a/MP.Data/MoonProContext.cs b/MP.Data/MoonProContext.cs index 70966108..03f34685 100644 --- a/MP.Data/MoonProContext.cs +++ b/MP.Data/MoonProContext.cs @@ -102,6 +102,7 @@ namespace MP.Data public virtual DbSet DbSetInstKit { get; set; } public virtual DbSet DbSetTempKit { get; set; } public virtual DbSet DbSetWipKit { get; set; } + public virtual DbSet DbSetTksScore { get; set; } #endregion Public Properties diff --git a/MP.SPEC/Components/GestKitPodl.razor.cs b/MP.SPEC/Components/GestKitPodl.razor.cs deleted file mode 100644 index e2b99b1b..00000000 --- a/MP.SPEC/Components/GestKitPodl.razor.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace MP.SPEC.Components -{ - public partial class GestKitPodl - { - - } -} \ No newline at end of file diff --git a/MP.SPEC/Components/GestKitVerif.razor.cs b/MP.SPEC/Components/GestKitVerif.razor.cs deleted file mode 100644 index c3394c1d..00000000 --- a/MP.SPEC/Components/GestKitVerif.razor.cs +++ /dev/null @@ -1,7 +0,0 @@ -namespace MP.SPEC.Components -{ - public partial class GestKitVerif - { - - } -} \ No newline at end of file diff --git a/MP.SPEC/Components/GestKitPodl.razor b/MP.SPEC/Components/ProdKit/GestKitPodl.razor similarity index 100% rename from MP.SPEC/Components/GestKitPodl.razor rename to MP.SPEC/Components/ProdKit/GestKitPodl.razor diff --git a/MP.SPEC/Components/ProdKit/Composer.razor b/MP.SPEC/Components/ProdKit/KitComposer.razor similarity index 97% rename from MP.SPEC/Components/ProdKit/Composer.razor rename to MP.SPEC/Components/ProdKit/KitComposer.razor index 694b7b08..239abf31 100644 --- a/MP.SPEC/Components/ProdKit/Composer.razor +++ b/MP.SPEC/Components/ProdKit/KitComposer.razor @@ -2,7 +2,7 @@
-

Composizione KIT

+

Composizione KIT

@@ -59,7 +59,7 @@
diff --git a/MP.SPEC/Components/ProdKit/Composer.razor.cs b/MP.SPEC/Components/ProdKit/KitComposer.razor.cs similarity index 94% rename from MP.SPEC/Components/ProdKit/Composer.razor.cs rename to MP.SPEC/Components/ProdKit/KitComposer.razor.cs index ff96b4ce..61fe20b2 100644 --- a/MP.SPEC/Components/ProdKit/Composer.razor.cs +++ b/MP.SPEC/Components/ProdKit/KitComposer.razor.cs @@ -5,10 +5,13 @@ using MP.SPEC.Data; namespace MP.SPEC.Components.ProdKit { - public partial class Composer + public partial class KitComposer { #region Public Properties + [Parameter] + public string KeyFilt { get; set; } = ""; + [Parameter] public PODLExpModel? Rec2Add { @@ -77,13 +80,14 @@ namespace MP.SPEC.Components.ProdKit // calcolo codice temporaneo utente...da apertura KIT if (string.IsNullOrEmpty(KeyFilt)) { - DateTime adesso = DateTime.Now; - KeyFilt = $"KIT_{adesso:yyMMdd}_{adesso:HHmmss}"; // elimino dati + vecchi di 2h... DateTime dtLimit = DateTime.Now.AddHours(-2); var done = MDService.WipKitDeleteOlder(dtLimit); } + } + protected override void OnParametersSet() + { ReloadData(); } @@ -92,7 +96,6 @@ namespace MP.SPEC.Components.ProdKit #region Private Fields private PODLExpModel? currRec = null; - private string KeyFilt = ""; private List ListRecords = new List(); private List SearchRecord = new List(); diff --git a/MP.SPEC/Components/ProdKit/PodlMan.razor b/MP.SPEC/Components/ProdKit/KitPodlMan.razor similarity index 100% rename from MP.SPEC/Components/ProdKit/PodlMan.razor rename to MP.SPEC/Components/ProdKit/KitPodlMan.razor diff --git a/MP.SPEC/Components/ProdKit/PodlMan.razor.cs b/MP.SPEC/Components/ProdKit/KitPodlMan.razor.cs similarity index 99% rename from MP.SPEC/Components/ProdKit/PodlMan.razor.cs rename to MP.SPEC/Components/ProdKit/KitPodlMan.razor.cs index 43e025e8..1e8d29eb 100644 --- a/MP.SPEC/Components/ProdKit/PodlMan.razor.cs +++ b/MP.SPEC/Components/ProdKit/KitPodlMan.razor.cs @@ -8,7 +8,7 @@ using NLog; namespace MP.SPEC.Components.ProdKit { - public partial class PodlMan : IDisposable + public partial class KitPodlMan : IDisposable { #region Public Properties diff --git a/MP.SPEC/Components/GestKitVerif.razor b/MP.SPEC/Components/ProdKit/KitVerify.razor similarity index 69% rename from MP.SPEC/Components/GestKitVerif.razor rename to MP.SPEC/Components/ProdKit/KitVerify.razor index a4f81c93..2b9187b3 100644 --- a/MP.SPEC/Components/GestKitVerif.razor +++ b/MP.SPEC/Components/ProdKit/KitVerify.razor @@ -1,11 +1,44 @@ -
-
-

Verifica KIT

-
-
+
+
+
+
+

Verifica KIT

+
+
+
+
Elenco KIT compatibili -

...tabella...

- @* + + + + + + + + + + + @foreach (var record in ListRecords) + { + + + + + + + } + +
Cod Kit# OKCoerenzaAzione
@record.CodArtParent@record.ChildFound@($"{record.TotalScore:P2}") + @if (record.TotalScore == 1) + { + + } + else + { + + } +
+ @* Nessun KIT trovato @@ -27,10 +60,10 @@ *@ -
+
Elenco promesse per KIT (100%)

...tabella...

- @* + @* @@ -68,11 +101,11 @@ *@ -
-
- -
+
+
+ +
diff --git a/MP.SPEC/Components/ProdKit/KitVerify.razor.cs b/MP.SPEC/Components/ProdKit/KitVerify.razor.cs new file mode 100644 index 00000000..4c568aab --- /dev/null +++ b/MP.SPEC/Components/ProdKit/KitVerify.razor.cs @@ -0,0 +1,41 @@ +using Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; +using MP.Data.DbModels; +using MP.SPEC.Data; + +namespace MP.SPEC.Components.ProdKit +{ + public partial class KitVerify + { + + [Parameter] + public string KeyFilt { get; set; } = ""; + + + [Inject] + protected IJSRuntime JSRuntime { get; set; } = null!; + + [Inject] + protected MpDataService MDService { get; set; } = null!; + + protected override void OnParametersSet() + { + ReloadData(); + } + + private List ListRecords = new List(); + + private List SearchRecord = new List(); + + private void ReloadData() + { + SearchRecord = MDService.TksScore(KeyFilt, 1000, true); + ListRecords = SearchRecord.ToList(); + } + + private void DoCreatePOdl(TksScoreModel currRec) + { + + } + } +} \ No newline at end of file diff --git a/MP.SPEC/Components/ProdKit/Manager.razor b/MP.SPEC/Components/ProdKit/Manager.razor index 901fa89f..0bc783fa 100644 --- a/MP.SPEC/Components/ProdKit/Manager.razor +++ b/MP.SPEC/Components/ProdKit/Manager.razor @@ -1,12 +1,12 @@ 
- +
- +
- +
diff --git a/MP.SPEC/Components/ProdKit/Manager.razor.cs b/MP.SPEC/Components/ProdKit/Manager.razor.cs index dda2ba14..53ecc3ed 100644 --- a/MP.SPEC/Components/ProdKit/Manager.razor.cs +++ b/MP.SPEC/Components/ProdKit/Manager.razor.cs @@ -22,8 +22,18 @@ namespace MP.SPEC.Components.ProdKit padCodXdl = MDService.ConfigTryGet("padCodXdl"); } currPodlRec = null; + + // Verifico chiave Kit o la rigenero + if (string.IsNullOrEmpty(keyFilt)) + { + DateTime adesso = DateTime.Now; + keyFilt = $"KIT_{adesso:yyMMdd}_{adesso:HHmmss}"; + keyFiltSearch = keyFilt; + } } + private string keyFilt = ""; + private string keyFiltSearch = ""; #endregion Protected Methods #region Private Fields @@ -36,7 +46,9 @@ namespace MP.SPEC.Components.ProdKit /// protected void SavePodl(PODLExpModel selRec) { + keyFiltSearch = "KIT#"; currPodlRec = selRec; + keyFiltSearch = keyFilt; } /// diff --git a/MP.SPEC/Data/MpDataService.cs b/MP.SPEC/Data/MpDataService.cs index d235ac17..6e354163 100644 --- a/MP.SPEC/Data/MpDataService.cs +++ b/MP.SPEC/Data/MpDataService.cs @@ -2042,6 +2042,43 @@ namespace MP.SPEC.Data return fatto; } + /// + /// Punteggio compatibilità KIT per KeyFilt indicato + /// + /// + /// + /// + /// + public List TksScore(string KeyFilt, int MaxResult, bool ForceDb) + { + string source = "DB"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + List? result = new List(); + // cerco in redis... + string currKey = $"{Utils.redisKitScore}:{KeyFilt}:{MaxResult}"; + RedisValue rawData = redisDb.StringGet(currKey); + if (rawData.HasValue && !ForceDb) + { + result = JsonConvert.DeserializeObject>($"{rawData}"); + source = "REDIS"; + } + else + { + result = dbController.TksScore(KeyFilt, MaxResult); + // serializzo e salvo... + rawData = JsonConvert.SerializeObject(result); + redisDb.StringSet(currKey, rawData, TimeSpan.FromMinutes(redisLongTimeCache)); + } + if (result == null) + { + result = new List(); + } + sw.Stop(); + Log.Debug($"TksScore | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + return result; + } + /// /// Esegue traduzione dato vocabolario da Lingua + Lemma /// @@ -2155,7 +2192,7 @@ namespace MP.SPEC.Data } /// - /// Elimina i record associati al KeyFilt indicato + /// Elimina i record associati al keyFilt indicato /// /// public bool WipKitDeleteGroup(string KeyFilt)