From 60085b2510dbf7da423cdb7682af3c7ee97de4be Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 27 Oct 2023 08:46:23 +0200 Subject: [PATCH] COmpletato ST Checks (da testare) --- MP-TAB-SERV/Components/TechSheetMan.razor | 8 +- MP-TAB-SERV/Components/TechSheetMan.razor.cs | 10 + .../Components/TechSheet_ST_ObjCheck.razor | 21 +- .../Components/TechSheet_ST_ObjCheck.razor.cs | 199 +++++++++++------- .../Components/TechSheet_ST_ObjView.razor.cs | 8 +- 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.Data/Controllers/MpTabController.cs | 22 ++ MP.Data/Services/TabDataService.cs | 20 +- 11 files changed, 208 insertions(+), 88 deletions(-) diff --git a/MP-TAB-SERV/Components/TechSheetMan.razor b/MP-TAB-SERV/Components/TechSheetMan.razor index bf0d7934..d38a4e30 100644 --- a/MP-TAB-SERV/Components/TechSheetMan.razor +++ b/MP-TAB-SERV/Components/TechSheetMan.razor @@ -14,9 +14,13 @@
- +
- @if (ListGruppi.Count == 0) + @if (isProcessing) + { + + } + else if (ListGruppi.Count == 0) {
ST: Nessun Gruppo Trovato
} diff --git a/MP-TAB-SERV/Components/TechSheetMan.razor.cs b/MP-TAB-SERV/Components/TechSheetMan.razor.cs index 69e1b733..3bed500e 100644 --- a/MP-TAB-SERV/Components/TechSheetMan.razor.cs +++ b/MP-TAB-SERV/Components/TechSheetMan.razor.cs @@ -39,6 +39,14 @@ namespace MP_TAB_SERV.Components checkReset(); } + protected async Task ForceRefresh() + { + isProcessing = true; + await InvokeAsync(StateHasChanged); + await ReloadData(); + isProcessing = false; + } + protected override async Task OnParametersSetAsync() { if (RecMSE != null) @@ -59,6 +67,8 @@ namespace MP_TAB_SERV.Components private bool inAttr = false; + private bool isProcessing = false; + #endregion Private Fields #region Private Properties diff --git a/MP-TAB-SERV/Components/TechSheet_ST_ObjCheck.razor b/MP-TAB-SERV/Components/TechSheet_ST_ObjCheck.razor index c76c1844..6c18d948 100644 --- a/MP-TAB-SERV/Components/TechSheet_ST_ObjCheck.razor +++ b/MP-TAB-SERV/Components/TechSheet_ST_ObjCheck.razor @@ -1,5 +1,16 @@ -
- Verifica - - -
\ No newline at end of file +@if (showChecks) +{ +
+ Verifica + + +
+ @if (!string.IsNullOrEmpty(MessageText)) + { +
+
+ @MessageText +
+
+ } +} \ No newline at end of file diff --git a/MP-TAB-SERV/Components/TechSheet_ST_ObjCheck.razor.cs b/MP-TAB-SERV/Components/TechSheet_ST_ObjCheck.razor.cs index 7c12852c..73f02e3d 100644 --- a/MP-TAB-SERV/Components/TechSheet_ST_ObjCheck.razor.cs +++ b/MP-TAB-SERV/Components/TechSheet_ST_ObjCheck.razor.cs @@ -1,131 +1,184 @@ -using global::System; -using global::System.Collections.Generic; -using global::System.Linq; -using global::System.Threading.Tasks; using global::Microsoft.AspNetCore.Components; -using System.Net.Http; -using Microsoft.AspNetCore.Authorization; -using Microsoft.AspNetCore.Components.Authorization; -using Microsoft.AspNetCore.Components.Forms; -using Microsoft.AspNetCore.Components.Routing; -using Microsoft.AspNetCore.Components.Web; -using Microsoft.AspNetCore.Components.Web.Virtualization; -using Microsoft.JSInterop; -using MP_TAB_SERV; -using MP_TAB_SERV.Shared; -using MP_TAB_SERV.Components; -using MP.Data; using MP.Data.DatabaseModels; -using MP.Data.DTO; +using MP.Data.Objects; using MP.Data.Services; -using Newtonsoft.Json; -using NLog; -using Amazon.Runtime.Internal.Util; namespace MP_TAB_SERV.Components { public partial class TechSheet_ST_ObjCheck { + #region Public Properties + [Parameter] public string CodArticolo { get; set; } = ""; + [Parameter] - public int idxOdl { get; set; } = 0; + public EventCallback E_Updated { get; set; } + + [Parameter] + public int IdxOdl { get; set; } = 0; + + #endregion Public Properties + + #region Public Methods + + public void checkInputData() + { + if (IdxOdl > 0) + { + var rawData = TabDServ.STAR_pendByOdl(IdxOdl); + showChecks = rawData.Count > 0; + } + else + { + showChecks = false; + } + } + + #endregion Public Methods + + #region Protected Properties + + [Inject] + protected MessageService MServ { get; set; } = null!; protected string ScanValue { get => ""; set { - lastScan = value; - // processo - processInput(); + lastBCodeVal = value; + // processo input in async.... + var pUpd = Task.Run(async () => + { + await processInput(); + //await InvokeAsync(() => StateHasChanged()); + }); + pUpd.Wait(); } } + [Inject] protected SharedMemService SMServ { get; set; } = null!; [Inject] protected TabDataService TabDServ { get; set; } = null!; + + #endregion Protected Properties + + #region Protected Methods + + protected override void OnParametersSet() + { + checkInputData(); + } + + #endregion Protected Methods + + #region Private Fields + + private string lastBCodeVal = ""; + private string MessageCss = ""; + private string MessageText = ""; + private bool showChecks = false; + + #endregion Private Fields + + #region Private Properties + + private string CognomeNome + { + get => MServ.CognomeNome; + } + + #endregion Private Properties + + #region Private Methods + /// /// procedura pricipale decodifica Barcode /// - private void processInput() + private async Task processInput() { bool found = false; bool batchOk = false; - List tabRichieste = TabDServ.STAR_pendByOdl(idxOdl); + List tabRichieste = TabDServ.STAR_pendByOdl(IdxOdl); List tabGiacenzeLotto = new List(); - ST_ActRow datiBatchCheck; - AnagLottiArca datiLotto; + ST_ActRow? datiBatchCheck; + AnagLottiArca? datiLotto; // per prima cosa recupero i valori "Pending" da leggere come candidati... -#if false if (tabRichieste != null && tabRichieste.Count > 0) { // cerco per EQ come primo step... - var trovatoEq = tabRichieste.Where(x => x.CheckType == "EQ" && x.Value == BCodeVal); + var trovatoEq = tabRichieste.Where(x => x.CheckType == "EQ" && x.Value == lastBCodeVal); if (trovatoEq != null && trovatoEq.Count() > 0) { // recupero record.. var datiEqCheck = trovatoEq.FirstOrDefault(); - // registro trovato - found = true; - lblMessage.Text = $"Parametro acquisito: {BCodeVal}"; - lblMessage.CssClass = "text-success"; - // upsert controllo - DataLayerObj.taSTChk.upsertQuery(idxOdl, datiEqCheck.IdxST, datiEqCheck.Oggetto, datiEqCheck.Num, BCodeVal, BCodeVal, true, user_std.UtSn.utente, false); + if (datiEqCheck != null) + { + // registro trovato + found = true; + MessageText = $"Parametro acquisito: {lastBCodeVal}"; + MessageCss = "text-success"; + // upsert controllo + await TabDServ.ST_CheckUpsert(IdxOdl, datiEqCheck.IdxST, datiEqCheck.Oggetto, datiEqCheck.Num, lastBCodeVal, lastBCodeVal, true, CognomeNome, false); + } } // se non trovato if (!found) { // recupero record.. cercando in giacenza il LOTTO... - tabGiacenzeLotto = DataLayerObj.taArcaGiac.getBySearch(null, "", BCodeVal, "", false); - // controllo condizione tipo BATCH (speciale) - prima solo che CI SIA una richiesta di questo tipo + tabGiacenzeLotto = await TabDServ.LottoEsterno("", lastBCodeVal, ""); + // controllo condizione tipo BATCH (speciale) - prima solo che CI SIA una + // richiesta di questo tipo var trovatoBatch = tabRichieste.Where(x => x.CheckType == "BATCH"); if (trovatoBatch != null && trovatoBatch.Count() > 0) { datiBatchCheck = trovatoBatch.FirstOrDefault(); - if (tabGiacenzeLotto != null && tabGiacenzeLotto.Count > 0) + if (datiBatchCheck != null && tabGiacenzeLotto != null && tabGiacenzeLotto.Count > 0) { datiLotto = tabGiacenzeLotto.FirstOrDefault(); - - // registro trovato - found = true; - // upsert controllo - DataLayerObj.taSTChk.upsertQuery(idxOdl, datiBatchCheck.IdxST, datiBatchCheck.Oggetto, datiBatchCheck.Num, BCodeVal, datiLotto.Cd_AR, true, user_std.UtSn.utente, false); - // conto quanti check ci sono dopo, se calati --> ok altrimenti errore - var tabRichiestePost = DataLayerObj.taSTAR.getPendingByOdl(idxOdl); - if (tabRichiestePost.Count < tabRichieste.Count) + if (datiLotto != null) { - lblMessage.Text = $"Lotto riconosciuto: {BCodeVal} --> {datiLotto.Cd_AR} | Articolo acquisito"; - lblMessage.CssClass = "text-success"; - batchOk = true; - } - else - { - lblMessage.Text = $"Lotto: {BCodeVal} --> {datiLotto.Cd_AR} | Articolo NON richiesto"; - lblMessage.CssClass = "text-danger"; + // registro trovato + found = true; + // upsert controllo + await TabDServ.ST_CheckUpsert(IdxOdl, datiBatchCheck.IdxST, datiBatchCheck.Oggetto, datiBatchCheck.Num, lastBCodeVal, datiLotto.Cd_AR, true, CognomeNome, false); + // conto quanti check ci sono dopo, se calati --> ok altrimenti errore + var tabRichiestePost = TabDServ.STAR_pendByOdl(IdxOdl); + if (tabRichiestePost.Count < tabRichieste.Count) + { + MessageText = $"Lotto riconosciuto: {lastBCodeVal} --> {datiLotto.Cd_AR} | Articolo acquisito"; + MessageCss = "text-success"; + batchOk = true; + } + else + { + MessageText = $"Lotto: {lastBCodeVal} --> {datiLotto.Cd_AR} | Articolo NON richiesto"; + MessageCss = "text-danger"; + } } } } if (!batchOk) { - var currDeroga = DataLayerObj.getDerogaSt(tabRichieste[0].IdxST); + var currDeroga = TabDServ.ST_DerogaGet(CognomeNome, tabRichieste[0].IdxST); // ciclo tra TUTTE le richeiste attive foreach (var item in tabRichieste) { - // verifico EVENTUALI deroghe - // se è deroga x gruppo/tipo/num corretto... + // verifico EVENTUALI deroghe se è deroga x gruppo/tipo/num corretto... if (currDeroga.CanForce && item.CodGruppo == currDeroga.CodGruppo && item.CodTipo == currDeroga.CodTipo && item.Num == currDeroga.Num && item.Oggetto == currDeroga.Oggetto) { // ... forzo accettazione deroga - DataLayerObj.taSTChk.upsertQuery(idxOdl, item.IdxST, item.Oggetto, item.Num, BCodeVal, item.Value, true, user_std.UtSn.utente, true); - lblMessage.Text = $"Lotto/articolo non valido: {BCodeVal} --> Forzato a valido per articolo {item.Value}"; - lblMessage.CssClass = "text-warning"; - DataLayerObj.setDerogaSt(new MapoSDK.StCheckOverride() { IdxST = item.IdxST, CanForce = false }); + await TabDServ.ST_CheckUpsert(IdxOdl, item.IdxST, item.Oggetto, item.Num, lastBCodeVal, item.Value, true, CognomeNome, true); + MessageText = $"Lotto/articolo non valido: {lastBCodeVal} --> Forzato a valido per articolo {item.Value}"; + MessageCss = "text-warning"; + TabDServ.ST_DerogaSet(new StCheckOverride() { IdxST = item.IdxST, CanForce = false }); batchOk = true; } } @@ -138,30 +191,32 @@ namespace MP_TAB_SERV.Components if (tabGiacenzeLotto != null && tabGiacenzeLotto.Count > 0) { datiLotto = tabGiacenzeLotto.FirstOrDefault(); - lblMessage.Text = $"Lotto: {BCodeVal} --> {datiLotto.Cd_AR} | Articolo NON richiesto"; - lblMessage.CssClass = "text-danger"; + if (datiLotto != null) + { + MessageText = $"Lotto: {lastBCodeVal} --> {datiLotto.Cd_AR} | Articolo NON richiesto"; + MessageCss = "text-danger"; + } } else { - lblMessage.Text = $"Parametro non riconosciuto: {BCodeVal}"; - lblMessage.CssClass = "text-secondary"; + MessageText = $"Parametro non riconosciuto: {lastBCodeVal}"; + MessageCss = "text-secondary"; } } } else { - lblMessage.Text = $"Parametro non valido: {BCodeVal}"; - lblMessage.CssClass = "text-secondary"; + MessageText = $"Parametro non valido: {lastBCodeVal}"; + MessageCss = "text-secondary"; } // sistemo visualizzaizone componente - BCodeVal = ""; + lastBCodeVal = ""; checkInputData(); // sollevo evento - reportUpdate(); -#endif + await E_Updated.InvokeAsync(true); } - private string lastScan = ""; + #endregion Private Methods } } \ No newline at end of file diff --git a/MP-TAB-SERV/Components/TechSheet_ST_ObjView.razor.cs b/MP-TAB-SERV/Components/TechSheet_ST_ObjView.razor.cs index cd4ec35c..09e834dd 100644 --- a/MP-TAB-SERV/Components/TechSheet_ST_ObjView.razor.cs +++ b/MP-TAB-SERV/Components/TechSheet_ST_ObjView.razor.cs @@ -80,7 +80,7 @@ namespace MP_TAB_SERV.Components CodTipo = CurrRec.CodTipo, CodGruppo = CurrRec.CodGruppo, IdxST = CurrRec.IdxST, - Utente = $"{MatrOpr}" + Utente = CognomeNome }; // salvo TabDServ.ST_DerogaSet(newDeroga); @@ -100,7 +100,7 @@ namespace MP_TAB_SERV.Components if (CurrRec != null) { hasDeroga = false; - var currDeroga = TabDServ.ST_DerogaGet($"{MatrOpr}", CurrRec.IdxST); + var currDeroga = TabDServ.ST_DerogaGet(CognomeNome, CurrRec.IdxST); if (currDeroga != null) { hasDeroga = (currDeroga.IdxST == CurrRec.IdxST && currDeroga.CanForce && currDeroga.Num == CurrRec.Num && currDeroga.CodGruppo == CurrRec.CodGruppo && currDeroga.CodTipo == CurrRec.CodTipo && currDeroga.Oggetto == CurrRec.Oggetto); @@ -156,9 +156,9 @@ namespace MP_TAB_SERV.Components } } - private int MatrOpr + private string CognomeNome { - get => MServ.MatrOpr; + get => MServ.CognomeNome; } #endregion Private Properties diff --git a/MP-TAB-SERV/MP-TAB-SERV.csproj b/MP-TAB-SERV/MP-TAB-SERV.csproj index 9fa8958b..9c3ab2c7 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.2619 + 6.16.2310.2708 enable MP_TAB_SERV diff --git a/MP-TAB-SERV/Resources/ChangeLog.html b/MP-TAB-SERV/Resources/ChangeLog.html index aa961ad8..f81d94bb 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.2619

+

Versione: 6.16.2310.2708


Note di rilascio:
  • diff --git a/MP-TAB-SERV/Resources/VersNum.txt b/MP-TAB-SERV/Resources/VersNum.txt index 3d4f1868..fdb2edcb 100644 --- a/MP-TAB-SERV/Resources/VersNum.txt +++ b/MP-TAB-SERV/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2310.2619 +6.16.2310.2708 diff --git a/MP-TAB-SERV/Resources/manifest.xml b/MP-TAB-SERV/Resources/manifest.xml index d3668781..e7dd2fec 100644 --- a/MP-TAB-SERV/Resources/manifest.xml +++ b/MP-TAB-SERV/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2310.2619 + 6.16.2310.2708 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.Data/Controllers/MpTabController.cs b/MP.Data/Controllers/MpTabController.cs index f96e2e5d..2b62f242 100644 --- a/MP.Data/Controllers/MpTabController.cs +++ b/MP.Data/Controllers/MpTabController.cs @@ -1053,6 +1053,28 @@ namespace MP.Data.Controllers } return fatto; } + public bool ST_CheckUpsert(int idxOdl, int idxST, int oggetto, int num, string valueRead, string extCode, bool checkOk, string userMod, bool forced) + { + bool fatto = false; + using (var dbCtx = new MoonProContext(_configuration)) + { + var IdxOdl = new SqlParameter("@IdxOdl", idxOdl); + var IdxST = new SqlParameter("@IdxST", idxST); + var Oggetto = new SqlParameter("@Oggetto", oggetto); + var Num = new SqlParameter("@Num", num); + var ValueRead = new SqlParameter("@ValueRead", valueRead); + var ExtCode = new SqlParameter("@ExtCode", extCode); + var CheckOk = new SqlParameter("@CheckOk", checkOk); + var UserMod = new SqlParameter("@UserMod", userMod); + var Forced = new SqlParameter("@Forced", forced); + + var result = dbCtx + .Database + .ExecuteSqlRaw("EXEC stp_ST_CHK_upsert @IdxOdl, @IdxST, @Oggetto, @Num, @ValueRead, @ExtCode, @CheckOk, @UserMod, @Forced", IdxOdl, IdxST, Oggetto, Num, ValueRead, ExtCode, CheckOk, UserMod, Forced); + fatto = result != 0; + } + return fatto; + } /// /// Recupero Righe pending da ODL diff --git a/MP.Data/Services/TabDataService.cs b/MP.Data/Services/TabDataService.cs index 03c17856..4637ee45 100644 --- a/MP.Data/Services/TabDataService.cs +++ b/MP.Data/Services/TabDataService.cs @@ -1405,6 +1405,24 @@ namespace MP.Data.Services return answ; } + + public async Task ST_CheckUpsert(int idxOdl, int idxST, int oggetto, int num, string valueRead, string extCode, bool checkOk, string userMod, bool forced) + { + bool answ = false; + try + { + // inserisco evento + answ = dbTabController.ST_CheckUpsert(idxOdl, idxST, oggetto, num, valueRead, extCode, checkOk, userMod, forced); + await FlushCache("ST"); + } + catch (Exception exc) + { + string logMsg = $"Eccezione in ST_CheckUpsert | idxOdl: {idxOdl}{Environment.NewLine}{exc}"; + Log.Error(logMsg); + } + return answ; + } + /// /// Dati deroga SchedaTecnica serializzati in REDIS /// @@ -1469,7 +1487,7 @@ namespace MP.Data.Services result = dbTabController.STAR_pendByOdl(idxODL); // serializzp e salvo... rawData = JsonConvert.SerializeObject(result); - redisDb.StringSet(currKey, rawData, LongCache); + redisDb.StringSet(currKey, rawData, TimeSpan.FromSeconds(5)); } if (result == null) {