diff --git a/MP.Data/Controllers/MpStatsController.cs b/MP.Data/Controllers/MpStatsController.cs index 1fdb1f9b..843c0daf 100644 --- a/MP.Data/Controllers/MpStatsController.cs +++ b/MP.Data/Controllers/MpStatsController.cs @@ -49,12 +49,68 @@ namespace MP.Data.Controllers return dbResult; } + /// + /// Elenco tabella Articoli da filtro + /// + /// + /// + /// + public List ArticoliGetSearch(int numRecord, string searchVal = "") + { + List dbResult = new List(); + + dbResult = dbCtx + .DbSetArticoli + .Where(x => x.CodArticolo.Contains(searchVal) || x.DescArticolo.Contains(searchVal) || x.Disegno.Contains(searchVal) || string.IsNullOrEmpty(searchVal)) + .OrderBy(x => x.CodArticolo) + .Take(numRecord) + .ToList(); + + return dbResult; + } + + /// + /// Elenco tabella Articoli da filtro + /// + /// + /// + /// + public List CommesseGetSearch(int numRecord, string searchVal = "") + { + List dbResult = new List(); + + dbResult = dbCtx + .DbSetODL + .Where(x => x.KeyRichiesta.Contains(searchVal) || string.IsNullOrEmpty(searchVal)) + .OrderBy(x => x.KeyRichiesta) + .Take(numRecord) + .ToList(); + + return dbResult; + } + public void Dispose() { // Clear database context dbCtx.Dispose(); } + /// + /// Elenco tabella Macchine + /// + /// + public List MacchineGetAll() + { + List dbResult = new List(); + + dbResult = dbCtx + .DbSetMacchine + .OrderBy(x => x.IdxMacchina) + .ToList(); + + return dbResult; + } + /// /// Annulla modifiche su una specifica entity (cancel update) /// @@ -77,26 +133,6 @@ namespace MP.Data.Controllers return answ; } - /// - /// Elenco tabella Articoli da filtro - /// - /// - /// - /// - public List StatArticoliGetSearch(int numRecord, string searchVal = "") - { - List dbResult = new List(); - - dbResult = dbCtx - .DbSetArticoli - .Where(x => x.CodArticolo.Contains(searchVal) || x.DescArticolo.Contains(searchVal) || x.Disegno.Contains(searchVal) || string.IsNullOrEmpty(searchVal)) - .OrderBy(x => x.CodArticolo) - .Take(numRecord) - .ToList(); - - return dbResult; - } - /// /// Elenco tabella controlli da filtro /// @@ -107,13 +143,6 @@ namespace MP.Data.Controllers { List dbResult = new List(); - //dbResult = dbCtx - // .DbSetControlli - // .Where(x => x.Note.Contains(searchVal) || x.IdxMacchina.Contains(searchVal) || x.CodArticolo.Contains(searchVal) || string.IsNullOrEmpty(searchVal)) - // .OrderByDescending(x => x.DataOra) - // .Take(numRecord) - // .ToList(); - var dataFrom = new SqlParameter("@dataFrom", DataStart); var dataTo = new SqlParameter("@dataTo", DataEnd); var idxMacchina = new SqlParameter("@idxMacchina", IdxMacchina); @@ -161,24 +190,6 @@ namespace MP.Data.Controllers return dbResult; } - /// - /// Elenco tabella MAcchine - /// - /// - /// - /// - public List StatMacchineGetAll() - { - List dbResult = new List(); - - dbResult = dbCtx - .DbSetMacchine - .OrderBy(x => x.IdxMacchina) - .ToList(); - - return dbResult; - } - /// /// Elenco tabella ODL da filtro /// diff --git a/MP.Stats/Components/DetailOee.razor b/MP.Stats/Components/DetailOee.razor new file mode 100644 index 00000000..032aae93 --- /dev/null +++ b/MP.Stats/Components/DetailOee.razor @@ -0,0 +1,100 @@ +@using MP.Stats.Data +@inject NavigationManager NavManager +@inject MessageService MessageService + +
+
+ GRAFICO +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +
+
+ +@code{ + + protected MP.Data.DatabaseModels.TurniOee _currRecord = new MP.Data.DatabaseModels.TurniOee(); + + [Parameter] + public MP.Data.DatabaseModels.TurniOee currRecord + { + get + { + return _currRecord; + } + set + { + _currRecord = value; + } + } + + [Parameter] + public SelectData CurrFilter { get; set; } + + protected void ShowCont() + { + SetFilter(); + // rimando... + NavManager.NavigateTo($"controlli"); + } + + protected void ShowDDB() + { + SetFilter(); + // rimando... + NavManager.NavigateTo($"diario"); + } + + protected void ShowScar() + { + SetFilter(); + // rimando... + NavManager.NavigateTo($"scarti"); + } + + protected void ShowUAL() + { + SetFilter(); + // rimando... + NavManager.NavigateTo($"userlog"); + } + + protected void SetFilter() + { + int oraStart = 0; + switch (currRecord.Turno) + { + case "T1": + oraStart = 6; + break; + case "T2": + oraStart = 14; + break; + case "T3": + oraStart = 22; + break; + default: + break; + } + CurrFilter = new SelectData() + { + IdxMacchina = currRecord.IdxMacchina, + CodArticolo = currRecord.CodArticolo, + DateStart = currRecord.DataRif.AddHours(oraStart), + DateEnd = currRecord.DataRif.AddHours(oraStart + 8) + }; + MessageService.DetailFilter = CurrFilter; + } +} \ No newline at end of file diff --git a/MP.Stats/Components/SelectionFilter.razor b/MP.Stats/Components/SelectionFilter.razor index 8d277f2b..f1bd95d1 100644 --- a/MP.Stats/Components/SelectionFilter.razor +++ b/MP.Stats/Components/SelectionFilter.razor @@ -1,4 +1,7 @@ - +@using Blazorise.Components +@using MP.Stats.Data + +
@@ -15,20 +18,50 @@
- + + @foreach (var item in ddlMacchine) + { + + } +
- - +
+
+ +
+ +
+ + @foreach (var item in ddlCommesse) + { + + } +
-
- - +
+
+ +
+ +
+ + @foreach (var item in ddlArticoli) + { + + } + +
+
+
+
+
+
diff --git a/MP.Stats/Components/SelectionFilter.razor.cs b/MP.Stats/Components/SelectionFilter.razor.cs index b9b00a3e..70af721e 100644 --- a/MP.Stats/Components/SelectionFilter.razor.cs +++ b/MP.Stats/Components/SelectionFilter.razor.cs @@ -10,6 +10,23 @@ namespace MP.Stats.Components { public partial class SelectionFilter { + #region Protected Fields + + protected string _searchArt = ""; + protected string _searchCom = ""; + protected int minChar = 3; + + #endregion Protected Fields + + #region Private Properties + + private List ddlArticoli { get; set; } + private List ddlCommesse { get; set; } + private List ddlMacchine { get; set; } + private string selectedSearchValue { get; set; } = "*"; + + #endregion Private Properties + #region Protected Properties protected string CodArticolo @@ -20,10 +37,9 @@ namespace MP.Stats.Components } set { - bool doReport = (!SelFilter.CodArticolo.Equals(value)); - SelFilter.CodArticolo = value; - if (doReport) + if (!SelFilter.CodArticolo.Equals(value)) { + SelFilter.CodArticolo = value; reportChange(); } } @@ -71,10 +87,9 @@ namespace MP.Stats.Components } set { - bool doReport = (!SelFilter.IdxMacchina.Equals(value)); - SelFilter.IdxMacchina = value; - if (doReport) + if (!SelFilter.IdxMacchina.Equals(value)) { + SelFilter.IdxMacchina = value; reportChange(); } } @@ -88,15 +103,49 @@ namespace MP.Stats.Components } set { - bool doReport = (!SelFilter.KeyRichiesta.Equals(value)); - SelFilter.KeyRichiesta = value; - if (doReport) + if (!SelFilter.KeyRichiesta.Equals(value)) { + SelFilter.KeyRichiesta = value; reportChange(); } } } + protected string SearchArt + { + get => _searchArt; + set + { + _searchArt = value; + int numRowArt = -1; + if (value.Count() > minChar) + { + numRowArt = 20; + } + ddlArticoli = StatService.ArticoliGetSearch(numRowArt, SearchArt).Result; + CodArticolo = "*"; + } + } + + protected string SearchCom + { + get => _searchCom; + set + { + _searchCom = value; + int numRowArt = -1; + if (value.Count() > minChar) + { + numRowArt = 20; + } + ddlCommesse = StatService.CommesseGetSearch(numRowArt, SearchCom).Result; + KeyRichiesta = "*"; + } + } + + [Inject] + protected MpStatsService StatService { get; set; } + #endregion Protected Properties #region Public Properties @@ -104,6 +153,9 @@ namespace MP.Stats.Components [Parameter] public EventCallback filterChanged { get; set; } + [Parameter] + public EventCallback filterReset { get; set; } + [Parameter] public SelectData SelFilter { get; set; } @@ -111,11 +163,37 @@ namespace MP.Stats.Components #region Private Methods + private void MySearchHandler(string newValue) + { + IdxMacchina = newValue; + } + + private async Task reloadData() + { + ddlMacchine = await StatService.MachineList(); + ddlArticoli = await StatService.ArticoliGetSearch(-1, SearchArt); + ddlCommesse = await StatService.CommesseGetSearch(-1, SearchArt); + } + private void reportChange() { filterChanged.InvokeAsync(SelFilter); } #endregion Private Methods + + #region Protected Methods + + protected override async Task OnInitializedAsync() + { + await reloadData(); + } + + protected void resetFilter() + { + filterReset.InvokeAsync(SelFilter); + } + + #endregion Protected Methods } } \ No newline at end of file diff --git a/MP.Stats/Data/AutocompleteModel.cs b/MP.Stats/Data/AutocompleteModel.cs new file mode 100644 index 00000000..59249ec0 --- /dev/null +++ b/MP.Stats/Data/AutocompleteModel.cs @@ -0,0 +1,17 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; + +namespace MP.Stats.Data +{ + public class AutocompleteModel + { + #region Public Properties + + public string LabelField { get; set; } + public string ValueField { get; set; } + + #endregion Public Properties + } +} \ No newline at end of file diff --git a/MP.Stats/Data/MessageService.cs b/MP.Stats/Data/MessageService.cs index c01e734c..13417b00 100644 --- a/MP.Stats/Data/MessageService.cs +++ b/MP.Stats/Data/MessageService.cs @@ -9,13 +9,17 @@ namespace MP.Stats.Data { #region Private Fields - private string searchVal; + private SelectData _detailFilter = new SelectData(); + private SelectData _masterFilter = new SelectData(); + private string _searchVal; private bool showSearch; #endregion Private Fields #region Public Events + public event Action EA_FilterUpdated; + public event Action EA_HideSearch; public event Action EA_SearchUpdated; @@ -26,14 +30,37 @@ namespace MP.Stats.Data #region Public Properties - public string SearchVal + public SelectData DDB_Filter { get; set; } = SelectData.Init(5, 3); + + public SelectData DetailFilter { - get => searchVal; + get => _detailFilter; set { - if (searchVal != value) + if (_detailFilter != value) { - searchVal = value; + _detailFilter = value; + + if (EA_FilterUpdated != null) + { + EA_FilterUpdated?.Invoke(); + } + } + } + } + + public SelectData KRE_Filter { get; set; } = SelectData.Init(5, 7); + public SelectData ODL_Filter { get; set; } = SelectData.Init(5, 7); + public SelectData OEE_Filter { get; set; } = SelectData.Init(5, 7); + + public string SearchVal + { + get => _searchVal; + set + { + if (_searchVal != value) + { + _searchVal = value; if (EA_SearchUpdated != null) { diff --git a/MP.Stats/Data/MpStatsService.cs b/MP.Stats/Data/MpStatsService.cs index 922b3656..9b17ab77 100644 --- a/MP.Stats/Data/MpStatsService.cs +++ b/MP.Stats/Data/MpStatsService.cs @@ -124,16 +124,54 @@ namespace MP.Stats.Data return await Task.FromResult(dbResult); } + public Task> ArticoliGetSearch(int numRecord, string searchVal = "") + { + List answ = new List(); + answ.Add(new AutocompleteModel { LabelField = "--- TUTTE ---", ValueField = "*" }); + if (numRecord > -1) + { + answ.AddRange(dbController.ArticoliGetSearch(numRecord, searchVal).Select(x => new AutocompleteModel { LabelField = $"{x.CodArticolo} {x.DescArticolo} {x.Disegno}", ValueField = x.CodArticolo }).ToList()); + } + return Task.FromResult(answ); + } + + public Task> ArticoliList(string searchVal) + { + List answ = new List(); + answ.Add(new AutocompleteModel { LabelField = "--- TUTTE ---", ValueField = "*" }); + answ.AddRange(dbController.MacchineGetAll().Select(x => new AutocompleteModel { LabelField = x.IdxMacchina, ValueField = x.IdxMacchina }).ToList()); + return Task.FromResult(answ); + } + + public Task> CommesseGetSearch(int numRecord, string searchVal = "") + { + List answ = new List(); + answ.Add(new AutocompleteModel { LabelField = "--- TUTTE ---", ValueField = "*" }); + if (numRecord > -1) + { + answ.AddRange(dbController.CommesseGetSearch(numRecord, searchVal).Select(x => new AutocompleteModel { LabelField = $"{x.CodArticolo} | {x.KeyRichiesta}", ValueField = x.KeyRichiesta }).ToList()); + } + return Task.FromResult(answ); + } + + public Task> MacchineGetAll() + { + return Task.FromResult(dbController.MacchineGetAll().ToList()); + } + + public Task> MachineList() + { + 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()); + return Task.FromResult(answ); + } + public void rollBackEdit(object item) { dbController.RollBackEntity(item); } - public Task StatArticoliGetSearch(int numRecord, string searchVal = "") - { - return Task.FromResult(dbController.StatArticoliGetSearch(numRecord, searchVal).ToArray()); - } - public async Task> StatControlliGetAll(SelectData CurrFilter, string searchVal = "") { //return Task.FromResult(dbController.StatControlliGetAll(DataStart, DataEnd, IdxMacchina, IdxODL, KeyRichiesta, CodArticolo).ToArray()); @@ -178,11 +216,6 @@ namespace MP.Stats.Data return await Task.FromResult(dbResult); } - public Task StatMacchineGetAll() - { - return Task.FromResult(dbController.StatMacchineGetAll().ToArray()); - } - public async Task> StatOdlGetAll(SelectData CurrFilter, string searchVal = "") { //return Task.FromResult(dbController.StatOdlGetAll(numRecord, searchVal)); diff --git a/MP.Stats/MP.Stats.csproj b/MP.Stats/MP.Stats.csproj index b033953d..b775dfbc 100644 --- a/MP.Stats/MP.Stats.csproj +++ b/MP.Stats/MP.Stats.csproj @@ -33,6 +33,7 @@ + diff --git a/MP.Stats/Pages/Controlli.razor b/MP.Stats/Pages/Controlli.razor index 494ccd16..afb31fb5 100644 --- a/MP.Stats/Pages/Controlli.razor +++ b/MP.Stats/Pages/Controlli.razor @@ -1,4 +1,5 @@ @page "/controlli" +@*@page "/controlli/{IdxMacchina}"*@ @using MP.Stats.Components @@ -13,13 +14,17 @@
- +
- @if (totalCount == 0 || ListRecords == null) + @if (ListRecords == null) { } + else if (totalCount == 0) + { +
Nessun record trovato
+ } else {
diff --git a/MP.Stats/Pages/Controlli.razor.cs b/MP.Stats/Pages/Controlli.razor.cs index fd6ddda6..9078500b 100644 --- a/MP.Stats/Pages/Controlli.razor.cs +++ b/MP.Stats/Pages/Controlli.razor.cs @@ -21,9 +21,10 @@ namespace MP.Stats.Pages #region Private Properties - private SelectData currFilter { get; set; } = new SelectData(); private int currPage { get; set; } = 1; + private bool isLoading { get; set; } = false; + private int numRecord { get; set; } = 10; #endregion Private Properties @@ -57,6 +58,26 @@ namespace MP.Stats.Pages #endregion Protected Properties + #region Public Properties + + [Parameter] + public SelectData currFilter + { + get + { + return MessageService.DetailFilter; + } + set + { + MessageService.DetailFilter = value; + } + } + + [Parameter] + public string IdxMacchina { get; set; } = ""; + + #endregion Public Properties + #region Private Methods private async Task reloadData() @@ -94,7 +115,6 @@ namespace MP.Stats.Pages protected override async Task OnInitializedAsync() { numRecord = 10; - currFilter = SelectData.Init(5, 7); MessageService.ShowSearch = false; MessageService.EA_SearchUpdated += OnSeachUpdated; await reloadData(); @@ -106,6 +126,15 @@ namespace MP.Stats.Pages currRecord = null; } + protected async Task ResetFilter(SelectData newFilter) + { + currRecord = null; + SearchRecords = null; + ListRecords = null; + currFilter = SelectData.Init(5, 7); + await reloadData(); + } + protected async Task UpdateData() { currRecord = null; diff --git a/MP.Stats/Pages/Diario.razor b/MP.Stats/Pages/Diario.razor index 80a93461..e31d0977 100644 --- a/MP.Stats/Pages/Diario.razor +++ b/MP.Stats/Pages/Diario.razor @@ -13,52 +13,56 @@
- +
- @if (totalCount == 0 || ListRecords == null || ListRecords.Count() == 0) + @if (ListRecords == null) { - + + } + else if (totalCount == 0) + { +
Nessun record trovato
} else { -
-
- - - - - - - - - - - - - - @foreach (var record in ListRecords) +
+
+
MacchinaDataODL/CommessaArticoloStatoDurataPezzi
+ + + + + + + + + + + + + @foreach (var record in ListRecords) { - - - - - - - - - + + + + + + + + + } - -
MacchinaDataODL/CommessaArticoloStatoDurataPezzi
-
@record.CodMacchina
-
@record.IdxMacchina
-
-
@record.InizioStato.ToString("yyyy.MM.dd")
-
@record.InizioStato.ToString("ddd HH:mm.ss")
-
@record.IdxOdl | @record.KeyRichiesta@record.CodArticolo@record.Descrizione@record.DurataMin@record.TotPzProd
+
@record.CodMacchina
+
@record.IdxMacchina
+
+
@record.InizioStato.ToString("yyyy.MM.dd")
+
@record.InizioStato.ToString("ddd HH:mm.ss")
+
@record.IdxOdl | @record.KeyRichiesta@record.CodArticolo@record.Descrizione@record.DurataMin@record.TotPzProd
+ + +
-
}