Ottimizzazione meccanismo lettura dati di prod da DB/REDIS x TAB
This commit is contained in:
@@ -160,9 +160,11 @@ namespace MP_TAB_SERV.Components
|
||||
imgBasePath = $"{Environment.CurrentDirectory}/images/";
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
[Inject]
|
||||
protected StatusData SDService { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Dati produzioen rilevati
|
||||
@@ -175,7 +177,16 @@ namespace MP_TAB_SERV.Components
|
||||
// controllo SE avessi idxMacchSub --> rileggo!
|
||||
if (RecMSE != null)
|
||||
{
|
||||
datiProdAct = await TabDServ.StatoProdMacchina(RecMSE.IdxMacchina, adesso);
|
||||
if (SDService.MachNumPzGet(RecMSE.IdxMacchina) != RecMSE.NumPezzi)
|
||||
{
|
||||
datiProdAct = await TabDServ.StatoProdMacchina(RecMSE.IdxMacchina, adesso);
|
||||
SDService.MachProdStSet(RecMSE.IdxMacchina, datiProdAct);
|
||||
SDService.MachNumPzSet(RecMSE.IdxMacchina, RecMSE.NumPezzi);
|
||||
}
|
||||
else
|
||||
{
|
||||
datiProdAct = SDService.MachProdStGet(RecMSE.IdxMacchina);
|
||||
}
|
||||
}
|
||||
if (!string.IsNullOrEmpty(IdxMacchSub) && RecMSE != null)
|
||||
{
|
||||
|
||||
@@ -57,7 +57,7 @@ namespace MP_TAB_SERV.Components
|
||||
}
|
||||
|
||||
[Inject]
|
||||
protected StatusData MDataService { get; set; } = null!;
|
||||
protected StatusData SDService { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
protected MessageService MServ { get; set; } = null!;
|
||||
@@ -113,7 +113,7 @@ namespace MP_TAB_SERV.Components
|
||||
|
||||
private async Task RefreshData()
|
||||
{
|
||||
List<MappaStatoExpl> ListMSE = await MDataService.MseGetAll();
|
||||
List<MappaStatoExpl> ListMSE = await SDService.MseGetAll();
|
||||
await MServ.SaveMse(ListMSE);
|
||||
await E_Updated.InvokeAsync(ListMSE);
|
||||
}
|
||||
|
||||
@@ -143,6 +143,79 @@ namespace MP.Data.Services
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce numPezzi (ultimo) x macchina
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
public int MachNumPzGet(string idxMacchina)
|
||||
{
|
||||
int answ = 0;
|
||||
if (MachineNumPz.ContainsKey(idxMacchina))
|
||||
{
|
||||
answ = MachineNumPz[idxMacchina];
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Salva numPezzi x macchina
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <param name="numPz"></param>
|
||||
/// <returns></returns>
|
||||
public bool MachNumPzSet(string idxMacchina, int numPz)
|
||||
{
|
||||
bool answ = false;
|
||||
if (MachineNumPz.ContainsKey(idxMacchina))
|
||||
{
|
||||
MachineNumPz[idxMacchina] = numPz;
|
||||
}
|
||||
else
|
||||
{
|
||||
MachineNumPz.Add(idxMacchina, numPz);
|
||||
}
|
||||
answ = true;
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce numPezzi (ultimo) x macchina
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
public StatoProdModel MachProdStGet(string idxMacchina)
|
||||
{
|
||||
StatoProdModel answ = new StatoProdModel();
|
||||
if (MachineProdStatus.ContainsKey(idxMacchina))
|
||||
{
|
||||
answ = MachineProdStatus[idxMacchina];
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
/// <summary>
|
||||
/// Salva numPezzi x macchina
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <param name="currStatus"></param>
|
||||
/// <returns></returns>
|
||||
public bool MachProdStSet(string idxMacchina, StatoProdModel currStatus)
|
||||
{
|
||||
bool answ = false;
|
||||
if (MachineProdStatus.ContainsKey(idxMacchina))
|
||||
{
|
||||
MachineProdStatus[idxMacchina] = currStatus;
|
||||
}
|
||||
else
|
||||
{
|
||||
MachineProdStatus.Add(idxMacchina, currStatus);
|
||||
}
|
||||
answ = true;
|
||||
return answ;
|
||||
}
|
||||
|
||||
private Dictionary<string, int> MachineNumPz { get; set; } = new Dictionary<string, int>();
|
||||
private Dictionary<string, StatoProdModel> MachineProdStatus { get; set; } = new Dictionary<string, StatoProdModel>();
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
Reference in New Issue
Block a user