diff --git a/MP-TAB-SERV/Components/DisabledAlert.razor.cs b/MP-TAB-SERV/Components/DisabledAlert.razor.cs index 79e86ab5..fa884552 100644 --- a/MP-TAB-SERV/Components/DisabledAlert.razor.cs +++ b/MP-TAB-SERV/Components/DisabledAlert.razor.cs @@ -1,36 +1,20 @@ -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.Services; -using Newtonsoft.Json; -using NLog; namespace MP_TAB_SERV.Components { public partial class DisabledAlert { + #region Public Properties + + [Parameter] + public string Message { get; set; } = ""; + + [Parameter] + public string Subtitle { get; set; } = ""; [Parameter] public string Title { get; set; } = ""; - [Parameter] - public string Subtitle { get; set; } = ""; - [Parameter] - public string Message { get; set; } = ""; + + #endregion Public Properties } } \ No newline at end of file diff --git a/MP-TAB-SERV/Components/TechSheetDetail.razor b/MP-TAB-SERV/Components/TechSheetDetail.razor deleted file mode 100644 index f654734d..00000000 --- a/MP-TAB-SERV/Components/TechSheetDetail.razor +++ /dev/null @@ -1,19 +0,0 @@ -
-
- Scheda Tecnica -
-
-
- -
-
- -
-
- -
-
- -
-
-
\ No newline at end of file diff --git a/MP-TAB-SERV/Components/TechSheetDetail.razor.cs b/MP-TAB-SERV/Components/TechSheetDetail.razor.cs deleted file mode 100644 index 885b880d..00000000 --- a/MP-TAB-SERV/Components/TechSheetDetail.razor.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace MP_TAB_SERV.Components -{ - public partial class TechSheetDetail - { - } -} \ No newline at end of file diff --git a/MP-TAB-SERV/Components/TechSheetMan.razor b/MP-TAB-SERV/Components/TechSheetMan.razor new file mode 100644 index 00000000..a111f5dd --- /dev/null +++ b/MP-TAB-SERV/Components/TechSheetMan.razor @@ -0,0 +1,40 @@ +
+
+
+
+

Scheda Tecnica

+
+
+ @if (inAttr) + { + + } +
+
+
+
+
+ +
+ @if (ListGruppi.Count == 0) + { +
ST: Nessun Gruppo Trovato
+ } + else + { + foreach (var item in ListGruppi) + { +
+
+
+ @item.DescGruppo +
+
+ +
+
+
+ } + } +
+
\ No newline at end of file diff --git a/MP-TAB-SERV/Components/TechSheetMan.razor.cs b/MP-TAB-SERV/Components/TechSheetMan.razor.cs new file mode 100644 index 00000000..cd6dc337 --- /dev/null +++ b/MP-TAB-SERV/Components/TechSheetMan.razor.cs @@ -0,0 +1,103 @@ +using Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; +using MP.Data.DatabaseModels; +using MP.Data.Services; + +namespace MP_TAB_SERV.Components +{ + public partial class TechSheetMan + { + #region Public Properties + + [Parameter] + public MappaStatoExpl? RecMSE { get; set; } = null; + + #endregion Public Properties + + #region Protected Properties + + [Inject] + protected IJSRuntime JSRuntime { get; set; } = null!; + + protected List ListGruppi { get; set; } = new List(); + + [Inject] + protected TabDataService TabServ { get; set; } = null!; + + #endregion Protected Properties + + #region Protected Methods + + protected async Task ClearOdl() + { + if (!await JSRuntime.InvokeAsync("confirm", $"Sicuro di voler resettare?")) + return; + if (IdxOdl > 0) + { + await TabServ.ST_CheckCleanByOdl(IdxOdl); + } + checkReset(); + } + + protected override async Task OnParametersSetAsync() + { + if (RecMSE != null) + { + CodArticolo = RecMSE.CodArticolo; + IdxMaccSel = RecMSE.IdxMacchina; + IdxOdl = RecMSE.IdxOdl ?? 0; + } + await ReloadData(); + checkReset(); + } + + #endregion Protected Methods + + #region Private Fields + + private string CodArticolo = ""; + + private bool inAttr = false; + + #endregion Private Fields + + #region Private Properties + + private string IdxMaccSel { get; set; } = ""; + + private int IdxOdl { get; set; } = 0; + + #endregion Private Properties + + #region Private Methods + + /// + /// Verifica visibilità reset + /// + private void checkReset() + { + // condizioni booleane + inAttr = false; + // SOLO SE ho articolo sennò niente reset... + if (!string.IsNullOrEmpty(CodArticolo)) + { + // controllo se la macchina è in attrezzaggio... + var rigaStato = TabServ.StatoMacchina(IdxMaccSel); + if (rigaStato != null) + { + inAttr = (rigaStato.IdxStato == 2); + } + } +#if false + cmp_ST_objCheck.checkInputData(); +#endif + } + + private async Task ReloadData() + { + ListGruppi = await TabServ.ST_AnagGruppiList(); + } + + #endregion Private Methods + } +} \ No newline at end of file diff --git a/MP-TAB-SERV/Components/TechSheet_ST_Detail.razor b/MP-TAB-SERV/Components/TechSheet_ST_Detail.razor new file mode 100644 index 00000000..8e41f52f --- /dev/null +++ b/MP-TAB-SERV/Components/TechSheet_ST_Detail.razor @@ -0,0 +1,15 @@ +@if (showWarning) +{ +
@txtWarning
+} + +@if (ListRecord.Count == 0) +{ +} +else +{ + foreach (var item in ListRecord) + { + + } +} \ No newline at end of file diff --git a/MP-TAB-SERV/Components/TechSheet_ST_Detail.razor.cs b/MP-TAB-SERV/Components/TechSheet_ST_Detail.razor.cs new file mode 100644 index 00000000..ddb43533 --- /dev/null +++ b/MP-TAB-SERV/Components/TechSheet_ST_Detail.razor.cs @@ -0,0 +1,62 @@ +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.Services; +using Newtonsoft.Json; +using NLog; +using Microsoft.Extensions.Primitives; + +namespace MP_TAB_SERV.Components +{ + public partial class TechSheet_ST_Detail + { + [Parameter] + public string CodArticolo { get; set; } = ""; + + [Parameter] + public string CodGruppo { get; set; } = ""; + + [Parameter] + public int IdxOdl { get; set; } = 0; + + + private bool showWarning = false; + private string txtWarning = ""; + + + protected override async Task OnParametersSetAsync() + { + if (IdxOdl > 0 && !string.IsNullOrEmpty(CodGruppo)) + { + await ReloadData(); + } + } + + [Inject] + protected TabDataService TabServ { get; set; } = null!; + + private async Task ReloadData() + { + await Task.Delay(1); + ListRecord = await TabServ.STAR_byGrpOdl(CodGruppo, IdxOdl); + } + + protected List ListRecord { get; set; } = new List(); + } +} \ No newline at end of file diff --git a/MP-TAB-SERV/Components/TechSheet_ST_ObjCheck.razor b/MP-TAB-SERV/Components/TechSheet_ST_ObjCheck.razor new file mode 100644 index 00000000..d190f8da --- /dev/null +++ b/MP-TAB-SERV/Components/TechSheet_ST_ObjCheck.razor @@ -0,0 +1,5 @@ +

TechSheet_ObjCheck

+ +@code { + +} diff --git a/MP-TAB-SERV/Components/TechSheet_ST_ObjView.razor b/MP-TAB-SERV/Components/TechSheet_ST_ObjView.razor new file mode 100644 index 00000000..f9d796a1 --- /dev/null +++ b/MP-TAB-SERV/Components/TechSheet_ST_ObjView.razor @@ -0,0 +1,32 @@ +
+
+ @CurrRec.Label +
+
+ @if (CurrRec.ShowMissingData && enableForceParamSchedaTecnica) + { + if (hasDeroga) + { + Deroga Attiva + } + else + { + + } + } + (@CurrRec.ValueRead) @CurrRec.Value + + + @if (showError) + { + + } + @if (showChecked) + { + + } + +
+
+ + diff --git a/MP-TAB-SERV/Components/TechSheet_ST_ObjView.razor.cs b/MP-TAB-SERV/Components/TechSheet_ST_ObjView.razor.cs new file mode 100644 index 00000000..d65b35a2 --- /dev/null +++ b/MP-TAB-SERV/Components/TechSheet_ST_ObjView.razor.cs @@ -0,0 +1,92 @@ +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.Services; +using Newtonsoft.Json; +using NLog; +using System.ComponentModel.DataAnnotations; + +namespace MP_TAB_SERV.Components +{ + public partial class TechSheet_ST_ObjView + { + [Parameter] + public ST_ActRow CurrRec { get; set; } = null!; + [Inject] + protected SharedMemService SMServ { get; set; } = null!; + + protected override void OnParametersSet() + { + enableForceParamSchedaTecnica = SMServ.GetConfBool("enableForceParamSchedaTecnica"); + hasDeroga = false; +#if false + try + { + var currDeroga = DataLayerObj.getDerogaSt(idxST); + answ = (currDeroga != null); + if (answ) + { + answ = (currDeroga.CanForce && currDeroga.Num == dataNum && currDeroga.CodGruppo == dataGroup && currDeroga.CodTipo == dataType && currDeroga.Oggetto == dataOggetto); + } + } + catch + { } +#endif + } + + private bool enableForceParamSchedaTecnica = false; + + public string dataCss + { + get + { + string answ = ""; + if (CurrRec.Required) + { + if (CurrRec.Value != CurrRec.ExtCode) + { + answ = " text-danger"; + } + else + { + answ = " text-success"; + } + } + return answ; + } + } + + public string derogaCss + { + get + { + string answ = enableForceParamSchedaTecnica && hasDeroga ? " bg-warning" : ""; + + return answ; + } + } + + + private bool hasDeroga = false; + private bool showError = false; + private bool showChecked = false; + + + } +} \ No newline at end of file diff --git a/MP-TAB-SERV/Pages/MachineDetail.razor b/MP-TAB-SERV/Pages/MachineDetail.razor index 74a2f0ba..9f2a5862 100644 --- a/MP-TAB-SERV/Pages/MachineDetail.razor +++ b/MP-TAB-SERV/Pages/MachineDetail.razor @@ -9,14 +9,5 @@ else - @**@ - @**@ } diff --git a/MP-TAB-SERV/Pages/ProdStop.razor.cs b/MP-TAB-SERV/Pages/ProdStop.razor.cs index 89638727..64482f08 100644 --- a/MP-TAB-SERV/Pages/ProdStop.razor.cs +++ b/MP-TAB-SERV/Pages/ProdStop.razor.cs @@ -87,7 +87,7 @@ namespace MP_TAB_SERV.Pages var rigaEvento = SMServ.GetEventRow(IdxEv); if (rigaEvento != null) { - var rigaStato = await TabServ.StatoMacchina(IdxMacc); + var rigaStato = TabServ.StatoMacchina(IdxMacc); // processo evento... if (insRealtime) { diff --git a/MP-TAB-SERV/Pages/TechSheet.razor b/MP-TAB-SERV/Pages/TechSheet.razor index fffce8e8..a728f9f2 100644 --- a/MP-TAB-SERV/Pages/TechSheet.razor +++ b/MP-TAB-SERV/Pages/TechSheet.razor @@ -9,7 +9,7 @@ else @if (enableSchedaTecnica) { - + } else { diff --git a/MP.Data/Controllers/MpTabController.cs b/MP.Data/Controllers/MpTabController.cs index 4a4ebfe1..6224c891 100644 --- a/MP.Data/Controllers/MpTabController.cs +++ b/MP.Data/Controllers/MpTabController.cs @@ -746,6 +746,39 @@ namespace MP.Data.Controllers return dbResult; } + /// + /// Restituisce elenco gruppi Scheda tecnica + /// + /// + public List ST_AnagGruppiList() + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetStAnagGruppi + .OrderBy(x => x.OrdVisual) + .AsNoTracking() + .ToList(); + } + return dbResult; + } + + public bool ST_CheckCleanByOdl(int idxOdl) + { + bool fatto = false; + using (var dbCtx = new MoonProContext(_configuration)) + { + var IdxOdl = new SqlParameter("@IdxOdl", idxOdl); + + var result = dbCtx + .Database + .ExecuteSqlRaw("EXEC stp_ST_CHK_cleanByOdl @IdxOdl", IdxOdl); + fatto = result != 0; + } + return fatto; + } + /// /// Registra controllo /// diff --git a/MP.Data/DatabaseModels/ST_ActRow.cs b/MP.Data/DatabaseModels/ST_ActRow.cs index 7248effa..c458e5ca 100644 --- a/MP.Data/DatabaseModels/ST_ActRow.cs +++ b/MP.Data/DatabaseModels/ST_ActRow.cs @@ -27,5 +27,10 @@ namespace MP.Data.DatabaseModels public string ValueRead { get; set; } = ""; public string Note { get; set; } = ""; + [NotMapped] + public bool ShowMissingData + { + get => Required && (Value != ExtCode); + } } } \ No newline at end of file diff --git a/MP.Data/Services/TabDataService.cs b/MP.Data/Services/TabDataService.cs index e4d7592c..b1619644 100644 --- a/MP.Data/Services/TabDataService.cs +++ b/MP.Data/Services/TabDataService.cs @@ -13,6 +13,7 @@ using System.Diagnostics; using System.Linq; using System.Text; using System.Threading.Tasks; +using static System.Runtime.CompilerServices.RuntimeHelpers; namespace MP.Data.Services { @@ -1024,6 +1025,59 @@ namespace MP.Data.Services } return answ; } + public async Task ST_CheckCleanByOdl(int idxOdl) + { + bool answ = false; + try + { + // inserisco evento + answ = dbTabController.ST_CheckCleanByOdl(idxOdl); + await FlushCache("ST"); + } + catch (Exception exc) + { + string logMsg = $"Eccezione in ST_CheckCleanByOdl | idxOdl: {idxOdl}{Environment.NewLine}{exc}"; + Log.Error(logMsg); + } + return answ; + } + + + /// + /// Restituisce elenco gruppi Scheda tecnica + /// + /// + public async Task> ST_AnagGruppiList() + { + // setup parametri costanti + string source = "DB"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + List? result = new List(); + // cerco in redis... + string currKey = $"{redisBaseKey}:ST:AnagGruppi"; + RedisValue rawData = await redisDb.StringGetAsync(currKey); + if (rawData.HasValue) + { + result = JsonConvert.DeserializeObject>($"{rawData}"); + source = "REDIS"; + } + else + { + result = dbTabController.ST_AnagGruppiList(); + // serializzp e salvo... + rawData = JsonConvert.SerializeObject(result); + await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + } + if (result == null) + { + result = new List(); + } + sw.Stop(); + Log.Debug($"ST_AnagGruppiList | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + return result; + } + /// /// Aggiunta record RegistroScarti @@ -1390,7 +1444,7 @@ namespace MP.Data.Services /// /// /// - public async Task StatoMacchina(string idxMacchina) + public StatoMacchineModel StatoMacchina(string idxMacchina) { // setup parametri costanti string source = "DB"; @@ -1399,8 +1453,7 @@ namespace MP.Data.Services StatoMacchineModel? result = new StatoMacchineModel(); // cerco in redis... string currKey = $"{redisBaseKey}:StatoMacc:{idxMacchina}"; - RedisValue rawData = await redisDb.StringGetAsync(currKey); - //if (!string.IsNullOrEmpty($"{rawData}")) + RedisValue rawData = redisDb.StringGet(currKey); if (rawData.HasValue) { result = JsonConvert.DeserializeObject($"{rawData}"); @@ -1411,7 +1464,7 @@ namespace MP.Data.Services result = dbTabController.StatoMacchina(idxMacchina); // serializzp e salvo... rawData = JsonConvert.SerializeObject(result); - await redisDb.StringSetAsync(currKey, rawData, TimeSpan.FromSeconds(2)); + redisDb.StringSet(currKey, rawData, TimeSpan.FromSeconds(2)); } if (result == null) {