93 lines
2.9 KiB
C#
93 lines
2.9 KiB
C#
using EgwCoreLib.Lux.Core.Generic;
|
|
using EgwCoreLib.Lux.Data.DbModel.Sales;
|
|
using Newtonsoft.Json;
|
|
using System.ComponentModel.DataAnnotations;
|
|
using System.ComponentModel.DataAnnotations.Schema;
|
|
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>
|
|
/// Valore effettivo serializzato dei WorkgroupList
|
|
/// </summary>
|
|
public string WorkGroupListRaw { get; set; } = "";
|
|
|
|
/// <summary>
|
|
/// Elenco valori dei prod workgroup stimati gestito come JSON serializzato/deserializzato al volo
|
|
/// </summary>
|
|
[NotMapped]
|
|
public Dictionary<string, ProdMachineDetailDto> WorkGroupList
|
|
{
|
|
get
|
|
{
|
|
Dictionary<string, ProdMachineDetailDto> answ = new();
|
|
if (!string.IsNullOrEmpty(WorkGroupListRaw))
|
|
{
|
|
answ = JsonConvert.DeserializeObject<Dictionary<string, ProdMachineDetailDto>>(WorkGroupListRaw) ?? new();
|
|
}
|
|
return answ;
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Num parts complessivamente incluse
|
|
/// </summary>
|
|
[NotMapped]
|
|
public int NumParts => WorkGroupList?.Sum(x => x.Value.NumParts) ?? 0;
|
|
|
|
/// <summary>
|
|
/// Tempo stimato complessivo
|
|
/// </summary>
|
|
[NotMapped]
|
|
public double TotalEstimTime => WorkGroupList?.Sum(x => x.Value.Time) ?? 0;
|
|
|
|
|
|
/// <summary>
|
|
/// Elenco dei Plants riferiti
|
|
/// </summary>
|
|
[NotMapped]
|
|
public List<string> PlantList => WorkGroupList?
|
|
.Select(x => x.Key)
|
|
.Distinct()
|
|
.ToList() ?? new List<string>();
|
|
|
|
/// <summary>
|
|
/// Navigazione OrderRow
|
|
/// </summary>
|
|
[ForeignKey("OrderRowID")]
|
|
public virtual OrderRowModel OrderRowNav { get; set; } = null!;
|
|
|
|
}
|
|
}
|