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

100 lines
4.3 KiB

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using QMAPP.FJC.Entity.Operation;
using QMAPP.MD.DAL;
using QMAPP.MD.Entity;
using QMAPP.FJC.DAL.Operation;
namespace QMAPP.FJC.TRACING.DataAnalyzers
{
/// <summary>
/// 零件数据转换解析类
/// </summary>
public class PartConvertAnalyzer : DAInterface.IDataAnalyzer
{
public void Analyze(DAInterface.DAObject data)
{
//string camaterialtype = "IP_SKIN";
DAL.Produce.ProductDAL proddal = new DAL.Produce.ProductDAL();
var product = proddal.GetNewestProduct(data.DAValue.ToString());
if (product != null)
{
if ((!string.IsNullOrEmpty(data.DAI.MATERIAL_CODE))
&& (!data.DAI.MATERIAL_CODE.Contains(product.MATERIAL_CODE)))
{
PbomDAL bl = new PbomDAL();
string materialcode = "";
if (data.DAI.MATERIAL_CODE.Split(';').Length > 1)
{
var bomitems = bl.GetRelatedItems(product.MATERIAL_CODE);
materialcode = bomitems.Where(p => data.DAI.MATERIAL_CODE.Contains(p.MATERIAL_CODE))
.Select(p => p.MATERIAL_CODE).FirstOrDefault();
}
else
{
materialcode = data.DAI.MATERIAL_CODE;
}
if (!string.IsNullOrEmpty(materialcode))
{
DAL.QT.ProductStructureDAL pstructdal = new DAL.QT.ProductStructureDAL();
Entity.QT.ProductStructure pstruct = new Entity.QT.ProductStructure
{
PID = Guid.NewGuid().ToString(),
PART_PID=product.PID,
PROCESS_CODE = data.DAValue.ToString()
};
MaterialDAL mar = new MaterialDAL();
Material materialInfo = new Material();
materialInfo.MATERIAL_CODE = materialcode;
var material = mar.Get(materialInfo);
var gmp = bl.GetGMP(material.MATERIAL_CODE);
product = new Product
{
PID = Guid.NewGuid().ToString(),
CAPACITY = material.STD_QTY,
CREATEDATE = DateTime.Now,
CREATEUSER = "",
MATERIAL_CODE = material.MATERIAL_CODE,
MATERIAL_NAME = material.MATERIAL_NAME,
OUTFLAG = "0",
PRODUCESHIFTTCODE = "",
PRODUCTCODE = data.DAValue.ToString(),
PRODUCTSOURCE = "1",
STATUS = "0",
USINGCOUNT = 0,
USINGSTATE = "0",
WORKCELL_CODE = gmp == null ? "" : gmp.WORKCELL_CODE,
WORKCENTER_CODE = gmp == null ? "" : gmp.WORKCENTER_CODE,
WORKLOC_CODE = "",
TEAM_CODE = "",
MATERIAL_TYPE = material.MATERIAL_TYPE_CODE,
ENDOFLINE = "1",
UPDATEDATE = DateTime.Now,
UPDATEUSER = ""
};
ProductDAL pro = new ProductDAL();
pro.Insert(product);
pstruct.PRODUCT_PID = product.PID;
pstructdal.Insert(pstruct);
}
}
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 materialT = mdal.Get(data.MaterialCode);
data.MaterialName = materialT == null ? "" : materialT.MATERIAL_SHORT;
}
else
{
throw new Exception("无法查到此零件信息!");
}
}
}
}