Report ODL sotto cache redis e filtro!
This commit is contained in:
@@ -173,15 +173,27 @@ namespace MP.Data.Controllers
|
||||
/// <param name="numRecord"></param>
|
||||
/// <param name="searchVal"></param>
|
||||
/// <returns></returns>
|
||||
public List<DatabaseModels.ODL> StatOdlGetAll(int numRecord, string searchVal = "")
|
||||
public List<DatabaseModels.ODL> StatOdlGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo)
|
||||
{
|
||||
List<DatabaseModels.ODL> dbResult = new List<DatabaseModels.ODL>();
|
||||
|
||||
//dbResult = dbCtx
|
||||
// .DbSetODL
|
||||
// .Where(x => x.CodArticolo.Contains(searchVal) || x.IdxMacchina.Contains(searchVal) || x.KeyRichiesta.Contains(searchVal) || string.IsNullOrEmpty(searchVal))
|
||||
// .OrderByDescending(x => x.DataInizio)
|
||||
// .Take(numRecord)
|
||||
// .ToList();
|
||||
|
||||
var dataFrom = new SqlParameter("@dataFrom", DataStart);
|
||||
var dataTo = new SqlParameter("@dataTo", DataEnd);
|
||||
var idxMacchina = new SqlParameter("@idxMacchina", IdxMacchina);
|
||||
var idxODL = new SqlParameter("@IdxODL", IdxODL);
|
||||
var keyRichiesta = new SqlParameter("@KeyRichiesta", KeyRichiesta);
|
||||
var codArticolo = new SqlParameter("@CodArticolo", CodArticolo);
|
||||
|
||||
dbResult = dbCtx
|
||||
.DbSetODL
|
||||
.Where(x => x.CodArticolo.Contains(searchVal) || x.IdxMacchina.Contains(searchVal) || x.KeyRichiesta.Contains(searchVal) || string.IsNullOrEmpty(searchVal))
|
||||
.OrderByDescending(x => x.DataInizio)
|
||||
.Take(numRecord)
|
||||
.FromSqlRaw("EXEC stp_UI_RS_GetByFilter @dataFrom,@dataTo,@idxMacchina,@IdxODL,@KeyRichiesta,@CodArticolo", dataFrom, dataTo, idxMacchina, idxODL, keyRichiesta, codArticolo)
|
||||
.ToList();
|
||||
|
||||
return dbResult;
|
||||
|
||||
@@ -122,9 +122,26 @@ namespace MP.Stats.Data
|
||||
return Task.FromResult(dbController.StatMacchineGetAll().ToArray());
|
||||
}
|
||||
|
||||
public Task<MP.Data.DatabaseModels.ODL[]> StatOdlGetAll(int numRecord, string searchVal = "")
|
||||
public async Task<List<MP.Data.DatabaseModels.ODL>> StatOdlGetAll(SelectData CurrFilter, string searchVal = "")
|
||||
{
|
||||
return Task.FromResult(dbController.StatOdlGetAll(numRecord, searchVal).ToArray());
|
||||
//return Task.FromResult(dbController.StatOdlGetAll(numRecord, searchVal));
|
||||
List<MP.Data.DatabaseModels.ODL> dbResult = new List<MP.Data.DatabaseModels.ODL>();
|
||||
string cacheKey = getCacheKey("MP:STATS:ODL", CurrFilter);
|
||||
string rawData;
|
||||
var redisDataList = await distributedCache.GetAsync(cacheKey);
|
||||
if (redisDataList != null)
|
||||
{
|
||||
rawData = Encoding.UTF8.GetString(redisDataList);
|
||||
dbResult = JsonConvert.DeserializeObject<List<MP.Data.DatabaseModels.ODL>>(rawData);
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = dbController.StatOdlGetAll(CurrFilter.DateStart, CurrFilter.DateEnd, CurrFilter.IdxMacchina, CurrFilter.IdxOdl, CurrFilter.KeyRichiesta, CurrFilter.CodArticolo);
|
||||
rawData = JsonConvert.SerializeObject(dbResult);
|
||||
redisDataList = Encoding.UTF8.GetBytes(rawData);
|
||||
await distributedCache.SetAsync(cacheKey, redisDataList, cacheOpt);
|
||||
}
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
public Task<MP.Data.DatabaseModels.ResScarti[]> StatScartiGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo, string searchVal = "")
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
@page "/oee"
|
||||
|
||||
@using MP.Stats.Components
|
||||
@using MP.Stats.Data
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header table-primary">
|
||||
@@ -28,7 +27,6 @@
|
||||
<table class="table table-sm table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
@*<th></th>*@
|
||||
<th>Data</th>
|
||||
<th>Turno</th>
|
||||
<th>Macchina</th>
|
||||
@@ -62,7 +60,7 @@
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-footer py-1">
|
||||
<DataPager PageSize="@numRecord" currPage="@currPage" numRecordChanged="ForceReload" numPageChanged="ForceReloadPage" totalCount="@totalCount" />
|
||||
<div class="card-footer py-1">
|
||||
<DataPager PageSize="@numRecord" currPage="@currPage" numRecordChanged="ForceReload" numPageChanged="ForceReloadPage" totalCount="@totalCount" />
|
||||
</div>
|
||||
</div>
|
||||
@@ -11,25 +11,22 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body py-0">
|
||||
@if (currRecord != null)
|
||||
<div class="row">
|
||||
<div class="col-12 table-secondary">
|
||||
<SelectionFilter SelFilter="currFilter" filterChanged="DoFilter"></SelectionFilter>
|
||||
</div>
|
||||
</div>
|
||||
@if (totalCount == 0 || ListRecords == null || ListRecords.Count() == 0)
|
||||
{
|
||||
@*<BasketEditor Basket="@currBasket" DataReset="ResetData" DataUpdated="UpdateData"></BasketEditor>*@
|
||||
}
|
||||
@if (ListRecords == null)
|
||||
{
|
||||
<div class="progress-bar progress-bar-striped progress-bar-animated" style="width:70%"></div>
|
||||
<LoadingData></LoadingData>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="row">
|
||||
<div class="col-12 table-secondary">
|
||||
<SelectionFilter SelFilter="currFilter" filterChanged="DoFilter"></SelectionFilter>
|
||||
</div>
|
||||
<div class="col-12">
|
||||
<table class="table table-sm table-striped">
|
||||
<thead>
|
||||
<tr>
|
||||
@*<th></th>*@
|
||||
<th>Macchina</th>
|
||||
<th>ODL/Commessa</th>
|
||||
<th>Articolo</th>
|
||||
@@ -39,31 +36,25 @@
|
||||
<th class="text-right">Pezzi Evasi</th>
|
||||
<th class="text-right">Pezzi Scarti</th>
|
||||
<th class="text-right">Pezzi Rilav</th>
|
||||
@*<th>Operatore</th>*@
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@foreach (var record in ListRecords)
|
||||
{
|
||||
<tr class="@checkSelect(@record.IdxOdl)">
|
||||
@*<td><button class="btn btn-sm btn-info" @onclick="() => Edit(record)"><span class="oi oi-pencil"></span></button> <button class="btn btn-sm btn-success" @onclick="() => ShowDocs(record)" title="Vai ai documenti"><span class="oi oi-document"></span></button></td>*@
|
||||
<td>
|
||||
@record.IdxMacchina
|
||||
</td>
|
||||
@*<td>
|
||||
<div>@record.CodMacchina</div>
|
||||
<div class="small">@record.IdxMacchina</div>
|
||||
</td>*@
|
||||
<td>@record.IdxOdl | @record.KeyRichiesta</td>
|
||||
<td>@record.CodArticolo</td>
|
||||
<td>@record.DataInizio</td>
|
||||
<td>@record.DataFine</td>
|
||||
<td class="text-right">@record.NumPezzi</td>
|
||||
<td class="text-right">@record.NumPezziEv</td>
|
||||
<td class="text-right">@record.NumPezziRil</td>
|
||||
<td class="text-right">@record.NumPezziSca</td>
|
||||
</tr>
|
||||
}
|
||||
{
|
||||
<tr class="@checkSelect(@record.IdxOdl)">
|
||||
<td>
|
||||
@record.IdxMacchina
|
||||
</td>
|
||||
<td>@record.IdxOdl | @record.KeyRichiesta</td>
|
||||
<td>@record.CodArticolo</td>
|
||||
<td>@record.DataInizio</td>
|
||||
<td>@record.DataFine</td>
|
||||
<td class="text-right">@record.NumPezzi</td>
|
||||
<td class="text-right">@record.NumPezziEv</td>
|
||||
<td class="text-right">@record.NumPezziRil</td>
|
||||
<td class="text-right">@record.NumPezziSca</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
@@ -71,6 +62,6 @@
|
||||
}
|
||||
</div>
|
||||
<div class="card-footer py-1">
|
||||
<DataPager PageSize="@numRecord" currPage="@currPage" numRecordChanged="ForceReload" numPageChanged="ForceReloadPage" totalCount="@SearchRecords.Count()" />
|
||||
<DataPager PageSize="@numRecord" currPage="@currPage" numRecordChanged="ForceReload" numPageChanged="ForceReloadPage" totalCount="@totalCount" />
|
||||
</div>
|
||||
</div>
|
||||
@@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.JSInterop;
|
||||
using MP.Stats.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
@@ -13,8 +14,8 @@ namespace MP.Stats.Pages
|
||||
|
||||
private MP.Data.DatabaseModels.ODL currRecord = null;
|
||||
|
||||
private MP.Data.DatabaseModels.ODL[] ListRecords;
|
||||
private MP.Data.DatabaseModels.ODL[] SearchRecords;
|
||||
private List<MP.Data.DatabaseModels.ODL> ListRecords;
|
||||
private List<MP.Data.DatabaseModels.ODL> SearchRecords;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
@@ -40,15 +41,27 @@ 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;
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private async Task reloadData()
|
||||
{
|
||||
SearchRecords = await StatService.StatOdlGetAll(200, MessageService.SearchVal);
|
||||
//SearchRecords = await StatService.StatScartiGetAll(currFilter.DateStart, currFilter.DateEnd, currFilter.IdxMacchina, currFilter.IdxOdl, currFilter.KeyRichiesta, currFilter.CodArticolo, MessageService.SearchVal);
|
||||
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToArray();
|
||||
SearchRecords = await StatService.StatOdlGetAll(currFilter, MessageService.SearchVal);
|
||||
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
@@ -57,6 +70,8 @@ namespace MP.Stats.Pages
|
||||
|
||||
protected async Task DoFilter(SelectData newFilter)
|
||||
{
|
||||
SearchRecords = null;
|
||||
ListRecords = null;
|
||||
currFilter = newFilter;
|
||||
await reloadData();
|
||||
}
|
||||
@@ -76,6 +91,7 @@ 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();
|
||||
|
||||
Reference in New Issue
Block a user