天津投入产出系统后端
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.
 
 
 
 
 
 

1256 lines
52 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QMFrameWork.Data;
using QMAPP.FJC.Entity.ProductionPlan;
using System.Data;
using QMAPP.Entity;
using QMAPP.DAL;
using QMFrameWork.Log;
using QMAPP.FJC.Entity.FIS;
namespace QMAPP.FJC.DAL.ProductionPlan
{
/// <summary>
/// 模块名称:派工单
/// 作 者:张鹏
/// 编写日期:2017年10月24日
/// </summary>
public class WorkOrderDAL : BaseDAL
{
#region 获取信息
/// <summary>
/// 获取信息
/// </summary>
/// <param name="">条件</param>
/// <returns>*信息</returns>
public WorkOrder Get(WorkOrder info)
{
try
{
using (IDataSession session = AppDataFactory.CreateMainSession())
{
//获取信息
info = session.Get<WorkOrder>(info);
}
return info;
}
catch (Exception ex)
{
throw ex;
}
}
public WorkOrder GetOne(string ORDERPLANID)
{
string sql = "SELECT * FROM [T_PP_WORKORDER] WITH(NOLOCK) where [ORDERPLANID]='" + ORDERPLANID + "'";
List<DataParameter> parameters = new List<DataParameter>();
try
{
if (BaseSession != null)
{
return BaseSession.GetList<WorkOrder>(sql, parameters.ToArray()).FirstOrDefault();
}
using (IDataSession session = AppDataFactory.CreateMainSession())
{
return session.GetList<WorkOrder>(sql, parameters.ToArray()).FirstOrDefault();
}
}
catch (Exception ex)
{
throw ex;
}
}
public WorkOrder GetOneByID(string id)
{
string sql = "SELECT * FROM [T_PP_WORKORDER] WITH(NOLOCK) where [PID]='" + id + "'";
List<DataParameter> parameters = new List<DataParameter>();
try
{
if (BaseSession != null)
{
return BaseSession.GetList<WorkOrder>(sql, parameters.ToArray()).FirstOrDefault();
}
using (IDataSession session = AppDataFactory.CreateMainSession())
{
return session.GetList<WorkOrder>(sql, parameters.ToArray()).FirstOrDefault();
}
}
catch (Exception ex)
{
throw ex;
}
}
public WorkOrder GetOneByOrderNO(string ORDERPLANNO)
{
string sql = "SELECT * FROM [T_PP_WORKORDER] WITH(NOLOCK) where [ORDERPLAN_NO]='" + ORDERPLANNO + "'";
List<DataParameter> parameters = new List<DataParameter>();
try
{
if (BaseSession != null)
{
return BaseSession.GetList<WorkOrder>(sql, parameters.ToArray()).FirstOrDefault();
}
using (IDataSession session = AppDataFactory.CreateMainSession())
{
return session.GetList<WorkOrder>(sql, parameters.ToArray()).FirstOrDefault();
}
}
catch (Exception ex)
{
throw ex;
}
}
public WorkOrder GetOneByProduct(string productCode)
{
string sql = "SELECT * FROM [T_PP_WORKORDER] WITH(NOLOCK) where [REMARK]='" + productCode + "'";
List<DataParameter> parameters = new List<DataParameter>();
try
{
if (BaseSession != null)
{
return BaseSession.GetList<WorkOrder>(sql, parameters.ToArray()).FirstOrDefault();
}
using (IDataSession session = AppDataFactory.CreateMainSession())
{
return session.GetList<WorkOrder>(sql, parameters.ToArray()).FirstOrDefault();
}
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 获取计划单号下所有派工单信息
/// </summary>
/// <param name="ORDERPLANID"></param>
/// <returns></returns>
public int GetAllWorkOrder(string ORDERPLANID)
{
int count = 0;
string sql = "SELECT COUNT(1) FROM [T_PP_WORKORDER] WITH(NOLOCK) where [ORDERPLANID]='" + ORDERPLANID + "' AND STATE<>0";
List<DataParameter> parameters = new List<DataParameter>();
try
{
using (IDataSession session = AppDataFactory.CreateMainSession())
{
count =Convert.ToInt32(session.ExecuteSqlScalar(sql, parameters.ToArray()));
}
}
catch (Exception ex)
{
throw ex;
}
return count;
}
#endregion
#region 获取列表
/// <summary>
/// 获取列表
/// </summary>
/// <param name="condition">条件</param>
/// <param name="page">数据页</param>
/// <returns>数据页</returns>
public DataPage GetList(WorkOrder condition, DataPage page)
{
string sql = null;
List<DataParameter> parameters = new List<DataParameter>();
try
{
sql = this.GetQuerySql(condition, ref parameters);
//分页关键字段及排序
page.KeyName = "PID";
if (string.IsNullOrEmpty(page.SortExpression))
page.SortExpression = "UPDATEDATE DESC";
using (IDataSession session = AppDataFactory.CreateMainSession())
{
page = session.GetDataPage<WorkOrder>(sql, parameters.ToArray(), page);
}
return page;
}
catch (Exception ex)
{
throw ex;
}
}
public List<WorkOrder> GetList(WorkOrder condition)
{
List<WorkOrder> workOrderList = new List<WorkOrder>();
string sql = "select * from T_PP_WORKORDER WITH(NOLOCK) where 1=1 ";
if (string.IsNullOrEmpty(condition.ORDERPLANID) == false)
{
sql += string.Format(" and ORDERPLANID='{0}'",condition.ORDERPLANID);
}
using (IDataSession session = AppDataFactory.CreateMainSession())
{
workOrderList = session.GetList<WorkOrder>(sql, new List<DataParameter>().ToArray()).ToList<WorkOrder>();
}
return workOrderList;
}
public List<WorkOrder> GetWorkOrderInfo(string planno)
{
try
{
StringBuilder sql = new StringBuilder();
sql.AppendFormat("SELECT W.[PID]");
sql.AppendFormat(" ,W.[ORDERPLANID] ");
sql.AppendFormat(" ,W.[ORDERPLAN_NO] ");
sql.AppendFormat(" ,W.[ORDER_TYPE] ");
sql.AppendFormat(" ,W.[SEQ] ");
sql.AppendFormat(" ,W.[MATERIAL_CODE] ");
sql.AppendFormat(" ,M.[MATERIAL_NAME] ");
sql.AppendFormat(" ,W.[PBOM_CODE] ");
sql.AppendFormat(" ,W.[QTY] ");
sql.AppendFormat(" ,W.[COMPLETE_QTY] ");
sql.AppendFormat(" ,W.[PLAN_DATE] ");
sql.AppendFormat(" ,W.[SHIFT_CODE] ");
sql.AppendFormat(" ,W.[WORKCENTER_CODE] ");
sql.AppendFormat(" ,W.[WORKCENTER_NAME] ");
sql.AppendFormat(" ,W.[WORKCELL_CODE] ");
sql.AppendFormat(" ,W.[WORKCELL_NAME] ");
sql.AppendFormat(" ,W.[WORKLOC_CODE] ");
sql.AppendFormat(" ,W.[REMARK] ");
sql.AppendFormat(" ,W.[EQPT_NAME] ");
sql.AppendFormat(" ,W.[EQPT_CODE] ");
sql.AppendFormat(" ,W.[STATE] ");
sql.AppendFormat(" ,W.[MOULD_CODE] ");
sql.AppendFormat(" ,W.[PRI] ");
sql.AppendFormat(" ,W.[UPDATEDATE] ");
sql.AppendFormat(" ,W.[PRINTED] ");
sql.AppendFormat(" ,P.[IGNORE_FISBREAK] ");
sql.AppendFormat(" ,P.[FIS_ASMSETCODE] ");
sql.AppendFormat(" FROM [T_PP_WORKORDER] AS W WITH(NOLOCK) ");
sql.AppendFormat(" LEFT JOIN [T_PP_ORDERPLAN] AS P WITH(NOLOCK) ");
sql.AppendFormat(" ON P.[PID]=W.[ORDERPLANID] ");
sql.AppendFormat(" LEFT JOIN [T_MD_MATERIAL] AS M WITH(NOLOCK) ");
sql.AppendFormat(" ON W.[MATERIAL_CODE]=M.[MATERIAL_CODE] ");
sql.AppendFormat(" WHERE P.[PLAN_NO]=@planno ");
sql.AppendFormat(" ORDER BY W.[UPDATEDATE],W.[PRI],W.[PLAN_DATE],P.PLAN_SEQ,W.[SEQ],W.[MATERIAL_CODE] ");
List<DataParameter> parameters = new List<DataParameter>();
parameters.Add(new DataParameter("planno", planno));
using (var session = AppDataFactory.CreateMainSession())
{
return session.GetList<WorkOrder>(sql.ToString(), parameters.ToArray()).ToList();
}
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 获取指定工序的生产计划清单
/// </summary>
/// <param name="workcellcode">工序编码</param>
/// <param name="count">数量</param>
/// <param name="filter">过滤选项:0全部;1隐藏挂起;2只看挂起</param>
/// <returns></returns>
public List<WorkOrder> GetOrderInCell(string workcellcode,int filter=0, int count = 20)
{
try
{
StringBuilder sql = new StringBuilder();
if (workcellcode == "BRIM_WELDING_BC316")
{
sql.AppendFormat("SELECT TOP 12 A.[PID], A.[ORDERPLANID], A.[ORDERPLAN_NO], A.[ORDER_TYPE], A.[SEQ], A.[MATERIAL_CODE], A.[MATERIAL_NAME], A.[PBOM_CODE], A.[QTY], A.[COMPLETE_QTY], A.[PLAN_DATE], A.[SHIFT_CODE], A.[WORKCENTER_CODE], A.[WORKCENTER_NAME], A.[WORKCELL_CODE], A.[WORKCELL_NAME], A.[WORKLOC_CODE], A.[REMARK], A.[EQPT_NAME], A.[EQPT_CODE], A.[STATE], A.[MOULD_CODE], A.[PRI], A.[UPDATEDATE], A.[IGNORE_FISBREAK], A.[FIS_ASMSETCODE] FROM ( ");
sql.AppendFormat("SELECT TOP {0} W.[PID]\r\n", 12);
}else
{
sql.AppendFormat("SELECT TOP {0} W.[PID]\r\n", count);
}
sql.AppendFormat(" ,W.[ORDERPLANID] ");
sql.AppendFormat(" ,W.[ORDERPLAN_NO] ");
sql.AppendFormat(" ,W.[ORDER_TYPE] ");
sql.AppendFormat(" ,W.[SEQ] ");
sql.AppendFormat(" ,W.[MATERIAL_CODE] ");
sql.AppendFormat(" ,M.[MATERIAL_NAME] ");
sql.AppendFormat(" ,W.[PBOM_CODE] ");
sql.AppendFormat(" ,W.[QTY] ");
sql.AppendFormat(" ,W.[COMPLETE_QTY] ");
sql.AppendFormat(" ,W.[PLAN_DATE] ");
sql.AppendFormat(" ,W.[SHIFT_CODE] ");
sql.AppendFormat(" ,W.[WORKCENTER_CODE] ");
sql.AppendFormat(" ,W.[WORKCENTER_NAME] ");
sql.AppendFormat(" ,W.[WORKCELL_CODE] ");
sql.AppendFormat(" ,W.[WORKCELL_NAME] ");
sql.AppendFormat(" ,W.[WORKLOC_CODE] ");
sql.AppendFormat(" ,W.[REMARK] ");
sql.AppendFormat(" ,W.[EQPT_NAME] ");
sql.AppendFormat(" ,W.[EQPT_CODE] ");
sql.AppendFormat(" ,W.[STATE] ");
sql.AppendFormat(" ,W.[MOULD_CODE] ");
sql.AppendFormat(" ,W.[PRI] ");
sql.AppendFormat(" ,W.[UPDATEDATE] ");
sql.AppendFormat(" ,P.[PLAN_SEQ] ");
sql.AppendFormat(" ,P.[IGNORE_FISBREAK] ");
sql.AppendFormat(" ,P.[FIS_ASMSETCODE] ");
sql.AppendFormat(" FROM [T_PP_WORKORDER] AS W WITH(NOLOCK) ");
sql.AppendFormat(" LEFT JOIN [T_PP_ORDERPLAN] AS P WITH(NOLOCK) ");
sql.AppendFormat(" ON P.[PID]=W.[ORDERPLANID] ");
sql.AppendFormat(" LEFT JOIN [T_MD_MATERIAL] AS M WITH(NOLOCK)");
sql.AppendFormat(" ON W.[MATERIAL_CODE]=M.[MATERIAL_CODE] ");
sql.AppendFormat(" WHERE W.[WORKCELL_CODE]=@workcellcode ");
switch (filter)
{
case 1:
{
sql.AppendFormat(" AND W.[STATE]<>4 AND W.[STATE]<>2");
break;
}
case 2:
{
sql.AppendFormat(" AND W.[STATE]=4 AND W.[STATE]<>2");
break;
}
}
if (workcellcode == "BRIM_WELDING_BC316")
{
sql.AppendFormat(" ORDER BY W.ORDER_TYPE, W.[PLAN_DATE]) A ");
sql.AppendFormat(" ORDER BY A.[UPDATEDATE],A.[PRI],A.[PLAN_DATE],A.PLAN_SEQ,A.[SEQ],A.[MATERIAL_CODE] ");
}
else
{
sql.AppendFormat(" ORDER BY W.[UPDATEDATE],W.[PRI],W.[PLAN_DATE],P.PLAN_SEQ,W.[SEQ],W.[MATERIAL_CODE] ");
}
List<DataParameter> parameters = new List<DataParameter>();
parameters.Add(new DataParameter("workcellcode", workcellcode));
using (var session = AppDataFactory.CreateMainSession())
{
return session.GetList<WorkOrder>(sql.ToString(), parameters.ToArray()).ToList();
}
}
catch(Exception ex)
{
throw ex;
}
}
/// <summary>
/// 获取指定工序的生产计划清单
/// </summary>
/// <param name="workcellcode">工序编码</param>
/// <param name="count">数量</param>
/// <param name="filter">过滤选项:0全部;1隐藏挂起;2只看挂起</param>
/// <returns></returns>
public List<WorkOrder> GetOrderUnPrinted(string routecode, int filter = 0, int count = 20)
{
try
{
StringBuilder sql = new StringBuilder();
sql.AppendFormat("SELECT TOP {0} W.[PID]\r\n", count);
sql.AppendFormat(" ,W.[ORDERPLANID] ");
sql.AppendFormat(" ,W.[ORDERPLAN_NO] ");
sql.AppendFormat(" ,W.[ORDER_TYPE] ");
sql.AppendFormat(" ,W.[SEQ] ");
sql.AppendFormat(" ,W.[MATERIAL_CODE] ");
sql.AppendFormat(" ,M.[MATERIAL_NAME] ");
sql.AppendFormat(" ,W.[PBOM_CODE] ");
sql.AppendFormat(" ,W.[QTY] ");
sql.AppendFormat(" ,W.[COMPLETE_QTY] ");
sql.AppendFormat(" ,W.[PLAN_DATE] ");
sql.AppendFormat(" ,W.[SHIFT_CODE] ");
sql.AppendFormat(" ,W.[WORKCENTER_CODE] ");
sql.AppendFormat(" ,W.[WORKCENTER_NAME] ");
sql.AppendFormat(" ,W.[WORKCELL_CODE] ");
sql.AppendFormat(" ,W.[WORKCELL_NAME] ");
sql.AppendFormat(" ,W.[WORKLOC_CODE] ");
sql.AppendFormat(" ,W.[REMARK] ");
sql.AppendFormat(" ,W.[EQPT_NAME] ");
sql.AppendFormat(" ,W.[EQPT_CODE] ");
sql.AppendFormat(" ,W.[STATE] ");
sql.AppendFormat(" ,W.[MOULD_CODE] ");
sql.AppendFormat(" ,W.[PRI] ");
sql.AppendFormat(" ,W.[UPDATEDATE] ");
sql.AppendFormat(" ,W.[PRINTED] ");
sql.AppendFormat(" ,P.[IGNORE_FISBREAK] ");
sql.AppendFormat(" ,P.[FIS_ASMSETCODE] ");
sql.AppendFormat(" FROM [T_PP_WORKORDER] AS W WITH(NOLOCK) ");
sql.AppendFormat(" LEFT JOIN [T_PP_ORDERPLAN] AS P WITH(NOLOCK) ");
sql.AppendFormat(" ON P.[PID]=W.[ORDERPLANID] ");
sql.AppendFormat(" LEFT JOIN [T_MD_MATERIAL] AS M WITH(NOLOCK) ");
sql.AppendFormat(" ON W.[MATERIAL_CODE]=M.[MATERIAL_CODE] ");
sql.AppendFormat(" WHERE P.[ROUTE_CODE]=@routecode ");
sql.AppendFormat(" AND W.[PRINTED]='0' ");
switch (filter)
{
case 1:
{
sql.AppendFormat(" AND W.[STATE]<>4 ");
break;
}
case 2:
{
sql.AppendFormat(" AND W.[STATE]=4 ");
break;
}
}
sql.AppendFormat(" ORDER BY W.[UPDATEDATE],W.[PRI],W.[PLAN_DATE],P.PLAN_SEQ,W.[SEQ],W.[MATERIAL_CODE] ");
List<DataParameter> parameters = new List<DataParameter>();
parameters.Add(new DataParameter("routecode", routecode));
using (var session = AppDataFactory.CreateMainSession())
{
return session.GetList<WorkOrder>(sql.ToString(), parameters.ToArray()).ToList();
}
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 获取指定工序的待完成计划数量
/// </summary>
/// <param name="workcellcode">工序编码</param>
/// <param name="shift">不指定班次则查询全部计划</param>
/// <param name="date">不指定班次则无需输入日期</param>
/// <returns></returns>
public int GetOrderCountInCell(string workcellcode,string shift,DateTime date)
{
try
{
List<DataParameter> parameters = new List<DataParameter>();
StringBuilder sql = new StringBuilder();
sql.AppendFormat("SELECT COUNT(*) ");
sql.AppendFormat(" FROM [T_PP_WORKORDER] WITH(NOLOCK) ");
sql.AppendFormat(" WHERE [WORKCELL_CODE]=@workcellcode ");
sql.AppendFormat(" AND [STATE]<>4");
if (!string.IsNullOrWhiteSpace(shift))
{
sql.AppendFormat(" AND [SHIFT_CODE]=@shift");
parameters.Add(new DataParameter("shift", shift));
//sql.AppendFormat(" AND DATEDIFF(DAY,[PLAN_DATE],@date)=0");
//parameters.Add(new DataParameter("date", date));
sql.AppendFormat(" AND [PLAN_DATE] BETWEEN @date1 AND @date2");
parameters.Add(new DataParameter("date1", date.Date));
parameters.Add(new DataParameter("date2", date.Date.AddDays(1)));
}
parameters.Add(new DataParameter("workcellcode", workcellcode));
using (var session = AppDataFactory.CreateMainSession())
{
return (int)session.ExecuteSqlScalar(sql.ToString(), parameters.ToArray());
}
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取查询语句
/// <summary>
/// 获取查询语句
/// </summary>
/// <param name="user">查询条件</param>
/// <param name="parameters">参数</param>
/// <returns>查询语句</returns>
private string GetQuerySql(WorkOrder condition, ref List<DataParameter> parameters)
{
StringBuilder sqlBuilder = new StringBuilder();
StringBuilder whereBuilder = new StringBuilder();
try
{
//构成查询语句
sqlBuilder.Append("SELECT PID,ORDERPLANID,ORDERPLAN_NO,ORDER_TYPE,SEQ,MATERIAL_CODE,PBOM_CODE,QTY,COMPLETE_QTY,PLAN_DATE,SHIFT_CODE,WORKCENTER_CODE,WORKCENTER_NAME,WORKCELL_CODE,WORKCELL_NAME,WORKLOC_CODE,REMARK,EQPT_NAME,EQPT_CODE,STATE ");
sqlBuilder.Append("FROM T_PP_WORKORDER WITH(NOLOCK) ");
whereBuilder.Append(" AND FLGDEL<> '1' ");
//查询条件
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(WorkOrder info)
{
DataTable dt = null;
string sql = null;
List<DataParameter> parameters = new List<DataParameter>();
try
{
//构成查询语句
sql = this.GetQuerySql(info, ref parameters);
using (IDataSession session = AppDataFactory.CreateMainSession())
{
dt = session.GetTable(sql, parameters.ToArray());
dt.TableName = "WorkOrder";
}
return dt;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 信息是否重复
/// <summary>
/// 判断名称是否存在
/// </summary>
/// <param name="info"></param>
/// <returns>true:已存在;fasel:不存在。</returns>
public bool Exists(WorkOrder info)
{
StringBuilder sqlBuilder = new StringBuilder();
StringBuilder whereBuilder = new StringBuilder();
List<DataParameter> parameters = new List<DataParameter>();
int count = 0;
try
{
sqlBuilder.Append("SELECT COUNT(0) FROM T_PP_WORKORDER WITH(NOLOCK) ");
if (info.PID == null)
{
info.PID = "";
}
whereBuilder.Append(" AND PID <> @PID ");
parameters.Add(new DataParameter { ParameterName = "PID", DataType = DbType.String, Value = info.PID });
//添加进行无重复字段判断代码
if (whereBuilder.Length > 0)
{
sqlBuilder.Append(" WHERE " + whereBuilder.ToString().Substring(4));
}
using (IDataSession session = AppDataFactory.CreateMainSession())
{
count = Convert.ToInt32(session.ExecuteSqlScalar(sqlBuilder.ToString(), parameters.ToArray()));
}
return count > 0;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 插入信息
/// <summary>
/// 插入信息(单表)
/// </summary>
/// <param name="">信息</param>
/// <returns>插入行数</returns>
public int Insert(WorkOrder info)
{
try
{
if (BaseSession != null)
{
return BaseSession.Insert<WorkOrder>(info);
}
using (IDataSession session = AppDataFactory.CreateMainSession())
{
//插入基本信息
return session.Insert<WorkOrder>(info);
}
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 更新信息
/// <summary>
/// 更新信息
/// </summary>
/// <param name=""></param>
/// <returns>更新行数</returns>
public int Update(WorkOrder info)
{
int count = 0;
try
{
using (IDataSession session = AppDataFactory.CreateMainSession())
{
//更新基本信息
count = session.Update<WorkOrder>(info);
}
return count;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 逻辑删除
/// <summary>
/// 逻辑删除信息
/// </summary>
/// <param name=""></param>
/// <returns>删除个数</returns>
public int Delete(WorkOrder info)
{
StringBuilder sqlBuilder = new StringBuilder();
List<DataParameter> parameters = new List<DataParameter>();
int count = 0;
try
{
using (IDataSession session = AppDataFactory.CreateMainSession())
{
//删除基本信息
sqlBuilder.Append("UPDATE T_PP_WORKORDER ");
sqlBuilder.Append("SET FLGDEL = '1' ");
sqlBuilder.Append("WHERE PID = @PID ");
parameters.Add(new DataParameter { ParameterName = "PID", DataType = DbType.String, Value = info.PID });
count = session.ExecuteSql(sqlBuilder.ToString(), parameters.ToArray());
}
return count;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
/// <summary>
/// 删除派工单
/// </summary>
/// <param name="entity"></param>
public void BatchDeleteByOrderPlan(WorkOrder entity)
{
try
{
string deleteSql = string.Format("delete from T_PP_WORKORDER where ORDERPLANID='{0}' ", entity.ORDERPLANID);
this.BaseSession.ExecuteSql(deleteSql, new List<DataParameter>().ToArray());
}
catch (Exception ex)
{
throw ex;
}
}
#region 导入
public ImportMessage GetImportData(List<WorkOrder> list)
{
ImportMessage em = new ImportMessage();
List<DataParameter> parameters = new List<DataParameter>();
try
{
using (IDataSession session = AppDataFactory.CreateMainSession())
{
//设置祖先对象数据会话
session.OpenTs();
foreach (WorkOrder info in list)
{
if (info.IsNewInfo)
{
//插入信息
int count = session.Insert<WorkOrder>(info);
em.insertNum++;
}
else
{
//更新信息
int count = session.Update<WorkOrder>(info);
em.updateNum++;
}
}
session.CommitTs();
}
}
catch (Exception ex)
{
throw ex;
}
return em;
}
#endregion
/// <summary>
/// 获取指定工位正在执行的派工单
/// </summary>
/// <param name="workloccode"></param>
/// <returns></returns>
public WorkOrder GetWorkingOrderInLoc(string workloccode,string mouldcode)
{
try
{
List<DataParameter> parameters = new List<DataParameter>();
StringBuilder sql = new StringBuilder();
sql.AppendLine("SELECT O.* ");
sql.AppendLine(" ,P.[IGNORE_FISBREAK] ");
sql.AppendLine(" ,P.[FIS_ASMSETCODE] ");
sql.AppendLine(" FROM [T_PP_WORKORDER] AS O WITH(NOLOCK) ");
sql.AppendLine(" LEFT JOIN [T_PP_ORDERPLAN] AS P WITH(NOLOCK) ");
sql.AppendLine(" ON P.[PID]=O.[ORDERPLANID] ");
sql.AppendLine(" WHERE O.[WORKLOC_CODE]=@workloccode ");
sql.AppendLine(" AND O.[MOULD_CODE]=@mouldcode ");
sql.AppendLine(" AND O.[STATE]='2' "); //工单状态为执行中
parameters.Add(new DataParameter("workloccode", workloccode));
parameters.Add(new DataParameter("mouldcode", mouldcode));
using (var session = AppDataFactory.CreateMainSession())
{
return session.Get<WorkOrder>(sql.ToString(), parameters.ToArray());
}
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 获取第一条匹配的派工单
/// </summary>
/// <param name="workcellcode">工序</param>
/// <param name="productmaterial">产品物料号</param>
/// <returns></returns>
public WorkOrder GetFirstMatchOrder(string workcellcode, string productmaterial,string planpid="")
{
List<DataParameter> parameters = new List<DataParameter>();
StringBuilder sql = new StringBuilder();
sql.AppendLine("SELECT TOP 1 O.* ");
sql.AppendLine(" ,P.[IGNORE_FISBREAK] ");
sql.AppendLine(" ,P.[FIS_ASMSETCODE] ");
sql.AppendLine(" FROM [T_PP_WORKORDER] AS O WITH(NOLOCK) ");
sql.AppendLine(" LEFT JOIN [T_PP_ORDERPLAN] AS P WITH(NOLOCK) ");
sql.AppendLine(" ON P.[PID]=O.[ORDERPLANID] ");
sql.AppendLine(" WHERE O.[WORKCELL_CODE]=@workcellcode ");
if (!string.IsNullOrWhiteSpace(planpid))
{
sql.AppendLine(" AND O.[ORDERPLANID]=@planpid");
parameters.Add(new DataParameter("planpid", planpid));
}
sql.AppendLine(" AND (EXISTS (SELECT 1 ");
sql.AppendLine(" FROM T_MD_PBOM_ITEM AS I ");
sql.AppendLine(" WHERE O.PBOM_CODE = I.PBOM_CODE ");
sql.AppendLine(" AND I.FLGDEL = '0' ");
sql.AppendLine(" AND I.MATERIAL_CODE = @materialcode) ");
sql.AppendLine(" OR O.[MATERIAL_CODE]=@materialcode) ");
sql.AppendLine(" AND (O.[STATE]='0' OR O.[STATE]='1') ");
sql.AppendLine(" ORDER BY O.UPDATEDATE,O.PRI,O.PLAN_DATE,P.PLAN_SEQ,SEQ "); //排序为 FIS优先、日期正序、顺序号正序
parameters.Add(new DataParameter("workcellcode", workcellcode));
parameters.Add(new DataParameter("materialcode", productmaterial));
using (var session = AppDataFactory.CreateMainSession())
{
return session.Get<WorkOrder>(sql.ToString(), parameters.ToArray());
}
}
/// <summary>
/// 获取指定工位第一条的派工单
/// </summary>
/// <param name="workloccode"></param>
/// <returns></returns>
public WorkOrder GetFirstOrderInLoc(string workcellcode, string mouldcode)
{
try
{
List<DataParameter> parameters = new List<DataParameter>();
StringBuilder sql = new StringBuilder();
//sql.AppendLine("SELECT TOP 1 W.* ");
//sql.AppendLine(" ,P.[IGNORE_FISBREAK] ");
//sql.AppendFormat(" FROM [T_PP_WORKORDER] AS W ");
//sql.AppendFormat(" LEFT JOIN [T_PP_ORDERPLAN] AS P ");
//sql.AppendFormat(" ON P.[PID]=W.[ORDERPLANID] ");
//sql.AppendFormat(" LEFT JOIN [T_MD_MATERIAL] AS M ");
//sql.AppendFormat(" ON W.[MATERIAL_CODE]=M.[MATERIAL_CODE] ");
//sql.AppendFormat(" WHERE W.[WORKCELL_CODE]=@workcellcode ");
//sql.AppendLine(" AND W.[STATE]<>'4' AND W.[STATE]<>'2' ");
//sql.AppendFormat(" ORDER BY W.[PRI],W.[PLAN_DATE],P.PLAN_SEQ,W.[SEQ],W.[MATERIAL_CODE] ");
//parameters.Add(new DataParameter("workcellcode", workcellcode));
//parameters.Add(new DataParameter("mouldcode", mouldcode));
if (workcellcode == "BRIM_WELDING_BC316")
{
sql.AppendFormat("SELECT TOP 1 A.[PID], A.[ORDERPLANID], A.[ORDERPLAN_NO], A.[ORDER_TYPE], A.[SEQ], A.[MATERIAL_CODE], A.[MATERIAL_NAME], A.[PBOM_CODE], A.[QTY], A.[COMPLETE_QTY], A.[PLAN_DATE], A.[SHIFT_CODE], A.[WORKCENTER_CODE], A.[WORKCENTER_NAME], A.[WORKCELL_CODE], A.[WORKCELL_NAME], A.[WORKLOC_CODE], A.[REMARK], A.[EQPT_NAME], A.[EQPT_CODE], A.[STATE], A.[MOULD_CODE], A.[PRI], A.[UPDATEDATE], A.[IGNORE_FISBREAK], A.[FIS_ASMSETCODE] FROM ( ");
sql.AppendFormat("SELECT TOP {0} W.[PID]\r\n", 12);
}
else
{
sql.AppendFormat("SELECT TOP {0} W.[PID]\r\n", 1);
}
sql.AppendFormat(" ,W.[ORDERPLANID] ");
sql.AppendFormat(" ,W.[ORDERPLAN_NO] ");
sql.AppendFormat(" ,W.[ORDER_TYPE] ");
sql.AppendFormat(" ,W.[SEQ] ");
sql.AppendFormat(" ,W.[MATERIAL_CODE] ");
sql.AppendFormat(" ,M.[MATERIAL_NAME] ");
sql.AppendFormat(" ,W.[PBOM_CODE] ");
sql.AppendFormat(" ,W.[QTY] ");
sql.AppendFormat(" ,W.[COMPLETE_QTY] ");
sql.AppendFormat(" ,W.[PLAN_DATE] ");
sql.AppendFormat(" ,W.[SHIFT_CODE] ");
sql.AppendFormat(" ,W.[WORKCENTER_CODE] ");
sql.AppendFormat(" ,W.[WORKCENTER_NAME] ");
sql.AppendFormat(" ,W.[WORKCELL_CODE] ");
sql.AppendFormat(" ,W.[WORKCELL_NAME] ");
sql.AppendFormat(" ,W.[WORKLOC_CODE] ");
sql.AppendFormat(" ,W.[REMARK] ");
sql.AppendFormat(" ,W.[EQPT_NAME] ");
sql.AppendFormat(" ,W.[EQPT_CODE] ");
sql.AppendFormat(" ,W.[STATE] ");
sql.AppendFormat(" ,W.[MOULD_CODE] ");
sql.AppendFormat(" ,W.[PRI] ");
sql.AppendFormat(" ,W.[UPDATEDATE] ");
sql.AppendFormat(" ,P.[PLAN_SEQ] ");
sql.AppendFormat(" ,P.[IGNORE_FISBREAK] ");
sql.AppendFormat(" ,P.[FIS_ASMSETCODE] ");
sql.AppendFormat(" FROM [T_PP_WORKORDER] AS W WITH(NOLOCK) ");
sql.AppendFormat(" LEFT JOIN [T_PP_ORDERPLAN] AS P WITH(NOLOCK) ");
sql.AppendFormat(" ON P.[PID]=W.[ORDERPLANID] ");
sql.AppendFormat(" LEFT JOIN [T_MD_MATERIAL] AS M WITH(NOLOCK)");
sql.AppendFormat(" ON W.[MATERIAL_CODE]=M.[MATERIAL_CODE] ");
sql.AppendFormat(" WHERE W.[WORKCELL_CODE]=@workcellcode ");
sql.AppendFormat(" AND W.[STATE]<>4 and W.[STATE]<>2 ");
if (workcellcode == "BRIM_WELDING_BC316")
{
sql.AppendFormat(" ORDER BY W.ORDER_TYPE, W.[PLAN_DATE]) A ");
sql.AppendFormat(" ORDER BY A.[UPDATEDATE],A.[PRI],A.[PLAN_DATE],A.PLAN_SEQ,A.[SEQ],A.[MATERIAL_CODE] ");
}
else
{
sql.AppendFormat(" ORDER BY W.[UPDATEDATE],W.[PRI],W.[PLAN_DATE],P.PLAN_SEQ,W.[SEQ],W.[MATERIAL_CODE] ");
}
parameters.Add(new DataParameter("workcellcode", workcellcode));
using (var session = AppDataFactory.CreateMainSession())
{
return session.Get<WorkOrder>(sql.ToString(), parameters.ToArray());
}
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 获取指定工位第一条的派工单
/// </summary>
/// <param name="workloccode"></param>
/// <returns></returns>
public WorkOrder GetNewFirstOrderInLoc(string orderplan_pid, string mouldcode)
{
try
{
List<DataParameter> parameters = new List<DataParameter>();
StringBuilder sql = new StringBuilder();
sql.AppendLine("SELECT TOP 1 W.* ");
sql.AppendLine(" ,P.[IGNORE_FISBREAK] ");
sql.AppendFormat(" FROM [T_PP_WORKORDER] AS W ");
sql.AppendFormat(" LEFT JOIN [T_PP_ORDERPLAN] AS P ");
sql.AppendFormat(" ON P.[PID]=W.[ORDERPLANID] ");
sql.AppendFormat(" LEFT JOIN [T_MD_MATERIAL] AS M ");
sql.AppendFormat(" ON W.[MATERIAL_CODE]=M.[MATERIAL_CODE] ");
sql.AppendFormat(" WHERE W.[PID]=@orderplan_pid ");
sql.AppendLine(" AND W.[STATE]<>'4' ");
sql.AppendFormat(" ORDER BY W.[PRI],W.[PLAN_DATE],P.PLAN_SEQ,W.[SEQ],W.[MATERIAL_CODE] ");
parameters.Add(new DataParameter("orderplan_pid", orderplan_pid));
parameters.Add(new DataParameter("mouldcode", mouldcode));
using (var session = AppDataFactory.CreateMainSession())
{
return session.Get<WorkOrder>(sql.ToString(), parameters.ToArray());
}
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 获取工序下匹配的派工单
/// </summary>
/// <param name="workcellcode">工序</param>
/// <returns></returns>
public List<WorkOrder> GetMatchOrders(string workcellcode,string planpid="")
{
List<DataParameter> parameters = new List<DataParameter>();
StringBuilder sql = new StringBuilder();
sql.AppendLine("SELECT W.* ");
sql.AppendLine(" ,P.[IGNORE_FISBREAK] ");
sql.AppendLine(" ,P.[FIS_ASMSETCODE] ");
sql.AppendLine(" FROM [T_PP_WORKORDER] AS W WITH(NOLOCK) ");
sql.AppendLine(" LEFT JOIN [T_PP_ORDERPLAN] AS P WITH(NOLOCK) ");
sql.AppendLine(" ON P.[PID]=W.[ORDERPLANID] ");
sql.AppendLine(" WHERE W.SEQ = (SELECT TOP 1 SEQ ");
sql.AppendLine(" FROM [T_PP_WORKORDER] AS O WITH(NOLOCK) ");
sql.AppendLine(" LEFT JOIN [T_PP_ORDERPLAN] AS P1 WITH(NOLOCK) ");
sql.AppendLine(" ON P1.[PID]=O.[ORDERPLANID] ");
sql.AppendLine(" WHERE O.[WORKCELL_CODE]=@workcellcode ");
sql.AppendLine(" AND (O.[STATE]='0' OR O.[STATE]='1') ");
if (!string.IsNullOrWhiteSpace(planpid))
{
sql.AppendLine(" AND O.[ORDERPLANID]=@planpid");
}
sql.AppendLine(" ORDER BY O.UPDATEDATE,O.PRI,O.PLAN_DATE,P1.PLAN_SEQ,SEQ) ");//排序为 FIS优先、日期正序、计划顺序号、工单顺序号正序
sql.AppendLine(" AND W.[WORKCELL_CODE]=@workcellcode ");
sql.AppendLine(" AND (W.[STATE]='0' OR W.[STATE]='1') ");
if (!string.IsNullOrWhiteSpace(planpid))
{
sql.AppendLine(" AND W.[ORDERPLANID]=@planpid");
parameters.Add(new DataParameter("planpid", planpid));
}
parameters.Add(new DataParameter("workcellcode", workcellcode));
using (var session = AppDataFactory.CreateMainSession())
{
return session.GetList<WorkOrder>(sql.ToString(), parameters.ToArray()).ToList();
}
}
#region 改变派工单
/// <summary>
/// 改变派工单
/// </summary>
/// <param name="entity"></param>
public void ChangeByOrderPlan(WorkOrder entity)
{
if (this.BaseSession != null)
{
this.BaseSession.Update<WorkOrder>(entity);
}
else
{
using (IDataSession session = AppDataFactory.CreateMainSession())
{
session.Update<WorkOrder>(entity);
}
}
}
#endregion
/// <summary>
/// 获取派工单
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public WorkOrder GetworkOrderInfo(WorkOrder model)
{
string sql = null;
List<DataParameter> parameters = new List<DataParameter>();
try
{
sql = "SELECT TOP 1 * FROM T_PP_WORKORDER WITH(NOLOCK) WHERE STATE=0 ";
if (string.IsNullOrEmpty(model.ORDERPLANID) == false)
{
sql += " AND ORDERPLANID = @ORDERPLANID";
parameters.Add(new DataParameter("ORDERPLANID", model.ORDERPLANID));
}
if (BaseSession != null)
{
//获取信息
model = BaseSession.Get<WorkOrder>(sql, parameters.ToArray());
}
else
{
using (IDataSession session = AppDataFactory.CreateMainSession())
{
//获取信息
model = session.Get<WorkOrder>(sql, parameters.ToArray());
}
}
return model;
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "信息数据层-获取信息"
});
throw;
}
}
/// <summary>
/// 获取指定日期前的FIS计划顺序号
/// </summary>
/// <param name="plandate"></param>
/// <param name="workcentercode"></param>
/// <returns></returns>
public string GetLastFISSEQ(DateTime plandate, string workcentercode)
{
StringBuilder sql = new StringBuilder() ;
List<DataParameter> parameters = new List<DataParameter>();
try
{
sql.AppendLine("SELECT TOP 1 [PLAN_SEQ] ");
sql.AppendLine(" FROM [T_PP_ORDERPLAN] WITH(NOLOCK) ");
sql.AppendLine(" WHERE [PLANSOURCE]='0' ");
sql.AppendLine(" AND [PLAN_DATE]<@plandate ");
sql.AppendLine(" AND [WORKCENTER_CODE]=@workcentercode ");
sql.AppendLine(" ORDER BY [PLAN_DATE] DESC ");
parameters.Add(new DataParameter("plandate", plandate));
parameters.Add(new DataParameter("workcentercode", workcentercode));
using (IDataSession session = AppDataFactory.CreateMainSession())
{
//获取信息
var ret= session.ExecuteSqlScalar(sql.ToString(), parameters.ToArray());
if (ret != null)
{
return ret.ToString();
}
else
{
return "";
}
}
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "信息数据层-获取信息"
});
throw;
}
}
/// <summary>
/// 根据模架搜索工单
/// </summary>
/// <param name="mouldcode"></param>
/// <param name="workcellcode"></param>
public WorkOrder SearchByMould(string mouldcode, string workcellcode)
{
try
{
StringBuilder sql = new StringBuilder();
List<DataParameter> parameters = new List<DataParameter>();
sql.AppendLine("SELECT TOP 1 W.* ");
sql.AppendLine(" FROM T_PP_WORKORDER AS W WITH(NOLOCK) ");
sql.AppendLine(" LEFT JOIN [T_PP_ORDERPLAN] AS P WITH(NOLOCK) ");
sql.AppendLine(" ON P.[PID]=W.[ORDERPLANID] ");
sql.AppendLine(" LEFT JOIN T_MD_MATERIAL AS M WITH(NOLOCK) ");
sql.AppendLine(" ON M.MATERIAL_CODE=W.MATERIAL_CODE ");
sql.AppendLine(" LEFT JOIN T_QT_MATERIAL_BINDING AS MB WITH(NOLOCK) ");
sql.AppendLine(" ON MB.MATERIAL_CODE=M.MATERIAL_TYPE_CODE ");
sql.AppendLine(" AND MB.BINDING_TYPE='ASSY' ");
sql.AppendLine(" WHERE MB.TARGET_CODE=@mouldcode ");
sql.AppendLine(" AND W.WORKCELL_CODE=@workcellcode ");
sql.AppendLine(" AND (W.STATE='1' OR W.STATE='0') ");
sql.AppendLine(" ORDER BY W.UPDATEDATE,W.PRI,w.PLAN_DATE,P.PLAN_SEQ,W.SEQ ");
parameters.Add(new DataParameter("mouldcode", mouldcode));
parameters.Add(new DataParameter("workcellcode", workcellcode));
using (IDataSession session = AppDataFactory.CreateMainSession())
{
//获取信息
return session.Get<WorkOrder>(sql.ToString(), parameters.ToArray());
}
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "信息数据层-获取信息"
});
throw;
}
}
public List<WorkOrder> GetListByID(string[] orderid)
{
try
{
StringBuilder sql = new StringBuilder();
List<DataParameter> parameters = new List<DataParameter>();
string ids = string.Join("','", orderid);
sql.AppendFormat("SELECT * FROM T_PP_WORKORDER WITH(NOLOCK) WHERE PID IN ('{0}')", ids);
using (IDataSession session = AppDataFactory.CreateMainSession())
{
//获取信息
return session.GetList<WorkOrder>(sql.ToString(), parameters.ToArray()).ToList();
}
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "信息数据层-获取信息GetListByID"
});
throw;
}
}
/// <summary>
/// 批量更新
/// </summary>
/// <param name="orders"></param>
/// <returns></returns>
public int Update(List<WorkOrder> orders)
{
using (IDataSession session = AppDataFactory.CreateMainSession())
{
//获取信息
return session.Update(orders);
}
}
/// <summary>
/// 批量删除
/// </summary>
/// <param name="orders"></param>
/// <returns></returns>
public int Delete(List<WorkOrder> orders)
{
using (IDataSession session = AppDataFactory.CreateMainSession())
{
//获取信息
return session.Delete(orders);
}
}
public WorkOrder GetWorkingOrderWithProduct(string workcellcode, string productcode, string planpid = "")
{
List<DataParameter> parameters = new List<DataParameter>();
StringBuilder sql = new StringBuilder();
sql.AppendLine("SELECT TOP 1 O.* ");
sql.AppendLine(" ,P.[IGNORE_FISBREAK] ");
sql.AppendLine(" ,P.[FIS_ASMSETCODE] ");
sql.AppendLine(" FROM [T_PP_WORKORDER] AS O WITH(NOLOCK) ");
sql.AppendLine(" LEFT JOIN [T_PP_ORDERPLAN] AS P WITH(NOLOCK) ");
sql.AppendLine(" ON P.[PID]=O.[ORDERPLANID] ");
sql.AppendLine(" WHERE O.[WORKCELL_CODE]=@workcellcode ");
if (!string.IsNullOrWhiteSpace(planpid))
{
sql.AppendLine(" AND O.[ORDERPLANID]=@planpid");
parameters.Add(new DataParameter("planpid", planpid));
}
sql.AppendLine(" AND O.[REMARK]=@productcode");
sql.AppendLine(" AND (O.[STATE]='0' OR O.[STATE]='1') ");
sql.AppendLine(" ORDER BY O.UPDATEDATE,O.PRI,O.PLAN_DATE,P.PLAN_SEQ,SEQ "); //排序为 FIS优先、日期正序、顺序号正序
parameters.Add(new DataParameter("workcellcode", workcellcode));
parameters.Add(new DataParameter("productcode", productcode));
using (var session = AppDataFactory.CreateMainSession())
{
return session.Get<WorkOrder>(sql.ToString(), parameters.ToArray());
}
}
public int GetDayPlanCount(string workcentercode, DateTime date)
{
try
{
List<DataParameter> parameters = new List<DataParameter>();
StringBuilder sql = new StringBuilder();
sql.AppendLine("SELECT ISNULL(SUM(QTY),0) ");
sql.AppendLine(" FROM T_PP_ORDERPLAN WITH(NOLOCK) ");
sql.AppendLine(" WHERE WORKCENTER_CODE=@workcentercode ");
//sql.AppendLine(" AND DATEDIFF(DAY,PLAN_DATE,@date)=0 ");
sql.AppendFormat(" AND [PLAN_DATE] BETWEEN @date1 AND @date2");
parameters.Add(new DataParameter("date1", date.Date));
parameters.Add(new DataParameter("date2", date.Date.AddDays(1)));
parameters.Add(new DataParameter("workcentercode", workcentercode));
//parameters.Add(new DataParameter("date", date));
using (var session = AppDataFactory.CreateMainSession())
{
return (int)session.ExecuteSqlScalar(sql.ToString(), parameters.ToArray());
}
}
catch (Exception ex)
{
throw ex;
}
}
public int SetOrderPrinted(string orderpid)
{
List<DataParameter> parameters = new List<DataParameter>();
StringBuilder sql = new StringBuilder();
sql.AppendLine("UPDATE T_PP_WORKORDER SET PRINTED='1' WHERE PID=@orderpid");
parameters.Add(new DataParameter("orderpid", orderpid));
using (var session = AppDataFactory.CreateMainSession())
{
return session.ExecuteSql(sql.ToString(), parameters.ToArray());
}
}
public List<OrderPlan> GetLastFISPlan(string workcellcode, string routecode)
{
List<DataParameter> parameters = new List<DataParameter>();
StringBuilder sql = new StringBuilder();
sql.AppendLine("SELECT TOP 2 P.* ");
sql.AppendLine(" FROM T_PP_ORDERPLAN AS P WITH(NOLOCK) ");
sql.AppendLine(" LEFT JOIN T_PP_WORKORDER AS W WITH(NOLOCK) ");
sql.AppendLine(" ON W.ORDERPLAN_NO=P.PLAN_NO ");
sql.AppendLine(" WHERE P.PLANSOURCE='0' ");
sql.AppendLine(" AND P.ROUTE_CODE=@routecode ");
sql.AppendLine(" AND ((W.WORKCELL_CODE=@workcellcode ");
sql.AppendLine(" AND W.STATE='4') ");
sql.AppendLine(" OR W.WORKCELL_CODE<>@workcellcode) ");
sql.AppendLine(" ORDER BY P.PLAN_DATE DESC,P.PLAN_SEQ DESC,P.PLAN_NO DESC");
parameters.Add(new DataParameter("workcellcode", workcellcode));
parameters.Add(new DataParameter("routecode", routecode));
using (var session = AppDataFactory.CreateMainSession())
{
return session.GetList<OrderPlan>(sql.ToString(), parameters.ToArray()).ToList();
}
}
}
}