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

450 lines
16 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QMAPP.Entity;
using QMAPP.FJC.Entity;
using QMFrameWork.Log;
using QMAPP.BLL;
using QMAPP.FJC.Entity.Basic;
using QMAPP.FJC.DAL.Basic;
using QMFrameWork.Data;
namespace QMAPP.FJC.BLL.Basic
{
public class ProcessRouteBLL : BaseBLL
{
#region 获取工艺路线
/// <summary>
/// 获取工艺路线
/// </summary>
/// <param name="">条件</param>
/// <returns>信息</returns>
public DataResult<ProcessRoute> Get(ProcessRoute model)
{
DataResult<ProcessRoute> result = new DataResult<ProcessRoute>();
try
{
result.Result = new ProcessRouteDAL().Get(model);
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "工艺路线逻辑层-获取工艺路线!"
});
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
#endregion
#region 获取列表
/// <summary>
/// 获取列表
/// </summary>
/// <param name="condition">条件</param>
/// <param name="page">数据页</param>
/// <returns>数据页</returns>
public DataResult<DataPage> GetList(ProcessRoute condition, DataPage page)
{
DataResult<DataPage> result = new DataResult<DataPage>();
try
{
//获取工艺路线列表
DataPage dataPage = new ProcessRouteDAL().GetList(condition, page);
result.Result = dataPage;
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "工艺路线逻辑层-获取列表!"
});
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
#endregion
#region 信息是否重复
/// <summary>
/// 判断名称是否存在
/// </summary>
/// <param name="info"></param>
/// <returns>true:已存在;fasel:不存在。</returns>
public bool ExistsProcessRoute(ProcessRoute model)
{
try
{
return new ProcessRouteDAL().ExistsProcessRoute(model);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 插入信息
/// <summary>
/// 插入信息(单表)
/// </summary>
/// <param name="">信息</param>
/// <returns>插入行数</returns>
public DataResult<int> Insert(ProcessRoute model)
{
DataResult<int> result = new DataResult<int>();
//基本信息
model.PID = Guid.NewGuid().ToString();
model.FLAGDEL = "0";
model.CREATEUSR = this.LoginUser.UserID;
model.CREATEDATE = DateTime.Now;
model.UPDATEUSR = model.CREATEUSR;
model.UPDATEDATE = model.CREATEDATE;
try
{
if (ExistsProcessRoute(model) == true)
{
result.IsSuccess = false;
result.Msg = Resource.ProcessRouteIsHave;
return result;
}
result.Result = new ProcessRouteDAL().Insert(model);
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "工艺路线逻辑层-插入信息!"
});
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
#endregion
#region 更新信息
/// <summary>
/// 更新信息
/// </summary>
/// <param name=""></param>
/// <returns>更新行数</returns>
public DataResult<int> Update(ProcessRoute model)
{
DataResult<int> result = new DataResult<int>();
//基本信息
model.UPDATEUSR = this.LoginUser.UserID;
try
{
if (ExistsProcessRoute(model) == true)
{
result.IsSuccess = false;
result.Msg = Resource.ProcessRouteIsHave;
return result;
}
result.Result = new ProcessRouteDAL().Update(model);
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "工艺路线逻辑层-更新信息!"
});
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
#endregion
#region 删除
/// <summary>
/// 删除信息
/// </summary>
/// <param name=""></param>
/// <returns>删除个数</returns>
public DataResult<int> Delete(string strs)
{
int deleteWorkCellCount = 0;
int deleteWorkCellSeqCount = 0;
int deleteProcessRouteCount = 0;
DataResult<int> result = new DataResult<int>();
string[] list = strs.Split(":".ToCharArray());
ProcessRouteDAL processRouteDAL = new ProcessRouteDAL();
try
{
foreach (string str in list)
{
using (IDataSession session = AppDataFactory.CreateMainSession())
{
processRouteDAL.BaseSession = session;
session.OpenCon();
try
{
//删除工艺路线
deleteProcessRouteCount += processRouteDAL.Delete(new ProcessRoute { PID = str });
//删除工艺路线下的工序
deleteWorkCellCount += processRouteDAL.DeleteProcessRouteWorkCell(new ProcessRouteWorkCell { ROUTE_PID = str });
//删除工序配置的前置工序
deleteWorkCellSeqCount += processRouteDAL.DeleteProcessRouteWorkCellSeq(new ProcessRouteWorkCell { ROUTE_PID = str });
session.CommitTs();
}
catch (Exception)
{
session.RollbackTs();
throw;
}
}
}
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "工艺路线逻辑层-删除!"
});
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
/// <summary>
/// 删除信息
/// </summary>
/// <param name="">信息</param>
/// <returns>删除个数</returns>
public int DeleteProcessRoute(ProcessRoute model)
{
int count = 0;
try
{
count = new ProcessRouteDAL().Delete(model);
return count;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取工序配置信息列表(分页)
/// <summary>
/// 获取工序配置信息列表(分页)
/// </summary>
/// <param name="condition">条件</param>
/// <param name="page">数据页</param>
/// <returns>数据页</returns>
public DataResult<DataPage> GetProcessRouteWorkCellData(ProcessRouteWorkCell condition, DataPage page)
{
DataResult<DataPage> result = new DataResult<DataPage>();
try
{
//获取生产线信息列表
DataPage dataPage = new ProcessRouteDAL().GetProcessRouteWorkCellData(condition, page);
result.Result = dataPage;
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "工艺路线逻辑层-获取工序配置信息列表!"
});
result.IsSuccess = false;
result.Msg = Resource.SystemException;
return result;
}
result.IsSuccess = true;
return result;
}
#endregion
#region 工序配置信息保存
/// <summary>
/// 工序配置信息保存
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public DataResult<int> ProcessRouteWorkCellSave(ProcessRouteWorkCell model)
{
DataResult<int> result = new DataResult<int>();
ProcessRouteDAL proRouteDal = new ProcessRouteDAL();
List<ProcessRouteWorkCell> listPRWC = new List<ProcessRouteWorkCell>();
List<ProcessRouteWorkCellSeq> listPRWCS = new List<ProcessRouteWorkCellSeq>();
try
{
if (proRouteDal.ExistsProcess(new ProcessRouteWorkCell() { WORKCELL_PID = model.WORKCELL_PID, ROUTE_PID = model.ROUTE_PID }))
{
result.Msg = Resource.ProcessRouteWorkCellIsHave;
result.IsSuccess = false;
return result;
}
//工序配置信息
ProcessInfo info = new ProcessInfoDAL().Get(new ProcessInfo() { PID = model.WORKCELL_PID });
model.WORKCELL_NAME = info.PROCESSNAME;
model.PID = Guid.NewGuid().ToString();
model.CREATEUSR = this.LoginUser.UserID;
model.CREATEDATE = DateTime.Now;
model.UPDATEUSR = model.CREATEUSR;
model.UPDATEDATE = model.CREATEDATE;
model.FLAGDEL = EnumGeter.FLAGDEL.NO.GetHashCode().ToString();
//准备前置工序
listPRWCS = model.Details;
if (listPRWCS.Count != 0)
{
foreach (var item in listPRWCS)
{
ProcessInfo entity = new ProcessInfoDAL().Get(new ProcessInfo() { PID = item.PRE_WORKCELL_CODE });
item.PRWS_PID = Guid.NewGuid().ToString();
item.PRW_PID = model.PID;
item.PRE_PRW_PID = entity.PID;
item.ROUTE_PID = model.ROUTE_PID;
item.CREATEUSR = this.LoginUser.UserID;
item.CREATEDATE = DateTime.Now;
item.UPDATEUSR = item.CREATEUSR;
item.UPDATEDATE = item.CREATEDATE;
item.FLAGDEL = EnumGeter.FLAGDEL.NO.GetHashCode().ToString();
item.PRE_WORKCELL_NAME = entity.PROCESSNAME;
//item.PRE_WORKCELL_CODE = entity.WORKCELL_CODE;
}
}
using (IDataSession session = AppDataFactory.CreateMainSession())
{
session.OpenCon();
int processRouteWorkCellCount = proRouteDal.InsertProcessRouteWorkCell(model);
int processRouteWorkCellSeqCount = proRouteDal.InsertProcessRouteWorkCellSeq(listPRWCS);
session.CommitTs();
}
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "工艺路线逻辑层-工序配置信息保存!"
});
result.IsSuccess = false;
result.Msg = Resource.SystemException;
return result;
}
result.IsSuccess = true;
return result;
}
#endregion
#region 工序配置信息删除
/// <summary>
/// 工序配置信息删除
/// </summary>
/// <param name=""></param>
/// <returns>删除个数</returns>
public DataResult<int> ProcessRouteWorkCellDelete(string selectKey, string ROUTE_PID)
{
DataResult<int> result = new DataResult<int>();
int deleteWorkCellCount = 0;
int deleteWorkCellSeqCount = 0;
ProcessRouteDAL processRouteDAL = new ProcessRouteDAL();
string[] list = selectKey.Split(":".ToCharArray());
try
{
using (IDataSession session = AppDataFactory.CreateMainSession())
{
try
{
session.OpenTs();
processRouteDAL.BaseSession = session;
foreach (string str in list)
{
deleteWorkCellCount += processRouteDAL.DeleteProcessRouteWorkCell(new ProcessRouteWorkCell { PID = str, ROUTE_PID = ROUTE_PID });
deleteWorkCellSeqCount += processRouteDAL.DeleteProcessRouteWorkCellSeq(new ProcessRouteWorkCell { PID = str, ROUTE_PID = ROUTE_PID });
}
session.CommitTs();
}
catch (Exception e)
{
session.RollbackTs();
throw e;
}
}
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "工艺路线逻辑层-工序配置信息删除!"
});
result.IsSuccess = false;
result.Msg = Resource.SystemException;
return result;
}
result.IsSuccess = true;
return result;
}
#endregion
#region 获取班次列表(下拉列表使用)
/// <summary>
/// 获取列表
/// </summary>
/// <param name="condition">条件</param>
/// <returns>全部集合</returns>
public DataResult<List<ProcessRoute>> GetProcessRouteList(ProcessRoute condition)
{
DataResult<List<ProcessRoute>> result = new DataResult<List<ProcessRoute>>();
try
{
result.Result = new ProcessRouteDAL().GetProcessRouteList(condition);
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "班次信息逻辑层-获取班次列表(绑定下拉列表使用)!"
});
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
#endregion
}
}