Merge branch 'feature/DiarioProduzione' into develop

This commit is contained in:
Samuele Locatelli
2021-05-17 19:55:20 +02:00
9 changed files with 309 additions and 15 deletions
+23 -3
View File
@@ -36,12 +36,12 @@ namespace MP.Data.Controllers
/// Elenco Azioni (decodifica)
/// </summary>
/// <returns></returns>
public List<DatabaseModels.Actions> ActionsGetAll()
public List<DatabaseModels.AzioniUL> ActionsGetAll()
{
List<DatabaseModels.Actions> dbResult = new List<DatabaseModels.Actions>();
List<DatabaseModels.AzioniUL> dbResult = new List<DatabaseModels.AzioniUL>();
dbResult = dbCtx
.DbSetActions
.DbSetAzioniUL
.ToList();
return dbResult;
@@ -95,6 +95,26 @@ namespace MP.Data.Controllers
return dbResult;
}
/// <summary>
/// Elenco tabella DDB da filtro
/// </summary>
/// <param name="numRecord"></param>
/// <param name="searchVal"></param>
/// <returns></returns>
public List<DatabaseModels.DdbTurni> StatDdbGetAll(int numRecord, string searchVal = "")
{
List<DatabaseModels.DdbTurni> dbResult = new List<DatabaseModels.DdbTurni>();
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;
}
/// <summary>
/// Elenco tabella scarti da filtro
/// </summary>
@@ -5,7 +5,7 @@ using System.Collections.Generic;
namespace MP.Data.DatabaseModels
{
public partial class Actions
public partial class AzioniUL
{
#region Public Properties
+51
View File
@@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
#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; }
[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; }
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
}
}
+52 -4
View File
@@ -35,8 +35,9 @@ namespace MP.Data
#region Public Properties
public virtual DbSet<Actions> DbSetActions { get; set; }
public virtual DbSet<AzioniUL> DbSetAzioniUL { get; set; }
public virtual DbSet<ResControlli> DbSetControlli { get; set; }
public virtual DbSet<DdbTurni> DbSetDdbTurni { get; set; }
public virtual DbSet<ResScarti> DbSetScarti { get; set; }
public virtual DbSet<UserActionLog> 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<Actions>(entity =>
modelBuilder.Entity<DdbTurni>(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<AzioniUL>(entity =>
{
entity.HasKey(e => e.Azione);
+7 -2
View File
@@ -17,7 +17,7 @@ namespace MP.Stats.Data
private static IConfiguration _configuration;
private static ILogger<MpStatsService> _logger;
private static List<MP.Data.DatabaseModels.Actions> ActionsList = new List<MP.Data.DatabaseModels.Actions>();
private static List<MP.Data.DatabaseModels.AzioniUL> ActionsList = new List<MP.Data.DatabaseModels.AzioniUL>();
#endregion Private Fields
@@ -59,7 +59,7 @@ namespace MP.Stats.Data
#region Public Methods
public Task<MP.Data.DatabaseModels.Actions[]> ActionsGetAll()
public Task<MP.Data.DatabaseModels.AzioniUL[]> ActionsGetAll()
{
return Task.FromResult(dbController.ActionsGetAll().ToArray());
}
@@ -74,6 +74,11 @@ namespace MP.Stats.Data
return Task.FromResult(dbController.StatControlliGetAll(numRecord, searchVal).ToArray());
}
public Task<MP.Data.DatabaseModels.DdbTurni[]> StatDdbGetAll(int numRecord, string searchVal = "")
{
return Task.FromResult(dbController.StatDdbGetAll(numRecord, searchVal).ToArray());
}
public Task<MP.Data.DatabaseModels.ResScarti[]> StatScartiGetAll(int numRecord, string searchVal = "")
{
return Task.FromResult(dbController.StatScartiGetAll(numRecord, searchVal).ToArray());
+66
View File
@@ -0,0 +1,66 @@
@page "/diario"
@using MP.Stats.Components
@using MP.Stats.Data
<div class="card">
<div class="card-header table-primary h1">Diario Produzione</div>
<div class="card-body">
@if (currRecord != null)
{
@*<BasketEditor Basket="@currBasket" DataReset="ResetData" DataUpdated="UpdateData"></BasketEditor>*@
}
@if (ListRecords == null)
{
<div class="progress-bar progress-bar-striped progress-bar-animated" style="width:70%"></div>
}
else
{
<table class="table table-sm table-striped">
<thead>
<tr>
@*<th></th>*@
<th>Macchina</th>
<th>Data</th>
<th>ODL/Commessa</th>
<th>Articolo</th>
<th class="text-right">Stato</th>
<th class="text-right">Durata</th>
<th class="text-right">Pezzi</th>
@*<th>Operatore</th>*@
</tr>
</thead>
<tbody>
@foreach (var record in ListRecords)
{
<tr class="@checkSelect(@record.IdxMacchina, record.CodArticolo, record.InizioStato)">
@*<td><button class="btn btn-sm btn-info" @onclick="() => Edit(record)"><span class="oi oi-pencil"></span></button>&nbsp;<button class="btn btn-sm btn-success" @onclick="() => ShowDocs(record)" title="Vai ai documenti"><span class="oi oi-document"></span></button></td>*@
<td>
<div>@record.CodMacchina</div>
<div class="small">@record.IdxMacchina</div>
</td>
<td>
<div>@record.InizioStato.ToString("yyyy.MM.dd")</div>
<div class="small">@record.InizioStato.ToString("ddd HH:mm.ss")</div>
</td>
<td>@record.IdxOdl | @record.KeyRichiesta</td>
<td>@record.CodArticolo</td>
<td class="text-right">@record.Descrizione</td>
<td class="text-right">@record.DurataMin</td>
<td class="text-right">@record.TotPzProd</td>
</tr>
}
</tbody>
</table>
}
</div>
<div class="card-footer py-1">
<div class="row">
<div class="col-8 col-lg-10">
</div>
<div class="col-4 col-lg-2">
<DataPager numRecord="@numRecord" numRecordChanged="ForceReload" />
</div>
</div>
</div>
</div>
+104
View File
@@ -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.DdbTurni currRecord = null;
private MP.Data.DatabaseModels.DdbTurni[] 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.StatDdbGetAll(numRecord, MessageService.SearchVal);
}
protected override async Task OnInitializedAsync()
{
numRecord = 10;
MessageService.ShowSearch = true;
MessageService.EA_SearchUpdated += OnSeachUpdated;
ListRecords = await StatService.StatDdbGetAll(numRecord, MessageService.SearchVal);
}
protected void ResetData()
{
StatService.rollBackEdit(currRecord);
currRecord = null;
}
protected async Task UpdateData()
{
currRecord = null;
ListRecords = await StatService.StatDdbGetAll(numRecord, MessageService.SearchVal);
}
#endregion Protected Methods
#region Public Methods
public string checkSelect(string IdxMacchina, string CodArticolo, DateTime InizioStato)
{
string answ = "";
if (currRecord != null)
{
try
{
answ = (currRecord.IdxMacchina == IdxMacchina && currRecord.CodArticolo == CodArticolo && currRecord.InizioStato == InizioStato) ? "table-info" : "";
}
catch
{ }
}
return answ;
}
public void Dispose()
{
MessageService.EA_SearchUpdated -= OnSeachUpdated;
}
public void OnSeachUpdated()
{
InvokeAsync(() =>
{
UpdateData();
StateHasChanged();
});
}
#endregion Public Methods
}
}
+4 -4
View File
@@ -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;
}
+1 -1
View File
@@ -13,7 +13,7 @@
</NavLink>
</li>
<li class="nav-item px-3">
<NavLink class="nav-link" href="produzione">
<NavLink class="nav-link" href="diario">
<span class="oi oi-book" aria-hidden="true" title="Dati di Produzione"></span> Diario Produzione
</NavLink>
</li>