예제 #1
0
        /// <summary>
        /// Update into LogisticsAging
        /// </summary>
        /// <param name="logisticsaging">LogisticsAging</param>
        public void UpdateLogisticsAging(LogisticsAging logisticsaging)
        {
            if (logisticsaging == null)
            {
                return;
            }

            if (this._context.IsAttached(logisticsaging))
            {
                this._context.LogisticsAgings.Attach(logisticsaging);
            }

            this._context.SaveChanges();
        }
예제 #2
0
        /// <summary>
        /// Insert into LogisticsAging
        /// </summary>
        /// <param name="logisticsaging">LogisticsAging</param>
        public void InsertLogisticsAging(LogisticsAging logisticsaging)
        {
            if (logisticsaging == null)
            {
                return;
            }

            if (!this._context.IsAttached(logisticsaging))
            {
                this._context.LogisticsAgings.AddObject(logisticsaging);
            }

            this._context.SaveChanges();
        }
예제 #3
0
        public List <string> GetFictitiousLogisticsInfoList(DateTime DeliveryTime, int days, LogisticsAging LogisticsAgingInfo)
        {
            DateTime      LogisticsDate = DeliveryTime;
            List <string> list          = new List <string>();
            string        Str           = LogisticsAgingInfo.DepartureCity + "仓拣单出库,物流开始承运。";

            if (LogisticsAgingInfo.Pathway != "")
            {
                int Count1 = GetMod((int)LogisticsAgingInfo.PathwayDate, days);
                for (int i = 0; i < Count1; i++)
                {
                    Str += "物品正在发往" + LogisticsAgingInfo.Pathway + "中转站,等待转运。";
                    //XMLogisticsInfo info = new XMLogisticsInfo();
                    //info.Note = Str;
                    //LogisticsDate = LogisticsDate.AddDays(i * days);
                    //info.LogisticsDate = LogisticsDate;
                    list.Add(Str);
                    Str = "";
                }
                Str = "物品已抵达" + LogisticsAgingInfo.Pathway + "中转站。物品从" + LogisticsAgingInfo.Pathway + "中转站发出。";
            }

            int Count2 = GetMod((int)LogisticsAgingInfo.DestinationDate, days);

            for (int i = 0; i < Count2; i++)
            {
                Str += "物品正在发往" + LogisticsAgingInfo.DestinationCity + "城市途中。";
                list.Add(Str);
                Str = "";
            }
            Str = "物品已经到达" + LogisticsAgingInfo.DestinationCity + ",等待派件员取货。物品已经取走,正在派送。签收人签收,草签。";
            list.Add(Str);
            return(list);
        }
예제 #4
0
        public int GetDue(int total, LogisticsAging info, int days)//应有记录条数
        {
            int count = 0;

            if (total == 0)
            {
                count++;
                return(count);
            }
            if (info.Pathway != "")
            {
                if (total >= info.PathwayDate)
                {
                    if (info.PathwayDate > days)
                    {
                        count += GetMod((int)info.PathwayDate, days);
                    }
                    else
                    {
                        count++;
                    }
                }
                else
                {
                    if (total > days)
                    {
                        count += GetMod(total, days);
                    }
                    else if (total == days)
                    {
                        count += GetMod(total, days) + 1;
                    }
                    else
                    {
                        count++;
                    }
                }
            }
            else
            {
                count++;//发货后,自动生成的第一条记录
            }

            int result = (int)(info.PathwayDate == null ? 0 : info.PathwayDate);

            if (total >= result)
            {
                total = total - result;
                if (total >= info.DestinationDate)
                {
                    if (info.DestinationDate > days)
                    {
                        count += GetMod((int)info.DestinationDate, days);
                        int mod = (int)info.DestinationDate % days;//剩余天数,是否正好整除
                        if (mod == 0)
                        {
                            count++;
                        }
                    }
                    else
                    {
                        count++;
                    }
                }
                else
                {
                    if (total > days)
                    {
                        count += GetMod(total, days);
                    }
                    else if (total == days)
                    {
                        count += GetMod(total, days) + 1;
                    }
                    else
                    {
                        count++;
                    }
                }
            }
            return(count);
        }
