Merge branch 'develop' of https://gitlab.steamware.net/steamware/mapo-core into develop
This commit is contained in:
@@ -74,7 +74,7 @@ namespace MP_TAB_SERV.Components
|
||||
showAll = value;
|
||||
var pUpd = Task.Run(async () =>
|
||||
{
|
||||
await ReloadData();
|
||||
await ReloadData(true);
|
||||
});
|
||||
pUpd.Wait();
|
||||
}
|
||||
@@ -110,15 +110,17 @@ namespace MP_TAB_SERV.Components
|
||||
if (RecMSE != null)
|
||||
{
|
||||
IdxMaccSel = RecMSE.IdxMacchina;
|
||||
await ReloadData();
|
||||
await ReloadData(true);
|
||||
}
|
||||
checkAll();
|
||||
}
|
||||
|
||||
protected PzProdModel? prodMacchina = null;
|
||||
|
||||
protected override async Task OnParametersSetAsync()
|
||||
{
|
||||
isMulti = MServ.DictMacchMulti[RecMSE?.IdxMacchina] == 1;
|
||||
await ReloadData();
|
||||
await ReloadData(false);
|
||||
}
|
||||
|
||||
protected async Task SetMacc(string selIdxMacc)
|
||||
@@ -151,6 +153,7 @@ namespace MP_TAB_SERV.Components
|
||||
private bool isInAttr = false;
|
||||
private bool isInProd = false;
|
||||
private bool isMulti = false;
|
||||
private bool isSlave = false;
|
||||
private bool isProcessing = false;
|
||||
|
||||
private int numDayOdl = 5;
|
||||
@@ -179,7 +182,16 @@ namespace MP_TAB_SERV.Components
|
||||
|
||||
private bool needConfProd
|
||||
{
|
||||
get => (RecMSE != null && RecMSE.PezziProd > RecMSE.PezziConf);
|
||||
get
|
||||
{
|
||||
bool answ = true;
|
||||
if (prodMacchina != null)
|
||||
{
|
||||
answ = prodMacchina.pezziNonConfermati > 0 && !isSlave;
|
||||
}
|
||||
//(RecMSE != null && RecMSE.PezziProd > RecMSE.PezziConf);
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
|
||||
private int numPz2Conf
|
||||
@@ -240,13 +252,24 @@ namespace MP_TAB_SERV.Components
|
||||
}
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private async Task ReloadData()
|
||||
private async Task ReloadData(bool forceReload)
|
||||
{
|
||||
Log.Trace("OdlMan.ReloadData");
|
||||
if (forceReload)
|
||||
{
|
||||
isSlave = MServ.ListM2S
|
||||
.Where(x => x.IdxMacchinaSlave.Equals(RecMSE?.IdxMacchina, StringComparison.InvariantCultureIgnoreCase))
|
||||
.ToList().Count > 0;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(IdxMaccSel))
|
||||
{
|
||||
ListODL = await TabDServ.VSOdlGetUnused(idxMaccParent, ShowAll, numDayOdl);
|
||||
Log.Trace($"found {ListODL.Count} rec");
|
||||
if (forceReload)
|
||||
{
|
||||
var rawData = await TabDServ.PezziProdMacchina(IdxMaccSel);
|
||||
prodMacchina = rawData.FirstOrDefault() ?? new PzProdModel();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -116,6 +116,10 @@ namespace MP_TAB_SERV.Shared
|
||||
// fix MSFD...
|
||||
var allMSFD = await TDataService.VMSFDGetAll();
|
||||
MStor.SetMsfd(allMSFD);
|
||||
// fix slave
|
||||
var macSlave = await TDataService.Macchine2Slave();
|
||||
MStor.SetM2S(macSlave);
|
||||
|
||||
// fix elenco eventi
|
||||
var allEvents = await TDataService.AnagEventiGetAll();
|
||||
MStor.SetEventi(allEvents);
|
||||
|
||||
@@ -646,6 +646,24 @@ namespace MP.Data.Controllers
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Intera tabella relazione master/slave in machine (gestione setup master --> slave)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<Macchine2SlaveModel> Macchine2Slave()
|
||||
{
|
||||
List<Macchine2SlaveModel> dbResult = new List<Macchine2SlaveModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetM2S
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.IdxMacchina)
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// MicroStato macchina (da key)
|
||||
/// </summary>
|
||||
@@ -719,6 +737,26 @@ namespace MP.Data.Controllers
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stato prod macchina
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
public List<PzProdModel> PezziProdMacchina(string idxMacchina)
|
||||
{
|
||||
List<PzProdModel> dbResult = new List<PzProdModel>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
var IdxMacchina = new SqlParameter("@IdxMacchina", idxMacchina);
|
||||
dbResult = dbCtx
|
||||
.DbSetPzProd
|
||||
.FromSqlRaw("EXEC stp_PzProd_getByMacchina @IdxMacchina", IdxMacchina)
|
||||
.AsNoTracking()
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce elenco RC filtrato
|
||||
/// </summary>
|
||||
@@ -942,6 +980,23 @@ namespace MP.Data.Controllers
|
||||
return answ;
|
||||
}
|
||||
|
||||
public bool SetDerogaSt(StCheckOverride deroga)
|
||||
{
|
||||
bool fatto = false;
|
||||
#if false
|
||||
try
|
||||
{
|
||||
string keyDerogaST = memLayer.ML.redHash($"DerogaSt:{user_std.UtSn.utente}:{deroga.IdxST:000}");
|
||||
string rawData = JsonConvert.SerializeObject(deroga);
|
||||
memLayer.ML.setRSV(keyDerogaST, rawData, 60 * 2);
|
||||
fatto = true;
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
#endif
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Intera tabella state machine eventi 2 stati
|
||||
/// </summary>
|
||||
@@ -1053,6 +1108,7 @@ namespace MP.Data.Controllers
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
public bool ST_CheckUpsert(int idxOdl, int idxST, int oggetto, int num, string valueRead, string extCode, bool checkOk, string userMod, bool forced)
|
||||
{
|
||||
bool fatto = false;
|
||||
@@ -1076,27 +1132,6 @@ namespace MP.Data.Controllers
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupero Righe pending da ODL
|
||||
/// </summary>
|
||||
/// <param name="idxODL"></param>
|
||||
/// <returns></returns>
|
||||
public List<ST_ActRow> STAR_pendByOdl(int idxODL)
|
||||
{
|
||||
List<ST_ActRow> dbResult = new List<ST_ActRow>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
var IdxODL = new SqlParameter("@IdxODL", idxODL);
|
||||
|
||||
dbResult = dbCtx
|
||||
.DbSetStActRow
|
||||
.FromSqlRaw("exec dbo.stp_ST_AR_getPendingOdl @IdxODL", IdxODL)
|
||||
.AsNoTracking()
|
||||
//.AsEnumerable()
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
/// <summary>
|
||||
/// Recupero Righe (Actual) della scheda tecnica da GRUPPO + ODL
|
||||
/// </summary>
|
||||
@@ -1147,6 +1182,28 @@ namespace MP.Data.Controllers
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupero Righe pending da ODL
|
||||
/// </summary>
|
||||
/// <param name="idxODL"></param>
|
||||
/// <returns></returns>
|
||||
public List<ST_ActRow> STAR_pendByOdl(int idxODL)
|
||||
{
|
||||
List<ST_ActRow> dbResult = new List<ST_ActRow>();
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
var IdxODL = new SqlParameter("@IdxODL", idxODL);
|
||||
|
||||
dbResult = dbCtx
|
||||
.DbSetStActRow
|
||||
.FromSqlRaw("exec dbo.stp_ST_AR_getPendingOdl @IdxODL", IdxODL)
|
||||
.AsNoTracking()
|
||||
//.AsEnumerable()
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Intera tabella state machine ingressi 2 eventi data famiglia
|
||||
/// </summary>
|
||||
@@ -1292,23 +1349,6 @@ namespace MP.Data.Controllers
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
public bool SetDerogaSt(StCheckOverride deroga)
|
||||
{
|
||||
bool fatto = false;
|
||||
#if false
|
||||
try
|
||||
{
|
||||
string keyDerogaST = memLayer.ML.redHash($"DerogaSt:{user_std.UtSn.utente}:{deroga.IdxST:000}");
|
||||
string rawData = JsonConvert.SerializeObject(deroga);
|
||||
memLayer.ML.setRSV(keyDerogaST, rawData, 60 * 2);
|
||||
fatto = true;
|
||||
}
|
||||
catch
|
||||
{ }
|
||||
#endif
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco causali scarto
|
||||
/// </summary>
|
||||
@@ -1373,6 +1413,7 @@ namespace MP.Data.Controllers
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
@@ -65,6 +65,13 @@ namespace MP.Data.Services
|
||||
/// </summary>
|
||||
public List<AnagStatiModel> ListStati { get; set; } = new List<AnagStatiModel>();
|
||||
|
||||
/// <summary>
|
||||
/// Lista macchine master2slave stati
|
||||
/// </summary>
|
||||
public List<Macchine2SlaveModel> ListM2S { get; set; } = new List<Macchine2SlaveModel>();
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Lista completa stati
|
||||
/// </summary>
|
||||
@@ -194,11 +201,17 @@ namespace MP.Data.Services
|
||||
public void SetMsfd(List<VMSFDModel> newList)
|
||||
{
|
||||
ListMSFD = newList ?? new List<VMSFDModel>();
|
||||
// salvo dizionario
|
||||
// salvo dizionario MULTI
|
||||
DictMacchMulti = ListMSFD.ToDictionary(x => x.IdxMacchina, x => x.Multi);
|
||||
Log.Info("SharedMemService | SetMsfd executed!");
|
||||
}
|
||||
|
||||
public void SetM2S(List<Macchine2SlaveModel> newList)
|
||||
{
|
||||
ListM2S = newList ?? new List<Macchine2SlaveModel>();
|
||||
Log.Info("SharedMemService | SetM2S executed!");
|
||||
}
|
||||
|
||||
public void SetStati(List<AnagStatiModel> allStati)
|
||||
{
|
||||
ListStati = allStati ?? new List<AnagStatiModel>();
|
||||
|
||||
@@ -854,6 +854,42 @@ namespace MP.Data.Services
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Intera tabella relazione master/slave in machine (gestione setup master --> slave)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<Macchine2SlaveModel>> Macchine2Slave()
|
||||
{
|
||||
// setup parametri costanti
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<Macchine2SlaveModel> result = new List<Macchine2SlaveModel>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisBaseKey}:Mach2Slave";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
//if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<Macchine2SlaveModel>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbTabController.Macchine2Slave();
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(currKey, rawData, UltraFastCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<Macchine2SlaveModel>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"Macchine2Slave | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Lista parametri correnti (ObjItemDTO) della macchina
|
||||
/// </summary>
|
||||
@@ -997,6 +1033,43 @@ namespace MP.Data.Services
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stato prod macchina
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<PzProdModel>> PezziProdMacchina(string idxMacchina)
|
||||
{
|
||||
// setup parametri costanti
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<PzProdModel> result = new List<PzProdModel>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisBaseKey}:PzProd:{idxMacchina}";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
//if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<PzProdModel>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbTabController.PezziProdMacchina(idxMacchina);
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(currKey, rawData, UltraFastCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<PzProdModel>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"PezziProdMacchina | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce elenco RC filtrato
|
||||
/// </summary>
|
||||
@@ -1406,7 +1479,6 @@ namespace MP.Data.Services
|
||||
return answ;
|
||||
}
|
||||
|
||||
|
||||
public async Task<bool> ST_CheckUpsert(int idxOdl, int idxST, int oggetto, int num, string valueRead, string extCode, bool checkOk, string userMod, bool forced)
|
||||
{
|
||||
bool answ = false;
|
||||
@@ -1463,41 +1535,6 @@ namespace MP.Data.Services
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupero Righe pending da ODL
|
||||
/// </summary>
|
||||
/// <param name="idxODL"></param>
|
||||
/// <returns></returns>
|
||||
public List<ST_ActRow> STAR_pendByOdl(int idxODL)
|
||||
{
|
||||
// setup parametri costanti
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<ST_ActRow>? result = new List<ST_ActRow>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisBaseKey}:STAR:Pend:{idxODL}";
|
||||
RedisValue rawData = redisDb.StringGet(currKey);
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<ST_ActRow>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbTabController.STAR_pendByOdl(idxODL);
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
redisDb.StringSet(currKey, rawData, TimeSpan.FromSeconds(5));
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<ST_ActRow>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"STAR_pendByOdl | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// Recupero Righe (Actual) della scheda tecnica da GRUPPO + ODL
|
||||
/// </summary>
|
||||
@@ -1575,6 +1612,42 @@ namespace MP.Data.Services
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupero Righe pending da ODL
|
||||
/// </summary>
|
||||
/// <param name="idxODL"></param>
|
||||
/// <returns></returns>
|
||||
public List<ST_ActRow> STAR_pendByOdl(int idxODL)
|
||||
{
|
||||
// setup parametri costanti
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<ST_ActRow>? result = new List<ST_ActRow>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisBaseKey}:STAR:Pend:{idxODL}";
|
||||
RedisValue rawData = redisDb.StringGet(currKey);
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<ST_ActRow>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbTabController.STAR_pendByOdl(idxODL);
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
redisDb.StringSet(currKey, rawData, TimeSpan.FromSeconds(5));
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<ST_ActRow>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"STAR_pendByOdl | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Stato macchina
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user