update:更新B位静置库

This commit is contained in:
XingCheng3
2026-06-05 13:52:52 +08:00
parent d1403d22b8
commit 4aab62831a
21 changed files with 336 additions and 67 deletions

View File

@@ -81,6 +81,7 @@
<Compile Include="OpcServer\FixOver.cs" />
<Compile Include="OpcServer\MesSaveNowData.cs" />
<Compile Include="OpcServer\HeartBeat.cs" />
<Compile Include="OpcServer\ManualStaticBSave.cs" />
<Compile Include="OpcServer\MesRead.cs" />
<Compile Include="OpcServer\MesReadOver.cs" />
<Compile Include="OpcServer\PartLoad.cs" />
@@ -116,4 +117,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>

View File

@@ -100,6 +100,13 @@ namespace MesServerFunctions
case "65":
fun_MesSaveNowData(e);
break;
//OP420 静置B位产品信息保存请求
case "64":
if (m_OpName == "OP420")
{
fun_ManualStaticBSave(e);
}
break;
//MES 系统健康心跳
case "14":
fun_HeartBeatMIS(e);
@@ -251,6 +258,16 @@ namespace MesServerFunctions
ThreadPool.QueueUserWorkItem(MesSaveNowData, e);
}
/// <summary>
/// OP420 静置B位产品信息保存
/// </summary>
/// <param name="OpName"></param>
/// <param name="tagValue"></param>
public void fun_ManualStaticBSave(DeviceDriver_BasicData.CustomeEvetnArgs e)
{
ThreadPool.QueueUserWorkItem(ManualStaticBSave, e);
}
/// <summary>
/// 拧紧完成
/// </summary>

View File

@@ -0,0 +1,114 @@
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)
{
try
{
var msgEvent = (DeviceDriver_BasicData.CustomeEvetnArgs)e;
string opName = Convert.ToString(msgEvent.OpName);
int tagValue = Convert.ToInt32(msgEvent.TagValue);
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 (!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("OP420", err.Message);
}
}
/// <summary>
/// 保存 OP420 静置B位开始记录同一产品只保留最新一条。
/// </summary>
private bool SaveManualStaticBRecord(string engineID, string engineType, int engineTypeID, out string message)
{
message = "";
SqlParameter[] sqlParameters = new SqlParameter[]
{
new SqlParameter("@产品编号", engineID),
new SqlParameter("@产品型号", engineType),
new SqlParameter("@产品型号代码", engineTypeID),
new SqlParameter("@静置开始时间", DateTime.Now)
};
string errorMessage;
DataAccess.ExecuteStoredProcedure("线下手动静置_记录_保存", ref sqlParameters, out errorMessage);
if (!string.IsNullOrWhiteSpace(errorMessage))
{
message = "保存线下手动静置记录失败:" + errorMessage;
return false;
}
return true;
}
/// <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);
}
}
}

View File

@@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Data;
using System.Threading;
using MesDataFunction;
//using SystemFramework;
using MesServerWork;
using MisDataFunDll;
@@ -99,8 +100,7 @@ namespace MesServerFunctions
}
else
{
MIS_BASE.Write_MesReadOver(OpName, false);
MIS_BASE.Write_MesWorkFinish(OpName, false);
MisDataBaseFun.WriteMesReadOver(OpName, false);
MisDataFun.LogRecording_OP(OpName, "INFO", "MesRead", "PLC允许保存数据取消");
}