| | 1 | | using ReportingServices.Shared.Models.ProductionReport; |
| | 2 | |
|
| | 3 | | namespace ReportingServices.Shared.ViewModels.ProductionReport |
| | 4 | | { |
| | 5 | | public class YieldStatistics |
| | 6 | | { |
| 0 | 7 | | public DateTime StartDate { get; set; } |
| 0 | 8 | | public List<ReactorOutsByDay> OutsByDay { get; set; } |
| 0 | 9 | | public List<ScrapByDay> ScrapByDay { get; set; } |
| 0 | 10 | | public int DailyPlanWafers { get; set; } |
| 0 | 11 | | public bool IsCurrentWeek { get; set; } |
| | 12 | |
|
| 0 | 13 | | public YieldStatistics(DateTime startDate, bool isCurrentWeek) |
| 0 | 14 | | { |
| 0 | 15 | | StartDate = startDate; |
| 0 | 16 | | IsCurrentWeek = isCurrentWeek; |
| 0 | 17 | | } |
| | 18 | |
|
| | 19 | | public void SetYieldInformation(YieldInformation yieldInformation, QuarterlyTargets targets) |
| 0 | 20 | | { |
| 0 | 21 | | OutsByDay = GetReactorOutsByDay(yieldInformation.Outs); |
| 0 | 22 | | ScrapByDay = yieldInformation.Scrap; |
| 0 | 23 | | DailyPlanWafers = targets.Yield_Outs / targets.PlanWorkingDays; |
| 0 | 24 | | } |
| | 25 | |
|
| | 26 | | public static List<string> GetDistinctDatesFromReactorOuts(List<ReactorOutsByRDS> outs) |
| 0 | 27 | | { |
| 0 | 28 | | List<string> dates = new(); |
| | 29 | |
|
| 0 | 30 | | foreach (ReactorOutsByRDS rout in outs) |
| 0 | 31 | | { |
| 0 | 32 | | if (!dates.Contains(DateTime.Parse(rout.EndProcessTime).Date.ToString())) |
| 0 | 33 | | dates.Add(DateTime.Parse(rout.EndProcessTime).Date.ToString()); |
| 0 | 34 | | } |
| | 35 | |
|
| 0 | 36 | | return dates; |
| 0 | 37 | | } |
| | 38 | |
|
| | 39 | | public static List<ReactorOutsByDay> GetReactorOutsByDay(List<ReactorOutsByRDS> outs) |
| 0 | 40 | | { |
| 0 | 41 | | List<ReactorOutsByDay> outsByDay = new(); |
| | 42 | |
|
| 0 | 43 | | List<string> dates = GetDistinctDatesFromReactorOuts(outs); |
| | 44 | |
|
| 0 | 45 | | foreach (string date in dates) |
| 0 | 46 | | { |
| 0 | 47 | | int waferCount = 0; |
| | 48 | |
|
| 0 | 49 | | foreach (ReactorOutsByRDS rout in outs) |
| 0 | 50 | | { |
| 0 | 51 | | if (DateTime.Parse(rout.EndProcessTime).Date.ToString() == date) |
| 0 | 52 | | waferCount += (int)float.Parse(rout.Units); |
| 0 | 53 | | } |
| | 54 | |
|
| 0 | 55 | | outsByDay.Add(new ReactorOutsByDay { StartDate = date, TotalWafers = waferCount }); |
| 0 | 56 | | } |
| | 57 | |
|
| 0 | 58 | | return outsByDay; |
| 0 | 59 | | } |
| | 60 | | } |
| | 61 | | } |