Esempio n. 1
0
        /// <summary>
        /// 导出蓄电池覆盖区域--按品牌
        /// </summary>
        /// <param name="brand"></param>
        /// <returns></returns>
        public async Task <ActionResult> ExportData(string productType, string brand)
        {
            if (string.IsNullOrEmpty(brand))
            {
                return(Json(new { Status = false, Msg = "请选择品牌" }, JsonRequestBehavior.AllowGet));
            }
            var workbook = new XSSFWorkbook();
            var index    = 0;
            var sheet    = workbook.CreateSheet();
            var row      = sheet.CreateRow(index++);
            var cellNum  = 0;

            row.CreateCell(cellNum++).SetCellValue("省份名称");
            row.CreateCell(cellNum++).SetCellValue("城市名称");
            row.CreateCell(cellNum++).SetCellValue("区域名称");
            row.CreateCell(cellNum++).SetCellValue("品牌");
            row.CreateCell(cellNum++).SetCellValue("是否启用TRUE/FALSE");
            row.CreateCell(cellNum).SetCellValue("备注(选填)");
            cellNum = 0;
            sheet.SetColumnWidth(cellNum++, 10 * 256);
            sheet.SetColumnWidth(cellNum++, 10 * 256);
            sheet.SetColumnWidth(cellNum++, 10 * 256);
            sheet.SetColumnWidth(cellNum++, 14 * 256);
            sheet.SetColumnWidth(cellNum++, 20 * 256);
            sheet.SetColumnWidth(cellNum, 28 * 256);
            var pager = new PagerModel()
            {
                CurrentPage = 1,
                PageSize    = int.MaxValue
            };
            var manager = new VendorProductCoverAreaManager();
            var list    = (await manager.SelectVendorProductCoverArea
                               (productType, "Brand", brand, string.Empty, 0, 0, 0, pager))?.Item1;

            if (list != null && list.Any())
            {
                foreach (var item in list)
                {
                    row     = sheet.CreateRow(index++);
                    cellNum = 0;
                    row.CreateCell(cellNum++).SetCellValue(item.ProvinceName);
                    row.CreateCell(cellNum++).SetCellValue(item.CityName);
                    row.CreateCell(cellNum++).SetCellValue(item.DistrictName);
                    row.CreateCell(cellNum++).SetCellValue(item.Brand);
                    row.CreateCell(cellNum++).SetCellValue(item.IsEnabled);
                    row.CreateCell(cellNum).SetCellValue(item.Remark);
                }
            }
            var ms = new MemoryStream();

            workbook.Write(ms);
            var zhName = manager.GetZhNameByProductType(productType);

            return(File(ms.ToArray(), "application/x-xls", $"{zhName}产品{brand}品牌覆盖区域数据" +
                        $"{DateTime.Now.ToString("yyyy年MM月dd日HH时mm分ss秒")}.xlsx"));
        }
Esempio n. 2
0
        /// <summary>
        /// 查询覆盖区域--按品牌
        /// </summary>
        /// <param name="brand"></param>
        /// <param name="province"></param>
        /// <param name="city"></param>
        /// <param name="district"></param>
        /// <param name="pageNum"></param>
        /// <param name="pageSize"></param>
        /// <returns></returns>
        public async Task <JsonResult> SelectCoverArea
            (string productType, string coverType, string brand, string pid, int provinceId, int cityId,
            int districtId, int pageIndex, int pageSize = 20)
        {
            var manager = new VendorProductCoverAreaManager();
            var pager   = new PagerModel(pageIndex, pageSize);
            var result  = await manager.SelectVendorProductCoverArea(productType, coverType, brand, pid,
                                                                     provinceId, cityId, districtId, pager);

            return(Json(new { Status = result.Item1 != null, Data = result.Item1, TotalCount = result.Item2 }
                        , JsonRequestBehavior.AllowGet));
        }