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.

101 lines
3.3 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;
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 LotDefineController : BaseController
{
private ILotDefineService service;
private IGridColumnService colService;
public LotDefineController(ILotDefineService _service, IGridColumnService colService)
{
service = _service;
this.colService = colService;
}
public ActionResult Index()
{
return View();
}
public string GetWhereStr()
{
string _whereStr = string.Empty;
//零件号
if (!string.IsNullOrEmpty(Request.Form["txtPart_No"]))
{
if (Request.Form["txtPart_No"].ToString().Trim() == "")
{
_whereStr += "";
}
else
{
_whereStr += " and a.item_part_no = '" + Request.Form["txtPart_No"].ToString().Trim() + "'";
}
}
//批次
if (!string.IsNullOrEmpty(Request.Form["txtLotNo"]))
{
if (Request.Form["txtLotNo"].ToString().Trim() == "")
{
_whereStr += "";
}
else
{
_whereStr += " and lot_no = '" + Request.Form["txtLotNo"].ToString().Trim() + "'";
}
}
return _whereStr;
}
/// <summary>
/// 获取批次追溯查询列表数据
/// </summary>
/// <returns></returns>
public ActionResult GetQuery(Pager pager)
{
if (string.IsNullOrEmpty(Request.Form["txtPart_No"]) && string.IsNullOrEmpty(Request.Form["txtLotNo"]))
{
return Json("");
}
string wheres = GetWhereStr();
int totalCount = 0;
List<GMoveTrans> dataHt = service.GetQuery(wheres, pager, ref totalCount);
Hashtable result = new Hashtable();
result.Add("rows", dataHt);
result.Add("pager.totalRows", totalCount);
return Json(result);
}
public ActionResult exportData(Pager pager)
{
// 如果没有数据就直接返回
Hashtable resault = new Hashtable();
string wheres = GetWhereStr();
int totalCount = 0;
Hashtable dataHt = service.getTableListByPage(wheres, pager);
List<LotDefine> listHt = (List<LotDefine>)dataHt["dataList"];
var memoryStream = ExcelHelper.ToExcel(listHt);
return File(memoryStream.ToArray(), "application/ms-excel", "批次追溯查询.xls");
}
}
}