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

222 lines
7.8 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QMAPP.FJC.Entity.Basic;
using QMAPP.FJC.Entity.Operation;
using QMAPP.FJC.DAL.Operation;
using QMAPP.FJC.Entity;
using QMAPP.FJC.BLL.Basic;
using QMFrameWork.Data;
using QMAPP.FJC.DAL.Injection;
using QMAPP.FJC.Entity.Injection;
namespace QMAPP.FJC.BLL.Process
{
/// <summary>
/// 红外扫描操作处理类
/// 作者:闫永刚
/// 日期:2015-05-28
/// </summary>
public class OperateProcess1
{
#region IProcess 成员
public void Process(MachineInfo machine,List<ParameterConfig> parConfigList)
{
#region 获取加工记录
List<MainOperation> listOperate = new List<MainOperation>();
MainOperationDAL modal = new MainOperationDAL();
MainOperation condition = new MainOperation()
{
OPERATESTATE = EnumGeter.OPERATESTATE.OPERATING.GetHashCode().ToString(),
PROCESSTYPE = machine.PROCESSTYPE,
MACHINECODDE = machine.MACHINECODDE,
MOLDNUMBER = parConfigList.First(o => o.COLUMNCODE.Contains("MCNO")).PARAVALUE.ToString(),
PRODUCELINE = machine.PRODUCELINE
};
//获取正在加工中的加工记录
List<MainOperation> mainOperatingList = modal.GetList(condition)
.OrderBy(o => o.CREATEDATE).ToList<MainOperation>();
//加工操作
if (mainOperatingList.Count > 0)
{
List<ProductInjection> addInjectItemList = new List<ProductInjection>();
//获取加工工序记录
MainOperation mainOpe = mainOperatingList[0];
#region 处理本体或是产品对象
//初始化本体对象
MainDAL mainDal=new MainDAL();
Main mainObj = new Main();
//初始化零件对象
ProductDAL productDal = new ProductDAL();
Product product = new Product();
//判断加工工序产品的产品类别,获取对应的对象
if (mainOpe.PRODUCTTYPE == EnumGeter.ProductType.benti.GetHashCode().ToString())
{
//获取本体对象
mainObj = mainDal.Get(new Main() { PID = mainOpe.PDID});
}
else
{
//获取产品对象
product = productDal.Get(new Product() { PID = mainOpe.PDID });
}
#endregion
#region 如果浇注操作关联浇注投料信息
if (machine.PROCESSTYPE == EnumGeter.ProcessType.jiaozhu.GetHashCode().ToString())
{
InjectionRecorderDAL injectDal = new InjectionRecorderDAL();
List<InjectionRecorder> list = injectDal.GetLastRecorder(new InjectionRecorder()
{
MACHINECODDE = machine.MACHINECODDE,
});
if (list.Count > 0)
{
InjectionRecorder inRecorder = list[0];
#region 零件投料关联记录
ProductInjection proInject = new ProductInjection();
proInject.PID = Guid.NewGuid().ToString();
proInject.IPID = inRecorder.PID;
proInject.MPPID = mainObj.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
}
}
#endregion
#region 设定一下道工序
//获取当前工序设置信息
ProcessSetBLL processSetBLL = new ProcessSetBLL();
//该产品的下一道工序信息
ProcessSet nextSet = processSetBLL.GetNextProcess(new ProcessSet()
{
PRODUCTTYPE = mainOpe.PRODUCTTYPE,
PRODUCELINE = mainOpe.PRODUCELINE
});
if (mainOpe.PRODUCTTYPE == EnumGeter.ProductType.benti.GetHashCode().ToString())
{
if (nextSet != null && string.IsNullOrEmpty(nextSet.PID) == false)
{
mainObj.CURRENTPROCESS = nextSet.PROCESSTYPE;
}
else
{
//没有下一道工序,修改加工完成标记和加工完成时间
mainObj.COMPLETEFLAG = EnumGeter.COMPLETEFLAG.COMPLETED.GetHashCode().ToString();
mainObj.PROCESSSTATE = EnumGeter.COMPLETEFLAG.COMPLETED.GetHashCode().ToString();
mainObj.COMPLETETIME = System.DateTime.Now;
}
}
else
{
product.CURRENTPROCESS = nextSet.PROCESSTYPE;
}
#endregion
#region 数据库操作
using (IDataSession session = AppDataFactory.CreateMainSession())
{
session.OpenTs();
modal.BaseSession = session;
try
{
//更新加工工序对象
modal.Update(mainOpe);
#region 更新本体或是零件信息
if (mainOpe.PRODUCTTYPE == EnumGeter.ProductType.benti.GetHashCode().ToString())
{
//更新本体信息
mainDal.BaseSession = session;
mainDal.Update(mainObj);
}
else
{
//更新零件信息
productDal.BaseSession = session;
productDal.Update(product);
}
#endregion
#region 浇注投料信息
if (addInjectItemList.Count > 0)
{
ProductInjectionDAL proInDal = new ProductInjectionDAL();
proInDal.BaseSession = session;
foreach (var p in addInjectItemList)
{
proInDal.Insert(p);
}
}
#endregion
//新增加工参数
ParameterDeal deal = new ParameterDeal();
deal.InsertParameter(parConfigList, mainOpe, session);
session.CommitTs();
}
catch (Exception ex)
{
session.RollbackTs();
}
}
#endregion
}
#endregion
}
#endregion
}
}