diff --git a/MP.Core/Utils.cs b/MP.Core/Utils.cs
index 82b63f8d..e1c13b99 100644
--- a/MP.Core/Utils.cs
+++ b/MP.Core/Utils.cs
@@ -20,6 +20,8 @@ namespace MP.Core
public const string redisConfKey = redisBaseAddr + "Cache:Config";
+ public const string redisDecNumArtKey = redisBaseAddr + "Cache:DecNumArt";
+
public const string redisDossByMac = redisBaseAddr + "Cache:DossByMac";
public const string redisEventList = redisBaseAddr + "Cache:EventList";
diff --git a/MP.Data/Controllers/MpIocController.cs b/MP.Data/Controllers/MpIocController.cs
index c1e8d1ca..f0d5556b 100644
--- a/MP.Data/Controllers/MpIocController.cs
+++ b/MP.Data/Controllers/MpIocController.cs
@@ -2,6 +2,7 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using MP.Data.DbModels;
+using MP.Data.DbModels.Anag;
using NLog;
using System;
using System.Collections.Generic;
@@ -55,6 +56,28 @@ namespace MP.Data.Controllers
return fatto;
}
+ ///
+ /// Elenco tabella decodifica articoli / codice decimale
+ ///
+ /// Vuoto = tutti / Singolo CodArt
+ ///
+ public async Task> DecNumArtGetFiltAsync(string codArt = "")
+ {
+ List dbResult = new List();
+ using (var dbCtx = new MoonProContext(_configuration))
+ {
+ var query = dbCtx.DbSetDecNumArt
+ .AsNoTracking()
+ .AsQueryable();
+
+ if (!string.IsNullOrEmpty(codArt))
+ query = query.Where(x => x.CodArticolo == codArt);
+
+ dbResult = await query.ToListAsync();
+ }
+ return dbResult;
+ }
+
///
/// Elenco da tabella Config
///
@@ -65,10 +88,10 @@ namespace MP.Data.Controllers
using (var dbCtx = new MoonProContext(_configuration))
{
dbResult = dbCtx
- .DbSetConfig
- .AsNoTracking()
- .OrderBy(x => x.Chiave)
- .ToList();
+ .DbSetConfig
+ .AsNoTracking()
+ .OrderBy(x => x.Chiave)
+ .ToList();
}
return dbResult;
}
diff --git a/MP.IOC/Controllers/IOBController.cs b/MP.IOC/Controllers/IOBController.cs
index af325bda..723bd34e 100644
--- a/MP.IOC/Controllers/IOBController.cs
+++ b/MP.IOC/Controllers/IOBController.cs
@@ -32,7 +32,7 @@ namespace MP.IOC.Controllers
[HttpGet("addOptPar/{id}")]
public async Task AddOptPar(string id, string pName, string pValue)
{
- DService.ScriviKeepAlive(id, DateTime.Now);
+ await DService.ScriviKeepAliveAsync(id, DateTime.Now);
try
{
DService.AddOptPar4Machine(id, pName, pValue);
@@ -440,7 +440,7 @@ namespace MP.IOC.Controllers
id = id.Replace("|", "#");
string answ = "";
// scrivo keep alive!!! (se necessario, altrimenti è in cache...)
- DService.ScriviKeepAlive(id, DateTime.Now);
+ await DService.ScriviKeepAliveAsync(id, DateTime.Now);
try
{
// leggo da REDIS eventuale elenco task x macchina...
@@ -452,6 +452,109 @@ namespace MP.IOC.Controllers
return Ok(answ);
}
+
+ ///
+ /// Recupera ArtNum dato CodXdl (per impianti che accettano solo INT in scrittura):
+ /// GET: IOB/getArtNum/SIMUL_03?CodXdl=ABC123
+ ///
+ /// IdxMacchina (NON considerato)
+ /// CodXdl richiesto, se vuoto restituisce TUTTI i valori in tabella di decodifica
+ /// Json contenente le righe delle codifiche attive Articolo/Numero
+ [HttpGet("getArtNum/{id}")]
+ public async Task GetArtNum(string id, string CodArt = "")
+ {
+ // in realtà ID macchina non conterebbe...
+ if (string.IsNullOrEmpty(id)) return BadRequest("Missing ID");
+ // Multi: gestione carattere "|" trasformato in "#"
+ id = id.Replace("|", "#");
+ string answ = "";
+ try
+ {
+ await DService.ScriviKeepAliveAsync(id, DateTime.Now);
+ // leggo da REDIS eventuale elenco task x macchina...
+ Dictionary valori = await DService.GetArtNumAsync(CodArt);
+ answ = JsonConvert.SerializeObject(valori);
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Errore in GetArtNum{Environment.NewLine}{exc}");
+ return StatusCode(StatusCodes.Status500InternalServerError, "NO");
+ }
+ return Ok(answ);
+ }
+
+#if false
+ ///
+ /// Restituisce il valore dello stato di IDLE della macchina, quindi SOLO SE NON é in lavoro
+ /// e già convertito in minuti...
+ /// GET: IOB/getIdlePeriod/SIMUL_01
+ ///
+ ///
+ ///
+ [HttpGet("getIdlePeriod/{id}")]
+ public int GetIdlePeriod(string id)
+ {
+ // attenzione! poiché nell'URL il carattere "#" viene filtrato ci aspettiamo il
+ // carattere "|" che poi trasformiamo ora in "#"
+ id = id.Replace("|", "#");
+ int answ = 0;
+ DataLayer DataLayerObj = new DataLayer();
+ DS_applicazione.StatoMacchineDataTable currData = null;
+ // chiamo metodo redis/db...
+ try
+ {
+ currData = DataLayerObj.currSMTab(id);
+ if (currData.Count > 0)
+ {
+ // recupero da redis elenco stati
+ DS_applicazione.AnagraficaStatiDataTable anagStati = DataLayerObj.AnagraficaStati();
+ DS_applicazione.AnagraficaStatiRow currStato = anagStati.FindByIdxStato(currData[0].IdxStato);
+ // calcolo SE sia idle... OVVERO SEMAFORO NON VERDE!!!
+ if (currStato.Semaforo != "sVe")
+ {
+ // calcolo durata...
+ answ = (int)DateTime.Now.Subtract(currData[0].InizioStato).TotalMinutes;
+ }
+ }
+ }
+ catch (Exception exc)
+ {
+ logger.lg.scriviLog($"Eccezione in recupero getIdlePeriod{Environment.NewLine}{exc}", tipoLog.EXCEPTION);
+ }
+ return answ;
+ }
+
+ ///
+ /// Recupera codice numerico ODL/PODL dato CodXdl, in pratica la parte finale SENZA ODL/PODL
+ /// Funzione per impianti che accettano solo INT in scrittura:
+ ///
+ /// GET: IOB/getXdlNum/SIMUL_03?CodXdl=ODL00000123
+ ///
+ /// IdxMacchina (NON considerato)
+ ///
+ /// CodXdl richiesto, se vuoto restituisce TUTTI i valori in tabella di decodifica
+ ///
+ /// SINGOLO VALORE calcolato on the fly
+ [HttpGet("getXdlNum/{id}")]
+ public string GetXdlNum(string id, string CodXdl = "")
+ {
+ // in realtà ID macchina non conta e lo ignoriamo...
+ string answ = "";
+ // scrivo keep alive!!! (se necessario, altrimenti è in cache...)
+ MapoDb.MapoDb connDb = new MapoDb.MapoDb();
+ DataLayer DataLayerObj = new DataLayer();
+ connDb.scriviKeepAlive(id, DateTime.Now);
+ try
+ {
+ // sostituisco PODL/ODL con "" e lascio zero iniziali (conversione INT in IOB)
+ answ = CodXdl.Replace("PODL", "").Replace("ODL", "");
+ }
+ catch
+ { }
+ return answ;
+ }
+#endif
+
///
/// Recupera TASK richiesto x macchina:
/// GET: IOB/getTask2Exe/SIMUL_03
@@ -468,7 +571,7 @@ namespace MP.IOC.Controllers
string answ = "";
try
{
- DService.ScriviKeepAlive(id, DateTime.Now);
+ await DService.ScriviKeepAliveAsync(id, DateTime.Now);
// leggo da REDIS eventuale elenco task x macchina...
Dictionary valori = await DService.GetTask2ExeMacchinaAsync(id);
answ = JsonConvert.SerializeObject(valori);
diff --git a/MP.IOC/Data/MpDataService.cs b/MP.IOC/Data/MpDataService.cs
index 96983526..e1d014d8 100644
--- a/MP.IOC/Data/MpDataService.cs
+++ b/MP.IOC/Data/MpDataService.cs
@@ -3,6 +3,7 @@ using MP.Core.DTO;
using MP.Core.Objects;
using MP.Data;
using MP.Data.DbModels;
+using MP.Data.DbModels.Anag;
using MP.Data.MgModels;
using Newtonsoft.Json;
using NLog;
@@ -687,6 +688,27 @@ namespace MP.IOC.Data
return result;
}
+ public async Task> DecNumArtGetFiltAsync(string codArt = "")
+ {
+ List result = new();
+ string tag = string.IsNullOrEmpty(codArt) ? "ALL" : codArt;
+ string currKey = $"{Utils.redisDecNumArtKey}:{tag}";
+ // cerco in redis dato valore sel macchina...
+ RedisValue rawData = await redisDb.StringGetAsync(currKey);
+ if (rawData.HasValue)
+ {
+ result = JsonConvert.DeserializeObject>($"{rawData}") ?? new();
+ }
+ else
+ {
+ result = await IocDbController.DecNumArtGetFiltAsync(codArt);
+ // serializzo e salvo...
+ rawData = JsonConvert.SerializeObject(result);
+ redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache));
+ }
+ return result;
+ }
+
///
/// Dispose del connettore ai dati
///
@@ -3593,6 +3615,28 @@ namespace MP.IOC.Data
#endregion Public Methods
+ #region Internal Methods
+
+ ///
+ /// Recupera ArtNum dato CodArt (per impianti che accettano solo INT in scrittura)
+ ///
+ ///
+ /// CodArt richiesto, se vuoto restituisce TUTTI i valori in tabella di decodifica
+ ///
+ /// Dizionario contenente le righe delle codifiche attive Articolo/Numero
+ internal async Task> GetArtNumAsync(string codArt)
+ {
+ Dictionary answ = new Dictionary();
+ var currData = await DecNumArtGetFiltAsync(codArt);
+ foreach (var item in currData)
+ {
+ answ.Add(item.CodArticolo, item.NumART);
+ }
+ return answ;
+ }
+
+ #endregion Internal Methods
+
#region Protected Fields
protected Random rand = new Random();
diff --git a/MP.IOC/MP.IOC.csproj b/MP.IOC/MP.IOC.csproj
index f6a5e0de..f56c5055 100644
--- a/MP.IOC/MP.IOC.csproj
+++ b/MP.IOC/MP.IOC.csproj
@@ -4,7 +4,7 @@
net8.0
enable
enable
- 6.16.2604.1517
+ 6.16.2604.1518
diff --git a/MP.IOC/Resources/ChangeLog.html b/MP.IOC/Resources/ChangeLog.html
index 5b1014d6..535ddd74 100644
--- a/MP.IOC/Resources/ChangeLog.html
+++ b/MP.IOC/Resources/ChangeLog.html
@@ -1,6 +1,6 @@
Modulo MP-IOC
- Versione: 6.16.2604.1517
+ Versione: 6.16.2604.1518
Note di rilascio:
-
diff --git a/MP.IOC/Resources/VersNum.txt b/MP.IOC/Resources/VersNum.txt
index 9cef419a..ce7763f1 100644
--- a/MP.IOC/Resources/VersNum.txt
+++ b/MP.IOC/Resources/VersNum.txt
@@ -1 +1 @@
-6.16.2604.1517
+6.16.2604.1518
diff --git a/MP.IOC/Resources/manifest.xml b/MP.IOC/Resources/manifest.xml
index 71938dea..3a14dabf 100644
--- a/MP.IOC/Resources/manifest.xml
+++ b/MP.IOC/Resources/manifest.xml
@@ -1,6 +1,6 @@
-
- 6.16.2604.1517
+ 6.16.2604.1518
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