- inizio pagina gest fluxLog e pareto eventi
- ok visualizzazione ultimo mese
This commit is contained in:
Samuele Locatelli
2023-10-20 18:54:28 +02:00
parent 66bad58f8f
commit 571ac2cea8
15 changed files with 494 additions and 30 deletions
+45 -5
View File
@@ -2,6 +2,7 @@
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.Configuration;
using MP.Data.DatabaseModels;
using MP.Data.DTO;
using NLog;
using System;
using System.Collections.Generic;
@@ -53,10 +54,10 @@ namespace MP.Data.Controllers
using (var dbCtx = new MoonProContext(_configuration))
{
dbResult = dbCtx
.DbSetAnagGruppi
.AsNoTracking()
.OrderBy(x => x.CodGruppo)
.ToList();
.DbSetAnagGruppi
.AsNoTracking()
.OrderBy(x => x.CodGruppo)
.ToList();
}
return dbResult;
}
@@ -81,6 +82,24 @@ namespace MP.Data.Controllers
return dbResult;
}
/// <summary>
/// Elenco Gruppi
/// </summary>
/// <returns></returns>
public List<AnagKeyValueModel> AnagKeyValGetAll()
{
List<AnagKeyValueModel> dbResult = new List<AnagKeyValueModel>();
using (var dbCtx = new MoonProContext(_configuration))
{
dbResult = dbCtx
.DbSetAKV
.AsNoTracking()
.OrderBy(x => x.nomeVar)
.ToList();
}
return dbResult;
}
/// <summary>
/// Elenco valori ammessi x Stati commessa (es Yacht Baglietto)
/// </summary>
@@ -737,7 +756,7 @@ namespace MP.Data.Controllers
}
catch (Exception exc)
{
Log.Error($"Eccezione in MacchineGetFilt{Environment.NewLine}{exc}");
Log.Error($"Eccezione in MacchineByMatrOper{Environment.NewLine}{exc}");
}
return dbResult;
}
@@ -1067,6 +1086,27 @@ 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>
+11
View File
@@ -0,0 +1,11 @@
using System;
namespace MP.Data.DTO
{
public class ParetoFluxLogDTO
{
public string IdxMacchina { get; set; }
public string CodFlux { get; set; }
public int Qty { get; set; }
}
}
@@ -0,0 +1,26 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
#nullable disable
// <Auto-Generated>
// This is here so CodeMaid doesn't reorganize this document
// </Auto-Generated>
namespace MP.Data.DatabaseModels
{
[Table("AnagKeyValue")]
public partial class AnagKeyValueModel
{
#region Public Properties
[Key]
public string nomeVar { get; set; } = "";
public int valInt { get; set; } = 0;
public double valFloat { get; set; } = 0;
public string valString { get; set; } = "";
public string descrizione { get; set; } = "";
#endregion Public Properties
}
}
+6 -1
View File
@@ -39,6 +39,7 @@ namespace MP.Data
public virtual DbSet<AlarmLogModel> DbSetAlarmLog { get; set; }
public virtual DbSet<AnagKeyValueModel> DbSetAKV { get; set; }
public virtual DbSet<StatsAnagArticoli> DbSetStatArticoli { get; set; }
public virtual DbSet<AnagArticoli> DbSetArticoli { get; set; }
public virtual DbSet<AnagEventiModel> DbSetAnagEventi { get; set; }
@@ -94,6 +95,7 @@ namespace MP.Data
public virtual DbSet<vSelEventiBCodeModel> DbSetVSEB { get; set; }
public virtual DbSet<vSelOdlModel> DbSetVSODL { get; set; }
public virtual DbSet<vSelCauScartoModel> DbSetVSCS { get; set; }
public virtual DbSet<ParetoFluxLogDTO> DbSetParetoFluxLog { get; set; }
#endregion Public Properties
@@ -566,7 +568,10 @@ namespace MP.Data
{
entity.ToView("v_DD_exp");
});
modelBuilder.Entity<ParetoFluxLogDTO>(entity =>
{
entity.HasKey(e => new { e.IdxMacchina, e.CodFlux });
});
OnModelCreatingPartial(modelBuilder);
}
+2
View File
@@ -230,6 +230,8 @@ namespace MP.Data
public const string redisArtList = redisBaseAddr + "Cache:ArtList";
public const string redisBaseAddr = "MP:";
public const string redisConfKey = redisBaseAddr + "Cache:Config";
public const string redisAKVKey = redisBaseAddr + "Cache:AKV";
public const string redisParetoFLKey = redisBaseAddr + "Cache:ParetoFL";
public const string redisDossByMac = redisBaseAddr + "Cache:DossByMac";
public const string redisFluxByMac = redisBaseAddr + "Cache:FluxByMac";
public const string redisFluxLogFilt = redisBaseAddr + "Cache:FluxLogFilt";
+40
View File
@@ -0,0 +1,40 @@
@if (isProcessing)
{
<LoadingData DisplaySize="LoadingData.CtrlSize.Large"></LoadingData>
}
else
{
<table class="table table-sm table-striped">
<thead>
<tr class="">
<th>Macchina</th>
<th>Key</th>
<th>Qty</th>
<th>#/gg</th>
<th>#/h</th>
</tr>
</thead>
<tbody>
@foreach (var item in ListPaged)
{
<tr>
<td>
@item.IdxMacchina
</td>
<td>
@item.CodFlux
</td>
<td>
@($"{item.Qty:N0}")
</td>
<td>
@($"{(item.Qty / numDay):N0}")
</td>
<td>
@($"{(item.Qty / numHour):N0}")
</td>
</tr>
}
</tbody>
</table>
}
+126
View File
@@ -0,0 +1,126 @@
using global::Microsoft.AspNetCore.Components;
using MP.Data.DTO;
using MP.SPEC.Data;
using NLog;
using static EgwCoreLib.Utils.DtUtils;
namespace MP.SPEC.Components
{
public partial class FLStatusList
{
#region Public Properties
[Parameter]
public Periodo CurrPeriodo { get; set; } = new Periodo();
[Parameter]
public EventCallback<int> E_TotalCount { get; set; }
[Parameter]
public string IdxMaccSel { get; set; } = "";
[Parameter]
public int NumRecPage { get; set; } = 10;
[Parameter]
public int PageNum { get; set; } = 1;
#endregion Public Properties
#region Protected Properties
protected List<ParetoFluxLogDTO> ListComplete { get; set; } = new List<ParetoFluxLogDTO>();
protected List<ParetoFluxLogDTO> ListPaged { get; set; } = new List<ParetoFluxLogDTO>();
[Inject]
protected MpDataService MDataServ { get; set; } = null!;
protected int TotalCount
{
get => totalCount;
set
{
if (totalCount != value)
{
totalCount = value;
E_TotalCount.InvokeAsync(value).ConfigureAwait(false);
}
}
}
protected int numDay
{
get
{
var numRaw = (int)CurrPeriodo.Fine.Subtract(CurrPeriodo.Inizio).TotalDays;
int answ = numRaw > 1 ? numRaw : 1;
return answ;
}
}
protected int numHour
{
get
{
var numRaw = (int)CurrPeriodo.Fine.Subtract(CurrPeriodo.Inizio).TotalHours;
int answ = numRaw > 1 ? numRaw : 1;
return answ;
}
}
#endregion Protected Properties
#region Protected Methods
protected override async Task OnParametersSetAsync()
{
await ReloadData();
}
/// <summary>
/// Aggiorno valori produzione alla data richiesta...
/// </summary>
/// <param name="newDate"></param>
protected async Task ReloadData()
{
isProcessing = true;
await Task.Delay(1);
if (!string.IsNullOrEmpty(IdxMaccSel) && (!IdxMaccSel.Equals(idxMaccLast) || !CurrPeriodo.Equals(lastPeriodo)))
{
idxMaccLast = IdxMaccSel;
lastPeriodo = CurrPeriodo;
ListComplete = await MDataServ.ParetoFluxLog(IdxMaccSel, CurrPeriodo.Inizio, CurrPeriodo.Fine);
TotalCount = ListComplete.Count;
}
// esegue paginazione
UpdateTable();
isProcessing = false;
await Task.Delay(1);
}
protected void UpdateTable()
{
// esegue paginazione
if (TotalCount > NumRecPage)
{
ListPaged = ListComplete.Skip((PageNum - 1) * NumRecPage).Take(NumRecPage).ToList();
}
else
{
ListPaged = ListComplete;
}
}
#endregion Protected Methods
#region Private Fields
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
private bool isProcessing = false;
private int totalCount = 0;
private string idxMaccLast = "";
private Periodo lastPeriodo { get; set; } = new Periodo();
#endregion Private Fields
}
}
+88 -19
View File
@@ -119,6 +119,40 @@ namespace MP.SPEC.Data
return fatto;
}
/// <summary>
/// Elenco Gruppi
/// </summary>
/// <returns></returns>
public async Task<List<AnagKeyValueModel>> AnagKeyValGetAll()
{
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
string source = "DB";
List<AnagKeyValueModel>? result = new List<AnagKeyValueModel>();
// cerco in redis...
RedisValue rawData = await redisDb.StringGetAsync(Utils.redisAKVKey);
if (!string.IsNullOrEmpty($"{rawData}"))
{
result = JsonConvert.DeserializeObject<List<AnagKeyValueModel>>($"{rawData}");
source = "REDIS";
}
else
{
result = await Task.FromResult(dbController.AnagKeyValGetAll());
// serializzo e salvo...
rawData = JsonConvert.SerializeObject(result);
await redisDb.StringSetAsync(Utils.redisConfKey, rawData, getRandTOut(redisLongTimeCache));
}
if (result == null)
{
result = new List<AnagKeyValueModel>();
}
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Debug($"AnagKeyValGetAll Read from {source}: {ts.TotalMilliseconds}ms");
return result;
}
public async Task<List<ListValues>> AnagStatiComm()
{
Stopwatch stopWatch = new Stopwatch();
@@ -389,6 +423,25 @@ namespace MP.SPEC.Data
await redisDb.StringSetAsync(Utils.redisConfKey, "");
}
/// <summary>
/// Restituisce valore della stringa (SE disponibile)
/// </summary>
/// <param name="keyName"></param>
/// <returns></returns>
public async Task<string> ConfigTryGet(string keyName)
{
string answ = "";
// preselezione valori
var configData = await ConfigGetAll();
var currRec = configData.FirstOrDefault(x => x.Chiave == keyName);
if (currRec != null)
{
answ = currRec.Valore;
}
return answ;
}
/// <summary>
/// Update chiave config
/// </summary>
@@ -1123,6 +1176,41 @@ 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>
@@ -1511,25 +1599,6 @@ namespace MP.SPEC.Data
return answ;
}
/// <summary>
/// Restituisce valore della stringa (SE disponibile)
/// </summary>
/// <param name="keyName"></param>
/// <returns></returns>
public async Task<string> ConfigTryGet(string keyName)
{
string answ = "";
// preselezione valori
var configData = await ConfigGetAll();
var currRec = configData.FirstOrDefault(x => x.Chiave == keyName);
if (currRec != null)
{
answ = currRec.Valore;
}
return answ;
}
public async Task<bool> updateDossierValue(DossierModel currDoss, FluxLogDTO editFL)
{
bool answ = false;
+3 -2
View File
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<RootNamespace>MP.SPEC</RootNamespace>
<Version>6.16.2310.411</Version>
<Version>6.16.2310.2018</Version>
</PropertyGroup>
<ItemGroup>
@@ -39,7 +39,8 @@
<ItemGroup>
<PackageReference Include="Blazored.LocalStorage" Version="4.3.0" />
<PackageReference Include="Blazored.SessionStorage" Version="2.4.0" />
<PackageReference Include="EgwCoreLib.Razor" Version="1.4.2308.216" />
<PackageReference Include="EgwCoreLib.Razor" Version="1.4.2310.1312" />
<PackageReference Include="EgwCoreLib.Utils" Version="1.4.2310.1312" />
<PackageReference Include="Microsoft.AspNetCore.Authentication.Negotiate" Version="6.0.9" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
</ItemGroup>
+37
View File
@@ -0,0 +1,37 @@
@page "/FluxLogStatus"
<div class="card mb-5">
<div class="card-header">
<div class="row">
<div class="col-4">
<h3>FluxLogStatus</h3>
</div>
<div class="col-4">
<div class="input-group ">
<span class="input-group-text">Macc</span>
<select class="form-select form-select-sm" @bind="@idxMaccSel">
<option value="*" selected>-- Tutti --</option>
@if (ListMacchineAll == null)
{
<option value="" disabled>No record found</option>
}
else
{
@foreach (var item in ListMacchineAll)
{
<option value="@item.Key">@item.Value</option>
}
}
</select>
</div>
</div>
<div class="col-4">
<PeriodoSel CurrPeriodo="@CurrPeriodo" E_PeriodoSel="SetPeriodo"></PeriodoSel>
</div>
</div>
</div>
<div class="card-body">
<FLStatusList CurrPeriodo="@CurrPeriodo" IdxMaccSel="@idxMaccSel" NumRecPage="numRecPage" PageNum="pageNum" E_TotalCount="SetTotCount"></FLStatusList>
<EgwCoreLib.Razor.DataPager currPage="@pageNum" PageSize="@numRecPage" totalCount="@totalCount" numPageChanged="SavePage" numRecordChanged="SaveNumRec"></EgwCoreLib.Razor.DataPager>
</div>
</div>
+107
View File
@@ -0,0 +1,107 @@
using global::Microsoft.AspNetCore.Components;
using MP.SPEC.Data;
using NLog;
using System;
using static EgwCoreLib.Utils.DtUtils;
namespace MP.SPEC.Pages
{
public partial class FluxLogStatus
{
#region Protected Fields
protected int numRecPage = 10;
protected int pageNum = 1;
protected int totalCount = 0;
#endregion Protected Fields
#region Protected Properties
protected Dictionary<string, string> ListMacchineAll { get; set; } = new Dictionary<string, string>();
[Inject]
protected MpDataService MDataServ { get; set; } = null!;
#endregion Protected Properties
#region Protected Methods
protected override async Task OnInitializedAsync()
{
await ReloadData();
}
protected async Task ReloadMacchine()
{
if (ListMacchineAll == null || ListMacchineAll.Count == 0)
{
var rawData = await MDataServ.MacchineGetFilt("*");
// trasformo!
if (rawData != null)
{
ListMacchineAll = rawData.ToDictionary(x => x.IdxMacchina, x => $"{x.IdxMacchina} | {x.Nome}");
}
}
}
protected void SaveNumRec(int newNum)
{
if (numRecPage >= newNum)
{
numRecPage = newNum;
}
}
protected void SavePage(int newNum)
{
if (pageNum >= newNum)
{
pageNum = newNum;
}
}
protected async Task SetPeriodo(Periodo newPeriodo)
{
if (!CurrPeriodo.Equals(newPeriodo))
{
CurrPeriodo = newPeriodo;
}
await Task.Delay(1);
}
protected async Task SetTotCount(int numRec)
{
totalCount = numRec;
await Task.Delay(1);
}
#endregion Protected Methods
#region Private Fields
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
#endregion Private Fields
#region Private Properties
private Periodo CurrPeriodo { get; set; } = new Periodo();
private string idxMaccSel { get; set; } = "";
#endregion Private Properties
#region Private Methods
private async Task ReloadData()
{
await ReloadMacchine();
DateTime dtEnd = DateTime.Today.AddDays(1);
DateTime dtStart = dtEnd.AddMonths(-1);
CurrPeriodo = new Periodo(dtStart, dtEnd);
}
#endregion Private Methods
}
}
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>Modulo MAPOSPEC </i>
<h4>Versione: 6.16.2310.411</h4>
<h4>Versione: 6.16.2310.2018</h4>
<br /> Note di rilascio:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
6.16.2310.411
6.16.2310.2018
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>6.16.2310.411</version>
<version>6.16.2310.2018</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>
Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB