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.

158 lines
5.4 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using Estsh.Core.Controllers;
using Estsh.Core.Model.ExcelModel;
using Estsh.Core.Model.Result;
using Estsh.Core.Models;
using Estsh.Core.Services.IServices;
using Estsh.Core.Util;
using Microsoft.AspNetCore.Mvc;
using NPOI.HSSF.UserModel;
using System.Collections;
/***************************************************************************************************
*
* 更新人sitong.dong
* 描述:打包信息查询
* 修改时间2022.06.22
* 修改日志:系统迭代升级
*
**************************************************************************************************/
namespace Estsh.Core.Web.Controllers
{
public class ShippingInformationDefineController: BaseController
{
private IShippingInformationDefineService service;
public ShippingInformationDefineController(IShippingInformationDefineService _service)
{
service = _service;
}
//
// GET: /Menu/
public ActionResult Index()
{
return View();
}
string _where = "";
public string SetWhere()
{
int condition = 0;
_where = "";
DateTime startDate = DateTime.Now.AddDays(-1); //Request.RequestContext.HttpContext.Timestamp.AddDays(-1);
DateTime endDate = DateTime.Now;//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.Form["txtOrderNo"]))
{
condition++;
_where += " and a.orderNo like '%" + Request.Form["txtOrderNo"].ToString().Trim() + "%' ";
}
if (!string.IsNullOrEmpty(Request.Form["txtPartNo"]))
{
condition++;
_where += " and a.partNo = '%" + Request.Form["txtPartNo"].ToString().Trim() + "%' ";
}
if (!string.IsNullOrEmpty(Request.Form["txtStartTime"]) || !string.IsNullOrEmpty(Request.Form["txtEndTime"]))
{
condition++;
_where += " and a.updateYmd+' '+a.updateHms BETWEEN '" + Request.Form["txtStartTime"].ToString().Trim() + "' and '" + Request.Form["txtEndTime"].ToString().Trim() + "' ";
}
if (condition == 0)
{
_where += " and a.updateYmd+' '+a.updateHms BETWEEN '" + starttime + "' and '" + endtime + "' ";
}
return _where;
}
/// <summary>
/// 获取列表数据
/// </summary>
/// <param name="PartMasterName">菜单名称</param>
/// <param name="pager">分页</param>
/// <param name="direction">排序方式</param>
/// <param name="sort">排序列</param>
/// <returns></returns>
public ActionResult getShippingListByPage(Pager pager, String direction, String sort)
{
_where = SetWhere();
Hashtable result = new Hashtable();
result.Add("pager.pageNo", pager.pageNo);
Hashtable dataHt = this.service.getShippingListByPage(_where, pager);
result.Add("rows", dataHt["dataList"]);
result.Add("pager.totalRows", dataHt["totalCount"]);
result.Add("sort", sort);
result.Add("direction", direction);
return Json(result);
}
/// <summary>
/// 获取列表数据
/// </summary>
/// <param name="PartMasterName">菜单名称</param>
/// <param name="pager">分页</param>
/// <param name="direction">排序方式</param>
/// <param name="sort">排序列</param>
/// <returns></returns>
public ActionResult getShippingListDetailByPage(Pager pager, String direction, String sort)
{
_where = SetWhere();
Hashtable result = new Hashtable();
result.Add("pager.pageNo", pager.pageNo);
Hashtable dataHt = this.service.getShippingListDetailByPage(_where, pager);
result.Add("rows", dataHt["dataList"]);
result.Add("pager.totalRows", dataHt["totalCount"]);
result.Add("sort", sort);
result.Add("direction", direction);
return Json(result);
}
/// <summary>
/// 导出全部
/// </summary>
/// <returns></returns>
public ActionResult exportData(Pager pager)
{
_where = SetWhere();
List<ShippingInformationDefine> sumList = service.getTableListByPage(_where);
List<GMiscoSn> detailList = service.GetCountShippingDetail(_where);
HSSFWorkbook workbook = new HSSFWorkbook();
HSSFSheet sheet = (HSSFSheet)workbook.CreateSheet("汇总");
HSSFSheet sheet2 = (HSSFSheet)workbook.CreateSheet("明细");
var memoryStream = ExcelHelper.ToExcel(sumList);
return File(memoryStream.ToArray(), "application/ms-excel", "发运信息_.xls");
}
/// <summary>
/// 客户产线集合
/// </summary>
/// <returns>数据集</returns>
public ActionResult GetCustPDLineName()
{
Hashtable resault = new Hashtable();
List<KeyValueResult> list = service.GetCustPDLineName();
resault.Add("list", list);
return Json(resault);
}
}
}