diff --git a/MP.Data/Controllers/MpSpecController.cs b/MP.Data/Controllers/MpSpecController.cs index 1eddded3..e21feec9 100644 --- a/MP.Data/Controllers/MpSpecController.cs +++ b/MP.Data/Controllers/MpSpecController.cs @@ -199,15 +199,18 @@ namespace MP.Data.Controllers public async Task> StatOdl(int IdxOdl) { List dbResult = new List(); - using (var dbCtx = new MoonProContext(_configuration)) + if (IdxOdl > 0) { - var IdxODL = new SqlParameter("@IdxODL", IdxOdl); + using (var dbCtx = new MoonProContext(_configuration)) + { + var IdxODL = new SqlParameter("@IdxODL", IdxOdl); - dbResult = await dbCtx - .DbSetStatOdl - .FromSqlRaw("EXEC stp_STAT_ODL @IdxODL", IdxODL) - .AsNoTracking() - .ToListAsync(); + dbResult = await dbCtx + .DbSetStatOdl + .FromSqlRaw("EXEC stp_STAT_ODL @IdxODL", IdxODL) + .AsNoTracking() + .ToListAsync(); + } } return dbResult; } @@ -421,7 +424,7 @@ namespace MP.Data.Controllers .FirstOrDefault(); if (currRec != null) { - currRec.Valore= editRec.Valore; + currRec.Valore = editRec.Valore; dbCtx.Entry(currRec).State = EntityState.Modified; } else @@ -730,6 +733,110 @@ namespace MP.Data.Controllers return fatto; } + + /// + /// Stato prod macchina + /// + /// + /// + public StatoProdModel StatoProdMacchina(string idxMacchina) + { + StatoProdModel dbResult = new StatoProdModel(); + using (var dbCtx = new MoonProContext(_configuration)) + { + var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina); + dbResult = dbCtx + .DbSetStatoProd + .FromSqlRaw("EXEC stp_PzProd_getByMacchina @IdxMacchina", IdxMacchina) + .AsNoTracking() + .FirstOrDefault(); + } + return dbResult; + } + + /// + /// Chiusura ODL con eventuale conferma pezzi + /// + /// idx odl da chiudere + /// idx macchina + /// matricola operatore + /// indica se confermare i pezzi prima di chiudere ODL + /// Conferma con rettifica (ev 121) x pezzi lasciati in macchina + /// Modo conferma produzione (0=periodo, 1=giorno, 2=turno) + /// + public async Task ODLClose(int idxOdl, string idxMacchina, int matrOpr, bool confPezzi, bool confRett, int modoConfProd) + { + bool fatto = false; + if (idxOdl > 0) + { + using (var dbCtx = new MoonProContext(_configuration)) + { + DateTime adesso = DateTime.Now; + // preparo i parametri + var IdxODL = new SqlParameter("@IdxODL", idxOdl); + var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina); + + // FARE FIXME TODO !!! + // da valutare casi setup/autoconferma... +#if false + // controllo se HO pezzi da confermare... + var statoProd = StatoProdMacchina(idxMacchina); + if (statoProd.pezziNonConfermati < 1) + { } +#endif + + // se richiesto confermo produzione + if (confPezzi) + { + var MatrApp = new SqlParameter("@MatrApp", idxMacchina); + + /* ---------------------------------- + * CONFERMA PEZZI + * + * condizioni da verificare: + * - gestione rettifica (ev121) / pezzi da LASCIARE in macchina + * - conferma a zero pezzi (setup) oppure con i pezzi fatti e non ancora confermati + * + * + * + * */ + + // recupero i dati dei pezzi da confermare... con DbSetPzProd + exec stp_PzProd_getByMacchina 'SIMUL_01' + + // stp_ConfermaProduzCompletaFull + /* + * @idxMacchina NVARCHAR(50), + @MatrApp INT, + @dataFrom DATETIME, + @dataTo DATETIME, + @pezziConf INT, + @pezziLasciati INT, -- pezzi lasciati = evento 121 (-) pre conferma e (+) dopo --> da lasciare in macchina post conferma + @pezziScar INT = 0, -- pezzi scartati (registrati da 2016.11.20) DA INDICARE COME VALORE > 0!!! sennò faccio ABS... + @TipoConf INT = 0, -- Tipo intervallo conferma: 0 = periodo intero, 1 = per giorni, 2 = per turni + @DataOraApp DATETIME = NULL, -- di norma GETDATE() nel programma - serve per ricalcolo + @TestConferma BIT = 1 -- TestConferma : 1 = verifica conf. duplicata e inserisci in ElencoConfermeProd, 0 = nessuna verifica e inserimento ( per ricalcolo ) + */ + } + + // ora chiudo ODL + try + { + var dbResult = await dbCtx + .DbSetStatOdl + .FromSqlRaw("EXEC stp_ODL_fineProd @IdxODL, @IdxMacchina", IdxODL, IdxMacchina) + .AsNoTracking() + .ToListAsync(); + } + catch (Exception exc) + { + Log.Error($"Eccezione durante ODLClose{Environment.NewLine}{exc}"); + } + } + } + return fatto; + } + + /// /// Annulla modifiche su una specifica entity (cancel update) /// diff --git a/MP.Data/DatabaseModels/StatoProdModel.cs b/MP.Data/DatabaseModels/StatoProdModel.cs new file mode 100644 index 00000000..4072485e --- /dev/null +++ b/MP.Data/DatabaseModels/StatoProdModel.cs @@ -0,0 +1,20 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +#nullable disable +// +// This is here so CodeMaid doesn't reorganize this document +// +namespace MP.Data.DatabaseModels +{ + public partial class StatoProdModel + { + [Key] + public string idxMacchina { get; set; } = "NA"; + public int pezziNonConfermati { get; set; } = 0; + public DateTime DataFrom { get; set; } = DateTime.Now; + public DateTime DataTo { get; set; } = DateTime.Now; + } +} diff --git a/MP.Data/MoonProContext.cs b/MP.Data/MoonProContext.cs index e35a351e..163b7600 100644 --- a/MP.Data/MoonProContext.cs +++ b/MP.Data/MoonProContext.cs @@ -49,6 +49,7 @@ namespace MP.Data public virtual DbSet DbSetFluxLog { get; set; } public virtual DbSet DbSetDossiers { get; set; } public virtual DbSet DbSetStatOdl { get; set; } + public virtual DbSet DbSetStatoProd { get; set; } #endregion Public Properties diff --git a/MP.SPEC/Components/ListODL.razor b/MP.SPEC/Components/ListODL.razor index 0a1ecb65..28787cf1 100644 --- a/MP.SPEC/Components/ListODL.razor +++ b/MP.SPEC/Components/ListODL.razor @@ -12,10 +12,26 @@ else if (totalCount == 0) else {
+ @if (currRecord != null && !showStats && isCurrOdl) + { +
+
+
+ @*
+ + + +
*@ + +
+ }
+ @@ -28,6 +44,17 @@ else @foreach (var record in ListRecords) { + +
+ + Articolo Fase Macchina
+ @if (isCurrOdl) + { + + } + else + { + + } + @record.CodArticolo
@record.ArticoloNav.DescArticolo
@@ -114,7 +141,7 @@ else