using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using QMAPP.DAL;
using QMAPP.MD.Entity;
using QMFrameWork.Data;
namespace QMAPP.MD.DAL
{
///
/// 模块名称:工序
/// 作 者:郭兆福
/// 编写日期:2017年05月11日
///
public class WorkCellDAL : BaseDAL
{
#region 获取信息
///
/// 获取信息
///
/// 条件
/// 信息
public WorkCell Get(WorkCell model)
{
string sql = null;
List parameters = new List();
try
{
sql = "SELECT * FROM T_MD_WORKCELL WHERE FLGDEL='0' ";
if (string.IsNullOrEmpty(model.PID) == false)
{
sql += " AND PID = @PID";
parameters.Add(new DataParameter("PID", model.PID));
}
if (string.IsNullOrEmpty(model.WORKCELL_CODE) == false)
{
sql += " AND WORKCELL_CODE = @WORKCELL_CODE";
parameters.Add(new DataParameter("WORKCELL_CODE", model.WORKCELL_CODE));
}
if (string.IsNullOrEmpty(model.WORKCENTER_CODE) == false)
{
sql += " AND WORKCENTER_CODE = @WORKCENTER_CODE";
parameters.Add(new DataParameter("WORKCENTER_CODE", model.WORKCENTER_CODE));
}
using (IDataSession session = AppDataFactory.CreateMainSession())
{
// 对应多种数据库
string sqlChange = this.ChangeSqlByDB(sql, session);
//获取信息
model = session.Get(sqlChange, parameters.ToArray());
}
return model;
}
catch (Exception ex)
{
RecordExceptionLog(ex, "工序数据层-获取信息");
throw ex;
}
}
#endregion
#region 获取列表
///
/// 获取列表
///
/// 条件
/// 数据页
/// 数据页
public DataPage GetList(WorkCell condition, DataPage page)
{
string sql = null;
List parameters = new List();
try
{
sql = this.GetQuerySql(condition, ref parameters);
#region 排序
//分页关键字段及排序
page.KeyName = "PID";
if (string.IsNullOrEmpty(page.SortExpression))
{
page.SortExpression = "UPDATEDATE DESC";
}
#endregion
using (IDataSession session = AppDataFactory.CreateMainSession())
{
// 对应多种数据库
string sqlChange = this.ChangeSqlByDB(sql, session);
page = session.GetDataPage(sqlChange, parameters.ToArray(), page);
}
return page;
}
catch (Exception ex)
{
RecordExceptionLog(ex, "工序信息-获取列表");
throw ex;
}
}
///
/// 获取列表
///
/// 条件
/// 列表
public List GetList(WorkCell condition)
{
string sql = null;
List parameters = new List();
List listProcessInfo = new List();
try
{
sql = this.GetQuerySql(condition, ref parameters);
using (IDataSession session = AppDataFactory.CreateMainSession())
{
// 对应多种数据库
string sqlChange = this.ChangeSqlByDB(sql, session);
listProcessInfo = session.GetList(sqlChange, parameters.ToArray()).ToList();
}
return listProcessInfo;
}
catch (Exception ex)
{
RecordExceptionLog(ex, "工序信息-获取列表");
throw ex;
}
}
#endregion
#region 获取查询语句
///
/// 获取查询语句
///
/// 查询条件
/// 参数
/// 查询语句
private string GetQuerySql(WorkCell condition, ref List parameters)
{
StringBuilder sqlBuilder = new StringBuilder();
StringBuilder whereBuilder = new StringBuilder();
try
{
//构成查询语句
sqlBuilder.AppendLine(" SELECT M.PID ");
sqlBuilder.AppendLine(" ,M.WORKCELL_CODE ");
sqlBuilder.AppendLine(" ,M.WORKCELL_NAME ");
sqlBuilder.AppendLine(" ,M.WORKCENTER_CODE ");
sqlBuilder.AppendLine(" ,W.WORKCENTER_NAME ");
sqlBuilder.AppendLine(" ,M.FACTORY_CODE ");
sqlBuilder.AppendLine(" ,F.FACTORY_NAME ");
sqlBuilder.AppendLine(" ,M.FLAG_BACKFLUSH ");
sqlBuilder.AppendLine(" ,M.REMARK ");
sqlBuilder.AppendLine(" ,M.CREATEUSER ");
sqlBuilder.AppendLine(" ,M.CREATEDATE ");
sqlBuilder.AppendLine(" ,M.UPDATEUSER ");
sqlBuilder.AppendLine(" ,M.UPDATEDATE ");
sqlBuilder.AppendLine(" FROM T_MD_WORKCELL M ");
sqlBuilder.AppendLine(" LEFT JOIN T_MD_WORKCENTER W ON M.WORKCENTER_CODE=W.WORKCENTER_CODE AND M.FACTORY_CODE=W.FACTORY_CODE");
sqlBuilder.AppendLine(" LEFT JOIN T_MD_FACTORY F ON F.FACTORY_CODE=M.FACTORY_CODE ");
//查询条件
//工序名称
if (string.IsNullOrEmpty(condition.WORKCELL_NAME) == false)
{
whereBuilder.Append(" AND M.WORKCELL_NAME LIKE @WORKCELL_NAME");
parameters.Add(new DataParameter { ParameterName = "WORKCELL_NAME", DataType = DbType.String, Value = EscapeValue(condition.WORKCELL_NAME) + "%" });
}
//工序类别
if (string.IsNullOrEmpty(condition.WORKCELL_CODE) == false)
{
whereBuilder.Append(" AND M.WORKCELL_CODE = @WORKCELL_CODE");
parameters.Add(new DataParameter { ParameterName = "WORKCELL_CODE", DataType = DbType.String, Value = condition.WORKCELL_CODE });
}
//工作中心
if (string.IsNullOrEmpty(condition.WORKCENTER_CODE) == false)
{
whereBuilder.Append(" AND M.WORKCENTER_CODE = @WORKCENTER_CODE");
parameters.Add(new DataParameter { ParameterName = "WORKCENTER_CODE", DataType = DbType.String, Value = condition.WORKCENTER_CODE });
}
if (string.IsNullOrEmpty(condition.FACTORY_CODE) == false)
{
whereBuilder.Append(" AND M.FACTORY_CODE = @FACTORY_CODE");
parameters.Add(new DataParameter { ParameterName = "FACTORY_CODE", DataType = DbType.String, Value = condition.FACTORY_CODE });
}
whereBuilder.Append(" AND M.FLGDEL ='0'");
if (whereBuilder.Length > 0)
{
sqlBuilder.Append(" WHERE " + whereBuilder.ToString().Substring(4));
}
return sqlBuilder.ToString();
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 判断工序编号或者名称是否重复
///
/// 判断工序编号或者名称是否重复
///
/// 工序
/// true:已存在;false:不存在。
public bool IsExistsWorkCellCodeName(WorkCell model)
{
string PID = "";
int count = 0;
string sql = null;
try
{
if (string.IsNullOrEmpty(model.PID) == false)
{
PID = model.PID;
}
List paramList = new List();
sql = "SELECT COUNT(*) FROM T_MD_WORKCELL WHERE PID <> @PID AND FACTORY_CODE=@FACTORY_CODE AND WORKCELL_CODE=@WORKCELL_CODE";
paramList.Add(new DataParameter { ParameterName = "PID", Value = PID });
paramList.Add(new DataParameter { ParameterName = "FACTORY_CODE", Value = model.FACTORY_CODE });
paramList.Add(new DataParameter { ParameterName = "WORKCELL_CODE", Value = model.WORKCELL_CODE });
using (IDataSession session = AppDataFactory.CreateMainSession())
{
// 对应多种数据库
string sqlChange = this.ChangeSqlByDB(sql, session);
count = Convert.ToInt32(session.ExecuteSqlScalar(sqlChange, paramList.ToArray()));
}
return count > 0;
}
catch (Exception ex)
{
RecordExceptionLog(ex, "工序信息-判断编号名称是否存在");
throw ex;
}
}
#endregion
#region 插入信息
///
/// 插入信息(单表)
///
/// 信息
/// 插入行数
public int Insert(WorkCell model)
{
int count = 0;
try
{
using (IDataSession session = AppDataFactory.CreateMainSession())
{
//插入基本信息
count = session.Insert(model);
}
return count;
}
catch (Exception ex)
{
RecordExceptionLog(ex, "工序信息-插入信息");
throw ex;
}
}
#endregion
#region 更新信息
///
/// 更新信息
///
///
/// 更新行数
public int Update(WorkCell model)
{
int count = 0;
try
{
using (IDataSession session = AppDataFactory.CreateMainSession())
{
//更新基本信息
count = session.Update(model);
}
return count;
}
catch (Exception ex)
{
RecordExceptionLog(ex, "工序信息-更新信息");
throw ex;
}
}
#endregion
#region 删除
///
/// 删除信息
///
/// 物料号信息(ID)
/// 删除个数
public int Delete(WorkCell model)
{
StringBuilder sqlBuilder = new StringBuilder();
List parameters = new List();
int count = 0;
try
{
using (IDataSession session = AppDataFactory.CreateMainSession())
{
//删除基本信息
count = session.Delete(model);
}
return count;
}
catch (Exception ex)
{
RecordExceptionLog(ex, "工序信息-删除");
throw ex;
}
}
#endregion
#region 工序下拉
///
///
///
///
///
public List GetWorkCellBasicList(WorkCell condition)
{
List list = new List();
string sql = null;
List parameters = new List();
try
{
sql = this.GetQuerySql(condition, ref parameters);
using (IDataSession session = AppDataFactory.CreateMainSession())
{
// 对应多种数据库
string sqlChange = this.ChangeSqlByDB(sql, session);
list = session.GetList(sqlChange, parameters.ToArray()).ToList();
}
return list;
}
catch (Exception ex)
{
RecordExceptionLog(ex, "工序信息-列表");
throw ex;
}
}
#endregion
#region 获取工序下拉列表数据
///
/// 获取工序下拉列表数据
///
///
///
public List GetWorkCellList(WorkCell model)
{
string sql = null;
List parameters = new List();
List list = new List();
//sql = @" SELECT * FROM T_MD_WORKCELL WHERE FLGDEL = '0' ";
sql = this.GetQuerySql(model, ref parameters);
using (IDataSession session = AppDataFactory.CreateMainSession())
{
sql = this.ChangeSqlByDB(sql, session);
list = session.GetList(sql, parameters.ToArray()).OrderBy(p=>p.WORKCELL_CODE).ToList();
}
return list;
}
#endregion
#region 工序信息下拉
///
///
///
///
///
public List GetWorkCellWithRouteList(WorkCell model, string routecode)
{
List list = new List();
string sql = null;
StringBuilder sqlBuilder = new StringBuilder();
List parameters = new List();
try
{
using (IDataSession session = AppDataFactory.CreateMainSession())
{
sqlBuilder.AppendLine("SELECT * FROM T_MD_WORKCELL W ");
sqlBuilder.AppendLine(" LEFT JOIN T_MD_PROCESS_ROUTE_WORKCELL PRW ON PRW.WORKCELL_CODE=W.WORKCELL_CODE ");
sqlBuilder.AppendLine(" LEFT JOIN T_MD_PROCESS_ROUTE PR ON PR.ROUTE_CODE=PRW.ROUTE_CODE ");
sqlBuilder.AppendLine(" WHERE PR.ROUTE_CODE=@ROUTE_CODE");
parameters.Add(new DataParameter { ParameterName = "ROUTE_CODE", DataType = DbType.String, Value = routecode });
sql = this.ChangeSqlByDB(sqlBuilder.ToString(), session);
list = session.GetList(sql, parameters.ToArray()).ToList();
}
return list;
}
catch (Exception ex)
{
RecordExceptionLog(ex, "工序信息-下拉列表");
throw ex;
}
}
#endregion
#region 工序信息下拉排序
///
///
///
///
///
public List GetWorkCellWithRouteListSeq(string routecode)
{
List list = new List();
string sql = null;
StringBuilder sqlBuilder = new StringBuilder();
List parameters = new List();
try
{
using (IDataSession session = AppDataFactory.CreateMainSession())
{
sqlBuilder.AppendLine("with DEPTS as ");
sqlBuilder.AppendLine("( select * from T_MD_PROCESS_ROUTE_WORKCELL_SEQ where ROUTE_CODE=@ROUTE_CODE and PRE_WORKCELL_CODE is null ");
sqlBuilder.AppendLine("union all ");
sqlBuilder.AppendLine("select t.* from T_MD_PROCESS_ROUTE_WORKCELL_SEQ t , DEPTS where DEPTS.WORKCELL_CODE = t.PRE_WORKCELL_CODE ) ");
sqlBuilder.AppendLine("select d.WORKCELL_CODE,(select WORKCELL_NAME from T_MD_WORKCELL where WORKCELL_CODE=d.WORKCELL_CODE) as WORKCELL_NAME from DEPTS d ");
parameters.Add(new DataParameter { ParameterName = "ROUTE_CODE", DataType = DbType.String, Value = routecode });
sql = this.ChangeSqlByDB(sqlBuilder.ToString(), session);
list = session.GetList(sql, parameters.ToArray()).ToList();
}
return list;
}
catch (Exception ex)
{
RecordExceptionLog(ex, "工序信息-下拉列表");
throw ex;
}
}
#endregion
#region 判断工序是否完成
///
/// 断工序是否完成
///
/// 计划编码
/// 工序
/// true;完成 false:未完成
public bool IsWorkCellEnd(string ppCode, string cellCode)
{
try
{
StringBuilder sqlBuilder = new StringBuilder();
//构成查询语句
sqlBuilder.Append(" SELECT COUNT(1) ");
sqlBuilder.Append(" FROM T_QT_DAI C ");
sqlBuilder.Append(" WHERE ");
sqlBuilder.Append(" C.FLGDEL = '0' ");
// 主要采集点
sqlBuilder.Append(" AND C.PIVOTAL = '1' ");
// 采集点状态
sqlBuilder.Append(" AND C.DA_STATUS = '1' ");
sqlBuilder.Append(" AND C.WORKCELL_CODE = @WORKCELL_CODE ");
sqlBuilder.Append(" AND NOT EXISTS ( ");
sqlBuilder.Append(" SELECT 1 ");
sqlBuilder.Append(" FROM T_QT_WIP_DAI_HIS E ");
sqlBuilder.Append(" WHERE ");
sqlBuilder.Append(" E.WORKCELL_CODE = C.WORKCELL_CODE ");
sqlBuilder.Append(" AND E.PP_CODE = @PP_CODE ");
sqlBuilder.Append(" AND E.DA_CODE = C.DA_CODE ) ");
DataParameter[] para = { new DataParameter("WORKCELL_CODE", DbType.String, cellCode), new DataParameter("PP_CODE", DbType.String, ppCode) };
if (null != BaseSession)
{
string sqlChange = ChangeSqlByDB(sqlBuilder.ToString(), BaseSession);
return (Convert.ToInt32(BaseSession.ExecuteSqlScalar(sqlChange, para)) == 0 ? true : false);
}
else
{
using (IDataSession session = AppDataFactory.CreateMainSession())
{
string sqlChange = ChangeSqlByDB(sqlBuilder.ToString(), session);
return (Convert.ToInt32(session.ExecuteSqlScalar(sqlChange, para)) == 0 ? true : false);
}
}
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取当前工序的下一工序
///
/// 获取当前工序的下一工序
///
/// 工艺路线
/// 当前工序
/// 工序列表
public WorkCell GetNextWorkCell(string routeCode,string workCellCode)
{
StringBuilder sqlBuilder = new StringBuilder();
try
{
sqlBuilder.Append(" SELECT ");
// 下一工序
sqlBuilder.Append(GetSqlSelectItem("C"));
sqlBuilder.Append(" FROM T_MD_PROCESS_ROUTE_WORKCELL A ");
sqlBuilder.Append(" ,T_MD_PROCESS_ROUTE_WORKCELL_SEQ B ");
sqlBuilder.Append(" ,T_MD_WORKCELL C ");
sqlBuilder.Append(" WHERE A.WORKCELL_CODE = B.PRE_WORKCELL_CODE "); // 得到当前工序的下一个工序
sqlBuilder.Append(" AND A.ROUTE_CODE = B.ROUTE_CODE ");
sqlBuilder.Append(" AND B.WORKCELL_CODE = C.WORKCELL_CODE "); // 得到下一个工序
sqlBuilder.Append(" AND A.FLGDEL = '0' ");
sqlBuilder.Append(" AND B.FLGDEL = '0' ");
sqlBuilder.Append(" AND C.FLGDEL = '0' ");
sqlBuilder.Append(" AND A.ROUTE_CODE = @ROUTE_CODE ");
sqlBuilder.Append(" AND A.WORKCELL_CODE =@WORKCELL_CODE ");
DataParameter[] para = { new DataParameter("ROUTE_CODE", DbType.String, routeCode), new DataParameter("WORKCELL_CODE", DbType.String, workCellCode) };
if (null != BaseSession)
{
// 对应多种数据库
string sqlChange = this.ChangeSqlByDB(sqlBuilder.ToString(), BaseSession);
return BaseSession.Get(sqlChange, para);
}
else
{
using (IDataSession session = AppDataFactory.CreateMainSession())
{
// 对应多种数据库
string sqlChange = this.ChangeSqlByDB(sqlBuilder.ToString(), session);
return session.Get(sqlChange, para);
}
}
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 判断是否是第一道工序
///
/// 判断是否是第一道工序
///
/// 工艺路线
/// 当前工序
/// true:是 false:否
public bool IsFristWorkCell(string routeCode, string workCellCode)
{
StringBuilder sqlBuilder = new StringBuilder();
try
{
sqlBuilder.Append(" SELECT ");
sqlBuilder.Append(" * ");
sqlBuilder.Append(" FROM T_MD_PROCESS_ROUTE_WORKCELL_SEQ ");
sqlBuilder.Append(" WHERE ROUTE_CODE = @ROUTE_CODE ");
sqlBuilder.Append(" AND WORKCELL_CODE =@WORKCELL_CODE ");
sqlBuilder.Append(" AND FLGDEL = '0' ");
ProcessRouteWorkCellSeq workCellSeq;
DataParameter[] para = { new DataParameter("ROUTE_CODE", DbType.String, routeCode), new DataParameter("WORKCELL_CODE", DbType.String, workCellCode) };
if (null != BaseSession)
{
// 对应多种数据库
string sqlChange = this.ChangeSqlByDB(sqlBuilder.ToString(), BaseSession);
workCellSeq = BaseSession.Get(sqlChange, para);
}
else
{
using (IDataSession session = AppDataFactory.CreateMainSession())
{
// 对应多种数据库
string sqlChange = this.ChangeSqlByDB(sqlBuilder.ToString(), session);
workCellSeq = session.Get(sqlChange, para);
}
}
// 没有数据,或者是前置工序为空 则为第一道工序
if (null == workCellSeq || string.IsNullOrEmpty(workCellSeq.PRE_WORKCELL_CODE) == true)
{
return true;
}
else
{
return false;
}
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 得到检索项目
///
/// 得到检索项目
///
///
///
private string GetSqlSelectItem(string suffix)
{
String[] tableItem = {"PID"
,"WORKCENTER_CODE"
,"WORKCELL_CODE"
,"WORKCELL_NAME"
,"FLAG_BACKFLUSH"
,"REMARK"
,"CREATEUSER"
,"CREATEDATE"
,"UPDATEUSER"
,"UPDATEDATE"
,"FLGDEL"
};
StringBuilder sb = new StringBuilder();
if (String.IsNullOrEmpty(suffix))
{
suffix = ",";
}
else
{
suffix = "," + suffix + ".";
}
foreach (string str in tableItem)
{
sb.Append(suffix).Append(str);
}
return sb.ToString().Substring(1);
}
#endregion
#region 根据工序编码获取工序
///
/// 根据工序编码获取工序
///
///
///
public WorkCell GetWorkCellByCode(string workcellcode)
{
try
{
using (IDataSession session = AppDataFactory.CreateMainSession())
{
string sql = "SELECT * FROM [T_MD_WORKCELL] WHERE WORKCELL_CODE=@workcellcode";
var workcell = session.Get(sql, new DataParameter("workcellcode", workcellcode));
return workcell;
}
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 通过查询条件获取工序
///
/// 通过查询条件获取工序
///
///
///
public WorkCell GetByCondition(WorkCell condition)
{
WorkCell entity = new WorkCell();
StringBuilder sql = new StringBuilder();
sql.Append("select * from T_MD_WORKCELL where 1=1 ");
List paraList = new List();
if (string.IsNullOrEmpty(condition.WORKCELL_CODE) == false)
{
sql.Append(" and WORKCELL_CODE=@WORKCELL_CODE ");
paraList.Add(new DataParameter() { ParameterName = "WORKCELL_CODE", DataType = DbType.String, Value = condition.WORKCELL_CODE });
}
List workCellList = new List();
using (IDataSession session = AppDataFactory.CreateMainSession())
{
workCellList = session.GetList(sql.ToString(), paraList.ToArray()).ToList();
}
if (workCellList.Count > 0)
{
entity = workCellList[0];
}
return entity;
}
#endregion
#region 获取下道工序
///
/// 获取下道工序
///
///
///
public WorkCell GetNextWorkCell(WorkCell currentCell)
{
WorkCell cell = new WorkCell();
string sql = string.Format("select * from T_MD_WORKCELL where WORKCELL_CODE in (select WORKCELL_CODE from T_MD_PROCESS_ROUTE_WORKCELL_SEQ where PRE_WORKCELL_CODE='{0}' ) ", currentCell.WORKCELL_CODE);
using (IDataSession session = AppDataFactory.CreateMainSession())
{
cell = session.Get(sql, new List().ToArray());
}
return cell;
}
#endregion
#region 根据物料号获取PBOM表中工作中心
///
/// 根据物料号获取PBOM表中工作中心
///
///
///
public string GetWorkcenterWithMaterial(string materialcode)
{
string workcentercode="";
StringBuilder sqlBuilder = new StringBuilder();
List parameters = new List();
sqlBuilder.Append(" SELECT WC.WORKCENTER_CODE ");
sqlBuilder.Append(" FROM T_MD_WORKCELL WC ");
sqlBuilder.Append("LEFT JOIN T_MD_PROCESS_ROUTE_WORKCELL PRW ON PRW.WORKCELL_CODE = WC.WORKCELL_CODE ");
sqlBuilder.Append("LEFT JOIN T_MD_PROCESS_ROUTE PR ON PR.ROUTE_CODE = PRW.ROUTE_CODE ");
sqlBuilder.Append("LEFT JOIN T_MD_MATERIAL_ROUTE MR ON MR.ROUTE_CODE = PR.ROUTE_CODE ");
sqlBuilder.Append("LEFT JOIN T_MD_PBOM P ON P.MATERIAL_CODE = MR.MATERIAL_CODE ");
sqlBuilder.Append(" WHERE P.MATERIAL_CODE = @MATERIAL_CODE");
parameters.Add(new DataParameter { ParameterName = "MATERIAL_CODE", DataType = DbType.String, Value = materialcode });
try
{
using (IDataSession session = AppDataFactory.CreateMainSession())
{
string sqlChange = ChangeSqlByDB(sqlBuilder.ToString(), session);
//获取信息
var temp=session.ExecuteSqlScalar(sqlChange, parameters.ToArray());
if(temp!=null)
workcentercode = temp.ToString();
}
return workcentercode;
}
catch (Exception ex)
{
RecordExceptionLog(ex, "工序信息数据层-根据物料号获取PBOM表中工作中心");
throw ex;
}
}
#endregion
#region 根据工作中心
///
/// 工作中心
///
///
///
public string GetWorkcenter(string ordertype)
{
string workcentercode = "";
StringBuilder sqlBuilder = new StringBuilder();
List parameters = new List();
sqlBuilder.Append(" SELECT WORKCENTER ");
sqlBuilder.Append(" FROM T_PP_ORDERINDENTITY ");
sqlBuilder.Append(" WHERE ORDER_TYPE = @ORDER_TYPE");
parameters.Add(new DataParameter { ParameterName = "ORDER_TYPE", DataType = DbType.String, Value = ordertype });
try
{
using (IDataSession session = AppDataFactory.CreateMainSession())
{
string sqlChange = ChangeSqlByDB(sqlBuilder.ToString(), session);
//获取信息
var temp = session.ExecuteSqlScalar(sqlChange, parameters.ToArray());
if (temp != null)
workcentercode = temp.ToString();
}
return workcentercode;
}
catch (Exception ex)
{
RecordExceptionLog(ex, "工序信息数据层-根据物料号获取PBOM表中工作中心");
throw ex;
}
}
#endregion
#region
public List GetFirstWorkCell(string pbomcode)
{
List list = new List();
if (string.IsNullOrEmpty(pbomcode))
{
return list;
}
string sql = string.Format(@"SELECT seq.* FROM T_MD_PBOM pm,T_MD_MATERIAL_ROUTE mr,T_MD_PROCESS_ROUTE_WORKCELL rw,T_MD_PROCESS_ROUTE_WORKCELL_SEQ seq
where pm.PBOM_CODE='{0}' and pm.MATERIAL_CODE=mr.MATERIAL_CODE
and mr.ROUTE_CODE=rw.ROUTE_CODE and rw.WORKCELL_CODE=seq.WORKCELL_CODE
and (seq.PRE_WORKCELL_CODE='' or seq.PRE_WORKCELL_CODE is null)", pbomcode);
using (IDataSession session = AppDataFactory.CreateMainSession())
{
list = session.GetList(sql, new List().ToArray()).ToList();
}
return list;
}
#endregion
}
}