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.
546 lines
18 KiB
546 lines
18 KiB
4 years ago
|
using System;
|
||
|
using System.Collections.Generic;
|
||
|
using System.Data;
|
||
|
using System.Linq;
|
||
|
using System.Text;
|
||
|
using QMFrameWork.Common.Encrypt;
|
||
|
using QMFrameWork.Data;
|
||
|
using QMAPP.FJC.DAL.Operation;
|
||
|
using QMAPP.FJC.Entity.Operation;
|
||
|
using QMAPP.BLL;
|
||
|
using QMAPP.Entity;
|
||
|
using QMAPP.FJC.BLL.Dict;
|
||
|
using QMFrameWork.Log;
|
||
|
using QMAPP.FJC.Entity;
|
||
|
namespace QMAPP.FJC.BLL.Operation
|
||
|
{
|
||
|
/// <summary>
|
||
|
/// 模块编号:
|
||
|
/// 作 用:零件与投料对应表
|
||
|
/// 作 者:王庆男
|
||
|
/// 编写日期:2015年06月02日
|
||
|
///</summary>
|
||
|
public class ProductInjectionBLL : BaseBLL
|
||
|
{
|
||
|
|
||
|
|
||
|
#region 获取信息
|
||
|
/// <summary>
|
||
|
/// 获取信息
|
||
|
/// </summary>
|
||
|
/// <param name="">条件</param>
|
||
|
/// <returns>信息</returns>
|
||
|
public ProductInjection Get(ProductInjection model)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
return new ProductInjectionDAL().Get(model);
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
#region 获取列表
|
||
|
/// <summary>
|
||
|
/// 获取列表
|
||
|
/// </summary>
|
||
|
/// <param name="condition">条件</param>
|
||
|
/// <param name="page">数据页</param>
|
||
|
/// <returns>数据页</returns>
|
||
|
public DataPage GetList(ProductInjection condition, DataPage page)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
return new ProductInjectionDAL().GetList(condition, page);
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
public List<ProductInjection> GetProductInjections(ProductInjection condition)
|
||
|
{
|
||
|
//DataPage dataPage = new DataPage();
|
||
|
//var desult = new List<ProductInjection>();
|
||
|
//DataResult<DataPage> result = new DataResult<DataPage>();
|
||
|
MainBLL mb = new MainBLL();
|
||
|
try
|
||
|
{
|
||
|
if (string.IsNullOrEmpty(condition.PRODUCTCODE))
|
||
|
{
|
||
|
if (string.IsNullOrEmpty(condition.MAINCODE))
|
||
|
{
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
var m = mb.GetByCondition(new Main { publicCode = condition.MAINCODE });
|
||
|
if (m == null)
|
||
|
{
|
||
|
return null;
|
||
|
}
|
||
|
condition.PRODUCTCODE = m.EPIDERMISCODE;
|
||
|
}
|
||
|
|
||
|
|
||
|
//condition.MAINCODE = main.MAINCODE;
|
||
|
//condition.PRODUCTCODE = main.EPIDERMISCODE;
|
||
|
//dataPage = new ProductInjectionDAL().GetProductInjections(condition);
|
||
|
|
||
|
#region 转换零件类别、物料类别显示类型
|
||
|
List<ProductInjection> machineInfoList = new ProductInjectionDAL().GetProductInjections(condition);
|
||
|
|
||
|
DictManageBLL dictProductTypeBll = new DictManageBLL(DictKind.PRODUCTTYPE);
|
||
|
DictManageBLL dictMaterialTypeBll = new DictManageBLL(DictKind.MATERIALTYPE);
|
||
|
|
||
|
foreach (ProductInjection m in machineInfoList)
|
||
|
{
|
||
|
//产品条码
|
||
|
m.PRODUCTCODE = condition.PRODUCTCODE;
|
||
|
//总成条码
|
||
|
var main = mb.GetByCondition(new Main { publicCode = condition.PRODUCTCODE });
|
||
|
if (main != null)
|
||
|
{
|
||
|
m.MAINCODE = condition.MAINCODE;
|
||
|
}
|
||
|
m.CREATEDATESTR = m.CREATEDATE.ToString("yyyy-MM-dd HH:mm:ss");
|
||
|
//零件类别
|
||
|
m.PRODUCTTYPE = dictProductTypeBll.GetDictValue(m.PRODUCTTYPE);
|
||
|
//物料类别
|
||
|
m.MATERIALTYPE = dictMaterialTypeBll.GetDictValue(m.MATERIALTYPE);
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
//result.Result = dataPage;
|
||
|
//result.IsSuccess = true;
|
||
|
return machineInfoList;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
#region 信息是否重复
|
||
|
/// <summary>
|
||
|
/// 判断名称是否存在
|
||
|
/// </summary>
|
||
|
/// <param name="info"></param>
|
||
|
/// <returns>true:已存在;fasel:不存在。</returns>
|
||
|
public bool ExistsProductInjection(ProductInjection model)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
return new ProductInjectionDAL().ExistsProductInjection(model);
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
/// <summary>
|
||
|
/// 判断投料是否存在
|
||
|
/// </summary>
|
||
|
/// <param name="info"></param>
|
||
|
/// <returns>true:已存在;fasel:不存在。</returns>
|
||
|
public bool ExistsInjection(ProductInjection model)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
return new ProductInjectionDAL().ExistsInjection(model);
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
#region 插入信息
|
||
|
/// <summary>
|
||
|
/// 插入信息(单表)
|
||
|
/// </summary>
|
||
|
/// <param name="">信息</param>
|
||
|
/// <returns>插入行数</returns>
|
||
|
public int Insert(ProductInjection model)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
//基本信息
|
||
|
model.PID = Guid.NewGuid().ToString();
|
||
|
model.CREATEUSER = this.LoginUser.UserID;
|
||
|
model.CREATEDATE = DateTime.Now;
|
||
|
model.UPDATEUSER = model.CREATEUSER;
|
||
|
model.UPDATEDATE = model.CREATEDATE;
|
||
|
ProductInjectionDAL cmdDAL = new ProductInjectionDAL();
|
||
|
if (ExistsProductInjection(model) == true)
|
||
|
return -1;
|
||
|
return new ProductInjectionDAL().Insert(model);
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
#region 更新信息
|
||
|
/// <summary>
|
||
|
/// 更新信息
|
||
|
/// </summary>
|
||
|
/// <param name=""></param>
|
||
|
/// <returns>更新行数</returns>
|
||
|
public int Update(ProductInjection model)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
//if (ExistsProductInjection(Model) == true)
|
||
|
//return -1;
|
||
|
//基本信息
|
||
|
model.UPDATEUSER = this.LoginUser.UserID;
|
||
|
return new ProductInjectionDAL().Update(model);
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
#region 删除
|
||
|
/// <summary>
|
||
|
/// 删除信息
|
||
|
/// </summary>
|
||
|
/// <param name=""></param>
|
||
|
/// <returns>删除个数</returns>
|
||
|
public DataResult<int> Delete(string strs)
|
||
|
{
|
||
|
DataResult<int> result = new DataResult<int>();
|
||
|
string[] list = strs.Split(":".ToCharArray());
|
||
|
try
|
||
|
{
|
||
|
foreach (string str in list)
|
||
|
{
|
||
|
result.Result += this.DeleteProductInjection(new ProductInjection { PID = str });
|
||
|
}
|
||
|
result.IsSuccess = true;
|
||
|
result.Msg = Resource.MsgSuccess;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
LogManager.LogHelper.Error(new LogInfo()
|
||
|
{
|
||
|
ErrorInfo = ex,
|
||
|
Tag = ex.StackTrace,
|
||
|
Info = "原材料投料-删除信息"
|
||
|
});
|
||
|
result.IsSuccess = false;
|
||
|
result.Msg = Resource.SystemException;
|
||
|
}
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
|
||
|
/// <summary>
|
||
|
/// 删除信息
|
||
|
/// </summary>
|
||
|
/// <param name="">信息</param>
|
||
|
/// <returns>删除个数</returns>
|
||
|
public int DeleteProductInjection(ProductInjection model)
|
||
|
{
|
||
|
int count = 0;
|
||
|
try
|
||
|
{
|
||
|
count = new ProductInjectionDAL().Delete(model);
|
||
|
return count;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
#region 导出数据
|
||
|
/// <summary>
|
||
|
/// 获取导出的数据
|
||
|
/// </summary>
|
||
|
/// <param name="user">查询条件</param>
|
||
|
/// <returns>数据</returns>
|
||
|
public DataTable GetExportData(ProductInjection model)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
return new ProductInjectionDAL().GetExportData(model);
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
|
||
|
#region 导入数据
|
||
|
public DataResult<ImportMessage> GetImportData(List<ProductInjection> list)
|
||
|
{
|
||
|
DataResult<ImportMessage> result = new DataResult<ImportMessage>();
|
||
|
ProductInjectionDAL cmDal = new ProductInjectionDAL();
|
||
|
List<ProductInjection> List = new List<ProductInjection>();
|
||
|
int index = 0;
|
||
|
try
|
||
|
{
|
||
|
result.Result = new ImportMessage();
|
||
|
result.Result.Errors = new List<RowError>();
|
||
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
||
|
{
|
||
|
//状态判断
|
||
|
foreach (ProductInjection ma in list)
|
||
|
{
|
||
|
index++;
|
||
|
if (string.IsNullOrEmpty(ma.InfoError) == false)
|
||
|
{
|
||
|
ma.PID = null;
|
||
|
result.Result.failureNum += 1;
|
||
|
continue;
|
||
|
}
|
||
|
//修改改时根据主键等信息获取详细内容信息
|
||
|
ProductInjection 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 ProductInjection();
|
||
|
ma.PID = Guid.NewGuid().ToString();
|
||
|
ma.CREATEUSER = this.LoginUser.UserID;
|
||
|
ma.CREATEDATE = DateTime.Now;
|
||
|
ma.UPDATEUSER = ma.CREATEUSER;
|
||
|
ma.UPDATEDATE = ma.CREATEDATE;
|
||
|
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
|
||
|
|
||
|
|
||
|
#region 产品批次追溯
|
||
|
|
||
|
#region 获取列表
|
||
|
/// <summary>
|
||
|
/// 获取列表
|
||
|
/// </summary>
|
||
|
/// <param name="condition">条件</param>
|
||
|
/// <param name="page">数据页</param>
|
||
|
/// <returns>数据页</returns>
|
||
|
public DataResult<DataPage> GetProductInjectionList(ProductInjection condition, DataPage page)
|
||
|
{
|
||
|
DataPage dataPage = new DataPage();
|
||
|
dataPage.Result = new List<ProductInjection>();
|
||
|
DataResult<DataPage> result = new DataResult<DataPage>();
|
||
|
try
|
||
|
{
|
||
|
if (string.IsNullOrEmpty(condition.PRODUCTCODE)
|
||
|
&& string.IsNullOrEmpty(condition.MAINCODE)
|
||
|
)
|
||
|
{
|
||
|
result.Result = dataPage;
|
||
|
result.IsSuccess = true;
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
Main main = new MainDAL().GetMain(new Main { EPIDERMISCODE = condition.PRODUCTCODE ,MAINCODE=condition.MAINCODE });
|
||
|
if (main == null)
|
||
|
{
|
||
|
result.Msg = Resource.OperationMainNotFound;
|
||
|
result.Result = dataPage;
|
||
|
result.IsSuccess = false;
|
||
|
return result;
|
||
|
}
|
||
|
|
||
|
condition.MAINCODE = main.MAINCODE;
|
||
|
condition.PRODUCTCODE = main.EPIDERMISCODE;
|
||
|
dataPage = new ProductInjectionDAL().GetProductInjectionList(condition, page);
|
||
|
|
||
|
#region 转换零件类别、物料类别显示类型
|
||
|
List<ProductInjection> machineInfoList = dataPage.Result as List<ProductInjection>;
|
||
|
|
||
|
DictManageBLL dictProductTypeBll = new DictManageBLL(DictKind.PRODUCTTYPE);
|
||
|
DictManageBLL dictMaterialTypeBll = new DictManageBLL(DictKind.MATERIALTYPE);
|
||
|
|
||
|
foreach (ProductInjection m in machineInfoList)
|
||
|
{
|
||
|
//零件类别
|
||
|
m.PRODUCTTYPE = dictProductTypeBll.GetDictValue(m.PRODUCTTYPE);
|
||
|
//物料类别
|
||
|
m.MATERIALTYPE = dictMaterialTypeBll.GetDictValue(m.MATERIALTYPE);
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
result.Result = dataPage;
|
||
|
result.IsSuccess = true;
|
||
|
return result;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#region 导出数据
|
||
|
/// <summary>
|
||
|
/// 获取导出的数据
|
||
|
/// </summary>
|
||
|
/// <param name="user">查询条件</param>
|
||
|
/// <returns>数据</returns>
|
||
|
public DataTable GetExportDataForPI(ProductInjection model)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
if (string.IsNullOrEmpty(model.PRODUCTCODE)
|
||
|
&& string.IsNullOrEmpty(model.MAINCODE)
|
||
|
)
|
||
|
{
|
||
|
return new DataTable();
|
||
|
}
|
||
|
|
||
|
Main main = new MainDAL().GetMain(new Main { EPIDERMISCODE = model.PRODUCTCODE, MAINCODE = model.MAINCODE });
|
||
|
if (main == null)
|
||
|
{
|
||
|
return new DataTable();
|
||
|
}
|
||
|
|
||
|
model.MAINCODE = main.MAINCODE;
|
||
|
model.PRODUCTCODE = main.EPIDERMISCODE;
|
||
|
|
||
|
DataTable dt = new ProductInjectionDAL().GetExportDataForPI(model);
|
||
|
|
||
|
#region 转换零件类别、物料类别显示类型
|
||
|
DictManageBLL dictProductTypeBll = new DictManageBLL(DictKind.PRODUCTTYPE);
|
||
|
DictManageBLL dictMaterialTypeBll = new DictManageBLL(DictKind.MATERIALTYPE);
|
||
|
|
||
|
foreach (DataRow item in dt.Rows)
|
||
|
{
|
||
|
//零件类别
|
||
|
item["PRODUCTTYPE"] = dictProductTypeBll.GetDictValue(item["PRODUCTTYPE"].ToString());
|
||
|
//物料类别
|
||
|
item["MATERIALTYPE"] = dictMaterialTypeBll.GetDictValue(item["MATERIALTYPE"].ToString());
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
return dt;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
public DataTable GetExportDataForPINew(ProductInjection model)
|
||
|
{
|
||
|
try
|
||
|
{
|
||
|
//if (string.IsNullOrEmpty(model.PRODUCTCODE)
|
||
|
// && string.IsNullOrEmpty(model.MAINCODE)
|
||
|
// )
|
||
|
//{
|
||
|
// return new DataTable();
|
||
|
//}
|
||
|
|
||
|
//Main main = new MainDAL().GetMain(new Main { EPIDERMISCODE = model.PRODUCTCODE, MAINCODE = model.MAINCODE });
|
||
|
//if (main == null)
|
||
|
//{
|
||
|
// return new DataTable();
|
||
|
//}
|
||
|
|
||
|
//model.MAINCODE = main.MAINCODE;
|
||
|
//model.PRODUCTCODE = main.EPIDERMISCODE;
|
||
|
MainBLL mb = new MainBLL();
|
||
|
if (string.IsNullOrEmpty(model.PRODUCTCODE))
|
||
|
{
|
||
|
if (string.IsNullOrEmpty(model.MAINCODE))
|
||
|
{
|
||
|
return null;
|
||
|
}
|
||
|
|
||
|
var m = mb.GetByCondition(new Main { publicCode = model.MAINCODE });
|
||
|
if (m == null)
|
||
|
{
|
||
|
return null;
|
||
|
}
|
||
|
model.PRODUCTCODE = m.EPIDERMISCODE;
|
||
|
}
|
||
|
|
||
|
DataTable dt = new ProductInjectionDAL().GetExportDataForPINew(model);
|
||
|
|
||
|
#region 转换零件类别、物料类别显示类型
|
||
|
DictManageBLL dictProductTypeBll = new DictManageBLL(DictKind.PRODUCTTYPE);
|
||
|
DictManageBLL dictMaterialTypeBll = new DictManageBLL(DictKind.MATERIALTYPE);
|
||
|
|
||
|
foreach (DataRow item in dt.Rows)
|
||
|
{
|
||
|
//产品条码
|
||
|
item["PRODUCTCODE"] = model.PRODUCTCODE;
|
||
|
//零件类别
|
||
|
item["PRODUCTTYPE"] = dictProductTypeBll.GetDictValue(item["PRODUCTTYPE"].ToString());
|
||
|
//物料类别
|
||
|
item["MATERIALTYPE"] = dictMaterialTypeBll.GetDictValue(item["MATERIALTYPE"].ToString());
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
return dt;
|
||
|
}
|
||
|
catch (Exception ex)
|
||
|
{
|
||
|
throw ex;
|
||
|
}
|
||
|
}
|
||
|
#endregion
|
||
|
|
||
|
#endregion
|
||
|
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|