165 lines
4.2 KiB
C#
165 lines
4.2 KiB
C#
using EgwCoreLib.Lux.Core.Generic;
|
|
using EgwCoreLib.Lux.Core.RestPayload;
|
|
using EgwCoreLib.Lux.Data.Services;
|
|
using Microsoft.AspNetCore.Components;
|
|
using NLog.Targets.Wrappers;
|
|
|
|
namespace Lux.UI.Components.Compo.WorkLoad
|
|
{
|
|
public partial class TimeEstim
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public int OrderRowId { get; set; } = 0;
|
|
|
|
[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; }
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Fields
|
|
[Inject]
|
|
protected DataLayerServices DLService { get; set; } = null!;
|
|
|
|
protected BalanceReqDto cBalanceReq = new BalanceReqDto();
|
|
|
|
#endregion Protected Fields
|
|
|
|
#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;
|
|
}
|
|
|
|
protected List<string> ListTargetMachine
|
|
{
|
|
get
|
|
{
|
|
var answ = DetailRecord.ListMachines;
|
|
// aggiungo la macchina EXT...
|
|
answ.Add("EXT");
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
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 override void OnParametersSet()
|
|
{
|
|
ResetDictReq();
|
|
}
|
|
|
|
protected async Task ReqBalance()
|
|
{
|
|
await EC_RunBalance.InvokeAsync(cBalanceReq);
|
|
}
|
|
|
|
protected async Task ReRunJob()
|
|
{
|
|
await EC_ReRunReq.InvokeAsync(true);
|
|
}
|
|
|
|
protected void ToggleBalance(List<string> listTag)
|
|
{
|
|
setBalance = !setBalance;
|
|
if (setBalance)
|
|
{
|
|
cBalanceReq.TagsList = listTag;
|
|
ResetDictReq();
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Assegnazione item unworkable a EXT
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
protected async Task SendUnworkExt()
|
|
{
|
|
// recupero ProdAssignId x EXT... da elenco record mostrati...
|
|
int ProdAssignId = 0;
|
|
if (OrderRowId > 0 && ProdAssignId > 0)
|
|
{
|
|
// recupero elenco e converto in Dict
|
|
var dictUnwokr = DetailRecord
|
|
.ListUnWorkable
|
|
.ToDictionary(x => x, x => 0.0);
|
|
|
|
// chiamo update!
|
|
await DLService.ProdItemBulkAssignItems(OrderRowId, ProdAssignId, dictUnwokr);
|
|
|
|
}
|
|
// rileggo!
|
|
await ReloadData();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Rilettura dati da DB associazioni
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
protected async Task ReloadData()
|
|
{
|
|
await Task.Delay(500);
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private string selUid = "";
|
|
|
|
private bool setBalance = false;
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Private Methods
|
|
|
|
private void ResetDictReq()
|
|
{
|
|
DictPercReq.Clear();
|
|
var cList = ListTargetMachine;
|
|
double stdPerc = 1.0;
|
|
if (cList.Count > 1)
|
|
{
|
|
stdPerc = 1.0 / (cList.Count - 1);
|
|
}
|
|
DictPercReq = cList.ToDictionary(x => x, x => x != "EXT" ? stdPerc : 0);
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |