STATS:
- Update visualizzazione ODL ed Energy
This commit is contained in:
@@ -3,6 +3,7 @@ using YamlDotNet.Serialization.NamingConventions;
|
||||
using YamlDotNet.Serialization;
|
||||
using static IobConf.Core.EnumConf;
|
||||
using NLog;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
@@ -23,6 +24,63 @@ namespace IobConf.Core
|
||||
Log = LogManager.GetCurrentClassLogger();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Init classe configurazione da file
|
||||
/// </summary>
|
||||
public IobConfTree(string confFilePath)
|
||||
{
|
||||
Log = LogManager.GetCurrentClassLogger();
|
||||
if (File.Exists(confFilePath))
|
||||
{
|
||||
IobConfTree newConfObj = new IobConfTree();
|
||||
// verifico TIPO file...
|
||||
string fileExt = Path.GetExtension(confFilePath);
|
||||
string fileName = Path.GetFileName(confFilePath);
|
||||
string rawData = File.ReadAllText(confFilePath);
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
// leggo in base al tipo...
|
||||
switch (fileExt)
|
||||
{
|
||||
case "yaml":
|
||||
case "yml":
|
||||
var deserializer = new DeserializerBuilder()
|
||||
.WithNamingConvention(CamelCaseNamingConvention.Instance)
|
||||
.Build();
|
||||
try
|
||||
{
|
||||
newConfObj = deserializer.Deserialize<IobConfTree>(rawData);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
//lgError($"Eccezione in LoadFromYaml{Environment.NewLine}{exc}");
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (newConfObj != null)
|
||||
{
|
||||
// ora copio in oggetto corrente...
|
||||
CncData = newConfObj.CncData;
|
||||
CodIOB = newConfObj.CodIOB;
|
||||
ConfFileName = fileName;
|
||||
Customer = newConfObj.Customer;
|
||||
GeneralCom = newConfObj.GeneralCom;
|
||||
InputDataProc = newConfObj.InputDataProc;
|
||||
IobManConf = newConfObj.IobManConf;
|
||||
IobType = newConfObj.IobType;
|
||||
Model = newConfObj.Model;
|
||||
OptPar = newConfObj.OptPar;
|
||||
ReleaseVers = newConfObj.ReleaseVers;
|
||||
ServerMES = newConfObj.ServerMES;
|
||||
TempoCiclo = newConfObj.TempoCiclo;
|
||||
Vendor = newConfObj.Vendor;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce un oggetto di conf leggendo INI ed effettuando conversione
|
||||
/// </summary>
|
||||
@@ -80,7 +138,7 @@ namespace IobConf.Core
|
||||
newConfObj.ServerMES.Transport = MpIp.StartsWith("https://") ? "https" : "http";
|
||||
newConfObj.ServerMES.IpAddr = MpIp.Replace($"{newConfObj.ServerMES.Transport}://", ""); // tolgo http/https...
|
||||
}
|
||||
|
||||
|
||||
// Altro (versione, ...)
|
||||
newConfObj.ReleaseVers = $"{System.Reflection.Assembly.GetExecutingAssembly().GetName().Version}";
|
||||
newConfObj.IobManConf.MinDeltaSec = fIni.ReadInteger("IOB", "MinDeltaSec", 6);
|
||||
@@ -114,6 +172,35 @@ namespace IobConf.Core
|
||||
return newConfObj;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce un oggetto di conf deserializzando lo Yaml relativo
|
||||
/// </summary>
|
||||
/// <param name="yamlFilePath"></param>
|
||||
/// <returns></returns>
|
||||
public static IobConfTree LoadFromYaml(string yamlFilePath)
|
||||
{
|
||||
IobConfTree newConfObj = new IobConfTree();
|
||||
if (File.Exists(yamlFilePath))
|
||||
{
|
||||
string rawData = File.ReadAllText(yamlFilePath);
|
||||
if (!string.IsNullOrEmpty(rawData))
|
||||
{
|
||||
var deserializer = new DeserializerBuilder()
|
||||
.WithNamingConvention(CamelCaseNamingConvention.Instance)
|
||||
.Build();
|
||||
try
|
||||
{
|
||||
newConfObj = deserializer.Deserialize<IobConfTree>(rawData);
|
||||
}
|
||||
catch (Exception exc)
|
||||
{
|
||||
//lgError($"Eccezione in LoadFromYaml{Environment.NewLine}{exc}");
|
||||
}
|
||||
}
|
||||
}
|
||||
return newConfObj;
|
||||
}
|
||||
|
||||
#region Logging
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -42,6 +42,22 @@ namespace MP.Data.Controllers
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco FLTranslations (decodifica + UM)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<AnagFLTransModel> AnagFLTransGetAll()
|
||||
{
|
||||
List<AnagFLTransModel> dbResult = new List<AnagFLTransModel>();
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetAnagFLTrans
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco tabella Articoli da filtro
|
||||
/// </summary>
|
||||
@@ -84,6 +100,24 @@ namespace MP.Data.Controllers
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco da tabella Config
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<ConfigModel> ConfigGetAll()
|
||||
{
|
||||
List<ConfigModel> dbResult = new List<ConfigModel>();
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetConfig
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.Chiave)
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
@@ -351,6 +385,24 @@ namespace MP.Data.Controllers
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Vocabolario (completo)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<VocabolarioModel> VocabolarioGetAll()
|
||||
{
|
||||
List<VocabolarioModel> dbResult = new List<VocabolarioModel>();
|
||||
using (var dbCtx = new MoonPro_STATSContext(_configuration))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetVocabolario
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.Lemma)
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
using DnsClient.Protocol;
|
||||
using Microsoft.Data.SqlClient;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.Data.DatabaseModels;
|
||||
using NLog;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Drawing.Drawing2D;
|
||||
using System.Linq;
|
||||
using static MP.Data.Objects.Enums;
|
||||
|
||||
namespace MP.Data.Controllers
|
||||
{
|
||||
public class MpVocController : IDisposable
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public MpVocController(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
Log.Info("Avviata classe MpVocController");
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Elenco da tabella Config
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<ConfigModel> ConfigGetAll()
|
||||
{
|
||||
List<ConfigModel> dbResult = new List<ConfigModel>();
|
||||
using (var dbCtx = new MoonPro_VocContext(_configuration))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetConfig
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.Chiave)
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Lingue
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<LingueModel> LingueGetAll()
|
||||
{
|
||||
List<LingueModel> dbResult = new List<LingueModel>();
|
||||
using (var dbCtx = new MoonPro_VocContext(_configuration))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetLilngue
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.Lingua)
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Vocabolario (completo)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<VocabolarioModel> VocabolarioGetAll()
|
||||
{
|
||||
List<VocabolarioModel> dbResult = new List<VocabolarioModel>();
|
||||
using (var dbCtx = new MoonPro_VocContext(_configuration))
|
||||
{
|
||||
dbResult = dbCtx
|
||||
.DbSetVocabolario
|
||||
.AsNoTracking()
|
||||
.OrderBy(x => x.Lemma)
|
||||
.ToList();
|
||||
}
|
||||
return dbResult;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static IConfiguration _configuration;
|
||||
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
#endregion Private Fields
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
// </Auto-Generated>
|
||||
namespace MP.Data.DatabaseModels
|
||||
{
|
||||
[Table("AnagFLTrans")]
|
||||
public class AnagFLTransModel
|
||||
{
|
||||
[Key, MaxLength(50)]
|
||||
public string CodFluxIn { get; set; } = "";
|
||||
|
||||
[MaxLength(50)]
|
||||
public string CodFluxOut { get; set; } = "";
|
||||
|
||||
[MaxLength(50)]
|
||||
public string UM { get; set; } = "";
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
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("Lingue")]
|
||||
public partial class LingueModel
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
[Key]
|
||||
public string Lingua { get; set; } = "";
|
||||
public string DescrizioneLingua { get; set; } = "";
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
}
|
||||
@@ -19,10 +19,32 @@ namespace MP.Data.DatabaseModels
|
||||
public string DescArticolo { get; set; } = "";
|
||||
public decimal TCAssegnato { get; set; }
|
||||
public string IdxMacchina { get; set; }
|
||||
public DateTime? DataInizio { get; set; }
|
||||
public DateTime DataInizio { get; set; } = DateTime.MinValue;
|
||||
public DateTime? DataFine { get; set; }
|
||||
public decimal TotCount { get; set; } = 0;
|
||||
public decimal TotWatt { get; set; } = 0;
|
||||
public decimal TotGas { get; set; } = 0;
|
||||
public decimal TotWatt { get; set; } = 0;
|
||||
public decimal TotCount01 { get; set; } = 0;
|
||||
public decimal TotCount02 { get; set; } = 0;
|
||||
public decimal TotCount03 { get; set; } = 0;
|
||||
public decimal TotEn01 { get; set; } = 0;
|
||||
public decimal TotEn02 { get; set; } = 0;
|
||||
public decimal TotEn03 { get; set; } = 0;
|
||||
|
||||
[NotMapped]
|
||||
public decimal AvgWatt
|
||||
{
|
||||
get
|
||||
{
|
||||
var num = TotWatt;
|
||||
var den = TotCount;
|
||||
if (den == 0)
|
||||
{
|
||||
den = 1;
|
||||
}
|
||||
decimal answ = num / den;
|
||||
return answ;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
|
||||
|
||||
#nullable disable
|
||||
@@ -29,6 +30,19 @@ namespace MP.Data.DatabaseModels
|
||||
public int? PzPallet { get; set; }
|
||||
public decimal Tcassegnato { get; set; }
|
||||
|
||||
[NotMapped]
|
||||
public int TotCicli
|
||||
{
|
||||
get => NumPezziEv + NumPezziSca;
|
||||
}
|
||||
|
||||
[NotMapped]
|
||||
public int NumPezziScaNet
|
||||
{
|
||||
get => NumPezziSca - NumPezziRil;
|
||||
}
|
||||
|
||||
|
||||
#endregion Public Properties
|
||||
}
|
||||
}
|
||||
@@ -36,16 +36,19 @@ namespace MP.Data
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public virtual DbSet<AnagFLTransModel> DbSetAnagFLTrans { get; set; }
|
||||
public virtual DbSet<StatsAnagArticoli> DbSetArticoli { get; set; }
|
||||
public virtual DbSet<AzioniUL> DbSetAzioniUL { get; set; }
|
||||
public virtual DbSet<ConfigModel> DbSetConfig { get; set; }
|
||||
public virtual DbSet<ResControlli> DbSetControlli { get; set; }
|
||||
public virtual DbSet<DdbTurni> DbSetDdbTurni { get; set; }
|
||||
public virtual DbSet<Macchine> DbSetMacchine { get; set; }
|
||||
public virtual DbSet<StatsODL> DbSetODL { get; set; }
|
||||
public virtual DbSet<OdlEnergyModel> DbSetOdlEnergy { get; set; }
|
||||
public virtual DbSet<ResScarti> DbSetScarti { get; set; }
|
||||
public virtual DbSet<TurniOee> DbSetTurniOee { get; set; }
|
||||
public virtual DbSet<UserActionLog> DbSetUserLog { get; set; }
|
||||
public virtual DbSet<OdlEnergyModel> DbSetOdlEnergy { get; set; }
|
||||
public virtual DbSet<VocabolarioModel> DbSetVocabolario { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
@@ -72,6 +75,31 @@ namespace MP.Data
|
||||
{
|
||||
modelBuilder.HasAnnotation("Relational:Collation", "SQL_Latin1_General_CP1_CI_AS");
|
||||
|
||||
modelBuilder.Entity<ConfigModel>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Chiave);
|
||||
|
||||
entity.ToTable("Config");
|
||||
|
||||
entity.Property(e => e.Chiave)
|
||||
.HasMaxLength(50)
|
||||
.HasColumnName("chiave");
|
||||
|
||||
entity.Property(e => e.Note).HasColumnName("note");
|
||||
|
||||
entity.Property(e => e.Valore).HasColumnName("valore");
|
||||
|
||||
entity.Property(e => e.ValoreStd)
|
||||
.HasColumnName("valoreStd")
|
||||
.HasComment("Valore di default/riferimento per la variabile");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<VocabolarioModel>(entity =>
|
||||
{
|
||||
entity.HasKey(e => new { e.Lingua, e.Lemma });
|
||||
|
||||
});
|
||||
|
||||
modelBuilder.Entity<TurniOee>(entity =>
|
||||
{
|
||||
entity.HasNoKey();
|
||||
|
||||
@@ -0,0 +1,97 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Metadata;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.Data.DatabaseModels;
|
||||
using NLog;
|
||||
|
||||
#nullable disable
|
||||
// <Auto-Generated>
|
||||
// This is here so CodeMaid doesn't reorganize this document
|
||||
// </Auto-Generated>
|
||||
namespace MP.Data
|
||||
{
|
||||
public partial class MoonPro_VocContext : DbContext
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private IConfiguration _configuration;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
public MoonPro_VocContext(IConfiguration configuration)
|
||||
{
|
||||
_configuration = configuration;
|
||||
}
|
||||
|
||||
public MoonPro_VocContext(DbContextOptions<MoonPro_VocContext> options) : base(options)
|
||||
{
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public virtual DbSet<ConfigModel> DbSetConfig { get; set; }
|
||||
public virtual DbSet<LingueModel> DbSetLilngue { get; set; }
|
||||
public virtual DbSet<VocabolarioModel> DbSetVocabolario { get; set; }
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
partial void OnModelCreatingPartial(ModelBuilder modelBuilder);
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
|
||||
{
|
||||
if (!optionsBuilder.IsConfigured)
|
||||
{
|
||||
string connString = _configuration.GetConnectionString("MP.Voc");
|
||||
|
||||
optionsBuilder.UseSqlServer(connString);
|
||||
}
|
||||
}
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
modelBuilder.HasAnnotation("Relational:Collation", "SQL_Latin1_General_CP1_CI_AS");
|
||||
|
||||
modelBuilder.Entity<ConfigModel>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Chiave);
|
||||
|
||||
entity.ToTable("Config");
|
||||
|
||||
entity.Property(e => e.Chiave)
|
||||
.HasMaxLength(50)
|
||||
.HasColumnName("chiave");
|
||||
|
||||
entity.Property(e => e.Note).HasColumnName("note");
|
||||
|
||||
entity.Property(e => e.Valore).HasColumnName("valore");
|
||||
|
||||
entity.Property(e => e.ValoreStd)
|
||||
.HasColumnName("valoreStd")
|
||||
.HasComment("Valore di default/riferimento per la variabile");
|
||||
});
|
||||
|
||||
modelBuilder.Entity<VocabolarioModel>(entity =>
|
||||
{
|
||||
entity.HasKey(e => new { e.Lingua, e.Lemma });
|
||||
|
||||
});
|
||||
|
||||
OnModelCreatingPartial(modelBuilder);
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
}
|
||||
}
|
||||
@@ -91,9 +91,39 @@ namespace MP.Data.Services
|
||||
return result;
|
||||
}
|
||||
|
||||
public Task<List<ConfigModel>> ConfigGetAll()
|
||||
/// <summary>
|
||||
/// Recupero elenco config
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<ConfigModel>> ConfigGetAll()
|
||||
{
|
||||
return Task.FromResult(dbController.ConfigGetAll().ToList());
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<ConfigModel>? result = new List<ConfigModel>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisBaseKey}:Conf";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
//if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<ConfigModel>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbController.ConfigGetAll();
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
redisDb.StringSet(currKey, rawData, LongCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<ConfigModel>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"ConfigGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
@@ -104,6 +134,7 @@ namespace MP.Data.Services
|
||||
redisConn = null;
|
||||
redisDb = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pulizia cache Redis (tutta)
|
||||
/// </summary>
|
||||
@@ -126,6 +157,40 @@ namespace MP.Data.Services
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco link JQM (totale)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<LinkMenu>> ListLinkAll()
|
||||
{
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<LinkMenu>? result = new List<LinkMenu>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisBaseKey}:Menu:ALL";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<LinkMenu>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = await Task.FromResult(dbController.ListLinkAll());
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<LinkMenu>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"ListLinkAll | tipoLink: * | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco link JQM dato filtro tipo
|
||||
/// </summary>
|
||||
@@ -161,39 +226,6 @@ namespace MP.Data.Services
|
||||
Log.Debug($"ListLinkFilt | tipoLink: {tipoLink} | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// Elenco link JQM (totale)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<LinkMenu>> ListLinkAll()
|
||||
{
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<LinkMenu>? result = new List<LinkMenu>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisBaseKey}:Menu:ALL";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<LinkMenu>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = await Task.FromResult(dbController.ListLinkAll());
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(currKey, rawData, UltraLongCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<LinkMenu>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"ListLinkAll | tipoLink: * | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco Macchine dato operatore secondo gruppi (macchine/operatore)
|
||||
|
||||
@@ -55,13 +55,57 @@ namespace MP.Data.Services
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Recupero elenco config
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<ConfigModel>> ConfigGetAll()
|
||||
{
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<ConfigModel>? result = new List<ConfigModel>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisBaseKey}:Conf";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
//if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<ConfigModel>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbController.ConfigGetAll();
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
redisDb.StringSet(currKey, rawData, LongCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<ConfigModel>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"ConfigGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Clear database controller
|
||||
dbController.Dispose();
|
||||
// redis dispose
|
||||
redisConn = null;
|
||||
redisDb = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco ODL filtrati x articolo e macchina
|
||||
/// </summary>
|
||||
/// <param name="CodArt">Cod articolo</param>
|
||||
/// <param name="IdxMacchina">Macchina selezionata</param>
|
||||
/// <returns></returns>
|
||||
public async Task<List<ODLExpModel>> ListODLFilt(string CodArt, string IdxMacchina="*")
|
||||
public async Task<List<ODLExpModel>> ListODLFilt(string CodArt, string IdxMacchina = "*")
|
||||
{
|
||||
// setup parametri costanti
|
||||
bool inCorso = false;
|
||||
@@ -84,7 +128,7 @@ namespace MP.Data.Services
|
||||
}
|
||||
else
|
||||
{
|
||||
result = await Task.FromResult(dbController.ListODLFilt(inCorso,CodArt, keyRichPart, Reparto, IdxMacchina, startDate, endDate));
|
||||
result = await Task.FromResult(dbController.ListODLFilt(inCorso, CodArt, keyRichPart, Reparto, IdxMacchina, startDate, endDate));
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(currKey, rawData, LongCache);
|
||||
@@ -98,23 +142,6 @@ namespace MP.Data.Services
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Task<List<ConfigModel>> ConfigGetAll()
|
||||
{
|
||||
return Task.FromResult(dbController.ConfigGetAll().ToList());
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Clear database controller
|
||||
dbController.Dispose();
|
||||
// redis dispose
|
||||
redisConn = null;
|
||||
redisDb = null;
|
||||
}
|
||||
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.Data.Conf;
|
||||
using MP.Data.Controllers;
|
||||
using MP.Data.DatabaseModels;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
@@ -74,9 +75,39 @@ namespace MP.Data.Services
|
||||
|
||||
#region Public Methods
|
||||
|
||||
public Task<List<ConfigModel>> ConfigGetAll()
|
||||
/// <summary>
|
||||
/// Recupero elenco config
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<ConfigModel>> ConfigGetAll()
|
||||
{
|
||||
return Task.FromResult(dbController.ConfigGetAll().ToList());
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<ConfigModel>? result = new List<ConfigModel>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisBaseKey}:Conf";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
//if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<ConfigModel>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbController.ConfigGetAll();
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
redisDb.StringSet(currKey, rawData, LongCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<ConfigModel>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"ConfigGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
@@ -227,6 +258,22 @@ namespace MP.Data.Services
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elimina info numPezzi x macchina
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
public bool MachProdStRem(string idxMacchina)
|
||||
{
|
||||
bool answ = false;
|
||||
if (MachineProdStatus.ContainsKey(idxMacchina))
|
||||
{
|
||||
MachineProdStatus.Remove(idxMacchina);
|
||||
}
|
||||
answ = true;
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Salva numPezzi x macchina
|
||||
/// </summary>
|
||||
@@ -248,22 +295,6 @@ namespace MP.Data.Services
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elimina info numPezzi x macchina
|
||||
/// </summary>
|
||||
/// <param name="idxMacchina"></param>
|
||||
/// <returns></returns>
|
||||
public bool MachProdStRem(string idxMacchina)
|
||||
{
|
||||
bool answ = false;
|
||||
if (MachineProdStatus.ContainsKey(idxMacchina))
|
||||
{
|
||||
MachineProdStatus.Remove(idxMacchina);
|
||||
}
|
||||
answ = true;
|
||||
return answ;
|
||||
}
|
||||
|
||||
public async Task<List<MappaStatoExpl>> MseGetAll(bool forceDb = false)
|
||||
{
|
||||
Stopwatch sw = new Stopwatch();
|
||||
@@ -313,17 +344,12 @@ namespace MP.Data.Services
|
||||
#region Private Fields
|
||||
|
||||
private static IConfiguration _configuration = null!;
|
||||
|
||||
private static NLog.Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
/// <summary>
|
||||
/// Cache breve durata
|
||||
/// </summary>
|
||||
private TimeSpan FastCache = TimeSpan.FromSeconds(5);
|
||||
/// <summary>
|
||||
/// Cache brevissima durata
|
||||
/// </summary>
|
||||
private TimeSpan UltraFastCache = TimeSpan.FromMilliseconds(1500);
|
||||
|
||||
/// <summary>
|
||||
/// Cache lunga durata
|
||||
@@ -331,6 +357,12 @@ namespace MP.Data.Services
|
||||
private TimeSpan LongCache = TimeSpan.FromSeconds(60);
|
||||
|
||||
private int maxAge = 2000;
|
||||
private string redisBaseKey = "MP:ALL:Cache";
|
||||
|
||||
/// <summary>
|
||||
/// Cache brevissima durata
|
||||
/// </summary>
|
||||
private TimeSpan UltraFastCache = TimeSpan.FromMilliseconds(1500);
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
|
||||
@@ -0,0 +1,285 @@
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using MP.Data.Conf;
|
||||
using MP.Data.DatabaseModels;
|
||||
using Newtonsoft.Json;
|
||||
using NLog;
|
||||
using StackExchange.Redis;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MP.Data.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// Classe accesso processi traduzione
|
||||
/// </summary>
|
||||
public class TranslateSrv : BaseServ, IDisposable
|
||||
{
|
||||
#region Public Constructors
|
||||
|
||||
public TranslateSrv(IConfiguration configuration)
|
||||
{
|
||||
Stopwatch sw = Stopwatch.StartNew();
|
||||
sw.Start();
|
||||
_configuration = configuration;
|
||||
// setup compoenti REDIS
|
||||
redisConn = ConnectionMultiplexer.Connect(_configuration.GetConnectionString("Redis"));
|
||||
redisDb = redisConn.GetDatabase();
|
||||
|
||||
// conf DB
|
||||
string connStr = _configuration.GetConnectionString("MP.Voc");
|
||||
if (string.IsNullOrEmpty(connStr))
|
||||
{
|
||||
Log.Error("MP.Voc: ConnString empty!");
|
||||
}
|
||||
else
|
||||
{
|
||||
dbController = new Controllers.MpVocController(configuration);
|
||||
InitDict();
|
||||
sw.Stop();
|
||||
Log.Info($"TranslateSrv | MpVocController OK | {sw.Elapsed.TotalMilliseconds} ms");
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Constructors
|
||||
|
||||
#region Public Properties
|
||||
|
||||
public static Controllers.MpVocController dbController { get; set; } = null!;
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Public Methods
|
||||
|
||||
/// <summary>
|
||||
/// Recupero elenco config
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<ConfigModel>> ConfigGetAll()
|
||||
{
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<ConfigModel>? result = new List<ConfigModel>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisBaseKey}:Conf";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
//if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<ConfigModel>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbController.ConfigGetAll();
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
redisDb.StringSet(currKey, rawData, LongCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<ConfigModel>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"ConfigGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Clear database controller
|
||||
dbController.Dispose();
|
||||
// redis dispose
|
||||
redisConn = null;
|
||||
redisDb = null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pulizia cache Redis (tutta)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> FlushCache()
|
||||
{
|
||||
RedisValue pattern = new RedisValue($"{redisBaseKey}:*");
|
||||
bool answ = await ExecFlushRedisPattern(pattern);
|
||||
// rileggo vocabolario!
|
||||
var rawData = await VocabolarioGetAll();
|
||||
DictVocab = rawData.ToDictionary(kvp => $"{kvp.Lingua}_{kvp.Lemma}".ToUpper(), kvp => kvp.Traduzione);
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Pulizia cache Redis per chiave specifica (da redisBaseKey...)
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<bool> FlushCache(string KeyReq)
|
||||
{
|
||||
RedisValue pattern = new RedisValue($"{redisBaseKey}:{KeyReq}:*");
|
||||
bool answ = await ExecFlushRedisPattern(pattern);
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupero elenco config
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<LingueModel>> LingueGetAll()
|
||||
{
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<LingueModel>? result = new List<LingueModel>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisBaseKey}:Lang";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
//if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<LingueModel>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbController.LingueGetAll();
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
redisDb.StringSet(currKey, rawData, UltraLongCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<LingueModel>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"LingueGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Traduzione termine
|
||||
/// </summary>
|
||||
/// <param name="lemma"></param>
|
||||
/// <param name="lingua"></param>
|
||||
/// <returns></returns>
|
||||
public string Traduci(string lemma, string lingua = "IT")
|
||||
{
|
||||
string answ = $"[{lemma}.{lingua}]";
|
||||
string key = $"{lingua}_{lemma}".ToUpper();
|
||||
if (DictVocab.ContainsKey(key))
|
||||
{
|
||||
answ = DictVocab[key];
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupero elenco config
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<VocabolarioModel>> VocabolarioGetAll()
|
||||
{
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<VocabolarioModel>? result = new List<VocabolarioModel>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisBaseKey}:Voc";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
//if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<VocabolarioModel>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbController.VocabolarioGetAll();
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
redisDb.StringSet(currKey, rawData, LongCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<VocabolarioModel>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"VocabolarioGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
/// <summary>
|
||||
/// Vocabolario x recupero rapido traduzioni
|
||||
/// </summary>
|
||||
protected static Dictionary<string, string> DictVocab = new Dictionary<string, string>();
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto per connessione a REDIS
|
||||
/// </summary>
|
||||
protected ConnectionMultiplexer redisConn = null!;
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto DB redis da impiegare x chiamate R/W
|
||||
/// </summary>
|
||||
protected IDatabase redisDb = null!;
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Private Fields
|
||||
|
||||
private static Logger Log = LogManager.GetCurrentClassLogger();
|
||||
|
||||
private string redisBaseKey = "MP:Voc:Cache";
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Inizializzazione dict vari
|
||||
/// </summary>
|
||||
private static void InitDict()
|
||||
{
|
||||
// inizializzo dizionario vocabolario
|
||||
var rawData = dbController.VocabolarioGetAll();
|
||||
DictVocab = rawData.ToDictionary(kvp => $"{kvp.Lingua}_{kvp.Lemma}".ToUpper(), kvp => kvp.Traduzione);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Esegue flush memoria redis dato pattern
|
||||
/// </summary>
|
||||
/// <param name="pattern"></param>
|
||||
/// <returns></returns>
|
||||
private async Task<bool> ExecFlushRedisPattern(RedisValue pattern)
|
||||
{
|
||||
bool answ = false;
|
||||
var listEndpoints = redisConn.GetEndPoints();
|
||||
foreach (var endPoint in listEndpoints)
|
||||
{
|
||||
//var server = redisConnAdmin.GetServer(listEndpoints[0]);
|
||||
var server = redisConn.GetServer(endPoint);
|
||||
if (server != null)
|
||||
{
|
||||
var keyList = server.Keys(redisDb.Database, pattern);
|
||||
foreach (var item in keyList)
|
||||
{
|
||||
await redisDb.KeyDeleteAsync(item);
|
||||
}
|
||||
answ = true;
|
||||
}
|
||||
}
|
||||
|
||||
return answ;
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
@using ChartJs
|
||||
|
||||
<div class="row">
|
||||
@if (RawData == null || RawData.Count == 0)
|
||||
{
|
||||
<div class="col-12">
|
||||
<div class="alert alert-secondary text-center h4"><span class="oi oi-graph"></span> No Chart Data</div>
|
||||
</div>
|
||||
}
|
||||
else
|
||||
{
|
||||
<div class="col-2" style="max-height: 10em; overflow:hidden; overflow-y: auto;">
|
||||
<ul class="list-group list-group-sm small">
|
||||
@foreach (var item in @ParetoData)
|
||||
{
|
||||
<li class="list-group-item p-1 d-flex justify-content-between align-items-center">
|
||||
@item.label
|
||||
<span class="badge badge-primary badge-pill">@item.value</span>
|
||||
</li>
|
||||
}
|
||||
</ul>
|
||||
</div>
|
||||
<div class="col-10">
|
||||
<div class="row">
|
||||
<div class="col-2">
|
||||
<PieChart Id="PieODL" AspRatio="1" LegendPos="bottom" Data="@DatiPareto" Labels="@LabelPareto" lineColor="@lineColors" backColor="@bgColors" Title="ODL"></PieChart>
|
||||
</div>
|
||||
<div class="col-10">
|
||||
<Line Id="PlotODL" AspRatio="6" DataTS="@DatiPlot" Labels="@LabelPlot" lineColor="@lineColor" backColor="@lineColor" lTens="0" Title="Consumi"></Line>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
@@ -0,0 +1,181 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.IdentityModel.Tokens;
|
||||
using MP.Data;
|
||||
using MP.Stats.Data;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
||||
namespace MP.Stats.Components
|
||||
{
|
||||
public partial class ChartEnergy
|
||||
{
|
||||
#region Public Properties
|
||||
|
||||
[Parameter]
|
||||
public List<MP.Data.DatabaseModels.OdlEnergyModel> RawData
|
||||
{
|
||||
get => _rawData;
|
||||
set
|
||||
{
|
||||
// salvo valori
|
||||
_rawData = value;
|
||||
if (value != null)
|
||||
{
|
||||
// ricalcolo charting data
|
||||
recalcData();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Public Properties
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected const string EsitoKO = "Esito: Non Passato";
|
||||
|
||||
protected const string EsitoOK = "Esito: OK";
|
||||
|
||||
#endregion Protected Fields
|
||||
|
||||
#region Protected Properties
|
||||
|
||||
protected SelectData _currFilter { get; set; } = new SelectData();
|
||||
|
||||
protected List<MP.Data.DatabaseModels.OdlEnergyModel> _rawData { get; set; } = new List<MP.Data.DatabaseModels.OdlEnergyModel>();
|
||||
|
||||
/// <summary>
|
||||
/// Genera colori sfondo 33% rosso / arancione / giallo
|
||||
/// </summary>
|
||||
/// <param name="numRecords"></param>
|
||||
/// <returns></returns>
|
||||
protected List<string> bgColors
|
||||
{
|
||||
get => semaphColors(ParetoData.Count, "0.3");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Genera colori sfondo 33% rosso / arancione / giallo
|
||||
/// </summary>
|
||||
/// <param name="numRecords"></param>
|
||||
/// <returns></returns>
|
||||
protected List<string> lineColor
|
||||
{
|
||||
get => solidColors("1");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Genera colori sfondo 33% rosso / arancione / giallo
|
||||
/// </summary>
|
||||
/// <param name="numRecords"></param>
|
||||
/// <returns></returns>
|
||||
protected List<string> lineColors
|
||||
{
|
||||
get => semaphColors(ParetoData.Count, "1");
|
||||
}
|
||||
|
||||
[Inject]
|
||||
protected MessageService MessageService { get; set; }
|
||||
|
||||
protected List<ChartKV> ParetoData { get; set; } = new List<ChartKV>();
|
||||
|
||||
[Inject]
|
||||
protected MpStatsService StatService { get; set; }
|
||||
|
||||
protected List<chartJsData.chartJsTSerie> TSData { get; set; } = new List<chartJsData.chartJsTSerie>();
|
||||
|
||||
#endregion Protected Properties
|
||||
|
||||
#region Protected Methods
|
||||
|
||||
/// Genera colori sfondo 33% rosso / arancione / giallo
|
||||
/// </summary>
|
||||
/// <param name="numRecords"></param>
|
||||
/// <returns></returns>
|
||||
protected List<string> semaphColors(int numRecords, string alpha)
|
||||
{
|
||||
List<string> answ = new List<string>();
|
||||
|
||||
int numStep = 5;
|
||||
// ciclo x numStep-1
|
||||
for (int j = 0; j < numStep; j++)
|
||||
{
|
||||
for (int i = 0; i < numRecords / numStep; i++)
|
||||
{
|
||||
answ.Add($"rgba({54 + (180 - 54) * j / numStep}, {254 + (180 - 254) * j / numStep}, {86 + (35 - 86) * j / numStep}, {alpha}");
|
||||
}
|
||||
}
|
||||
// chiude
|
||||
while (answ.Count < numRecords)
|
||||
{
|
||||
answ.Add($"rgba(180, 180, 35, {alpha})");
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Genera colori sfondo 33% rosso / arancione / giallo
|
||||
/// </summary>
|
||||
/// <param name="numRecords"></param>
|
||||
/// <returns></returns>
|
||||
protected List<string> solidColors(string alpha)
|
||||
{
|
||||
List<string> answ = new List<string>();
|
||||
answ.Add($"rgba(54, 162, 235, {alpha})");
|
||||
return answ;
|
||||
}
|
||||
|
||||
#endregion Protected Methods
|
||||
|
||||
#region Private Properties
|
||||
|
||||
private List<double> DatiPareto
|
||||
{
|
||||
get => ParetoData.Select(x => x.value).ToList();
|
||||
}
|
||||
|
||||
private List<chartJsData.chartJsTSerie> DatiPlot
|
||||
{
|
||||
get => TSData;
|
||||
}
|
||||
|
||||
private List<string> LabelPareto
|
||||
{
|
||||
get => ParetoData.Select(x => x.label).ToList();
|
||||
}
|
||||
|
||||
private List<string> LabelPlot
|
||||
{
|
||||
get => TSData.Select(r => $"{r.x:yyyy-MM-dd}").ToList();
|
||||
}
|
||||
|
||||
#endregion Private Properties
|
||||
|
||||
#region Private Methods
|
||||
|
||||
private List<string> GetLineChartLabels()
|
||||
{
|
||||
var answ = TSData.Select(x => x.x.ToString("ddd dd.MM")).ToList();
|
||||
return answ;
|
||||
}
|
||||
|
||||
private void recalcData()
|
||||
{
|
||||
if (RawData != null)
|
||||
{
|
||||
ParetoData = RawData
|
||||
.GroupBy(p => new { p.IdxMacchina, p.CodArticolo })
|
||||
.Select(y => new ChartKV() { label = $"{y.First().IdxMacchina} {y.First().CodArticolo}", value = y.Count() })
|
||||
.OrderByDescending(x => x.value)
|
||||
.ToList();
|
||||
|
||||
TSData = RawData
|
||||
.GroupBy(x => x.DataInizio.Date)
|
||||
.Select(r => new chartJsData.chartJsTSerie() { x = r.First().DataInizio.Date, y = r.Average(l => (double)l.AvgWatt) })
|
||||
.OrderBy(o => o.x)
|
||||
.ToList();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Private Methods
|
||||
}
|
||||
}
|
||||
+152
-52
@@ -30,9 +30,10 @@ namespace MP.Stats.Data
|
||||
|
||||
#region Public Constructors
|
||||
|
||||
public MpStatsService(IConfiguration configuration, ILogger<MpStatsService> logger)
|
||||
public MpStatsService(IConfiguration configuration)
|
||||
{
|
||||
_logger = logger;
|
||||
Stopwatch sw = Stopwatch.StartNew();
|
||||
sw.Start();
|
||||
_configuration = configuration;
|
||||
|
||||
// setup compoenti REDIS
|
||||
@@ -43,14 +44,14 @@ namespace MP.Stats.Data
|
||||
string connStr = _configuration.GetConnectionString("MP.Stats");
|
||||
if (string.IsNullOrEmpty(connStr))
|
||||
{
|
||||
_logger.LogError("ConnString empty!");
|
||||
Log.Error("MP.Stats: ConnString empty!");
|
||||
}
|
||||
else
|
||||
{
|
||||
dbController = new MP.Data.Controllers.MpStatsController(configuration);
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendLine($"DbController OK");
|
||||
_logger.LogInformation(sb.ToString());
|
||||
InitDict();
|
||||
sw.Stop();
|
||||
Log.Info($"MpStatsService | MpStatsController OK | {sw.Elapsed.TotalMilliseconds} ms");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -95,7 +96,39 @@ namespace MP.Stats.Data
|
||||
result = new List<AzioniUL>();
|
||||
}
|
||||
sw.Stop();
|
||||
_logger.LogDebug($"ActionsGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
Log.Debug($"ActionsGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
public async Task<List<AnagFLTransModel>> AnagFLTransGetAll()
|
||||
{
|
||||
// setup parametri costanti
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<AnagFLTransModel> result = new List<AnagFLTransModel>();
|
||||
// cerco in redis...
|
||||
DateTime adesso = DateTime.Now;
|
||||
string currKey = $"{redisBaseKey}:Cache:FLTrans";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<AnagFLTransModel>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbController.AnagFLTransGetAll();
|
||||
// serializzp e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
await redisDb.StringSetAsync(currKey, rawData, FastCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<AnagFLTransModel>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"AnagFLTransGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -127,23 +160,6 @@ namespace MP.Stats.Data
|
||||
return Task.FromResult(answ);
|
||||
}
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Aggiorna record calcolando prossima scadenza dato ultima esecuzione
|
||||
/// </summary>
|
||||
/// <param name="taskRec"></param>
|
||||
/// <returns></returns>
|
||||
public DateTime CalcNextExe(TaskListModel? taskRec)
|
||||
{
|
||||
DateTime dtNext = DateTime.Today;
|
||||
if (taskRec != null)
|
||||
{
|
||||
dtNext = dbController.CalcNextExe(taskRec);
|
||||
}
|
||||
return dtNext;
|
||||
}
|
||||
#endif
|
||||
|
||||
public Task<List<AutocompleteModel>> CommesseGetSearch(int numRecord, string searchVal = "")
|
||||
{
|
||||
List<AutocompleteModel> answ = new List<AutocompleteModel>();
|
||||
@@ -155,6 +171,41 @@ namespace MP.Stats.Data
|
||||
return Task.FromResult(answ);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupero elenco config
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<ConfigModel>> ConfigGetAll()
|
||||
{
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<ConfigModel>? result = new List<ConfigModel>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisBaseKey}:Conf";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
//if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<ConfigModel>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbController.ConfigGetAll();
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
redisDb.StringSet(currKey, rawData, LongCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<ConfigModel>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"ConfigGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Clear database controller
|
||||
@@ -164,22 +215,6 @@ namespace MP.Stats.Data
|
||||
redisDb = null;
|
||||
}
|
||||
|
||||
#if false
|
||||
/// <summary>
|
||||
/// Chiamata esecuzione di un singolo task programmato
|
||||
/// </summary>
|
||||
/// <param name="TaskId"></param>
|
||||
/// <param name="SchedNext">Se true rischedula successiva chiamata</param>
|
||||
/// <returns></returns>
|
||||
public async Task<TaskResultModel> ExecuteTask(int TaskId, bool SchedNext)
|
||||
{
|
||||
TaskResultModel dbResult = dbController.ExecuteTask(TaskId, SchedNext);
|
||||
// svuoto cache!
|
||||
await FlushCache("Task");
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
#endif
|
||||
|
||||
/// <summary>
|
||||
/// Pulizia cache Redis (tutta)
|
||||
/// </summary>
|
||||
@@ -188,6 +223,10 @@ namespace MP.Stats.Data
|
||||
{
|
||||
RedisValue pattern = new RedisValue($"{redisBaseKey}:*");
|
||||
bool answ = await ExecFlushRedisPattern(pattern);
|
||||
|
||||
// rileggo conf UM!
|
||||
var rawData = await AnagFLTransGetAll();
|
||||
DictFluxUm = rawData.ToDictionary(kvp => $"{kvp.CodFluxOut}", kvp => kvp.UM);
|
||||
return answ;
|
||||
}
|
||||
|
||||
@@ -202,6 +241,20 @@ namespace MP.Stats.Data
|
||||
return answ;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Restituisce UM del flusso configurato
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public string FluxGetUM(string codFlux)
|
||||
{
|
||||
string answ = "#";
|
||||
if (DictFluxUm.ContainsKey(codFlux))
|
||||
{
|
||||
answ = DictFluxUm[codFlux];
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
public async Task<List<Macchine>> MacchineGetAll()
|
||||
{
|
||||
// setup parametri costanti
|
||||
@@ -230,7 +283,7 @@ namespace MP.Stats.Data
|
||||
result = new List<Macchine>();
|
||||
}
|
||||
sw.Stop();
|
||||
_logger.LogDebug($"MacchineGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
Log.Debug($"MacchineGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -303,7 +356,7 @@ namespace MP.Stats.Data
|
||||
.ToList();
|
||||
}
|
||||
sw.Stop();
|
||||
_logger.LogDebug($"StatControlliGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
Log.Debug($"StatControlliGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -335,7 +388,7 @@ namespace MP.Stats.Data
|
||||
result = new List<DdbTurni>();
|
||||
}
|
||||
sw.Stop();
|
||||
_logger.LogDebug($"StatDdbGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
Log.Debug($"StatDdbGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -354,7 +407,7 @@ namespace MP.Stats.Data
|
||||
dbResult = dbController.StatDdbGetAll(CurrFilter.DateStart, CurrFilter.DateEnd, CurrFilter.IdxMacchina, CurrFilter.IdxOdl, CurrFilter.KeyRichiesta, CurrFilter.CodArticolo, 1, 0);
|
||||
stopWatch.Stop();
|
||||
TimeSpan ts = stopWatch.Elapsed;
|
||||
_logger.LogTrace($"Effettuata lettura COMPLETA da DB + caching per StatDdbGetAllExport: {ts.TotalMilliseconds} ms");
|
||||
Log.Trace($"Effettuata lettura COMPLETA da DB + caching per StatDdbGetAllExport: {ts.TotalMilliseconds} ms");
|
||||
return await Task.FromResult(dbResult);
|
||||
}
|
||||
|
||||
@@ -382,7 +435,7 @@ namespace MP.Stats.Data
|
||||
await redisDb.StringSetAsync(currKey, rawData, FastCache);
|
||||
}
|
||||
sw.Stop();
|
||||
_logger.LogDebug($"StatDdbGetCount | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
Log.Debug($"StatDdbGetCount | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return numRec;
|
||||
}
|
||||
|
||||
@@ -420,7 +473,7 @@ namespace MP.Stats.Data
|
||||
result = new List<OdlEnergyModel>();
|
||||
}
|
||||
sw.Stop();
|
||||
_logger.LogDebug($"StatOdlEnergyGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
Log.Debug($"StatOdlEnergyGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -458,7 +511,7 @@ namespace MP.Stats.Data
|
||||
result = new List<StatsODL>();
|
||||
}
|
||||
sw.Stop();
|
||||
_logger.LogDebug($"StatOdlEnergyGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
Log.Debug($"StatOdlEnergyGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -490,7 +543,7 @@ namespace MP.Stats.Data
|
||||
result = new List<ResScarti>();
|
||||
}
|
||||
sw.Stop();
|
||||
_logger.LogDebug($"StatScartiGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
Log.Debug($"StatScartiGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -527,7 +580,7 @@ namespace MP.Stats.Data
|
||||
result = new List<TurniOee>();
|
||||
}
|
||||
sw.Stop();
|
||||
_logger.LogDebug($"StatTurniOeeGetAllCached | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
Log.Debug($"StatTurniOeeGetAllCached | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -559,10 +612,44 @@ namespace MP.Stats.Data
|
||||
result = new List<UserActionLog>();
|
||||
}
|
||||
sw.Stop();
|
||||
_logger.LogDebug($"StatUserLogGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
Log.Debug($"StatUserLogGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupero vocabolario
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public async Task<List<VocabolarioModel>> VocabolarioGetAll()
|
||||
{
|
||||
string source = "DB";
|
||||
Stopwatch sw = new Stopwatch();
|
||||
sw.Start();
|
||||
List<VocabolarioModel> result = new List<VocabolarioModel>();
|
||||
// cerco in redis...
|
||||
string currKey = $"{redisBaseKey}:Vocabolario";
|
||||
RedisValue rawData = await redisDb.StringGetAsync(currKey);
|
||||
//if (!string.IsNullOrEmpty($"{rawData}"))
|
||||
if (rawData.HasValue)
|
||||
{
|
||||
result = JsonConvert.DeserializeObject<List<VocabolarioModel>>($"{rawData}");
|
||||
source = "REDIS";
|
||||
}
|
||||
else
|
||||
{
|
||||
result = dbController.VocabolarioGetAll();
|
||||
// serializzo e salvo...
|
||||
rawData = JsonConvert.SerializeObject(result);
|
||||
redisDb.StringSet(currKey, rawData, LongCache);
|
||||
}
|
||||
if (result == null)
|
||||
{
|
||||
result = new List<VocabolarioModel>();
|
||||
}
|
||||
sw.Stop();
|
||||
Log.Debug($"VocabolarioGetAll | {source} | {sw.Elapsed.TotalMilliseconds}ms");
|
||||
return result;
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
@@ -572,6 +659,11 @@ namespace MP.Stats.Data
|
||||
|
||||
protected static string connStringFatt = "";
|
||||
|
||||
/// <summary>
|
||||
/// Vocabolario x recupero rapido traduzioni
|
||||
/// </summary>
|
||||
protected static Dictionary<string, string> DictFluxUm = new Dictionary<string, string>();
|
||||
|
||||
/// <summary>
|
||||
/// Oggetto per connessione a REDIS
|
||||
/// </summary>
|
||||
@@ -604,14 +696,22 @@ namespace MP.Stats.Data
|
||||
|
||||
private static IConfiguration _configuration;
|
||||
|
||||
private static ILogger<MpStatsService> _logger;
|
||||
|
||||
private string redisBaseKey = "MP:STATS";
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
#region Private Methods
|
||||
|
||||
/// <summary>
|
||||
/// Inizializzazione dict vari
|
||||
/// </summary>
|
||||
private static void InitDict()
|
||||
{
|
||||
// inizializzo dizionario vocabolario
|
||||
var rawData = dbController.AnagFLTransGetAll();
|
||||
DictFluxUm = rawData.ToDictionary(kvp => $"{kvp.CodFluxOut}", kvp => kvp.UM);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Esegue flush memoria redis dato pattern
|
||||
/// </summary>
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<RootNamespace>MP.Stats</RootNamespace>
|
||||
<UserSecretsId>826e877c-ba70-4253-84cb-d0b1cafd4440</UserSecretsId>
|
||||
<Version>6.16.2502.1011</Version>
|
||||
<Version>6.16.2502.1011</Version>
|
||||
<Version>6.16.2502.1811</Version>
|
||||
<Version>6.16.2502.1811</Version>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<NoWarn>$(NoWarn);1591</NoWarn>
|
||||
<SatelliteResourceLanguages>en</SatelliteResourceLanguages>
|
||||
|
||||
+141
-32
@@ -4,9 +4,13 @@
|
||||
|
||||
<div class="card">
|
||||
<div class="card-header table-primary p-1">
|
||||
<SelectionFilter SelFilter="currFilter" filterChanged="DoFilter" filterReset="ResetFilter"></SelectionFilter>
|
||||
<SelectionFilter SelFilter="currFilter" filterChanged="DoFilter" filterReset="ResetFilter" chartVisible="ShowCharts" chartsToggle="ToggleChart" ChartEnabled="true"></SelectionFilter>
|
||||
</div>
|
||||
<div class="card-body py-0 px-1">
|
||||
@if (ShowCharts == true)
|
||||
{
|
||||
<ChartEnergy RawData="SearchRecords"></ChartEnergy>
|
||||
}
|
||||
@if (ListRecords == null)
|
||||
{
|
||||
<LoadingData></LoadingData>
|
||||
@@ -27,12 +31,36 @@
|
||||
<th>Articolo</th>
|
||||
<th>Inizio</th>
|
||||
<th>Fine</th>
|
||||
<th class="text-right">Unit</th>
|
||||
<th class="text-right">Energy</th>
|
||||
<th class="text-right">Gas</th>
|
||||
@* <th class="text-right">P1</th>
|
||||
<th class="text-right">P2</th>
|
||||
<th class="text-right">P3</th> *@
|
||||
@if (dynMode)
|
||||
{
|
||||
<th class="text-right">@Traduci("MP-STATS_TotCount01")</th>
|
||||
@if (numCount > 1)
|
||||
{
|
||||
<th class="text-right">@Traduci("MP-STATS_TotCount02")</th>
|
||||
}
|
||||
@if (numCount > 2)
|
||||
{
|
||||
<th class="text-right">@Traduci("MP-STATS_TotCount03")</th>
|
||||
}
|
||||
<th class="text-right">@Traduci("MP-STATS_TotEn01")</th>
|
||||
<th class="text-right">@Traduci("MP-STATS_TotEn01")/Unit</th>
|
||||
@if (numTotEn > 1)
|
||||
{
|
||||
<th class="text-right">@Traduci("MP-STATS_TotEn02")</th>
|
||||
<th class="text-right">@Traduci("MP-STATS_TotEn02")/Unit</th>
|
||||
}
|
||||
@if (numTotEn > 2)
|
||||
{
|
||||
<th class="text-right">@Traduci("MP-STATS_TotEn03")</th>
|
||||
<th class="text-right">@Traduci("MP-STATS_TotEn03")/Unit</th>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<th class="text-right">Unit</th>
|
||||
<th class="text-right">Energy</th>
|
||||
<th class="text-right">Gas</th>
|
||||
}
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -46,33 +74,114 @@
|
||||
</td>
|
||||
<td>
|
||||
@record.CodArticolo
|
||||
<div class="small">TBD: @record.CodArticolo</div>
|
||||
@* <div class="small">@record.DescArticolo</div> *@
|
||||
<div class="small">@record.DescArticolo</div>
|
||||
</td>
|
||||
<td>@record.DataInizio</td>
|
||||
<td>@record.DataFine</td>
|
||||
<td class="text-right">@(record.TotCount.ToString("N0")) m</td>
|
||||
<td class="text-right">
|
||||
<div>
|
||||
@record.TotWatt.ToString("N2") kWh
|
||||
</div>
|
||||
<small>
|
||||
@righDiv(record.TotWatt, record.TotCount).ToString("N3") kWh/m
|
||||
</small>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<div>
|
||||
@record.TotGas.ToString("N2") m<sup>3</sup>
|
||||
</div>
|
||||
<small>
|
||||
@righDiv(record.TotGas, record.TotCount).ToString("N3") m<sup>3</sup>/m
|
||||
</small>
|
||||
</td>
|
||||
@*
|
||||
<td class="text-right">@($"{currSim:N1}")</td>
|
||||
<td class="text-right">@($"{currSimGas:N1}")</td>
|
||||
<td class="text-right">@($"{currSim + currSimGas:N1}")</td>
|
||||
*@
|
||||
@if (dynMode)
|
||||
{
|
||||
<td class="text-right">@($"{record.TotCount01:N0}") @GetUM("TotCount01")</td>
|
||||
@if (numCount > 1)
|
||||
{
|
||||
<td class="text-right">@($"{record.TotCount02:N0}") @GetUM("TotCount02")</td>
|
||||
}
|
||||
@if (numCount > 2)
|
||||
{
|
||||
<td class="text-right">@($"{record.TotCount03:N0}") @GetUM("TotCount03")</td>
|
||||
}
|
||||
<td class="text-right">
|
||||
<div>
|
||||
@($"{record.TotEn01:N2}") @GetUM("TotEn01")
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<div class="small">
|
||||
@righDiv(record.TotEn01, record.TotCount01).ToString("N3") @GetUM("TotEn01")/@GetUM("TotCount01")
|
||||
</div>
|
||||
@if (numCount > 1)
|
||||
{
|
||||
<div class="small">
|
||||
@righDiv(record.TotEn01, record.TotCount02).ToString("N3") @GetUM("TotEn01")/@GetUM("TotCount02")
|
||||
</div>
|
||||
}
|
||||
@if (numCount > 2)
|
||||
{
|
||||
<div class="small">
|
||||
@righDiv(record.TotEn01, record.TotCount03).ToString("N3") @GetUM("TotEn01")/@GetUM("TotCount03")
|
||||
</div>
|
||||
}
|
||||
</td>
|
||||
@if (numTotEn > 1)
|
||||
{
|
||||
<td class="text-right">
|
||||
<div>
|
||||
@($"{record.TotEn02:N2}") @GetUM("TotEn02")
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<div class="small">
|
||||
@righDiv(record.TotEn02, record.TotCount01).ToString("N3") @GetUM("TotEn02")/@GetUM("TotCount01")
|
||||
</div>
|
||||
@if (numCount > 1)
|
||||
{
|
||||
<div class="small">
|
||||
@righDiv(record.TotEn02, record.TotCount02).ToString("N3") @GetUM("TotEn02")/@GetUM("TotCount02")
|
||||
</div>
|
||||
}
|
||||
@if (numCount > 2)
|
||||
{
|
||||
<div class="small">
|
||||
@righDiv(record.TotEn02, record.TotCount03).ToString("N3") @GetUM("TotEn02")/@GetUM("TotCount03")
|
||||
</div>
|
||||
}
|
||||
</td>
|
||||
}
|
||||
@if (numTotEn > 2)
|
||||
{
|
||||
<td class="text-right">
|
||||
<div>
|
||||
@($"{record.TotEn03:N2}") @GetUM("TotEn03")
|
||||
</div>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<div class="small">
|
||||
@righDiv(record.TotEn03, record.TotCount01).ToString("N3") @GetUM("TotEn02")/@GetUM("TotCount01")
|
||||
</div>
|
||||
@if (numCount > 1)
|
||||
{
|
||||
<div class="small">
|
||||
@righDiv(record.TotEn03, record.TotCount02).ToString("N3") @GetUM("TotEn02")/@GetUM("TotCount02")
|
||||
</div>
|
||||
}
|
||||
@if (numCount > 2)
|
||||
{
|
||||
<div class="small">
|
||||
@righDiv(record.TotEn03, record.TotCount03).ToString("N3") @GetUM("TotEn02")/@GetUM("TotCount03")
|
||||
</div>
|
||||
}
|
||||
</td>
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
<td class="text-right">@(record.TotCount.ToString("N0")) m</td>
|
||||
<td class="text-right">
|
||||
<div>
|
||||
@record.TotWatt.ToString("N2") kWh
|
||||
</div>
|
||||
<small>
|
||||
@righDiv(record.TotWatt, record.TotCount).ToString("N3") kWh/m
|
||||
</small>
|
||||
</td>
|
||||
<td class="text-right">
|
||||
<div>
|
||||
@record.TotGas.ToString("N2") m<sup>3</sup>
|
||||
</div>
|
||||
<small>
|
||||
@righDiv(record.TotGas, record.TotCount).ToString("N3") m<sup>3</sup>/m
|
||||
</small>
|
||||
</td>
|
||||
}
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
@@ -82,6 +191,6 @@
|
||||
}
|
||||
</div>
|
||||
<div class="card-footer py-1">
|
||||
<DataPager PageSize="numRecord" currPage="currPage" numRecordChanged="ForceReload" numPageChanged="ForceReloadPage" exportEnabled="true" exportRequested="ExportCsv" fileName="@fileName" totalCount="totalCount" showLoading="isLoading" />
|
||||
<DataPager PageSize="numRecord" currPage="currPage" numRecordChanged="SetNumRec" numPageChanged="SetPage" exportEnabled="true" exportRequested="ExportCsv" fileName="@fileName" totalCount="totalCount" showLoading="isLoading" />
|
||||
</div>
|
||||
</div>
|
||||
@@ -1,5 +1,7 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.JSInterop;
|
||||
using MP.Data.DatabaseModels;
|
||||
using MP.Data.Services;
|
||||
using MP.Stats.Data;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
@@ -13,13 +15,18 @@ namespace MP.Stats.Pages
|
||||
{
|
||||
#region Private Fields
|
||||
|
||||
private MP.Data.DatabaseModels.OdlEnergyModel currRecord = null;
|
||||
private OdlEnergyModel currRecord = null;
|
||||
|
||||
private List<MP.Data.DatabaseModels.OdlEnergyModel> ListRecords;
|
||||
private List<MP.Data.DatabaseModels.OdlEnergyModel> SearchRecords;
|
||||
private List<OdlEnergyModel> ListRecords;
|
||||
private List<OdlEnergyModel> SearchRecords;
|
||||
private List<ConfigModel> ConfigList;
|
||||
|
||||
#endregion Private Fields
|
||||
|
||||
|
||||
[Inject]
|
||||
protected TranslateSrv TradService { get; set; }
|
||||
|
||||
#region Protected Fields
|
||||
|
||||
protected string fileName = "ODL_Energy.csv";
|
||||
@@ -58,7 +65,7 @@ namespace MP.Stats.Pages
|
||||
protected IJSRuntime JSRuntime { get; set; }
|
||||
|
||||
[Inject]
|
||||
protected MessageService MessageService { get; set; }
|
||||
protected MP.Stats.Data.MessageService MessageService { get; set; }
|
||||
|
||||
[Inject]
|
||||
protected NavigationManager NavManager { get; set; }
|
||||
@@ -99,9 +106,64 @@ namespace MP.Stats.Pages
|
||||
private async Task ReloadData()
|
||||
{
|
||||
SearchRecords = await StatService.StatOdlEnergyGetAll(currFilter, MessageService.SearchVal);
|
||||
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
|
||||
DisplayData();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Traduzione lemma richeisto (lingua default="IT")
|
||||
/// </summary>
|
||||
/// <param name="Lemma"></param>
|
||||
/// <returns></returns>
|
||||
public string Traduci(string Lemma)
|
||||
{
|
||||
return TradService.Traduci(Lemma);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// recupero UM del flusso indicato
|
||||
/// </summary>
|
||||
/// <param name="CodFlux"></param>
|
||||
/// <returns></returns>
|
||||
public string GetUM(string CodFlux)
|
||||
{
|
||||
return StatService.FluxGetUM(CodFlux);
|
||||
}
|
||||
|
||||
private async Task LoadConfData()
|
||||
{
|
||||
ConfigList = await StatService.ConfigGetAll();
|
||||
dynMode = convVal("STATS_EnergyMode") == "Dynamic";
|
||||
var sNumCount = convVal("STATS_EnergyNumCount");
|
||||
int.TryParse(convVal("STATS_EnergyNumCount"), out numCount);
|
||||
int.TryParse(convVal("STATS_EnergyNumTotEn"), out numTotEn);
|
||||
}
|
||||
|
||||
private string convVal(string chiave)
|
||||
{
|
||||
string answ = "";
|
||||
if (ConfigList != null && ConfigList.Count > 0)
|
||||
{
|
||||
var searchRec = ConfigList.First(x => x.Chiave == chiave);
|
||||
if (searchRec != null)
|
||||
{
|
||||
answ = searchRec.Valore;
|
||||
}
|
||||
}
|
||||
return answ;
|
||||
}
|
||||
|
||||
private void DisplayData()
|
||||
{
|
||||
ListRecords = SearchRecords
|
||||
.Skip(numRecord * (currPage - 1))
|
||||
.Take(numRecord)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
private bool dynMode = false;
|
||||
private int numCount = 1;
|
||||
private int numTotEn = 1;
|
||||
|
||||
#endregion Private Methods
|
||||
|
||||
#region Protected Methods
|
||||
@@ -115,16 +177,16 @@ namespace MP.Stats.Pages
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
protected async Task ForceReload(int newNum)
|
||||
protected void SetNumRec(int newNum)
|
||||
{
|
||||
numRecord = newNum;
|
||||
await ReloadData();
|
||||
DisplayData();
|
||||
}
|
||||
|
||||
protected async Task ForceReloadPage(int newNum)
|
||||
protected void SetPage(int newNum)
|
||||
{
|
||||
currPage = newNum;
|
||||
await ReloadData();
|
||||
DisplayData();
|
||||
}
|
||||
|
||||
protected override async Task OnInitializedAsync()
|
||||
@@ -135,6 +197,7 @@ namespace MP.Stats.Pages
|
||||
MessageService.PageName = "ENERGY";
|
||||
MessageService.PageIcon = "oi oi-bar-chart";
|
||||
MessageService.EA_SearchUpdated += OnSeachUpdated;
|
||||
await LoadConfData();
|
||||
await ReloadData();
|
||||
}
|
||||
|
||||
@@ -196,6 +259,15 @@ namespace MP.Stats.Pages
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
private bool ShowCharts { get; set; } = false;
|
||||
protected async Task ToggleChart(bool doShow)
|
||||
{
|
||||
ShowCharts = !ShowCharts;
|
||||
if (ShowCharts)
|
||||
{
|
||||
await ReloadData();
|
||||
}
|
||||
}
|
||||
protected decimal righDiv(decimal num, decimal den)
|
||||
{
|
||||
if (den == 0)
|
||||
|
||||
@@ -16,6 +16,9 @@ namespace MP.Stats.Pages
|
||||
[Inject]
|
||||
protected MpStatsService StatService { get; set; }
|
||||
|
||||
[Inject]
|
||||
protected TranslateSrv TradServ { get; set; } = null!;
|
||||
|
||||
[Inject]
|
||||
protected TaskService TServ { get; set; } = null!;
|
||||
|
||||
@@ -27,6 +30,7 @@ namespace MP.Stats.Pages
|
||||
{
|
||||
await StatService.FlushCache();
|
||||
await TServ.FlushCache();
|
||||
await TradServ.FlushCache();
|
||||
await Task.Delay(500);
|
||||
NavManager.NavigateTo("", true);
|
||||
}
|
||||
|
||||
@@ -27,10 +27,11 @@
|
||||
<th>Articolo</th>
|
||||
<th>Inizio</th>
|
||||
<th>Fine</th>
|
||||
<th class="text-right">Pezzi Rich</th>
|
||||
<th class="text-right">Pezzi Evasi</th>
|
||||
<th class="text-right">Pezzi Scarti</th>
|
||||
<th class="text-right">Pezzi Rilav</th>
|
||||
<th class="text-end">Pezzi Rich</th>
|
||||
<th class="text-end"># Buoni</th>
|
||||
<th class="text-end"># Scarti</th>
|
||||
<th class="text-end">Cicli Rilav</th>
|
||||
<th class="text-end"># Cicli Tot</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
@@ -48,10 +49,11 @@
|
||||
</td>
|
||||
<td>@record.DataInizio</td>
|
||||
<td>@record.DataFine</td>
|
||||
<td class="text-right">@record.NumPezzi</td>
|
||||
<td class="text-right">@record.NumPezziEv</td>
|
||||
<td class="text-right">@record.NumPezziSca</td>
|
||||
<td class="text-right">@record.NumPezziRil</td>
|
||||
<td class="text-end">@record.NumPezzi</td>
|
||||
<td class="text-end">@record.NumPezziEv</td>
|
||||
<td class="text-end">@record.NumPezziScaNet</td>
|
||||
<td class="text-end">@record.NumPezziRil</td>
|
||||
<td class="text-end">@record.TotCicli</td>
|
||||
</tr>
|
||||
}
|
||||
</tbody>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo statistiche MAPO</i>
|
||||
<h4>Versione: 6.16.2502.1011</h4>
|
||||
<h4>Versione: 6.16.2502.1811</h4>
|
||||
<br />
|
||||
Note di rilascio:
|
||||
<ul>
|
||||
|
||||
@@ -1 +1 @@
|
||||
6.16.2502.1011
|
||||
6.16.2502.1811
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>6.16.2502.1011</version>
|
||||
<version>6.16.2502.1811</version>
|
||||
<url>https://nexus.steamware.net/repository/SWS/MP-STATS/stable/LAST/MP.Stats.zip</url>
|
||||
<changelog>https://nexus.steamware.net/repository/SWS/MP-STATS/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
@@ -43,10 +43,10 @@
|
||||
</li>
|
||||
<li class="nav-item px-2">
|
||||
<NavLink class="nav-link" href="ReportODL">
|
||||
<span class="oi oi-book" aria-hidden="true" title="Dati di Produzione ODL"></span>
|
||||
<span class="oi oi-book" aria-hidden="true" title="Dati di Produzione (P)ODL/Commesse"></span>
|
||||
@if (showText)
|
||||
{
|
||||
<span class="@hideText">Report ODL/Comm.</span>
|
||||
<span class="@hideText">Rep. ODL/Comm</span>
|
||||
}
|
||||
</NavLink>
|
||||
</li>
|
||||
|
||||
+3
-1
@@ -5,6 +5,7 @@ using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using Microsoft.Extensions.Hosting;
|
||||
using Microsoft.OpenApi.Models;
|
||||
using MP.Data.Services;
|
||||
using MP.Stats.Data;
|
||||
using MP.TaskMan.Services;
|
||||
using StackExchange.Redis;
|
||||
@@ -146,8 +147,9 @@ namespace MP.Stats
|
||||
|
||||
services.AddSingleton<MpStatsService>();
|
||||
services.AddSingleton<TaskService>();
|
||||
services.AddSingleton<TranslateSrv>();
|
||||
|
||||
services.AddScoped<MessageService>();
|
||||
services.AddScoped<MP.Stats.Data.MessageService>();
|
||||
}
|
||||
|
||||
#endregion Public Methods
|
||||
|
||||
@@ -6,5 +6,9 @@
|
||||
"Microsoft": "Warning",
|
||||
"Microsoft.Hosting.Lifetime": "Information"
|
||||
}
|
||||
}
|
||||
},
|
||||
//"ConnectionStrings": {
|
||||
// "DefaultConnection": "Server=SQL2022PROD;Database=TFT_MoonPro_STATS_Prod;Trusted_Connection=True;MultipleActiveResultSets=true",
|
||||
// "MP.Stats": "Server=SQL2022PROD;Database=TFT_MoonPro_STATS_Prod;User ID=sa;Password=keyhammer16;integrated security=False;MultipleActiveResultSets=True;App=MP.STATS;"
|
||||
//}
|
||||
}
|
||||
|
||||
@@ -53,7 +53,8 @@
|
||||
"ConnectionStrings": {
|
||||
"Redis": "localhost:26379,serviceName=devel,DefaultDatabase=5,connectTimeout=5000,syncTimeout=5000,asyncTimeout=5000,abortConnect=false,ssl=false,allowAdmin=true",
|
||||
"DefaultConnection": "Server=SQL2016DEV;Database=MoonPro_STATS;Trusted_Connection=True;MultipleActiveResultSets=true",
|
||||
"MP.Stats": "Server=SQL2016DEV;Database=MoonPro_STATS;User ID=sa;Password=keyhammer16;integrated security=False;MultipleActiveResultSets=True;App=MP.STATS;"
|
||||
"MP.Stats": "Server=SQL2016DEV;Database=MoonPro_STATS;User ID=sa;Password=keyhammer16;integrated security=False;MultipleActiveResultSets=True;App=MP.STATS;",
|
||||
"MP.Voc": "Server=SQL2016DEV;Database=MoonPro_STATS;User ID=sa;Password=keyhammer16;integrated security=False;MultipleActiveResultSets=True;App=MP.STATS;"
|
||||
},
|
||||
"FormatDur": "HH:mm.ss.ff",
|
||||
"SpecialConf": {
|
||||
|
||||
Reference in New Issue
Block a user