using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QMFrameWork.Data;
using QMFrameWork.Log;
using System.Data;
using QMAPP.FJC.Entity.ProcessParameter;
using QMAPP.FJC.Entity.Produce;
using QMAPP.FJC.Entity.Operation;
namespace QMAPP.FJC.DAL.ProductPetrospect
{
///
/// 模块编号:M5-1
/// 作 用:产品档案数据层
/// 作 者:王丹丹
/// 编写日期:2015年06月08日
///
public class ProductArchivesDAL
{
#region 根据本体ID、工序类别获取加工记录
///
/// 根据本体ID、工序类别获取加工记录
///
/// 条件
/// *信息
public MainOperation GetMainOperation(Main condition)
{
List parameters = new List();
StringBuilder sqlBuilder = new StringBuilder();
StringBuilder whereBuilder = new StringBuilder();
MainOperation mainPoeration = new MainOperation();
try
{
//sqlBuilder.AppendLine(" SELECT MO.* FROM T_AW_MAINPRODUCT MP ");
//sqlBuilder.AppendLine(" LEFT JOIN T_AW_MAINOPERATION MO ON MO.PID=MP.MOID ");
sqlBuilder.AppendLine(" SELECT MO.* FROM T_AW_MAINPRODUCT MP ");
sqlBuilder.AppendLine(" LEFT JOIN T_AW_MAINOPERATION MO ON MO.PDID=MP.PDID ");
sqlBuilder.AppendLine(" WHERE MP.MID =@PID ");
//工序类别
if (string.IsNullOrEmpty(condition.PROCESSTYPE) == false)
{
sqlBuilder.Append(" AND MO.PROCESSTYPE =@PROCESSTYPE ");
}
sqlBuilder.AppendLine(" union ");
sqlBuilder.AppendLine(" SELECT distinct MO.* FROM T_AW_MAINPRODUCT MP ");
sqlBuilder.AppendLine(" LEFT JOIN T_AW_MAINOPERATION MO ON MO.PDID=MP.MID ");
sqlBuilder.AppendLine(" WHERE MP.MID =@PID ");
parameters.Add(new DataParameter { ParameterName = "PID", DataType = DbType.String, Value = condition.PID });
//工序类别
if (string.IsNullOrEmpty(condition.PROCESSTYPE) == false)
{
sqlBuilder.Append(" AND MO.PROCESSTYPE =@PROCESSTYPE ");
parameters.Add(new DataParameter { ParameterName = "PROCESSTYPE", DataType = DbType.String, Value = condition.PROCESSTYPE });
}
//if (whereBuilder.Length > 0)
//{
// sqlBuilder.Append(" WHERE " + whereBuilder.ToString().Substring(4));
//}
using (IDataSession session = AppDataFactory.CreateMainSession())
{
//获取信息
mainPoeration = session.Get(sqlBuilder.ToString(), parameters.ToArray());
}
return mainPoeration;
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "产品档案数据层-根据本体ID、工序类别获取加工记录"
});
throw;
}
}
///
/// 根据本体ID、工序类别获取加工记录
///
/// 条件
/// *信息
public List GetMainOperations(Main condition)
{
List parameters = new List();
StringBuilder sqlBuilder = new StringBuilder();
StringBuilder whereBuilder = new StringBuilder();
List mainPoerations = new List();
try
{
//sqlBuilder.AppendLine(" SELECT MO.* FROM T_AW_MAINPRODUCT MP ");
//sqlBuilder.AppendLine(" LEFT JOIN T_AW_MAINOPERATION MO ON MO.PID=MP.MOID ");
sqlBuilder.AppendLine(" SELECT MO.* FROM T_AW_MAINPRODUCT MP ");
sqlBuilder.AppendLine(" LEFT JOIN T_AW_MAINOPERATION MO ON MO.PDID=MP.PDID ");
sqlBuilder.AppendLine(" WHERE MP.MID =@PID ");
//工序类别
if (string.IsNullOrEmpty(condition.PROCESSTYPE) == false)
{
sqlBuilder.Append(" AND MO.PROCESSTYPE =@PROCESSTYPE ");
}
sqlBuilder.AppendLine(" union ");
sqlBuilder.AppendLine(" SELECT distinct MO.* FROM T_AW_MAINPRODUCT MP ");
sqlBuilder.AppendLine(" LEFT JOIN T_AW_MAINOPERATION MO ON MO.PDID=MP.MID ");
sqlBuilder.AppendLine(" WHERE MP.MID =@PID ");
parameters.Add(new DataParameter { ParameterName = "PID", DataType = DbType.String, Value = condition.PID });
//工序类别
if (string.IsNullOrEmpty(condition.PROCESSTYPE) == false)
{
sqlBuilder.Append(" AND MO.PROCESSTYPE =@PROCESSTYPE ");
parameters.Add(new DataParameter { ParameterName = "PROCESSTYPE", DataType = DbType.String, Value = condition.PROCESSTYPE });
}
//if (whereBuilder.Length > 0)
//{
// sqlBuilder.Append(" WHERE " + whereBuilder.ToString().Substring(4));
//}
using (IDataSession session = AppDataFactory.CreateMainSession())
{
//获取信息
mainPoerations = session.GetList(sqlBuilder.ToString(), parameters.ToArray()).ToList();
}
return mainPoerations;
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "产品档案数据层-根据本体ID、工序类别获取加工记录"
});
throw;
}
}
#endregion
#region 获取加工参数信息
///
/// 获取加工参数信息
///
/// 条件
/// *信息
public List GetTableParamter(string strProductCode)
{
List parameters = new List();
List dtList = new List();
DataTable dt = new DataTable();
try
{
var sqls =string.Format(
"select distinct p.TABLENAME from T_AW_MAINOPERATION m,T_BD_PARAMETERCONFIG p where m.MACHINECODDE=p.MACHINECODDE and m.pdid in (select PRODUCT_PID from T_QT_PRODUCT_STRUCTURE where PROCESS_CODE='{0}' union select PART_PID from T_QT_PRODUCT_STRUCTURE where PROCESS_CODE='{0}')", strProductCode);
using (IDataSession session = AppDataFactory.CreateMainSession())
{
var tables = session.GetTable(sqls, parameters.ToArray());
if (tables != null && tables.Rows.Count>0)
{
for (int i = 0; i < tables.Rows.Count; i++)
{
var tableName = "[" + tables.Rows[i].ItemArray[0] + "]";
var sql = "SELECT * FROM " + tableName + " WHERE PRODUCTCODE = '" + strProductCode + "'";
dt = session.GetTable(sql, parameters.ToArray());
dtList.Add(dt);
}
}
}
return dtList;
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "产品档案数据层-获取加工参数信息"
});
throw;
}
}
#endregion
#region 获取搪塑加工参数信息
///
/// 获取搪塑加工参数信息
///
/// 条件
/// *信息
public DataTable GetSlushParamter(SlushParamter condition)
{
List parameters = new List();
StringBuilder sqlBuilder = new StringBuilder();
StringBuilder whereBuilder = new StringBuilder();
DataTable dt = new DataTable();
try
{
sqlBuilder.AppendLine(" SELECT * ");
sqlBuilder.AppendLine(" FROM T_AW_SLUSHPARAMTER ");
//加工记录主键
if (string.IsNullOrEmpty(condition.IOID) == false)
{
whereBuilder.Append(" AND MOID =@MOID ");
parameters.Add(new DataParameter { ParameterName = "MOID", DataType = DbType.String, Value = condition.IOID });
}
if (whereBuilder.Length > 0)
{
sqlBuilder.Append(" WHERE " + whereBuilder.ToString().Substring(4));
}
using (IDataSession session = AppDataFactory.CreateMainSession())
{
dt.TableName = "搪塑";
//获取信息
dt = session.GetTable(sqlBuilder.ToString(), parameters.ToArray());
}
return dt;
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "产品档案数据层-获取搪塑加工参数信息"
});
throw;
}
}
#endregion
#region 获取注塑加工参数信息
///
/// 获取注塑加工参数信息
///
/// 条件
/// *信息
public DataTable GetInJectionParameter(InJectionParameter condition)
{
List parameters = new List();
StringBuilder sqlBuilder = new StringBuilder();
StringBuilder whereBuilder = new StringBuilder();
DataTable dt = new DataTable();
try
{
sqlBuilder.AppendLine(" SELECT * ");
sqlBuilder.AppendLine(" FROM T_AW_INJECTIONPARAMETER ");
//加工记录主键
if (string.IsNullOrEmpty(condition.MOID) == false)
{
whereBuilder.Append(" AND MOID =@MOID ");
parameters.Add(new DataParameter { ParameterName = "MOID", DataType = DbType.String, Value = condition.MOID });
}
//零件类别
if (string.IsNullOrEmpty(condition.PRODUCTTYPE) == false)
{
whereBuilder.Append(" AND PRODUCTTYPE =@PRODUCTTYPE ");
parameters.Add(new DataParameter { ParameterName = "PRODUCTTYPE", DataType = DbType.String, Value = condition.PRODUCTTYPE });
}
if (whereBuilder.Length > 0)
{
sqlBuilder.Append(" WHERE " + whereBuilder.ToString().Substring(4));
}
using (IDataSession session = AppDataFactory.CreateMainSession())
{
//获取信息
dt = session.GetTable(sqlBuilder.ToString(), parameters.ToArray());
}
return dt;
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "产品档案数据层-获取注塑加工参数信息"
});
throw;
}
}
#endregion
#region 获取冷刀弱化参数信息
///
/// 获取冷刀弱化参数信息
///
/// 条件
/// *信息
public DataTable GetBurnParameter(BurnParameter condition)
{
List parameters = new List();
StringBuilder sqlBuilder = new StringBuilder();
StringBuilder whereBuilder = new StringBuilder();
DataTable dt = new DataTable();
try
{
sqlBuilder.AppendLine(" SELECT * ");
sqlBuilder.AppendLine(" FROM T_AW_BURNPARAMETER ");
//加工记录主键
if (string.IsNullOrEmpty(condition.MOID) == false)
{
whereBuilder.Append(" AND MOID =@MOID ");
parameters.Add(new DataParameter { ParameterName = "MOID", DataType = DbType.String, Value = condition.MOID });
}
if (whereBuilder.Length > 0)
{
sqlBuilder.Append(" WHERE " + whereBuilder.ToString().Substring(4));
}
using (IDataSession session = AppDataFactory.CreateMainSession())
{
//获取信息
dt = session.GetTable(sqlBuilder.ToString(), parameters.ToArray());
}
return dt;
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "产品档案数据层-获取冷刀弱化参数信息"
});
throw;
}
}
#endregion
#region 获取火焰加工参数信息
///
/// 获取火焰加工参数信息
///
/// 条件
/// *信息
public DataTable GetFlamepParameter(FlamepParameter condition)
{
List parameters = new List();
StringBuilder sqlBuilder = new StringBuilder();
StringBuilder whereBuilder = new StringBuilder();
DataTable dt = new DataTable();
try
{
sqlBuilder.AppendLine(" SELECT * ");
sqlBuilder.AppendLine(" FROM T_AW_FLAMEPPARAMETER ");
//加工记录主键
if (string.IsNullOrEmpty(condition.MOID) == false)
{
whereBuilder.Append(" AND MOID =@MOID ");
parameters.Add(new DataParameter { ParameterName = "MOID", DataType = DbType.String, Value = condition.MOID });
}
if (whereBuilder.Length > 0)
{
sqlBuilder.Append(" WHERE " + whereBuilder.ToString().Substring(4));
}
using (IDataSession session = AppDataFactory.CreateMainSession())
{
//获取信息
dt = session.GetTable(sqlBuilder.ToString(), parameters.ToArray());
}
return dt;
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "产品档案数据层-获取火焰加工参数信息"
});
throw;
}
}
#endregion
#region 获取预热参数信息
///
/// 获取预热参数信息
///
/// 条件
/// *信息
public DataTable GetPreheatParameter(PreheatParameter condition)
{
List parameters = new List();
StringBuilder sqlBuilder = new StringBuilder();
StringBuilder whereBuilder = new StringBuilder();
DataTable dt = new DataTable();
try
{
sqlBuilder.AppendLine(" SELECT * ");
sqlBuilder.AppendLine(" FROM T_AW_PREHEATPARAMETER ");
//加工记录主键
if (string.IsNullOrEmpty(condition.MOID) == false)
{
whereBuilder.Append(" AND MOID =@MOID ");
parameters.Add(new DataParameter { ParameterName = "MOID", DataType = DbType.String, Value = condition.MOID });
}
if (whereBuilder.Length > 0)
{
sqlBuilder.Append(" WHERE " + whereBuilder.ToString().Substring(4));
}
using (IDataSession session = AppDataFactory.CreateMainSession())
{
//获取信息
dt = session.GetTable(sqlBuilder.ToString(), parameters.ToArray());
}
return dt;
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "产品档案数据层-获取预热参数信息"
});
throw;
}
}
#endregion
#region 获取浇注参数信息
///
/// 获取浇注参数信息
///
/// 条件
/// *信息
public DataTable GetCastingParameter(CastingParameter condition)
{
List parameters = new List();
StringBuilder sqlBuilder = new StringBuilder();
StringBuilder whereBuilder = new StringBuilder();
DataTable dt = new DataTable();
try
{
sqlBuilder.AppendLine(" SELECT * ");
sqlBuilder.AppendLine(" FROM T_AW_CASTINGPARAMETER ");
//加工记录主键
if (string.IsNullOrEmpty(condition.MOID) == false)
{
whereBuilder.Append(" AND MOID =@MOID ");
parameters.Add(new DataParameter { ParameterName = "MOID", DataType = DbType.String, Value = condition.MOID });
}
if (whereBuilder.Length > 0)
{
sqlBuilder.Append(" WHERE " + whereBuilder.ToString().Substring(4));
}
using (IDataSession session = AppDataFactory.CreateMainSession())
{
//获取信息
dt = session.GetTable(sqlBuilder.ToString(), parameters.ToArray());
}
return dt;
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "产品档案数据层-获取浇注参数信息"
});
throw;
}
}
#endregion
#region 获取红外扫描参数信息
///
/// 获取红外扫描参数信息
///
/// 条件
/// *信息
public DataTable GetHostcanPatameter(HostcanPatameter condition)
{
List parameters = new List();
StringBuilder sqlBuilder = new StringBuilder();
StringBuilder whereBuilder = new StringBuilder();
DataTable dt = new DataTable();
try
{
sqlBuilder.AppendLine(" SELECT * ");
sqlBuilder.AppendLine(" FROM T_AW_HOTSCANPARAMETER ");
//加工记录主键
if (string.IsNullOrEmpty(condition.MOID) == false)
{
whereBuilder.Append(" AND MOID =@MOID ");
parameters.Add(new DataParameter { ParameterName = "MOID", DataType = DbType.String, Value = condition.MOID });
}
if (whereBuilder.Length > 0)
{
sqlBuilder.Append(" WHERE " + whereBuilder.ToString().Substring(4));
}
using (IDataSession session = AppDataFactory.CreateMainSession())
{
//获取信息
dt = session.GetTable(sqlBuilder.ToString(), parameters.ToArray());
}
return dt;
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "产品档案数据层-获取红外扫描参数信息"
});
throw;
}
}
#endregion
#region 获取冲切参数信息
///
/// 获取冲切参数信息
///
/// 条件
/// *信息
public DataTable GetPunchParameter(PunchParameter condition)
{
List parameters = new List();
StringBuilder sqlBuilder = new StringBuilder();
StringBuilder whereBuilder = new StringBuilder();
DataTable dt = new DataTable();
try
{
sqlBuilder.AppendLine(" SELECT * ");
sqlBuilder.AppendLine(" FROM T_AW_PUNCHPARAMETER ");
//加工记录主键
if (string.IsNullOrEmpty(condition.MOID) == false)
{
whereBuilder.Append(" AND MOID =@MOID ");
parameters.Add(new DataParameter { ParameterName = "MOID", DataType = DbType.String, Value = condition.MOID });
}
if (whereBuilder.Length > 0)
{
sqlBuilder.Append(" WHERE " + whereBuilder.ToString().Substring(4));
}
using (IDataSession session = AppDataFactory.CreateMainSession())
{
//获取信息
dt = session.GetTable(sqlBuilder.ToString(), parameters.ToArray());
}
return dt;
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "产品档案数据层-获取冲切参数信息"
});
throw;
}
}
#endregion
#region 获取铣削参数信息
///
/// 获取铣削参数信息
///
/// 条件
/// *信息
public DataTable GetMilingParameter(MilingParameter condition)
{
List parameters = new List();
StringBuilder sqlBuilder = new StringBuilder();
StringBuilder whereBuilder = new StringBuilder();
DataTable dt = new DataTable();
try
{
sqlBuilder.AppendLine(" SELECT * ");
sqlBuilder.AppendLine(" FROM T_AW_MILINGPARAMETER ");
//加工记录主键
if (string.IsNullOrEmpty(condition.MOID) == false)
{
whereBuilder.Append(" AND MOID =@MOID ");
parameters.Add(new DataParameter { ParameterName = "MOID", DataType = DbType.String, Value = condition.MOID });
}
if (whereBuilder.Length > 0)
{
sqlBuilder.Append(" WHERE " + whereBuilder.ToString().Substring(4));
}
using (IDataSession session = AppDataFactory.CreateMainSession())
{
//获取信息
dt = session.GetTable(sqlBuilder.ToString(), parameters.ToArray());
}
return dt;
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "产品档案数据层-获取铣削参数信息"
});
throw;
}
}
#endregion
#region 获取铆接参数信息
///
/// 获取铆接参数信息
///
/// 条件
/// *信息
public DataTable GetRivetingPatameter(RivetingPatameter condition)
{
List parameters = new List();
StringBuilder sqlBuilder = new StringBuilder();
StringBuilder whereBuilder = new StringBuilder();
DataTable dt = new DataTable();
try
{
sqlBuilder.AppendLine(" SELECT * ");
sqlBuilder.AppendLine(" FROM T_AW_RIVETINGPARAMETER ");
//加工记录主键
if (string.IsNullOrEmpty(condition.MOID) == false)
{
whereBuilder.Append(" AND MOID =@MOID ");
parameters.Add(new DataParameter { ParameterName = "MOID", DataType = DbType.String, Value = condition.MOID });
}
if (whereBuilder.Length > 0)
{
sqlBuilder.Append(" WHERE " + whereBuilder.ToString().Substring(4));
}
using (IDataSession session = AppDataFactory.CreateMainSession())
{
//获取信息
dt = session.GetTable(sqlBuilder.ToString(), parameters.ToArray());
}
return dt;
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "产品档案数据层-获取铆接参数信息"
});
throw;
}
}
#endregion
#region 获取超声波焊接参数信息
///
/// 获取超声波焊接参数信息
///
/// 条件
/// *信息
public DataTable GetUltrasParameter(UltrasParameter condition)
{
List parameters = new List();
StringBuilder sqlBuilder = new StringBuilder();
StringBuilder whereBuilder = new StringBuilder();
DataTable dt = new DataTable();
try
{
sqlBuilder.AppendLine(" SELECT * ");
sqlBuilder.AppendLine(" FROM T_AW_ULTRASPARAMETER ");
//加工记录主键
if (string.IsNullOrEmpty(condition.MOID) == false)
{
whereBuilder.Append(" AND MOID =@MOID ");
parameters.Add(new DataParameter { ParameterName = "MOID", DataType = DbType.String, Value = condition.MOID });
}
if (whereBuilder.Length > 0)
{
sqlBuilder.Append(" WHERE " + whereBuilder.ToString().Substring(4));
}
using (IDataSession session = AppDataFactory.CreateMainSession())
{
//获取信息
dt = session.GetTable(sqlBuilder.ToString(), parameters.ToArray());
}
return dt;
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "产品档案数据层-获取超声波焊接参数信息"
});
throw;
}
}
#endregion
#region 获取红外焊接参数信息
///
/// 获取红外焊接参数信息
///
/// 条件
/// *信息
public DataTable GetHotweldParameter(HotweldParameter condition)
{
List parameters = new List();
StringBuilder sqlBuilder = new StringBuilder();
StringBuilder whereBuilder = new StringBuilder();
DataTable dt = new DataTable();
try
{
sqlBuilder.AppendLine(" SELECT * ");
sqlBuilder.AppendLine(" FROM T_AW_HOTWELDPARAMETER ");
//加工记录主键
if (string.IsNullOrEmpty(condition.MOID) == false)
{
whereBuilder.Append(" AND MOID =@MOID ");
parameters.Add(new DataParameter { ParameterName = "MOID", DataType = DbType.String, Value = condition.MOID });
}
if (whereBuilder.Length > 0)
{
sqlBuilder.Append(" WHERE " + whereBuilder.ToString().Substring(4));
}
using (IDataSession session = AppDataFactory.CreateMainSession())
{
//获取信息
dt = session.GetTable(sqlBuilder.ToString(), parameters.ToArray());
}
return dt;
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "产品档案数据层-获取红外焊接参数信息"
});
throw;
}
}
#endregion
#region 获取总成装配参数信息
///
/// 获取总成装配参数信息
///
/// 条件
/// *信息
public DataTable GetAssembleParameter(AssembleParameter condition)
{
List parameters = new List();
StringBuilder sqlBuilder = new StringBuilder();
StringBuilder whereBuilder = new StringBuilder();
DataTable dt = new DataTable();
try
{
sqlBuilder.AppendLine(" SELECT * ");
sqlBuilder.AppendLine(" FROM T_AW_ASSEMBLEPARAMETER ");
//加工记录主键
if (string.IsNullOrEmpty(condition.MOID) == false)
{
whereBuilder.Append(" AND MOID =@MOID ");
parameters.Add(new DataParameter { ParameterName = "MOID", DataType = DbType.String, Value = condition.MOID });
}
if (whereBuilder.Length > 0)
{
sqlBuilder.Append(" WHERE " + whereBuilder.ToString().Substring(4));
}
using (IDataSession session = AppDataFactory.CreateMainSession())
{
//获取信息
dt = session.GetTable(sqlBuilder.ToString(), parameters.ToArray());
}
return dt;
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "产品档案数据层-获取总成装配参数信息"
});
throw;
}
}
#endregion
}
}