diff --git a/MP.Core/Utils.cs b/MP.Core/Utils.cs
index e2923703..21ff1646 100644
--- a/MP.Core/Utils.cs
+++ b/MP.Core/Utils.cs
@@ -78,6 +78,7 @@ namespace MP.Core
public const string redisTipoArt = redisBaseAddr + "Cache:TipoArt";
+ public const string redisVetoSplitOdl = redisBaseAddr + "Cache:VetoOdlMacc";
public const string redisVocabolario = redisBaseAddr + "Cache:Vocabolario";
public const string redisXdlData = redisBaseAddr + "Cache:XDL:";
diff --git a/MP.Data/Controllers/MpIocController.cs b/MP.Data/Controllers/MpIocController.cs
index 2ad11b1d..192249ff 100644
--- a/MP.Data/Controllers/MpIocController.cs
+++ b/MP.Data/Controllers/MpIocController.cs
@@ -96,6 +96,140 @@ namespace MP.Data.Controllers
return dbResult;
}
+ ///
+ /// Apre in automatico un nuovo PODL/ODL chiudendo l'attuale (aperto)
+ ///
+ /// Idx ODL corrente
+ /// Matricola operatore
+ /// idx macchina da confermare
+ /// TempoCiclo richiesto in attrezzaggio
+ /// # pz pallet
+ /// note ODL
+ /// bool per avvio nuovo ODL (def: true)
+ /// Qty da produrre, deve essere >0
+ /// KeyRich esterno, se vuoto uso vecchia, se KIT sovrascritto con KeyKit
+ ///
+ public async Task AutoStartOdlAsync(int idxOdl, int MatrOpr, string idxMacchina, decimal tCRich, int pzPallet, string note, bool startNewOdl, int qtyRich, string keyRich)
+ {
+ bool answ = false;
+ try
+ {
+ using (var dbCtx = new MoonProContext(_configuration))
+ {
+ var IdxOdl = new SqlParameter("@idxOdl ", idxOdl);
+ var MatrApp = new SqlParameter("@MatrApp ", MatrOpr);
+ var IdxMacchina = new SqlParameter("@idxMacchina", idxMacchina);
+ var TCRich = new SqlParameter("@TCRichAttr", tCRich);
+ var PzPallet = new SqlParameter("@PzPallet", pzPallet);
+ var Note = new SqlParameter("@Note", note);
+ var StartNewOdl = new SqlParameter("@StartNewOdl", startNewOdl);
+ var QtyRich = new SqlParameter("@QtyRich", qtyRich);
+ var KeyRichiesta = new SqlParameter("@KeyRichiesta", keyRich);
+
+ var result = await dbCtx
+ .Database
+ .ExecuteSqlRawAsync("EXEC stp_ODL_AutoStart @idxOdl, @MatrApp, @idxMacchina, @TCRichAttr, @PzPallet, @Note, @StartNewOdl, @QtyRich, @KeyRichiesta", IdxOdl, MatrApp, IdxMacchina, TCRich, PzPallet, Note, StartNewOdl, QtyRich, KeyRichiesta);
+
+ // indico eseguito!
+ answ = result > 0;
+ }
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione in ConfermaProdMacchina:{Environment.NewLine}{exc}");
+ }
+ return answ;
+ }
+
+ ///
+ /// Effettua conferma prod macchina dell'intero periodo da confermare (ultima conferma - dtEvent)
+ ///
+ /// idx macchina da confermare
+ /// 0=periodo, 1 = giorno, 2 = turno
+ /// qta pezzi BUONI da confermare
+ /// qta pezzi SCARTO da confermare
+ /// DataOra in cui registrare approvazione
+ /// Matricola operatore
+ ///
+ public async Task ConfermaProdMacchinaAsync(string idxMacchina, int modoConfProd, int numPzConfermati, int numPzScarto, DateTime DataOraApp, int MatrOpr)
+ {
+ bool answ = false;
+ try
+ {
+ var rigaProd = await StatoProdMacchinaAsync(idxMacchina, DateTime.Now);
+ using (var dbCtx = new MoonProContext(_configuration))
+ {
+ var IdxMacchina = new SqlParameter("@idxMacchina", idxMacchina);
+ var MatrApp = new SqlParameter("@MatrApp ", MatrOpr);
+ var DataFrom = new SqlParameter("@dataFrom ", rigaProd.DataFrom);
+ var DataTo = new SqlParameter("@dataTo", DataOraApp);
+ var PezziConf = new SqlParameter("@pezziConf", numPzConfermati);
+ var PezziScar = new SqlParameter("@pezziScar", numPzScarto);
+ var TipoConf = new SqlParameter("@TipoConf", modoConfProd);
+ var DtOraApp = new SqlParameter("@DataOraApp", DataOraApp);
+ var TestConferma = new SqlParameter("@TestConferma", true);
+
+ var result = await dbCtx
+ .Database
+ .ExecuteSqlRawAsync("EXEC stp_ConfermaProduzCompleta @idxMacchina, @MatrApp, @dataFrom, @dataTo, @pezziConf, @pezziScar, @TipoConf, @DataOraApp, @TestConferma ", IdxMacchina, MatrApp, DataFrom, DataTo, PezziConf, PezziScar, TipoConf, DtOraApp, TestConferma);
+
+ // indico eseguito!
+ answ = result > 0;
+ }
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione in ConfermaProdMacchina:{Environment.NewLine}{exc}");
+ }
+ return answ;
+ }
+
+ ///
+ /// Effettua conferma prod macchina dell'intero periodo da confermare (ultima conferma - dtEvent)
+ ///
+ /// idx macchina da confermare
+ /// 0=periodo, 1 = giorno, 2 = turno
+ /// qta pezzi BUONI da confermare
+ /// qta pezzi LASCIATI da confermare
+ /// qta pezzi SCARTO da confermare
+ /// DataOra in cui registrare approvazione
+ /// Matricola operatore
+ ///
+ public async Task ConfermaProdMacchinaFullAsync(string idxMacchina, int modoConfProd, int numPzConfermati, int numPzLasciati, int numPzScarto, DateTime DataOraApp, int MatrOpr)
+ {
+ bool answ = false;
+ try
+ {
+ var rigaProd = await StatoProdMacchinaAsync(idxMacchina, DateTime.Now);
+ using (var dbCtx = new MoonProContext(_configuration))
+ {
+ var IdxMacchina = new SqlParameter("@idxMacchina", idxMacchina);
+ var MatrApp = new SqlParameter("@MatrApp ", MatrOpr);
+ var DataFrom = new SqlParameter("@dataFrom ", rigaProd.DataFrom);
+ var DataTo = new SqlParameter("@dataTo", DataOraApp);
+ var PezziConf = new SqlParameter("@pezziConf", numPzConfermati);
+ var PezziLasc = new SqlParameter("@pezziLasciati", numPzLasciati);
+ var PezziScar = new SqlParameter("@pezziScar", numPzScarto);
+ var TipoConf = new SqlParameter("@TipoConf", modoConfProd);
+ var DtOraApp = new SqlParameter("@DataOraApp", DataOraApp);
+ var TestConferma = new SqlParameter("@TestConferma", true);
+ var Force = new SqlParameter("@Force", false);
+
+ var result = await dbCtx
+ .Database
+ .ExecuteSqlRawAsync("EXEC stp_ConfermaProduzCompletaFull @idxMacchina, @MatrApp, @dataFrom, @dataTo, @pezziConf, @pezziLasciati, @pezziScar, @TipoConf, @DataOraApp, @TestConferma,@Force", IdxMacchina, MatrApp, DataFrom, DataTo, PezziConf, PezziLasc, PezziScar, TipoConf, DtOraApp, TestConferma, Force);
+
+ // indico eseguito!
+ answ = result > 0;
+ }
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione in ConfermaProdMacchinaAsync:{Environment.NewLine}{exc}");
+ }
+ return answ;
+ }
+
///
/// Record ConfFlux dato macchina (oppure tutti se vuoto)
///
@@ -326,6 +460,65 @@ namespace MP.Data.Controllers
}
return fatto;
}
+ ///
+ /// Fix ODL per macchine SLAVE
+ ///
+ ///
+ ///
+ ///
+ ///
+ public bool OdlFixMachineSlave(string idxMacchina, int numDayPrev, int doInsert)
+ {
+ bool fatto = false;
+ using (var dbCtx = new MoonProContext(_configuration))
+ {
+ try
+ {
+ var IdxMacc = new SqlParameter("@IdxMacchina", idxMacchina);
+ var NumDayPrev = new SqlParameter("@NumDayPrev", numDayPrev);
+ var DoInsert = new SqlParameter("@DoInsert", doInsert);
+ var result = dbCtx
+ .Database
+ .ExecuteSqlRaw("EXEC stp_ODL_fixMachineSlave @IdxMacchina, @NumDayPrev, @DoInsert", IdxMacc, NumDayPrev, DoInsert);
+ fatto = result != 0;
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione durante OdlFixMachineSlave{Environment.NewLine}{exc}");
+ }
+ }
+ return fatto;
+ }
+
+ ///
+ /// Fix ODL per macchine SLAVE Async
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task OdlFixMachineSlaveAsync(string idxMacchina, int numDayPrev, int doInsert)
+ {
+ bool fatto = false;
+ using (var dbCtx = new MoonProContext(_configuration))
+ {
+ try
+ {
+ var IdxMacc = new SqlParameter("@IdxMacchina", idxMacchina);
+ var NumDayPrev = new SqlParameter("@NumDayPrev", numDayPrev);
+ var DoInsert = new SqlParameter("@DoInsert", doInsert);
+ var result = await dbCtx
+ .Database
+ .ExecuteSqlRawAsync("EXEC stp_ODL_fixMachineSlave @IdxMacchina, @NumDayPrev, @DoInsert", IdxMacc, NumDayPrev, DoInsert);
+ fatto = result != 0;
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione durante OdlFixMachineSlaveAsync{Environment.NewLine}{exc}");
+ }
+ }
+ return fatto;
+ }
///
/// Chiamata x stored recupero FluxLog x macchina (first)
@@ -597,9 +790,9 @@ namespace MP.Data.Controllers
public List MacchineGetAll()
{
List dbResult = new List();
- using (MoonProContext localDbCtx = new MoonProContext(_configuration))
+ using (MoonProContext dbCtx = new MoonProContext(_configuration))
{
- dbResult = localDbCtx
+ dbResult = dbCtx
.DbSetMacchine
.ToList();
}
@@ -609,14 +802,25 @@ namespace MP.Data.Controllers
public MacchineModel? MacchineGetByIdx(string IdxMacchina)
{
MacchineModel dbResult = null;
- using (MoonProContext localDbCtx = new MoonProContext(_configuration))
+ using (MoonProContext dbCtx = new MoonProContext(_configuration))
{
- dbResult = localDbCtx
+ dbResult = dbCtx
.DbSetMacchine
.FirstOrDefault(x => x.IdxMacchina == IdxMacchina);
}
return dbResult;
}
+ public async Task MacchineGetByIdxAsync(string IdxMacchina)
+ {
+ MacchineModel dbResult = null;
+ using (MoonProContext dbCtx = new MoonProContext(_configuration))
+ {
+ dbResult = await dbCtx
+ .DbSetMacchine
+ .FirstOrDefaultAsync(x => x.IdxMacchina == IdxMacchina);
+ }
+ return dbResult;
+ }
///
/// Elenco da tabella Macchine
@@ -667,21 +871,21 @@ namespace MP.Data.Controllers
///
public bool MacchineUpsert(MacchineModel entity)
{
- using (MoonProContext localDbCtx = new MoonProContext(_configuration))
+ using (MoonProContext dbCtx = new MoonProContext(_configuration))
{
// Recuperiamo l'entità tracciata dal context
- var trackedEntity = localDbCtx.DbSetMacchine.FirstOrDefault(x => x.IdxMacchina == entity.IdxMacchina);
+ var trackedEntity = dbCtx.DbSetMacchine.FirstOrDefault(x => x.IdxMacchina == entity.IdxMacchina);
if (trackedEntity != null)
{
// Aggiorna i valori dell'entità tracciata con quelli della nuova
- localDbCtx.Entry(trackedEntity).CurrentValues.SetValues(entity);
+ dbCtx.Entry(trackedEntity).CurrentValues.SetValues(entity);
}
else
{
- localDbCtx.DbSetMacchine.Update(entity);
+ dbCtx.DbSetMacchine.Update(entity);
}
- return localDbCtx.SaveChanges() > 0;
+ return dbCtx.SaveChanges() > 0;
}
}
@@ -691,28 +895,29 @@ namespace MP.Data.Controllers
///
public async Task MacchineUpsertAsync(MacchineModel entity)
{
- using (MoonProContext localDbCtx = new MoonProContext(_configuration))
+ using (MoonProContext dbCtx = new MoonProContext(_configuration))
{
// Recuperiamo l'entità tracciata dal context
- var trackedEntity = await localDbCtx.DbSetMacchine.FirstOrDefaultAsync(x => x.IdxMacchina == entity.IdxMacchina);
+ var trackedEntity = await dbCtx.DbSetMacchine.FirstOrDefaultAsync(x => x.IdxMacchina == entity.IdxMacchina);
if (trackedEntity != null)
{
// Aggiorna i valori dell'entità tracciata con quelli della nuova
- localDbCtx.Entry(trackedEntity).CurrentValues.SetValues(entity);
+ dbCtx.Entry(trackedEntity).CurrentValues.SetValues(entity);
}
else
{
- localDbCtx.DbSetMacchine.Update(entity);
+ dbCtx.DbSetMacchine.Update(entity);
}
- return await localDbCtx.SaveChangesAsync() > 0;
+ bool fatto = await dbCtx.SaveChangesAsync() > 0;
+ return fatto;
}
}
///
/// Elenco da tabella Macchine
///
- ///
+ ///
///
public List MicroStatoMacchinaGetByIdxMacc(string IdxMacc)
{
@@ -727,6 +932,24 @@ namespace MP.Data.Controllers
return dbResult;
}
}
+ ///
+ /// Elenco da tabella Macchine
+ ///
+ ///
+ ///
+ public async Task> MicroStatoMacchinaGetByIdxMaccAsync(string IdxMacc)
+ {
+ List dbResult = new List();
+ using (var dbCtx = new MoonProContext(_configuration))
+ {
+ dbResult = await dbCtx
+ .DbSetMicroStatoMacc
+ .Where(x => x.IdxMacchina == IdxMacc)
+ .AsNoTracking()
+ .ToListAsync();
+ return dbResult;
+ }
+ }
///
/// Aggiornamento record Microstato macchina
@@ -1100,7 +1323,38 @@ namespace MP.Data.Controllers
}
catch (Exception exc)
{
- Log.Error($"Eccezione in RicalcMse:{Environment.NewLine}{exc}");
+ Log.Error($"Eccezione in RecalcMse:{Environment.NewLine}{exc}");
+ }
+ return answ;
+ }
+ ///
+ /// Effettua ricalcolo MSE x macchina indicata
+ ///
+ /// idx macchina da confermare
+ /// Num massimo secondi di "vecchiaia" del dato
+ ///
+ public async Task RecalcMseAsync(string idxMacchina, int maxAgeSec)
+ {
+ bool answ = false;
+ try
+ {
+ var rigaProd = await StatoProdMacchinaAsync(idxMacchina, DateTime.Now);
+ using (var dbCtx = new MoonProContext(_configuration))
+ {
+ var MaxAgeSec = new SqlParameter("@maxAgeSec ", maxAgeSec);
+ var IdxMacchina = new SqlParameter("@idxMacchina", idxMacchina);
+
+ var result = await dbCtx
+ .Database
+ .ExecuteSqlRawAsync("EXEC stp_MSE_recalc @maxAgeSec, @idxMacchina ", MaxAgeSec, IdxMacchina);
+
+ // indico eseguito!
+ answ = result > 0;
+ }
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione in RecalcMseAsync:{Environment.NewLine}{exc}");
}
return answ;
}
diff --git a/MP.IOC/Components/Compo/ParetoDetail.razor.cs b/MP.IOC/Components/Compo/ParetoDetail.razor.cs
index 45e46d93..65d47e7f 100644
--- a/MP.IOC/Components/Compo/ParetoDetail.razor.cs
+++ b/MP.IOC/Components/Compo/ParetoDetail.razor.cs
@@ -14,7 +14,7 @@ namespace MP.IOC.Components.Compo
public List ParetoList { get; set; } = null!;
[Parameter]
- public string Title { get; set; } = null!;
+ public string Title { get; set; } = "";
#endregion Public Properties
@@ -29,6 +29,11 @@ namespace MP.IOC.Components.Compo
{
grandTotal = 1;
}
+ if (_title != Title)
+ {
+ _title = Title;
+ currSelect = "";
+ }
UpdateTable();
}
@@ -44,15 +49,18 @@ namespace MP.IOC.Components.Compo
private string currSelect = "";
private double grandTotal = 1;
private List ListPaged = new();
-
private int numRecPage = 10;
-
private int pageNum = 1;
-
private int totalCount = 0;
#endregion Private Fields
+ #region Private Properties
+
+ private string _title { get; set; } = null!;
+
+ #endregion Private Properties
+
#region Private Methods
private string CheckSelect(string curKey)
diff --git a/MP.IOC/Components/Pages/CallStats.razor.cs b/MP.IOC/Components/Pages/CallStats.razor.cs
index d56668aa..08767393 100644
--- a/MP.IOC/Components/Pages/CallStats.razor.cs
+++ b/MP.IOC/Components/Pages/CallStats.razor.cs
@@ -127,6 +127,7 @@ namespace MP.IOC.Components.Pages
currTsId = $"TS_{reqKey}";
currTitle = $"Pareto | {reqKey}";
currData = ParetoDay[reqKey];
+ tsDataDetail = new();
}
}
diff --git a/MP.IOC/Controllers/IOBController.cs b/MP.IOC/Controllers/IOBController.cs
index 1c58ef23..e43f2633 100644
--- a/MP.IOC/Controllers/IOBController.cs
+++ b/MP.IOC/Controllers/IOBController.cs
@@ -326,6 +326,37 @@ namespace MP.IOC.Controllers
}
}
+ ///
+ /// Chiude ODL precedente ed avvia uno nuovo (duplicandolo e sitemando quantità RIMANENTE),
+ /// e CONFERMA produzione...
+ ///
+ /// GET: IOB/forceSplitOdl/SIMUL_03
+ ///
+ ///
+ /// Esito chiamata (OK/vuoto)
+
+ [HttpGet("forceSplitOdl/{id}")]
+ public async Task ForceSplitOdl(string id)
+ {
+ if (string.IsNullOrEmpty(id)) return BadRequest("Missing ID");
+
+ // Multi: gestione carattere "|" trasformato in "#"
+ id = id.Replace("|", "#");
+
+ string answ = "";
+
+ try
+ {
+ answ = await DService.AutoStartOdlAsync(id, true, true, 100, 0, "");
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Errore in ForceSplitOdl{Environment.NewLine}{exc}");
+ return StatusCode(StatusCodes.Status500InternalServerError, "NO");
+ }
+ return Ok(answ);
+ }
+
///
/// Recupera ArtNum dato CodXdl (per impianti che accettano solo INT in scrittura):
/// GET: IOB/getArtNum/SIMUL_03?CodXdl=ABC123
@@ -779,20 +810,19 @@ namespace MP.IOC.Controllers
// Multi: gestione carattere "|" trasformato in "#"
id = id.Replace("|", "#");
- string answ = "";
+ Dictionary valori = new();
try
{
await DService.ScriviKeepAliveAsync(id, DateTime.Now);
// leggo da REDIS eventuale elenco task x macchina...
- Dictionary valori = await DService.GetTask2ExeMacchinaAsync(id);
- answ = JsonConvert.SerializeObject(valori);
+ valori = await DService.GetTask2ExeMacchinaAsync(id);
}
catch (Exception exc)
{
Log.Error($"Errore in GetTask2Exe{Environment.NewLine}{exc}");
return StatusCode(StatusCodes.Status500InternalServerError, "NO");
}
- return Ok(answ);
+ return Ok(valori);
}
///
@@ -840,7 +870,7 @@ namespace MP.IOC.Controllers
if (string.IsNullOrEmpty(id)) return BadRequest("Missing ID");
string answ = "";
- if (cnt == null)
+ if (string.IsNullOrEmpty(cnt))
{
cnt = "0";
}
diff --git a/MP.IOC/Data/MpDataService.cs b/MP.IOC/Data/MpDataService.cs
index 434495af..58bfa36c 100644
--- a/MP.IOC/Data/MpDataService.cs
+++ b/MP.IOC/Data/MpDataService.cs
@@ -246,6 +246,70 @@ namespace MP.IOC.Data
return answ;
}
+ ///
+ /// Aggiunge un set di task x macchina all'elenco di quelli salvati (in modalità upsert)
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task AddTask4MacListAsync(string idxMacchina, Dictionary taskDict)
+ {
+ bool answ = false;
+ bool needSaveParams = false;
+ var currHash = Utils.RedKeyTask2ExeMacc(idxMacchina, MpIoNS);
+ var currSavedParHash = Utils.RedKeySavedTask2ExeMacc(idxMacchina, MpIoNS);
+ Dictionary currTask = new Dictionary();
+ Dictionary savedTask = new Dictionary();
+
+ // leggo valori attuali...
+ currTask = await mTaskMacchinaAsync(idxMacchina);
+ // verifico processing dei ricevuti
+ foreach (var item in taskDict)
+ {
+ if (currTask.ContainsKey($"{item.Key}"))
+ {
+ currTask[$"{item.Key}"] = item.Value;
+ }
+ else
+ {
+ currTask.Add($"{item.Key}", item.Value);
+ }
+ Log.Trace($"Task ADD | hash: {currHash} | idxMacchina: {idxMacchina} | taskKey: {item.Key} | taskVal: {item.Value}");
+
+ // verifico in base al tipo di tName se fare backup...
+ switch (item.Key)
+ {
+ case Enums.taskType.setArt:
+ case Enums.taskType.setComm:
+ case Enums.taskType.setPzComm:
+ case Enums.taskType.setProg:
+ // leggo tName SALVATI attuali...
+ savedTask = mSavedTaskMacchina(idxMacchina);
+ savedTask[item.Key.ToString()] = item.Value;
+ needSaveParams = true;
+ break;
+
+ case Enums.taskType.endProd:
+ // salvo un DICT vuoto x resettare
+ savedTask = new Dictionary();
+ needSaveParams = true;
+ break;
+
+ default:
+ break;
+ }
+ }
+ // salvo!
+ answ = await RedisSetHashDictAsync(currHash, currTask);
+
+ if (needSaveParams)
+ {
+ answ = await RedisSetHashDictAsync(currSavedParHash, savedTask);
+ }
+ return answ;
+ }
+
///
/// Insert record allarme
///
@@ -549,6 +613,308 @@ namespace MP.IOC.Data
return answ;
}
+ ///
+ /// Effettua split ODL
+ ///
+ /// macchina
+ /// effettuare conferma qty
+ /// imposta la qty prox ODL da ODL che si chiude
+ /// matricola operatore
+ /// Round Step quantità prox ODL (corrente come riferimento)
+ /// Cod ext da associare all'ODL
+ ///
+ public async Task AutoStartOdlAsync(string idxMacchina, bool doConfirm, bool qtyFromLast, int matrOpr, int roundStep = 100, string keyRichiesta = "")
+ {
+ string answ = "KO";
+ DateTime adesso = DateTime.Now;
+
+ // verifico NON CI SIA un veto a NUOVI split...
+ string redKey = $"{Utils.redisVetoSplitOdl}:{idxMacchina}";
+ var rawData = await redisDb.StringGetAsync(redKey);
+ if (rawData.HasValue)
+ {
+ Log.Info($"VETO ATTIVO | Richiesto forceSplitOdl per impianto {idxMacchina} | impossibile procedere");
+ }
+ else
+ {
+ // registro VETO x altri split... 5 minuti
+ await redisDb.StringSetAsync(redKey, $"Inizio SPLIT-ODL {adesso}", TimeSpan.FromMinutes(5));
+ // setup dati da config
+ bool confRett = false;
+ int modoConfProd = -1;
+ bool slaveConfirmPzProd = false;
+ var configData = await ConfigGetAllAsync();
+ if (configData != null)
+ {
+ var currRec = configData.FirstOrDefault(x => x.Chiave == "confRett");
+ if (currRec != null)
+ {
+ bool.TryParse(currRec.Valore, out confRett);
+ }
+ currRec = configData.FirstOrDefault(x => x.Chiave == "modoConfProd");
+ if (currRec != null)
+ {
+ int.TryParse(currRec.Valore, out modoConfProd);
+ }
+ currRec = configData.FirstOrDefault(x => x.Chiave == "SlaveConfirmPzProd");
+ if (currRec != null)
+ {
+ bool.TryParse(currRec.Valore, out slaveConfirmPzProd);
+ }
+ }
+ // calcolo la qta da gestire
+ int qtyConf = 0;
+ int qtyNew = 0;
+ int qtyScarto = 0;
+ if (doConfirm)
+ {
+ try
+ {
+ var rigaProd = await IocDbController.PezziProdMacchinaAsync(idxMacchina);
+ var statoProd = await IocDbController.StatoProdMacchinaAsync(idxMacchina, adesso);
+ qtyConf = rigaProd.pezziNonConfermati;
+ qtyScarto = statoProd.Pz2RecScarto;
+ // calcolo nuovi pezzi da confermare
+ if (qtyFromLast)
+ {
+ roundStep = roundStep == 0 ? 1 : roundStep;
+ double ratio = (double)qtyConf / roundStep;
+ qtyNew = (int)Math.Round(Math.Ceiling(ratio) * roundStep, 0);
+ }
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"AutoStartOdlAsync | Errore recupero pezzi da confermare | idxMacchina {idxMacchina}{Environment.NewLine}{exc}");
+ }
+ }
+
+ // chiamo metodo redis/db...
+ try
+ {
+ // recupero ODL corrente
+ var currData = await IocDbController.OdlCurrByMaccAsync(idxMacchina);
+ if (currData != null && currData.IdxOdl > 0)
+ {
+ // preparo var x master/slave
+ bool isMachMaster = await IobIsMasterAsync(idxMacchina);
+ List slaveList = new();
+ if (isMachMaster)
+ {
+ List allSlaveList = await IocDbController.Macchine2SlaveAsync();
+ slaveList = allSlaveList.Where(x => x.IdxMacchina == idxMacchina).ToList();
+ }
+
+ // registro un evento di inizio attrezzaggio (idxTipoEv = 2)
+ int idxEvento = 2;
+ Log.Info($"Invio evento ODL-SPLIT per macchina {idxMacchina} | ev: {idxEvento} | art: {currData.CodArticolo} | qty conf: {qtyConf} | sty sca: {qtyScarto} | new qty: {qtyNew}");
+
+ // creo evento
+ EventListModel newRecEv = new EventListModel()
+ {
+ CodArticolo = currData.CodArticolo,
+ IdxMacchina = idxMacchina,
+ IdxTipo = idxEvento,
+ InizioStato = adesso,
+ MatrOpr = matrOpr,
+ pallet = "",
+ Value = "ODL-SPLIT"
+ };
+ inputComandoMapo resCmd = await scriviRigaEventoBarcodeAsync(newRecEv);
+
+ // era 100, messo 50...
+ int wTime = 50;
+
+ // eventuale conferma produzione
+ if (doConfirm)
+ {
+ await Task.Delay(wTime);
+ adesso = DateTime.Now;
+ // chiamo conferma produzione...
+ try
+ {
+ string chiamata = confRett ? "confermaProdMacchinaFull" : "confermaProdMacchina";
+ Log.Info($"Chiamata a {chiamata} con parametri {currData.IdxMacchina} |{matrOpr} | {DateTime.Now.AddDays(-10)} | {DateTime.Now} | {qtyConf} | 0 | {qtyScarto} | {DateTime.Now} | false");
+ string idxMacchinaSel = currData.IdxMacchina;
+ bool fatto = false;
+ if (confRett)
+ {
+ // confermo al netto dei pezzi lasciati...
+ fatto = await IocDbController.ConfermaProdMacchinaFullAsync(idxMacchinaSel, modoConfProd, qtyConf, 0, qtyScarto, adesso, matrOpr);
+ if (slaveConfirmPzProd)
+ {
+ foreach (var machine in slaveList)
+ {
+ await IocDbController.ConfermaProdMacchinaFullAsync(machine.IdxMacchinaSlave, modoConfProd, qtyConf, 0, qtyScarto, adesso, matrOpr);
+ }
+ }
+ }
+ else
+ {
+ fatto = await IocDbController.ConfermaProdMacchinaAsync(idxMacchinaSel, modoConfProd, qtyConf, qtyScarto, adesso, matrOpr);
+ if (slaveConfirmPzProd)
+ {
+ foreach (var machine in slaveList)
+ {
+ await IocDbController.ConfermaProdMacchinaAsync(idxMacchinaSel, modoConfProd, qtyConf, qtyScarto, adesso, matrOpr);
+ }
+ }
+ }
+ if (!fatto)
+ {
+ Log.Error($"ERRORE in chiamata {chiamata}");
+ }
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione in ConfermaProduzione{Environment.NewLine}{exc}");
+ }
+ }
+ // 2025.02.19 portato da 100 a 1000 ms attesa x evitare che ODL sia avviato PRIMA della conferma
+ // attendo 1000 msec x chiudere ODL
+ await Task.Delay(1000);
+ // chiamo splitOdl
+ await IocDbController.AutoStartOdlAsync(currData.IdxOdl, 0, idxMacchina, currData.TCRichAttr, currData.PzPallet, $"Nuovo ODL da forceSplitOdl.autoStart", true, qtyNew, keyRichiesta);
+
+ // elimino eventuale ODL precedente...
+ string currKey = $"{Utils.redisOdlCurrByMac}:{idxMacchina}";
+ await redisDb.KeyDeleteAsync(currKey);
+
+ // ricalcola ODL macchina
+ var newOdl = await GetCurrOdlAsync(idxMacchina);
+ // attendo 1000 msec
+ await Task.Delay(1000);
+
+ adesso = DateTime.Now;
+ // registro fine ODL (idxTipoEv = 1)
+ idxEvento = 1;
+ Log.Info($"Invio evento FINE ODL-SPLIT | idx: {idxMacchina} | ev: {idxEvento} | art: {currData.CodArticolo}");
+ // costruisco nuovo evento
+ newRecEv = new EventListModel()
+ {
+ CodArticolo = currData.CodArticolo,
+ IdxMacchina = idxMacchina,
+ IdxTipo = idxEvento,
+ InizioStato = adesso,
+ MatrOpr = matrOpr,
+ pallet = "",
+ Value = "ODL-START"
+ };
+ resCmd = await scriviRigaEventoBarcodeAsync(newRecEv);
+ // invio eventi setup a macchina....
+ string setArtVal = $"{currData.CodArticolo}";
+ string setPzCommVal = $"{qtyNew}";
+ string setCommVal = $"ODL{newOdl}";
+ if (!string.IsNullOrEmpty(keyRichiesta))
+ {
+ setCommVal = $"{keyRichiesta} ODL{newOdl}";
+ }
+ try
+ {
+ // invio task caricamento dati ODL
+ Dictionary updDict = new Dictionary();
+ updDict.Add(taskType.setArt, setArtVal);
+ updDict.Add(taskType.setComm, setCommVal);
+ updDict.Add(taskType.setPzComm, setPzCommVal);
+#if false
+ addTask4Machine(idxMacchina, taskType.setArt, setArtVal);
+ addTask4Machine(idxMacchina, taskType.setComm, setCommVal);
+ addTask4Machine(idxMacchina, taskType.setPzComm, setPzCommVal);
+
+ updateMachineParameter(idxMacchina, "setArt", setArtVal);
+ updateMachineParameter(idxMacchina, "setComm", setCommVal);
+ updateMachineParameter(idxMacchina, "setPzComm", setPzCommVal);
+#endif
+ // recupero set attuale parametri
+ var currMachPar = await MachineParamListAsync(idxMacchina);
+ List list2upd = new();
+ // aggiorno i valori interessati tra quelli nel dizionario
+ foreach (var item in updDict)
+ {
+ var cRec = currMachPar.FirstOrDefault(x => x.uid == $"{item.Key}");
+ if (cRec != null)
+ {
+ list2upd.Add(cRec);
+ }
+ }
+ // aggiungo task di setParameters x la commessa...
+ updDict.Add(taskType.setParameter, setCommVal);
+ // salvo
+ await AddTask4MacListAsync(idxMacchina, updDict);
+ await MachineParamUpsertAsync(idxMacchina, list2upd);
+ }
+ catch
+ { }
+ // chiamo refresh MSE
+ await IocDbController.RecalcMseAsync(idxMacchina, 0);
+ // resetto stato macchina...
+ var kStatoMacc = $"{Utils.redisStatoMacch}:{idxMacchina}";
+ await redisDb.KeyDeleteAsync(kStatoMacc);
+ answ = "OK";
+ Log.Info($"Effettuato reset e ricalcoli x split ODL per macchina {idxMacchina}");
+ // se è una master richiamo fix x child...
+ if (isMachMaster)
+ {
+ Dictionary updDict = new Dictionary();
+ string ts = "";
+ string outData = "";
+ await IocDbController.OdlFixMachineSlaveAsync(idxMacchina, 30, 1);
+ foreach (var machine in slaveList)
+ {
+ // invio chiusura attrezzaggio
+ ts = string.Format("{0:yyMMdd}T{0:HHmmss.fff}Z", DateTime.Now);
+ outData = $"TS:{ts}|MATR:{matrOpr}|ODL:{newOdl}";
+
+ updDict.Clear();
+ updDict.Add(taskType.setArt, setArtVal);
+ updDict.Add(taskType.setComm, setCommVal);
+ updDict.Add(taskType.setPzComm, setPzCommVal);
+
+
+#if false
+ addTask4Machine(machine.IdxMacchinaSlave, taskType.fixStopSetup, outData);
+ addTask4Machine(machine.IdxMacchinaSlave, taskType.forceResetPzCount, outData);
+ // invio task caricamento dati ODL
+ addTask4Machine(machine.IdxMacchinaSlave, taskType.setArt, setArtVal);
+ addTask4Machine(machine.IdxMacchinaSlave, taskType.setComm, setCommVal);
+ addTask4Machine(machine.IdxMacchinaSlave, taskType.setPzComm, setPzCommVal);
+
+ updateMachineParameter(machine.IdxMacchinaSlave, "setArt", setArtVal);
+ updateMachineParameter(machine.IdxMacchinaSlave, "setComm", setCommVal);
+ updateMachineParameter(machine.IdxMacchinaSlave, "setPzComm", setPzCommVal);
+#endif
+
+ // recupero set attuale parametri
+ var currMachPar = await MachineParamListAsync(machine.IdxMacchinaSlave);
+ List list2upd = new();
+ // aggiorno i valori interessati tra quelli nel dizionario
+ foreach (var item in updDict)
+ {
+ var cRec = currMachPar.FirstOrDefault(x => x.uid == $"{item.Key}");
+ if (cRec != null)
+ {
+ list2upd.Add(cRec);
+ }
+ }
+ // aggiungo task di setParameters x la commessa...
+ updDict.Add(taskType.fixStopSetup, outData);
+ updDict.Add(taskType.forceResetPzCount, outData);
+ updDict.Add(taskType.setParameter, setCommVal);
+ // salvo
+ await AddTask4MacListAsync(machine.IdxMacchinaSlave, updDict);
+ await MachineParamUpsertAsync(machine.IdxMacchinaSlave, list2upd);
+ }
+ }
+ }
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione in forceSplitOdl{Environment.NewLine}{exc}");
+ }
+ }
+ return answ;
+ }
+
+
public string CalcRecipe(RecipeModel currRecipe)
{
return mongoController.CalcRecipe(currRecipe);
@@ -571,7 +937,7 @@ namespace MP.IOC.Data
inputComandoMapo answ = new inputComandoMapo();
// verifico se esista la macchina altrimenti la creo... REDIS compliant
- verificaIdxMacchina(idxMacchina);
+ await verificaIdxMacchinaAsync(idxMacchina);
// continuo processing...
string CodArticolo = datiMacc["CodArticolo"];
@@ -654,7 +1020,7 @@ namespace MP.IOC.Data
answ = await scriviRigaEventoAsync(newRecEv);
//currTask = scriviRigaEvento(idxMacchina, idxTipoEv, codArticolo, valEsteso, 0, "-", dtEve, DateTime.Now);
// forzo RESET dati macchina...
- ResetDatiMacchina(idxMacchina);
+ await ResetDatiMacchinaAsync(idxMacchina);
}
catch (Exception exc)
{
@@ -811,39 +1177,6 @@ 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
///
@@ -1349,19 +1682,8 @@ namespace MP.IOC.Data
///
public async Task> GetTask2ExeMacchinaAsync(string idxMacchina)
{
- // hard coded dimensione vettore DatiMacchine
- Dictionary answ = new Dictionary();
- // ORA recupero da memoria redis...
- try
- {
- var currHash = Utils.RedKeyTask2ExeMacc(idxMacchina, MpIoNS);
- answ = await RedisGetHashDictAsync(currHash);
- }
- catch (Exception exc)
- {
- Log.Info(string.Format("Errore in GetTask2ExeMacchinaAsync | idxMacchina {2}:{0}{1}", Environment.NewLine, exc, idxMacchina));
- }
- return answ;
+ var currHash = Utils.RedKeyTask2ExeMacc(idxMacchina, MpIoNS);
+ return await RedisGetHashDictAsync(currHash);
}
///
@@ -1412,6 +1734,31 @@ namespace MP.IOC.Data
return val != null && (val == "1" || val.ToLower() == "true");
}
+ ///
+ /// Restituisce il valore booleano se la macchina sia master
+ ///
+ ///
+ ///
+ public async Task IobIsMasterAsync(string idxMacchina)
+ {
+ var key = Utils.RedKeyDatiMacc(idxMacchina, MpIoNS);
+
+ // 1. Tentativo ottimizzato: leggiamo solo il campo che ci serve
+ // Supponendo che tu usi StackExchange.Redis direttamente o un wrapper
+ string? val = await redisDb.HashGetAsync(key, "Master");
+
+ // 2. Se non c'è in cache, carichiamo/resettiamo tutto
+ if (val == null)
+ {
+ //var data = ResetDatiMacchina(idxMacchina);
+ var data = await ResetDatiMacchinaAsync(idxMacchina);
+ data.TryGetValue("Master", out val);
+ }
+
+ // 3. Parsing sicuro
+ return val != null && (val == "1" || val.ToLower() == "true");
+ }
+
///
///
/// idxMacc odl da cercare
@@ -1447,6 +1794,32 @@ namespace MP.IOC.Data
return result;
}
+ public async Task> ListValuesFilt(string tabName, string fieldName)
+ {
+ List resultList = new List();
+ string tag = "";
+ tag += string.IsNullOrEmpty(tabName) ? "" : $"{tabName}:";
+ tag += string.IsNullOrEmpty(fieldName) ? "" : $"{fieldName}:";
+ var currKey = $"{Utils.redisConfFlux}:{tag}";
+ RedisValue rawData = await redisDb.StringGetAsync(currKey);
+ if (rawData.HasValue)
+ {
+ resultList = JsonConvert.DeserializeObject>($"{rawData}") ?? new();
+ }
+ else
+ {
+ resultList = await IocDbController.ListValuesFilt(tabName, fieldName);
+ // serializzo e salvo...
+ rawData = JsonConvert.SerializeObject(resultList);
+ await redisDb.StringSetAsync(currKey, rawData, getRandTOut(redisLongTimeCache));
+ }
+ if (resultList == null)
+ {
+ resultList = new();
+ }
+ return resultList;
+ }
+
///
/// Elenco completo valori Macchine 2 Slave
///
@@ -2049,10 +2422,24 @@ namespace MP.IOC.Data
}
catch (Exception exc)
{
- Log.Info(string.Format("Errore in mTaskMacchina | idxMacchina {2}:{0}{1}", Environment.NewLine, exc, idxMacchina));
+ Log.Error(string.Format("Errore in mTaskMacchina | idxMacchina {2}:{0}{1}", Environment.NewLine, exc, idxMacchina));
}
return answ;
}
+ ///
+ /// Restitusice elenco KVP dei TASK (da passare a IOB-WIN) per l'impianto indicato
+ ///
+ ///
+ ///
+ public async Task> mTaskMacchinaAsync(string idxMacchina)
+ {
+ // hard coded dimensione vettore DatiMacchine
+ Dictionary answ = new Dictionary();
+ // ORA recupero da memoria redis...
+ var currHash = Utils.RedKeyTask2ExeMacc(idxMacchina, MpIoNS);
+ answ = await RedisGetHashDictAsync(currHash);
+ return answ;
+ }
///
/// Generazione autoOdl
@@ -2431,6 +2818,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;
+ }
+
///
/// Recupero PODL da IdxODL
///
@@ -2599,7 +3019,7 @@ namespace MP.IOC.Data
// 2018.10.26 controllo dtEve e dtCurr
if (dtEve == null || dtCurr == null)
{
- Log.Info(string.Format("procInput: valori nulli date: idxMacchina: {0} | valore: {1} | dtEve: {2} | dtCurr:{3}", idxMacchina, valore, dtEve, dtCurr));
+ Log.Warn(string.Format("procInput: valori nulli date: idxMacchina: {0} | valore: {1} | dtEve: {2} | dtCurr:{3}", idxMacchina, valore, dtEve, dtCurr));
}
else if (dtEve.Length < 17 || dtCurr.Length < 17)
{
@@ -2663,7 +3083,7 @@ namespace MP.IOC.Data
// se ho deltaClass loggo
if (deltaClass != "")
{
- Log.Info("Correzione " + deltaClass);
+ Log.Debug("Correzione " + deltaClass);
}
}
catch (Exception exc)
@@ -2677,7 +3097,7 @@ namespace MP.IOC.Data
if (idxMacchina != "" && valore != "")
{
// se abilitato registro evento sul DB
- if (idxMacchina != "" && sLogEnab(idxMacchina))
+ if (!string.IsNullOrEmpty(idxMacchina) && await sLogEnabAsync(idxMacchina))
{
int cntVal = 0;
int.TryParse(contatore, out cntVal);
@@ -3129,17 +3549,7 @@ namespace MP.IOC.Data
public async Task RedisKeyPresentAsync(RedisKey key)
{
- bool result = false;
- try
- {
- result = await redisDb.KeyExistsAsync(key);
- }
- catch (Exception arg)
- {
- Log.Error($"Errore in redKeyPresent per la currKey {key}:{Environment.NewLine}{arg}");
- }
-
- return result;
+ return await redisDb.KeyExistsAsync(key);
}
public bool RedisKeyPresentSz(string key)
@@ -3698,29 +4108,16 @@ namespace MP.IOC.Data
{
string nomeVar = string.Format("KeepAlive:{0}", IdxMacchina);
// cerco se ho keep alive in redis,
- bool keyPresent = false;
DateTime adesso = DateTime.Now;
var currKey = Utils.RedKeyHash(nomeVar);
- try
- {
- keyPresent = await RedisKeyPresentAsync(currKey);
- }
- catch
- { }
+ bool keyPresent = await RedisKeyPresentAsync(currKey);
// se NON presente salvo in REDIS con TTL 10 sec e sul DB...
if (!keyPresent)
{
- await redisDb.StringSetAsync(currKey, adesso.ToString("s"), TimeSpan.FromSeconds(10));
- try
- {
- Log.Trace($"Scrittura keep alive! IdxMacchina: {IdxMacchina}");
- // effettuo scrittura sul DB
- await IocDbController.KeepAliveUpsertAsync(IdxMacchina, DateTime.Now, oraMacchina);
- }
- catch (Exception exc)
- {
- Log.Error($"Errore in scrittura keep alive!{Environment.NewLine}oraMacchina: {oraMacchina} - IdxMacchina: {IdxMacchina}{Environment.NewLine}{exc}");
- }
+ await redisDb.StringSetAsync(currKey, adesso.ToString("s"), TimeSpan.FromSeconds(20));
+ Log.Trace($"Scrittura keep alive! IdxMacchina: {IdxMacchina}");
+ // effettuo scrittura sul DB
+ await IocDbController.KeepAliveUpsertAsync(IdxMacchina, DateTime.Now, oraMacchina);
}
}
@@ -3757,6 +4154,38 @@ namespace MP.IOC.Data
return answ;
}
+ ///
+ /// Restituisce il valore booleano se la macchina sia abilitata all'inserimento COMPLETO nel
+ /// Signal Log
+ ///
+ ///
+ ///
+ public async Task sLogEnabAsync(string idxMacchina)
+ {
+ bool answ = false;
+ // ORA recupero da memoria redis...
+ try
+ {
+ var currHash = Utils.RedKeyDatiMacc(idxMacchina, MpIoNS);
+ RedisValue rawData = await redisDb.HashGetAsync(currHash, (RedisValue)"sLogEnabled");
+ // se è vuoto... leggo da DB e popolo!
+ if (!rawData.HasValue)
+ {
+ await ResetDatiMacchinaAsync(idxMacchina);
+ // riprovo
+ rawData = await redisDb.HashGetAsync(currHash, (RedisValue)"sLogEnabled");
+ }
+
+ // provo conversione
+ bool.TryParse($"{rawData}", out answ);
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Errore sLogEnabAsync | idxMacchina {idxMacchina}:{Environment.NewLine}{exc}");
+ }
+ return answ;
+ }
+
///
/// Restitusice elenco KVP dei campi della State Machine ingressi nel formato
/// currKey: cState_nVal (current MICRO-STATE + "_" + new Value)
@@ -4171,32 +4600,6 @@ namespace MP.IOC.Data
return resultList;
}
- public async Task> ListValuesFilt(string tabName, string fieldName)
- {
- List resultList = new List();
- string tag = "";
- tag += string.IsNullOrEmpty(tabName) ? "" : $"{tabName}:";
- tag += string.IsNullOrEmpty(fieldName) ? "" : $"{fieldName}:";
- var currKey = $"{Utils.redisConfFlux}:{tag}";
- RedisValue rawData = await redisDb.StringGetAsync(currKey);
- if (rawData.HasValue)
- {
- resultList = JsonConvert.DeserializeObject>($"{rawData}") ?? new();
- }
- else
- {
- resultList = await IocDbController.ListValuesFilt(tabName, fieldName);
- // serializzo e salvo...
- rawData = JsonConvert.SerializeObject(resultList);
- await redisDb.StringSetAsync(currKey, rawData, getRandTOut(redisLongTimeCache));
- }
- if (resultList == null)
- {
- resultList = new();
- }
- return resultList;
- }
-
///
/// Svuota la cache redis x l'elenco delle righe di confFlux x una macchina (se presenti)
///
@@ -4618,6 +5021,32 @@ namespace MP.IOC.Data
return answ;
}
+ ///
+ /// Scrive una riga di evento manuale (barcode) nel db + check cambio stato DiarioDiBordo
+ ///
+ /// codice macchina
+ ///
+ private async Task scriviRigaEventoBarcodeAsync(EventListModel newRec)
+ {
+ bool inserito = false;
+ try
+ {
+ // inserisco evento
+ inserito = await IocDbController.EvListInsertAsync(newRec);
+ // faccio controllo per eventuale cambio stato da tab transizioni...
+ checkCambiaStatoBatch(tipoInputEvento.barcode, newRec.IdxMacchina, newRec.InizioStato ?? DateTime.Now, newRec.IdxTipo, newRec.CodArticolo, newRec.Value, newRec.MatrOpr, newRec.pallet);
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Errore in scriviRigaEvento | IdxMacchina {newRec.IdxMacchina} | IdxTipo {newRec.IdxTipo} | codArticolo {newRec.CodArticolo} | Value {newRec.Value} | MatrOpr {newRec.MatrOpr} | Pallet {newRec.pallet} | dTime {newRec.InizioStato}{Environment.NewLine}{exc}");
+ }
+ // formatto output
+ inputComandoMapo answ = new inputComandoMapo();
+ answ.outValue = inserito.ToString();
+ answ.needStatusRefresh = true;
+ return answ;
+ }
+
///
/// Restituisce il valore booleano se la macchina sia abilitata all'inserimento COMPLETO nel
/// Signal Log
@@ -4719,7 +5148,6 @@ namespace MP.IOC.Data
{
answ = currRec.Valore;
}
-
return answ;
}
@@ -4889,6 +5317,60 @@ namespace MP.IOC.Data
}
}
+ ///
+ /// cerca codice in anagrafica macchine ed eventualmente inserisce nuova macchina
+ ///
+ ///
+ private async Task verificaIdxMacchinaAsync(string IdxMacchina)
+ {
+ bool needDB = false;
+ try
+ {
+ // esecuzione in REDIS...cerco status macchina...
+ if ((await mDatiMacchineAsync(IdxMacchina)).Count == 0)
+ {
+ needDB = true;
+ }
+ }
+ catch { }
+
+ if (needDB)
+ {
+ // verifico se esiste su DB
+ var dbRec = await IocDbController.MacchineGetByIdxAsync(IdxMacchina);
+ if (dbRec == null)
+ {
+ MacchineModel newRec = new MacchineModel()
+ {
+ IdxMacchina = IdxMacchina,
+ CodMacchina = "0000",
+ Nome = IdxMacchina,
+ Descrizione = "Macchina non codificata",
+ Note = "-",
+ locazione = "",
+ RecipeArchivePath = "",
+ RecipePath = ""
+ };
+ await IocDbController.MacchineUpsertAsync(newRec);
+
+ // verifico ci sia un microstato macchina...
+ var recMSM = await IocDbController.MicroStatoMacchinaGetByIdxMaccAsync(IdxMacchina);
+ if (recMSM.Count == 0)
+ {
+ // inserisco nuovo stato...
+ MicroStatoMacchinaModel msRec = new MicroStatoMacchinaModel()
+ {
+ IdxMacchina = IdxMacchina,
+ IdxMicroStato = 0,
+ InizioStato = DateTime.Now,
+ Value = "00"
+ };
+ await IocDbController.MicroStatoMacchinaUpsertAsync(msRec);
+ }
+ }
+ }
+ }
+
#endregion Private Methods
#if false
diff --git a/MP.IOC/MP.IOC.csproj b/MP.IOC/MP.IOC.csproj
index e4ed4b17..0f6d257a 100644
--- a/MP.IOC/MP.IOC.csproj
+++ b/MP.IOC/MP.IOC.csproj
@@ -4,7 +4,7 @@
net8.0
enable
enable
- 6.16.2604.1618
+ 6.16.2604.1709
diff --git a/MP.IOC/Resources/ChangeLog.html b/MP.IOC/Resources/ChangeLog.html
index 1ea573fb..32944119 100644
--- a/MP.IOC/Resources/ChangeLog.html
+++ b/MP.IOC/Resources/ChangeLog.html
@@ -1,6 +1,6 @@
Modulo MP-IOC
- Versione: 6.16.2604.1618
+ Versione: 6.16.2604.1709
Note di rilascio:
-
diff --git a/MP.IOC/Resources/VersNum.txt b/MP.IOC/Resources/VersNum.txt
index 139563a9..974a30ac 100644
--- a/MP.IOC/Resources/VersNum.txt
+++ b/MP.IOC/Resources/VersNum.txt
@@ -1 +1 @@
-6.16.2604.1618
+6.16.2604.1709
diff --git a/MP.IOC/Resources/manifest.xml b/MP.IOC/Resources/manifest.xml
index fc43241b..7516b3f9 100644
--- a/MP.IOC/Resources/manifest.xml
+++ b/MP.IOC/Resources/manifest.xml
@@ -1,6 +1,6 @@
-
- 6.16.2604.1618
+ 6.16.2604.1709
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
diff --git a/MP.IOC/appsettings.Production.json b/MP.IOC/appsettings.Production.json
index ad5fa751..703dacca 100644
--- a/MP.IOC/appsettings.Production.json
+++ b/MP.IOC/appsettings.Production.json
@@ -15,10 +15,10 @@
],
"Clusters": {
"cluster-old": {
- "Destinations": { "old1": { "Address": "https://iis01.egalware.com/MP/IO/IOB/" } }
+ "Destinations": { "old1": { "Address": "https://maposrv.egalware.com/MP/IO/IOB/" } }
},
"cluster-new": {
- "Destinations": { "new1": { "Address": "https://iis01.egalware.com/MP/IOC/api/IOB/" } }
+ "Destinations": { "new1": { "Address": "https://maposrv.egalware.com/MP/IOC/api/IOB/" } }
}
}
},