using System; using System.Collections.Generic; using System.Linq; using QMAPP.BLL; using QMAPP.Entity; using QMAPP.FJC.BLL.Dict; using QMAPP.FJC.BLL.Operation; using QMAPP.FJC.DAL.Basic; using QMAPP.FJC.DAL.Injection; using QMAPP.FJC.Entity; using QMAPP.FJC.Entity.Basic; using QMAPP.FJC.Entity.Injection; using QMAPP.FJC.Entity.Operation; using QMFrameWork.Data; using QMFrameWork.Log; namespace QMAPP.FJC.BLL.Injection { /// /// 模块编号:M3-1 /// 作 用:注塑投料记录逻辑层 /// 作 者:王丹丹 /// 编写日期:2015年06月05日 /// public class InjectionRecorderBLL : 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 GetList(InjectionRecorder condition, DataPage page) { try { //获取信息列表 DataPage dataPage = new InjectionRecorderDAL().GetList(condition, page); #region 转换操作者,入料口 List injectionRecorderList = dataPage.Result as List; DictManageBLL dictInjectionterminalBll = new DictManageBLL(DictKind.INJECTIONTERMINAL); DictManageBLL dictMeTypeBll = new DictManageBLL(DictKind.INJECTIONMATERIALTYPE); foreach (InjectionRecorder m in injectionRecorderList) { m.INJECTIONTERMINALNAME = dictInjectionterminalBll.GetDictValue(m.INJECTIONTERMINAL.ToString("00")); if (!string.IsNullOrEmpty(m.MATERIALTYPE)) { m.MATERIALTYPENAME = dictMeTypeBll.GetDictValue(m.MATERIALTYPE.ToString()); } } #endregion return dataPage; } 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); } #endregion return dataPage; } catch (Exception ex) { LogManager.LogHelper.Error(new LogInfo() { ErrorInfo = ex, Tag = ex.StackTrace, Info = "原材料投料-查询列表" }); throw ex; } } #endregion #region 判断零件投料关联表信息是否存在,如果存在不允许删除 /// /// 判断零件投料关联表信息是否存在,如果存在不允许删除 /// /// /// public bool ExistsInjectionRecorder(string iPid) { try { return new InjectionRecorderDAL().ExistsProductInJection(iPid); } catch (Exception ex) { LogManager.LogHelper.Error(new LogInfo() { ErrorInfo = ex, Tag = ex.StackTrace, Info = "原材料投料-判断零件投料关联表信息是否存在" }); throw ex; } } #endregion #region 插入信息 /// /// 插入信息(单表) /// /// 信息 /// 插入行数 public DataResult Insert(InjectionRecorder model) { DataResult result = new DataResult(); try { //基本信息 model.PID = Guid.NewGuid().ToString(); model.CREATEDATE = DateTime.Now; model.UPDATEUSER = model.CREATEUSER; model.UPDATEDATE = model.CREATEDATE; InjectionRecorderDAL cmdDAL = new InjectionRecorderDAL(); result.Result = new InjectionRecorderDAL().Insert(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 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 DataResult Delete(string strs) { DataResult result = new DataResult(); string[] list = strs.Split(":".ToCharArray()); try { foreach (string str in list) { result.Result += this.DeleteInjectionRecorder(new InjectionRecorder { PID = str }); } 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; } /// /// 删除信息 /// /// /// 删除个数 public DataResult DeleteSingle(string str) { DataResult result = new DataResult(); try { ProductInjectionBLL productInjectionBLL = new ProductInjectionBLL(); if (productInjectionBLL.ExistsProductInjection(new ProductInjection { PID = str })) { result.IsSuccess = false; result.Msg = Resource.InjectionIsHaving; return result; } result.Result += this.DeleteInjectionRecorder(new InjectionRecorder { PID = str }); 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; } /// /// 删除信息 /// /// 信息 /// 删除个数 public int DeleteInjectionRecorder(InjectionRecorder model) { int count = 0; try { count = new InjectionRecorderDAL().Delete(model); return count; } catch (Exception ex) { LogManager.LogHelper.Error(new LogInfo() { ErrorInfo = ex, Tag = ex.StackTrace, Info = "原材料投料-删除信息" }); throw ex; } } #endregion #region 获取班次信息集合 /// /// 获取班次信息集合 /// /// 条件 /// *信息 public List GetProduceShiftList(ProduceShift model) { try { //获取设备信息集合 return new ProduceShiftDAL().GetList(model).ToList(); } 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 /// /// /// /// /// public bool CheckInjectMaterial(InjectionInfo recorders) { try { return new InjectionRecorderDAL().CheckInjectMaterial(recorders); } catch (Exception ex) { LogManager.LogHelper.Error(new LogInfo() { ErrorInfo = ex, Tag = ex.StackTrace, Info = "原材料投料-判断零件信息是否存在" }); throw ex; } } public DataResult InsertNew(InjectionInfo model) { DataResult result = new DataResult(); try { //基本信息 model.PID = Guid.NewGuid().ToString(); model.CREATEDATE = DateTime.Now; model.UPDATEUSER = model.CREATEUSER; model.UPDATEDATE = model.CREATEDATE; InjectionRecorderDAL cmdDAL = new InjectionRecorderDAL(); result.Result = new InjectionRecorderDAL().InsertNew(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; } /// /// 查验是否存在此批次物料(楼上) /// /// /// public DataResult GetCheckInjection(InjectionInfo recorders) { DataResult result = new DataResult(); try { result.Result = new InjectionRecorderDAL().GetInjectMaterial(recorders); } catch (Exception ex) { LogManager.LogHelper.Error(new LogInfo() { ErrorInfo = ex, Tag = ex.StackTrace, Info = "原材料投料-判断零件信息是否存在" }); throw ex; } result.IsSuccess = true; return result; } #region 获取料罐与孔信息集合 /// /// 获取设备信息集合 /// /// 条件 /// *信息 public List GetInjectHoleList() { try { //获取设备信息集合 return new InjectionRecorderDAL().GetInjectHoleList(); } catch (Exception ex) { LogManager.LogHelper.Error(new LogInfo() { ErrorInfo = ex, Tag = ex.StackTrace, Info = "注塑投料记录逻辑层-获取料孔信息集合" }); throw ex; } } #endregion /// /// /// /// /// public InjectionInfo WriteMaterialDetail(InjectionInfo model) { try { return new InjectionRecorderDAL().GetInjectMaterial(model); } catch (Exception ex) { LogManager.LogHelper.Error(new LogInfo() { ErrorInfo = ex, Tag = ex.StackTrace, Info = "原材料投料-获取信息" }); throw ex; } } } }