92 lines
2.9 KiB
C#
92 lines
2.9 KiB
C#
using EgwCoreLib.Lux.Data.DbModel.Production;
|
|
using Microsoft.AspNetCore.Components;
|
|
|
|
namespace Lux.UI.Components.Compo.Planner
|
|
{
|
|
public partial class BalanceProgGroup
|
|
{
|
|
#region Public Properties
|
|
|
|
[Parameter]
|
|
public List<ProductionGroupModel>? AllRecords { get; set; } = null;
|
|
|
|
[Parameter]
|
|
public EventCallback<int> EC_RemBalance { get; set; }
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Protected Properties
|
|
|
|
protected decimal BalancedTotalTime
|
|
{
|
|
get => AllRecords?.Sum(x => x.TotalEstimTime) ?? 0;
|
|
}
|
|
|
|
#endregion Protected Properties
|
|
|
|
#region Protected Methods
|
|
|
|
protected string FormatEstTime(decimal totSeconds)
|
|
{
|
|
var tSpan = TimeSpan.FromSeconds((double)totSeconds);
|
|
string answ = EgwCoreLib.Lux.Core.DtUtils.FormatDateTime(tSpan);
|
|
return answ;
|
|
}
|
|
|
|
protected override void OnParametersSet()
|
|
{
|
|
if (AllRecords != null)
|
|
{
|
|
// Supponendo che 'listaOriginale' sia la tua List<ProductionGroupModel>
|
|
DictGrouped = AllRecords
|
|
.GroupBy(x => x.OrderRowNav.OrderRowUID)
|
|
.ToDictionary(
|
|
g => g.Key, // La chiave del dizionario è l'OrderRowNav.OrderRowUID
|
|
g => g.ToList() // Il valore è la lista di oggetti raggruppati
|
|
);
|
|
|
|
ListBalancedDet = AllRecords?
|
|
.SelectMany(pg => pg.WorkGroupList) // appiattisce tutti i dizionari
|
|
.GroupBy(kvp => kvp.Key) // raggruppa per la chiave del dizionario
|
|
.Select(g => new GroupDetail
|
|
{
|
|
MachineName = g.Key,
|
|
TotalBarQty = g.Sum(x => x.Value.BarQty),
|
|
TotalNumPart = g.Sum(x => x.Value.NumParts),
|
|
TotalTime = g.Sum(x => x.Value.Time)
|
|
})
|
|
.ToList();
|
|
}
|
|
}
|
|
|
|
#endregion Protected Methods
|
|
|
|
#region Private Fields
|
|
|
|
private Dictionary<string, List<ProductionGroupModel>> DictGrouped = new();
|
|
|
|
#endregion Private Fields
|
|
|
|
#region Protected Classes
|
|
|
|
protected class GroupDetail
|
|
{
|
|
#region Public Properties
|
|
|
|
public string MachineName { get; set; } = "";
|
|
public int TotalBarQty { get; set; } = 0;
|
|
public int TotalNumPart{ get; set; } = 0;
|
|
public decimal TotalTime { get; set; } = 0;
|
|
|
|
#endregion Public Properties
|
|
}
|
|
|
|
#endregion Protected Classes
|
|
|
|
#region Private Properties
|
|
|
|
private List<GroupDetail>? ListBalancedDet { get; set; } = new();
|
|
|
|
#endregion Private Properties
|
|
}
|
|
} |