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.
96 lines
5.1 KiB
96 lines
5.1 KiB
4 years ago
|
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 : 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.WORKCELL_CODE, data.WorkLocState.WORKCELL_CODE)) //如果零件信息的工序字段与当前工序一致
|
||
|
{
|
||
|
return new ValidateResult(true, "");
|
||
|
}
|
||
|
else if (string.IsNullOrWhiteSpace(product.WORKCELL_CODE)) //如果零件信息工序字段为空则不校验跳序
|
||
|
{
|
||
|
return new ValidateResult(true, "");
|
||
|
}
|
||
|
else //零件信息工序字段与当前工序不一致
|
||
|
{
|
||
|
DAL.Basic.ProcessRouteWithWorkCellSeqDAL prwwcdal = new DAL.Basic.ProcessRouteWithWorkCellSeqDAL();
|
||
|
|
||
|
if (prwwcdal.InSameRoute(product.WORKCELL_CODE, data.WorkLocState.WORKCELL_CODE))//两个工序是否在同一工艺路线下
|
||
|
{
|
||
|
DAL.QT.ProcessRecordDAL prdal = new DAL.QT.ProcessRecordDAL();
|
||
|
var record = prdal.Get(product.PID, data.WorkLocState.WORKCELL_CODE); //查询此零件当前工序的加工记录
|
||
|
if (record != null) //如果存在当前工序加工记录
|
||
|
{
|
||
|
var preworkcells = prwwcdal.GetPreWorkcell(product.WORKCELL_CODE).Where(p => !string.IsNullOrWhiteSpace(p.PRE_WORKCELL_CODE)).Select(p => p.PRE_WORKCELL_CODE).ToArray();
|
||
|
if (preworkcells.Length <= 0 || preworkcells.Contains(data.WorkLocState.WORKCELL_CODE)) //当前工序为零件加工工序的前置工序
|
||
|
{
|
||
|
return new ValidateResult(true, ""); //零件刚刚经过当前工序加工,此处校验放行,交由重复扫描校验进行控制
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
//零件已经经过后序工序的加工
|
||
|
return new ValidateResult(false, string.Format("零件“{0}”已经过此工序加工并已流转至后序工序!", product.PRODUCTCODE));
|
||
|
}
|
||
|
}
|
||
|
else //如果不存在当前工序加工记录
|
||
|
{
|
||
|
//return new ValidateResult(false, string.Format("零件“{0}”前序加工未完成!", product.PRODUCTCODE));
|
||
|
if (string.IsNullOrEmpty(product.PLAN_ID))
|
||
|
{
|
||
|
return new ValidateResult(false, string.Format("零件“{0}”未在“{1}”进行加工操作!", product.PRODUCTCODE, product.WORKCELL_NAME));
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return new ValidateResult(false, string.Format("零件“{0}”未在“{1}”进行加工操作!", product.PRODUCTCODE, product.WORKCELL_NAME));
|
||
|
}
|
||
|
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return new ValidateResult(false, string.Format("零件“{0}”未在“{1}”进行加工操作!", product.PRODUCTCODE, product.WORKCELL_NAME));
|
||
|
////return new ValidateResult(false, string.Format("零件“{0}”前序加工未完成!", product.PRODUCTCODE));
|
||
|
//return new ValidateResult(false, string.Format("零件“{0}”无法在此生产线使用!", product.PRODUCTCODE));
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
throw new Exception("查找零件信息失败!");
|
||
|
}
|
||
|
}
|
||
|
else
|
||
|
{
|
||
|
return new ValidateResult(true, "");
|
||
|
}
|
||
|
}
|
||
|
}
|
||
|
}
|