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.
153 lines
5.7 KiB
153 lines
5.7 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using QMAPP.FJC.Entity.WIPManage;
|
|
using QMFrameWork.Data;
|
|
using System.Data;
|
|
using QMFrameWork.Log;
|
|
|
|
namespace QMAPP.FJC.DAL.WIPManage
|
|
{
|
|
/// <summary>
|
|
/// 模块编号:M7-4
|
|
/// 作 用:低储报警信息数据层
|
|
/// 作 者:王丹丹
|
|
/// 编写日期:2015年06月19日
|
|
///</summary>
|
|
public class StorageAlarmDAL
|
|
{
|
|
#region 获取列表
|
|
/// <summary>
|
|
/// 获取列表
|
|
/// </summary>
|
|
/// <param name="condition">条件</param>
|
|
/// <param name="page">数据页</param>
|
|
/// <returns>数据页</returns>
|
|
public DataPage GetList(StorageAlarm condition, DataPage page)
|
|
{
|
|
string sql = null;
|
|
List<DataParameter> parameters = new List<DataParameter>();
|
|
try
|
|
{
|
|
sql = this.GetStorageAlarmSql(condition, ref parameters);
|
|
//分页关键字段及排序
|
|
page.KeyName = "PID";
|
|
page.SortExpression = "UPDATEDATE DESC";
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
page = session.GetDataPage<StorageAlarm>(sql, parameters.ToArray(), page);
|
|
}
|
|
return page;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
{
|
|
ErrorInfo = ex,
|
|
Tag = ex.StackTrace,
|
|
Info = "低储报警信息数据层-获取列表!"
|
|
});
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 获取查询语句
|
|
/// <summary>
|
|
/// 获取查询语句
|
|
/// </summary>
|
|
/// <param name="user">查询条件</param>
|
|
/// <param name="parameters">参数</param>
|
|
/// <returns>查询语句</returns>
|
|
private string GetStorageAlarmSql(StorageAlarm condition, ref List<DataParameter> parameters)
|
|
{
|
|
StringBuilder sqlBuilder = new StringBuilder();
|
|
StringBuilder whereBuilder = new StringBuilder();
|
|
try
|
|
{
|
|
//构成查询语句
|
|
sqlBuilder.AppendLine(" SELECT S.PID ");
|
|
sqlBuilder.AppendLine(" ,S.PROCESSTYPE ");
|
|
sqlBuilder.AppendLine(" ,S.MINVALUE ");
|
|
sqlBuilder.AppendLine(" ,S.PRODUCEMINVALUE ");
|
|
sqlBuilder.AppendLine(" ,S.CURRENTSTORAGE ");
|
|
sqlBuilder.AppendLine(" ,S.ALARMSTATUS ");
|
|
sqlBuilder.AppendLine(" ,S.PRODUCESHIFTNAME ");
|
|
sqlBuilder.AppendLine(" ,S.PRODUCESHIFTTCODE ");
|
|
sqlBuilder.AppendLine(" ,S.PRODUCELINE ");
|
|
sqlBuilder.AppendLine(" ,S.CREATEUSER ");
|
|
sqlBuilder.AppendLine(" ,S.CREATEDATE ");
|
|
sqlBuilder.AppendLine(" ,S.UPDATEUSER ");
|
|
sqlBuilder.AppendLine(" ,S.UPDATEDATE ");
|
|
sqlBuilder.AppendLine(" FROM T_AW_STORAGEALARM S ");
|
|
|
|
//查询条件
|
|
//工序类别
|
|
if (string.IsNullOrEmpty(condition.PROCESSTYPE) == false)
|
|
{
|
|
whereBuilder.Append(" AND S.PROCESSTYPE =@PROCESSTYPE ");
|
|
parameters.Add(new DataParameter { ParameterName = "PROCESSTYPE", DataType = DbType.String, Value = condition.PROCESSTYPE });
|
|
}
|
|
//报警时间
|
|
if (string.IsNullOrEmpty(condition.CREATEDATESTART) == false)
|
|
{
|
|
whereBuilder.Append(" AND S.CREATEDATE >=@CREATEDATESTART");
|
|
parameters.Add(new DataParameter { ParameterName = "CREATEDATESTART", DataType = DbType.DateTime, Value = condition.CREATEDATESTART });
|
|
}
|
|
if (string.IsNullOrEmpty(condition.CREATEDATEEND) == false)
|
|
{
|
|
whereBuilder.Append(" AND S.CREATEDATE <=@CREATEDATEEND");
|
|
parameters.Add(new DataParameter { ParameterName = "CREATEDATEEND", DataType = DbType.String, Value = condition.CREATEDATEEND });
|
|
}
|
|
|
|
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(StorageAlarm model)
|
|
{
|
|
DataTable dt = null;
|
|
string sql = null;
|
|
List<DataParameter> parameters = new List<DataParameter>();
|
|
try
|
|
{
|
|
//构成查询语句
|
|
sql = this.GetStorageAlarmSql(model, ref parameters);
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
dt = session.GetTable(sql, parameters.ToArray());
|
|
dt.TableName = "T_AW_STORAGEALARM";
|
|
}
|
|
return dt;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
{
|
|
ErrorInfo = ex,
|
|
Tag = ex.StackTrace,
|
|
Info = "低储报警信息数据层-获取导出的数据!"
|
|
});
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
}
|
|
}
|
|
|