using System;
using System.Collections.Generic;
using System.Linq;
using QMAPP.BLL;
using QMAPP.Entity;
using QMAPP.FJC.BLL.Basic;
using QMAPP.FJC.DAL.EM;
using QMAPP.FJC.Entity.Basic;
using QMAPP.FJC.Entity.Equipment;
using QMFrameWork.Data;
using QMFrameWork.Log;
using Resource = QMAPP.FJC.Entity.Resource;
namespace QMAPP.FJC.BLL.Equipment
{
public class UsageLogBLL : BaseBLL
{
#region 获取信息
///
/// 获取信息
///
/// 条件
/// 信息
public DataResult Get(UsageLogEntity model)
{
DataResult result = new DataResult();
try
{
result.Result = new UsageLogDAL().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 获取列表
///
/// 获取列表
///
/// 条件
/// 数据页
/// 数据页
public DataResult GetList(UsageLogEntity condition, DataPage page)
{
DataResult result = new DataResult();
try
{
DataPage dataPage = new UsageLogDAL().GetList(condition, page);
#region 转换设备状态、接收控制指令、工序类别显示类型
List InfoList = dataPage.Result as List;
var mouldList = new MouldBLL().GetAllList(new Mould());
var machineInfoList = new MachineInfoBLL().GetAllList(new MachineInfo());
foreach (UsageLogEntity m in InfoList)
{
//模具
var mould = mouldList.FirstOrDefault(x => x.PID == m.MOULD_PID);
if (mould != null)
{
m.MOULD_PID_TXT = mould.MOULD_NAME;
m.MOULD_PID = mould.MOULD_CODE;
}
//设备
var machineInfo = machineInfoList.FirstOrDefault(x => x.PID == m.MACHINE_PID);
if (machineInfo != null)
{
m.MACHINE_PID_TXT = machineInfo.MACHINENAME;
m.MACHINE_PID = machineInfo.MACHINECODDE;
}
}
//查询磨具号
if (!string.IsNullOrEmpty(condition.MOULD_PID))
{
dataPage.Result = InfoList.Where(x => x.MOULD_PID.Contains(condition.MOULD_PID)).ToList();
}
#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;
}
#endregion
///
/// 获取列表
///
/// 条件
/// 数据页
/// 数据页
public DataResult GetCountList(UsageLogEntity condition, DataPage page)
{
DataResult result = new DataResult();
try
{
DataPage dataPage = new UsageLogDAL().GetCountList(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;
}
}
}