diff --git a/MP-TAB3/Components/ControlsMan.razor.cs b/MP-TAB3/Components/ControlsMan.razor.cs index fc59d458..0d815de0 100644 --- a/MP-TAB3/Components/ControlsMan.razor.cs +++ b/MP-TAB3/Components/ControlsMan.razor.cs @@ -33,7 +33,7 @@ namespace MP_TAB3.Components await Task.Delay(1); if (!string.IsNullOrEmpty(IdxMaccSel)) { - ListComplete = await TabDServ.RegControlliFilt(IdxMaccSel, IdxOdl, CurrPeriodo.Inizio, CurrPeriodo.Fine, false); + ListComplete = await TabDServ.RegControlliFiltAsync(IdxMaccSel, IdxOdl, CurrPeriodo.Inizio, CurrPeriodo.Fine, false); TotalCount = ListComplete.Count; // esegue paginazione UpdateTable(); diff --git a/MP-TAB3/Components/ProdConfMan.razor b/MP-TAB3/Components/ProdConfMan.razor new file mode 100644 index 00000000..6a70fc3c --- /dev/null +++ b/MP-TAB3/Components/ProdConfMan.razor @@ -0,0 +1,77 @@ + + + + +
+
+
+
+

Tipo Selezione

+
+
+
+ + +
+
+
+ @if (useOdl) + { + + } + else + { + + } +
+
+
+
+ + + + + + + + + @if (ShowRilav) + { + + } + + + + + @foreach (var item in ListPaged) + { + var actOdl = ActiveOdl(item.DataTo); + + + + + + + + @if (ShowRilav) + { + + } + + + } + +
DataOraODL/CommArticolo# Pz Conf# Pz Scarto# Pz RilavOperatore
+
@($"{item.DataOraConf:yyyy-MM-dd}")
+
@($"{item.DataOraConf:ddd, HH:mm:ss}")
+
+
@($"ODL{actOdl.IdxOdl:00000000}")
+
@item.CommessaEsterna
+
@actOdl.CodArticolo@item.PezziConf@item.PezziScar@item.PezziDaRilav@OperDto(item.MatrApp)
+
+
+
+ +
diff --git a/MP-TAB3/Components/ProdConfMan.razor.cs b/MP-TAB3/Components/ProdConfMan.razor.cs new file mode 100644 index 00000000..1fbd1805 --- /dev/null +++ b/MP-TAB3/Components/ProdConfMan.razor.cs @@ -0,0 +1,312 @@ +using Microsoft.AspNetCore.Components; +using MP.Data.DbModels; +using MP.Data.Services; +using NLog; +using static EgwCoreLib.Utils.DtUtils; + +namespace MP_TAB3.Components +{ + public partial class ProdConfMan + { + #region Public Properties + + [Parameter] + public EventCallback E_MachSel { get; set; } + + [Parameter] + public EventCallback E_Updated { get; set; } + + [Parameter] + public string IdxMacchSub { get; set; } = ""; + + [Parameter] + public bool ShowRilav { get; set; } = false; + + [Parameter] + public MappaStatoExplModel? RecMSE { get; set; } = null; + + #endregion Public Properties + + #region Protected Properties + + protected List ListComplete { get; set; } = new List(); + + protected List ListPaged { get; set; } = new List(); + + [Inject] + protected MessageService MServ { get; set; } = null!; + + [Inject] + protected SharedMemService SMServ { get; set; } = null!; + + [Inject] + protected TabDataService TabDServ { get; set; } = null!; + + #endregion Protected Properties + + #region Protected Methods + + protected override async Task OnInitializedAsync() + { + await Task.Delay(1); + await ReloadBaseList(); + if (RecMSE != null) + { + IdxMaccSel = RecMSE.IdxMacchina; + isMulti = SMServ.DictMacchMulti[IdxMaccSel] == 1; + if (isMulti) + { + var idxMSel = MServ.UserPrefGet(IdxMaccSel); + if (!string.IsNullOrEmpty(idxMSel)) + { + IdxMaccSel = idxMSel; + } + } + setupPeriodo(); + await ReloadData(); + } + } + + private void setupPeriodo() + { + DateTime fine = DateTime.Today.AddDays(1); + DateTime inizio = fine.AddDays(-7); + CurrPeriodo = new Periodo(inizio, fine); + } + + protected async Task SetMacc(string selIdxMacc) + { + isProcessing = true; + await Task.Delay(1); + IdxMaccSel = selIdxMacc; + await ReloadData(); + await Task.Delay(1); + isProcessing = false; + await E_MachSel.InvokeAsync(selIdxMacc); + } + + protected void SetNumRec(int newNum) + { + NumRecPage = newNum; + UpdateTable(); + } + + protected async Task SetOdl(int selIdxOdl) + { + isProcessing = true; + IdxOdl = selIdxOdl; + // se ho odl --> imposto periodo + if (IdxOdl > 0) + { + var recOdl = GetOdl(IdxOdl); + if (recOdl != null && recOdl.IdxOdl == IdxOdl) + { + DateTime fine = DateTime.Today.AddDays(1); + DateTime inizio = fine.AddDays(-7); + CurrPeriodo = new Periodo(recOdl.DataInizio ?? inizio, recOdl.DataFine ?? fine); + } + } + // altrimenti reset.. + else + { + setupPeriodo(); + } + await ReloadData(); + isProcessing = false; + //await Task.Delay(1); + } + + protected void SetPage(int newNum) + { + PageNum = newNum; + UpdateTable(); + } + + protected async Task SetPeriodo(Periodo newPeriodo) + { + CurrPeriodo = newPeriodo; + await ReloadData(); + } + + protected void UpdateTable() + { + // esegue paginazione + if (TotalCount > NumRecPage) + { + ListPaged = ListComplete + .OrderByDescending(x => x.DataTo) + .Skip((PageNum - 1) * NumRecPage) + .Take(NumRecPage) + .ToList(); + } + else + { + ListPaged = ListComplete; + } + } + + #endregion Protected Methods + + #region Private Fields + + private static Logger Log = LogManager.GetCurrentClassLogger(); + + private Dictionary DictOpr = new Dictionary(); + + private bool isMulti = false; + + private bool isProcessing = false; + + private List ListaOdl = new List(); + + private List ListaOper = new List(); + + private int NumRecPage = 10; + + private int PageNum = 1; + + private int TotalCount = 0; + + private bool useOdl = false; + + #endregion Private Fields + + #region Private Properties + + private Periodo CurrPeriodo { get; set; } = new Periodo(); + + private string IdxMaccAltra { get; set; } = ""; + + /// + /// Restituisce il codice IdxMacchina dell'altra tavola (se multi) altrimenti la stessa macchina... + /// + private string idxMaccAltraTav + { + get + { + string answ = ""; + if (RecMSE != null) + { + try + { + // verifico se SIA una tavola (ha char "#") + int iSharp = IdxMaccMain.IndexOf('#'); + if (iSharp > 0) + { + // ora verifico SE ALTRA TAVOLA ha ODL... + string nomeTav = IdxMaccMain.Substring(iSharp); + string altraTav = nomeTav.Substring(0, nomeTav.Length - 1); + altraTav += nomeTav.EndsWith("1") ? "2" : "1"; + // sistemo nome + answ = IdxMaccMain.Replace(nomeTav, altraTav); + } + } + catch + { } + } + return answ; + } + } + + /// + /// Macchina selezionata MAIN + /// + private string IdxMaccMain + { + get => RecMSE != null ? RecMSE.IdxMacchina : ""; + } + + private string IdxMaccSel { get; set; } = ""; + + private int IdxOdl { get; set; } = 0; + + private string selMessage + { + get => useOdl ? "Periodo da ODL" : "Periodo Libero"; + } + + private bool UseOdl + { + get => useOdl; + set + { + useOdl = value; + if (!value) + { + IdxOdl = 0; + } + } + } + + #endregion Private Properties + + #region Private Methods + + private MarkupString OperDto(int matr) + { + string answ = $"[{matr}]"; + // cerco in dizionario + if (DictOpr.ContainsKey(matr)) + { + answ = DictOpr[matr]; + } + else + { + // altrimenti cerco da lista e inserisco in dizionario + var recOpr = ListaOper.Where(x => x.MatrOpr == matr).FirstOrDefault(); + if (recOpr != null) + { + answ = $"{recOpr.Cognome} {recOpr.Nome}
[{matr}]"; + } + DictOpr.Add(matr, answ); + } + return (MarkupString)answ; + } + + private ODLModel ActiveOdl(DateTime dtRif) + { + var recOdl = ListaOdl + .Where(x => x.DataInizio <= dtRif && (x.DataFine >= dtRif || x.DataFine == null)) + .FirstOrDefault(); + return recOdl ?? new ODLModel(); + } + + private ODLModel GetOdl(int idxOdl) + { + var recOdl = ListaOdl + .Where(x => x.IdxOdl == idxOdl) + .FirstOrDefault(); + return recOdl ?? new ODLModel(); + } + + /// + /// Rileggo anagrafiche di base + /// + /// + private async Task ReloadBaseList() + { + ListaOper = await TabDServ.ElencoOperatori(); + } + + /// + /// Aggiorno valori produzione alla data richiesta... + /// + /// + private async Task ReloadData() + { + isProcessing = true; + await Task.Delay(1); + if (!string.IsNullOrEmpty(IdxMaccSel)) + { + ListaOdl = await TabDServ.OdlListByMaccPeriodo(IdxMaccSel, CurrPeriodo.Inizio, CurrPeriodo.Fine); + ListComplete = await TabDServ.ElencoConfProdFiltAsync(IdxMaccSel, CurrPeriodo.Inizio, CurrPeriodo.Fine); + TotalCount = ListComplete.Count; + // esegue paginazione + UpdateTable(); + } + isProcessing = false; + } + + #endregion Private Methods + } +} \ No newline at end of file diff --git a/MP-TAB3/MP-TAB3.csproj b/MP-TAB3/MP-TAB3.csproj index cc7fbe38..6f085bcc 100644 --- a/MP-TAB3/MP-TAB3.csproj +++ b/MP-TAB3/MP-TAB3.csproj @@ -3,7 +3,7 @@ net6.0 enable - 6.16.2507.1117 + 6.16.2507.2319 enable MP_TAB3 diff --git a/MP-TAB3/Pages/ProdConf.razor b/MP-TAB3/Pages/ProdConf.razor new file mode 100644 index 00000000..5a77509a --- /dev/null +++ b/MP-TAB3/Pages/ProdConf.razor @@ -0,0 +1,16 @@ +@page "/ProdConf" +@page "/prod-conf" +@inherits BasePage + +@if (string.IsNullOrEmpty(IdxMacc) || CurrMSE == null || IsLoading) +{ + +} +else +{ + + + +} + + diff --git a/MP-TAB3/Pages/ProdConf.razor.cs b/MP-TAB3/Pages/ProdConf.razor.cs new file mode 100644 index 00000000..e2dfaf87 --- /dev/null +++ b/MP-TAB3/Pages/ProdConf.razor.cs @@ -0,0 +1,35 @@ +namespace MP_TAB3.Pages +{ + public partial class ProdConf + { + #region Protected Methods + + protected async Task ForceReload() + { + IsLoading = true; + await Task.Delay(5); + IsLoading = false; + } + + protected override async Task OnInitializedAsync() + { + await base.OnInitializedAsync(); + await ReloadData(); + } + + protected void SetMacc(string selIdxMacc) + { + IdxMaccSubSel = selIdxMacc; + } + + #endregion Protected Methods + + #region Private Fields + + private string IdxMaccSubSel = ""; + + private bool IsLoading = false; + + #endregion Private Fields + } +} \ No newline at end of file diff --git a/MP-TAB3/Resources/ChangeLog.html b/MP-TAB3/Resources/ChangeLog.html index 97de475d..d52aa69e 100644 --- a/MP-TAB3/Resources/ChangeLog.html +++ b/MP-TAB3/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOSPEC -

Versione: 6.16.2507.1117

+

Versione: 6.16.2507.2319


Note di rilascio:
  • diff --git a/MP-TAB3/Resources/VersNum.txt b/MP-TAB3/Resources/VersNum.txt index fc35e574..ebd9ef09 100644 --- a/MP-TAB3/Resources/VersNum.txt +++ b/MP-TAB3/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2507.1117 +6.16.2507.2319 diff --git a/MP-TAB3/Resources/manifest.xml b/MP-TAB3/Resources/manifest.xml index d615d9dc..a9eefdf7 100644 --- a/MP-TAB3/Resources/manifest.xml +++ b/MP-TAB3/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2507.1117 + 6.16.2507.2319 https://nexus.steamware.net/repository/SWS/MP-TAB3/stable/LAST/MP-TAB3.zip https://nexus.steamware.net/repository/SWS/MP-TAB3/stable/LAST/ChangeLog.html false diff --git a/MP.Data/Controllers/MpTabController.cs b/MP.Data/Controllers/MpTabController.cs index bd2eb46d..e2188dd4 100644 --- a/MP.Data/Controllers/MpTabController.cs +++ b/MP.Data/Controllers/MpTabController.cs @@ -1717,6 +1717,29 @@ namespace MP.Data.Controllers return dbResult; } + /// + /// Restituisce elenco RC filtrato + /// + /// + /// + /// + /// + public List ElencoConfProdFilt(string idxMacchina, DateTime dataFrom, DateTime dataTo) + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetElConfProd + .Where (x => x.IdxMacchina== idxMacchina && (dataFrom <= x.DataOraConf && x.DataOraConf <= dataTo)) + .AsNoTracking() + .ToList(); + } + return dbResult; + } + + + /// /// Registra controllo /// diff --git a/MP.Data/DbModels/ElencoConfermeProdModel.cs b/MP.Data/DbModels/ElencoConfermeProdModel.cs new file mode 100644 index 00000000..f8b7b437 --- /dev/null +++ b/MP.Data/DbModels/ElencoConfermeProdModel.cs @@ -0,0 +1,39 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + + +#nullable disable +// +// This is here so CodeMaid doesn't reorganize this document +// +namespace MP.Data.DbModels +{ + [Table("ElencoConfermeProd")] + public partial class ElencoConfermeProdModel + { + #region Public Properties + + public DateTime DataOraConf { get; set; } = DateTime.Now; + [MaxLength(50), Column("idxMacchina")] + public string IdxMacchina { get; set; } = ""; + + public int MatrApp { get; set; } = 0; + [Column("dataFrom")] + public DateTime DataFrom { get; set; } = DateTime.Now; + [Column("dataTo")] + public DateTime DataTo { get; set; } = DateTime.Now; + [Column("pezziConf")] + public int PezziConf { get; set; } = 0; + [Column("pezziScar")] + public int PezziScar { get; set; } = 0; + [Column("pezziDaRilav")] + public int PezziDaRilav { get; set; } = 0; + [MaxLength(50)] + public string CommessaEsterna { get; set; } = ""; + public int TipoConf { get; set; } = 1; + + #endregion Public Properties + } +} \ No newline at end of file diff --git a/MP.Data/MoonProContext.cs b/MP.Data/MoonProContext.cs index 60c35a10..6029e3e7 100644 --- a/MP.Data/MoonProContext.cs +++ b/MP.Data/MoonProContext.cs @@ -49,6 +49,7 @@ namespace MP.Data public virtual DbSet DbSetAnagTags { get; set; } public virtual DbSet DbSetArticoli { get; set; } public virtual DbSet DbSetConfig { get; set; } + public virtual DbSet DbSetElConfProd { get; set; } public virtual DbSet DbSetLinkMenu { get; set; } public virtual DbSet DbSetListValues { get; set; } public virtual DbSet DbSetMacchine { get; set; } @@ -196,6 +197,11 @@ namespace MP.Data .IsRequired() .HasMaxLength(50); }); + + modelBuilder.Entity(entity => + { + entity.HasKey(e => new { e.DataOraConf, e.IdxMacchina }); + }); modelBuilder.Entity(entity => { diff --git a/MP.Data/Services/TabDataService.cs b/MP.Data/Services/TabDataService.cs index d063dd49..de1e6e47 100644 --- a/MP.Data/Services/TabDataService.cs +++ b/MP.Data/Services/TabDataService.cs @@ -2644,7 +2644,7 @@ namespace MP.Data.Services /// /// /// - public async Task> RegControlliFilt(string idxMacchina, int idxODL, DateTime dataFrom, DateTime dataTo, bool showMulti) + public async Task> RegControlliFiltAsync(string idxMacchina, int idxODL, DateTime dataFrom, DateTime dataTo, bool showMulti) { int rndWait = rnd.Next(0, 2); await Task.Delay(rndWait); @@ -2655,10 +2655,10 @@ namespace MP.Data.Services List? result = new List(); // cerco in redis... string currKey = $"{redisBaseKey}:RecContr:{idxMacchina}:{idxODL}:{dataFrom:yyyyyMMdd-HHmm}:{dataFrom:yyyyyMMdd-HHmm}:{showMulti}"; - RedisValue rawData = redisDb.StringGet(currKey); #if false - RedisValue rawData = await redisDb.StringGetAsync(currKey); + RedisValue rawData = redisDb.StringGet(currKey); #endif + RedisValue rawData = await redisDb.StringGetAsync(currKey); if (rawData.HasValue) { result = JsonConvert.DeserializeObject>($"{rawData}"); @@ -2669,10 +2669,10 @@ namespace MP.Data.Services result = dbTabController.RegControlliFilt(idxMacchina, idxODL, dataFrom, dataTo, showMulti); // serializzo e salvo... rawData = JsonConvert.SerializeObject(result); - redisDb.StringSet(currKey, rawData, UltraLongCache); #if false - await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + redisDb.StringSet(currKey, rawData, UltraLongCache); #endif + await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); } if (result == null) { @@ -2680,9 +2680,49 @@ namespace MP.Data.Services } sw.Stop(); #if false - Log.Debug($"RegControlliFilt | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + Log.Debug($"RegControlliFiltAsync | {source} | {sw.Elapsed.TotalMilliseconds}ms"); #endif - string callName = $"RegControlliFilt.{source}"; + string callName = $"RegControlliFiltAsync.{source}"; + int numRec = esCollect.RecordCall(callName, sw.Elapsed.TotalMilliseconds); + if (numRec >= nRecLog) + { + Log.Debug(esCollect.GetCallSum(callName, true)); + } + return result; + } + + + /// + /// Restituisce elenco ElencoConfermeProd filtrato e async + /// + /// + /// + /// + /// + public async Task> ElencoConfProdFiltAsync(string idxMacchina, DateTime dataFrom, DateTime dataTo) + { + // setup parametri costanti + string source = "DB"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + List result = new List(); + // cerco in redis... + string currKey = $"{redisBaseKey}:ElConfProd:{idxMacchina}:{dataFrom:yyyyyMMdd-HHmm}:{dataFrom:yyyyyMMdd-HHmm}"; + RedisValue rawData = await redisDb.StringGetAsync(currKey); + if (rawData.HasValue) + { + result = JsonConvert.DeserializeObject>($"{rawData}")?? new List(); + source = "REDIS"; + } + else + { + result = dbTabController.ElencoConfProdFilt(idxMacchina, dataFrom, dataTo); + // serializzo e salvo... + rawData = JsonConvert.SerializeObject(result); + await redisDb.StringSetAsync(currKey, rawData, UltraLongCache); + } + sw.Stop(); + string callName = $"ElencoConfProdFiltAsync.{source}"; int numRec = esCollect.RecordCall(callName, sw.Elapsed.TotalMilliseconds); if (numRec >= nRecLog) {