TAB:
- aggiunta gest tab gruppi2operatore - metodi estrazione macchine x operatori - test filtro TCiclo
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
@inject MenuData MDataService
|
||||
|
||||
@inject OprFiltData MDataService
|
||||
|
||||
@* <div class="row w-100 slideMen"> *@
|
||||
<div class="row w-100">
|
||||
@@ -61,12 +60,10 @@
|
||||
</div>
|
||||
|
||||
@code{
|
||||
|
||||
/// <summary>
|
||||
/// Elenco items da menù per pagina corrente...
|
||||
/// </summary>
|
||||
protected List<LinkMenu> CurrMenuItems { get; set; } = new List<LinkMenu>();
|
||||
|
||||
/// <summary>
|
||||
/// Livello corrente del menu
|
||||
/// </summary>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
@page "/tc-history"
|
||||
@inject OprFiltData MDataService
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header">
|
||||
@@ -11,10 +12,18 @@
|
||||
<div class="input-group" title="Filtro Impianto">
|
||||
<span class="input-group-text"><i class="fa-solid fa-industry"></i></span>
|
||||
<select class="form-select" aria-label="Select Macchina" style="width: 15rem;">
|
||||
<option value ="0" selected>-- Selezionare Impianto --</option>
|
||||
<option value="1">One</option>
|
||||
<option value="2">Two</option>
|
||||
<option value="3">Three</option>
|
||||
<option value="0" selected>-- Selezionare Impianto --</option>
|
||||
@if (ListMacchine == null || ListMacchine.Count == 0)
|
||||
{
|
||||
<b>loading...</b>
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var item in ListMacchine)
|
||||
{
|
||||
<option value="@item.IdxMacchina">@item.CodMacchina | @item.Descrizione</option>
|
||||
}
|
||||
}
|
||||
</select>
|
||||
</div>
|
||||
</div>
|
||||
@@ -23,22 +32,82 @@
|
||||
<span class="input-group-text"><i class="fa-solid fa-box"></i></span>
|
||||
<input class="form-control" style="width: 4rem;" placeholder="*" title="Ricerca Articolo" />
|
||||
<select class="form-select" aria-label="Select Articolo" style="width: 25rem;">
|
||||
<option selected>Open this select menu</option>
|
||||
<option value="1">One</option>
|
||||
<option value="2">Two</option>
|
||||
<option value="3">Three</option>
|
||||
<option value="*" selected>-- Selezionare Articolo --</option>
|
||||
@if (ListArticoli == null || ListArticoli.Count == 0)
|
||||
{
|
||||
<b>loading...</b>
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (var item in ListArticoli)
|
||||
{
|
||||
<option value="@item.CodArticolo">@item.CodArticolo | @item.DescArticolo</option>
|
||||
}
|
||||
<option disabled>...totale @TotalCount rec</option>
|
||||
}
|
||||
</select>
|
||||
<button class="btn btn-primary" @onclick="LoadMore" title="Show more"><b>+10</b</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="card-body">
|
||||
griglia risultati
|
||||
@if (ListArticoli != null)
|
||||
{
|
||||
<b>griglia risultati</b>
|
||||
@* <div style="height: 200px;overflow-y:scroll">
|
||||
<Virtualize Items="@ListArticoli" OverscanCount="6" ItemSize="10">
|
||||
<ItemContent>
|
||||
<p>@context.CodArticolo | @context.DescArticolo</p>
|
||||
</ItemContent>
|
||||
<Placeholder>
|
||||
<p>Loading...</p>
|
||||
</Placeholder>
|
||||
<EmptyContent>
|
||||
<p>
|
||||
There are no strings to display.
|
||||
</p>
|
||||
</EmptyContent>
|
||||
</Virtualize>
|
||||
</div> *@
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
@code {
|
||||
|
||||
/// <summary>
|
||||
/// Matricola operatore corrente (da rendere parametrico con gest operatore)
|
||||
/// </summary>
|
||||
protected int MatrOpr { get; set; } = 102;
|
||||
protected int NumRec { get; set; } = 100000;
|
||||
protected string azienda { get; set; } = "*";
|
||||
protected string searchVal { get; set; } = "";
|
||||
|
||||
protected int num2Displ { get; set; } = 10;
|
||||
|
||||
protected List<Macchine>? ListMacchine { get; set; } = null;
|
||||
protected List<AnagArticoli>? SearchArticoli { get; set; } = null;
|
||||
protected List<AnagArticoli>? ListArticoli { get; set; } = null;
|
||||
|
||||
protected async override Task OnInitializedAsync()
|
||||
{
|
||||
SearchArticoli = await MDataService.ArticoliGetSearch(NumRec, azienda, searchVal);
|
||||
TotalCount = SearchArticoli.Count;
|
||||
ListArticoli = SearchArticoli.Take(num2Displ).ToList();
|
||||
ListMacchine = await MDataService.MacchineByMatrOper(MatrOpr);
|
||||
}
|
||||
|
||||
protected int TotalCount { get; set; } = 0;
|
||||
|
||||
protected void LoadMore()
|
||||
{
|
||||
ListArticoli = null;
|
||||
// await Task.Delay(1);
|
||||
num2Displ += 10;
|
||||
num2Displ = num2Displ < TotalCount ? num2Displ : TotalCount;
|
||||
ListArticoli = SearchArticoli?.Take(num2Displ).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ var redisMultiplexer = ConnectionMultiplexer.Connect(connStringRedis);
|
||||
// Add services x accesso dati
|
||||
builder.Services.AddSingleton<IConnectionMultiplexer>(redisMultiplexer);
|
||||
builder.Services.AddSingleton<StatusData>();
|
||||
builder.Services.AddSingleton<MenuData>();
|
||||
builder.Services.AddSingleton<OprFiltData>();
|
||||
|
||||
// nuova versione contenuti...
|
||||
builder.Services.AddRazorComponents()
|
||||
|
||||
@@ -185,7 +185,8 @@ namespace MP.Data.Controllers
|
||||
dbResult = dbCtx
|
||||
.DbSetArticoli
|
||||
.AsNoTracking()
|
||||
.Where(x => (x.Azienda == azienda || azienda == "*") && (x.CodArticolo.Contains(searchVal) || x.DescArticolo.Contains(searchVal) || x.Disegno.Contains(searchVal) || string.IsNullOrEmpty(searchVal)))
|
||||
.Where(x => (azienda == "*" || x.Azienda == azienda ) && (string.IsNullOrEmpty(searchVal) || x.CodArticolo.Contains(searchVal) || x.DescArticolo.Contains(searchVal) || x.Disegno.Contains(searchVal) ))
|
||||
//.AsNoTracking()
|
||||
.OrderBy(x => x.CodArticolo)
|
||||
.Take(numRecord)
|
||||
.ToList();
|
||||
@@ -713,24 +714,74 @@ namespace MP.Data.Controllers
|
||||
if (codGruppo == "*")
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetMacchine
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.IdxMacchina)
|
||||
.ToList();
|
||||
.DbSetMacchine
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.IdxMacchina)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetGrp2Macc
|
||||
.Where(g => g.CodGruppo == codGruppo)
|
||||
.Join(dbCtx.DbSetMacchine,
|
||||
g => g.IdxMacchina,
|
||||
m => m.IdxMacchina,
|
||||
(g, m) => m
|
||||
)
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.IdxMacchina)
|
||||
.ToList();
|
||||
.DbSetGrp2Macc
|
||||
.Where(g => g.CodGruppo == codGruppo)
|
||||
.Join(dbCtx.DbSetMacchine,
|
||||
g => g.IdxMacchina,
|
||||
m => m.IdxMacchina,
|
||||
(g, m) => m
|
||||
)
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.IdxMacchina)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
Log.Error($"Eccezione in MacchineGetFilt{Environment.NewLine}{exc}");
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Macchine dato operatore secondo gruppi (macchine/operatore)
|
||||
/// </summary>
|
||||
/// <param name="MatrOpr"></param>
|
||||
/// <returns></returns>
|
||||
public List<Macchine> MacchineByMatrOper(int MatrOpr)
|
||||
{
|
||||
List<Macchine> dbResult = new List<Macchine>();
|
||||
try
|
||||
{
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
if (MatrOpr == 0)
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetMacchine
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.IdxMacchina)
|
||||
.ToList();
|
||||
}
|
||||
else
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetGrp2Oper
|
||||
.Where(g => g.MatrOpr == MatrOpr)
|
||||
.Join(dbCtx.DbSetGrp2Macc,
|
||||
g => g.CodGruppo,
|
||||
m => m.CodGruppo,
|
||||
(g, m) => m
|
||||
)
|
||||
.Distinct()
|
||||
.Join(dbCtx.DbSetMacchine,
|
||||
g => g.IdxMacchina,
|
||||
m => m.IdxMacchina,
|
||||
(g, m) => m
|
||||
)
|
||||
.Distinct()
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.IdxMacchina)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
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("Gruppi2Operatori")]
|
||||
public partial class Gruppi2OperModel
|
||||
{
|
||||
#region Public Properties
|
||||
public int MatrOpr { get; set; } = 0;
|
||||
|
||||
public string CodGruppo { get; set; } = "";
|
||||
|
||||
/// <summary>
|
||||
/// Navigazione oggetto Operatori
|
||||
/// </summary>
|
||||
[ForeignKey("MatrOpr")]
|
||||
public virtual AnagOperatoriModel OperNav { get; set; } = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Navigazione oggetto Machine
|
||||
/// </summary>
|
||||
[ForeignKey("CodGruppo")]
|
||||
public virtual AnagGruppi GruppiNav { get; set; } = null!;
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
}
|
||||
@@ -55,6 +55,7 @@ namespace MP.Data
|
||||
public virtual DbSet<EventListModel> DbSetEvList { get; set; }
|
||||
public virtual DbSet<VocabolarioModel> DbSetVocabolario { get; set; }
|
||||
public virtual DbSet<AnagOperatoriModel> DbOperatori { get; set; }
|
||||
public virtual DbSet<Gruppi2OperModel> DbSetGrp2Oper { get; set; }
|
||||
public virtual DbSet<Gruppi2MaccModel> DbSetGrp2Macc { get; set; }
|
||||
public virtual DbSet<DatiMacchineModel> DbSetDatiMacchine { get; set; }
|
||||
public virtual DbSet<VMSFDModel> DbSetMSFD { get; set; }
|
||||
@@ -323,7 +324,12 @@ namespace MP.Data
|
||||
});
|
||||
modelBuilder.Entity<Gruppi2MaccModel>(entity =>
|
||||
{
|
||||
entity.HasKey(e => new { e.CodGruppo, e.IdxMacchina});
|
||||
entity.HasKey(e => new { e.CodGruppo, e.IdxMacchina });
|
||||
|
||||
});
|
||||
modelBuilder.Entity<Gruppi2OperModel>(entity =>
|
||||
{
|
||||
entity.HasKey(e => new { e.CodGruppo, e.MatrOpr});
|
||||
|
||||
});
|
||||
|
||||
|
||||
@@ -30,7 +30,7 @@ namespace MP.Data.Services
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache molto breve (10 sec circa + perturbazione percentuale +/-10%)
|
||||
/// Durata cache MOLTO breve (10 sec circa + perturbazione percentuale +/-10%)
|
||||
/// </summary>
|
||||
protected TimeSpan UltraFastCache
|
||||
{
|
||||
@@ -38,7 +38,7 @@ namespace MP.Data.Services
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Durata cache lunga (+ perturbazione percentuale +/-10%)
|
||||
/// Durata cache MOLTO lunga (+ perturbazione percentuale +/-10%)
|
||||
/// </summary>
|
||||
protected TimeSpan UltraLongCache
|
||||
{
|
||||
|
||||
@@ -15,11 +15,14 @@ using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Data.Services
|
||||
{
|
||||
public class MenuData : BaseServ, IDisposable
|
||||
/// <summary>
|
||||
/// Classe accesso dati filtrati per operatore
|
||||
/// </summary>
|
||||
public class OprFiltData : BaseServ, IDisposable
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public MenuData(IConfiguration configuration)
|
||||
public OprFiltData(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
|
||||
@@ -75,7 +78,7 @@ namespace MP.Data.Services
|
||||
sw.Start();
|
||||
List<LinkMenu>? result = new List<LinkMenu>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisMenuDataKey}:{tipoLink}";
|
||||
string currKey = $"{redisBaseKey}:Menu:{tipoLink}";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
{
|
||||
@@ -98,6 +101,81 @@ namespace MP.Data.Services
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Macchine dato operatore secondo gruppi (macchine/operatore)
|
||||
/// </summary>
|
||||
/// <param name="MatrOpr"></param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<Macchine>> MacchineByMatrOper(int MatrOpr)
|
||||
{
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<Macchine>? result = new List<Macchine>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisBaseKey}:Macc:{MatrOpr}";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<Macchine>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = await Task.FromResult(dbController.MacchineByMatrOper(MatrOpr));
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<Macchine>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"MacchineGetFilt | MatrOpr: {MatrOpr} | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Elenco tabella Articoli da filtro
|
||||
/// </summary>
|
||||
/// <param name="numRecord">Numero record max da recuperare</param>
|
||||
/// <param name="azienda">cod azienda, * = tutte</param>
|
||||
/// <param name="searchVal">Ricerca testuale</param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<AnagArticoli>> ArticoliGetSearch(int numRecord, string azienda, string searchVal)
|
||||
{
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<AnagArticoli>? result = new List<AnagArticoli>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisBaseKey}:Art:{azienda}:{searchVal}:{numRecord}";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<AnagArticoli>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = await Task.FromResult(dbController.ArticoliGetSearch(numRecord, azienda, searchVal));
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(currKey, rawData, LongCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<AnagArticoli>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"ArticoliGetSearch | azienda: {azienda} | searchVal: {searchVal} | numRecord: {numRecord} | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
@@ -119,7 +197,7 @@ namespace MP.Data.Services
|
||||
private static IConfiguration _configuration = null!;
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
private string redisMenuDataKey = "MP:ALL:Cache:Menu";
|
||||
private string redisBaseKey = "MP:ALL:Cache";
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
Reference in New Issue
Block a user