diff --git a/GPW.CORE.UI/Components/DayCheckEditor.razor b/GPW.CORE.UI/Components/DayCheckEditor.razor index 0cfa87a..f604ac2 100644 --- a/GPW.CORE.UI/Components/DayCheckEditor.razor +++ b/GPW.CORE.UI/Components/DayCheckEditor.razor @@ -1,10 +1,10 @@ @using CORE.Data.DbModels @using UI.Data +@inject IJSRuntime JSRuntime +@inject GpwDataService GDataServ @inject MessageService AppMServ - -
@@ -20,24 +20,68 @@
gestione temperature rilevate + insert quotidiano @TargetDate.ToShortDateString() + @if (currRecord != null) + { +
+ Temp odierna + @currRecord.TempRil +
+ } + else + { + + }
- - + @if (listRilTemp != null) + { + + + } + else + { + + }
- elenco ultimi check VC19... + @if (listVC19 != null) + { +

elenco ultimi check VC19...

+ } + else + { + + }
@code { + private int numDays = 60; [Parameter] public EventCallback 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? listRilTemp { get; set; } = null; + protected List? listVC19 { get; set; } = null; + protected RilievoTempModel? currRecord { get; set; } = null; /// /// 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(); + } } diff --git a/GPW.CORE.UI/Data/GpwDataService.cs b/GPW.CORE.UI/Data/GpwDataService.cs index c5685c4..af27522 100644 --- a/GPW.CORE.UI/Data/GpwDataService.cs +++ b/GPW.CORE.UI/Data/GpwDataService.cs @@ -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); } + + /// + /// Recupera l'elenco dei Rilievi temperatura nel periodo indicato x dipendente + /// + /// Dipendente interessato + /// Data di riferimento (ultima/corrente) + /// NUm settimane precedenti da recuperare + /// + public async Task> RilTempList(int idxDipendente, DateTime dtInizio, DateTime dtFine) + { + List? dbResult = new List(); + 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>(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(); + } + return await Task.FromResult(dbResult); + } + + /// + /// Recupera l'elenco dei controlli VC19 nel periodo indicato x dipendente + /// + /// Dipendente interessato + /// Data di riferimento (ultima/corrente) + /// NUm settimane precedenti da recuperare + /// + public async Task> CheckVC19List(int idxDipendente, DateTime dtInizio, DateTime dtFine) + { + List? dbResult = new List(); + 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>(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(); + } + return await Task.FromResult(dbResult); + } + /// /// Registra in cache chiave se non fosse già in elenco /// @@ -509,184 +591,11 @@ namespace GPW.CORE.UI.Data return answ; } -#if false - public async Task> MaterialsGetAll() - { - List? dbResult = new List(); - string rawData; - var redisDataList = await distributedCache.GetAsync(rKeyDipendenti); - if (redisDataList != null) - { - rawData = Encoding.UTF8.GetString(redisDataList); - dbResult = JsonConvert.DeserializeObject>(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(); - } - return await Task.FromResult(dbResult); - } - - public async Task> MovMagGetFilt(int RemnId, int numShow) - { - List dbResult = new List(); - 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 AddPrintJob(int RemnId) - { - bool answ = dbController.AddPrintJob("docRemnant", $"{RemnId}", "queueRemnants"); - return await Task.FromResult(answ); - } - - public async Task> RemnantsGetFilt(int matId, int minQty) - { - List? dbResult = new List(); - 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>(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(); - } - return await Task.FromResult(dbResult); - } - - public async Task 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 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 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 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(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 TimbratureDelete(TimbratureModel currItem) {