From 05c26f4e53a964fa3e03fab2c3dcd7065e32effd Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Sat, 11 Jun 2022 12:42:42 +0200 Subject: [PATCH] Fix selezione interventi nel periodo --- MP.MONO.Data/Controllers/MpDbController.cs | 4 +- MP.MONO.UI/Components/MaintOverview.razor | 46 ++++++++++--------- MP.MONO.UI/Components/ProgBar.razor.cs | 4 +- MP.MONO.UI/Components/SchedMaintTask.razor | 2 +- MP.MONO.UI/Components/SchedMaintTask.razor.cs | 41 +++++++++++++---- MP.MONO.UI/Data/CurrentDataService.cs | 29 ++++++------ 6 files changed, 79 insertions(+), 47 deletions(-) diff --git a/MP.MONO.Data/Controllers/MpDbController.cs b/MP.MONO.Data/Controllers/MpDbController.cs index de2852c..12c0373 100644 --- a/MP.MONO.Data/Controllers/MpDbController.cs +++ b/MP.MONO.Data/Controllers/MpDbController.cs @@ -440,7 +440,8 @@ namespace MP.MONO.Data.Controllers /// /// Recupero elenco Task Schedulati (ultimi dato "skip") /// - /// + /// Macchina selezionata + /// Finestra di ore per cui msotrare interventi che scadono solo in questa /// /// /// @@ -454,6 +455,7 @@ namespace MP.MONO.Data.Controllers { dbResult = localDbCtx .DbSetSMTask + .Include(i => i.CounterNav) .Where(x => x.PMTaskeNav.MachineId == MachineId && (x.DtExecution == DateTime.MinValue || showCompleted)) .Include(m => m.PMTaskeNav.MachGroupNav) .Include(m => m.CounterNav) diff --git a/MP.MONO.UI/Components/MaintOverview.razor b/MP.MONO.UI/Components/MaintOverview.razor index 2858bae..30d8576 100644 --- a/MP.MONO.UI/Components/MaintOverview.razor +++ b/MP.MONO.UI/Components/MaintOverview.razor @@ -4,28 +4,30 @@ @inject CurrentDataService MMDataService - -

...deve mostrare quelli in scadenza nel periodo richeisto, es 10/15 gg...

