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.
93 lines
4.5 KiB
93 lines
4.5 KiB
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using QMAPP.FJC.TRACING.DAInterface;
|
|
|
|
namespace QMAPP.FJC.TRACING.DataValidators
|
|
{
|
|
/// <summary>
|
|
/// 生产计划验证
|
|
/// </summary>
|
|
public class PlanValidator_Old2 : IDataValidator
|
|
{
|
|
public ValidateResult Validate(DAObject data, Entity.QT.DAIValidation validOption)
|
|
{
|
|
//如果采集点不包含物料信息则不进行验证
|
|
if (string.IsNullOrWhiteSpace(data.MaterialCode))
|
|
{
|
|
return new ValidateResult(true, "");
|
|
}
|
|
DAL.ProductionPlan.WorkOrderDAL workorderdal = new DAL.ProductionPlan.WorkOrderDAL();
|
|
var workorderlist = new List<Entity.ProductionPlan.WorkOrder>();
|
|
//获取当前工位正在执行的派工单
|
|
var workorder= workorderdal.GetWorkingOrderInLoc(data.WorkLocState.WORKLOC_CODE,data.MouldCode);
|
|
if (workorder == null) //不存在正在执行的派工单
|
|
{
|
|
//获取当前工序优先级最高的工单
|
|
workorderlist = workorderdal.GetMatchOrders(data.WorkLocState.WORKCELL_CODE);// data.WorkLocState.CurrentState.ORDERPLAN_PID);
|
|
}
|
|
else
|
|
{
|
|
workorderlist.Add(workorder);
|
|
}
|
|
if (workorderlist.Count == 0)
|
|
{
|
|
return new ValidateResult(false, "当前没有可执行的生产计划,请先下达生产计划!");
|
|
}
|
|
QMAPP.MD.DAL.PbomDAL bomdal = new QMAPP.MD.DAL.PbomDAL();
|
|
if (string.Equals(workorderlist[0].ORDER_TYPE, "aa0") || string.Equals(workorderlist[0].ORDER_TYPE, "aa2")) //如果为FIS工单
|
|
{
|
|
if (data.OrderPlan != null) //如果条码绑定了生产计划
|
|
{
|
|
if (data.OrderPlan.ORDER_TYPE == "1")
|
|
{
|
|
return new ValidateResult(false, string.Format("请优先完成FIS工单!", workorderlist[0].SEQ));
|
|
}
|
|
var inputSEQ = 0;
|
|
var correctSEQ = 0;
|
|
inputSEQ = int.Parse(data.OrderPlan.SEQ.Split('-', '_')[0]);
|
|
correctSEQ = int.Parse(workorderlist[0].SEQ.Split('-', '_')[0]);
|
|
if (inputSEQ > correctSEQ)
|
|
{
|
|
return new ValidateResult(false, string.Format("请按照FIS顺序生产!顺序号为“{0}”的工单尚未完成生产。", workorderlist[0].SEQ));
|
|
}
|
|
workorderlist = workorderlist.Where(p => p.ORDERPLANID == data.OrderPlan.PID).ToList();
|
|
}
|
|
var bomlist = bomdal.GetPbomByMaterialCode(data.MaterialCode);//或取与此当前输入物料相关的BOM
|
|
if (!bomlist.Exists(p => workorderlist.Exists(o => p.PBOM_CODE == o.PBOM_CODE))) //当前使用的物料与工单BOM不匹配
|
|
{
|
|
return new ValidateResult(false, "使用的物料不符合当前下达的生产计划要求!");
|
|
}
|
|
|
|
}
|
|
else //如果为建储工单
|
|
{
|
|
|
|
if (workorder == null)
|
|
{
|
|
//使用物料号和工序编码过滤工单
|
|
var order = workorderdal.GetFirstMatchOrder(data.WorkLocState.WORKCELL_CODE, data.MaterialCode, data.WorkLocState.CurrentState.ORDERPLAN_PID);
|
|
if (order == null)//不存在则标示当前使用的物料不符合工单要求
|
|
{
|
|
return new ValidateResult(false, "使用的物料不符合当前下达的生产计划要求!");
|
|
}
|
|
}
|
|
else
|
|
{
|
|
if (data.OrderPlan != null) //如果条码绑定了生产计划
|
|
{
|
|
workorderlist = workorderlist.Where(p => p.ORDERPLANID == data.OrderPlan.PID).ToList();
|
|
}
|
|
var bomlist = bomdal.GetPbomByMaterialCode(data.MaterialCode);//或取与此当前输入物料相关的BOM
|
|
if (!bomlist.Exists(p => workorderlist.Exists(o => p.PBOM_CODE == o.PBOM_CODE))) //当前使用的物料与工单BOM不匹配
|
|
{
|
|
return new ValidateResult(false, "使用的物料不符合当前下达的生产计划要求!");
|
|
}
|
|
}
|
|
}
|
|
return new ValidateResult(true, "");
|
|
|
|
}
|
|
}
|
|
}
|
|
|