From f88ccf4bfaf1f082c55718a2530ffe4c54a5c79e Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 24 Mar 2023 18:20:46 +0100 Subject: [PATCH] Aggiunta metodi x avvio PODL passati --- MP-IO/Controllers/IOBController.cs | 30 ++-- MP-TAB/WebUserControls/mod_ODL.ascx.cs | 3 +- MapoDb/DS_ProdTempi.xsd | 80 +++++++---- MapoDb/DS_ProdTempi.xss | 10 +- MapoDb/DS_ProdTempi1.Designer.cs | 110 ++++++++++++++- MapoDb/DataLayer.cs | 187 +++++++++++++++---------- 6 files changed, 289 insertions(+), 131 deletions(-) diff --git a/MP-IO/Controllers/IOBController.cs b/MP-IO/Controllers/IOBController.cs index 2265a467..352698e1 100644 --- a/MP-IO/Controllers/IOBController.cs +++ b/MP-IO/Controllers/IOBController.cs @@ -121,13 +121,13 @@ namespace MP_IO.Controllers public bool closeODL(string id, int idxOdl) { bool answ = false; - // init obj DataLayer DataLayer DataLayerObj = new DataLayer(); try { // chiamata diretta sul DB... - DataLayerObj.taODL.forceClose(idxOdl, id); + DateTime dtEvento = DateTime.Now; + DataLayerObj.taODL.forceClose(idxOdl, id, dtEvento); answ = true; } catch @@ -136,7 +136,7 @@ namespace MP_IO.Controllers } /// - /// Chiude PODL --> ODL x macchina: + /// Chiude PODL --> ODL x macchina: /// /// GET: IOB/closePODL/SIMUL_03?idxPOdl=123 /// @@ -146,7 +146,6 @@ namespace MP_IO.Controllers public bool closePODL(string id, int idxPOdl) { bool answ = false; - // init obj DataLayer DataLayer DataLayerObj = new DataLayer(); try @@ -158,8 +157,8 @@ namespace MP_IO.Controllers { int idxOdl = tabPodl[0].IdxODL; // chiamata diretta sul DB... - DataLayerObj.taODL.forceClose(idxOdl, id); - answ = true; + DateTime dtEvento = DateTime.Now; + DataLayerObj.taODL.forceClose(idxOdl, id, dtEvento); } } catch @@ -567,22 +566,25 @@ namespace MP_IO.Controllers /// /// Avvia PODL indicato - /// - se esistesse un ODL da altro PODL --> chiude - /// - se fosse già in essere ODL collegato --> lascia aperto - /// - se fosse chiuso ODL collegato --> duplica PODL e poi avvia nuovo ODL. + /// - se esistesse un ODL da altro PODL --> chiude + /// - se fosse già in essere ODL collegato --> lascia aperto + /// - se fosse chiuso ODL collegato --> duplica PODL e poi avvia nuovo ODL. /// - /// GET: IOB/forceStartPOdl/SIMUL_03?idxPODL=123 + /// GET: IOB/forceStartPOdl/SIMUL_03?idxPODL=123&dtEve=20230323151100000&dtCurr=20230323221100000 /// /// /// idx del PDL da avviare + /// data-ora di avvio (opzionale) + /// data-ora attuale (opzionale) /// Esito chiamata (OK/vuoto) - public string forceStartPOdl(string id, int idxPODL) + public string forceStartPOdl(string id, int idxPODL, string dtEve = "", string dtCurr = "") { // attenzione! poiché nell'URL il carattere "#" viene filtrato ci aspettiamo il // carattere "|" che poi trasformiamo ora in "#" id = id.Replace("|", "#"); DataLayer DataLayerObj = new DataLayer(); - return DataLayerObj.ForceStartPOdl(id, idxPODL, true); + string answ = DataLayerObj.ForceStartPOdl(id, idxPODL, true, dtEve, dtCurr); + return answ; } /// @@ -979,7 +981,7 @@ namespace MP_IO.Controllers /// /// GET: IOB/getLastDossArt/cod_articolo /// - /// codice articolo, se vuoto --> non fa nulla + /// codice articolo, se vuoto --> non fa nulla /// Json contenente lista oggetti DOSSIER serializzati public string getLastDossArt(string id) { @@ -1014,7 +1016,7 @@ namespace MP_IO.Controllers /// /// GET: IOB/getLastDossArt/cod_articolo /// - /// codice articolo, se vuoto --> non fa nulla + /// codice articolo, se vuoto --> non fa nulla /// Json contenente lista oggetti DOSSIER serializzati public string getLastDossByMacc(string id) { diff --git a/MP-TAB/WebUserControls/mod_ODL.ascx.cs b/MP-TAB/WebUserControls/mod_ODL.ascx.cs index 6ea63e35..05fb6528 100644 --- a/MP-TAB/WebUserControls/mod_ODL.ascx.cs +++ b/MP-TAB/WebUserControls/mod_ODL.ascx.cs @@ -1181,7 +1181,8 @@ namespace MoonProTablet.WebUserControls if (enableRPO) { // creo nuovo ODL da promessa ed associo - DataLayerObj.taODL.inizioSetupPromessa(idxODLSel, DataLayerObj.MatrOpr, idxMacchinaFix, TCRichAttr, PzPallet, txtNote.Text); + DateTime adesso = DateTime.Now; + DataLayerObj.taODL.inizioSetupPromessa(idxODLSel, DataLayerObj.MatrOpr, idxMacchinaFix, TCRichAttr, PzPallet, txtNote.Text, adesso); // salvo ODL attrezzato idxODL_curr = DataLayerObj.taODL.getByMacchina(idxMacchinaFix)[0].IdxODL; } diff --git a/MapoDb/DS_ProdTempi.xsd b/MapoDb/DS_ProdTempi.xsd index 419d1b41..315b1913 100644 --- a/MapoDb/DS_ProdTempi.xsd +++ b/MapoDb/DS_ProdTempi.xsd @@ -357,6 +357,7 @@ FROM v_ODL_exp ORDER BY IdxODL DESC + @@ -494,6 +495,7 @@ FROM v_ODL_exp ORDER BY IdxODL DESC + @@ -2294,8 +2296,8 @@ FROM dbo.v_RegistroScarti - SELECT * -FROM v_PODL_exp + SELECT * +FROM v_PODL_exp ORDER BY idxPromessa DESC @@ -2320,6 +2322,9 @@ ORDER BY idxPromessa DESC + + + @@ -3052,82 +3057,82 @@ SELECT IdxMacchina, IdxMacchinaSlave FROM Macchine2Slave WHERE (IdxMacchina = @I - - - + + + - + - + - + - - - + + + - + - - - - + + + + - - + + - - - - - - - - - - - - + + + + + + + + + + + + @@ -3385,6 +3390,21 @@ SELECT IdxMacchina, IdxMacchinaSlave FROM Macchine2Slave WHERE (IdxMacchina = @I + + + + + + + + + + + + + + + diff --git a/MapoDb/DS_ProdTempi.xss b/MapoDb/DS_ProdTempi.xss index 9cee3317..c5f4b901 100644 --- a/MapoDb/DS_ProdTempi.xss +++ b/MapoDb/DS_ProdTempi.xss @@ -4,23 +4,23 @@ Changes to this file may cause incorrect behavior and will be lost if the code is regenerated. --> - + - - + + - + - + diff --git a/MapoDb/DS_ProdTempi1.Designer.cs b/MapoDb/DS_ProdTempi1.Designer.cs index a283fe87..04f74a41 100644 --- a/MapoDb/DS_ProdTempi1.Designer.cs +++ b/MapoDb/DS_ProdTempi1.Designer.cs @@ -8874,6 +8874,12 @@ namespace MapoDb { private global::System.Data.DataColumn columnNote; + private global::System.Data.DataColumn columnCodCli; + + private global::System.Data.DataColumn columnInsertDate; + + private global::System.Data.DataColumn columnRecipe; + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] public PromesseODLDataTable() { @@ -9043,6 +9049,30 @@ namespace MapoDb { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] + public global::System.Data.DataColumn CodCliColumn { + get { + return this.columnCodCli; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] + public global::System.Data.DataColumn InsertDateColumn { + get { + return this.columnInsertDate; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] + public global::System.Data.DataColumn RecipeColumn { + get { + return this.columnRecipe; + } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] [global::System.ComponentModel.Browsable(false)] @@ -9096,7 +9126,10 @@ namespace MapoDb { System.DateTime DueDate, int Priorita, int PzPallet, - string Note) { + string Note, + string CodCli, + System.DateTime InsertDate, + string Recipe) { PromesseODLRow rowPromesseODLRow = ((PromesseODLRow)(this.NewRow())); object[] columnValuesArray = new object[] { null, @@ -9115,7 +9148,10 @@ namespace MapoDb { DueDate, Priorita, PzPallet, - Note}; + Note, + CodCli, + InsertDate, + Recipe}; rowPromesseODLRow.ItemArray = columnValuesArray; this.Rows.Add(rowPromesseODLRow); return rowPromesseODLRow; @@ -9162,6 +9198,9 @@ namespace MapoDb { this.columnPriorita = base.Columns["Priorita"]; this.columnPzPallet = base.Columns["PzPallet"]; this.columnNote = base.Columns["Note"]; + this.columnCodCli = base.Columns["CodCli"]; + this.columnInsertDate = base.Columns["InsertDate"]; + this.columnRecipe = base.Columns["Recipe"]; } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -9201,6 +9240,12 @@ namespace MapoDb { base.Columns.Add(this.columnPzPallet); this.columnNote = new global::System.Data.DataColumn("Note", typeof(string), null, global::System.Data.MappingType.Element); base.Columns.Add(this.columnNote); + this.columnCodCli = new global::System.Data.DataColumn("CodCli", typeof(string), null, global::System.Data.MappingType.Element); + base.Columns.Add(this.columnCodCli); + this.columnInsertDate = new global::System.Data.DataColumn("InsertDate", typeof(global::System.DateTime), null, global::System.Data.MappingType.Element); + base.Columns.Add(this.columnInsertDate); + this.columnRecipe = new global::System.Data.DataColumn("Recipe", typeof(string), null, global::System.Data.MappingType.Element); + base.Columns.Add(this.columnRecipe); this.Constraints.Add(new global::System.Data.UniqueConstraint("Constraint1", new global::System.Data.DataColumn[] { this.columnidxPromessa}, true)); this.columnidxPromessa.AutoIncrement = true; @@ -9233,6 +9278,11 @@ namespace MapoDb { this.columnPzPallet.AllowDBNull = false; this.columnNote.AllowDBNull = false; this.columnNote.MaxLength = 2500; + this.columnCodCli.AllowDBNull = false; + this.columnCodCli.MaxLength = 50; + this.columnInsertDate.AllowDBNull = false; + this.columnRecipe.AllowDBNull = false; + this.columnRecipe.MaxLength = 500; } [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] @@ -15282,6 +15332,39 @@ namespace MapoDb { } } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] + public string CodCli { + get { + return ((string)(this[this.tablePromesseODL.CodCliColumn])); + } + set { + this[this.tablePromesseODL.CodCliColumn] = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] + public System.DateTime InsertDate { + get { + return ((global::System.DateTime)(this[this.tablePromesseODL.InsertDateColumn])); + } + set { + this[this.tablePromesseODL.InsertDateColumn] = value; + } + } + + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] + public string Recipe { + get { + return ((string)(this[this.tablePromesseODL.RecipeColumn])); + } + set { + this[this.tablePromesseODL.RecipeColumn] = value; + } + } + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] public bool IsDescArticoloNull() { @@ -17660,6 +17743,7 @@ SELECT IdxMacchina, CodArticolo, DataOraRif, TCMedio, PzProd FROM TempiCicloRile this._commandCollection[9].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@RETURN_VALUE", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.ReturnValue, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[9].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@idxODL", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[9].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@IdxMacchina", global::System.Data.SqlDbType.NVarChar, 50, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[9].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@dtEvento", global::System.Data.SqlDbType.DateTime, 8, global::System.Data.ParameterDirection.Input, 23, 3, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[10] = new global::System.Data.SqlClient.SqlCommand(); this._commandCollection[10].Connection = this.Connection; this._commandCollection[10].CommandText = "dbo.stp_ODL_getByCodArt"; @@ -17742,6 +17826,7 @@ SELECT IdxMacchina, CodArticolo, DataOraRif, TCMedio, PzProd FROM TempiCicloRile this._commandCollection[20].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@TCRichAttr", global::System.Data.SqlDbType.Decimal, 9, global::System.Data.ParameterDirection.Input, 18, 8, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[20].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@PzPallet", global::System.Data.SqlDbType.Int, 4, global::System.Data.ParameterDirection.Input, 10, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[20].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@Note", global::System.Data.SqlDbType.NVarChar, 2500, global::System.Data.ParameterDirection.Input, 0, 0, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); + this._commandCollection[20].Parameters.Add(new global::System.Data.SqlClient.SqlParameter("@dtEvento", global::System.Data.SqlDbType.DateTime, 8, global::System.Data.ParameterDirection.Input, 23, 3, null, global::System.Data.DataRowVersion.Current, false, null, "", "", "")); this._commandCollection[21] = new global::System.Data.SqlClient.SqlCommand(); this._commandCollection[21].Connection = this.Connection; this._commandCollection[21].CommandText = "dbo.stp_ODL_inizioSetupPromessaPostuma"; @@ -18413,7 +18498,7 @@ SELECT IdxMacchina, CodArticolo, DataOraRif, TCMedio, PzProd FROM TempiCicloRile [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] - public virtual int forceClose(global::System.Nullable idxODL, string IdxMacchina) { + public virtual int forceClose(global::System.Nullable idxODL, string IdxMacchina, global::System.Nullable dtEvento) { global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[9]; if ((idxODL.HasValue == true)) { command.Parameters[1].Value = ((int)(idxODL.Value)); @@ -18427,6 +18512,12 @@ SELECT IdxMacchina, CodArticolo, DataOraRif, TCMedio, PzProd FROM TempiCicloRile else { command.Parameters[2].Value = ((string)(IdxMacchina)); } + if ((dtEvento.HasValue == true)) { + command.Parameters[3].Value = ((System.DateTime)(dtEvento.Value)); + } + else { + command.Parameters[3].Value = global::System.DBNull.Value; + } global::System.Data.ConnectionState previousConnectionState = command.Connection.State; if (((command.Connection.State & global::System.Data.ConnectionState.Open) != global::System.Data.ConnectionState.Open)) { @@ -18505,7 +18596,7 @@ SELECT IdxMacchina, CodArticolo, DataOraRif, TCMedio, PzProd FROM TempiCicloRile [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Data.Design.TypedDataSetGenerator", "17.0.0.0")] [global::System.ComponentModel.Design.HelpKeywordAttribute("vs.data.TableAdapter")] - public virtual int inizioSetupPromessa(global::System.Nullable idxPromessa, global::System.Nullable MatrOpr, string IdxMacchina, global::System.Nullable TCRichAttr, global::System.Nullable PzPallet, string Note) { + public virtual int inizioSetupPromessa(global::System.Nullable idxPromessa, global::System.Nullable MatrOpr, string IdxMacchina, global::System.Nullable TCRichAttr, global::System.Nullable PzPallet, string Note, global::System.Nullable dtEvento) { global::System.Data.SqlClient.SqlCommand command = this.CommandCollection[20]; if ((idxPromessa.HasValue == true)) { command.Parameters[1].Value = ((int)(idxPromessa.Value)); @@ -18543,6 +18634,12 @@ SELECT IdxMacchina, CodArticolo, DataOraRif, TCMedio, PzProd FROM TempiCicloRile else { command.Parameters[6].Value = ((string)(Note)); } + if ((dtEvento.HasValue == true)) { + command.Parameters[7].Value = ((System.DateTime)(dtEvento.Value)); + } + else { + command.Parameters[7].Value = global::System.DBNull.Value; + } global::System.Data.ConnectionState previousConnectionState = command.Connection.State; if (((command.Connection.State & global::System.Data.ConnectionState.Open) != global::System.Data.ConnectionState.Open)) { @@ -28327,6 +28424,9 @@ SELECT IdxMacchina, T1, T2, T3 FROM TurniMacchina WHERE (IdxMacchina = @IdxMacch tableMapping.ColumnMappings.Add("Priorita", "Priorita"); tableMapping.ColumnMappings.Add("PzPallet", "PzPallet"); tableMapping.ColumnMappings.Add("Note", "Note"); + tableMapping.ColumnMappings.Add("CodCli", "CodCli"); + tableMapping.ColumnMappings.Add("InsertDate", "InsertDate"); + tableMapping.ColumnMappings.Add("Recipe", "Recipe"); this._adapter.TableMappings.Add(tableMapping); } @@ -28343,7 +28443,7 @@ SELECT IdxMacchina, T1, T2, T3 FROM TurniMacchina WHERE (IdxMacchina = @IdxMacch this._commandCollection = new global::System.Data.SqlClient.SqlCommand[11]; this._commandCollection[0] = new global::System.Data.SqlClient.SqlCommand(); this._commandCollection[0].Connection = this.Connection; - this._commandCollection[0].CommandText = "SELECT *\r\nFROM v_PODL_exp\r\nORDER BY idxPromessa DESC"; + this._commandCollection[0].CommandText = "SELECT *\r\nFROM v_PODL_exp\r\nORDER BY idxPromessa DESC"; this._commandCollection[0].CommandType = global::System.Data.CommandType.Text; this._commandCollection[1] = new global::System.Data.SqlClient.SqlCommand(); this._commandCollection[1].Connection = this.Connection; diff --git a/MapoDb/DataLayer.cs b/MapoDb/DataLayer.cs index a0cf7804..8e520f82 100644 --- a/MapoDb/DataLayer.cs +++ b/MapoDb/DataLayer.cs @@ -1170,7 +1170,7 @@ namespace MapoDb /// /// Effettua conferma prod macchina dell'intero periodo da confermare (ultima conferma - /// --> adesso) + /// --> dtEvent) /// /// idx macchina da confermare /// 0=periodo, 1 = giorno, 2 = turno @@ -1197,7 +1197,7 @@ namespace MapoDb /// /// Effettua conferma prod macchina dell'intero periodo da confermare (ultima conferma - /// --> adesso) + /// --> dtEvent) /// /// idx macchina da confermare /// 0=periodo, 1 = giorno, 2 = turno @@ -1660,26 +1660,45 @@ namespace MapoDb return resultList; } - /// Effettua force Start PODL [CurrProdStatus = 1] se fosse già in essere ODL + /// + /// Effettua force Start PODL [CurrProdStatus = 1] se fosse già in essere ODL /// collegato --> lascia aperto [CurrProdStatus = 2] se esistesse un ODL da altro PODL x /// diverso articolo/fase --> chiude vecchio x poi far partire nuovo [CurrProdStatus = 3] se /// fosse chiuso ODL collegato --> duplica PODL e poi avvia nuovo ODL [CurrProdStatus = 4] - /// se fosse già in essere ODL non collegato --> lascia aperto e collego macchina IDX PODL da processare - /// effettuare conferma qty STEP x cui arrotondare la - /// quantità prox ODL (corrente come riferimento) - public string ForceStartPOdl(string idxMacchina, int idxPODL, bool doConfirm) + /// se fosse già in essere ODL non collegato --> lascia aperto e collego + /// + /// macchina + /// IDX PODL da processare + /// effettuare conferma qty + /// data-ora di avvio (opzionale) + /// data-ora attuale (opzionale) + /// + public string ForceStartPOdl(string idxMacchina, int idxPODL, bool doConfirm, string dtEve = "", string dtCurr = "") { string answ = "KO"; int CurrProdStatus = 0; string sIdxODL = ""; - string redKey = vetoForceStartPOdlMaccHash(idxMacchina); - // verifico NON CI SIA un veto altre chiamate (es split...) - 30 sec di default... - string rawData = memLayer.ML.getRSV(redKey); - if (string.IsNullOrEmpty(rawData)) + // Verifica se evento realtime oppure ho data specificata x processing @dtEve + DateTime dtEvent = DateTime.Now; + bool rtimeProc = string.IsNullOrEmpty(dtEve); + if (!rtimeProc) { + dtEvent = getSrvDtEvent(dtEve, dtCurr); + } + + // verifico NON CI SIA un veto altre chiamate (es split...) - 30 sec di default... + string redKey = vetoForceStartPOdlMaccHash(idxMacchina); + string rawData = memLayer.ML.getRSV(redKey); + if (!string.IsNullOrEmpty(rawData)) + { + logger.lg.scriviLog($"VETO ATTIVO | Richiesto ForceStartPOdl per impianto {idxMacchina} | impossibile procedere"); + } + else + { + // determino veto: se realtime 30sec, altrimenti 1 soltanto + int vetoTtl = rtimeProc ? 30 : 1; // registro VETO x altre chiamate (es split...) 30sec - memLayer.ML.setRSV(redKey, $"Inizio FORCE START PODL: {idxPODL} | {DateTime.Now}", 30); + memLayer.ML.setRSV(redKey, $"Inizio FORCE START PODL: {idxPODL} | realtime: {rtimeProc} | dtEve: {dtEvent}", vetoTtl); // calcolo la qta da gestire int qtyConf = 0; if (doConfirm) @@ -1779,15 +1798,15 @@ namespace MapoDb break; case 2: - // eventuale chiusura vecchio ODL + // eventuale chiusura vecchio ODL, 5 sec prima... if (currODLData.Count > 0) { - doCloseCurrODL(idxMacchina, doConfirm, qtyConf, currODLData, DateTime.Now); + doCloseCurrODL(idxMacchina, doConfirm, qtyConf, currODLData, dtEvent.AddSeconds(-2)); } // avvio PODL: creo nuovo ODL da promessa ed associo - taODL.inizioSetupPromessa(idxPODL, MatrOpr, POdlRow.IdxMacchina, POdlRow.TCAssegnato, POdlRow.PzPallet, POdlRow.Note); - // fix (invio ) dati ODL - Thread.Sleep(1000); + taODL.inizioSetupPromessa(idxPODL, MatrOpr, POdlRow.IdxMacchina, POdlRow.TCAssegnato, POdlRow.PzPallet, POdlRow.Note, dtEvent); + // fix (invio ) dati ODL alla ,acchina tramite IOB + Thread.Sleep(200); answ = saveOdlData(idxMacchina, currODLData, reqPODLData); break; @@ -1796,7 +1815,7 @@ namespace MapoDb // eventuale chiusura vecchio ODL if (currODLData.Count > 0) { - doCloseCurrODL(idxMacchina, doConfirm, qtyConf, currODLData, DateTime.Now); + doCloseCurrODL(idxMacchina, doConfirm, qtyConf, currODLData, dtEvent.AddSeconds(-2)); } // duplico PODL... inserisco nuovo record... taPODL.insertQuery(POdlRow.KeyRichiesta, POdlRow.KeyBCode, true, POdlRow.CodArticolo, POdlRow.CodGruppo, POdlRow.IdxMacchina, POdlRow.NumPezzi, POdlRow.TCAssegnato, POdlRow.DueDate, POdlRow.Priorita, POdlRow.PzPallet, POdlRow.Note); @@ -1806,9 +1825,9 @@ namespace MapoDb var lastPodl = podlList.Where(x => x.KeyRichiesta == POdlRow.KeyRichiesta && x.IdxMacchina == POdlRow.IdxMacchina).OrderByDescending(x => x.idxPromessa).FirstOrDefault(); int newPODL = lastPodl != null ? lastPodl.idxPromessa : POdlRow.idxPromessa; // avvio (nuovo) PODL - taODL.inizioSetupPromessa(idxPODL, MatrOpr, POdlRow.IdxMacchina, POdlRow.TCAssegnato, POdlRow.PzPallet, POdlRow.Note); - // fix (invio ) dati ODL - Thread.Sleep(1000); + taODL.inizioSetupPromessa(idxPODL, MatrOpr, POdlRow.IdxMacchina, POdlRow.TCAssegnato, POdlRow.PzPallet, POdlRow.Note, dtEvent); + // fix (invio ) dati ODL alla ,acchina tramite IOB + Thread.Sleep(200); answ = saveOdlData(idxMacchina, currODLData, reqPODLData); break; @@ -1830,10 +1849,7 @@ namespace MapoDb logger.lg.scriviLog($"Eccezione in ForceStartPOdl{Environment.NewLine}{exc}", tipoLog.EXCEPTION); } } - else - { - logger.lg.scriviLog($"VETO ATTIVO | Richiesto ForceStartPOdl per impianto {idxMacchina} | impossibile procedere"); - } + return answ; } @@ -2373,16 +2389,56 @@ namespace MapoDb MapoDb connDb = new MapoDb(); // scrivo keep alive!!! (se necessario, altrimenti è in cache...) connDb.scriviKeepAlive(idxMacchina, DateTime.Now); - // 2017.09.14 trimmo eventualmente lo zero finale dalle date SE supera i millisecondi... - dtEve = dtEve.Length > 17 ? dtEve.Substring(0, 17) : dtEve; - dtCurr = dtCurr.Length > 17 ? dtCurr.Substring(0, 17) : dtCurr; // registro conteggio impiego chiamate REDIS if (memLayer.ML.CRB("IOB_RedEnab")) { saveCallRec("processFluxLog"); } string answ = ""; + DateTime dataOraEvento = getSrvDtEvent(dtEve, dtCurr); + // inizio processing vero e proprio INPUT... + if (idxMacchina != null && valore != null) + { + if (idxMacchina != "" && valore != "") + { + // 2020.01.31 nuovo OBJ + DataLayer man = new DataLayer(); + man.taFL.InsNew(idxMacchina, dataOraEvento, flux, valore, contatore); + // 2022.06.06 salvo su redis il valore ULTIMO del flux x recupero rapido ultimo valore + string key = DataLayer.LiveFLogKeyHash(idxMacchina, flux); + // 10 min cache max... + int ttlFlog = 60 * 10; + memLayer.ML.setRSV(key, valore, ttlFlog); + // registro in risposta che è andato tutto bene... + answ = "OK"; + } + else + { + string errore = "processFluxLog | Errore: parametri macchina/valore vuoti"; + logger.lg.scriviLog(errore, tipoLog.INFO); + answ = errore; + } + } + else + { + string errore = "processFluxLog | Errore: mancano parametri macchina/valore"; + logger.lg.scriviLog(errore, tipoLog.INFO); + answ = errore; + } + return answ; + } + /// + /// Effettua calcolo data-ora di riferimento per il server a poartire da + /// + /// + /// + /// + private DateTime getSrvDtEvent(string dtEve, string dtCurr) + { DateTime dataOraEvento = DateTime.Now; + // 2017.09.14 trimmo eventualmente lo zero finale dalle date SE supera i millisecondi... + dtEve = dtEve.Length > 17 ? dtEve.Substring(0, 17) : dtEve; + dtCurr = dtCurr.Length > 17 ? dtCurr.Substring(0, 17) : dtCurr; DateTime dtEvento, dtCorrente; // controllo: se ho valori dt x evento e orario DIVERSI per acquisitore IOB calcolo // dataOraEvento corretto @@ -2415,39 +2471,14 @@ namespace MapoDb } catch (Exception exc) { - logger.lg.scriviLog(string.Format("processFluxLog | Errore calcolo ms evento/ora corrente da device remoto:{0}dtEve : {1}{0}dtCurr: {2}{0}{3}", Environment.NewLine, dtEve, dtCurr, exc), tipoLog.EXCEPTION); + logger.lg.scriviLog($"getSrvDtEvent | Errore calcolo ms evento/ora corrente da device remoto:{Environment.NewLine}" + + $"dtEve : {dtEve}{Environment.NewLine}" + + $"dtCurr: {dtCurr}{Environment.NewLine}" + + $"{exc}", tipoLog.EXCEPTION); } } - // inizio processing vero e proprio INPUT... - if (idxMacchina != null && valore != null) - { - if (idxMacchina != "" && valore != "") - { - // 2020.01.31 nuovo OBJ - DataLayer man = new DataLayer(); - man.taFL.InsNew(idxMacchina, dataOraEvento, flux, valore, contatore); - // 2022.06.06 salvo su redis il valore ULTIMO del flux x recupero rapido ultimo valore - string key = DataLayer.LiveFLogKeyHash(idxMacchina, flux); - // 10 min cache max... - int ttlFlog = 60 * 10; - memLayer.ML.setRSV(key, valore, ttlFlog); - // registro in risposta che è andato tutto bene... - answ = "OK"; - } - else - { - string errore = "processFluxLog | Errore: parametri macchina/valore vuoti"; - logger.lg.scriviLog(errore, tipoLog.INFO); - answ = errore; - } - } - else - { - string errore = "processFluxLog | Errore: mancano parametri macchina/valore"; - logger.lg.scriviLog(errore, tipoLog.INFO); - answ = errore; - } - return answ; + + return dataOraEvento; } /// @@ -4387,34 +4418,37 @@ namespace MapoDb } } - private bool doCloseCurrODL(string idxMacchina, bool doConfirm, int qtyConf, DS_ProdTempi.ODLDataTable currODLData, DateTime adesso) + private bool doCloseCurrODL(string idxMacchina, bool doConfirm, int qtyConf, DS_ProdTempi.ODLDataTable currODLData, DateTime dtEvento) { + DateTime adesso = DateTime.Now; bool fatto = false; - // registro un evento di inizio attrezzaggio (idxTipoEv = 2) + // registro un evento di attrezzaggio (idxTipoEv = 2) PRIMA di chiudere ODL int idxEvento = 2; - logger.lg.scriviLog($"Invio evento CHIUSURA ODL per macchina {idxMacchina}, evento {idxEvento}, articolo {currODLData[0].CodArticolo}, qty confermata {qtyConf}", tipoLog.INFO); + logger.lg.scriviLog($"Invio evento attrezzaggio x CHIUSURA ODL | idxMacc {idxMacchina} | idxEv {idxEvento} | CodArt {currODLData[0].CodArticolo} | qtyConf {qtyConf}", tipoLog.INFO); - // chiudo ALTRO ODL - inputComandoMapo resCmd = scriviRigaEventoBarcode(idxMacchina, idxEvento, currODLData[0].CodArticolo, "ODL-CLOSE", 0, "", adesso, adesso); + // invio un evento x messa in manuale macchina x attrezzaggio in chiusura + inputComandoMapo resCmd = scriviRigaEventoBarcode(idxMacchina, idxEvento, currODLData[0].CodArticolo, "ODL-CLOSE-ATTR", 0, "", dtEvento, adesso); if (doConfirm) { - // attendo 100 msec - Thread.Sleep(100); - adesso = DateTime.Now; + //// attendo 100 msec + //Thread.Sleep(100); + + // modifico la dataEvento + dtEvento.AddMilliseconds(200); // chiamo conferma produzione... try { string chiamata = confRett ? "confermaProdMacchinaFull" : "confermaProdMacchina"; - logger.lg.scriviLog($"Chiamata a {chiamata} con parametri {currODLData[0].IdxMacchina} |{MatrOpr} | {DateTime.Now.AddDays(-10)} | {DateTime.Now} | {qtyConf} | 0 | 1 | {DateTime.Now} | false", tipoLog.INFO); + logger.lg.scriviLog($"Chiamata a {chiamata} con parametri | IdxMacchina: {currODLData[0].IdxMacchina} | MatrOpr: {MatrOpr} | dtEvent {dtEvento} | {qtyConf} | modoConf: {memLayer.ML.CRI("modoConfProd")}", tipoLog.INFO); string idxMacchinaSel = currODLData[0].IdxMacchina; if (confRett) { // confermo al netto dei pezzi lasciati... - fatto = confermaProdMacchinaFull(idxMacchinaSel, memLayer.ML.CRI("modoConfProd"), qtyConf, 0, 0, adesso); + fatto = confermaProdMacchinaFull(idxMacchinaSel, memLayer.ML.CRI("modoConfProd"), qtyConf, 0, 0, dtEvento); } else { - fatto = confermaProdMacchina(idxMacchinaSel, memLayer.ML.CRI("modoConfProd"), qtyConf, 0, adesso); + fatto = confermaProdMacchina(idxMacchinaSel, memLayer.ML.CRI("modoConfProd"), qtyConf, 0, dtEvento); } if (!fatto) { @@ -4423,13 +4457,14 @@ namespace MapoDb } catch (Exception exc) { - logger.lg.scriviLog($"Eccezione in ConfermaProduzione{Environment.NewLine}{exc}", tipoLog.EXCEPTION); + logger.lg.scriviLog($"Eccezione in doCloseCurrODL{Environment.NewLine}{exc}", tipoLog.EXCEPTION); } } - // attendo 100 msec - Thread.Sleep(100); + //// attendo 100 msec + //Thread.Sleep(100); + dtEvento.AddMilliseconds(200); // chiamo chiusura - MapoDbObj.taODL.forceClose(currODLData[0].IdxODL, idxMacchina); + MapoDbObj.taODL.forceClose(currODLData[0].IdxODL, idxMacchina, dtEvento); // elimino eventuale ODL precedente... string rKey = memLayer.ML.redHash($"ODL:{idxMacchina}"); memLayer.ML.setRSV(rKey, ""); @@ -4543,7 +4578,7 @@ namespace MapoDb // attendo 1000 msec registro fine ODL (idxTipoEv = 1) int idxEvento = 1; logger.lg.scriviLog($"Invio evento ODL-forced start per macchina {idxMacchina}, evento {idxEvento}, articolo {currODLData[0].CodArticolo}", tipoLog.INFO); - var resCmd = scriviRigaEventoBarcode(idxMacchina, idxEvento, currODLData[0].CodArticolo, "ODL-FORFCE-START"); + var resCmd = scriviRigaEventoBarcode(idxMacchina, idxEvento, currODLData[0].CodArticolo, "ODL-FORCE-START"); // invio eventi setup a macchina.... string setArtVal = $"{currODLData[0].CodArticolo}"; string setPzCommVal = $"{reqPODLData[0].NumPezzi}";