diff --git a/MP-TAB-SERV/Components/OdlMan.razor b/MP-TAB-SERV/Components/OdlMan.razor
index 4e8f6fae..355f0de0 100644
--- a/MP-TAB-SERV/Components/OdlMan.razor
+++ b/MP-TAB-SERV/Components/OdlMan.razor
@@ -38,9 +38,25 @@
}
else
{
-
- Slave machine man
-
+ @if (showSplitOdlOnTavVal || showReopOdlTav)
+ {
+
+
+
+ @if (showSplitOdlOnTavVal)
+ {
+
+ }
+
+
+ @if (showReopOdlTav)
+ {
+
+ }
+
+
+
+ }
Check articolo in revisione
@@ -243,9 +259,12 @@
}
}
-
-
-
+ @if (!inAttr && enableFixSetup)
+ {
+
+
+
+ }
diff --git a/MP-TAB-SERV/Components/OdlMan.razor.cs b/MP-TAB-SERV/Components/OdlMan.razor.cs
index 7392b525..62ccc4c5 100644
--- a/MP-TAB-SERV/Components/OdlMan.razor.cs
+++ b/MP-TAB-SERV/Components/OdlMan.razor.cs
@@ -5,7 +5,6 @@ using MP.Data.DatabaseModels;
using MP.Data.Objects;
using MP.Data.Services;
using NLog;
-using System;
using System.Text;
using static MP.Data.Objects.Enums;
@@ -102,7 +101,7 @@ namespace MP_TAB_SERV.Components
///
protected bool odlOk
{
- get => (RecMSE != null && RecMSE.IdxOdl > 0);
+ get => IdxOdl > 0;
}
protected bool ShowAll
@@ -189,6 +188,70 @@ namespace MP_TAB_SERV.Components
return answ;
}
+ ///
+ /// Effettua ripresa ODL su tavola
+ ///
+ ///
+ ///
+ protected async Task OdlReopenTav()
+ {
+ MaxVal = 3;
+ int currStep = 0;
+ await advStep(currStep);
+ isProcessing = true;
+ // chiamo stored x riprendere ODL (toglie data chiusura...)
+ var rowRes = TabDServ.OdlReopenOdlMacc(IdxMaccSel);
+ if (rowRes != null && rowRes.IdxOdl > 0)
+ {
+ // messaggio utente
+ string evText = "Registrato riapertura ODL {0} | art {1}";
+ StringBuilder sb = new StringBuilder();
+ sb.AppendLine(String.Format(evText, rowRes.IdxOdl, rowRes.CodArticolo));
+ lblOut = sb.ToString();
+ }
+ await advStep(currStep++);
+ // update button x setup da altra tavola...
+ checkAll();
+ // faccio refresh e riporto
+ await RefreshData();
+ await CheckAttr();
+ await advStep(currStep++);
+ // chiudo update...
+ isProcessing = false;
+ }
+
+ ///
+ /// Effettua split ODL da ALTRA tavola su tav corrente
+ ///
+ ///
+ ///
+ protected async Task OdlSetSameAsOtherTav()
+ {
+ MaxVal = 3;
+ int currStep = 0;
+ await advStep(currStep);
+ isProcessing = true;
+ // se ho ODL su altra macchina...
+ if (IdxOdlAltra > 0)
+ {
+ await TabDServ.OdlDividiDaAltraTavola(IdxOdlAltra, MatrOpr, IdxMaccSel);
+ // messaggio utente
+ string evText = "Registrata inizio attrezzaggio da split ODL {0} (come da altra tavola)";
+ StringBuilder sb = new StringBuilder();
+ sb.AppendLine(String.Format(evText, IdxOdlAltra));
+ lblOut = sb.ToString();
+ }
+ await advStep(currStep++);
+ // update button x setup da altra tavola...
+ checkAll();
+ // faccio refresh e riporto
+ await RefreshData();
+ await CheckAttr();
+ await advStep(currStep++);
+ // chiudo update...
+ isProcessing = false;
+ }
+
///
/// Registrazione Fine Setup / Inizio Produzione
///
@@ -280,8 +343,7 @@ namespace MP_TAB_SERV.Components
lblOut = sb.ToString().Replace("---", "
");
// update buttons...
checkAll();
- // imposto odl...
- idxOdl = idxODLStart;
+ // reset vari
IdxPOdlSel = 0;
inAttr = false;
IdxPOdlSel = 0;
@@ -485,7 +547,7 @@ namespace MP_TAB_SERV.Components
checkBtnStatus();
fixSplitBtn(false);
// faccio refresh e riporto
- idxOdl = idxODL_curr;
+ await TabDServ.FlushCache("ODL");
IdxPOdlSel = 0;
RecMSE = null;
await RefreshData();
@@ -505,6 +567,10 @@ namespace MP_TAB_SERV.Components
modoConfProd = SMServ.GetConfInt("modoConfProd");
enableRPO = SMServ.GetConfBool("enableRPO");
enableSchedaTecnica = SMServ.GetConfBool("enableSchedaTecnica");
+ enableFixSetup = SMServ.GetConfBool("OptEnableFixSetup");
+ showSplitOdlOnTav = SMServ.GetConfBool("showSplitOdlOnTav");
+ showReopenOdlTav = SMServ.GetConfBool("showReopenOdlTav");
+ gPeriodReopenOdlTav = SMServ.GetConfInt("gPeriodReopenOdlTav");
string rawEmailDest = SMServ.GetConf("_adminEmail");
emailAdmDest = rawEmailDest.Split(',').ToList();
if (RecMSE != null)
@@ -663,6 +729,32 @@ namespace MP_TAB_SERV.Components
tcRichAttr = newTCRich;
}
+ protected async Task SendFixEndSetup()
+ {
+ if (!await JSRuntime.InvokeAsync("confirm", $"Confermi invio FIX chiusura atrtezzaggio ad impianto?"))
+ return;
+
+ string ts = string.Format("{0:yyMMdd}T{0:HHmmss.fff}Z", DateTime.Now);
+ string outData = $"TS:{ts}|MATR:{MatrOpr}|ODL:{IdxOdl}";
+ TabDServ.addTask4Machine(IdxMaccSel, taskType.fixStopSetup, outData);
+ outData = "Inserita richiesta invio Fix chiusura attrezzaggio " + outData;
+ lblOut = outData;
+ // se è master --> chiamo update child!
+ if (isMaster)
+ {
+ // invio eventi ad IOB slave...
+ var slaveList = SMServ.ListM2S
+ .Where(x => x.IdxMacchina.Equals(IdxMaccSel, StringComparison.InvariantCultureIgnoreCase))
+ .ToList();
+ foreach (var machine in slaveList)
+ {
+ // invio chiusura attrezzaggio
+ outData = $"TS:{ts}|MATR:{MatrOpr}|ODL:{IdxOdl}|master machine:{IdxMaccSel}";
+ TabDServ.addTask4Machine(machine.IdxMacchinaSlave, taskType.fixStopSetup, outData);
+ }
+ }
+ }
+
protected async Task SendWarnTcChangeReq(int idxOdl, decimal tcAss, decimal tcRich)
{
// carico altri parametri email...
@@ -713,76 +805,11 @@ namespace MP_TAB_SERV.Components
}
}
- private string txtForceCloseOdl
- {
- get => forceCloseOdl ? Traduci("ForceCloseODL") : Traduci("SplitCurrODL");
- }
-
- private async Task ReloadXDL(bool reloadFromOdl)
- {
- int currIdxPOdl = IdxPOdlSel;
- if (RecMSE != null)
- {
- if (reloadFromOdl)
- {
- currIdxPOdl = RecMSE.IdxPOdl ?? 0;
- }
- // se ho PODL valido...
- if (currIdxPOdl > 0)
- {
- currPodl = await TabDServ.PODLExp_getByKey(currIdxPOdl);
- }
- else
- {
- currPodl = new PODLExpModel()
- {
- IdxOdl = RecMSE.IdxOdl ?? 0,
- KeyRichiesta = "-",
- CodArticolo = RecMSE.CodArticolo,
- DescArticolo = RecMSE.CodArticolo,
- NumPezzi = RecMSE.NumPezzi,
- Tcassegnato = RecMSE.TCAssegnato
- };
- }
- }
- // update a runtime dati ODL se assegnato
- if (currPodl.IdxOdl > 0)
- {
- currOdl = await TabDServ.OdlByIdx(currPodl.IdxOdl, false);
- }
- }
-
protected string Traduci(string lemma)
{
return SMServ.Traduci($"{baseLang}_{lemma}".ToUpper());
}
- protected async Task SendFixEndSetup()
- {
- if (!await JSRuntime.InvokeAsync("confirm", $"Confermi invio FIX chiusura atrtezzaggio ad impianto?"))
- return;
-
- string ts = string.Format("{0:yyMMdd}T{0:HHmmss.fff}Z", DateTime.Now);
- string outData = $"TS:{ts}|MATR:{MatrOpr}|ODL:{IdxOdl}";
- TabDServ.addTask4Machine(IdxMaccSel, taskType.fixStopSetup, outData);
- outData = "Inserita richiesta invio Fix chiusura attrezzaggio " + outData;
- lblOut = outData;
- // se è master --> chiamo update child!
- if (isMaster)
- {
- // invio eventi ad IOB slave...
- var slaveList = SMServ.ListM2S
- .Where(x => x.IdxMacchina.Equals(IdxMaccSel, StringComparison.InvariantCultureIgnoreCase))
- .ToList();
- foreach (var machine in slaveList)
- {
- // invio chiusura attrezzaggio
- outData = $"TS:{ts}|MATR:{MatrOpr}|ODL:{idxOdl}|master machine:{IdxMaccSel}";
- TabDServ.addTask4Machine(machine.IdxMacchinaSlave, taskType.fixStopSetup, outData);
- }
- }
- }
-
#endregion Protected Methods
#region Private Fields
@@ -797,6 +824,8 @@ namespace MP_TAB_SERV.Components
private List emailAdmDest = new List();
+ private bool enableFixSetup = false;
+
private bool enableRPO = true;
private bool enableSchedaTecnica = false;
@@ -807,9 +836,9 @@ namespace MP_TAB_SERV.Components
private bool forceCloseOdl = true;
- private string IdxMaccSel = "";
+ private int gPeriodReopenOdlTav = 1;
- private int idxOdl = 0;
+ private string IdxMaccSel = "";
private int idxPOdlSel = 0;
@@ -845,6 +874,10 @@ namespace MP_TAB_SERV.Components
private bool showOdlDetail = false;
+ private bool showReopenOdlTav = false;
+
+ private bool showSplitOdlOnTav = false;
+
private decimal tcRichAttr = 1;
#endregion Private Fields
@@ -859,19 +892,67 @@ namespace MP_TAB_SERV.Components
set { MServ.UserPrefGet("Lang"); }
}
- private PODLExpModel currPodl { get; set; } = new PODLExpModel();
+ private string cssDetailOdl
+ {
+ get => IdxPOdlSel > 0 ? "bg-primary text-light" : "bg-warning";
+ }
+
private ODLExpModel currOdl { get; set; } = new ODLExpModel();
+ private PODLExpModel currPodl { get; set; } = new PODLExpModel();
+
+ ///
+ /// Verifica se l'ALTRA macchina NON abbia ODL valido (== 0)
+ ///
+ private bool emptyOdlAltraMacc
+ {
+ get => IdxOdlAltra == 0;
+ }
+
+ ///
+ /// Verifica se la macchina NON abbia ODL valido (== 0)
+ ///
+ private bool emptyOdlMacc
+ {
+ get => IdxOdl == 0;
+ }
+
+ private bool endProdDisabled
+ {
+ get => !odlOk || needConfProd;
+ }
+
///
/// Variabile idxMacc parent x selezione ODL
///
private string IdxMaccParent { get; set; } = "";
+ ///
+ /// Valore calcolato key ODL corrente...
+ ///
private int IdxOdl
{
get => RecMSE != null ? RecMSE.IdxOdl ?? 0 : 0;
}
+ ///
+ /// Valore calcolato key ODL altra tavola attivo...
+ ///
+ private int IdxOdlAltra
+ {
+ get
+ {
+ int answ = 0;
+ var pUpd = Task.Run(async () =>
+ {
+ var tabOdlAltra = await TabDServ.OdlCurrByMacc(idxMaccAltraTav, false);
+ answ = tabOdlAltra.IdxOdl;
+ });
+ pUpd.Wait();
+ return answ;
+ }
+ }
+
private string lblWarnBody
{
get => odlOk ? Traduci("ConfProdBeforeContinueBody") : Traduci("setOdlBeforeContinueBody");
@@ -882,7 +963,6 @@ namespace MP_TAB_SERV.Components
get => odlOk ? Traduci("ConfProdBeforeContinueHead") : Traduci("setOdlBeforeContinueHead");
}
-
private int MatrOpr
{
get => MServ.MatrOpr;
@@ -901,11 +981,6 @@ namespace MP_TAB_SERV.Components
}
}
- private bool endProdDisabled
- {
- get => !odlOk || needConfProd;
- }
-
private int numPz2Conf
{
get
@@ -923,18 +998,100 @@ namespace MP_TAB_SERV.Components
}
}
- private string txtBtnOdlDetail
+ ///
+ /// Verifica visibilità btn riprendi ODL su 2° tavola SE:
+ /// - sia un impianto MULTI (= con + tavole)
+ /// - sia disattrezzata la tavola
+ /// - in tab congif: se sia abilitato la ripresa ODL sulla seconda tavola
+ /// - in tab config: sia il grace period
+ /// - NON SIANO passati i minuti indicati dalla chiusura
+ ///
+ private bool showReopOdlTav
{
- get => showOdlDetail ? "Nascondi Dettaglio ODL" : "MOSTRA Dettaglio ODL Corrente";
+ get
+ {
+ bool answ = false;
+ // se è multi controllo
+ if (isMulti)
+ {
+ // verifico se NON HA ODL...
+ if (emptyOdlMacc)
+ {
+ // verifico SE siamo nel gracePeriod... chiuso da meno di 1h
+ DateTime adesso = DateTime.Now;
+ DateTime dtChiusura = DateTime.Now.AddHours(-1);
+ try
+ {
+ var lastOdl = TabDServ.OdlLastByMacc(IdxMaccSel, true);
+ if (lastOdl != null)
+ {
+ dtChiusura = lastOdl.DataFine ?? DateTime.Now.AddHours(-1);
+ }
+ }
+ catch
+ { }
+
+ // ora verifico SE E SOLO SE è ANCORA in attrezzaggio
+ if (inAttr)
+ {
+ // ora verifico SE ALTRA TAVOLA ha ODL...
+ if (dtChiusura.AddMinutes(gPeriodReopenOdlTav) > adesso)
+ {
+ answ = showReopenOdlTav;
+ }
+ }
+ }
+ }
+ return answ;
+ }
}
+
+ ///
+ /// Verifica visibilità btn split ODL su 2° tavola SE:
+ /// - sia un impianto MULTI (= con + tavole)
+ /// - sia già attrezzata la prima tavola
+ /// - in tab Congif: se sia abilitato lo split ODL sulla seconda tavola
+ /// - la macchina SIA ANCORA in attrezzaggio (2019.07.08) = 2
+ ///
+ private bool showSplitOdlOnTavVal
+ {
+ get
+ {
+ bool answ = false;
+ // se è multi controllo
+ if (isMulti)
+ {
+ // verifico se NON HA ODL ma ce l'ha altra tavola...
+ if (emptyOdlMacc)
+ {
+ // ora verifico SE ALTRA TAVOLA ha ODL...
+ if (!emptyOdlAltraMacc)
+ {
+ // ora verifico SE E SOLO SE è ANCORA in attrezzaggio
+ if (inAttr)
+ {
+ answ = showSplitOdlOnTav;
+ }
+ }
+ }
+ }
+ return answ;
+ }
+ }
+
private string titleOdlDetail
{
get => IdxPOdlSel > 0 ? "Verifica parametri attrezzaggio NUOVO PODL" : inAttr ? "Parametri PODL in Attrezzaggio" : "Parametri ODL Corrente";
}
- private string cssDetailOdl
+ private string txtBtnOdlDetail
{
- get => IdxPOdlSel > 0 ? "bg-primary text-light" : "bg-warning";
+ get => showOdlDetail ? "Nascondi Dettaglio ODL" : "MOSTRA Dettaglio ODL Corrente";
+ }
+
+ private string txtForceCloseOdl
+ {
+ get => forceCloseOdl ? Traduci("ForceCloseODL") : Traduci("SplitCurrODL");
}
#endregion Private Properties
@@ -1284,6 +1441,40 @@ namespace MP_TAB_SERV.Components
}
}
+ private async Task ReloadXDL(bool reloadFromOdl)
+ {
+ int currIdxPOdl = IdxPOdlSel;
+ if (RecMSE != null)
+ {
+ if (reloadFromOdl)
+ {
+ currIdxPOdl = RecMSE.IdxPOdl ?? 0;
+ }
+ // se ho PODL valido...
+ if (currIdxPOdl > 0)
+ {
+ currPodl = await TabDServ.PODLExp_getByKey(currIdxPOdl);
+ }
+ else
+ {
+ currPodl = new PODLExpModel()
+ {
+ IdxOdl = RecMSE.IdxOdl ?? 0,
+ KeyRichiesta = "-",
+ CodArticolo = RecMSE.CodArticolo,
+ DescArticolo = RecMSE.CodArticolo,
+ NumPezzi = RecMSE.NumPezzi,
+ Tcassegnato = RecMSE.TCAssegnato
+ };
+ }
+ }
+ // update a runtime dati ODL se assegnato
+ if (currPodl.IdxOdl > 0)
+ {
+ currOdl = await TabDServ.OdlByIdx(currPodl.IdxOdl, false);
+ }
+ }
+
#endregion Private Methods
}
}
\ No newline at end of file
diff --git a/MP-TAB-SERV/MP-TAB-SERV.csproj b/MP-TAB-SERV/MP-TAB-SERV.csproj
index 2a4052df..c93c3d22 100644
--- a/MP-TAB-SERV/MP-TAB-SERV.csproj
+++ b/MP-TAB-SERV/MP-TAB-SERV.csproj
@@ -3,7 +3,7 @@
net6.0
enable
- 6.16.2311.919
+ 6.16.2311.1016
enable
MP_TAB_SERV
diff --git a/MP-TAB-SERV/Resources/ChangeLog.html b/MP-TAB-SERV/Resources/ChangeLog.html
index cc1f4884..8d44feee 100644
--- a/MP-TAB-SERV/Resources/ChangeLog.html
+++ b/MP-TAB-SERV/Resources/ChangeLog.html
@@ -1,6 +1,6 @@
Modulo MAPOSPEC
- Versione: 6.16.2311.919
+ Versione: 6.16.2311.1016
Note di rilascio:
-
diff --git a/MP-TAB-SERV/Resources/VersNum.txt b/MP-TAB-SERV/Resources/VersNum.txt
index 07056f18..e1f886bd 100644
--- a/MP-TAB-SERV/Resources/VersNum.txt
+++ b/MP-TAB-SERV/Resources/VersNum.txt
@@ -1 +1 @@
-6.16.2311.919
+6.16.2311.1016
diff --git a/MP-TAB-SERV/Resources/manifest.xml b/MP-TAB-SERV/Resources/manifest.xml
index ab8d78fe..e8dda042 100644
--- a/MP-TAB-SERV/Resources/manifest.xml
+++ b/MP-TAB-SERV/Resources/manifest.xml
@@ -1,6 +1,6 @@
-
- 6.16.2311.919
+ 6.16.2311.1016
https://nexus.steamware.net/repository/SWS/MP-TAB-SERV/stable/LAST/MP-TAB-SERV.zip
https://nexus.steamware.net/repository/SWS/MP-TAB-SERV/stable/LAST/ChangeLog.html
false
diff --git a/MP.Data/Controllers/MpTabController.cs b/MP.Data/Controllers/MpTabController.cs
index a3190441..ef4d23f9 100644
--- a/MP.Data/Controllers/MpTabController.cs
+++ b/MP.Data/Controllers/MpTabController.cs
@@ -848,6 +848,37 @@ namespace MP.Data.Controllers
}
return fatto;
}
+ ///
+ /// Attrezzo stesso ODL dell'altra tavola
+ ///
+ ///
+ ///
+ ///
+ ///
+ public bool OdlDividiDaAltraTavola(int idxODL, int matrOpr, string idxMacchinaTo)
+ {
+ bool fatto = false;
+ using (var dbCtx = new MoonProContext(_configuration))
+ {
+ try
+ {
+ var IdxODL = new SqlParameter("@idxODL", idxODL);
+ var MatrOpr = new SqlParameter("@MatrOpr", matrOpr);
+ var IdxMaccTo = new SqlParameter("@IdxMacchinaTo", idxMacchinaTo);
+ var result = dbCtx
+ .Database
+ .ExecuteSqlRaw("EXEC stp_ODL_dividiDaAltraTav @idxODL, @MatrOpr, @IdxMacchinaTo", IdxODL, MatrOpr, IdxMaccTo);
+ fatto = result != 0;
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione durante OdlDividiDaAltraTavola{Environment.NewLine}{exc}");
+ }
+ }
+ return fatto;
+ }
+
+
///
/// Fix ODL per macchine SLAVE
@@ -946,6 +977,63 @@ namespace MP.Data.Controllers
return dbResult;
}
+ ///
+ /// Ultimo ODL data macchina
+ ///
+ ///
+ ///
+ public List OdlLastByMacc(string idxMacchina)
+ {
+ List dbResult = new List();
+ using (var dbCtx = new MoonProContext(_configuration))
+ {
+ try
+ {
+ var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
+ dbResult = dbCtx
+ .DbSetODL
+ .FromSqlRaw("EXEC stp_ODL_getLastByMacchina @IdxMacchina", IdxMacchina)
+ .AsNoTracking()
+ .ToList();
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione durante OdlLastByMacc{Environment.NewLine}{exc}");
+ }
+ }
+ return dbResult;
+ }
+
+
+ ///
+ /// Riapertura ULTIMO ODL data macchina
+ ///
+ ///
+ ///
+ public List OdlReopenOdlMacc(string idxMacchina)
+ {
+ List dbResult = new List();
+ using (var dbCtx = new MoonProContext(_configuration))
+ {
+ try
+ {
+ var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
+ dbResult = dbCtx
+ .DbSetODL
+ .FromSqlRaw("EXEC stp_ODL_reopenOdlMacc @IdxMacchina", IdxMacchina)
+ .AsNoTracking()
+ .ToList();
+ }
+ catch (Exception exc)
+ {
+ Log.Error($"Eccezione durante OdlReopenOdlMacc{Environment.NewLine}{exc}");
+ }
+ }
+ return dbResult;
+ }
+
+
+
///
/// Setup ODL Postumo
///
diff --git a/MP.Data/Services/TabDataService.cs b/MP.Data/Services/TabDataService.cs
index 191de962..d73c08cc 100644
--- a/MP.Data/Services/TabDataService.cs
+++ b/MP.Data/Services/TabDataService.cs
@@ -10,6 +10,7 @@ using System;
using System.Collections.Generic;
using System.Data;
using System.Diagnostics;
+using System.Drawing.Drawing2D;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
@@ -1154,14 +1155,41 @@ namespace MP.Data.Services
return answ;
}
+
///
- /// Fix ODL per macchine SLAVE
+ /// Attrezzo stesso ODL dell'altra tavola
///
- ///
- ///
- ///
+ ///
+ ///
+ ///
///
- public async Task OdlFixMachineSlave(string idxMacchina, int numDayPrev, int doInsert)
+ public async Task OdlDividiDaAltraTavola(int idxODL, int matrOpr, string idxMacchinaTo)
+ {
+ bool answ = false;
+ try
+ {
+ // inserisco evento
+ answ = dbTabController.OdlDividiDaAltraTavola(idxODL, matrOpr, idxMacchinaTo);
+ await FlushCache("ODL");
+ await FlushCache("PODL");
+ await FlushCache("VSODL");
+ }
+ catch (Exception exc)
+ {
+ string logMsg = $"Eccezione in OdlDividiDaAltraTavola | idxODL: {idxODL} | matrOpr: {matrOpr} | idxMacchinaTo: {idxMacchinaTo}{Environment.NewLine}{exc}";
+ Log.Error(logMsg);
+ }
+ return answ;
+ }
+
+ ///
+ /// Fix ODL per macchine SLAVE
+ ///
+ ///
+ ///
+ ///
+ ///
+ public async Task OdlFixMachineSlave(string idxMacchina, int numDayPrev, int doInsert)
{
bool answ = false;
try
@@ -1209,6 +1237,72 @@ namespace MP.Data.Services
return answ;
}
+ ///
+ /// Ultimo ODL data macchina
+ ///
+ ///
+ ///
+ ///
+ public ODLModel OdlLastByMacc(string idxMacchina, bool forceDb)
+ {
+ string source = "DB";
+ Stopwatch sw = new Stopwatch();
+ sw.Start();
+ ODLModel result = new ODLModel();
+ // cerco in redis...
+ string currKey = $"{redisBaseKey}:ODL:{idxMacchina}:LAST";
+ RedisValue rawData = redisDb.StringGet(currKey);
+ if (rawData.HasValue && !forceDb)
+ {
+ result = JsonConvert.DeserializeObject($"{rawData}");
+ source = "REDIS";
+ }
+ else
+ {
+ var results = dbTabController.OdlLastByMacc(idxMacchina);
+ // riordino
+ result = results.FirstOrDefault();
+ // serializzp e salvo...
+ rawData = JsonConvert.SerializeObject(result);
+ redisDb.StringSet(currKey, rawData, UltraLongCache);
+ }
+ if (result == null)
+ {
+ result = new ODLModel();
+ }
+ sw.Stop();
+ Log.Debug($"OdlLastByMacc | {source} | {sw.Elapsed.TotalMilliseconds}ms");
+ return result;
+ }
+
+ ///
+ /// Riapertura ULTIMO ODL data macchina
+ ///
+ ///
+ ///
+ public ODLModel OdlReopenOdlMacc(string idxMacchina)
+ {
+ string source = "DB";
+ Stopwatch sw = new Stopwatch();
+ sw.Start();
+ ODLModel result = new ODLModel();
+ // cerco in redis...
+ string currKey = $"{redisBaseKey}:ODL:{idxMacchina}:LAST";
+ var results = dbTabController.OdlReopenOdlMacc(idxMacchina);
+ // riordino
+ result = results.FirstOrDefault();
+ // serializzp e salvo...
+ var rawData = JsonConvert.SerializeObject(result);
+ redisDb.StringSet(currKey, rawData, UltraLongCache);
+ if (result == null)
+ {
+ result = new ODLModel();
+ }
+ sw.Stop();
+ Log.Debug($"OdlReopenOdlMacc | {source} | {sw.Elapsed.TotalMilliseconds}ms");
+ return result;
+ }
+
///
/// Elenco ODL data macchina e periodo
///