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

74 lines
2.5 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QMAPP.FJC.TRACING.DAInterface;
using QMAPP.FJC.Entity.InterfaceData;
using QMAPP.FJC.Entity.Operation;
namespace QMAPP.FJC.TRACING.DataValidators
{
public class LeakInspectionValidator : IDataValidator
{
public ValidateResult Validate(DAObject data, Entity.QT.DAIValidation validOption)
{
if (!string.Equals(data.DAI.DATA_TYPE, "SN")) //采集点类型为SN
{
return new ValidateResult(true, "");
}
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);
}
var parts = new DAL.Operation.ProductDAL().GetPartList(product.PRODUCTCODE);
parts.Add(product);
var lirDAL = new DAL.InterfaceData.LeakInspectRecordDAL();
LeakInspectRecord record = null;
var barcodes=parts.Where(p => p.CAPACITY > 0).OrderBy(p=>p.PRODUCTCODE).Select(p => p.PRODUCTCODE).Distinct();
foreach (var barcode in barcodes)
{
record = lirDAL.GetLastRecord(barcode);
if (record != null)
{
break;
}
}
int result = 0;
if (record != null)
{
result = record.RESULT == "1" ? 1 : -1;
}
switch (result)
{
case 0:
{
return new ValidateResult(false, string.Format("零件“{0}”无漏装检测记录!", product.PRODUCTCODE));
//break;
}
case 1:
{
return new ValidateResult(true, "");
//break;
}
case -1:
{
return new ValidateResult(false, string.Format("零件“{0}”漏装检测结果不合格!", product.PRODUCTCODE));
////break;
}
}
return new ValidateResult(true, "");
}
}
}