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

292 lines
8.9 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QMAPP.BLL;
using QMFrameWork.Log;
using QMAPP.Entity;
using QMAPP.MD.Entity;
using QMAPP.MD.DAL;
using QMFrameWork.Data;
using QMAPP.MD.BLL.Dict;
namespace QMAPP.MD.BLL
{
/// <summary>
/// 模块名称:工作中心
/// 作 者:郭兆福
/// 编写日期:2017年05月09日
/// </summary>
public class WorkCenterBLL : BaseBLL
{
#region 获取信息
/// <summary>
/// 获取信息
/// </summary>
/// <param name="">条件</param>
/// <returns>信息</returns>
public QMAPP.Entity.DataResult<WorkCenter> Get(WorkCenter model)
{
QMAPP.Entity.DataResult<WorkCenter> result = new DataResult<WorkCenter>();
try
{
WorkCenter workCenterObj = new WorkCenterDAL().Get(model);
workCenterObj.WORKCENTER_CODE_OLD = workCenterObj.CENTER_TYPE;
result.Result = workCenterObj;
}
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(WorkCenter condition, DataPage page)
{
DataResult<DataPage> result = new DataResult<DataPage>();
try
{
DataPage dataPage = new WorkCenterDAL().GetList(condition, page);
List<WorkCenter> workCenterList = dataPage.Result as List<WorkCenter>;
DictManageBLL dictBackFlushFlagBll = new DictManageBLL(DictKind.CenterType);
foreach (WorkCenter m in workCenterList)
{
m.CENTER_TYPE = dictBackFlushFlagBll.GetDictValue(m.CENTER_TYPE);
}
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="info"></param>
/// <returns>true:已存在;fasel:不存在。</returns>
public bool ExistsWorkCenter(WorkCenter model)
{
try
{
return new WorkCenterDAL().ExistsWorkCenter(model);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 判断工厂是否被使用
/// <summary>
/// 判断工厂是否被使用
/// </summary>
/// <param name="workCenterAry">工作中心信息</param>
/// <param name="isDel">是否是删除</param>
/// <returns>true:已使用;false:未使用。</returns>
public bool IsWorkCenterUsed(string[] workCenterAry, bool isDel)
{
try
{
//用到工厂基础信息表
List<string> tableList = new List<string>();
//MD_采集设备
tableList.Add("T_MD_EQUIPMENT");
//MD_工序
tableList.Add("T_MD_WORKCELL");
return new WorkCenterDAL().IsWorkCenterUsed(workCenterAry, tableList, isDel);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 插入信息
/// <summary>
/// 插入信息(单表)
/// </summary>
/// <param name="">信息</param>
/// <returns>插入行数</returns>
public DataResult<int> Insert(WorkCenter model)
{
DataResult<int> result = new DataResult<int>();
//基本信息
model.PID = Guid.NewGuid().ToString();
model.FLGDEL = "0";
model.CREATEUSER = this.LoginUser.UserID;
model.UPDATEUSER = model.CREATEUSER;
WorkCenterDAL cmdDAL = new WorkCenterDAL();
try
{
if (ExistsWorkCenter(model) == true)
{
result.IsSuccess = false;
result.Msg = Resource.CodeExists;
return result;
}
result.Result = new WorkCenterDAL().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(WorkCenter model)
{
DataResult<int> result = new DataResult<int>();
model.UPDATEUSER = this.LoginUser.UserID;
try
{
if (ExistsWorkCenter(model) == true)
{
result.IsSuccess = false;
result.Msg = Resource.CodeExists;
return result;
}
// 工作中心编码修改
if (model.WORKCENTER_CODE_OLD != model.CENTER_TYPE)
{
string[] param = { model.WORKCENTER_CODE_OLD };
if (IsWorkCenterUsed(param, false) == true)
{
result.IsSuccess = false;
result.Msg = Resource.WorkCenterUsed;
return result;
}
}
result.Result = new WorkCenterDAL().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)
{
int count = 0;
string[] list = strs.Split(":".ToCharArray());
DataResult<int> result = new DataResult<int>();
try
{
if (IsWorkCenterUsed(list, true) == true)
{
result.IsSuccess = false;
result.Msg = Resource.UsedNotDeleted;
return result;
}
count = this.DeleteWorkCenter(list);
if (count == 0)
{
result.IsSuccess = false;
return result;
}
result.Result = count;
result.IsSuccess = true;
return result;
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 删除信息
/// </summary>
/// <param name="pidAry">要删除的主键</param>
/// <returns>删除个数</returns>
public int DeleteWorkCenter(string[] pidAry)
{
int count = 0;
try
{
count = new WorkCenterDAL().Delete(pidAry, this.LoginUser.UserID);
return count;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取工作中心列表(下拉列表使用)
/// <summary>
///
/// </summary>
/// <param name="condition"></param>
/// <returns></returns>
public DataResult<List<WorkCenter>> GetWorkCenterList(WorkCenter condition)
{
DataResult<List<WorkCenter>> result = new DataResult<List<WorkCenter>>();
try
{
result.Result = new WorkCenterDAL().GetWorkCenterList(condition);
}
catch (Exception ex)
{
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
#endregion
}
}