From 7dd060a493e2bbd271f49dcd8b3b00d45d6810ae Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 23 Jan 2026 17:21:49 +0100 Subject: [PATCH] update x salvataggio ritorno BOM in stima ODL --- .../Controllers/LuxController.cs | 131 +++++++++++------- .../DbModel/Production/ProductionODLModel.cs | 28 +++- .../Services/DataLayerServices.cs | 33 ++++- Lux.API/Lux.API.csproj | 2 +- Lux.API/Services/ExternalMessageProcessor.cs | 12 +- Resources/ChangeLog.html | 2 +- Resources/VersNum.txt | 2 +- Resources/manifest.xml | 2 +- 8 files changed, 155 insertions(+), 57 deletions(-) diff --git a/EgwCoreLib.Lux.Data/Controllers/LuxController.cs b/EgwCoreLib.Lux.Data/Controllers/LuxController.cs index 0cebee48..5f4c2fbd 100644 --- a/EgwCoreLib.Lux.Data/Controllers/LuxController.cs +++ b/EgwCoreLib.Lux.Data/Controllers/LuxController.cs @@ -3844,6 +3844,90 @@ namespace EgwCoreLib.Lux.Data.Controllers return numItem; } + /// + /// Elenco PODL non assegnati con struttura DTO appiattita + /// + /// + internal async Task?> ProdOdlAssignGetAsync() + { + List? dbResults = null; + //using (DataLayerContext dbCtx = new DataLayerContext(_config)) + using (DataLayerContext dbCtx = new DataLayerContext()) + { + try + { + dbResults = await dbCtx.DbSetProdODL + .Where(x => !x.DateAssign.HasValue) + .Select(odl => new OdlAssignDto + { + Envir = odl.ProdBatchNav.Envir, + ProdODLID = odl.ProdODLID, + Description = odl.Description, + EstimTime = odl.EstimTime, + Index = odl.Index, + OdlTag = odl.OdlTag, + PhaseID = odl.PhaseID, + ProdBatchID = odl.ProdBatchID, + ProdPlantCod = odl.ProdPlantCod, + Qty = odl.Qty, + ResourceID = odl.ResourceID, + ItemList = odl.Item2OdlNav.Select(i => new ItemAssignDto + { + ProdItemID = i.ProdItemID, + OrderID = i.ProductionItemNav.OrderRowNav.OrderNav.OrderID, + OrderRowID = i.ProductionItemNav.OrderRowNav.OrderRowID, + OrderTag = i.ProductionItemNav.OrderRowNav.OrderNav.OrderCode, + OrderRowTag = i.ProductionItemNav.OrderRowNav.OrderRowCode, + ProdItemTag = i.ProductionItemNav.ProdItemTag ?? "***" + }).ToList() + }) + .ToListAsync(); + } + catch (Exception exc) + { + Log.Error($"Eccezione durante ProductionOdlUnassignAsync{Environment.NewLine}{exc}"); + } + } + return dbResults; + } + + /// + /// Aggiorna record ProdOdl (se trovato) con BOM (raw) ricevuta + /// + /// + /// + /// + internal async Task ProdOdlUpdateBomAsync(string uID, string bomRaw) + { + bool answ = false; + //using (DataLayerContext dbCtx = new DataLayerContext(_config)) + using (DataLayerContext dbCtx = new DataLayerContext()) + { + try + { + var currRec = dbCtx + .DbSetProdODL + .Where(x => x.OdlTag == uID) + .FirstOrDefault(); + // se trovato --> salvo BOM e calcolo costi + if (currRec != null) + { + currRec.RawBoM = bomRaw; + dbCtx.Entry(currRec).State = EntityState.Modified; + } + + // salvo... + var result = dbCtx.SaveChanges(); + answ = result > 0; + } + catch (Exception exc) + { + Log.Error($"Eccezione durante ProdOdlUpdateBomAsync{Environment.NewLine}{exc}"); + } + } + return answ; + } + internal async Task> ProdPlantGetAllAsync() { List dbResult = new List(); @@ -3976,53 +4060,6 @@ namespace EgwCoreLib.Lux.Data.Controllers return dbRestults; } - /// - /// Elenco PODL non assegnati con struttura DTO appiattita - /// - /// - internal async Task?> ProdOdlAssignGetAsync() - { - List? dbResults = null; - //using (DataLayerContext dbCtx = new DataLayerContext(_config)) - using (DataLayerContext dbCtx = new DataLayerContext()) - { - try - { - dbResults = await dbCtx.DbSetProdODL - .Where(x => !x.DateAssign.HasValue) - .Select(odl => new OdlAssignDto - { - Envir = odl.ProdBatchNav.Envir, - ProdODLID = odl.ProdODLID, - Description = odl.Description, - EstimTime = odl.EstimTime, - Index = odl.Index, - OdlTag = odl.OdlTag, - PhaseID = odl.PhaseID, - ProdBatchID = odl.ProdBatchID, - ProdPlantCod = odl.ProdPlantCod, - Qty = odl.Qty, - ResourceID = odl.ResourceID, - ItemList = odl.Item2OdlNav.Select(i => new ItemAssignDto - { - ProdItemID = i.ProdItemID, - OrderID = i.ProductionItemNav.OrderRowNav.OrderNav.OrderID, - OrderRowID = i.ProductionItemNav.OrderRowNav.OrderRowID, - OrderTag = i.ProductionItemNav.OrderRowNav.OrderNav.OrderCode, - OrderRowTag = i.ProductionItemNav.OrderRowNav.OrderRowCode, - ProdItemTag = i.ProductionItemNav.ProdItemTag ?? "***" - }).ToList() - }) - .ToListAsync(); - } - catch (Exception exc) - { - Log.Error($"Eccezione durante ProductionOdlUnassignAsync{Environment.NewLine}{exc}"); - } - } - return dbResults; - } - /// /// Eliminazione record /// diff --git a/EgwCoreLib.Lux.Data/DbModel/Production/ProductionODLModel.cs b/EgwCoreLib.Lux.Data/DbModel/Production/ProductionODLModel.cs index b21996a6..c68f3e53 100644 --- a/EgwCoreLib.Lux.Data/DbModel/Production/ProductionODLModel.cs +++ b/EgwCoreLib.Lux.Data/DbModel/Production/ProductionODLModel.cs @@ -1,5 +1,7 @@ -using EgwCoreLib.Lux.Data.DbModel.Cost; +using EgwCoreLib.Lux.Core.RestPayload; +using EgwCoreLib.Lux.Data.DbModel.Cost; using EgwCoreLib.Lux.Data.DbModel.Task; +using Newtonsoft.Json; using System; using System.Collections.Generic; using System.ComponentModel.DataAnnotations; @@ -99,6 +101,28 @@ namespace EgwCoreLib.Lux.Data.DbModel.Production /// public decimal WorkTime { get; set; } = 0; + /// + /// BOM serializzata per la produzione dell'intero ODL + /// + public string RawBoM { get; set; } = ""; + + /// + /// BOM in versione deserializzata + /// + [NotMapped] + public List ListBoM + { + get + { + List bomList = new List(); + if (!string.IsNullOrEmpty(RawBoM) && RawBoM.Length > 2) + { + bomList = JsonConvert.DeserializeObject>(RawBoM) ?? new List(); + } + return bomList; + } + } + /// /// Navigazione sui Batch /// @@ -122,6 +146,6 @@ namespace EgwCoreLib.Lux.Data.DbModel.Production /// /// Navigazione verso tabella Item2Odl /// - public ICollection Item2OdlNav { get; set; } = new List(); + public ICollection Item2OdlNav { get; set; } = new List(); } } diff --git a/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs b/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs index b02a3402..acbd6451 100644 --- a/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs +++ b/EgwCoreLib.Lux.Data/Services/DataLayerServices.cs @@ -2309,10 +2309,11 @@ namespace EgwCoreLib.Lux.Data.Services /// Esegue salvataggio BOM sul DB /// /// UID dell'item offerta di cui si è ricevuto la BOM + /// Mode della chiamata (x decidere cosa/dove salvare) /// Environment dell'item /// BOM serializzata /// - public async Task SaveBomAsync(string uID, Constants.EXECENVIRONMENTS execEnvironment, string bomContent) + public async Task SaveBomAsync(string uID, Egw.Window.Data.Enums.QuestionModes qMode, Constants.EXECENVIRONMENTS execEnvironment, string bomContent) { // salvo sul DB il risultato della BOM if (!string.IsNullOrEmpty(bomContent)) @@ -2328,8 +2329,34 @@ namespace EgwCoreLib.Lux.Data.Services { // verifico 1:1 gli item ricevuti dalla BOM sul DB con eventuale insert in anagrafica dei nuovi dbController.ItemUpsertFromBom(bomList); - // salvo la BOM nel record del DB relativo all'oggetto richiesto - dbController.OfferUpsertFromBom(uID, bomList); + // se mode = 2 è offerta, se 5 = ODL... + switch (qMode) + { + case Egw.Window.Data.Enums.QuestionModes.NULL: + break; + case Egw.Window.Data.Enums.QuestionModes.PREVIEW: + break; + + // BOM in offerta + case Egw.Window.Data.Enums.QuestionModes.BOM: + // salvo la BOM nel record Offer del DB relativo all'oggetto richiesto + dbController.OfferUpsertFromBom(uID, bomList); + break; + + case Egw.Window.Data.Enums.QuestionModes.HARDWARE: + break; + case Egw.Window.Data.Enums.QuestionModes.CONFIG: + break; + + // BOM in ODL + case Egw.Window.Data.Enums.QuestionModes.ORDER: + // salvo la BOM nel record Offer del DB relativo all'oggetto richiesto + await dbController.ProdOdlUpdateBomAsync(uID, bomContent); + break; + + default: + break; + } } } await Task.Delay(1); diff --git a/Lux.API/Lux.API.csproj b/Lux.API/Lux.API.csproj index 1b553c92..ac57bdcb 100644 --- a/Lux.API/Lux.API.csproj +++ b/Lux.API/Lux.API.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 1.1.2601.2316 + 1.1.2601.2317 diff --git a/Lux.API/Services/ExternalMessageProcessor.cs b/Lux.API/Services/ExternalMessageProcessor.cs index 9c37895a..005c4964 100644 --- a/Lux.API/Services/ExternalMessageProcessor.cs +++ b/Lux.API/Services/ExternalMessageProcessor.cs @@ -105,6 +105,16 @@ namespace Lux.API.Services * ----------------------------------------*/ string UID = retData.Args["UID"]; string RUID = ""; + string sMode = retData.Args["Mode"]; + Egw.Window.Data.Enums.QuestionModes cMode = QuestionModes.NULL; + if (int.TryParse(sMode, out int iMode)) + { + bool modeValido = Enum.IsDefined(typeof(QuestionModes), iMode); + if (modeValido) + { + cMode = (QuestionModes)iMode; + } + } // gestione RUID if (retData.Args.ContainsKey("RUID")) @@ -145,7 +155,7 @@ namespace Lux.API.Services // salvo BOM ricevuta RAW in redis (cache) await cacheService.SaveBomAsync(UID, retData.ExecEnvironment, newBom); // salvo la BOM completa con i dati recuperati dal DB - await dbService.SaveBomAsync(UID, retData.ExecEnvironment, newBom); + await dbService.SaveBomAsync(UID, cMode, retData.ExecEnvironment, newBom); // reset cache redis... await cacheService.ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:Offers:*"); await cacheService.ExecFlushRedisPatternAsync((RedisValue)$"{redisBaseKey}:OfferRows:*"); diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index fd40e9fa..633cbb61 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ LUX - Web Windows MES -

Versione: 1.1.2601.2316

+

Versione: 1.1.2601.2317


Note di rilascio:
  • diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index f6cd1ace..fc601231 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -1.1.2601.2316 +1.1.2601.2317 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index 91c5e88b..ce4ca4a5 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 1.1.2601.2316 + 1.1.2601.2317 http://nexus.steamware.net/repository/SWS/GPW/stable/GPW.UI.zip http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html false