Abbozzato recupero dati scarti
This commit is contained in:
@@ -0,0 +1,35 @@
|
||||
@using MP.Stats.Data
|
||||
|
||||
@inject MessageService MessageService
|
||||
@inject MpStatsService StatService
|
||||
|
||||
<div class="row">
|
||||
<div class="col-6">
|
||||
<ul>
|
||||
|
||||
@foreach (var item in CurrData)
|
||||
{
|
||||
<li>@item.label: @item.value</li>
|
||||
}
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-6"></div>
|
||||
</div>
|
||||
|
||||
@code {
|
||||
|
||||
[Parameter]
|
||||
public SelectData currFilter { get; set; }
|
||||
|
||||
protected List<ChartKV> CurrData = new List<ChartKV>();
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
{
|
||||
await reloadData();
|
||||
}
|
||||
|
||||
private async Task reloadData()
|
||||
{
|
||||
CurrData = await StatService.StatScartiGetPareto(currFilter, MessageService.SearchVal);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Stats.Data
|
||||
{
|
||||
public class ChartKV
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
public string label { get; set; } = "";
|
||||
public double value { get; set; } = 0;
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
}
|
||||
@@ -242,7 +242,7 @@ namespace MP.Stats.Data
|
||||
{
|
||||
//return Task.FromResult(dbController.StatScartiGetAll(DataStart, DataEnd, IdxMacchina, IdxODL, KeyRichiesta, CodArticolo).ToArray());
|
||||
List<MP.Data.DatabaseModels.ResScarti> dbResult = new List<MP.Data.DatabaseModels.ResScarti>();
|
||||
string cacheKey = getCacheKey("MP:STATS:SCARTI", CurrFilter);
|
||||
string cacheKey = getCacheKey("MP:STATS:SCARTI:RAW", CurrFilter);
|
||||
string rawData;
|
||||
var redisDataList = await distributedCache.GetAsync(cacheKey);
|
||||
if (redisDataList != null)
|
||||
@@ -260,6 +260,35 @@ 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 = StatScartiGetAll(CurrFilter, searchVal);
|
||||
// faccio conteggio...
|
||||
statResult = dbResult
|
||||
.Result
|
||||
.GroupBy(x => x.Causale)
|
||||
.Select(y => new ChartKV() { label = y.First().Causale, value = y.Sum(c => c.Qta) })
|
||||
.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,6 +7,7 @@
|
||||
<SelectionFilter SelFilter="currFilter" filterChanged="DoFilter" filterReset="ResetFilter"></SelectionFilter>
|
||||
</div>
|
||||
<div class="card-body py-0 px-1">
|
||||
@*<ChartScarti></ChartScarti>*@
|
||||
@if (ListRecords == null)
|
||||
{
|
||||
<LoadingData></LoadingData>
|
||||
|
||||
Reference in New Issue
Block a user