160 lines
4.2 KiB
C#
160 lines
4.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;
|
|
using Microsoft.AspNetCore.Components;
|
|
using NLog.Targets.Wrappers;
|
|
|
|
namespace Lux.UI.Components.Compo.WorkLoad
|
|
{
|
|
public partial class TimeEstim
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public OrderRowModel OrderRowRecord { get; set; } = null!;
|
|
|
|
[Parameter]
|
|
public List<ProductionAssignModel>? AllProdAss { 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; }
|
|
|
|
#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 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()
|
|
{
|
|
ReloadData();
|
|
}
|
|
|
|
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 (OrderRowRecord.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(OrderRowRecord.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 = AllProdAss;
|
|
double stdPerc = 1.0;
|
|
if (cList != null && cList.Count > 1)
|
|
{
|
|
stdPerc = 1.0 / (cList.Count - 1);
|
|
}
|
|
DictPercReq = cList.ToDictionary(x => x.ProdPlantCod, x => x.ProdPlantCod != "EXT" ? stdPerc : 0);
|
|
}
|
|
|
|
#endregion Private Methods
|
|
}
|
|
} |