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

281 lines
9.0 KiB

using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using QMFrameWork.Data;
using QMAPP.Entity;
using QMAPP.BLL;
using QMAPP.BLL.Sys;
using QMAPP.DAL;
using QMAPP.MD.BLL.Dict;
using QMAPP.MD.Entity;
using QMAPP.MD.DAL;
using QMAPP.FJC.DAL.QT;
namespace QMAPP.MD.BLL
{
/// <summary>
/// 模块名称:采集数据借口
/// 作 者:QMMES
/// 编写日期:2017年09月05日
/// </summary>
public class DaiBLL : BaseBLL
{
#region 获取信息
/// <summary>
/// 获取信息
/// </summary>
/// <param name="">条件</param>
/// <returns>信息</returns>
public Dai Get(Dai info)
{
try
{
return new DaiDAL().Get(info);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取列表
/// <summary>
/// 获取列表
/// </summary>
/// <param name="condition">条件</param>
/// <param name="page">数据页</param>
/// <returns>数据页</returns>
public DataPage GetList(Dai condition, DataPage page)
{
try
{
var p = new DaiDAL().GetList(condition, page);
#region 翻译
List<Dai> pList = p.Result as List<Dai>;
var workCellList = new WorkCellBLL().GetAllList(new WorkCell());
var materialClassList = new MaterialBLL().GetMaterialClassList(new MaterialClass()).Result;
var materialList = new MaterialBLL().GetMaterialList(new Material());
var analyzerList = new AnalyzerDAL().GetList();
var stateCodeList = GetWorkCellStateCodeList("");
var UserList = new UserManageBLL().GetUserComboxSource();
DictManageBLL dictDataType = new DictManageBLL(DictKind.DataType);
DictManageBLL dictDaMode = new DictManageBLL(DictKind.DaMode);
DictManageBLL dictIsProcessCode = new DictManageBLL(DictKind.IsProcessCode);
DictManageBLL dictDivbyMould = new DictManageBLL(DictKind.DivbyMould);
foreach (Dai m in pList)
{
//采集类型
m.DATA_TYPE_NAME = dictDataType.GetDictValue(m.DATA_TYPE);
//采集方式
m.DA_MODE_NAME = dictDaMode.GetDictValue(m.DA_MODE);
//过程主码
m.ISPROCESSCODE_NAME = dictIsProcessCode.GetDictValue(m.ISPROCESSCODE);
//区分模具
m.DIVBY_MOULD_NAME = dictDivbyMould.GetDictValue(m.DIVBY_MOULD);
//工序
var workCell = workCellList.FirstOrDefault(x => x.WORKCELL_CODE == m.WORKCELL_CODE);
if (workCell != null)
m.WORKCELL_NAME = workCell.WORKCELL_NAME;
//物料类型
var materialClass = materialClassList.FirstOrDefault(x => x.MATERIAL_TYPE_CODE == m.MATERIAL_TYPE);
if (materialClass != null)
m.MATERIAL_TYPE_NAME = materialClass.MATERIAL_TYPE_NAME;
//物料号 如何MATERIAL_CODE==MATERIAL_TYPE说明页面选的是类型
if (m.MATERIAL_TYPE == m.MATERIAL_CODE)
{
m.MATERIAL_CODE = null;
}
else
{
var material = materialList.FirstOrDefault(x => x.MATERIAL_CODE == m.MATERIAL_CODE);
if (material != null)
m.MATERIAL_CODE_NAME = material.MATERIAL_NAME;
}
//解析类别
var analyzer = analyzerList.FirstOrDefault(x => x.ANALYZER_CODE == m.ANALYZE_CODE);
if (analyzer != null)
m.ANALYZE_CODE_NAME = analyzer.ANALYZER_NAME;
//状态码
var stateCode = stateCodeList.FirstOrDefault(x => x.STATE_CODE == m.STATE_CODE);
if (stateCode != null)
m.STATE_NAME = stateCode.STATE_NAME;
//创建人员
var userCreat = UserList.FirstOrDefault(x => x.UserID == m.CREATEUSER);
if (userCreat != null)
m.CREATEUSER_NAME = userCreat.UserName;
//更新人员
var userUpdate = UserList.FirstOrDefault(x => x.UserID == m.UPDATEUSER);
if (userUpdate != null)
m.UPDATEUSER_NAME = userUpdate.UserName;
}
#endregion
return p;
}
catch (Exception ex)
{
throw ex;
}
}
//获取状态码的下拉框
public List<Dai> GetWorkCellStateCodeList(string workCellCode)
{
try
{
return new DaiDAL().GetWorkCellStateCodeList(workCellCode);
}
catch (Exception e)
{
throw e;
}
}
#endregion
#region 信息是否重复
/// <summary>
/// 判断名称是否存在
/// </summary>
/// <param name="">信息</param>
/// <returns>true:已存在;fasel:不存在。</returns>
public bool Exists(Dai info)
{
try
{
return new DaiDAL().Exists(info);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 插入信息
/// <summary>
/// 插入信息(单表)
/// </summary>
/// <param name="">信息</param>
/// <returns>插入行数</returns>
public DataResult<int> Insert(Dai info)
{
DataResult<int> result = new DataResult<int>();
try
{
//基本信息
info.PID = Guid.NewGuid().ToString();
info.CREATEUSER = this.LoginUser.UserID;
info.CREATEDATE = DateTime.Now;
info.UPDATEUSER = info.CREATEUSER;
info.UPDATEDATE = info.CREATEDATE;
//if (Exists(info) == true)
//{
// result.IsSuccess = false;
// result.Msg = Resource.MaterielCodeIsHave;
// return result;
//}
DaiDAL cmdDAL = new DaiDAL();
result.Result = new DaiDAL().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(Dai info)
{
DataResult<int> result = new DataResult<int>();
try
{
info.UPDATEUSER = this.LoginUser.UserID;
info.UPDATEDATE = DateTime.Now;
//if (Exists(info) == true)
//{
// result.IsSuccess = false;
// result.Msg = Resource.MaterielCodeIsHave;
// return result;
//}
result.Result = new DaiDAL().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 Dai { 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(Dai info)
{
try
{
return new DaiDAL().Del(info);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
}
}