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.
81 lines
3.4 KiB
81 lines
3.4 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 WorkSequenceValidator_Old : IDataValidator
|
|
{
|
|
public ValidateResult Validate(DAObject data, DAIValidation validOption)
|
|
{
|
|
if (string.Equals(data.DAI.DATA_TYPE, "SN") || string.Equals(data.DAI.DATA_TYPE, "BN")) //采集点类型为SN和BN的需要进行跳序校验
|
|
{
|
|
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.PRODUCTSOURCE, "1")) //如果为外购件
|
|
{
|
|
return new ValidateResult(true, ""); //不验证工序
|
|
}
|
|
else
|
|
{
|
|
DAL.Basic.ProcessRouteWithWorkCellSeqDAL prwwcdal = new DAL.Basic.ProcessRouteWithWorkCellSeqDAL();
|
|
var preworkcells = prwwcdal.GetPreWorkcell(data.WorkLocState.WORKCELL_CODE).Select(p => p.PRE_WORKCELL_CODE).ToArray();
|
|
|
|
DAL.QT.ProcessRecordDAL prdal = new DAL.QT.ProcessRecordDAL();
|
|
var record = prdal.GetLastRecord(product.PID);
|
|
if (record != null
|
|
&& (preworkcells.Contains(record.WORKCELL_CODE)
|
|
|| string.Equals(record.WORKCELL_CODE, data.WorkLocState.WORKCELL_CODE))) //零件的最后加工工序为当前工序或前置工序
|
|
{
|
|
return new ValidateResult(true, "");
|
|
}
|
|
else
|
|
{
|
|
if (string.Equals(product.ENDOFLINE, "1")) //判断零件是否是完成的成品
|
|
{
|
|
if (string.Equals(product.USINGSTATE, "0")) //判断零件是否未被使用过
|
|
{
|
|
return new ValidateResult(true, "");
|
|
}
|
|
else
|
|
{
|
|
return new ValidateResult(false, "此零件已被使用!");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return new ValidateResult(false, "此零件前序加工未完成!");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else
|
|
{
|
|
throw new Exception("查找零件信息失败!");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
return new ValidateResult(true, "");
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|