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

285 lines
8.5 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QMAPP.BLL;
using QMFrameWork.Data;
using QMAPP.Entity;
using QMFrameWork.Log;
using System.Data;
using QMAPP.FJC.Entity;
using QMAPP.FJC.DAL;
using QMAPP.FJC.Entity.CCParameters;
using QMAPP.FJC.DAL.CCParameters;
namespace QMAPP.FJC.BLL.CCParameters
{
/// <summary>
/// 作 用:加工参数采集
/// 作 者:张松男
/// 编写日期:2023年02月06日
///</summary>
public class PARAMETERSCONFIGBLL : BaseBLL
{
#region 获取信息
/// <summary>
/// 获取信息
/// </summary>
/// <param name="">条件</param>
/// <returns>信息</returns>
public DataResult<PARAMETERSCONFIG> Get(PARAMETERSCONFIG model)
{
DataResult<PARAMETERSCONFIG> result = new DataResult<PARAMETERSCONFIG>();
try
{
result.Result = new PARAMETERSCONFIGDAL().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(PARAMETERSCONFIG condition, DataPage page)
{
DataResult<DataPage> result = new DataResult<DataPage>();
try
{
//获取物料信息列表
DataPage dataPage = new PARAMETERSCONFIGDAL().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>
/// <returns></returns>
public List<PARAMETERSCONFIG> GetAllList()
{
return new PARAMETERSCONFIGDAL().GetAllList();
}
#endregion
#region 信息是否重复
/// <summary>
/// 判断名称是否存在
/// </summary>
/// <param name="">信息</param>
/// <returns>true:已存在;fasel:不存在。</returns>
public bool Exists(PARAMETERSCONFIG info)
{
try
{
return new PARAMETERSCONFIGDAL().Exists(info);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 插入信息
/// <summary>
/// 插入信息(单表)
/// </summary>
/// <param name="">信息</param>
/// <returns>插入行数</returns>
public DataResult<int> Insert(PARAMETERSCONFIG info)
{
DataResult<int> result = new DataResult<int>();
try
{
//基本信息
info.pid = Guid.NewGuid().ToString();
info.createdata = DateTime.Now;
info.creatauser = LoginUser.LoginUserID;
PARAMETERSCONFIGDAL cmdDAL = new PARAMETERSCONFIGDAL();
result.Result = new PARAMETERSCONFIGDAL().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(PARAMETERSCONFIG info)
{
DataResult<int> result = new DataResult<int>();
try
{
result.Result = new PARAMETERSCONFIGDAL().Update(info);
result.IsSuccess = true;
return result;
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 删除
/// <summary>
/// 删除信息
/// </summary>
/// <param name="">主键串</param>
/// <returns>删除个数</returns>
public DataResult<int> Delete(string strs)
{
int count = 0;
DataResult<int> result = new DataResult<int>();
string[] list = strs.Split(":".ToCharArray());
try
{
foreach (string str in list)
{
count += this.DeleteBarcodeRules(new PARAMETERSCONFIG { pid = str });
}
result.Result = count;
result.IsSuccess = true;
return result;
}
catch (Exception ex)
{
throw ex;
}
}
/// <summary>
/// 删除信息
/// </summary>
/// <param name="">信息</param>
/// <returns>删除个数</returns>
public int DeleteBarcodeRules(PARAMETERSCONFIG info)
{
try
{
return new PARAMETERSCONFIGDAL().Delete(info);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 导出数据
/// <summary>
/// 获取导出的数据
/// </summary>
/// <param name="">查询条件</param>
/// <returns>数据</returns>
public DataTable GetExportData(PARAMETERSCONFIG info)
{
try
{
return new PARAMETERSCONFIGDAL().GetExportData(info);
}
catch (Exception ex)
{
throw ex;
}
}
#endregion
#region 导入数据
/// <summary>
/// 导入数据
/// </summary>
/// <param name="list">数据</param>
/// <returns>导入结果</returns>
public DataResult<ImportMessage> ImportData(List<PARAMETERSCONFIG> list)
{
DataResult<ImportMessage> result = new DataResult<ImportMessage>();
PARAMETERSCONFIGDAL cmDal = new PARAMETERSCONFIGDAL();
List<PARAMETERSCONFIG> List = new List<PARAMETERSCONFIG>();
int index = 0;
try
{
result.Result = new ImportMessage();
result.Result.Errors = new List<RowError>();
using (IDataSession session = AppDataFactory.CreateMainSession())
{
//状态判断
foreach (PARAMETERSCONFIG ma in list)
{
index++;
if (!string.IsNullOrEmpty(ma.InfoError))
{
ma.pid = null;
result.Result.failureNum += 1;
continue;
}
//修改改时根据主键等信息获取详细内容信息
PARAMETERSCONFIG oldInfo = cmDal.Get(ma);
if (oldInfo != null)
{
//更新
ma.pid = oldInfo.pid;
ma.IsNewInfo = false;
result.Result.updateNum += 1;
}
else
{
//新增
oldInfo = new PARAMETERSCONFIG();
ma.pid = Guid.NewGuid().ToString();
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
}
}