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.
194 lines
7.4 KiB
C#
194 lines
7.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
using Estsh.BLL;
|
|
using System.Collections;
|
|
using System.Data;
|
|
using Estsh.Web.Util;
|
|
using System.IO;
|
|
using Estsh.Web.Service;
|
|
using NPOI.HSSF.UserModel;
|
|
|
|
|
|
namespace Estsh.Core.Web.Controllers
|
|
{
|
|
public class YYRankQueryController : Controller
|
|
{
|
|
//
|
|
YYRankQueryService Service = new YYRankQueryService();
|
|
|
|
public ActionResult Index()
|
|
{
|
|
return View();
|
|
}
|
|
|
|
string _where = "";
|
|
public string SetWhere()
|
|
{
|
|
int condition = 0;
|
|
_where = "";
|
|
|
|
DateTime startDate = Request.RequestContext.HttpContext.Timestamp.AddDays(-1);
|
|
DateTime endDate = Request.RequestContext.HttpContext.Timestamp;
|
|
|
|
string starttime = startDate.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
string endtime = endDate.ToString("yyyy-MM-dd HH:mm:ss");
|
|
|
|
if (!string.IsNullOrEmpty(Request["txtOrderNo"]))
|
|
{
|
|
condition++;
|
|
_where += " and a.order_no= '" + Request["txtOrderNo"].ToString().Trim() + "'";
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(Request["txtPartNo"]))
|
|
{
|
|
condition++;
|
|
_where += " and a.part_no = '" + Request["txtPartNo"].Trim() + "'";
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(Request["txtSN"]))
|
|
{
|
|
condition++;
|
|
_where += " and a.serial_number like '%" + Request["txtSN"].Trim() + "'%";
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(Request["txtStartTime"])&& !string.IsNullOrEmpty(Request["txtEndTime"]))
|
|
{
|
|
condition++;
|
|
_where += " and a.create_ymd+' '+a.create_hms >= '" + Request["txtStartTime"].Trim() + "'";
|
|
_where += " and a.create_ymd+' '+a.create_hms <= '" + Request["txtEndTime"].Trim() + "'";
|
|
}
|
|
|
|
if (condition == 0)
|
|
{
|
|
_where += " and a.create_ymd+' '+a.create_hms >= '" + starttime + "'";
|
|
_where += " and a.create_ymd+' '+a.create_hms <= '" + endtime + "'";
|
|
}
|
|
return _where;
|
|
}
|
|
/// <summary>
|
|
/// 汇总
|
|
/// </summary>
|
|
/// <param name="pager"></param>
|
|
/// <returns></returns>
|
|
public ActionResult GetYYRankData(Pager pager)
|
|
{
|
|
_where = SetWhere();
|
|
int totalCount = 0;
|
|
DataTable dtQuery = Service.GetYYRankData(_where, pager, ref totalCount);
|
|
Hashtable result = new Hashtable();
|
|
result.Add("rows", DataTypeConvert.NewObject.DataTableToArrayList(dtQuery));
|
|
result.Add("pager.totalRows", totalCount);
|
|
return Json(result);
|
|
}
|
|
/// <summary>
|
|
/// 车型
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
public ActionResult GetTypeName()
|
|
{
|
|
Hashtable ht = new Hashtable();
|
|
ArrayList alType = Service.GetTypeName();
|
|
ht.Add("list", alType);
|
|
return Json(ht, JsonRequestBehavior.AllowGet);
|
|
|
|
}
|
|
/// <summary>
|
|
/// 配置
|
|
/// </summary>
|
|
/// <param name="typeName"></param>
|
|
/// <returns></returns>
|
|
public ActionResult GetModelName(string typeName)
|
|
{
|
|
Hashtable ht = new Hashtable();
|
|
ArrayList alModel = Service.GetModelName(typeName);
|
|
ht.Add("list", alModel);
|
|
return Json(ht, JsonRequestBehavior.AllowGet);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 导出数据
|
|
/// </summary>
|
|
/// <param name="pager"></param>
|
|
/// <param name="a"></param>
|
|
/// <param name="sort"></param>
|
|
/// <param name="direction"></param>
|
|
/// <param name="isPage"></param>
|
|
/// <returns></returns>
|
|
public ActionResult exportData(String txtStartTime,String txtEndTime,String txtOrderNo,String txtPartNo,String txtSN, Pager pager, int a, String sort, String direction, String isPage)
|
|
{
|
|
int totalCount = 0;
|
|
|
|
_where = SetWhere();
|
|
|
|
DataTable dataHt = Service.GetYYRankData(_where, pager, ref totalCount);
|
|
|
|
HSSFWorkbook workbook = new HSSFWorkbook();
|
|
Stream outputStream = Response.OutputStream;
|
|
HSSFSheet sheet = (HSSFSheet)workbook.CreateSheet("物料排序扫描信息");
|
|
try
|
|
{
|
|
if (workbook != null)
|
|
{
|
|
HSSFRow headRow = (HSSFRow)sheet.CreateRow(0);
|
|
headRow.CreateCell(0).SetCellValue("单号");
|
|
headRow.CreateCell(1).SetCellValue("零件号");
|
|
headRow.CreateCell(2).SetCellValue("零件描述");
|
|
headRow.CreateCell(3).SetCellValue("零件条码");
|
|
headRow.CreateCell(4).SetCellValue("状态");
|
|
headRow.CreateCell(5).SetCellValue("是否正常");
|
|
headRow.CreateCell(6).SetCellValue("更新人");
|
|
headRow.CreateCell(7).SetCellValue("更新日期");
|
|
headRow.CreateCell(8).SetCellValue("更新时间");
|
|
headRow.CreateCell(9).SetCellValue("创建人");
|
|
headRow.CreateCell(10).SetCellValue("创建日期");
|
|
headRow.CreateCell(11).SetCellValue("创建时间");
|
|
|
|
}
|
|
|
|
for (int i = 0; i < dataHt.Rows.Count; i++)
|
|
{
|
|
int row = i + 1;
|
|
HSSFRow dataRow = (HSSFRow)sheet.CreateRow(row);
|
|
|
|
dataRow.CreateCell(0).SetCellValue(dataHt.Rows[i]["order_no"].ToString());
|
|
dataRow.CreateCell(1).SetCellValue(dataHt.Rows[i]["part_no"].ToString());
|
|
dataRow.CreateCell(2).SetCellValue(dataHt.Rows[i]["part_spec"].ToString());
|
|
dataRow.CreateCell(3).SetCellValue(dataHt.Rows[i]["serial_number"].ToString());
|
|
dataRow.CreateCell(4).SetCellValue(dataHt.Rows[i]["status"].ToString());
|
|
dataRow.CreateCell(5).SetCellValue(dataHt.Rows[i]["enabled"].ToString());
|
|
dataRow.CreateCell(6).SetCellValue(dataHt.Rows[i]["update_name"].ToString());
|
|
dataRow.CreateCell(7).SetCellValue(dataHt.Rows[i]["update_ymd"].ToString());
|
|
dataRow.CreateCell(8).SetCellValue(dataHt.Rows[i]["update_hms"].ToString());
|
|
dataRow.CreateCell(9).SetCellValue(dataHt.Rows[i]["create_name"].ToString());
|
|
dataRow.CreateCell(10).SetCellValue(dataHt.Rows[i]["create_ymd"].ToString());
|
|
dataRow.CreateCell(11).SetCellValue(dataHt.Rows[i]["create_hms"].ToString());
|
|
|
|
}
|
|
|
|
Response.Clear();
|
|
workbook.Write(outputStream);
|
|
|
|
Response.Buffer = true;
|
|
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;
|
|
}
|
|
}
|
|
}
|