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.
163 lines
5.8 KiB
163 lines
5.8 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 ChaimUpRecordBll
|
||
|
{
|
||
|
BasicBLL<tb_ChainUp> db = new BasicBLL<tb_ChainUp>();
|
||
|
|
||
|
public string SearchInfoAll(string page, string pagesize, string startTime, string endTime,int flag,string barCode)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
string jsonStr = "[]";
|
||
|
int total = 0;//总行数
|
||
|
List<tb_ChainUp> list = new List<tb_ChainUp>();
|
||
|
|
||
|
string sql = @" SELECT ID,barcode,carType,color,flag,createTime,productName from tb_ChainUp where 1=1";
|
||
|
|
||
|
if (!string.IsNullOrEmpty(startTime))
|
||
|
{
|
||
|
sql += @" and createTime between '"+ startTime + @"' and '"+ endTime +@"'";
|
||
|
}
|
||
|
if (flag == 2)
|
||
|
{
|
||
|
|
||
|
}
|
||
|
else if (flag == 0)
|
||
|
{
|
||
|
sql += @" and flag=0";
|
||
|
}
|
||
|
else if (flag == 1)
|
||
|
{
|
||
|
sql += @" and flag=1";
|
||
|
}
|
||
|
|
||
|
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_ChainUp>(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_ChainUp> md = new JsonDataModel<tb_ChainUp>();
|
||
|
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, int flag, string barCode)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
List<List<string>> list = new List<List<string>>();
|
||
|
|
||
|
string jsonStr = "[]";
|
||
|
int total = 0;//总行数
|
||
|
List<tb_ChainUp> listProduct = new List<tb_ChainUp>();
|
||
|
|
||
|
string sql = @" SELECT ID,barcode,carType,color,flag,createTime,productName from tb_ChainUp where 1=1";
|
||
|
|
||
|
if (!string.IsNullOrEmpty(startTime))
|
||
|
{
|
||
|
sql += @" and createTime between '" + startTime + @"' and '" + endTime + @"'";
|
||
|
}
|
||
|
if (flag == 2)
|
||
|
{
|
||
|
|
||
|
}
|
||
|
else if (flag == 0)
|
||
|
{
|
||
|
sql += @" and flag=0";
|
||
|
}
|
||
|
else if (flag == 1)
|
||
|
{
|
||
|
sql += @" and flag=1";
|
||
|
}
|
||
|
|
||
|
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_ChainUp>(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;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|