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.
1069 lines
43 KiB
1069 lines
43 KiB
6 months ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Linq;
|
||
|
using System.Text;
|
||
|
using QMAPP.FJC.Entity.FIS;
|
||
|
using System.Data;
|
||
|
using QMFrameWork.Data;
|
||
|
using QMFrameWork.Log;
|
||
|
using QMAPP.Entity;
|
||
|
using QMAPP.DAL;
|
||
|
using QMAPP.FJC.Entity.FileCopy.FIS;
|
||
|
|
||
|
namespace QMAPP.FJC.DAL.FIS
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// 门板计划管理
|
||
|
///
|
||
|
///
|
||
|
/// </summary>
|
||
|
public class PaoMoDoorPlankPlanDAL : BaseDAL
|
||
|
{
|
||
|
#region 获取信息
|
||
|
/// <summary>
|
||
|
/// 获取信息
|
||
|
/// </summary>
|
||
|
/// <param name="">条件</param>
|
||
|
/// <returns>信息</returns>
|
||
|
public PaoMoOrderPlan Get(PaoMoOrderPlan model)
|
||
|
{
|
||
|
string sql = null;
|
||
|
List<DataParameter> parameters = new List<DataParameter>();
|
||
|
try
|
||
|
{
|
||
|
sql = "SELECT * FROM T_PP_ORDERPLAN WHERE '1'='1'";
|
||
|
if (string.IsNullOrEmpty(model.PID) == false)
|
||
|
{
|
||
|
sql += " AND PID = @PID";
|
||
|
parameters.Add(new DataParameter("PID", model.PID));
|
||
|
}
|
||
|
if (string.IsNullOrEmpty(model.PLAN_NO) == false)
|
||
|
{
|
||
|
sql += " AND PLAN_NO = @PLAN_NO";
|
||
|
parameters.Add(new DataParameter("PLAN_NO", model.PLAN_NO));
|
||
|
}
|
||
|
|
||
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
||
|
{
|
||
|
//获取信息
|
||
|
model = session.Get<PaoMoOrderPlan>(sql, parameters.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(PaoMoOrderPlan 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 = "PLAN_DATE DESC,PLAN_SEQ DESC";
|
||
|
}
|
||
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
||
|
{
|
||
|
page = session.GetDataPage<PaoMoOrderPlan>(sql, parameters.ToArray(), page);
|
||
|
}
|
||
|
return page;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogManager.LogHelper.Error(new LogInfo()
|
||
|
{
|
||
|
ErrorInfo = ex,
|
||
|
Tag = ex.StackTrace,
|
||
|
Info = "公司信息数据层-获取列表"
|
||
|
});
|
||
|
throw;
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region 获取查询语句
|
||
|
/// <summary>
|
||
|
/// 获取查询语句
|
||
|
/// </summary>
|
||
|
/// <param name="user">查询条件</param>
|
||
|
/// <param name="parameters">参数</param>
|
||
|
/// <returns>查询语句</returns>
|
||
|
private string GetQuerySql(PaoMoOrderPlan condition, ref List<DataParameter> parameters)
|
||
|
{
|
||
|
StringBuilder sqlBuilder = new StringBuilder();
|
||
|
StringBuilder whereBuilder = new StringBuilder();
|
||
|
try
|
||
|
{
|
||
|
//构成查询语句
|
||
|
sqlBuilder.AppendLine(" SELECT DISTINCT O.PID ");
|
||
|
sqlBuilder.AppendLine(" ,O.FACTORY_CODE ");
|
||
|
sqlBuilder.AppendLine(" ,F.FACTORY_NAME ");
|
||
|
sqlBuilder.AppendLine(" ,O.PLAN_NO ");
|
||
|
sqlBuilder.AppendLine(" ,O.PLAN_SEQ ");
|
||
|
sqlBuilder.AppendLine(" ,O.PLAN_STATE ");
|
||
|
sqlBuilder.AppendLine(" ,O.MATERIAL_CODE ");
|
||
|
sqlBuilder.AppendLine(" ,M.MATERIAL_NAME ");
|
||
|
sqlBuilder.AppendLine(" ,O.MACHINECODDE ");
|
||
|
sqlBuilder.AppendLine(" ,O.PBOM_CODE ");
|
||
|
sqlBuilder.AppendLine(" ,O.ROUTE_CODE ");
|
||
|
sqlBuilder.AppendLine(" ,R.ROUTE_NAME ");
|
||
|
sqlBuilder.AppendLine(" ,O.REMARK ");
|
||
|
sqlBuilder.AppendLine(" ,O.QTY ");
|
||
|
sqlBuilder.AppendLine(" ,O.COMPLETE_QTY ");
|
||
|
sqlBuilder.AppendLine(" ,CONVERT(VARCHAR(19),O.PLAN_DATE,120) AS PLAN_DATE ");
|
||
|
sqlBuilder.AppendLine(" ,O.SHIFT_CODE ");
|
||
|
sqlBuilder.AppendLine(" ,P.PRODUCESHIFTNAME AS SHIFT_NAME ");
|
||
|
sqlBuilder.AppendLine(" ,O.PLANSOURCE ");
|
||
|
sqlBuilder.AppendLine(" ,O.PRODUCEREQUIRE ");
|
||
|
sqlBuilder.AppendLine(" ,O.CREATEUSER ");
|
||
|
sqlBuilder.AppendLine(" ,O.CREATEDATE ");
|
||
|
sqlBuilder.AppendLine(" ,O.UPDATEUSER ");
|
||
|
sqlBuilder.AppendLine(" ,O.UPDATEDATE ");
|
||
|
sqlBuilder.AppendLine(" ,O.IGNORE_FISBREAK ");
|
||
|
sqlBuilder.AppendLine(" ,O.FIS_ASMSETCODE ");
|
||
|
sqlBuilder.AppendLine(" ,O.STARTTIME AS STARTTIMEVIEW ");
|
||
|
sqlBuilder.AppendLine(" ,O.ENDTIME AS ENDTIMEVIEW");
|
||
|
sqlBuilder.AppendLine(" ,C.USERNAME AS CREATEUSERNAME ");
|
||
|
sqlBuilder.AppendLine(" ,U.USERNAME AS UPDATEUSERNAME ");
|
||
|
sqlBuilder.AppendLine(" FROM T_PP_ORDERPLAN O ");
|
||
|
|
||
|
//门板所需要的表T_PP_FISORDER
|
||
|
sqlBuilder.AppendLine(" LEFT JOIN T_PP_FISWITHPLAN W ON W.PLANID=O.PID ");
|
||
|
sqlBuilder.AppendLine(" LEFT JOIN T_PP_FISORDER A ON W.FISID=A.PID ");
|
||
|
sqlBuilder.AppendLine(" LEFT JOIN T_MD_FACTORY F ON F.FACTORY_CODE=O.FACTORY_CODE ");
|
||
|
sqlBuilder.AppendLine(" LEFT JOIN T_MD_MATERIAL M ON M.MATERIAL_CODE=O.MATERIAL_CODE ");
|
||
|
|
||
|
sqlBuilder.AppendLine(" LEFT JOIN T_MD_PBOM PB ON PB.MATERIAL_CODE=O.MATERIAL_CODE ");
|
||
|
sqlBuilder.AppendLine(" LEFT JOIN T_MD_MATERIAL_ROUTE MR ON MR.MATERIAL_CODE=PB.MATERIAL_CODE ");
|
||
|
sqlBuilder.AppendLine(" LEFT JOIN T_MD_PROCESS_ROUTE PR ON PR.ROUTE_CODE=MR.ROUTE_CODE ");
|
||
|
sqlBuilder.AppendLine(" LEFT JOIN T_MD_PROCESS_ROUTE_WORKCELL PRW ON PRW.ROUTE_CODE=PR.ROUTE_CODE ");
|
||
|
sqlBuilder.AppendLine(" LEFT JOIN T_MD_WORKCELL WC ON WC.WORKCELL_CODE=PRW.WORKCELL_CODE ");
|
||
|
sqlBuilder.AppendLine(" LEFT JOIN T_BD_PRODUCESHIFT P ON P.PRODUCESHIFTTCODE=O.SHIFT_CODE ");
|
||
|
sqlBuilder.AppendLine(" LEFT JOIN T_BD_PROCESS_ROUTE R ON R.ROUTE_CODE=O.ROUTE_CODE ");
|
||
|
sqlBuilder.AppendLine(" LEFT JOIN T_QM_USER C ON C.USERID=O.CREATEUSER ");
|
||
|
sqlBuilder.AppendLine(" LEFT JOIN T_QM_USER U ON U.USERID=O.UPDATEUSER ");
|
||
|
|
||
|
whereBuilder.AppendFormat(" AND O.WORKCENTER_CODE in (select distinct WORKCENTER from T_PP_ORDERINDENTITY where ORDER_TYPE IN ('{0}','DOORPLANK018D'))", condition.ORDER_TYPE);
|
||
|
|
||
|
//查询条件
|
||
|
if (string.IsNullOrEmpty(condition.FACTORY_CODE) == false)
|
||
|
{
|
||
|
whereBuilder.Append(" AND O.FACTORY_CODE = @FACTORY_CODE ");
|
||
|
parameters.Add(new DataParameter { ParameterName = "FACTORY_CODE", DataType = DbType.String, Value = condition.FACTORY_CODE });
|
||
|
}
|
||
|
if (string.IsNullOrEmpty(condition.PLAN_NO) == false)
|
||
|
{
|
||
|
whereBuilder.Append(" AND PLAN_NO = @PLAN_NO ");
|
||
|
parameters.Add(new DataParameter { ParameterName = "PLAN_NO", DataType = DbType.String, Value = condition.PLAN_NO });
|
||
|
}
|
||
|
if (string.IsNullOrEmpty(condition.PLAN_STATE) == false)
|
||
|
{
|
||
|
whereBuilder.Append(" AND O.PLAN_STATE = @PLAN_STATE ");
|
||
|
parameters.Add(new DataParameter { ParameterName = "PLAN_STATE", DataType = DbType.String, Value = condition.PLAN_STATE });
|
||
|
}
|
||
|
//物料号
|
||
|
if (string.IsNullOrEmpty(condition.MATERIAL_CODE) == false)
|
||
|
{
|
||
|
whereBuilder.Append(" AND O.MATERIAL_CODE = @MATERIAL_CODE ");
|
||
|
parameters.Add(new DataParameter { ParameterName = "MATERIAL_CODE", DataType = DbType.String, Value = condition.MATERIAL_CODE });
|
||
|
}
|
||
|
//工艺路线
|
||
|
if (string.IsNullOrEmpty(condition.ROUTE_CODE) == false)
|
||
|
{
|
||
|
whereBuilder.Append(" AND ROUTE_CODE = @ROUTE_CODE ");
|
||
|
parameters.Add(new DataParameter { ParameterName = "ROUTE_CODE", DataType = DbType.String, Value = condition.ROUTE_CODE });
|
||
|
}
|
||
|
//班次编码
|
||
|
if (string.IsNullOrEmpty(condition.SHIFT_CODE) == false)
|
||
|
{
|
||
|
whereBuilder.Append(" AND O.SHIFT_CODE = @SHIFT_CODE ");
|
||
|
parameters.Add(new DataParameter { ParameterName = "SHIFT_CODE", DataType = DbType.String, Value = condition.SHIFT_CODE });
|
||
|
}
|
||
|
//计划来源
|
||
|
if (string.IsNullOrEmpty(condition.PLANSOURCE) == false)
|
||
|
{
|
||
|
whereBuilder.Append(" AND O.PLANSOURCE = @PLANSOURCE ");
|
||
|
parameters.Add(new DataParameter { ParameterName = "PLANSOURCE", DataType = DbType.String, Value = condition.PLANSOURCE });
|
||
|
}
|
||
|
|
||
|
//if (string.IsNullOrEmpty(condition.PIDList) == false)
|
||
|
//{
|
||
|
// whereBuilder.Append(" AND O.PID IN ( " + condition.PIDList + ") ");
|
||
|
// parameters.Add(new DataParameter { ParameterName = "PIDList", DataType = DbType.String, Value = condition.PIDList });
|
||
|
//}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
//计划时间
|
||
|
if (condition.PLANTIMESTART != DateTime.MinValue)
|
||
|
{
|
||
|
whereBuilder.Append(" AND O.PLAN_DATE >= @PLANTIMESTART");
|
||
|
parameters.Add(new DataParameter { ParameterName = "PLANTIMESTART", DataType = DbType.String, Value = condition.PLANTIMESTART });
|
||
|
}
|
||
|
if (condition.PLANTIMEEND != DateTime.MinValue)
|
||
|
{
|
||
|
whereBuilder.Append(" AND O.PLAN_DATE <= @PLANTIMEEND");
|
||
|
parameters.Add(new DataParameter { ParameterName = "PLANTIMEEND", DataType = DbType.String, Value = condition.PLANTIMEEND });
|
||
|
}
|
||
|
|
||
|
|
||
|
if (whereBuilder.Length > 0)
|
||
|
{
|
||
|
sqlBuilder.Append(" WHERE " + whereBuilder.ToString().Substring(4));
|
||
|
}
|
||
|
return sqlBuilder.ToString();
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
/// <summary>
|
||
|
/// 为了修改计划顺序号用
|
||
|
/// </summary>
|
||
|
/// <param name="condition"></param>
|
||
|
/// <param name="parameters"></param>
|
||
|
/// <returns></returns>
|
||
|
private string GetQuerySqlForSeq(PaoMoOrderPlan condition, ref List<DataParameter> parameters)
|
||
|
{
|
||
|
StringBuilder sqlBuilder = new StringBuilder();
|
||
|
StringBuilder whereBuilder = new StringBuilder();
|
||
|
try
|
||
|
{
|
||
|
//构成查询语句
|
||
|
sqlBuilder.AppendLine(" SELECT DISTINCT O.PID ");
|
||
|
sqlBuilder.AppendLine(" ,O.FACTORY_CODE ");
|
||
|
sqlBuilder.AppendLine(" ,F.FACTORY_NAME ");
|
||
|
sqlBuilder.AppendLine(" ,O.PLAN_NO ");
|
||
|
sqlBuilder.AppendLine(" ,O.PLAN_SEQ ");
|
||
|
sqlBuilder.AppendLine(" ,O.PLAN_STATE ");
|
||
|
sqlBuilder.AppendLine(" ,O.MATERIAL_CODE ");
|
||
|
sqlBuilder.AppendLine(" ,M.MATERIAL_NAME ");
|
||
|
sqlBuilder.AppendLine(" ,O.MACHINECODDE ");
|
||
|
sqlBuilder.AppendLine(" ,O.PBOM_CODE ");
|
||
|
sqlBuilder.AppendLine(" ,O.ROUTE_CODE ");
|
||
|
sqlBuilder.AppendLine(" ,R.ROUTE_NAME ");
|
||
|
sqlBuilder.AppendLine(" ,O.REMARK ");
|
||
|
sqlBuilder.AppendLine(" ,O.QTY ");
|
||
|
sqlBuilder.AppendLine(" ,O.COMPLETE_QTY ");
|
||
|
sqlBuilder.AppendLine(" ,O.PLAN_DATE ");
|
||
|
sqlBuilder.AppendLine(" ,O.SHIFT_CODE ");
|
||
|
sqlBuilder.AppendLine(" ,P.PRODUCESHIFTNAME AS SHIFT_NAME ");
|
||
|
sqlBuilder.AppendLine(" ,O.PLANSOURCE ");
|
||
|
sqlBuilder.AppendLine(" ,O.PRODUCEREQUIRE ");
|
||
|
sqlBuilder.AppendLine(" ,O.CREATEUSER ");
|
||
|
sqlBuilder.AppendLine(" ,O.CREATEDATE ");
|
||
|
sqlBuilder.AppendLine(" ,O.UPDATEUSER ");
|
||
|
sqlBuilder.AppendLine(" ,O.UPDATEDATE ");
|
||
|
sqlBuilder.AppendLine(" ,O.IGNORE_FISBREAK ");
|
||
|
sqlBuilder.AppendLine(" ,O.FIS_ASMSETCODE ");
|
||
|
sqlBuilder.AppendLine(" ,O.STARTTIME AS STARTTIMEVIEW ");
|
||
|
sqlBuilder.AppendLine(" ,O.ENDTIME AS ENDTIMEVIEW");
|
||
|
sqlBuilder.AppendLine(" ,C.USERNAME AS CREATEUSERNAME ");
|
||
|
sqlBuilder.AppendLine(" ,U.USERNAME AS UPDATEUSERNAME ");
|
||
|
sqlBuilder.AppendLine(" FROM T_PP_ORDERPLAN O ");
|
||
|
|
||
|
//门板所需要的表T_PP_FISORDER
|
||
|
sqlBuilder.AppendLine(" LEFT JOIN T_PP_FISWITHPLAN W ON W.PLANID=O.PID ");
|
||
|
sqlBuilder.AppendLine(" LEFT JOIN T_PP_FISORDER A ON W.FISID=A.PID ");
|
||
|
sqlBuilder.AppendLine(" LEFT JOIN T_MD_FACTORY F ON F.FACTORY_CODE=O.FACTORY_CODE ");
|
||
|
sqlBuilder.AppendLine(" LEFT JOIN T_MD_MATERIAL M ON M.MATERIAL_CODE=O.MATERIAL_CODE ");
|
||
|
|
||
|
sqlBuilder.AppendLine(" LEFT JOIN T_MD_PBOM PB ON PB.MATERIAL_CODE=O.MATERIAL_CODE ");
|
||
|
sqlBuilder.AppendLine(" LEFT JOIN T_MD_MATERIAL_ROUTE MR ON MR.MATERIAL_CODE=PB.MATERIAL_CODE ");
|
||
|
sqlBuilder.AppendLine(" LEFT JOIN T_MD_PROCESS_ROUTE PR ON PR.ROUTE_CODE=MR.ROUTE_CODE ");
|
||
|
sqlBuilder.AppendLine(" LEFT JOIN T_MD_PROCESS_ROUTE_WORKCELL PRW ON PRW.ROUTE_CODE=PR.ROUTE_CODE ");
|
||
|
sqlBuilder.AppendLine(" LEFT JOIN T_MD_WORKCELL WC ON WC.WORKCELL_CODE=PRW.WORKCELL_CODE ");
|
||
|
sqlBuilder.AppendLine(" LEFT JOIN T_BD_PRODUCESHIFT P ON P.PRODUCESHIFTTCODE=O.SHIFT_CODE ");
|
||
|
sqlBuilder.AppendLine(" LEFT JOIN T_BD_PROCESS_ROUTE R ON R.ROUTE_CODE=O.ROUTE_CODE ");
|
||
|
sqlBuilder.AppendLine(" LEFT JOIN T_QM_USER C ON C.USERID=O.CREATEUSER ");
|
||
|
sqlBuilder.AppendLine(" LEFT JOIN T_QM_USER U ON U.USERID=O.UPDATEUSER ");
|
||
|
|
||
|
whereBuilder.AppendFormat(" AND O.WORKCENTER_CODE in (select distinct WORKCENTER from T_PP_ORDERINDENTITY where ORDER_TYPE='{0}')", condition.ORDER_TYPE);
|
||
|
|
||
|
//查询条件
|
||
|
if (string.IsNullOrEmpty(condition.FACTORY_CODE) == false)
|
||
|
{
|
||
|
whereBuilder.Append(" AND O.FACTORY_CODE = @FACTORY_CODE ");
|
||
|
parameters.Add(new DataParameter { ParameterName = "FACTORY_CODE", DataType = DbType.String, Value = condition.FACTORY_CODE });
|
||
|
}
|
||
|
if (string.IsNullOrEmpty(condition.PLAN_NO) == false)
|
||
|
{
|
||
|
whereBuilder.Append(" AND PLAN_NO = @PLAN_NO ");
|
||
|
parameters.Add(new DataParameter { ParameterName = "PLAN_NO", DataType = DbType.String, Value = condition.PLAN_NO });
|
||
|
}
|
||
|
//物料号
|
||
|
if (string.IsNullOrEmpty(condition.MATERIAL_CODE) == false)
|
||
|
{
|
||
|
whereBuilder.Append(" AND O.MATERIAL_CODE = @MATERIAL_CODE ");
|
||
|
parameters.Add(new DataParameter { ParameterName = "MATERIAL_CODE", DataType = DbType.String, Value = condition.MATERIAL_CODE });
|
||
|
}
|
||
|
//工艺路线
|
||
|
if (string.IsNullOrEmpty(condition.ROUTE_CODE) == false)
|
||
|
{
|
||
|
whereBuilder.Append(" AND ROUTE_CODE = @ROUTE_CODE ");
|
||
|
parameters.Add(new DataParameter { ParameterName = "ROUTE_CODE", DataType = DbType.String, Value = condition.ROUTE_CODE });
|
||
|
}
|
||
|
//班次编码
|
||
|
if (string.IsNullOrEmpty(condition.SHIFT_CODE) == false)
|
||
|
{
|
||
|
whereBuilder.Append(" AND O.SHIFT_CODE = @SHIFT_CODE ");
|
||
|
parameters.Add(new DataParameter { ParameterName = "SHIFT_CODE", DataType = DbType.String, Value = condition.SHIFT_CODE });
|
||
|
}
|
||
|
|
||
|
|
||
|
if (string.IsNullOrEmpty(condition.PIDList) == false)
|
||
|
{
|
||
|
whereBuilder.Append(" AND O.PID IN ( " + condition.PIDList + ") ");
|
||
|
//parameters.Add(new DataParameter { ParameterName = "PIDList", DataType = DbType.String, Value = condition.PIDList });
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
//计划时间
|
||
|
if (condition.PLANTIMESTART != DateTime.MinValue)
|
||
|
{
|
||
|
whereBuilder.Append(" AND O.PLAN_DATE >= @PLANTIMESTART");
|
||
|
parameters.Add(new DataParameter { ParameterName = "PLANTIMESTART", DataType = DbType.String, Value = condition.PLANTIMESTART });
|
||
|
}
|
||
|
if (condition.PLANTIMEEND != DateTime.MinValue)
|
||
|
{
|
||
|
whereBuilder.Append(" AND O.PLAN_DATE <= @PLANTIMEEND");
|
||
|
parameters.Add(new DataParameter { ParameterName = "PLANTIMEEND", DataType = DbType.String, Value = condition.PLANTIMEEND });
|
||
|
}
|
||
|
|
||
|
|
||
|
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="info"></param>
|
||
|
/// <returns>true:已存在;fasel:不存在。</returns>
|
||
|
public int ExistsOrderPlan(PaoMoOrderPlan model)
|
||
|
{
|
||
|
string PID = "";
|
||
|
int count = 0;
|
||
|
StringBuilder sqlBuilder = new StringBuilder();
|
||
|
|
||
|
try
|
||
|
{
|
||
|
if (string.IsNullOrEmpty(model.PID) == false)
|
||
|
{
|
||
|
PID = model.PID;
|
||
|
}
|
||
|
sqlBuilder.AppendLine("SELECT COUNT(*) FROM T_PP_ORDERPLAN ");
|
||
|
sqlBuilder.AppendLine($" WHERE PID <> '{model.PID}' AND PLAN_NO=@PLAN_NO");
|
||
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
||
|
{
|
||
|
count = Convert.ToInt32(session.ExecuteSqlScalar(sqlBuilder.ToString(),
|
||
|
new DataParameter { ParameterName = "PLAN_NO", Value = model.PLAN_NO }));
|
||
|
}
|
||
|
return count;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region 插入信息
|
||
|
/// <summary>
|
||
|
/// 插入信息(单表)
|
||
|
/// </summary>
|
||
|
/// <param name="">信息</param>
|
||
|
/// <returns>插入行数</returns>
|
||
|
public int Insert(PaoMoOrderPlan model)
|
||
|
{
|
||
|
int count = 0;
|
||
|
try
|
||
|
{
|
||
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
||
|
{
|
||
|
//插入基本信息
|
||
|
count = session.Insert<PaoMoOrderPlan>(model);
|
||
|
new PaoMoOrderPlanDAL().InsertOrderPlanTrace(session, model, "新增");
|
||
|
}
|
||
|
return count;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region 更新信息
|
||
|
/// <summary>
|
||
|
/// 更新信息
|
||
|
/// </summary>
|
||
|
/// <param name=""></param>
|
||
|
/// <returns>更新行数</returns>
|
||
|
public int Update(PaoMoOrderPlan model)
|
||
|
{
|
||
|
int count = 0;
|
||
|
try
|
||
|
{
|
||
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
||
|
{
|
||
|
//更新基本信息
|
||
|
count = session.Update<PaoMoOrderPlan>(model);
|
||
|
}
|
||
|
return count;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region 删除
|
||
|
/// <summary>
|
||
|
/// 删除信息
|
||
|
/// </summary>
|
||
|
/// <param name=""></param>
|
||
|
/// <returns>删除个数</returns>
|
||
|
//提交事务
|
||
|
public int Delete(PaoMoOrderPlan model)
|
||
|
{
|
||
|
int count = 0;
|
||
|
try
|
||
|
{
|
||
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
||
|
{
|
||
|
//删除基本信息
|
||
|
count = session.Delete<PaoMoOrderPlan>(model);
|
||
|
}
|
||
|
return count;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region 删除校验
|
||
|
/// <summary>
|
||
|
/// 删除校验
|
||
|
/// </summary>
|
||
|
/// <param name="model"></param>
|
||
|
/// <returns></returns>
|
||
|
public int DelCheck(PaoMoOrderPlan model)
|
||
|
{
|
||
|
int num = 0;
|
||
|
int state;
|
||
|
StringBuilder sqlBuilder = new StringBuilder();
|
||
|
StringBuilder sqlBuilder2 = new StringBuilder();
|
||
|
sqlBuilder.AppendLine(" SELECT COMPLETE_QTY ");
|
||
|
sqlBuilder.AppendLine(" FROM T_PP_ORDERPLAN ");
|
||
|
sqlBuilder.AppendLine(" WHERE PID = @PID ");
|
||
|
sqlBuilder2.AppendLine(" SELECT PLAN_STATE ");
|
||
|
sqlBuilder2.AppendLine(" FROM T_PP_ORDERPLAN ");
|
||
|
sqlBuilder2.AppendLine(" WHERE PID = @PID ");
|
||
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
||
|
{
|
||
|
num = Convert.ToInt32(session.ExecuteSqlScalar(sqlBuilder.ToString(), new DataParameter("PID", model.PID)));
|
||
|
state = Convert.ToInt32(session.ExecuteSqlScalar(sqlBuilder2.ToString(), new DataParameter("PID", model.PID)));
|
||
|
}
|
||
|
return num + state;
|
||
|
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region 发布
|
||
|
/// <summary>
|
||
|
/// 发布信息
|
||
|
/// </summary>
|
||
|
/// <param name=""></param>
|
||
|
/// <returns>发布个数</returns>
|
||
|
public int PutOut(PaoMoOrderPlan model, DataTable workOrderDt)
|
||
|
{
|
||
|
BaseSession = AppDataFactory.CreateMainSession();
|
||
|
IDbConnection dbConn = DbManager.MainConnectionInfo.Connection;
|
||
|
IDbTransaction ids = dbConn.BeginTransaction();
|
||
|
try
|
||
|
{
|
||
|
if (workOrderDt.Rows != null)
|
||
|
{
|
||
|
BaseSession.DbHelper.BulkCopyData(workOrderDt, "T_PP_WORKORDER", dbConn, ids);
|
||
|
ids.Commit();
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
ids.Rollback();
|
||
|
throw ex;
|
||
|
}
|
||
|
int count = 0;
|
||
|
int count2 = 0;
|
||
|
StringBuilder sqlBuilder = new StringBuilder();
|
||
|
StringBuilder sqlBuilder2 = new StringBuilder();
|
||
|
List<DataParameter> parameters = new List<DataParameter>();
|
||
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
||
|
{
|
||
|
sqlBuilder.AppendLine(" UPDATE T_PP_ORDERPLAN ");
|
||
|
sqlBuilder.AppendLine(" SET PLAN_STATE='1' ");
|
||
|
sqlBuilder.AppendLine(" WHERE PID = @PID ");
|
||
|
|
||
|
sqlBuilder2.AppendLine(" UPDATE T_PP_WORKORDER ");
|
||
|
sqlBuilder2.AppendLine(" SET STATE='1' ");
|
||
|
sqlBuilder2.AppendLine(" WHERE ORDERPLANID = @PID ");
|
||
|
|
||
|
//发布更新基本信息
|
||
|
parameters.Add(new DataParameter { ParameterName = "PID", DataType = DbType.String, Value = model.PID });
|
||
|
count = session.ExecuteSql(sqlBuilder.ToString(), parameters.ToArray());
|
||
|
count2 = session.ExecuteSql(sqlBuilder2.ToString(), parameters.ToArray());
|
||
|
}
|
||
|
return count;
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region 发布校验
|
||
|
/// <summary>
|
||
|
/// 发布校验
|
||
|
/// </summary>
|
||
|
/// <param name="model"></param>
|
||
|
/// <returns></returns>
|
||
|
public int PutOutCheck(PaoMoOrderPlan model)
|
||
|
{
|
||
|
int num = 0;
|
||
|
StringBuilder sqlBuilder = new StringBuilder();
|
||
|
|
||
|
sqlBuilder.AppendLine(" SELECT PLAN_STATE ");
|
||
|
sqlBuilder.AppendLine(" FROM T_PP_ORDERPLAN ");
|
||
|
sqlBuilder.AppendLine(" WHERE PID = @PID ");
|
||
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
||
|
{
|
||
|
num = Convert.ToInt32(session.ExecuteSqlScalar(sqlBuilder.ToString(), new DataParameter("PID", model.PID)));
|
||
|
}
|
||
|
return num;
|
||
|
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region 导入
|
||
|
public ImportMessage GetImportData(List<PaoMoOrderPlan> list)
|
||
|
{
|
||
|
ImportMessage em = new ImportMessage();
|
||
|
List<DataParameter> parameters = new List<DataParameter>();
|
||
|
try
|
||
|
{
|
||
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
||
|
{
|
||
|
//设置祖先对象数据会话
|
||
|
session.OpenTs();
|
||
|
foreach (PaoMoOrderPlan info in list)
|
||
|
{
|
||
|
if (info.IsNewInfo == true)
|
||
|
{
|
||
|
//插入信息
|
||
|
int count = session.Insert<PaoMoOrderPlan>(info);
|
||
|
new PaoMoOrderPlanDAL().InsertOrderPlanTrace(session, info, "新增");
|
||
|
em.insertNum++;
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//更新信息
|
||
|
int count = session.Update<PaoMoOrderPlan>(info);
|
||
|
new PaoMoOrderPlanDAL().InsertOrderPlanTrace(session, info, "修改");
|
||
|
em.updateNum++;
|
||
|
}
|
||
|
}
|
||
|
session.CommitTs();
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
return em;
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region 导入校验工厂区域信息是否匹配
|
||
|
///// <summary>
|
||
|
///// 导入校验工厂区域信息是否匹配
|
||
|
///// </summary>
|
||
|
///// <param name="plantmodel">工厂</param>
|
||
|
///// <param name="areamodel">区域</param>
|
||
|
///// <returns>结果</returns>
|
||
|
//public int ImportCheck(Plant plantmodel, Area areamodel)
|
||
|
//{
|
||
|
// int num = 0;
|
||
|
// StringBuilder sqlBuilder = new StringBuilder();
|
||
|
// try
|
||
|
// {
|
||
|
// sqlBuilder.AppendLine("SELECT COUNT(1) FROM T_BD_FACTORY ");
|
||
|
// sqlBuilder.AppendLine(" WHERE PID=@PID AND AREAID=@AREAID");
|
||
|
// using (IDataSession session = AppDataFactory.CreateMainSession())
|
||
|
// {
|
||
|
// num = Convert.ToInt32(session.ExecuteSqlScalar(sqlBuilder.ToString(), new DataParameter("PID", plantmodel.PID),
|
||
|
// new DataParameter { ParameterName = "AREAID", Value = areamodel.PID }));
|
||
|
// }
|
||
|
// return num;
|
||
|
// }
|
||
|
// catch (Exception ex)
|
||
|
// {
|
||
|
// throw ex;
|
||
|
// }
|
||
|
//}
|
||
|
#endregion
|
||
|
|
||
|
#region 获取导出的数据
|
||
|
/// <summary>
|
||
|
/// 获取导出的数据
|
||
|
/// </summary>
|
||
|
/// <param name="user">查询条件</param>
|
||
|
/// <returns>数据</returns>
|
||
|
public DataTable GetExportData(PaoMoOrderPlan model)
|
||
|
{
|
||
|
DataTable dt = null;
|
||
|
string sql = null;
|
||
|
List<DataParameter> parameters = new List<DataParameter>();
|
||
|
try
|
||
|
{
|
||
|
//构成查询语句
|
||
|
sql = this.GetQuerySql(model, ref parameters);
|
||
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
||
|
{
|
||
|
dt = session.GetTable(sql, parameters.ToArray());
|
||
|
dt.TableName = "DoorPlankPlanExp";
|
||
|
}
|
||
|
return dt;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region 获取流水号信息
|
||
|
/// <summary>
|
||
|
/// 获取流水号信息
|
||
|
/// </summary>
|
||
|
/// <param name="">条件</param>
|
||
|
/// <returns>信息</returns>
|
||
|
public int GetNum(PaoMoOrderPlan model)
|
||
|
{
|
||
|
int num = 0;
|
||
|
StringBuilder sqlBuilder = new StringBuilder();
|
||
|
try
|
||
|
{
|
||
|
sqlBuilder.AppendLine("SELECT count(*) FROM T_PP_ORDERPLAN ");
|
||
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
||
|
{
|
||
|
//获取数量信息
|
||
|
num = Convert.ToInt32(session.ExecuteSqlScalar(sqlBuilder.ToString()))+1;
|
||
|
}
|
||
|
return num;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogManager.LogHelper.Error(new LogInfo()
|
||
|
{
|
||
|
ErrorInfo = ex,
|
||
|
Tag = ex.StackTrace,
|
||
|
Info = "门板信息数据层-获取信息"
|
||
|
});
|
||
|
throw;
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 查询
|
||
|
/// </summary>
|
||
|
/// <param name="model"></param>
|
||
|
/// <returns></returns>
|
||
|
public OrderPlanSerial GetNumSerial(PaoMoOrderPlan model)
|
||
|
{
|
||
|
string sql = null;
|
||
|
OrderPlanSerial serial = new OrderPlanSerial();
|
||
|
List<DataParameter> parameters = new List<DataParameter>();
|
||
|
try
|
||
|
{
|
||
|
sql = "SELECT * FROM T_PP_ORDERPLANSERIAL WHERE '1'='1'";
|
||
|
if (string.IsNullOrEmpty(model.ORDER_TYPE) == false)
|
||
|
{
|
||
|
sql += " AND SERIAL_TYPE = @SERIAL_TYPE";
|
||
|
parameters.Add(new DataParameter("SERIAL_TYPE", model.ORDER_TYPE));
|
||
|
}
|
||
|
if (model.PLAN_DATE != DateTime.MinValue)
|
||
|
{
|
||
|
sql += " AND SERIAL_DATE = @SERIAL_DATE";
|
||
|
parameters.Add(new DataParameter("SERIAL_DATE", model.PLAN_DATE.ToString("yyyyMMdd")));
|
||
|
}
|
||
|
|
||
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
||
|
{
|
||
|
//获取信息
|
||
|
serial = session.Get<OrderPlanSerial>(sql, parameters.ToArray());
|
||
|
}
|
||
|
return serial;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogManager.LogHelper.Error(new LogInfo()
|
||
|
{
|
||
|
ErrorInfo = ex,
|
||
|
Tag = ex.StackTrace,
|
||
|
Info = "门板信息数据层-获取信息"
|
||
|
});
|
||
|
throw;
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 更新流水号
|
||
|
/// </summary>
|
||
|
/// <param name="model"></param>
|
||
|
/// <returns></returns>
|
||
|
public int UpdateSerial(OrderPlanSerial model)
|
||
|
{
|
||
|
int count = 0;
|
||
|
try
|
||
|
{
|
||
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
||
|
{
|
||
|
//更新基本信息
|
||
|
count = session.Update<OrderPlanSerial>(model);
|
||
|
}
|
||
|
return count;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 插入信息
|
||
|
/// </summary>
|
||
|
/// <param name="">信息</param>
|
||
|
/// <returns>插入行数</returns>
|
||
|
public int InsertSerial(OrderPlanSerial model)
|
||
|
{
|
||
|
int count = 0;
|
||
|
try
|
||
|
{
|
||
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
||
|
{
|
||
|
//插入基本信息
|
||
|
count = session.Insert<OrderPlanSerial>(model);
|
||
|
}
|
||
|
return count;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
#region 整车插入信息
|
||
|
public int InsertDoorPlan(List<PaoMoOrderPlan> list)
|
||
|
{
|
||
|
ImportMessage em = new ImportMessage();
|
||
|
int count=0;
|
||
|
List<DataParameter> parameters = new List<DataParameter>();
|
||
|
try
|
||
|
{
|
||
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
||
|
{
|
||
|
//设置祖先对象数据会话
|
||
|
session.OpenTs();
|
||
|
foreach (PaoMoOrderPlan info in list)
|
||
|
{
|
||
|
count = session.Insert<PaoMoOrderPlan>(info);
|
||
|
new PaoMoOrderPlanDAL().InsertOrderPlanTrace(session, info, "新增");
|
||
|
}
|
||
|
session.CommitTs();
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
return count;
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region 获取上一条FIS计划
|
||
|
/// <summary>
|
||
|
/// 获取上一条FIS计划
|
||
|
/// </summary>
|
||
|
/// <param name="position"></param>
|
||
|
/// <returns></returns>
|
||
|
public PaoMoOrderPlan GetLastFIS(PaoMoOrderPlan position)
|
||
|
{
|
||
|
StringBuilder sql = new StringBuilder();
|
||
|
List<DataParameter> parameters = new List<DataParameter>();
|
||
|
try
|
||
|
{
|
||
|
sql.AppendLine("SELECT TOP 1 * ");
|
||
|
sql.AppendLine(" FROM T_PP_ORDERPLAN ");
|
||
|
sql.AppendLine(" WHERE PLAN_DATE<=@plandate ");
|
||
|
sql.AppendLine(" AND PLAN_SEQ<@planseq ");
|
||
|
sql.AppendLine("AND (PLANSOURCE='0' OR PLANSOURCE='2') ");
|
||
|
sql.AppendLine(" ORDER BY PLAN_DATE DESC,PLAN_SEQ DESC ");
|
||
|
|
||
|
parameters.Add(new DataParameter("plandate", position.PLAN_DATE));
|
||
|
parameters.Add(new DataParameter("planseq", position.PLAN_SEQ));
|
||
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
||
|
{
|
||
|
return session.Get<PaoMoOrderPlan>(sql.ToString(), parameters.ToArray());
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogManager.LogHelper.Error(new LogInfo()
|
||
|
{
|
||
|
ErrorInfo = ex,
|
||
|
Tag = ex.StackTrace,
|
||
|
Info = "数据层门板计划管理-获取上一条FIS计划"
|
||
|
});
|
||
|
throw;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region 获取指定FIS计划位置存在的最大插单序号
|
||
|
/// <summary>
|
||
|
/// 获取指定FIS计划位置存在的最大插单序号
|
||
|
/// </summary>
|
||
|
/// <param name="model"></param>
|
||
|
/// <returns></returns>
|
||
|
public int GetMaxFISInsertNum(PaoMoOrderPlan model)
|
||
|
{
|
||
|
StringBuilder sql = new StringBuilder();
|
||
|
List<DataParameter> parameters = new List<DataParameter>();
|
||
|
try
|
||
|
{
|
||
|
sql.AppendLine("SELECT ISNULL(MAX(PLAN_SEQ),'0')");
|
||
|
sql.AppendLine("FROM T_PP_ORDERPLAN ");
|
||
|
sql.AppendLine("WHERE PLAN_SEQ LIKE @planseq+'%' ");
|
||
|
sql.AppendLine("AND PLANSOURCE='2' ");
|
||
|
sql.AppendLine("AND PLAN_DATE=@plandate ");
|
||
|
|
||
|
parameters.Add(new DataParameter("plandate", model.PLAN_DATE));
|
||
|
parameters.Add(new DataParameter("planseq", model.PLAN_SEQ));
|
||
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
||
|
{
|
||
|
var maxseq= session.ExecuteSqlScalar(sql.ToString(), parameters.ToArray()).ToString();
|
||
|
if (string.Equals(maxseq,"0"))
|
||
|
{
|
||
|
return 0;
|
||
|
}
|
||
|
if (maxseq.Split('-').Length > 1)
|
||
|
{
|
||
|
return int.Parse(maxseq.Split('-')[1]);
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return 0;
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogManager.LogHelper.Error(new LogInfo()
|
||
|
{
|
||
|
ErrorInfo = ex,
|
||
|
Tag = ex.StackTrace,
|
||
|
Info = "数据层门板计划管理-获取上一条FIS计划"
|
||
|
});
|
||
|
throw;
|
||
|
}
|
||
|
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region 获取列表(为了修改顺序号使用)
|
||
|
/// <summary>
|
||
|
/// 获取列表
|
||
|
/// </summary>
|
||
|
/// <param name="condition">条件</param>
|
||
|
/// <param name="page">数据页</param>
|
||
|
/// <returns>数据页</returns>
|
||
|
public DataPage GetDoorPlankPlanList(PaoMoOrderPlan condition, DataPage page)
|
||
|
{
|
||
|
string sql = null;
|
||
|
List<DataParameter> parameters = new List<DataParameter>();
|
||
|
try
|
||
|
{
|
||
|
#region 排序
|
||
|
//分页关键字段及排序
|
||
|
page.KeyName = "PID";
|
||
|
page.SortExpression = "UPDATEDATE DESC";
|
||
|
#endregion
|
||
|
sql = this.GetQuerySqlForSeq(condition, ref parameters);
|
||
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
||
|
{
|
||
|
page = session.GetDataPage<PaoMoOrderPlan>(sql, parameters.ToArray(), page);
|
||
|
}
|
||
|
return page;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogManager.LogHelper.Error(new LogInfo()
|
||
|
{
|
||
|
ErrorInfo = ex,
|
||
|
Tag = ex.StackTrace,
|
||
|
Info = "信息数据层-获取列表"
|
||
|
});
|
||
|
throw;
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region 更新计划顺序号
|
||
|
/// <summary>
|
||
|
/// 更新计划顺序号
|
||
|
/// </summary>
|
||
|
/// <param name="model"></param>
|
||
|
/// <returns></returns>
|
||
|
public int UpdateSeq(PaoMoOrderPlan model)
|
||
|
{
|
||
|
int count = 0;
|
||
|
StringBuilder sql = new StringBuilder();
|
||
|
List<DataParameter> parameters = new List<DataParameter>();
|
||
|
try
|
||
|
{
|
||
|
sql.AppendLine("UPDATE T_PP_ORDERPLAN SET PLAN_SEQ =@PLAN_SEQ WHERE PID=@PID");
|
||
|
parameters.Add(new DataParameter("PLAN_SEQ", model.PLAN_SEQ));
|
||
|
parameters.Add(new DataParameter("PID", model.PID));
|
||
|
|
||
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
||
|
{
|
||
|
count= session.ExecuteSql(sql.ToString(), parameters.ToArray());
|
||
|
}
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogManager.LogHelper.Error(new LogInfo()
|
||
|
{
|
||
|
ErrorInfo = ex,
|
||
|
Tag = ex.StackTrace,
|
||
|
Info = "FIS 计划信息数据层-获取列表"
|
||
|
});
|
||
|
throw;
|
||
|
}
|
||
|
return Convert.ToInt32(count);
|
||
|
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
#region 获取门板计划使用的物料号成都
|
||
|
/// <summary>
|
||
|
/// 获取门板计划使用的物料号成都
|
||
|
/// </summary>
|
||
|
/// <param name="info"></param>
|
||
|
/// <returns></returns>
|
||
|
public List<FISAssembly> GetMaterialDoorPlanForCD(FISAssembly info)
|
||
|
{
|
||
|
string sql = null;
|
||
|
List<FISAssembly> list = new List<FISAssembly>();
|
||
|
StringBuilder sqlBuilder = new StringBuilder();
|
||
|
StringBuilder whereBuilder = new StringBuilder();
|
||
|
List<DataParameter> parameters = new List<DataParameter>();
|
||
|
try
|
||
|
{
|
||
|
sqlBuilder.AppendLine(" SELECT Id ");
|
||
|
sqlBuilder.AppendLine(" ,Name ");
|
||
|
sqlBuilder.AppendLine(" ,Description ");
|
||
|
sqlBuilder.AppendLine(" ,CarModel ");
|
||
|
sqlBuilder.AppendLine(" ,ProjectCode ");
|
||
|
sqlBuilder.AppendLine(" ,BaseSet ");
|
||
|
sqlBuilder.AppendLine(" ,Color ");
|
||
|
sqlBuilder.AppendLine(" ,Cover ");
|
||
|
sqlBuilder.AppendLine(" ,SetOption ");
|
||
|
sqlBuilder.AppendLine(" ,OptionDesc1 ");
|
||
|
sqlBuilder.AppendLine(" ,OptionDesc2 ");
|
||
|
sqlBuilder.AppendLine(" ,OptionDesc3 ");
|
||
|
sqlBuilder.AppendLine(" ,OptionDesc4 ");
|
||
|
sqlBuilder.AppendLine(" ,OptionDesc5 ");
|
||
|
sqlBuilder.AppendLine(" ,AsmSetCode ");
|
||
|
sqlBuilder.AppendLine(" ,Active ");
|
||
|
sqlBuilder.AppendLine(" ,LegendColor ");
|
||
|
sqlBuilder.AppendLine(" ,LegendText ");
|
||
|
sqlBuilder.AppendLine(" ,ContractNo ");
|
||
|
sqlBuilder.AppendLine(" ,IsDeleted ");
|
||
|
sqlBuilder.AppendLine(" ,MESModulFL ");
|
||
|
sqlBuilder.AppendLine(" ,MESModulFR ");
|
||
|
sqlBuilder.AppendLine(" ,MESModulRL ");
|
||
|
sqlBuilder.AppendLine(" ,MESModulRR ");
|
||
|
sqlBuilder.AppendLine(" FROM [T_FIS_ASSEMBLY] AS FA ");
|
||
|
whereBuilder.Append("AND FA.[MESModulFL] IS NOT NULL ");
|
||
|
whereBuilder.Append("AND FA.[MESModulFR] IS NOT NULL ");
|
||
|
whereBuilder.Append("AND FA.[MESModulRL] IS NOT NULL ");
|
||
|
whereBuilder.Append("AND FA.[MESModulRR] IS NOT NULL ");
|
||
|
//查询条件
|
||
|
|
||
|
if (string.IsNullOrEmpty(info.Id) == false)
|
||
|
{
|
||
|
whereBuilder.Append(" AND FA.Id = @Id ");
|
||
|
parameters.Add(new DataParameter { ParameterName = "Id", DataType = DbType.String, Value = info.Id });
|
||
|
}
|
||
|
|
||
|
if (whereBuilder.Length > 0)
|
||
|
{
|
||
|
sqlBuilder.Append(" WHERE " + whereBuilder.ToString().Substring(4));
|
||
|
}
|
||
|
sqlBuilder.AppendLine(" ORDER BY FA.Name");
|
||
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
||
|
{
|
||
|
sql = this.ChangeSqlByDB(sqlBuilder.ToString(), session);
|
||
|
list = session.GetList<FISAssembly>(sql, parameters.ToArray()).ToList();
|
||
|
}
|
||
|
return list;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
RecordExceptionLog(ex, "物料号信息数据层-获取信息");
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
}
|
||
|
}
|