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.
141 lines
5.7 KiB
C#
141 lines
5.7 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Web;
|
|
using System.Web.Mvc;
|
|
using Estsh.Web.Service;
|
|
using System.Data;
|
|
using System.Collections;
|
|
using NPOI.HSSF.UserModel;
|
|
using System.IO;
|
|
using Estsh.Web.Util;
|
|
|
|
namespace Estsh.Core.Web.Controllers
|
|
{
|
|
public class TerminalKPSNController : Controller
|
|
{
|
|
TerminalKPSNService completeSetService = new TerminalKPSNService();
|
|
//
|
|
// GET: /Menu/
|
|
public ActionResult Index()
|
|
{
|
|
return View();
|
|
}
|
|
public ActionResult GetTerminalName()
|
|
{
|
|
Hashtable resault = new Hashtable();
|
|
ArrayList list = completeSetService.GetTerminalName();
|
|
resault.Add("list", list);
|
|
return Json(resault, JsonRequestBehavior.AllowGet);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 获取列表数据
|
|
/// </summary>
|
|
/// <param name="PartMasterName">菜单名称</param>
|
|
/// <param name="pager">分页</param>
|
|
/// <param name="direction">排序方式</param>
|
|
/// <param name="sort">排序列</param>
|
|
/// <returns></returns>
|
|
public ActionResult getTerminalKPSNByPage(String txtStartTime, String txtEndTime, String kPartNo, string cbTerminalName, Pager pager)
|
|
{
|
|
|
|
if (string.IsNullOrEmpty(txtStartTime) || string.IsNullOrEmpty(txtEndTime))
|
|
{
|
|
return null;
|
|
}
|
|
|
|
Hashtable result = new Hashtable();
|
|
Hashtable dataHt = this.completeSetService.getTerminalKPSNByPage(txtStartTime, txtEndTime, kPartNo, cbTerminalName, pager);
|
|
result.Add("rows", dataHt["dataList"]);
|
|
result.Add("pager.totalRows", dataHt["totalCount"]);
|
|
return Json(result);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 导出数据到Excel
|
|
/// </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(String txtStartTime, String txtEndTime, String kPartNo, String cbTerminalName, Pager pager, String sort, String direction, String isPage)
|
|
{
|
|
|
|
|
|
if (string.IsNullOrEmpty(txtStartTime) || string.IsNullOrEmpty(txtEndTime))
|
|
{
|
|
return null;
|
|
}
|
|
|
|
int totalCount = 0;
|
|
DataTable dataHt = this.completeSetService.getTeKPSN(txtStartTime, txtEndTime,kPartNo, cbTerminalName, 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("关键件条码");
|
|
|
|
|
|
}
|
|
|
|
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]["terminal_name"].ToString());
|
|
dataRow.CreateCell(1).SetCellValue(dataHt.Rows[i]["type_name"].ToString());
|
|
dataRow.CreateCell(2).SetCellValue(dataHt.Rows[i]["model_name"].ToString());
|
|
dataRow.CreateCell(3).SetCellValue(dataHt.Rows[i]["part_no"].ToString());
|
|
dataRow.CreateCell(4).SetCellValue(dataHt.Rows[i]["part_spec"].ToString());
|
|
dataRow.CreateCell(5).SetCellValue(dataHt.Rows[i]["serial_number"].ToString());
|
|
dataRow.CreateCell(6).SetCellValue(dataHt.Rows[i]["create_ymd"].ToString());
|
|
dataRow.CreateCell(7).SetCellValue(dataHt.Rows[i]["create_hms"].ToString());
|
|
dataRow.CreateCell(8).SetCellValue(dataHt.Rows[i]["k_part_no"].ToString());
|
|
dataRow.CreateCell(9).SetCellValue(dataHt.Rows[i]["k_part_spec"].ToString());
|
|
dataRow.CreateCell(10).SetCellValue(dataHt.Rows[i]["kpsn"].ToString());
|
|
|
|
|
|
}
|
|
|
|
Response.Clear();
|
|
workbook.Write(outputStream);
|
|
|
|
Response.Buffer = true;
|
|
Response.AppendHeader("Content-Disposition", "attachment;filename=关键件绑定信息_" + DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") + ".xls");
|
|
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
|
Response.ContentType = "application/vnd.ms-excel";
|
|
Response.Flush();
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
}
|
|
finally
|
|
{
|
|
workbook = null;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
} |