using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QMAPP.BLL;
using QMAPP.Entity;
using QMFrameWork.Log;
using QMAPP.MD.Entity;
using QMFrameWork.Data;
using QMAPP.MD.DAL;
using QMAPP.MD.BLL.Dict;
using QMAPP.FJC.Entity.Basic;
namespace QMAPP.MD.BLL
{
///
/// 模块名称:物料
/// 作 者:郭兆福
/// 编写日期:2017年05月10日
///
public class MaterialBLL : BaseBLL
{
#region 获取信息
///
/// 获取信息
///
/// 条件
/// 信息
public DataResult Get(Material model)
{
DataResult result = new DataResult();
try
{
result.Result = new MaterialDAL().Get(model);
}
catch (Exception ex)
{
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
public DataResult GetWithAnyFormate(string materialcode)
{
DataResult result = new DataResult();
try
{
result.Result = new MaterialDAL().GetWithAnyFormate(materialcode);
}
catch (Exception ex)
{
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
#endregion
#region 获取分页列表
///
/// 获取分页列表
///
/// 条件
/// 数据页
/// 数据页
public DataResult GetList(Material condition, DataPage page)
{
DataResult result = new DataResult();
try
{
//获取物料信息列表
DataPage dataPage = new MaterialDAL().GetList(condition, page);
#region 外购件标识
List materielList = dataPage.Result as List;
DictManageBLL dictOutSourceBll = new DictManageBLL(DictKind.OutSourceFlag);
DictManageBLL dictHBtypeBll = new DictManageBLL(DictKind.HBTYPE);
DictManageBLL dictCOLORBll = new DictManageBLL(DictKind.COLOR);
foreach (Material m in materielList)
{
//物料类别
m.OUTSOURCE_NAME = dictOutSourceBll.GetDictValue(m.OUTSOURCE);
//高低配
m.HBTYPE = dictHBtypeBll.GetDictValue(m.HBTYPE);
//颜色
m.COLOR = dictCOLORBll.GetDictValue(m.COLOR);
}
#endregion
result.Result = dataPage;
}
catch (Exception ex)
{
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
///
/// 获取列表
///
/// 条件
/// 全部集合
public List GetAllList(Material condition)
{
try
{
//获取物料信息列表
List list = new MaterialDAL().GetList(condition);
return list;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 信息是否重复
///
/// 判断名称是否存在
///
///
/// true:已存在;fasel:不存在。
public bool ExistsMateriel(Material model)
{
try
{
return new MaterialDAL().ExistsMateriel(model);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 插入信息
///
/// 插入信息(单表)
///
/// 信息
/// 插入行数
public DataResult Insert(Material model)
{
DataResult result = new DataResult();
//基本信息
model.PID = Guid.NewGuid().ToString();
model.FLGDEL = "0";
model.CREATEUSER = this.LoginUser.UserID;
model.UPDATEUSER = model.CREATEUSER;
MaterialDAL cmdDAL = new MaterialDAL();
try
{
if (ExistsMateriel(model) == true)
{
result.IsSuccess = false;
result.Msg = Resource.MaterielCodeIsHave;
return result;
}
result.Result = new MaterialDAL().Insert(model);
}
catch (Exception ex)
{
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
#endregion
#region 更新信息
///
/// 更新信息
///
///
/// 更新行数
public DataResult Update(Material model)
{
DataResult result = new DataResult();
//基本信息
model.UPDATEUSER = this.LoginUser.UserID;
//model.UPDATEDATE=DateTime.Now;
try
{
if (ExistsMateriel(model) == true)
{
result.IsSuccess = false;
result.Msg = Resource.MaterielCodeIsHave;
return result;
}
result.Result = new MaterialDAL().Update(model);
}
catch (Exception ex)
{
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
#endregion
#region 删除
///
/// 删除信息
///
///
/// 删除个数
public DataResult Delete(string strs)
{
DataResult result = new DataResult();
string[] list = strs.Split(":".ToCharArray());
try
{
if (IsUsing(list)==true)
{
result.IsSuccess = false;
result.Msg = "物料号已被使用不能删除";
return result;
}
foreach (string str in list)
{
result.Result += this.DeleteMateriel(new Material { PID = str });
}
}
catch (Exception ex)
{
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
///
/// 删除信息
///
/// 信息
/// 删除个数
public int DeleteMateriel(Material model)
{
int count = 0;
try
{
count = new MaterialDAL().Delete(model);
return count;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 物料号是否使用
///
/// 物料号是否使用
///
///
/// true:已使用;fasel:未使用。
public bool IsUsing(string[] pid)
{
try
{
return new MaterialDAL().IsUsing(pid);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取物料信息列表(下拉列表使用)
///
///
///
///
///
public List GetMaterialList(Material condition)
{
List list = new List();
try
{
list = new MaterialDAL().GetMaterialList(condition);
DictManageBLL dictOutSourceBll = new DictManageBLL(DictKind.OutSourceFlag);
DictManageBLL dictHBtypeBll = new DictManageBLL(DictKind.HBTYPE);
DictManageBLL dictCOLORBll = new DictManageBLL(DictKind.COLOR);
foreach (Material m in list)
{
//物料类别
m.OUTSOURCE = dictOutSourceBll.GetDictValue(m.OUTSOURCE);
//高低配
m.HBTYPE = dictHBtypeBll.GetDictValue(m.HBTYPE);
//颜色
m.COLOR = dictCOLORBll.GetDictValue(m.COLOR);
}
}
catch (Exception ex)
{
throw ex;
}
return list;
}
#endregion
#region 获取物料类型列表(下拉列表使用)
///
/// 获取物料类型列表(下拉列表使用)
///
/// 物料类型
///
public DataResult> GetMaterialClassList(MaterialClass condition)
{
DataResult> result = new DataResult>();
try
{
result.Result = new MaterialClassDAL().GetMaterialClassList(condition);
}
catch (Exception ex)
{
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
///
///
///
///
///
public List GetAllMaterialClassList(MaterialClass condition)
{
List result = new List();
try
{
List list = new MaterialClassDAL().GetMaterialClassList(condition);
return list;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 根据物料类型获取物料号(手持)
///
/// 根据物料类型获取物料号(手持)
///
///
///
public List GetMaterialListByClass(MaterialClass condition)
{
List result = new List();
try
{
List list = new MaterialDAL().GetMaterialListByClass(condition);
return list;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取物料类型列表(winform批量报废)
public List GetMaterialClassToMendRecorderWasteForm()
{
List result = new List();
try
{
List list = new MaterialClassDAL().GetMaterialClassToMendRecorderWasteForm();
return list;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取物料类型列表(winform注塑使用)
///
/// 获取物料类型列表(winform注塑使用)
///
/// 物料类型
///
public List GetMaterialClassWithType(MaterialClass condition, WorkCell workcellmodel)
{
List result = new List();
try
{
List list = new MaterialClassDAL().GetMaterialClassWithType(condition, workcellmodel);
return list;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取物料信息列表(Fis下拉列表使用)
///
///
///
///
///
public List GetNewMaterialList(Material condition,WorkCell workcellmodel)
{
List result = new List();
try
{
result = new MaterialDAL().GetNewMaterialList(condition, workcellmodel);
}
catch (Exception ex)
{
throw ex;
}
return result;
}
///
/// 获取订单计划使用的物料号
///
///
///
public List GetMaterialForOrder(string OrderType)
{
List result = new List();
try
{
result = new MaterialDAL().GetNewMaterialList(OrderType);
}
catch (Exception ex)
{
throw ex;
}
return result;
}
//GetInjectMaterialList
public List GetMaterialForInjectOrder(string OrderType)
{
List result = new List();
try
{
result = new MaterialDAL().GetInjectMaterialList(OrderType);
}
catch (Exception ex)
{
throw ex;
}
return result;
}
#endregion
#region 获取PBOM头物料(下拉列表使用)
///
/// 获取PBOM头物料
///
/// 物料
///
public DataResult> GetPbomMaterialList(Material condition)
{
DataResult> result = new DataResult>();
try
{
result.Result = new MaterialDAL().GetPbomMaterialList(condition);
}
catch (Exception ex)
{
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
#endregion
#region 获取本体信息
///
/// 获取本体信息
///
///
///
public Material GetMaterialInfo(Material condition)
{
Material material = new Material();
//根据表皮条码获取本体信息
material.MATERIAL_CODE = condition.MATERIAL_CODE;
material.MaterialCodes = condition.MaterialCodes;
try
{
List materialList = new MaterialDAL().GetMaterialInfo(material);
DictManageBLL dictHBtypeBll = new DictManageBLL(DictKind.HBTYPE);
DictManageBLL dictCOLORBll = new DictManageBLL(DictKind.COLOR);
foreach (Material m in materialList)
{
material.HBTYPE = m.HBTYPE;
material.COLOR = m.COLOR;
material.IMAGE_PATH = m.IMAGE_PATH;
//高低配
m.HBTYPE = dictHBtypeBll.GetDictValue(m.HBTYPE);
//颜色
m.COLOR = dictCOLORBll.GetDictValue(m.COLOR);
material.MATERIAL_NAME = m.MATERIAL_NAME;
material.HBTYPECHINESE = m.HBTYPE;
material.COLORCHINESE = m.COLOR;
material.MATERIAL_TYPE_CODE = m.MATERIAL_TYPE_CODE;
}
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "产品档案逻辑层-获取本体信息!"
});
throw ex;
}
return material;
}
#endregion
#region 获取本体信息list
///
/// 获取本体信息
///
///
///
public List GetMaterialInfoList(Material condition)
{
Material material = new Material();
//根据表皮条码获取本体信息
material.MaterialCodes = condition.MaterialCodes;
try
{
return new MaterialDAL().GetMaterialInfoList(material);
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "产品档案逻辑层-获取本体信息!"
});
throw ex;
}
}
#endregion
#region 获取Product-type
///
///
///
///
///
public MaterialCodeInit GetProductType(string materialtype)
{
try
{
return new MaterialDAL().GetProductType(materialtype);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取门板计划使用的物料号
///
/// 获取门板计划使用的物料号
///
///
///
public List GetMaterialDoorPlan(Material info)
{
List result = new List();
try
{
result = new MaterialDAL().GetMaterialDoorPlan(info);
//转换高低配和颜色
}
catch (Exception ex)
{
throw ex;
}
return result;
}
#endregion
///
/// 成都注塑打码
///
///
///
public List GetMaterialInfoListBy(Material condition)
{
List result = new List();
try
{
result = new MaterialDAL().GetMaterialInfoListBy(condition);
}
catch (Exception ex)
{
throw ex;
}
return result;
}
///
///
///
///
///
public OrderIndentity GetOrderInfo(OrderIndentity condition)
{
OrderIndentity order = new OrderIndentity();
try
{
order = new MaterialDAL().GetOrderInfo(condition);
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "产品档案逻辑层-获取本体信息!"
});
throw ex;
}
return order;
}
}
}