From 5ef3cf53463d6297e364100fb764311c67a67817 Mon Sep 17 00:00:00 2001 From: XingCheng3 <1773407212@qq.com> Date: Wed, 10 Jun 2026 18:53:57 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AF=E9=80=9A=E8=BF=87PACK=E7=A0=81?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=20=E4=BA=A7=E5=93=81=E9=9D=99=E7=BD=AE?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=20=E8=BF=9B=E8=A1=8C=E9=9D=99=E7=BD=AE?= =?UTF-8?q?=E4=B8=8A=E7=BA=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../OpcServer/ManualStaticBSave.cs | 15 ++--- .../Function1062/DataAccess/DataAccess.cs | 57 +++++++++++++++++-- .../Function1062/OpcServer/MesRead.cs | 2 +- 3 files changed, 59 insertions(+), 15 deletions(-) diff --git a/MisDataFunction/Function1055/OpcServer/ManualStaticBSave.cs b/MisDataFunction/Function1055/OpcServer/ManualStaticBSave.cs index 26a184d..3f94151 100644 --- a/MisDataFunction/Function1055/OpcServer/ManualStaticBSave.cs +++ b/MisDataFunction/Function1055/OpcServer/ManualStaticBSave.cs @@ -45,17 +45,12 @@ namespace MesServerFunctions return; } - // PLC 可能只给产品码和机型代码,补查数据库中的产品型号。 - string dbEngineType; - int dbEngineTypeID; - MisDataFun.Moby_Select_PDC(engineID, out orderForm, out dbEngineType, out dbEngineTypeID); - if (dbEngineTypeID > 0) + // PLC 当前产品区已是最终 PACK 码,只补查订单和产品型号。 + MisDataFun.Moby_Select_PDC(engineID, out orderForm, out engineType, out engineTypeID); + if (engineTypeID <= 0) { - engineTypeID = dbEngineTypeID; - } - if (!string.IsNullOrWhiteSpace(dbEngineType)) - { - engineType = dbEngineType; + WriteManualStaticBSaveError(opName, "未查询到产品执行信息:" + engineID); + return; } string message; diff --git a/MisDataFunction/Function1062/DataAccess/DataAccess.cs b/MisDataFunction/Function1062/DataAccess/DataAccess.cs index 43b285c..9fa6a53 100644 --- a/MisDataFunction/Function1062/DataAccess/DataAccess.cs +++ b/MisDataFunction/Function1062/DataAccess/DataAccess.cs @@ -58,16 +58,15 @@ namespace MesServerFunctions return false; } - MisDataFun.Moby_Select_PDC(engineID, out string orderForm, out string engineType, out int engineTypeID); - if (engineTypeID <= 0 || string.IsNullOrWhiteSpace(engineType)) + // PAD 可能扫描箱体码,最终产品编号以存储过程返回的产品编号为准。 + if (!TrySelectManualStaticPdcProduct(engineID, out string productCode, out string orderForm, out string engineType, out int engineTypeID, out message)) { - message = "未查询到产品执行信息:" + engineID; return false; } product = new ManualStaticOutProduct { - EngineID = engineID.Trim(), + EngineID = productCode, OrderForm = orderForm, EngineType = engineType, EngineTypeID = engineTypeID @@ -75,6 +74,56 @@ namespace MesServerFunctions return true; } + /// + /// 查询 PDC 产品执行信息,兼容产品码和箱体码输入。 + /// + private bool TrySelectManualStaticPdcProduct(string scanCode, out string productCode, out string orderForm, out string engineType, out int engineTypeID, out string message) + { + productCode = ""; + orderForm = ""; + engineType = ""; + engineTypeID = 0; + message = ""; + + try + { + SqlParameter[] sqlParameters = new SqlParameter[1]; + sqlParameters[0] = new SqlParameter("@发动机号", scanCode); + DataAccess.ExecuteStoredProcedure("测量数据工位_监控系统_MOBY_查询_PDC", ref sqlParameters, out DataTable dt, out string errorMessage); + if (!string.IsNullOrWhiteSpace(errorMessage)) + { + message = "查询产品执行信息失败:" + errorMessage; + return false; + } + + if (dt == null || dt.Rows.Count == 0) + { + message = "未查询到产品执行信息:" + scanCode; + return false; + } + + DataRow row = dt.Rows[0]; + productCode = dt.Columns.Contains("产品编号") ? Convert.ToString(row["产品编号"]) : Convert.ToString(row["发动机号"]); + orderForm = Convert.ToString(row["订单号"]); + engineType = Convert.ToString(row["产品型号"]); + engineTypeID = Convert.ToInt32(row["机型代码"]); + + if (string.IsNullOrWhiteSpace(productCode) || engineTypeID <= 0 || string.IsNullOrWhiteSpace(engineType)) + { + message = "产品执行信息不完整:" + scanCode; + return false; + } + + productCode = productCode.Trim(); + return true; + } + catch (Exception err) + { + message = "查询产品执行信息失败:" + err.Message; + return false; + } + } + /// /// 查询 OP420 记录的线下手动静置开始时间。 /// diff --git a/MisDataFunction/Function1062/OpcServer/MesRead.cs b/MisDataFunction/Function1062/OpcServer/MesRead.cs index 6292f6e..c3b4678 100644 --- a/MisDataFunction/Function1062/OpcServer/MesRead.cs +++ b/MisDataFunction/Function1062/OpcServer/MesRead.cs @@ -38,7 +38,7 @@ namespace MesServerFunctions return; } - // 重新查询 MES 执行信息,避免直接使用 PLC 中不完整的订单/机型数据。 + // 保存阶段从 PLC 读取到的已经是最终 PACK 码,只补查订单和机型信息。 MisDataFun.Moby_Select_PDC(engineID, out orderForm, out engineType, out engineTypeID); if (engineTypeID <= 0) {