public void GenerateItemFlowPlanDetail(ItemFlowPlan parentItemFlowPlan, ItemFlowPlan itemFlowPlan, decimal qtyPer, bool isAccum) { IList<ItemFlowPlanDetail> itemFlowPlanDetailList = new List<ItemFlowPlanDetail>(); itemFlowPlanDetailList = this.GetPreItemFlowPlanDetailByParent(parentItemFlowPlan, itemFlowPlan, qtyPer); if (isAccum) { itemFlowPlanDetailList = this.MergeItemFlowPlanDetail(itemFlowPlanDetailList, itemFlowPlan.ItemFlowPlanDetails); } itemFlowPlanDetailList = this.GetItemFlowPlanDetailView(itemFlowPlan, itemFlowPlanDetailList, true); itemFlowPlan.AddRangeItemFlowPlanDetail(itemFlowPlanDetailList); }
private void SaveItemFlowPlan(ItemFlowPlan itemFlowPlan) { //Clear Old this.ClearOldItemFlowPlan(itemFlowPlan.FlowDetail.Item.Code, "", ""); this.CreateItemFlowPlan(itemFlowPlan); //Create ItemFlowPlanDetails if (itemFlowPlan.ItemFlowPlanDetails != null && itemFlowPlan.ItemFlowPlanDetails.Count > 0) { foreach (ItemFlowPlanDetail itemFlowPlanDetail in itemFlowPlan.ItemFlowPlanDetails) { ItemFlowPlanDetailMgrE.CreateItemFlowPlanDetail(itemFlowPlanDetail); //Create ItemFlowPlanTracks if (itemFlowPlanDetail.ItemFlowPlanTracks != null && itemFlowPlanDetail.ItemFlowPlanTracks.Count > 0) { foreach (ItemFlowPlanTrack itemFlowPlanTrack in itemFlowPlanDetail.ItemFlowPlanTracks) { ItemFlowPlanTrackMgrE.CreateItemFlowPlanTrack(itemFlowPlanTrack); } } } } }
private void RunPlanning(IList<ItemFlowPlan> itemFlowPlanList, IList<SupplyChainDetail> supplyChainDetailList, ItemFlowPlan parentItemFlowPlan, int parentSupplyChainDetailId) { IList<SupplyChainDetail> scdList = this.GetSuppliers(supplyChainDetailList, parentSupplyChainDetailId); if (scdList.Count > 0) { foreach (SupplyChainDetail supplyChainDetail in scdList) { bool isEnd = false; string planType = string.Empty; if (supplyChainDetail.Flow.Type == BusinessConstants.CODE_MASTER_FLOW_TYPE_VALUE_PRODUCTION) { isEnd = true; planType = BusinessConstants.CODE_MASTER_PLAN_TYPE_VALUE_MPS; } else if (this.CheckSupplyChainDetailEnd(supplyChainDetail, supplyChainDetailList)) { isEnd = true; planType = BusinessConstants.CODE_MASTER_PLAN_TYPE_VALUE_MRP; } int index = -1; foreach (ItemFlowPlan ifp in itemFlowPlanList) { if (ifp.Flow.Code == supplyChainDetail.Flow.Code && ifp.FlowDetail.Id == supplyChainDetail.FlowDetail.Id) { index = itemFlowPlanList.IndexOf(ifp); break; } } ItemFlowPlan itemFlowPlan = new ItemFlowPlan(); IList<ItemFlowPlanDetail> itemFlowPlanDetailList = new List<ItemFlowPlanDetail>(); if (index < 0) { itemFlowPlan.Flow = supplyChainDetail.Flow; itemFlowPlan.FlowDetail = supplyChainDetail.FlowDetail; if (isEnd) { itemFlowPlan.PlanType = planType; if (planType == BusinessConstants.CODE_MASTER_PLAN_TYPE_VALUE_MPS) { //itemFlowPlan.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_CREATE; } else if (planType == BusinessConstants.CODE_MASTER_PLAN_TYPE_VALUE_MRP) { //itemFlowPlan.Status = BusinessConstants.CODE_MASTER_STATUS_VALUE_SUBMIT; } } ItemFlowPlanDetailMgrE.GenerateItemFlowPlanDetail(parentItemFlowPlan, itemFlowPlan, supplyChainDetail.QuantityPer); } else { //叠加需求 itemFlowPlan = itemFlowPlanList[index]; itemFlowPlanList.RemoveAt(index); ItemFlowPlanDetailMgrE.GenerateItemFlowPlanDetail(parentItemFlowPlan, itemFlowPlan, supplyChainDetail.QuantityPer, true); } if (itemFlowPlan.ItemFlowPlanDetails != null && itemFlowPlan.ItemFlowPlanDetails.Count > 0) { itemFlowPlanList.Add(itemFlowPlan); } if (isEnd) { //end continue; } else { this.RunPlanning(itemFlowPlanList, supplyChainDetailList, itemFlowPlan, supplyChainDetail.Id); } } } }
private void CloseOldItemFlowPlan(ItemFlowPlan itemFlowPlan, string status) { DetachedCriteria criteria = DetachedCriteria.For(typeof(ItemFlowPlan)); criteria.Add(Expression.Eq("Status", status)); criteria.Add(Expression.Eq("PlanType", itemFlowPlan.PlanType)); criteria.Add(Expression.Eq("Flow.Code", itemFlowPlan.Flow.Code)); criteria.Add(Expression.Eq("FlowDetail.Id", itemFlowPlan.FlowDetail.Id)); IList<ItemFlowPlan> itemFlowPlanList = CriteriaMgrE.FindAll<ItemFlowPlan>(criteria); if (itemFlowPlanList != null && itemFlowPlanList.Count > 0) { foreach (ItemFlowPlan ifp in itemFlowPlanList) { this.UpdateItemFlowPlan(ifp); } } }
private void CloseOldItemFlowPlan(ItemFlowPlan itemFlowPlan) { this.CloseOldItemFlowPlan(itemFlowPlan, ""); }
public IList<ItemFlowPlan> GetPreItemFlowPlan(string planType, string timePeriodType, DateTime startTime, DateTime endTime, string party, string flow, string item, string userCode) { IList<ItemFlowPlan> itemFlowPlanList = new List<ItemFlowPlan>(); DetachedCriteria criteria = DetachedCriteria.For(typeof(FlowDetail)); criteria.CreateAlias("Flow", "f"); if (flow != null && flow.Trim() != string.Empty) criteria.Add(Expression.Eq("f.Code", flow)); if (item != null && item.Trim() != string.Empty) criteria.Add(Expression.Eq("Item.Code", item)); if (planType == BusinessConstants.CODE_MASTER_PLAN_TYPE_VALUE_DMDSCHEDULE) criteria.Add(Expression.Eq("f.Type", BusinessConstants.CODE_MASTER_FLOW_TYPE_VALUE_DISTRIBUTION)); else if (planType == BusinessConstants.CODE_MASTER_PLAN_TYPE_VALUE_MPS) criteria.Add(Expression.Eq("f.Type", BusinessConstants.CODE_MASTER_FLOW_TYPE_VALUE_PRODUCTION)); else if (planType == BusinessConstants.CODE_MASTER_PLAN_TYPE_VALUE_MRP) criteria.Add(Expression.Eq("f.Type", BusinessConstants.CODE_MASTER_FLOW_TYPE_VALUE_PROCUREMENT)); criteria.AddOrder(Order.Asc("Flow.Code")); criteria.AddOrder(Order.Asc("Item.Code")); IList<FlowDetail> flowDetailList = CriteriaMgrE.FindAll<FlowDetail>(criteria); if (flowDetailList != null && flowDetailList.Count > 0) { foreach (FlowDetail fd in flowDetailList) { ItemFlowPlan ifp = this.GetItemFlowPlan(fd.Flow.Code, fd.Id, planType); if (ifp == null) { ifp = new ItemFlowPlan(); ifp.Flow = fd.Flow; ifp.FlowDetail = fd; ifp.PlanType = planType; this.CreateItemFlowPlan(ifp); } itemFlowPlanList.Add(ifp); } } return itemFlowPlanList; }
public void GenerateItemFlowPlanDetail(ItemFlowPlan parentItemFlowPlan, ItemFlowPlan itemFlowPlan, decimal qtyPer) { this.GenerateItemFlowPlanDetail(parentItemFlowPlan, itemFlowPlan, qtyPer, false); }
public virtual void UpdateItemFlowPlan(ItemFlowPlan entity) { entityDao.UpdateItemFlowPlan(entity); }
public virtual void CreateItemFlowPlan(ItemFlowPlan entity) { Create(entity); }
public IList<ItemFlowPlanDetail> GetItemFlowPlanDetailView(ItemFlowPlan itemFlowPlan, IList<ItemFlowPlanDetail> itemFlowPlanDetailList, bool computePlanQty) { if (itemFlowPlan.PlanType == BusinessConstants.CODE_MASTER_PLAN_TYPE_VALUE_DMDSCHEDULE) { if (itemFlowPlanDetailList != null && itemFlowPlanDetailList.Count > 0) { foreach (ItemFlowPlanDetail itemFlowPlanDetail in itemFlowPlanDetailList) { DateTime startWinTime = itemFlowPlanDetail.ReqDate.Date; DateTime endWinTime = this.GetDmdEndTime(itemFlowPlanDetail, itemFlowPlanDetailList); IList<OrderLocationTransaction> orderLocTransList = new List<OrderLocationTransaction>(); if (itemFlowPlanDetailList.IndexOf(itemFlowPlanDetail) == itemFlowPlanDetailList.Count - 1) { orderLocTransList = this.GetOpenOrderLocTransInByFlow(itemFlowPlan.Flow.Code, itemFlowPlan.FlowDetail.Item.Code, startWinTime, null); } else { orderLocTransList = this.GetOpenOrderLocTransInByFlow(itemFlowPlan.Flow.Code, itemFlowPlan.FlowDetail.Item.Code, startWinTime, endWinTime); } this.RefreshItemFlowPlanDetail(itemFlowPlanDetail, orderLocTransList); } if (DateTime.Compare(DateTime.Now.Date, itemFlowPlanDetailList[0].ReqDate) < 0) { IList<OrderLocationTransaction> orderLocTransList = this.GetOpenOrderLocTransInByFlow(itemFlowPlan.Flow.Code, itemFlowPlan.FlowDetail.Item.Code, DateTime.Now.Date, itemFlowPlanDetailList[0].ReqDate); IList<ItemFlowPlanDetail> orderDemandList = this.ConvertOrderDmdToItemFlowPlanDetail(itemFlowPlan, orderLocTransList); foreach (ItemFlowPlanDetail ifpd in itemFlowPlanDetailList) { orderDemandList.Add(ifpd); } itemFlowPlanDetailList = orderDemandList; } } else { IList<OrderLocationTransaction> orderLocTransList = this.GetOpenOrderLocTransInByFlow(itemFlowPlan.Flow.Code, itemFlowPlan.FlowDetail.Item.Code, DateTime.Now.Date, null); itemFlowPlanDetailList = this.ConvertOrderDmdToItemFlowPlanDetail(itemFlowPlan, orderLocTransList); } } else if (itemFlowPlan.PlanType == BusinessConstants.CODE_MASTER_PLAN_TYPE_VALUE_MPS) { decimal PAB = this.GetDmdStartPAB(WorkCalendarMgrE.GetDayShiftStart(DateTime.Now, itemFlowPlan.Flow.PartyTo.Code), "", itemFlowPlan.FlowDetail.Item.Code); //itemFlowPlan.PAB = PAB; DateTime maxDate = DateTime.Now.Date; if (itemFlowPlanDetailList != null && itemFlowPlanDetailList.Count > 0) { maxDate = itemFlowPlanDetailList[itemFlowPlanDetailList.Count - 1].ReqDate; } IList<OrderLocationTransaction> orderLocTransList = this.GetOpenOrderLocTransInByFlow(itemFlowPlan.Flow.Code, itemFlowPlan.FlowDetail.Item.Code, DateTime.Now.Date, null); if (orderLocTransList != null && orderLocTransList.Count > 0) { DateTime maxWinTime = orderLocTransList[orderLocTransList.Count - 1].OrderDetail.OrderHead.WindowTime; maxWinTime = WorkCalendarMgrE.GetDayShiftStart(maxWinTime, itemFlowPlan.Flow.PartyTo.Code); if (DateTime.Compare(maxDate, maxWinTime) < 0) { maxDate = maxWinTime; } } DateTime date = DateTime.Now.Date; while (date <= maxDate) { ItemFlowPlanDetail itemFlowPlanDetail = new ItemFlowPlanDetail(); itemFlowPlanDetail.ItemFlowPlan = itemFlowPlan; itemFlowPlanDetail.GrossDemand = 0; itemFlowPlanDetail.OrderRemainQty = 0; itemFlowPlanDetail.PlanQty = 0; foreach (ItemFlowPlanDetail ifpd in itemFlowPlanDetailList) { if (DateTime.Compare(ifpd.ReqDate, date) == 0) { itemFlowPlanDetail = ifpd; break; } } foreach (OrderLocationTransaction orderLocTrans in orderLocTransList) { DateTime winTime = orderLocTrans.OrderDetail.OrderHead.WindowTime; if (DateTime.Compare(date, winTime) <= 0 && DateTime.Compare(date.AddDays(1), winTime) > 0) { ItemFlowPlanTrack itemFlowPlanTrack = new ItemFlowPlanTrack(); itemFlowPlanTrack.ItemFlowPlanDetail = itemFlowPlanDetail; itemFlowPlanTrack.OrderLocationTransaction = orderLocTrans; //itemFlowPlanTrack.DemandQty = orderLocTrans.RemainQty; itemFlowPlanDetail.AddItemFlowPlanTrack(itemFlowPlanTrack); } } date = date.AddDays(1); } } itemFlowPlanDetailList = this.PlanningAndScheduling(itemFlowPlanDetailList, itemFlowPlan, computePlanQty); return itemFlowPlanDetailList; }
public IList<ItemFlowPlanDetail> GetItemFlowPlanDetailView(ItemFlowPlan itemFlowPlan, bool computePlanQty) { IList<ItemFlowPlanDetail> itemFlowPlanDetailList = this.GetActiveItemFlowPlanDetailListSort(itemFlowPlan.Id); return this.GetItemFlowPlanDetailView(itemFlowPlan, itemFlowPlanDetailList, computePlanQty); }
public IList<ItemFlowPlanDetail> GetPreItemFlowPlanDetailByParent(ItemFlowPlan parentItemFlowPlan, ItemFlowPlan itemFlowPlan, decimal qtyPer) { IList<ItemFlowPlanDetail> itemFlowPlanDetailList = new List<ItemFlowPlanDetail>(); if (parentItemFlowPlan.ItemFlowPlanDetails != null && parentItemFlowPlan.ItemFlowPlanDetails.Count > 0) { DateTime dmdStartTime = DateTime.Now; DateTime dmdEndTime = DateTime.Now; foreach (ItemFlowPlanDetail parentItemFlowPlanDetail in parentItemFlowPlan.ItemFlowPlanDetails) { //确定计划区间/需求时界 double leadTime = parentItemFlowPlanDetail.ItemFlowPlan.Flow.LeadTime == null ? 0 : Convert.ToDouble((decimal)(parentItemFlowPlanDetail.ItemFlowPlan.Flow.LeadTime)); if (parentItemFlowPlan.ItemFlowPlanDetails.IndexOf(parentItemFlowPlanDetail) == 0) { dmdStartTime = parentItemFlowPlanDetail.ReqDate.AddHours(-1 * leadTime); //WorkCalendar if (itemFlowPlan.PlanType == BusinessConstants.CODE_MASTER_PLAN_TYPE_VALUE_MPS || itemFlowPlan.PlanType == BusinessConstants.CODE_MASTER_PLAN_TYPE_VALUE_MRP) { dmdStartTime = WorkCalendarMgrE.GetWorkTime(dmdStartTime, parentItemFlowPlan.Flow.PartyFrom.Code, true); } } dmdEndTime = this.GetDmdEndTime(parentItemFlowPlanDetail, parentItemFlowPlan.ItemFlowPlanDetails).AddHours(-1 * leadTime); //WorkCalendar if (itemFlowPlan.PlanType == BusinessConstants.CODE_MASTER_PLAN_TYPE_VALUE_MPS || itemFlowPlan.PlanType == BusinessConstants.CODE_MASTER_PLAN_TYPE_VALUE_MRP) { dmdEndTime = WorkCalendarMgrE.GetWorkTime(dmdEndTime, parentItemFlowPlan.Flow.PartyFrom.Code, true); } if (DateTime.Compare(DateTime.Now, dmdStartTime) > 0) { //Rogue Town! dmdStartTime = dmdEndTime; continue; } ItemFlowPlanDetail itemFlowPlanDetail = new ItemFlowPlanDetail(); itemFlowPlanDetail.ReqDate = WorkCalendarMgrE.GetDayShiftStart(dmdStartTime, itemFlowPlan.Flow.PartyTo.Code); //毛需求 itemFlowPlanDetail.GrossDemand = (Math.Max(parentItemFlowPlanDetail.OrderRemainQty, parentItemFlowPlanDetail.PlanQty)) * qtyPer; itemFlowPlanDetailList.Add(itemFlowPlanDetail); //Rogue Town! dmdStartTime = dmdEndTime; } } return itemFlowPlanDetailList; }
public IList<ItemFlowPlanDetail> PlanningAndScheduling(IList<ItemFlowPlanDetail> preItemFlowPlanDetailList, ItemFlowPlan itemFlowPlan, bool computePlanQty) { IList<ItemFlowPlanDetail> itemFlowPlanDetailList = new List<ItemFlowPlanDetail>(); decimal PAB = 0;// itemFlowPlan.PAB; decimal safeInv = itemFlowPlan.FlowDetail.SafeStock == null ? 0 : (decimal)(itemFlowPlan.FlowDetail.SafeStock); foreach (ItemFlowPlanDetail itemFlowPlanDetail in preItemFlowPlanDetailList) { //计划量 decimal planQty = itemFlowPlanDetail.PlanQty; if (computePlanQty) { planQty = itemFlowPlanDetail.GrossDemand - (PAB + itemFlowPlanDetail.OrderRemainQty) + safeInv; planQty = this.GetFinalPlanQty(planQty, itemFlowPlan.FlowDetail); itemFlowPlanDetail.PlanQty = planQty; } //区间期末PAB PAB = PAB + itemFlowPlanDetail.OrderRemainQty + planQty - itemFlowPlanDetail.GrossDemand; itemFlowPlanDetail.PAB = PAB; if (planQty > 0) { itemFlowPlanDetail.ItemFlowPlan = itemFlowPlan; itemFlowPlanDetailList.Add(itemFlowPlanDetail); } } return itemFlowPlanDetailList; }
public IList<ItemFlowPlanDetail> ConvertOrderDmdToItemFlowPlanDetail(ItemFlowPlan itemFlowPlan, IList<OrderLocationTransaction> orderLocTransList) { IList<ItemFlowPlanDetail> itemFlowPlanDetailList = new List<ItemFlowPlanDetail>(); List<DateTime> dateTimeList = this.CollectDateList(orderLocTransList); if (dateTimeList.Count > 0) { foreach (DateTime date in dateTimeList) { ItemFlowPlanDetail itemFlowPlanDetail = new ItemFlowPlanDetail(); itemFlowPlanDetail.ItemFlowPlan = itemFlowPlan; itemFlowPlanDetail.ReqDate = date; itemFlowPlanDetail.OrderRemainQty = 0; foreach (OrderLocationTransaction orderLocTrans in orderLocTransList) { if (DateTime.Compare(date, orderLocTrans.OrderDetail.OrderHead.WindowTime.Date) == 0) { itemFlowPlanDetail.OrderRemainQty += orderLocTrans.RemainQty; ItemFlowPlanTrack itemFlowPlanTrack = new ItemFlowPlanTrack(); itemFlowPlanTrack.ItemFlowPlanDetail = itemFlowPlanDetail; itemFlowPlanTrack.OrderLocationTransaction = orderLocTrans; //itemFlowPlanTrack.DemandQty = orderLocTrans.RemainQty; itemFlowPlanDetail.AddItemFlowPlanTrack(itemFlowPlanTrack); } } if (itemFlowPlanDetail.OrderRemainQty > 0) { itemFlowPlanDetailList.Add(itemFlowPlanDetail); } } } return itemFlowPlanDetailList; }
public decimal GetStartPAB(ItemFlowPlan ifp, DateTime date) { decimal startPAB = 0; string loc = string.Empty; if (ifp.Flow.Code == ifp.FlowDetail.Flow.Code) { loc = ifp.FlowDetail.DefaultLocationTo == null ? string.Empty : ifp.FlowDetail.DefaultLocationTo.Code; } else { //Reference flow loc = ifp.Flow.LocationTo == null ? string.Empty : ifp.Flow.LocationTo.Code; } LocationDetail locDet = LocDetMgrE.FindLocationDetail(loc, ifp.FlowDetail.Item.Code, date); if (locDet != null) startPAB = locDet.Qty; return startPAB; }
public virtual void UpdateItemFlowPlan(ItemFlowPlan entity) { Update(entity); }
public virtual void CreateItemFlowPlan(ItemFlowPlan entity) { entityDao.CreateItemFlowPlan(entity); }
public virtual void DeleteItemFlowPlan(ItemFlowPlan entity) { Delete(entity); }
public virtual void DeleteItemFlowPlan(ItemFlowPlan entity) { entityDao.DeleteItemFlowPlan(entity); }
public IList<ItemFlowPlanDetail> GetItemFlowPlanDetailRangeOrderByReqDate(ItemFlowPlan itemFlowPlan, string timePeriodType, List<DateTime> dateList, bool autoPlan) { IList<ItemFlowPlanDetail> ifpdList = new List<ItemFlowPlanDetail>(); DateTime planStartTime = DateTimeHelper.GetStartTime(timePeriodType, DateTime.Now.Date); decimal PAB = itemFlowPlan.StartPAB; foreach (DateTime date in dateList) { ItemFlowPlanDetail ifpd = this.GetItemFlowPlanDetail(itemFlowPlan.Id, timePeriodType, date); if (ifpd == null) { ifpd = new ItemFlowPlanDetail(); ifpd.ItemFlowPlan = itemFlowPlan; ifpd.TimePeriodType = timePeriodType; ifpd.ReqDate = date; ifpd.PlanQty = 0;//todo } ifpd.GrossDemand = 0;//todo IList<ItemFlowPlanTrack> ifptList = ItemFlowPlanTrackMgrE.GetItemFlowPlanTrackList(ifpd, null, null); if (ifptList != null && ifptList.Count > 0) { foreach (ItemFlowPlanTrack ifpt in ifptList) { ifpd.GrossDemand += ifpt.ReferencePlanDetail.PlanQty * ifpt.Rate; } } ifpd.OrderRemainQty = 0;//todo //auto Plan,已有计划不再重排 if (autoPlan && ifpd.PlanQty == 0) { decimal safeInv = ifpd.ItemFlowPlan.FlowDetail.SafeStock.HasValue ? (decimal)ifpd.ItemFlowPlan.FlowDetail.SafeStock : 0; decimal planQty = ifpd.GrossDemand + safeInv - PAB; if (planQty > 0) { if (ifpd.ItemFlowPlan.FlowDetail.BatchSize.HasValue) { decimal batchSize = (decimal)ifpd.ItemFlowPlan.FlowDetail.BatchSize; if (batchSize > 0) planQty = batchSize * Math.Ceiling(planQty / batchSize); } ifpd.PlanQty = planQty; } } PAB += Math.Max(ifpd.PlanQty, ifpd.OrderRemainQty) - ifpd.GrossDemand; ifpd.PAB = PAB; ifpdList.Add(ifpd); } return ifpdList; }