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.
704 lines
28 KiB
704 lines
28 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using QMAPP.FJC.Entity.ProcessParameter;
|
|
using QMAPP.FJC.Entity.Operation;
|
|
using QMAPP.FJC.Entity.Basic;
|
|
using QMAPP.FJC.DAL.Basic;
|
|
using QMAPP.FJC.Entity;
|
|
using QMAPP.FJC.Entity.Injection;
|
|
using QMAPP.FJC.DAL.Injection;
|
|
using QMFrameWork.Data;
|
|
using QMAPP.FJC.DAL.Operation;
|
|
using QMAPP.FJC.DAL;
|
|
using QMAPP.FJC.BLL.Common;
|
|
using QMFrameWork.Common.Util;
|
|
using System.Configuration;
|
|
using QMAPP.FJC.BLL.Dict;
|
|
using QMFrameWork.Log;
|
|
using QMAPP.MD.Entity;
|
|
using QMAPP.MD.DAL;
|
|
|
|
namespace QMAPP.FJC.BLL.Process
|
|
{
|
|
/// <summary>
|
|
/// 搪塑加工处理类
|
|
/// 作者:闫永刚
|
|
/// 日期:2015-05-28
|
|
/// </summary>
|
|
public class SlushProcess
|
|
{
|
|
/// <summary>
|
|
/// 处理搪塑信息
|
|
/// </summary>
|
|
/// <param name="entity"></param>
|
|
public List<string> Process(MachineInfo machine, List<ParameterConfig> parConfigList)
|
|
{
|
|
|
|
List<string> barcodeList = new List<string>();
|
|
//搪塑投料记录更新列表
|
|
List<InjectionRecorder> updateInjectList = new List<InjectionRecorder>();
|
|
//零件投料关联表
|
|
List<ProductInjection> addInjectItemList = new List<ProductInjection>();
|
|
|
|
InjectionRecorderDAL injectDal = new InjectionRecorderDAL();
|
|
|
|
//条码
|
|
StringBuilder slushCode1 = new StringBuilder();
|
|
StringBuilder slushCode2 = new StringBuilder();
|
|
|
|
try
|
|
{
|
|
#region 产品条码属性
|
|
|
|
string year = "";
|
|
string month = "";
|
|
string day = "";
|
|
string hour = "";
|
|
string minute = "";
|
|
string second = "";
|
|
|
|
string mechineNo = "";
|
|
string producttype = "";
|
|
string hudorbasic = "";
|
|
string color = "";
|
|
string cavitytype = "";
|
|
string mouldcarrier1 = "";
|
|
string mouldcarrier2 = "";
|
|
string armNumber = "";
|
|
|
|
//
|
|
|
|
#endregion
|
|
|
|
#region 获取表皮条码号
|
|
|
|
//将十六进制装换成十进制
|
|
var a = parConfigList.First(o => o.COLUMNCODE.Contains("YEAR")).PARAVALUE;
|
|
year = BinaryConvert.DecToHex(parConfigList.First(o => o.COLUMNCODE.Contains("YEAR")).PARAVALUE.ToString());
|
|
month = BinaryConvert.DecToHex(parConfigList.First(o => o.COLUMNCODE.Contains("MONTH")).PARAVALUE.ToString());
|
|
day = BinaryConvert.DecToHex(parConfigList.First(o => o.COLUMNCODE.Contains("DAY")).PARAVALUE.ToString());
|
|
hour = BinaryConvert.DecToHex(parConfigList.First(o => o.COLUMNCODE.Contains("HOUR")).PARAVALUE.ToString());
|
|
minute = BinaryConvert.DecToHex(parConfigList.First(o => o.COLUMNCODE.Contains("MINUTE")).PARAVALUE.ToString());
|
|
second = BinaryConvert.DecToHex(parConfigList.First(o => o.COLUMNCODE.Contains("SECOND")).PARAVALUE.ToString());
|
|
|
|
//机器号
|
|
//mechineNo = parConfigList.First(o => o.COLUMNCODE.Contains("MACHINENO")).PARAVALUE.ToString();
|
|
mechineNo = machine.MACHINENUM.ToString();
|
|
//产品类别
|
|
//producttype = parConfigList.First(o => o.COLUMNCODE.Contains("PRODUCT")).PARAVALUE.ToString();
|
|
producttype = "A";
|
|
//高低配
|
|
hudorbasic = parConfigList.First(o => o.COLUMNCODE.Contains("HUDORBASIC")).PARAVALUE.ToString();
|
|
//颜色
|
|
List<ParameterConfig> cc = parConfigList.Where(o => o.COLUMNCODE.Contains("SLUSHCOLOR")).ToList<ParameterConfig>();
|
|
color = parConfigList.First(o => o.COLUMNCODE.Contains("SLUSHCOLOR")).PARAVALUE.ToString();
|
|
//腔信息
|
|
cavitytype = parConfigList.First(o => o.COLUMNCODE.Contains("CAVITYTYPE")).PARAVALUE.ToString();
|
|
//腔号
|
|
mouldcarrier1 = parConfigList.First(o => o.COLUMNCODE.Contains("MOULDCARRIER1")).PARAVALUE.ToString();
|
|
|
|
mouldcarrier2 = parConfigList.First(o => o.COLUMNCODE.Contains("MOULDCARRIER2")).PARAVALUE.ToString();
|
|
|
|
|
|
armNumber = parConfigList.First(o => o.COLUMNCODE.Contains("ARMNUMBER")).PARAVALUE.ToString();
|
|
|
|
DateTime nowDt = System.DateTime.Now;
|
|
year = nowDt.Year.ToString().Substring(2);
|
|
month = nowDt.Month.ToString().PadLeft(2, '0');
|
|
day = nowDt.Day.ToString().PadLeft(2, '0');
|
|
hour = nowDt.Hour.ToString().PadLeft(2, '0');
|
|
minute = nowDt.Minute.ToString().PadLeft(2, '0');
|
|
|
|
slushCode1.Append(year.PadLeft(2, '0'));
|
|
slushCode2.Append(year.PadLeft(2, '0'));
|
|
|
|
|
|
slushCode1.Append(month.PadLeft(2, '0'));
|
|
slushCode2.Append(month.PadLeft(2, '0'));
|
|
|
|
slushCode1.Append(day.PadLeft(2, '0'));
|
|
slushCode2.Append(day.PadLeft(2, '0'));
|
|
|
|
slushCode1.Append(hour.PadLeft(2, '0'));
|
|
slushCode2.Append(hour.PadLeft(2, '0'));
|
|
|
|
slushCode1.Append(minute.PadLeft(2, '0'));
|
|
slushCode2.Append(minute.PadLeft(2, '0'));
|
|
|
|
slushCode1.Append(mechineNo);
|
|
slushCode2.Append(mechineNo);
|
|
|
|
slushCode1.Append(producttype);
|
|
slushCode2.Append(producttype);
|
|
|
|
List<string> hbList = hudorbasic.Split('/').ToList<string>();
|
|
slushCode1.Append(hbList[0]);
|
|
slushCode2.Append(hbList[1]);
|
|
|
|
slushCode1.Append(color);
|
|
slushCode2.Append(color);
|
|
|
|
List<string> ctList = cavitytype.Split('/').ToList<string>();
|
|
slushCode1.Append(ctList[0]);
|
|
slushCode2.Append(ctList[1]);
|
|
|
|
//判断模具号的来源
|
|
//MoulderConfig值为true,表示来源于配置文件
|
|
//MoulderConfig值为false,表示来源于PLC读取
|
|
|
|
//2016-6-2通过数据库获取
|
|
List<MoldSet> setList = new MoldSetDAL().GetList();
|
|
|
|
string moulderConfig = ConfigurationManager.AppSettings["MoulderConfig"].ToString();
|
|
if (Convert.ToBoolean(moulderConfig))
|
|
{
|
|
MoldSet moldSet = setList.First(o => o.ARMNUMBER == Convert.ToInt32(armNumber));
|
|
//DictManageBLL dictStatusBll = new DictManageBLL(DictKind.ARMNUMBERWITHMOULDER);
|
|
slushCode1.Append(moldSet.MOLDNUMBERA.ToString().PadLeft(2, '0'));
|
|
slushCode2.Append(moldSet.MOLDNUMBERB.ToString().PadLeft(2, '0'));
|
|
}
|
|
else
|
|
{
|
|
|
|
slushCode1.Append(mouldcarrier1.PadLeft(2, '0'));
|
|
slushCode2.Append(mouldcarrier2.PadLeft(2, '0'));
|
|
}
|
|
|
|
barcodeList.Add(slushCode1.ToString());
|
|
barcodeList.Add(slushCode2.ToString());
|
|
|
|
#endregion
|
|
|
|
#region 零件条码信息
|
|
|
|
List<Product> productList = new List<Product>();
|
|
|
|
Product product = new Product();
|
|
product.PID = Guid.NewGuid().ToString();
|
|
product.PRODUCTCODE = slushCode1.ToString();
|
|
product.PRODUCTTYPE = EnumGeter.ProductType.biaopi.GetHashCode().ToString();
|
|
product.MACHINENAME = machine.MACHINENAME;
|
|
product.MACHINECODDE = machine.MACHINECODDE;
|
|
//自制件
|
|
product.PRODUCTSOURCE = EnumGeter.PRODUCTSOURCE.SELFMADE.GetHashCode().ToString();
|
|
//合格品
|
|
product.STATUS = EnumGeter.STATUS.QUALIFIED.GetHashCode().ToString();
|
|
product.CURRENTPROCESS = EnumGeter.ProcessType.lengdaoruohua.GetHashCode().ToString();
|
|
//product.CURRENTPROCESS
|
|
product.PRODUCELINE = "B9";
|
|
product.PRODUCESHIFTNAME = "";
|
|
product.PRODUCESHIFTTCODE = "";
|
|
//在库
|
|
product.OUTFLAG = EnumGeter.OUTFLAG.INWAREHOUSE.GetHashCode().ToString();
|
|
//未使用
|
|
product.USINGSTATE = EnumGeter.USINGSTATE.UNUSED.GetHashCode().ToString();
|
|
product.CAPACITY = 1;
|
|
product.USINGCOUNT = 0;
|
|
product.CREATEUSER = machine.PID;
|
|
product.CREATEDATE = System.DateTime.Now;
|
|
product.UPDATEUSER = machine.PID;
|
|
product.UPDATEDATE = System.DateTime.Now;
|
|
|
|
Product product2 = new Product();
|
|
product2 = BindHelper.CopyToModel<Product, Product>(product, false);
|
|
product2.PID = Guid.NewGuid().ToString();
|
|
product2.PRODUCTCODE = slushCode2.ToString();
|
|
|
|
productList.Add(product);
|
|
productList.Add(product2);
|
|
|
|
|
|
#endregion
|
|
|
|
#region 表皮属性
|
|
|
|
List<ProductAttribute> proAttrList = new List<ProductAttribute>();
|
|
|
|
ProductAttribute proAttr = new ProductAttribute();
|
|
proAttr.PID = Guid.NewGuid().ToString();
|
|
proAttr.MPPID = product.PID;
|
|
proAttr.VAL1 = machine.MACHINENUM;
|
|
proAttr.VAL2 = product.PRODUCTTYPE;
|
|
proAttr.VAL3 = hudorbasic.Substring(0, 1) ;
|
|
proAttr.VAL4 = color.ToString();
|
|
proAttr.VAL5 = cavitytype.Substring(0, 1);
|
|
proAttr.VAL6 = mouldcarrier1.PadLeft(2,'0');
|
|
proAttr.VAL7 = System.DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
|
|
proAttr.CREATEDATE = System.DateTime.Now;
|
|
proAttr.CREATEDATE = System.DateTime.Now;
|
|
proAttr.CREATEUSER = machine.PID;
|
|
proAttr.UPDATEUSER = machine.PID;
|
|
proAttrList.Add(proAttr);
|
|
|
|
ProductAttribute proAttr2 = new ProductAttribute();
|
|
|
|
proAttr2 = BindHelper.CopyToModel<ProductAttribute, ProductAttribute>(proAttr, false);
|
|
proAttr2.PID = Guid.NewGuid().ToString();
|
|
proAttr2.MPPID = product2.PID;
|
|
proAttr2.VAL3 = hudorbasic.Substring(2, 1);
|
|
proAttr2.VAL6 = mouldcarrier2.PadLeft(2, '0');
|
|
|
|
proAttrList.Add(proAttr2);
|
|
|
|
#endregion
|
|
|
|
#region 加工工序信息
|
|
|
|
List<MainOperation> moList = new List<MainOperation>();
|
|
|
|
MainOperation operation = new MainOperation();
|
|
operation.PID = Guid.NewGuid().ToString();
|
|
operation.PDID = product.PID;
|
|
operation.PRODUCTCODE = product.PRODUCTCODE;
|
|
//搪塑
|
|
operation.PROCESSTYPE = EnumGeter.ProcessType.tangsu.GetHashCode().ToString();
|
|
operation.PRODUCTTYPE = EnumGeter.ProductType.biaopi.GetHashCode().ToString();
|
|
operation.MACHINENAME = machine.MACHINENAME;
|
|
operation.MACHINECODDE = machine.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();
|
|
|
|
List<ParameterConfig> cccList = parConfigList.Where(o => o.COLUMNCODE.Contains("ARMNUMBER") && o.MOLDNUMBER != "0").ToList<ParameterConfig>();
|
|
operation.MOLDNUMBER = parConfigList.First(o => o.COLUMNCODE.Contains("ARMNUMBER") && o.MOLDNUMBER != "0").PARAVALUE.ToString();
|
|
operation.PRODUCESHIFTNAME = "";
|
|
operation.PRODUCESHIFTTCODE = "";
|
|
operation.PRODUCELINE = "B9";
|
|
operation.MODELSTATION = operation.MOLDNUMBER;
|
|
operation.CREATEUSER = machine.PID;
|
|
operation.CREATEDATE = System.DateTime.Now;
|
|
operation.UPDATEUSER = machine.PID;
|
|
operation.UPDATEDATE = System.DateTime.Now;
|
|
|
|
moList.Add(operation);
|
|
|
|
MainOperation operation2 = new MainOperation();
|
|
operation2 = BindHelper.CopyToModel<MainOperation, MainOperation>(operation, false);
|
|
operation2.PID = Guid.NewGuid().ToString();
|
|
operation2.PDID = product2.PID;
|
|
operation2.PRODUCTCODE = product2.PRODUCTCODE;
|
|
moList.Add(operation2);
|
|
|
|
|
|
#endregion
|
|
|
|
#region 加工记录
|
|
|
|
List<SlushParamter> slushParaList = new List<SlushParamter>();
|
|
|
|
SlushParamter slushParamter = new SlushParamter();
|
|
slushParamter.PID = Guid.NewGuid().ToString();
|
|
slushParamter.IOID = operation.PID;
|
|
slushParamter.EID = operation.PDID;
|
|
//slushParamter.PRODUCTCODE = operation.PRODUCTCODE;
|
|
slushParamter.MACHINECODDE = operation.MACHINECODDE;
|
|
slushParamter.MACHINENAME = operation.MACHINENAME;
|
|
slushParamter.CREATEDATE = System.DateTime.Now;
|
|
slushParamter.EPIDERMISCODE = product.PRODUCTCODE;
|
|
|
|
|
|
List<ParameterConfig> parameterList = parConfigList.Where(o => o.COLUMNTYPE == "5").ToList<ParameterConfig>();
|
|
Type t = typeof(SlushParamter);
|
|
|
|
foreach (ParameterConfig pc in parameterList)
|
|
{
|
|
|
|
try
|
|
{
|
|
if (pc.DATATYPE == "DECIMAL")
|
|
{
|
|
decimal val = Convert.ToDecimal(pc.PARAVALUE);
|
|
if (pc.DEALTYPE == "DIVIDE")
|
|
val = val / 10;
|
|
t.GetProperty(pc.COLUMNCODE).SetValue(slushParamter, val, null);
|
|
}
|
|
else if (pc.DATATYPE == "INT")
|
|
{
|
|
int val = Convert.ToInt32(pc.PARAVALUE);
|
|
if (pc.DEALTYPE == "DIVIDE")
|
|
val = val / 10;
|
|
|
|
t.GetProperty(pc.COLUMNCODE).SetValue(slushParamter, val, null);
|
|
}
|
|
else
|
|
{
|
|
t.GetProperty(pc.COLUMNCODE).SetValue(slushParamter, pc.PARAVALUE.ToString(), null);
|
|
}
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
|
|
}
|
|
|
|
}
|
|
|
|
slushParamter.HB = proAttr.VAL3;
|
|
|
|
slushParaList.Add(slushParamter);
|
|
|
|
SlushParamter slushParamter2 = new SlushParamter();
|
|
|
|
slushParamter2 = BindHelper.CopyToModel<SlushParamter, SlushParamter>(slushParamter, false);
|
|
|
|
slushParamter2.PID = Guid.NewGuid().ToString();
|
|
slushParamter2.IOID = operation2.PID;
|
|
slushParamter2.EID = operation2.PDID;
|
|
//slushParamter2.PRODUCTCODE = operation2.PRODUCTCODE;
|
|
slushParamter2.HB = proAttr2.VAL3;
|
|
slushParamter2.EPIDERMISCODE = product2.PRODUCTCODE;
|
|
slushParaList.Add(slushParamter2);
|
|
|
|
#endregion
|
|
|
|
#region 获取表皮投料配置规则
|
|
|
|
//获取该颜色、高低配的表皮投料配置信息
|
|
List<ProductMderule> ruleList = new ProductMderuleDAL().GetList(new ProductMderule()
|
|
{
|
|
HB = slushParamter.HB,
|
|
COLORCODE = slushParamter.COLORCODE,
|
|
PRODUCTTYPE = EnumGeter.ProductType.biaopi.GetHashCode().ToString()
|
|
});
|
|
|
|
List<ProductMderule> ruleList2 = new ProductMderuleDAL().GetList(new ProductMderule()
|
|
{
|
|
HB = slushParamter2.HB,
|
|
COLORCODE = slushParamter2.COLORCODE,
|
|
PRODUCTTYPE = EnumGeter.ProductType.biaopi.GetHashCode().ToString()
|
|
});
|
|
|
|
//遍历规则信息
|
|
foreach (ProductMderule pm in ruleList)
|
|
{
|
|
#region 获取相应的投料信息
|
|
|
|
List<InjectionRecorder> list = injectDal.GetLastRecorder(new InjectionRecorder()
|
|
{
|
|
//INJECTIONINDEX = pm.INJECTIONINDEX,
|
|
INJECTIONTERMINAL = pm.INJECTIONTERMINAL,
|
|
MACHINECODDE = machine.MACHINECODDE,
|
|
|
|
});
|
|
|
|
#endregion
|
|
|
|
if (list.Count > 0)
|
|
{
|
|
#region 修改投料记录
|
|
|
|
InjectionRecorder inRecorder = list[0];
|
|
inRecorder.USEDWEIGHTSUM += pm.USEDWEIGHT;
|
|
updateInjectList.Add(inRecorder);
|
|
|
|
#endregion
|
|
|
|
#region 零件投料关联记录
|
|
|
|
ProductInjection proInject = new ProductInjection();
|
|
|
|
proInject.PID = Guid.NewGuid().ToString();
|
|
proInject.IPID = inRecorder.PID;
|
|
proInject.MPPID = product.PID;
|
|
proInject.MATERIALNAME = inRecorder.MATERIALNAME;
|
|
proInject.MATERIALCODE = inRecorder.MATERIALCODE;
|
|
proInject.MATERIALTYPE = inRecorder.MATERIALTYPE;
|
|
proInject.MATERIALBATCH = inRecorder.MATERIALBATCH;
|
|
proInject.MATERIALCODE = inRecorder.MATERIALCODE;
|
|
proInject.INJECTIONINDEX = pm.INJECTIONINDEX;
|
|
proInject.INJECTIONTERMINAL = pm.INJECTIONTERMINAL;
|
|
proInject.USEDWEIGHT = pm.USEDWEIGHT;
|
|
proInject.CREATEDATE = System.DateTime.Now;
|
|
proInject.CREATEUSER = inRecorder.CREATEUSER;
|
|
proInject.UPDATEUSER = inRecorder.UPDATEUSER;
|
|
|
|
addInjectItemList.Add(proInject);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
//遍历规则信息
|
|
foreach (ProductMderule pm in ruleList2)
|
|
{
|
|
#region 获取相应的投料信息
|
|
|
|
List<InjectionRecorder> list = injectDal.GetLastRecorder(new InjectionRecorder()
|
|
{
|
|
//INJECTIONINDEX = pm.INJECTIONINDEX,
|
|
INJECTIONTERMINAL = pm.INJECTIONTERMINAL,
|
|
MACHINECODDE = machine.MACHINECODDE,
|
|
|
|
});
|
|
|
|
#endregion
|
|
|
|
if (list.Count > 0)
|
|
{
|
|
#region 修改投料记录
|
|
|
|
InjectionRecorder inRecorder = list[0];
|
|
|
|
//updateInjectList是否已经存在
|
|
if (updateInjectList.Count(o => o.PID == inRecorder.PID) > 0)
|
|
{
|
|
inRecorder = updateInjectList.First(o => o.PID == inRecorder.PID);
|
|
inRecorder.USEDWEIGHTSUM += pm.USEDWEIGHT;
|
|
}
|
|
else
|
|
{
|
|
inRecorder.USEDWEIGHTSUM += pm.USEDWEIGHT;
|
|
updateInjectList.Add(inRecorder);
|
|
}
|
|
|
|
|
|
|
|
#endregion
|
|
|
|
#region 零件投料关联记录
|
|
|
|
ProductInjection proInject = new ProductInjection();
|
|
|
|
proInject.PID = Guid.NewGuid().ToString();
|
|
proInject.IPID = inRecorder.PID;
|
|
proInject.MPPID = product2.PID;
|
|
proInject.MATERIALNAME = inRecorder.MATERIALNAME;
|
|
proInject.MATERIALCODE = inRecorder.MATERIALCODE;
|
|
proInject.MATERIALTYPE = inRecorder.MATERIALTYPE;
|
|
proInject.MATERIALBATCH = inRecorder.MATERIALBATCH;
|
|
proInject.MATERIALCODE = inRecorder.MATERIALCODE;
|
|
proInject.INJECTIONINDEX = pm.INJECTIONINDEX;
|
|
proInject.INJECTIONTERMINAL = pm.INJECTIONTERMINAL;
|
|
proInject.USEDWEIGHT = pm.USEDWEIGHT;
|
|
proInject.CREATEDATE = System.DateTime.Now;
|
|
proInject.CREATEUSER = inRecorder.CREATEUSER;
|
|
proInject.UPDATEUSER = inRecorder.UPDATEUSER;
|
|
|
|
addInjectItemList.Add(proInject);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 数据库操作
|
|
|
|
ProductDAL productDAL = new ProductDAL();
|
|
ProductInjectionDAL proInjectDal = new ProductInjectionDAL();
|
|
MainOperationDAL mainOperationDAL = new MainOperationDAL();
|
|
//SlushParamterDAL slushParamterDAL = new SlushParamterDAL();
|
|
ProductAttributeDAL paDal = new ProductAttributeDAL();
|
|
using (IDataSession session = AppDataFactory.CreateMainSession())
|
|
{
|
|
session.OpenTs();
|
|
|
|
#region session注入
|
|
|
|
productDAL.BaseSession = session;
|
|
injectDal.BaseSession = session;
|
|
proInjectDal.BaseSession = session;
|
|
mainOperationDAL.BaseSession = session;
|
|
//slushParamterDAL.BaseSession = session;
|
|
|
|
|
|
#endregion
|
|
|
|
try
|
|
{
|
|
#region 插入产品信息
|
|
|
|
foreach (var p in productList)
|
|
{
|
|
productDAL.Insert(p);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 产品属性
|
|
|
|
foreach (var pro in proAttrList)
|
|
{
|
|
paDal.Insert(pro);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 插入加工记录
|
|
|
|
foreach (var mo in moList)
|
|
{
|
|
mainOperationDAL.Insert(mo);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 插入加工参数记录
|
|
|
|
foreach (var p in slushParaList)
|
|
{
|
|
////slushParamterDAL.Insert(p);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 插入产品投料记录关联表
|
|
|
|
foreach (var proinject in addInjectItemList)
|
|
{
|
|
proInjectDal.Insert(proinject);
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 更新投料信息
|
|
|
|
foreach (var inject in updateInjectList)
|
|
{
|
|
injectDal.Update(inject);
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
session.CommitTs();
|
|
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
session.RollbackTs();
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
|
|
#endregion
|
|
|
|
return barcodeList;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
#region 日志输出
|
|
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
{
|
|
ErrorInfo = ex,
|
|
Tag = ex.StackTrace,
|
|
Info = "生成条码信息出错!"
|
|
});
|
|
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
{
|
|
Info = "条码信息" + slushCode1.ToString()
|
|
});
|
|
LogManager.LogHelper.Error(new LogInfo()
|
|
{
|
|
Info = "条码信息" + slushCode2.ToString()
|
|
});
|
|
|
|
#endregion
|
|
|
|
throw ex;
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public List<ProductInjection> GetProductInjectionList(List<Product> products,MachineInfo machine,ref List<InjectionRecorder> updateInjectList)
|
|
{
|
|
InjectionRecorderDAL injectDal = new InjectionRecorderDAL();
|
|
updateInjectList = new List<InjectionRecorder>();
|
|
List<ProductInjection> addInjectItemList = new List<ProductInjection>();
|
|
|
|
foreach (var product in products)
|
|
{
|
|
//获取该颜色、高低配的表皮投料配置信息
|
|
//List<ProductMderule> ruleList = new ProductMderuleDAL().GetList(new ProductMderule()
|
|
//{
|
|
// HB = product.PRODUCTATTRIBUTE.VAL3,
|
|
// COLORCODE = product.PRODUCTATTRIBUTE.VAL4,
|
|
// PRODUCTTYPE = EnumGeter.ProductType.biaopi.GetHashCode().ToString()
|
|
//});
|
|
List<MD.Entity.PbomItem> boms = new PbomDAL().GetSubItem(product.MATERIAL_CODE);
|
|
|
|
//遍历规则信息
|
|
foreach (MD.Entity.PbomItem bom in boms)
|
|
{
|
|
#region 获取相应的投料信息
|
|
InjectionRecorder inRecorder = null;
|
|
|
|
|
|
|
|
List<InjectionRecorder> list = injectDal.GetLastRecorder(new InjectionRecorder()
|
|
{
|
|
//INJECTIONINDEX = pm.INJECTIONINDEX,
|
|
//INJECTIONTERMINAL = pm.INJECTIONTERMINAL,
|
|
MATERIALCODE=bom.MATERIAL_CODE,
|
|
MACHINECODDE = machine.MACHINECODDE,
|
|
|
|
});
|
|
|
|
#endregion
|
|
|
|
if (list.Count > 0)
|
|
{
|
|
#region 修改投料记录
|
|
inRecorder = updateInjectList.Find(m => m.PID.Equals(list[0].PID));
|
|
if (inRecorder != null)
|
|
{
|
|
inRecorder.USEDWEIGHTSUM += bom.UNIT_SUM;
|
|
}
|
|
else
|
|
{
|
|
|
|
|
|
inRecorder = list[0];
|
|
inRecorder.USEDWEIGHTSUM += bom.UNIT_SUM;
|
|
updateInjectList.Add(inRecorder);
|
|
}
|
|
|
|
|
|
#endregion
|
|
}
|
|
|
|
|
|
if (inRecorder != null)
|
|
{
|
|
#region 零件投料关联记录
|
|
|
|
ProductInjection proInject = new ProductInjection();
|
|
|
|
proInject.PID = Guid.NewGuid().ToString();
|
|
proInject.IPID = inRecorder.PID;
|
|
proInject.MPPID = product.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 = bom.UNIT_SUM;
|
|
proInject.CREATEDATE = System.DateTime.Now;
|
|
proInject.CREATEUSER = inRecorder.CREATEUSER;
|
|
proInject.UPDATEUSER = inRecorder.UPDATEUSER;
|
|
|
|
addInjectItemList.Add(proInject);
|
|
|
|
#endregion
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
return addInjectItemList;
|
|
|
|
}
|
|
|
|
|
|
}
|
|
}
|
|
|