diff --git a/MP.Data/Controllers/MpStatsController.cs b/MP.Data/Controllers/MpStatsController.cs index acf6ffda..d567fc7a 100644 --- a/MP.Data/Controllers/MpStatsController.cs +++ b/MP.Data/Controllers/MpStatsController.cs @@ -6,6 +6,7 @@ using MP.Data.DbModels; using NLog; using System; using System.Collections.Generic; +using System.Data; using System.Drawing.Drawing2D; using System.Linq; using static MP.Core.Objects.Enums; @@ -122,6 +123,66 @@ namespace MP.Data.Controllers { } + /// + /// Restituisce dataset FluxLog filtrato + /// + /// Macchina singola, se "" = tutte + /// Data inizio selezione odl (inizio/fine) + /// Data fine selezione odl (inizio/fine) + /// Tipo Flusso, "" = tutti + /// + public List FluxLogRawData(string IdxMacchina, DateTime DtStart, DateTime DtEnd, string fluxType) + { + List dbResult = new List(); + using (var dbCtx = new MoonPro_STATSContext(_configuration)) + { + dbResult = dbCtx + .DbSetFL + .Where(x => + (IdxMacchina == "*" || x.IdxMacchina == IdxMacchina) + && (fluxType == "*" || x.FluxType == fluxType) + && (x.dtEvento >= DtStart && x.dtEvento <= DtEnd)) + .ToList(); + } + return dbResult; + } + + /// + /// Elenco di tipi flusso disponibili + /// + /// + public List FluxTypeList() + { + List dbResult = new List(); + using (var dbCtx = new MoonPro_STATSContext(_configuration)) + { + dbResult = dbCtx + .DbSetFL + .Select(x => x.FluxType) + .Distinct() + .OrderBy(x => x) + .ToList(); + } + return dbResult; + } + + /// + /// Elenco da tabella Macchine con dati Energy + /// + /// + public List MacchineEnergy() + { + List dbResult = new List(); + using (var dbCtx = new MoonPro_STATSContext(_configuration)) + { + dbResult = dbCtx + .DbSetMacchine + .FromSqlRaw("EXEC stp_MaccEnergy") + .ToList(); + } + return dbResult; + } + /// /// Elenco da tabella Macchine /// @@ -277,52 +338,6 @@ namespace MP.Data.Controllers return dbResult; } - - /// - /// Restituisce dataset FluxLog filtrato - /// - /// Macchina singola, se "" = tutte - /// Data inizio selezione odl (inizio/fine) - /// Data fine selezione odl (inizio/fine) - /// Tipo Flusso, "" = tutti - /// - public List FluxLogRawData(string IdxMacchina, DateTime DtStart, DateTime DtEnd, string fluxType) - { - List dbResult = new List(); - using (var dbCtx = new MoonPro_STATSContext(_configuration)) - { - - dbResult = dbCtx - .DbSetFL - .Where(x => - (IdxMacchina == "*" || x.IdxMacchina == IdxMacchina) - && (fluxType == "*" || x.FluxType == fluxType) - && (x.dtEvento >= DtStart && x.dtEvento <= DtEnd)) - .ToList(); - } - return dbResult; - } - - /// - /// Elenco di tipi flusso disponibili - /// - /// - public List FluxTypeList() - { - List dbResult = new List(); - using (var dbCtx = new MoonPro_STATSContext(_configuration)) - { - - dbResult = dbCtx - .DbSetFL - .Select(x => x.FluxType) - .Distinct() - .OrderBy(x => x) - .ToList(); - } - return dbResult; - } - /// /// Elenco tabella ODL da filtro /// diff --git a/MP.Stats/Components/ChartEnergy.razor.cs b/MP.Stats/Components/ChartEnergy.razor.cs index e2ae0f65..b956f68f 100644 --- a/MP.Stats/Components/ChartEnergy.razor.cs +++ b/MP.Stats/Components/ChartEnergy.razor.cs @@ -15,6 +15,9 @@ namespace MP.Stats.Components [Parameter] public bool DynMode { get; set; } = false; + [Parameter] + public bool HideCurrent { get; set; } = false; + [Parameter] public List RawData { @@ -163,14 +166,15 @@ namespace MP.Stats.Components { if (RawData != null) { + lineTitles = new List(); if (DynMode) { ParetoData = RawData - .GroupBy(p => new { p.IdxMacchina }) //.GroupBy(p => new { p.IdxMacchina, p.CodArticolo }) + //.Select(y => new ChartKV() { label = $"{y.First().IdxMacchina} {y.First().CodArticolo}", value = y.Count() }) + .GroupBy(p => new { p.IdxMacchina }) .Select(y => new ChartKV() { label = y.First().IdxMacchina, value = y.Count() }) - //.Select(y => new ChartKV() { label = $"{y.First().IdxMacchina} {y.First().CodArticolo}", value = y.Count() }) .OrderByDescending(x => x.value) .ToList(); @@ -192,7 +196,7 @@ namespace MP.Stats.Components lineTitles.Add($"{idxMacc} | {TradService.Traduci("MP-STATS_TotEn01")} / {StatService.FluxGetUM("TotCount01")}"); var TSDataCurr = RawData - .Where(x => x.IdxMacchina == idxMacc) + .Where(x => x.IdxMacchina == idxMacc && (!HideCurrent || (x.TotCount01 + x.TotCount02 + x.TotCount03) > 0)) .Select(r => new chartJsData.chartJsTSerie() { x = r.DataInizio, y = (double)r.AvgTotEn01 }) .OrderBy(o => o.x) .ToList(); @@ -211,6 +215,7 @@ namespace MP.Stats.Components .ToList(); TSData = RawData + .Where(x => (!HideCurrent || (x.TotCount01 + x.TotCount02 + x.TotCount03) > 0)) .GroupBy(x => x.DataInizio.Date) .Select(r => new chartJsData.chartJsTSerie() { x = r.First().DataInizio.Date, y = r.Average(l => (double)l.AvgWatt) }) .OrderBy(o => o.x) diff --git a/MP.Stats/Components/ChartTrends.razor b/MP.Stats/Components/ChartTrends.razor index da6afa29..b1156ef1 100644 --- a/MP.Stats/Components/ChartTrends.razor +++ b/MP.Stats/Components/ChartTrends.razor @@ -3,17 +3,19 @@
-
+
+
+
    @@ -26,18 +28,20 @@
