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
{
///
/// 模块名称:采集数据借口-状态码配置
/// 作 者:周晓东
/// 编写日期:2010514
///
public class WorkCellStateBLL : BaseBLL
{
#region 获取信息
///
/// 获取信息
///
/// 条件
/// 信息
public WorkCellState Get(WorkCellState info)
{
try
{
return new WorkCellStateDAL().Get(info);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取列表
///
/// 获取列表
///
/// 条件
/// 数据页
/// 数据页
public DataPage GetList(WorkCellState condition, DataPage page)
{
try
{
var p = new WorkCellStateDAL().GetList(condition, page);
//#region 翻译
//List pList = p.Result as List;
//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 (WorkCellState 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;
}
}
#endregion
#region 插入信息
///
/// 插入信息(单表)
///
/// 信息
/// 插入行数
public DataResult Insert(WorkCellState info)
{
DataResult result = new DataResult();
try
{
//基本信息
info.PID = Guid.NewGuid().ToString();
info.CREATEUSER = this.LoginUser.UserID;
info.CREATEDATE = DateTime.Now;
info.UPDATEUSER = info.CREATEUSER;
info.UPDATEDATE = info.CREATEDATE;
//if (info.Details != null)
//{
// foreach (WorkCellStateData detail in info.Details)
// {
// detail.PID = Guid.NewGuid().ToString();
// detail.DA_CODE = info.PID;
// }
//}
WorkCellStateDAL cmdDAL = new WorkCellStateDAL();
result.Result = new WorkCellStateDAL().Insert(info);
result.IsSuccess = true;
return result;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 更新信息
///
/// 更新信息
///
/// 信息
/// 更新行数
public DataResult Update(WorkCellState info)
{
DataResult result = new DataResult();
try
{
info.UPDATEUSER = this.LoginUser.UserID;
info.UPDATEDATE = DateTime.Now;
//if (info.Details != null)
//{
// foreach (WorkCellStateData detail in info.Details)
// {
// detail.PID = Guid.NewGuid().ToString();
// detail.DA_CODE = info.PID;
// }
//}
result.Result = new WorkCellStateDAL().Update(info);
result.IsSuccess = true;
return result;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 删除
///
/// 删除信息
///
/// 主键串
/// 删除个数
public DataResult DeleteArray(string strs)
{
int count = 0;
DataResult result = new DataResult();
string[] list = strs.Split(":".ToCharArray());
try
{
foreach (string str in list)
{
count += this.Delete(new WorkCellState { PID = str });
}
result.Result = count;
result.IsSuccess = true;
return result;
}
catch (Exception ex)
{
throw ex;
}
}
///
/// 删除信息
///
/// 信息
/// 删除个数
public int Delete(WorkCellState info)
{
try
{
return new WorkCellStateDAL().Del(info);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 获取录入退出
///
/// 获取录入退出
///
/// 数据源
public List GetEntryExitActionList()
{
try
{
return new WorkCellStateDAL().GetEntryExitActionList();
}
catch (Exception e)
{
throw e;
}
}
#endregion
}
}