From 60cc1970e80afece50cf035121a56a804881e849 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 12 Oct 2023 19:13:01 +0200 Subject: [PATCH 1/4] Update gestione controlli --- MP-TAB-SERV/Components/AlarmsMan.razor.cs | 2 +- MP-TAB-SERV/Components/ControlsMan.razor | 104 ++++++++++- MP-TAB-SERV/Components/ControlsMan.razor.cs | 176 ++++++++++++++++++ MP-TAB-SERV/MP-TAB-SERV.csproj | 2 +- MP-TAB-SERV/Pages/Controls.razor | 6 +- MP-TAB-SERV/Resources/ChangeLog.html | 2 +- MP-TAB-SERV/Resources/VersNum.txt | 2 +- MP-TAB-SERV/Resources/manifest.xml | 2 +- MP.Data/Controllers/MpTabController.cs | 62 +++++- .../DatabaseModels/RegistroControlliModel.cs | 32 ++++ MP.Data/MoonProContext.cs | 2 + MP.Data/Services/TabDataService.cs | 55 ++++++ 12 files changed, 431 insertions(+), 16 deletions(-) create mode 100644 MP-TAB-SERV/Components/ControlsMan.razor.cs create mode 100644 MP.Data/DatabaseModels/RegistroControlliModel.cs diff --git a/MP-TAB-SERV/Components/AlarmsMan.razor.cs b/MP-TAB-SERV/Components/AlarmsMan.razor.cs index fe242239..b992c334 100644 --- a/MP-TAB-SERV/Components/AlarmsMan.razor.cs +++ b/MP-TAB-SERV/Components/AlarmsMan.razor.cs @@ -97,7 +97,7 @@ namespace MP_TAB_SERV.Components if (RecMSE != null) { IdxMaccSel = RecMSE.IdxMacchina; - CurrPeriodo = new Periodo(PeriodSet.LastWeek); + CurrPeriodo = new Periodo(PeriodSet.ThisWeek); await doUpdate(); } var rawDest = config.GetValue("AlarmDest"); diff --git a/MP-TAB-SERV/Components/ControlsMan.razor b/MP-TAB-SERV/Components/ControlsMan.razor index 7e1c74cd..cb245a6a 100644 --- a/MP-TAB-SERV/Components/ControlsMan.razor +++ b/MP-TAB-SERV/Components/ControlsMan.razor @@ -1,5 +1,103 @@ -

ControlsMan

