Random call update x planner

This commit is contained in:
Samuele Locatelli
2026-01-14 18:45:45 +01:00
parent b8aa2312fa
commit fa784ef5b0
12 changed files with 459 additions and 53 deletions
+38 -28
View File
@@ -9,9 +9,15 @@ namespace EgwCoreLib.Lux.Core.Generic
public class EventDto
{
public string CodTipo { get; set; } = "";
/// <summary>
/// Idx univoco evento
/// </summary>
public int IdxEv { get; set; } = 0;
#if false
public int IdxDipendente { get; set; } = 0;
public string CognomeNome { get; set; } = "";
public string CognomeNome { get; set; } = "";
#endif
public string Abbrev { get; set; } = "";
public string Titolo { get; set; } = "";
public string Descrizione { get; set; } = "";
@@ -29,9 +35,11 @@ namespace EgwCoreLib.Lux.Core.Generic
{
CodTipo = this.CodTipo,
IdxEv = this.IdxEv,
#if false
IdxDipendente = this.IdxDipendente,
CognomeNome = this.CognomeNome,
Abbrev = this.Abbrev,
#endif
Abbrev = this.Abbrev,
Titolo = this.Titolo,
Descrizione = this.Descrizione,
Tooltip = this.Tooltip,
@@ -75,63 +83,65 @@ namespace EgwCoreLib.Lux.Core.Generic
get => calcText(CodTipo, Conf, IsCompany);
}
private string calcColor(string codGiust, bool conf, bool isComp)
private string calcColor(string codTipo, bool conf, bool isComp)
{
string answ = "#EDEDED";
switch (codGiust)
switch (codTipo)
{
case "FER":
case "Saomad":
answ = isComp ? "#EEDD11" : conf ? "#11CD44" : "#AAFFCD";
break;
case "FEST":
case "Essetre":
answ = "#DD0033";
break;
case "104":
answ = conf ? "#DE00AB" : "#FFAACD";
break;
//case "104":
// answ = conf ? "#DE00AB" : "#FFAACD";
// break;
case "MAL":
answ = conf ? "#000" : "#696969";
break;
//case "MAL":
// answ = conf ? "#000" : "#696969";
// break;
case "PERM":
answ = conf ? "#9966DE" : "#CDAAFF";
break;
//case "PERM":
// answ = conf ? "#9966DE" : "#CDAAFF";
// break;
default:
answ = isComp ? "#EEDD11" : conf ? "#11CD44" : "#AAFFCD";
break;
}
return answ;
}
private string calcText(string codGiust, bool conf, bool isComp)
private string calcText(string codTipo, bool conf, bool isComp)
{
string answ = "#EDEDED";
switch (codGiust)
switch (codTipo)
{
case "FER":
case "Saomad":
answ = isComp ? "#000000" : conf ? "#FFFFFF" : "#000000";
break;
case "FEST":
case "Essetre":
answ = "#EEDD11";
break;
case "104":
answ = conf ? "#DEDEDE" : "#000000";
break;
//case "104":
// answ = conf ? "#DEDEDE" : "#000000";
// break;
case "MAL":
answ = conf ? "#DEDEDE" : "#ABABAB";
break;
//case "MAL":
// answ = conf ? "#DEDEDE" : "#ABABAB";
// break;
case "PERM":
answ = conf ? "#DEDEDE" : "#000000";
break;
//case "PERM":
// answ = conf ? "#DEDEDE" : "#000000";
// break;
default:
answ = isComp ? "#000000" : conf ? "#FFFFFF" : "#000000";
break;
}
return answ;
+1 -1
View File
@@ -4,7 +4,7 @@
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Version>0.9.2601.1417</Version>
<Version>0.9.2601.1418</Version>
</PropertyGroup>
<ItemGroup>
-1
View File
@@ -30,7 +30,6 @@
@* <Routes /> *@
@* <Routes @rendermode=RenderMode.InteractiveServer /> *@
<Routes @rendermode="@(new InteractiveServerRenderMode(prerender: false))" />
<script src="_framework/blazor.web.js"></script>
@* <script src="_framework/blazor.server.js" autostart="false"></script>
<script>
@@ -7,14 +7,14 @@
SlotRender=@OnSlotRender SlotSelect=@OnSlotSelect TodayText="Oggi"
AppointmentSelect=@OnAppointmentSelect AppointmentRender=@OnAppointmentRender
LoadData=OnLoadData>
<Template Context="EvDTO">
<Template Context="EvDto">
<div>
<strong>@EvDTO.CodTipo</strong> | @EvDTO.Abbrev
<strong>@EvDto.CodTipo</strong> | @EvDto.Abbrev
</div>
<small>
@if (EvDTO.CodTipo == "PERM" || EvDTO.CodTipo == "104")
@if (EvDto.CodTipo == "PERM" || EvDto.CodTipo == "104")
{
@($"{EventDto.DateForm(EvDTO.CodTipo, EvDTO.DtStart)} --> {EventDto.DateForm(EvDTO.CodTipo, EvDTO.DtEnd)}")
@($"{EventDto.DateForm(EvDto.CodTipo, EvDto.DtStart)} --> {EventDto.DateForm(EvDto.CodTipo, EvDto.DtEnd)}")
}
</small>
</Template>
@@ -1,6 +1,7 @@
using EgwCoreLib.Lux.Core.Generic;
using EgwCoreLib.Utils;
using Microsoft.AspNetCore.Components;
using NLog;
using Radzen;
using Radzen.Blazor;
using static WebWindowComplex.TableComp;
@@ -57,8 +58,32 @@ namespace Lux.UI.Components.Compo.Planner
#endregion Protected Properties
#region Protected Methods
protected override async Task OnParametersSetAsync()
{
numEvAll = 0;
numEvFilt = 0;
if (EvDtoList != null && EvDtoList.Count > 0)
{
numEvAll = EvDtoList.Count();
FilterData();
try
{
await scheduler.Reload();
}
catch (Exception exc)
{
Log.Error($"Eccezione durante OnParametersSet{Environment.NewLine}{exc}");
}
}
}
#endregion Protected Methods
#region Private Fields
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
private int selectedIndex = 2;
#endregion Private Fields
@@ -67,8 +92,11 @@ namespace Lux.UI.Components.Compo.Planner
private int cMonth { get; set; } = 3;
private string currView { get; set; } = "";
private List<EventDto> EvDtoFilt { get; set; } = new List<EventDto>();
private int numEvAll { get; set; } = 0;
private int numEvFilt { get; set; } = 0;
private string schedHeight { get; set; } = "height: 50rem;";
private DateTime SelDate { get; set; } = DateTime.Today;
@@ -77,6 +105,50 @@ namespace Lux.UI.Components.Compo.Planner
#region Private Methods
private void FilterData()
{
// in primis copio tutto
EvDtoFilt = EvDtoList;
if (ShowNeedConf)
{
EvDtoFilt = EvDtoFilt.Where(x => !x.Conf).ToList();
}
#if false
// controllo ogni toggle...
if (!showChiu)
{
EvDtoFilt = EvDtoFilt
.Where(x => !x.IsCompany || (x.IsCompany && !x.CodTipo.Equals("FER", StringComparison.InvariantCultureIgnoreCase)))
.ToList();
}
if (!showFer)
{
EvDtoFilt = EvDtoFilt
.Where(x => !x.CodTipo.Equals("FER", StringComparison.InvariantCultureIgnoreCase) || (x.CodTipo.Equals("FER", StringComparison.InvariantCultureIgnoreCase) && x.IsCompany))
.ToList();
}
if (!showFest)
{
EvDtoFilt = EvDtoFilt
.Where(x => !x.CodTipo.Equals("FEST", StringComparison.InvariantCultureIgnoreCase))
.ToList();
}
if (!showMal)
{
EvDtoFilt = EvDtoFilt
.Where(x => !x.CodTipo.Equals("MAL", StringComparison.InvariantCultureIgnoreCase))
.ToList();
}
if (!showPer)
{
EvDtoFilt = EvDtoFilt
.Where(x => !x.CodTipo.Equals("PERM", StringComparison.InvariantCultureIgnoreCase) && !x.CodTipo.Equals("104", StringComparison.InvariantCultureIgnoreCase))
.ToList();
}
#endif
numEvFilt = EvDtoFilt.Count();
}
/// <summary>
/// Sistemazione colore sfonto di ogni evento mostrato
/// </summary>
@@ -99,8 +171,6 @@ namespace Lux.UI.Components.Compo.Planner
var data = await DialogService.OpenAsync<TaskDetail>("", new Dictionary<string, object> { { "ThisTask", copy } });
}
private string currView { get; set; } = "";
/// <summary>
/// Gestione richeista caricamento dati dal controllo x avere nuovo set da mostrare
/// </summary>
@@ -12,14 +12,15 @@
<li class="list-group-item">
<div class="d-flex justify-content-between">
<div class="px-0">Nome:</div>
@if (@model.IdxDipendente > 0)
@* @if (@model.IdxDipendente > 0)
{
<div class="px-0"><b>@model.Abbrev</b></div>
}
else
{
<div class="px-0"><b>@model.Descrizione</b></div>
}
} *@
<div class="px-0"><b>@model.Descrizione</b></div>
</div>
</li>
@if (model.DtEnd.Subtract(model.DtStart).TotalDays < 1 && model.CodTipo != "FER")
@@ -43,7 +44,7 @@
<div class="px-0"><b>@(EventDto.DateForm(model.CodTipo, model.DtEnd))</b></div>
</div>
</li>
@if (model.IdxDipendente == idxDipendente)
@* @if (model.IdxDipendente == idxDipendente)
{
<li class="list-group-item">
<div class="d-flex justify-content-between">
@@ -51,7 +52,13 @@
<div class="px-0"><b>@model.Note</b></div>
</div>
</li>
}
} *@
<li class="list-group-item">
<div class="d-flex justify-content-between">
<div class="px-0">Note:</div>
<div class="px-0"><b>@model.Note</b></div>
</div>
</li>
@if (!model.Conf)
{
<li class="list-group-item text-center bg-danger text-warning">
+1 -1
View File
@@ -11,7 +11,7 @@
</div>
</div>
<div class="card-body">
<CalendarPlanner></CalendarPlanner>
<CalendarPlanner EvDtoList="ListEventi"></CalendarPlanner>
</div>
</div>
+328 -8
View File
@@ -1,18 +1,344 @@
using EgwCoreLib.Lux.Core.Generic;
namespace Lux.UI.Components.Pages
{
public partial class ProdPlanner
{
#region Protected Methods
protected override async Task OnParametersSetAsync()
{
await ReloadData();
}
#endregion Protected Methods
#region Private Fields
private List<EventDto> ListEventi = new();
/// <summary>
/// Periodo selezionato attuale
/// </summary>
private EgwCoreLib.Utils.DtUtils.Periodo PeriodoSel = new EgwCoreLib.Utils.DtUtils.Periodo(EgwCoreLib.Utils.DtUtils.PeriodSet.ThisYear);
private Random rnd = new Random();
/// <summary>
/// modo sim:
/// 1: qwen coder 30b
/// 2: qwen 2504 4b
/// 3: manuale
/// </summary>
private int simMode = 1;
#endregion Private Fields
#region Private Methods
/// <summary>
/// Sim modo 1 (QWEN 2504 30b)
/// </summary>
/// <returns></returns>
private async Task DoSimModeOne()
{
// qwen 2504 coder 30b
// simulo eventi...
ListEventi.Clear();
DateTime inizio = new DateTime(DateTime.Today.Year, 1, 1);
int numSim = 350;
int hStart = 8;
int hEnd = 18;
DateTime dtStart = inizio.AddHours(hStart);
int idx = 1;
// ordini Saomad
string codMacc = "Saomad";
for (int i = 0; i < numSim; i++)
{
// Calcola la fine dell'evento
DateTime dtEnd = dtStart.AddMinutes(rnd.Next(120, 960));
// Verifica se l'evento supera il limite orario
DateTime fineGiornata = dtStart.Date.AddHours(hEnd);
if (dtEnd > fineGiornata)
{
// Se supera il limite, taglia l'evento entro 30 minuti dopo hEnd
dtEnd = fineGiornata.AddMinutes(30);
}
EventDto newEv = new EventDto()
{
CodTipo = codMacc,
Abbrev = $"POR.{inizio.Year}.{idx++:x8}",
Titolo = $"POR.{inizio.Year}.{idx++:x8}",
Descrizione = $"Produzione {codMacc}",
DtStart = dtStart,
DtEnd = dtEnd
};
ListEventi.Add(newEv);
dtStart = dtEnd;
// se finisce di sabato/domenica --> scatta al lunedì!
if (dtStart.DayOfWeek >= DayOfWeek.Saturday)
{
dtStart = dtStart.AddDays(2);
// Assicurati che il nuovo inizio sia all'inizio della giornata lavorativa
dtStart = dtStart.Date.AddHours(hStart);
}
}
// ordini Essetre..
codMacc = "Essetre";
dtStart = inizio.AddHours(hStart);
for (int i = 0; i < numSim; i++)
{
// Calcola la fine dell'evento
DateTime dtEnd = dtStart.AddMinutes(rnd.Next(120, 960));
// Verifica se l'evento supera il limite orario
DateTime fineGiornata = dtStart.Date.AddHours(hEnd);
if (dtEnd > fineGiornata)
{
// Se supera il limite, taglia l'evento entro 30 minuti dopo hEnd
dtEnd = fineGiornata.AddMinutes(30);
}
EventDto newEv = new EventDto()
{
CodTipo = codMacc,
Abbrev = $"POR.{inizio.Year}.{idx++:x8}",
Titolo = $"POR.{inizio.Year}.{idx++:x8}",
Descrizione = $"Produzione {codMacc}",
DtStart = dtStart,
DtEnd = dtEnd
};
ListEventi.Add(newEv);
dtStart = dtEnd;
// se finisce di sabato/domenica --> scatta al lunedì!
if (dtStart.DayOfWeek >= DayOfWeek.Saturday)
{
dtStart = dtStart.AddDays(2);
// Assicurati che il nuovo inizio sia all'inizio della giornata lavorativa
dtStart = dtStart.Date.AddHours(hStart);
}
}
}
/// <summary>
/// Sim modalità iniziale
/// </summary>
/// <returns></returns>
private async Task DoSimModeThree()
{
// simulo eventi...
ListEventi.Clear();
DateTime inizio = new DateTime(DateTime.Today.Year, 1, 1);
int numSim = 365;
int hStart = 8;
int hEnd = 18;
DateTime dtStart = inizio.AddHours(hStart);
DateTime dtEnd = dtStart;
int idx = 1;
// ordini Saomad
string codMacc = "Saomad";
for (int i = 0; i < numSim; i++)
{
dtEnd = dtStart.AddMinutes(rnd.Next(120, 960));
// se vado oltre fine --> taglia!
var delta = dtEnd.Subtract(dtEnd.Date.AddHours(hEnd));
if (delta.TotalMinutes > 30)
{
dtEnd = dtEnd.AddMinutes(-(delta.TotalMinutes - rnd.Next(5, 25)));
}
EventDto newEv = new EventDto()
{
CodTipo = codMacc,
Abbrev = $"POR.{inizio.Year}.{idx++:x8}",
Titolo = $"POR.{inizio.Year}.{idx++:x8}",
Descrizione = $"Produzione {codMacc}",
DtStart = dtStart,
DtEnd = dtEnd
};
ListEventi.Add(newEv);
dtStart = dtEnd;
// se finisce di sabato/domenica --> scatta al lunedì!
if (dtStart.DayOfWeek >= DayOfWeek.Saturday)
{
dtStart = dtStart.AddDays(2);
}
}
// ordini Essetre..
codMacc = "Essetre";
dtStart = inizio.AddHours(hStart);
dtEnd = dtStart;
for (int i = 0; i < numSim; i++)
{
dtEnd = dtStart.AddMinutes(rnd.Next(120, 960));
// se vado oltre fine --> taglia!
var delta = dtEnd.Subtract(dtEnd.Date.AddHours(hEnd));
if (delta.TotalMinutes > 30)
{
dtEnd = dtEnd.AddMinutes(-(delta.TotalMinutes - rnd.Next(5, 25)));
}
EventDto newEv = new EventDto()
{
CodTipo = codMacc,
Abbrev = $"POR.{inizio.Year}.{idx++:x8}",
Titolo = $"POR.{inizio.Year}.{idx++:x8}",
Descrizione = $"Produzione {codMacc}",
DtStart = dtStart,
DtEnd = dtEnd
};
ListEventi.Add(newEv);
dtStart = dtEnd;
// se finisce di sabato/domenica --> scatta al lunedì!
if (dtStart.DayOfWeek >= DayOfWeek.Saturday)
{
dtStart = dtStart.AddDays(2);
}
}
}
/// <summary>
/// Sim modo 2 (QWEN 2504 4b)
/// </summary>
/// <returns></returns>
private async Task DoSimModeTwo()
{
// qwen 2504 4b
// simulo eventi...
ListEventi.Clear();
DateTime inizio = new DateTime(DateTime.Today.Year, 1, 1);
int numSim = 350;
int hStart = 8;
int hEnd = 18; // orario di fine (18:00)
// Durata massima consentita: 30 minuti dopo le 18:00 → max 18:30
DateTime dtStart = inizio.AddHours(hStart);
DateTime dtEnd = dtStart;
int idx = 1;
// --- Ordini Saomad ---
string codMacc = "Saomad";
for (int i = 0; i < numSim; i++)
{
// Genera una durata casuale (da 120 a 960 minuti) → ma non va oltre 18:30
// Quindi dobbiamo limitare il valore finale a 18:30
// Calcoliamo il massimo possibile: 18:30
DateTime maxEnd = inizio.AddHours(hEnd).AddMinutes(30); // 18:30
// Se il giorno è sabato/domenica, spostiamo il giorno al lunedì (come prima)
DateTime currentStart = dtStart;
// Calcoliamo il tempo massimo di fine: 18:30
DateTime endLimit = currentStart.AddHours(hEnd).AddMinutes(30); // 18:30
// Durata casuale (ma non superiore a 30 minuti dopo le 18:00)
int duration = rnd.Next(120, 960); // da 120 a 960 minuti
DateTime proposedEnd = currentStart.AddMinutes(duration);
// Se l'evento supera 18:30, lo tagliamo a 18:30
if (proposedEnd > endLimit)
{
proposedEnd = endLimit;
}
// Assicuriamo che l'evento non finisca dopo le 18:30
dtEnd = proposedEnd;
EventDto newEv = new EventDto()
{
CodTipo = codMacc,
Abbrev = $"POR.{inizio.Year}.{idx++:x8}",
Titolo = $"POR.{inizio.Year}.{idx++:x8}",
Descrizione = $"Produzione {codMacc}",
DtStart = currentStart,
DtEnd = dtEnd
};
ListEventi.Add(newEv);
// Passa al giorno successivo (se finisce sabato/domenica → passa al lunedì)
if (dtEnd.DayOfWeek >= DayOfWeek.Saturday)
{
dtStart = dtEnd.AddDays(2); // lunedì dopo sabato/domenica
}
else
{
dtStart = dtEnd; // continua il giorno successivo
}
}
// --- Ordini Essetre ---
codMacc = "Essetre";
dtStart = inizio.AddHours(hStart);
for (int i = 0; i < numSim; i++)
{
// Lo stesso ragionamento
DateTime currentStart = dtStart;
DateTime endLimit = currentStart.AddHours(hEnd).AddMinutes(30); // 18:30
int duration = rnd.Next(120, 960);
DateTime proposedEnd = currentStart.AddMinutes(duration);
if (proposedEnd > endLimit)
{
proposedEnd = endLimit;
}
dtEnd = proposedEnd;
EventDto newEv = new EventDto()
{
CodTipo = codMacc,
Abbrev = $"POR.{inizio.Year}.{idx++:x8}",
Titolo = $"POR.{inizio.Year}.{idx++:x8}",
Descrizione = $"Produzione {codMacc}",
DtStart = currentStart,
DtEnd = dtEnd
};
ListEventi.Add(newEv);
if (dtEnd.DayOfWeek >= DayOfWeek.Saturday)
{
dtStart = dtEnd.AddDays(2);
}
else
{
dtStart = dtEnd;
}
}
}
/// <summary>
/// Legge i dati dei record completi
/// </summary>
private async Task ReloadData()
{
switch (simMode)
{
case 1:
await DoSimModeOne();
break;
case 2:
await DoSimModeTwo();
break;
case 3:
default:
await DoSimModeThree();
break;
}
}
/// <summary>
/// Imposta periodo da filtro
/// </summary>
@@ -24,13 +350,6 @@ namespace Lux.UI.Components.Pages
await ReloadData();
UpdateTable();
}
/// <summary>
/// Legge i dati dei record completi
/// </summary>
private async Task ReloadData()
{
await Task.Delay(100);
}
/// <summary>
/// Filtro e paginazione
@@ -42,9 +361,10 @@ namespace Lux.UI.Components.Pages
ListRecords = ListFilt
.Skip(numRecord * (currPage - 1))
.Take(numRecord)
.ToList();
.ToList();
#endif
}
#endregion Private Methods
}
}
+1 -1
View File
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<UserSecretsId>aspnet-Lux.UI-a758c101-a2f4-4e38-977d-1c4887dbbd50</UserSecretsId>
<Version>0.9.2601.1417</Version>
<Version>0.9.2601.1418</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>LUX - Web Windows MES</i>
<h4>Versione: 0.9.2601.1417</h4>
<h4>Versione: 0.9.2601.1418</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
0.9.2601.1417
0.9.2601.1418
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>0.9.2601.1417</version>
<version>0.9.2601.1418</version>
<url>http://nexus.steamware.net/repository/SWS/GPW/stable/GPW.UI.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/GPW/stable/ChangeLog.html</changelog>
<mandatory>false</mandatory>