public ActionResult ToStockBilReportExcel()
        {
            string searchKey = WebUtil.GetFormValue<string>("ProductName", string.Empty);
            string localName = WebUtil.GetFormValue<string>("LocalName", string.Empty);
            string localType = WebUtil.GetFormValue<string>("LocalType", string.Empty);
            string storageNum = this.DefaultStore;

            LocalProductProvider provider = new LocalProductProvider();
            LocalProductEntity entity = new LocalProductEntity();
            if (!localType.IsEmpty())
            {
                entity.Where("LocalType", ECondition.Eth, localType);
            }
            if (storageNum.IsNotNull())
            {
                entity.Where("StorageNum", ECondition.Eth, storageNum);
            }
            if (!localName.IsEmpty())
            {
                entity.Where("LocalName", ECondition.Like, "%" + localName + "%");
            }
            if (!searchKey.IsEmpty())
            {
                entity.Begin<LocalProductEntity>()
                 .Where<LocalProductEntity>("ProductName", ECondition.Like, "%" + searchKey + "%")
                 .Or<LocalProductEntity>("ProductNum", ECondition.Like, "%" + searchKey + "%")
                 .Or<LocalProductEntity>("BarCode", ECondition.Like, "%" + searchKey + "%")
                 .End<LocalProductEntity>();
            }

            PageInfo pageInfo = new PageInfo() { PageIndex = 1, PageSize = Int32.MaxValue };
            List<LocalProductEntity> listResult = provider.GetList(entity, ref pageInfo);
            int allNum = provider.GetAllNum(localName, localType, searchKey, storageNum);
            double allTotalPrice = provider.GetAllTotalPrice(localName, localType, searchKey, storageNum);
            if (!listResult.IsNullOrEmpty())
            {
                listResult.ForEach(a =>
                {
                    a.TotalPrice = a.Num * a.AvgPrice;
                });
                DataTable dt = new DataTable();
                dt.Columns.Add(new DataColumn("序号 "));
                dt.Columns.Add(new DataColumn("库位 "));
                dt.Columns.Add(new DataColumn("库位类型"));
                dt.Columns.Add(new DataColumn("产品编号"));
                dt.Columns.Add(new DataColumn("产品条码"));
                dt.Columns.Add(new DataColumn("产品名称"));
                dt.Columns.Add(new DataColumn("类别名称"));
                dt.Columns.Add(new DataColumn("规格"));
                dt.Columns.Add(new DataColumn("预警值下限"));
                dt.Columns.Add(new DataColumn("预警值上限"));
                dt.Columns.Add(new DataColumn("库存数"));
                dt.Columns.Add(new DataColumn("价格"));
                dt.Columns.Add(new DataColumn("总价"));

                int count = 1;
                foreach (LocalProductEntity t in listResult)
                {
                    DataRow row = dt.NewRow();
                    row[0] = count;
                    row[1] = t.LocalName;
                    row[2] = EnumHelper.GetEnumDesc<ELocalType>(t.LocalType);
                    row[3] = t.ProductNum;
                    row[4] = t.BarCode;
                    row[5] = t.ProductName;
                    row[6] = t.CateName;
                    row[7] = t.Size;
                    row[8] = t.MinNum;
                    row[9] = t.MaxNum;
                    row[10] = t.Num;
                    row[11] = t.AvgPrice;
                    row[12] = t.TotalPrice;
                    dt.Rows.Add(row);
                    count++;
                }
                DataRow rowTemp = dt.NewRow();
                rowTemp[0] = count;
                rowTemp[1] = "";
                rowTemp[2] = "";
                rowTemp[3] = "";
                rowTemp[4] = "";
                rowTemp[5] = "";
                rowTemp[6] = "";
                rowTemp[7] = "";
                rowTemp[8] = "";
                rowTemp[9] = "总计";
                rowTemp[10] = allNum;
                rowTemp[11] = "";
                rowTemp[12] = allTotalPrice;
                dt.Rows.Add(rowTemp);
                string filePath = Server.MapPath("~/UploadFiles/");
                if (!System.IO.Directory.Exists(filePath))
                {
                    System.IO.Directory.CreateDirectory(filePath);
                }
                string filename = string.Format("库存清单报表{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmss"));
                AsposeExcel excel = new AsposeExcel(System.IO.Path.Combine(filePath, filename), "");
                excel.DatatableToExcel(dt, "库存清单报表", "库存清单报表");
                this.ReturnJson.AddProperty("Path", ("/UploadFiles/" + filename).Escape());
                this.ReturnJson.AddProperty("Path", ("/UploadFiles/" + filename).Escape());
            }
            else
            {
                this.ReturnJson.AddProperty("d", "无数据导出!");
            }
            return Content(this.ReturnJson.ToString());
        }
        public ActionResult ToProductReportExcel()
        {
            PageInfo pageInfo = new Git.Framework.DataTypes.PageInfo() { PageIndex = 1, PageSize = Int32.MaxValue };
            string searchKey = WebUtil.GetFormValue<string>("ProductName", string.Empty);
            string beginTime = WebUtil.GetFormValue<string>("BeginTime", string.Empty);
            string endTime = WebUtil.GetFormValue<string>("EndTime", string.Empty);
            string storageNum = this.DefaultStore;

            ProductProvider provider = new ProductProvider();
            ProductEntity entity = new ProductEntity();
            if (!searchKey.IsEmpty())
            {
                entity.Begin<ProductEntity>()
                 .Where<ProductEntity>("ProductName", ECondition.Like, "%" + searchKey + "%")
                 .Or<ProductEntity>("SnNum", ECondition.Like, "%" + searchKey + "%")
                 .Or<ProductEntity>("BarCode", ECondition.Like, "%" + searchKey + "%")
                 .End<ProductEntity>();
            }
            if (!beginTime.IsEmpty() && !endTime.IsEmpty())
            {
                entity.Where("CreateTime", ECondition.Between, ConvertHelper.ToType<DateTime>(beginTime), ConvertHelper.ToType<DateTime>(endTime));
            }
            if (storageNum.IsNotNull())
            {
                entity.Where("StorageNum", ECondition.Eth, storageNum);
            }
            List<ProductEntity> listResult = provider.GetList(entity, ref pageInfo, searchKey, beginTime, endTime);
            listResult = listResult.IsNull() ? new List<ProductEntity>() : listResult;
            if (!listResult.IsNullOrEmpty())
            {
                DataTable dt = new DataTable();
                dt.Columns.Add(new DataColumn("序号 "));
                dt.Columns.Add(new DataColumn("产品编号"));
                dt.Columns.Add(new DataColumn("产品条码"));
                dt.Columns.Add(new DataColumn("产品名称"));
                dt.Columns.Add(new DataColumn("类别名称"));
                dt.Columns.Add(new DataColumn("预警值下限"));
                dt.Columns.Add(new DataColumn("预警值上限"));
                dt.Columns.Add(new DataColumn("规格"));
                dt.Columns.Add(new DataColumn("价格"));
                dt.Columns.Add(new DataColumn("库存数"));
                dt.Columns.Add(new DataColumn("进货总数"));
                dt.Columns.Add(new DataColumn("出货总数"));
                dt.Columns.Add(new DataColumn("报损总数"));

                int count = 1;
                foreach (ProductEntity t in listResult)
                {
                    DataRow row = dt.NewRow();
                    row[0] = count;
                    row[1] = t.SnNum;
                    row[2] = t.BarCode;
                    row[3] = t.ProductName;
                    row[4] = t.CateName;
                    row[5] = t.MinNum;
                    row[6] = t.MaxNum;
                    row[7] = t.Size;
                    row[8] = t.AvgPrice;
                    row[9] = t.LocalProductNum;
                    row[10] = t.InStorageNum;
                    row[11] = t.OutStorageNum;
                    row[12] = t.BadReportNum;
                    dt.Rows.Add(row);
                    count++;
                }
                DataRow rowTemp = dt.NewRow();
                rowTemp[0] = count;
                rowTemp[1] = "";
                rowTemp[2] = "";
                rowTemp[3] = "";
                rowTemp[4] = "";
                rowTemp[5] = "";
                rowTemp[6] = "";
                rowTemp[7] = "";
                rowTemp[8] = "总计";
                rowTemp[9] = listResult[0].TotalLocalProductNum;
                rowTemp[10] = listResult[0].TotalInStorageNum;
                rowTemp[11] = listResult[0].TotalOutStorageNum;
                rowTemp[12] = listResult[0].TotalBadReportNum;
                dt.Rows.Add(rowTemp);
                string filePath = Server.MapPath("~/UploadFiles/");
                if (!System.IO.Directory.Exists(filePath))
                {
                    System.IO.Directory.CreateDirectory(filePath);
                }
                string filename = string.Format("产品在线库存报表{0}.xls", DateTime.Now.ToString("yyyyMMddHHmmss"));
                AsposeExcel excel = new AsposeExcel(System.IO.Path.Combine(filePath, filename), "");
                excel.DatatableToExcel(dt, "产品在线库存报表", "产品在线库存报表");
                this.ReturnJson.AddProperty("Path", ("/UploadFiles/" + filename).Escape());
                this.ReturnJson.AddProperty("Path", ("/UploadFiles/" + filename).Escape());
            }
            else
            {
                this.ReturnJson.AddProperty("d", "无数据导出!");
            }
            return Content(this.ReturnJson.ToString());
        }