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.

122 lines
4.0 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 System.Collections;
/***************************************************************************************************
*
* 更新人sitong.dong
* 描述:成品异常领用查询
* 修改时间2022.06.22
* 修改日志:系统迭代升级
*
**************************************************************************************************/
namespace Estsh.Core.Web.Controllers
{
public class ProductAbnormalConsumeController : BaseController
{
private IProductAbnormalConsumeService service;
public ProductAbnormalConsumeController(IProductAbnormalConsumeService _service)
{
service = _service;
}
public ActionResult Index()
{
return View();
}
public string SetWhere()
{
string _where = "";
if (!string.IsNullOrEmpty(Request.Form["txtEmpName"].ToString()))
{
_where += " and e.emp_name= '" + Request.Form["txtEmpName"].ToString().Trim() + "'";
}
if (!string.IsNullOrEmpty(Request.Form["txtSerialNumber"]))
{
_where += " and a.serial_number= '" + Request.Form["txtSerialNumber"].ToString().Trim() + "'";
}
if (!string.IsNullOrEmpty(Request.Form["txtStartTime"]) && !string.IsNullOrEmpty(Request.Form["txtEndTime"]))
{
DateTime startTime = Convert.ToDateTime(Request.Form["txtStartTime"]);
DateTime endTime = Convert.ToDateTime(Request.Form["txtEndTime"]);
_where += "and a.update_time between '" + startTime.ToString("yyyy-MM-dd") +
"' and '" + endTime.ToString("yyyy-MM-dd") + "'";
}
return _where;
}
public ActionResult GetDetailData(Pager pager, String enabled = "Y")
{
if (string.IsNullOrEmpty(Request.Form["txtStartTime"]) && string.IsNullOrEmpty(Request.Form["txtEndTime"])
&& string.IsNullOrEmpty(Request.Form["txtSerialNumber"]) && string.IsNullOrEmpty(Request.Form["txtEmpName"]))
{
return Json("");
}
string where = SetWhere();
if (enabled != null && !enabled.Trim().Equals(""))
{
where += " and a.enabled = '" + enabled + "'";
}
String factoryId = CurrentEmp.FactoryId.ToString();
if (factoryId != null && !factoryId.Trim().Equals(""))
{
where += " and a.factory_id = '" + factoryId + "'";
}
int totalCount = 0;
List<GSnStatus> dtQuery = service.GetDetailData(where, pager, ref totalCount);
Hashtable result = new Hashtable();
result.Add("rows", dtQuery);
result.Add("pager.totalRows", totalCount);
return Json(result);
}
public ActionResult GetModelName(string typeName)
{
Hashtable ht = new Hashtable();
List<KeyValueResult> alModel = service.GetModelName(typeName);
ht.Add("list", alModel);
return Json(ht);
}
public ActionResult GetTypeName()
{
Hashtable ht = new Hashtable();
List<KeyValueResult> alType = service.GetTypeName();
ht.Add("list", alType);
return Json(ht);
}
public ActionResult exportData(Pager pager, int a)
{
int totalCount = 0;
//string where = SetWhere();
List<ProductAbnormalConsume> dataHt = service.getTableListByPage("", pager, ref totalCount);
var memoryStream = ExcelHelper.ToExcel(dataHt);
return File(memoryStream.ToArray(), "application/ms-excel", "成品异常领用.xls");
}
}
}