private ItemFlowPlanDetail GetSupplyFlow(string item, string timePeriodType, DateTime reqDate)
        {
            IList <ItemFlowPlan> ifpList = this.GetPreItemFlowPlan(BusinessConstants.CODE_MASTER_PLAN_TYPE_VALUE_MPS, timePeriodType, DateTime.Now, DateTime.Now, null, null, item, null);

            if (ifpList.Count == 0)
            {
                ifpList = this.GetPreItemFlowPlan(BusinessConstants.CODE_MASTER_PLAN_TYPE_VALUE_MRP, timePeriodType, DateTime.Now, DateTime.Now, null, null, item, null);
            }

            //todo,bid
            ItemFlowPlanDetail ifpd = null;

            if (ifpList.Count > 0)
            {
                ItemFlowPlan ifp = ifpList[0];
                ifpd = ItemFlowPlanDetailMgr.GetItemFlowPlanDetail(ifp.Id, timePeriodType, reqDate);
                if (ifpd == null)
                {
                    ifpd = new ItemFlowPlanDetail();
                    ifpd.ItemFlowPlan   = ifp;
                    ifpd.TimePeriodType = timePeriodType;
                    ifpd.ReqDate        = reqDate;
                    ifpd.PlanQty        = 0;
                    ItemFlowPlanDetailMgr.CreateItemFlowPlanDetail(ifpd);
                }
            }
            return(ifpd);
        }
        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)
                {
                    ItemFlowPlanDetailMgr.CreateItemFlowPlanDetail(itemFlowPlanDetail);

                    //Create ItemFlowPlanTracks
                    if (itemFlowPlanDetail.ItemFlowPlanTracks != null && itemFlowPlanDetail.ItemFlowPlanTracks.Count > 0)
                    {
                        foreach (ItemFlowPlanTrack itemFlowPlanTrack in itemFlowPlanDetail.ItemFlowPlanTracks)
                        {
                            ItemFlowPlanTrackMgr.CreateItemFlowPlanTrack(itemFlowPlanTrack);
                        }
                    }
                }
            }
        }
Exemple #3
0
        private 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);
        }
Exemple #4
0
        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 = ItemFlowPlanTrackMgr.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);
        }
        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 = CriteriaMgr.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);
        }
Exemple #6
0
        private 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 = WorkCalendarMgr.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 = WorkCalendarMgr.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 = WorkCalendarMgr.GetDayShiftStart(dmdStartTime, itemFlowPlan.Flow.PartyTo.Code);

                    //毛需求
                    itemFlowPlanDetail.GrossDemand = (Math.Max(parentItemFlowPlanDetail.OrderRemainQty, parentItemFlowPlanDetail.PlanQty)) * qtyPer;

                    itemFlowPlanDetailList.Add(itemFlowPlanDetail);

                    //Rogue Town!
                    dmdStartTime = dmdEndTime;
                }
            }

            return(itemFlowPlanDetailList);
        }
Exemple #7
0
        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 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 = CriteriaMgr.FindAll <ItemFlowPlan>(criteria);

            if (itemFlowPlanList != null && itemFlowPlanList.Count > 0)
            {
                foreach (ItemFlowPlan ifp in itemFlowPlanList)
                {
                    this.UpdateItemFlowPlan(ifp);
                }
            }
        }
        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 = LocDetMgr.FindLocationDetail(loc, ifp.FlowDetail.Item.Code, date);

            if (locDet != null)
            {
                startPAB = locDet.Qty;
            }

            return(startPAB);
        }
 public virtual void DeleteItemFlowPlan(ItemFlowPlan entity)
 {
     Delete(entity);
 }
Exemple #11
0
        private 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 virtual void CreateItemFlowPlan(ItemFlowPlan entity)
 {
     entityDao.CreateItemFlowPlan(entity);
 }
        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;
                            }
                        }

                        ItemFlowPlanDetailMgr.GenerateItemFlowPlanDetail(parentItemFlowPlan, itemFlowPlan, supplyChainDetail.QuantityPer);
                    }
                    else
                    {
                        //叠加需求
                        itemFlowPlan = itemFlowPlanList[index];
                        itemFlowPlanList.RemoveAt(index);

                        ItemFlowPlanDetailMgr.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);
                    }
                }
            }
        }
 public virtual void UpdateItemFlowPlan(ItemFlowPlan entity)
 {
     entityDao.UpdateItemFlowPlan(entity);
 }
 private void CloseOldItemFlowPlan(ItemFlowPlan itemFlowPlan)
 {
     this.CloseOldItemFlowPlan(itemFlowPlan, "");
 }
Exemple #16
0
        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(WorkCalendarMgr.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 = WorkCalendarMgr.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);
        }
Exemple #17
0
        public IList <ItemFlowPlanDetail> GetItemFlowPlanDetailView(ItemFlowPlan itemFlowPlan, bool computePlanQty)
        {
            IList <ItemFlowPlanDetail> itemFlowPlanDetailList = this.GetActiveItemFlowPlanDetailListSort(itemFlowPlan.Id);

            return(this.GetItemFlowPlanDetailView(itemFlowPlan, itemFlowPlanDetailList, computePlanQty));
        }
 public virtual void UpdateItemFlowPlan(ItemFlowPlan entity)
 {
     Update(entity);
 }
 public virtual void DeleteItemFlowPlan(ItemFlowPlan entity)
 {
     entityDao.DeleteItemFlowPlan(entity);
 }
Exemple #20
0
 public void GenerateItemFlowPlanDetail(ItemFlowPlan parentItemFlowPlan, ItemFlowPlan itemFlowPlan, decimal qtyPer)
 {
     this.GenerateItemFlowPlanDetail(parentItemFlowPlan, itemFlowPlan, qtyPer, false);
 }
Exemple #21
0
    public void Save()
    {
        if (GV_List.Rows.Count == 0 || dt.Rows.Count == 0)
        {
            return;
        }

        int rowIndex = 0;

        foreach (DataRow dr in dt.Rows)
        {
            if (dr["Type"].ToString() == BusinessConstants.PLAN_VIEW_TYPE_PLAN)
            {
                string timePeriodType = dr["TimePeriodType"].ToString();
                for (int j = 0; j < GV_List.Columns.Count - _firstDynColIndex; j++)
                {
                    int          itemFlowPlanId = (int)dr["ItemFlowPlanId"];
                    DateTime     date           = this.dateList[j];
                    ItemFlowPlan ifp            = TheItemFlowPlanMgr.LoadItemFlowPlan(itemFlowPlanId);
                    try
                    {
                        string  editControlID = this.GetDynControlID(j);
                        TextBox _editControl  = (TextBox)GV_List.Rows[rowIndex].Cells[j + _firstDynColIndex].FindControl(editControlID);
                        string  colName       = "DynCol_" + j.ToString();
                        decimal newValue      = 0;
                        if (_editControl.Text.Trim() != string.Empty)
                        {
                            newValue = decimal.Parse(_editControl.Text.Trim());
                        }

                        decimal oldValue = (decimal)dr[colName];

                        if (newValue != 0 || oldValue != 0)
                        {
                            ItemFlowPlanDetail ifpd = new ItemFlowPlanDetail();
                            ifpd.ItemFlowPlan   = ifp;
                            ifpd.TimePeriodType = timePeriodType;
                            ifpd.ReqDate        = date;
                            ifpd.PlanQty        = newValue;
                            //ifpd.LastModifyDate = DateTime.Now;
                            //ifpd.LastModifyUser = this.Session["UserCode"].ToString();

                            if (ifpd.PlanQty < 0)
                            {
                                ShowErrorMessage("MRP.Error.Save", ifp.FlowDetail.Item.Code, GetHeaderText(timePeriodType, date));
                                return;
                            }

                            TheItemFlowPlanDetailMgr.SaveItemFlowPlanDetail(ifpd);
                            dr[colName] = newValue;
                            ShowSuccessMessage("Common.Business.Result.Save.Successfully");
                        }
                    }
                    catch (Exception)
                    {
                        ShowErrorMessage("MRP.Error.Save", ifp.FlowDetail.Item.Code, GetHeaderText(timePeriodType, date));
                        return;
                    }
                }
            }
            rowIndex++;
        }

        this.ListView();
    }
 public virtual void CreateItemFlowPlan(ItemFlowPlan entity)
 {
     Create(entity);
 }