private void DataValidCheck(ItemFlow itemFlow) { if (itemFlow.Flow == null) { throw new BusinessException("Flow is key infomation, it can't be empty!"); } }
private void ProcessReqQty(ItemFlow itemFlow) { IOAE processor = this.GetProcessor(itemFlow.Flow.FlowStrategy.Strategy); if (processor != null) { processor.ProcessReqQty(itemFlow); } }
private void SetFlowProperty(ItemFlow itemFlow, List <Flow> flows) { Flow flow = flows.Single(f => f.Equals(itemFlow.Flow)); itemFlow.Flow.WindowTime = flow.WindowTime; itemFlow.Flow.NextOrderTime = flow.NextOrderTime; itemFlow.Flow.NextWindowTime = flow.NextWindowTime; itemFlow.Flow.IsUpdateWindowTime = flow.IsUpdateWindowTime; }
public override void ProcessReqQty(ItemFlow itemFlow) { //ReqQty? It's too early for this DateTime?orderTime = itemFlow.Flow.OrderTime; if (orderTime.HasValue && orderTime.Value > DateTime.Now) { return; } base.ProcessReqQty(itemFlow); }
protected virtual OrderTracer GetDemand_OrderTracer(ItemFlow itemFlow) { OrderTracer orderTracer = new OrderTracer(); orderTracer.TracerType = Enumerators.TracerType.Demand; orderTracer.Code = itemFlow.Flow.Code; orderTracer.ReqTime = DateTime.Now; orderTracer.Item = itemFlow.Item; orderTracer.Qty = itemFlow.SafeInv; return(orderTracer); }
protected override bool CheckReq(ItemFlow itemFlow) { bool isReq = false; DateTime?orderTime = itemFlow.Flow.OrderTime; decimal reqQty = this.GetReqQty(itemFlow.OrderTracers); if (reqQty > 0) { isReq = true; } return(isReq); }
public List <Orders> DemandToOrders(List <ItemFlow> itemFlows) { #region ProcessOrderQty var query = from i in itemFlows where i.ReqQty > 0 group i by new { i.LocTo, i.Item } into g select new { g.Key, list = g.ToList(), Count = g.Count() }; if (query != null && query.Count() > 0) { foreach (var g in query) { if (g.Count == 1) { ItemFlow itemFlow = itemFlows.Single(i => i.Equals(g.list[0])); this.ProcessOrderQty(itemFlow); } else { //to be testing ItemFlow winBidItemFlow = this.BidItemFlow(g.list); ItemFlow itemFlow = itemFlows.SingleOrDefault(i => i.Equals(winBidItemFlow)); this.ProcessOrderQty(itemFlow); } } } #endregion List <Orders> result = new List <Orders>(); #region Emergency Orders List <Orders> emOrders = this.BuildOrders(itemFlows, true); result = result.Concat(emOrders).ToList(); #endregion #region Normal Orders List <Orders> nmlOrders = this.BuildOrders(itemFlows, false); result = result.Concat(nmlOrders).ToList(); #endregion #region Filter result = result.Where(r => (r.IsEmergency && r.ItemFlows.Count > 0) || (!r.IsEmergency && (r.Flow.IsUpdateWindowTime || r.ItemFlows.Count > 0))).ToList(); #endregion return(result); }
protected virtual bool CheckReq(ItemFlow itemFlow) { bool isReq = false; DateTime?orderTime = itemFlow.Flow.OrderTime; decimal reqQty = this.GetReqQty(itemFlow.OrderTracers); if (reqQty > 0) { //Emergency isReq = true; itemFlow.IsEmergency = true; } else if (!orderTime.HasValue || orderTime.Value <= DateTime.Now) { //Normal isReq = true; } return(isReq); }
protected override decimal GetReqQty(ItemFlow itemFlow) { string item = itemFlow.Item; DateTime?winTime = itemFlow.Flow.WindowTime; decimal maxInv = itemFlow.MaxInv; decimal safeInv = itemFlow.SafeInv; #region Demand OrderTracer demand = this.GetDemand_OrderTracer(itemFlow); itemFlow.AddOrderTracer(demand); #endregion foreach (var loc in itemFlow.DemandSources) { #region OnhandInv OrderTracer onhandInv = this.GetOnhandInv_OrderTracer(loc, item); itemFlow.AddOrderTracer(onhandInv); #endregion #region InspectInv OrderTracer inspectInv = this.GetInspectInv_OrderTracer(loc, item); itemFlow.AddOrderTracer(inspectInv); #endregion #region OrderRct var orderRcts = this.GetOrderRct(loc, item, null, winTime); itemFlow.AddOrderTracer(orderRcts); #endregion } decimal reqQty = 0; bool isReq = this.CheckReq(itemFlow); if (isReq) { demand.Qty = maxInv;//Actual demand reqQty = this.GetReqQty(itemFlow.OrderTracers); } return(reqQty); }
private void ProcessOrderQty(ItemFlow itemFlow) { if (itemFlow == null || itemFlow.ReqQty <= 0) { return; } decimal orderQty = itemFlow.ReqQty; decimal minLotSize = itemFlow.MinLotSize; //Min qty to order decimal UC = itemFlow.UC; //Unit container Enumerators.RoundUp roundUp = itemFlow.RoundUp; //Round up option //decimal orderLotSize = itemFlow.OrderLotSize;//Order lot size, one to many //Min lot size to order if (minLotSize > 0 && orderQty < minLotSize) { orderQty = minLotSize; } //round up if (UC > 0) { if (roundUp == Enumerators.RoundUp.Ceiling) { orderQty = Math.Ceiling(orderQty / UC) * UC; } else if (roundUp == Enumerators.RoundUp.Floor) { orderQty = Math.Floor(orderQty / UC) * UC; } } itemFlow.OrderQty = orderQty; //Order lot size, only production support //if (itemFlow.Flow.FlowType == Enumerators.FlowType.Production && orderLotSize > 0) //{ // itemFlow.OrderQtyList = this.SplitOrderByLotSize(orderQty, orderLotSize); //} }
public virtual void ProcessReqQty(ItemFlow itemFlow) { if (itemFlow == null) { throw new BusinessException("Key value is empty"); } if (itemFlow.OrderTracers == null) { itemFlow.OrderTracers = new List <OrderTracer>(); } string loc = itemFlow.LocTo; string item = itemFlow.Item; string flowCode = itemFlow.Flow.Code; itemFlow.ReqQty = 0; itemFlow.IsEmergency = false; #region DemandSources if (itemFlow.DemandSources == null) { itemFlow.DemandSources = new List <string>(); } if (!itemFlow.DemandSources.Contains(loc) && loc != null) { itemFlow.DemandSources.Add(loc); } if (itemFlow.DemandSources.Count == 0) { return; } itemFlow.DemandSources = itemFlow.DemandSources.Distinct().ToList(); #endregion itemFlow.ReqQty = this.GetReqQty(itemFlow); }
private int ItemFlowComparer(ItemFlow x, ItemFlow y) { if (x.LocTo == null) { if (y.LocTo == null) { return(0); } else { return(-1); } } else if (x.LocFrom == null) { if (y.LocFrom == null) { return(0); } else { return(1); } } else if (y.LocFrom != null && y.LocTo != null) { if (Utilities.StringEq(x.LocFrom, y.LocTo)) { return(-1); } else if (Utilities.StringEq(x.LocTo, y.LocFrom)) { return(1); } } return(0); }
protected override decimal GetReqQty(ItemFlow itemFlow) { string item = itemFlow.Item; DateTime?orderTime = itemFlow.Flow.OrderTime; DateTime?winTime = itemFlow.Flow.WindowTime; DateTime?nextWinTime = itemFlow.Flow.NextWindowTime; #region Demand OrderTracer demand = this.GetDemand_OrderTracer(itemFlow); itemFlow.AddOrderTracer(demand); #endregion foreach (var loc in itemFlow.DemandSources) { #region Demand var demands = this.GetOrderIss(loc, item, winTime, nextWinTime, Enumerators.TracerType.Demand); itemFlow.AddOrderTracer(demands); #endregion //#region OnhandInv //OrderTracer onhandInv = this.GetOnhandInv_OrderTracer(loc, item); //itemFlow.AddOrderTracer(onhandInv); //#endregion //#region InspectInv //OrderTracer inspectInv = this.GetInspectInv_OrderTracer(loc, item); //itemFlow.AddOrderTracer(inspectInv); //#endregion #region OrderRct var orderRcts = this.GetOrderRct(loc, item, null, winTime); itemFlow.AddOrderTracer(orderRcts); #endregion #region OrderIss DateTime?startTime = null; if (true)//todo,config { startTime = orderTime; } var orderIsss = this.GetOrderIss(loc, item, startTime, winTime); itemFlow.AddOrderTracer(orderIsss); #endregion } decimal reqQty = this.GetReqQty(itemFlow.OrderTracers); return(reqQty); //double relativeLeadTime = demandChain.RelativeLeadTime; //decimal relativeQtyPer = demandChain.RelativeQtyPer; //string loc = demandChain.Loc; //string item = demandChain.Item; //string flowCode = demandChain.FlowCode; //DateTime? winTime = itemFlow.Flow.WindowTime.HasValue ? // itemFlow.Flow.WindowTime.Value : DateTime.Now.AddHours(itemFlow.Flow.FlowStrategy.LeadTime); //winTime = this.GetRelativeTime(itemFlow.Flow.WindowTime, demandChain); //DateTime? nextWinTime = this.GetRelativeTime(itemFlow.Flow.NextWindowTime, demandChain); //List<Plans> demandList = (from p in Plans // where Utilities.StringEq(loc, p.Loc) // && (flowCode == null || Utilities.StringEq(flowCode, p.FlowCode)) // && Utilities.StringEq(item, p.Item) // && (!winTime.HasValue || p.ReqTime >= winTime.Value)//greater equal // && (!nextWinTime.HasValue || p.ReqTime < nextWinTime.Value)//less than // && p.IRType == Enumerators.IRType.ISS // select p).ToList(); //decimal orderQty = demandList.Where(d => d.PlanType == Enumerators.PlanType.Orders).Sum(d => d.Qty); //decimal planQty = demandList.Where(d => d.PlanType == Enumerators.PlanType.Plans).Sum(d => d.Qty); //decimal demandQty = Math.Max(orderQty, planQty); //decimal safeInv = Math.Max(demandChain.SafeInv, itemFlow.SafeInv);//todo //decimal availableInv = this.GetAvailableInvQty(loc, item, winTime); //decimal reqQty = this.GetJITReqQty(availableInv, safeInv, demandQty); //if (reqQty > 0 && demandChain.IsTrace) //{ // itemFlow.DemandList.AddRange(demandList); //} //return reqQty; }
protected abstract decimal GetReqQty(ItemFlow itemFlow);