123 lines
3.7 KiB
C#
123 lines
3.7 KiB
C#
using Newtonsoft.Json;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Reflection.PortableExecutable;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace EgwCoreLib.Lux.Core.RestPayload
|
|
{
|
|
/// <summary>
|
|
/// Classe per definizione WorkLoad in dettaglio x un dato task (POR tipicamente)
|
|
/// </summary>
|
|
public class WorkLoadDetailDTO
|
|
{
|
|
#region Public Constructors
|
|
|
|
/// <summary>
|
|
/// Init classe aprtendo dal valore serializzato di una stima di lavorabilità di un item d'ordine minimo (POR)
|
|
/// </summary>
|
|
/// <param name="UID"></param>
|
|
/// <param name="rawData"></param>
|
|
public WorkLoadDetailDTO(string UID, string rawData)
|
|
{
|
|
uID = UID;
|
|
// deserializzo risultati calcolo
|
|
machineCalcResults = JsonConvert.DeserializeObject<List<MachineCalcResultDTO>>(rawData) ?? new List<MachineCalcResultDTO>();
|
|
// calcolo "esito sinteico" della lavorabilità (NESSUNA part UnHealthy su ogni macchina)
|
|
workable = machineCalcResults.Sum(x => x.NumPartsKo) == 0;
|
|
// se almeno 1 verifico SE ci siano part unhealty su OGNI macchina (altrimenti è cmq lavorabile
|
|
if (!workable)
|
|
{
|
|
var listKo = new List<PartCalcDTO>();
|
|
// cerco l'insieme dei pezzi DAVVERO non lavorabili
|
|
listUnWorkable = MachineCalc.Utils.IntersectTags(machineCalcResults, p => p.CalcResult != Enums.PartVerificationResult.MACHINABLE).ToList();
|
|
workable = !listUnWorkable.Any();
|
|
numKo = listUnWorkable.Count();
|
|
}
|
|
|
|
LoadDetail = MachineCalc.Utils.CalculateIntersections(machineCalcResults);
|
|
}
|
|
|
|
#endregion Public Constructors
|
|
|
|
#region Public Properties
|
|
|
|
/// <summary>
|
|
/// Elenco Macchine
|
|
/// </summary>
|
|
public string ListMachines
|
|
{
|
|
get => string.Join(", ", machineCalcResults.Select(x => x.Name).OrderBy(x => x).ToList());
|
|
}
|
|
/// <summary>
|
|
/// Num Macchine
|
|
/// </summary>
|
|
public int NumMachines
|
|
{
|
|
get => machineCalcResults.Count();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Elenco delle etichette parts non OK
|
|
/// </summary>
|
|
public List<string> ListUnWorkable
|
|
{
|
|
get => listUnWorkable ?? new List<string>();
|
|
}
|
|
|
|
/// <summary>
|
|
/// Dettaglio combinazioni carico di lavoro
|
|
/// </summary>
|
|
public List<MachineTagDTO> LoadDetail { get; set; } = new List<MachineTagDTO>();
|
|
|
|
public List<MachineCalcResultDTO> MachineCalcResults
|
|
{
|
|
get => machineCalcResults;
|
|
}
|
|
|
|
public int NumKo
|
|
{
|
|
get => numKo;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Tempo massimo complessivo in ORE
|
|
/// </summary>
|
|
public decimal TotMaxTime
|
|
{
|
|
get => LoadDetail.Sum(x => x.MaxTime) / 3600;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Tempo minimo complessivo in ORE
|
|
/// </summary>
|
|
public decimal TotMinTime
|
|
{
|
|
get => LoadDetail.Sum(x => x.MinTime) / 3600;
|
|
}
|
|
|
|
public string UID
|
|
{
|
|
get => uID;
|
|
}
|
|
|
|
public bool Workable
|
|
{
|
|
get => workable;
|
|
}
|
|
|
|
#endregion Public Properties
|
|
|
|
#region Private Fields
|
|
|
|
private List<string>? listUnWorkable = null;
|
|
private List<MachineCalcResultDTO> machineCalcResults = new List<MachineCalcResultDTO>();
|
|
private int numKo = 0;
|
|
private string uID = "";
|
|
private bool workable = false;
|
|
|
|
#endregion Private Fields
|
|
}
|
|
} |