public static LotLedWaste CalculateLotLedWaste(LotLedWasteStruc lot) { int ledExpectedUsageA = lot.requiredRankA * lot.manufacturedModules; int ledExpectedUsageB = lot.requiredRankB * lot.manufacturedModules; int ledExpectedLeftoversA = lot.reelsUsed / 2 * lot.ledsPerReel - ledExpectedUsageA; int ledExpectedLeftoversB = lot.reelsUsed / 2 * lot.ledsPerReel - ledExpectedUsageB; int droppedA = ledExpectedLeftoversA - lot.ledLeftA; int droppedB = ledExpectedLeftoversB - lot.ledLeftB; LotLedWaste result = new LotLedWaste(); result.droppedA = droppedA; result.droppedB = droppedB; result.ledExpectedUsageA = ledExpectedUsageA; result.ledExpectedUsageB = ledExpectedUsageB; return(result); }
public static SortedDictionary <DateTime, SortedDictionary <int, List <LotLedWasteStruc> > > LedWasteDictionary(SortedDictionary <DateTime, SortedDictionary <int, DataTable> > inputSmtData, Dictionary <string, MesModels> mesModels) { SortedDictionary <DateTime, SortedDictionary <int, List <LotLedWasteStruc> > > result = new SortedDictionary <DateTime, SortedDictionary <int, List <LotLedWasteStruc> > >(); foreach (var dateEntry in inputSmtData) { if (!result.ContainsKey(dateEntry.Key)) { result.Add(dateEntry.Key, new SortedDictionary <int, List <LotLedWasteStruc> >()); } foreach (var shiftEntry in dateEntry.Value) { if (!result[dateEntry.Key].ContainsKey(shiftEntry.Key)) { result[dateEntry.Key].Add(shiftEntry.Key, new List <LotLedWasteStruc>()); } foreach (DataRow row in shiftEntry.Value.Rows) { //107577:2OPF00050A:0|107658:2OPF00050A:0#107580:2OPF00050A:27|107657:2OPF00050A:23 string lot = row["NrZlecenia"].ToString(); string model = row["Model"].ToString(); int requiredRankA = mesModels[model].LedAQty; int requiredRankB = mesModels[model].LedBQty; string[] ledDropped = row["KoncowkiLED"].ToString().Split('#'); int reelsUsed = ledDropped.Length * 2; int ledALeftTotal = 0; int ledBLeftTotal = 0; int ledPerReel = 0; int manufacturedModules = int.Parse(row["IloscWykonana"].ToString()); string smtLine = row["LiniaSMT"].ToString(); foreach (var item in ledDropped) { if (string.IsNullOrWhiteSpace(item)) { continue; } string[] ranks = item.Split('|'); string[] rankA = ranks[0].ToString().Split(':'); string[] rankB = ranks[1].ToString().Split(':'); int leftA = int.Parse(rankA[2]); int leftB = int.Parse(rankB[2]); string ledId = rankA[1]; if (ledId.Length > 10) { ledPerReel = 3000; } else { ledPerReel = 3500; } ledALeftTotal += leftA; ledBLeftTotal += leftB; } if (ledPerReel * reelsUsed / 2 - requiredRankA * manufacturedModules < ledALeftTotal || ledPerReel * reelsUsed / 2 - requiredRankB * manufacturedModules < ledBLeftTotal) { continue; } LotLedWasteStruc newItem = new LotLedWasteStruc(); newItem.lotId = lot; newItem.requiredRankA = requiredRankA; newItem.requiredRankB = requiredRankB; newItem.ledLeftA = ledALeftTotal; newItem.ledLeftB = ledBLeftTotal; newItem.ledsPerReel = ledPerReel; newItem.manufacturedModules = manufacturedModules; newItem.smtLine = smtLine; newItem.reelsUsed = reelsUsed; newItem.model = model; result[dateEntry.Key][shiftEntry.Key].Add(newItem); } } } return(result); }