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

225 lines
7.3 KiB

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using QMFrameWork.Data;
using QMAPP.Entity;
using QMAPP.FJC.Entity.QT;
using QMAPP.FJC.BLL.QT;
using QMAPP.FJC.DAL.QT;
using QMAPP.BLL;
using QMAPP.FJC.BLL.Basic;
using QMAPP.FJC.BLL.Equipment;
using QMAPP.FJC.Entity.Basic;
using QMAPP.FJC.Entity.Equipment;
using QMAPP.MD.BLL;
using QMAPP.MD.Entity;
using Resource = QMAPP.FJC.Entity.Resource;
namespace QMAPP.FJC.BLL.QT
{
/// <summary>
/// 模块名称:物料信息绑定关系
/// 作 者:张鹏
/// 编写日期:2017年09月01日
/// </summary>
public class MaterialBindingBLL : BaseBLL
{
#region 获取信息
/// <summary>
/// 获取信息
/// </summary>
/// <param name="">条件</param>
/// <returns>信息</returns>
public MaterialBinding Get(MaterialBinding info)
{
try
{
return new MaterialBindingDAL().Get(info);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取列表
/// <summary>
/// 获取列表
/// </summary>
/// <param name="condition">条件</param>
/// <param name="page">数据页</param>
/// <returns>数据页</returns>
public DataResult<DataPage> GetList(MaterialBinding condition, DataPage page)
{
DataResult<DataPage> result = new DataResult<DataPage>();
try
{
//获取物料信息列表
DataPage dataPage = new MaterialBindingDAL().GetMaterialBindingList(condition, page);
#region 翻译code
List<MaterialBinding> materialBindingList = dataPage.Result as List<MaterialBinding>;
var materialClassList = new MaterialBLL().GetMaterialClassList(new MaterialClass());
var materialList = new MaterialBLL().GetMaterialList(new Material());
var machineInfoList = new MachineInfoBLL().GetAllMachineInfoList();
var mouldList = new MouldBLL().GetMoulds();
var EQUIP = "设备";
var MOULD = "模具";
var CLASS = "物料类型";
var CODE = "物料号";
if (materialBindingList != null && materialBindingList.Count>0)
foreach (MaterialBinding m in materialBindingList)
{
if (m.BINDING_TYPE == "EQUIP")
{
m.BINDING_TYPE_NAME = EQUIP;
MachineInfo target = machineInfoList.FirstOrDefault(x => x.MACHINECODDE == m.TARGET_CODE);
if (target != null)
{
m.TARGET_CODE_NAME = target.MACHINENAME;
}
}
else if (m.BINDING_TYPE == "MOULD")
{
m.BINDING_TYPE_NAME = MOULD;
Mould target = mouldList.FirstOrDefault(x => x.MOULD_CODE == m.TARGET_CODE);
if (target != null)
{
m.TARGET_CODE_NAME = target.MOULD_NAME;
}
}
if (m.IS_MATERIAL_CODE == "0")
{
m.IS_MATERIAL_NAME = CLASS;
MaterialClass target = materialClassList.Result.FirstOrDefault(x => x.MATERIAL_TYPE_CODE == m.MATERIAL_CODE);
if (target != null)
{
m.MATERIAL_CODE_NAME = target.MATERIAL_TYPE_NAME;
}
}
else if (m.IS_MATERIAL_CODE == "1")
{
m.IS_MATERIAL_NAME = CODE;
Material target = materialList.FirstOrDefault(x => x.MATERIAL_CODE == m.MATERIAL_CODE);
if (target != null)
{
m.MATERIAL_CODE_NAME = target.MATERIAL_NAME;
}
}
}
#endregion
result.Result = dataPage;
}
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> Insert(MaterialBinding info)
{
DataResult<int> result = new DataResult<int>();
try
{
//基本信息
info.PID = Guid.NewGuid().ToString();
MaterialBindingDAL cmdDAL = new MaterialBindingDAL();
result.Result = new MaterialBindingDAL().Insert(info);
result.IsSuccess = true;
return result;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 更新信息
/// <summary>
/// 更新信息
/// </summary>
/// <param name="">信息</param>
/// <returns>更新行数</returns>
public DataResult<int> Update(MaterialBinding info)
{
DataResult<int> result = new DataResult<int>();
try
{
result.Result = new MaterialBindingDAL().Update(info);
result.IsSuccess = true;
return result;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 删除
/// <summary>
/// 删除信息
/// </summary>
/// <param name="">主键串</param>
/// <returns>删除个数</returns>
public DataResult<int> DeleteArray(string strs)
{
int count = 0;
DataResult<int> result = new DataResult<int>();
string[] list = strs.Split(":".ToCharArray());
try
{
foreach (string str in list)
{
count += this.Delete(new MaterialBinding { PID = str });
}
result.Result = count;
result.IsSuccess = true;
return result;
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 删除信息
/// </summary>
/// <param name="">信息</param>
/// <returns>删除个数</returns>
public int Delete(MaterialBinding info)
{
try
{
return new MaterialBindingDAL().Del(info);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
}
}