diff --git a/MP.Data/Controllers/MpSpecController.cs b/MP.Data/Controllers/MpSpecController.cs index 1c0f822f..e4c4e183 100644 --- a/MP.Data/Controllers/MpSpecController.cs +++ b/MP.Data/Controllers/MpSpecController.cs @@ -70,15 +70,6 @@ namespace MP.Data.Controllers return dbResult; } - /// - /// Elenco valori ammessi x Tipo articoli - /// - /// - public List AnagTipoArtLV() - { - return ListValuesFilt("AnagArticoli", "Tipo"); - } - /// /// Elenco valori ammessi x Stati commessa (es Yacht Baglietto) /// @@ -88,29 +79,13 @@ namespace MP.Data.Controllers return ListValuesFilt("PODL", "StatoComm"); } - /// - /// Elenco valori link (x home e navMenu laterale) + /// Elenco valori ammessi x Tipo articoli /// /// - public List ElencoLink() + public List AnagTipoArtLV() { - return ListLinkFilt("SpecLink"); - } - - public List ListLinkFilt(string tipoLink) - { - List dbResult = new List(); - using (var dbCtx = new MoonProContext(_configuration)) - { - dbResult = dbCtx - .DbSetLinkMenu - .Where(x => x.TipoLink == tipoLink) - .AsNoTracking() - .OrderBy(x => x.ordine) - .ToList(); - } - return dbResult; + return ListValuesFilt("AnagArticoli", "Tipo"); } /// @@ -165,25 +140,6 @@ namespace MP.Data.Controllers return dbResult; } - - /// - /// Elenco tabella Articoli IMPIEGATI (da stored stp_ART_getUsed) - /// - /// - public List ArticoliGetUsed() - { - List dbResult = new List(); - using (var dbCtx = new MoonProContext(_configuration)) - { - dbResult = dbCtx - .DbSetArticoli - .FromSqlRaw("EXEC stp_ART_getUsed") - .AsNoTracking() - .ToList(); - } - return dbResult; - } - /// /// Elenco tabella Articoli da filtro /// @@ -207,6 +163,24 @@ namespace MP.Data.Controllers return dbResult; } + /// + /// Elenco tabella Articoli IMPIEGATI (da stored stp_ART_getUsed) + /// + /// + public List ArticoliGetUsed() + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetArticoli + .FromSqlRaw("EXEC stp_ART_getUsed") + .AsNoTracking() + .ToList(); + } + return dbResult; + } + /// /// Update Record /// @@ -278,7 +252,7 @@ namespace MP.Data.Controllers { dbResult = dbCtx .DbSetConfig - .Where(x => x.Chiave== updRec.Chiave) + .Where(x => x.Chiave == updRec.Chiave) .FirstOrDefault(); if (dbResult != null) { @@ -294,6 +268,30 @@ namespace MP.Data.Controllers { } + /// + /// Elenco valori link (x home e navMenu laterale) + /// + /// + public List ElencoLink() + { + return ListLinkFilt("SpecLink"); + } + + public List ListLinkFilt(string tipoLink) + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetLinkMenu + .Where(x => x.TipoLink == tipoLink) + .AsNoTracking() + .OrderBy(x => x.ordine) + .ToList(); + } + return dbResult; + } + /// /// Elenco valori ammessi x tabella/colonna /// @@ -353,6 +351,48 @@ namespace MP.Data.Controllers return dbResult; } + /// + /// Elenco ODL filtrati x stato, articolo, KeyRich (che contiene stato) + /// + /// Stato ODL: true=in corso/completato + /// Cod articolo + /// KeyRich (parziale) da cercare (es cod stato x yacht) + /// + public List ListODLFilt(bool inCorso, string codArt, string keyRichPart) + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetODL + .Where(x => ((inCorso && x.DataFine == null) || (!inCorso && x.DataFine != null)) && (x.KeyRichiesta.Contains(keyRichPart) || keyRichPart == "*") && (x.CodArticolo == codArt || codArt == "*")) + .AsNoTracking() + .OrderBy(x => x.IdxOdl) + .ToList(); + } + return dbResult; + } + /// + /// Elenco PODL non avviati filtrati x articolo, KeyRich (che contiene stato) + /// + /// Cod articolo + /// KeyRich (parziale) da cercare (es cod stato x yacht) + /// + public List ListPODLFilt(string codArt, string keyRichPart) + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + dbResult = dbCtx + .DbSetPODL + .Where(x => (x.IdxOdl == 0) && (x.KeyRichiesta.Contains(keyRichPart) || keyRichPart == "*") && (x.CodArticolo == codArt || codArt == "*")) + .AsNoTracking() + .OrderBy(x => x.InsertDate) + .ToList(); + } + return dbResult; + } + /// /// Annulla modifiche su una specifica entity (cancel update) /// diff --git a/MP.Data/Controllers/MpStatsController.cs b/MP.Data/Controllers/MpStatsController.cs index 20921ed3..e070696e 100644 --- a/MP.Data/Controllers/MpStatsController.cs +++ b/MP.Data/Controllers/MpStatsController.cs @@ -73,9 +73,9 @@ namespace MP.Data.Controllers /// /// /// - public List CommesseGetSearch(int numRecord, string searchVal = "") + public List CommesseGetSearch(int numRecord, string searchVal = "") { - List dbResult = new List(); + List dbResult = new List(); using (var dbCtx = new MoonPro_STATSContext(_configuration)) { dbResult = dbCtx @@ -223,9 +223,9 @@ namespace MP.Data.Controllers /// /// /// - public List StatOdlGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo) + public List StatOdlGetAll(DateTime DataStart, DateTime DataEnd, string IdxMacchina, int IdxODL, string KeyRichiesta, string CodArticolo) { - List dbResult = new List(); + List dbResult = new List(); using (var dbCtx = new MoonPro_STATSContext(_configuration)) { var dataFrom = new SqlParameter("@dataFrom", DataStart); diff --git a/MP.Data/DatabaseModels/ODLModel.cs b/MP.Data/DatabaseModels/ODLModel.cs new file mode 100644 index 00000000..6e411485 --- /dev/null +++ b/MP.Data/DatabaseModels/ODLModel.cs @@ -0,0 +1,35 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +#nullable disable + +namespace MP.Data.DatabaseModels +{ + [Table("ODL")] + public partial class ODLModel + { + #region Public Properties + + [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int IdxOdl { get; set; } + [MaxLength(50)] + public string CodArticolo { get; set; } = ""; + [MaxLength(50)] + public string IdxMacchina { get; set; } + public int NumPezzi { get; set; } + public decimal Tcassegnato { get; set; } + public DateTime? DataInizio { get; set; } + public DateTime? DataFine { get; set; } + [MaxLength(2500)] + public string Note { get; set; } = ""; + [MaxLength(50)] + public string KeyRichiesta { get; set; } + public int PzPallet { get; set; } = 1; + [MaxLength(50)] + public string CodCli { get; set; } = ""; + + #endregion Public Properties + } +} \ No newline at end of file diff --git a/MP.Data/DatabaseModels/PODLModel.cs b/MP.Data/DatabaseModels/PODLModel.cs new file mode 100644 index 00000000..18c11d26 --- /dev/null +++ b/MP.Data/DatabaseModels/PODLModel.cs @@ -0,0 +1,42 @@ +using System; +using System.Collections.Generic; +using System.ComponentModel.DataAnnotations; +using System.ComponentModel.DataAnnotations.Schema; + +#nullable disable + +namespace MP.Data.DatabaseModels +{ + [Table("PODL")] + public partial class PODLModel + { + #region Public Properties + + [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int IdxPromessa { get; set; } + [MaxLength(50)] + public string KeyRichiesta { get; set; } + [MaxLength(50)] + public string KeyBCode { get; set; } + public bool Attivabile { get; set; } = false; + public int IdxOdl { get; set; } = 0; + [MaxLength(50)] + public string CodArticolo { get; set; } = ""; + [MaxLength(50)] + public string CodGruppo { get; set; } = ""; + [MaxLength(50)] + public string IdxMacchina { get; set; } + public int NumPezzi { get; set; } = 1; + public decimal Tcassegnato { get; set; } = 1; + public DateTime? DueDate { get; set; } + public int Priorita { get; set; } = 1; + public int PzPallet { get; set; } = 1; + [MaxLength(2500)] + public string Note { get; set; } = ""; + [MaxLength(50)] + public string CodCli { get; set; } = ""; + public DateTime InsertDate { get; set; } = DateTime.Now; + + #endregion Public Properties + } +} \ No newline at end of file diff --git a/MP.Data/DatabaseModels/ODL.cs b/MP.Data/DatabaseModels/StatsODL.cs similarity index 96% rename from MP.Data/DatabaseModels/ODL.cs rename to MP.Data/DatabaseModels/StatsODL.cs index 52bc9f61..b84a6a98 100644 --- a/MP.Data/DatabaseModels/ODL.cs +++ b/MP.Data/DatabaseModels/StatsODL.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; namespace MP.Data.DatabaseModels { - public partial class ODL + public partial class StatsODL { #region Public Properties diff --git a/MP.Data/MoonProContext.cs b/MP.Data/MoonProContext.cs index c477a8e9..2471364a 100644 --- a/MP.Data/MoonProContext.cs +++ b/MP.Data/MoonProContext.cs @@ -42,6 +42,8 @@ namespace MP.Data public virtual DbSet DbSetAnagGruppi { get; set; } public virtual DbSet DbSetListValues { get; set; } public virtual DbSet DbSetLinkMenu { get; set; } + public virtual DbSet DbSetODL { get; set; } + public virtual DbSet DbSetPODL { get; set; } #endregion Public Properties diff --git a/MP.Data/MoonPro_STATSContext.cs b/MP.Data/MoonPro_STATSContext.cs index a2317345..3a83c4f8 100644 --- a/MP.Data/MoonPro_STATSContext.cs +++ b/MP.Data/MoonPro_STATSContext.cs @@ -39,7 +39,7 @@ namespace MP.Data public virtual DbSet DbSetControlli { get; set; } public virtual DbSet DbSetDdbTurni { get; set; } public virtual DbSet DbSetMacchine { get; set; } - public virtual DbSet DbSetODL { get; set; } + public virtual DbSet DbSetODL { get; set; } public virtual DbSet DbSetScarti { get; set; } public virtual DbSet DbSetTurniOee { get; set; } public virtual DbSet DbSetUserLog { get; set; } @@ -325,7 +325,7 @@ namespace MP.Data .HasMaxLength(250); }); - modelBuilder.Entity(entity => + modelBuilder.Entity(entity => { entity.HasKey(e => e.IdxOdl) .HasName("PK_ODL_1"); diff --git a/MP.SPEC/Components/ListODL.razor b/MP.SPEC/Components/ListODL.razor new file mode 100644 index 00000000..4dae2789 --- /dev/null +++ b/MP.SPEC/Components/ListODL.razor @@ -0,0 +1,64 @@ +@using MP.SPEC.Components +@using MP.SPEC.Data + +

