254 lines
7.2 KiB
C#
254 lines
7.2 KiB
C#
using EgwCoreLib.Lux.Core.Generic;
|
|
using EgwCoreLib.Lux.Core.RestPayload;
|
|
using EgwCoreLib.Lux.Data.DbModel.Production;
|
|
using EgwCoreLib.Lux.Data.DbModel.Sales;
|
|
using EgwCoreLib.Lux.Data.Services.General;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Microsoft.JSInterop;
|
|
|
|
namespace Lux.UI.Components.Compo.WorkLoad
|
|
{
|
|
public partial class TimeEstim
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public List<ProductionGroupModel>? AllProdGroup { get; set; }
|
|
|
|
[Parameter]
|
|
public WorkLoadDetailDTO DetailRecord { get; set; } = null!;
|
|
|
|
[Parameter]
|
|
public EventCallback<bool> EC_ClosePopup { get; set; }
|
|
|
|
[Parameter]
|
|
public EventCallback<bool> EC_ReRunReq { get; set; }
|
|
|
|
[Parameter]
|
|
public EventCallback<BalanceReqDto> EC_RunBalance { get; set; }
|
|
[Parameter]
|
|
public EventCallback<DirectAssignReqDto> EC_DirectAssign { get; set; }
|
|
[Parameter]
|
|
public EventCallback<int> EC_ResetAssign { get; set; }
|
|
|
|
[Parameter]
|
|
public OrderRowModel OrderRowRecord { get; set; } = null!;
|
|
|
|
#endregion Public Properties
|
|
|
|
|
|
|
|
#region Protected Fields
|
|
|
|
protected BalanceReqDto cBalanceReq = new BalanceReqDto();
|
|
|
|
/// <summary>
|
|
/// Gestione modalità assegnazione Parts a macchine
|
|
/// </summary>
|
|
protected SetMode CurrMode = SetMode.None;
|
|
|
|
#endregion Protected Fields
|
|
|
|
#region Protected Enums
|
|
|
|
protected enum SetMode
|
|
{
|
|
/// <summary>
|
|
/// Modalità non definita
|
|
/// </summary>
|
|
None = 0,
|
|
|
|
/// <summary>
|
|
/// Modalità preparazione richiesta balance
|
|
/// </summary>
|
|
Balance,
|
|
|
|
/// <summary>
|
|
/// Assegnazione diretta pezzi OK
|
|
/// </summary>
|
|
AssignOk,
|
|
|
|
/// <summary>
|
|
/// Assegnazione pezzi non lavorabili
|
|
/// </summary>
|
|
AssignUnwork
|
|
}
|
|
|
|
#endregion Protected Enums
|
|
|
|
#region Protected Properties
|
|
|
|
protected int BarLenght
|
|
{
|
|
get => cBalanceReq.BarLenght;
|
|
set => cBalanceReq.BarLenght = value;
|
|
}
|
|
|
|
protected bool checkSend
|
|
{
|
|
get => DictPercReq != null && DictPercReq.Count > 0 && DictPercReq.Sum(x => x.Value) == 1;
|
|
}
|
|
|
|
protected Dictionary<string, double> DictPercReq
|
|
{
|
|
get => cBalanceReq.MachineBalance;
|
|
set => cBalanceReq.MachineBalance = value;
|
|
}
|
|
|
|
[Inject]
|
|
private IDataLayerServices DLService { get; set; } = null!;
|
|
|
|
protected string MainCss
|
|
{
|
|
get => string.IsNullOrEmpty(selUid) ? "col-12" : "col-6";
|
|
}
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected async Task ClosePopup()
|
|
{
|
|
await EC_ClosePopup.InvokeAsync(true);
|
|
}
|
|
protected async Task ForceResetAssign()
|
|
{
|
|
if (!await JSRuntime.InvokeAsync<bool>("confirm", $"Confermi di vole resettare tutte le assegnazioniper gli articoli?"))
|
|
return;
|
|
|
|
await EC_ResetAssign.InvokeAsync(OrderRowRecord.OrderRowID);
|
|
}
|
|
|
|
protected async Task DirectAssign()
|
|
{
|
|
await Task.Delay(200);
|
|
}
|
|
|
|
protected override async Task OnParametersSetAsync()
|
|
{
|
|
await ReloadDataAsync();
|
|
}
|
|
|
|
private decimal TotMaxTimeRatio(decimal currTime)
|
|
{
|
|
return DetailRecord.TotMaxTime > 0 ? currTime / DetailRecord.TotMaxTime : (decimal)0.0;
|
|
}
|
|
private double NumPartRatio(int numPart)
|
|
{
|
|
return DetailRecord.NumParts > 0 ? (double)numPart / DetailRecord.NumParts : 0.0;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Rilettura dati da DB associazioni
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
protected async Task ReloadDataAsync()
|
|
{
|
|
await Task.Delay(500);
|
|
}
|
|
|
|
protected async Task ReqBalance()
|
|
{
|
|
await EC_RunBalance.InvokeAsync(cBalanceReq);
|
|
}
|
|
|
|
protected async Task ReRunJob()
|
|
{
|
|
await EC_ReRunReq.InvokeAsync(true);
|
|
}
|
|
|
|
[Inject]
|
|
protected IJSRuntime JSRuntime { get; set; } = null!;
|
|
|
|
/// <summary>
|
|
/// Assegnazione item unworkable a EXT
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
protected async Task SendUnworkExt(int ProdAssignId)
|
|
{
|
|
if (!await JSRuntime.InvokeAsync<bool>("confirm", $"Confermi assegnazione Ext/Manual per {DetailRecord.NumKo} articoli?"))
|
|
return;
|
|
|
|
if (OrderRowRecord.OrderRowID > 0 && ProdAssignId > 0)
|
|
{
|
|
// recupero elenco e converto in Dict
|
|
var dictPartUnwokr = DetailRecord
|
|
.ListUnWorkable
|
|
.ToDictionary(x => x, x => 0.0);
|
|
|
|
DirectAssignReqDto assignReq = new DirectAssignReqDto()
|
|
{
|
|
OrderRowID = OrderRowRecord.OrderRowID,
|
|
ProdAssignID = ProdAssignId,
|
|
DictPartAssign = dictPartUnwokr
|
|
};
|
|
|
|
await EC_DirectAssign.InvokeAsync(assignReq);
|
|
CurrMode = SetMode.None;
|
|
}
|
|
}
|
|
|
|
protected void ToggleAssignMode(List<string> listTag, SetMode reqMode)
|
|
{
|
|
// se era già attivo --> chiude... altrimenti assegna!
|
|
CurrMode = CurrMode == reqMode ? SetMode.None : reqMode;
|
|
// ora imposto secondo modo...
|
|
if (CurrMode == reqMode)
|
|
{
|
|
cBalanceReq.TagList = listTag;
|
|
PrepareSendReq();
|
|
}
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private string selUid = "";
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Methods
|
|
|
|
private void PrepareSendReq()
|
|
{
|
|
DictPercReq.Clear();
|
|
var cList = AllProdGroup;
|
|
double stdPerc = 1.0;
|
|
if (cList != null && cList.Count > 1)
|
|
{
|
|
stdPerc = 1.0 / (cList.Count - 1);
|
|
}
|
|
|
|
// da rivedere
|
|
#if false
|
|
//if (cList != null)
|
|
//{
|
|
// // valutare se determinare EXT/manuale in modo diverso da ProdPlantModel
|
|
// switch (CurrMode)
|
|
// {
|
|
// case SetMode.None:
|
|
// break;
|
|
|
|
// case SetMode.Balance:
|
|
// DictPercReq = cList.ToDictionary(x => x.ProdPlantCod, x => x.ProdPlantCod != "EXT" ? stdPerc : 0.0);
|
|
// break;
|
|
|
|
// case SetMode.AssignOk:
|
|
// DictPercReq = cList.ToDictionary(x => x.ProdPlantCod, x => 0.0);
|
|
// break;
|
|
|
|
// case SetMode.AssignUnwork:
|
|
// DictPercReq = cList.ToDictionary(x => x.ProdPlantCod, x => x.ProdPlantCod == "EXT" ? 1.0 : 0.0);
|
|
// break;
|
|
|
|
// default:
|
|
// break;
|
|
// }
|
|
//}
|
|
#endif
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |