From 28c2bc8cc80a14291d1646458e016a1bc3d31ae3 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 23 Sep 2025 19:29:43 +0200 Subject: [PATCH] Update x richeista ricalco,oBOM --- .../Services/CalcRequestService.cs | 83 +++++++++++++++++++ Lux.API/Controllers/GenericController.cs | 49 +++++++++-- Lux.API/Lux.API.csproj | 2 +- Lux.API/appsettings.Staging.json | 4 +- Lux.UI/Components/Compo/OfferRowMan.razor | 5 +- Lux.UI/Components/Compo/OfferRowMan.razor.cs | 36 +++++++- Lux.UI/Lux.UI.csproj | 4 +- Lux.UI/Program.cs | 1 + Lux.UI/appsettings.json | 2 + Resources/ChangeLog.html | 2 +- Resources/VersNum.txt | 2 +- Resources/manifest.xml | 2 +- 12 files changed, 173 insertions(+), 19 deletions(-) create mode 100644 EgwCoreLib.Lux.Data/Services/CalcRequestService.cs diff --git a/EgwCoreLib.Lux.Data/Services/CalcRequestService.cs b/EgwCoreLib.Lux.Data/Services/CalcRequestService.cs new file mode 100644 index 00000000..e74fb77f --- /dev/null +++ b/EgwCoreLib.Lux.Data/Services/CalcRequestService.cs @@ -0,0 +1,83 @@ +using Microsoft.Extensions.Configuration; +using Newtonsoft.Json; +using NLog; +using RestSharp; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace EgwCoreLib.Lux.Data.Services +{ + public class CalcRequestService + { + #region Public Constructors + + public CalcRequestService(IConfiguration config, IRedisService redisService) + { + _config = config; + _redisService = redisService; + bomChannel = _config.GetValue("ServerConf:BomChannel") ?? "bom"; + // verifico la url base + apiUrl = _config.GetValue("ServerConf:Prog.ApiUrl") ?? "https://iis01.egalware.com/lux/srv/api"; + routeBasePath = _config.GetValue("ServerConf:RouteBaseUrl") ?? "window"; + // fix opzioni base del RestClient + restOptStd = new RestClientOptions + { + Timeout = TimeSpan.FromSeconds(60), + BaseUrl = new Uri($"{apiUrl}/{routeBasePath}") + }; + Log.Info("ImageCache Service Started"); + } + + #endregion Public Constructors + + #region Public Methods + + /// + /// Effettua una generica chiamata ApiRest + /// + /// URL Api di base + /// Richiesta completa + /// Corpo Json trasmesso con richiesta + /// + public async Task CallRestPost(string ApiUrl, string ApiRequest, object rawBody) + { + RestResponse response; + // cerco online + using (RestClient client = new RestClient(ApiUrl)) + { + var request = new RestRequest(ApiRequest, Method.Post); + string rawData = JsonConvert.SerializeObject(rawBody); + request.AddJsonBody(rawData); + response = await client.ExecutePostAsync(request); + } + return response; + } + + #endregion Public Methods + + #region Private Fields + + private static Logger Log = LogManager.GetCurrentClassLogger(); + private readonly IRedisService _redisService; + private readonly string apiUrl = ""; + private readonly string bomChannel = "bomdev"; + private readonly string routeBasePath = ""; + private IConfiguration _config; + + #endregion Private Fields + + #region Private Properties + + /// + /// Conf client RestSharp standard: + /// - base URI al sito + /// - timeout 1 min + /// + private RestClientOptions restOptStd { get; set; } = new RestClientOptions(); + + #endregion Private Properties + } +} \ No newline at end of file diff --git a/Lux.API/Controllers/GenericController.cs b/Lux.API/Controllers/GenericController.cs index 2ea38ffa..9ff26c35 100644 --- a/Lux.API/Controllers/GenericController.cs +++ b/Lux.API/Controllers/GenericController.cs @@ -36,13 +36,7 @@ namespace Lux.API.Controllers { Stopwatch sw = new Stopwatch(); sw.Start(); - string svgContent = ""; - - // se contiene ".svg" lo levo... - if (id.EndsWith(".svg")) - { - id = id.Replace(".svg", ""); - } + string retVal = ""; // ...se ricevo percorso --> leggo jwd/svg cablato if (currReq != null) @@ -62,11 +56,48 @@ namespace Lux.API.Controllers QuestionDTO currArgs = new QuestionDTO(nId, currReq.EnvType, DictExec); await _redisService.PublishAsync(pubChannel, currArgs.sProcessArgs); - svgContent = "DONE"; + retVal = "DONE"; } sw.Stop(); Log.Info($"calcSvg | {sw.Elapsed.TotalMilliseconds:N3} ms"); - return Ok(svgContent); + return Ok(retVal); + } + + /// + /// Chiamata POST: riceve Json in formato JWD serializzato, invia richiesta calcolo modo 2 (BOM) + /// PUT: api/window/bom/00000000-0000-0000-0000-000000000000 + /// + /// id oggetto + /// + [HttpPost("bom/{id}")] + public async Task> getBom(string id, [FromBody] string currSer) + { + Stopwatch sw = new Stopwatch(); + sw.Start(); + string retVal = ""; + + // se messaggio vuoto --> uso default! + currSer = string.IsNullOrEmpty(currSer) ? "" : currSer; + + // ...se ricevo percorso --> leggo jwd/svg cablato + if (!string.IsNullOrEmpty(currSer)) + { + Dictionary DictExec = new Dictionary(); + // cablata la BOM + DictExec.Add("Mode", "2"); + // UID cablato x ora... + DictExec.Add("UID", id); + DictExec.Add("Jwd", currSer); + int nId = 1; + // da modificare con tipo richiesta... + QuestionDTO currArgs = new QuestionDTO(nId, EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS.WINDOW, DictExec); + + await _redisService.PublishAsync(pubChannel, currArgs.sProcessArgs); + retVal = "DONE"; + } + sw.Stop(); + Log.Info($"getBom | {sw.Elapsed.TotalMilliseconds:N3} ms"); + return Ok(retVal); } #endregion Public Methods diff --git a/Lux.API/Lux.API.csproj b/Lux.API/Lux.API.csproj index 47763ac3..ec598b55 100644 --- a/Lux.API/Lux.API.csproj +++ b/Lux.API/Lux.API.csproj @@ -4,7 +4,7 @@ net8.0 enable enable - 0.9.2509.2312 + 0.9.2509.2319 diff --git a/Lux.API/appsettings.Staging.json b/Lux.API/appsettings.Staging.json index 02f2251b..c294297e 100644 --- a/Lux.API/appsettings.Staging.json +++ b/Lux.API/appsettings.Staging.json @@ -7,7 +7,7 @@ }, "ServerConf": { "BaseUrl": "/lux/srv/", - "PubChannel": "EgwDevEngineInput", - "SubChannel": "EgwDevEngineOutput" + "PubChannel": "EgwEngineInput", + "SubChannel": "EgwEngineOutput" } } diff --git a/Lux.UI/Components/Compo/OfferRowMan.razor b/Lux.UI/Components/Compo/OfferRowMan.razor index a7e498f8..d1768cf1 100644 --- a/Lux.UI/Components/Compo/OfferRowMan.razor +++ b/Lux.UI/Components/Compo/OfferRowMan.razor @@ -74,7 +74,10 @@ else } - @item.OfferRowUID + + @item.OfferRowUID + + @item.Note @item.Qty diff --git a/Lux.UI/Components/Compo/OfferRowMan.razor.cs b/Lux.UI/Components/Compo/OfferRowMan.razor.cs index ec9a6bc4..64135f95 100644 --- a/Lux.UI/Components/Compo/OfferRowMan.razor.cs +++ b/Lux.UI/Components/Compo/OfferRowMan.razor.cs @@ -2,6 +2,7 @@ using EgwCoreLib.Lux.Core.RestPayload; using EgwCoreLib.Lux.Data; using EgwCoreLib.Lux.Data.DbModel.Sales; using EgwCoreLib.Lux.Data.Services; +using EgwMultiEngineManager.Data; using Microsoft.AspNetCore.Components; using Microsoft.JSInterop; using static EgwCoreLib.Lux.Core.Enums; @@ -87,6 +88,38 @@ namespace Lux.UI.Components.Compo await DoRecalcOffer(); } + /// + /// Lancia la richiesta di ricaolo della BOM dal JWD (o equivalente) + /// + /// + protected async Task RequestBom(OfferRowModel currRec) + { + if (!await JSRuntime.InvokeAsync("confirm", $"Confermi di voler ricalcolare la BOM?")) + return; + + // devo recuperare da ofgferta environment corrente, roa cablato + EgwMultiEngineManager.Data.Constants.EXECENVIRONMENTS currEnv = Constants.EXECENVIRONMENTS.WINDOW; + // preparo la domanda serializzata + Dictionary DictExec = new Dictionary(); + // cablata la BOM + DictExec.Add("Mode", "2"); + // UID cablato x ora... + DictExec.Add("UID", currRec.OfferRowUID); + DictExec.Add("Jwd", currRec.SerStruct); + + CalcRequestDTO req = new CalcRequestDTO() + { + EnvType = currEnv, + DictExec = DictExec + }; + + // chiamo la chiamata POST alla API, che manda la richiesta via REDIS + await CService.CallRestPost($"{apiUrl}/{genBasePath}", $"{calcTag}/{currRec.OfferRowUID}", req); + } + + [Inject] + protected CalcRequestService CService { get; set; } = null!; + #endregion Protected Methods #region Private Fields @@ -104,7 +137,8 @@ namespace Lux.UI.Components.Compo private OfferRowModel? EditRecord = null; private string imgBasePath = ""; - + private string genBasePath = "generic"; + private string calcTag = "calc"; private bool isLoading = false; private List ListRecords = new List(); diff --git a/Lux.UI/Lux.UI.csproj b/Lux.UI/Lux.UI.csproj index 44a1394d..e61d1a30 100644 --- a/Lux.UI/Lux.UI.csproj +++ b/Lux.UI/Lux.UI.csproj @@ -5,7 +5,7 @@ enable enable aspnet-Lux.UI-a758c101-a2f4-4e38-977d-1c4887dbbd50 - 0.9.2509.2312 + 0.9.2509.2319 @@ -17,7 +17,7 @@ - + diff --git a/Lux.UI/Program.cs b/Lux.UI/Program.cs index b2532041..3ebeafd5 100644 --- a/Lux.UI/Program.cs +++ b/Lux.UI/Program.cs @@ -63,6 +63,7 @@ builder.Services.AddSingleton(); // Aggiunta servizi specifici builder.Services.AddSingleton(); builder.Services.AddSingleton(); +builder.Services.AddSingleton(); var app = builder.Build(); diff --git a/Lux.UI/appsettings.json b/Lux.UI/appsettings.json index 4cc386fb..6b6e5cef 100644 --- a/Lux.UI/appsettings.json +++ b/Lux.UI/appsettings.json @@ -59,9 +59,11 @@ "ImageCalcTag": "svg-preview", "Prog.ApiUrl": "https://office.egalware.com/lux/srv/api", "ImageBaseUrl": "window", + "RouteBaseUrl": "window", "PubChannel": "EgwDevEngineInput", "SubChannel": "EgwDevEngineOutput", "SvgChannel": "svg:img", + "BomChannel": "bom", "BaseUrl": "/lux/ui/" } } diff --git a/Resources/ChangeLog.html b/Resources/ChangeLog.html index 39fc89ec..0cb3700a 100644 --- a/Resources/ChangeLog.html +++ b/Resources/ChangeLog.html @@ -1,6 +1,6 @@ LUX - Web Windows MES -

Versione: 0.9.2509.2312

+

Versione: 0.9.2509.2319


Note di rilascio:
  • diff --git a/Resources/VersNum.txt b/Resources/VersNum.txt index 9d1aeb92..e30f38e5 100644 --- a/Resources/VersNum.txt +++ b/Resources/VersNum.txt @@ -1 +1 @@ -0.9.2509.2312 +0.9.2509.2319 diff --git a/Resources/manifest.xml b/Resources/manifest.xml index 2f7d9c89..1647a7d6 100644 --- a/Resources/manifest.xml +++ b/Resources/manifest.xml @@ -1,6 +1,6 @@ - 0.9.2509.2312 + 0.9.2509.2319 http://nexus.steamware.net/repository/SWS/GPW/stable/GPW.UI.zip http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html false