|
|
|
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.Entity.Basic;
|
|
|
|
using QMAPP.FJC.Entity.ProduceManage;
|
|
|
|
using QMAPP.FJC.BLL.Dict;
|
|
|
|
using QMAPP.FJC.BLL.Basic;
|
|
|
|
using QMAPP.FJC.Entity;
|
|
|
|
using QMFrameWork.Log;
|
|
|
|
using QMAPP.FJC.DAL.Injection;
|
|
|
|
using QMAPP.FJC.Entity.Injection;
|
|
|
|
using System.Configuration;
|
|
|
|
using QMAPP.BLL.Sys;
|
|
|
|
using QMAPP.FJC.DAL.Basic;
|
|
|
|
using QMAPP.FJC.Entity.QT;
|
|
|
|
using QMAPP.MD.Entity;
|
|
|
|
using QMAPP.MD.DAL;
|
|
|
|
namespace QMAPP.FJC.BLL.Operation
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// 模块编号:M13-1
|
|
|
|
/// 作 用:零件条码表
|
|
|
|
/// 作 者:王庆男
|
|
|
|
/// 编写日期:2015年05月29日
|
|
|
|
///</summary>
|
|
|
|
public class ProductBLL : BaseBLL
|
|
|
|
{
|
|
|
|
|
|
|
|
#region 获取信息
|
|
|
|
/// <summary>
|
|
|
|
/// 获取信息
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="">条件</param>
|
|
|
|
/// <returns>信息</returns>
|
|
|
|
public Product Get(Product model)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
return new ProductDAL().Get(model);
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
|
|
{
|
|
|
|
ErrorInfo = ex,
|
|
|
|
Tag = ex.StackTrace,
|
|
|
|
Info = "零件条码--获取零件信息"
|
|
|
|
});
|
|
|
|
throw ex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 获取信息
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="">条件</param>
|
|
|
|
/// <returns>信息</returns>
|
|
|
|
public List<Product> GetListpro(Product model)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
return new ProductDAL().GetListpro(model);
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
|
|
{
|
|
|
|
ErrorInfo = ex,
|
|
|
|
Tag = ex.StackTrace,
|
|
|
|
Info = "零件条码--获取零件信息"
|
|
|
|
});
|
|
|
|
throw ex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 获取信息
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="">条件</param>
|
|
|
|
/// <returns>信息</returns>
|
|
|
|
public DataResult<Product> GetModle(Product model)
|
|
|
|
{
|
|
|
|
DataResult<Product> result = new DataResult<Product>();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
result.Result = new ProductDAL().Get(model);
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
result.IsSuccess = false;
|
|
|
|
result.Msg = Resource.SystemException;
|
|
|
|
throw ex;
|
|
|
|
}
|
|
|
|
result.IsSuccess = true;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 获取T_AW_PACKAGE信息
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="">条件</param>
|
|
|
|
/// <returns>信息</returns>
|
|
|
|
public DataResult<Entity.Operation.Package> GetPackageModle(Entity.Operation.Package model)
|
|
|
|
{
|
|
|
|
DataResult<Entity.Operation.Package> result = new DataResult<Entity.Operation.Package>();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
result.Result = new ProductDAL().GetPackage(model);
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
result.IsSuccess = false;
|
|
|
|
result.Msg = Resource.SystemException;
|
|
|
|
throw ex;
|
|
|
|
}
|
|
|
|
result.IsSuccess = true;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 获取列表
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="condition">条件</param>
|
|
|
|
/// <returns>全部集合</returns>
|
|
|
|
public Product GetByCondition(Product condition)
|
|
|
|
{
|
|
|
|
Product product = new Product();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
List<Product> list = new ProductDAL().GetList(condition);
|
|
|
|
if (list.Count > 0)
|
|
|
|
{
|
|
|
|
product = list[0];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
product = null;
|
|
|
|
}
|
|
|
|
if (product != null)
|
|
|
|
{
|
|
|
|
//product.productBasic = new ProductBasicBLL().GetByCode(new ProductBasic { PRODUCTTYPE = product.PRODUCTTYPE});
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
product = null;
|
|
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
|
|
{
|
|
|
|
ErrorInfo = ex,
|
|
|
|
Tag = ex.StackTrace,
|
|
|
|
Info = "零件条码--获取零件所有列表"
|
|
|
|
});
|
|
|
|
throw ex;
|
|
|
|
}
|
|
|
|
return product;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 获取列表
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="condition">条件</param>
|
|
|
|
/// <returns>全部集合</returns>
|
|
|
|
public List<Product> GetListAndAttrByCondition(Product condition)
|
|
|
|
{
|
|
|
|
//Product product = new Product();
|
|
|
|
List<Product> list;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
list = new ProductDAL().GetListAndAttribute(condition);
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
list = null;
|
|
|
|
//product = null;
|
|
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
|
|
{
|
|
|
|
ErrorInfo = ex,
|
|
|
|
Tag = ex.StackTrace,
|
|
|
|
Info = "零件条码--获取零件"
|
|
|
|
});
|
|
|
|
throw ex;
|
|
|
|
}
|
|
|
|
return list;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 获取列表
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="condition">条件</param>
|
|
|
|
/// <returns>全部集合</returns>
|
|
|
|
public Product GetAndAttrByCondition(Product condition)
|
|
|
|
{
|
|
|
|
Product product = new Product();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
List<Product> list = new ProductDAL().GetListAndAttribute(condition);
|
|
|
|
if (list.Count > 0)
|
|
|
|
{
|
|
|
|
|
|
|
|
product = list[0];
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
product = null;
|
|
|
|
}
|
|
|
|
if (product != null)
|
|
|
|
{
|
|
|
|
product.productBasic = new ProductBasicBLL().GetByCode(new ProductBasic { PRODUCTTYPE = product.PRODUCTTYPE });
|
|
|
|
//product.processSet = new ProcessSetBLL().GetByModel(new ProcessSet { PRODUCTTYPE = product.PRODUCTTYPE, PROCESSTYPESEARCH = product.CURRENTPROCESS }).Result;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
product = null;
|
|
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
|
|
{
|
|
|
|
ErrorInfo = ex,
|
|
|
|
Tag = ex.StackTrace,
|
|
|
|
Info = "零件条码--获取零件"
|
|
|
|
});
|
|
|
|
throw ex;
|
|
|
|
}
|
|
|
|
return product;
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 获取列表
|
|
|
|
/// <summary>
|
|
|
|
/// 获取列表
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="condition">条件</param>
|
|
|
|
/// <param name="page">数据页</param>
|
|
|
|
/// <returns>数据页</returns>
|
|
|
|
public DataPage GetList(Product condition, DataPage page)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
//获取信息列表
|
|
|
|
//if (!string.IsNullOrEmpty(condition.PRODUCTTYPES))
|
|
|
|
//{
|
|
|
|
// condition.PRODUCTTYPES = "'" + condition.PRODUCTTYPES.Replace(",", "','") + "'";
|
|
|
|
//}
|
|
|
|
DataPage dataPage = new ProductDAL().GetList(condition, page);
|
|
|
|
return dataPage;
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
|
|
{
|
|
|
|
ErrorInfo = ex,
|
|
|
|
Tag = ex.StackTrace,
|
|
|
|
Info = "零件条码--获取零件列表"
|
|
|
|
});
|
|
|
|
throw ex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 获取列表
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="condition">条件</param>
|
|
|
|
/// <param name="page">数据页</param>
|
|
|
|
/// <returns>数据页</returns>
|
|
|
|
public DataPage GetListAndAttribute(Product condition, DataPage page)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
//获取信息列表
|
|
|
|
DataPage dataPage = new ProductDAL().GetListAndAttribute(condition, page);
|
|
|
|
|
|
|
|
#region 转换属性
|
|
|
|
List<Product> proList = dataPage.Result as List<Product>;
|
|
|
|
DictManageBLL dictProType = new DictManageBLL(DictKind.PROTYPE);
|
|
|
|
DictManageBLL dictColor = new DictManageBLL(DictKind.SKIN_COLOR);
|
|
|
|
DictManageBLL dictHAndL = new DictManageBLL(DictKind.HAndL);
|
|
|
|
DictManageBLL dictPosi = new DictManageBLL(DictKind.CAVITYTYPE);
|
|
|
|
|
|
|
|
foreach (Product m in proList)
|
|
|
|
{
|
|
|
|
//产品类型
|
|
|
|
m.VAL2 = dictProType.GetDictValue(m.VAL2);
|
|
|
|
//颜色
|
|
|
|
m.VAL4 = dictColor.GetDictValue(m.VAL4);
|
|
|
|
//高低配
|
|
|
|
m.VAL3 = dictHAndL.GetDictValue(m.VAL3);
|
|
|
|
//腔
|
|
|
|
m.VAL5 = dictPosi.GetDictValue(m.VAL5);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
return dataPage;
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
|
|
{
|
|
|
|
ErrorInfo = ex,
|
|
|
|
Tag = ex.StackTrace,
|
|
|
|
Info = "零件条码--获取零件属性列表"
|
|
|
|
});
|
|
|
|
throw ex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 获取替换列表
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="condition">条件</param>
|
|
|
|
/// <param name="page">数据页</param>
|
|
|
|
/// <returns>数据页</returns>
|
|
|
|
public DataResult<DataPage> GetProductReplaceList(ProductReplace condition, DataPage page)
|
|
|
|
{
|
|
|
|
DataResult<DataPage> result = new DataResult<DataPage>();
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
result.IsSuccess = true;
|
|
|
|
page = new ProductDAL().GetProductReplaceList(condition, page);
|
|
|
|
//List<ProductReplace> list = page.Result as List<ProductReplace>;
|
|
|
|
|
|
|
|
////处理字典信息
|
|
|
|
//var UserList = new UserManageBLL().GetUserComboxSource();
|
|
|
|
|
|
|
|
//foreach (var info in list)
|
|
|
|
//{
|
|
|
|
// //创建人员
|
|
|
|
// var userCreat = UserList.FirstOrDefault(x => x.UserID == info.CREATEUSER);
|
|
|
|
// if (userCreat != null)
|
|
|
|
// info.CREATEUSERNAME = userCreat.UserName;
|
|
|
|
//}
|
|
|
|
|
|
|
|
//page.Result = list;
|
|
|
|
|
|
|
|
result.Result = page;
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
|
|
{
|
|
|
|
ErrorInfo = ex,
|
|
|
|
Tag = ex.StackTrace,
|
|
|
|
Info = "本体信息获取列表错误!"
|
|
|
|
});
|
|
|
|
result.IsSuccess = false;
|
|
|
|
result.Msg = "本体信息获取列表错误!";
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 获取列表
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="condition">条件</param>
|
|
|
|
/// <returns>全部集合</returns>
|
|
|
|
public List<Product> GetAllList(Product condition)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
return new ProductDAL().GetList(condition);
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
|
|
{
|
|
|
|
ErrorInfo = ex,
|
|
|
|
Tag = ex.StackTrace,
|
|
|
|
Info = "零件条码--获取零件所有列表"
|
|
|
|
});
|
|
|
|
throw ex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 信息是否重复
|
|
|
|
/// <summary>
|
|
|
|
/// 判断名称是否存在
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="info"></param>
|
|
|
|
/// <returns>true:已存在;fasel:不存在。</returns>
|
|
|
|
public bool ExistsProduct(Product model)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
return new ProductDAL().ExistsProduct(model);
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
|
|
{
|
|
|
|
ErrorInfo = ex,
|
|
|
|
Tag = ex.StackTrace,
|
|
|
|
Info = "零件条码--判断零件重复"
|
|
|
|
});
|
|
|
|
throw ex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 判断名称是否存在
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="info"></param>
|
|
|
|
/// <returns>true:已存在;fasel:不存在。</returns>
|
|
|
|
public bool IsUsedProduct(Product model)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
return new ProductDAL().IsUsedProduct(model);
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
|
|
{
|
|
|
|
ErrorInfo = ex,
|
|
|
|
Tag = ex.StackTrace,
|
|
|
|
Info = "零件条码--判断零件是否使用"
|
|
|
|
});
|
|
|
|
throw ex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 插入信息
|
|
|
|
/// <summary>
|
|
|
|
/// 插入信息(单表)
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="">信息</param>
|
|
|
|
/// <returns>插入行数</returns>
|
|
|
|
public DataResult<int> Insert(Product model)
|
|
|
|
{
|
|
|
|
DataResult<int> result = new DataResult<int>();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
//基本信息
|
|
|
|
if(string.IsNullOrEmpty(model.PID))
|
|
|
|
model.PID = Guid.NewGuid().ToString();
|
|
|
|
model.CREATEUSER = this.LoginUser.UserID;
|
|
|
|
model.CREATEDATE = DateTime.Now;
|
|
|
|
model.UPDATEUSER = model.CREATEUSER;
|
|
|
|
model.UPDATEDATE = model.CREATEDATE;
|
|
|
|
ProductDAL cmdDAL = new ProductDAL();
|
|
|
|
if (ExistsProduct(model) == true)
|
|
|
|
{
|
|
|
|
result.IsSuccess = false;
|
|
|
|
result.Msg = Resource.IsHaving;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
result.Result = new ProductDAL().Insert(model);
|
|
|
|
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 DataResult<int> InsertInjection(Product model, MachineInfo machine)
|
|
|
|
{
|
|
|
|
DataResult<int> result = new DataResult<int>();
|
|
|
|
|
|
|
|
//基本信息
|
|
|
|
model.PID = Guid.NewGuid().ToString();
|
|
|
|
|
|
|
|
ProductDAL cmdDAL = new ProductDAL();
|
|
|
|
if (ExistsProduct(model) == true)
|
|
|
|
{
|
|
|
|
result.IsSuccess = false;
|
|
|
|
result.Msg = Resource.IsHaving;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
MainOperation operation = new MainOperation();
|
|
|
|
operation.PID = Guid.NewGuid().ToString();
|
|
|
|
operation.PDID = model.PID;
|
|
|
|
operation.PRODUCTCODE = model.PRODUCTCODE;
|
|
|
|
//搪塑
|
|
|
|
operation.PROCESSTYPE = EnumGeter.ProcessType.gujiazhusu.GetHashCode().ToString();
|
|
|
|
operation.PRODUCTTYPE = model.PRODUCTTYPE;
|
|
|
|
operation.MACHINENAME = model.MACHINENAME;
|
|
|
|
operation.MACHINECODDE = model.MACHINECODDE;
|
|
|
|
operation.MATERIAL_CODE = model.MATERIAL_CODE;
|
|
|
|
operation.MATERIAL_TYPE_CODE = model.MATERIAL_TYPE;
|
|
|
|
operation.STATUS = EnumGeter.STATUS.QUALIFIED.GetHashCode().ToString();
|
|
|
|
operation.OPERATESTATE = EnumGeter.OPERATESTATE.COMPLETED.GetHashCode().ToString();
|
|
|
|
operation.OPERATEDDATE = model.CREATEDATE;
|
|
|
|
operation.CURRENTPROCESS = EnumGeter.ProcessType.gujiazhusu.GetHashCode().ToString();
|
|
|
|
operation.PRODUCESHIFTNAME = model.PRODUCESHIFTNAME;
|
|
|
|
operation.PRODUCESHIFTTCODE = model.PRODUCESHIFTTCODE;
|
|
|
|
operation.PRODUCELINE = "B9";
|
|
|
|
operation.MODELSTATION = "";
|
|
|
|
operation.CREATEUSER = model.CREATEUSER;
|
|
|
|
operation.CREATEDATE = System.DateTime.Now;
|
|
|
|
operation.UPDATEUSER = model.UPDATEUSER;
|
|
|
|
operation.UPDATEDATE = System.DateTime.Now;
|
|
|
|
|
|
|
|
model.CREATEDATE = DateTime.Now;
|
|
|
|
model.CREATEUSER = this.LoginUser.UserID;
|
|
|
|
model.UPDATEUSER = model.CREATEUSER;
|
|
|
|
model.UPDATEDATE = model.CREATEDATE;
|
|
|
|
|
|
|
|
string productType = model.MATERIAL_CODE;
|
|
|
|
List<MaterialCodeInit> initList = new MaterialCodeInitDAL().GetList(new MaterialCodeInit() { MATERIAL_CODE = productType });
|
|
|
|
if (initList.Count > 0)
|
|
|
|
{
|
|
|
|
MaterialCodeInit init = initList[0];
|
|
|
|
model.WORKCELL_CODE = init.WORKCELL_CODE;
|
|
|
|
model.WORKCENTER_CODE = init.WORKCENTER_CODE;
|
|
|
|
model.WORKLOC_CODE = init.WORKLOC_CODE;
|
|
|
|
|
|
|
|
operation.WORKCENTER_CODE = init.WORKCENTER_CODE;
|
|
|
|
}
|
|
|
|
|
|
|
|
//零件投料关联表
|
|
|
|
List<ProductInjection> addInjectItemList = new List<ProductInjection>();
|
|
|
|
|
|
|
|
|
|
|
|
InjectionRecorderDAL injectDal = new InjectionRecorderDAL();
|
|
|
|
|
|
|
|
List<InjectionRecorder> list = injectDal.GetLastRecorder(new InjectionRecorder()
|
|
|
|
{
|
|
|
|
MACHINECODDE = machine.MACHINECODDE,
|
|
|
|
MATERIALTYPE = "0"
|
|
|
|
});//0位原材料
|
|
|
|
|
|
|
|
if (list.Count > 0)
|
|
|
|
{
|
|
|
|
|
|
|
|
InjectionRecorder inRecorder = list[0];
|
|
|
|
#region 零件投料关联记录
|
|
|
|
|
|
|
|
ProductInjection proInject = new ProductInjection();
|
|
|
|
|
|
|
|
proInject.PID = Guid.NewGuid().ToString();
|
|
|
|
proInject.IPID = inRecorder.PID;
|
|
|
|
proInject.MPPID = model.PID;
|
|
|
|
proInject.MATERIALNAME = inRecorder.MATERIALNAME;
|
|
|
|
proInject.MATERIALCODE = inRecorder.MATERIALCODE;
|
|
|
|
proInject.MATERIALTYPE = inRecorder.MATERIALTYPE;
|
|
|
|
proInject.MATERIALBATCH = inRecorder.MATERIALBATCH;
|
|
|
|
proInject.MATERIALCODE = inRecorder.MATERIALCODE;
|
|
|
|
proInject.INJECTIONINDEX = inRecorder.INJECTIONINDEX;
|
|
|
|
proInject.INJECTIONTERMINAL = inRecorder.INJECTIONTERMINAL;
|
|
|
|
proInject.USEDWEIGHT = 0;
|
|
|
|
proInject.CREATEDATE = System.DateTime.Now;
|
|
|
|
proInject.CREATEUSER = inRecorder.CREATEUSER;
|
|
|
|
proInject.UPDATEUSER = inRecorder.UPDATEUSER;
|
|
|
|
|
|
|
|
addInjectItemList.Add(proInject);
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
list = injectDal.GetLastRecorder(new InjectionRecorder()
|
|
|
|
{
|
|
|
|
MACHINECODDE = machine.MACHINECODDE,
|
|
|
|
MATERIALTYPE = "1"
|
|
|
|
});//1位织布
|
|
|
|
|
|
|
|
if (list.Count > 0)
|
|
|
|
{
|
|
|
|
|
|
|
|
InjectionRecorder inRecorder = list[0];
|
|
|
|
#region 零件投料关联记录
|
|
|
|
|
|
|
|
ProductInjection proInject = new ProductInjection();
|
|
|
|
|
|
|
|
proInject.PID = Guid.NewGuid().ToString();
|
|
|
|
proInject.IPID = inRecorder.PID;
|
|
|
|
proInject.MPPID = model.PID;
|
|
|
|
proInject.MATERIALNAME = inRecorder.MATERIALNAME;
|
|
|
|
proInject.MATERIALCODE = inRecorder.MATERIALCODE;
|
|
|
|
proInject.MATERIALTYPE = inRecorder.MATERIALTYPE;
|
|
|
|
proInject.MATERIALBATCH = inRecorder.MATERIALBATCH;
|
|
|
|
proInject.MATERIALCODE = inRecorder.MATERIALCODE;
|
|
|
|
proInject.INJECTIONINDEX = inRecorder.INJECTIONINDEX;
|
|
|
|
proInject.INJECTIONTERMINAL = inRecorder.INJECTIONTERMINAL;
|
|
|
|
proInject.USEDWEIGHT = 0;
|
|
|
|
proInject.CREATEDATE = System.DateTime.Now;
|
|
|
|
proInject.CREATEUSER = inRecorder.CREATEUSER;
|
|
|
|
proInject.UPDATEUSER = inRecorder.UPDATEUSER;
|
|
|
|
|
|
|
|
addInjectItemList.Add(proInject);
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
list = injectDal.GetLastRecorder(new InjectionRecorder()
|
|
|
|
{
|
|
|
|
MACHINECODDE = machine.MACHINECODDE,
|
|
|
|
MATERIALTYPE = "2"
|
|
|
|
});//1金属支架
|
|
|
|
|
|
|
|
if (list.Count > 0)
|
|
|
|
{
|
|
|
|
|
|
|
|
InjectionRecorder inRecorder = list[0];
|
|
|
|
#region 零件投料关联记录
|
|
|
|
|
|
|
|
ProductInjection proInject = new ProductInjection();
|
|
|
|
|
|
|
|
proInject.PID = Guid.NewGuid().ToString();
|
|
|
|
proInject.IPID = inRecorder.PID;
|
|
|
|
proInject.MPPID = model.PID;
|
|
|
|
proInject.MATERIALNAME = inRecorder.MATERIALNAME;
|
|
|
|
proInject.MATERIALCODE = inRecorder.MATERIALCODE;
|
|
|
|
proInject.MATERIALTYPE = inRecorder.MATERIALTYPE;
|
|
|
|
proInject.MATERIALBATCH = inRecorder.MATERIALBATCH;
|
|
|
|
proInject.MATERIALCODE = inRecorder.MATERIALCODE;
|
|
|
|
proInject.INJECTIONINDEX = inRecorder.INJECTIONINDEX;
|
|
|
|
proInject.INJECTIONTERMINAL = inRecorder.INJECTIONTERMINAL;
|
|
|
|
proInject.USEDWEIGHT = 0;
|
|
|
|
proInject.CREATEDATE = System.DateTime.Now;
|
|
|
|
proInject.CREATEUSER = inRecorder.CREATEUSER;
|
|
|
|
proInject.UPDATEUSER = inRecorder.UPDATEUSER;
|
|
|
|
|
|
|
|
addInjectItemList.Add(proInject);
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#region 数据库操作
|
|
|
|
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
|
|
{
|
|
|
|
session.OpenTs();
|
|
|
|
|
|
|
|
ProductDAL productDal = new ProductDAL();
|
|
|
|
MainOperationDAL mainOpeDal = new MainOperationDAL();
|
|
|
|
ProductInjectionDAL proInDal = new ProductInjectionDAL();
|
|
|
|
InjectionRecorderDAL recoderDal = new InjectionRecorderDAL();
|
|
|
|
productDal.BaseSession = session;
|
|
|
|
mainOpeDal.BaseSession = session;
|
|
|
|
proInDal.BaseSession = session;
|
|
|
|
recoderDal.BaseSession = session;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
|
|
|
|
#region 插入产品信息
|
|
|
|
|
|
|
|
productDal.Insert(model);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 投料关联表
|
|
|
|
foreach (var proinject in addInjectItemList)
|
|
|
|
{
|
|
|
|
proInDal.Insert(proinject);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 插入操作记录
|
|
|
|
|
|
|
|
mainOpeDal.Insert(operation);
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
session.CommitTs();
|
|
|
|
result.Result = 1;
|
|
|
|
result.IsSuccess = true; ;
|
|
|
|
result.Msg = Resource.MsgSuccess;
|
|
|
|
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
session.RollbackTs();
|
|
|
|
result.Result = 0;
|
|
|
|
result.IsSuccess = false; ;
|
|
|
|
result.Msg = Resource.MsgFaile;
|
|
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
|
|
{
|
|
|
|
ErrorInfo = ex,
|
|
|
|
Tag = ex.StackTrace,
|
|
|
|
Info = "零件条码--插入零件条码"
|
|
|
|
});
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 插入信息(单表)
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="">信息</param>
|
|
|
|
/// <returns>插入行数</returns>
|
|
|
|
public DataResult<int> InsertForBundle(Product model)
|
|
|
|
{
|
|
|
|
DataResult<int> result = new DataResult<int>();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
//基本信息
|
|
|
|
model.PID = Guid.NewGuid().ToString();
|
|
|
|
model.CREATEUSER = this.LoginUser.UserID;
|
|
|
|
model.CREATEDATE = DateTime.Now;
|
|
|
|
model.UPDATEUSER = model.CREATEUSER;
|
|
|
|
model.UPDATEDATE = model.CREATEDATE;
|
|
|
|
ProductDAL cmdDAL = new ProductDAL();
|
|
|
|
result.Result = new ProductDAL().Insert(model);
|
|
|
|
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 DataResult<Product> InsertAndReturn(Product model)
|
|
|
|
{
|
|
|
|
DataResult<Product> result = new DataResult<Product>();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
//基本信息
|
|
|
|
model.PID = Guid.NewGuid().ToString();
|
|
|
|
model.CREATEUSER = this.LoginUser.UserID;
|
|
|
|
model.CREATEDATE = DateTime.Now;
|
|
|
|
model.UPDATEUSER = model.CREATEUSER;
|
|
|
|
model.UPDATEDATE = model.CREATEDATE;
|
|
|
|
ProductDAL cmdDAL = new ProductDAL();
|
|
|
|
if (ExistsProduct(model) == true)
|
|
|
|
{
|
|
|
|
result.IsSuccess = false;
|
|
|
|
result.Msg = Resource.IsHaving;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
int count = new ProductDAL().Insert(model);
|
|
|
|
result.Result = this.Get(model);
|
|
|
|
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 DataResult<List<string>> InsertEpidermis(Product model)
|
|
|
|
{
|
|
|
|
DataResult<List<string>> result = new DataResult<List<string>>();
|
|
|
|
List<Product> proList = new List<Product>();
|
|
|
|
List<MainOperation> mainOperations = new List<MainOperation>();
|
|
|
|
List<InjectionRecorder> updateInjectList = new List<InjectionRecorder>();
|
|
|
|
List<string> listCodes = new List<string>();
|
|
|
|
//零件投料关联表
|
|
|
|
List<ProductInjection> addInjectItemList = new List<ProductInjection>();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
|
|
|
|
//基本信息
|
|
|
|
model.PID = Guid.NewGuid().ToString();
|
|
|
|
model.CREATEUSER = this.LoginUser.UserID;
|
|
|
|
model.CREATEDATE = DateTime.Now;
|
|
|
|
model.UPDATEUSER = model.CREATEUSER;
|
|
|
|
model.UPDATEDATE = model.CREATEDATE;
|
|
|
|
//生成条码
|
|
|
|
if (string.IsNullOrEmpty(model.PRODUCTCODE) == true)
|
|
|
|
{
|
|
|
|
StringBuilder proCode = new StringBuilder();
|
|
|
|
string OpDate = model.PRODUCTATTRIBUTE.VAL7;
|
|
|
|
proCode.Append(Convert.ToDateTime(OpDate).ToString("yyMMddHHmm"));
|
|
|
|
/**
|
|
|
|
//获取当前日期加工表皮列表
|
|
|
|
Product searchModel = new Product();
|
|
|
|
searchModel.CREATEDATE = Convert.ToDateTime(OpDate);
|
|
|
|
searchModel.PRODUCELINE = model.PRODUCELINE;
|
|
|
|
searchModel.PRODUCTTYPE = model.PRODUCTTYPE;
|
|
|
|
|
|
|
|
List<Product> list = this.GetAllList(searchModel);
|
|
|
|
string hhmm = "";
|
|
|
|
if (list.Count > 0)
|
|
|
|
{
|
|
|
|
list.Sort((b, a) => { return a.CREATEDATE.CompareTo(b.CREATEDATE); });
|
|
|
|
for (int i = 0; i < list.Count; i++)
|
|
|
|
{
|
|
|
|
DateTime createDate = list[i].CREATEDATE;
|
|
|
|
if (i + 1 < list.Count && !createDate.AddMinutes(-1).ToString("HHmm").Equals(list[i + 1].CREATEDATE.ToString("HHmm")))
|
|
|
|
{
|
|
|
|
hhmm = createDate.AddMinutes(-1).ToString("HHmm");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (i + 1 == list.Count)
|
|
|
|
{
|
|
|
|
hhmm = createDate.AddMinutes(-1).ToString("HHmm");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
hhmm = DateTime.Now.AddMinutes(-1).ToString("HHmm");
|
|
|
|
}
|
|
|
|
|
|
|
|
proCode.Append(hhmm);
|
|
|
|
**/
|
|
|
|
proCode.Append(model.PRODUCTATTRIBUTE.VAL1);//设备名称
|
|
|
|
proCode.Append(model.PRODUCTATTRIBUTE.VAL2);//产品类型
|
|
|
|
proCode.Append(model.PRODUCTATTRIBUTE.VAL3);//高低配
|
|
|
|
proCode.Append(model.PRODUCTATTRIBUTE.VAL4);//颜色
|
|
|
|
proCode.Append(model.PRODUCTATTRIBUTE.VAL5);//腔
|
|
|
|
proCode.Append(model.PRODUCTATTRIBUTE.VAL6);//模腔号
|
|
|
|
model.PRODUCTCODE = proCode.ToString();
|
|
|
|
|
|
|
|
#region 初始化零件号
|
|
|
|
//获取产品零件号
|
|
|
|
string productType = model.PRODUCTATTRIBUTE.VAL2 + model.PRODUCTATTRIBUTE.VAL3 + model.PRODUCTATTRIBUTE.VAL4;
|
|
|
|
List<MaterialCodeInit> initList = new MaterialCodeInitDAL().GetList(new MaterialCodeInit() { PRODUCT_TYPES = productType });
|
|
|
|
if (initList.Count > 0)
|
|
|
|
{
|
|
|
|
MaterialCodeInit init = initList[0];
|
|
|
|
model.WORKCELL_CODE = init.WORKCELL_CODE;
|
|
|
|
model.WORKCENTER_CODE = init.WORKCENTER_CODE;
|
|
|
|
model.MATERIAL_CODE = init.MATERIAL_CODE;
|
|
|
|
model.WORKLOC_CODE = init.WORKLOC_CODE;
|
|
|
|
model.MATERIAL_TYPE = init.MATERIAL_TYPE;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(model.PRODUCTATTRIBUTE.PID))
|
|
|
|
{
|
|
|
|
//属性表
|
|
|
|
model.PRODUCTATTRIBUTE.PID = Guid.NewGuid().ToString();
|
|
|
|
model.PRODUCTATTRIBUTE.MPPID = model.PID;
|
|
|
|
model.PRODUCTATTRIBUTE.CREATEUSER = model.CREATEUSER;
|
|
|
|
model.PRODUCTATTRIBUTE.CREATEDATE = model.CREATEDATE;
|
|
|
|
model.PRODUCTATTRIBUTE.UPDATEUSER = model.UPDATEUSER;
|
|
|
|
model.PRODUCTATTRIBUTE.UPDATEDATE = model.UPDATEDATE;
|
|
|
|
}
|
|
|
|
if (ExistsProduct(model) == true)
|
|
|
|
{
|
|
|
|
result.IsSuccess = false;
|
|
|
|
result.Msg = Resource.IsHaving;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
//判断一次出几个码
|
|
|
|
if (model.PRODUCTATTRIBUTE.VAL5.Equals("A-B"))
|
|
|
|
{
|
|
|
|
string code = model.PRODUCTCODE.Clone().ToString();
|
|
|
|
model.PRODUCTATTRIBUTE.VAL5 = "A";
|
|
|
|
model.PRODUCTCODE = model.PRODUCTCODE.Replace("A-B", "A");
|
|
|
|
proList.Add(model);
|
|
|
|
Product newModel = model.Clone() as Product;
|
|
|
|
string newId = Guid.NewGuid().ToString();
|
|
|
|
newModel.PID = newId;
|
|
|
|
newModel.PRODUCTATTRIBUTE = model.PRODUCTATTRIBUTE.Clone() as ProductAttribute;
|
|
|
|
newModel.PRODUCTATTRIBUTE.PID = Guid.NewGuid().ToString();
|
|
|
|
newModel.PRODUCTATTRIBUTE.MPPID = newId;
|
|
|
|
newModel.PRODUCTATTRIBUTE.VAL5 = "B";
|
|
|
|
string newCode = code.Replace("A-B", "B");
|
|
|
|
newModel.PRODUCTCODE = newCode;
|
|
|
|
proList.Add(newModel);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
proList.Add(model);
|
|
|
|
}
|
|
|
|
for (int i = 0; i < proList.Count; i++)
|
|
|
|
{
|
|
|
|
MainOperation operation = new MainOperation();
|
|
|
|
operation.PID = Guid.NewGuid().ToString();
|
|
|
|
operation.PDID = proList[i].PID;
|
|
|
|
operation.PRODUCTCODE = proList[i].PRODUCTCODE;
|
|
|
|
//搪塑
|
|
|
|
operation.PROCESSTYPE = EnumGeter.ProcessType.tangsu.GetHashCode().ToString();
|
|
|
|
operation.PRODUCTTYPE = model.PRODUCTTYPE;
|
|
|
|
operation.MACHINENAME = model.MACHINENAME;
|
|
|
|
operation.MACHINECODDE = model.MACHINECODDE;
|
|
|
|
operation.STATUS = EnumGeter.STATUS.QUALIFIED.GetHashCode().ToString();
|
|
|
|
operation.OPERATESTATE = EnumGeter.OPERATESTATE.COMPLETED.GetHashCode().ToString();
|
|
|
|
operation.OPERATEDDATE = System.DateTime.Now;
|
|
|
|
operation.CURRENTPROCESS = EnumGeter.ProcessType.tangsu.GetHashCode().ToString();
|
|
|
|
operation.PRODUCESHIFTNAME = model.PRODUCESHIFTNAME;
|
|
|
|
operation.PRODUCESHIFTTCODE = model.PRODUCESHIFTTCODE;
|
|
|
|
operation.PRODUCELINE = "B9";
|
|
|
|
operation.MODELSTATION = "";
|
|
|
|
operation.CREATEUSER = model.CREATEUSER;
|
|
|
|
operation.CREATEDATE = System.DateTime.Now;
|
|
|
|
operation.UPDATEUSER = model.UPDATEUSER;
|
|
|
|
operation.UPDATEDATE = System.DateTime.Now;
|
|
|
|
mainOperations.Add(operation);
|
|
|
|
listCodes.Add(operation.PRODUCTCODE);
|
|
|
|
|
|
|
|
}
|
|
|
|
#region 加工工序信息
|
|
|
|
if (model.AddM)//如果需要添加物料扣减需要调用接口
|
|
|
|
{
|
|
|
|
MachineInfo mInfo = new MachineInfoBLL().GetAllList(new MachineInfo { MACHINECODDE = model.MACHINECODDE })[0];
|
|
|
|
Process.SlushProcess slush = new Process.SlushProcess();
|
|
|
|
addInjectItemList = slush.GetProductInjectionList(proList, mInfo, ref updateInjectList);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
InjectionRecorderDAL injectDal = new InjectionRecorderDAL();
|
|
|
|
List<MD.Entity.PbomItem> boms = new PbomDAL().GetSubItem(model.MATERIAL_CODE);
|
|
|
|
foreach (var bom in boms)
|
|
|
|
{
|
|
|
|
List<InjectionRecorder> listInject = injectDal.GetLastRecorder(new InjectionRecorder()
|
|
|
|
{
|
|
|
|
MACHINECODDE = model.MACHINECODDE,
|
|
|
|
MATERIALCODE = bom.MATERIAL_CODE
|
|
|
|
});
|
|
|
|
#region 获取投料信息
|
|
|
|
foreach (Product item in proList)
|
|
|
|
{
|
|
|
|
if (listInject.Count > 0)
|
|
|
|
{
|
|
|
|
InjectionRecorder inRecorder = listInject[0];
|
|
|
|
#region 零件投料关联记录
|
|
|
|
ProductInjection proInject = new ProductInjection();
|
|
|
|
proInject.PID = Guid.NewGuid().ToString();
|
|
|
|
proInject.IPID = inRecorder.PID;
|
|
|
|
proInject.MPPID = item.PID;
|
|
|
|
proInject.MATERIALNAME = inRecorder.MATERIALNAME;
|
|
|
|
proInject.MATERIALCODE = inRecorder.MATERIALCODE;
|
|
|
|
proInject.MATERIALTYPE = inRecorder.MATERIALTYPE;
|
|
|
|
proInject.MATERIALBATCH = inRecorder.MATERIALBATCH;
|
|
|
|
proInject.MATERIALCODE = inRecorder.MATERIALCODE;
|
|
|
|
proInject.INJECTIONINDEX = inRecorder.INJECTIONINDEX;
|
|
|
|
proInject.INJECTIONTERMINAL = inRecorder.INJECTIONTERMINAL;
|
|
|
|
proInject.USEDWEIGHT = 0;
|
|
|
|
proInject.CREATEDATE = System.DateTime.Now;
|
|
|
|
proInject.CREATEUSER = inRecorder.CREATEUSER;
|
|
|
|
proInject.UPDATEUSER = inRecorder.UPDATEUSER;
|
|
|
|
proInject.PROCESSTYPE = model.CURRENTPROCESS;
|
|
|
|
addInjectItemList.Add(proInject);
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 数据库操作
|
|
|
|
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
|
|
{
|
|
|
|
session.OpenTs();
|
|
|
|
|
|
|
|
ProductDAL productDal = new ProductDAL();
|
|
|
|
MainOperationDAL mainOpeDal = new MainOperationDAL();
|
|
|
|
ProductInjectionDAL proInDal = new ProductInjectionDAL();
|
|
|
|
InjectionRecorderDAL recoderDal = new InjectionRecorderDAL();
|
|
|
|
productDal.BaseSession = session;
|
|
|
|
mainOpeDal.BaseSession = session;
|
|
|
|
proInDal.BaseSession = session;
|
|
|
|
recoderDal.BaseSession = session;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
|
|
|
|
#region 插入产品信息
|
|
|
|
foreach (Product item in proList)
|
|
|
|
{
|
|
|
|
productDal.InsertMainAndAttribute(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 插入操作记录
|
|
|
|
foreach (MainOperation item in mainOperations)
|
|
|
|
{
|
|
|
|
mainOpeDal.Insert(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 投料关联表
|
|
|
|
|
|
|
|
|
|
|
|
foreach (ProductInjection item in addInjectItemList)
|
|
|
|
{
|
|
|
|
proInDal.Insert(item);
|
|
|
|
}
|
|
|
|
foreach (InjectionRecorder item in updateInjectList)
|
|
|
|
{
|
|
|
|
recoderDal.Update(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
session.CommitTs();
|
|
|
|
result.Result = listCodes;
|
|
|
|
result.IsSuccess = true; ;
|
|
|
|
result.Msg = Resource.MsgSuccess;
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
session.RollbackTs();
|
|
|
|
result.IsSuccess = true; ;
|
|
|
|
result.Msg = Resource.MsgFaile;
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
//result.Result = new ProductDAL().InsertMainAndAttribute(model);
|
|
|
|
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
|
|
{
|
|
|
|
ErrorInfo = ex,
|
|
|
|
Tag = ex.StackTrace,
|
|
|
|
Info = "零件条码--插入表皮信息"
|
|
|
|
});
|
|
|
|
result.IsSuccess = false;
|
|
|
|
result.Msg = Resource.SystemException;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
public DataResult<List<string>> TaskInsertEpidermis(Product model, IDataSession session)
|
|
|
|
{
|
|
|
|
DataResult<List<string>> result = new DataResult<List<string>>();
|
|
|
|
List<Product> proList = new List<Product>();
|
|
|
|
List<MainOperation> mainOperations = new List<MainOperation>();
|
|
|
|
List<InjectionRecorder> updateInjectList = new List<InjectionRecorder>();
|
|
|
|
List<string> listCodes = new List<string>();
|
|
|
|
//零件投料关联表
|
|
|
|
List<ProductInjection> addInjectItemList = new List<ProductInjection>();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
var workcellCode = "";
|
|
|
|
var workcenterCode = "";
|
|
|
|
var worklogCode = "";
|
|
|
|
|
|
|
|
//基本信息
|
|
|
|
model.PID = Guid.NewGuid().ToString();
|
|
|
|
model.CREATEUSER = this.LoginUser.UserID;
|
|
|
|
model.CREATEDATE = DateTime.Now;
|
|
|
|
model.UPDATEUSER = model.CREATEUSER;
|
|
|
|
model.UPDATEDATE = model.CREATEDATE;
|
|
|
|
|
|
|
|
#region 初始化零件号
|
|
|
|
//获取产品零件号
|
|
|
|
//string productType = model.PRODUCTATTRIBUTE.VAL2 + model.PRODUCTATTRIBUTE.VAL3 + model.PRODUCTATTRIBUTE.VAL4;
|
|
|
|
List<MaterialCodeInit> initList = new MaterialCodeInitDAL().GetList(new MaterialCodeInit() { MATERIAL_TYPE = model.MATERIAL_TYPE });
|
|
|
|
if (initList.Count > 0)
|
|
|
|
{
|
|
|
|
MaterialCodeInit init = initList[0];
|
|
|
|
workcellCode = init.WORKCELL_CODE;
|
|
|
|
workcenterCode = init.WORKCENTER_CODE;
|
|
|
|
worklogCode = init.WORKLOC_CODE;
|
|
|
|
model.WORKCELL_CODE = init.WORKCELL_CODE;
|
|
|
|
model.WORKCENTER_CODE = init.WORKCENTER_CODE;
|
|
|
|
model.WORKLOC_CODE = init.WORKLOC_CODE;
|
|
|
|
}
|
|
|
|
|
|
|
|
ProcessRecord recorder = new ProcessRecord
|
|
|
|
{
|
|
|
|
PID = Guid.NewGuid().ToString(),
|
|
|
|
PRODUCT_PID = model.PID,
|
|
|
|
WORKLOC_CODE = worklogCode,
|
|
|
|
WORKCELL_CODE = workcellCode,
|
|
|
|
IN_WORKCELL_TIME = System.DateTime.Now,
|
|
|
|
WORK_START_TIME = System.DateTime.Now,
|
|
|
|
WORK_END_TIME = System.DateTime.Now,
|
|
|
|
PROCESS_STATE = "1",
|
|
|
|
MANUAL_PASS = "0",
|
|
|
|
MODULE_CODE = "1"
|
|
|
|
};
|
|
|
|
//直接插入数据库
|
|
|
|
session.Insert<ProcessRecord>(recorder);
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
if (ExistsProduct(model) == true)
|
|
|
|
{
|
|
|
|
result.IsSuccess = false;
|
|
|
|
result.Msg = Resource.IsHaving;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
proList.Add(model);
|
|
|
|
|
|
|
|
for (int i = 0; i < proList.Count; i++)
|
|
|
|
{
|
|
|
|
MainOperation operation = new MainOperation();
|
|
|
|
operation.PID = Guid.NewGuid().ToString();
|
|
|
|
operation.PDID = proList[i].PID;
|
|
|
|
operation.PRODUCTCODE = proList[i].PRODUCTCODE;
|
|
|
|
operation.MACHINENAME = model.MACHINENAME;
|
|
|
|
operation.MACHINECODDE = model.MACHINECODDE;
|
|
|
|
operation.STATUS = EnumGeter.STATUS.QUALIFIED.GetHashCode().ToString();
|
|
|
|
operation.OPERATESTATE = EnumGeter.OPERATESTATE.COMPLETED.GetHashCode().ToString();
|
|
|
|
operation.OPERATEDDATE = System.DateTime.Now;
|
|
|
|
operation.CURRENTPROCESS = EnumGeter.ProcessType.tangsu.GetHashCode().ToString();
|
|
|
|
operation.PRODUCESHIFTNAME = model.PRODUCESHIFTNAME;
|
|
|
|
operation.PRODUCESHIFTTCODE = model.PRODUCESHIFTTCODE;
|
|
|
|
operation.PRODUCELINE = "";
|
|
|
|
operation.MODELSTATION = "";
|
|
|
|
operation.CREATEUSER = model.CREATEUSER;
|
|
|
|
operation.CREATEDATE = System.DateTime.Now;
|
|
|
|
operation.UPDATEUSER = model.UPDATEUSER;
|
|
|
|
operation.UPDATEDATE = System.DateTime.Now;
|
|
|
|
operation.MATERIAL_CODE = model.MATERIAL_CODE;
|
|
|
|
operation.MATERIAL_NAME = model.MATERIAL_NAME;
|
|
|
|
operation.MATERIAL_TYPE_CODE = model.MATERIAL_TYPE;
|
|
|
|
operation.WORKCENTER_CODE = workcenterCode;
|
|
|
|
operation.WORKCELL_CODE = workcellCode;
|
|
|
|
mainOperations.Add(operation);
|
|
|
|
listCodes.Add(operation.PRODUCTCODE);
|
|
|
|
|
|
|
|
}
|
|
|
|
#region 加工工序信息
|
|
|
|
if (model.AddM)//如果需要添加物料扣减需要调用接口
|
|
|
|
{
|
|
|
|
MachineInfo mInfo = new MachineInfoBLL().GetAllList(new MachineInfo { MACHINECODDE = model.MACHINECODDE })[0];
|
|
|
|
Process.SlushProcess slush = new Process.SlushProcess();
|
|
|
|
addInjectItemList = slush.GetProductInjectionList(proList, mInfo, ref updateInjectList);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
InjectionRecorderDAL injectDal = new InjectionRecorderDAL();
|
|
|
|
List<InjectionRecorder> listInject = injectDal.GetLastRecorder(new InjectionRecorder()
|
|
|
|
{
|
|
|
|
MACHINECODDE = model.MACHINECODDE,
|
|
|
|
});
|
|
|
|
#region 获取投料信息
|
|
|
|
foreach (Product item in proList)
|
|
|
|
{
|
|
|
|
if (listInject.Count > 0)
|
|
|
|
{
|
|
|
|
InjectionRecorder inRecorder = listInject[0];
|
|
|
|
#region 零件投料关联记录
|
|
|
|
ProductInjection proInject = new ProductInjection();
|
|
|
|
proInject.PID = Guid.NewGuid().ToString();
|
|
|
|
proInject.IPID = inRecorder.PID;
|
|
|
|
proInject.MPPID = item.PID;
|
|
|
|
proInject.MATERIALNAME = inRecorder.MATERIALNAME;
|
|
|
|
proInject.MATERIALCODE = inRecorder.MATERIALCODE;
|
|
|
|
proInject.MATERIALTYPE = inRecorder.MATERIALTYPE;
|
|
|
|
proInject.MATERIALBATCH = inRecorder.MATERIALBATCH;
|
|
|
|
proInject.INJECTIONINDEX = inRecorder.INJECTIONINDEX;
|
|
|
|
proInject.INJECTIONTERMINAL = inRecorder.INJECTIONTERMINAL;
|
|
|
|
proInject.USEDWEIGHT = 0;
|
|
|
|
proInject.CREATEDATE = System.DateTime.Now;
|
|
|
|
proInject.CREATEUSER = inRecorder.CREATEUSER;
|
|
|
|
proInject.UPDATEUSER = inRecorder.UPDATEUSER;
|
|
|
|
proInject.PROCESSTYPE = model.CURRENTPROCESS;
|
|
|
|
addInjectItemList.Add(proInject);
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 数据库操作
|
|
|
|
|
|
|
|
ProductDAL productDal = new ProductDAL();
|
|
|
|
MainOperationDAL mainOpeDal = new MainOperationDAL();
|
|
|
|
ProductInjectionDAL proInDal = new ProductInjectionDAL();
|
|
|
|
InjectionRecorderDAL recoderDal = new InjectionRecorderDAL();
|
|
|
|
productDal.BaseSession = session;
|
|
|
|
mainOpeDal.BaseSession = session;
|
|
|
|
proInDal.BaseSession = session;
|
|
|
|
recoderDal.BaseSession = session;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
|
|
|
|
#region 插入产品信息
|
|
|
|
foreach (Product item in proList)
|
|
|
|
{
|
|
|
|
productDal.InsertMainAndAttribute(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 插入操作记录
|
|
|
|
foreach (MainOperation item in mainOperations)
|
|
|
|
{
|
|
|
|
mainOpeDal.Insert(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
#region 投料关联表
|
|
|
|
|
|
|
|
|
|
|
|
foreach (ProductInjection item in addInjectItemList)
|
|
|
|
{
|
|
|
|
proInDal.Insert(item);
|
|
|
|
}
|
|
|
|
foreach (InjectionRecorder item in updateInjectList)
|
|
|
|
{
|
|
|
|
recoderDal.Update(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
//session.CommitTs();
|
|
|
|
result.Result = listCodes;
|
|
|
|
result.IsSuccess = true; ;
|
|
|
|
result.Msg = Resource.MsgSuccess;
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
//session.RollbackTs();
|
|
|
|
result.IsSuccess = false; ;
|
|
|
|
result.Msg = Resource.MsgFaile;
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
//result.Result = new ProductDAL().InsertMainAndAttribute(model);
|
|
|
|
|
|
|
|
}
|
|
|
|
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 DataResult<List<PrintCode>> InsertListEpidermis(List<Product> models)
|
|
|
|
{
|
|
|
|
DataResult<List<PrintCode>> result = new DataResult<List<PrintCode>>();
|
|
|
|
List<Product> proList = new List<Product>();
|
|
|
|
List<MainOperation> mainOperations = new List<MainOperation>();
|
|
|
|
List<InjectionRecorder> updateInjectList = new List<InjectionRecorder>();
|
|
|
|
|
|
|
|
PrintCode printInfo = new PrintCode();
|
|
|
|
List<PrintCode> listCodes = new List<PrintCode>();
|
|
|
|
List<ProcessRecord> recorderList = new List<ProcessRecord>();
|
|
|
|
//零件投料关联表
|
|
|
|
List<ProductInjection> addInjectItemList = new List<ProductInjection>();
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
string cartype = "";
|
|
|
|
foreach (Product model in models)
|
|
|
|
{
|
|
|
|
//基本信息
|
|
|
|
model.PID = Guid.NewGuid().ToString();
|
|
|
|
model.CREATEUSER = this.LoginUser.UserID;
|
|
|
|
model.CREATEDATE = DateTime.Now;
|
|
|
|
model.UPDATEUSER = model.CREATEUSER;
|
|
|
|
model.UPDATEDATE = model.CREATEDATE;
|
|
|
|
//生成条码
|
|
|
|
if (string.IsNullOrEmpty(model.PRODUCTCODE) == true)
|
|
|
|
{
|
|
|
|
StringBuilder proCode = new StringBuilder();
|
|
|
|
string OpDate = model.PRODUCTATTRIBUTE.VAL7;
|
|
|
|
proCode.Append(Convert.ToDateTime(OpDate).ToString("yyMMddHHmm"));
|
|
|
|
proCode.Append(model.PRODUCTATTRIBUTE.VAL1);//设备名称
|
|
|
|
proCode.Append(model.PRODUCTATTRIBUTE.VAL2);//产品类型
|
|
|
|
proCode.Append(model.PRODUCTATTRIBUTE.VAL3);//高低配
|
|
|
|
proCode.Append(model.PRODUCTATTRIBUTE.VAL4);//颜色
|
|
|
|
proCode.Append(model.PRODUCTATTRIBUTE.VAL5);//腔
|
|
|
|
proCode.Append(model.PRODUCTATTRIBUTE.VAL6);//模腔号
|
|
|
|
model.PRODUCTCODE = proCode.ToString();
|
|
|
|
|
|
|
|
#region 初始化零件号
|
|
|
|
//获取产品零件号
|
|
|
|
string productType = model.PRODUCTATTRIBUTE.VAL2 + model.PRODUCTATTRIBUTE.VAL3 + model.PRODUCTATTRIBUTE.VAL4;
|
|
|
|
List<MaterialCodeInit> initList = new MaterialCodeInitDAL().GetList(new MaterialCodeInit() { PRODUCT_TYPES = productType });
|
|
|
|
if (initList.Count > 0)
|
|
|
|
{
|
|
|
|
MaterialCodeInit init = initList[0];
|
|
|
|
model.WORKCELL_CODE = init.WORKCELL_CODE;
|
|
|
|
model.WORKCENTER_CODE = init.WORKCENTER_CODE;
|
|
|
|
model.MATERIAL_CODE = init.MATERIAL_CODE;
|
|
|
|
model.WORKLOC_CODE = init.WORKLOC_CODE;
|
|
|
|
model.MATERIAL_TYPE = init.MATERIAL_TYPE;
|
|
|
|
cartype = init.CARTYPE;
|
|
|
|
|
|
|
|
ProcessRecord recorder = new ProcessRecord();
|
|
|
|
recorder.PID = Guid.NewGuid().ToString();
|
|
|
|
recorder.PRODUCT_PID = model.PID;
|
|
|
|
recorder.WORKLOC_CODE = init.WORKLOC_CODE_INIT;
|
|
|
|
recorder.WORKCELL_CODE = init.WORKCELL_CODE_INIT;
|
|
|
|
recorder.IN_WORKCELL_TIME = System.DateTime.Now;
|
|
|
|
recorder.WORK_START_TIME = System.DateTime.Now;
|
|
|
|
recorder.WORK_END_TIME = System.DateTime.Now;
|
|
|
|
recorder.PROCESS_STATE = "1";
|
|
|
|
recorder.MANUAL_PASS = "0";
|
|
|
|
recorder.MODULE_CODE = "1";
|
|
|
|
recorderList.Add(recorder);
|
|
|
|
|
|
|
|
printInfo.PRODUCTCODE = init.MATERIAL_CODE;
|
|
|
|
printInfo.COLOR_CODE = init.COLOR;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
if (string.IsNullOrEmpty(model.PRODUCTATTRIBUTE.PID))
|
|
|
|
{
|
|
|
|
//属性表
|
|
|
|
model.PRODUCTATTRIBUTE.PID = Guid.NewGuid().ToString();
|
|
|
|
model.PRODUCTATTRIBUTE.MPPID = model.PID;
|
|
|
|
model.PRODUCTATTRIBUTE.CREATEUSER = model.CREATEUSER;
|
|
|
|
model.PRODUCTATTRIBUTE.CREATEDATE = model.CREATEDATE;
|
|
|
|
model.PRODUCTATTRIBUTE.UPDATEUSER = model.UPDATEUSER;
|
|
|
|
model.PRODUCTATTRIBUTE.UPDATEDATE = model.UPDATEDATE;
|
|
|
|
}
|
|
|
|
if (ExistsProduct(model) == true)
|
|
|
|
{
|
|
|
|
result.IsSuccess = false;
|
|
|
|
result.Msg = Resource.IsHaving;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
//判断一次出几个码
|
|
|
|
if (model.PRODUCTATTRIBUTE.VAL5.Equals("A-B"))
|
|
|
|
{
|
|
|
|
string code = model.PRODUCTCODE.Clone().ToString();
|
|
|
|
model.PRODUCTATTRIBUTE.VAL5 = "A";
|
|
|
|
model.PRODUCTCODE = model.PRODUCTCODE.Replace("A-B", "A");
|
|
|
|
proList.Add(model);
|
|
|
|
Product newModel = model.Clone() as Product;
|
|
|
|
string newId = Guid.NewGuid().ToString();
|
|
|
|
newModel.PID = newId;
|
|
|
|
newModel.PRODUCTATTRIBUTE = model.PRODUCTATTRIBUTE.Clone() as ProductAttribute;
|
|
|
|
newModel.PRODUCTATTRIBUTE.PID = Guid.NewGuid().ToString();
|
|
|
|
newModel.PRODUCTATTRIBUTE.MPPID = newId;
|
|
|
|
newModel.PRODUCTATTRIBUTE.VAL5 = "B";
|
|
|
|
string newCode = code.Replace("A-B", "B");
|
|
|
|
newModel.PRODUCTCODE = newCode;
|
|
|
|
proList.Add(newModel);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
proList.Add(model);
|
|
|
|
}
|
|
|
|
|
|
|
|
MainOperation operation = new MainOperation();
|
|
|
|
operation.PID = Guid.NewGuid().ToString();
|
|
|
|
operation.PDID = model.PID;
|
|
|
|
operation.PRODUCTCODE = model.PRODUCTCODE;
|
|
|
|
//搪塑
|
|
|
|
operation.PROCESSTYPE = EnumGeter.ProcessType.tangsu.GetHashCode().ToString();
|
|
|
|
operation.PRODUCTTYPE = model.PRODUCTTYPE;
|
|
|
|
operation.MACHINENAME = model.MACHINENAME;
|
|
|
|
operation.MACHINECODDE = model.MACHINECODDE;
|
|
|
|
operation.STATUS = EnumGeter.STATUS.QUALIFIED.GetHashCode().ToString();
|
|
|
|
operation.OPERATESTATE = EnumGeter.OPERATESTATE.COMPLETED.GetHashCode().ToString();
|
|
|
|
operation.OPERATEDDATE = System.DateTime.Now;
|
|
|
|
operation.CURRENTPROCESS = EnumGeter.ProcessType.tangsu.GetHashCode().ToString();
|
|
|
|
operation.PRODUCESHIFTNAME = model.PRODUCESHIFTNAME;
|
|
|
|
operation.PRODUCESHIFTTCODE = model.PRODUCESHIFTTCODE;
|
|
|
|
operation.PRODUCELINE = cartype;
|
|
|
|
|
|
|
|
operation.MATERIAL_CODE = model.MATERIAL_CODE;
|
|
|
|
operation.MATERIAL_TYPE_CODE = model.MATERIAL_TYPE;
|
|
|
|
operation.WORKCENTER_CODE = model.WORKCENTER_CODE;
|
|
|
|
operation.WORKCELL_CODE = model.WORKCELL_CODE;
|
|
|
|
|
|
|
|
operation.MODELSTATION = "";
|
|
|
|
operation.CREATEUSER = model.CREATEUSER;
|
|
|
|
operation.CREATEDATE = System.DateTime.Now;
|
|
|
|
operation.UPDATEUSER = model.UPDATEUSER;
|
|
|
|
operation.UPDATEDATE = System.DateTime.Now;
|
|
|
|
mainOperations.Add(operation);
|
|
|
|
printInfo.MAINCODE = operation.PRODUCTCODE;
|
|
|
|
|
|
|
|
if (model.AddM == false)//如果需要添加物料扣减需要调用接口
|
|
|
|
{
|
|
|
|
MachineInfo mInfo = new MachineInfoBLL().GetAllList(new MachineInfo { MACHINECODDE = model.MACHINECODDE })[0];
|
|
|
|
Process.SlushProcess slush = new Process.SlushProcess();
|
|
|
|
addInjectItemList = slush.GetProductInjectionList(proList, mInfo, ref updateInjectList);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
InjectionRecorderDAL injectDal = new InjectionRecorderDAL();
|
|
|
|
List<MD.Entity.PbomItem> boms = new PbomDAL().GetSubItem(model.MATERIAL_CODE);
|
|
|
|
foreach (var bom in boms)
|
|
|
|
{
|
|
|
|
List<InjectionRecorder> listInject = injectDal.GetLastRecorder(new InjectionRecorder()
|
|
|
|
{
|
|
|
|
MATERIALCODE=bom.MATERIAL_CODE,
|
|
|
|
MACHINECODDE = model.MACHINECODDE,
|
|
|
|
});
|
|
|
|
#region 获取投料信息
|
|
|
|
//foreach (Product item in proList)
|
|
|
|
//{
|
|
|
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
if (listInject.Count > 0)
|
|
|
|
{
|
|
|
|
InjectionRecorder inRecorder = listInject[0];
|
|
|
|
#region 零件投料关联记录
|
|
|
|
ProductInjection proInject = new ProductInjection();
|
|
|
|
proInject.PID = Guid.NewGuid().ToString();
|
|
|
|
proInject.IPID = inRecorder.PID;
|
|
|
|
proInject.MPPID = model.PID;
|
|
|
|
proInject.MATERIALNAME = inRecorder.MATERIALNAME;
|
|
|
|
proInject.MATERIALCODE = inRecorder.MATERIALCODE;
|
|
|
|
proInject.MATERIALTYPE = inRecorder.MATERIALTYPE;
|
|
|
|
proInject.MATERIALBATCH = inRecorder.MATERIALBATCH;
|
|
|
|
proInject.MATERIALCODE = inRecorder.MATERIALCODE;
|
|
|
|
proInject.INJECTIONINDEX = inRecorder.INJECTIONINDEX;
|
|
|
|
proInject.INJECTIONTERMINAL = inRecorder.INJECTIONTERMINAL;
|
|
|
|
proInject.USEDWEIGHT = 0;
|
|
|
|
proInject.CREATEDATE = System.DateTime.Now;
|
|
|
|
proInject.CREATEUSER = inRecorder.CREATEUSER;
|
|
|
|
proInject.UPDATEUSER = inRecorder.UPDATEUSER;
|
|
|
|
proInject.PROCESSTYPE = model.CURRENTPROCESS;
|
|
|
|
addInjectItemList.Add(proInject);
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#region 数据库操作
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
|
|
{
|
|
|
|
session.OpenTs();
|
|
|
|
|
|
|
|
ProductDAL productDal = new ProductDAL();
|
|
|
|
MainOperationDAL mainOpeDal = new MainOperationDAL();
|
|
|
|
ProductInjectionDAL proInDal = new ProductInjectionDAL();
|
|
|
|
InjectionRecorderDAL recoderDal = new InjectionRecorderDAL();
|
|
|
|
productDal.BaseSession = session;
|
|
|
|
mainOpeDal.BaseSession = session;
|
|
|
|
proInDal.BaseSession = session;
|
|
|
|
recoderDal.BaseSession = session;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
|
|
|
|
#region 插入产品信息
|
|
|
|
foreach (Product item in proList)
|
|
|
|
{
|
|
|
|
productDal.InsertMainAndAttribute(item);
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 插入操作记录
|
|
|
|
foreach (MainOperation item in mainOperations)
|
|
|
|
{
|
|
|
|
mainOpeDal.Insert(item);
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 投料关联表
|
|
|
|
foreach (ProductInjection item in addInjectItemList)
|
|
|
|
{
|
|
|
|
proInDal.Insert(item);
|
|
|
|
}
|
|
|
|
foreach (InjectionRecorder item in updateInjectList)
|
|
|
|
{
|
|
|
|
recoderDal.Update(item);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 插入加工记录
|
|
|
|
|
|
|
|
foreach (var recorder in recorderList)
|
|
|
|
{
|
|
|
|
session.Insert<ProcessRecord>(recorder);
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
session.CommitTs();
|
|
|
|
listCodes.Add(printInfo);
|
|
|
|
result.Result = listCodes;
|
|
|
|
result.IsSuccess = true; ;
|
|
|
|
result.Msg = Resource.MsgSuccess;
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
session.RollbackTs();
|
|
|
|
result.IsSuccess = true; ;
|
|
|
|
result.Msg = Resource.MsgFaile;
|
|
|
|
throw;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
|
|
{
|
|
|
|
ErrorInfo = ex,
|
|
|
|
Tag = ex.StackTrace,
|
|
|
|
Info = "零件条码--插入表皮信息"
|
|
|
|
});
|
|
|
|
result.IsSuccess = false;
|
|
|
|
result.Msg = Resource.SystemException;
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 插入T_AW_PACKAGE信息
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="model"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public DataResult<int> InsertPackage(Entity.Operation.Package model)
|
|
|
|
{
|
|
|
|
DataResult<int> result = new DataResult<int>();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
ProductDAL cmdDAL = new ProductDAL();
|
|
|
|
//基本信息
|
|
|
|
model.PID = Guid.NewGuid().ToString();
|
|
|
|
model.CREATEUSER = this.LoginUser.UserID;
|
|
|
|
model.CREATEDATE = DateTime.Now;
|
|
|
|
model.UPDATEUSER = model.CREATEUSER;
|
|
|
|
model.UPDATEDATE = model.CREATEDATE;
|
|
|
|
model.USINGCOUNT = 0;
|
|
|
|
model.USINGSTATE = 0;
|
|
|
|
//去T_MD_PACKAGESET查找容量信息
|
|
|
|
PackageSet packageSet = cmdDAL.GetPackageSetInfo(new PackageSet { MATERIAL_CODE = model.MATERIAL_CODE });
|
|
|
|
if (packageSet != null)
|
|
|
|
{
|
|
|
|
model.CAPACITY = packageSet.CAPACITY;
|
|
|
|
}
|
|
|
|
//if (ExistsProduct(model) == true)
|
|
|
|
//{
|
|
|
|
// result.IsSuccess = false;
|
|
|
|
// result.Msg = Resource.IsHaving;
|
|
|
|
// return result;
|
|
|
|
//}
|
|
|
|
result.Result = new ProductDAL().InsertPackage(model);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 更新信息
|
|
|
|
/// <summary>
|
|
|
|
/// 更新信息
|
|
|
|
/// </summary>
|
|
|
|
/// <param name=""></param>
|
|
|
|
/// <returns>更新行数</returns>
|
|
|
|
public DataResult<int> Update(Product model)
|
|
|
|
{
|
|
|
|
DataResult<int> result = new DataResult<int>();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
model.UPDATEUSER = this.LoginUser.UserID;
|
|
|
|
result.Result = new ProductDAL().Update(model);
|
|
|
|
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 DataResult<int> UpdateStatus(Product model, MendRecorder recorder)
|
|
|
|
{
|
|
|
|
DataResult<int> result = new DataResult<int>();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
model.UPDATEUSER = this.LoginUser.UserID;
|
|
|
|
recorder.PID = Guid.NewGuid().ToString();
|
|
|
|
recorder.CREATEUSER = this.LoginUser.UserID;
|
|
|
|
recorder.CREATEDATE = DateTime.Now;
|
|
|
|
recorder.UPDATEUSER = model.CREATEUSER;
|
|
|
|
recorder.UPDATEDATE = model.CREATEDATE;
|
|
|
|
result.Result = new ProductDAL().Update(model, recorder);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
#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.DeleteProduct(new Product { 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 DataResult<int> DeleteSingle(string str)
|
|
|
|
{
|
|
|
|
DataResult<int> result = new DataResult<int>();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if (this.IsUsedProduct(new Product { PID = str, USINGSTATE = EnumGeter.PRODUCTUSESTATE.UNUSED.GetHashCode().ToString() }))
|
|
|
|
{
|
|
|
|
result.IsSuccess = false;
|
|
|
|
result.Msg = Resource.ProductIsUsing;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
result.Result = this.DeleteProduct(new Product { 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 DeleteProduct(Product model)
|
|
|
|
{
|
|
|
|
int count = 0;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
count = new ProductDAL().Delete(model);
|
|
|
|
return count;
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
|
|
{
|
|
|
|
ErrorInfo = ex,
|
|
|
|
Tag = ex.StackTrace,
|
|
|
|
Info = "零件条码--删除零件信息"
|
|
|
|
});
|
|
|
|
throw ex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public DataResult<int> DeleteProductt(string ProductCode, string machineCode)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
DataResult<int> result = new DataResult<int>();
|
|
|
|
result.Result = new ProductDAL().DeleteProduct(ProductCode, machineCode);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
|
|
{
|
|
|
|
ErrorInfo = ex,
|
|
|
|
Tag = ex.StackTrace,
|
|
|
|
Info = "零件条码--获取零件信息"
|
|
|
|
});
|
|
|
|
throw ex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 导出数据
|
|
|
|
/// <summary>
|
|
|
|
/// 获取导出的数据
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="user">查询条件</param>
|
|
|
|
/// <returns>数据</returns>
|
|
|
|
public DataTable GetExportData(Product model)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
return new ProductDAL().GetExportData(model);
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
|
|
{
|
|
|
|
ErrorInfo = ex,
|
|
|
|
Tag = ex.StackTrace,
|
|
|
|
Info = "零件条码--导出零件信息"
|
|
|
|
});
|
|
|
|
throw ex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 导入数据
|
|
|
|
public DataResult<ImportMessage> GetImportData(List<Product> list)
|
|
|
|
{
|
|
|
|
DataResult<ImportMessage> result = new DataResult<ImportMessage>();
|
|
|
|
ProductDAL cmDal = new ProductDAL();
|
|
|
|
List<Product> List = new List<Product>();
|
|
|
|
int index = 0;
|
|
|
|
try
|
|
|
|
{
|
|
|
|
result.Result = new ImportMessage();
|
|
|
|
result.Result.Errors = new List<RowError>();
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
|
|
{
|
|
|
|
//状态判断
|
|
|
|
foreach (Product ma in list)
|
|
|
|
{
|
|
|
|
index++;
|
|
|
|
if (string.IsNullOrEmpty(ma.InfoError) == false)
|
|
|
|
{
|
|
|
|
ma.PID = null;
|
|
|
|
result.Result.failureNum += 1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
//修改改时根据主键等信息获取详细内容信息
|
|
|
|
Product 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 Product();
|
|
|
|
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)
|
|
|
|
{
|
|
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
|
|
{
|
|
|
|
ErrorInfo = ex,
|
|
|
|
Tag = ex.StackTrace,
|
|
|
|
Info = "零件条码--导入零件信息"
|
|
|
|
});
|
|
|
|
result.IsSuccess = false;
|
|
|
|
result.Ex = ex;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 返修登记、返修完成更新产品(工控机)
|
|
|
|
/// <summary>
|
|
|
|
/// 返修登记、返修完成更新产品(工控机)
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="model">更新信息</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public DataResult<int> MendUpdate(Product model)
|
|
|
|
{
|
|
|
|
DataResult<int> result = new DataResult<int>();
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
Product condition = new ProductDAL().Get(model);
|
|
|
|
if (condition == null)
|
|
|
|
{
|
|
|
|
result.IsSuccess = false;
|
|
|
|
result.Msg = Resource.OperationProNotFound;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
condition.UPDATEUSER = this.LoginUser.UserID;
|
|
|
|
condition.STATUS = model.STATUS;
|
|
|
|
result.Result = new ProductDAL().Update(condition);
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 获取信息(工控机)
|
|
|
|
/// <summary>
|
|
|
|
/// 获取信息
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="">条件</param>
|
|
|
|
/// <returns>信息</returns>
|
|
|
|
public Product GetProductInfo(Product model)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
return new ProductDAL().GetProductInfo(model);
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
|
|
{
|
|
|
|
ErrorInfo = ex,
|
|
|
|
Tag = ex.StackTrace,
|
|
|
|
Info = "零件条码--获取零件信息"
|
|
|
|
});
|
|
|
|
throw ex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
public Product GetProductByAssembleCode(string code)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
return new ProductDAL().GetProductByAssembleCode(code);
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
|
|
{
|
|
|
|
ErrorInfo = ex,
|
|
|
|
Tag = ex.StackTrace,
|
|
|
|
Info = "零件条码--获取零件信息"
|
|
|
|
});
|
|
|
|
throw ex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
|
|
/// 查询条码所代表的原始产品信息
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="productcode"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public Product GetOrginProduct(string productcode)
|
|
|
|
{
|
|
|
|
FJC.DAL.Produce.ProductDAL dal = new DAL.Produce.ProductDAL();
|
|
|
|
return dal.GetByCode(productcode);
|
|
|
|
}
|
|
|
|
|
|
|
|
public Product GetProductByPart(string partpid)
|
|
|
|
{
|
|
|
|
FJC.DAL.Produce.ProductDAL dal = new DAL.Produce.ProductDAL();
|
|
|
|
return dal.GetProductByPart(partpid);
|
|
|
|
}
|
|
|
|
public Product GetProductByPartID(string partpid)
|
|
|
|
{
|
|
|
|
FJC.DAL.Produce.ProductDAL dal = new DAL.Produce.ProductDAL();
|
|
|
|
return dal.GetProductByPartID(partpid);
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 插入金属支架
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="barCode">金属支架盒编码</param>
|
|
|
|
public void InsertAirbagSupportPackage(string barCode)
|
|
|
|
{
|
|
|
|
Product product = new Product();
|
|
|
|
ProductDAL productdal = new ProductDAL();
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
//判断该对象是否已经存在
|
|
|
|
product = productdal.GetProductInfo(new Product() { PRODUCTCODE = barCode.Replace("\r", "").Replace("\n", "").ToUpper() });
|
|
|
|
if (product != null && string.IsNullOrEmpty(product.PID) == false)
|
|
|
|
{
|
|
|
|
|
|
|
|
LogManager.LogHelper.Info(new LogInfo() { Info = "AirbagSupportPackage:" + barCode + " exist!" });
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
product = new Product();
|
|
|
|
product.PID = Guid.NewGuid().ToString();
|
|
|
|
product.PRODUCTCODE = barCode.Replace("\r", "").Replace("\n", "").ToUpper().ToString();
|
|
|
|
product.PRODUCTTYPE = EnumGeter.ProductType.jinshuzhijia.GetHashCode().ToString();
|
|
|
|
product.MACHINENAME = "";//machine.MACHINENAME;
|
|
|
|
product.MACHINECODDE = "";//machine.MACHINECODDE;
|
|
|
|
//自制件
|
|
|
|
product.PRODUCTSOURCE = EnumGeter.PRODUCTSOURCE.OUTSOURCING.GetHashCode().ToString();
|
|
|
|
//合格品
|
|
|
|
product.STATUS = EnumGeter.STATUS.QUALIFIED.GetHashCode().ToString();
|
|
|
|
product.CURRENTPROCESS = EnumGeter.ProcessType.qinangzhijiazhusu.GetHashCode().ToString();
|
|
|
|
product.PRODUCELINE = "B9";
|
|
|
|
product.PRODUCESHIFTNAME = "";
|
|
|
|
product.PRODUCESHIFTTCODE = "";
|
|
|
|
//在库
|
|
|
|
product.OUTFLAG = EnumGeter.OUTFLAG.INWAREHOUSE.GetHashCode().ToString();
|
|
|
|
//未使用
|
|
|
|
product.USINGSTATE = EnumGeter.USINGSTATE.UNUSED.GetHashCode().ToString();
|
|
|
|
string piece = ConfigurationManager.AppSettings["Piece"];
|
|
|
|
product.CAPACITY = Convert.ToInt32(piece);
|
|
|
|
product.USINGCOUNT = 0;
|
|
|
|
//product.CREATEUSER = machine.PID;
|
|
|
|
product.CREATEDATE = System.DateTime.Now;
|
|
|
|
//product.UPDATEUSER = machine.PID;
|
|
|
|
product.UPDATEDATE = System.DateTime.Now;
|
|
|
|
|
|
|
|
productdal.Insert(product);
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
LogManager.LogHelper.Error(new LogInfo() { Info = "insert AirbagSupportPackage:" + barCode + " error!", ErrorInfo = ex });
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 条码作废
|
|
|
|
/// <summary>
|
|
|
|
///
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="condition"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public DataResult ScarpProduct(Product condition)
|
|
|
|
{
|
|
|
|
DataResult result = new DataResult();
|
|
|
|
result.IsSuccess = true;
|
|
|
|
|
|
|
|
try
|
|
|
|
{
|
|
|
|
|
|
|
|
ProductDAL prodal = new ProductDAL();
|
|
|
|
Product entity = prodal.GetProductInfo(condition);
|
|
|
|
|
|
|
|
if (entity == null)
|
|
|
|
{
|
|
|
|
result.IsSuccess = false;
|
|
|
|
result.Msg = string.Format("产品{0}不存在!", condition.PRODUCTCODE);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (entity.USINGSTATE == EnumGeter.USINGSTATE.USED.GetHashCode().ToString())
|
|
|
|
{
|
|
|
|
result.IsSuccess = false;
|
|
|
|
result.Msg = string.Format("产品{0}已使用!", condition.PRODUCTCODE);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (entity.STATUS == EnumGeter.STATUS.SCRAP.GetHashCode().ToString())
|
|
|
|
{
|
|
|
|
result.IsSuccess = false;
|
|
|
|
result.Msg = string.Format("产品{0}已作废!", condition.PRODUCTCODE);
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
|
|
|
entity.STATUS = EnumGeter.STATUS.SCRAP.GetHashCode().ToString();
|
|
|
|
|
|
|
|
prodal.Update(entity);
|
|
|
|
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
|
|
|
|
result.IsSuccess = false;
|
|
|
|
result.Msg = string.Format("系统异常!");
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
public int ModifyProductCode(string productCode)
|
|
|
|
{
|
|
|
|
int result = 0;
|
|
|
|
|
|
|
|
Product entityInsert = new Product();
|
|
|
|
entityInsert.PID = Guid.NewGuid().ToString();
|
|
|
|
entityInsert.PRODUCTCODE = productCode;
|
|
|
|
entityInsert.PRODUCTSOURCE = "0";
|
|
|
|
entityInsert.PRODUCELINE = "B9";
|
|
|
|
entityInsert.OUTFLAG = "0";
|
|
|
|
entityInsert.USINGSTATE = "0";
|
|
|
|
entityInsert.CAPACITY = 1;
|
|
|
|
entityInsert.USINGCOUNT = 0;
|
|
|
|
|
|
|
|
|
|
|
|
string startStr = productCode.Substring(0, 3);
|
|
|
|
string endStr = productCode.Substring(productCode.Length - 4, 4);
|
|
|
|
|
|
|
|
string selectSql = "select * from t_aw_product t where 1=1 ";
|
|
|
|
|
|
|
|
if (productCode.Substring(0, 3) == "B9A")
|
|
|
|
{
|
|
|
|
selectSql += " AND createdate>'2016-05-1 09:13:33.000'";
|
|
|
|
selectSql += " AND currentprocess='7' ";
|
|
|
|
selectSql += " AND PRODUCTTYPE='1' ";
|
|
|
|
selectSql += " AND PRODUCTCODE LIKE 'B9A1605%";
|
|
|
|
selectSql += endStr;
|
|
|
|
selectSql += "'";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (productCode.Substring(0, 3) == "B9B")
|
|
|
|
{
|
|
|
|
selectSql += " AND createdate>'2016-05-1 09:13:33.000'";
|
|
|
|
selectSql += " AND currentprocess='13' ";
|
|
|
|
selectSql += " AND PRODUCTTYPE='4' ";
|
|
|
|
selectSql += " AND PRODUCTCODE LIKE 'B9B1605%";
|
|
|
|
selectSql += endStr;
|
|
|
|
selectSql += "'";
|
|
|
|
|
|
|
|
entityInsert.PRODUCTTYPE = "4";
|
|
|
|
entityInsert.MACHINENAME = "恩格尔3200T注塑";
|
|
|
|
entityInsert.MACHINECODDE = "Engel3200T";
|
|
|
|
entityInsert.STATUS = "0";
|
|
|
|
entityInsert.CURRENTPROCESS = "13";
|
|
|
|
entityInsert.CREATEUSER = "c361d78c-91ed-4b1f-9777-8ff0aefa6cc6";
|
|
|
|
entityInsert.UPDATEUSER = "c361d78c-91ed-4b1f-9777-8ff0aefa6cc6";
|
|
|
|
entityInsert.CREATEDATE = Convert.ToDateTime("2016-05-" + productCode.Substring(7, 2) + " " + productCode.Substring(9, 2) + ":" + productCode.Substring(11, 2) + ":00");
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if (productCode.Substring(0, 3) == "B9C")
|
|
|
|
{
|
|
|
|
selectSql += " AND createdate>'2016-05-1 09:13:33.000'";
|
|
|
|
selectSql += " AND currentprocess='13' ";
|
|
|
|
selectSql += " AND PRODUCTTYPE='5' ";
|
|
|
|
selectSql += " AND PRODUCTCODE LIKE 'B9C1605%";
|
|
|
|
selectSql += endStr;
|
|
|
|
selectSql += "'";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (productCode.Substring(0, 3) == "FJC")
|
|
|
|
{
|
|
|
|
selectSql += " AND createdate>'2016-04-1 09:13:33.000'";
|
|
|
|
selectSql += " AND currentprocess='15' ";
|
|
|
|
selectSql += " AND PRODUCTTYPE='2' ";
|
|
|
|
selectSql += " AND PRODUCTCODE LIKE 'FJC160%";
|
|
|
|
selectSql += endStr;
|
|
|
|
selectSql += "'";
|
|
|
|
}
|
|
|
|
|
|
|
|
if (productCode.Substring(0, 3) == "AAA")
|
|
|
|
{
|
|
|
|
selectSql += " AND createdate>'2016-04-1 09:13:33.000'";
|
|
|
|
selectSql += " AND currentprocess='15' ";
|
|
|
|
selectSql += " AND PRODUCTTYPE='2' ";
|
|
|
|
selectSql += " AND PRODUCTCODE LIKE 'FJC160%";
|
|
|
|
selectSql += endStr;
|
|
|
|
selectSql += "'";
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
List<Product> productList = new List<Product>();
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
|
|
{
|
|
|
|
|
|
|
|
productList = session.GetList<Product>(selectSql, new List<DataParameter>().ToArray()).ToList<Product>();
|
|
|
|
}
|
|
|
|
|
|
|
|
if (productList.Count == 0)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
if (productCode.Substring(0, 3) == "B9B")
|
|
|
|
{
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
|
|
{
|
|
|
|
session.Insert<Product>(entityInsert);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
|
|
|
|
LogManager.LogHelper.Error(new LogInfo() { ErrorInfo = ex, Info = ex.Message });
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
result = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (productList.Count > 0 && productList.Count < 2)
|
|
|
|
{
|
|
|
|
Product entity = productList[0];
|
|
|
|
|
|
|
|
if (entity.PRODUCTCODE == productCode)
|
|
|
|
{
|
|
|
|
if (productCode.Substring(0, 3) != "B9B")
|
|
|
|
{
|
|
|
|
result = 2;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
|
|
{
|
|
|
|
session.Insert<Product>(entityInsert);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
|
|
{
|
|
|
|
entity.PRODUCTCODE = productCode;
|
|
|
|
session.Update<Product>(entity);
|
|
|
|
}
|
|
|
|
|
|
|
|
result = 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
result = 2;
|
|
|
|
}
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 门板强制终检
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="productcode"></param>
|
|
|
|
/// <param name="materialcode"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public Product CreateAssy(string productcode, string materialcode)
|
|
|
|
{
|
|
|
|
var materialdal = new MD.DAL.MaterialDAL();
|
|
|
|
var material = materialdal.Get(new MD.Entity.Material { MATERIAL_CODE = materialcode });
|
|
|
|
var matinitdal = new FJC.DAL.Basic.MaterialCodeInitDAL();
|
|
|
|
var mcinit = matinitdal.GetByCondition(new MaterialCodeInit { MATERIAL_TYPE = material.MATERIAL_TYPE_CODE});
|
|
|
|
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
session.OpenTs();
|
|
|
|
ProductDAL prodal = new ProductDAL();
|
|
|
|
prodal.BaseSession = session;
|
|
|
|
var product = new Product
|
|
|
|
{
|
|
|
|
CAPACITY = 1,
|
|
|
|
CREATEDATE = DateTime.Now,
|
|
|
|
CREATEUSER = base.LoginUser.UserID,
|
|
|
|
CURRENTPROCESS = "",
|
|
|
|
ENDOFLINE = "1",
|
|
|
|
MACHINECODDE = "",
|
|
|
|
MACHINENAME = "",
|
|
|
|
MATERIAL_CODE = materialcode,
|
|
|
|
MATERIAL_TYPE = material.MATERIAL_TYPE_CODE,
|
|
|
|
OUTFLAG = "0",
|
|
|
|
PID = Guid.NewGuid().ToString(),
|
|
|
|
PRODUCELINE = "",
|
|
|
|
PRODUCESHIFTNAME = "A",
|
|
|
|
PRODUCESHIFTTCODE = "A",
|
|
|
|
PRODUCTCODE = productcode,
|
|
|
|
PRODUCTSOURCE = "0",
|
|
|
|
PRODUCTTYPE = "",
|
|
|
|
STATUS = "0",
|
|
|
|
TEAM_CODE = "",
|
|
|
|
UPDATEDATE = DateTime.Now,
|
|
|
|
UPDATEUSER = base.LoginUser.UserID,
|
|
|
|
USINGCOUNT = 0,
|
|
|
|
USINGSTATE = "0",
|
|
|
|
WORKCELL_CODE = mcinit == null ? "" : mcinit.WORKCELL_CODE_INIT,
|
|
|
|
WORKCENTER_CODE = mcinit == null ? "" : mcinit.WORKCENTER_CODE_INIT,
|
|
|
|
WORKLOC_CODE = "",
|
|
|
|
PLAN_ID = ""
|
|
|
|
};
|
|
|
|
prodal.Insert(product);
|
|
|
|
DAL.Operation.MainDAL maindal = new MainDAL();
|
|
|
|
maindal.BaseSession = session;
|
|
|
|
session.CommitTs();
|
|
|
|
return product;
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
session.RollbackTs();
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// 创建门板总成
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="framecode"></param>
|
|
|
|
/// <param name="materialcode"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
public Product CreateDPAssy(string framecode, string materialcode)
|
|
|
|
{
|
|
|
|
ProductDAL prodal = new ProductDAL();
|
|
|
|
var frame=prodal.Get(new Product{ PRODUCTCODE=framecode});
|
|
|
|
if(frame==null)
|
|
|
|
{
|
|
|
|
throw new Exception("查找主框架信息失败!");
|
|
|
|
}
|
|
|
|
MD.DAL.PbomDAL bomdal=new MD.DAL.PbomDAL();
|
|
|
|
var bom= bomdal.Get(new MD.Entity.Pbom { MATERIAL_CODE= materialcode});
|
|
|
|
if(bom==null)
|
|
|
|
{
|
|
|
|
throw new Exception("查找总成BOM信息失败!");
|
|
|
|
}
|
|
|
|
var DFmaterial= bomdal.GetUPLevelItem(bom.PBOM_CODE,frame.MATERIAL_CODE);
|
|
|
|
string productcode=GenerateCode(DFmaterial.MATERIAL_CODE,DateTime.Now.AddDays(-5));
|
|
|
|
|
|
|
|
var materialdal = new MD.DAL.MaterialDAL();
|
|
|
|
var material = materialdal.Get(new MD.Entity.Material { MATERIAL_CODE = materialcode });
|
|
|
|
var materialdf = materialdal.Get(new MD.Entity.Material { MATERIAL_CODE = DFmaterial.MATERIAL_CODE });
|
|
|
|
|
|
|
|
var matinitdal = new FJC.DAL.Basic.MaterialCodeInitDAL();
|
|
|
|
var mcinit = matinitdal.GetByCondition(new MaterialCodeInit { MATERIAL_TYPE = material.MATERIAL_TYPE_CODE });
|
|
|
|
var mcinitdf = matinitdal.GetByCondition(new MaterialCodeInit { MATERIAL_TYPE = materialdf.MATERIAL_TYPE_CODE });
|
|
|
|
|
|
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
session.OpenTs();
|
|
|
|
prodal.BaseSession = session;
|
|
|
|
|
|
|
|
var frameassy = new Product
|
|
|
|
{
|
|
|
|
CAPACITY = 1,
|
|
|
|
CREATEDATE = DateTime.Now.AddDays(-5),
|
|
|
|
CREATEUSER = base.LoginUser.UserID,
|
|
|
|
CURRENTPROCESS = "",
|
|
|
|
ENDOFLINE = "1",
|
|
|
|
MACHINECODDE = "",
|
|
|
|
MACHINENAME = "",
|
|
|
|
MATERIAL_CODE = DFmaterial.MATERIAL_CODE,
|
|
|
|
MATERIAL_TYPE = materialdf.MATERIAL_TYPE_CODE,
|
|
|
|
OUTFLAG = "0",
|
|
|
|
PID = Guid.NewGuid().ToString(),
|
|
|
|
PRODUCELINE = "",
|
|
|
|
PRODUCESHIFTNAME = "A",
|
|
|
|
PRODUCESHIFTTCODE = "A",
|
|
|
|
PRODUCTCODE = productcode,
|
|
|
|
PRODUCTSOURCE = "0",
|
|
|
|
PRODUCTTYPE = "",
|
|
|
|
STATUS = "0",
|
|
|
|
TEAM_CODE = "",
|
|
|
|
UPDATEDATE = DateTime.Now.AddDays(-5),
|
|
|
|
UPDATEUSER = base.LoginUser.UserID,
|
|
|
|
USINGCOUNT = 0,
|
|
|
|
USINGSTATE = "0",
|
|
|
|
WORKCELL_CODE = mcinit == null ? "" : mcinit.WORKCELL_CODE_INIT,
|
|
|
|
WORKCENTER_CODE = mcinit == null ? "" : mcinit.WORKCENTER_CODE_INIT,
|
|
|
|
WORKLOC_CODE = "",
|
|
|
|
PLAN_ID = ""
|
|
|
|
};
|
|
|
|
var dpassy = new Product
|
|
|
|
{
|
|
|
|
CAPACITY = 1,
|
|
|
|
CREATEDATE = DateTime.Now.AddDays(-5).AddSeconds(1),
|
|
|
|
CREATEUSER = base.LoginUser.UserID,
|
|
|
|
CURRENTPROCESS = "",
|
|
|
|
ENDOFLINE = "1",
|
|
|
|
MACHINECODDE = "",
|
|
|
|
MACHINENAME = "",
|
|
|
|
MATERIAL_CODE = materialcode,
|
|
|
|
MATERIAL_TYPE = material.MATERIAL_TYPE_CODE,
|
|
|
|
OUTFLAG = "0",
|
|
|
|
PID = Guid.NewGuid().ToString(),
|
|
|
|
PRODUCELINE = "",
|
|
|
|
PRODUCESHIFTNAME = "A",
|
|
|
|
PRODUCESHIFTTCODE = "A",
|
|
|
|
PRODUCTCODE = productcode,
|
|
|
|
PRODUCTSOURCE = "0",
|
|
|
|
PRODUCTTYPE = "",
|
|
|
|
STATUS = "0",
|
|
|
|
TEAM_CODE = "",
|
|
|
|
UPDATEDATE = DateTime.Now.AddDays(-5).AddSeconds(1),
|
|
|
|
UPDATEUSER = base.LoginUser.UserID,
|
|
|
|
USINGCOUNT = 0,
|
|
|
|
USINGSTATE = "0",
|
|
|
|
WORKCELL_CODE = mcinit == null ? "" : mcinit.WORKCELL_CODE_INIT,
|
|
|
|
WORKCENTER_CODE = mcinit == null ? "" : mcinit.WORKCENTER_CODE_INIT,
|
|
|
|
WORKLOC_CODE = "",
|
|
|
|
PLAN_ID = ""
|
|
|
|
};
|
|
|
|
prodal.Insert(dpassy);
|
|
|
|
prodal.Insert(frameassy);
|
|
|
|
DAL.QT.ProductStructureDAL psdal = new DAL.QT.ProductStructureDAL();
|
|
|
|
psdal.BaseSession = session;
|
|
|
|
psdal.Insert(new ProductStructure { PID = Guid.NewGuid().ToString(), PROCESS_CODE = productcode, PRODUCT_PID = frameassy.PID, PART_PID = frame.PID });
|
|
|
|
psdal.Insert(new ProductStructure { PID = Guid.NewGuid().ToString(), PROCESS_CODE = productcode, PRODUCT_PID = dpassy.PID, PART_PID = frameassy.PID });
|
|
|
|
session.CommitTs();
|
|
|
|
return dpassy;
|
|
|
|
}
|
|
|
|
catch (Exception e)
|
|
|
|
{
|
|
|
|
session.RollbackTs();
|
|
|
|
throw e;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
private string GenerateCode(string materialcode, DateTime time)
|
|
|
|
{
|
|
|
|
MD.DAL.MaterialDAL mdal = new MD.DAL.MaterialDAL();
|
|
|
|
var material = mdal.Get(new MD.Entity.Material { MATERIAL_CODE = materialcode });
|
|
|
|
if (material == null)
|
|
|
|
{
|
|
|
|
throw new Exception("查找物料信息失败!");
|
|
|
|
}
|
|
|
|
DAL.Basic.MaterialCodeInitDAL mcdal = new DAL.Basic.MaterialCodeInitDAL();
|
|
|
|
var materialinit = mcdal.GetByCondition(new Entity.Basic.MaterialCodeInit { MATERIAL_TYPE = material.MATERIAL_TYPE_CODE });
|
|
|
|
|
|
|
|
string prefix = "";
|
|
|
|
if (materialinit != null)
|
|
|
|
{
|
|
|
|
prefix = materialinit.PRODUCT_TYPES;
|
|
|
|
}
|
|
|
|
|
|
|
|
var productdal = new DAL.Produce.ProductDAL();
|
|
|
|
|
|
|
|
string maxcode = productdal.GetMaxCode(material.MATERIAL_TYPE_CODE, time);
|
|
|
|
string newcode = "1";
|
|
|
|
if (!string.IsNullOrEmpty(maxcode))
|
|
|
|
{
|
|
|
|
newcode = (Convert.ToInt32(maxcode) + 1) + "";
|
|
|
|
}
|
|
|
|
newcode = prefix + time.ToString("yyyyMMdd") + newcode.PadLeft(6, '0');
|
|
|
|
|
|
|
|
return newcode;
|
|
|
|
}
|
|
|
|
|
|
|
|
#region 获取主体条码下的零件列表
|
|
|
|
|
|
|
|
public List<Product> GetMainProductMaterialCodeList(string productcode)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
return new ProductDAL().GetMainProductMaterialCodeList(productcode);
|
|
|
|
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
throw ex;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 替换并添加临时表
|
|
|
|
|
|
|
|
public int ReplaceProductMaterialCode(Product mainProduct, Product childProduct, Product replaceProduct)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
return new ProductDAL().ReplaceProductMaterialCode(mainProduct, childProduct, replaceProduct,LoginUser.UserID);
|
|
|
|
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
#region 替换件导出数据
|
|
|
|
/// <summary>
|
|
|
|
/// 获取导出的数据
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="user">查询条件</param>
|
|
|
|
/// <returns>数据</returns>
|
|
|
|
public DataResult<DataTable> GetExpProductReplaceList(ProductReplace model)
|
|
|
|
{
|
|
|
|
DataResult<DataTable> result = new DataResult<DataTable>();
|
|
|
|
try
|
|
|
|
{
|
|
|
|
result.IsSuccess = true;
|
|
|
|
result.Result = new ProductDAL().GetExpProductReplaceList(model);
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
|
|
{
|
|
|
|
ErrorInfo = ex,
|
|
|
|
Tag = ex.StackTrace,
|
|
|
|
Info = "导出错误!"
|
|
|
|
});
|
|
|
|
result.IsSuccess = false;
|
|
|
|
result.Msg = "导出错误!";
|
|
|
|
}
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
|
|
public DataResult<ProductFullInfo> GetProductAllInfo(string productcode)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
var result=new DataResult<ProductFullInfo>();
|
|
|
|
var product = new ProductDAL().GetProductByAssembleCode(productcode);
|
|
|
|
if (product == null)
|
|
|
|
{
|
|
|
|
DAL.Operation.MainCodeChangeDAL dal = new MainCodeChangeDAL();
|
|
|
|
var codechangerecord=dal.GetChangeRecord(productcode);
|
|
|
|
if (codechangerecord != null && codechangerecord.Count > 0)
|
|
|
|
{
|
|
|
|
string newproductcode = codechangerecord.OrderByDescending(p => p.CREATEDATE).FirstOrDefault().NEWMAINCODE;
|
|
|
|
product = new ProductDAL().GetProductByAssembleCode(newproductcode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (product == null)
|
|
|
|
{
|
|
|
|
List<Product> ProductList = new MainOperationDAL().GetMainOperations(new Product() { PRODUCTCODE = productcode });
|
|
|
|
if (ProductList != null && ProductList.Count > 1)
|
|
|
|
{
|
|
|
|
result.IsSuccess = false;
|
|
|
|
result.Msg = "此条码为批量条码,无法进行反关联查询!";
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
product = ProductList[0];
|
|
|
|
}
|
|
|
|
|
|
|
|
if (product == null)
|
|
|
|
{
|
|
|
|
result.IsSuccess = false;
|
|
|
|
result.Msg = "条码无效,未找到与此条码相关产品信息!";
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
if (product.USINGSTATE == "2" && product.CAPACITY <= 1)
|
|
|
|
{
|
|
|
|
var product1 = new ProductDAL().GetProductByPartID(product.PID);
|
|
|
|
if (product1 != null)
|
|
|
|
{
|
|
|
|
product = product1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var material = new MD.DAL.MaterialDAL().GetMaterial(product.MATERIAL_CODE);
|
|
|
|
|
|
|
|
|
|
|
|
if (material != null)
|
|
|
|
{
|
|
|
|
product.MATERIAL_NAME = material.MATERIAL_NAME;
|
|
|
|
product.MATERIAL_TYPE_NAME = material.MATERIAL_TYPE_NAME;
|
|
|
|
product.MATERIAL_ATTRIBUTE = material.MATERIAL_ATTRIBUTE;
|
|
|
|
}
|
|
|
|
|
|
|
|
var partlist = new DAL.Operation.ProductDAL().GetPartList(product.PRODUCTCODE);
|
|
|
|
|
|
|
|
|
|
|
|
DictManageBLL dictOutFlagBll = new DictManageBLL(DictKind.OUTFLAG);
|
|
|
|
DictManageBLL dictUsingStateBll = new DictManageBLL(DictKind.USINGSTATE);
|
|
|
|
DictManageBLL dictMaterialAttributeBll = new DictManageBLL("MATERIALATTRIBUTE");
|
|
|
|
DictManageBLL dictProductStatusBll = new DictManageBLL(DictKind.PRODUCTSTATUS);
|
|
|
|
DictManageBLL dictIntypeBll = new DictManageBLL(DictKind.INTTYPE);
|
|
|
|
|
|
|
|
product.STATUSNAME = dictProductStatusBll.GetDictValue(product.STATUS);
|
|
|
|
product.OUTFLAGNAME = dictOutFlagBll.GetDictValue(product.OUTFLAG);
|
|
|
|
product.USINGSTATENAME = dictUsingStateBll.GetDictValue(product.USINGSTATE);
|
|
|
|
product.MATERIAL_ATTRIBUTE = dictMaterialAttributeBll.GetDictValue(material.MATERIAL_ATTRIBUTE);
|
|
|
|
|
|
|
|
DAL.Operation.ProductOutDAL outdal = new ProductOutDAL();
|
|
|
|
var outrecord=outdal.GetList(product.PRODUCTCODE);
|
|
|
|
|
|
|
|
DAL.ProductIn.ProductInDAL indal = new DAL.ProductIn.ProductInDAL();
|
|
|
|
var inrecord = indal.GetInRecords(string.IsNullOrEmpty(product.MAINCODE) ? product.PRODUCTCODE : product.MAINCODE);
|
|
|
|
foreach (var ir in inrecord)
|
|
|
|
{
|
|
|
|
ir.INTTYPE_NAME = dictIntypeBll.GetDictValue(ir.INTTYPE);
|
|
|
|
}
|
|
|
|
|
|
|
|
var shipinfo = new DAL.Operation.ProductDAL().GetShipmentInfo(string.IsNullOrEmpty(product.MAINCODE) ? product.PRODUCTCODE : product.MAINCODE);
|
|
|
|
|
|
|
|
var codereplaterecord = new MainCodeChangeDAL().GetChangeRecordFromNewCode(string.IsNullOrEmpty(product.MAINCODE) ? product.PRODUCTCODE : product.MAINCODE);
|
|
|
|
|
|
|
|
result.IsSuccess = true;
|
|
|
|
result.Result = new ProductFullInfo
|
|
|
|
{
|
|
|
|
ProductBasicInfo = product,
|
|
|
|
ProductOutRecord = outrecord,
|
|
|
|
ProductInRecord = inrecord,
|
|
|
|
PartList = partlist,
|
|
|
|
ShipmentInfo=shipinfo,
|
|
|
|
CodeReplaceRecord=codereplaterecord
|
|
|
|
};
|
|
|
|
return result;
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
catch (Exception ex)
|
|
|
|
{
|
|
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
|
|
{
|
|
|
|
ErrorInfo = ex,
|
|
|
|
Tag = ex.StackTrace,
|
|
|
|
Info = "零件条码--获取零件信息"
|
|
|
|
});
|
|
|
|
throw ex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public DataResult<Product> GetProductInfoByAnyBarcode(string productcode)
|
|
|
|
{
|
|
|
|
try
|
|
|
|
{
|
|
|
|
var result = new DataResult<Product>();
|
|
|
|
var product = new ProductDAL().GetProductByAssembleCode(productcode);
|
|
|
|
if (product == null)
|
|
|
|
{
|
|
|
|
DAL.Operation.MainCodeChangeDAL dal = new MainCodeChangeDAL();
|
|
|
|
var codechangerecord = dal.GetChangeRecord(productcode);
|
|
|
|
if (codechangerecord != null && codechangerecord.Count > 0)
|
|
|
|
{
|
|
|
|
string newproductcode = codechangerecord.OrderByDescending(p => p.CREATEDATE).FirstOrDefault().NEWMAINCODE;
|
|
|
|
product = new ProductDAL().GetProductByAssembleCode(newproductcode);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (product == null)
|
|
|
|
{
|
|
|
|
result.IsSuccess = false;
|
|
|
|
result.Msg = "条码无效,未找到与此条码相关产品信息!";
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
if (product.USINGSTATE == "2" && product.CAPACITY <= 1)
|
|
|
|
{
|
|
|
|
var product1 = new ProductDAL().GetProductByPartID(product.PID);
|
|
|
|
if (product1 != null)
|
|
|
|
{
|
|
|
|
product = product1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
var material = new MD.DAL.MaterialDAL().GetMaterial(product.MATERIAL_CODE);
|
|
|
|
|
|
|
|
|
|
|
|
if (material != null)
|
|
|
|
{
|
|
|
|
product.MATERIAL_NAME = material.MATERIAL_NAME;
|
|
|
|
product.MATERIAL_TYPE_NAME = material.MATERIAL_TYPE_NAME;
|
|
|
|
product.MATERIAL_ATTRIBUTE = material.MATERIAL_ATTRIBUTE;
|
|
|
|
}
|
|
|
|
DictManageBLL dictOutFlagBll = new DictManageBLL(DictKind.OUTFLAG);
|
|
|
|
DictManageBLL dictUsingStateBll = new DictManageBLL(DictKind.USINGSTATE);
|
|
|
|
DictManageBLL dictMaterialAttributeBll = new DictManageBLL("MATERIALATTRIBUTE");
|
|
|
|
DictManageBLL dictProductStatusBll = new DictManageBLL(DictKind.PRODUCTSTATUS);
|
|
|
|
//DictManageBLL dictIntypeBll = new DictManageBLL(DictKind.INTTYPE);
|
|
|
|
|
|
|
|
product.STATUSNAME = dictProductStatusBll.GetDictValue(product.STATUS);
|
|
|
|
product.OUTFLAGNAME = dictOutFlagBll.GetDictValue(product.OUTFLAG);
|
|
|
|
product.USINGSTATENAME = dictUsingStateBll.GetDictValue(product.USINGSTATE);
|
|
|
|
product.MATERIAL_ATTRIBUTE = dictMaterialAttributeBll.GetDictValue(material.MATERIAL_ATTRIBUTE);
|
|
|
|
result.IsSuccess = true;
|
|
|
|
result.Result = product;
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
catch(Exception ex)
|
|
|
|
{
|
|
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
|
|
{
|
|
|
|
ErrorInfo = ex,
|
|
|
|
Tag = ex.StackTrace,
|
|
|
|
Info = "零件条码--获取零件信息"
|
|
|
|
});
|
|
|
|
throw ex;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<Product> GetPartList(string productCode)
|
|
|
|
{
|
|
|
|
var partlist = new DAL.Operation.ProductDAL().GetPartList(productCode);
|
|
|
|
return partlist;
|
|
|
|
}
|
|
|
|
|
|
|
|
public ShipmentInfo GetShipmentInfo(string productCode)
|
|
|
|
{
|
|
|
|
var shipinfo = new DAL.Operation.ProductDAL().GetShipmentInfo(productCode);
|
|
|
|
return shipinfo;
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|