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

397 lines
12 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QMAPP.BLL;
using QMAPP.MD.Entity;
using QMAPP.Entity;
using QMFrameWork.Data;
using QMAPP.MD.DAL;
using QMFrameWork.Log;
using QMAPP.MD.Entity.Sys;
using QMAPP.FJC.DAL.Basic;
using QMAPP.FJC.Entity.Basic;
using QMAPP.Entity.Sys;
namespace QMAPP.MD.BLL
{
/// <summary>
/// 模 块:逻辑矩阵
/// 作 者:郭兆福
/// 时 间:2018年04月20日
/// </summary>
public class UserWithMachineBLL : BaseBLL
{
#region 获取信息
/// <summary>
/// 获取信息
/// </summary>
/// <param name="">条件</param>
/// <returns>信息</returns>
public DataResult<UserWithMachine> Get(UserWithMachine model)
{
DataResult<UserWithMachine> result = new DataResult<UserWithMachine>();
try
{
result.Result = new UserWithMachineDAL().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(UserWithMachine condition, DataPage page)
{
DataResult<DataPage> result = new DataResult<DataPage>();
try
{
//获取物料信息列表
DataPage dataPage = new UserWithMachineDAL().GetList(condition, page);
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 ExistsMateriel(UserWithMachine model)
{
try
{
return new UserWithMachineDAL().ExistsMateriel(model);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 插入信息
/// <summary>
/// 插入信息
/// </summary>
/// <param name="">信息</param>
/// <returns>插入行数</returns>
public DataResult<int> InsertUserWithMachine(UserWithMachine model, List<MachineInfo> machinelist)
{
List<UserWithMachine> List = new List<UserWithMachine>();
DataResult<int> result = new DataResult<int>();
UserWithMachineDAL cmdDAL = new UserWithMachineDAL();
cmdDAL.BaseSession = AppDataFactory.CreateMainSession();
foreach (MachineInfo ma in machinelist)
{
UserWithMachine planmodel = new UserWithMachine();
planmodel.PID = Guid.NewGuid().ToString();
planmodel.USERID = model.USERID;
planmodel.MACHINEID = ma.PID;
planmodel.CREATEUSER = this.LoginUser.UserID;
planmodel.CREATEDATE = DateTime.Now;
planmodel.UPDATEUSER = planmodel.CREATEUSER;
planmodel.UPDATEDATE = planmodel.CREATEDATE;
List.Add(planmodel);
}
try
{
if (ExistsMateriel(model))
{
result.IsSuccess = false;
result.Msg = Resource.MaterielCodeIsHave;
return result;
}
result.Result = cmdDAL.InsertUserWithMachine(List);
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "逻辑矩阵逻辑层-插入信息!"
});
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
#endregion
#region 删除
#region 主列表界面点击删除
/// <summary>
/// 主列表界面点击删除
/// </summary>
/// <param name=""></param>
/// <returns>删除个数</returns>
public DataResult<int> Delete(string userid)
{
DataResult<int> result = new DataResult<int>();
string[] list = userid.Split(":".ToCharArray());
try
{
foreach (string str in list)
{
result.Result += this.DeleteUserWithMachine(new UserWithMachine { USERID = userid });
}
}
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 DeleteUserWithMachine(UserWithMachine model)
{
int count = 0;
try
{
count = new UserWithMachineDAL().EditDeleteUserWithMachine(model);
return count;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 编辑时删除
/// <summary>
/// 编辑时删除
/// </summary>
/// <param name=""></param>
/// <returns>删除个数</returns>
public DataResult<int> EditDelete(UserWithMachine model)
{
DataResult<int> result = new DataResult<int>();
if (string.IsNullOrEmpty(model.EDITFLAG))
{
string[] list = model.MachineIds.Split(";".ToCharArray());
try
{
foreach (string str in list)
{
result.Result += this.EditDeleteUserWithMachine(new UserWithMachine { MACHINEID = str, USERID = model.USERID });
}
}
catch (Exception ex)
{
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
}
else
{
try
{
result.Result += this.EditDeleteUserWithMachine(new UserWithMachine {USERID = model.USERID });
}
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 EditDeleteUserWithMachine(UserWithMachine model)
{
int count = 0;
try
{
count = new UserWithMachineDAL().EditDeleteUserWithMachine(model);
return count;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#endregion
#region 获取用户列表(下拉列表使用)
/// <summary>
///
/// </summary>
/// <param name="condition"></param>
/// <returns></returns>
public DataResult<List<User>> GetUserInfoList(User condition)
{
DataResult<List<User>> result = new DataResult<List<User>>();
try
{
result.Result = new UserWithMachineDAL().GetUserInfoList(condition);
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "逻辑矩阵逻辑层-获取列表(绑定下拉列表使用)!"
});
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
#endregion
#region 获取设备信息,填充Grid
/// <summary>
/// 获取设备信息,填充Grid
/// </summary>
/// <param name="condition"></param>
/// <returns></returns>
public MachineInfo GetMachineInfo(MachineInfo condition)
{
MachineInfo material = new MachineInfo();
//根据设备iD获取本体信息
material.PID = condition.PID;
material.Machineids = condition.Machineids;
try
{
List<MachineInfo> materialList = new MachineInfoDAL().GetMachineInfoList(material);
foreach (MachineInfo m in materialList)
{
material.MACHINECODDE = m.MACHINECODDE;
material.MACHINENAME = m.MACHINENAME;
}
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "逻辑矩阵逻辑层-获取本体信息!"
});
throw ex;
}
return material;
}
#endregion
#region 保存时获取设备信息
/// <summary>
/// 获取本体信息
/// </summary>
/// <param name="condition"></param>
/// <returns></returns>
public List<MachineInfo> GetMachineList(MachineInfo condition)
{
//MachineInfo machine = new MachineInfo();
////根据设备主键信息
//machine.Machineids = condition.Machineids;
//machine.PIDS = condition.PIDS;
try
{
return new MachineInfoDAL().GetMachineInfoList(condition);
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "逻辑矩阵逻辑层-获取设备信息!"
});
throw ex;
}
}
#endregion
#region
/// <summary>
///
/// </summary>
/// <param name="condition"></param>
/// <returns></returns>
public DataResult<List<User>> GetUserInfoListForEdit(User condition)
{
DataResult<List<User>> result = new DataResult<List<User>>();
try
{
result.Result = new UserWithMachineDAL().GetUserInfoListForEdit(condition);
}
catch (Exception ex)
{
LogManager.LogHelper.Error(new LogInfo()
{
ErrorInfo = ex,
Tag = ex.StackTrace,
Info = "逻辑矩阵逻辑层-获取列表(绑定下拉列表使用)!"
});
result.IsSuccess = false;
result.Msg = Resource.SystemException;
throw ex;
}
result.IsSuccess = true;
return result;
}
#endregion
public List<UserWithMachine> GetUserAbility(string userid)
{
return new UserWithMachineDAL().GetUserAbility(userid);
}
}
}