90e4e18ce5
- fix filtro in PODL-KIT
212 lines
6.8 KiB
C#
212 lines
6.8 KiB
C#
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.AspNetCore.Components.Authorization;
|
|
using MP.Data.DbModels;
|
|
using MP.SPEC.Data;
|
|
using System;
|
|
using System.Reflection.PortableExecutable;
|
|
|
|
namespace MP.SPEC.Components.ProdKit
|
|
{
|
|
public partial class Manager
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public SelectXdlParams ActFilt { get; set; } = new SelectXdlParams();
|
|
|
|
[Parameter]
|
|
public bool DoAddNew { get; set; } = false;
|
|
|
|
[Parameter]
|
|
public EventCallback<SelectXdlParams> EC_FiltUpdated { get; set; }
|
|
|
|
[Parameter]
|
|
public EventCallback<bool> EC_IsComposing { get; set; }
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Properties
|
|
|
|
[Inject]
|
|
protected AuthenticationStateProvider AuthStateProv { get; set; } = null!;
|
|
|
|
[Inject]
|
|
protected MpDataService MDService { get; set; } = null!;
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected override async Task OnInitializedAsync()
|
|
{
|
|
isLoading = false;
|
|
if (string.IsNullOrEmpty(padCodXdl))
|
|
{
|
|
padCodXdl = MDService.ConfigTryGet("padCodXdl");
|
|
}
|
|
currPodlRec = null;
|
|
// recupero user...
|
|
var authState = await AuthStateProv.GetAuthenticationStateAsync();
|
|
var user = authState.User;
|
|
if (user.Identity != null && user.Identity.IsAuthenticated)
|
|
{
|
|
userNameFull = $"{user.Identity.Name}";
|
|
if (!string.IsNullOrEmpty(userNameFull))
|
|
{
|
|
var splitName = userNameFull.Split(@"\");
|
|
if (splitName.Length > 1)
|
|
{
|
|
domainName = splitName[0];
|
|
userName = splitName[1];
|
|
}
|
|
}
|
|
}
|
|
|
|
// Verifico chiave Kit o la rigenero
|
|
if (string.IsNullOrEmpty(keyFilt))
|
|
{
|
|
calcKitCode();
|
|
}
|
|
DateTime oggi = DateTime.Today;
|
|
}
|
|
|
|
protected override void OnParametersSet()
|
|
{
|
|
//base.OnParametersSet();
|
|
ReloadData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Salvataggio su Tab WIP dei dati del PODL ricevuto...
|
|
/// </summary>
|
|
/// <param name="selRec"></param>
|
|
protected async Task SavePodl(PODLExpModel selRec)
|
|
{
|
|
if (currPodlRec == null || currPodlRec.IdxPromessa != selRec.IdxPromessa)
|
|
{
|
|
if (selRec != null)
|
|
{
|
|
// chiamo tentativo update!
|
|
WipSetupKitModel newRec = new WipSetupKitModel()
|
|
{
|
|
KeyFilt = keyFilt,
|
|
CodArt = selRec.CodArticolo,
|
|
CodOrd = selRec.KeyRichiesta,
|
|
IdxPODL = selRec.IdxPromessa,
|
|
DescArt = selRec.DescArticolo,
|
|
Qta = selRec.NumPezzi,
|
|
DataIns = DateTime.Now
|
|
};
|
|
bool fatto = MDService.WipKitUpsert(newRec);
|
|
// se non già impostato riporto impostazione filtro con macchina e gruppo ricevuto...
|
|
ActFilt.IdxMacchina = selRec.IdxMacchina;
|
|
ActFilt.CodReparto = selRec.CodGruppo;
|
|
await EC_FiltUpdated.InvokeAsync(ActFilt);
|
|
}
|
|
currPodlRec = selRec;
|
|
isComposing = true;
|
|
await EC_IsComposing.InvokeAsync(true);
|
|
|
|
// rileggo
|
|
ReloadData();
|
|
}
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private string codArtKit = "";
|
|
|
|
/// <summary>
|
|
/// Record PODL corrente da inserire
|
|
/// </summary>
|
|
private PODLExpModel? currPodlRec = null;
|
|
|
|
private string domainName = "";
|
|
private bool isComposing;
|
|
private bool isLoading = false;
|
|
private string keyFilt = "";
|
|
private List<IstanzeKitModel> listIKP = new List<IstanzeKitModel>();
|
|
private List<PODLExpModel> listPOdlAct = new List<PODLExpModel>();
|
|
private List<PODLExpModel> listPOdlCheck = new List<PODLExpModel>();
|
|
private List<TksScoreModel> listTSM = new List<TksScoreModel>();
|
|
private List<WipSetupKitModel> listWSM = new List<WipSetupKitModel>();
|
|
private string padCodXdl = "00000";
|
|
private string userName = "";
|
|
private string userNameFull = "";
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Properties
|
|
|
|
private string KPColClass
|
|
{
|
|
get => DoAddNew ? "col-6" : "col-12";
|
|
}
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private void calcKitCode()
|
|
{
|
|
DateTime adesso = DateTime.Now;
|
|
keyFilt = $"KIT_{userName}_{adesso:yyMMdd}_{adesso:HHmmss}";
|
|
}
|
|
|
|
private async Task ForceReloadData(bool doReload)
|
|
{
|
|
isLoading = true;
|
|
listWSM = new List<WipSetupKitModel>();
|
|
// se richiesto resetto KIT...
|
|
if (doReload)
|
|
{
|
|
calcKitCode();
|
|
}
|
|
ReloadData();
|
|
isComposing = false;
|
|
await EC_IsComposing.InvokeAsync(false);
|
|
}
|
|
|
|
private async Task SetHasOdl(bool setHasOdl)
|
|
{
|
|
ActFilt.HasOdl = setHasOdl;
|
|
await EC_FiltUpdated.InvokeAsync(ActFilt);
|
|
ReloadData();
|
|
}
|
|
|
|
private async Task ForceReset()
|
|
{
|
|
// svuoto filtro
|
|
ActFilt.CodReparto = "*";
|
|
ActFilt.IdxMacchina = "*";
|
|
// forzo rlettura
|
|
await ForceReloadData(true);
|
|
await EC_FiltUpdated.InvokeAsync(ActFilt);
|
|
}
|
|
|
|
private void ReloadData()
|
|
{
|
|
listPOdlCheck = new List<PODLExpModel>();
|
|
listPOdlAct = MDService.POdlListGetFilt(ActFilt.HasOdl, ActFilt.CodFase, ActFilt.IdxMacchina, ActFilt.CodReparto, ActFilt.DtStart, ActFilt.DtEnd);
|
|
listWSM = MDService.WipKitFilt(keyFilt);
|
|
listTSM = MDService.TksScore(keyFilt, 1000, true);
|
|
listIKP = MDService.IstKitFilt("", "");
|
|
// verifico se ho score 100%...
|
|
var recMaxScore = listTSM
|
|
.Where(x => x.TotalScore == 1)
|
|
.OrderByDescending(x => x.TotalScore)
|
|
.FirstOrDefault();
|
|
codArtKit = recMaxScore != null ? recMaxScore.CodArtParent : "";
|
|
// continuo con PODL
|
|
if (!string.IsNullOrEmpty(codArtKit))
|
|
{
|
|
listPOdlCheck = MDService.ListPODL_ByCodArt(codArtKit, true);
|
|
}
|
|
isLoading = false;
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |