Пример #1
0
        public void AddItemFlowPlanDetail(ItemFlowPlanDetail itemFlowPlanDetail)
        {
            if (this.ItemFlowPlanDetails == null)
            {
                this.ItemFlowPlanDetails = new List<ItemFlowPlanDetail>();
            }

            this.ItemFlowPlanDetails.Add(itemFlowPlanDetail);
        }
Пример #2
0
        public void AddItemFlowPlanDetail(ItemFlowPlanDetail itemFlowPlanDetail)
        {
            if (this.ItemFlowPlanDetails == null)
            {
                this.ItemFlowPlanDetails = new List <ItemFlowPlanDetail>();
            }

            this.ItemFlowPlanDetails.Add(itemFlowPlanDetail);
        }
 public void ClearOldRelation(ItemFlowPlanDetail mstrIfpd, ItemFlowPlanDetail refIfpd, OrderLocationTransaction orderLocTrans)
 {
     IList<ItemFlowPlanTrack> ifptList = this.GetItemFlowPlanTrackList(mstrIfpd, refIfpd, orderLocTrans);
     if (ifptList != null && ifptList.Count > 0)
     {
         foreach (ItemFlowPlanTrack ifpt in ifptList)
         {
             this.DeleteItemFlowPlanTrack(ifpt);
         }
     }
 }
        public IList<ItemFlowPlanTrack> GetItemFlowPlanTrackList(ItemFlowPlanDetail mstrIfpd, ItemFlowPlanDetail refIfpd, OrderLocationTransaction orderLocTrans)
        {
            DetachedCriteria criteria = DetachedCriteria.For(typeof(ItemFlowPlanTrack));
            if (mstrIfpd != null)
                criteria.Add(Expression.Eq("ItemFlowPlanDetail.Id", mstrIfpd.Id));
            if (refIfpd != null)
                criteria.Add(Expression.Eq("ReferencePlanDetail.Id", refIfpd.Id));
            if (orderLocTrans != null)
                criteria.Add(Expression.Eq("OrderLocationTransaction.Id", orderLocTrans.Id));

            return CriteriaMgr.FindAll<ItemFlowPlanTrack>(criteria);
        }
        public IList<ItemFlowPlanTrack> GenerateItemFlowPlanTrack(ItemFlowPlanDetail parentItemFlowPlanDetail, ItemFlowPlanDetail itemFlowPlanDetail, decimal qtyPer)
        {
            IList<ItemFlowPlanTrack> itemFlowPlanTrackList = new List<ItemFlowPlanTrack>();
            if (parentItemFlowPlanDetail.ItemFlowPlanTracks != null && parentItemFlowPlanDetail.ItemFlowPlanTracks.Count > 0)
            {
                foreach (ItemFlowPlanTrack parentItemFlowPlanTrack in parentItemFlowPlanDetail.ItemFlowPlanTracks)
                {
                    ItemFlowPlanTrack itemFlowPlanTrack = new ItemFlowPlanTrack();
                    itemFlowPlanTrack.ItemFlowPlanDetail = itemFlowPlanDetail;
                    itemFlowPlanTrack.ReferencePlanDetail = parentItemFlowPlanTrack.ReferencePlanDetail;
                    itemFlowPlanTrack.OrderLocationTransaction = parentItemFlowPlanTrack.OrderLocationTransaction;
                    //itemFlowPlanTrack.DemandQty = parentItemFlowPlanTrack.DemandQty * qtyPer;
                    itemFlowPlanTrackList.Add(itemFlowPlanTrack);
                }
            }

            return itemFlowPlanTrackList;
        }
 public virtual void DeleteItemFlowPlanDetail(ItemFlowPlanDetail entity)
 {
     entityDao.DeleteItemFlowPlanDetail(entity);
 }
 public virtual void UpdateItemFlowPlanDetail(ItemFlowPlanDetail entity)
 {
     entityDao.UpdateItemFlowPlanDetail(entity);
 }
 public virtual void CreateItemFlowPlanDetail(ItemFlowPlanDetail entity)
 {
     entityDao.CreateItemFlowPlanDetail(entity);
 }
        public 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 = ItemFlowPlanDetailMgrE.GetItemFlowPlanDetail(ifp.Id, timePeriodType, reqDate);
                if (ifpd == null)
                {
                    ifpd = new ItemFlowPlanDetail();
                    ifpd.ItemFlowPlan = ifp;
                    ifpd.TimePeriodType = timePeriodType;
                    ifpd.ReqDate = reqDate;
                    ifpd.PlanQty = 0;
                    ItemFlowPlanDetailMgrE.CreateItemFlowPlanDetail(ifpd);
                }
            }
            return ifpd;
        }
        public IList<ItemFlowPlanDetail> MergeItemFlowPlanDetail(IList<ItemFlowPlanDetail> preItemFlowPlanDetailList, IList<ItemFlowPlanDetail> oldItemFlowPlanDetailList)
        {
            IList<ItemFlowPlanDetail> itemFlowPlanDetailList = new List<ItemFlowPlanDetail>();
            if (oldItemFlowPlanDetailList == null || oldItemFlowPlanDetailList.Count > 0)
            {
                return preItemFlowPlanDetailList;
            }
            if (preItemFlowPlanDetailList == null || preItemFlowPlanDetailList.Count > 0)
            {
                return oldItemFlowPlanDetailList;
            }

            int i = 0;
            foreach (ItemFlowPlanDetail preItemFlowPlanDetail in preItemFlowPlanDetailList)
            {
                while (i < oldItemFlowPlanDetailList.Count)
                {
                    ItemFlowPlanDetail itemFlowPlanDetail = new ItemFlowPlanDetail();
                    if (DateTime.Compare(preItemFlowPlanDetail.ReqDate.Date, oldItemFlowPlanDetailList[i].ReqDate.Date) == 0)
                    {
                        itemFlowPlanDetail = preItemFlowPlanDetail;
                        itemFlowPlanDetail.GrossDemand = preItemFlowPlanDetail.GrossDemand + oldItemFlowPlanDetailList[i].GrossDemand;
                        itemFlowPlanDetail.AddRangeItemFlowPlanTrack(preItemFlowPlanDetail.ItemFlowPlanTracks);
                        itemFlowPlanDetail.AddRangeItemFlowPlanTrack(oldItemFlowPlanDetailList[i].ItemFlowPlanTracks);
                        itemFlowPlanDetailList.Add(itemFlowPlanDetail);

                        i++;
                        continue;
                    }
                    else if (DateTime.Compare(preItemFlowPlanDetail.ReqDate, oldItemFlowPlanDetailList[i].ReqDate) < 0)
                    {
                        itemFlowPlanDetailList.Add(preItemFlowPlanDetail);

                        break;
                    }
                    else
                    {
                        itemFlowPlanDetailList.Add(oldItemFlowPlanDetailList[i]);

                        i++;
                        continue;
                    }
                }
            }

            return itemFlowPlanDetailList;
        }
        private DateTime GetDmdEndTime(ItemFlowPlanDetail itemFlowPlanDetail, IList<ItemFlowPlanDetail> itemFlowPlanDetailList)
        {
            DateTime dmdEndTime = DateTime.Now;
            int index = itemFlowPlanDetailList.IndexOf(itemFlowPlanDetail);

            if (index + 1 < itemFlowPlanDetailList.Count)
            {
                dmdEndTime = itemFlowPlanDetailList[index + 1].ReqDate;
            }
            else
            {
                if (index >= 1)
                {
                    TimeSpan ts = itemFlowPlanDetailList[index].ReqDate - itemFlowPlanDetailList[index - 1].ReqDate;
                    dmdEndTime = itemFlowPlanDetailList[index].ReqDate.AddDays(ts.TotalDays);
                }
                else
                {
                    dmdEndTime = itemFlowPlanDetailList[index].ReqDate.AddDays(1);
                }
            }

            return dmdEndTime.Date;
        }
        private DateTime GetReqDate(ItemFlowPlanDetail parentItemFlowPlanDetail)
        {
            double leadTime = 0;
            if (parentItemFlowPlanDetail.ItemFlowPlan.Flow.LeadTime != null)
            {
                leadTime = Convert.ToDouble((decimal)(parentItemFlowPlanDetail.ItemFlowPlan.Flow.LeadTime));
            }

            DateTime reqDate = parentItemFlowPlanDetail.ReqDate.AddHours(-1 * leadTime);
            reqDate = WorkCalendarMgrE.GetWorkTime(reqDate, parentItemFlowPlanDetail.ItemFlowPlan.Flow.PartyFrom.Code, true);

            return reqDate;
        }
        private void RefreshItemFlowPlanDetail(ItemFlowPlanDetail itemFlowPlanDetail, IList<OrderLocationTransaction> orderLocTransList)
        {
            decimal inputOrderDmd = 0;
            if (orderLocTransList != null && orderLocTransList.Count > 0)
            {
                foreach (OrderLocationTransaction orderLocTrans in orderLocTransList)
                {
                    if (orderLocTrans.RemainQty > 0)
                    {
                        inputOrderDmd += orderLocTrans.RemainQty;

                        ItemFlowPlanTrack itemFlowPlanTrack = new ItemFlowPlanTrack();
                        itemFlowPlanTrack.ItemFlowPlanDetail = itemFlowPlanDetail;
                        itemFlowPlanTrack.OrderLocationTransaction = orderLocTrans;
                        //itemFlowPlanTrack.DemandQty = orderLocTrans.RemainQty;
                        itemFlowPlanDetail.AddItemFlowPlanTrack(itemFlowPlanTrack);
                    }
                }
            }

            itemFlowPlanDetail.OrderRemainQty = inputOrderDmd;
        }
 public void SaveItemFlowPlanDetail(ItemFlowPlanDetail itemFlowPlanDetail)
 {
     ItemFlowPlanDetail ifpd = this.GetItemFlowPlanDetail(itemFlowPlanDetail.ItemFlowPlan.Id, itemFlowPlanDetail.TimePeriodType, itemFlowPlanDetail.ReqDate);
     if (ifpd == null)
     {
         this.CreateItemFlowPlanDetail(itemFlowPlanDetail);
     }
     else
     {
         if (ifpd.PlanQty != itemFlowPlanDetail.PlanQty)
         {
             ifpd.PlanQty = itemFlowPlanDetail.PlanQty;
             this.UpdateItemFlowPlanDetail(ifpd);
         }
     }
 }
        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;
        }
        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 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 void ReleaseItemFlowPlanDetail(ItemFlowPlanDetail itemFlowPlanDetail)
        {
            if (itemFlowPlanDetail.PlanQty < 0)
                return;

            DateTime reqDate = itemFlowPlanDetail.ReqDate;
            double leadTime = Convert.ToDouble(itemFlowPlanDetail.ItemFlowPlan.Flow.LeadTime == null ? 0 : (decimal)itemFlowPlanDetail.ItemFlowPlan.Flow.LeadTime);
            if (itemFlowPlanDetail.TimePeriodType == BusinessConstants.CODE_MASTER_TIME_PERIOD_TYPE_VALUE_DAY)
            {
                //to be refactored
                if (leadTime > 12)
                    reqDate = reqDate.AddHours(-1 * leadTime);
            }

            ItemFlowPlanTrackMgrE.ClearOldRelation(null, itemFlowPlanDetail, null);
            if (itemFlowPlanDetail.ItemFlowPlan.PlanType == BusinessConstants.CODE_MASTER_PLAN_TYPE_VALUE_DMDSCHEDULE)
            {
                ItemFlowPlanDetail ifpd = this.GetSupplyFlow(itemFlowPlanDetail.ItemFlowPlan.FlowDetail.Item.Code, itemFlowPlanDetail.TimePeriodType, reqDate);
                if (ifpd != null)
                    this.SaveRelation(ifpd, itemFlowPlanDetail, 1);
            }
            else if (itemFlowPlanDetail.ItemFlowPlan.PlanType == BusinessConstants.CODE_MASTER_PLAN_TYPE_VALUE_MPS)
            {
                string bomCode = itemFlowPlanDetail.ItemFlowPlan.FlowDetail.Item.Bom == null ? itemFlowPlanDetail.ItemFlowPlan.FlowDetail.Item.Code : itemFlowPlanDetail.ItemFlowPlan.FlowDetail.Item.Bom.Code;
                IList<BomDetail> bomdetList = BomDetailMgrE.GetFlatBomDetail(bomCode, reqDate);
                if (bomdetList != null && bomdetList.Count > 0)
                {
                    foreach (BomDetail bd in bomdetList)
                    {
                        decimal rateQty = (1 + bd.ScrapPercentage) * bd.RateQty;
                        ItemFlowPlanDetail ifpd = this.GetSupplyFlow(bd.Item.Code, itemFlowPlanDetail.TimePeriodType, reqDate);
                        if (ifpd != null)
                            this.SaveRelation(ifpd, itemFlowPlanDetail, rateQty);
                    }
                }
            }
        }
        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 void SaveRelation(ItemFlowPlanDetail ifpd, ItemFlowPlanDetail parIfpd, decimal rate)
 {
     ItemFlowPlanTrack ifpt = new ItemFlowPlanTrack();
     ifpt.ItemFlowPlanDetail = ifpd;
     ifpt.ReferencePlanDetail = parIfpd;
     ifpt.Rate = rate;
     ItemFlowPlanTrackMgrE.CreateItemFlowPlanTrack(ifpt);
 }
Пример #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();
    }