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

428 lines
13 KiB

using System;
using System.Collections.Generic;
using QMAPP.BLL;
using QMAPP.Entity;
using QMAPP.MD.DAL;
using QMFrameWork.Data;
using WorkCellEquipment = QMAPP.MD.Entity.WorkCellEquipment;
using WorkLoc = QMAPP.MD.Entity.WorkLoc;
namespace QMAPP.MD.BLL
{
/// <summary>
/// 模块名称:工位
/// 作 者:郭兆福
/// 编写日期:2017年05月11日
/// </summary>
public class WorkLocBLL : BaseBLL
{
#region 获取信息
/// <summary>
/// 获取信息
/// </summary>
/// <param name="">条件</param>
/// <returns>信息</returns>
public DataResult<WorkLoc> Get(WorkLoc model)
{
DataResult<WorkLoc> result = new DataResult<WorkLoc>();
try
{
result.Result = new WorkLocDAL().Get(model);
}
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(WorkLoc condition, DataPage page)
{
DataResult<DataPage> result = new DataResult<DataPage>();
try
{
//获取信息列表
DataPage dataPage = new WorkLocDAL().GetList(condition, page);
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<WorkLoc> GetAllList(WorkLoc condition)
{
try
{
//获取物料信息列表
List<WorkLoc> list = new WorkLocDAL().GetList(condition);
return list;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 信息是否重复
/// <summary>
/// 判断编码名称是否存在
/// </summary>
/// <param name="info"></param>
/// <returns>true:不存在;false:已存在</returns>
public DataResult<bool> IsExistsWorkLoc(WorkLoc model)
{
DataResult<bool> result = new DataResult<bool>();
try
{
if (new WorkLocDAL().IsExistsWorkLocCode(model) == true)
{
result.IsSuccess = false;
result.Msg = "相同的工位编码已经存在";
return result;
}
}
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(WorkLoc model)
{
DataResult<int> result = new DataResult<int>();
WorkLocDAL cmdDAL = new WorkLocDAL();
//基本信息
model.FLGDEL = "0";
model.PID = Guid.NewGuid().ToString();
model.CREATEUSER = this.LoginUser.UserID;
model.UPDATEUSER = model.CREATEUSER;
try
{
DataResult<bool> isExist = new DataResult<bool>();
isExist = IsExistsWorkLoc(model);
if (isExist.IsSuccess == false)
{
result.IsSuccess = false;
result.Msg = isExist.Msg;
return result;
}
result.Result = new WorkLocDAL().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(WorkLoc model)
{
DataResult<int> result = new DataResult<int>();
//基本信息
model.UPDATEUSER = this.LoginUser.UserID;
try
{
DataResult<bool> isExist = new DataResult<bool>();
isExist = IsExistsWorkLoc(model);
if (isExist.IsSuccess == false)
{
result.IsSuccess = false;
result.Msg = isExist.Msg;
return result;
}
result.Result = new WorkLocDAL().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 (new WorkLocDAL().IsUsedWorkLocCode(list) == true)
{
result.IsSuccess = false;
result.Msg = "准备删除的数据已被使用,删除不可!";
return result;
}
foreach (string str in list)
{
result.Result += this.DeleteProcessInfo(new WorkLoc { 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 DeleteProcessInfo(WorkLoc model)
{
int count = 0;
try
{
count = new WorkLocDAL().Delete(model);
return count;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 工位设备相关操作
/// <summary>
/// 得到工位设备信息
/// </summary>
/// <param name="model">工位设备信息</param>
/// <param name="page"></param>
/// <returns></returns>
public DataResult<DataPage> GetWorkLocEquipmentList(WorkCellEquipment model, DataPage page)
{
DataResult<DataPage> result = new DataResult<DataPage>();
try
{
result.Result = new WorkLocDAL().GetWorkLocEquipmentList(model, page);
}
catch (Exception ex)
{
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
/// <summary>
/// 插入工位设备信息
/// </summary>
/// <param name="model">工位设备信息</param>
/// <returns></returns>
public DataResult<int> InsertWorkLocEquip(WorkCellEquipment model)
{
DataResult<int> result = new DataResult<int>();
WorkLocDAL cmdDAL = new WorkLocDAL();
//基本信息
model.FLGDEL = "0";
model.PID = Guid.NewGuid().ToString();
model.CREATEUSER = this.LoginUser.UserID;
model.UPDATEUSER = model.CREATEUSER;
try
{
DataResult<bool> isExist = new DataResult<bool>();
isExist = IsExistsWorkLocEquip(model);
if (isExist.IsSuccess == false)
{
result.IsSuccess = false;
result.Msg = isExist.Msg;
return result;
}
result.Result = new WorkLocDAL().InsertWorkLocEquip(model);
}
catch (Exception ex)
{
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
/// <summary>
/// 判断编码名称是否存在
/// </summary>
/// <param name="model">工位设备信息</param>
/// <returns>true:不存在;false:已存在</returns>
public DataResult<bool> IsExistsWorkLocEquip(WorkCellEquipment model)
{
DataResult<bool> result = new DataResult<bool>();
try
{
if (new WorkLocDAL().IsExistsWorkLocEquip(model) == true)
{
result.IsSuccess = false;
result.Msg = "相同的工位设备已经存在";
return result;
}
}
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 DataResult<int> DeleteWorkLocEquip(string strs)
{
DataResult<int> result = new DataResult<int>();
string[] list = strs.Split(":".ToCharArray());
try
{
foreach (string str in list)
{
result.Result += this.DeleteWorkLocEquipInfo(new WorkCellEquipment { 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 DeleteWorkLocEquipInfo(WorkCellEquipment model)
{
int count = 0;
try
{
count = new WorkLocDAL().DeleteWorkLocEquip(model);
return count;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取(联动)工位下拉列表数据
/// <summary>
/// 获取工序下拉列表数据
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public List<WorkLoc> GetWorkLocFromWorkCellList(WorkLoc model, string routecode)
{
try
{
return new WorkLocDAL().GetWorkLocFromWorkCellList(model, routecode);
}
catch (Exception ex)
{
throw ex;
}
}
public List<WorkLoc> GetWorkLocFromWorkCenterCodeList(string workCenterCode)
{
try
{
return new WorkLocDAL().GetWorkLocFromWorkCenterCodeList(workCenterCode);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 根据工位信息获得工序信息
/// <summary>
/// 获取工序下拉列表数据
/// </summary>
/// <param name="model"></param>
/// <returns></returns>
public List<WorkLoc> GetWorkCellFromWorkLocList(WorkLoc model, string routecode)
{
try
{
return new WorkLocDAL().GetWorkCellFromWorkLocList(model, routecode);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
}
}