ODL

+ +@if (ListRecords == null) +{ + +} +else if (totalCount == 0) +{ +
Nessun record trovato
+} +else +{ +
+
+ + + + + + + + + + + + + + @foreach (var record in ListRecords) + { + + + + + + + + + + } + +
+ @**@ + ArticoloMacchina# pzInizioNote
+ @**@ + +
@record.CodArticolo
+
+
@record.IdxMacchina
+
+
@record.NumPezzi
+
+
@record.DataInizio
+
@record.Note + @*@if (ArticoloDelEnabled(record.CodArticolo)) + { + + }*@ +
+
+
+} diff --git a/MP.SPEC/Components/ListODL.razor.cs b/MP.SPEC/Components/ListODL.razor.cs new file mode 100644 index 00000000..1169fb63 --- /dev/null +++ b/MP.SPEC/Components/ListODL.razor.cs @@ -0,0 +1,73 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Components; +using System.Net.Http; +using Microsoft.AspNetCore.Authorization; +using Microsoft.AspNetCore.Components.Authorization; +using Microsoft.AspNetCore.Components.Forms; +using Microsoft.AspNetCore.Components.Routing; +using Microsoft.AspNetCore.Components.Web; +using Microsoft.AspNetCore.Components.Web.Virtualization; +using Microsoft.JSInterop; +using MP.SPEC; +using MP.SPEC.Shared; +using MP.SPEC.Components; +using MP.SPEC.Data; +using MP.Data.DatabaseModels; + +namespace MP.SPEC.Components +{ + public partial class ListODL + { + + + private bool isLoading { get; set; } = false; + private List? ListRecords; + + private ODLModel? currRecord = null; + + private List? SearchRecords; + + + [Inject] + protected IJSRuntime JSRuntime { get; set; } = null!; + + [Inject] + protected MpDataService MDService { get; set; } = null!; + + [Inject] + protected MessageService MessageService { get; set; } = null!; + + protected override async Task OnInitializedAsync() + { + await reloadData(); + } + + private async Task reloadData() + { + isLoading = true; + SearchRecords = await MDService.ListODLFilt(true, "*","*"); + totalCount = SearchRecords.Count; + ListRecords = SearchRecords;//.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList(); + isLoading = false; + } + + public string checkSelect(string CodArticolo) + { + string answ = ""; + if (currRecord != null) + { + try + { + answ = (currRecord.CodArticolo == CodArticolo) ? "table-info" : ""; + } + catch + { } + } + return answ; + } + private int totalCount = 0; + } +} \ No newline at end of file diff --git a/MP.SPEC/Components/ListPODL.razor b/MP.SPEC/Components/ListPODL.razor new file mode 100644 index 00000000..95d7c06a --- /dev/null +++ b/MP.SPEC/Components/ListPODL.razor @@ -0,0 +1,5 @@ +

PODL

+ +@code { + +} diff --git a/MP.SPEC/Data/MpDataService.cs b/MP.SPEC/Data/MpDataService.cs index 10cb7fff..c9dc6483 100644 --- a/MP.SPEC/Data/MpDataService.cs +++ b/MP.SPEC/Data/MpDataService.cs @@ -67,6 +67,38 @@ namespace MP.SPEC.Data #region Public Methods + public async Task> AnagStatiComm() + { + int maxAgeConfig = 5; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + List? result = new List(); + // cerco in redis... + RedisValue rawData = await redisDb.StringGetAsync(redisStatoCom); + if (!string.IsNullOrEmpty($"{rawData}")) + { + result = JsonConvert.DeserializeObject>($"{rawData}"); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"AnagStatiComm Read from REDIS: {ts.TotalMilliseconds}ms"); + } + else + { + result = await Task.FromResult(dbController.AnagStatiComm()); + // serializzp e salvo... + rawData = JsonConvert.SerializeObject(result); + await redisDb.StringSetAsync(redisStatoCom, rawData, TimeSpan.FromMinutes(maxAgeConfig)); + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"AnagStatiComm Read from DB: {ts.TotalMilliseconds}ms"); + } + if (result == null) + { + result = new List(); + } + return result; + } + public async Task> AnagTipoArtLV() { int maxAgeConfig = 5; @@ -99,8 +131,6 @@ namespace MP.SPEC.Data return result; } - - /// /// Eliminazione record selezionato /// @@ -132,6 +162,28 @@ namespace MP.SPEC.Data return await dbController.ArticoliUpdateRecord(currRec); } + /// + /// Elenco ODL filtrati x stato, articolo, KeyRich (che contiene stato) + /// + /// Stato ODL: true=in corso/completato + /// Cod articolo + /// KeyRich (parziale) da cercare (es cod stato x yacht) + /// + public async Task> ListODLFilt(bool inCorso, string codArt, string keyRichPart) + { + return await Task.FromResult(dbController.ListODLFilt(inCorso, codArt, keyRichPart)); + } + /// + /// Elenco PODL non avviati filtrati x articolo, KeyRich (che contiene stato) + /// + /// Cod articolo + /// KeyRich (parziale) da cercare (es cod stato x yacht) + /// + public async Task> ListPODLFilt(string codArt, string keyRichPart) + { + return await Task.FromResult(dbController.ListPODLFilt(codArt, keyRichPart)); + } + /// /// Verifica se sia possiubile cancellare articolo dato suo CodArt cercando su redis o su /// tab veto da DB @@ -231,38 +283,6 @@ namespace MP.SPEC.Data return result; } - public async Task> AnagStatiComm() - { - int maxAgeConfig = 5; - Stopwatch stopWatch = new Stopwatch(); - stopWatch.Start(); - List? result = new List(); - // cerco in redis... - RedisValue rawData = await redisDb.StringGetAsync(redisStatoCom); - if (!string.IsNullOrEmpty($"{rawData}")) - { - result = JsonConvert.DeserializeObject>($"{rawData}"); - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"AnagStatiComm Read from REDIS: {ts.TotalMilliseconds}ms"); - } - else - { - result = await Task.FromResult(dbController.AnagStatiComm()); - // serializzp e salvo... - rawData = JsonConvert.SerializeObject(result); - await redisDb.StringSetAsync(redisStatoCom, rawData, TimeSpan.FromMinutes(maxAgeConfig)); - stopWatch.Stop(); - TimeSpan ts = stopWatch.Elapsed; - Log.Debug($"AnagStatiComm Read from DB: {ts.TotalMilliseconds}ms"); - } - if (result == null) - { - result = new List(); - } - return result; - } - /// /// Reset dati cache config /// @@ -391,8 +411,6 @@ namespace MP.SPEC.Data private int fastRefreshMs = 1000; private string redisConfKey = "MP:MON:Cache:Config"; - private string redisTipoArt = "MP:MON:Cache:TipoArt"; - private string redisStatoCom = "MP:MON:Cache:StatoCom"; /// /// Oggetto per connessione a REDIS @@ -406,6 +424,8 @@ namespace MP.SPEC.Data private IDatabase redisDb = null!; private string redisMseKey = "MP:MON:Cache:MSE"; + private string redisStatoCom = "MP:MON:Cache:StatoCom"; + private string redisTipoArt = "MP:MON:Cache:TipoArt"; #endregion Private Fields diff --git a/MP.SPEC/Pages/Articoli.razor b/MP.SPEC/Pages/Articoli.razor index 2bad5e47..0dc1a125 100644 --- a/MP.SPEC/Pages/Articoli.razor +++ b/MP.SPEC/Pages/Articoli.razor @@ -6,7 +6,7 @@
-
+

Articoli

@@ -16,7 +16,7 @@
-
+