-
-
-
    - @foreach (var item in @ParetoData) - { -
  • - @item.label - @item.value -
  • - } -
- selezione ITEM da mostrare, tra quelli POSSIBILI dato periodo... +
diff --git a/MP.Stats/Components/SelectionFilter.razor.cs b/MP.Stats/Components/SelectionFilter.razor.cs index 14cd8c0e..9fc1ca50 100644 --- a/MP.Stats/Components/SelectionFilter.razor.cs +++ b/MP.Stats/Components/SelectionFilter.razor.cs @@ -9,6 +9,52 @@ namespace MP.Stats.Components { public partial class SelectionFilter { + #region Public Properties + + /// + /// Indica se filtrare ANCHE le azioni (x tab UL) + /// + [Parameter] + public bool ActionsEnabled { get; set; } = false; + + public string btnClass + { + get + { + return ChartEnabled ? "btn btn-sm btn-info" : "btn btn-sm btn-secondary"; + } + } + + [Parameter] + public bool ChartEnabled { get; set; } = false; + + [Parameter] + public EventCallback chartsToggle { get; set; } + + [Parameter] + public bool chartVisible { get; set; } = false; + + [Parameter] + public bool CommessaEnabled { get; set; } = true; + + [Parameter] + public EventCallback filterChanged { get; set; } + + [Parameter] + public EventCallback filterReset { get; set; } + + /// + /// Selettore x mostrare filtri relativi ad energia: + /// es: mostra solo macchine con dati energia + /// + [Parameter] + public bool OnlyEnergy { get; set; } = false; + + [Parameter] + public SelectData SelFilter { get; set; } + + #endregion Public Properties + #region Protected Fields protected string _searchArt = ""; @@ -17,16 +63,6 @@ namespace MP.Stats.Components #endregion Protected Fields - #region Private Properties - - private List ddlArticoli { get; set; } - private List ddlCommesse { get; set; } - private List ddlMacchine { get; set; } - private List ddlAzioni { get; set; } - private string selectedSearchValue { get; set; } = "*"; - - #endregion Private Properties - #region Protected Properties protected string Azione @@ -164,67 +200,6 @@ namespace MP.Stats.Components #endregion Protected Properties - #region Public Properties - - public string btnClass - { - get - { - return ChartEnabled ? "btn btn-sm btn-info" : "btn btn-sm btn-secondary"; - } - } - - [Parameter] - public bool ChartEnabled { get; set; } = false; - - [Parameter] - public EventCallback chartsToggle { get; set; } - - [Parameter] - public bool chartVisible { get; set; } = false; - - [Parameter] - public bool CommessaEnabled { get; set; } = true; - - /// - /// Indica se filtrare ANCHE le azioni (x tab UL) - /// - [Parameter] - public bool ActionsEnabled { get; set; } = false; - - [Parameter] - public EventCallback filterChanged { get; set; } - - [Parameter] - public EventCallback filterReset { get; set; } - - [Parameter] - public SelectData SelFilter { get; set; } - - #endregion Public Properties - - #region Private Methods - - private void MySearchHandler(string newValue) - { - IdxMacchina = newValue; - } - - private async Task reloadData() - { - ddlArticoli = await StatService.ArticoliGetSearch(-1, SearchArt); - ddlAzioni = await StatService.AzioniList(); - ddlCommesse = await StatService.CommesseGetSearch(-1, SearchArt); - ddlMacchine = await StatService.MachineList(); - } - - private void reportChange() - { - filterChanged.InvokeAsync(SelFilter); - } - - #endregion Private Methods - #region Protected Methods protected override async Task OnInitializedAsync() @@ -243,5 +218,37 @@ namespace MP.Stats.Components } #endregion Protected Methods + + #region Private Properties + + private List ddlArticoli { get; set; } + private List ddlAzioni { get; set; } + private List ddlCommesse { get; set; } + private List ddlMacchine { get; set; } + private string selectedSearchValue { get; set; } = "*"; + + #endregion Private Properties + + #region Private Methods + + private void MySearchHandler(string newValue) + { + IdxMacchina = newValue; + } + + private async Task reloadData() + { + ddlArticoli = await StatService.ArticoliGetSearch(-1, SearchArt); + ddlAzioni = await StatService.AzioniList(); + ddlCommesse = await StatService.CommesseGetSearch(-1, SearchArt); + ddlMacchine = await StatService.MachineList(OnlyEnergy); + } + + private void reportChange() + { + filterChanged.InvokeAsync(SelFilter); + } + + #endregion Private Methods } } \ No newline at end of file diff --git a/MP.Stats/Data/MpStatsService.cs b/MP.Stats/Data/MpStatsService.cs index 517c7dac..a2897632 100644 --- a/MP.Stats/Data/MpStatsService.cs +++ b/MP.Stats/Data/MpStatsService.cs @@ -250,7 +250,7 @@ namespace MP.Stats.Data return answ; } - public async Task> MacchineGetAll() + public List MacchineGetAll() { // setup parametri costanti string source = "DB"; @@ -260,7 +260,7 @@ namespace MP.Stats.Data // cerco in redis... DateTime adesso = DateTime.Now; string currKey = $"{redisBaseKey}:Cache:Macchine"; - RedisValue rawData = await redisDb.StringGetAsync(currKey); + RedisValue rawData = redisDb.StringGet(currKey); if (rawData.HasValue) { result = JsonConvert.DeserializeObject>($"{rawData}"); @@ -271,7 +271,7 @@ namespace MP.Stats.Data result = dbController.MacchineGetAll().ToList(); // serializzp e salvo... rawData = JsonConvert.SerializeObject(result); - await redisDb.StringSetAsync(currKey, rawData, FastCache); + redisDb.StringSet(currKey, rawData, FastCache); } if (result == null) { @@ -282,18 +282,64 @@ namespace MP.Stats.Data return result; } - public Task> MachineList() + public List MacchineEnergy() + { + // setup parametri costanti + string source = "DB"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + List result = new List(); + // cerco in redis... + DateTime adesso = DateTime.Now; + string currKey = $"{redisBaseKey}:Cache:MacchineEnergy"; + RedisValue rawData = redisDb.StringGet(currKey); + if (rawData.HasValue) + { + result = JsonConvert.DeserializeObject>($"{rawData}"); + source = "REDIS"; + } + else + { + result = dbController.MacchineEnergy().ToList(); + // serializzp e salvo... + rawData = JsonConvert.SerializeObject(result); + redisDb.StringSet(currKey, rawData, FastCache); + } + if (result == null) + { + result = new List(); + } + sw.Stop(); + Log.Debug($"MacchineEnergy | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + return result; + } + + public Task> MachineList(bool onlyEnergy = false) { List answ = new List(); answ.Add(new AutocompleteModel { LabelField = "--- TUTTE ---", ValueField = "*" }); - answ.AddRange(dbController - .MacchineGetAll() - .Select(x => new AutocompleteModel - { - LabelField = $"{x.IdxMacchina} | {x.Nome} {x.Descrizione} ", - ValueField = x.IdxMacchina - }) - .ToList()); + if (onlyEnergy) + { + answ.AddRange(dbController + .MacchineEnergy() + .Select(x => new AutocompleteModel + { + LabelField = $"{x.IdxMacchina} | {x.Nome} {x.Descrizione} ", + ValueField = x.IdxMacchina + }) + .ToList()); + } + else + { + answ.AddRange(dbController + .MacchineGetAll() + .Select(x => new AutocompleteModel + { + LabelField = $"{x.IdxMacchina} | {x.Nome} {x.Descrizione} ", + ValueField = x.IdxMacchina + }) + .ToList()); + } return Task.FromResult(answ); } diff --git a/MP.Stats/MP.Stats.csproj b/MP.Stats/MP.Stats.csproj index b11297f0..d0094905 100644 --- a/MP.Stats/MP.Stats.csproj +++ b/MP.Stats/MP.Stats.csproj @@ -4,8 +4,8 @@ net6.0 MP.Stats 826e877c-ba70-4253-84cb-d0b1cafd4440 - 6.16.2507.0213 - 6.16.2507.0213 + 6.16.2507.0217 + 6.16.2507.0217 true $(NoWarn);1591 en diff --git a/MP.Stats/Pages/Energy.razor b/MP.Stats/Pages/Energy.razor index d72ed36b..c1d94d5d 100644 --- a/MP.Stats/Pages/Energy.razor +++ b/MP.Stats/Pages/Energy.razor @@ -4,12 +4,12 @@
- +
@if (ShowCharts == true) { - + } @if (ListRecords == null) { @@ -66,7 +66,7 @@ @foreach (var record in ListRecords) { - + @record.IdxMacchina
@record.KeyRichiesta
diff --git a/MP.Stats/Pages/Energy.razor.cs b/MP.Stats/Pages/Energy.razor.cs index 32e8afa0..f4a9b001 100644 --- a/MP.Stats/Pages/Energy.razor.cs +++ b/MP.Stats/Pages/Energy.razor.cs @@ -51,18 +51,7 @@ namespace MP.Stats.Pages [Inject] protected MpStatsService StatService { get; set; } - protected int totalCount - { - get - { - int answ = 0; - if (SearchRecords != null) - { - answ = SearchRecords.Count; - } - return answ; - } - } + protected int totalCount = 0; [Inject] protected TranslateSrv TradService { get; set; } @@ -71,14 +60,19 @@ namespace MP.Stats.Pages #region Protected Methods - protected string checkSelect(int IdxODL) + /// + /// Verifica: se è nullo il valore pz totali --> current --> indico non confermato + /// + /// + /// + protected string checkCurrent(OdlEnergyModel testRec) { string answ = ""; - if (currRecord != null) + if (testRec != null) { try { - answ = (currRecord.IdxOdl == IdxODL) ? "table-info" : ""; + answ = (testRec.TotCount01 + testRec.TotCount02 + testRec.TotCount03) == 0 || testRec.DataFine == null ? "table-warning opacity-50" : ""; } catch { } @@ -272,6 +266,7 @@ namespace MP.Stats.Pages private async Task ReloadData() { SearchRecords = await StatService.StatOdlEnergyGetAll(currFilter, MServ.SearchVal); + totalCount = SearchRecords.Count; DisplayData(); } diff --git a/MP.Stats/Pages/TrendAnalysis.razor b/MP.Stats/Pages/TrendAnalysis.razor index cb6d58aa..cb934cb1 100644 --- a/MP.Stats/Pages/TrendAnalysis.razor +++ b/MP.Stats/Pages/TrendAnalysis.razor @@ -5,7 +5,7 @@
- +
@if (isLoading) diff --git a/MP.Stats/Resources/ChangeLog.html b/MP.Stats/Resources/ChangeLog.html index e6c21b4e..50fc96da 100644 --- a/MP.Stats/Resources/ChangeLog.html +++ b/MP.Stats/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo statistiche MAPO -

Versione: 6.16.2507.0213

+

Versione: 6.16.2507.0217


Note di rilascio:
    diff --git a/MP.Stats/Resources/VersNum.txt b/MP.Stats/Resources/VersNum.txt index 294dc18e..c0a31142 100644 --- a/MP.Stats/Resources/VersNum.txt +++ b/MP.Stats/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2507.0213 +6.16.2507.0217 diff --git a/MP.Stats/Resources/manifest.xml b/MP.Stats/Resources/manifest.xml index 73b20bf6..a8ea4ca5 100644 --- a/MP.Stats/Resources/manifest.xml +++ b/MP.Stats/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2507.0213 + 6.16.2507.0217 https://nexus.steamware.net/repository/SWS/MP-STATS/stable/LAST/MP.Stats.zip https://nexus.steamware.net/repository/SWS/MP-STATS/stable/LAST/ChangeLog.html false