From 3eca7da2e96504de397143e2f177e98a8f8fd8bc Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 16 Apr 2026 11:35:58 +0200 Subject: [PATCH] OK metodo PODLNext --- MP.Core/Utils.cs | 1 + MP.Data/Controllers/MpIocController.cs | 41 +++++- MP.IOC/Controllers/IOBController.cs | 176 +++++++++++++++++++++++++ MP.IOC/Data/MpDataService.cs | 33 +++++ MP.IOC/MP.IOC.csproj | 2 +- MP.IOC/Resources/ChangeLog.html | 2 +- MP.IOC/Resources/VersNum.txt | 2 +- MP.IOC/Resources/manifest.xml | 2 +- 8 files changed, 248 insertions(+), 11 deletions(-) diff --git a/MP.Core/Utils.cs b/MP.Core/Utils.cs index aa94c020..e2923703 100644 --- a/MP.Core/Utils.cs +++ b/MP.Core/Utils.cs @@ -62,6 +62,7 @@ namespace MP.Core public const string redisParetoFLKey = redisBaseAddr + "Cache:ParetoFL"; public const string redisPOdlByCodArt = redisXdlData + "POdlByCodArt"; + public const string redisPOdlByMaccArt = redisXdlData + "POdlByMaccArt"; public const string redisPOdlByOdl = redisXdlData + "POdlByOdl"; public const string redisPOdlByPOdl = redisXdlData + "POdlByPOdl"; public const string redisPOdlList = redisXdlData + "POdlList"; diff --git a/MP.Data/Controllers/MpIocController.cs b/MP.Data/Controllers/MpIocController.cs index 0272b937..872e3880 100644 --- a/MP.Data/Controllers/MpIocController.cs +++ b/MP.Data/Controllers/MpIocController.cs @@ -213,14 +213,14 @@ namespace MP.Data.Controllers var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina); var InizioStato = new SqlParameter("@InizioStato", inizioStato); var IdxStato = new SqlParameter("@IdxStato", idxStato); - var CodArticolo = new SqlParameter("@CodArticolo", codArt); + var CodArticolo = new SqlParameter("@codArticolo", codArt); var Value = new SqlParameter("@Value", value); var MatrOpr = new SqlParameter("@MatrOpr", matrOpr); var Pallet = new SqlParameter("@pallet", pallet); var result = dbCtx .Database - .ExecuteSqlRaw("exec dbo.stp_DDB_InsStatoBatch @IdxMacchina, @InizioStato, @IdxStato, @CodArticolo, @Value, @MatrOpr, @pallet", IdxMacchina, InizioStato, IdxStato, CodArticolo, Value, MatrOpr, Pallet); + .ExecuteSqlRaw("exec dbo.stp_DDB_InsStatoBatch @IdxMacchina, @InizioStato, @IdxStato, @codArticolo, @Value, @MatrOpr, @pallet", IdxMacchina, InizioStato, IdxStato, CodArticolo, Value, MatrOpr, Pallet); // indico eseguito! fatto = result > 0; @@ -804,11 +804,11 @@ namespace MP.Data.Controllers var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina); var DataInizio = new SqlParameter("@DataInizio", dataInizio); var DataFine = new SqlParameter("@DataFine", dataFine); - var CodArticolo = new SqlParameter("@CodArticolo", codArticolo); + var CodArticolo = new SqlParameter("@codArticolo", codArticolo); var result = dbCtx .Database - .ExecuteSqlRaw("EXEC stp_ODL_AutoDayGener @IdxMacchina, @DataInizio, @DataFine, @CodArticolo", IdxMacchina, DataInizio, DataFine, CodArticolo); + .ExecuteSqlRaw("EXEC stp_ODL_AutoDayGener @IdxMacchina, @DataInizio, @DataFine, @codArticolo", IdxMacchina, DataInizio, DataFine, CodArticolo); // indico eseguito! answ = result > 0; @@ -836,18 +836,18 @@ namespace MP.Data.Controllers var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina); var DataInizio = new SqlParameter("@DataInizio", dataInizio); var DataFine = new SqlParameter("@DataFine", dataFine); - var CodArticolo = new SqlParameter("@CodArticolo", codArticolo); + var CodArticolo = new SqlParameter("@codArticolo", codArticolo); var PzPODL = new SqlParameter("@PzPODL", pzPODL); var PzPallet = new SqlParameter("@PzPallet", pzPallet); var KeyRichiesta = new SqlParameter("@KeyRichiesta", keyRichiesta); var TCAssegnato = new SqlParameter("@TCAssegnato", tcAssegnato); - var CodGruppo = new SqlParameter("@CodGruppo", codGruppo); + var CodGruppo = new SqlParameter("@codGruppo", codGruppo); var FlgCreaPODL = new SqlParameter("@flgCreaPODL", flgCreaPODL); var FlgCheckTC = new SqlParameter("@flgCheckTC", flgCheckTC); var result = dbCtx .Database - .ExecuteSqlRaw("EXEC stp_ODL_AutoDayGenerFull @IdxMacchina, @DataInizio, @DataFine, @CodArticolo, @PzPODL, @PzPallet, @KeyRichiesta, @TCAssegnato, @CodGruppo, @flgCreaPODL, @flgCheckTC", IdxMacchina, DataInizio, DataFine, CodArticolo, PzPODL, PzPallet, KeyRichiesta, TCAssegnato, CodGruppo, FlgCreaPODL, FlgCheckTC); + .ExecuteSqlRaw("EXEC stp_ODL_AutoDayGenerFull @IdxMacchina, @DataInizio, @DataFine, @codArticolo, @PzPODL, @PzPallet, @KeyRichiesta, @TCAssegnato, @codGruppo, @flgCreaPODL, @flgCheckTC", IdxMacchina, DataInizio, DataFine, CodArticolo, PzPODL, PzPallet, KeyRichiesta, TCAssegnato, CodGruppo, FlgCreaPODL, FlgCheckTC); // indico eseguito! answ = result > 0; @@ -1019,6 +1019,33 @@ namespace MP.Data.Controllers return dbResult; } + /// + /// Recupero elenco PODL EXPL filtrati x macchina, articolo... + /// + /// + /// + /// + /// True = aperti (=senza ODL) + /// + public async Task> POdlGetByMaccArtAsync(string idxMacchina, string codArticolo, string codGruppo, bool onlyFree) + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + var pIdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina); + var pCodArticolo = new SqlParameter("@CodArticolo", codArticolo); + var pCodGruppo = new SqlParameter("@CodGruppo", codGruppo); + var pOnlyFree = new SqlParameter("@onlyFree", onlyFree); + + dbResult = await dbCtx + .DbSetPODLExp + .FromSqlRaw("EXEC stp_PODL_getByMaccArt @IdxMacchina, @CodArticolo, @CodGruppo, @onlyFree", pIdxMacchina, pCodArticolo, pCodGruppo, pOnlyFree) + .AsNoTracking() + .ToListAsync(); + } + return dbResult; + } + /// /// Effettua ricalcolo MSE x macchina indicata /// diff --git a/MP.IOC/Controllers/IOBController.cs b/MP.IOC/Controllers/IOBController.cs index 1b3180fa..33a019b7 100644 --- a/MP.IOC/Controllers/IOBController.cs +++ b/MP.IOC/Controllers/IOBController.cs @@ -622,6 +622,182 @@ namespace MP.IOC.Controllers return Ok(answ); } + ///// + ///// restituisce elenco parametri correnti come una List Json di oggetti objItem + ///// GET: IOB/getObjItems/SIMUL_03 + ///// + ///// ID dell'IOB + ///// + //[HttpGet("getObjItems/{id}")] + //public async Task GetObjItems(string id) + //{ + + // if (string.IsNullOrEmpty(id)) return BadRequest("Missing ID"); + // // Multi: gestione carattere "|" trasformato in "#" + // id = id.Replace("|", "#"); + + // string answ = ""; + + // // procedo a recuperare l'oggetto... + // List currParams = new List(); + // try + // { + // DataLayer DataLayerObj = new DataLayer(); + // // deserializzo + // currParams = DataLayerObj.getCurrObjItems(id); + // // se != null --> salvo! + // if (currParams != null) + // { + // answ = JsonConvert.SerializeObject(currParams); + // } + // } + // catch (Exception exc) + // { + // Log.Error($"Errore in GetObjItems{Environment.NewLine}{exc}"); + // return StatusCode(StatusCodes.Status500InternalServerError, "NO"); + // } + // return Ok(answ); + + //} + + ///// + ///// restituisce elenco parametri CHE RICHIEDONO scrittura su PLC come una List Json di + ///// oggetti objItem + ///// GET: IOB/getObjItems2Write/SIMUL_03 + ///// + ///// ID dell'IOB + ///// + + //[HttpGet("getObjItems2Write/{id}")] + //public async Task GetObjItems2Write(string id) + //{ + + // if (string.IsNullOrEmpty(id)) return BadRequest("Missing ID"); + // // Multi: gestione carattere "|" trasformato in "#" + // id = id.Replace("|", "#"); + + // string answ = ""; + + // // procedo a recuperare l'oggetto... + // List currParams = new List(); + // try + // { + // DataLayer DataLayerObj = new DataLayer(); + // // deserializzo + // currParams = DataLayerObj.getCurrObjItemsPendigWrite(id); + // // se != null --> salvo! + // if (currParams != null) + // { + // answ = JsonConvert.SerializeObject(currParams); + // } + // } + // catch (Exception exc) + // { + // Log.Error($"Errore in GetObjItems2Write{Environment.NewLine}{exc}"); + // return StatusCode(StatusCodes.Status500InternalServerError, "NO"); + // } + // return Ok(answ); + //} + + + /// + /// Recupera DATI PODL NEXT (=NON AVVIATI) x macchina: (copia di getCurrPODL) + /// + /// GET: IOB/getPOdlNext/SIMUL_03 + /// + /// id macchina, se "" mostra tutto + /// Json contenente lista oggetti PODL serializzati + + [HttpGet("getPOdlNext/{id}")] + public async Task GetPOdlNext(string id) + { + + if (string.IsNullOrEmpty(id)) return BadRequest("Missing ID"); + // Multi: gestione carattere "|" trasformato in "#" + id = id.Replace("|", "#"); + + string answ = ""; + try + { + // recupero dati macchina... + var elencoOdl = await DService.POdlGetByMaccArtAsync(id, "", "", true); + answ = JsonConvert.SerializeObject(elencoOdl); + } + catch (Exception exc) + { + Log.Error($"Errore in GetPOdlNext{Environment.NewLine}{exc}"); + return StatusCode(StatusCodes.Status500InternalServerError, "NO"); + } + return Ok(answ); + } + +#if false + /// + /// Recupera DATI PODL x macchina e codice PODL: + /// + /// GET: IOB/getPODL/SIMUL_03?idxPODL=123 + /// + /// + /// idx del PDL da avviare + /// Json contenente lista oggetti PODL serializzati + public string getPODL(string id, int idxPODL) + { + // attenzione! poiché nell'URL il carattere "#" viene filtrato ci aspettiamo il + // carattere "|" che poi trasformiamo ora in "#" + if (!string.IsNullOrEmpty(id)) + { + id = id.Replace("|", "#"); + } + string answ = ""; + + // init obj DataLayer + DataLayer DataLayerObj = new DataLayer(); + try + { + // recupero dati da chaive, ignorando info macchina... + var elencoOdl = DataLayerObj.taPODL.getByKey(idxPODL); + answ = JsonConvert.SerializeObject(elencoOdl); + } + catch + { } + return answ; + } + + /// + /// Recupera DATI PODL Running/Actual (AVVIATO e in corso) x macchina: + /// + /// GET: IOB/getPOdlAct/SIMUL_03 + /// + /// id macchina, se "" mostra tutto + /// Json contenente lista 1 oggetto PODL serializzato, se presente + public string getPOdlAct(string id) + { + // attenzione! poiché nell'URL il carattere "#" viene filtrato ci aspettiamo il + // carattere "|" che poi trasformiamo ora in "#" + if (!string.IsNullOrEmpty(id)) + { + id = id.Replace("|", "#"); + } + string answ = ""; + + // init obj DataLayer + DataLayer DataLayerObj = new DataLayer(); + try + { + // recupero IdxOdl corrente + string sIdxOdl = DataLayerObj.currODL(id); + int IdxOdl = 0; + int.TryParse(sIdxOdl, out IdxOdl); + // recupero Podl running x macchina ... + DS_ProdTempi.PromesseODLDataTable elencoOdl = DataLayerObj.taPODL.getByIdxOdl(IdxOdl); + answ = JsonConvert.SerializeObject(elencoOdl); + } + catch + { } + return answ; + } +#endif + /// /// Recupera TASK richiesto x macchina: /// GET: IOB/getOptPar/SIMUL_03 diff --git a/MP.IOC/Data/MpDataService.cs b/MP.IOC/Data/MpDataService.cs index 967a44d1..f828c45f 100644 --- a/MP.IOC/Data/MpDataService.cs +++ b/MP.IOC/Data/MpDataService.cs @@ -811,6 +811,39 @@ namespace MP.IOC.Data return result; } + public async Task> POdlGetByMaccArtAsync(string idxMacchina, string codArticolo, string codGruppo, bool onlyFree) + { + List result = new List(); + + var currKey = $"{Utils.redisPOdlByMaccArt}:{idxMacchina}"; + if (!string.IsNullOrEmpty(codArticolo)) + { + currKey += $":A{codArticolo}"; + } + if (!string.IsNullOrEmpty(codGruppo)) + { + currKey += $":G{codGruppo}"; + } + currKey += onlyFree ? $":FREE" : ":ALL"; + RedisValue rawData = await redisDb.StringGetAsync(currKey); + if (rawData.HasValue) + { + result = JsonConvert.DeserializeObject>($"{rawData}") ?? new(); + } + else + { + result = await IocDbController.POdlGetByMaccArtAsync(idxMacchina, codArticolo, codGruppo, onlyFree); + // serializzo e salvo... + rawData = JsonConvert.SerializeObject(result); + await redisDb.StringSetAsync(currKey, rawData, getRandTOut(redisLongTimeCache)); + } + if (result == null) + { + result = new List(); + } + return result; + } + /// /// Eliminazione di un dossier /// diff --git a/MP.IOC/MP.IOC.csproj b/MP.IOC/MP.IOC.csproj index cf93a95b..e0835f13 100644 --- a/MP.IOC/MP.IOC.csproj +++ b/MP.IOC/MP.IOC.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 6.16.2604.1610 + 6.16.2604.1611 diff --git a/MP.IOC/Resources/ChangeLog.html b/MP.IOC/Resources/ChangeLog.html index e35d2f7d..ec3380ca 100644 --- a/MP.IOC/Resources/ChangeLog.html +++ b/MP.IOC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MP-IOC -

Versione: 6.16.2604.1610

+

Versione: 6.16.2604.1611


Note di rilascio:
  • diff --git a/MP.IOC/Resources/VersNum.txt b/MP.IOC/Resources/VersNum.txt index 3f3d0380..e97957d1 100644 --- a/MP.IOC/Resources/VersNum.txt +++ b/MP.IOC/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2604.1610 +6.16.2604.1611 diff --git a/MP.IOC/Resources/manifest.xml b/MP.IOC/Resources/manifest.xml index 5e39598a..d75fd07c 100644 --- a/MP.IOC/Resources/manifest.xml +++ b/MP.IOC/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2604.1610 + 6.16.2604.1611 https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/MP.IOC.zip https://nexus.steamware.net/repository/SWS/MP-IOC/stable/LAST/ChangeLog.html false