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

327 lines
9.8 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QMAPP.BLL;
using QMAPP.Entity;
using QMAPP.MD.Entity;
using QMAPP.MD.DAL;
using QMFrameWork.Data;
using QMFrameWork.Log;
namespace QMAPP.MD.BLL
{
/// <summary>
/// 模块名称:工厂
/// 作 者:郭兆福
/// 编写日期:2017年05月04日
/// </summary>
public class FactoryBLL : BaseBLL
{
#region 获取信息
/// <summary>
/// 获取信息
/// </summary>
/// <param name="">条件</param>
/// <returns>信息</returns>
public DataResult<Factory> Get(Factory model)
{
DataResult<Factory> result = new DataResult<Factory>();
try
{
Factory factoryObj = new FactoryDAL().Get(model);
factoryObj.FACTORY_CODE_OLD = factoryObj.FACTORY_CODE;
result.Result = factoryObj;
}
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(Factory condition, DataPage page)
{
DataResult<DataPage> result = new DataResult<DataPage>();
try
{
//获取工厂信息列表
DataPage dataPage = new FactoryDAL().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<Factory> GetAllList(Factory condition)
{
try
{
//获取物料信息列表
List<Factory> list = new FactoryDAL().GetAllList(condition);
return list;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 得到当前公司信息
/// <summary>
/// 得到公司信息
/// </summary>
/// <returns>当前公司信息</returns>
public Corp GetCurrentCorp()
{
try
{
return new CorpDAL().Get();
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 信息是否重复
/// <summary>
/// 判断名称是否存在
/// </summary>
/// <param name="info"></param>
/// <returns>true:已存在;false:不存在。</returns>
public bool ExistsFactory(Factory model)
{
try
{
return new FactoryDAL().ExistsFactory(model);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 判断工厂是否被使用
/// <summary>
/// 判断工厂是否被使用
/// </summary>
/// <param name="factoryAry">工厂信息</param>
/// <param name="isDel">是否是删除</param>
/// <returns>true:已使用;false:未使用。</returns>
public bool IsFactoryUsed(string[] factoryAry, bool isDel)
{
try
{
//用到工厂基础信息表
List<string> tableList = new List<string>();
//MD_工作中心
tableList.Add("T_MD_WORKCENTER");
//MD_工厂物料
tableList.Add("T_MD_MATERIAL_IN_FACTORY");
//MD_工厂PBOM
tableList.Add("T_MD_PBOM_IN_FACTORY");
//QT_班组
tableList.Add("T_QT_TEAM");
//QT_班次信息
tableList.Add("T_QT_SHIFT");
//MD_工厂工艺
tableList.Add("T_MD_FACTORY_PROCESS");
//MD_替代工艺路线
tableList.Add("T_MD_SUBSTITUTE_ROUTE");
return new FactoryDAL().IsFactoryUsed(factoryAry, tableList, isDel);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 插入信息
/// <summary>
/// 插入信息(单表)
/// </summary>
/// <param name="">信息</param>
/// <returns>插入行数</returns>
public DataResult<int> Insert(Factory model)
{
DataResult<int> result = new DataResult<int>();
//基本信息
model.PID = Guid.NewGuid().ToString();
model.FLGDEL = "0";
model.CREATEUSER = this.LoginUser.UserID;
model.UPDATEUSER = model.CREATEUSER;
FactoryDAL cmdDAL = new FactoryDAL();
try
{
if (ExistsFactory(model) == true)
{
result.IsSuccess = false;
result.Msg = Resource.CodeExists;
return result;
}
model.CORP_CODE = GetCurrentCorp().CORP_CODE;
if (string.IsNullOrEmpty(model.CORP_CODE) == true)
{
result.IsSuccess = false;
result.Msg = Resource.CorpNotExists;
return result;
}
result.Result = new FactoryDAL().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(Factory model)
{
DataResult<int> result = new DataResult<int>();
model.UPDATEUSER = this.LoginUser.UserID;
try
{
if (ExistsFactory(model) == true)
{
result.IsSuccess = false;
result.Msg = Resource.CodeExists;
return result;
}
// 工厂编号修改
if (model.FACTORY_CODE_OLD != model.FACTORY_CODE)
{
string[] param = { model.FACTORY_CODE_OLD };
if (IsFactoryUsed(param, false) == true)
{
result.IsSuccess = false;
result.Msg = Resource.FactoryUsed;
return result;
}
}
result.Result = new FactoryDAL().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 (IsFactoryUsed(list, true) == true)
{
result.IsSuccess = false;
result.Msg = Resource.UsedNotDeleted;
return result;
}
count = this.DeleteFactory(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 DeleteFactory(string[] pidAry)
{
int count = 0;
count = new FactoryDAL().Delete(pidAry, this.LoginUser.UserID);
return count;
}
#endregion
#region 获取工厂列表(下拉列表使用)
/// <summary>
/// 获取列表
/// </summary>
/// <param name="condition">条件</param>
/// <returns>全部集合</returns>
public DataResult<List<Factory>> GetFactoryList(Factory condition)
{
DataResult<List<Factory>> result = new DataResult<List<Factory>>();
try
{
result.Result = new FactoryDAL().GetAllList(condition);
}
catch (Exception ex)
{
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
#endregion
}
}