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.
122 lines
5.0 KiB
122 lines
5.0 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Text;
|
|
using MESClassLibrary.BLL;
|
|
using MESClassLibrary.BLL.Log;
|
|
using MESClassLibrary.EFModel;
|
|
using MESClassLibrary.Model;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Converters;
|
|
|
|
namespace MESClassLibrary.DAL.Injection
|
|
{
|
|
public class BarCodeRecordDAL
|
|
{
|
|
public string SearchInfoAll(string page, string pagesize, string stationID, string barcode,string startTime,string endTime)
|
|
{
|
|
try
|
|
{
|
|
string jsonStr = "[]";
|
|
int total = 0;//总行数
|
|
List<BarCodeModel> list=new List<BarCodeModel>();
|
|
|
|
string sql = @"SELECT dbo.tb_Station.StationNo, dbo.v_Code.StationID, dbo.v_Code.OneBarCode,dbo.v_Code.BarCode, dbo.v_Code.PrintType, dbo.v_Code.CreateTime,ISNULL(dbo.v_Code.Weight,0.00) Weight
|
|
FROM dbo.v_Code LEFT OUTER JOIN
|
|
dbo.tb_Station ON dbo.v_Code.StationID = dbo.tb_Station.StationID
|
|
where 1=1
|
|
";
|
|
if (!string.IsNullOrEmpty(stationID))
|
|
{
|
|
sql += " and dbo.v_Code.StationID='" + stationID + @"'";
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(barcode))
|
|
{
|
|
sql += " and dbo.v_Code.OneBarCode like '%" + barcode + @"%'";
|
|
}
|
|
if (!string.IsNullOrEmpty(startTime))
|
|
{
|
|
sql += " and (dbo.v_Code.CreateTime between '" + startTime + @"' and '" + endTime + @"')";
|
|
}
|
|
|
|
|
|
sql += " ORDER BY CreateTime ";
|
|
|
|
DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
list = Tool.ConvertTo<BarCodeModel>(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<BarCodeModel> md = new JsonDataModel<BarCodeModel>();
|
|
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);
|
|
//jsonStr = JSONTools.ScriptSerialize<JsonDataModel<RepairOrderModel>>(md);
|
|
}
|
|
return jsonStr;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(), MethodBase.GetCurrentMethod());
|
|
return null;
|
|
}
|
|
|
|
}
|
|
|
|
public string SearchInfoByRepeat(string page, string pagesize, string startTime, string endTime)
|
|
{
|
|
try
|
|
{
|
|
string jsonStr = "[]";
|
|
int total = 0;//总行数
|
|
List<BarCodeModel> list = new List<BarCodeModel>();
|
|
|
|
string sql = @"SELECT OneBarCode FROM dbo.v_Code
|
|
WHERE PrintType=0 AND IsDel=0 ";
|
|
if (!string.IsNullOrEmpty(startTime))
|
|
{
|
|
sql += " and (CreateTime between '" + startTime + @"' and '" + endTime + @"')";
|
|
}
|
|
|
|
sql += @" GROUP BY OneBarCode
|
|
HAVING COUNT(OneBarCode) >1";
|
|
DataTable dt = SqlHelper.ExecuteDataset(SqlHelper.GetConnSting(), CommandType.Text, sql, null).Tables[0];
|
|
if (dt != null && dt.Rows.Count > 0)
|
|
{
|
|
list = Tool.ConvertTo<BarCodeModel>(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<BarCodeModel> md = new JsonDataModel<BarCodeModel>();
|
|
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);
|
|
jsonStr = JSONTools.ScriptSerialize<JsonDataModel<BarCodeModel>>(md);
|
|
}
|
|
return jsonStr;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogErrBLL.AddInfo(ex.ToString(),MethodBase.GetCurrentMethod());
|
|
return "";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|