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

672 lines
20 KiB

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
{
/// <summary>
/// 模块名称:物料
/// 作 者:郭兆福
/// 编写日期:2017年05月10日
/// </summary>
public class MaterialBLL : BaseBLL
{
#region 获取信息
/// <summary>
/// 获取信息
/// </summary>
/// <param name="">条件</param>
/// <returns>信息</returns>
public DataResult<Material> Get(Material model)
{
DataResult<Material> result = new DataResult<Material>();
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<Material> GetWithAnyFormate(string materialcode)
{
DataResult<Material> result = new DataResult<Material>();
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 获取分页列表
/// <summary>
/// 获取分页列表
/// </summary>
/// <param name="condition">条件</param>
/// <param name="page">数据页</param>
/// <returns>数据页</returns>
public DataResult<DataPage> GetList(Material condition, DataPage page)
{
DataResult<DataPage> result = new DataResult<DataPage>();
try
{
//获取物料信息列表
DataPage dataPage = new MaterialDAL().GetList(condition, page);
#region 外购件标识
List<Material> materielList = dataPage.Result as List<Material>;
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;
}
/// <summary>
/// 获取列表
/// </summary>
/// <param name="condition">条件</param>
/// <returns>全部集合</returns>
public List<Material> GetAllList(Material condition)
{
try
{
//获取物料信息列表
List<Material> list = new MaterialDAL().GetList(condition);
return list;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 信息是否重复
/// <summary>
/// 判断名称是否存在
/// </summary>
/// <param name="info"></param>
/// <returns>true:已存在;fasel:不存在。</returns>
public bool ExistsMateriel(Material model)
{
try
{
return new MaterialDAL().ExistsMateriel(model);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 插入信息
/// <summary>
/// 插入信息(单表)
/// </summary>
/// <param name="">信息</param>
/// <returns>插入行数</returns>
public DataResult<int> Insert(Material model)
{
DataResult<int> result = new DataResult<int>();
//基本信息
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 更新信息
/// <summary>
/// 更新信息
/// </summary>
/// <param name=""></param>
/// <returns>更新行数</returns>
public DataResult<int> Update(Material model)
{
DataResult<int> result = new DataResult<int>();
//基本信息
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 删除
/// <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
{
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;
}
/// <summary>
/// 删除信息
/// </summary>
/// <param name="">信息</param>
/// <returns>删除个数</returns>
public int DeleteMateriel(Material model)
{
int count = 0;
try
{
count = new MaterialDAL().Delete(model);
return count;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 物料号是否使用
/// <summary>
/// 物料号是否使用
/// </summary>
/// <param name="info"></param>
/// <returns>true:已使用;fasel:未使用。</returns>
public bool IsUsing(string[] pid)
{
try
{
return new MaterialDAL().IsUsing(pid);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取物料信息列表(下拉列表使用)
/// <summary>
///
/// </summary>
/// <param name="condition"></param>
/// <returns></returns>
public List<Material> GetMaterialList(Material condition)
{
List<Material> list = new List<Material>();
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 获取物料类型列表(下拉列表使用)
/// <summary>
/// 获取物料类型列表(下拉列表使用)
/// </summary>
/// <param name="condition">物料类型</param>
/// <returns></returns>
public DataResult<List<MaterialClass>> GetMaterialClassList(MaterialClass condition)
{
DataResult<List<MaterialClass>> result = new DataResult<List<MaterialClass>>();
try
{
result.Result = new MaterialClassDAL().GetMaterialClassList(condition);
}
catch (Exception ex)
{
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
/// <summary>
///
/// </summary>
/// <param name="condition"></param>
/// <returns></returns>
public List<MaterialClass> GetAllMaterialClassList(MaterialClass condition)
{
List<MaterialClass> result = new List<MaterialClass>();
try
{
List<MaterialClass> list = new MaterialClassDAL().GetMaterialClassList(condition);
return list;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 根据物料类型获取物料号(手持)
/// <summary>
/// 根据物料类型获取物料号(手持)
/// </summary>
/// <param name="condition"></param>
/// <returns></returns>
public List<Material> GetMaterialListByClass(MaterialClass condition)
{
List<Material> result = new List<Material>();
try
{
List<Material> list = new MaterialDAL().GetMaterialListByClass(condition);
return list;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取物料类型列表(winform批量报废)
public List<MaterialClass> GetMaterialClassToMendRecorderWasteForm()
{
List<MaterialClass> result = new List<MaterialClass>();
try
{
List<MaterialClass> list = new MaterialClassDAL().GetMaterialClassToMendRecorderWasteForm();
return list;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取物料类型列表(winform注塑使用)
/// <summary>
/// 获取物料类型列表(winform注塑使用)
/// </summary>
/// <param name="condition">物料类型</param>
/// <returns></returns>
public List<MaterialClass> GetMaterialClassWithType(MaterialClass condition, WorkCell workcellmodel)
{
List<MaterialClass> result = new List<MaterialClass>();
try
{
List<MaterialClass> list = new MaterialClassDAL().GetMaterialClassWithType(condition, workcellmodel);
return list;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取物料信息列表(Fis下拉列表使用)
/// <summary>
///
/// </summary>
/// <param name="condition"></param>
/// <returns></returns>
public List<Material> GetNewMaterialList(Material condition,WorkCell workcellmodel)
{
List<Material> result = new List<Material>();
try
{
result = new MaterialDAL().GetNewMaterialList(condition, workcellmodel);
}
catch (Exception ex)
{
throw ex;
}
return result;
}
/// <summary>
/// 获取订单计划使用的物料号
/// </summary>
/// <param name="OrderType"></param>
/// <returns></returns>
public List<Material> GetMaterialForOrder(string OrderType)
{
List<Material> result = new List<Material>();
try
{
result = new MaterialDAL().GetNewMaterialList(OrderType);
}
catch (Exception ex)
{
throw ex;
}
return result;
}
//GetInjectMaterialList
public List<Material> GetMaterialForInjectOrder(string OrderType)
{
List<Material> result = new List<Material>();
try
{
result = new MaterialDAL().GetInjectMaterialList(OrderType);
}
catch (Exception ex)
{
throw ex;
}
return result;
}
#endregion
#region 获取PBOM头物料(下拉列表使用)
/// <summary>
/// 获取PBOM头物料
/// </summary>
/// <param name="condition">物料</param>
/// <returns></returns>
public DataResult<List<Material>> GetPbomMaterialList(Material condition)
{
DataResult<List<Material>> result = new DataResult<List<Material>>();
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 获取本体信息
/// <summary>
/// 获取本体信息
/// </summary>
/// <param name="condition"></param>
/// <returns></returns>
public Material GetMaterialInfo(Material condition)
{
Material material = new Material();
//根据表皮条码获取本体信息
material.MATERIAL_CODE = condition.MATERIAL_CODE;
material.MaterialCodes = condition.MaterialCodes;
try
{
List<Material> 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
/// <summary>
/// 获取本体信息
/// </summary>
/// <param name="condition"></param>
/// <returns></returns>
public List<Material> 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
/// <summary>
///
/// </summary>
/// <param name="materialtype"></param>
/// <returns></returns>
public MaterialCodeInit GetProductType(string materialtype)
{
try
{
return new MaterialDAL().GetProductType(materialtype);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取门板计划使用的物料号
/// <summary>
/// 获取门板计划使用的物料号
/// </summary>
/// <param name="OrderType"></param>
/// <returns></returns>
public List<Material> GetMaterialDoorPlan(Material info)
{
List<Material> result = new List<Material>();
try
{
result = new MaterialDAL().GetMaterialDoorPlan(info);
//转换高低配和颜色
}
catch (Exception ex)
{
throw ex;
}
return result;
}
#endregion
/// <summary>
/// 成都注塑打码
/// </summary>
/// <param name="condition"></param>
/// <returns></returns>
public List<Material> GetMaterialInfoListBy(Material condition)
{
List<Material> result = new List<Material>();
try
{
result = new MaterialDAL().GetMaterialInfoListBy(condition);
}
catch (Exception ex)
{
throw ex;
}
return result;
}
/// <summary>
///
/// </summary>
/// <param name="condition"></param>
/// <returns></returns>
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;
}
}
}