From f099a8d48e54e473fef41d338c0f162c3c332c55 Mon Sep 17 00:00:00 2001 From: Samuele Locatelli Date: Tue, 7 Feb 2023 17:17:53 +0100 Subject: [PATCH] Inizio modifiche PODL x gestione ricette --- MP.SPEC/Components/CmpFooter.razor.cs | 9 +- MP.SPEC/Components/ListPODL.razor | 118 +++++++++++++++----------- MP.SPEC/Components/ListPODL.razor.cs | 92 +++++++++++++------- MP.SPEC/Data/MpDataService.cs | 36 ++++++++ MP.SPEC/MP.SPEC.csproj | 5 +- MP.SPEC/Pages/PODL.razor | 18 ---- MP.SPEC/Pages/PODL.razor.cs | 1 + MP.SPEC/Resources/ChangeLog.html | 2 +- MP.SPEC/Resources/VersNum.txt | 2 +- MP.SPEC/Resources/manifest.xml | 2 +- 10 files changed, 183 insertions(+), 102 deletions(-) diff --git a/MP.SPEC/Components/CmpFooter.razor.cs b/MP.SPEC/Components/CmpFooter.razor.cs index 45a9cccf..1bfe95fb 100644 --- a/MP.SPEC/Components/CmpFooter.razor.cs +++ b/MP.SPEC/Components/CmpFooter.razor.cs @@ -8,9 +8,12 @@ namespace MP.SPEC.Components public void Dispose() { - aTimer.Elapsed -= ElapsedTimer; - aTimer.Stop(); - aTimer.Dispose(); + if (aTimer != null) + { + aTimer.Elapsed -= ElapsedTimer; + aTimer.Stop(); + aTimer.Dispose(); + } } public void ElapsedTimer(object? source, System.Timers.ElapsedEventArgs e) diff --git a/MP.SPEC/Components/ListPODL.razor b/MP.SPEC/Components/ListPODL.razor index 5500e381..b790af50 100644 --- a/MP.SPEC/Components/ListPODL.razor +++ b/MP.SPEC/Components/ListPODL.razor @@ -12,7 +12,7 @@ else if (totalCount == 0) else {
-
+
@@ -25,11 +25,13 @@ else - - - @**@ - - + @if (!showRecipe) + { + + + + + } @@ -37,27 +39,39 @@ else { - - - @**@ - - + @if (!showRecipe) + { + + + + + } }
Cod Articolo Fase Macchina Info ciclo Note Att Macchina Info ciclo Att
- - @if (record.IdxOdl == 0) + @if (!showRecipe) { - @if (canStartOdl(record.IdxMacchina)) + + @if (record.IdxOdl == 0) { - + @if (canStartOdl(record.IdxMacchina)) + { + + } + else + { + + } + @if (canStartOdl(record.IdxMacchina)) + { + + } + else + { + + } } - else + } + @if (MachineWithRecipe) + { + @if (machineHasRecipe(record.IdxMacchina).Result) { - - } - @if (canStartOdl(record.IdxMacchina)) - { - - } - else - { - } } @@ -100,36 +114,44 @@ else } - @record.IdxMacchina -
@record.Nome
-
-
N° pezzi: @record.NumPezzi
-
T. Ciclo: @record.Tcassegnato.ToString("N3")
-
@record.Note - @if (@record.Attivabile) - { - - } - else - { - - } - - @if (POdlDelEnabled(record.IdxOdl)) - { - - } - + @record.IdxMacchina +
@record.Nome
+
+
N° pezzi: @record.NumPezzi
+
T. Ciclo: @record.Tcassegnato.ToString("N3")
+
+ @if (@record.Attivabile) + { + + } + else + { + + } + + @if (POdlDelEnabled(record.IdxOdl)) + { + + } +
+ @if (showRecipe) + { +
+ dettaglio ricetta +
+ }
} diff --git a/MP.SPEC/Components/ListPODL.razor.cs b/MP.SPEC/Components/ListPODL.razor.cs index f481fb79..1bb09f32 100644 --- a/MP.SPEC/Components/ListPODL.razor.cs +++ b/MP.SPEC/Components/ListPODL.razor.cs @@ -59,6 +59,12 @@ namespace MP.SPEC.Components #region Protected Properties + protected string header + { + get => actFilter.Header; + set => actFilter.Header = value; + } + [Inject] protected IJSRuntime JSRuntime { get; set; } = null!; @@ -104,8 +110,9 @@ namespace MP.SPEC.Components protected override async Task OnInitializedAsync() { - //await FilterChanged.InvokeAsync(actFilter); ListStati = await MDService.AnagStatiComm(); + var strMachRecipe = await MDService.tryGetConfig("MachineWithRecipe"); + bool.TryParse(strMachRecipe, out MachineWithRecipe); } protected override async Task OnParametersSetAsync() @@ -136,6 +143,7 @@ namespace MP.SPEC.Components protected async Task resetSel() { currRecord = null; + showRecipe = false; await RecordSel.InvokeAsync(null); } @@ -196,6 +204,12 @@ namespace MP.SPEC.Components } } + protected void doShowRecipe(PODLExpModel selRec) + { + showRecipe = true; + currRecord = selRec; + } + protected async Task UpdateData() { currRecord = null; @@ -207,10 +221,15 @@ namespace MP.SPEC.Components #region Private Fields private static Logger Log = LogManager.GetCurrentClassLogger(); + private PODLExpModel? currRecord = null; + private List? ListRecords; + private List? ListStati; + private bool MachineWithRecipe = false; + /// /// scadenza validità lista ODL correnti /// @@ -223,35 +242,12 @@ namespace MP.SPEC.Components private List? SearchRecords; + private bool showRecipe = false; + #endregion Private Fields #region Private Properties - - private DateTime selDtStart - { - get => actFilter.DtStart; - set - { - if (!actFilter.DtStart.Equals(value)) - { - actFilter.DtStart = value; - currPage = 1; - } - } - } - private DateTime selDtEnd - { - get => actFilter.DtEnd; - set - { - if (!actFilter.DtEnd.Equals(value)) - { - actFilter.DtEnd = value; - currPage = 1; - } - } - } private int _totalCount { get; set; } = 0; private int currPage @@ -267,6 +263,7 @@ namespace MP.SPEC.Components } private bool isLoading { get; set; } = false; + private SelectXdlParams lastFilter { get; set; } = new SelectXdlParams() { CurrPage = -1 }; private string macchina @@ -275,6 +272,11 @@ namespace MP.SPEC.Components set => actFilter.IdxMacchina = value; } + private string mainCss + { + get => showRecipe ? "col-8" : "col-12"; + } + private int numRecord { get => actFilter.NumRec; @@ -292,6 +294,32 @@ namespace MP.SPEC.Components get => string.IsNullOrEmpty(actFilter.SearchVal) ? "*" : actFilter.SearchVal; } + private DateTime selDtEnd + { + get => actFilter.DtEnd; + set + { + if (!actFilter.DtEnd.Equals(value)) + { + actFilter.DtEnd = value; + currPage = 1; + } + } + } + + private DateTime selDtStart + { + get => actFilter.DtStart; + set + { + if (!actFilter.DtStart.Equals(value)) + { + actFilter.DtStart = value; + currPage = 1; + } + } + } + private string StatoSel { get => actFilter.CodFase; @@ -385,10 +413,16 @@ namespace MP.SPEC.Components answ = !odlCurrList.Contains(idxMacchina); return answ; } - protected string header + + /// + /// Verifica se la macchina abbia associata una ricetta (template) + /// + /// + /// + private async Task machineHasRecipe(string idxMacchina) { - get => actFilter.Header; - set => actFilter.Header = value; + string recipePath = await MDService.MacchineRecipe(idxMacchina); + return !string.IsNullOrEmpty(recipePath); } /// diff --git a/MP.SPEC/Data/MpDataService.cs b/MP.SPEC/Data/MpDataService.cs index d8925e97..c583d9c8 100644 --- a/MP.SPEC/Data/MpDataService.cs +++ b/MP.SPEC/Data/MpDataService.cs @@ -886,6 +886,41 @@ namespace MP.SPEC.Data return result; } + /// + /// Verifica se la macchina abbia un codice ricetta associato + /// + /// + /// + public async Task MacchineRecipe(string idxMacchina) + { + string? result = ""; + Stopwatch stopWatch = new Stopwatch(); + stopWatch.Start(); + string readType = "DB"; + string currKey = $"{redisMacRecipe}:{idxMacchina}"; + // cerco in redis dato valore sel macchina... + RedisValue rawData = redisDb.StringGet(currKey); + if (rawData.HasValue) + { + result = JsonConvert.DeserializeObject($"{rawData}"); + readType = "REDIS"; + } + else + { + //recupero elenco macchine... + var machineList = await MacchineGetFilt("*"); + var currMach = machineList.Where(x => x.IdxMacchina == idxMacchina).FirstOrDefault(); + result = currMach != null ? currMach.RecipePath : null; + // serializzo e salvo... + rawData = JsonConvert.SerializeObject(result); + redisDb.StringSet(currKey, rawData, getRandTOut(redisLongTimeCache)); + } + stopWatch.Stop(); + TimeSpan ts = stopWatch.Elapsed; + Log.Debug($"MacchineRecipe | Read from {readType}: {ts.TotalMilliseconds}ms"); + return result ?? ""; + } + /// /// Elenco id Macchine che abbiano dati FLuxLog, nel periodo indicato /// @@ -1436,6 +1471,7 @@ namespace MP.SPEC.Data private const string redisMacByFlux = redisBaseAddrSpec + "Cache:MacByFlux"; private const string redisMacList = redisBaseAddrSpec + "Cache:MacList"; + private const string redisMacRecipe = redisBaseAddrSpec + "Cache:Recipe"; private const string redisOdlByBatch = redisXdlData + "OdlByBatch"; private const string redisOdlCurrByMac = redisXdlData + "OdlByMac"; diff --git a/MP.SPEC/MP.SPEC.csproj b/MP.SPEC/MP.SPEC.csproj index f6142ab5..b174410e 100644 --- a/MP.SPEC/MP.SPEC.csproj +++ b/MP.SPEC/MP.SPEC.csproj @@ -5,7 +5,7 @@ enable enable MP.SPEC - 6.16.2302.315 + 6.16.2302.717 @@ -39,6 +39,9 @@ + + PreserveNewest + Always diff --git a/MP.SPEC/Pages/PODL.razor b/MP.SPEC/Pages/PODL.razor index 1c4eb2c1..ff9d7e44 100644 --- a/MP.SPEC/Pages/PODL.razor +++ b/MP.SPEC/Pages/PODL.razor @@ -80,17 +80,9 @@ { foreach (var item in ListArticoli) { - @* @if (item.CodArticolo == currRecordControlli.CodArticolo) - { - - else - { - } - }*@ } } - }
@@ -135,7 +127,6 @@ @if (currGruppoSel != null) { - @* *@ } @@ -153,15 +144,6 @@ { @if (!item.Descrizione.Contains("NEW Descrizione")) { - - @*if (item.IdxMacchina == currRecordControlli.IdxMacchina) - { - - } - else - { - } - *@ } } diff --git a/MP.SPEC/Pages/PODL.razor.cs b/MP.SPEC/Pages/PODL.razor.cs index cf8fe54f..8fd268a4 100644 --- a/MP.SPEC/Pages/PODL.razor.cs +++ b/MP.SPEC/Pages/PODL.razor.cs @@ -404,6 +404,7 @@ namespace MP.SPEC.Pages #region Private Methods + /// /// Chiama metodo x chiedere sync DB /// diff --git a/MP.SPEC/Resources/ChangeLog.html b/MP.SPEC/Resources/ChangeLog.html index d5e65297..bb9f2529 100644 --- a/MP.SPEC/Resources/ChangeLog.html +++ b/MP.SPEC/Resources/ChangeLog.html @@ -1,6 +1,6 @@ Modulo MAPOSPEC -

Versione: 6.16.2302.315

+

Versione: 6.16.2302.717


Note di rilascio: