Aggiunto ricalcolo preliminare giornata
This commit is contained in:
@@ -100,8 +100,13 @@
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<div class="col-12 statsContainer m-2 mt-0">
|
||||
<button class="btn btn-success" @onclick="@CloseDet">Close</button>
|
||||
<div class="col-4 my-2">
|
||||
<button class="btn btn-warning w-100" @onclick="() => RecalcDay()"><i class="fa-solid fa-calculator"></i> Recalc</button>
|
||||
</div>
|
||||
<div class="col-4 my-2">
|
||||
</div>
|
||||
<div class="col-4 my-2">
|
||||
<button class="btn btn-info w-100" @onclick="@CloseDet"><i class="fa-solid fa-xmark"></i> Close</button>
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Microsoft.AspNetCore.Components;
|
||||
using Microsoft.JSInterop;
|
||||
using MP.Core.DTO;
|
||||
using MP.Data.DbModels;
|
||||
using MP.Data.Services;
|
||||
@@ -47,7 +48,10 @@ namespace MP_TAB3.Components
|
||||
// filtra dati odierni x tab editabile...
|
||||
if (ListPeriod != null && ListPeriod.Count > 0)
|
||||
{
|
||||
ListDay = ListPeriod.Where(x => x.InizioStato.Date == dtSel).ToList();
|
||||
ListDay = ListPeriod
|
||||
.Where(x => x.InizioStato.Date == dtSel)
|
||||
.OrderBy(x => x.IdxInsMan)
|
||||
.ToList();
|
||||
}
|
||||
#if false
|
||||
MService.targetDate = dtSel;
|
||||
@@ -138,15 +142,78 @@ namespace MP_TAB3.Components
|
||||
if (EditRecord != null)
|
||||
{
|
||||
// sistemo i dati...
|
||||
var dayElap = EditRecord.InizioStato.Subtract(EditRecord.InizioStato.Date);
|
||||
EditRecord.InizioStato = dtCurr.Date.Add(dayElap);
|
||||
EditRecord.MinProd = EditRecord.TCiclo * EditRecord.PzBuoni;
|
||||
EditRecord.FineStato = EditRecord.InizioStato.AddMinutes((double)EditRecord.MinProd);
|
||||
// lancio salvataggio sul DB
|
||||
await TabDServ.InsManUpsert(EditRecord);
|
||||
EditRecord = null;
|
||||
if (!timeInfoOk())
|
||||
{
|
||||
int numChange = await DoRecalcDay();
|
||||
}
|
||||
// rileggo i dati...
|
||||
ReloadData();
|
||||
}
|
||||
}
|
||||
[Inject]
|
||||
protected IJSRuntime JSRuntime { get; set; } = null!;
|
||||
|
||||
private bool timeInfoOk()
|
||||
{
|
||||
bool allOk = false;
|
||||
if (ListDTO != null)
|
||||
{
|
||||
var dayDto = ListDTO.FirstOrDefault(x => x.DataRif == dtCurr.Date);
|
||||
if (dayDto != null && ListDay != null)
|
||||
{
|
||||
var firstRec = ListDay.OrderBy(x => x.InizioStato).FirstOrDefault();
|
||||
var lastRec = ListDay.OrderByDescending(x => x.InizioStato).FirstOrDefault();
|
||||
var deltaMins = lastRec!.FineStato!.Value.Subtract(firstRec!.InizioStato).TotalMinutes;
|
||||
allOk = Math.Abs(deltaMins - (double)dayDto.MinProdTot) < 1;
|
||||
}
|
||||
}
|
||||
return allOk;
|
||||
}
|
||||
|
||||
private async Task<int> RecalcDay()
|
||||
{
|
||||
if (!await JSRuntime.InvokeAsync<bool>("confirm", $"Sicuro di voler ricalcolare i dati della giornata?"))
|
||||
return 0;
|
||||
|
||||
return await DoRecalcDay();
|
||||
}
|
||||
|
||||
private async Task<int> DoRecalcDay()
|
||||
{
|
||||
int numChange = 0;
|
||||
// prendo i dati odierni, e uno x uno ciclo e sistemo...
|
||||
DateTime lastDate = dtCurr.Date;
|
||||
List<InsManualiModel> ListChange = new List<InsManualiModel>();
|
||||
if (ListDay != null && ListDay.Count > 0)
|
||||
{
|
||||
foreach (var item in ListDay)
|
||||
{
|
||||
if (item.InizioStato < lastDate)
|
||||
{
|
||||
item.InizioStato = lastDate;
|
||||
}
|
||||
// controllo se la data fine è ok...
|
||||
if (!item.FineStato.HasValue || Math.Abs(item.InizioStato.AddMinutes((double)item.MinProd).Subtract(item.FineStato.Value).TotalMinutes) > 1)
|
||||
{
|
||||
item.FineStato = item.InizioStato.AddMinutes((double)item.MinProd);
|
||||
numChange++;
|
||||
ListChange.Add(item);
|
||||
}
|
||||
lastDate = item.FineStato.Value;
|
||||
}
|
||||
// salvo tutto
|
||||
await TabDServ.InsManUpsert(ListChange);
|
||||
}
|
||||
return numChange;
|
||||
}
|
||||
|
||||
|
||||
private double NumGreen = 25;
|
||||
private double NumYellow = 5;
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
<PropertyGroup>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<Nullable>enable</Nullable>
|
||||
<Version>6.16.2504.112</Version>
|
||||
<Version>6.16.2504.115</Version>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<RootNamespace>MP_TAB3</RootNamespace>
|
||||
</PropertyGroup>
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<body>
|
||||
<i>Modulo MAPOSPEC </i>
|
||||
<h4>Versione: 6.16.2504.112</h4>
|
||||
<h4>Versione: 6.16.2504.115</h4>
|
||||
<br /> Note di rilascio:
|
||||
<ul>
|
||||
<li>
|
||||
|
||||
@@ -1 +1 @@
|
||||
6.16.2504.112
|
||||
6.16.2504.115
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<item>
|
||||
<version>6.16.2504.112</version>
|
||||
<version>6.16.2504.115</version>
|
||||
<url>https://nexus.steamware.net/repository/SWS/MP-TAB3/stable/LAST/MP-TAB3.zip</url>
|
||||
<changelog>https://nexus.steamware.net/repository/SWS/MP-TAB3/stable/LAST/ChangeLog.html</changelog>
|
||||
<mandatory>false</mandatory>
|
||||
|
||||
@@ -708,6 +708,50 @@ namespace MP.Data.Controllers
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Esegue salvataggio lista records + svuotamento cache
|
||||
/// </summary>
|
||||
/// <param name="currRecord"></param>
|
||||
public bool InsManUpsert(List<InsManualiModel> listRecord)
|
||||
{
|
||||
bool fatto = false;
|
||||
using (var dbCtx = new MoonProContext(_configuration))
|
||||
{
|
||||
foreach (var currRecord in listRecord)
|
||||
{
|
||||
var actRec = dbCtx
|
||||
.DbSetInsManuali
|
||||
.Where(x => currRecord.IdxInsMan > 0 && x.IdxInsMan == currRecord.IdxInsMan)
|
||||
.FirstOrDefault();
|
||||
// se ci fosse aggiorno...
|
||||
if (actRec == null)
|
||||
{
|
||||
dbCtx
|
||||
.DbSetInsManuali
|
||||
.Add(currRecord);
|
||||
}
|
||||
else
|
||||
{
|
||||
actRec.CodArticolo = currRecord.CodArticolo;
|
||||
actRec.FineStato = currRecord.FineStato;
|
||||
actRec.IdxMacchina = currRecord.IdxMacchina;
|
||||
actRec.IdxTipoEv = currRecord.IdxTipoEv;
|
||||
actRec.Imported = currRecord.Imported;
|
||||
actRec.InizioStato = currRecord.InizioStato;
|
||||
actRec.KeyRichiesta = currRecord.KeyRichiesta;
|
||||
actRec.MatrOpr = currRecord.MatrOpr;
|
||||
actRec.MinProd = currRecord.MinProd;
|
||||
actRec.PzBuoni = currRecord.PzBuoni;
|
||||
actRec.TCiclo = currRecord.TCiclo;
|
||||
dbCtx.Entry(actRec).State = EntityState.Modified;
|
||||
}
|
||||
}
|
||||
var res = dbCtx.SaveChanges();
|
||||
fatto = res != 0;
|
||||
}
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Elenco PODL macchina
|
||||
/// </summary>
|
||||
|
||||
@@ -970,6 +970,20 @@ namespace MP.Data.Services
|
||||
await ExecFlushRedisPattern(pattern);
|
||||
return fatto;
|
||||
}
|
||||
/// <summary>
|
||||
/// Esegue salvataggio record + svuotamento cache
|
||||
/// </summary>
|
||||
/// <param name="listRecord"></param>
|
||||
public async Task<bool> InsManUpsert(List<InsManualiModel> listRecord)
|
||||
{
|
||||
bool fatto = false;
|
||||
// salvo
|
||||
fatto = dbTabController.InsManUpsert(listRecord);
|
||||
// svuoto cache
|
||||
RedisValue pattern = $"{redisBaseKey}:InsMan";
|
||||
await ExecFlushRedisPattern(pattern);
|
||||
return fatto;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Recupero info IOB x TAB (da info registrate IOB-WIN--> MP-IO)
|
||||
|
||||
Reference in New Issue
Block a user