增加 兜底时记录订货号 增加常量 app.config配置文件

This commit is contained in:
XingCheng3
2026-05-14 13:06:53 +08:00
parent fa121f4ab8
commit e0391dc32f
4 changed files with 92 additions and 42 deletions

View File

@@ -26,6 +26,11 @@
<!--扫码枪波特率-->
<add key="BarcodeBaudRate" value="9600"/>
<!--曲线采样间隔(ms)-->
<add key="CurveCollectorSampleIntervalMs" value="200"/>
<!--曲线稳定窗口点数-->
<add key="CurveStableWindowSize" value="20"/>
</appSettings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.8"/>

View File

@@ -363,12 +363,22 @@ namespace MesWork
/// <summary>
/// 更新过站记录为完成case 19 请求保存时调用)
/// </summary>
public static bool UpdateStationComplete(string engineNo, string stationNo, decimal weight)
public static bool UpdateStationComplete(string engineNo, string stationNo, decimal weight,
string modelNo = "", string orderNo = "", string palletNo = "", string stationName = "",
decimal addOilQty = 0, decimal extractOilQty = 0, decimal density = 0, string worker = "")
{
var sqlParameter = new SqlParameter[] {
new SqlParameter("@发动机号", engineNo),
new SqlParameter("@工位号", stationNo),
new SqlParameter("@称重重量", weight)
new SqlParameter("@称重重量", weight),
new SqlParameter("@机型号", modelNo),
new SqlParameter("@工单号", orderNo),
new SqlParameter("@托盘号", palletNo),
new SqlParameter("@工位名称", stationName),
new SqlParameter("@加油量", addOilQty),
new SqlParameter("@抽油量", extractOilQty),
new SqlParameter("@油密度", density),
new SqlParameter("@操作者", worker)
};
SqlOperation.ExecuteStoredProcedure("过站记录_完成", sqlParameter, out DataTable dt, out string err);
return dt != null && dt.Rows.Count > 0 && dt.Rows[0]["result"].ToString() == "1";

View File

@@ -1,6 +1,7 @@
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Configuration;
using System.Globalization;
using System.Linq;
using System.Threading;
@@ -30,8 +31,13 @@ namespace MesWork
private static readonly ConcurrentDictionary<string, CurveCollectorState> _curveCollectors
= new ConcurrentDictionary<string, CurveCollectorState>(StringComparer.OrdinalIgnoreCase);
private const int CurveCollectorSampleIntervalMs = 200;
private const int CurveStableWindowSize = 20;
private static readonly int CurveCollectorSampleIntervalMs = int.TryParse(
ConfigurationManager.AppSettings["CurveCollectorSampleIntervalMs"], out int _sampleIntervalMs)
? _sampleIntervalMs : 200;
private static readonly int CurveStableWindowSize = int.TryParse(
ConfigurationManager.AppSettings["CurveStableWindowSize"], out int _stableWindowSize)
? _stableWindowSize : 20;
/// <summary>
/// 允许工作后启动曲线采集,每个工位同一时间只保留一个采集段。

View File

@@ -319,9 +319,16 @@ namespace MesWork
decimal plcWeight = Convert.ToDecimal(ReadPLC(100140, opName)); // PLC锁定重量曲线无效时兜底使用
decimal weight = plcWeight; // 默认使用PLC锁定重量曲线算法成功后覆盖
decimal waterContent = Convert.ToDecimal(ReadPLC(100180, opName)); // 水含量
string engineNo = PLC_R.GetString_CleanGarbled(ReadPLC(10, opName)); // 产品编号
if (TryConvertCodeBlockData(engineNo, out _, out string parsedProductNo))
string engineNo = PLC_R.GetString_CleanGarbled(ReadPLC(10, opName)); // 原始代码串/产品编号
string modelNo = PLC_R.GetString_CleanGarbled(ReadPLC(11, opName)); // 机型号
string orderNo = PLC_R.GetString_CleanGarbled(ReadPLC(39, opName)); // 工单号/订货号
string palletNo = PLC_R.GetString_CleanGarbled(ReadPLC(80, opName)); // 托盘号
if (TryConvertCodeBlockData(engineNo, out string parsedOrderNo, out string parsedProductNo))
{
if (!string.IsNullOrWhiteSpace(parsedOrderNo))
{
orderNo = parsedOrderNo;
}
engineNo = parsedProductNo;
}
else if (string.IsNullOrWhiteSpace(engineNo))
@@ -351,8 +358,30 @@ namespace MesWork
}
long curveWeighingRecordId = 0;
B_DB_Opera.UpdateStationComplete(engineNo, opName, weight); // 过站记录保存最终采用重量
string weighType = GetWeighingType(opName);
decimal addOilQty = 0;
decimal extractOilQty = 0;
decimal density = 0;
decimal residualOilUpperLimit = 0;
decimal residualOilLowerLimit = 0;
if (!string.IsNullOrWhiteSpace(orderNo) &&
B_DB_Opera.QueryWorkpieceByOrderNo(orderNo, out string matchedModelNo, out decimal matchedAddOilQty,
out decimal matchedExtractOilQty, out decimal matchedDensity, out decimal matchedResidualOilUpperLimit,
out decimal matchedResidualOilLowerLimit))
{
modelNo = matchedModelNo;
addOilQty = matchedAddOilQty;
extractOilQty = matchedExtractOilQty;
density = matchedDensity;
residualOilUpperLimit = matchedResidualOilUpperLimit;
residualOilLowerLimit = matchedResidualOilLowerLimit;
}
if (!B_DB_Opera.UpdateStationComplete(engineNo, opName, weight, modelNo, orderNo, palletNo, weighType,
addOilQty, extractOilQty, density, Curr_UserName)) // 过站记录保存最终采用重量找不到则由SP补异常完成记录
{
LogWeighingFallback(opName, engineNo, "请求保存-过站", "未找到请求工作过站记录,已补异常过站完成记录", AID);
}
decimal oilReleaseQty = 0;
decimal residualOilQty = 0;
int finalQualityFlag = 1;
@@ -376,8 +405,8 @@ namespace MesWork
else
{
// 兜底机制请求工作阶段资料异常可能没有占位记录保存时补一条异常完成记录避免PLC等不到保存完成。
curveWeighingRecordId = B_DB_Opera.InsertWeighingRecord(opName, "地面", engineNo, "", "", "",
0, weight, 0, 0, 0, 0, 0, 0, 0, 2, waterContent,
curveWeighingRecordId = B_DB_Opera.InsertWeighingRecord(opName, "地面", engineNo, modelNo, orderNo, palletNo,
0, weight, addOilQty, extractOilQty, density, residualOilUpperLimit, residualOilLowerLimit, 0, 0, 2, waterContent,
opName, Curr_UserName, isComplete: 1);
finalQualityFlag = 2;
qualityMsg = "未找到请求工作占位记录,已按异常地面记录保存";
@@ -400,8 +429,8 @@ namespace MesWork
else
{
// 兜底机制:没有占位记录时补异常记录并完成握手,后续放油后仍可按异常链路继续。
curveWeighingRecordId = B_DB_Opera.InsertWeighingRecord(opName, "空中", engineNo, "", "", "",
weight, 0, 0, 0, 0, 0, 0, 0, 0, 2, waterContent,
curveWeighingRecordId = B_DB_Opera.InsertWeighingRecord(opName, "空中", engineNo, modelNo, orderNo, palletNo,
weight, 0, addOilQty, extractOilQty, density, residualOilUpperLimit, residualOilLowerLimit, 0, 0, 2, waterContent,
opName, Curr_UserName, isComplete: 1);
finalQualityFlag = 2;
qualityMsg = "未找到请求工作占位记录,已按异常放油前记录保存";
@@ -427,8 +456,8 @@ namespace MesWork
else
{
// 找不到放油前记录(可能直接进放油后工位):创建一条放油后记录并标记完成
curveWeighingRecordId = B_DB_Opera.InsertWeighingRecord(opName, "空中放油后", engineNo, "", "", "",
0, weight, 0, 0, 0, 0, 0, 0, 0, 2, waterContent,
curveWeighingRecordId = B_DB_Opera.InsertWeighingRecord(opName, "空中放油后", engineNo, modelNo, orderNo, palletNo,
0, weight, addOilQty, extractOilQty, density, residualOilUpperLimit, residualOilLowerLimit, 0, 0, 2, waterContent,
opName, Curr_UserName, isComplete: 1); // 异常兜底记录,质量直接判不合格
finalQualityFlag = 2;
qualityMsg = "未找到放油前记录";