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

69 lines
2.8 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QMAPP.FJC.TRACING.DAInterface;
using QMAPP.FJC.Entity.QT;
using QMAPP.FJC.Entity.Operation;
namespace QMAPP.FJC.TRACING.DataValidators
{
/// <summary>
/// 零件重复扫描使用校验
/// </summary>
public class ReuseValidator:IDataValidator
{
public ValidateResult Validate(DAObject data, DAIValidation validOption)
{
if (string.Equals(data.DAI.DATA_TYPE, "SN")) //如果采集数据为零件SN号
{
DAL.QT.DAICacheDAL dcdal = new DAL.QT.DAICacheDAL();
var dcache= dcdal.GetByValue(data.AnalyzedValue);
if (dcache != null && dcache.WORKLOC_CODE != data.WorkLocState.WORKLOC_CODE && dcache.MOULD_CODE != data.MouldCode)
{
return new ValidateResult(false, string.Format("该零件在”{1}“加工中,请在“{1}”放行!", data.AnalyzedValue, dcache.WORKLOC_NAME));
}
DAL.Produce.ProductDAL pdal = new DAL.Produce.ProductDAL();
var product = data.GetObjectFromCache<Product>(p => p.PID == data.ObjectPID);
if (product == null)
{
product = pdal.GetByPID(data.ObjectPID);
if (product == null)
{
throw new Exception("查找零件信息失败!");
}
data.ObjectCacheList.Add(product);
}
if (product != null)
{
if (string.Equals(product.USINGSTATE,"0"))
{
DAL.QT.ProcessRecordDAL prdal=new DAL.QT.ProcessRecordDAL();
var record= prdal.GetByProdutCode(product.PRODUCTCODE,data.WorkLocState.WORKCELL_CODE);
if (record != null)//&&!string.Equals(record.PROCESS_STATE,"0"))
{
return new ValidateResult(false, string.Format("零件“{0}”已经过此工序加工!", product.PRODUCTCODE));
}
else
{
return new ValidateResult(true, "");
}
}
else
{
return new ValidateResult(false, string.Format("零件“{0}”已被使用!", product.PRODUCTCODE));
}
}
else
{
throw new Exception("查找零件信息失败!");
}
}
else
{
return new ValidateResult(true, "");
}
}
}
}