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

406 lines
12 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 QMFrameWork.Data;
using QMAPP.FJC.Entity;
using QMAPP.FJC.BLL.Dict;
using QMAPP.Entity;
using QMFrameWork.Log;
using QMAPP.MD.Entity;
namespace QMAPP.FJC.BLL.Basic
{
/// <summary>
/// 模块编号:M2-2
/// 作 用:设备信息逻辑层
/// 作 者:王丹丹
/// 编写日期:2015年05月28日
///</summary>
public class MachineInfoBLL : BaseBLL
{
#region 获取信息
/// <summary>
/// 获取信息
/// </summary>
/// <param name="">条件</param>
/// <returns>信息</returns>
public DataResult<MachineInfo> Get(MachineInfo model)
{
DataResult<MachineInfo> result = new DataResult<MachineInfo>();
try
{
result.Result = new MachineInfoDAL().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;
}
public MachineInfo GetMachineInfo(MachineInfo model)
{
return new MachineInfoDAL().GetMachineInfo(model);
}
#endregion
#region 获取列表
/// <summary>
/// 获取列表
/// </summary>
/// <param name="condition">条件</param>
/// <param name="page">数据页</param>
/// <returns>数据页</returns>
public DataResult<DataPage> GetList(MachineInfo condition, DataPage page)
{
DataResult<DataPage> result = new DataResult<DataPage>();
try
{
//获取信息列表
DataPage dataPage = new MachineInfoDAL().GetList(condition, page);
#region 转换设备状态、接收控制指令、工序类别显示类型
List<MachineInfo> machineInfoList = dataPage.Result as List<MachineInfo>;
DictManageBLL dictIsControlBll = new DictManageBLL(DictKind.ISCONTROL);
DictManageBLL dictStatusBll = new DictManageBLL(DictKind.STATUS);
foreach (MachineInfo m in machineInfoList)
{
//设备状态
m.STATUSTXT = dictStatusBll.GetDictValue(m.STATUS);
//接收控制指令
m.ISCONTROLTXT = dictIsControlBll.GetDictValue(m.ISCONTROL);
}
#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;
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="condition">条件</param>
/// <returns>全部集合</returns>
public List<MachineInfo> GetAllList(MachineInfo condition)
{
try
{
List<MachineInfo> list = new MachineInfoDAL().GetList(condition);
return list;
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="condition">条件</param>
/// <returns>全部集合</returns>
public List<MachineInfo> GetAllListAndModels(MachineInfo condition)
{
try
{
List<MachineInfo> list = new MachineInfoDAL().GetList(condition);
foreach (MachineInfo item in list)
{
item.MODELS = new MachineInfoModelDAL().GetList(new MachineInfoModels{MID=item.PID});
}
return list;
}
catch (Exception ex)
{
throw ex;
}
}
public List<MachineInfo> GetMachineInfoMachineCheck()
{
try
{
return new MachineInfoDAL().GetMachineInfoMachineCheck();
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 信息是否重复
/// <summary>
/// 判断名称是否存在
/// </summary>
/// <param name="info"></param>
/// <returns>true:已存在;fasel:不存在。</returns>
public bool ExistsMachineInfo(MachineInfo model)
{
try
{
return new MachineInfoDAL().ExistsMachineInfo(model);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 插入信息
/// <summary>
/// 插入信息(单表)
/// </summary>
/// <param name="">信息</param>
/// <returns>插入行数</returns>
public DataResult<int> Insert(MachineInfo model)
{
DataResult<int> result = new DataResult<int>();
MachineInfoDAL cmdDAL = new MachineInfoDAL();
//基本信息
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.VW371.ToString();
try
{
if (ExistsMachineInfo(model) == true)
{
result.IsSuccess = false;
result.Msg = Resource.MachineCodeIsHave;
return result;
}
result.Result = new MachineInfoDAL().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(MachineInfo model)
{
DataResult<int> result = new DataResult<int>();
//基本信息
model.UPDATEUSER = this.LoginUser.UserID;
try
{
if (ExistsMachineInfo(model) == true)
{
result.IsSuccess = false;
result.Msg = Resource.MachineCodeIsHave;
return result;
}
result.Result = new MachineInfoDAL().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.DeleteMachineInfo(new MachineInfo { 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 DeleteMachineInfo(MachineInfo model)
{
int count = 0;
try
{
count = new MachineInfoDAL().Delete(model);
return count;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取设备信息列表()
/// <summary>
///
/// </summary>
/// <param name="condition"></param>
/// <returns></returns>
public List<MachineInfo> GetMachineForOrderList(MachineInfo condition, WorkCell workcellmodel)
{
List<MachineInfo> result = new List<MachineInfo>();
try
{
result = new MachineInfoDAL().GetMachineForOrder(condition, workcellmodel);
}
catch (Exception ex)
{
throw ex;
}
return result;
}
public List<MachineInfo> GetMachineList()
{
List<MachineInfo> result = new List<MachineInfo>();
try
{
result = new MachineInfoDAL().GetMachineList();
}
catch (Exception ex)
{
throw ex;
}
return result;
}
#endregion
#region 获取设备名称列表(下拉列表使用)
/// <summary>
///
/// </summary>
/// <param name="condition"></param>
/// <returns></returns>
public List<MachineInfo> GetMachineInfoList(MachineInfo condition)
{
List<MachineInfo> result = new List<MachineInfo>();
try
{
result = new MachineInfoDAL().GetMachineInfoList(condition);
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "设备信息逻辑层-获取列表(绑定下拉列表使用)!"
});
throw ex;
}
return result;
}
public List<MachineInfo> GetAllMachineInfoList()
{
List<MachineInfo> result = new List<MachineInfo>();
try
{
result = new MachineInfoDAL().GetAllMachineInfoList();
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "设备信息逻辑层-获取列表(绑定下拉列表使用)!"
});
throw ex;
}
return result;
}
#endregion
}
}