202 lines
8.9 KiB
C#
202 lines
8.9 KiB
C#
using System;
|
||
using System.Data;
|
||
using bizFacade;
|
||
using MesServerWork;
|
||
|
||
namespace MesServerFunctions
|
||
{
|
||
partial class Functions_BASE_25
|
||
{
|
||
/// <summary>
|
||
/// 正常逻辑工作(传递机型)
|
||
/// </summary>
|
||
/// <param name="OpName"></param>
|
||
/// <param name="EngineTypeID"></param>
|
||
/// <param name="EngineType"></param>
|
||
/// <param name="EngineID"></param>
|
||
/// <param name="PartPallet_Code"></param>
|
||
private void EngineTypeGetOver_PLC_Work(string OpName, int EngineTypeID, string EngineType, string EngineID, int PartPallet_Code,string OrderForm)
|
||
{
|
||
|
||
{
|
||
int IsrepairBarcode = 0;//拆解返修标志
|
||
int RepairPartStatusPLC = 0;
|
||
int MES_QualityMask = 1;
|
||
|
||
//string OrderForm = "";//订单号
|
||
string repairBarcode = "";//拆解返修条码
|
||
DataTable dt;
|
||
//OP050
|
||
|
||
int PartPalletCode;
|
||
// 1 读取机型等信息,保存到监控表
|
||
//DtWebApi.ReadWritePLC.GetEngineTypeFromPLC(OpName, out EngineTypeID, out EngineType, out EngineID, out PartPalletCode);
|
||
|
||
BaseDataSystemMES.GetEngineID_Select(OpName, EngineID, out dt);//查询订单信息
|
||
|
||
if (dt != null && dt.Rows.Count > 0)
|
||
{
|
||
//OrderForm = Convert.ToString(dt.Rows[0]["订单号"]);
|
||
IsrepairBarcode = Convert.ToInt32(dt.Rows[0]["拆解标志"]);
|
||
repairBarcode = Convert.ToString(dt.Rows[0]["拆解返修条码"]);
|
||
}
|
||
|
||
BaseDataSystemMES.OpName_MIS_MOBY_Insert(OpName, OrderForm, EngineTypeID, EngineType, EngineID, PartPallet_Code, 0, IsrepairBarcode, repairBarcode);
|
||
SaveMobyMessage(OpName, EngineTypeID, EngineType, EngineID, OrderForm);
|
||
Sendmessage("5", "1", OpName);
|
||
SendInfomation("QualityMask", Convert.ToString(MES_QualityMask), OpName);
|
||
SendInfomation("RepairPartStatusPLC", Convert.ToString(RepairPartStatusPLC), OpName);
|
||
BaseDataSystemMES.MesServer_Process_EngineTypeOver(OpName);
|
||
Sendmessage("123", "111", OpName);//向前台发送显示操作指南、物料、图片的命令 x
|
||
|
||
BaseDataSystemMES.MaterialPush_EngineIDStatus_Insert(OpName);
|
||
//比对缓存库上线(OP0050)
|
||
MathEngineTypePartLoad(OpName, OrderForm);
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 比对缓存库上线(OP0050)
|
||
/// </summary>
|
||
/// <param name="OpName"></param>
|
||
public void MathEngineTypePartLoad(string OpName,string orderForm)
|
||
{
|
||
//获得 盆子码(发动机号)、小车号、机型代码、机型
|
||
try
|
||
{
|
||
object locker = new object();
|
||
lock (locker)
|
||
{
|
||
//int engineTypeID;
|
||
//string engineID;
|
||
//string engineType;
|
||
string PartCode_orderForm;
|
||
byte kuweiNum;
|
||
//if (tagValue == "1")
|
||
{
|
||
string[] PartCodeList = new string[6];
|
||
PartCodeList[0] = DtWebApi.ReadWritePLC.ReadPLC("2001", OpName).ToString();
|
||
PartCodeList[1] = DtWebApi.ReadWritePLC.ReadPLC("2002", OpName).ToString();
|
||
PartCodeList[2] = DtWebApi.ReadWritePLC.ReadPLC("2003", OpName).ToString();
|
||
PartCodeList[3] = DtWebApi.ReadWritePLC.ReadPLC("2004", OpName).ToString();
|
||
PartCodeList[4] = DtWebApi.ReadWritePLC.ReadPLC("2005", OpName).ToString();
|
||
PartCodeList[5] = DtWebApi.ReadWritePLC.ReadPLC("2006", OpName).ToString();
|
||
int codeID = 2007;//2007 2008 2009 2010 2011 2012
|
||
bool IsMath = false;
|
||
int MathchNum = 0;
|
||
for (int i = 0; i < PartCodeList.Length; i++)
|
||
{
|
||
//处理字符串 测量数据发动机在线状态_下线工位_是否存在_查询
|
||
// 查询分线下线的工件订单号是否和总线匹配
|
||
PartCode_orderForm = GetEngineTypeByEngineID(PartCodeList[i], OpName);
|
||
if (PartCode_orderForm == orderForm)
|
||
{
|
||
DtWebApi.ReadWritePLC.WritePLC(codeID.ToString(), OpName, 1);
|
||
IsMath = true;
|
||
MathchNum = i + 1;
|
||
|
||
//第二步,将零件信息转移到零件_临时表中(本地BOM与订单BOM的选择显示关系)
|
||
BaseDataSystemMES.MesServer_Process_EngineTypeOver(OpName,1);
|
||
//第三步直接验证物料
|
||
bool IsSuccess;
|
||
BaseDataSystemMES.PartMaterial_DM_Update(OpName, PartCodeList[i], out IsSuccess);
|
||
|
||
break;
|
||
}
|
||
}
|
||
SendInfomation("MatchingCompleted", "1", OpName);//界面显示匹配完成
|
||
if (IsMath)
|
||
{
|
||
DtWebApi.ReadWritePLC.WritePLC("2014", OpName, MathchNum);
|
||
SendInfomation("Match", "1", OpName);//界面显示匹配结果成功
|
||
SendInfomation("MatchSuccess", "1", OpName);//界面显示匹配成功笑脸
|
||
}
|
||
else
|
||
{
|
||
DtWebApi.ReadWritePLC.WritePLC("2014", OpName, 0);
|
||
SendInfomation("Match", "2", OpName);//界面显示匹配结果不成功
|
||
SendInfomation("MatchSuccess", "2", OpName);//界面显示匹配不成功哭脸
|
||
}
|
||
}
|
||
}
|
||
}
|
||
catch (Exception err)
|
||
{
|
||
////ApplicationLog.WriteLog(err, "Function03:PartLoad");
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 测量数据发动机在线状态_下线工位_是否存在_查询
|
||
/// </summary>
|
||
/// <param name="PartCode"></param>
|
||
/// <returns></returns>
|
||
private static string GetEngineTypeByEngineID(string engineID, string opName)
|
||
{
|
||
string engineType = "";
|
||
DataTable dt;
|
||
BaseDataSystemMES.GetEngineTypeByEngineID(engineID, opName, out dt);
|
||
if (dt.Rows.Count > 0)
|
||
{
|
||
engineType = dt.Rows[0]["订单号"].ToString();
|
||
}
|
||
return engineType;
|
||
}
|
||
|
||
|
||
|
||
/// <summary>
|
||
/// 保存MOBY信息
|
||
/// </summary>
|
||
/// <param name="OpName"></param>
|
||
/// <param name="engineTypeID"></param>
|
||
/// <param name="engineType"></param>
|
||
/// <param name="engineID"></param>
|
||
private void SaveMobyMessage(string OpName, int engineTypeID, string engineType, string engineID, string orderForm)
|
||
{
|
||
if(MIS_BASE.hashtable_EngineGetOver_EngineTypeID==null)
|
||
{
|
||
MIS_BASE.InitHashtable_MesServerCode();
|
||
}
|
||
if (MIS_BASE.hashtable_EngineGetOver_EngineTypeID.ContainsKey(OpName))
|
||
{
|
||
MIS_BASE.hashtable_EngineGetOver_EngineTypeID[OpName] = engineTypeID;
|
||
}
|
||
if (MIS_BASE.hashtable_EngineGetOver_EngineType.ContainsKey(OpName))
|
||
{
|
||
MIS_BASE.hashtable_EngineGetOver_EngineType[OpName] = engineType;
|
||
}
|
||
if (MIS_BASE.hashtable_EngineGetOver_EngineID.ContainsKey(OpName))
|
||
{
|
||
MIS_BASE.hashtable_EngineGetOver_EngineID[OpName] = engineID;
|
||
}
|
||
if (MIS_BASE.hashtable_EngineGetOver_OrderForm.ContainsKey(OpName))
|
||
{
|
||
MIS_BASE.hashtable_EngineGetOver_OrderForm[OpName] = orderForm;
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 返修件需要工作
|
||
/// </summary>
|
||
/// <param name="OpName">工位号</param>
|
||
private void IsNeedRepaire_OK(string OpName)
|
||
{
|
||
|
||
int isRepair;
|
||
int engineTypeID;
|
||
|
||
string engineType = "";
|
||
string engineID = "";
|
||
string palletCode = "";
|
||
string orderForm = "";
|
||
string repairCode = "";
|
||
//从监控系统中查询出本工位信息
|
||
BaseDataSystemMES.OpName_MIS_Moby_Select(OpName,
|
||
out orderForm, out engineTypeID, out engineType,
|
||
out engineID, out palletCode, out isRepair, out repairCode);
|
||
|
||
EngineTypeGetOver_PLC_Work(OpName, engineTypeID, engineType, engineID, Convert.ToInt32(palletCode), orderForm);
|
||
}
|
||
|
||
}
|
||
}
|