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.
316 lines
12 KiB
316 lines
12 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Text;
|
|
using QMFrameWork.Data;
|
|
using QMAPP.FJC.Entity.FIS;
|
|
using QMFrameWork.Log;
|
|
using System.Data;
|
|
using System.Linq;
|
|
using QMAPP.DAL;
|
|
using QMAPP.FJC.Entity.FileCopy.FIS;
|
|
using QMAPP.MD.Entity;
|
|
|
|
namespace QMAPP.FJC.DAL.FIS
|
|
{
|
|
public class FISOrderDAL : BaseDAL
|
|
{
|
|
#region 获取列表
|
|
/// <summary>
|
|
/// 获取列表
|
|
/// </summary>
|
|
/// <param name="condition">条件</param>
|
|
/// <param name="page">数据页</param>
|
|
/// <returns>数据页</returns>
|
|
public DataPage GetList(FISOrder condition, DataPage page)
|
|
{
|
|
string sql = null;
|
|
List<DataParameter> parameters = new List<DataParameter>();
|
|
//List<FISOrder> list = new List<FISOrder>();
|
|
try
|
|
{
|
|
sql = this.GetQuerySql(condition, ref parameters);
|
|
//分页关键字段及排序
|
|
page.KeyName = "PID";
|
|
if (string.IsNullOrEmpty(page.SortExpression))
|
|
{
|
|
page.SortExpression = "CP5A DESC";
|
|
}
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
page = session.GetDataPage<FISOrder>(sql, parameters.ToArray(), page);
|
|
}
|
|
return page;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
{
|
|
ErrorInfo = ex,
|
|
Tag = ex.StackTrace,
|
|
Info = "FIS 计划信息数据层-获取列表"
|
|
});
|
|
throw;
|
|
}
|
|
}
|
|
public List<FISOrder> FISOrderIsNull(FISOrder condition)
|
|
{
|
|
//string sql = "SELECT * FROM [T_PP_FISORDER] where [VWSEQ]='" + condition.VWSEQ + "' and [KIN]='" + condition.KIN + "' and [VIN]='" + condition.VIN + "' and [LINENO]='" + condition.LINENO + "'";
|
|
string sql = "SELECT * FROM [T_PP_FISORDER] where [KIN]='" + condition.KIN + "' and [LINENO]='" + condition.LINENO + "'";
|
|
List<DataParameter> parameters = new List<DataParameter>();
|
|
try
|
|
{
|
|
//if (BaseSession != null)
|
|
//{
|
|
// return BaseSession.GetList<FISOrder>(sql, parameters.ToArray()).ToList();
|
|
//}
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
return session.GetList<FISOrder>(sql, parameters.ToArray()).ToList();
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
{
|
|
ErrorInfo = ex,
|
|
Tag = ex.StackTrace,
|
|
Info = "FIS 计划信息数据层-获取列表"
|
|
});
|
|
throw;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 获取查询语句
|
|
/// <summary>
|
|
/// 获取查询语句
|
|
/// </summary>
|
|
/// <param name="user">查询条件</param>
|
|
/// <param name="parameters">参数</param>
|
|
/// <returns>查询语句</returns>
|
|
private string GetQuerySql(FISOrder condition, ref List<DataParameter> parameters)
|
|
{
|
|
StringBuilder sqlBuilder = new StringBuilder();
|
|
StringBuilder whereBuilder = new StringBuilder();
|
|
try
|
|
{
|
|
//构成查询语句
|
|
sqlBuilder.AppendLine(" SELECT F.PID, ");
|
|
sqlBuilder.AppendLine(" F.VWSEQ, ");
|
|
sqlBuilder.AppendLine(" F.KIN, ");
|
|
sqlBuilder.AppendLine(" F.VIN, ");
|
|
sqlBuilder.AppendLine(" F.PRODNO, ");
|
|
sqlBuilder.AppendLine(" F.CARSETDESC_CN, ");
|
|
sqlBuilder.AppendLine(" F.CP5A, ");
|
|
sqlBuilder.AppendLine(" F.SCANSTATE, ");
|
|
sqlBuilder.AppendLine(" F.[LINENO], ");
|
|
sqlBuilder.AppendLine(" CONVERT(VARCHAR(19),F.CREATETIME,120) AS CREATETIME, ");
|
|
sqlBuilder.AppendLine(" F.FLAGDEL ");
|
|
sqlBuilder.AppendLine(" FROM T_PP_FISORDER F ");
|
|
//查询条件
|
|
|
|
//大众顺序号
|
|
if (string.IsNullOrEmpty(condition.VWSEQ) == false)
|
|
{
|
|
whereBuilder.Append(" AND VWSEQ = @VWSEQ");
|
|
parameters.Add(new DataParameter { ParameterName = "VWSEQ", DataType = DbType.String, Value = condition.VWSEQ });
|
|
}
|
|
//KIN号
|
|
if (string.IsNullOrEmpty(condition.KIN) == false)
|
|
{
|
|
whereBuilder.Append(" AND KIN LIKE '%'+" + "@KIN" + "+'%'");
|
|
parameters.Add(new DataParameter { ParameterName = "KIN", DataType = DbType.String, Value = condition.KIN });
|
|
}
|
|
//VIN号
|
|
if (string.IsNullOrEmpty(condition.VIN) == false)
|
|
{
|
|
whereBuilder.Append(" AND VIN LIKE '%'+" + "@VIN " + "+'%'");
|
|
parameters.Add(new DataParameter { ParameterName = "VIN", DataType = DbType.String, Value = condition.VIN });
|
|
}
|
|
//产品号
|
|
if (string.IsNullOrEmpty(condition.PRODNO) == false)
|
|
{
|
|
whereBuilder.Append(" AND PRODNO = @PRODNO");
|
|
parameters.Add(new DataParameter { ParameterName = "PRODNO", DataType = DbType.String, Value = condition.PRODNO });
|
|
}
|
|
//扫描状态
|
|
if (string.IsNullOrEmpty(condition.SCANSTATE) == false)
|
|
{
|
|
whereBuilder.Append(" AND SCANSTATE = @SCANSTATE");
|
|
parameters.Add(new DataParameter { ParameterName = "SCANSTATE", DataType = DbType.String, Value = condition.SCANSTATE });
|
|
}
|
|
//上线时间
|
|
if (condition.ONLINETIMESTART != DateTime.MinValue)
|
|
{
|
|
whereBuilder.Append(" AND CREATETIME >= @ONLINETIMESTART");
|
|
parameters.Add(new DataParameter { ParameterName = "ONLINETIMESTART", DataType = DbType.String, Value = condition.ONLINETIMESTART });
|
|
}
|
|
if (condition.ONLINETIMEEND != DateTime.MinValue)
|
|
{
|
|
whereBuilder.Append(" AND CREATETIME <= @ONLINETIMEEND");
|
|
parameters.Add(new DataParameter { ParameterName = "ONLINETIMEEND", DataType = DbType.String, Value = condition.ONLINETIMEEND });
|
|
}
|
|
|
|
if (whereBuilder.Length > 0)
|
|
{
|
|
sqlBuilder.Append(" WHERE " + whereBuilder.ToString().Substring(4));
|
|
}
|
|
return sqlBuilder.ToString();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 获取导出的数据
|
|
/// <summary>
|
|
/// 获取导出的数据
|
|
/// </summary>
|
|
/// <param name="user">查询条件</param>
|
|
/// <returns>数据</returns>
|
|
public DataTable GetExportData(FISOrder model)
|
|
{
|
|
DataTable dt = null;
|
|
string sql = null;
|
|
List<DataParameter> parameters = new List<DataParameter>();
|
|
try
|
|
{
|
|
//构成查询语句
|
|
sql = this.GetQuerySql(model, ref parameters);
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
dt = session.GetTable(sql, parameters.ToArray());
|
|
dt.TableName = "FISOrderExp";
|
|
}
|
|
return dt;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
{
|
|
ErrorInfo = ex,
|
|
Tag = ex.StackTrace,
|
|
Info = "FIS计划查询信息导出获取数据错误!"
|
|
});
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 插入信息
|
|
/// <summary>
|
|
/// 插入信息(单表)
|
|
/// </summary>
|
|
/// <param name="">信息</param>
|
|
/// <returns>插入行数</returns>
|
|
public int Insert(FISOrder model)
|
|
{
|
|
int count = 0;
|
|
try
|
|
{
|
|
|
|
if (BaseSession != null)
|
|
{
|
|
//插入基本信息
|
|
count = BaseSession.Insert<FISOrder>(model);
|
|
|
|
}
|
|
else
|
|
{
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
//插入基本信息
|
|
count = session.Insert<FISOrder>(model);
|
|
}
|
|
}
|
|
//using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
//{
|
|
// //插入基本信息
|
|
// count = session.Insert<FISOrder>(model);
|
|
//}
|
|
return count;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
{
|
|
ErrorInfo = ex,
|
|
Tag = ex.StackTrace,
|
|
Info = "FIS 计划信息数据层-插入信息"
|
|
});
|
|
throw;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 更新信息
|
|
|
|
public int Update(FISOrder model)
|
|
{
|
|
int count = 0;
|
|
try
|
|
{
|
|
|
|
if (BaseSession != null)
|
|
{
|
|
//插入基本信息
|
|
count = BaseSession.Update(model);
|
|
|
|
}
|
|
else
|
|
{
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
//插入基本信息
|
|
count = session.Update(model);
|
|
}
|
|
}
|
|
//using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
//{
|
|
// //插入基本信息
|
|
// count = session.Insert<FISOrder>(model);
|
|
//}
|
|
return count;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
{
|
|
ErrorInfo = ex,
|
|
Tag = ex.StackTrace,
|
|
Info = "FIS 计划信息数据层-插入信息"
|
|
});
|
|
throw;
|
|
}
|
|
}
|
|
#endregion
|
|
public FISOrder GetByPlan(string planno, string materialcode)
|
|
{
|
|
StringBuilder sql = new StringBuilder();
|
|
List<DataParameter> parameters = new List<DataParameter>();
|
|
//List<FISOrder> list = new List<FISOrder>();
|
|
try
|
|
{
|
|
sql.AppendLine("SELECT * FROM [T_PP_FISORDER] WHERE [ORDER_NO]=@planno AND [PRODNO]=@materialcode");
|
|
parameters.Add(new DataParameter("planno",planno));
|
|
parameters.Add(new DataParameter("materialcode",materialcode));
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
return session.Get<FISOrder>(sql.ToString(), parameters.ToArray());
|
|
}
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
{
|
|
ErrorInfo = ex,
|
|
Tag = ex.StackTrace,
|
|
Info = "FIS 计划信息数据层-获取列表"
|
|
});
|
|
throw;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|