private static void Allocate_Init(this DcnMaster mst, DateTime now, DateTime startTime, DateTime endTime) { mst.StartTime = startTime; mst.EndTime = endTime; mst.Current = new List <DcnPlan>(); foreach (var bck in mst.Buckets) { bck.Allocate_Init(now); //apply eqp state var eqpStates = mst.EqpStates; if (eqpStates != null && eqpStates.Count > 0) { string eqpID = bck.EqpID; EqpStatusInfo info; if (eqpStates.TryGetValue(eqpID, out info)) { bck.Allocate_State(info, startTime, endTime, now); //remove if (info.Duration <= 0) { eqpStates.Remove(eqpID); } } } } }
private static List <DcnTarget> GetLoadableTargetList(this DcnMaster mst, DcnBucket bck, List <DcnTarget> targetList) { if (targetList == null || targetList.Count == 0) { return(null); } targetList.RemoveAll(t => t.RemainQty <= 0); if (targetList == null || targetList.Count == 0) { return(null); } DateTime startTime = mst.StartTime; DateTime endTime = mst.EndTime; List <DcnTarget> list = new List <DcnTarget>(); foreach (var target in targetList) { bool hasMainShopTarget = mst.HasRemainTarget(bck.MainRunShopID); if (bck.CanAllocate(startTime, endTime, target, hasMainShopTarget) == false) { continue; } list.Add(target); } return(list); }
private static void OnDayChanged(this DcnMaster mst, DateTime now) { foreach (var bck in mst.Buckets) { bck.OnDayChanged(now); } }
private static int FixedTargetQty(this DcnMaster mst, DcnTarget target) { if (target == null) { return(0); } string key = target.ProductID; int prevDiff; if (mst.Diffs.TryGetValue(key, out prevDiff)) { int targetQty = target.RemainQty; int min = Math.Min(targetQty, prevDiff); int allocQty = min; target.AllocQty += allocQty; int remainDiff = prevDiff - allocQty; if (remainDiff <= 0) { mst.Diffs.Remove(key); } else { mst.Diffs[key] = remainDiff; } } return(target.RemainQty); }
private static DcnBucket SelectBucket(this DcnMaster mst, List <DcnBucket> list) { if (list == null || list.Count == 0) { return(null); } //sort bucket if (list.Count > 1) { list.Sort(DcnBucketComparer.Default); } return(list[0]); }
private static void SetSupportSteps(this DcnMaster mst) { var gate = BopHelper.FindStdStep(Constants.ArrayShop, Constants.GATE_PHOTO_STEP); if (gate != null) { mst.SupportSteps.Add(gate); } var bm = BopHelper.FindStdStep(Constants.CfShop, Constants.BM__PHOTO_STEP); if (bm != null) { mst.SupportSteps.Add(bm); } }
private static void Allocate(this DcnMaster mst, DateTime now) { var bckList = mst.Buckets.ToList(); if (bckList == null || bckList.Count == 0) { return; } var targetList = mst.AllTargets; if (targetList == null || targetList.Count == 0) { return; } int lotSize = SeeplanConfiguration.Instance.LotUnitSize; while (true) { var bck = mst.SelectBucket(bckList); if (bck == null) { break; } var target = mst.SelectTarget(bck, targetList); if (target == null) { bckList.Remove(bck); continue; } //선투입 수량 반영 int remainQty = mst.FixedTargetQty(target); if (remainQty <= 0) { continue; } int diff; if (mst.Allocate(bck, target, lotSize, now, out diff)) { mst.UpdateDiff(target, diff); } } }
private static void Allocate_FixPlan(this DcnMaster mst, DateTime now) { var plans = mst.FixPlans; if (plans == null || plans.Count == 0) { return; } DateTime startTime = mst.StartTime; DateTime endTime = mst.EndTime; foreach (var it in plans) { string eqpID = it.Key; var bck = mst.GetBucket(eqpID); if (bck == null) { continue; } var list = it.Value; if (list == null || list.Count == 0) { continue; } for (int i = 0; i < list.Count; i++) { var fixPlan = list[i]; var target = mst.SelectTarget_FixPlan(fixPlan); if (bck.CanAllocate(startTime, endTime, target, false) == false) { break; } if (mst.Allocate_FixPlan(bck, target, fixPlan, now)) { list.RemoveAt(i); i--; } } } }
private static DcnBucket GetBucket(this DcnMaster mst, string eqpID) { if (string.IsNullOrEmpty(eqpID)) { return(null); } var list = mst.Buckets; if (list == null || list.Count == 0) { return(null); } var find = list.Find(t => t.EqpID == eqpID); return(find); }
private static bool Allocate(this DcnMaster mst, DcnBucket bck, DcnTarget target, int lotSize, DateTime now, out int diff) { diff = 0; int targetQty = target.RemainQty; if (lotSize <= 0) { lotSize = targetQty; } //lotSize 단위로 Alloc int remain = targetQty; int allocQty = lotSize; var plan = bck.Allocate(target.Product, allocQty, target, now); //전체 Alloc Plan 기록 if (plan != null) { plan.AllocSeq = mst.AllPlans.Count + 1; mst.AllPlans.Add(plan); mst.Current.Add(plan); } remain = remain - allocQty; if (remain < 0) { diff = Math.Abs(remain); } bool isNoAlloc = remain == targetQty; if (isNoAlloc) { return(false); } return(true); }
private static bool Allocate_FixPlan(this DcnMaster mst, DcnBucket bck, DcnTarget target, FixPlanDCN fixPlan, DateTime now) { int allocQty = fixPlan.PLAN_QTY; if (allocQty <= 0) { return(false); } FabProduct prod = target == null ? null : target.Product; if (prod == null) { prod = BopHelper.FindProduct(fixPlan.SHOP_ID, fixPlan.PRODUCT_ID); } if (prod == null) { return(false); } var plan = bck.Allocate(prod, allocQty, target, now); //전체 Alloc Plan 기록 if (plan != null) { plan.FixPlan = fixPlan; plan.AllocSeq = mst.AllPlans.Count + 1; mst.AllPlans.Add(plan); mst.Current.Add(plan); } bool isNoAlloc = plan == null; if (isNoAlloc) { return(false); } return(true); }
private static void UpdateDiff(this DcnMaster mst, DcnTarget target, int diffQty) { if (diffQty == 0) { return; } string key = target.ProductID; int prev; if (mst.Diffs.TryGetValue(key, out prev)) { mst.Diffs[key] = prev + diffQty; } else { mst.Diffs.Add(key, diffQty); } }
private static DcnTarget SelectTarget_FixPlan(this DcnMaster mst, FixPlanDCN fixPlan) { if (fixPlan == null) { return(null); } var targetList = mst.AllTargets; if (targetList == null || targetList.Count == 0) { return(null); } var find = targetList.Find(t => t.ShopID == fixPlan.SHOP_ID && t.ProductID == fixPlan.PRODUCT_ID && t.RemainQty > 0); return(find); }
private static DcnTarget SelectTarget(this DcnMaster mst, DcnBucket bck, List <DcnTarget> targetList) { if (bck == null) { return(null); } var list = mst.GetLoadableTargetList(bck, targetList); if (list == null || list.Count == 0) { return(null); } if (list.Count > 1) { list.Sort(new DcnTargetComparer(bck, mst.SupportSteps, mst.SupportEqps)); } return(list[0]); }
private static bool HasRemainTarget(this DcnMaster mst, string targetShopID) { if (string.IsNullOrEmpty(targetShopID)) { return(false); } var targetList = mst.AllTargets; if (targetList == null || targetList.Count == 0) { return(false); } var find = targetList.Find(t => t.ShopID == targetShopID && t.RemainQty > 0); if (find != null) { return(true); } return(false); }
private static void SetSupportEqps(this DcnMaster mst) { var stepList = mst.SupportSteps; if (stepList == null || stepList.Count == 0) { return; } foreach (var it in stepList) { foreach (var targetEqp in it.AllEqps) { var eqp = AoFactory.Current.GetEquipment(targetEqp.EqpID) as FabAoEquipment; if (eqp == null) { continue; } mst.SupportEqps.Add(eqp); } } }
private static void DoReserveBatch(this DcnMaster mst, DateTime now) { AoBatchRelease inputBatch = AoFactory.Current.BatchRelease; foreach (DcnPlan plan in mst.Current) { FabProduct prod = plan.Product; if (prod == null) { continue; } FabStep step = prod.Process.FirstStep as FabStep; if (step == null) { continue; } string lotID = EntityHelper.CreateFrontInLotID(prod); double unitQty = plan.AllocQty; FabWipInfo wip = CreateHelper.CreateWipInfo(lotID, prod, step, unitQty); FabLot lot = CreateHelper.CreateLot(wip, LotState.CREATE); DateTime releaseTime = LcdHelper.Max(plan.EqpEndTime, now); lot.ReleaseTime = releaseTime; lot.LotState = LotState.CREATE; lot.ReleasePlan = plan; var inTarget = plan.Target == null ? null : plan.Target.InTarget; lot.FrontInTarget = inTarget; inputBatch.AddEntity(releaseTime, lot); } }
public static void Initialize(this DcnMaster mst) { mst.SetSupportSteps(); mst.SetSupportEqps(); }