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; }
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); }
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 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 override bool Equals(object obj) { ItemFlow another = obj as ItemFlow; if (another == null) { return(false); } else { return(this.ID == another.ID); } }
protected override decimal GetReqQty(ItemFlow itemFlow) { 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, itemFlow.Item, winTime, nextWinTime, Enumerators.TracerType.Demand); itemFlow.AddOrderTracer(demands); #endregion #region OnhandInv OrderTracer onhandInv = this.GetOnhandInv_OrderTracer(loc, itemFlow.Item); itemFlow.AddOrderTracer(onhandInv); #endregion #region InspectInv OrderTracer inspectInv = this.GetInspectInv_OrderTracer(loc, itemFlow.Item); itemFlow.AddOrderTracer(inspectInv); #endregion #region OrderRct var orderRcts = this.GetOrderRct(loc, itemFlow.Item, null, winTime); itemFlow.AddOrderTracer(orderRcts); #endregion #region OrderIss DateTime? startTime = null; if (true)//todo,config { startTime = orderTime; } //var orderIsss = this.GetOrderIss(loc, itemFlow.Item, startTime, winTime); //考虑过期的待发需求 var orderIsss = this.GetOrderIss(loc, itemFlow.Item, null, winTime); itemFlow.AddOrderTracer(orderIsss); #endregion } decimal reqQty = this.GetReqQty(itemFlow.LocTo, itemFlow.OrderTracers); return reqQty; }
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; }
public void SetUp() { engine = new Engine(); flow = new Flow(); flow.FlowStrategy = new FlowStrategy(); itemFlow = new ItemFlow(); itemFlow.Item = new Item(); itemFlow.Flow = flow; itemFlow.Item.ItemCode = "Item"; itemFlow.LocFrom = "LocFrom"; itemFlow.LocTo = "LocTo"; ItemFlows = new List<ItemFlow>(); ItemFlows.Add(itemFlow); container = new EngineContainer(); container.ItemFlows = ItemFlows; }
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 ProcessReqQty(ItemFlow itemFlow) { IOAE processor = this.GetProcessor(itemFlow.Flow.FlowStrategy.Strategy); if (processor != null) processor.ProcessReqQty(itemFlow); }
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; }
public void SetUp() { itemCode = "RM_A"; locFrom = null; locTo = "RM"; engine = new Engine(); container = new EngineContainer(); flow = new Flow(); item = new Item(); itemFlow = new ItemFlow(); ItemFlows = new List<ItemFlow>(); invBalance = new InvBalance(); invBalances = new List<InvBalance>(); plans = new List<Plans>(); demandChains = new List<DemandChain>(); flow.Code = "Flow01"; item.ItemCode = itemCode; flow.FlowStrategy = new FlowStrategy(); flow.FlowStrategy.Strategy = Enumerators.Strategy.JIT; itemFlow.Flow = flow; itemFlow.Item = item; itemFlow.LocFrom = locFrom; itemFlow.LocTo = locTo; itemFlow.MaxInv = 0; itemFlow.SafeInv = 50; ItemFlows.Add(itemFlow); time = DateTime.Parse(DateTime.Now.AddHours(1).ToString("yyyy-MM-dd HH") + ":00"); string[] winTimes = new string[] { "00:00", "01:00", "02:00", "03:00", "04:00", "05:00", "06:00", "07:00", "08:00", "09:00", "10:00","11:00", "12:00","13:00", "14:00","15:00", "16:00","17:00", "18:00","19:00", "20:00","21:00", "22:00","23:00" }; flow.FlowStrategy.MonWinTime = winTimes; flow.FlowStrategy.TueWinTime = winTimes; flow.FlowStrategy.WedWinTime = winTimes; flow.FlowStrategy.ThuWinTime = winTimes; flow.FlowStrategy.FriWinTime = winTimes; flow.FlowStrategy.SatWinTime = winTimes; flow.FlowStrategy.SunWinTime = winTimes; flow.WindowTime = time; flow.OrderTime = DateTime.Now; flow.NextOrderTime = null; flow.FlowStrategy.LeadTime = 0.5; invBalance.Item = item; invBalance.Loc = locTo; invBalance.Qty = 100; invBalances.Add(invBalance); //RCT:20 plan = new Plans(); plan.Loc = locTo; plan.Item = item; plan.ReqTime = DateTime.Now.AddDays(-1); plan.OrderedQty = 100; plan.FinishedQty = 80; plan.PlanType = Enumerators.PlanType.Orders; plan.IRType = Enumerators.IRType.RCT; plans.Add(plan); //RCT:50 plan = new Plans(); plan.Loc = locTo; plan.Item = item; plan.ReqTime = DateTime.Now; plan.OrderedQty = 50; plan.FinishedQty = 0; plan.PlanType = Enumerators.PlanType.Orders; plan.IRType = Enumerators.IRType.RCT; plans.Add(plan); //RCT:30(Ignore) plan = new Plans(); plan.Loc = locTo; plan.Item = item; plan.ReqTime = time; plan.OrderedQty = 30; plan.FinishedQty = 0; plan.PlanType = Enumerators.PlanType.Orders; plan.IRType = Enumerators.IRType.RCT; plans.Add(plan); //ISS:120 plan = new Plans(); plan.Loc = locTo; plan.Item = item; plan.ReqTime = DateTime.Now; plan.OrderedQty = 120; plan.FinishedQty = 0; plan.PlanType = Enumerators.PlanType.Orders; plan.IRType = Enumerators.IRType.ISS; plans.Add(plan); //ISS:500(Ignore) plan = new Plans(); plan.Loc = locTo; plan.Item = item; plan.ReqTime = time.AddHours(1); plan.OrderedQty = 500; plan.FinishedQty = 0; plan.PlanType = Enumerators.PlanType.Orders; plan.IRType = Enumerators.IRType.ISS; plans.Add(plan); //ISS:450(Demand) plan = new Plans(); plan.Loc = locTo; plan.Item = item; plan.ReqTime = time; plan.OrderedQty = 450; plan.FinishedQty = 0; plan.PlanType = Enumerators.PlanType.Orders; plan.IRType = Enumerators.IRType.ISS; plans.Add(plan); container.ItemFlows = ItemFlows; container.InvBalances = invBalances; container.Plans = plans; container.DemandChains = demandChains; }
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; orderTracer.Location = itemFlow.LocTo; //安全库存设置是目的库位的 return orderTracer; }
public void SetUp() { itemCode = "RM_A"; locFrom = null; locTo = "RM"; engine = new Engine(); container = new EngineContainer(); flow = new Flow(); item = new Item(); itemFlow = new ItemFlow(); ItemFlows = new List<ItemFlow>(); invBalance = new InvBalance(); invBalances = new List<InvBalance>(); plans = new List<Plans>(); flow.FlowStrategy = new FlowStrategy(); flow.FlowStrategy.Strategy = Enumerators.Strategy.KB; itemFlow.Flow = flow; item.ItemCode = itemCode; itemFlow.Item = item; itemFlow.LocFrom = locFrom; itemFlow.LocTo = locTo; itemFlow.MaxInv = 400; itemFlow.SafeInv = 200; itemFlow.UC = 50; ItemFlows.Add(itemFlow); string[] winTimes = new string[] { "11:00" }; flow.FlowStrategy.MonWinTime = winTimes; flow.FlowStrategy.TueWinTime = winTimes; flow.FlowStrategy.WedWinTime = winTimes; flow.FlowStrategy.ThuWinTime = winTimes; flow.FlowStrategy.FriWinTime = winTimes; flow.FlowStrategy.SatWinTime = winTimes; flow.FlowStrategy.SunWinTime = winTimes; flow.WindowTime = DateTime.Parse(DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") + " 11:00"); flow.NextOrderTime = null; invBalance.Item = item; invBalance.Loc = locTo; invBalance.Qty = 300; invBalances.Add(invBalance); plan = new Plans(); plan.Loc = locTo; plan.Item = item; plan.ReqTime = DateTime.Now.AddDays(-1); plan.OrderedQty = 100; plan.FinishedQty = 80; plan.PlanType = Enumerators.PlanType.Orders; plan.IRType = Enumerators.IRType.RCT; plans.Add(plan); plan = new Plans(); plan.Loc = locTo; plan.Item = item; plan.ReqTime = DateTime.Now; plan.OrderedQty = 50; plan.FinishedQty = 0; plan.PlanType = Enumerators.PlanType.Orders; plan.IRType = Enumerators.IRType.RCT; plans.Add(plan); plan = new Plans(); plan.Loc = locTo; plan.Item = item; plan.ReqTime = DateTime.Now.AddDays(2); plan.OrderedQty = 500; plan.FinishedQty = 0; plan.PlanType = Enumerators.PlanType.Orders; plan.IRType = Enumerators.IRType.RCT; plans.Add(plan); plan = new Plans(); plan.Loc = locTo; plan.Item = item; plan.ReqTime = DateTime.Now; plan.OrderedQty = 500; plan.FinishedQty = 0; plan.PlanType = Enumerators.PlanType.Plans; plan.IRType = Enumerators.IRType.RCT; plans.Add(plan); plan = new Plans(); plan.Loc = locTo; plan.Item = item; plan.ReqTime = DateTime.Now; plan.OrderedQty = 450; plan.FinishedQty = 0; plan.PlanType = Enumerators.PlanType.Orders; plan.IRType = Enumerators.IRType.ISS; plans.Add(plan); container.ItemFlows = ItemFlows; container.InvBalances = invBalances; container.Plans = plans; }
public void Test_IsUpdateWindowTime() { ItemFlow itemFlow1 = new ItemFlow(); itemFlow1.Flow = flow; itemFlow1.Item = item; itemFlow1.LocFrom = locFrom; itemFlow1.LocTo = locTo; itemFlow1.MaxInv = 400; itemFlow1.SafeInv = 200; itemFlow1.UC = 50; ItemFlows.Add(itemFlow1); engine.TellMeDemands(container); var result = container.ItemFlows; Assert.AreEqual(true, result[0].Flow.IsUpdateWindowTime); Assert.AreEqual(true, result[1].Flow.IsUpdateWindowTime); }
protected abstract decimal GetReqQty(ItemFlow itemFlow);
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); //} }
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; }
private void DataValidCheck(ItemFlow itemFlow) { if (itemFlow.Flow == null) { throw new BusinessException("Flow is key infomation, it can't be empty!"); } }