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

528 lines
17 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QMAPP.BLL;
using QMAPP.FJC.Entity.Basic;
using QMAPP.FJC.DAL.Basic;
using QMAPP.FJC.BLL.Dict;
using QMFrameWork.Data;
using QMAPP.FJC.Entity;
using QMAPP.Entity;
using QMFrameWork.Log;
using System.Data;
namespace QMAPP.FJC.BLL.Basic
{
///</summary>
/// 模块编号:M2-8
/// 作 用:加工参数标准值设定逻辑层
/// 作 者:王丹丹
/// 编写日期:2015年06月03日
///</summary>
public class ProcessParameterBLL : BaseBLL
{
#region 获取信息
/// <summary>
/// 获取信息
/// </summary>
/// <param name="">条件</param>
/// <returns>信息</returns>
public DataResult<ProcessParameter> Get(ProcessParameter model)
{
DataResult<ProcessParameter> result = new DataResult<ProcessParameter>();
try
{
result.Result = new ProcessParameterDAL().Get(model);
#region 转换工序类别显示类型
if (model != null)
{
DictManageBLL dictProcessTypeBll = new DictManageBLL(DictKind.PROCESSTYPE);
//工序类别
result.Result.PROCESSTYPETXT = dictProcessTypeBll.GetDictValue(result.Result.PROCESSTYPE);
}
#endregion
}
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(ProcessParameter condition, DataPage page)
{
DataResult<DataPage> result = new DataResult<DataPage>();
try
{
//获取信息列表
DataPage dataPage = new ProcessParameterDAL().GetList(condition, page);
#region 转换工序类别显示类型
List<ProcessParameter> processParameterList = dataPage.Result as List<ProcessParameter>;
DictManageBLL dictProcessTypeBll = new DictManageBLL(DictKind.PROCESSTYPE);
foreach (ProcessParameter m in processParameterList)
{
//工序类别
m.PROCESSTYPETXT = dictProcessTypeBll.GetDictValue(m.PROCESSTYPE);
}
#endregion
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;
}
public DataResult<List<ProcessParameter>> GetAllList(ProcessParameter condition)
{
DataResult<List<ProcessParameter>> result = new DataResult<List<ProcessParameter>>();
try
{
//获取信息列表
List<ProcessParameter> list = new ProcessParameterDAL().GetList(condition);
result.Result = list;
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "加工参数标准值设定逻辑层-获取列表!"
});
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
return result;
}
#endregion
#region 信息是否重复
/// <summary>
/// 判断名称是否存在
/// </summary>
/// <param name="info"></param>
/// <returns>true:已存在;fasel:不存在。</returns>
public bool ExistsProcessParameter(ProcessParameter model)
{
try
{
return new ProcessParameterDAL().ExistsProcessParameter(model);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 插入信息
/// <summary>
/// 插入信息(单表)
/// </summary>
/// <param name="">信息</param>
/// <returns>插入行数</returns>
public DataResult<int> Insert(ProcessParameter model)
{
DataResult<int> result = new DataResult<int>();
ProcessParameterDAL cmdDAL = new ProcessParameterDAL();
//基本信息
model.PID = Guid.NewGuid().ToString();
model.CREATEUSER = this.LoginUser.UserID;
model.CREATEDATE = DateTime.Now;
model.UPDATEUSER = model.CREATEUSER;
model.UPDATEDATE = model.CREATEDATE;
model.PRODUCELINE = EnumGeter.PRODUCELINE.B9.ToString();
try
{
if (ExistsProcessParameter(model) == true)
{
result.IsSuccess = false;
result.Msg = Resource.IsHaving;
return result;
}
if (ExistsParaTableName(model) == false)
{
result.IsSuccess = false;
result.Msg = Resource.NoParaTableName;
return result;
}
if (ExistsParaName(model) == false)
{
result.IsSuccess = false;
result.Msg = Resource.NoParaName;
return result;
}
result.Result = new ProcessParameterDAL().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(ProcessParameter model)
{
DataResult<int> result = new DataResult<int>();
//基本信息
model.UPDATEUSER = this.LoginUser.UserID;
try
{
if (ExistsProcessParameter(model) == true)
{
result.IsSuccess = false;
result.Msg = Resource.IsHaving;
return result;
}
if (ExistsParaTableName(model) == false)
{
result.IsSuccess = false;
result.Msg = Resource.NoParaTableName;
return result;
}
if (ExistsParaName(model) == false)
{
result.IsSuccess = false;
result.Msg = Resource.NoParaName;
return result;
}
result.Result = new ProcessParameterDAL().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)
{
DataResult<int> result = new DataResult<int>();
string[] list = strs.Split(":".ToCharArray());
try
{
foreach (string str in list)
{
result.Result += this.DeleteProcessParameter(new ProcessParameter { PID = str });
}
}
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 DeleteProcessParameter(ProcessParameter model)
{
int count = 0;
try
{
count = new ProcessParameterDAL().Delete(model);
return count;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取设备信息(根据设备id获取设备表对应的工序类别)
/// <summary>
/// 获取设备信息
/// </summary>
/// <param name="">条件</param>
/// <returns>*信息</returns>
public DataResult<MachineInfo> GetMachineInfo(ProcessParameter model)
{
MachineInfo condition = new MachineInfo();
MachineInfoDAL miDal = new MachineInfoDAL();
DataResult<MachineInfo> result = new DataResult<MachineInfo>();
try
{
if (model != null && !string.IsNullOrEmpty(model.MACHINEID))
{
condition.PID = model.MACHINEID;
//获取工序信息
condition = miDal.Get(condition);
#region 转换工序类别显示类型
if (condition != null)
{
DictManageBLL dictProcessTypeBll = new DictManageBLL(DictKind.PROCESSTYPE);
//工序类别
condition.PROCESSTYPETXT = dictProcessTypeBll.GetDictValue(condition.PROCESSTYPE);
}
#endregion
}
result.Result = 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
#region 获取设备信息集合
/// <summary>
/// 获取设备信息集合
/// </summary>
/// <param name="">条件</param>
/// <returns>*信息</returns>
public DataResult<List<MachineInfo>> GetMachineInfoList(ProcessParameter model)
{
MachineInfo condition = new MachineInfo();
ProcessInfoDAL psDal = new ProcessInfoDAL();
DataResult<List<MachineInfo>> result = new DataResult<List<MachineInfo>>();
try
{
if (model != null && !string.IsNullOrEmpty(model.MACHINEID))
{
condition.PID = model.MACHINEID;
}
//获取工序信息
result.Result = new MachineInfoDAL().GetList(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
#region 校验表和对应字段是否存在
/// <summary>
/// 校验表和对应字段是否存在
/// </summary>
/// <param name="info"></param>
/// <returns>true:已存在;fasel:不存在。</returns>
public bool ExistsParaTableName(ProcessParameter model)
{
try
{
return new ProcessParameterDAL().ExistsParaTableName(model);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 校验表和对应字段是否存在
/// <summary>
/// 校验表和对应字段是否存在
/// </summary>
/// <param name="info"></param>
/// <returns>true:已存在;fasel:不存在。</returns>
public bool ExistsParaName(ProcessParameter model)
{
try
{
return new ProcessParameterDAL().ExistsParaName(model);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取参数列表
public DataResult<DataPage> GetParamList(ProcessParameter condition, DataPage page)
{
DataResult<DataPage> result = new DataResult<DataPage>();
try
{
//获取信息列表
DataPage dataPage = new ProcessParameterDAL().GetParamList(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;
}
public object GetParameter(ProcessParameter condition)
{
try
{
//获取信息列表
var table = new ProcessParameterDAL().GetParameter(condition);
//Newtonsoft.Json.JsonConvert.SerializeObject(table);
if (table.Rows.Count > 0)
{
return table;
}
else
{
return null;
}
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "加工参数标准值设定逻辑层-获取列表!"
});
throw ex;
}
}
public DataResult<DataTable> GetParamExport(ProcessParameter condition)
{
DataResult<DataTable> result = new DataResult<DataTable>();
try
{
//获取信息列表
var dataPage = new ProcessParameterDAL().GetParamExport(condition);
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
}
}