From 4d437374dda6f14e8866bb259d8f826e4e5295e3 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 29 Nov 2022 11:46:54 +0100 Subject: [PATCH] COmpletato import RegGIacenze (con test) --- MP-IO/Controllers/IOBController.cs | 32 ++- MP-IO/MP-IO.csproj | 4 + MP-IO/Web.config | 3 +- MagData/MagData.csproj | 6 + MagData/MagDataLayer.cs | 323 +++++++++++++++++------------ MapoSDK/Enums.cs | 7 +- MapoSDK/Objects.cs | 21 ++ 7 files changed, 252 insertions(+), 144 deletions(-) diff --git a/MP-IO/Controllers/IOBController.cs b/MP-IO/Controllers/IOBController.cs index 58649588..4345c377 100644 --- a/MP-IO/Controllers/IOBController.cs +++ b/MP-IO/Controllers/IOBController.cs @@ -1,4 +1,5 @@ -using MapoDb; +using MagData; +using MapoDb; using MapoSDK; using Newtonsoft.Json; using SteamWare; @@ -1251,6 +1252,7 @@ namespace MP_IO.Controllers if (content != "") { DataLayer DataLayerObj = new DataLayer(); + MagDataLayer DataLayerMagObj = new MagDataLayer(); // deserializzo come un dictionary generico di oggetti rawDataType/string List receivedData = new List(); // procedo a deserializzare in blocco l'oggetto... @@ -1273,7 +1275,6 @@ namespace MP_IO.Controllers { // per ora salvo su REDIS ultimo x tipo DataLayerObj.lastRawTrasfData = JsonConvert.SerializeObject(item.mesContent); - //DataLayerObj.lastRawTrasfData = item.mesContent; // !!! FixMe ToDo fare deserializzazione e salvataggio su MongoDB // salvataggio su tab RawTrasf su DB IS @@ -1281,15 +1282,36 @@ namespace MP_IO.Controllers // in base al tipo processo... switch (item.mesType) { - case rawTransfType.ND: - break; - case rawTransfType.IcoelBatch: break; case rawTransfType.IcoelVarInfo: break; + case rawTransfType.RegGiacenze: + // elenco ODL da svuotare preventivamente x insert... + List listOdl = new List(); + // processo scrittura giacenze... processo 1:1 record di RegGiacenze + List recData = new List(); + foreach (var singleRow in item.mesContent) + { + var listGiac = JsonConvert.DeserializeObject(singleRow.Value.ToString()); + recData.Add(listGiac); + if (!listOdl.Contains(listGiac.IdxODL)) + { + listOdl.Add(listGiac.IdxODL); + } + } + // svuoto le giacenze degli ODL oggetto di import... + bool fatto = DataLayerMagObj.resetRegGiacByOdl(listOdl); + if (fatto) + { + // invio x salvare + fatto = DataLayerMagObj.salvaRegGiac(recData); + } + break; + + case rawTransfType.ND: default: break; } diff --git a/MP-IO/MP-IO.csproj b/MP-IO/MP-IO.csproj index fdc7116a..c0d9166c 100644 --- a/MP-IO/MP-IO.csproj +++ b/MP-IO/MP-IO.csproj @@ -385,6 +385,10 @@ + + {973245E4-02C0-4ED1-A81B-1727C5F4CA59} + MagData + {4617a665-d6e3-4ceb-a689-ce2eecd45713} MapoDb diff --git a/MP-IO/Web.config b/MP-IO/Web.config index 290d86fe..695bcb77 100644 --- a/MP-IO/Web.config +++ b/MP-IO/Web.config @@ -35,7 +35,8 @@ - + + diff --git a/MagData/MagData.csproj b/MagData/MagData.csproj index 81bfb0d3..d8e4ece1 100644 --- a/MagData/MagData.csproj +++ b/MagData/MagData.csproj @@ -268,6 +268,12 @@ + + + {D07211B6-CF67-4C7F-8040-5B8C3B12BB4B} + MapoSDK + + diff --git a/MagData/MagDataLayer.cs b/MagData/MagDataLayer.cs index 4ca2d4e0..70e1456e 100644 --- a/MagData/MagDataLayer.cs +++ b/MagData/MagDataLayer.cs @@ -1,4 +1,5 @@ -using Newtonsoft.Json; +using MapoSDK; +using Newtonsoft.Json; using SteamWare.IO; using SteamWare.Reports; using System; @@ -239,141 +240,6 @@ namespace MagData #endregion Public Properties - #region Private Methods - - /// - /// Verifica esistenza record da NOME CODA stampa + tipoDoc + chiave... - /// - /// - /// - /// - /// - private bool checkDoc(string printQueue, tipoDocumento tipoDoc, string keyParam) - { - bool answ = false; - reportRichiesto tipoReport = reportRichiesto.ND; - - // se ho un TIPO DOC --> cerco - if (tipoDoc != tipoDocumento.docND) - { - //cerco in setup queueConf - var repConf = reportConfRedis.Find(a => a.name == $"{tipoDoc}"); - if (repConf != null) - { - try - { - tipoReport = (reportRichiesto)Enum.Parse(typeof(reportRichiesto), repConf.template.Replace(".rdlc", "")); - } - catch - { } - } - } - // se non trovato esplicitamente - if (tipoReport == reportRichiesto.ND) - { - //cerco in setup queueConf - var coda = queueConfRedis.Find(a => a.name == printQueue); - if (coda != null) - { - try - { - tipoReport = (reportRichiesto)Enum.Parse(typeof(reportRichiesto), coda.template.Replace(".rdlc", "")); - } - catch - { } - } - } - // ricerco! - switch (tipoReport) - { - case reportRichiesto.CartellinoFinitiOdette: - var tabFiniti = taCFOdette.GetData(keyParam); - answ = tabFiniti.Count > 0; - break; - - case reportRichiesto.CartellinoPedane: - var tabPedane = taCPed.GetData(keyParam); - answ = tabPedane.Count > 0; - break; - - case reportRichiesto.CartellinoSemilavorati: - var tabSemilav = taCSemil.GetData(keyParam); - answ = tabSemilav.Count > 0; - break; - - case reportRichiesto.ReportPackList: - var tabPackList = taRepPL.GetData(keyParam, false); - answ = tabPackList.Count > 0; - break; - - case reportRichiesto.ReportPackListFull: - var tabPackListFull = taRepPLFull.GetData(keyParam, false); - answ = tabPackListFull.Count > 0; - break; - - default: - break; - } - return answ; - } - - private void initTA() - { - // reports - taPJQ = new DS_ReportTableAdapters.PrintJobQueueTableAdapter(); - taCFOdette = new DS_ReportTableAdapters.stp_prt_CartellinoFinitiOdetteTableAdapter(); - taCPed = new DS_ReportTableAdapters.stp_prt_CartellinoPedaneTableAdapter(); - taCSemil = new DS_ReportTableAdapters.stp_prt_CartellinoSemilavoratiTableAdapter(); - taRepPL = new DS_ReportTableAdapters.stp_prt_ReportPackListTableAdapter(); - taRepPLFull = new DS_ReportTableAdapters.stp_prt_ReportPackListFullTableAdapter(); - - taAA = new DS_MagTableAdapters.AnagArtTableAdapter(); - taAA2C = new DS_MagTableAdapters.AnagArticoli2ClientiTableAdapter(); - taACF = new DS_MagTableAdapters.AnagClientiTableAdapter(); - taADC= new DS_MagTableAdapters.AnagDestinClientiTableAdapter(); - taEA2U = new DS_MagTableAdapters.ElencoAL2UDCTableAdapter(); - taEAL = new DS_MagTableAdapters.ElencoALTableAdapter(); - taEL = new DS_MagTableAdapters.ElencoLottiTableAdapter(); - taEP2Q = new DS_MagTableAdapters.Elencopost2QueueTableAdapter(); - taEUdc = new DS_MagTableAdapters.ElencoUdcTableAdapter(); - taODL = new DS_MagTableAdapters.ODLTableAdapter(); - taRegGia = new DS_MagTableAdapters.RegGiacenzeTableAdapter(); - - taEOL = new DS_PackListTableAdapters.ExtOrdersListTableAdapter(); - taOList = new DS_PackListTableAdapters.OrdersListTableAdapter(); - taPList = new DS_PackListTableAdapters.PackListTableAdapter(); - } - - private void setupConnString() - { - string connString = memLayer.ML.CRS("MagDataConnectionString"); - // reports - taPJQ.Connection.ConnectionString = connString; - taCFOdette.Connection.ConnectionString = connString; - taCPed.Connection.ConnectionString = connString; - taCSemil.Connection.ConnectionString = connString; - taRepPL.Connection.ConnectionString = connString; - taRepPLFull.Connection.ConnectionString = connString; - - taAA.Connection.ConnectionString = connString; - taAA2C.Connection.ConnectionString = connString; - taACF.Connection.ConnectionString = connString; - taADC.Connection.ConnectionString = connString; - taEA2U.Connection.ConnectionString = connString; - taEAL.Connection.ConnectionString = connString; - taEL.Connection.ConnectionString = connString; - taEP2Q.Connection.ConnectionString = connString; - taEUdc.Connection.ConnectionString = connString; - taODL.Connection.ConnectionString = connString; - taRegGia.Connection.ConnectionString = connString; - - taEOL.Connection.ConnectionString = connString; - taOList.Connection.ConnectionString = connString; - taPList.Connection.ConnectionString = connString; - } - - #endregion Private Methods - #region Public Methods /// @@ -504,11 +370,59 @@ namespace MagData return answ; } + /// + /// Esegue svuotamento giacenze dato elenco ODL... + /// + /// + /// + public bool resetRegGiacByOdl(List listODL) + { + bool fatto = false; + if (listODL.Count > 0) + { + foreach (var item in listODL) + { + taRegGia.DeleteByOdl(item); + fatto = true; + } + } + else + { + fatto = true; + } + return fatto; + } + + /// + /// Esegue salvataggio records giacenze... + /// + /// + /// + public bool salvaRegGiac(List listGiacenze) + { + bool fatto = false; + if (listGiacenze.Count > 0) + { + foreach (var item in listGiacenze) + { + taRegGia.InsertQuery(item.IdxODL, item.IdentRG, item.Product, item.Variety, item.Supplier, item.ExtDoc, item.DateRif, item.QtyTot, item.NumPack, item.Notes); + fatto = true; + } + } + else + { + fatto = true; + } + return fatto; + } + /// /// effettua la stampa di un documento /// /// Codice UNIVOCO del documento - /// stampante specifica (da postazione o std da web.config, a cura dell'utente + /// + /// stampante specifica (da postazione o std da web.config, a cura dell'utente + /// /// Tipo documento richiesto /// IP del chiamante /// @@ -539,5 +453,140 @@ namespace MagData } #endregion Public Methods + + #region Private Methods + + /// + /// Verifica esistenza record da NOME CODA stampa + tipoDoc + chiave... + /// + /// + /// + /// + /// + private bool checkDoc(string printQueue, tipoDocumento tipoDoc, string keyParam) + { + bool answ = false; + reportRichiesto tipoReport = reportRichiesto.ND; + + // se ho un TIPO DOC --> cerco + if (tipoDoc != tipoDocumento.docND) + { + //cerco in setup queueConf + var repConf = reportConfRedis.Find(a => a.name == $"{tipoDoc}"); + if (repConf != null) + { + try + { + tipoReport = (reportRichiesto)Enum.Parse(typeof(reportRichiesto), repConf.template.Replace(".rdlc", "")); + } + catch + { } + } + } + // se non trovato esplicitamente + if (tipoReport == reportRichiesto.ND) + { + //cerco in setup queueConf + var coda = queueConfRedis.Find(a => a.name == printQueue); + if (coda != null) + { + try + { + tipoReport = (reportRichiesto)Enum.Parse(typeof(reportRichiesto), coda.template.Replace(".rdlc", "")); + } + catch + { } + } + } + // ricerco! + switch (tipoReport) + { + case reportRichiesto.CartellinoFinitiOdette: + var tabFiniti = taCFOdette.GetData(keyParam); + answ = tabFiniti.Count > 0; + break; + + case reportRichiesto.CartellinoPedane: + var tabPedane = taCPed.GetData(keyParam); + answ = tabPedane.Count > 0; + break; + + case reportRichiesto.CartellinoSemilavorati: + var tabSemilav = taCSemil.GetData(keyParam); + answ = tabSemilav.Count > 0; + break; + + case reportRichiesto.ReportPackList: + var tabPackList = taRepPL.GetData(keyParam, false); + answ = tabPackList.Count > 0; + break; + + case reportRichiesto.ReportPackListFull: + var tabPackListFull = taRepPLFull.GetData(keyParam, false); + answ = tabPackListFull.Count > 0; + break; + + default: + break; + } + return answ; + } + + private void initTA() + { + // reports + taPJQ = new DS_ReportTableAdapters.PrintJobQueueTableAdapter(); + taCFOdette = new DS_ReportTableAdapters.stp_prt_CartellinoFinitiOdetteTableAdapter(); + taCPed = new DS_ReportTableAdapters.stp_prt_CartellinoPedaneTableAdapter(); + taCSemil = new DS_ReportTableAdapters.stp_prt_CartellinoSemilavoratiTableAdapter(); + taRepPL = new DS_ReportTableAdapters.stp_prt_ReportPackListTableAdapter(); + taRepPLFull = new DS_ReportTableAdapters.stp_prt_ReportPackListFullTableAdapter(); + + taAA = new DS_MagTableAdapters.AnagArtTableAdapter(); + taAA2C = new DS_MagTableAdapters.AnagArticoli2ClientiTableAdapter(); + taACF = new DS_MagTableAdapters.AnagClientiTableAdapter(); + taADC = new DS_MagTableAdapters.AnagDestinClientiTableAdapter(); + taEA2U = new DS_MagTableAdapters.ElencoAL2UDCTableAdapter(); + taEAL = new DS_MagTableAdapters.ElencoALTableAdapter(); + taEL = new DS_MagTableAdapters.ElencoLottiTableAdapter(); + taEP2Q = new DS_MagTableAdapters.Elencopost2QueueTableAdapter(); + taEUdc = new DS_MagTableAdapters.ElencoUdcTableAdapter(); + taODL = new DS_MagTableAdapters.ODLTableAdapter(); + taRegGia = new DS_MagTableAdapters.RegGiacenzeTableAdapter(); + + taEOL = new DS_PackListTableAdapters.ExtOrdersListTableAdapter(); + taOList = new DS_PackListTableAdapters.OrdersListTableAdapter(); + taPList = new DS_PackListTableAdapters.PackListTableAdapter(); + } + + private void setupConnString() + { + string connString = memLayer.ML.CRS("MagDataConnectionString"); + // reports + taPJQ.Connection.ConnectionString = connString; + taCFOdette.Connection.ConnectionString = connString; + taCPed.Connection.ConnectionString = connString; + taCSemil.Connection.ConnectionString = connString; + taRepPL.Connection.ConnectionString = connString; + taRepPLFull.Connection.ConnectionString = connString; + + taAA.Connection.ConnectionString = connString; + taAA2C.Connection.ConnectionString = connString; + taACF.Connection.ConnectionString = connString; + taADC.Connection.ConnectionString = connString; + taEA2U.Connection.ConnectionString = connString; + taEAL.Connection.ConnectionString = connString; + taEL.Connection.ConnectionString = connString; + taEP2Q.Connection.ConnectionString = connString; + taEUdc.Connection.ConnectionString = connString; + taODL.Connection.ConnectionString = connString; + taRegGia.Connection.ConnectionString = connString; + + taEOL.Connection.ConnectionString = connString; + taOList.Connection.ConnectionString = connString; + taPList.Connection.ConnectionString = connString; + } + + #endregion Private Methods } } \ No newline at end of file diff --git a/MapoSDK/Enums.cs b/MapoSDK/Enums.cs index 744e2006..d3e28016 100644 --- a/MapoSDK/Enums.cs +++ b/MapoSDK/Enums.cs @@ -197,7 +197,12 @@ namespace MapoSDK /// /// Icoel: Variety + layout info relative /// - IcoelVarInfo + IcoelVarInfo, + + /// + /// Info tipo tabella RegGiacenze (MAG) + /// + RegGiacenze } /// diff --git a/MapoSDK/Objects.cs b/MapoSDK/Objects.cs index f0ddf9e0..b86777f5 100644 --- a/MapoSDK/Objects.cs +++ b/MapoSDK/Objects.cs @@ -496,6 +496,27 @@ namespace MapoSDK #endregion Public Properties } + /// + /// Tracciato RegGiacenze x insert da IOB + /// + public class RegGiacenze + { + #region Public Properties + + public DateTime DateRif { get; set; } = DateTime.Today; + public string ExtDoc { get; set; } = ""; + public string IdentRG { get; set; } = ""; + public int IdxODL { get; set; } = 0; + public string Notes { get; set; } = ""; + public int NumPack { get; set; } = 0; + public string Product { get; set; } = ""; + public double QtyTot { get; set; } = 0; + public string Supplier { get; set; } = ""; + public string Variety { get; set; } = ""; + + #endregion Public Properties + } + public class StCheckOverride { #region Public Properties