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

72 lines
3.2 KiB

3 years ago
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace QMAPP.FJC.TRACING.DataAnalyzers
{
/// <summary>
/// 线束号解析
/// </summary>
public class MaterialAnalyzer : DAInterface.IDataAnalyzer
{
public void Analyze(DAInterface.DAObject data)
{
if (data.DAValue.ToString().StartsWith("NO-")) //无用零件
{
DAL.QT.WorkCellRunStateDAL statedal = new DAL.QT.WorkCellRunStateDAL();
var state = statedal.GetCurrentState(data.DAI.WORKCELL_CODE, data.DAI.WORKLOC_CODE, data.MouldCode);
if (state == null || string.IsNullOrWhiteSpace(state.BOM_CODE))
{
return;
}
MD.DAL.PbomDAL bomdal = new MD.DAL.PbomDAL();
var item = bomdal.GetBomItemByMaterilType(state.BOM_CODE, data.DAI.MATERIAL_TYPE,true);
if (item.UNIT_SUM > 0 && item.PBOM_CODE.Contains("F_"))
{
throw new Exception("当前产品为有线束件!");
}
data.ObjectPID = "";//mould.PID;
data.AnalyzedValue = data.DAValue.ToString();
data.MaterialCode = item.MATERIAL_CODE;
DAL.MD.MaterialDAL mdal = new DAL.MD.MaterialDAL();
var material = mdal.Get(data.MaterialCode);
data.MaterialName = material == null ? "" : material.MATERIAL_SHORT;
}
else
{
DAL.MD.MaterialDAL dal = new DAL.MD.MaterialDAL();
var material = dal.GetWithAnyFormate(data.DAValue.ToString());
if (material == null)
{
material = dal.GetWithAnyFormateTo(data.DAValue.ToString());
if (material == null)
throw new Exception("无法查到与此条码相关的物料信息!");
}
data.ObjectPID = "";//mould.PID;
data.AnalyzedValue = data.DAValue.ToString();
data.MaterialCode = material.MATERIAL_CODE;
//DAL.MD.MaterialDAL mdal = new DAL.MD.MaterialDAL();
//var material = mdal.Get(data.MaterialCode);
data.MaterialName = material == null ? "" : material.MATERIAL_SHORT;
if (string.Equals(data.DAI.DIVBY_MOULD, "1"))
{
DAL.Basic.MachineInfoModelDAL moulddal = new DAL.Basic.MachineInfoModelDAL();
var moulds = moulddal.GetMouldOnMachine(data.MachineCode);
var bindingdal = new DAL.QT.MaterialBindingDAL();
var bindings = bindingdal.GetBindingTargets(data.DAI.WORKLOC_CODE + "_MOULD", material.MATERIAL_TYPE_CODE);
var binding = bindings.FirstOrDefault(p => moulds.Exists(m => m.MODELCODE == p.TARGET_CODE));
if (binding == null)
{
throw new Exception("此零件无法在当前工位进行加工!");
}
data.MouldCode = binding.TARGET_CODE;
data.MouldReLocate = true;
}
}
}
}
}