5722ad4167
- porting blazor 8.0 - riorganizzazione area components - add componenti da 6 - spostamento ver 6 a old (migrata comunque)
537 lines
16 KiB
C#
537 lines
16 KiB
C#
using GPW.CORE.Data.DbModels;
|
|
using GPW.CORE.Data.DTO;
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
namespace GPW.CORE.WRKLOG.Components.Compo
|
|
{
|
|
public partial class DayHoriz
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public DailyDataDTO? DayDTO { get; set; }
|
|
|
|
[Parameter]
|
|
public DateTime DtRif { get; set; } = DateTime.MinValue.Date;
|
|
|
|
[Parameter]
|
|
public bool EnableActionMenu { get; set; } = true;
|
|
|
|
[Parameter]
|
|
public int EndHour { get; set; }
|
|
|
|
[Parameter]
|
|
public int IdxDipSel { get; set; } = 0;
|
|
|
|
[Parameter]
|
|
public bool IsTitle { get; set; } = false;
|
|
|
|
[Parameter]
|
|
public EventCallback<RegAttivitaModel> ItemSelected { get; set; }
|
|
|
|
[Parameter]
|
|
public EventCallback<RegAttivitaModel> ItemUpdated { get; set; }
|
|
|
|
[Parameter]
|
|
public List<AnagFasiModel> ListFasi { get; set; } = null!;
|
|
|
|
[Parameter]
|
|
public bool MultiUser { get; set; } = false;
|
|
|
|
[Parameter]
|
|
public EventCallback<DailyDataDTO> PeriodSelected { get; set; }
|
|
|
|
[Parameter]
|
|
public EventCallback<DailyDataDTO> ReqDayAgenda { get; set; }
|
|
|
|
[Parameter]
|
|
public EventCallback<DateTime> ReqTempList { get; set; }
|
|
|
|
[Parameter]
|
|
public int StartHour { get; set; }
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Fields
|
|
|
|
/// <summary>
|
|
/// record prima timbratura x inserimento
|
|
/// </summary>
|
|
protected DateTime FirstTimb = DateTime.Now;
|
|
|
|
#endregion Protected Fields
|
|
|
|
#region Protected Properties
|
|
|
|
protected string cStyle
|
|
{
|
|
get
|
|
{
|
|
int numBlock = ListRegAtt().Count;
|
|
string fSize = "1.1rem";
|
|
if (numBlock > 9)
|
|
{
|
|
fSize = "0.85rem";
|
|
}
|
|
else if (numBlock > 7)
|
|
{
|
|
fSize = "0.9rem";
|
|
}
|
|
else if (numBlock > 5)
|
|
{
|
|
fSize = "1.0rem";
|
|
}
|
|
return $"font-size: {fSize};";
|
|
}
|
|
}
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
/// <summary>
|
|
/// Indico item selezionato
|
|
/// </summary>
|
|
protected async void PeriodoSelected(PeriodoDTO selPeriodo)
|
|
{
|
|
if (DayDTO != null)
|
|
{
|
|
await PeriodSelected.InvokeAsync(DayDTO);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Indico item selezionato
|
|
/// </summary>
|
|
protected async void ReportCloned()
|
|
{
|
|
await ItemSelected.InvokeAsync(null);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Indico item selezionato
|
|
/// </summary>
|
|
protected async void ReportSelected(RegAttivitaModel selRecord)
|
|
{
|
|
await ItemSelected.InvokeAsync(selRecord);
|
|
}
|
|
|
|
/// <summary>
|
|
/// Indico item aggiornato
|
|
/// </summary>
|
|
protected async void ReportUpdated()
|
|
{
|
|
await ItemUpdated.InvokeAsync(null);
|
|
}
|
|
|
|
protected async void SelDayAgenda()
|
|
{
|
|
if (DayDTO != null)
|
|
{
|
|
await ReqDayAgenda.InvokeAsync(DayDTO);
|
|
}
|
|
}
|
|
|
|
protected async void SelTemperature()
|
|
{
|
|
if (DayDTO != null)
|
|
{
|
|
await ReqTempList.InvokeAsync(DayDTO.DtRif);
|
|
}
|
|
}
|
|
|
|
protected async void SelTimbrature()
|
|
{
|
|
if (DayDTO != null)
|
|
{
|
|
await PeriodSelected.InvokeAsync(DayDTO);
|
|
}
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Properties
|
|
|
|
private string Cognome
|
|
{
|
|
get
|
|
{
|
|
string answ = "NA";
|
|
if (DayDTO != null)
|
|
{
|
|
answ = DayDTO.TimbrExpl.CognomeNome.Split(" ")[0] ?? " NA";
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
private string cssBadgeLav
|
|
{
|
|
get
|
|
{
|
|
string bCtr = "btn";
|
|
string answ = $"{bCtr}-light";
|
|
var deltaComm = oreComm - oreLav;
|
|
if (Math.Abs(deltaComm) < 0.5)
|
|
{
|
|
answ = $"{bCtr}-primary bg-opacity-75";
|
|
}
|
|
else if (Math.Abs(deltaComm) < 1)
|
|
{
|
|
answ = $"{bCtr}-warning";
|
|
}
|
|
else
|
|
{
|
|
answ = $"{bCtr}-danger";
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
private string cssCheck
|
|
{
|
|
get => OkVC19 ? "text-success" : "text-secondary";
|
|
}
|
|
|
|
private string cssThermo
|
|
{
|
|
get
|
|
{
|
|
string answ = "";
|
|
// verifico in base a ok temp o meno...
|
|
if (OkTemp)
|
|
{
|
|
// colore in base al valore...
|
|
var currTemp = tempRil;
|
|
if (currTemp >= (decimal)37.5)
|
|
{
|
|
answ = "text-danger";
|
|
}
|
|
else if (currTemp >= 37)
|
|
{
|
|
answ = "text-warning";
|
|
}
|
|
else
|
|
{
|
|
answ = "text-success";
|
|
}
|
|
}
|
|
else
|
|
{
|
|
answ = "text-secondary";
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
private string dayCardCss
|
|
{
|
|
get => hasTimb ? "border border-dark text-dark rounded shadow" : "text-secondary rounded";
|
|
}
|
|
|
|
private bool hasFerie
|
|
{
|
|
get => DayDTO != null && DayDTO.ListFerieDip != null;
|
|
}
|
|
|
|
private bool hasFest
|
|
{
|
|
get => DayDTO != null && DayDTO.ListFermateAzienda != null;
|
|
}
|
|
|
|
private bool hasPerm
|
|
{
|
|
get => DayDTO != null && DayDTO.ListRichiesteDip != null;
|
|
}
|
|
|
|
private bool hasTimb
|
|
{
|
|
get => DayDTO != null && DayDTO.ListTimbr != null && DayDTO.ListTimbr.Count > 0;
|
|
}
|
|
|
|
private int midHour
|
|
{
|
|
get => StartHour + (int)Math.Floor((double)periodo / 2);
|
|
}
|
|
|
|
private bool noData
|
|
{
|
|
get => DayDTO == null || DayDTO.ListRA == null || DayDTO.ListRA.Count == 0;
|
|
}
|
|
|
|
private string Nome
|
|
{
|
|
get
|
|
{
|
|
string answ = "NA";
|
|
if (DayDTO != null)
|
|
{
|
|
answ = DayDTO.TimbrExpl.CognomeNome.Replace($"{Cognome} ", "");
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
private bool OkTemp
|
|
{
|
|
get
|
|
{
|
|
bool answ = false;
|
|
if (DayDTO != null && DayDTO.ListRilTemp != null)
|
|
{
|
|
answ = DayDTO.ListRilTemp.Count > 0;
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
private bool OkVC19
|
|
{
|
|
get
|
|
{
|
|
bool answ = false;
|
|
if (DayDTO != null && DayDTO.ListCheckC19 != null)
|
|
{
|
|
answ = DayDTO.ListCheckC19.Count > 0;
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
private Double oreComm
|
|
{
|
|
get
|
|
{
|
|
double answ = 0;
|
|
if (DayDTO != null && DayDTO.ListRA != null)
|
|
{
|
|
answ = DayDTO.OreComm;
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
private Double oreLav
|
|
{
|
|
get
|
|
{
|
|
double answ = 0;
|
|
if (DayDTO != null && DayDTO.TimbrExpl != null && DayDTO.TimbrExpl.HLav != null)
|
|
{
|
|
answ = DayDTO.OreLav;
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
private int periodo
|
|
{
|
|
get
|
|
{
|
|
int answ = 1;
|
|
if (DayDTO != null)
|
|
{
|
|
answ = EndHour - StartHour;
|
|
}
|
|
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
private decimal tempRil
|
|
{
|
|
get
|
|
{
|
|
decimal answ = 0;
|
|
if (OkTemp && DayDTO != null)
|
|
{
|
|
if (DayDTO.ListRilTemp != null)
|
|
{
|
|
answ = DayDTO.ListRilTemp[0].TempRil;
|
|
}
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
private string TotComm
|
|
{
|
|
get
|
|
{
|
|
string answ = "--:--";
|
|
if (DayDTO != null && DayDTO.TimbrExpl != null && DayDTO.TimbrExpl.HLav != null)
|
|
{
|
|
answ = DayDTO.OreMinComm;
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
private string TotLav
|
|
{
|
|
get
|
|
{
|
|
string answ = "--:--";
|
|
if (DayDTO != null && DayDTO.TimbrExpl != null && DayDTO.TimbrExpl.HLav != null)
|
|
{
|
|
answ = DayDTO.OreMinLav;
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private List<RegAttivitaModel> ListRegAtt()
|
|
{
|
|
// init
|
|
List<RegAttivitaModel> result = new List<RegAttivitaModel>();
|
|
if (DayDTO != null)
|
|
{
|
|
DateTime currHour = DayDTO.DtRif.AddHours(StartHour);
|
|
DateTime lastHour = DayDTO.DtRif.AddHours(EndHour);
|
|
// ciclo partendo dal primo evento ed aggiungendo eventuali periodi in testa / coda
|
|
// / intermedi
|
|
if (DayDTO.ListRA != null)
|
|
{
|
|
foreach (var item in DayDTO.ListRA)
|
|
{
|
|
// se evento > ora corrente --> aggiungo vuoto...
|
|
if (item.Inizio > currHour)
|
|
{
|
|
CORE.Data.DbModels.RegAttivitaModel? newItem = new CORE.Data.DbModels.RegAttivitaModel()
|
|
{
|
|
Inizio = currHour,
|
|
IdxFase = 0,
|
|
Descrizione = "-",
|
|
Fine = item.Inizio,
|
|
OreTot = (decimal)item.Inizio.Subtract(currHour).TotalHours
|
|
};
|
|
result.Add(newItem);
|
|
}
|
|
|
|
// ...altrimenti parto con lui...
|
|
result.Add(item);
|
|
currHour = item.Fine;
|
|
}
|
|
}
|
|
// se non sono in fondo --> aggiungo!
|
|
if (currHour < lastHour)
|
|
{
|
|
RegAttivitaModel? newItem = new RegAttivitaModel()
|
|
{
|
|
Inizio = currHour,
|
|
IdxFase = 0,
|
|
Descrizione = "-",
|
|
Fine = lastHour,
|
|
OreTot = (decimal)lastHour.Subtract(currHour).TotalHours
|
|
};
|
|
result.Add(newItem);
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
private List<PeriodoDTO> ListTimb()
|
|
{
|
|
// init
|
|
List<PeriodoDTO> result = new List<PeriodoDTO>();
|
|
if (DayDTO != null)
|
|
{
|
|
// limiti estremi visualizzazione
|
|
DateTime currHour = DayDTO.DtRif.AddHours(StartHour);
|
|
DateTime lastHour = DayDTO.DtRif.AddHours(EndHour);
|
|
int idxTimb = 0;
|
|
if (DayDTO.ListTimbr != null)
|
|
{
|
|
// divido tra ingressi e uscite
|
|
var timbIN = DayDTO.ListTimbr.Where(x => x.Entrata == true).ToList();
|
|
var timbOUT = DayDTO.ListTimbr.Where(x => x.Entrata == false).ToList();
|
|
DateTime fineLav = currHour;
|
|
|
|
// sistemo la prima timbratura
|
|
if (timbIN.Count > 0)
|
|
{
|
|
var firstRec = timbIN.OrderBy(x => x.DataOra).FirstOrDefault();
|
|
if (firstRec != null)
|
|
{
|
|
FirstTimb = CORE.Data.Utils.DateRounded(firstRec.DataOra, 5, false);
|
|
}
|
|
}
|
|
|
|
// ciclo partendo dal primo evento timbratura IN ed aggiungendo eventuali
|
|
// periodi in testa / coda / intermedi
|
|
foreach (var item in timbIN)
|
|
{
|
|
bool isClosed = true;
|
|
// se evento > ora corrente --> aggiungo vuoto...
|
|
if (item.DataOra > currHour)
|
|
{
|
|
PeriodoDTO emptyPeriod = new PeriodoDTO()
|
|
{
|
|
Inizio = currHour,
|
|
Fine = item.DataOra,
|
|
Tipo = CORE.Data.TipoPeriodo.ND,
|
|
OreTot = (decimal)item.DataOra.Subtract(currHour).TotalHours,
|
|
IsClosed = true
|
|
};
|
|
result.Add(emptyPeriod);
|
|
}
|
|
|
|
|
|
// ...processo cercando uscita relativa oppure NOW
|
|
if (timbOUT.Count > idxTimb)
|
|
{
|
|
fineLav = timbOUT[idxTimb].DataOra;
|
|
}
|
|
else
|
|
{
|
|
DateTime adesso = DateTime.Now;
|
|
int minRound = ((int)Math.Floor((double)adesso.Minute / 5)) * 5;
|
|
fineLav = DateTime.Today.AddHours(adesso.Hour).AddMinutes(minRound);
|
|
isClosed = false;
|
|
}
|
|
// solo x la prima prendo entrata_1... x rettifica ingresso
|
|
DateTime inizioLav = item.DataOra;
|
|
if (idxTimb == 0 && DayDTO.TimbrExpl.Entrata1 != null)
|
|
{
|
|
inizioLav = DayDTO.TimbrExpl.Entrata1 ?? item.DataOra;
|
|
}
|
|
PeriodoDTO workPeriod = new PeriodoDTO()
|
|
{
|
|
|
|
Inizio = inizioLav,
|
|
Fine = fineLav,
|
|
Tipo = CORE.Data.TipoPeriodo.Lavoro,
|
|
OreTot = (decimal)fineLav.Subtract(inizioLav).TotalHours,
|
|
IsClosed = isClosed
|
|
};
|
|
result.Add(workPeriod);
|
|
idxTimb++;
|
|
currHour = fineLav;
|
|
}
|
|
// se non sono in fondo --> aggiungo!
|
|
if (currHour < lastHour)
|
|
{
|
|
PeriodoDTO emptyPeriod = new PeriodoDTO()
|
|
{
|
|
Inizio = currHour,
|
|
Fine = lastHour,
|
|
Tipo = CORE.Data.TipoPeriodo.ND,
|
|
OreTot = (decimal)lastHour.Subtract(currHour).TotalHours,
|
|
IsClosed = true
|
|
};
|
|
result.Add(emptyPeriod);
|
|
}
|
|
}
|
|
}
|
|
|
|
return result;
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |