|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Text;
|
|
|
|
using QMFrameWork.Data;
|
|
|
|
using QMAPP.FJC.Entity.Basic;
|
|
|
|
using System.Data;
|
|
|
|
using QMFrameWork.Log;
|
|
|
|
|
|
|
|
namespace QMAPP.FJC.DAL.Basic
|
|
|
|
{
|
|
|
|
///</summary>
|
|
|
|
/// 模块编号:M2-8
|
|
|
|
/// 作 用:加工参数标准值设定数据层
|
|
|
|
/// 作 者:王丹丹
|
|
|
|
/// 编写日期:2015年06月03日
|
|
|
|
///</summary>
|
|
|
|
public class ProcessParameterDAL
|
|
|
|
{
|
|
|
|
#region 获得指定列的加工参数数据
|
|
|
|
/// <summary>
|
|
|
|
/// 获得指定列的加工参数数据
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="condition">条件</param>
|
|
|
|
/// <returns>返回加工参数表</returns>
|
|
|
|
public DataTable GetData(QMAPP.FJC.Entity.Basic.ProcessParameter condition)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
StringBuilder sbSql = new StringBuilder();
|
|
|
|
sbSql.AppendFormat(" SELECT TOP {0} {1} FROM {2} WHERE 1=1 ",
|
|
|
|
condition.MonitorCount,
|
|
|
|
condition.SelectColumn,
|
|
|
|
condition.PARATABLENAME);
|
|
|
|
if(condition.MVStart != 0)
|
|
|
|
{
|
|
|
|
sbSql.AppendFormat(" AND {0} >={1}",condition.SelectColumn,condition.MVStart);
|
|
|
|
}
|
|
|
|
if(condition.MVEnd != 0)
|
|
|
|
{
|
|
|
|
sbSql.AppendFormat(" AND {0} <={1}",condition.SelectColumn,condition.MVEnd);
|
|
|
|
}
|
|
|
|
sbSql.Append(" ORDER BY CREATEDATE DESC ");
|
|
|
|
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
|
|
{
|
|
|
|
return session.GetTable(sbSql.ToString(), new DataParameter[] { });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
|
|
{
|
|
|
|
ErrorInfo = ex,
|
|
|
|
Tag = ex.StackTrace,
|
|
|
|
Info = "加工参数数据层-获取加工参数标准值"
|
|
|
|
});
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 获取信息
|
|
|
|
/// <summary>
|
|
|
|
/// 获取信息
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="">条件</param>
|
|
|
|
/// <returns>*信息</returns>
|
|
|
|
public QMAPP.FJC.Entity.Basic.ProcessParameter Get(QMAPP.FJC.Entity.Basic.ProcessParameter model)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
List<DataParameter> listDataPara= new List<DataParameter>();
|
|
|
|
string sql = GetQuerySql(model, ref listDataPara);
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
|
|
{
|
|
|
|
//获取信息
|
|
|
|
model = session.Get<QMAPP.FJC.Entity.Basic.ProcessParameter>(sql, listDataPara.ToArray());
|
|
|
|
}
|
|
|
|
return model;
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
|
|
{
|
|
|
|
ErrorInfo = ex,
|
|
|
|
Tag = ex.StackTrace,
|
|
|
|
Info = "加工参数标准值设定数据层-获取加工参数标准值"
|
|
|
|
});
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 获取列表
|
|
|
|
/// <summary>
|
|
|
|
/// 获取列表
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="condition">条件</param>
|
|
|
|
/// <param name="page">数据页</param>
|
|
|
|
/// <returns>数据页</returns>
|
|
|
|
public DataPage GetList(QMAPP.FJC.Entity.Basic.ProcessParameter condition, DataPage page)
|
|
|
|
{
|
|
|
|
string sql = null;
|
|
|
|
List<DataParameter> parameters = new List<DataParameter>();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
sql = this.GetQuerySql(condition, ref parameters);
|
|
|
|
|
|
|
|
#region 排序
|
|
|
|
//分页关键字段及排序
|
|
|
|
page.KeyName = "PID";
|
|
|
|
if (string.IsNullOrEmpty(page.SortExpression))
|
|
|
|
{
|
|
|
|
page.SortExpression = "UPDATEDATE DESC";
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
//按照标题排序
|
|
|
|
if (page.SortExpression.IndexOf("PROCESSTYPETXT") > -1)
|
|
|
|
{
|
|
|
|
page.SortExpression = page.SortExpression.Replace("PROCESSTYPETXT", "PROCESSTYPE");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
|
|
{
|
|
|
|
page = session.GetDataPage<QMAPP.FJC.Entity.Basic.ProcessParameter>(sql, parameters.ToArray(), page);
|
|
|
|
}
|
|
|
|
return page;
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
|
|
{
|
|
|
|
ErrorInfo = ex,
|
|
|
|
Tag = ex.StackTrace,
|
|
|
|
Info = "加工参数标准值设定数据层-获取列表"
|
|
|
|
});
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 获取列表
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="condition">条件</param>
|
|
|
|
/// <returns>数据页</returns>
|
|
|
|
public List<QMAPP.FJC.Entity.Basic.ProcessParameter> GetList(QMAPP.FJC.Entity.Basic.ProcessParameter condition)
|
|
|
|
{
|
|
|
|
List<QMAPP.FJC.Entity.Basic.ProcessParameter> list = new List<QMAPP.FJC.Entity.Basic.ProcessParameter>();
|
|
|
|
string sql = null;
|
|
|
|
List<DataParameter> parameters = new List<DataParameter>();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
sql = this.GetQuerySql(condition, ref parameters);
|
|
|
|
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
|
|
{
|
|
|
|
list = session.GetList<QMAPP.FJC.Entity.Basic.ProcessParameter>(sql, parameters.ToArray()).ToList();
|
|
|
|
}
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
throw ex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 获取查询语句
|
|
|
|
/// <summary>
|
|
|
|
/// 获取查询语句
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="user">查询条件</param>
|
|
|
|
/// <param name="parameters">参数</param>
|
|
|
|
/// <returns>查询语句</returns>
|
|
|
|
private string GetQuerySql(QMAPP.FJC.Entity.Basic.ProcessParameter condition, ref List<DataParameter> parameters)
|
|
|
|
{
|
|
|
|
StringBuilder sqlBuilder = new StringBuilder();
|
|
|
|
StringBuilder whereBuilder = new StringBuilder();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
//构成查询语句
|
|
|
|
sqlBuilder.AppendLine(" SELECT PP.PID ");
|
|
|
|
sqlBuilder.AppendLine(" ,PP.PARADESCRIBE ");
|
|
|
|
sqlBuilder.AppendLine(" ,PP.PARANAME ");
|
|
|
|
sqlBuilder.AppendLine(" ,PP.PARATABLENAME ");
|
|
|
|
sqlBuilder.AppendLine(" ,PP.MACHINEID ");
|
|
|
|
sqlBuilder.AppendLine(" ,PP.MACHINECODDE ");
|
|
|
|
sqlBuilder.AppendLine(" ,PP.WORKCELL_CODE ");
|
|
|
|
sqlBuilder.AppendLine(" ,PP.PROCESSTYPE ");
|
|
|
|
sqlBuilder.AppendLine(" ,PP.PRODUCELINE ");
|
|
|
|
sqlBuilder.AppendLine(" ,PP.MAXVALUE ");
|
|
|
|
sqlBuilder.AppendLine(" ,PP.MINVALUE ");
|
|
|
|
sqlBuilder.AppendLine(" ,PP.MEMO ");
|
|
|
|
sqlBuilder.AppendLine(" ,PP.SHOWINDEX ");
|
|
|
|
sqlBuilder.AppendLine(" ,PP.CREATEUSER ");
|
|
|
|
sqlBuilder.AppendLine(" ,PP.CREATEDATE ");
|
|
|
|
sqlBuilder.AppendLine(" ,PP.UPDATEUSER ");
|
|
|
|
sqlBuilder.AppendLine(" ,PP.UPDATEDATE ");
|
|
|
|
sqlBuilder.AppendLine(" ,PP.ALIGNVALUE ");
|
|
|
|
sqlBuilder.AppendLine(" ,PP.WIDTH ");
|
|
|
|
sqlBuilder.AppendLine(" ,C.USERNAME AS CREATEUSERNAME ");
|
|
|
|
sqlBuilder.AppendLine(" ,U.USERNAME AS UPDATEUSERNAME ");
|
|
|
|
sqlBuilder.AppendLine(" FROM T_BD_ProcessParameter PP ");
|
|
|
|
sqlBuilder.AppendLine(" LEFT JOIN T_QM_USER C ON C.USERID=PP.CREATEUSER ");
|
|
|
|
sqlBuilder.AppendLine(" LEFT JOIN T_QM_USER U ON U.USERID=PP.UPDATEUSER ");
|
|
|
|
|
|
|
|
|
|
|
|
//查询条件
|
|
|
|
//主键
|
|
|
|
if (string.IsNullOrEmpty(condition.PID) == false)
|
|
|
|
{
|
|
|
|
whereBuilder.Append(" AND PP.PID = @PID ");
|
|
|
|
parameters.Add(new DataParameter { ParameterName = "PID", DataType = DbType.String, Value = condition.PID });
|
|
|
|
}
|
|
|
|
//设备编号
|
|
|
|
if (string.IsNullOrEmpty(condition.MACHINEID) == false)
|
|
|
|
{
|
|
|
|
whereBuilder.Append(" AND PP.MACHINEID = @MACHINEID ");
|
|
|
|
parameters.Add(new DataParameter { ParameterName = "MACHINEID", DataType = DbType.String, Value = condition.MACHINEID });
|
|
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(condition.MACHINECODDE) == false)
|
|
|
|
{
|
|
|
|
whereBuilder.Append(" AND PP.MACHINECODDE = @MACHINECODDE ");
|
|
|
|
parameters.Add(new DataParameter { ParameterName = "MACHINECODDE", DataType = DbType.String, Value = condition.MACHINECODDE });
|
|
|
|
}
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(condition.WORKCELL_CODE) == false)
|
|
|
|
{
|
|
|
|
whereBuilder.Append(" AND PP.WORKCELL_CODE = @WORKCELL_CODE ");
|
|
|
|
parameters.Add(new DataParameter { ParameterName = "WORKCELL_CODE", DataType = DbType.String, Value = condition.WORKCELL_CODE });
|
|
|
|
}
|
|
|
|
//工序类别
|
|
|
|
if (string.IsNullOrEmpty(condition.PROCESSTYPESEARCH) == false || string.IsNullOrEmpty(condition.PROCESSTYPE) == false)
|
|
|
|
{
|
|
|
|
whereBuilder.Append(" AND PP.PROCESSTYPE = @PROCESSTYPE ");
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(condition.PROCESSTYPESEARCH) == false)
|
|
|
|
{
|
|
|
|
parameters.Add(new DataParameter { ParameterName = "PROCESSTYPE", DataType = DbType.String, Value = condition.PROCESSTYPESEARCH });
|
|
|
|
}
|
|
|
|
|
|
|
|
if (string.IsNullOrEmpty(condition.PROCESSTYPE) == false)
|
|
|
|
{
|
|
|
|
parameters.Add(new DataParameter { ParameterName = "PROCESSTYPE", DataType = DbType.String, Value = condition.PROCESSTYPE });
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//参数名称
|
|
|
|
if (string.IsNullOrEmpty(condition.PARANAME) == false)
|
|
|
|
{
|
|
|
|
whereBuilder.Append(" AND PP.PARANAME LIKE '%'+" + "@PARANAME" + "+'%'");
|
|
|
|
parameters.Add(new DataParameter { ParameterName = "PARANAME", DataType = DbType.String, Value = condition.PARANAME });
|
|
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(condition.PARADESCRIBE) == false)
|
|
|
|
{
|
|
|
|
whereBuilder.Append(" AND PP.PARADESCRIBE LIKE '%'+" + "@PARADESCRIBE" + "+'%'");
|
|
|
|
parameters.Add(new DataParameter { ParameterName = "PARADESCRIBE", DataType = DbType.String, Value = condition.PARADESCRIBE });
|
|
|
|
}
|
|
|
|
//工序类别(注塑,用于设备加工记录查询)
|
|
|
|
if (string.IsNullOrEmpty(condition.PROCESSTYPES) == false)
|
|
|
|
{
|
|
|
|
whereBuilder.Append(" AND PP.PROCESSTYPE in (" + condition.PROCESSTYPES + ")");
|
|
|
|
//parameters.Add(new DataParameter { ParameterName = "PROCESSTYPES", DataType = DbType.String, Value = condition.PROCESSTYPES });
|
|
|
|
}
|
|
|
|
if (whereBuilder.Length > 0)
|
|
|
|
{
|
|
|
|
sqlBuilder.Append(" WHERE " + whereBuilder.ToString().Substring(4));
|
|
|
|
}
|
|
|
|
sqlBuilder.Append(" ORDER BY PP.SHOWINDEX,PP.PARANAME");
|
|
|
|
return sqlBuilder.ToString();
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
throw ex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 判断信息是否重复
|
|
|
|
/// <summary>
|
|
|
|
/// 判断信息是否重复
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="info"></param>
|
|
|
|
/// <returns>true:已存在;fasel:不存在。</returns>
|
|
|
|
public bool ExistsProcessParameter(QMAPP.FJC.Entity.Basic.ProcessParameter model)
|
|
|
|
{
|
|
|
|
string PID = "";
|
|
|
|
int count = 0;
|
|
|
|
string sql = null;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if (string.IsNullOrEmpty(model.PID) == false)
|
|
|
|
{
|
|
|
|
PID = model.PID;
|
|
|
|
}
|
|
|
|
|
|
|
|
sql = "SELECT COUNT(*) FROM T_BD_ProcessParameter WHERE PID <> @PID AND MACHINECODDE=@MACHINECODDE AND PARANAME=@PARANAME ";
|
|
|
|
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
|
|
{
|
|
|
|
count = Convert.ToInt32(session.ExecuteSqlScalar(sql, new DataParameter("PID", PID),
|
|
|
|
new DataParameter { ParameterName = "MACHINECODDE", Value = model.MACHINECODDE },
|
|
|
|
new DataParameter { ParameterName = "PARANAME", Value = model.PARANAME }));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (count > 0)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
|
|
{
|
|
|
|
ErrorInfo = ex,
|
|
|
|
Tag = ex.StackTrace,
|
|
|
|
Info = "加工参数标准值设定数据层-判断信息是否重复"
|
|
|
|
});
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 校验数据库中表是否存在
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="info"></param>
|
|
|
|
/// <returns>true:已存在;fasel:不存在。</returns>
|
|
|
|
public bool ExistsParaTableName(QMAPP.FJC.Entity.Basic.ProcessParameter model)
|
|
|
|
{
|
|
|
|
int count = 0;
|
|
|
|
string sql = null;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
sql = "SELECT COUNT(*) FROM DBO.SYSOBJECTS WHERE NAME=@PARATABLENAME ";
|
|
|
|
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
|
|
{
|
|
|
|
count = Convert.ToInt32(session.ExecuteSqlScalar(sql, new DataParameter("PARATABLENAME", model.PARATABLENAME)));
|
|
|
|
}
|
|
|
|
if (count > 0)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
|
|
{
|
|
|
|
ErrorInfo = ex,
|
|
|
|
Tag = ex.StackTrace,
|
|
|
|
Info = "加工参数标准值设定数据层-校验数据库中表是否存在"
|
|
|
|
});
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 校验数据库中表对应的字段否存在
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="info"></param>
|
|
|
|
/// <returns>true:已存在;fasel:不存在。</returns>
|
|
|
|
public bool ExistsParaName(QMAPP.FJC.Entity.Basic.ProcessParameter model)
|
|
|
|
{
|
|
|
|
int count = 0;
|
|
|
|
string sql = null;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
sql = "SELECT COUNT(*) FROM SYSCOLUMNS WHERE ID=OBJECT_ID(@PARATABLENAME) AND NAME=@PARANAME ";
|
|
|
|
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
|
|
{
|
|
|
|
count = Convert.ToInt32(session.ExecuteSqlScalar(sql,
|
|
|
|
new DataParameter("PARATABLENAME", model.PARATABLENAME),
|
|
|
|
new DataParameter("PARANAME", model.PARANAME))
|
|
|
|
);
|
|
|
|
}
|
|
|
|
if (count > 0)
|
|
|
|
{
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
|
|
{
|
|
|
|
ErrorInfo = ex,
|
|
|
|
Tag = ex.StackTrace,
|
|
|
|
Info = "加工参数标准值设定数据层-校验数据库中表对应的字段否存在"
|
|
|
|
});
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 插入信息
|
|
|
|
/// <summary>
|
|
|
|
/// 插入信息(单表)
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="">信息</param>
|
|
|
|
/// <returns>插入行数</returns>
|
|
|
|
public int Insert(QMAPP.FJC.Entity.Basic.ProcessParameter model)
|
|
|
|
{
|
|
|
|
int count = 0;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
|
|
{
|
|
|
|
//插入基本信息
|
|
|
|
count = session.Insert<QMAPP.FJC.Entity.Basic.ProcessParameter>(model);
|
|
|
|
}
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
|
|
{
|
|
|
|
ErrorInfo = ex,
|
|
|
|
Tag = ex.StackTrace,
|
|
|
|
Info = "加工参数标准值设定数据层-插入信息"
|
|
|
|
});
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 更新信息
|
|
|
|
/// <summary>
|
|
|
|
/// 更新信息
|
|
|
|
/// </summary>
|
|
|
|
/// <param name=""></param>
|
|
|
|
/// <returns>更新行数</returns>
|
|
|
|
public int Update(QMAPP.FJC.Entity.Basic.ProcessParameter model)
|
|
|
|
{
|
|
|
|
int count = 0;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
|
|
{
|
|
|
|
//更新基本信息
|
|
|
|
count = session.Update<QMAPP.FJC.Entity.Basic.ProcessParameter>(model);
|
|
|
|
}
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
|
|
{
|
|
|
|
ErrorInfo = ex,
|
|
|
|
Tag = ex.StackTrace,
|
|
|
|
Info = "加工参数标准值设定数据层-更新信息"
|
|
|
|
});
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 删除信息
|
|
|
|
/// <summary>
|
|
|
|
/// 删除信息
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="model">加工参数标准值(ID)</param>
|
|
|
|
/// <returns>删除个数</returns>
|
|
|
|
public int Delete(QMAPP.FJC.Entity.Basic.ProcessParameter model)
|
|
|
|
{
|
|
|
|
StringBuilder sqlBuilder = new StringBuilder();
|
|
|
|
List<DataParameter> parameters = new List<DataParameter>();
|
|
|
|
int count = 0;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
|
|
{
|
|
|
|
//删除基本信息
|
|
|
|
count = session.Delete<QMAPP.FJC.Entity.Basic.ProcessParameter>(model);
|
|
|
|
}
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
|
|
{
|
|
|
|
ErrorInfo = ex,
|
|
|
|
Tag = ex.StackTrace,
|
|
|
|
Info = "加工参数标准值设定数据层-删除信息"
|
|
|
|
});
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
public DataPage GetParamList(ProcessParameter condition, DataPage page)
|
|
|
|
{
|
|
|
|
List<DataParameter> parameters = new List<DataParameter>();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if (string.IsNullOrEmpty(condition.PARATABLENAME))
|
|
|
|
{
|
|
|
|
throw new Exception("未确定参数表名称!");
|
|
|
|
}
|
|
|
|
|
|
|
|
StringBuilder sql = new StringBuilder();
|
|
|
|
sql.AppendLine("SELECT PA0.PID ");
|
|
|
|
sql.AppendLine(" ,PA0.PDID ");
|
|
|
|
sql.AppendLine(" ,PA0.PRODUCTCODE ");
|
|
|
|
sql.AppendLine(" ,PA0.MOID ");
|
|
|
|
sql.AppendLine(" ,PA0.MACHINENAME ");
|
|
|
|
sql.AppendLine(" ,PA0.MACHINECODDE ");
|
|
|
|
sql.AppendLine(" ,PA0.MOLDNUMBER ");
|
|
|
|
sql.AppendLine(" ,PA0.CREATEDATE ");
|
|
|
|
sql.AppendLine(","+condition.Fileds+" ");
|
|
|
|
sql.AppendLine("FROM ");
|
|
|
|
var tables = condition.PARATABLENAME.Split(',');
|
|
|
|
for (int i = 0; i < tables.Length; i++)
|
|
|
|
{
|
|
|
|
if (i == 0)
|
|
|
|
{
|
|
|
|
sql.AppendLine(string.Format("{0} AS PA{1} ", tables[i], i));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sql.AppendLine(string.Format("LEFT JOIN {0} AS PA{1} ", tables[i], i));
|
|
|
|
sql.AppendLine(string.Format("ON PA0.PID = PA{1}.PID ", tables[i], i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sql.AppendLine("WHERE 1=1 ");
|
|
|
|
if (!string.IsNullOrEmpty(condition.MACHINECODDE))
|
|
|
|
{
|
|
|
|
sql.AppendLine("AND PA0.MACHINECODDE=@MACHINECODDE ");
|
|
|
|
parameters.Add(new DataParameter("MACHINECODDE", condition.MACHINECODDE));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(condition.MouldCode))
|
|
|
|
{
|
|
|
|
sql.AppendLine("AND PA0.MOLDNUMBER=@MouldCode ");
|
|
|
|
parameters.Add(new DataParameter("MouldCode", condition.MouldCode));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(condition.ProductCode))
|
|
|
|
{
|
|
|
|
sql.AppendLine("AND PA0.PRODUCTCODE=@ProductCode ");
|
|
|
|
parameters.Add(new DataParameter("ProductCode", condition.ProductCode));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(condition.CREATEDATESTART))
|
|
|
|
{
|
|
|
|
sql.AppendLine(" AND PA0.CREATEDATE >= @CREATEDATESTART");
|
|
|
|
parameters.Add(new DataParameter() { DataType = DbType.String, ParameterName = "CREATEDATESTART", Value = condition.CREATEDATESTART });
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(condition.CREATEDATEEND))
|
|
|
|
{
|
|
|
|
sql.AppendLine(" AND PA0.CREATEDATE <= @CREATEDATEEND");
|
|
|
|
parameters.Add(new DataParameter() { DataType = DbType.String, ParameterName = "CREATEDATEEND", Value = condition.CREATEDATEEND });
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#region 排序
|
|
|
|
//分页关键字段及排序
|
|
|
|
page.KeyName = "PID";
|
|
|
|
if (string.IsNullOrEmpty(page.SortExpression))
|
|
|
|
{
|
|
|
|
page.SortExpression = "CREATEDATE DESC";
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
|
|
{
|
|
|
|
page = session.GetDataPage(sql.ToString(), parameters.ToArray(), page);
|
|
|
|
}
|
|
|
|
return page;
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
|
|
{
|
|
|
|
ErrorInfo = ex,
|
|
|
|
Tag = ex.StackTrace,
|
|
|
|
Info = "加工参数标准值设定数据层-获取列表"
|
|
|
|
});
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public DataTable GetParameter(ProcessParameter condition)
|
|
|
|
{
|
|
|
|
List<DataParameter> parameters = new List<DataParameter>();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if (string.IsNullOrEmpty(condition.PARATABLENAME))
|
|
|
|
{
|
|
|
|
throw new Exception("未确定参数表名称!");
|
|
|
|
}
|
|
|
|
|
|
|
|
StringBuilder sql = new StringBuilder();
|
|
|
|
sql.AppendLine("SELECT PA0.PID ");
|
|
|
|
sql.AppendLine(" ,PA0.PDID ");
|
|
|
|
sql.AppendLine(" ,PA0.PRODUCTCODE ");
|
|
|
|
sql.AppendLine(" ,PA0.MOID ");
|
|
|
|
sql.AppendLine(" ,PA0.MACHINENAME ");
|
|
|
|
sql.AppendLine(" ,PA0.MACHINECODDE ");
|
|
|
|
sql.AppendLine(" ,PA0.MOLDNUMBER ");
|
|
|
|
sql.AppendLine(" ,PA0.CREATEDATE ");
|
|
|
|
sql.AppendLine("," + condition.Fileds + " ");
|
|
|
|
sql.AppendLine("FROM ");
|
|
|
|
var tables = condition.PARATABLENAME.Split(',');
|
|
|
|
for (int i = 0; i < tables.Length; i++)
|
|
|
|
{
|
|
|
|
if (i == 0)
|
|
|
|
{
|
|
|
|
sql.AppendLine(string.Format("{0} AS PA{1} ", tables[i], i));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sql.AppendLine(string.Format("LEFT JOIN {0} AS PA{1} ", tables[i], i));
|
|
|
|
sql.AppendLine(string.Format("ON PA0.PID = PA{1}.PID ", tables[i], i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sql.AppendLine("WHERE 1=1 ");
|
|
|
|
if (!string.IsNullOrEmpty(condition.MACHINECODDE))
|
|
|
|
{
|
|
|
|
sql.AppendLine("AND PA0.MACHINECODDE=@MACHINECODDE ");
|
|
|
|
parameters.Add(new DataParameter("MACHINECODDE", condition.MACHINECODDE));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(condition.MouldCode))
|
|
|
|
{
|
|
|
|
sql.AppendLine("AND PA0.MOLDNUMBER=@MouldCode ");
|
|
|
|
parameters.Add(new DataParameter("MouldCode", condition.MouldCode));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(condition.ProductCode))
|
|
|
|
{
|
|
|
|
sql.AppendLine("AND PA0.PRODUCTCODE=@ProductCode ");
|
|
|
|
parameters.Add(new DataParameter("ProductCode", condition.ProductCode));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(condition.CREATEDATESTART))
|
|
|
|
{
|
|
|
|
sql.AppendLine(" AND PA0.CREATEDATE >= @CREATEDATESTART");
|
|
|
|
parameters.Add(new DataParameter() { DataType = DbType.String, ParameterName = "CREATEDATESTART", Value = condition.CREATEDATESTART });
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(condition.CREATEDATEEND))
|
|
|
|
{
|
|
|
|
sql.AppendLine(" AND PA0.CREATEDATE <= @CREATEDATEEND");
|
|
|
|
parameters.Add(new DataParameter() { DataType = DbType.String, ParameterName = "CREATEDATEEND", Value = condition.CREATEDATEEND });
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
|
|
{
|
|
|
|
return session.GetTable(sql.ToString(), parameters.ToArray());
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
|
|
{
|
|
|
|
ErrorInfo = ex,
|
|
|
|
Tag = ex.StackTrace,
|
|
|
|
Info = "加工参数标准值设定数据层-获取列表"
|
|
|
|
});
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public DataTable GetParamExport(ProcessParameter condition)
|
|
|
|
{
|
|
|
|
List<DataParameter> parameters = new List<DataParameter>();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if (string.IsNullOrEmpty(condition.PARATABLENAME))
|
|
|
|
{
|
|
|
|
throw new Exception("未确定参数表名称!");
|
|
|
|
}
|
|
|
|
|
|
|
|
StringBuilder sql = new StringBuilder();
|
|
|
|
sql.AppendLine("SELECT PA0.PID ");
|
|
|
|
sql.AppendLine(" ,PA0.PDID ");
|
|
|
|
sql.AppendLine(" ,PA0.PRODUCTCODE ");
|
|
|
|
sql.AppendLine(" ,PA0.MOID ");
|
|
|
|
sql.AppendLine(" ,PA0.MACHINENAME ");
|
|
|
|
sql.AppendLine(" ,PA0.MACHINECODDE ");
|
|
|
|
sql.AppendLine(" ,PA0.MOLDNUMBER ");
|
|
|
|
sql.AppendLine(" ,PA0.CREATEDATE ");
|
|
|
|
sql.AppendLine(","+condition.Fileds+" ");
|
|
|
|
sql.AppendLine("FROM ");
|
|
|
|
var tables = condition.PARATABLENAME.Split(',');
|
|
|
|
for (int i = 0; i < tables.Length; i++)
|
|
|
|
{
|
|
|
|
if (i == 0)
|
|
|
|
{
|
|
|
|
sql.AppendLine(string.Format("{0} AS PA{1} ", tables[i], i));
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
sql.AppendLine(string.Format("LEFT JOIN {0} AS PA{1} ", tables[i], i));
|
|
|
|
sql.AppendLine(string.Format("ON PA0.PID = PA{1}.PID ", tables[i], i));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
sql.AppendLine("WHERE 1=1 ");
|
|
|
|
if (!string.IsNullOrEmpty(condition.MACHINECODDE))
|
|
|
|
{
|
|
|
|
sql.AppendLine("AND PA0.MACHINECODDE=@MACHINECODDE ");
|
|
|
|
parameters.Add(new DataParameter("MACHINECODDE", condition.MACHINECODDE));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(condition.MouldCode))
|
|
|
|
{
|
|
|
|
sql.AppendLine("AND PA0.MOLDNUMBER=@MouldCode ");
|
|
|
|
parameters.Add(new DataParameter("MouldCode", condition.MouldCode));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(condition.ProductCode))
|
|
|
|
{
|
|
|
|
sql.AppendLine("AND PA0.PRODUCTCODE=@ProductCode ");
|
|
|
|
parameters.Add(new DataParameter("ProductCode", condition.ProductCode));
|
|
|
|
}
|
|
|
|
if (!string.IsNullOrEmpty(condition.CREATEDATESTART))
|
|
|
|
{
|
|
|
|
sql.AppendLine(" AND PA0.CREATEDATE >= @CREATEDATESTART");
|
|
|
|
parameters.Add(new DataParameter() { DataType = DbType.String, ParameterName = "CREATEDATESTART", Value = condition.CREATEDATESTART });
|
|
|
|
}
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(condition.CREATEDATEEND))
|
|
|
|
{
|
|
|
|
sql.AppendLine(" AND PA0.CREATEDATE <= @CREATEDATEEND");
|
|
|
|
parameters.Add(new DataParameter() { DataType = DbType.String, ParameterName = "CREATEDATEEND", Value = condition.CREATEDATEEND });
|
|
|
|
}
|
|
|
|
|
|
|
|
sql.AppendLine(" ORDER BY PA0.CREATEDATE DESC");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
|
|
{
|
|
|
|
return session.GetTable(sql.ToString(), parameters.ToArray());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
|
|
{
|
|
|
|
ErrorInfo = ex,
|
|
|
|
Tag = ex.StackTrace,
|
|
|
|
Info = "加工参数标准值设定数据层-获取列表"
|
|
|
|
});
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool HasParameterRecord(string productcode,string parametertable)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
StringBuilder sql = new StringBuilder();
|
|
|
|
sql.AppendLine("SELECT * ");
|
|
|
|
sql.AppendLine(" FROM [" + parametertable + "]");
|
|
|
|
sql.AppendLine(" WHERE [PRODUCTCODE] = @productcode");
|
|
|
|
List<DataParameter> parameters = new List<DataParameter>();
|
|
|
|
parameters.Add(new DataParameter("productcode", productcode));
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
|
|
{
|
|
|
|
var record = session.GetTable(sql.ToString(), parameters.ToArray());
|
|
|
|
return record.Rows.Count > 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
throw ex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public bool BFParameterRecord(string productcode)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
StringBuilder sql = new StringBuilder();
|
|
|
|
sql.AppendLine("SELECT * ");
|
|
|
|
sql.AppendLine(" FROM T_MD_ExchangeProduct");
|
|
|
|
sql.AppendLine(" WHERE ProductCode = @productcode");
|
|
|
|
List<DataParameter> parameters = new List<DataParameter>();
|
|
|
|
parameters.Add(new DataParameter("productcode", productcode));
|
|
|
|
|
|
|
|
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
|
|
{
|
|
|
|
var record = session.GetTable(sql.ToString(), parameters.ToArray());
|
|
|
|
if (record.Rows.Count > 0)
|
|
|
|
{
|
|
|
|
var sql2 = $"select * from T_AW_MAINOPERATION where PRODUCTCODE = '{record.Rows[0]["MainCode"].ToString() }' and WORKCELL_CODE = 'PRESS_FIT_BC316'";
|
|
|
|
var record2 = session.GetTable(sql2.ToString(), new List<DataParameter>().ToArray());
|
|
|
|
return record2.Rows.Count > 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
throw ex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|