calcolo al volo dati x charting
This commit is contained in:
@@ -17,18 +17,20 @@ namespace MP.Stats.Components
|
||||
|
||||
protected SelectData _currFilter { get; set; } = new SelectData();
|
||||
|
||||
|
||||
protected List<MP.Data.DatabaseModels.ResScarti> _listScarti { get; set; } = new List<MP.Data.DatabaseModels.ResScarti>();
|
||||
|
||||
[Parameter]
|
||||
public SelectData DataFilter
|
||||
public List<MP.Data.DatabaseModels.ResScarti> ListScarti
|
||||
{
|
||||
get => _currFilter;
|
||||
get => _listScarti;
|
||||
set
|
||||
{
|
||||
_currFilter = value;
|
||||
// salvo valori
|
||||
_listScarti = value;
|
||||
// ricalcolo charting data
|
||||
recalcData();
|
||||
var dataReload = Task.Run(async () =>
|
||||
{
|
||||
await reloadData();
|
||||
await HandleRedraw();
|
||||
});
|
||||
}
|
||||
@@ -121,15 +123,16 @@ namespace MP.Stats.Components
|
||||
List<string> borderColors = new List<string>
|
||||
{ ChartColor.FromRgba(255, 99, 132, 1f), ChartColor.FromRgba(54, 162, 235, 1f), ChartColor.FromRgba(255, 206, 86, 1f), ChartColor.FromRgba(75, 192, 192, 1f), ChartColor.FromRgba(153, 102, 255, 1f), ChartColor.FromRgba(255, 159, 64, 1f) };
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
private void recalcData()
|
||||
{
|
||||
await reloadData();
|
||||
if (ListScarti != null)
|
||||
{
|
||||
CurrData = ListScarti
|
||||
.GroupBy(x => x.Causale)
|
||||
.Select(y => new ChartKV() { label = y.First().Descrizione, value = y.Sum(c => c.Qta) })
|
||||
.OrderByDescending(x => x.value)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
private async Task reloadData()
|
||||
{
|
||||
CurrData = await StatService.StatScartiGetPareto(DataFilter, MessageService.SearchVal);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -261,35 +261,6 @@ namespace MP.Stats.Data
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
public async Task<List<ChartKV>> StatScartiGetPareto(SelectData CurrFilter, string searchVal = "")
|
||||
{
|
||||
List<ChartKV> statResult = new List<ChartKV>();
|
||||
string cacheKey = getCacheKey("MP:STATS:SCARTI:PARETO", CurrFilter);
|
||||
string rawData;
|
||||
var redisDataList = await distributedCache.GetAsync(cacheKey);
|
||||
if (redisDataList != null)
|
||||
{
|
||||
rawData = Encoding.UTF8.GetString(redisDataList);
|
||||
statResult = JsonConvert.DeserializeObject<List<ChartKV>>(rawData);
|
||||
}
|
||||
else
|
||||
{
|
||||
// recupero dal DB (eventualmente con cache)
|
||||
var dbResult = await StatScartiGetAll(CurrFilter, searchVal);
|
||||
// faccio conteggio...
|
||||
statResult = dbResult
|
||||
.GroupBy(x => x.Causale)
|
||||
.Select(y => new ChartKV() { label = y.First().Descrizione, value = y.Sum(c => c.Qta) })
|
||||
.OrderByDescending(x => x.value)
|
||||
.ToList();
|
||||
|
||||
rawData = JsonConvert.SerializeObject(statResult);
|
||||
redisDataList = Encoding.UTF8.GetBytes(rawData);
|
||||
await distributedCache.SetAsync(cacheKey, redisDataList, cacheOpt);
|
||||
}
|
||||
return await Task.FromResult(statResult);
|
||||
}
|
||||
|
||||
public async Task<List<MP.Data.DatabaseModels.TurniOee>> StatTurniOeeGetAllAsync(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo, string searchVal = "")
|
||||
{
|
||||
return await Task.FromResult(dbController.StatTurniOeeGetAll(DataStart, DataEnd, IdxMacchina, IdxODL, KeyRichiesta, CodArticolo));
|
||||
|
||||
@@ -7,7 +7,7 @@
|
||||
<SelectionFilter SelFilter="currFilter" filterChanged="DoFilter" filterReset="ResetFilter"></SelectionFilter>
|
||||
</div>
|
||||
<div class="card-body py-0 px-1">
|
||||
<ChartScarti DataFilter="@currFilter"></ChartScarti>
|
||||
<ChartScarti ListScarti="@SearchRecords"></ChartScarti>
|
||||
@if (ListRecords == null)
|
||||
{
|
||||
<LoadingData></LoadingData>
|
||||
|
||||
Reference in New Issue
Block a user