diff --git a/MP.Data/Controllers/MpStatsController.cs b/MP.Data/Controllers/MpStatsController.cs index 61036130..853d1c02 100644 --- a/MP.Data/Controllers/MpStatsController.cs +++ b/MP.Data/Controllers/MpStatsController.cs @@ -220,6 +220,87 @@ namespace MP.Data.Controllers return dbResult; } + /// + /// Elenco tabella TurniOee da filtro + /// + /// + /// + /// + /// + /// + public List StatTurniOeeGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo) + { + List dbResult = new List(); + + var dataFrom = new SqlParameter("@dataFrom", DataStart); + var dataTo = new SqlParameter("@dataTo", DataEnd); + var idxMacchina = new SqlParameter("@idxMacchina", IdxMacchina); + var idxODL = new SqlParameter("@IdxODL", IdxODL); + var keyRichiesta = new SqlParameter("@KeyRichiesta", KeyRichiesta); + var codArticolo = new SqlParameter("@CodArticolo", CodArticolo); + + dbResult = dbCtx + .DbSetTurniOee + .FromSqlRaw("EXEC stp_UI_TurniOee_GetByFilter @dataFrom,@dataTo,@idxMacchina,@IdxODL,@KeyRichiesta,@CodArticolo", dataFrom, dataTo, idxMacchina, idxODL, keyRichiesta, codArticolo) + .ToList(); + + return dbResult; + } + + /// + /// Elenco tabella TurniPareto da filtro + /// + /// + /// + /// + /// + /// + public List StatTurniParetoGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo) + { + List dbResult = new List(); + + var dataFrom = new SqlParameter("@dataFrom", DataStart); + var dataTo = new SqlParameter("@dataTo", DataEnd); + var idxMacchina = new SqlParameter("@idxMacchina", IdxMacchina); + var idxODL = new SqlParameter("@IdxODL", IdxODL); + var keyRichiesta = new SqlParameter("@KeyRichiesta", KeyRichiesta); + var codArticolo = new SqlParameter("@CodArticolo", CodArticolo); + + dbResult = dbCtx + .DbSetTurniPareto + .FromSqlRaw("EXEC stp_UI_ParetoTurni_GetByFilter @dataFrom,@dataTo,@idxMacchina,@IdxODL,@KeyRichiesta,@CodArticolo", dataFrom, dataTo, idxMacchina, idxODL, keyRichiesta, codArticolo) + .ToList(); + + return dbResult; + } + + /// + /// Elenco tabella TurniParetoOdl da filtro + /// + /// + /// + /// + /// + /// + public List StatTurniParetoOdlGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo) + { + List dbResult = new List(); + + var dataFrom = new SqlParameter("@dataFrom", DataStart); + var dataTo = new SqlParameter("@dataTo", DataEnd); + var idxMacchina = new SqlParameter("@idxMacchina", IdxMacchina); + var idxODL = new SqlParameter("@IdxODL", IdxODL); + var keyRichiesta = new SqlParameter("@KeyRichiesta", KeyRichiesta); + var codArticolo = new SqlParameter("@CodArticolo", CodArticolo); + + dbResult = dbCtx + .DbSetTurniParetoOdl + .FromSqlRaw("EXEC stp_UI_ParetoTurniOdl_GetByFilter @dataFrom,@dataTo,@idxMacchina,@IdxODL,@KeyRichiesta,@CodArticolo", dataFrom, dataTo, idxMacchina, idxODL, keyRichiesta, codArticolo) + .ToList(); + + return dbResult; + } + /// /// Elenco tabella UserLog da filtro /// diff --git a/MP.Data/DatabaseModels/TurniOee.cs b/MP.Data/DatabaseModels/TurniOee.cs new file mode 100644 index 00000000..969bcc0c --- /dev/null +++ b/MP.Data/DatabaseModels/TurniOee.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +#nullable disable + +namespace MP.Data.DatabaseModels +{ + public partial class TurniOee + { + #region Public Properties + + public string ClasseTempo { get; set; } + public string CodArticolo { get; set; } + public string CodMacchina { get; set; } + public DateTime DataRif { get; set; } + public string DescArticolo { get; set; } + public string Descrizione { get; set; } + public string IdxMacchina { get; set; } + public int IdxStato { get; set; } + + [NotMapped] + [DisplayFormat(DataFormatString = "{0:N2}", ApplyFormatInEditMode = true)] + public double OEE => (double)TotPeriodo / 480; + + [DisplayFormat(DataFormatString = "{0:N2}", ApplyFormatInEditMode = true)] + public double TotPeriodo { get; set; } + + public int? TotPz { get; set; } + public string Turno { get; set; } + + #endregion Public Properties + } +} \ No newline at end of file diff --git a/MP.Data/DatabaseModels/TurniPareto.cs b/MP.Data/DatabaseModels/TurniPareto.cs new file mode 100644 index 00000000..73c9d689 --- /dev/null +++ b/MP.Data/DatabaseModels/TurniPareto.cs @@ -0,0 +1,26 @@ +using System; +using System.Collections.Generic; + +#nullable disable + +namespace MP.Data.DatabaseModels +{ + public partial class TurniPareto + { + #region Public Properties + + public string ClasseTempo { get; set; } + public string CodArticolo { get; set; } + public string CodMacchina { get; set; } + public DateTime DataRif { get; set; } + public string DescArticolo { get; set; } + public string Descrizione { get; set; } + public string IdxMacchina { get; set; } + public int IdxStato { get; set; } + public double? TotPeriodo { get; set; } + public int? TotPz { get; set; } + public string Turno { get; set; } + + #endregion Public Properties + } +} \ No newline at end of file diff --git a/MP.Data/DatabaseModels/TurniParetoOdl.cs b/MP.Data/DatabaseModels/TurniParetoOdl.cs new file mode 100644 index 00000000..7a15b270 --- /dev/null +++ b/MP.Data/DatabaseModels/TurniParetoOdl.cs @@ -0,0 +1,28 @@ +using System; +using System.Collections.Generic; + +#nullable disable + +namespace MP.Data.DatabaseModels +{ + public partial class TurniParetoOdl + { + #region Public Properties + + public string ClasseTempo { get; set; } + public string CodArticolo { get; set; } + public string CodMacchina { get; set; } + public DateTime DataRif { get; set; } + public string DescArticolo { get; set; } + public string Descrizione { get; set; } + public string IdxMacchina { get; set; } + public int? IdxOdl { get; set; } + public int IdxStato { get; set; } + public string KeyRichiesta { get; set; } + public double? TotPeriodo { get; set; } + public int? TotPz { get; set; } + public string Turno { get; set; } + + #endregion Public Properties + } +} \ No newline at end of file diff --git a/MP.Data/MP.Data.csproj b/MP.Data/MP.Data.csproj index 658bbfa1..0c89b33d 100644 --- a/MP.Data/MP.Data.csproj +++ b/MP.Data/MP.Data.csproj @@ -6,9 +6,6 @@ MP.Data - - - diff --git a/MP.Data/MoonPro_STATSContext.cs b/MP.Data/MoonPro_STATSContext.cs index 6a821592..b6161519 100644 --- a/MP.Data/MoonPro_STATSContext.cs +++ b/MP.Data/MoonPro_STATSContext.cs @@ -42,6 +42,9 @@ namespace MP.Data public virtual DbSet DbSetMacchine { get; set; } public virtual DbSet DbSetODL { get; set; } public virtual DbSet DbSetScarti { get; set; } + public virtual DbSet DbSetTurniOee { get; set; } + public virtual DbSet DbSetTurniPareto { get; set; } + public virtual DbSet DbSetTurniParetoOdl { get; set; } public virtual DbSet DbSetUserLog { get; set; } #endregion Public Properties @@ -68,6 +71,104 @@ namespace MP.Data protected override void OnModelCreating(ModelBuilder modelBuilder) { modelBuilder.HasAnnotation("Relational:Collation", "SQL_Latin1_General_CP1_CI_AS"); + + modelBuilder.Entity(entity => + { + entity.HasNoKey(); + + entity.ToView("v_UI_OEE_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.DescArticolo).HasMaxLength(250); + + entity.Property(e => e.Descrizione).HasMaxLength(50); + + entity.Property(e => e.IdxMacchina) + .IsRequired() + .HasMaxLength(50); + + entity.Property(e => e.TotPeriodo).HasColumnName("totPeriodo"); + + entity.Property(e => e.Turno) + .IsRequired() + .HasMaxLength(5); + }); + + modelBuilder.Entity(entity => + { + entity.HasNoKey(); + + entity.ToView("v_UI_Pareto_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.DescArticolo).HasMaxLength(250); + + entity.Property(e => e.Descrizione).HasMaxLength(50); + + entity.Property(e => e.IdxMacchina) + .IsRequired() + .HasMaxLength(50); + + entity.Property(e => e.TotPeriodo).HasColumnName("totPeriodo"); + + entity.Property(e => e.Turno) + .IsRequired() + .HasMaxLength(5); + }); + + modelBuilder.Entity(entity => + { + entity.HasNoKey(); + + entity.ToView("v_UI_Pareto_TurniOdl"); + + 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.DescArticolo).HasMaxLength(250); + + entity.Property(e => e.Descrizione).HasMaxLength(50); + + entity.Property(e => e.IdxMacchina) + .IsRequired() + .HasMaxLength(50); + + entity.Property(e => e.IdxOdl).HasColumnName("IdxODL"); + + entity.Property(e => e.KeyRichiesta).HasMaxLength(50); + + entity.Property(e => e.TotPeriodo).HasColumnName("totPeriodo"); + + entity.Property(e => e.Turno) + .IsRequired() + .HasMaxLength(5); + }); + modelBuilder.Entity(entity => { entity.HasNoKey(); diff --git a/MP.Stats/Data/MpStatsService.cs b/MP.Stats/Data/MpStatsService.cs index fb5e3995..0ef4c259 100644 --- a/MP.Stats/Data/MpStatsService.cs +++ b/MP.Stats/Data/MpStatsService.cs @@ -100,6 +100,21 @@ namespace MP.Stats.Data return Task.FromResult(dbController.StatScartiGetAll(DataStart, DataEnd, IdxMacchina, IdxODL, KeyRichiesta, CodArticolo).ToArray()); } + public Task StatTurniOeeGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo, string searchVal = "") + { + return Task.FromResult(dbController.StatTurniOeeGetAll(DataStart, DataEnd, IdxMacchina, IdxODL, KeyRichiesta, CodArticolo).ToArray()); + } + + public Task StatTurniParetoGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo, string searchVal = "") + { + return Task.FromResult(dbController.StatTurniParetoGetAll(DataStart, DataEnd, IdxMacchina, IdxODL, KeyRichiesta, CodArticolo).ToArray()); + } + + public Task StatTurniParetoOdlGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo, string searchVal = "") + { + return Task.FromResult(dbController.StatTurniParetoOdlGetAll(DataStart, DataEnd, IdxMacchina, IdxODL, KeyRichiesta, CodArticolo).ToArray()); + } + public Task StatUserLogGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo, string searchVal = "") { return Task.FromResult(dbController.StatUserLogGetAll(DataStart, DataEnd, IdxMacchina, IdxODL, KeyRichiesta, CodArticolo).ToArray()); diff --git a/MP.Stats/Pages/Index.razor b/MP.Stats/Pages/Index.razor index 014e7f34..f2d91a2f 100644 --- a/MP.Stats/Pages/Index.razor +++ b/MP.Stats/Pages/Index.razor @@ -26,13 +26,12 @@
Main Topics
+ - @**@ - @**@
diff --git a/MP.Stats/Pages/Oee.razor b/MP.Stats/Pages/Oee.razor new file mode 100644 index 00000000..a2e0beff --- /dev/null +++ b/MP.Stats/Pages/Oee.razor @@ -0,0 +1,71 @@ +@page "/oee" + +@using MP.Stats.Components +@using MP.Stats.Data + +
+
+
+
TRS / OEE %
+
+
+
+
+
+ @if (currRecord != null) + { + @**@ + } + @if (ListRecords == null) + { +
+ } + else + { +
+
+ +
+
+ + + + @**@ + + + + + + + + + + + @foreach (var record in ListRecords) + { + + @**@ + + + + + + + + + } + +
DataTurnoMacchinaArticoloDurataPezziOEE %
  +
@record.DataRif.ToString("yyyy.MM.dd")
+
@record.Turno +
@record.CodMacchina
+
@record.IdxMacchina
+
@record.CodArticolo@record.TotPeriodo.ToString("N2")@record.TotPz@record.OEE.ToString("P2")
+
+
+ } +
+ +
\ No newline at end of file diff --git a/MP.Stats/Pages/Oee.razor.cs b/MP.Stats/Pages/Oee.razor.cs new file mode 100644 index 00000000..be601c8e --- /dev/null +++ b/MP.Stats/Pages/Oee.razor.cs @@ -0,0 +1,131 @@ +using Microsoft.AspNetCore.Components; +using Microsoft.JSInterop; +using MP.Stats.Data; +using System; +using System.Linq; +using System.Threading.Tasks; + +namespace MP.Stats.Pages +{ + public partial class Oee : ComponentBase, IDisposable + { + #region Private Fields + + private MP.Data.DatabaseModels.TurniOee currRecord = null; + + private MP.Data.DatabaseModels.TurniOee[] ListRecords; + + private MP.Data.DatabaseModels.TurniOee[] SearchRecords; + + #endregion Private Fields + + #region Private Properties + + private SelectData currFilter { get; set; } = new SelectData(); + private int currPage { get; set; } = 1; + 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 Private Methods + + private async Task reloadData() + { + SearchRecords = await StatService.StatTurniOeeGetAll(currFilter.DateStart, currFilter.DateEnd, currFilter.IdxMacchina, currFilter.IdxOdl, currFilter.KeyRichiesta, currFilter.CodArticolo, MessageService.SearchVal); + ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToArray(); + } + + #endregion Private Methods + + #region Protected Methods + + protected async Task DoFilter(SelectData newFilter) + { + currFilter = newFilter; + await reloadData(); + } + + protected async Task ForceReload(int newNum) + { + numRecord = newNum; + await reloadData(); + } + + protected async Task ForceReloadPage(int newNum) + { + currPage = newNum; + await reloadData(); + } + + protected override async Task OnInitializedAsync() + { + numRecord = 10; + MessageService.ShowSearch = true; + MessageService.EA_SearchUpdated += OnSeachUpdated; + await reloadData(); + } + + protected void ResetData() + { + StatService.rollBackEdit(currRecord); + currRecord = null; + } + + protected async Task UpdateData() + { + currRecord = null; + await reloadData(); + } + + #endregion Protected Methods + + #region Public Methods + + public string checkSelect(DateTime DataRif, string Turno, string IdxMacchina) + { + string answ = ""; + if (currRecord != null) + { + try + { + answ = (currRecord.IdxMacchina == IdxMacchina && currRecord.Turno == Turno && currRecord.DataRif == DataRif) ? "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 2ebff8ca..ef470f19 100644 --- a/MP.Stats/Shared/NavMenu.razor +++ b/MP.Stats/Shared/NavMenu.razor @@ -12,6 +12,11 @@ Home + - @* + @*