Avanzamento gestione manutenzione rpeventiva (NON completata...)

This commit is contained in:
Samuele Locatelli
2022-06-10 19:45:22 +02:00
parent 010ca67d6e
commit 5586dcfede
28 changed files with 458 additions and 122 deletions
+1 -1
View File
@@ -5,7 +5,7 @@
<TargetFramework>net6.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Version>1.12206.1018</Version>
<Version>1.12206.1019</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>MAPO-MONO</i>
<h4>Version: 1.12206.1018</h4>
<h4>Version: 1.12206.1019</h4>
<br /> Release Note:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
1.12206.1018
1.12206.1019
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.12206.1018</version>
<version>1.12206.1019</version>
<url>http://nexus.steamware.net/repository/SWS/MP.MONO.ADAPTER/stable/LAST/MP.Mon.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/MP.MONO.ADAPTER/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+1 -1
View File
@@ -6,7 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Platforms>AnyCPU;x86;x64</Platforms>
<Version>1.12206.1018</Version>
<Version>1.12206.1019</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>MAPO-MONO</i>
<h4>Version: 1.12206.1018</h4>
<h4>Version: 1.12206.1019</h4>
<br /> Release Note:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
1.12206.1018
1.12206.1019
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.12206.1018</version>
<version>1.12206.1019</version>
<url>http://nexus.steamware.net/repository/SWS/MP.MONO.ANALYZER/stable/LAST/MP.Mon.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/MP.MONO.ANALYZER/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+1 -1
View File
@@ -6,7 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Platforms>AnyCPU;x86;x64</Platforms>
<Version>1.12206.1018</Version>
<Version>1.12206.1019</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>MAPO-MONO</i>
<h4>Version: 1.12206.1018</h4>
<h4>Version: 1.12206.1019</h4>
<br /> Release Note:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
1.12206.1018
1.12206.1019
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.12206.1018</version>
<version>1.12206.1019</version>
<url>http://nexus.steamware.net/repository/SWS/MP.MONO.DECODER/stable/LAST/MP.Mon.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/MP.MONO.DECODER/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+114 -2
View File
@@ -17,7 +17,7 @@ namespace MP.MONO.Data.Controllers
#region Public Methods
/// <summary>
/// Recupero elenco allarmi (ultimi datop "skip")
/// Recupero elenco allarmi (ultimi dato "skip")
/// </summary>
/// <param name="MachineId"></param>
/// <param name="skipRec"></param>
@@ -328,7 +328,7 @@ namespace MP.MONO.Data.Controllers
}
/// <summary>
/// Recupero elenco allarmi (ultimi datop "skip")
/// Recupero elenco Task Manut Prev Previsti/Configurati (ultimi dato "skip")
/// </summary>
/// <param name="MachineId"></param>
/// <param name="skipRec"></param>
@@ -362,6 +362,118 @@ namespace MP.MONO.Data.Controllers
return dbResult;
}
/// <summary>
/// Recupero elenco Task Schedulati (ultimi dato "skip")
/// </summary>
/// <param name="MachineId"></param>
/// <param name="skipRec"></param>
/// <param name="numRec"></param>
/// <param name="showCompleted"></param>
/// <returns></returns>
public List<ScheduledMaintModel> SchedMaintTaskGetFilt(int MachineId, int skipRec, int numRec, bool showCompleted)
{
List<ScheduledMaintModel> dbResult = new List<ScheduledMaintModel>();
using (MapoMonoContext localDbCtx = new MapoMonoContext())
{
try
{
dbResult = localDbCtx
.DbSetSMTask
.Where(x => x.PMTaskeNav.MachineId == MachineId && (x.DtExecution == DateTime.MinValue || showCompleted))
.Include(m => m.PMTaskeNav.MachGroupNav)
.Include(m => m.CounterNav)
.Include(m => m.PMTaskeNav.MachineNav)
.Include(m => m.PMTaskeNav.TopicNav)
.Include(m => m.PMTaskeNav.UserTeamNav)
.OrderBy(x => x.PMTaskeNav.ExtIdx)
.Skip(skipRec)
.Take(numRec)
.ToList();
}
catch (Exception exc)
{
Log.Error($"Eccezione durante SchedMaintTaskGetFilt{Environment.NewLine}{exc}");
}
}
return dbResult;
}
/// <summary>
/// genera elenco Task Schedulati missing da schema + attualmente presenti...
/// </summary>
/// <param name="MachineId"></param>
/// <param name="skipRec"></param>
/// <param name="numRec"></param>
/// <param name="showCompleted"></param>
/// <returns></returns>
public async Task<bool> SchedMaintTaskCreateMissing(int MachineId)
{
bool answ = false;
using (MapoMonoContext localDbCtx = new MapoMonoContext())
{
try
{
List<PrevMaintTaskModel> missTask = new List<PrevMaintTaskModel>();
List<PrevMaintTaskModel>? allTask = localDbCtx
.DbSetPMTask
.Where(x => x.MachineId == MachineId)
.ToList();
// analizzo task per idx del PMTask
var reqTask = allTask
.Select(x => x.PMTaskId)
.ToList();
var openTask = localDbCtx
.DbSetSMTask
.Where(x => x.DtExecution == DateTime.MinValue)
.Include(m => m.PMTaskeNav)
.ToList();
var currTask = openTask
.Where(x => x.PMTaskeNav.MachineId == MachineId)
.Select(x => x.PMTaskId)
.ToList();
// elenco dei SOLI task presenti
var listTaskOk = currTask.Intersect(reqTask).ToList();
// dall'elenco di quelli originali elimino presenti --> ho elenco mancanti...
foreach (var iTask in allTask)
{
// se non nell'elenco aggiungo...
if (!listTaskOk.Exists(x => x == iTask.PMTaskId))
{
missTask.Add(iTask);
}
}
var newRecs = missTask.Select(x => new ScheduledMaintModel()
{
CCode = x.CCode,
DtCreation = DateTime.Now,
ExpiryVal = x.ExpiryVal,
PMTaskId = x.PMTaskId
}).ToList();
localDbCtx
.DbSetSMTask
.AddRange(newRecs);
// salvo
localDbCtx.SaveChanges();
answ = true;
}
catch (Exception exc)
{
Log.Error($"Eccezione durante SchedMaintTaskGetFilt{Environment.NewLine}{exc}");
}
}
await Task.Delay(1);
return answ;
}
#endregion Public Methods
#region Private Fields
+4 -2
View File
@@ -42,20 +42,22 @@ namespace MP.MONO.Data.DbModels
/// <summary>
/// DataOra di esecuzione del task
/// </summary>
public DateTime DtExecution { get; set; } = DateTime.Now;
public DateTime DtExecution { get; set; } = DateTime.MinValue;
/// <summary>
/// Codice utente che esegue il task
/// </summary>
public string UserCode { get; set; } = "";
#if false
/// <summary>
/// Task completato (se data esecuzione passata + cod user != null)
/// </summary>
public bool Completed
{
get => (DtExecution <= DateTime.Now && !string.IsNullOrEmpty(UserCode));
}
}
#endif
/// <summary>
/// DataOra stimata di expiry (dato valore expity + contatore attuale, ipotesi SEMPRE ATTIVO il conter 24/24...)
+1 -1
View File
@@ -6,7 +6,7 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Platforms>AnyCPU;x86;x64</Platforms>
<Version>1.12206.1018</Version>
<Version>1.12206.1019</Version>
</PropertyGroup>
<ItemGroup>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>MAPO-MONO</i>
<h4>Version: 1.12206.1018</h4>
<h4>Version: 1.12206.1019</h4>
<br /> Release Note:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
1.12206.1018
1.12206.1019
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.12206.1018</version>
<version>1.12206.1019</version>
<url>http://nexus.steamware.net/repository/SWS/MP.MONO.SIM/stable/LAST/MP.Mon.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/MP.MONO.SIM/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>
+1 -1
View File
@@ -8,7 +8,7 @@
<div class="card">
<div class="card-header">
<h5>Alarm History</h5>
<h5>Preventive/Programmed Maintenance's Task</h5>
</div>
<div class="card-body">
@if (ListRecords == null)
+71 -97
View File
@@ -1,26 +1,22 @@
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.MONO.UI;
using MP.MONO.UI.Shared;
using MP.MONO.UI.Components;
using MP.MONO.Data.DbModels;
namespace MP.MONO.UI.Components
{
public partial class PrevMaintTask
{
#region Protected Methods
protected override async Task OnInitializedAsync()
{
await ReloadData();
}
#endregion Protected Methods
#region Private Fields
private int _MaxRecord = 200;
private bool doSetup = false;
private List<PrevMaintTaskModel>? ListRecords = null;
// FARE!!! filtro macchina
@@ -28,88 +24,9 @@ namespace MP.MONO.UI.Components
private List<PrevMaintTaskModel>? SearchRecords = null;
#endregion Private Fields
private int _MaxRecord = 200;
private int MaxRecord
{
get
{
return _MaxRecord;
}
set
{
if (_MaxRecord != value)
{
_MaxRecord = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
private int totalCount
{
get
{
int answ = 0;
if (SearchRecords != null)
{
answ = SearchRecords.Count;
}
return answ;
}
}
protected void ForceReload(int newNum)
{
numRecord = newNum;
}
protected void ForceReloadPage(int newNum)
{
currPage = newNum;
}
protected override async Task OnInitializedAsync()
{
await ReloadData();
}
protected async Task ReloadData()
{
isLoading = true;
ListRecords = null;
await Task.Delay(1);
SearchRecords = await MMDataService.PrevMaintTaskGetFilt(MachineId, 0, MaxRecord);
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
await Task.Delay(1);
await Task.Delay(1);
isLoading = false;
}
protected async Task reloadFromMessage()
{
isLoading = true;
ListRecords = null;
await Task.Delay(300);
await ReloadData();
await Task.Delay(1);
await InvokeAsync(() =>
{
StateHasChanged();
});
}
protected bool doSetup = false;
protected async Task SetupAlarms()
{
await Task.Delay(1);
doSetup = !doSetup;
await Task.Delay(1);
}
#region Private Properties
private int _currPage { get; set; } = 1;
@@ -131,6 +48,23 @@ namespace MP.MONO.UI.Components
private bool isLoading { get; set; } = false;
private int MaxRecord
{
get
{
return _MaxRecord;
}
set
{
if (_MaxRecord != value)
{
_MaxRecord = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
private int numRecord
{
get => _numRecord;
@@ -145,5 +79,45 @@ namespace MP.MONO.UI.Components
}
}
private int totalCount
{
get
{
int answ = 0;
if (SearchRecords != null)
{
answ = SearchRecords.Count;
}
return answ;
}
}
#endregion Private Properties
#region Private Methods
private void ForceReload(int newNum)
{
numRecord = newNum;
}
private void ForceReloadPage(int newNum)
{
currPage = newNum;
}
private async Task ReloadData()
{
isLoading = true;
ListRecords = null;
await Task.Delay(1);
SearchRecords = await MMDataService.PrevMaintTaskGetFilt(MachineId, 0, MaxRecord);
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
await Task.Delay(1);
await Task.Delay(1);
isLoading = false;
}
#endregion Private Methods
}
}
@@ -0,0 +1,76 @@
@using MP.MONO.Data
@using MP.MONO.UI.Components
@using MP.MONO.Core.DTO
@using MP.MONO.UI.Data
@inject CurrentDataService MMDataService
<div class="card">
<div class="card-header">
<div class="d-flex justify-content-between">
<div class="p-2">
<h5>Scheduled Maintenance's Task</h5>
</div>
<div class="p-2">
<div class="form-check form-check-sm form-switch" title="Show Closed">
<input class="form-check-input" type="checkbox" id="filClosed" name="filtShowCompleted" value="@showCompleted" unchecked @onclick="() => ToggleCompleted()">
<label class="form-check-label" for="filClosed">Show Completed</label>
</div>
<button class="btn btn-primary" @onclick="() => RegenTask()">Refresh <i class="bi bi-tools"></i></button>
</div>
</div>
</div>
<div class="card-body">
@if (ListRecords == null)
{
<LoadingData></LoadingData>
}
else if (totalCount == 0)
{
<div class="alert alert-warning text-center display-4">No record found</div>
}
else
{
<table class="table table-sm table-striped table-responsive-lg small">
<thead>
<tr>
<th>ID</th>
<th>Created</th>
<th>Topic</th>
<th>Machine Group</th>
<th>Rem. Hours</th>
<th>Team in Charge</th>
<th>Counter Var</th>
<th>Job Description</th>
<th></th>
</tr>
</thead>
<tbody>
@foreach (var record in ListRecords)
{
<tr>
<td>@record.PMTaskeNav.ExtIdx</td>
<td>@record.DtCreation.ToString("yyyy-MM-dd HH:mm:ss")</td>
<td>@record.PMTaskeNav.TopicNav.Description</td>
<td>@record.PMTaskeNav.MachGroupNav.Description</td>
<td class="text-end"><b>@record.RemainingHours</b>/@record.ExpiryVal</td>
<td>@record.PMTaskeNav.UserTeamNav.Description</td>
<td>@record.CounterNav.Description</td>
<td>@record.PMTaskeNav.JobDescription</td>
<td>
@*..buttons...*@
</td>
</tr>
}
</tbody>
</table>
}
</div>
<div class="card-footer py-0">
<DataPager PageSize="numRecord" currPage="currPage" numRecordChanged="ForceReload" numPageChanged="ForceReloadPage" totalCount="totalCount" showLoading="isLoading" />
</div>
</div>
@@ -0,0 +1,149 @@
using MP.MONO.Data.DbModels;
namespace MP.MONO.UI.Components
{
public partial class SchedMaintTask
{
#region Protected Methods
protected override async Task OnInitializedAsync()
{
await ReloadData();
}
#endregion Protected Methods
#region Private Fields
private int _MaxRecord = 200;
private bool _showCompleted = false;
private List<ScheduledMaintModel>? ListRecords = null;
// FARE!!! filtro macchina
private int MachineId = 1;
private List<ScheduledMaintModel>? SearchRecords = null;
#endregion Private Fields
#region Private Properties
private int _currPage { get; set; } = 1;
private int _numRecord { get; set; } = 10;
private int currPage
{
get => _currPage;
set
{
if (_currPage != value)
{
_currPage = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
private bool isLoading { get; set; } = false;
private int MaxRecord
{
get
{
return _MaxRecord;
}
set
{
if (_MaxRecord != value)
{
_MaxRecord = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
private int numRecord
{
get => _numRecord;
set
{
if (_numRecord != value)
{
_numRecord = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
}
private bool showCompleted
{
get
{
return _showCompleted;
}
set
{
_showCompleted = value;
var pUpd = Task.Run(async () => await ReloadData());
pUpd.Wait();
}
}
private int totalCount
{
get
{
int answ = 0;
if (SearchRecords != null)
{
answ = SearchRecords.Count;
}
return answ;
}
}
#endregion Private Properties
#region Private Methods
private void ForceReload(int newNum)
{
numRecord = newNum;
}
private void ForceReloadPage(int newNum)
{
currPage = newNum;
}
private async Task RegenTask()
{
await MMDataService.createMissingSchedTask(MachineId);
await ReloadData();
}
private async Task ReloadData()
{
isLoading = true;
ListRecords = null;
await Task.Delay(1);
SearchRecords = await MMDataService.SchedMaintTaskGetFilt(MachineId, 0, MaxRecord, showCompleted);
ListRecords = SearchRecords.Skip(numRecord * (currPage - 1)).Take(numRecord).ToList();
await Task.Delay(1);
await Task.Delay(1);
isLoading = false;
}
private async Task ToggleCompleted()
{
await Task.Delay(1);
showCompleted = !showCompleted;
await Task.Delay(1);
}
#endregion Private Methods
}
}
+22
View File
@@ -85,6 +85,17 @@ namespace MP.MONO.UI.Data
return await Task.FromResult(dbResult);
}
public async Task<bool> createMissingSchedTask(int machineId)
{
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
bool answ = await dbController.SchedMaintTaskCreateMissing(machineId);
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Trace($"Effettuata chiamata a createMissingSchedTask: {ts.TotalMilliseconds} ms");
return await Task.FromResult(answ);
}
public async Task<List<DataLogModel>> DataLogGetFilt(int machineId, string fluxType, DateTime inizio, DateTime fine)
{
Stopwatch stopWatch = new Stopwatch();
@@ -323,6 +334,17 @@ namespace MP.MONO.UI.Data
return await Task.FromResult(dbResult);
}
public async Task<List<ScheduledMaintModel>> SchedMaintTaskGetFilt(int machineId, int skipRec, int numRec, bool showCompleted)
{
Stopwatch stopWatch = new Stopwatch();
stopWatch.Start();
List<ScheduledMaintModel>? dbResult = dbController.SchedMaintTaskGetFilt(machineId, skipRec, numRec, showCompleted);
stopWatch.Stop();
TimeSpan ts = stopWatch.Elapsed;
Log.Trace($"Effettuata lettura da DB SchedMaintTaskGetFilt: {ts.TotalMilliseconds} ms");
return await Task.FromResult(dbResult);
}
public async Task<bool> setAlarmSetup(List<BaseAlarmConf> alarmConf)
{
bool answ = false;
+1 -1
View File
@@ -5,7 +5,7 @@
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<Platforms>AnyCPU;x86;x64</Platforms>
<Version>1.12206.1018</Version>
<Version>1.12206.1019</Version>
</PropertyGroup>
<ItemGroup>
+1
View File
@@ -23,6 +23,7 @@
}
else
{
<SchedMaintTask></SchedMaintTask>
<MaintOverview></MaintOverview>
}
</div>
+1 -1
View File
@@ -1,6 +1,6 @@
<body>
<i>MAPO-MONO</i>
<h4>Version: 1.12206.1018</h4>
<h4>Version: 1.12206.1019</h4>
<br /> Release Note:
<ul>
<li>
+1 -1
View File
@@ -1 +1 @@
1.12206.1018
1.12206.1019
+1 -1
View File
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<item>
<version>1.12206.1018</version>
<version>1.12206.1019</version>
<url>http://nexus.steamware.net/repository/SWS/MP.MONO.UI/stable/LAST/MP.Mon.zip</url>
<changelog>http://nexus.steamware.net/repository/SWS/MP.MONO.UI/stable/LAST/ChangeLog.html</changelog>
<mandatory>false</mandatory>