一厂MES,含注塑,喷涂,冲孔
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

138 lines
5.2 KiB

3 months ago
using MESClassLibrary.BLL.Log;
using MESClassLibrary.DAL;
using MESClassLibrary.EFModel;
using MESClassLibrary.Model;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Reflection;
using System.Text;
namespace MESClassLibrary.BLL.Painting
{
public class ChaimDownRecordBll
{
BasicBLL<tb_ChainDown> db = new BasicBLL<tb_ChainDown>();
public string SearchInfoAll(string page, string pagesize, string startTime, string endTime,string barCode)
{
try
{
string jsonStr = "[]";
int total = 0;//总行数
List<tb_ChainDown> list = new List<tb_ChainDown>();
string sql = @" SELECT ID,barcode,carType,color,createTime,productName from tb_ChainDown where 1=1";
if (!string.IsNullOrEmpty(startTime))
{
sql += @" and createTime between '" + startTime + @"' and '" + endTime + @"'";
}
if (!string.IsNullOrEmpty(barCode))
{
sql += @" and barcode like '%" + barCode + @"%'";
}
DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql).Tables[0];
if (dt != null && dt.Rows.Count > 0)
{
list = Tool.ConvertTo<tb_ChainDown>(dt).ToList();
}
if (list.Count > 0)
{
total = list.Count;
int Skipcount = (Convert.ToInt32(page) - 1) * Convert.ToInt32(pagesize);
list = list.Skip(Skipcount).Take(Convert.ToInt32(pagesize)).ToList();
JsonDataModel<tb_ChainDown> md = new JsonDataModel<tb_ChainDown>();
md.total = total.ToString();
md.rows = list;
IsoDateTimeConverter timeConverter = new IsoDateTimeConverter { DateTimeFormat = "yyyy-MM-dd HH:mm:ss" };
jsonStr = Newtonsoft.Json.JsonConvert.SerializeObject(md, Formatting.Indented, timeConverter);
}
return jsonStr;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return "";
}
}
public List<List<string>> SearchForExcel(string page, string pagesize, string startTime, string endTime,string barCode)
{
try
{
List<List<string>> list = new List<List<string>>();
string jsonStr = "[]";
int total = 0;//总行数
List<tb_ChainDown> listProduct = new List<tb_ChainDown>();
string sql = @" SELECT ID,barcode,carType,color,createTime,productName from tb_ChainDown where 1=1";
if (!string.IsNullOrEmpty(startTime))
{
sql += @" and createTime between '" + startTime + @"' and '" + endTime + @"'";
}
if (!string.IsNullOrEmpty(barCode))
{
sql += @" and barcode like '%" + barCode + @"%'";
}
DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql).Tables[0];
if (dt != null && dt.Rows.Count > 0)
{
listProduct = Tool.ConvertTo<tb_ChainDown>(dt).ToList();
}
if (listProduct != null && listProduct.Count() > 0)
{
List<string> title_ = new List<string>();
title_.Add("条码");
//title_.Add("车型");
title_.Add("产品名称");
title_.Add("颜色");
//title_.Add("是否下悬挂链");
title_.Add("下悬挂链时间");
list.Add(title_);
foreach (var item in listProduct)
{
List<string> rowList = new List<string>();
rowList.Add(item.barcode == null ? "" : item.barcode);
//rowList.Add(item.carType == null ? "" : item.carType);
rowList.Add(item.productName == null ? "" : item.productName);
rowList.Add(item.color == null ? "" : item.color);
//switch (item.flag)
//{
// case 0:
// rowList.Add("未下悬挂链");
// break;
// case 1:
// rowList.Add("已下悬挂链");
// break;
//}
rowList.Add(item.createTime == null ? "" : item.createTime.ToString());
list.Add(rowList);
}
}
return list;
}
catch (Exception ex)
{
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
return null;
}
}
}
}