diff --git a/MP-TAB-SERV/Components/ScrapKitMan.razor b/MP-TAB-SERV/Components/ScrapKitMan.razor index 0ebc9b1f..b8af8abd 100644 --- a/MP-TAB-SERV/Components/ScrapKitMan.razor +++ b/MP-TAB-SERV/Components/ScrapKitMan.razor @@ -1,12 +1,74 @@ -
+ + +
- -

ScrapKitMan

- dettaglio gestione kit +
+ + + + + + + + @if (TotalCount == 0) + { + + + + } + else + { + @foreach (var item in ListPaged) + { + + + + } + } + +
+ Esplosione scarti KIT +
+
No record found
+
+
+
+
+ Art: @item.CodArticolo +
+
+ @item.Descrizione +
+
+
+
+ @item.Qta +
+
+ ×pz +
+
+
+
+ @($"{item.DataOra:ddd dd.MM.yy HH:mm:ss}") + +
+
+ @item.Operatore + +
+
+
+ @if (!string.IsNullOrEmpty(item.Note)) + { + Nota: @item.Note + } +
+
+
+
-@code { -} diff --git a/MP-TAB-SERV/Components/ScrapKitMan.razor.cs b/MP-TAB-SERV/Components/ScrapKitMan.razor.cs new file mode 100644 index 00000000..3d1f352c --- /dev/null +++ b/MP-TAB-SERV/Components/ScrapKitMan.razor.cs @@ -0,0 +1,83 @@ +using Microsoft.AspNetCore.Components; +using MP.Data.DatabaseModels; +using MP.Data.Services; +using NLog; + +namespace MP_TAB_SERV.Components +{ + public partial class ScrapKitMan + { + #region Public Properties + + [Parameter] + public RegistroScartiModel ParentKit { get; set; } = null!; + + #endregion Public Properties + + #region Protected Properties + + protected List ListComplete { get; set; } = new List(); + + protected List ListPaged { get; set; } = new List(); + + [Inject] + protected TabDataService TabDServ { get; set; } = null!; + + #endregion Protected Properties + + #region Protected Methods + + protected override async Task OnParametersSetAsync() + { + await ReloadData(); + } + + protected void UpdateTable() + { + // esegue paginazione + if (TotalCount > NumRecPage) + { + ListPaged = ListComplete.Skip((PageNum - 1) * NumRecPage).Take(NumRecPage).ToList(); + } + else + { + ListPaged = ListComplete; + } + } + + #endregion Protected Methods + + #region Private Fields + + private static Logger Log = LogManager.GetCurrentClassLogger(); + + private bool isProcessing = false; + + private int NumRecPage = 10; + + private int PageNum = 1; + + private int TotalCount = 0; + + #endregion Private Fields + + #region Private Methods + + private async Task ReloadData() + { + isProcessing = true; + await Task.Delay(1); + if (ParentKit != null) + { + ListComplete = await TabDServ.RegScartiKitGetFilt(ParentKit); + TotalCount = ListComplete.Count; + // esegue paginazione + UpdateTable(); + } + isProcessing = false; + await Task.Delay(1); + } + + #endregion Private Methods + } +} \ No newline at end of file diff --git a/MP-TAB-SERV/Components/ScrapMan.razor b/MP-TAB-SERV/Components/ScrapMan.razor index de4fa036..0c5916e7 100644 --- a/MP-TAB-SERV/Components/ScrapMan.razor +++ b/MP-TAB-SERV/Components/ScrapMan.razor @@ -49,70 +49,81 @@ - @foreach (var item in ListPaged) + @if (TotalCount == 0) { - - -
-
-
- Art: @item.CodArticolo -
-
- @item.Descrizione -
-
-
-
- @item.Qta -
-
- × - @if (item.Tipo == "KIT") - { - - } - else - { - pz - } -
-
-
-
- @($"{item.DataOra:ddd dd.MM.yy HH:mm:ss}") - -
-
- @item.Operatore - -
-
-
- @if (!string.IsNullOrEmpty(item.Note)) - { - Nota: @item.Note - } -
-
+ + +
No record found
- @if(item.Equals(selItem)) + } + else + { + @foreach (var item in ListPaged) { - + - +
+
+
+ Art: @item.CodArticolo +
+
+ @item.Descrizione +
+
+
+
+ @item.Qta +
+
+ × + @if (item.Tipo == "ART") + { + + } + else + { + pz + } +
+
+
+
+ @($"{item.DataOra:ddd dd.MM.yy HH:mm:ss}") + +
+
+ @item.Operatore + +
+
+
+ @if (!string.IsNullOrEmpty(item.Note)) + { + Nota: @item.Note + } +
+
+ @if (item.Equals(selItem)) + { + + + + + + } } } diff --git a/MP-TAB-SERV/Components/ScrapMan.razor.cs b/MP-TAB-SERV/Components/ScrapMan.razor.cs index a294e372..284b7eb5 100644 --- a/MP-TAB-SERV/Components/ScrapMan.razor.cs +++ b/MP-TAB-SERV/Components/ScrapMan.razor.cs @@ -40,25 +40,23 @@ namespace MP_TAB_SERV.Components #region Protected Properties - - + protected bool enableScarti { get; set; } = true; protected List ListComplete { get; set; } = new List(); protected List ListPaged { get; set; } = new List(); [Inject] protected MessageService MServ { get; set; } = null!; - [Inject] - protected TabDataService TabDServ { get; set; } = null!; [Inject] protected SharedMemService SMServ { get; set; } = null!; + [Inject] + protected TabDataService TabDServ { get; set; } = null!; + #endregion Protected Properties #region Protected Methods - protected bool enableScarti { get; set; } = true; - protected override async Task OnInitializedAsync() { await Task.Delay(1); @@ -73,22 +71,23 @@ namespace MP_TAB_SERV.Components } } - - protected void SaveNumRec(int newNum) { NumRecPage = newNum; UpdateTable(); } - - protected void SavePage(int newNum) { PageNum = newNum; UpdateTable(); } + protected string selectedCss(RegistroScartiModel currItem) + { + return currItem.Equals(selItem) ? "table-info" : ""; + } + protected async Task SetMacc(string selIdxMacc) { isProcessing = true; @@ -115,7 +114,18 @@ namespace MP_TAB_SERV.Components await doUpdate(); } - + protected void ShowKitDetail(RegistroScartiModel currItem) + { + // faccio toggle show item (se era già selezionato --> null!) + if (!currItem.Equals(selItem)) + { + selItem = currItem; + } + else + { + selItem = null; + } + } protected void UpdateTable() { @@ -132,32 +142,13 @@ namespace MP_TAB_SERV.Components #endregion Protected Methods - protected void ShowKitDetail(RegistroScartiModel currItem) - { - // faccio toggle show item (se era già selezionato --> null!) - if (!currItem.Equals(selItem)) - { - selItem = currItem; - } - else - { - selItem = null; - } - } - - protected string selectedCss(RegistroScartiModel currItem) - { - return currItem.Equals(selItem) ? "table-info" : ""; - } - - private RegistroScartiModel? selItem = null; - #region Private Fields private static Logger Log = LogManager.GetCurrentClassLogger(); private bool isProcessing = false; private int NumRecPage = 10; private int PageNum = 1; + private RegistroScartiModel? selItem = null; private int TotalCount = 0; private bool useOdl = false; diff --git a/MP.Data/Controllers/MpTabController.cs b/MP.Data/Controllers/MpTabController.cs index a3a73f25..2162756a 100644 --- a/MP.Data/Controllers/MpTabController.cs +++ b/MP.Data/Controllers/MpTabController.cs @@ -1445,13 +1445,9 @@ namespace MP.Data.Controllers return fatto; } - /// Restituisce elenco Ultimi RC macchina - /// - /// - /// - /// - /// - /// + /// Restituisce elenco Ultimi RC macchina + /// public List RegControlliLast(string idxMacchina) { List dbResult = new List(); @@ -1607,6 +1603,29 @@ namespace MP.Data.Controllers return fatto; } + /// + /// Elenco scarti KIT dato record parent + /// + /// + /// + public List RegScartiKitGetFilt(RegistroScartiModel parentRec) + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + var IdxMacc = new SqlParameter("@IdxMacchina", parentRec.IdxMacchina); + var DtRif = new SqlParameter("@DataRif", parentRec.DataOra); + var Causale = new SqlParameter("@Causale", parentRec.Causale); + + dbResult = dbCtx + .DbSetRegScartiKit + .FromSqlRaw("EXEC stp_RSK_getByFilt @IdxMacchina, @DataRif, @Causale", IdxMacc, DtRif, Causale) + .AsNoTracking() + .ToList(); + } + return dbResult; + } + /// /// Aggiunta record RegistroScartiKit in tab RSK esplodendo x kit /// diff --git a/MP.Data/DatabaseModels/RegistroScartiModel.cs b/MP.Data/DatabaseModels/RegistroScartiModel.cs index 00ab4363..a0829887 100644 --- a/MP.Data/DatabaseModels/RegistroScartiModel.cs +++ b/MP.Data/DatabaseModels/RegistroScartiModel.cs @@ -49,5 +49,10 @@ namespace MP.Data.DatabaseModels return true; } + + public override int GetHashCode() + { + return base.GetHashCode(); + } } } \ No newline at end of file diff --git a/MP.Data/Services/TabDataService.cs b/MP.Data/Services/TabDataService.cs index e313679c..0e93a842 100644 --- a/MP.Data/Services/TabDataService.cs +++ b/MP.Data/Services/TabDataService.cs @@ -2122,6 +2122,42 @@ namespace MP.Data.Services return result; } + /// + /// Restituisce elenco RSK filtrato x parent + /// + /// + /// + public async Task> RegScartiKitGetFilt(RegistroScartiModel ParentRec) + { + // setup parametri costanti + string source = "DB"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + List? result = new List(); + // cerco in redis... + string currKey = $"{redisBaseKey}:RegScartiKit:{ParentRec.IdxMacchina}:{ParentRec.DataOra:yyyyyMMdd-HHmm}:{ParentRec.Causale}"; + RedisValue rawData = await redisDb.StringGetAsync(currKey); + if (rawData.HasValue) + { + result = JsonConvert.DeserializeObject>($"{rawData}"); + source = "REDIS"; + } + else + { + result = dbTabController.RegScartiKitGetFilt(ParentRec); + // serializzp e salvo... + rawData = JsonConvert.SerializeObject(result); + await redisDb.StringSetAsync(currKey, rawData, FastCache); + } + if (result == null) + { + result = new List(); + } + sw.Stop(); + Log.Debug($"RegScartiKitGetFilt | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + return result; + } + /// /// Aggiunta record RegistroScarti ///