Files
52-NingdePDC-MesProject/MisDataFunction/Function1055/OpcServer/ManualStaticBSave.cs
2026-06-26 13:45:37 +08:00

91 lines
3.4 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 DataLinkMesWork1;
using MesServerWork;
using MisDataFunDll;
using System;
using System.Data.SqlClient;
namespace MesServerFunctions
{
partial class FunctionMES
{
/// <summary>
/// OP420 静置B位产品信息保存64=1 保存开始静置信息64=0 复位保存完成点位。
/// </summary>
private void ManualStaticBSave(object e)
{
var msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e;
string opName = Convert.ToString(msgEvent.OpName);
int tagValue = Convert.ToInt32(msgEvent.TagValue);
try
{
if (opName != "OP420")
{
return;
}
if (tagValue != 1)
{
MIS_BASE.Write_TagValueByTagTypeID(31, opName, false);
MisDataFun.LogRecording_OP(opName, "INFO", "ManualStaticBSave", "PLC请求保存静置B位产品信息取消");
return;
}
int engineTypeID;
string engineType;
string engineID;
int palletCode;
string orderForm;
// 从 PLC 当前产品区读取 B 位产品信息,作为线下手动静置开始记录。
MIS_BASE.GetEngineTypeFromPLC(opName, out engineTypeID, out engineType, out engineID, out palletCode, out orderForm);
if (string.IsNullOrWhiteSpace(engineID))
{
WriteManualStaticBSaveError(opName, "PLC当前产品码为空无法记录静置B位产品信息");
return;
}
// PLC 可能只给产品码和机型代码,补查数据库中的产品型号。
string dbEngineType;
int dbEngineTypeID;
MisDataFun.Moby_Select_PDC(engineID, out orderForm, out dbEngineType, out dbEngineTypeID);
if (dbEngineTypeID > 0)
{
engineTypeID = dbEngineTypeID;
}
if (!string.IsNullOrWhiteSpace(dbEngineType))
{
engineType = dbEngineType;
}
string message;
if (!MisDataFun.SaveManualStaticBRecord(engineID, engineType, engineTypeID, out message))
{
WriteManualStaticBSaveError(opName, message);
return;
}
MIS_BASE.Write_TagValueByTagTypeID(31, opName, true);
MisDataFun.LogRecording_OP(opName, "INFO", "ManualStaticBSave", "静置B位产品信息保存完成" + engineID);
}
catch (Exception err)
{
MyLog4Net.MyLogHelper.Error("Function1055.ManualStaticBSave", err.Message);
WriteManualStaticBSaveError(opName, err.Message);
}
}
/// <summary>
/// OP420 静置B位保存失败时复位完成点位并通知页面。
/// </summary>
private void WriteManualStaticBSaveError(string opName, string message)
{
MIS_BASE.Write_TagValueByTagTypeID(31, opName, false);
MIS_BASE.Write_TagValueByTagTypeID(34, opName, true);
SendMessage.AsyncSendMessage_Notice(opName, "【" + opName + "】" + message);
MisDataFun.LogRecording_OP(opName, "ERROR", "ManualStaticBSave", message);
}
}
}