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.

167 lines
6.1 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 RepairQueryController : BaseController
{
private IRepairQueryService service;
public RepairQueryController(IRepairQueryService _service)
{
service = _service;
}
public ActionResult Index()
{
return View();
}
/// <summary>
/// 产线
/// </summary>
/// <returns>数据集</returns>
public ActionResult GetPDLineName()
{
Hashtable resault = new Hashtable();
List<KeyValueResult> list = service.GetPDLineName();
resault.Add("list", list);
return Json(resault);
}
/// <summary>
/// 车型
/// </summary>
/// <returns>数据集</returns>
public ActionResult GetModelTypeList()
{
Hashtable resault = new Hashtable();
List<KeyValueResult> list = service.GetModelTypeList();
resault.Add("list", list);
return Json(resault);
}
/// <summary>
/// 配置
/// </summary>
/// <returns>数据集</returns>
public ActionResult GetModelList(string typeName)
{
Hashtable resault = new Hashtable();
List<KeyValueResult> 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;
}
/// <summary>
/// 根据用户选择的条件查找数据
/// </summary>
/// <param name="wheres">筛选条件</param>
/// <returns>获取汇总表</returns>
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<GSnStatus> dataHt = service.GetRepairDataList(wheres, pager, ref totalCount);
Hashtable result = new Hashtable();
result.Add("rows", dataHt);
result.Add("pager.totalRows", totalCount);
return Json(result);
}
/// <summary>
/// 导出全部
/// </summary>
/// <returns></returns>
public ActionResult exportData(Pager pager)
{
// 如果没有数据就直接返回
Hashtable resault = new Hashtable();
string wheres = GetWhereStr();
int totalCount = 0;
List<RepairQuery> dataHt = service.getTableListByPage(wheres, pager, ref totalCount);
var memoryStream = ExcelHelper.ToExcel(dataHt);
return File(memoryStream.ToArray(), "application/ms-excel", "不良条码查询.xls");
}
}
}