-@if (@ListRecords != null && ListRecords.Count > 0) -{ - - -} -else -{ - -} + else + { + + } + + diff --git a/MP.MONO.UI/Components/ProgBar.razor.cs b/MP.MONO.UI/Components/ProgBar.razor.cs index 2db7e55..ee0296b 100644 --- a/MP.MONO.UI/Components/ProgBar.razor.cs +++ b/MP.MONO.UI/Components/ProgBar.razor.cs @@ -13,10 +13,10 @@ namespace MP.MONO.UI.Components public double maxVal { get; set; } = 100; [Parameter] - public int redLim { get; set; } = 24 * 3; + public int redLim { get; set; } = 10; [Parameter] - public int yelLim { get; set; } = 24 * 5; + public int yelLim { get; set; } = 20; #endregion Public Properties diff --git a/MP.MONO.UI/Components/SchedMaintTask.razor b/MP.MONO.UI/Components/SchedMaintTask.razor index 1072cdf..f4397f2 100644 --- a/MP.MONO.UI/Components/SchedMaintTask.razor +++ b/MP.MONO.UI/Components/SchedMaintTask.razor @@ -115,7 +115,7 @@ @record.CounterNav.Description @record.PMTaskeNav.JobDescription - @if (record.CountRemainVal <= yelLim) + @if (record.CountRemainVal <= hourLim) { } diff --git a/MP.MONO.UI/Components/SchedMaintTask.razor.cs b/MP.MONO.UI/Components/SchedMaintTask.razor.cs index f6388cc..0200f93 100644 --- a/MP.MONO.UI/Components/SchedMaintTask.razor.cs +++ b/MP.MONO.UI/Components/SchedMaintTask.razor.cs @@ -15,24 +15,30 @@ namespace MP.MONO.UI.Components #region Private Fields - private int _MaxRecord = 200; + private int _MaxRecord = 2000; private bool _showCompleted = false; + + /// + /// Valore limite (in ore) per permettere di chiudere un intervento + /// + private int hourLim = 24 * 1; + private List? ListRecords = null; // FARE!!! filtro macchina private int MachineId = 1; /// - /// Valore limite (in ore) per indicare come rosso una scadenza + /// Valore limite (in %) per indicare come rosso una scadenza /// - private int redLim = 24 * 2; + private int redLim = 10; private List? SearchRecords = null; /// - /// Valore limite (in ore) per indicare come giallo una scadenza + /// Valore limite (in %) per indicare come giallo una scadenza /// - private int yelLim = 24 * 7; + private int yelLim = 20; #endregion Private Fields @@ -60,7 +66,26 @@ namespace MP.MONO.UI.Components private string execName { get; set; } = ""; private bool isLoading { get; set; } = false; - private int LimitDayPeriod { get; set; } = 7; + private int _limitDayPeriod { get; set; } = 7; + + private int LimitDayPeriod + { + get => _limitDayPeriod; + set + { + if (_limitDayPeriod != value) + { + _limitDayPeriod = value; + var pUpd = Task.Run(async () => await ReloadData()); + pUpd.Wait(); + } + } + } + + private int maxRemainHour + { + get => LimitDayPeriod * 24; + } private int MaxRecord { @@ -156,7 +181,7 @@ namespace MP.MONO.UI.Components private async Task RegenTask() { - await MMDataService.createMissingSchedTask(MachineId); + await MMDataService.SchedMaintTaskCreateMissing(MachineId); await ReloadData(); } @@ -165,7 +190,7 @@ namespace MP.MONO.UI.Components isLoading = true; ListRecords = null; await Task.Delay(1); - SearchRecords = await MMDataService.SchedMaintTaskGetFilt(MachineId, 0, MaxRecord, showCompleted); + SearchRecords = await MMDataService.SchedMaintTaskGetFilt(MachineId, maxRemainHour, 0, MaxRecord, showCompleted); ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList(); await Task.Delay(1); await Task.Delay(1); diff --git a/MP.MONO.UI/Data/CurrentDataService.cs b/MP.MONO.UI/Data/CurrentDataService.cs index bb6f054..27cec85 100644 --- a/MP.MONO.UI/Data/CurrentDataService.cs +++ b/MP.MONO.UI/Data/CurrentDataService.cs @@ -85,17 +85,6 @@ namespace MP.MONO.UI.Data return await Task.FromResult(dbResult); } - public async Task createMissingSchedTask(int machineId) - { - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - bool answ = await dbController.SchedMaintTaskCreateMissing(machineId); - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Trace($"Effettuata chiamata a createMissingSchedTask: {ts.TotalMilliseconds} ms"); - return await Task.FromResult(answ); - } - public async Task> DataLogGetFilt(int machineId, string fluxType, DateTime inizio, DateTime fine) { Stopwatch stopWatch = new Stopwatch(); @@ -334,11 +323,25 @@ namespace MP.MONO.UI.Data return await Task.FromResult(dbResult); } - public async Task> SchedMaintTaskGetFilt(int machineId, int skipRec, int numRec, bool showCompleted) + public async Task SchedMaintTaskCreateMissing(int machineId) { Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); - List? dbResult = dbController.SchedMaintTaskGetFilt(machineId, skipRec, numRec, showCompleted); + bool answ = await dbController.SchedMaintTaskCreateMissing(machineId); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Trace($"Effettuata chiamata a createMissingSchedTask: {ts.TotalMilliseconds} ms"); + return await Task.FromResult(answ); + } + + public async Task> SchedMaintTaskGetFilt(int machineId, int maxRemain, int skipRec, int numRec, bool showCompleted) + { + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + // ricerca sul DB "raw" + List? rawResult = dbController.SchedMaintTaskGetFilt(machineId, skipRec, numRec, showCompleted); + // filtro ulteriormente ora... + var dbResult = rawResult.Where(x => x.CountRemainVal <= maxRemain || maxRemain == 0).ToList(); stopWatch.Stop(); TimeSpan ts = stopWatch.Elapsed; Log.Trace($"Effettuata lettura da DB SchedMaintTaskGetFilt: {ts.TotalMilliseconds} ms");