using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using QMFrameWork.Common.Encrypt;
using QMFrameWork.Data;
using QMAPP.FJC.DAL.Injection;
using QMAPP.FJC.Entity.Injection;
using QMAPP.BLL;
using QMAPP.FJC.BLL.Dict;
using QMAPP.Entity;
using QMAPP.FJC.Entity.Basic;
using QMAPP.FJC.BLL.Basic;
using QMAPP.FJC.Entity;
using QMAPP.FJC.DAL.Basic;
using QMFrameWork.Log;
namespace QMAPP.FJC.BLL.Injection
{
///
/// 模块编号:M3-2
/// 作 用:搪塑投料记录逻辑层
/// 作 者:王丹丹
/// 编写日期:2015年06月06日
///
public class SlushRecorderBLL : BaseBLL
{
#region 获取信息
///
/// 获取信息
///
/// 条件
/// 信息
public InjectionRecorder Get(InjectionRecorder model)
{
try
{
return new InjectionRecorderDAL().Get(model);
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "搪塑投料记录逻辑层-获取信息!"
});
throw ex;
}
}
#endregion
#region 获取列表
///
/// 获取列表
///
/// 条件
/// 数据页
/// 数据页
public DataPage GetRecordList(InjectionRecorder condition, DataPage page)
{
try
{
//获取信息列表
DataPage dataPage = new InjectionRecorderDAL().GetInjectionRecordList(condition, page);
#region 转换物料类别、设备分类、工序类别显示类型
List recorderList = dataPage.Result as List;
DictManageBLL dictIJMTypeBll = new DictManageBLL(DictKind.INJECTIONMATERIALTYPE);
DictManageBLL dictProcessTypeBll = new DictManageBLL(DictKind.PROCESSTYPE);
DictManageBLL dictMachineTypeBll = new DictManageBLL(DictKind.MACHINETYPE);
foreach (InjectionRecorder m in recorderList)
{
//物料类别
m.MATERIALTYPETXT = dictIJMTypeBll.GetDictValue(m.MATERIALTYPE);
//工序类别
m.PROCESSTYPETXT = dictProcessTypeBll.GetDictValue(m.PROCESSTYPE);
//设备分类
m.MACHINETYPETXT = dictMachineTypeBll.GetDictValue(m.MACHINETYPE);
m.INJECTIONTERMINALNAME = m.INJECTIONTERMINAL.ToString() + "-" + m.INJECTIONINDEX.ToString();
}
#endregion
return dataPage;
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "搪塑投料记录逻辑层-获取列表!"
});
throw ex;
}
}
#endregion
#region 更新信息
///
/// 更新信息
///
///
/// 更新行数
public DataResult Update(InjectionRecorder model)
{
DataResult result = new DataResult();
try
{
//基本信息
model.UPDATEUSER = this.LoginUser.UserID;
result.Result= new InjectionRecorderDAL().Update(model);
result.IsSuccess = true;
result.Msg = Resource.MsgSuccess;
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "搪塑投料记录逻辑层-更新信息!"
});
result.IsSuccess = false;
result.Msg = Resource.SystemException;
}
return result;
}
#endregion
#region 删除
///
/// 删除信息
///
///
/// 删除个数
public int Delete(string strs)
{
int count = 0;
string[] list = strs.Split(":".ToCharArray());
InjectionRecorder model = new InjectionRecorder();
try
{
//判断记录是否可删除
foreach (var item in list)
{
//获取投料信息
model.PID = item;
model = Get(model);
//如果投料信息的使用重量不等于0,则不允许删除
if (model.USEDWEIGHTSUM != 0)
return -1;
}
foreach (string str in list)
{
count += this.DeleteInjectionRecorder(new InjectionRecorder { PID = str });
}
return count;
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "搪塑投料记录逻辑层-删除!"
});
throw ex;
}
}
///
/// 删除信息
///
/// 信息
/// 删除个数
public int DeleteInjectionRecorder(InjectionRecorder model)
{
int count = 0;
try
{
count = new InjectionRecorderDAL().Delete(model);
return count;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取班次信息集合
///
/// 获取班次信息集合
///
/// 条件
/// *信息
public List GetProduceShiftList(ProduceShift model)
{
try
{
//获取设备信息集合
return new ProduceShiftDAL().GetList(model);
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "搪塑投料记录逻辑层-获取班次信息集合!"
});
throw ex;
}
}
#endregion
#region 获取设备信息集合
///
/// 获取设备信息集合
///
/// 条件
/// *信息
public List GetMachineInfoList(MachineInfo model)
{
try
{
//获取设备信息集合
return new MachineInfoDAL().GetList(model);
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "搪塑投料记录逻辑层-获取设备信息集合!"
});
throw ex;
}
}
#endregion
#region 更新零件投料关联表
///
/// 更新零件投料关联表
///
///
///
public DataResult UpdateProductInjection(InjectionRecorder model)
{
DataResult result = new DataResult();
try
{
//基本信息
model.UPDATEUSER = this.LoginUser.UserID;
result.Result = new InjectionRecorderDAL().UpdateProductInjection(model);
result.IsSuccess = true;
result.Msg = Resource.MsgSuccess;
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "搪塑投料记录逻辑层-更新零件投料关联表!"
});
result.IsSuccess = false;
result.Msg = Resource.SystemException;
}
return result;
}
#endregion
}
}