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

456 lines
16 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QMAPP.BLL;
using QMAPP.Entity;
using QMFrameWork.Log;
using QMAPP.MD.Entity;
using QMFrameWork.Data;
using QMAPP.MD.DAL;
using QMAPP.MD.BLL.Dict;
namespace QMAPP.MD.BLL
{
/// <summary>
/// 模块名称:工艺路线
/// 作 者:郭兆福
/// 编写日期:2017年05月12日
/// </summary>
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)
{
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)
{
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.FLGDEL = "0";
model.CREATEUSER = this.LoginUser.UserID;
model.UPDATEUSER = model.CREATEUSER;
try
{
if (ExistsProcessRoute(model) == true)
{
result.IsSuccess = false;
result.Msg = "工艺路线已经存在!";
return result;
}
result.Result = new ProcessRouteDAL().Insert(model);
}
catch (Exception ex)
{
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.UPDATEUSER = 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)
{
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_CODE = str });
//删除工序配置的前置工序
deleteWorkCellSeqCount += processRouteDAL.DeleteProcessRouteWorkCellSeq(new ProcessRouteWorkCell { ROUTE_CODE = str });
session.CommitTs();
}
catch (Exception)
{
session.RollbackTs();
throw;
}
}
}
}
catch (Exception ex)
{
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);
#region 转换质检标记
List<ProcessRouteWorkCell> processRouteWorkCellList = dataPage.Result as List<ProcessRouteWorkCell>;
DictManageBLL qcFlagBll = new DictManageBLL(DictKind.QcFlag);
foreach (ProcessRouteWorkCell m in processRouteWorkCellList)
{
//质检标记
m.FLAG_QC_NAME = qcFlagBll.GetDictValue(m.FLAG_QC);
}
#endregion
result.Result = dataPage;
}
catch (Exception ex)
{
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_CODE = model.WORKCELL_CODE }))
{
result.Msg = Resource.ProcessRouteWorkCellIsHave;
result.IsSuccess = false;
return result;
}
//工序配置信息
WorkCell info = new WorkCellDAL().Get(new WorkCell() { WORKCELL_CODE = model.WORKCELL_CODE });
model.WORKCELL_CODE=info.WORKCELL_CODE;
model.WORKCELL_NAME=info.WORKCELL_NAME;
model.PID = Guid.NewGuid().ToString();
model.CREATEUSER = this.LoginUser.UserID;
model.UPDATEUSER = model.CREATEUSER;
model.FLGDEL = "0";
//准备前置工序
listPRWCS = model.Details;
if (listPRWCS.Count != 0)
{
foreach (var item in listPRWCS)
{
WorkCell entity = new WorkCellDAL().Get(new WorkCell() { WORKCELL_CODE = item.PRE_WORKCELL_CODE });
item.PID = Guid.NewGuid().ToString();
item.WORKCELL_CODE = model.WORKCELL_CODE;
item.ROUTE_CODE = model.ROUTE_CODE;
item.VER_NUM = model.VER_NUM;
item.CREATEUSER = this.LoginUser.UserID;
item.CREATEDATE = DateTime.Now;
item.UPDATEUSER = item.CREATEUSER;
item.UPDATEDATE = item.CREATEDATE;
item.FLGDEL = "0";
item.PRE_WORKCELL_NAME = entity.WORKCELL_NAME;
item.PRE_WORKCELL_CODE = entity.WORKCELL_CODE;
}
}
else
{
// Q5 特殊,没有前置工序的时候加一条前置工序为空的工序顺序记录
ProcessRouteWorkCellSeq item = new ProcessRouteWorkCellSeq();
item.PID = Guid.NewGuid().ToString();
item.WORKCELL_CODE = model.WORKCELL_CODE;
item.ROUTE_CODE = model.ROUTE_CODE;
item.VER_NUM = model.VER_NUM;
item.CREATEUSER = this.LoginUser.UserID;
item.CREATEDATE = DateTime.Now;
item.UPDATEUSER = item.CREATEUSER;
item.UPDATEDATE = item.CREATEDATE;
item.FLGDEL = "0";
listPRWCS.Add(item);
}
using (IDataSession session = AppDataFactory.CreateMainSession())
{
session.OpenCon();
int processRouteWorkCellCount=proRouteDal.InsertProcessRouteWorkCell(model);
int processRouteWorkCellSeqCount = proRouteDal.InsertProcessRouteWorkCellSeq(listPRWCS);
session.CommitTs();
}
}
catch (Exception ex)
{
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_CODE)
{
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_CODE = ROUTE_CODE });
deleteWorkCellSeqCount += processRouteDAL.DeleteProcessRouteWorkCellSeq(new ProcessRouteWorkCell { PID = str, ROUTE_CODE = ROUTE_CODE });
}
session.CommitTs();
}
catch (Exception e)
{
session.RollbackTs();
throw e;
}
}
}
catch (Exception ex)
{
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().GetRouteList(condition);
result.IsSuccess = true;
return result;
}
catch (Exception ex)
{
result.IsSuccess = false;
result.Msg = Resource.SystemException;
return result;
}
}
#endregion
#region 获取工艺路线工序下拉列表
/// <summary>
/// 获取工艺路线工序下拉列表
/// </summary>
/// <param name="condition">条件</param>
/// <returns>数据页</returns>
public DataResult<List<ProcessRouteWorkCell>> GeProcessRouteWorkCellList(ProcessRouteWorkCell condtion)
{
DataResult<List<ProcessRouteWorkCell>> result = new DataResult<List<ProcessRouteWorkCell>>();
try
{
result.Result = new ProcessRouteDAL().GetProcessRouteWorkCellData(condtion);
result.IsSuccess = true;
return result;
}
catch (Exception ex)
{
result.IsSuccess = false;
result.Msg = Resource.SystemException;
return result;
}
}
#endregion
public ProcessRoute GetRouteByMachine(string machinecode)
{
return new ProcessRouteDAL().GetRouteByMachine(machinecode);
}
}
}