From f4b5870f06e98a7f0684fecaa07e0d5a618df8f2 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Wed, 2 Apr 2025 07:45:01 +0200 Subject: [PATCH] Update gestione ins manuali --- MP-TAB3/Components/InsManual.razor | 24 +- MP-TAB3/Components/InsManual.razor.cs | 314 +++++++++++++++----------- MP-TAB3/MP-TAB3.csproj | 2 +- MP-TAB3/Resources/ChangeLog.html | 2 +- MP-TAB3/Resources/VersNum.txt | 2 +- MP-TAB3/Resources/manifest.xml | 2 +- MP.Data/Services/TabDataService.cs | 9 + 7 files changed, 209 insertions(+), 146 deletions(-) diff --git a/MP-TAB3/Components/InsManual.razor b/MP-TAB3/Components/InsManual.razor index 9f07e615..de512dd0 100644 --- a/MP-TAB3/Components/InsManual.razor +++ b/MP-TAB3/Components/InsManual.razor @@ -8,29 +8,21 @@ { if (SeqStatus != null && SeqStatus.Count() > 0) { -
+
+
+
OEE: @($"{DayOee:P0}")
+
@($"{DayMinLav:N1}") min
+
+
+
@foreach (var item in SeqStatus) {
@item.Title
@($"{item.Value:N0}min") -
} - - @*
- @($"{NumGray}%") -
-
- @($"{NumGreen}%") -
-
- @($"{NumYellow}%") -
-
- @($"{NumGray}%") -
*@
} @@ -102,7 +94,7 @@ @item.IdxMacchina @item.KeyRichiesta @item.CodArticolo - @($"{item.InizioStato:HH:mm}") + {item.FineStato:yyyy.MM.dd HH:mm:ss}")">@($"{item.InizioStato:HH:mm}") @item.PzBuoni @($"{item.TCiclo:f3}") @($"{item.MinProd:f2}") diff --git a/MP-TAB3/Components/InsManual.razor.cs b/MP-TAB3/Components/InsManual.razor.cs index 4a336202..38556ddb 100644 --- a/MP-TAB3/Components/InsManual.razor.cs +++ b/MP-TAB3/Components/InsManual.razor.cs @@ -3,6 +3,7 @@ using Microsoft.JSInterop; using MP.Core.DTO; using MP.Data.DbModels; using MP.Data.Services; +using System.Net.Security; using static MP_TAB3.Components.ProdAdvDispl; namespace MP_TAB3.Components @@ -11,6 +12,12 @@ namespace MP_TAB3.Components { #region Public Properties + /// + /// Post update restituisco nuova lista dati + /// + [Parameter] + public EventCallback> E_Updated { get; set; } + [Parameter] public MappaStatoExpl? RecMSE { @@ -24,111 +31,20 @@ namespace MP_TAB3.Components } } } - /// - /// Post update restituisco nuova lista dati - /// - [Parameter] - public EventCallback> E_Updated { get; set; } - [Inject] - protected TabDataService TabDServ { get; set; } = null!; #endregion Public Properties - #region Private Properties + #region Protected Properties - private bool confProdActive { get; set; } = false; - private MappaStatoExpl? currRecMSE { get; set; } = null; + [Inject] + protected IJSRuntime JSRuntime { get; set; } = null!; - private DateTime dtCurr { get; set; } = DateTime.Today; + [Inject] + protected TabDataService TabDServ { get; set; } = null!; - private void DisplayDate(DateTime dtSel) - { - dtCurr = dtSel; - showDetail = true; - // filtra dati odierni x tab editabile... - if (ListPeriod != null && ListPeriod.Count > 0) - { - // calcolo eventi giorno - ListDay = ListPeriod - .Where(x => x.InizioStato.Date == dtSel) - .OrderBy(x => x.IdxInsMan) - .ToList(); + #endregion Protected Properties - // ora calcolo il sequencer x mostrare dettaglio orario... - SeqStatus = TabDServ.SeqDayStatus(ListDay); - } - } - - private void CloseDet() - { - showDetail = false; - } - - private async Task ReloadMonth(DateTime dtSel) - { - dtCurr = dtSel; -#if false - MService.targetDate = dtSel; - showDetail = false; - await Task.Delay(1); - MService.ReportDateChange(); -#endif - await Task.Delay(1); - } - /// - /// Lista date + css associato x display calendario - /// - private Dictionary DateCheck = new Dictionary(); - private Dictionary DateCFF = new Dictionary(); - - private List SeqStatus = new List(); - - private bool showDetail { get; set; } = false; - - protected override async Task OnParametersSetAsync() - { - //return base.OnParametersSetAsync(); - ReloadData(); - await Task.Delay(1); - } - - private void ReloadData() - { - // rileggo dati periodo... - ListDTO = new List(); - if (RecMSE != null) - { - DateTime MeseStart = new DateTime(dtCurr.Year, dtCurr.Month, 1); - DateTime MeseEnd = MeseStart.AddMonths(1); - ListPeriod = TabDServ.InsManFilt(RecMSE.IdxMacchina, MeseStart, MeseEnd); - ListDTO = TabDServ.InsManDayDto(ListPeriod); - DateCheck = new Dictionary(); - DateCFF = new Dictionary(); - string cssOkComm = "bg-success text-light rounded-circle p-2"; - string cssOkLav = "bg-warning text-light rounded-circle p-2"; - string cssToday = "bg-info text-dark rounded-circle p-2"; - string cssFest = "bg-danger text-warning rounded-pill2 px-0 opacity-50"; - string cssChius = "bg-warning text-dark rounded-pill2 px-0 opacity-50"; - string cssFerie = "bg-success text-light px-0 opacity-50"; - if (ListDTO != null) - { - string currCss = ""; - foreach (var item in ListDTO) - { - currCss = item.MinProdTot == 0 ? "" : cssOkLav; - if (item.DataRif == DateTime.Today) - { - currCss = cssToday; - } - else if (item.RatioImport == 1) - { - currCss = cssOkComm; - } - DateCheck.Add(item.DataRif, currCss); - } - } - } - } + #region Protected Methods protected void DoEdit(InsManualiModel? selRec) { @@ -147,43 +63,115 @@ namespace MP_TAB3.Components EditRecord.FineStato = EditRecord.InizioStato.AddMinutes((double)EditRecord.MinProd); // lancio salvataggio sul DB await TabDServ.InsManUpsert(EditRecord); - EditRecord = null; - if (!timeInfoOk()) + // rileggo i dati... + ReloadData(); + if (!IsTimeInfoOk()) { int numChange = await DoRecalcDay(); } // rileggo i dati... ReloadData(); + //RecalcDayData(dtCurr); + EditRecord = null; } } - [Inject] - protected IJSRuntime JSRuntime { get; set; } = null!; - private bool timeInfoOk() + protected override async Task OnParametersSetAsync() { - bool allOk = false; - if (ListDTO != null) + //return base.OnParametersSetAsync(); + ReloadData(); + await Task.Delay(1); + } + + #endregion Protected Methods + + #region Private Fields + + private Dictionary DateCFF = new Dictionary(); + + /// + /// Lista date + css associato x display calendario + /// + private Dictionary DateCheck = new Dictionary(); + + private InsManualiModel? EditRecord = null; + private List SeqStatus = new List(); + + #endregion Private Fields + + #region Private Properties + + private bool confProdActive { get; set; } = false; + private MappaStatoExpl? currRecMSE { get; set; } = null; + + private DateTime dtCurr { get; set; } = DateTime.Today; + + private List? ListDay { get; set; } = new List(); + + private List? ListDTO { get; set; } = new List(); + + private List? ListPeriod { get; set; } = new List(); + + private bool showDetail { get; set; } = false; + + #endregion Private Properties + + #region Private Methods + + private void CloseDet() + { + showDetail = false; + } + + private void DisplayDate(DateTime dtSel) + { + dtCurr = dtSel; + showDetail = true; + RecalcDayData(dtSel); + } + /// + /// Ricalcola dati giornalieri + /// + /// + private void RecalcDayData(DateTime dtSel) + { + // filtra dati odierni x tab editabile... + if (ListPeriod != null && ListPeriod.Count > 0) { - var dayDto = ListDTO.FirstOrDefault(x => x.DataRif == dtCurr.Date); - if (dayDto != null && ListDay != null) + // calcolo eventi giorno + ListDay = ListPeriod + .Where(x => x.InizioStato.Date == dtSel) + .OrderBy(x => x.IdxInsMan) + .ToList(); + + // ora calcolo il sequencer x mostrare dettaglio orario... + SeqStatus = TabDServ.SeqDayStatus(ListDay); + + // calcolo min lavorati odierni + DayMinLav = 0; + var recLav = SeqStatus.FirstOrDefault(x => x.IdxTipo == 1); + if (recLav != null) { - var firstRec = ListDay.OrderBy(x => x.InizioStato).FirstOrDefault(); - var lastRec = ListDay.OrderByDescending(x => x.InizioStato).FirstOrDefault(); - var deltaMins = lastRec!.FineStato!.Value.Subtract(firstRec!.InizioStato).TotalMinutes; - allOk = Math.Abs(deltaMins - (double)dayDto.MinProdTot) < 1; + DayMinLav = recLav.Value; + DayOee = recLav.ValuePerc; } } - return allOk; } - private async Task RecalcDay() - { - if (!await JSRuntime.InvokeAsync("confirm", $"Sicuro di voler ricalcolare i dati della giornata?")) - return 0; + /// + /// Minuti lavorfati (da sequencer) + /// + private double DayMinLav = 0; - return await DoRecalcDay(); - } + /// + /// OEE giornaliero (ore lav / 24h) + /// + private double DayOee = 0; + /// + /// Ricalcolo dati giornalieri + /// + /// private async Task DoRecalcDay() { int numChange = 0; @@ -213,16 +201,90 @@ namespace MP_TAB3.Components return numChange; } + private bool IsTimeInfoOk() + { + bool allOk = false; + if (ListDTO != null) + { + var dayDto = ListDTO.FirstOrDefault(x => x.DataRif == dtCurr.Date); + if (dayDto != null && ListDay != null) + { + var firstRec = ListDay.OrderBy(x => x.InizioStato).FirstOrDefault(); + var lastRec = ListDay.OrderByDescending(x => x.InizioStato).FirstOrDefault(); + var deltaMins = lastRec!.FineStato!.Value.Subtract(firstRec!.InizioStato).TotalMinutes; + allOk = Math.Abs(deltaMins - (double)dayDto.MinProdTot) < 1; + } + } + return allOk; + } - private double NumGreen = 25; - private double NumYellow = 5; - private double NumGray = 30; + private async Task RecalcDay() + { + if (!await JSRuntime.InvokeAsync("confirm", $"Sicuro di voler ricalcolare i dati della giornata?")) + return 0; - private List? ListDTO { get; set; } = new List(); - private List? ListPeriod { get; set; } = new List(); - private List? ListDay { get; set; } = new List(); - private InsManualiModel? EditRecord = null; + return await DoRecalcDay(); + } - #endregion Private Properties + private void ReloadData() + { + // rileggo dati periodo... + ListDTO = new List(); + if (RecMSE != null) + { + DateTime MeseStart = new DateTime(dtCurr.Year, dtCurr.Month, 1); + DateTime MeseEnd = MeseStart.AddMonths(1); + ListPeriod = TabDServ.InsManFilt(RecMSE.IdxMacchina, MeseStart, MeseEnd); + ListDTO = TabDServ.InsManDayDto(ListPeriod); + DateCheck = new Dictionary(); + DateCFF = new Dictionary(); + string cssOkComm = "bg-success text-light rounded-circle p-2"; + string cssOkLav = "bg-warning text-light rounded-circle p-2"; + string cssToday = "bg-info text-dark rounded-circle p-2"; + string cssFest = "bg-danger text-warning rounded-pill2 px-0 opacity-50"; + string cssChius = "bg-warning text-dark rounded-pill2 px-0 opacity-50"; + string cssFerie = "bg-success text-light px-0 opacity-50"; + if (ListDTO != null) + { + string currCss = ""; + foreach (var item in ListDTO) + { + currCss = item.MinProdTot == 0 ? "" : cssOkLav; + if (item.DataRif == DateTime.Today) + { + currCss = cssToday; + } + else if (item.RatioImport == 1) + { + currCss = cssOkComm; + } + DateCheck.Add(item.DataRif, currCss); + } + } + +#if false + // verifico dati giornalieri... + if (!IsTimeInfoOk()) + { + // se non ok --> sposo primo e poi ricalcolo... + //int numChange = await DoRecalcDay(); + } +#endif + } + } + + private async Task ReloadMonth(DateTime dtSel) + { + dtCurr = dtSel; +#if false + MService.targetDate = dtSel; + showDetail = false; + await Task.Delay(1); + MService.ReportDateChange(); +#endif + await Task.Delay(1); + } + + #endregion Private Methods } } \ No newline at end of file diff --git a/MP-TAB3/MP-TAB3.csproj b/MP-TAB3/MP-TAB3.csproj index 211ff96b..496aa2ae 100644 --- a/MP-TAB3/MP-TAB3.csproj +++ b/MP-TAB3/MP-TAB3.csproj @@ -3,7 +3,7 @@ net6.0 enable - 6.16.2504.116 + 6.16.2504.207 enable MP_TAB3 diff --git a/MP-TAB3/Resources/ChangeLog.html b/MP-TAB3/Resources/ChangeLog.html index 3ba7b8b5..d07a4862 100644 --- a/MP-TAB3/Resources/ChangeLog.html +++ b/MP-TAB3/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOSPEC -

Versione: 6.16.2504.116

+

Versione: 6.16.2504.207


Note di rilascio:
  • diff --git a/MP-TAB3/Resources/VersNum.txt b/MP-TAB3/Resources/VersNum.txt index f0f45c6a..d90fae9f 100644 --- a/MP-TAB3/Resources/VersNum.txt +++ b/MP-TAB3/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2504.116 +6.16.2504.207 diff --git a/MP-TAB3/Resources/manifest.xml b/MP-TAB3/Resources/manifest.xml index d5b43f6f..6be7f533 100644 --- a/MP-TAB3/Resources/manifest.xml +++ b/MP-TAB3/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2504.116 + 6.16.2504.207 https://nexus.steamware.net/repository/SWS/MP-TAB3/stable/LAST/MP-TAB3.zip https://nexus.steamware.net/repository/SWS/MP-TAB3/stable/LAST/ChangeLog.html false diff --git a/MP.Data/Services/TabDataService.cs b/MP.Data/Services/TabDataService.cs index 5aab3ccd..acac2910 100644 --- a/MP.Data/Services/TabDataService.cs +++ b/MP.Data/Services/TabDataService.cs @@ -960,6 +960,15 @@ namespace MP.Data.Services periodStart = item.InizioStato; periodEnd = item.FineStato.Value; duration = (double)item.MinProd; + currRec = new ManualStatusDTO + { + IdxTipo = lastIdxTipo, + // fare da DB --> anagEventi + CssBlock = item.IdxTipoEv == 1 ? "bg-success text-light" : "bg-secondary text-light", + Title = $"{periodStart:HH:mm}-{periodEnd:HH:mm}", + Value = duration, + ValueMax = 1440 + }; } else {