using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Mvc; using Estsh.Web.Service; using System.Collections; using Estsh.Web.Util; using System.Data; using NPOIReport; using System.IO; using NPOI.HSSF.UserModel; namespace Estsh.Core.Web.Controllers { public class PDLineStandbyQueryController : Controller { PDLineStandbyQueryService service = new PDLineStandbyQueryService(); // // GET: /PDLineStandbyQuery/ public ActionResult Index() { return View(); } public ActionResult GetPdLine() { Hashtable ht = service.GetPdLine(); if (ht != null && ht.ContainsKey("data")) { //ArrayList list = ht["data"] as ArrayList; Hashtable result = new Hashtable(); result.Add("list", ht["data"]); return Json(result, JsonRequestBehavior.AllowGet); } else { return null; } } public ActionResult GetSeatType() { Hashtable ht = service.GetSeatType(); if (ht != null && ht.ContainsKey("data")) { //ArrayList list = ht["data"] as ArrayList; Hashtable result = new Hashtable(); result.Add("list", ht["data"]); return Json(result, JsonRequestBehavior.AllowGet); } else { return null; } } public ActionResult GetStandbyTimeType() { Hashtable ht = service.GetStandbyTimeType(); if (ht != null && ht.ContainsKey("data")) { //ArrayList list = ht["data"] as ArrayList; Hashtable result = new Hashtable(); result.Add("list", ht["data"]); return Json(result, JsonRequestBehavior.AllowGet); } else { return null; } } /// /// 获得状态类型 /// /// public ActionResult GetStatusType() { Hashtable ht = service.GetStatusType(); if (ht != null && ht.ContainsKey("data")) { //ArrayList list = ht["data"] as ArrayList; Hashtable result = new Hashtable(); result.Add("list", ht["data"]); return Json(result, JsonRequestBehavior.AllowGet); } else { return null; } } /// /// 获得最小时间列 /// /// public ActionResult GetTimeLowLimit() { Hashtable ht = service.GetTimeLowLimit(); if (ht != null && ht.ContainsKey("data")) { //ArrayList list = ht["data"] as ArrayList; Hashtable result = new Hashtable(); result.Add("list", ht["data"]); return Json(result, JsonRequestBehavior.AllowGet); } else { return null; } } /// /// 获得班别 /// /// public ActionResult GetShiftData() { Hashtable ht = service.GetShiftData(); if (ht != null && ht.ContainsKey("data")) { //ArrayList list = ht["data"] as ArrayList; Hashtable result = new Hashtable(); result.Add("list", ht["data"]); return Json(result, JsonRequestBehavior.AllowGet); } else { return null; } } /// /// 获得部门 /// /// public ActionResult GetDeptInfo() { Hashtable ht = service.GetDeptInfo(); if (ht != null && ht.ContainsKey("data")) { //ArrayList list = ht["data"] as ArrayList; Hashtable result = new Hashtable(); result.Add("list", ht["data"]); return Json(result, JsonRequestBehavior.AllowGet); } else { return null; } } public ActionResult GetStandbyInfo(Pager pager) { string startTime = Request["startDate"]; if (string.IsNullOrEmpty(startTime)) { return null; } string stopTime = Request["stopDate"]; string pdLineId = Request["cbbPDLineName"]; string status = Request["cbbStatus"]; string timeType = Request["cbbTimeType"]; string timeLowLimit = Request["cbbTimeLowLimit"]; string seatType = Request["cbbSeatTypeName"]; string shiftId = Request["cbbShift"]; string deptId = Request["cbbDeptName"]; if (string.IsNullOrEmpty(pdLineId)) { pdLineId = "ALL"; } if (string.IsNullOrEmpty(shiftId)) { shiftId = "ALL"; } if (string.IsNullOrEmpty(deptId)) { deptId = "ALL"; } DataTable dt = service.GetStandbyInfo(ref pager, pdLineId, seatType, shiftId, status, deptId, timeLowLimit, timeType, startTime, stopTime); Hashtable result = new Hashtable(); if (dt != null) { result.Add("rows", DataTypeConvert.NewObject.DataTableToArrayList(dt)); result.Add("pager.totalRows", pager.totalRows); } return Json(result, JsonRequestBehavior.AllowGet); } public ActionResult EditStandInfo(string txtRuid, string txtStartTime, string txtPDLineName, string txtEndTime, string txtSeatType, string txtStandbyTime, string cbbDeptName, string cbbStatus, string sReason, string sAction) { ViewData.Add("txtRuid",txtRuid); ViewData.Add("txtStartTime", txtStartTime); ViewData.Add("txtPDLineName", txtPDLineName); ViewData.Add("txtEndTime", txtEndTime); ViewData.Add("txtSeatType", txtSeatType); ViewData.Add("txtStandbyTime", txtStandbyTime); ViewData.Add("cbbDeptName", cbbDeptName); ViewData.Add("cbbStatus", cbbStatus); ViewData.Add("sReason", sReason); ViewData.Add("sAction", sAction); return View("~/Views/PDLineStandbyQuery/PDLineStandEdit.aspx"); } public bool SaveStandInfo() { int ruid = Convert.ToInt32(Request["txtRuid"]); String txtStartTime = Request["txtStartTime"]; String txtPDLineName = Request["txtPDLineName"]; String txtEndTime = Request["txtEndTime"]; String txtSeatType = Request["txtSeatType"]; String txtStandbyTime = Request["txtStandbyTime"]; String cbbDeptName = Request["cbbDeptName"]; String cbbStatus = Request["cbbStatus"]; String sReason = Request["sReason"]; string sAction =Request["sAction"]; bool result = service.UpdatdStandbyInfo(ruid, sReason, cbbDeptName, sAction, cbbStatus); return result; } public ActionResult exportData(int rowCount, int pageIndex) { Pager page = new Pager(); page.pageNo = pageIndex; page.pageSize = rowCount; string startTime = Request["startDate"]; if (string.IsNullOrEmpty(startTime)) { return null; } string stopTime = Request["stopDate"]; string pdLineId = Request["cbbPDLineName"]; string status = Request["cbbStatus"]; string timeType = Request["cbbTimeType"]; string timeLowLimit = Request["cbbTimeLowLimit"]; string seatType = Request["cbbSeatTypeName"]; string shiftId = Request["cbbShift"]; string deptId = Request["cbbDeptName"]; if (string.IsNullOrEmpty(pdLineId)) { pdLineId = "ALL"; } if (string.IsNullOrEmpty(shiftId)) { shiftId = "ALL"; } if (string.IsNullOrEmpty(deptId)) { deptId = "ALL"; } DataTable dt = service.GetStandbyInfo(ref page, pdLineId, seatType, shiftId, status, deptId, timeLowLimit, timeType, startTime, stopTime); Stream outputStream = Response.OutputStream; try { 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, dt, "停线时间查询"); Response.Clear(); workbook.Write(outputStream); Response.Buffer = true; if (Request.Browser.Type.ToUpper().IndexOf("IE") >= 0) { Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode("停线时间查询.xls", System.Text.Encoding.UTF8)); } else { Response.AppendHeader("Content-Disposition", "attachment;filename=停线时间查询.xls"); } Response.ContentEncoding = System.Text.Encoding.UTF8; Response.ContentType = "application/vnd.ms-excel"; Response.Flush(); } catch { } return null; } } }