From cf5f43f2e7f65e5925f15e308ed527d0bb47803d Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 17 May 2021 19:07:59 +0200 Subject: [PATCH 1/5] Bozza pagine diario produzione --- MP.Stats/Pages/Diario.razor | 59 +++++++++++++++++++ MP.Stats/Pages/Diario.razor.cs | 104 +++++++++++++++++++++++++++++++++ MP.Stats/Shared/NavMenu.razor | 2 +- 3 files changed, 164 insertions(+), 1 deletion(-) create mode 100644 MP.Stats/Pages/Diario.razor create mode 100644 MP.Stats/Pages/Diario.razor.cs diff --git a/MP.Stats/Pages/Diario.razor b/MP.Stats/Pages/Diario.razor new file mode 100644 index 00000000..0bfda3cf --- /dev/null +++ b/MP.Stats/Pages/Diario.razor @@ -0,0 +1,59 @@ +@page "/diario" + +@using MP.Stats.Components +@using MP.Stats.Data + +
+
Controlli
+
+ @if (currRecord != null) + { + @**@ + } + @if (ListRecords == null) + { +
+ } + else + { + + + + @**@ + + + + + + + + + + + @foreach (var record in ListRecords) + { + + @**@ + + + + + + + + + } + +
MacchinaDataODL/CommessaArticoloEsitoNoteOperatore
 @record.IdxMacchina@record.DataOra@record.IdxOdl@record.CodArticolo@record.EsitoOk@record.Note@record.MatrOpr
+ } +
+ +
\ No newline at end of file diff --git a/MP.Stats/Pages/Diario.razor.cs b/MP.Stats/Pages/Diario.razor.cs new file mode 100644 index 00000000..2bbe8d86 --- /dev/null +++ b/MP.Stats/Pages/Diario.razor.cs @@ -0,0 +1,104 @@ +using Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; +using MP.Stats.Data; +using System; +using System.Threading.Tasks; + +namespace MP.Stats.Pages +{ + public partial class Diario : ComponentBase, IDisposable + { + #region Private Fields + + private MP.Data.DatabaseModels.ResControlli currRecord = null; + + private MP.Data.DatabaseModels.ResControlli[] ListRecords; + + #endregion Private Fields + + #region Private Properties + + private int numRecord { get; set; } = 10; + + #endregion Private Properties + + #region Protected Properties + + [Inject] + protected IJSRuntime JSRuntime { get; set; } + + [Inject] + protected MessageService MessageService { get; set; } + + [Inject] + protected NavigationManager NavManager { get; set; } + + [Inject] + protected MpStatsService StatService { get; set; } + + #endregion Protected Properties + + #region Protected Methods + + protected async Task ForceReload(int newNum) + { + numRecord = newNum; + ListRecords = await StatService.StatControlliGetAll(numRecord, MessageService.SearchVal); + } + + protected override async Task OnInitializedAsync() + { + numRecord = 10; + MessageService.ShowSearch = true; + MessageService.EA_SearchUpdated += OnSeachUpdated; + ListRecords = await StatService.StatControlliGetAll(numRecord, MessageService.SearchVal); + } + + protected void ResetData() + { + StatService.rollBackEdit(currRecord); + currRecord = null; + } + + protected async Task UpdateData() + { + currRecord = null; + ListRecords = await StatService.StatControlliGetAll(numRecord, MessageService.SearchVal); + } + + #endregion Protected Methods + + #region Public Methods + + public string checkSelect(int IdxControllo) + { + string answ = ""; + if (currRecord != null) + { + try + { + answ = (currRecord.IdxControllo == IdxControllo) ? "table-info" : ""; + } + catch + { } + } + return answ; + } + + public void Dispose() + { + MessageService.EA_SearchUpdated -= OnSeachUpdated; + } + + public void OnSeachUpdated() + { + InvokeAsync(() => + { + UpdateData(); + StateHasChanged(); + }); + } + + #endregion Public Methods + } +} \ No newline at end of file diff --git a/MP.Stats/Shared/NavMenu.razor b/MP.Stats/Shared/NavMenu.razor index 78ef73f4..d152ea26 100644 --- a/MP.Stats/Shared/NavMenu.razor +++ b/MP.Stats/Shared/NavMenu.razor @@ -13,7 +13,7 @@ From 48fe8312080b2b5b56b2a8e112b201e198fdafe5 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 17 May 2021 19:28:36 +0200 Subject: [PATCH 2/5] Renaming action(s) --- MP.Data/Controllers/MpStatsController.cs | 26 ++++++++++++++++--- .../{Actions.cs => AzioniUL.cs} | 2 +- 2 files changed, 24 insertions(+), 4 deletions(-) rename MP.Data/DatabaseModels/{Actions.cs => AzioniUL.cs} (90%) diff --git a/MP.Data/Controllers/MpStatsController.cs b/MP.Data/Controllers/MpStatsController.cs index 68a357fa..81ff033a 100644 --- a/MP.Data/Controllers/MpStatsController.cs +++ b/MP.Data/Controllers/MpStatsController.cs @@ -36,12 +36,12 @@ namespace MP.Data.Controllers /// Elenco Azioni (decodifica) /// /// - public List ActionsGetAll() + public List ActionsGetAll() { - List dbResult = new List(); + List dbResult = new List(); dbResult = dbCtx - .DbSetActions + .DbSetAzioniUL .ToList(); return dbResult; @@ -95,6 +95,26 @@ namespace MP.Data.Controllers return dbResult; } + /// + /// Elenco tabella DDB da filtro + /// + /// + /// + /// + public List StatDdbGetAll(int numRecord, string searchVal = "") + { + List dbResult = new List(); + + dbResult = dbCtx + .DbSetDdbTurni + .Where(x => x.Descrizione.Contains(searchVal) || x.IdxMacchina.Contains(searchVal) || x.CodArticolo.Contains(searchVal) || x.KeyRichiesta.Contains(searchVal) || string.IsNullOrEmpty(searchVal)) + .OrderByDescending(x => x.InizioStato) + .Take(numRecord) + .ToList(); + + return dbResult; + } + /// /// Elenco tabella scarti da filtro /// diff --git a/MP.Data/DatabaseModels/Actions.cs b/MP.Data/DatabaseModels/AzioniUL.cs similarity index 90% rename from MP.Data/DatabaseModels/Actions.cs rename to MP.Data/DatabaseModels/AzioniUL.cs index 171eff98..ce81115b 100644 --- a/MP.Data/DatabaseModels/Actions.cs +++ b/MP.Data/DatabaseModels/AzioniUL.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; namespace MP.Data.DatabaseModels { - public partial class Actions + public partial class AzioniUL { #region Public Properties From 84a769cfcf56f0849e21ec9aa5cd74cbeab90fec Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 17 May 2021 19:28:41 +0200 Subject: [PATCH 3/5] Bozza gestione DDB --- MP.Data/DatabaseModels/DdbTurni.cs | 37 ++++++++++++++++++++ MP.Data/MoonPro_STATSContext.cs | 56 +++++++++++++++++++++++++++--- MP.Stats/Data/MpStatsService.cs | 4 +-- MP.Stats/Pages/Diario.razor | 2 +- MP.Stats/Pages/Diario.razor.cs | 14 ++++---- MP.Stats/Pages/UserLog.razor.cs | 8 ++--- 6 files changed, 103 insertions(+), 18 deletions(-) create mode 100644 MP.Data/DatabaseModels/DdbTurni.cs diff --git a/MP.Data/DatabaseModels/DdbTurni.cs b/MP.Data/DatabaseModels/DdbTurni.cs new file mode 100644 index 00000000..5a14c106 --- /dev/null +++ b/MP.Data/DatabaseModels/DdbTurni.cs @@ -0,0 +1,37 @@ +using System; +using System.Collections.Generic; + +#nullable disable + +namespace MP.Data.DatabaseModels +{ + public partial class DdbTurni + { + #region Public Properties + + public string ClasseTempo { get; set; } + public string CodArticolo { get; set; } + public string CodMacchina { get; set; } + public DateTime DataRif { get; set; } + public DateTime? DataTurnoFine { get; set; } + public DateTime? DataTurnoInizio { get; set; } + public string Descrizione { get; set; } + public long? DurataPeriodo { get; set; } + public long? DurataStato { get; set; } + public DateTime? FinePeriodo { get; set; } + public DateTime FineStato { get; set; } + public string IdxMacchina { get; set; } + public int? IdxOdl { get; set; } + public int IdxStato { get; set; } + public DateTime InizioPeriodo { get; set; } + public DateTime InizioStato { get; set; } + public string KeyRichiesta { get; set; } + public string Pallet { get; set; } + public int? PzPalletProd { get; set; } + public decimal? TempoCicloBase { get; set; } + public int TotPzProd { get; set; } + public string Turno { get; set; } + + #endregion Public Properties + } +} \ No newline at end of file diff --git a/MP.Data/MoonPro_STATSContext.cs b/MP.Data/MoonPro_STATSContext.cs index 079efed5..f84e76fb 100644 --- a/MP.Data/MoonPro_STATSContext.cs +++ b/MP.Data/MoonPro_STATSContext.cs @@ -35,8 +35,9 @@ namespace MP.Data #region Public Properties - public virtual DbSet DbSetActions { get; set; } + public virtual DbSet DbSetAzioniUL { get; set; } public virtual DbSet DbSetControlli { get; set; } + public virtual DbSet DbSetDdbTurni { get; set; } public virtual DbSet DbSetScarti { get; set; } public virtual DbSet DbSetUserLog { get; set; } @@ -57,8 +58,6 @@ namespace MP.Data string connString = _configuration.GetConnectionString("Mp.Stats"); optionsBuilder.UseSqlServer(_configuration.GetConnectionString("Mp.Stats")); - -#warning To protect potentially sensitive information in your connection string, you should move it out of source code. You can avoid scaffolding the connection string by using the Name= syntax to read it from configuration - see https://go.microsoft.com/fwlink/?linkid=2131148. For more guidance on storing connection strings, see http://go.microsoft.com/fwlink/?LinkId=723263. //optionsBuilder.UseSqlServer("Server=SQL2016DEV;Database=MoonPro_STATS;Trusted_Connection=True;"); } } @@ -67,7 +66,56 @@ namespace MP.Data { modelBuilder.HasAnnotation("Relational:Collation", "SQL_Latin1_General_CP1_CI_AS"); - modelBuilder.Entity(entity => + modelBuilder.Entity(entity => + { + entity.HasNoKey(); + + entity.ToView("v_UI_DDB_Turni"); + + entity.Property(e => e.ClasseTempo).HasMaxLength(50); + + entity.Property(e => e.CodArticolo) + .IsRequired() + .HasMaxLength(50); + + entity.Property(e => e.CodMacchina).HasMaxLength(50); + + entity.Property(e => e.DataRif).HasColumnType("datetime"); + + entity.Property(e => e.DataTurnoFine).HasColumnType("datetime"); + + entity.Property(e => e.DataTurnoInizio).HasColumnType("datetime"); + + entity.Property(e => e.Descrizione).HasMaxLength(50); + + entity.Property(e => e.FinePeriodo).HasColumnType("datetime"); + + entity.Property(e => e.FineStato).HasColumnType("datetime"); + + entity.Property(e => e.IdxMacchina) + .IsRequired() + .HasMaxLength(50); + + entity.Property(e => e.IdxOdl).HasColumnName("IdxODL"); + + entity.Property(e => e.InizioPeriodo).HasColumnType("datetime"); + + entity.Property(e => e.InizioStato).HasColumnType("datetime"); + + entity.Property(e => e.KeyRichiesta).HasMaxLength(50); + + entity.Property(e => e.Pallet) + .HasMaxLength(20) + .HasColumnName("pallet"); + + entity.Property(e => e.TempoCicloBase).HasColumnType("decimal(18, 8)"); + + entity.Property(e => e.Turno) + .IsRequired() + .HasMaxLength(5); + }); + + modelBuilder.Entity(entity => { entity.HasKey(e => e.Azione); diff --git a/MP.Stats/Data/MpStatsService.cs b/MP.Stats/Data/MpStatsService.cs index ee17cadd..85a9053d 100644 --- a/MP.Stats/Data/MpStatsService.cs +++ b/MP.Stats/Data/MpStatsService.cs @@ -17,7 +17,7 @@ namespace MP.Stats.Data private static IConfiguration _configuration; private static ILogger _logger; - private static List ActionsList = new List(); + private static List ActionsList = new List(); #endregion Private Fields @@ -59,7 +59,7 @@ namespace MP.Stats.Data #region Public Methods - public Task ActionsGetAll() + public Task ActionsGetAll() { return Task.FromResult(dbController.ActionsGetAll().ToArray()); } diff --git a/MP.Stats/Pages/Diario.razor b/MP.Stats/Pages/Diario.razor index 0bfda3cf..54e6fa6f 100644 --- a/MP.Stats/Pages/Diario.razor +++ b/MP.Stats/Pages/Diario.razor @@ -4,7 +4,7 @@ @using MP.Stats.Data
-
Controlli
+
Diario Produzione
@if (currRecord != null) { diff --git a/MP.Stats/Pages/Diario.razor.cs b/MP.Stats/Pages/Diario.razor.cs index 2bbe8d86..4e407d62 100644 --- a/MP.Stats/Pages/Diario.razor.cs +++ b/MP.Stats/Pages/Diario.razor.cs @@ -10,9 +10,9 @@ namespace MP.Stats.Pages { #region Private Fields - private MP.Data.DatabaseModels.ResControlli currRecord = null; + private MP.Data.DatabaseModels.DdbTurni currRecord = null; - private MP.Data.DatabaseModels.ResControlli[] ListRecords; + private MP.Data.DatabaseModels.DdbTurni[] ListRecords; #endregion Private Fields @@ -43,7 +43,7 @@ namespace MP.Stats.Pages protected async Task ForceReload(int newNum) { numRecord = newNum; - ListRecords = await StatService.StatControlliGetAll(numRecord, MessageService.SearchVal); + ListRecords = await StatService.StatDdbGetAll(numRecord, MessageService.SearchVal); } protected override async Task OnInitializedAsync() @@ -51,7 +51,7 @@ namespace MP.Stats.Pages numRecord = 10; MessageService.ShowSearch = true; MessageService.EA_SearchUpdated += OnSeachUpdated; - ListRecords = await StatService.StatControlliGetAll(numRecord, MessageService.SearchVal); + ListRecords = await StatService.StatDdbGetAll(numRecord, MessageService.SearchVal); } protected void ResetData() @@ -63,21 +63,21 @@ namespace MP.Stats.Pages protected async Task UpdateData() { currRecord = null; - ListRecords = await StatService.StatControlliGetAll(numRecord, MessageService.SearchVal); + ListRecords = await StatService.StatDdbGetAll(numRecord, MessageService.SearchVal); } #endregion Protected Methods #region Public Methods - public string checkSelect(int IdxControllo) + public string checkSelect(string IdxMacchina, string CodArticolo, DateTime InizioStato) { string answ = ""; if (currRecord != null) { try { - answ = (currRecord.IdxControllo == IdxControllo) ? "table-info" : ""; + answ = (currRecord.IdxMacchina == IdxMacchina && currRecord.CodArticolo == CodArticolo && currRecord.InizioStato == InizioStato) ? "table-info" : ""; } catch { } diff --git a/MP.Stats/Pages/UserLog.razor.cs b/MP.Stats/Pages/UserLog.razor.cs index 9084314a..3c87c098 100644 --- a/MP.Stats/Pages/UserLog.razor.cs +++ b/MP.Stats/Pages/UserLog.razor.cs @@ -11,7 +11,7 @@ namespace MP.Stats.Pages { #region Private Fields - private MP.Data.DatabaseModels.Actions[] ActionsList; + private MP.Data.DatabaseModels.AzioniUL[] ActionsList; private MP.Data.DatabaseModels.UserActionLog currRecord = null; private MP.Data.DatabaseModels.UserActionLog[] ListRecords; @@ -97,13 +97,13 @@ namespace MP.Stats.Pages return answ; } - public MP.Data.DatabaseModels.Actions decodeAction(string azione) + public MP.Data.DatabaseModels.AzioniUL decodeAction(string azione) { // cerco - MP.Data.DatabaseModels.Actions data = ActionsList + MP.Data.DatabaseModels.AzioniUL data = ActionsList .Where(x => x.Azione == azione) .FirstOrDefault(); - data = data != null ? data : new MP.Data.DatabaseModels.Actions() { Azione = "ND", Class = "", Descrizione = "ND" }; + data = data != null ? data : new MP.Data.DatabaseModels.AzioniUL() { Azione = "ND", Class = "", Descrizione = "ND" }; return data; } From f7e19dcf9de9b2f02fa4980d1076df16aec9e09a Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 17 May 2021 19:46:29 +0200 Subject: [PATCH 4/5] Bozza pagina DDB --- MP.Data/DatabaseModels/DdbTurni.cs | 14 ++++++++++++++ MP.Stats/Data/MpStatsService.cs | 5 +++++ MP.Stats/Pages/Diario.razor | 27 +++++++++++++++++---------- 3 files changed, 36 insertions(+), 10 deletions(-) diff --git a/MP.Data/DatabaseModels/DdbTurni.cs b/MP.Data/DatabaseModels/DdbTurni.cs index 5a14c106..ca6059ec 100644 --- a/MP.Data/DatabaseModels/DdbTurni.cs +++ b/MP.Data/DatabaseModels/DdbTurni.cs @@ -1,5 +1,7 @@ using System; using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; #nullable disable @@ -16,6 +18,18 @@ namespace MP.Data.DatabaseModels public DateTime? DataTurnoFine { get; set; } public DateTime? DataTurnoInizio { get; set; } public string Descrizione { get; set; } + + [NotMapped] + [DisplayFormat(DataFormatString = "{0:N2}", ApplyFormatInEditMode = true)] + public long? DurataMin + { + get + { + long answ = (long)(DurataStato != null ? DurataStato : 0); + return answ / 60000; + } + } + public long? DurataPeriodo { get; set; } public long? DurataStato { get; set; } public DateTime? FinePeriodo { get; set; } diff --git a/MP.Stats/Data/MpStatsService.cs b/MP.Stats/Data/MpStatsService.cs index 85a9053d..56df3569 100644 --- a/MP.Stats/Data/MpStatsService.cs +++ b/MP.Stats/Data/MpStatsService.cs @@ -74,6 +74,11 @@ namespace MP.Stats.Data return Task.FromResult(dbController.StatControlliGetAll(numRecord, searchVal).ToArray()); } + public Task StatDdbGetAll(int numRecord, string searchVal = "") + { + return Task.FromResult(dbController.StatDdbGetAll(numRecord, searchVal).ToArray()); + } + public Task StatScartiGetAll(int numRecord, string searchVal = "") { return Task.FromResult(dbController.StatScartiGetAll(numRecord, searchVal).ToArray()); diff --git a/MP.Stats/Pages/Diario.razor b/MP.Stats/Pages/Diario.razor index 54e6fa6f..ad4bf737 100644 --- a/MP.Stats/Pages/Diario.razor +++ b/MP.Stats/Pages/Diario.razor @@ -24,23 +24,30 @@ Data ODL/Commessa Articolo - Esito - Note - Operatore + Stato + Durata + Pezzi + @*Operatore*@ @foreach (var record in ListRecords) { - + @* *@ - @record.IdxMacchina - @record.DataOra - @record.IdxOdl + +
@record.CodMacchina
+
@record.IdxMacchina
+ + +
@record.InizioStato.ToString("yyyy.MM.dd")
+
@record.InizioStato.ToString("ddd HH:mm.ss")
+ + @record.IdxOdl | @record.KeyRichiesta @record.CodArticolo - @record.EsitoOk - @record.Note - @record.MatrOpr + @record.Descrizione + @record.DurataMin + @record.TotPzProd } From e31d71b4c099be16af4792ce185609a27a430edb Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Mon, 17 May 2021 19:55:08 +0200 Subject: [PATCH 5/5] Prima bozza corretta display durata DDB --- MP.Data/DatabaseModels/DdbTurni.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/MP.Data/DatabaseModels/DdbTurni.cs b/MP.Data/DatabaseModels/DdbTurni.cs index ca6059ec..dbdd1e8e 100644 --- a/MP.Data/DatabaseModels/DdbTurni.cs +++ b/MP.Data/DatabaseModels/DdbTurni.cs @@ -21,7 +21,7 @@ namespace MP.Data.DatabaseModels [NotMapped] [DisplayFormat(DataFormatString = "{0:N2}", ApplyFormatInEditMode = true)] - public long? DurataMin + public long DurataMin { get {