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 RepairQueryController : BaseController { private IRepairQueryService service; public RepairQueryController(IRepairQueryService _service) { service = _service; } public ActionResult Index() { return View(); } /// /// 产线 /// /// 数据集 public ActionResult GetPDLineName() { Hashtable resault = new Hashtable(); List list = service.GetPDLineName(); resault.Add("list", list); return Json(resault); } /// /// 车型 /// /// 数据集 public ActionResult GetModelTypeList() { Hashtable resault = new Hashtable(); List list = service.GetModelTypeList(); resault.Add("list", list); return Json(resault); } /// /// 配置 /// /// 数据集 public ActionResult GetModelList(string typeName) { Hashtable resault = new Hashtable(); List list = service.GetModelList(typeName); resault.Add("list", list); return Json(resault); } public string GetWhereStr() { string _whereStr = string.Empty; string pdLine = string.Empty; string outPDLine = string.Empty; //产线 if (!string.IsNullOrEmpty(Request.Form["cmbPDLineName"])) { _whereStr += " AND pdlineName = '" + Request.Form["cmbPDLineName"].ToString() + "'"; } //车型 if (!string.IsNullOrEmpty(Request.Form["cmbCarType"])) { _whereStr += " AND type_name = '" + Request.Form["cmbCarType"].ToString() + "'"; } //配置 if (!string.IsNullOrEmpty(Request.Form["cmbModel"])) { _whereStr += " AND model_name = '" + Request.Form["cmbModel"].ToString() + "'"; } //总成 if (!string.IsNullOrEmpty(Request.Form["cmbSeatTypeName"])) { string SeatTypeName = Request.Form["cmbSeatTypeName"].ToString(); switch (SeatTypeName) { case "ALL": _whereStr += " AND part_location in ('01','02','03','04','05','06','07','08','09','10','11')"; break; case "前排": _whereStr += " AND part_location in ('01','02','08','09','10','11')"; break; case "后坐垫": _whereStr += " AND part_location in ('03')"; break; case "后靠背": _whereStr += " AND part_location in ('04','05')"; break; } } //显示充料条码 //if (!string.IsNullOrEmpty(Request["history"])) //{ // _whereStr += " AND prod_type NOT IN ('C')"; //} if (!string.IsNullOrEmpty(Request.Form["txtStartTime"]) && !string.IsNullOrEmpty(Request.Form["txtEndTime"])) { DateTime startPrintTime = Convert.ToDateTime(Request.Form["txtStartTime"]); DateTime endPrintTime = Convert.ToDateTime(Request.Form["txtEndTime"]); _whereStr += " AND ((convert(datetime,a.updateYmd +' ' + a.updateHms) >= '" + startPrintTime.ToString("yyyy-MM-dd HH:mm:ss") + "' AND convert(datetime,a.updateYmd +' ' + a.updateHms) <= '" + endPrintTime.ToString("yyyy-MM-dd HH:mm:ss") + "') OR in_pdline_time IS NULL) "; } return _whereStr; } /// /// 根据用户选择的条件查找数据 /// /// 筛选条件 /// 获取汇总表 public ActionResult GetRepairDataList(Pager pager) { if (string.IsNullOrEmpty(Request.Form["cmbPDLineName"]) && string.IsNullOrEmpty(Request.Form["cmbCarType"]) && string.IsNullOrEmpty(Request.Form["cmbSeatTypeName"]) && string.IsNullOrEmpty(Request.Form["cmbModel"]) && string.IsNullOrEmpty(Request.Form["txtStartTime"]) && string.IsNullOrEmpty(Request.Form["txtEndTime"])) { return null; } string wheres = GetWhereStr(); int totalCount = 0; List dataHt = service.GetRepairDataList(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; List dataHt = service.getTableListByPage(wheres, pager, ref totalCount); var memoryStream = ExcelHelper.ToExcel(dataHt); return File(memoryStream.ToArray(), "application/ms-excel", "不良条码查询.xls"); } } }