From 58130dc704356ecb61962906a2ebdb4742275eea Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 3 Nov 2023 15:37:29 +0100 Subject: [PATCH] Update gestione ODL --- MP-TAB-SERV/Components/OdlMan.razor | 34 +++++++-- MP-TAB-SERV/Components/OdlMan.razor.cs | 101 ++++++++++++++++++++++--- MP-TAB-SERV/MP-TAB-SERV.csproj | 2 +- MP-TAB-SERV/Resources/ChangeLog.html | 2 +- MP-TAB-SERV/Resources/VersNum.txt | 2 +- MP-TAB-SERV/Resources/manifest.xml | 2 +- MP-TAB-SERV/appsettings.json | 2 +- MP.Data/Controllers/MpTabController.cs | 24 ++++++ MP.Data/DatabaseModels/vSelOdlModel.cs | 2 +- MP.Data/Services/TabDataService.cs | 37 +++++++++ 10 files changed, 188 insertions(+), 20 deletions(-) diff --git a/MP-TAB-SERV/Components/OdlMan.razor b/MP-TAB-SERV/Components/OdlMan.razor index 7c80034b..c5b7f09b 100644 --- a/MP-TAB-SERV/Components/OdlMan.razor +++ b/MP-TAB-SERV/Components/OdlMan.razor @@ -19,15 +19,30 @@
Slave machine man
+
+ Check articolo in revisione +
+ @if (cancelSetupEnabled) + { +
+ +
+ } + +
-
+
-
- +
+ @@ -35,9 +50,18 @@
- + + @if (podlOk) + { + + }
+ @if (showOdlDetail) + { +

...dettaglio ODL...

+ } +
diff --git a/MP-TAB-SERV/Components/OdlMan.razor.cs b/MP-TAB-SERV/Components/OdlMan.razor.cs index 184f7ba9..c605e701 100644 --- a/MP-TAB-SERV/Components/OdlMan.razor.cs +++ b/MP-TAB-SERV/Components/OdlMan.razor.cs @@ -1,6 +1,7 @@ using global::Microsoft.AspNetCore.Components; using MP.Data.DatabaseModels; using MP.Data.Services; +using NLog; namespace MP_TAB_SERV.Components { @@ -19,8 +20,42 @@ namespace MP_TAB_SERV.Components #endregion Public Properties + #region Protected Fields + + protected bool forceCloseOdl = true; + + #endregion Protected Fields + #region Protected Properties + /// + /// Restituisce il codice IdxMacchina dell'impianto PARENT (se multi) altrimenti la stessa macchina... + /// + protected string idxMaccParent + { + get + { + string answ = ""; + // se è multi controllo + if (isMulti) + { + // verifico se SIA una tavola (ha char "#") + int iSharp = IdxMaccSel.IndexOf('#'); + if (iSharp > 0) + { + // sistemo nome + answ = IdxMaccSel.Substring(0, iSharp); + } + } + return answ; + } + } + + protected List ListODL { get; set; } = new(); + + [Inject] + protected SharedMemService MServ { get; set; } = null!; + /// /// Verifica ODL OK (ovvero caricato x macchina...) /// @@ -29,9 +64,29 @@ namespace MP_TAB_SERV.Components get => (RecMSE != null && RecMSE.IdxOdl > 0); } + protected bool ShowAll + { + get => showAll; + set + { + if (showAll != value) + { + showAll = value; + var pUpd = Task.Run(async () => + { + await ReloadData(); + }); + pUpd.Wait(); + } + } + } + [Inject] protected SharedMemService SMServ { get; set; } = null!; + [Inject] + protected TabDataService TabDServ { get; set; } = null!; + #endregion Protected Properties #region Protected Methods @@ -48,15 +103,22 @@ namespace MP_TAB_SERV.Components await Task.Delay(1); } - protected override void OnInitialized() + protected override async Task OnInitializedAsync() { baseLang = SMServ.GetConf("baseLang"); + numDayOdl = SMServ.GetConfInt("numDaySelOdl"); + if (RecMSE != null) + { + IdxMaccSel = RecMSE.IdxMacchina; + await ReloadData(); + } + checkAll(); } protected override async Task OnParametersSetAsync() { - await Task.Delay(1); - checkAll(); + isMulti = MServ.DictMacchMulti[RecMSE?.IdxMacchina] == 1; + await ReloadData(); } protected async Task SetMacc(string selIdxMacc) @@ -69,6 +131,11 @@ namespace MP_TAB_SERV.Components await Task.Delay(10); } + protected void togOdlDetail() + { + showOdlDetail = !showOdlDetail; + } + protected string Traduci(string lemma) { return SMServ.Traduci($"{baseLang}_{lemma}".ToUpper()); @@ -79,20 +146,27 @@ namespace MP_TAB_SERV.Components #region Private Fields private string baseLang = "IT"; + private bool cancelSetupEnabled = false; + private string IdxMaccSel = ""; + private bool isInAttr = false; + private bool isInProd = false; + private bool isMulti = false; + private bool isProcessing = false; + + private int numDayOdl = 5; + private bool podlOk = false; + private bool showAll = false; + private bool showOdlDetail = false; #endregion Private Fields #region Private Properties - private string IdxMaccSel { get; set; } = ""; - private int IdxOdl { get => RecMSE != null ? RecMSE.IdxOdl ?? 0 : 0; } - private bool isProcessing { get; set; } = false; - private string lblWarnBody { get => odlOk ? Traduci("ConfProdBeforeContinueBody") : Traduci("setOdlBeforeContinueBody"); @@ -113,8 +187,6 @@ namespace MP_TAB_SERV.Components get => RecMSE != null ? RecMSE.PezziProd - RecMSE.PezziConf : 0; } - protected bool forceCloseOdl = true; - #endregion Private Properties #region Private Methods @@ -166,6 +238,17 @@ namespace MP_TAB_SERV.Components mod_ODL1.isEnabled = !needConfProd; #endif } + private static Logger Log = LogManager.GetCurrentClassLogger(); + + private async Task ReloadData() + { + Log.Trace("OdlMan.ReloadData"); + if (!string.IsNullOrEmpty(IdxMaccSel)) + { + ListODL = await TabDServ.VSOdlGetUnused(idxMaccParent, ShowAll, numDayOdl); + Log.Trace($"found {ListODL.Count} rec"); + } + } #endregion Private Methods } diff --git a/MP-TAB-SERV/MP-TAB-SERV.csproj b/MP-TAB-SERV/MP-TAB-SERV.csproj index 40d1715c..f4f6b3fc 100644 --- a/MP-TAB-SERV/MP-TAB-SERV.csproj +++ b/MP-TAB-SERV/MP-TAB-SERV.csproj @@ -3,7 +3,7 @@ net6.0 enable - 6.16.2310.3115 + 6.16.2310.3117 enable MP_TAB_SERV diff --git a/MP-TAB-SERV/Resources/ChangeLog.html b/MP-TAB-SERV/Resources/ChangeLog.html index 10495aae..dcc264dc 100644 --- a/MP-TAB-SERV/Resources/ChangeLog.html +++ b/MP-TAB-SERV/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOSPEC -

Versione: 6.16.2310.3115

+

Versione: 6.16.2310.3117


Note di rilascio:
  • diff --git a/MP-TAB-SERV/Resources/VersNum.txt b/MP-TAB-SERV/Resources/VersNum.txt index 8cb9df45..a52150d6 100644 --- a/MP-TAB-SERV/Resources/VersNum.txt +++ b/MP-TAB-SERV/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2310.3115 +6.16.2310.3117 diff --git a/MP-TAB-SERV/Resources/manifest.xml b/MP-TAB-SERV/Resources/manifest.xml index 9e258330..51e111c4 100644 --- a/MP-TAB-SERV/Resources/manifest.xml +++ b/MP-TAB-SERV/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2310.3115 + 6.16.2310.3117 https://nexus.steamware.net/repository/SWS/MP-TAB-SERV/stable/LAST/MP-TAB-SERV.zip https://nexus.steamware.net/repository/SWS/MP-TAB-SERV/stable/LAST/ChangeLog.html false diff --git a/MP-TAB-SERV/appsettings.json b/MP-TAB-SERV/appsettings.json index 96741cde..a1811dec 100644 --- a/MP-TAB-SERV/appsettings.json +++ b/MP-TAB-SERV/appsettings.json @@ -28,7 +28,7 @@ "DisplayName": "MAPO EgalWare Email BOT", "From": "steamwarebot@outlook.it", "Host": "smtp-mail.outlook.com", - "Password": "siamoInViaNazionale93", + "Password": "siamoInViaNazionale93!", "Port": 587, "UserName": "steamwarebot@outlook.it", "UseSSL": false, diff --git a/MP.Data/Controllers/MpTabController.cs b/MP.Data/Controllers/MpTabController.cs index 4c5dfbbb..2443c599 100644 --- a/MP.Data/Controllers/MpTabController.cs +++ b/MP.Data/Controllers/MpTabController.cs @@ -1349,6 +1349,30 @@ namespace MP.Data.Controllers return dbResult; } + /// + /// Elenco prossimi ODL/PODL x macchina + /// + /// Macchina + /// + /// + /// + public List VSOdlGetUnused(string idxMacchina, bool showAll, int numDayAdd) + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + var IdxMacc = new SqlParameter("@IdxMacchina", idxMacchina); + var ShowAll = new SqlParameter("@showAll", showAll); + var NumDayAdd = new SqlParameter("@numDayAdd", numDayAdd); + + dbResult = dbCtx + .DbSetVSODL + .FromSqlRaw("EXEC stp_vsODL_getUnused @IdxMacchina, @showAll, @numDayAdd", IdxMacc, ShowAll, NumDayAdd) + .AsNoTracking() + .ToList(); + } + return dbResult; + } #endregion Public Methods #region Private Fields diff --git a/MP.Data/DatabaseModels/vSelOdlModel.cs b/MP.Data/DatabaseModels/vSelOdlModel.cs index 8485d869..72e8ede8 100644 --- a/MP.Data/DatabaseModels/vSelOdlModel.cs +++ b/MP.Data/DatabaseModels/vSelOdlModel.cs @@ -14,6 +14,6 @@ namespace MP.Data.DatabaseModels [Key] public int value { get; set; } = 0; public string label { get; set; } = ""; - public DateTime conditio { get; set; } = DateTime.Now; + public DateTime? conditio { get; set; } = DateTime.Now; } } diff --git a/MP.Data/Services/TabDataService.cs b/MP.Data/Services/TabDataService.cs index f9232ca2..458980aa 100644 --- a/MP.Data/Services/TabDataService.cs +++ b/MP.Data/Services/TabDataService.cs @@ -1953,6 +1953,43 @@ namespace MP.Data.Services return result; } + /// + /// Elenco prossimi ODL/PODL x macchina + /// + /// Macchina + /// + /// + /// + public async Task> VSOdlGetUnused(string idxMacchina, bool showAll, int numDayAdd) + { + string source = "DB"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + List? result = new List(); + // cerco in redis... + string currKey = $"{redisBaseKey}:VSODL:{idxMacchina}:ALL_{showAll}:{numDayAdd}"; + RedisValue rawData = await redisDb.StringGetAsync(currKey); + if (rawData.HasValue) + { + result = JsonConvert.DeserializeObject>($"{rawData}"); + source = "REDIS"; + } + else + { + result = await Task.FromResult(dbTabController.VSOdlGetUnused(idxMacchina, showAll, numDayAdd)); + // serializzp e salvo... + rawData = JsonConvert.SerializeObject(result); + await redisDb.StringSetAsync(currKey, rawData, LongCache); + } + if (result == null) + { + result = new List(); + } + sw.Stop(); + Log.Debug($"VSOdlGetUnused | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + return result; + } + #endregion Public Methods #region Protected Fields