77 lines
2.1 KiB
C#
77 lines
2.1 KiB
C#
using EgwCoreLib.Lux.Core.Generic;
|
|
using Lux.UI.Components.Pages;
|
|
using static Lux.UI.Components.Compo.WorkLoad.TimeEstim;
|
|
|
|
namespace Lux.UI.Components.Compo.WorkLoad
|
|
{
|
|
public partial class AssegnaBilancia
|
|
{
|
|
#region Public Properties
|
|
|
|
|
|
[Parameter]
|
|
public BalanceReqDto BalanceReq { get; set; } = new();
|
|
|
|
[Parameter]
|
|
public EventCallback<BalanceReqDto> EC_RunBalance { get; set; }
|
|
|
|
[Parameter]
|
|
public List<ProductionGroupModel> GroupList { get; set; } = null!;
|
|
|
|
[Parameter]
|
|
public SetMode Mode { get; set; } = SetMode.None;
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Private Properties
|
|
|
|
private int BarLenght
|
|
{
|
|
get => BalanceReq.BarLenght;
|
|
set => BalanceReq.BarLenght = value;
|
|
}
|
|
|
|
private bool checkSend
|
|
{
|
|
get => BalanceReq.MachineBalance != null && BalanceReq.MachineBalance.Count > 0 && BalanceReq.MachineBalance.Sum(x => x.Value) == 1;
|
|
}
|
|
|
|
#endregion Private Properties
|
|
|
|
#region Private Methods
|
|
|
|
private Task DirectAssign()
|
|
{
|
|
return EC_RunBalance.InvokeAsync(BalanceReq);
|
|
}
|
|
|
|
private Task ReqBalance()
|
|
{
|
|
return EC_RunBalance.InvokeAsync(BalanceReq);
|
|
}
|
|
|
|
private void SetPerc(string key, decimal reqValue)
|
|
{
|
|
// ipotesi: solo 2 valori (attivi)
|
|
if (BalanceReq.MachineBalance.ContainsKey(key))
|
|
{
|
|
BalanceReq.MachineBalance[key] = (double)reqValue;
|
|
int numRec = BalanceReq.MachineBalance.Count;
|
|
foreach (var item in BalanceReq.MachineBalance)
|
|
{
|
|
if (!item.Key.Equals(key))
|
|
{
|
|
BalanceReq.MachineBalance[item.Key] = (double)((1 - reqValue) / (numRec - 1));
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void UpdatePerc(SingleRequest.PercRequest newVal)
|
|
{
|
|
SetPerc(newVal.Key, (decimal)newVal.Value);
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |