123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171 |
- 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
- {
- /// <summary>
- /// 机种
- /// </summary>
- public string ModuleType { get; set; } = string.Empty;
- /// <summary>
- /// 计划产能
- /// </summary>
- public int PlanCapacity { get; set; }
- /// <summary>
- /// 理论产能
- /// </summary>
- public int Capa { get; set; }
- /// <summary>
- /// 理论TT
- /// </summary>
- 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<ProductionPlanDtoV1> lst, string lineId, string topic, string lineName)
- {
- LineId = lineId;
- Floor = floor;
- Line = line;
- LineName = lineName;
- HourDataTopic = topic;
- IList<string> 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;
- /// <summary>
- /// 实时产能
- /// </summary>
- public int Capacity { get; private set; } = 0;
- /// <summary>
- /// 达成率
- /// </summary>
- //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);
- }
- }
- }
- }
|