diff --git a/MP-TAB-SERV/Components/ProdConfirm.razor b/MP-TAB-SERV/Components/ProdConfirm.razor index 853ccd65..20285dcc 100644 --- a/MP-TAB-SERV/Components/ProdConfirm.razor +++ b/MP-TAB-SERV/Components/ProdConfirm.razor @@ -1,5 +1,138 @@ 

ProdConfirm

-@code { -} +
+
+
+
+ + MOSTRA Conferma + + MANCA ODL: conferma NON permessa + + + + +
+
+ + + + + + +
+
+
+
+
+
+ Dati Incrementali +
+
+ ultima conferma --> + +
+
+ + +
+
+
+ + + + +
+
+ [B2] + + + [C2] +
+
+
+ + +   +
+
+ CONFERMA + USER INPUT +
+
+
+
+
+
+ + +
+
+
+   + ELABORAZIONE IN CORSO +   +
+
+
+
+
+
+
+
+
+
+ Dati Globali ODL +
+
+ Periodo ODL calcolato: + [dtInizio] + - + [dtFine] +
+
+
+
+ [A] NUOVI Pz.Prod +
+
+ [A] +
+
+
+
+
+
+ Pz Prodotti TOT [A+B+C] +
+
+ [A+B+C] +
+
+
+
+
+
+ [B] Scarti VERS. +
+
+ [B] +
+
+
+
+
+
+ [C] Pz Buoni VERS. +
+
+ [C] +
+
+
+
+
+
+ +
+
+ \ No newline at end of file diff --git a/MP-TAB-SERV/Components/ProdConfirm.razor.cs b/MP-TAB-SERV/Components/ProdConfirm.razor.cs new file mode 100644 index 00000000..7f65c633 --- /dev/null +++ b/MP-TAB-SERV/Components/ProdConfirm.razor.cs @@ -0,0 +1,563 @@ +using global::Microsoft.AspNetCore.Components; +using MP.Data.DatabaseModels; + +namespace MP_TAB_SERV.Components +{ + public partial class ProdConfirm + { + #region Public Properties + + [Parameter] + public MappaStatoExpl? RecMSE { get; set; } = null; + + #endregion Public Properties + + + + +#if false + + #region Public Fields + + /// + /// Dati produzioen rilevati + /// + public DS_ProdTempi.StatoProdRow datiProdAct; + + #endregion Public Fields + + #region Public Events + + /// + /// registrato nuovo valore + /// + public event EventHandler eh_inserting; + + /// + /// registrato nuovo valore + /// + public event EventHandler eh_newVal; + + /// + /// registrato nuovo valore + /// + public event EventHandler eh_reset; + + #endregion Public Events + + #region Public Properties + + /// + /// restituisce css disabled SE odl NON OK... + /// + public string cssBtnConf + { + get + { + return odlOk ? "" : "disabled"; + } + } + + /// + /// Data-Ora ultimo update valori produzione + /// + public DateTime dtReqUpdate + { + get + { + DateTime answ = DateTime.Now; + DateTime.TryParse(hfDtReqUpdate.Value, out answ); + return answ; + } + set + { + hfDtReqUpdate.Value = $"{value}"; + } + } + + /// + /// Verifica ODL OK (ovvero caricato x macchina...) + /// + public bool odlOk + { + get + { + bool answ = true; + // se ODL > 0 è ok!!! + answ = (idxOdl > 0); + return answ; + } + } + + #endregion Public Properties + + #region Public Methods + + /// + /// Aggiorno valori produzione alla data richiesta... + /// + /// + public void doUpdate() + { + datiProdAct = DataLayerObj.taStatoProd.GetData(idxMacchinaSel, dtReqUpdate)[0]; + // aggiorno visualizzazione... + numPzProdotti = datiProdAct.PzTotODL; + numPz2Rec = datiProdAct.Pz2RecTot; + numPzScaConf = datiProdAct.PzConfScarto; + numPzBuoniConf = datiProdAct.PzConfBuoni; + numPzProdotti2Rec = datiProdAct.Pz2RecTot; + numPzScarto2Rec = datiProdAct.Pz2RecScarto; + dtInizio = inizioOdl; + dtFine = dtReqUpdate; + reportUpdate(); + } + + #endregion Public Methods + + #region Protected Properties + + protected DateTime dtFine + { + set + { + lblFine.Text = value.ToString(); + } + } + + /// + /// Numero pezzi PRODOTTI da ultima conferma + /// + protected DateTime dtInizio + { + set + { + lblInizio.Text = value.ToString(); + } + } + + /// + /// Numero pezzi PRODOTTI da ultima conferma + /// + protected int numPz2Rec + { + set + { + lblPz2RecTot.Text = value.ToString(); + } + } + + /// + /// Numero pezzi BUONI già confermati + /// + protected int numPzBuoniConf + { + set + { + lblPzConfBuoni.Text = value.ToString(); + } + } + + /// + /// Numero pezzi confermati (buoni - scarto) + /// + protected int numPzConfermati + { + get + { + return numPzProdotti2Rec - numPzScarto2Rec; + } + } + + /// + /// Numero pezzi da LASCIARE non dichiarati + /// + protected int numPzLasciati + { + set + { + txtNumLasciati.Text = value.ToString(); + } + get + { + int answ = 0; + try + { + answ = Convert.ToInt32(txtNumLasciati.Text); + } + catch + { } + return answ; + } + } + + /// + /// Numero pezzi PRODOTTI GLOBALI + /// + protected int numPzProdotti + { + set + { + lblPzTotODL.Text = value.ToString(); + } + } + + /// + /// Numero pezzi PRODOTTI da registrare + /// + /// da ultima conferma + protected int numPzProdotti2Rec + { + set + { + txtNumPezzi.Text = value.ToString(); + } + get + { + int answ = 0; + try + { + answ = Convert.ToInt32(txtNumPezzi.Text); + } + catch + { } + return answ; + } + } + + /// + /// Numero pezzi SCARTO già confermati + /// + protected int numPzScaConf + { + set + { + lblPzConfScarto.Text = value.ToString(); + } + } + + /// + /// Numero pezzi SCARTATI da registrare + /// + protected int numPzScarto2Rec + { + set + { + lblPz2RecScarto.Text = value.ToString(); + memLayer.ML.setSessionVal("lblPz2RecScarto", value); + } + get + { + int answ = 0; + try + { + answ = memLayer.ML.IntSessionObj("lblPz2RecScarto"); + } + catch + { } + return answ; + } + } + + protected bool showInnov + { + get + { + return divInnovazioni.Visible; + } + set + { + divInnovazioni.Visible = value; + } + } + + #endregion Protected Properties + + #region Protected Methods + + protected void ddlSubMacc_DataBound(object sender, EventArgs e) + { + // se ho in memoria un valore LO REIMPOSTO... + if (!string.IsNullOrEmpty(subMaccSel)) + { + // se è una SUB machcina (contiene "#") + if (subMaccSel.Contains("#")) + { + // provo a preselezionare... + try + { + ddlSubMacc.SelectedValue = subMaccSel; + } + catch + { } + } + // altrimenti salvo! + else + { + subMaccSel = ddlSubMacc.SelectedValue; + } + } + } + + protected void ddlSubMacc_SelectedIndexChanged(object sender, EventArgs e) + { + subMaccSel = ddlSubMacc.SelectedValue; + // salvo ODL + DataLayerObj.taMSE.getByIdxMaccAndSub(idxMacchinaSel, subMaccSel); + //altri controlli + checkAll(); + } + + /// + /// salvo produzione + /// + /// + /// + protected void lbtSalva_Click(object sender, EventArgs e) + { + // effettua conferma con conf da DB del tipo (giorni / turni / periodo + bool fatto = effettuaConfermaProd(); + // refresh tabella dati tablet... + DataLayerObj.taMSE.forceRecalc(0, idxMacchinaSel); + // mostro output + lblOut.Text = string.Format("Confermata la produzione per {0} pezzi! (+{1} pz scarto) alle {2:yyyy-MM-dd HH:mm:ss}", numPzConfermati, numPzScarto2Rec, dtReqUpdate); + // cambio button conferma... + switchBtnConferma(!txtNumPezzi.Enabled); + // sollevo evento! + if (eh_newVal != null) + { + eh_newVal(this, new EventArgs()); + } + dtReqUpdate = DateTime.Now; + doUpdate(); + } + + /// + /// cambio stato visibilità pannello e testo button + /// + /// + /// + protected void lbtShowConfProd_Click(object sender, EventArgs e) + { + showInnov = !showInnov; + switchBtnConferma(showInnov); + } + + /// + /// caricamento pagina + /// + /// + /// + protected void Page_Load(object sender, EventArgs e) + { + if (!Page.IsPostBack) + { + checkAll(); + if (isMulti) + { + // sollevo evento! + if (eh_reset != null) + { + eh_reset(this, new EventArgs()); + } + } + } + } + + /// + /// Update pz lasciati --> aggiorno! + /// + /// + /// + protected void txtNumLasciati_TextChanged(object sender, EventArgs e) + { + lblOut.Text = ""; + updatePzBuoni(); + } + + /// + /// update post modifica pz buoni + /// + /// + /// + protected void txtNumPezzi_TextChanged(object sender, EventArgs e) + { + lblOut.Text = ""; + updatePzBuoni(); + } + + /// + /// ODL correntemente sulla macchina + /// - cerca in Redis (TTL 5 sec) + /// - altrimenti recupera da DB... + /// + protected void updateOdl() + { + // userò ODL del turno + int answ = 0; + // cerco da redis... + int.TryParse(DataLayerObj.currODL(idxMacchinaSel, true), out answ); + // salvo! + idxOdl = answ; + } + + #endregion Protected Methods + + #region Private Methods + + private void checkAll() + { + updateOdl(); + checkConfig(); + fixSelMacc(); + checkOdl(); + lblOut.Text = ""; + switchBtnConferma(false); + lbtShowConfProd.Visible = odlOk; + lblConfProd.Visible = !odlOk; + } + + /// + /// verifica config x modalità permesse + /// + private void checkConfig() + { + // verifico SE sia permesso gestire i "Pezzi lasciati" in macchina... + lblNumLasciati.Visible = enablePzProdLasciati; + txtNumLasciati.Visible = enablePzProdLasciati; + lblEmptyNumLasciati.Visible = !enablePzProdLasciati; + } + + /// + /// Verifica se abbia un ODL ATTIVO + /// + private void checkOdl() + { + lbtShowConfProd.Visible = odlOk; + lblConfProd.Visible = !odlOk; + lblMancaODL.Visible = !odlOk; + } + + /// + /// Registra conferma produzione in modalità nuova (con rettifica pezzi lasciati) o legacy + /// (con anticipo periodo) + /// + private bool effettuaConfermaProd() + { + bool fatto = false; + if (confRett) + { + // confermo al netto dei pezzi lasciati... + fatto = DataLayerObj.confermaProdMacchinaFull(idxMacchinaSel, memLayer.ML.CRI("modoConfProd"), numPzConfermati - numPzLasciati, numPzLasciati, numPzScarto2Rec, dtReqUpdate); + } + else + { + fatto = DataLayerObj.confermaProdMacchina(idxMacchinaSel, memLayer.ML.CRI("modoConfProd"), numPzConfermati, numPzScarto2Rec, dtReqUpdate); + } + return fatto; + } + + /// + /// Se la machcina è MULTI --> mostro selettore + /// + private void fixSelMacc() + { + divSelMacc.Visible = isMulti; + if (isMulti) + { + try + { + // salvo selezione submacc + ddlSubMacc.DataBind(); + subMaccSel = ddlSubMacc.SelectedValue; + } + catch + { } + } + updateOdl(); + } + + /// + /// Reset parametri x calcolo pezzi (no pezzi lasciati, dataora attuale...) + /// + private void resetParam() + { + dtReqUpdate = DateTime.Now; + numPzLasciati = 0; + } + + /// + /// determina comportamento btn conferma + /// + private void switchBtnConferma(bool showConf) + { + // aggiorno valori rilevati + resetParam(); + doUpdate(); + divInnovazioni.Visible = showConf; + if (showConf) + { + try + { + updatePzBuoni(); + // sollevo evento! + if (eh_inserting != null) + { + eh_inserting(this, new EventArgs()); + } + } + catch + { + txtNumPezzi.Text = "0"; + logger.lg.scriviLog(string.Format("Errore recupero pezzi da confermare per la macchina {0}", idxMacchinaSel), tipoLog.ERROR); + } + } + if (showConf) + { + lblShowConfProd.Text = "Nascondi Conferma"; + } + else + { + lblShowConfProd.Text = "Mostra Conferma"; + // sollevo evento! + if (eh_reset != null) + { + eh_reset(this, new EventArgs()); + } + } + } + + /// + /// aggiorna visualizzazione pz buoni /prodotti - scarti) + /// + private void updatePzBuoni() + { + if (confRett) + { + // cambio le qta di pezzi confermati... + lblPz2RecBuoni.Text = (numPzConfermati - numPzLasciati).ToString(); + } + else + { + // se ho dei pezzi lasciati RICALCOLO la data... + if (numPzLasciati > 0) + { + // calcolo la data.. + DS_ProdTempi.TempiCicloRilevatiDataTable tab = DataLayerObj.taTempiCicloRilevati.getLastPzByMaccQta(idxMacchinaSel, DateTime.Now, numPzLasciati); + if (tab.Rows.Count > 0) + { + dtReqUpdate = tab[0].DataOraRif.AddSeconds(1); + } + // aggiorno + doUpdate(); + } + lblPz2RecBuoni.Text = numPzConfermati.ToString(); + } + // aggiorno la data calcolo + pezzi buoni... + lblDtRec.Text = dtReqUpdate.ToString(); + } + + #endregion Private Methods +#endif + + } +} \ No newline at end of file diff --git a/MP-TAB-SERV/Pages/MachineDetail.razor b/MP-TAB-SERV/Pages/MachineDetail.razor index 482510f8..39435f87 100644 --- a/MP-TAB-SERV/Pages/MachineDetail.razor +++ b/MP-TAB-SERV/Pages/MachineDetail.razor @@ -1,6 +1,5 @@ @page "/machine-detail" - @if (string.IsNullOrEmpty(IdxMacc) || CurrMSE == null) { @@ -8,11 +7,11 @@ else {
- +
- - + +
Reg. SCARTI diff --git a/MP-TAB-SERV/Pages/MachineDetail.razor.cs b/MP-TAB-SERV/Pages/MachineDetail.razor.cs index 54d06e05..97f26115 100644 --- a/MP-TAB-SERV/Pages/MachineDetail.razor.cs +++ b/MP-TAB-SERV/Pages/MachineDetail.razor.cs @@ -1,7 +1,6 @@ using Microsoft.AspNetCore.Components; using MP.Data.DatabaseModels; using MP.Data.Services; -using NLog.Fluent; namespace MP_TAB_SERV.Pages { @@ -14,6 +13,7 @@ namespace MP_TAB_SERV.Pages [Inject] protected MessageService MsgServ { get; set; } = null!; + [Inject] protected TabDataService TabServ { get; set; } = null!; @@ -28,10 +28,22 @@ namespace MP_TAB_SERV.Pages if (enableSchedaTecnica) { checkLottiOdl(); - } + } #endif } + #endregion Protected Methods + + #region Private Fields + + private List? CurrConfig = null; + + private bool enableSchedaTecnica = false; + + #endregion Private Fields + + #region Private Methods + private void checkLottiOdl() { #if false @@ -52,14 +64,10 @@ namespace MP_TAB_SERV.Pages { } } } - } + } #endif } - #endregion Protected Methods - - #region Private Methods - private async Task ReloadData() { if (string.IsNullOrEmpty(IdxMacc)) @@ -90,14 +98,10 @@ namespace MP_TAB_SERV.Pages getConfValInt("pageRefreshSec", ref slowRefreshSec); getConfVal("sART", ref showArt); Log.Info($"setupConf | Effettuato setup parametri | keepAlive: {keepAliveMin} | MaxCol: {maxCol} | doAnimate: {doAnimate} | slowRefreshSec: {slowRefreshSec}"); - } + } #endif } - private List? CurrConfig = null; - - private bool enableSchedaTecnica = false; - #endregion Private Methods } } \ No newline at end of file