using Estsh.Core.Controllers; using Estsh.Core.Model.ExcelModel; 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 ProdunctFinishedController : BaseController { private IProdunctFinishedService service; public ProdunctFinishedController(IProdunctFinishedService _service) { service = _service; } public ActionResult Index() { return View(); } public string SetWhere() { string _where = ""; string dateStart = DateTime.MinValue.ToString("yyyy-MM-dd HH:mm:ss"); string dateEnd = DateTime.MaxValue.ToString("yyyy-MM-dd HH:mm:ss"); string chkUseTime = Request.Form["chkUseTime"]; if (string.IsNullOrEmpty(chkUseTime) == false) { dateStart = Request.Form["txtStartTime"].ToString(); dateEnd = Request.Form["txtEndTime"].ToString(); _where += " AND create_time BETWEEN '" + dateStart + "' AND '" + dateEnd + "' "; } return _where; } public ActionResult GetAll(Pager pager,string str) { if(string.IsNullOrEmpty(str)) { return Json(""); } string where = SetWhere(); int totalCount = 0; List dtQuery = service.GetAll(where, pager, ref totalCount); Hashtable result = new Hashtable(); result.Add("rows", dtQuery); result.Add("pager.totalRows", totalCount); return Json(result); } public ActionResult ProductShipping(string SerialNumber, string FinishPeople, string OutingNo, string Reason, string Remark, Pager pager) { Hashtable result = new Hashtable(); if (!string.IsNullOrEmpty(SerialNumber) && !string.IsNullOrEmpty(FinishPeople) && !string.IsNullOrEmpty(Reason)) { bool CheckSN = service.IsCartonNoExists(SerialNumber); if (CheckSN) { string tres = service.ProductShipping(SerialNumber, Remark, FinishPeople, 100, OutingNo, Reason); result.Add("status", tres); return Json(result); } else { result.Add("status", "条码不存在,请检查重新输入或者扫描!"); return Json(result); } } else { result.Add("status", "数据校验失败,请检查!"); return Json(result); } } public ActionResult exportData(Pager pager, int a) { int totalCount = 0; string where = SetWhere(); List dataHt = service.getTableListByPage(where, pager, ref totalCount); var memoryStream = ExcelHelper.ToExcel(dataHt); return File(memoryStream.ToArray(), "application/ms-excel", "成品异常领用.xls"); } } }