179 lines
6.5 KiB
Plaintext
179 lines
6.5 KiB
Plaintext
@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">
|
|
<div class="col-8">
|
|
<h4>Daily Cheks</h4>
|
|
</div>
|
|
<div class="col-4 py-1">
|
|
<button type="button" class="btn btn-block btn-warning py-1" @onclick="DoClose"><i class="fas fa-times"></i> Chiudi</button>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
<div class="card-body text-center">
|
|
<div class="row">
|
|
<div class="col-4">
|
|
<div class="card">
|
|
<div class="card-header text-center">
|
|
<b>@TargetDate.ToString("ddd dd/MM/yyyy")</b>
|
|
</div>
|
|
<div class="card-body">
|
|
@if (currRecord != null)
|
|
{
|
|
<div class="input-group">
|
|
<div class="input-group-prepend">
|
|
<span class="input-group-text">
|
|
<i class="fas fa-thermometer-half"></i>
|
|
</span>
|
|
</div>
|
|
<input type="number" @bind="@currRecord.TempRil"></input>
|
|
<div class="input-group-append">
|
|
<button class="btn btn-success btn-block" title="Salva temperatura" @onclick="() => DoSave()"><i class="far fa-save"></i></button>
|
|
</div>
|
|
</div>
|
|
}
|
|
else
|
|
{
|
|
<LoadingDataSmall></LoadingDataSmall>
|
|
}
|
|
</div>
|
|
<div class="card-footer">
|
|
<div class="input-group">
|
|
<div class="input-group-prepend">
|
|
<span class="input-group-text" style="width:3em;">
|
|
<i class="far fa-calendar-alt"></i>
|
|
</span>
|
|
</div>
|
|
<select @bind="@numDays" class="form-control" title="finestra analisi">
|
|
<option value="30">1 Mese</option>
|
|
<option value="60">2 Mese</option>
|
|
<option value="90">3 Mese</option>
|
|
<option value="180">6 Mese</option>
|
|
<option value="365">1 Anno</option>
|
|
<option value="730">2 Anno</option>
|
|
</select>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
</div>
|
|
<div class="col-4">
|
|
@if (listRilTemp != null)
|
|
{
|
|
<ChartTS Id="TempRil" DataTS="@listRilTemp" lineColor="rgb(7, 173, 236)" backColor="rgba(107, 223, 255, 0.3)"></ChartTS>
|
|
<ChartHist Id="FreqTemp1" Data="@histData" Labels="@histLabel" lineColor="rgb(7, 173, 236)" backColor="rgba(107, 223, 255, 0.5)"></ChartHist>
|
|
}
|
|
else
|
|
{
|
|
<LoadingDataSmall></LoadingDataSmall>
|
|
}
|
|
</div>
|
|
<div class="col-4">
|
|
@if (listVC19 != null)
|
|
{
|
|
<p>elenco ultimi check VC19...</p>
|
|
}
|
|
else
|
|
{
|
|
<LoadingDataSmall></LoadingDataSmall>
|
|
}
|
|
</div>
|
|
</div>
|
|
</div>
|
|
</div>
|
|
|
|
@code {
|
|
private int numDays
|
|
{
|
|
get
|
|
{
|
|
return _numDays;
|
|
}
|
|
set
|
|
{
|
|
_numDays = value;
|
|
var pUpd = Task.Run(async () => await ReloadData());
|
|
pUpd.Wait();
|
|
}
|
|
}
|
|
|
|
[Parameter]
|
|
public EventCallback<bool> CloseReq { get; set; }
|
|
[Parameter]
|
|
public DateTime TargetDate
|
|
{
|
|
get
|
|
{
|
|
return _targetDate;
|
|
}
|
|
set
|
|
{
|
|
_targetDate = value;
|
|
var pUpd = Task.Run(async () => await ReloadData());
|
|
pUpd.Wait();
|
|
}
|
|
}
|
|
|
|
protected int _numDays = 30;
|
|
protected DateTime _targetDate { get; set; } = DateTime.Today;
|
|
|
|
protected List<chartJsData.chartJsTSerie>? listRilTemp { get; set; } = null;
|
|
protected List<CheckVc19Model>? listVC19 { get; set; } = null;
|
|
protected RilievoTempModel? currRecord { get; set; } = null;
|
|
protected string[]? histData { get; set; } = null;
|
|
protected string[]? histLabel { get; set; } = null;
|
|
|
|
/// <summary>
|
|
/// Indico item selezionato
|
|
/// </summary>
|
|
protected async void DoClose()
|
|
{
|
|
await CloseReq.InvokeAsync(true);
|
|
}
|
|
|
|
|
|
|
|
protected async Task ReloadData()
|
|
{
|
|
// recupero dati completi...
|
|
var rawData = 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));
|
|
// calcolo dati derivati
|
|
listRilTemp = rawData
|
|
.Select(r => new chartJsData.chartJsTSerie() { x = r.DtRilievo, y = r.TempRil })
|
|
.ToList();
|
|
// calcolo hist frequenza con EFCore: https://entityframeworkcore.com/knowledge-base/60871048/group-by-and-to-dictionary-in-ef-core-3-1
|
|
var histDict = rawData
|
|
.GroupBy(r => r.TempRil.ToString("N1"))
|
|
.Select(g => new { g.Key, Count = g.Count() })
|
|
.OrderBy(d => d.Key)
|
|
.ToDictionary(x => x.Key, x => x.Count.ToString());
|
|
histData = histDict.Values.ToArray();
|
|
histLabel = histDict.Keys.ToArray();
|
|
// cerco se c'è dato odierno della temperatura...
|
|
currRecord = rawData.Where(x => x.DtRilievo == TargetDate).FirstOrDefault();
|
|
if (currRecord == null)
|
|
{
|
|
currRecord = new RilievoTempModel()
|
|
{
|
|
DtRilievo = DateTime.Now,
|
|
TempRil = 0
|
|
};
|
|
}
|
|
}
|
|
// effettua salvataggio misurazione temperatura
|
|
protected async void DoSave()
|
|
{
|
|
// chiamo classe gestione che salva e resetta cache dati...
|
|
|
|
// chiamo chiusura!
|
|
await CloseReq.InvokeAsync(true);
|
|
}
|
|
}
|