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

78 lines
2.3 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QMAPP.FJC.Entity.Operation;
using QMAPP.FJC.Entity.QT;
using QMAPP.FJC.DAL.Basic;
using QMAPP.FJC.Entity.Basic;
using QMAPP.MD.DAL;
using QMAPP.MD.Entity;
namespace QMAPP.FJC.TRACING.DataValidator
{
/// <summary>
/// 校验PBOM组合
/// </summary>
public class PbomValidater
{
public OperationServiceParam Validate(OperationServiceParam _para)
{
List<DAI> daiList = _para.tranferDaiList;
PbomDAL bomItemDal = new PbomDAL();
//获取条码的采集点信息
daiList = daiList.Where(o => o.DATA_TYPE == "SN" && string.IsNullOrEmpty(o.PBOMITEM) == false).ToList<DAI>();
StringBuilder sqlBomItem = new StringBuilder();
//当扫描第一个件时
if (daiList.Count == 1)
{
DAI dai = _para.tranferDaiList.First(o => o.DATA_TYPE == "SN");
dai.isOk = true;
return _para;
}
#region 通过零件号获取是否存在这样的BOM组合
StringBuilder sql = new StringBuilder();
//通过是否存在交集来判断
for (int i = 0; i < daiList.Count; i++)
{
sql.AppendFormat(" select pbom_code from T_MD_PBOM_ITEM where MATERIAL_CODE='{0}' ", daiList[i].MATERIAL_CODE);
if (i != daiList.Count - 1)
{
sql.AppendFormat(" intersect ");
}
}
List<PbomItem> pblist = new List<PbomItem>(); //bomItemDal.GetList(sql.ToString());
if (pblist.Count == 0)
{
DAI dai = _para.tranferDaiList.First(o => o.DATA_TYPE == "SN" && o.isOk == false);
dai.isOk = false;
return _para;
}
if (pblist.Count > 0)
{
foreach (var o in daiList)
{
//设置通过
o.isOk = true;
//如果只有一个BOM组合设置BOM
o.PBOM = (pblist.Count == 1) ? pblist[0].PBOM_CODE : "";
}
}
#endregion
return _para;
}
}
}