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
7.6 KiB
C#
198 lines
7.6 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
|
|
{
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public class XTShipDefineController : Controller
|
|
{
|
|
private XTShipDefineService service = new XTShipDefineService();
|
|
|
|
//
|
|
// GET: /XTShipDefine/
|
|
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["cbModelName"]))
|
|
{
|
|
condition++;
|
|
_where += " and c.model_id = '" + Request["cbModelName"].ToString().Trim() + "'";
|
|
}
|
|
if (!string.IsNullOrEmpty(Request["txtVIN"]))
|
|
{
|
|
condition++;
|
|
_where += " and b.VIN like '%" + Request["txtVIN"].Trim() + "%'";
|
|
}
|
|
if (!string.IsNullOrEmpty(Request["txtSN"]))
|
|
{
|
|
condition++;
|
|
_where += " and (g.serial_number like '%" + Request["txtSN"].Trim() + "%' OR g.csn like '%" + Request["txtSN"].Trim() + "%' )";
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(Request["txtstatus"]))
|
|
{
|
|
condition++;
|
|
_where += " and a.status = '" + Request["txtstatus"].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="CartonTrackName">菜单名称</param>
|
|
/// <param name="pager">分页</param>
|
|
/// <param name="direction">排序方式</param>
|
|
/// <param name="sort">排序列</param>
|
|
/// <returns></returns>
|
|
public ActionResult XTShipDefineListByPage(Pager pager)
|
|
{
|
|
int totalCount = 0;
|
|
_where = SetWhere();
|
|
DataTable dtQuery = service.XTShipDefineListByPage(_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 GetModelName()
|
|
{
|
|
Hashtable resault = new Hashtable();
|
|
ArrayList list = service.GetModelName();
|
|
resault.Add("list", list);
|
|
return Json(resault, JsonRequestBehavior.AllowGet);
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
/// 导出数据到Excel
|
|
/// BY NOAH
|
|
/// </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(Pager pager, int a, String sort, String direction, String isPage)
|
|
{
|
|
|
|
int totalCount = 0;
|
|
_where = SetWhere();
|
|
DataTable dataHt = this.service.XTShipDefineListByPage(_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("VIN");
|
|
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]["PNRSTRING"].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]["status"].ToString());
|
|
dataRow.CreateCell(7).SetCellValue(dataHt.Rows[i]["VIN"].ToString());
|
|
dataRow.CreateCell(8).SetCellValue(dataHt.Rows[i]["create_ymd"].ToString());
|
|
dataRow.CreateCell(9).SetCellValue(dataHt.Rows[i]["create_hms"].ToString());
|
|
dataRow.CreateCell(10).SetCellValue(dataHt.Rows[i]["ship_create_ymd"].ToString());
|
|
dataRow.CreateCell(11).SetCellValue(dataHt.Rows[i]["ship_create_hms"].ToString());
|
|
}
|
|
|
|
Response.Clear();
|
|
workbook.Write(outputStream);
|
|
|
|
Response.Buffer = true;
|
|
Response.AppendHeader("Content-Disposition", "attachment;filename=发运信息.xls");
|
|
Response.ContentEncoding = System.Text.Encoding.UTF8;
|
|
Response.ContentType = "application/vnd.ms-excel";
|
|
Response.Flush();
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
}
|
|
finally
|
|
{
|
|
workbook = null;
|
|
}
|
|
|
|
return null;
|
|
}
|
|
}
|
|
}
|