+ -@code { + +
+
+ + @if (showInsert) + { + @if (showNote) + { +
+
+
+ @*
+
*@ + + +
+
+
+ +
+
+ } + else + { +
+
+ +
+
+ +
+
+ } + } +
+
+
+
-} + + + + + + + + @foreach (var item in ListPaged) + { + + + + } + +
+ Elenco Controlli +
+
+
+
+ Art: @item.CodArticolo +
+
+ ODL: @($"ODL{item.IdxOdl:000000000}") +
+
+
+ @if (item.EsitoOk) + { + + } + else + { + + } +
+
+
+ @($"{item.DataOra:ddd dd.MM.yy HH:mm:ss}") +
+
+ @item.Operatore + +
+
+
+ @if (!string.IsNullOrEmpty(item.Note)) + { +
@item.Note
+ } +
+
+
+
+
+
+ +
\ No newline at end of file diff --git a/MP-TAB-SERV/Components/ControlsMan.razor.cs b/MP-TAB-SERV/Components/ControlsMan.razor.cs new file mode 100644 index 00000000..ffe6ec23 --- /dev/null +++ b/MP-TAB-SERV/Components/ControlsMan.razor.cs @@ -0,0 +1,176 @@ +using global::Microsoft.AspNetCore.Components; +using MP.Data.DatabaseModels; +using MP.Data.Services; +using NLog; +using static EgwCoreLib.Utils.DtUtils; + +namespace MP_TAB_SERV.Components +{ + public partial class ControlsMan + { + #region Public Properties + + [Parameter] + public MappaStatoExpl? RecMSE { get; set; } = null; + + #endregion Public Properties + + #region Public Methods + + /// + /// Aggiorno valori produzione alla data richiesta... + /// + /// + public async Task doUpdate() + { + isProcessing = true; + await Task.Delay(1); + if (!string.IsNullOrEmpty(IdxMaccSel)) + { + ListComplete = await TabDServ.RegControlliFilt(IdxMaccSel, idxOdl, CurrPeriodo.Inizio, CurrPeriodo.Fine, false); + TotalCount = ListComplete.Count; + // esegue paginazione + UpdateTable(); + } + isProcessing = false; + await Task.Delay(1); + } + + #endregion Public Methods + + #region Protected Fields + + protected int idxOdl = 0; + protected bool isProcessing = false; + protected string noteKo = ""; + protected int NumRecPage = 10; + protected int PageNum = 1; + protected bool showNote = false; + protected int TotalCount = 0; + + #endregion Protected Fields + + #region Protected Properties + + protected string ConfTitle + { + get => showInsert ? "Nascondi Controllo" : "Registra Controllo"; + } + + protected List ListComplete { get; set; } = new List(); + protected List ListPaged { get; set; } = new List(); + + [Inject] + protected MessageService MServ { 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); + if (RecMSE != null) + { + IdxMaccSel = RecMSE.IdxMacchina; + CurrPeriodo = new Periodo(PeriodSet.ThisWeek); + await doUpdate(); + } + } + + protected async Task SaveKo() + { + isProcessing = true; + await TabDServ.RegControlliInsert(IdxMaccSel, MServ.MatrOpr, false, noteKo, DateTime.Now); + showInsert = false; + showNote = false; + await doUpdate(); + isProcessing = false; + } + + protected void SaveNumRec(int newNum) + { + NumRecPage = newNum; + UpdateTable(); + } + + protected async Task SaveOk() + { + isProcessing = true; + await TabDServ.RegControlliInsert(IdxMaccSel, MServ.MatrOpr, true, noteKo, DateTime.Now); + showInsert = false; + showNote = false; + await doUpdate(); + isProcessing = false; + } + + protected void SavePage(int newNum) + { + PageNum = newNum; + UpdateTable(); + } + + protected async Task SetMacc(string selIdxMacc) + { + isProcessing = true; + await Task.Delay(10); + IdxMaccSel = selIdxMacc; + await doUpdate(); + isProcessing = false; + await Task.Delay(10); + } + + protected async Task SetPeriodo(Periodo newPeriodo) + { + CurrPeriodo = newPeriodo; + await doUpdate(); + } + + protected void ShowKo() + { + showNote = true; + } + + protected void ToggleBtn() + { + showInsert = !showInsert; + if (showInsert) + { + noteKo = ""; + showNote = false; + } + } + + protected void UpdateTable() + { + // esegue paginazione + if (TotalCount > NumRecPage) + { + ListPaged = ListComplete.Skip((PageNum - 1) * NumRecPage).Take(NumRecPage).ToList(); + } + else + { + ListPaged = ListComplete; + } + } + + #endregion Protected Methods + + #region Private Fields + + private static Logger Log = LogManager.GetCurrentClassLogger(); + private bool showInsert = false; + + #endregion Private Fields + + #region Private Properties + + private Periodo CurrPeriodo { get; set; } = new Periodo(); + private string IdxMaccSel { get; set; } = ""; + + #endregion Private Properties + } +} \ No newline at end of file diff --git a/MP-TAB-SERV/MP-TAB-SERV.csproj b/MP-TAB-SERV/MP-TAB-SERV.csproj index 90468e23..67d97063 100644 --- a/MP-TAB-SERV/MP-TAB-SERV.csproj +++ b/MP-TAB-SERV/MP-TAB-SERV.csproj @@ -3,7 +3,7 @@ net6.0 enable - 6.16.2310.1212 + 6.16.2310.1219 enable MP_TAB_SERV diff --git a/MP-TAB-SERV/Pages/Controls.razor b/MP-TAB-SERV/Pages/Controls.razor index e7d04849..f5c55bf1 100644 --- a/MP-TAB-SERV/Pages/Controls.razor +++ b/MP-TAB-SERV/Pages/Controls.razor @@ -6,8 +6,6 @@ } else { -
- -
- + + } diff --git a/MP-TAB-SERV/Resources/ChangeLog.html b/MP-TAB-SERV/Resources/ChangeLog.html index 866ca7e8..ecf63a72 100644 --- a/MP-TAB-SERV/Resources/ChangeLog.html +++ b/MP-TAB-SERV/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOSPEC -

Versione: 6.16.2310.1212

+

Versione: 6.16.2310.1219


Note di rilascio:
  • diff --git a/MP-TAB-SERV/Resources/VersNum.txt b/MP-TAB-SERV/Resources/VersNum.txt index e15728ba..206c09b1 100644 --- a/MP-TAB-SERV/Resources/VersNum.txt +++ b/MP-TAB-SERV/Resources/VersNum.txt @@ -1 +1 @@ -6.16.2310.1212 +6.16.2310.1219 diff --git a/MP-TAB-SERV/Resources/manifest.xml b/MP-TAB-SERV/Resources/manifest.xml index a999b583..45d66206 100644 --- a/MP-TAB-SERV/Resources/manifest.xml +++ b/MP-TAB-SERV/Resources/manifest.xml @@ -1,6 +1,6 @@ - 6.16.2310.1212 + 6.16.2310.1219 https://nexus.steamware.net/repository/SWS/MP-TAB-SERV/stable/LAST/MP-TAB-SERV.zip https://nexus.steamware.net/repository/SWS/MP-TAB-SERV/stable/LAST/ChangeLog.html false diff --git a/MP.Data/Controllers/MpTabController.cs b/MP.Data/Controllers/MpTabController.cs index 1c7cea51..41537008 100644 --- a/MP.Data/Controllers/MpTabController.cs +++ b/MP.Data/Controllers/MpTabController.cs @@ -461,13 +461,12 @@ namespace MP.Data.Controllers return fatto; } - //stp_DDB_getNextByMacchinaFrom - public void Dispose() { _configuration = null; } + //stp_DDB_getNextByMacchinaFrom /// /// Eliminazione record EventList (SE trovato) /// @@ -626,8 +625,6 @@ namespace MP.Data.Controllers return fatto; } - //stp_STM_setInsEnabled - /// /// MicroStato macchina (da key) /// @@ -647,6 +644,7 @@ namespace MP.Data.Controllers return dbResult; } + //stp_STM_setInsEnabled /// /// Stato macchina - tutte /// @@ -700,6 +698,62 @@ namespace MP.Data.Controllers return fatto; } + /// + /// Restituisce elenco RC filtrato + /// + /// + /// + /// + /// + /// + public List RegControlliFilt(string idxMacchina, int idxODL, DateTime dataFrom, DateTime dataTo, bool showMulti) + { + List dbResult = new List(); + using (var dbCtx = new MoonProContext(_configuration)) + { + var IdxMacc = new SqlParameter("@IdxMacchina", idxMacchina); + var IdxODL = new SqlParameter("@IdxODL", idxODL); + var DataFrom = new SqlParameter("@DataFrom", dataFrom); + var DataTo = new SqlParameter("@DataTo", dataTo); + var ShowMulti = new SqlParameter("@showMulti", showMulti); + + dbResult = dbCtx + .DbSetRegControlli + .FromSqlRaw("EXEC stp_RC_getByFilt @IdxMacchina, @IdxODL, @DataFrom, @DataTo, @ShowMulti", IdxMacc, IdxODL, DataFrom, DataTo, ShowMulti) + .AsNoTracking() + .ToList(); + } + return dbResult; + } + + /// + /// Registra controllo + /// + /// + /// + /// + /// + /// + /// + public bool RegControlliInsert(string idxMacchina, int matrOpr, bool esitoOk, string note, DateTime dataOra) + { + bool fatto = false; + using (var dbCtx = new MoonProContext(_configuration)) + { + var IdxMacc = new SqlParameter("@IdxMacchina", idxMacchina); + var MatrOpr = new SqlParameter("@MatrOpr", matrOpr); + var EsitoOk = new SqlParameter("@EsitoOk", esitoOk); + var Note = new SqlParameter("@Note", note); + var DataOra = new SqlParameter("@DataOra", dataOra); + + var result = dbCtx + .Database + .ExecuteSqlRaw("EXEC stp_RC_insert @IdxMacchina, @MatrOpr, @EsitoOk, @Note, @DataOra", IdxMacc, MatrOpr, EsitoOk, Note, DataOra); + fatto = result != 0; + } + return fatto; + } + /// /// Effettua ricalcolo MSE x macchina indicata /// diff --git a/MP.Data/DatabaseModels/RegistroControlliModel.cs b/MP.Data/DatabaseModels/RegistroControlliModel.cs new file mode 100644 index 00000000..44e08436 --- /dev/null +++ b/MP.Data/DatabaseModels/RegistroControlliModel.cs @@ -0,0 +1,32 @@ +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.DatabaseModels +{ + [Table("RegistroControlli")] + public partial class RegistroControlliModel + { + #region Public Properties + + + [Key, DatabaseGenerated(DatabaseGeneratedOption.Identity)] + public int IdxControllo { get; set; } = 0; + public DateTime DataOra { get; set; } + public string IdxMacchina { get; set; } + public int IdxOdl { get; set; } + public string CodArticolo { get; set; } + public int MatrOpr { get; set; } + public bool EsitoOk { get; set; } + public string Note { get; set; } + public string Operatore { get; set; } = ""; + + #endregion Public Properties + } +} \ No newline at end of file diff --git a/MP.Data/MoonProContext.cs b/MP.Data/MoonProContext.cs index 8b59ca5c..913c95dc 100644 --- a/MP.Data/MoonProContext.cs +++ b/MP.Data/MoonProContext.cs @@ -73,6 +73,8 @@ namespace MP.Data public virtual DbSet DbSetStatoMacc { get; set; } public virtual DbSet DbSetStatoProd { get; set; } public virtual DbSet DbSetTurniMacc { get; set; } + public virtual DbSet DbSetRegControlli { get; set; } + public virtual DbSet DbSetStAct { get; set; } public virtual DbSet DbSetStActRow { get; set; } diff --git a/MP.Data/Services/TabDataService.cs b/MP.Data/Services/TabDataService.cs index 8b6ab37c..84b566e4 100644 --- a/MP.Data/Services/TabDataService.cs +++ b/MP.Data/Services/TabDataService.cs @@ -631,6 +631,61 @@ namespace MP.Data.Services return answ; } + /// + /// Restituisce elenco RC filtrato + /// + /// + /// + /// + /// + /// + public async Task> RegControlliFilt(string idxMacchina, int idxODL, DateTime dataFrom, DateTime dataTo, bool showMulti) + { + // setup parametri costanti + string source = "DB"; + Stopwatch sw = new Stopwatch(); + sw.Start(); + List? result = new List(); + // cerco in redis... + string currKey = $"{redisBaseKey}:RecContr:{idxMacchina}:{idxODL}:{dataFrom:yyyyyMMdd-HHmm}:{dataFrom:yyyyyMMdd-HHmm}:{showMulti}"; + RedisValue rawData = await redisDb.StringGetAsync(currKey); + if (rawData.HasValue) + { + result = JsonConvert.DeserializeObject>($"{rawData}"); + source = "REDIS"; + } + else + { + result = dbTabController.RegControlliFilt(idxMacchina, idxODL, dataFrom, dataTo, showMulti); + // serializzp e salvo... + rawData = JsonConvert.SerializeObject(result); + await redisDb.StringSetAsync(currKey, rawData, FastCache); + } + if (result == null) + { + result = new List(); + } + sw.Stop(); + Log.Debug($"RegControlliFilt | {source} | {sw.Elapsed.TotalMilliseconds}ms"); + return result; + } + + /// + /// Registra controllo + /// + /// + /// + /// + /// + /// + /// + public async Task RegControlliInsert(string idxMacchina, int matrOpr, bool esitoOk, string note, DateTime dataOra) + { + bool answ = dbTabController.RegControlliInsert(idxMacchina, matrOpr, esitoOk, note, dataOra); + await FlushCache("RecContr"); + return answ; + } + /// /// Resetta (rileggendo) i dati della macchina /// From 8348f2633a1faec0b91da56df9ad4f64271294a0 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 12 Oct 2023 19:34:57 +0200 Subject: [PATCH 2/4] Bozza colore dinamico x gauge --- MP-TAB-SERV/Components/MachineBlock.razor | 10 +++++++++- MP-TAB-SERV/MP-TAB-SERV.csproj | 4 ++-- MP-TAB-SERV/Shared/MainLayout.razor | 3 +-- MP.Data/DatabaseModels/MappaStatoExpl.cs | 12 ++++++++++-- 4 files changed, 22 insertions(+), 7 deletions(-) diff --git a/MP-TAB-SERV/Components/MachineBlock.razor b/MP-TAB-SERV/Components/MachineBlock.razor index c1553df4..66dad6e4 100644 --- a/MP-TAB-SERV/Components/MachineBlock.razor +++ b/MP-TAB-SERV/Components/MachineBlock.razor @@ -162,7 +162,15 @@ else
    - + @if (RecMSE.ReqFulfill) + { + + + } + else + { + + }
    diff --git a/MP-TAB-SERV/MP-TAB-SERV.csproj b/MP-TAB-SERV/MP-TAB-SERV.csproj index 67d97063..d4ce481d 100644 --- a/MP-TAB-SERV/MP-TAB-SERV.csproj +++ b/MP-TAB-SERV/MP-TAB-SERV.csproj @@ -17,8 +17,8 @@ - - + + diff --git a/MP-TAB-SERV/Shared/MainLayout.razor b/MP-TAB-SERV/Shared/MainLayout.razor index 5f4ac299..d18e77a9 100644 --- a/MP-TAB-SERV/Shared/MainLayout.razor +++ b/MP-TAB-SERV/Shared/MainLayout.razor @@ -20,11 +20,10 @@   MapoTAB2   - +
    - @**@
    diff --git a/MP.Data/DatabaseModels/MappaStatoExpl.cs b/MP.Data/DatabaseModels/MappaStatoExpl.cs index 8bffd1f9..6c4e2708 100644 --- a/MP.Data/DatabaseModels/MappaStatoExpl.cs +++ b/MP.Data/DatabaseModels/MappaStatoExpl.cs @@ -20,14 +20,14 @@ namespace MP.Data.DatabaseModels public int? IdxPOdl { get; set; } = 0; public string CodArticolo { get; set; } public string Disegno { get; set; } - public int? NumPezzi { get; set; } + public int NumPezzi { get; set; } = 0; public decimal? TCAssegnato { get; set; } public DateTime? DataInizioOdl { get; set; } public string Semaforo { get; set; } public int? IdxStato { get; set; } public string DescrizioneStato { get; set; } public double? Durata { get; set; } - public int? PezziProd { get; set; } + public int PezziProd { get; set; } = 0; public int? PezziConf { get; set; } public decimal? TempoOn { get; set; } public decimal? TempoAuto { get; set; } @@ -138,5 +138,13 @@ namespace MP.Data.DatabaseModels return answ; } } + [NotMapped] + public bool ReqFulfill + { + get + { + return PezziProd >= NumPezzi; + } + } } } From eeb67f51c5ee01b5b31e1def63ce210ecc063789 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Thu, 12 Oct 2023 19:37:27 +0200 Subject: [PATCH 3/4] Aggiunta PODL/ODL --- MP-TAB-SERV/Components/MachineBlock.razor | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/MP-TAB-SERV/Components/MachineBlock.razor b/MP-TAB-SERV/Components/MachineBlock.razor index 66dad6e4..775b90a4 100644 --- a/MP-TAB-SERV/Components/MachineBlock.razor +++ b/MP-TAB-SERV/Components/MachineBlock.razor @@ -181,11 +181,14 @@ else
    @($"{RecMSE.PezziProd:N0}")
    -
    ART.
    @RecMSE.CodArticolo
    +
    +
    @($"PODL{RecMSE.IdxPOdl:00000000}")
    +
    @($"ODL{RecMSE.IdxOdl:00000000}")
    +
    From c246558db024cb21009a9c70bc621f76775581e8 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Fri, 13 Oct 2023 08:40:29 +0200 Subject: [PATCH 4/4] update machblock --- MP-TAB-SERV/Components/MachineBlock.razor | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/MP-TAB-SERV/Components/MachineBlock.razor b/MP-TAB-SERV/Components/MachineBlock.razor index 775b90a4..a4c24b3a 100644 --- a/MP-TAB-SERV/Components/MachineBlock.razor +++ b/MP-TAB-SERV/Components/MachineBlock.razor @@ -185,9 +185,11 @@ else
    ART.
    @RecMSE.CodArticolo
    -
    -
    @($"PODL{RecMSE.IdxPOdl:00000000}")
    -
    @($"ODL{RecMSE.IdxOdl:00000000}")
    +
    +
    ORD.
    +
    @($"ODL{RecMSE.IdxOdl:00000000}")
    + @*
    @($"PODL{RecMSE.IdxPOdl:00000000}")
    +
    @($"ODL{RecMSE.IdxOdl:00000000}")
    *@