COndizionata visibilità a dati temp/vc19 rilevati
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
@using CORE.Data.DbModels
|
||||
@using UI.Data
|
||||
|
||||
@inject IJSRuntime JSRuntime
|
||||
@inject GpwDataService GDataServ
|
||||
@inject MessageService AppMServ
|
||||
|
||||
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header bg-dark text-light py-1">
|
||||
<div class="row">
|
||||
@@ -20,24 +20,68 @@
|
||||
<div class="row">
|
||||
<div class="col-4">
|
||||
gestione temperature rilevate + insert quotidiano <b>@TargetDate.ToShortDateString()</b>
|
||||
@if (currRecord != null)
|
||||
{
|
||||
<div>
|
||||
Temp odierna
|
||||
<b>@currRecord.TempRil</b>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<LoadingDataSmall></LoadingDataSmall>
|
||||
}
|
||||
</div>
|
||||
<div class="col-4">
|
||||
<ChartHist Id="FreqTemp1" Data="@(new[] { "5", "8", "10", "6", "4", "3" })" Labels="@(new[] { "35.8", "35.9", "36.0", "36.1", "36.2", "36.3" })" lineColor="rgb(7, 173, 236)" backColor="rgba(107, 223, 255, 0.5)"></ChartHist>
|
||||
<ChartHist Id="FreqTemp2" Data="@(new[] { "5", "8", "10", "6", "4", "3" })" Labels="@(new[] { "35.8", "35.9", "36.0", "36.1", "36.2", "36.3" })" lineColor="rgb(7, 173, 236)" backColor="rgba(107, 223, 255, 0.5)"></ChartHist>
|
||||
@if (listRilTemp != null)
|
||||
{
|
||||
<ChartHist Id="FreqTemp1" Data="@(new[] { "5", "8", "10", "6", "4", "3" })" Labels="@(new[] { "35.8", "35.9", "36.0", "36.1", "36.2", "36.3" })" lineColor="rgb(7, 173, 236)" backColor="rgba(107, 223, 255, 0.5)"></ChartHist>
|
||||
<ChartHist Id="FreqTemp2" Data="@(new[] { "5", "8", "10", "6", "1", "2", "1", "2" })" Labels="@(new[] { "35.8", "35.9", "36.0", "36.1", "36.2", "36.3", "36.2", "36.3" })" lineColor="rgb(7, 173, 236)" backColor="rgba(107, 223, 255, 0.5)"></ChartHist>
|
||||
}
|
||||
else
|
||||
{
|
||||
<LoadingDataSmall></LoadingDataSmall>
|
||||
}
|
||||
</div>
|
||||
<div class="col-4">
|
||||
elenco ultimi check VC19...
|
||||
@if (listVC19 != null)
|
||||
{
|
||||
<p>elenco ultimi check VC19...</p>
|
||||
}
|
||||
else
|
||||
{
|
||||
<LoadingDataSmall></LoadingDataSmall>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
private int numDays = 60;
|
||||
|
||||
[Parameter]
|
||||
public EventCallback<bool> CloseReq { get; set; }
|
||||
[Parameter]
|
||||
public DateTime TargetDate { get; set; } = DateTime.Today;
|
||||
public DateTime TargetDate
|
||||
{
|
||||
get
|
||||
{
|
||||
return _targetDate;
|
||||
}
|
||||
set
|
||||
{
|
||||
_targetDate = value;
|
||||
var pUpd = Task.Run(async () => await ReloadData());
|
||||
pUpd.Wait();
|
||||
}
|
||||
}
|
||||
|
||||
protected DateTime _targetDate { get; set; } = DateTime.Today;
|
||||
|
||||
protected List<RilievoTempModel>? listRilTemp { get; set; } = null;
|
||||
protected List<CheckVc19Model>? listVC19 { get; set; } = null;
|
||||
protected RilievoTempModel? currRecord { get; set; } = null;
|
||||
|
||||
/// <summary>
|
||||
/// Indico item selezionato
|
||||
@@ -47,4 +91,14 @@
|
||||
await CloseReq.InvokeAsync(true);
|
||||
}
|
||||
|
||||
|
||||
|
||||
protected async Task ReloadData()
|
||||
{
|
||||
// recupero dati completi...
|
||||
listRilTemp = await GDataServ.RilTempList(AppMServ.IdxDipendente, TargetDate.AddDays(1 - numDays), TargetDate.AddDays(1));
|
||||
listVC19 = await GDataServ.CheckVC19List(AppMServ.IdxDipendente, TargetDate.AddDays(1 - numDays), TargetDate.AddDays(1));
|
||||
// cerco se c'è dato odierno della temperatura...
|
||||
currRecord = listRilTemp.Where(x => x.DtRilievo == TargetDate).FirstOrDefault();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -49,6 +49,8 @@ namespace GPW.CORE.UI.Data
|
||||
protected const string rKeyParetoRegAtt = "Cache:ParetoRegAtt";
|
||||
protected const string rKeyProjAll = "Cache:ProjAll";
|
||||
protected const string rKeyWeekStats = "Cache:WeekStats";
|
||||
protected const string rKeyRilTemp = "Cache:RilTemp";
|
||||
protected const string rKeyVC19 = "Cache:VC19";
|
||||
protected static string connStringBBM = "";
|
||||
|
||||
#endregion Protected Fields
|
||||
@@ -268,6 +270,7 @@ namespace GPW.CORE.UI.Data
|
||||
{
|
||||
CalcOreProgettiModel? dbResult = new CalcOreProgettiModel();
|
||||
string currKey = $"{rKeyCalcOreProj}:{idxProj}";
|
||||
trackCache(currKey);
|
||||
|
||||
string rawData;
|
||||
var redisDataList = await distributedCache.GetAsync(currKey);
|
||||
@@ -294,6 +297,85 @@ namespace GPW.CORE.UI.Data
|
||||
}
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera l'elenco dei Rilievi temperatura nel periodo indicato x dipendente
|
||||
/// </summary>
|
||||
/// <param name="idxDipendente">Dipendente interessato</param>
|
||||
/// <param name="dtInizio">Data di riferimento (ultima/corrente)</param>
|
||||
/// <param name="dtFine">NUm settimane precedenti da recuperare</param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<RilievoTempModel>> RilTempList(int idxDipendente, DateTime dtInizio, DateTime dtFine)
|
||||
{
|
||||
List<RilievoTempModel>? dbResult = new List<RilievoTempModel>();
|
||||
string currKey = $"{rKeyRilTemp}:{dtInizio:yyyyMMdd}:{dtFine:yyyMMdd}";
|
||||
trackCache(currKey);
|
||||
|
||||
string rawData;
|
||||
var redisDataList = await distributedCache.GetAsync(currKey);
|
||||
if (redisDataList != null)
|
||||
{
|
||||
rawData = Encoding.UTF8.GetString(redisDataList);
|
||||
dbResult = JsonConvert.DeserializeObject<List<RilievoTempModel>>(rawData);
|
||||
}
|
||||
else
|
||||
{
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = dbController.RilTempList(idxDipendente, dtInizio, dtFine);
|
||||
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
|
||||
redisDataList = Encoding.UTF8.GetBytes(rawData);
|
||||
await distributedCache.SetAsync(currKey, redisDataList, cacheOpt(true));
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB + caching per RilTempList: {ts.TotalMilliseconds} ms");
|
||||
}
|
||||
if (dbResult == null)
|
||||
{
|
||||
dbResult = new List<RilievoTempModel>();
|
||||
}
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupera l'elenco dei controlli VC19 nel periodo indicato x dipendente
|
||||
/// </summary>
|
||||
/// <param name="idxDipendente">Dipendente interessato</param>
|
||||
/// <param name="dtInizio">Data di riferimento (ultima/corrente)</param>
|
||||
/// <param name="dtFine">NUm settimane precedenti da recuperare</param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<CheckVc19Model>> CheckVC19List(int idxDipendente, DateTime dtInizio, DateTime dtFine)
|
||||
{
|
||||
List<CheckVc19Model>? dbResult = new List<CheckVc19Model>();
|
||||
string currKey = $"{rKeyVC19}:{dtInizio:yyyyMMdd}:{dtFine:yyyMMdd}";
|
||||
trackCache(currKey);
|
||||
|
||||
string rawData;
|
||||
var redisDataList = await distributedCache.GetAsync(currKey);
|
||||
if (redisDataList != null)
|
||||
{
|
||||
rawData = Encoding.UTF8.GetString(redisDataList);
|
||||
dbResult = JsonConvert.DeserializeObject<List<CheckVc19Model>>(rawData);
|
||||
}
|
||||
else
|
||||
{
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = dbController.CheckVC19List(idxDipendente, dtInizio, dtFine);
|
||||
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
|
||||
redisDataList = Encoding.UTF8.GetBytes(rawData);
|
||||
await distributedCache.SetAsync(currKey, redisDataList, cacheOpt(true));
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB + caching per CheckVC19List: {ts.TotalMilliseconds} ms");
|
||||
}
|
||||
if (dbResult == null)
|
||||
{
|
||||
dbResult = new List<CheckVc19Model>();
|
||||
}
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registra in cache chiave se non fosse già in elenco
|
||||
/// </summary>
|
||||
@@ -509,184 +591,11 @@ namespace GPW.CORE.UI.Data
|
||||
return answ;
|
||||
}
|
||||
|
||||
#if false
|
||||
public async Task<List<MaterialDTO>> MaterialsGetAll()
|
||||
{
|
||||
List<MaterialDTO>? dbResult = new List<MaterialDTO>();
|
||||
string rawData;
|
||||
var redisDataList = await distributedCache.GetAsync(rKeyDipendenti);
|
||||
if (redisDataList != null)
|
||||
{
|
||||
rawData = Encoding.UTF8.GetString(redisDataList);
|
||||
dbResult = JsonConvert.DeserializeObject<List<MaterialDTO>>(rawData);
|
||||
}
|
||||
else
|
||||
{
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = dbController.MaterialsGetAll();
|
||||
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
|
||||
redisDataList = Encoding.UTF8.GetBytes(rawData);
|
||||
await distributedCache.SetAsync(rKeyDipendenti, redisDataList, cacheOpt(false));
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB + caching per GetMaterials: {ts.TotalMilliseconds} ms");
|
||||
}
|
||||
if (dbResult == null)
|
||||
{
|
||||
dbResult = new List<MaterialDTO>();
|
||||
}
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
public async Task<List<MovMagModel>> MovMagGetFilt(int RemnId, int numShow)
|
||||
{
|
||||
List<MovMagModel> dbResult = new List<MovMagModel>();
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
dbResult = dbController.MovMagGetFilt(RemnId, numShow);
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB + caching per MovMagGetFilt: {ts.TotalMilliseconds} ms");
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
public async Task<bool> AddPrintJob(int RemnId)
|
||||
{
|
||||
bool answ = dbController.AddPrintJob("docRemnant", $"{RemnId}", "queueRemnants");
|
||||
return await Task.FromResult(answ);
|
||||
}
|
||||
|
||||
public async Task<List<RemnantsModel>> RemnantsGetFilt(int matId, int minQty)
|
||||
{
|
||||
List<RemnantsModel>? dbResult = new List<RemnantsModel>();
|
||||
string rawData;
|
||||
string cacheKey = $"{rKeyRemnants}:{matId}:{minQty}";
|
||||
if (!cachedDataList.Contains(cacheKey))
|
||||
{
|
||||
cachedDataList.Add(cacheKey);
|
||||
}
|
||||
|
||||
var redisDataList = await distributedCache.GetAsync(cacheKey);
|
||||
if (redisDataList != null)
|
||||
{
|
||||
rawData = Encoding.UTF8.GetString(redisDataList);
|
||||
dbResult = JsonConvert.DeserializeObject<List<RemnantsModel>>(rawData);
|
||||
}
|
||||
else
|
||||
{
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
var rawList = dbController.RemnantsGetFilt(matId, minQty);
|
||||
dbResult = rawList.OrderBy(o => o.Area).ToList();
|
||||
rawData = JsonConvert.SerializeObject(dbResult, JSSettings);
|
||||
redisDataList = Encoding.UTF8.GetBytes(rawData);
|
||||
await distributedCache.SetAsync(cacheKey, redisDataList, cacheOpt(false));
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB + caching per RemnantsGetAll: {ts.TotalMilliseconds} ms");
|
||||
}
|
||||
if (dbResult == null)
|
||||
{
|
||||
dbResult = new List<RemnantsModel>();
|
||||
}
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
public async Task<bool> RemnantsIsDupl(RemnantsModel currItem)
|
||||
{
|
||||
bool answ = false;
|
||||
var rawList = dbController.RemnantsGetFilt(currItem.MatID, 0);
|
||||
var duplicati = rawList
|
||||
.Where(x => x.RemnID != currItem.RemnID && x.LMm == currItem.LMm && x.WMm == currItem.WMm && x.TMm == currItem.TMm)
|
||||
.ToList();
|
||||
answ = duplicati.Count > 0;
|
||||
return await Task.FromResult(answ);
|
||||
}
|
||||
|
||||
public async Task<bool> RemnantsMovMag(RemnantsModel currItem, string userId, int deltaQty)
|
||||
{
|
||||
bool done = false;
|
||||
try
|
||||
{
|
||||
// recupero item da DB
|
||||
var currRecord = dbController.RemnantGetByid(currItem.RemnID);
|
||||
if (currRecord != null && currRecord.RemnID == currItem.RemnID)
|
||||
{
|
||||
// modifico qty entro limiti >=0..
|
||||
if (currRecord.QtyAvail + deltaQty >= 0)
|
||||
{
|
||||
currRecord.QtyAvail = currRecord.QtyAvail + deltaQty;
|
||||
done = dbController.RemnantsUpsert(currRecord, userId);
|
||||
await InvalidateAllCache();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in RemnantsMovMag:{Environment.NewLine}{exc}");
|
||||
}
|
||||
return await Task.FromResult(done);
|
||||
}
|
||||
|
||||
public async Task<bool> RemnantsUpsert(RemnantsModel currItem, string userId)
|
||||
{
|
||||
bool done = false;
|
||||
try
|
||||
{
|
||||
done = dbController.RemnantsUpsert(currItem, userId);
|
||||
await InvalidateAllCache();
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in RemnantsUpsert:{Environment.NewLine}{exc}");
|
||||
}
|
||||
return await Task.FromResult(done);
|
||||
}
|
||||
#endif
|
||||
|
||||
public void rollBackEdit(object item)
|
||||
{
|
||||
dbController.rollBackEntity(item);
|
||||
}
|
||||
|
||||
#if false
|
||||
public async Task<RemnantsModel> SearchQrRemnant(string QrCode)
|
||||
{
|
||||
RemnantsModel? answ = new RemnantsModel();
|
||||
string rawData = "";
|
||||
string cacheKey = $"{rKeyQrRemnants}:{QrCode}";
|
||||
// cerco in redis
|
||||
var redisData = await distributedCache.GetAsync(cacheKey);
|
||||
if (redisData != null)
|
||||
{
|
||||
rawData = Encoding.UTF8.GetString(redisData);
|
||||
answ = JsonConvert.DeserializeObject<RemnantsModel>(rawData);
|
||||
}
|
||||
// se non trovo cerco su DB
|
||||
else
|
||||
{
|
||||
Stopwatch stopWatch = new Stopwatch();
|
||||
stopWatch.Start();
|
||||
var foundItem = dbController.RemnantGetByQr(QrCode);
|
||||
if (foundItem != null && foundItem.RemDtmx == QrCode)
|
||||
{
|
||||
rawData = JsonConvert.SerializeObject(foundItem, JSSettings);
|
||||
redisData = Encoding.UTF8.GetBytes(rawData);
|
||||
await distributedCache.SetAsync(cacheKey, redisData, cacheOpt(false));
|
||||
answ = foundItem;
|
||||
}
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
Log.Trace($"Effettuata lettura da DB + caching per SearchQrRemnant: {ts.TotalMilliseconds} ms");
|
||||
}
|
||||
if (answ == null)
|
||||
{
|
||||
answ = new RemnantsModel();
|
||||
}
|
||||
return await Task.FromResult(answ);
|
||||
}
|
||||
#endif
|
||||
|
||||
public async Task<bool> TimbratureDelete(TimbratureModel currItem)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user