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; } /// /// 获取列表数据 /// /// 菜单名称 /// 分页 /// 排序方式 /// 排序列 /// 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); } /// /// 获取列表数据 /// /// 菜单名称 /// 分页 /// 排序方式 /// 排序列 /// 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); } /// /// 导出全部 /// /// public ActionResult exportData(Pager pager) { _where = SetWhere(); List sumList = service.getTableListByPage(_where); List 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"); } /// /// 客户产线集合 /// /// 数据集 public ActionResult GetCustPDLineName() { Hashtable resault = new Hashtable(); List list = service.GetCustPDLineName(); resault.Add("list", list); return Json(resault); } } }