public virtual void ProcessTime(Flow flow) { if (flow == null || flow.FlowStrategy == null) throw new BusinessException("Key value is empty"); int weekInterval = flow.FlowStrategy.WeekInterval; if (!flow.WindowTime.HasValue) this.SetDefaultWindowTime(flow); string[][] windowTimes = this.CreateWindowTimes(flow.FlowStrategy); if (windowTimes == null) return; #region If restart after pausing for a long time if (!flow.WindowTime.HasValue || flow.WindowTime.Value.AddHours(-flow.FlowStrategy.EmLeadTime) < DateTime.Now) { flow.WindowTime = this.GetNextWindowTime(DateTime.Now, windowTimes, weekInterval); flow.OrderTime = this.GetNextOrderTime(flow.WindowTime, flow.FlowStrategy.LeadTime); flow.NextWindowTime = flow.WindowTime; flow.NextOrderTime = flow.OrderTime; flow.IsUpdateWindowTime = true; } #endregion if (!flow.OrderTime.HasValue || flow.OrderTime <= DateTime.Now) { flow.NextWindowTime = this.GetNextWindowTime(flow.WindowTime.Value, windowTimes, weekInterval); flow.NextOrderTime = this.GetNextOrderTime(flow.NextWindowTime, flow.FlowStrategy.LeadTime); flow.IsUpdateWindowTime = true; } }
public virtual void ProcessTime(Flow flow) { if (flow == null || flow.FlowStrategy == null) throw new BusinessException("Key value is empty"); if (flow.FlowStrategy.WindowTimeType == Enumerators.WindowTimeType.Fix) { int weekInterval = flow.FlowStrategy.WeekInterval; if (!flow.WindowTime.HasValue) this.SetDefaultWindowTime(flow); string[][] windowTimes = this.CreateWindowTimes(flow.FlowStrategy); if (windowTimes == null) return; #region If restart after pausing for a long time if (!flow.WindowTime.HasValue || flow.WindowTime.Value.AddHours(-flow.FlowStrategy.EmLeadTime) < DateTime.Now) { flow.WindowTime = this.GetNextWindowTime(DateTime.Now, windowTimes, weekInterval); flow.OrderTime = this.GetNextOrderTime(flow.WindowTime, flow.FlowStrategy.LeadTime); flow.NextWindowTime = flow.WindowTime; flow.NextOrderTime = flow.OrderTime; flow.IsUpdateWindowTime = true; } #endregion if (!flow.OrderTime.HasValue || flow.OrderTime <= DateTime.Now) { flow.NextWindowTime = this.GetNextWindowTime(flow.WindowTime.Value, windowTimes, weekInterval); flow.NextOrderTime = this.GetNextOrderTime(flow.NextWindowTime, flow.FlowStrategy.LeadTime); flow.IsUpdateWindowTime = true; } } else { #region 循环滚动固定间隔时间拉动 //todo 如果窗口时间小于当前时间要重新计算新窗口时间和订单时间。 if (flow.WindowTime.HasValue && flow.OrderTime.HasValue && flow.OrderTime <= DateTime.Now) { //while (flow.WindowTime.Value.AddHours(-flow.FlowStrategy.EmLeadTime) < DateTime.Now) //{ // flow.OrderTime = Utilities.GetNextRollingWindowTime(flow.OrderTime.Value, flow.FlowStrategy.LeadTime, this.RestTimes); // //改为增加固定间隔时间 // flow.WindowTime = Utilities.GetNextRollingWindowTime(flow.WindowTime.Value, flow.FlowStrategy.LeadTime, this.RestTimes); //} flow.NextOrderTime = Utilities.GetNextRollingWindowTime(flow.OrderTime.Value, flow.FlowStrategy.LeadTime, this.RestTimes); //改为增加固定间隔时间 flow.NextWindowTime = Utilities.GetNextRollingWindowTime(flow.WindowTime.Value, flow.FlowStrategy.LeadTime, this.RestTimes); flow.IsUpdateWindowTime = true; } #endregion } }
public void SetUp() { kb = new KB(null, null, null); flow1 = new Flow(); flow1.FlowStrategy = new FlowStrategy(); flow2 = new Flow(); flow2.FlowStrategy = new FlowStrategy(); string[] winTimes = new string[] { "06:00", "08:00", "10:00", "12:00", "14:00", "16:00", "18:00" }; flow2.FlowStrategy.MonWinTime = winTimes; flow2.FlowStrategy.TueWinTime = winTimes; flow2.FlowStrategy.WedWinTime = winTimes; flow2.FlowStrategy.ThuWinTime = winTimes; flow2.FlowStrategy.FriWinTime = winTimes; flow2.FlowStrategy.SatWinTime = null; flow2.FlowStrategy.SunWinTime = null; flow2.FlowStrategy.LeadTime = 1; }
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; }
public override void ProcessTime(Flow flow) { flow.WindowTime = DateTime.Now.AddHours(flow.FlowStrategy.LeadTime); }
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; }
private void ProcessRestTime(Flow flow, List<RestTime> restTimes) { if (!flow.WindowTime.HasValue) return; DateTime winTime = flow.WindowTime.Value; var query = restTimes.Where(r => r.StartTime < winTime && r.EndTime > winTime).OrderBy(r => r.StartTime).ToList(); //party/region rest time var q1 = query.Where(r => r.Party.Equals(flow.PartyTo)).ToList(); if (q1.Count > 0) { flow.WindowTime = q1[0].EndTime; return; } //global var q2 = query.Where(r => r.Party == null).ToList(); if (q2.Count > 0) { flow.WindowTime = q2[0].EndTime; return; } }
private DateTime GetStartTime(Flow flow, bool isEmergency) { if (isEmergency) { return DateTime.Now; } else { DateTime windowTime = this.GetWindowTime(flow, isEmergency); return Utilities.GetStartTime(windowTime, flow.FlowStrategy.LeadTime, this.RestTimes); } }
private DateTime GetWindowTime(Flow flow, bool isEmergency) { if (isEmergency) return DateTime.Now.AddHours(flow.FlowStrategy.EmLeadTime); else return flow.WindowTime.HasValue ? flow.WindowTime.Value.AddHours(-flow.FlowStrategy.WinTimeDiff) : DateTime.Now.AddHours(flow.FlowStrategy.LeadTime); }
private void DataValidCheck(Flow flow) { if (flow.FlowStrategy == null) { throw new BusinessException("FlowStrategy is key infomation, just tell me the strategy!"); } }
private DateTime GetStartTime(Flow flow, bool isEmergency) { if (isEmergency) { return DateTime.Now; } else { DateTime windowTime = this.GetWindowTime(flow, isEmergency); return windowTime.AddHours(-flow.FlowStrategy.LeadTime); } }
protected virtual void SetDefaultWindowTime(Flow flow) { if (flow == null || flow.FlowStrategy == null) throw new BusinessException("Key value is empty"); flow.WindowTime = DateTime.Now.AddHours(flow.FlowStrategy.LeadTime); }
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; }