예제 #5
0
        public void TimingGetLogisticsAging()
        {
            int UserID = 0;

            if (HozestERPContext.Current.User != null)
            {
                UserID = HozestERPContext.Current.User.CustomerID;
            }
            else
            {
                string          UserName = "******";
                List <Customer> customer = IoC.Resolve <ICustomerService>().GetCustomerByUsernameList(UserName);

                if (customer.Count > 0)
                {
                    UserID = customer[0].CustomerID;
                }
            }

            int days = 0;
            var Days = IoC.Resolve <ISettingManager>().GetSettingByName("Logistics.Aging.NumberOfDays");

            if (Days != null)
            {
                if (int.TryParse(Days.Value.Trim(), out days) && Days.Value.Trim() != "0")
                {
                    days = int.Parse(Days.Value.Trim());
                    DateTime End         = DateTime.Now;
                    DateTime Begin       = End.AddMonths(-6);
                    var      OrderIDList = IoC.Resolve <IXMOrderInfoService>().GetVPHXMOrderInfoListByDateTime(Begin, End);
                    if (OrderIDList != null && OrderIDList.Count > 0)
                    {
                        foreach (int ID in OrderIDList)
                        {
                            var OrderInfo         = IoC.Resolve <IXMOrderInfoService>().GetXMOrderInfoByID(ID);
                            var LogisticsInfoList = IoC.Resolve <IXMLogisticsInfoService>().GetXMLogisticsInfoListByOrderInfoID(ID).OrderBy(x => x.CreateDate).ToList();
                            if (OrderInfo != null)
                            {
                                var LogisticsAgingList = IoC.Resolve <ILogisticsAgingService>().GetLogisticsAgingListByParam("", OrderInfo.City.Replace("市", "").Replace("区", ""), "-1");
                                if (LogisticsAgingList.Count > 0)
                                {
                                    int            Total              = 0;
                                    int            TotalDay           = 0;
                                    LogisticsAging LogisticsAgingInfo = LogisticsAgingList[0];
                                    TimeSpan       ts1 = new TimeSpan(((DateTime)OrderInfo.DeliveryTime).Ticks);
                                    TimeSpan       ts2 = new TimeSpan(DateTime.Now.Ticks);
                                    TimeSpan       ts  = ts1.Subtract(ts2).Duration();//显示时间
                                    TotalDay += ts.Days;
                                    Total     = GetDue(TotalDay, LogisticsAgingInfo, days);

                                    if (LogisticsInfoList.Count < Total)
                                    {
                                        List <string> list = GetFictitiousLogisticsInfoList((DateTime)OrderInfo.DeliveryTime, days, LogisticsAgingInfo);
                                        if (list.Count >= Total)
                                        {
                                            for (int i = LogisticsInfoList.Count; i < Total; i++)
                                            {
                                                XMLogisticsInfo Info = new XMLogisticsInfo();
                                                Info.OrderInfoID   = ID;
                                                Info.LogisticsDate = DateTime.Now;
                                                if (LogisticsInfoList.Count > 0)
                                                {
                                                    Info.LogisticsNumber  = LogisticsInfoList[0].LogisticsNumber;
                                                    Info.LogisticsCompany = LogisticsInfoList[0].LogisticsCompany;
                                                }
                                                else
                                                {
                                                    Info.LogisticsNumber  = "";
                                                    Info.LogisticsCompany = "";
                                                }
                                                Info.Note       = list[i];
                                                Info.IsExport   = false;
                                                Info.IsEnable   = false;
                                                Info.CreateID   = UserID;
                                                Info.CreateDate = DateTime.Now;
                                                Info.UpdateID   = UserID;
                                                Info.UpdateTime = DateTime.Now;
                                                IoC.Resolve <IXMLogisticsInfoService>().InsertXMLogisticsInfo(Info);
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }