Calendario carichi

This commit is contained in:
2026-02-02 13:54:37 +01:00
parent 09edc1f2b7
commit 915c3f3084
6 changed files with 215 additions and 1 deletions

View File

@ -0,0 +1,148 @@
@page "/Carico"
@using TecniStamp.Model.Carico
<RadzenDataGrid Data="@righe" TItem="CalendarioRigaViewModel"
ColumnWidth="120px"
AllowFiltering="false"
AllowSorting="false">
<Columns>
<!-- Colonna fissa -->
<RadzenDataGridColumn TItem="CalendarioRigaViewModel"
Property="Lavorazione"
Title="Lavorazione"
Frozen="true"
Width="100px" />
<!-- Colonne dinamiche: settimane -->
@foreach (var settimana in settimane)
{
<RadzenDataGridColumn TItem="CalendarioRigaViewModel"
Title="@($"SETTIMANA {settimana.Numero}")"
Width="175px">
<Template Context="riga">
@{
riga.Settimane.TryGetValue(settimana.Numero, out var cella);
}
@if (cella != null)
{
<div class="calendar-card">
<div class="card-header">
<span class="status">@cella.Stato</span>
<RadzenButton Icon="more_horiz"
Size="ButtonSize.Small"
ButtonStyle="ButtonStyle.Light" />
</div>
<div class="card-body">
<small>Commesse: @cella.Stato</small>
</div>
<RadzenProgressBar Value="@cella.Percentuale"
ShowValue="false"
Unit="%"
Style="height:12px"
Color="@GetColor(cella.Percentuale)" />
</div>
}
</Template>
</RadzenDataGridColumn>
}
</Columns>
</RadzenDataGrid>
@code {
private List<SettimanaViewModel> settimane = new();
private List<CalendarioRigaViewModel> righe = new();
protected override async Task OnInitializedAsync()
{
await base.OnInitializedAsync();
settimane = GeneraSettimaneAnno(2026);
var settimanePerMese = settimane
.GroupBy(s => new { s.Anno, Mese = s.Inizio.Month })
.Select(g => new
{
Mese = g.Key.Mese,
Nome = new DateTime(2026, g.Key.Mese, 1).ToString("MMMM").ToUpper(),
Count = g.Count()
})
.ToList();
righe = new List<CalendarioRigaViewModel>
{
new()
{
Id = 1,
Lavorazione = "Taglio laser Commessa A",
Settimane = new Dictionary<int, CalendarioCellaViewModel>
{
[6] = new() { Ore = 16, Stato = "InCorso", Percentuale = 50 },
[7] = new() { Ore = 24, Stato = "InCorso", Percentuale = 75 }
}
},
new()
{
Id = 2,
Lavorazione = "Saldatura Commessa A",
Settimane = new Dictionary<int, CalendarioCellaViewModel>
{
[7] = new() { Ore = 32, Stato = "Pianificato", Percentuale = 40},
[8] = new() { Ore = 16, Stato = "Pianificato", Percentuale = 60}
}
},
new()
{
Id = 3,
Lavorazione = "Verniciatura Commessa B",
Settimane = new Dictionary<int, CalendarioCellaViewModel>
{
[8] = new() { Ore = 40, Stato = "Pianificato", Percentuale = 90}
}
}
};
}
public static List<SettimanaViewModel> GeneraSettimaneAnno(int anno)
{
var settimane = new List<SettimanaViewModel>();
// ISO: settimana 1 = quella che contiene il 4 gennaio
var jan4 = new DateTime(anno, 1, 4);
// lunedì della settimana 1
var startOfWeek1 = jan4.AddDays(-(int)(jan4.DayOfWeek == DayOfWeek.Sunday
? 6
: jan4.DayOfWeek - DayOfWeek.Monday));
var currentStart = startOfWeek1;
var weekNumber = 1;
while (currentStart.Year <= anno)
{
var currentEnd = currentStart.AddDays(6);
settimane.Add(new SettimanaViewModel
{
Anno = anno,
Numero = weekNumber,
Inizio = currentStart,
Fine = currentEnd
});
currentStart = currentStart.AddDays(7);
weekNumber++;
}
return settimane;
}
object GetColor(int valuePercentuale)
{
return "Red";
}
}

View File

@ -0,0 +1,35 @@
.calendar-month-header {
display: grid;
grid-template-columns: 250px repeat(53, 120px);
border-bottom: 1px solid #ddd;
background: #f5f5f5;
}
.month-header {
text-align: center;
font-weight: 600;
padding: 8px 0;
border-left: 1px solid #ddd;
}
.month-spacer {
border-right: 1px solid #ddd;
}
.calendar-card {
background: #f7f7f7;
border-radius: 6px;
padding: 6px;
box-shadow: inset 0 0 0 1px #ddd;
}
.card-header {
display: flex;
justify-content: space-between;
font-size: 12px;
margin-bottom: 4px;
}
.status {
font-weight: 600;
}

View File

@ -0,0 +1,8 @@
namespace TecniStamp.Model.Carico;
public class CalendarioCellaViewModel
{
public int Ore { get; set; }
public string Stato { get; set; }
public int Percentuale { get; set; }
}

View File

@ -0,0 +1,9 @@
namespace TecniStamp.Model.Carico;
public class CalendarioRigaViewModel
{
public int Id { get; set; }
public string Lavorazione { get; set; }
public Dictionary<int, CalendarioCellaViewModel> Settimane { get; set; }
= new();
}

View File

@ -0,0 +1,11 @@
namespace TecniStamp.Model.Carico;
public class SettimanaViewModel
{
public int Anno { get; set; }
public int Numero { get; set; }
public DateTime Inizio { get; set; }
public DateTime Fine { get; set; }
public string Label => $"W{Numero}";
}

View File

@ -1,4 +1,5 @@
using TecniStamp.Domain;
using System.ComponentModel.DataAnnotations;
using TecniStamp.Domain;
namespace TecniStamp.Model;
@ -7,7 +8,9 @@ public class UserViewModel : BaseViewModel
public string Username { get; set; }
public string Email { get; set; }
public string Password { get; set; }
[Required(ErrorMessage = "Il nome è obbligatorio")]
public string Nome { get; set; }
[Required(ErrorMessage = "Il cognome è obbligatorio")]
public string Cognome { get; set; }
public Guid RuoloId { get; set; }
public string Ruolo { get; set; }