Renaming metodi x FluxLogPareto

This commit is contained in:
Samuele Locatelli
2023-11-17 14:20:44 +01:00
parent 3c67b98039
commit f914c28bf8
7 changed files with 61 additions and 62 deletions
+21 -22
View File
@@ -611,7 +611,6 @@ namespace MP.Data.Controllers
numRecProc += numRec;
if (numRec > maxItem)
{
List<Periodo> listPeriodi = new List<Periodo>();
switch (valMode)
@@ -713,6 +712,27 @@ namespace MP.Data.Controllers
return dbResult;
}
/// <summary>
/// Elenco Gruppi
/// </summary>
/// <returns></returns>
public List<ParetoFluxLogDTO> FluxLogPareto(string idxMacchina, DateTime dtFrom, DateTime dtTo)
{
List<ParetoFluxLogDTO> dbResult = new List<ParetoFluxLogDTO>();
using (var dbCtx = new MoonProContext(_configuration))
{
dbResult = dbCtx
.DbSetFluxLog
.Where(x => (string.IsNullOrEmpty(idxMacchina) || x.IdxMacchina == idxMacchina) && (dtFrom <= x.dtEvento && x.dtEvento <= dtTo))
.AsNoTracking()
.GroupBy(x => x.CodFlux)
.Select(g => new ParetoFluxLogDTO() { IdxMacchina = idxMacchina, CodFlux = g.Key, Qty = g.Count() })
.OrderByDescending(x => x.Qty)
.ToList();
}
return dbResult;
}
/// <summary>
/// Stored manutenzione del DB
/// </summary>
@@ -1270,27 +1290,6 @@ namespace MP.Data.Controllers
return dbResult;
}
/// <summary>
/// Elenco Gruppi
/// </summary>
/// <returns></returns>
public List<ParetoFluxLogDTO> ParetoFluxLog(string idxMacchina, DateTime dtFrom, DateTime dtTo)
{
List<ParetoFluxLogDTO> dbResult = new List<ParetoFluxLogDTO>();
using (var dbCtx = new MoonProContext(_configuration))
{
dbResult = dbCtx
.DbSetFluxLog
.Where(x => (string.IsNullOrEmpty(idxMacchina) || x.IdxMacchina == idxMacchina) && (dtFrom <= x.dtEvento && x.dtEvento <= dtTo))
.AsNoTracking()
.GroupBy(x => x.CodFlux)
.Select(g => new ParetoFluxLogDTO() { IdxMacchina = idxMacchina, CodFlux = g.Key, Qty = g.Count() })
.OrderByDescending(x => x.Qty)
.ToList();
}
return dbResult;
}
/// <summary>
/// Stato prod macchina
/// </summary>
+1 -1
View File
@@ -116,7 +116,7 @@ namespace MP.SPEC.Components
{
idxMaccLast = IdxMaccSel;
lastPeriodo = CurrPeriodo;
ListComplete = await MDataServ.ParetoFluxLog(IdxMaccSel, CurrPeriodo.Inizio, CurrPeriodo.Fine);
ListComplete = await MDataServ.FluxLogPareto(IdxMaccSel, CurrPeriodo.Inizio, CurrPeriodo.Fine);
TotalCount = ListComplete.Count;
TotalRecords = ListComplete.Sum(x => x.Qty);
FluxList = ListComplete.Select(x => x.CodFlux).ToList();
+35 -35
View File
@@ -800,6 +800,41 @@ namespace MP.SPEC.Data
return result;
}
/// <summary>
/// Elenco Gruppi
/// </summary>
/// <returns></returns>
public async Task<List<ParetoFluxLogDTO>> FluxLogPareto(string idxMacchina, DateTime dtFrom, DateTime dtTo)
{
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string source = "DB";
List<ParetoFluxLogDTO>? result = new List<ParetoFluxLogDTO>();
// cerco in redis...
string redKey = $"{Utils.redisParetoFLKey}:{idxMacchina}:{dtFrom:yyyyMMdd}:{dtTo:yyyyMMdd}";
RedisValue rawData = await redisDb.StringGetAsync(redKey);
if (!string.IsNullOrEmpty($"{rawData}"))
{
result = JsonConvert.DeserializeObject<List<ParetoFluxLogDTO>>($"{rawData}");
source = "REDIS";
}
else
{
result = await Task.FromResult(dbController.FluxLogPareto(idxMacchina, dtFrom, dtTo));
// serializzo e salvo...
rawData = JsonConvert.SerializeObject(result);
await redisDb.StringSetAsync(redKey, rawData, getRandTOut(redisLongTimeCache));
}
if (result == null)
{
result = new List<ParetoFluxLogDTO>();
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"ParetoFluxLog Read from {source}: {ts.TotalMilliseconds}ms");
return result;
}
/// <summary>
/// Stored manutenzione del DB
/// </summary>
@@ -1248,41 +1283,6 @@ namespace MP.SPEC.Data
return result;
}
/// <summary>
/// Elenco Gruppi
/// </summary>
/// <returns></returns>
public async Task<List<ParetoFluxLogDTO>> ParetoFluxLog(string idxMacchina, DateTime dtFrom, DateTime dtTo)
{
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string source = "DB";
List<ParetoFluxLogDTO>? result = new List<ParetoFluxLogDTO>();
// cerco in redis...
string redKey = $"{Utils.redisParetoFLKey}:{idxMacchina}:{dtFrom:yyyyMMdd}:{dtTo:yyyyMMdd}";
RedisValue rawData = await redisDb.StringGetAsync(redKey);
if (!string.IsNullOrEmpty($"{rawData}"))
{
result = JsonConvert.DeserializeObject<List<ParetoFluxLogDTO>>($"{rawData}");
source = "REDIS";
}
else
{
result = await Task.FromResult(dbController.ParetoFluxLog(idxMacchina, dtFrom, dtTo));
// serializzo e salvo...
rawData = JsonConvert.SerializeObject(result);
await redisDb.StringSetAsync(redKey, rawData, getRandTOut(redisLongTimeCache));
}
if (result == null)
{
result = new List<ParetoFluxLogDTO>();
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"ParetoFluxLog Read from {source}: {ts.TotalMilliseconds}ms");
return result;
}
/// <summary>
/// Eliminazione record selezionato
/// </summary>
+1 -1
View File
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>MP.SPEC</RootNamespace>
<Version>6.16.2311.1016</Version>
<Version>6.16.2311.1714</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MAPOSPEC </i>
<h4>Versione: 6.16.2311.1016</h4>
<h4>Versione: 6.16.2311.1714</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
6.16.2311.1016
6.16.2311.1714
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>6.16.2311.1016</version>
<version>6.16.2311.1714</version>
<url>https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/MP.SPEC.zip</url>
<changelog>https://nexus.steamware.net/repository/SWS/MP-SPEC/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>