Completato gestione FastRec (da provare...)
This commit is contained in:
@@ -305,7 +305,7 @@ namespace GPW.CORE.UI.Data
|
||||
public async Task<List<CORE.Data.DTO.DailyDataDTO>> DailyDetails(int idxDipendente, DateTime dtInizio, DateTime dtFine)
|
||||
{
|
||||
List<CORE.Data.DTO.DailyDataDTO>? dbResult = new List<CORE.Data.DTO.DailyDataDTO>();
|
||||
string currKey = $"{rKeyDailyData}:{idxDipendente}:{dtInizio.ToString("yyyy-MM-dd")}:{dtInizio.ToString("yyyy-MM-dd")}";
|
||||
string currKey = $"{rKeyDailyData}:{idxDipendente}:{dtInizio.ToString("yyyy-MM-dd")}:{dtFine.ToString("yyyy-MM-dd")}";
|
||||
if (!cachedDataList.Contains(currKey))
|
||||
{
|
||||
cachedDataList.Add(currKey);
|
||||
|
||||
@@ -2,6 +2,13 @@
|
||||
|
||||
@using GPW.CORE.UI
|
||||
@using GPW.CORE.UI.Components
|
||||
@using CORE.Data.DbModels
|
||||
@using CORE.Data.DTO
|
||||
@using UI.Data
|
||||
|
||||
@inject IJSRuntime JSRuntime
|
||||
@inject GpwDataService GDataServ
|
||||
@inject MessageService AppMServ
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header table-primary">
|
||||
@@ -50,7 +57,11 @@
|
||||
}
|
||||
</div>
|
||||
<div class="col-12">
|
||||
display della SOLA giornata corrente (titolo + riga)...
|
||||
<DayHoriz IsTitle="true" StartHour="@startHour" EndHour="@endHour" ListFasi="@ListFasi" IdxDipSel="@idxDipendente"></DayHoriz>
|
||||
@foreach (var currItem in ListRecords)
|
||||
{
|
||||
<DayHoriz DayDTO="@currItem" StartHour="@startHour" EndHour="@endHour" ListFasi="@ListFasi" IdxDipSel="@idxDipendente"></DayHoriz>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
@@ -60,6 +71,8 @@
|
||||
|
||||
@code {
|
||||
|
||||
private List<AnagFasiModel> ListFasi = new List<AnagFasiModel>();
|
||||
private List<DailyDataDTO> ListRecords = new List<DailyDataDTO>();
|
||||
private int _tipoSearch = 0;
|
||||
|
||||
public int TipoSearch
|
||||
@@ -78,8 +91,16 @@
|
||||
}
|
||||
}
|
||||
|
||||
protected int startHour = 7;
|
||||
protected int endHour = 21;
|
||||
protected bool isLoading = false;
|
||||
private int idxFaseSel = 0;
|
||||
|
||||
private int idxDipendente
|
||||
{
|
||||
get => AppMServ.IdxDipendente;
|
||||
}
|
||||
|
||||
private void SelFase(int idxFase)
|
||||
{
|
||||
idxFaseSel = idxFase;
|
||||
@@ -89,4 +110,79 @@
|
||||
{
|
||||
idxFaseSel = 0;
|
||||
}
|
||||
|
||||
private async Task ReloadData()
|
||||
{
|
||||
isLoading = true;
|
||||
DateTime oggi = DateTime.Today;
|
||||
var rawData=await GDataServ.DailyDetails(idxDipendente, oggi, oggi.AddDays(1));
|
||||
ListRecords = rawData.Where(x=> x.DtRif==oggi).ToList();
|
||||
await Task.Delay(100);
|
||||
checkHourRange();
|
||||
await Task.Delay(100);
|
||||
isLoading = false;
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
private void checkHourRange()
|
||||
{
|
||||
int minHour = 9;
|
||||
int maxHour = 18;
|
||||
if (ListRecords != null)
|
||||
{
|
||||
int roundMin = 15;
|
||||
// per ogni giornata
|
||||
foreach (var giornata in ListRecords)
|
||||
{
|
||||
var minRecTimb = giornata.ListTimbr
|
||||
.Where(x => x.Entrata == true)
|
||||
.OrderBy(x => x.DataOra)
|
||||
.FirstOrDefault();
|
||||
if (minRecTimb != null)
|
||||
{
|
||||
if (minHour > minRecTimb.DataOra.AddMinutes(-roundMin).Hour)
|
||||
{
|
||||
minHour = minRecTimb.DataOra.AddMinutes(-roundMin).Hour;
|
||||
}
|
||||
}
|
||||
var minRecRa = giornata.ListRA
|
||||
.OrderBy(x => x.Inizio)
|
||||
.FirstOrDefault();
|
||||
if (minRecRa != null)
|
||||
{
|
||||
if (minHour > minRecRa.Inizio.AddMinutes(-roundMin).Hour)
|
||||
{
|
||||
minHour = minRecRa.Inizio.AddMinutes(-roundMin).Hour;
|
||||
}
|
||||
}
|
||||
var maxRecTimb = giornata.ListTimbr
|
||||
.Where(x => x.Entrata == false)
|
||||
.OrderByDescending(x => x.DataOra)
|
||||
.FirstOrDefault();
|
||||
if (maxRecTimb != null)
|
||||
{
|
||||
if (maxHour < maxRecTimb.DataOra.AddMinutes(roundMin).Hour + 1)
|
||||
{
|
||||
maxHour = maxRecTimb.DataOra.AddMinutes(roundMin).Hour + 1;
|
||||
}
|
||||
}
|
||||
var maxRecRa = giornata.ListRA
|
||||
.OrderByDescending(x => x.Fine)
|
||||
.FirstOrDefault();
|
||||
if (maxRecRa != null)
|
||||
{
|
||||
if (maxHour < maxRecRa.Fine.AddMinutes(roundMin).Hour + 1)
|
||||
{
|
||||
maxHour = maxRecRa.Fine.AddMinutes(roundMin).Hour + 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
startHour = minHour;
|
||||
endHour = maxHour;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user