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

194 lines
8.4 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QMAPP.FJC.Entity.Operation;
namespace QMAPP.FJC.TRACING.DataAnalyzers
{
/// <summary>
/// 零件数据解析类
/// </summary>
public class PartAnalyzer : DAInterface.IDataAnalyzer
{
public void Analyze(DAInterface.DAObject data)
{
DAL.Produce.ProductDAL proddal = new DAL.Produce.ProductDAL();
//var product=proddal.GetNewestProduct(data.DAValue.ToString());
//if (product != null)
//{
// data.ObjectPID = product.PID;
// data.ObjectCacheList.Add(product);
// data.AnalyzedValue = product.PRODUCTCODE;
// data.MaterialCode = product.MATERIAL_CODE;
// DAL.MD.MaterialDAL mdal = new DAL.MD.MaterialDAL();
// var material = mdal.Get(data.MaterialCode);
// data.MaterialName = material == null ? "" : material.MATERIAL_SHORT;
//}
//else
//{
// DAL.MD.MaterialDAL mdal = new DAL.MD.MaterialDAL();
// var material = mdal.Get(data.MaterialCode);
// if (material == null)
// {
// throw new Exception("无法查到此零件信息!");
// }
// if (string.Equals(material.OUTSOURCE, "1")) // 如果是外购件则创建零件信息
// {
// var part = new Product()
// {
// PID = Guid.NewGuid().ToString(),
// CAPACITY = material.STD_QTY,
// CREATEDATE = DateTime.Now,
// CREATEUSER = data.UserID,
// MATERIAL_CODE = material.MATERIAL_CODE,
// OUTFLAG = "0",
// PRODUCESHIFTTCODE = "",
// PRODUCTCODE = data.DAValue.ToString(),
// PRODUCTSOURCE = "1",
// STATUS = "0",
// USINGCOUNT = 0,
// USINGSTATE = "0",
// WORKCELL_CODE = "",
// WORKCENTER_CODE = "",
// WORKLOC_CODE = "",
// TEAM_CODE = "",
// MATERIAL_TYPE = material.MATERIAL_TYPE_CODE
// };
// proddal.Insert(part);
// data.ObjectPID = part.PID;
// //data.ObjectCacheList.Add(part);
// data.AnalyzedValue = part.PRODUCTCODE;
// data.MaterialCode = part.MATERIAL_CODE;
// data.MaterialName = material.MATERIAL_SHORT;
// }
// else
// {
// throw new Exception("无法查到此零件信息!");
// }
//}
//20220928 DQZhang 查询最新加工记录,增加工序条件,因为创建时间有可能被修改,按时间培训获取最新会出问题
string Cell = data.WorkLocState.WORKLOC_CODE;
if (Cell.Equals("DP_R_PREASSY_2") || Cell.Equals("DP_L_PREASSY_2"))
{
var product = proddal.GetNewestProductCell(data.DAValue.ToString(), Cell);
if (product != null)
{
data.ObjectPID = product.PID;
data.ObjectCacheList.Add(product);
data.AnalyzedValue = product.PRODUCTCODE;
data.MaterialCode = product.MATERIAL_CODE;
DAL.MD.MaterialDAL mdal = new DAL.MD.MaterialDAL();
var material = mdal.Get(data.MaterialCode);
data.MaterialName = material == null ? "" : material.MATERIAL_SHORT;
}
else
{
DAL.MD.MaterialDAL mdal = new DAL.MD.MaterialDAL();
var material = mdal.Get(data.MaterialCode);
if (material == null)
{
throw new Exception("无法查到此零件信息!");
}
if (string.Equals(material.OUTSOURCE, "1")) // 如果是外购件则创建零件信息
{
var part = new Product()
{
PID = Guid.NewGuid().ToString(),
CAPACITY = material.STD_QTY,
CREATEDATE = DateTime.Now,
CREATEUSER = data.UserID,
MATERIAL_CODE = material.MATERIAL_CODE,
OUTFLAG = "0",
PRODUCESHIFTTCODE = "",
PRODUCTCODE = data.DAValue.ToString(),
PRODUCTSOURCE = "1",
STATUS = "0",
USINGCOUNT = 0,
USINGSTATE = "0",
WORKCELL_CODE = "",
WORKCENTER_CODE = "",
WORKLOC_CODE = "",
TEAM_CODE = "",
MATERIAL_TYPE = material.MATERIAL_TYPE_CODE
};
proddal.Insert(part);
data.ObjectPID = part.PID;
//data.ObjectCacheList.Add(part);
data.AnalyzedValue = part.PRODUCTCODE;
data.MaterialCode = part.MATERIAL_CODE;
data.MaterialName = material.MATERIAL_SHORT;
}
else
{
throw new Exception("无法查到此零件信息!");
}
}
}
else
{
var product = proddal.GetNewestProduct(data.DAValue.ToString());
if (product != null)
{
data.ObjectPID = product.PID;
data.ObjectCacheList.Add(product);
data.AnalyzedValue = product.PRODUCTCODE;
data.MaterialCode = product.MATERIAL_CODE;
DAL.MD.MaterialDAL mdal = new DAL.MD.MaterialDAL();
var material = mdal.Get(data.MaterialCode);
data.MaterialName = material == null ? "" : material.MATERIAL_SHORT;
}
else
{
DAL.MD.MaterialDAL mdal = new DAL.MD.MaterialDAL();
var material = mdal.Get(data.MaterialCode);
if (material == null)
{
throw new Exception("无法查到此零件信息!");
}
if (string.Equals(material.OUTSOURCE, "1")) // 如果是外购件则创建零件信息
{
var part = new Product()
{
PID = Guid.NewGuid().ToString(),
CAPACITY = material.STD_QTY,
CREATEDATE = DateTime.Now,
CREATEUSER = data.UserID,
MATERIAL_CODE = material.MATERIAL_CODE,
OUTFLAG = "0",
PRODUCESHIFTTCODE = "",
PRODUCTCODE = data.DAValue.ToString(),
PRODUCTSOURCE = "1",
STATUS = "0",
USINGCOUNT = 0,
USINGSTATE = "0",
WORKCELL_CODE = "",
WORKCENTER_CODE = "",
WORKLOC_CODE = "",
TEAM_CODE = "",
MATERIAL_TYPE = material.MATERIAL_TYPE_CODE
};
proddal.Insert(part);
data.ObjectPID = part.PID;
//data.ObjectCacheList.Add(part);
data.AnalyzedValue = part.PRODUCTCODE;
data.MaterialCode = part.MATERIAL_CODE;
data.MaterialName = material.MATERIAL_SHORT;
}
else
{
throw new Exception("无法查到此零件信息!");
}
}
}
}
}
}