Files
lux/EgwCoreLib.Lux.Data/DbModel/Production/ProductionGroupModel.cs
T

80 lines
2.4 KiB
C#

using EgwCoreLib.Lux.Core.Generic;
using EgwCoreLib.Lux.Data.DbModel.Sales;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static EgwCoreLib.Lux.Core.Enums;
namespace EgwCoreLib.Lux.Data.DbModel.Production
{
/// <summary>
/// Classe che rappresenta la suddivisione in gruppi di un POR
/// - nasce in fase di Balance
/// - serve x successive fasi di raggruppamento/split
/// - indipendente dall'assegnazione effettiva alle macchine
/// </summary>
[Table("production_group")]
public class ProductionGroupModel
{
[Key]
public int ProdGroupID { get; set; }
/// <summary>
/// Ordine cui fa riferimento
/// </summary>
public int OrderRowID { get; set; } = 0;
/// <summary>
/// Tipologia del raggruppamento secondo lavorabilità
/// </summary>
public ProdGroupType GrpType { get; set; } = ProdGroupType.Undef;
/// <summary>
/// Codice Gruppo calcolato dal tipo
/// </summary>
[NotMapped]
public string GroupCode
{
get => $"G{(int)GrpType:00}";
}
/// <summary>
/// Elenco valori dei prod workgroup stimati gestito come JSON nativo
/// </summary>
public List<ProdMachineDetailDto> WorkGroupList { get; set; } = new();
/// <summary>
/// Num parts complessivamente incluse
/// </summary>
[NotMapped]
public int NumParts => WorkGroupList?.Sum(x => x.NumParts) ?? 0;
/// <summary>
/// Tempo stimato complessivo
/// </summary>
[NotMapped]
public double TotalEstimTime => WorkGroupList?.Sum(x => x.Time) ?? 0;
/// <summary>
/// Elenco dei Plants riferiti
/// </summary>
[NotMapped]
public List<string> PlantList => WorkGroupList?
.Select(x => x.ProdPlantCod)
.Distinct()
.ToList() ?? new List<string>();
/// <summary>
/// Navigazione OrderRow
/// </summary>
[ForeignKey("OrderRowID")]
public virtual OrderRowModel OrderRowNav { get; set; } = null!;
}
}