using System; using System.Collections.Generic; using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Text; namespace ProductionLineMonitor.Application.Services.LineService.Dtos { public class ProductionPlanDto { /// /// 机种 /// public string ModuleType { get; set; } = string.Empty; /// /// 计划产能 /// public int PlanCapacity { get; set; } /// /// 理论产能 /// public int Capa { get; set; } /// /// 理论TT /// public double TT { get; set; } } public class ProductionPlanDtoV1 : ProductionPlanDto { public string Shift { get; set; } = string.Empty; } public class OverProductionPlanDto { public OverProductionPlanDto(int floor, int line, IList lst, string lineId, string topic, string lineName) { LineId = lineId; Floor = floor; Line = line; LineName = lineName; HourDataTopic = topic; IList ModuleTypes = lst .Where(x => x.ModuleType != "") .Select(x => x.ModuleType) .Distinct().ToList(); int[] capas = new int[ModuleTypes.Count()]; for (int i = 0; i < ModuleTypes.Count(); i++) { var l = lst.FirstOrDefault(x => x.ModuleType == ModuleTypes[i]); if (l != null) { capas[i] = l.Capa; } } Capa = string.Join (" / ", capas); //for (int i = 0; i < ModuleTypes.Count(); i++) //{ // if (ModuleTypes[i].Length > 10) // { // ModuleTypes[i] = ModuleTypes[i][..10]; // } //} ModuleType = string.Join(" / ", ModuleTypes); var ms = lst.Where(x => x.Shift == "1"); if (ms != null && ms.Count() > 0) { PlanMorningShiftCapacity = ms.Select(x => x.PlanCapacity).Sum(); } var ns = lst.Where(x => x.Shift == "2"); if (ns != null && ns.Count() > 0) { PlanNightShiftCapacity = ns.Select(x => x.PlanCapacity).Sum(); } } public void SetModuleType(string moduleType) { // 11 12 不截取 if ((Line == 11 || Line == 12) && Floor == 2) { ModuleType = moduleType; return; } if (moduleType.Length > 10) { moduleType = moduleType[..10]; } ModuleType = moduleType; } public string LineId { get; private set; } public void SetCapacity(int capacity) { Capacity = capacity; } public int Floor { get; set; } public int Line { get; set; } public string HourDataTopic { get; set; } public string ModuleType { get; private set; } = string.Empty; public string Capa { get; set; } = string.Empty; public string LineName { get; set; } = string.Empty; public bool MorningShiftState { get { return PlanMorningShiftCapacity != 0; } } public int PlanMorningShiftCapacity { get; set; } = 0; public bool NightShiftState { get { return PlanNightShiftCapacity != 0; } } public int PlanNightShiftCapacity { get; set; } = 0; /// /// 实时产能 /// public int Capacity { get; private set; } = 0; /// /// 达成率 /// //public string AchievementRate //{ // get // { // int p = PlanMorningShiftCapacity + PlanNightShiftCapacity; // if (p == 0) // { // return "-"; // } // return Math.Round((float)Capacity / p * 100, 2).ToString() + " %"; // } //} public double AchievementRate { get { int p = PlanMorningShiftCapacity + PlanNightShiftCapacity; if (p == 0) { return 0; } return Math.Round((float)Capacity / p * 100, 2); } } } }