|
|
|
using System;
|
|
|
|
using System.Collections.Generic;
|
|
|
|
using System.Linq;
|
|
|
|
using System.Text;
|
|
|
|
using QMAPP.FJC.TRACING.DAInterface;
|
|
|
|
using QMAPP.FJC.Entity.QT;
|
|
|
|
using QMAPP.MD.DAL;
|
|
|
|
|
|
|
|
namespace QMAPP.FJC.TRACING.DataValidators
|
|
|
|
{
|
|
|
|
/// <summary>
|
|
|
|
/// 根据BOM校验零件
|
|
|
|
/// </summary>
|
|
|
|
public class BOMValidator:IDataValidator
|
|
|
|
{
|
|
|
|
public ValidateResult Validate(DAObject data,DAIValidation validOption)
|
|
|
|
{
|
|
|
|
if (string.Equals(data.DAI.DA_MODE, "3")) // 如果采集项为自适应项 则不验证BOM
|
|
|
|
{
|
|
|
|
return new ValidateResult(true, "");
|
|
|
|
}
|
|
|
|
//提取采集数据中的物料号信息
|
|
|
|
var materials = (from da in data.WorkLocState.DataCache
|
|
|
|
where !string.IsNullOrWhiteSpace(da.MATERIAL_CODE)
|
|
|
|
&& !string.Equals(da.DA_MODE, "2") //过滤掉可省略的采集点
|
|
|
|
&& !string.Equals(da.DA_CODE, data.DAI.DA_CODE) //过滤掉当前输入的采集点
|
|
|
|
&& (!(string.Equals(da.MATERIAL_CODE, data.WorkLocState.CurrentState.MATERIAL_CODE)
|
|
|
|
&& da.ISPROCESSCODE == "1")) //过滤掉当前输入的采集点
|
|
|
|
select da.MATERIAL_CODE).ToList();
|
|
|
|
PbomDAL dal = new PbomDAL();
|
|
|
|
if(!string.IsNullOrEmpty(data.MaterialCode))
|
|
|
|
materials.Add(data.MaterialCode + "");
|
|
|
|
|
|
|
|
var bomlocates = dal.LocateBom(materials.Distinct().ToArray()); //匹配物料BOM
|
|
|
|
if (data != null && data.OrderPlan != null)
|
|
|
|
{
|
|
|
|
bomlocates = bomlocates.Where(p => p.BOMCode == data.OrderPlan.PBOM_CODE).ToList();
|
|
|
|
}
|
|
|
|
if (bomlocates.Count > 0) //如果存在匹配的BOM
|
|
|
|
{
|
|
|
|
ProcessRouteDAL prdal = new ProcessRouteDAL();
|
|
|
|
foreach (var bom in bomlocates)
|
|
|
|
{
|
|
|
|
var route = prdal.LocateRoute(bom.BOMCode, data.WorkLocState.WORKCELL_CODE); //验证工艺路线与BOM的匹配关系
|
|
|
|
if (route != null)
|
|
|
|
{
|
|
|
|
return new ValidateResult(true, "");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return new ValidateResult(false,"此物料不应在当前工序使用!");
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
return new ValidateResult(false,"当前产品配置不需要刚才扫描的零件,请确认产品BOM配置信息!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|