You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
198 lines
6.9 KiB
C#
198 lines
6.9 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
using System.Collections;
|
|
using Estsh.Web.Service;
|
|
using Estsh.Web.Util;
|
|
using NPOI.HSSF.UserModel;
|
|
using System.IO;
|
|
using System.Data;
|
|
|
|
namespace Estsh.Core.Web.Controllers
|
|
{
|
|
public class SeatAliveTimeSpanController : Controller
|
|
{
|
|
|
|
//
|
|
// GET: /SeatAliveTimeSpan/
|
|
public SeatAliveTimeSpanService service = new SeatAliveTimeSpanService();
|
|
public ActionResult Index()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
|
|
public ActionResult GetSeatType()
|
|
{
|
|
Hashtable resault = new Hashtable();
|
|
Hashtable ht = service.GetSeatType();
|
|
resault.Add("list", ht["data"]);
|
|
return Json(resault, JsonRequestBehavior.AllowGet);
|
|
}
|
|
|
|
public ActionResult GetTimeSpanType()
|
|
{
|
|
Hashtable resault = new Hashtable();
|
|
Hashtable ht = service.GetTimeSpanType();
|
|
resault.Add("list", ht["data"]);
|
|
return Json(resault, JsonRequestBehavior.AllowGet);
|
|
}
|
|
|
|
public ActionResult GetDataByPage(Pager pager)
|
|
{
|
|
if (string.IsNullOrEmpty(Request["startDate"]))
|
|
{
|
|
return null;
|
|
}
|
|
string startTime = Request["startDate"];
|
|
string stopTime = Request["stopDate"];
|
|
|
|
string seatType = Request["cbbSeatTypeName"];
|
|
string gapType = Request["cbbTimeSpanType"];
|
|
string rbSort = Request["rbSort"];
|
|
string cbRecordCount = Request["cbRecordCount"];
|
|
|
|
string sortType="DESC";
|
|
if(rbSort=="(A-Z)")
|
|
{
|
|
sortType="ASC";
|
|
}
|
|
int topN=0;
|
|
|
|
if(int.TryParse(cbRecordCount,out topN)==false)
|
|
{
|
|
return null;
|
|
}
|
|
DataTable dt = service.GetAliveTimeInfo(startTime, stopTime, "", "", seatType, "", gapType, sortType, topN);
|
|
Hashtable result = new Hashtable();
|
|
result.Add("rows", DataTypeConvert.NewObject.DataTableToArrayList(dt));
|
|
return Json(result, JsonRequestBehavior.AllowGet);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 导出
|
|
/// </summary>
|
|
/// <param name="pager"></param>
|
|
/// <param name="txtOrderNo"></param>
|
|
/// <param name="sort"></param>
|
|
/// <param name="direction"></param>
|
|
/// <param name="isPage"></param>
|
|
/// <returns></returns>
|
|
public ActionResult exportData()
|
|
{
|
|
int rowCount = Convert.ToInt32(Request["rowCount"]);
|
|
string startTime = Request["startDate"];
|
|
string stopTime = Request["stopDate"];
|
|
|
|
string seatType = Request["cbbSeatTypeName"];
|
|
string gapType = Request["cbbTimeSpanType"];
|
|
string rbSort = Request["rbSort"];
|
|
string cbRecordCount = Request["cbRecordCount"];
|
|
|
|
string sortType = "DESC";
|
|
if (rbSort == "(A-Z)")
|
|
{
|
|
sortType = "ASC";
|
|
}
|
|
int topN = 0;
|
|
|
|
if (int.TryParse(cbRecordCount, out topN) == false)
|
|
{
|
|
return null;
|
|
}
|
|
|
|
Pager pager = new Pager();
|
|
pager.pageSize = rowCount;
|
|
pager.pageNo = 1;
|
|
DataTable data = service.GetAliveTimeInfo(startTime, stopTime, "", "", seatType, "", gapType, sortType, topN);
|
|
|
|
Stream outputStream = Response.OutputStream;
|
|
|
|
string AbsolutePath = Request.UrlReferrer.AbsolutePath;
|
|
string url = AbsolutePath.Remove(0, Request.ApplicationPath.Length);
|
|
GridColumnService colService = new GridColumnService();
|
|
Models.SysWebGridColumn[] gridItems = colService.GetColumnByUrl(url);
|
|
HSSFWorkbook workbook = NPOIExcelTools.DataTableToWorkbook(gridItems, data, "下线时间间隔");
|
|
|
|
|
|
|
|
//ArrayList arr = data["data"] as ArrayList;
|
|
|
|
//HSSFWorkbook workbook = new HSSFWorkbook();
|
|
//Stream outputStream = Response.OutputStream;
|
|
//HSSFSheet sheet = (HSSFSheet)workbook.CreateSheet("即时产能");
|
|
//try
|
|
//{
|
|
// List<Models.sys_web_gridColumn> gridItems = service.GetGridItems();
|
|
// if (workbook != null)
|
|
// {
|
|
// HSSFRow headRow = (HSSFRow)sheet.CreateRow(0);
|
|
// for (int i = 0; i < gridItems.Count; i++)
|
|
// {
|
|
// if (gridItems[i].export)
|
|
// {
|
|
// headRow.CreateCell(i).SetCellValue(gridItems[i].display);
|
|
// }
|
|
// }
|
|
|
|
// for (int i = 0; i < arr.Count; i++)
|
|
// {
|
|
// Hashtable ht = arr[i] as Hashtable;
|
|
// int row = i + 1;
|
|
// HSSFRow dataRow = (HSSFRow)sheet.CreateRow(row);
|
|
// for (int idx = 0; idx < gridItems.Count; idx++)
|
|
// {
|
|
// if (gridItems[idx].export)
|
|
// {
|
|
// string key = gridItems[idx].name;
|
|
// if (ht.ContainsKey(key))
|
|
// {
|
|
// object obj = ht[key];
|
|
// if (obj != null && obj != DBNull.Value)
|
|
// {
|
|
// dataRow.CreateCell(idx).SetCellValue(obj.ToString());
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
// }
|
|
// for (int i = 0; i < gridItems.Count; i++)
|
|
// {
|
|
// if (gridItems[i].export)
|
|
// {
|
|
// sheet.AutoSizeColumn(i);
|
|
// }
|
|
// }
|
|
// }
|
|
Response.Clear();
|
|
workbook.Write(outputStream);
|
|
|
|
Response.Buffer = true;
|
|
if (Request.Browser.Type.ToUpper().IndexOf("IE") >= 0)
|
|
{
|
|
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode("下线时间间隔(" + DateTime.Now.ToString("yyyy-MM-dd") + ".xls"));
|
|
}
|
|
else
|
|
{
|
|
Response.AppendHeader("Content-Disposition", "attachment;filename=下线时间间隔(" + DateTime.Now.ToString("yyyy-MM-dd") + ").xls");
|
|
}
|
|
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
|
Response.ContentType = "application/vnd.ms-excel";
|
|
Response.Flush();
|
|
//}
|
|
//catch (Exception e)
|
|
//{
|
|
//}
|
|
//finally
|
|
//{
|
|
// workbook = null;
|
|
//}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
}
|