Abbozzato recupero dati scarti
This commit is contained in:
@@ -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));
|
||||
|
||||
Reference in New Issue
Block a user