private static void Allocate(this CellInProfile profile) { int lotSize = SeeplanConfiguration.Instance.LotUnitSize; int maxQty = int.MaxValue; var inTarget = profile.FirstTarget(); if (inTarget != null) { maxQty = (int)inTarget.TargetQty; //remove in target profile.InTargets.Remove(inTarget); } int allocQty = 0; while (true) { if (allocQty >= maxQty) { break; } var minfo = profile.GetMatQtyInfo(lotSize); DateTime matTime = minfo.Item1; int matQty = minfo.Item2; if (matQty <= 0) { break; } profile.AddCellInQty(matTime, matQty, inTarget); //remove out profile profile.RemoveOutProfile(matQty); } }
private static int CellInProfileComparer(CellInProfile x, CellInProfile y) { if (object.ReferenceEquals(x, y)) { return(0); } var xt = x.FirstTarget(); var yt = y.FirstTarget(); bool null_x = xt == null; bool null_y = yt == null; int cmp = null_x.CompareTo(null_y); if (null_x || null_y) { return(cmp); } if (cmp == 0) { cmp = xt.TargetDate.CompareTo(yt.TargetDate); } if (cmp == 0) { cmp = xt.TargetQty.CompareTo(yt.TargetQty) * -1; } //low level if (cmp == 0) { cmp = string.Compare(x.ProductID, y.ProductID); } return(cmp); }