Exemplo n.º 1
0
        public FubListViewModel BindListCenterViewModel(FubListFilterModel filter)
        {
            FubListViewModel model = new FubListViewModel();

            //model.SearchWheres.Add(new SelectListItem() { Text = "请选择", Value = "", Selected = !filter.SearchWhere.HasValue });
            //model.SearchWheres.Add(new SelectListItem() { Text = "客户邮袋号", Value = "1", Selected = "1" == filter.DateWhere.ToString() });
            //model.SearchWheres.Add(new SelectListItem() { Text = "福邮邮袋号", Value = "2", Selected = "2" == filter.DateWhere.ToString() });
            //model.SearchWheres.Add(new SelectListItem() { Text = "总包号", Value = "3", Selected = "3" == filter.DateWhere.ToString() });
            //model.DateWheres.Add(new SelectListItem { Text = "福州扫描日期", Value = "1", Selected = "1" == filter.DateWhere.ToString() });
            //model.DateWheres.Add(new SelectListItem { Text = "中心局扫描日期", Value = "2", Selected = "2" == filter.DateWhere.ToString() });
            model.FubListFilterModel = filter;
            model.CountryList        = GetCountryList("");
            FubListParam param = new FubListParam();

            param.DateWhere = filter.DateWhere;
            //param.SearchWhere = filter.SearchWhere;
            //param.SearchContext = filter.SearchContext;
            param.StartTime = filter.StartTime;
            param.EndTime   = filter.EndTime;
            param.CreatedBy = filter.CreatedBy;
            param.Page      = filter.Page;
            param.PageSize  = filter.PageSize;
            model.PagedList =
                _fubService.GetFubCenterPagedList(param).ToModelAsPageCollection <FubListModelExt, FubListModel>();
            return(model);
        }
        /// <summary>
        /// 中心局邮袋扫描查询
        /// Add By zhengsong
        /// Time:2014-12-30
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public IPagedList <FubListModelExt> GetFubCenterPagedList(FubListParam param)
        {
            var ctx = this.UnitOfWork as LMS_DbContext;

            Check.Argument.IsNotNull(ctx, "数据库对象");
            Expression <Func <MailTotalPackageOrPostBagRelational, bool> > filterRelational = p => true;

            switch (param.DateWhere)
            {
            case 0:
                break;

            case 2:
                filterRelational = filterRelational.And(r => r.ScanTime >= param.StartTime)
                                   .And(r => r.ScanTime <= param.EndTime)
                                   .AndIf(r => r.CreatedBy.Contains(param.CreatedBy),
                                          !param.CreatedBy.IsNullOrWhiteSpace());
                break;
            }
            var list = from mm in ctx.MailTotalPackageOrPostBagRelationals.Where(filterRelational)
                       join m in ctx.MailPostBagInfos on mm.PostBagNumber equals m.PostBagNumber
                       into mail
                       from ma in mail.DefaultIfEmpty()
                       join o in ctx.OutStorageInfos on ma.OutStorageID equals o.OutStorageID
                       into mailo
                       from mo in mailo.DefaultIfEmpty()
                       orderby mm.CreatedOn
                       select new FubListModelExt
            {
                PostBagNumber          = ma.PostBagNumber,
                FuPostBagNumber        = ma.FuPostBagNumber,
                MailTotalPackageNumber = mm.MailTotalPackageNumber,
                ShortNumber            = mm.MailTotalPackageInfo.ShortNumber,
                ScanTime        = ma.ScanTime,
                ScanBy          = ma.ScanBy,
                CenterScanTime  = mm.ScanTime,
                CenterCreatedBy = mm.CreatedBy,
                TotalWeight     = ma.TotalWeight,
                TotalNumber     = mo.TotalQty,
                CountryCode     = ma.CountryCode
            };

            return(list.ToPagedList(param.Page, param.PageSize));
        }
        /// <summary>
        /// 国际小包优+ 查询
        /// Add By zhengsong
        /// Time:2014-12-30
        /// </summary>
        /// <param name="param"></param>
        /// <returns></returns>
        public IPagedList <FubListModelExt> GetFubPagedList(FubListParam param)
        {
            var ctx = this.UnitOfWork as LMS_DbContext;

            Check.Argument.IsNotNull(ctx, "数据库对象");
            Expression <Func <MailPostBagInfo, bool> > filter = p => true;
            //Expression<Func<MailTotalPackageOrPostBagRelational, bool>> filterRelational = p => true;
            Expression <Func <MailTotalPackageInfo, bool> > filterPackage = p => true;

            if (!string.IsNullOrWhiteSpace(param.SearchContext))
            {
                var numberList =
                    param.SearchContext.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries)
                    .ToList();
                if (param.SearchWhere.HasValue && numberList.Count > 0)
                {
                    switch (param.SearchWhere.Value)
                    {
                    case 1:
                        filter = filter.And(p => numberList.Contains(p.PostBagNumber));
                        break;

                    case 2:
                        filter = filter.And(p => numberList.Contains(p.FuPostBagNumber));
                        break;

                    case 3:
                        List <int> shortNumbers = new List <int>();
                        numberList.ForEach(P =>
                        {
                            int a = 0;
                            if (Int32.TryParse(P, out a))
                            {
                                shortNumbers.Add(a);
                            }
                        }
                                           );
                        filterPackage = filterPackage.And(p => shortNumbers.Contains(p.ShortNumber));
                        break;
                    }
                }
            }
            switch (param.DateWhere)
            {
            case 0:
                break;

            case 1:
                filter = filter.And(r => r.ScanTime >= param.StartTime)
                         .And(r => r.ScanTime <= param.EndTime)
                         .AndIf(r => r.ScanBy.Contains(param.CreatedBy), !param.CreatedBy.IsNullOrWhiteSpace());
                break;

            case 2:
                filterPackage = filterPackage.And(r => r.ScanTime >= param.StartTime)
                                .And(r => r.ScanTime <= param.EndTime)
                                .AndIf(r => r.CreatedBy.Contains(param.CreatedBy),
                                       !param.CreatedBy.IsNullOrWhiteSpace());
                break;
            }
            if ((param.SearchWhere.HasValue && param.SearchWhere == 3 && !string.IsNullOrWhiteSpace(param.SearchContext)) || param.DateWhere == 2)
            {
                var list = from m in ctx.MailPostBagInfos.Where(filter)
                           join mm in ctx.MailTotalPackageOrPostBagRelationals on m.PostBagNumber equals mm.PostBagNumber
                           into mail
                           from ma in mail.DefaultIfEmpty()
                           join z in ctx.MailTotalPackageInfos.Where(filterPackage) on ma.MailTotalPackageNumber equals z.MailTotalPackageNumber
                           join o in ctx.OutStorageInfos on m.OutStorageID equals o.OutStorageID
                           into mailto
                           from mo in mailto.DefaultIfEmpty()
                           orderby m.CreatedOn
                           select new FubListModelExt
                {
                    PostBagNumber          = m.PostBagNumber,
                    FuPostBagNumber        = m.FuPostBagNumber,
                    MailTotalPackageNumber = ma.MailTotalPackageNumber,
                    ShortNumber            = z.ShortNumber,
                    ScanTime        = m.ScanTime,
                    ScanBy          = m.ScanBy,
                    CenterScanTime  = ma.ScanTime,
                    CenterCreatedBy = ma.CreatedBy,
                    TotalWeight     = m.TotalWeight,
                    TotalNumber     = mo.TotalQty,
                    CountryCode     = m.CountryCode
                };

                return(list.ToPagedList(param.Page, param.PageSize));
            }
            else
            {
                var list = from m in ctx.MailPostBagInfos.Where(filter)
                           join mm in ctx.MailTotalPackageOrPostBagRelationals on m.PostBagNumber equals mm.PostBagNumber
                           into mail
                           from ma in mail.DefaultIfEmpty()
                           join z in ctx.MailTotalPackageInfos.Where(filterPackage) on ma.MailTotalPackageNumber equals z.MailTotalPackageNumber
                           into mailt
                           from mt in mailt.DefaultIfEmpty()
                           join o in ctx.OutStorageInfos on m.OutStorageID equals o.OutStorageID
                           into mailto
                           from mo in mailto.DefaultIfEmpty()
                           orderby m.CreatedOn
                           select new FubListModelExt
                {
                    PostBagNumber          = m.PostBagNumber,
                    FuPostBagNumber        = m.FuPostBagNumber,
                    MailTotalPackageNumber = ma.MailTotalPackageNumber,
                    ShortNumber            = mt.ShortNumber,
                    ScanTime        = m.ScanTime,
                    ScanBy          = m.ScanBy,
                    CenterScanTime  = ma.ScanTime,
                    CenterCreatedBy = ma.CreatedBy,
                    TotalWeight     = m.TotalWeight,
                    TotalNumber     = mo.TotalQty,
                    CountryCode     = m.CountryCode
                };

                return(list.ToPagedList(param.Page, param.PageSize));
            }
        }
Exemplo n.º 4
0
 public IPagedList <FubListModelExt> GetFubCenterPagedList(FubListParam param)
 {
     return(_mailPostBagInfoRepository.GetFubCenterPagedList(param));
 }