Files
52-NingdePDC-MesProject/MisDataFunction/Function1062/OpcServer/EngineGetOver.cs
2026-05-31 10:22:04 +08:00

98 lines
4.5 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using MesServerWork;
using MisDataFunDll;
using MisDataSaveDate;
using System;
namespace MesServerFunctions
{
partial class FunctionMES
{
object lockBarcodeEngineTypeGetOver = new object();
/// <summary>
/// OP431 PLC 回传机型后,校验 PAD 确认信息并调用工厂 MES 进站。
/// </summary>
private void EngineTypeGetOver_PLC(object e)
{
lock (lockBarcodeEngineTypeGetOver)
{
try
{
var msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e;
string opName = Convert.ToString(msgEvent.OpName);
int tagValue = Convert.ToInt32(msgEvent.TagValue);
if (tagValue != 1)
{
MisDataFun.LogRecording_OP(opName, "INFO", "MIS", "PLC传递机型取消");
MIS_BASE.Write_FixAllow(opName, false);
return;
}
MisDataFun.LogRecording_OP(opName, "INFO", "MIS", "PLC传递机型");
MIS_BASE.Write_TagValueByTagTypeID(34, opName, false);
MIS_BASE.GetEngineTypeFromPLC(opName, out int engineTypeID, out string engineType, out string engineID, out int palletCode, out string orderForm);
MIS_BASE.GetEngineTypeFromPLC_MES(opName, out int engineTypeIDMes, out string engineTypeMes, out string engineIDMes, out string orderFormMes);
if (string.IsNullOrWhiteSpace(engineID) || engineTypeID <= 0)
{
WriteManualStaticEngineError(opName, "PLC产品码或机型为空产品码" + engineID + ",机型代码:" + engineTypeID);
return;
}
if (string.IsNullOrWhiteSpace(engineIDMes) || engineTypeIDMes <= 0)
{
WriteManualStaticEngineError(opName, "未查询到PAD确认上线信息请先在PAD确认上线");
return;
}
if (!string.Equals(engineID.Trim(), engineIDMes.Trim(), StringComparison.OrdinalIgnoreCase))
{
WriteManualStaticEngineError(opName, "PLC产品码与PAD确认产品码不一致PLC" + engineID + "PAD" + engineIDMes);
return;
}
if (engineTypeID != engineTypeIDMes)
{
WriteManualStaticEngineError(opName, "PLC机型与PAD确认机型不一致PLC" + engineTypeID + "PAD" + engineTypeIDMes);
return;
}
if (!TryGetManualStaticOutProduct(engineID, out ManualStaticOutProduct product, out string productMessage))
{
WriteManualStaticEngineError(opName, productMessage);
return;
}
CallWebService.Call_miFindCustomAndSfcData(opName, engineID, out string code, out string message);
if (code != "0")
{
WriteManualStaticEngineError(opName, "进站失败:" + engineID + "code" + code + "message" + message);
return;
}
MisDataFun.LogRecording_OP(opName, "INFO", "MOM", "进站成功:" + engineID);
MisDataFun.OpName_MIS_MOBY_Insert(opName, product.EngineTypeID, product.EngineType, product.EngineID, palletCode, product.OrderForm, 0, 0, "");
MIS_BASE.Write_FixAllow(opName, true);
SendMessage.AsyncSendMessage_Notice(opName, "【" + opName + "】进站成功允许PLC工作" + engineID);
}
catch (Exception err)
{
MyLog4Net.MyLogHelper.Error("Function1062.EngineTypeGetOver", err.Message);
MisDataFun.LogRecording_OP(ManualStaticOutOpName, "ERROR", "EngineTypeGetOver", err.Message);
}
}
}
private void WriteManualStaticEngineError(string opName, string message)
{
MIS_BASE.Write_FixAllow(opName, false);
MIS_BASE.Write_TagValueByTagTypeID(34, opName, true);
SendMessage.AsyncSendMessage_Notice(opName, "【" + opName + "】" + message);
MisDataFun.LogRecording_OP(opName, "ERROR", "EngineTypeGetOver", message);
}
}
}