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.
289 lines
8.5 KiB
289 lines
8.5 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using QMFrameWork.Data;
|
|
using QMAPP.Entity;
|
|
using QMAPP.FJC.Entity.QT;
|
|
using QMAPP.FJC.BLL.QT;
|
|
using QMAPP.FJC.DAL.QT;
|
|
using QMAPP.BLL;
|
|
|
|
namespace QMAPP.FJC.BLL.QT
|
|
{
|
|
/// <summary>
|
|
/// 模块名称:数据采集接口BLL
|
|
/// 作 者:张鹏
|
|
/// 编写日期:2017年08月31日
|
|
/// </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 GetPageList(DAI condition, DataPage page)
|
|
{
|
|
try
|
|
{
|
|
return new DAIDAL().GetList(condition, page);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 获取列表
|
|
/// </summary>
|
|
/// <param name="condition">条件</param>
|
|
public List<DAI> GetList(DAI condition)
|
|
{
|
|
return new DAIDAL().GetList(condition);
|
|
}
|
|
/// <summary>
|
|
/// 获取绑定启动信号的采集点编码
|
|
/// </summary>
|
|
/// <param name="workcellcode"></param>
|
|
/// <param name="mouldcode"></param>
|
|
/// <returns></returns>
|
|
public DataResult<string> GetSignalDAI(string workcellcode, string mouldcode)
|
|
{
|
|
var result = new DataResult<string>();
|
|
result.Result = new DAIDAL().GetSignalDAI(workcellcode, mouldcode);
|
|
return result;
|
|
}
|
|
|
|
#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;
|
|
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;
|
|
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().Delete(info);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 导出数据
|
|
/// <summary>
|
|
/// 获取导出的数据
|
|
/// </summary>
|
|
/// <param name="">查询条件</param>
|
|
/// <returns>数据</returns>
|
|
public DataTable GetExportData(DAI info)
|
|
{
|
|
try
|
|
{
|
|
return new DAIDAL().GetExportData(info);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
throw ex;
|
|
}
|
|
}
|
|
#endregion
|
|
|
|
#region 导入数据
|
|
/// <summary>
|
|
/// 导入数据
|
|
/// </summary>
|
|
/// <param name="list">数据</param>
|
|
/// <returns>导入结果</returns>
|
|
public DataResult<ImportMessage> ImportData(List<DAI> list)
|
|
{
|
|
DataResult<ImportMessage> result = new DataResult<ImportMessage>();
|
|
DAIDAL cmDal = new DAIDAL();
|
|
List<DAI> List = new List<DAI>();
|
|
int index = 0;
|
|
try
|
|
{
|
|
result.Result = new ImportMessage();
|
|
result.Result.Errors = new List<RowError>();
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
//状态判断
|
|
foreach (DAI ma in list)
|
|
{
|
|
index++;
|
|
if (!string.IsNullOrEmpty(ma.InfoError))
|
|
{
|
|
ma.PID = null;
|
|
result.Result.failureNum += 1;
|
|
continue;
|
|
}
|
|
//修改改时根据主键等信息获取详细内容信息
|
|
DAI oldInfo = cmDal.Get(ma);
|
|
if (oldInfo != null)
|
|
{
|
|
//更新
|
|
ma.PID = oldInfo.PID;
|
|
ma.CREATEUSER = oldInfo.CREATEUSER;
|
|
ma.CREATEDATE = oldInfo.CREATEDATE;
|
|
ma.UPDATEUSER = this.LoginUser.UserID;
|
|
ma.UPDATEDATE = oldInfo.UPDATEDATE;
|
|
ma.IsNewInfo = false;
|
|
result.Result.updateNum += 1;
|
|
}
|
|
else
|
|
{
|
|
//新增
|
|
oldInfo = new DAI();
|
|
ma.PID = Guid.NewGuid().ToString();
|
|
ma.CREATEUSER = this.LoginUser.UserID;
|
|
ma.CREATEDATE = DateTime.Now;
|
|
ma.UPDATEUSER = ma.CREATEUSER;
|
|
ma.UPDATEDATE = ma.UPDATEDATE;
|
|
ma.IsNewInfo = true;
|
|
result.Result.insertNum += 1;
|
|
}
|
|
List.Add(ma);
|
|
}
|
|
}
|
|
//导入
|
|
cmDal.GetImportData(List);
|
|
result.Msg = "导入成功";
|
|
result.IsSuccess = true;
|
|
return result;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
result.IsSuccess = false;
|
|
result.Ex = ex;
|
|
return result;
|
|
}
|
|
}
|
|
#endregion
|
|
}
|
|
|
|
}
|
|
|