提交最新项目改动
This commit is contained in:
@@ -5,7 +5,6 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MesWork
|
||||
@@ -431,17 +430,17 @@ namespace MesWork
|
||||
// ====================================================================
|
||||
|
||||
/// <summary>
|
||||
/// 创建曲线段记录(工件到位时调用)
|
||||
/// 创建紧凑曲线记录,点位值在保存时一次性写入。
|
||||
/// </summary>
|
||||
/// <returns>段ID,失败返回-1</returns>
|
||||
public static long Curve_StartSegment(string opName, string engineNo, string modelNo)
|
||||
public static long CurveRecord_Start(string opName, string productNo, string modelNo, int sampleIntervalMs)
|
||||
{
|
||||
var sqlParameter = new SqlParameter[] {
|
||||
new SqlParameter("@工位号", opName),
|
||||
new SqlParameter("@发动机号", engineNo),
|
||||
new SqlParameter("@机型号", modelNo ?? (object)DBNull.Value)
|
||||
new SqlParameter("@产品编号", productNo),
|
||||
new SqlParameter("@机型号", modelNo ?? (object)DBNull.Value),
|
||||
new SqlParameter("@采样间隔ms", sampleIntervalMs)
|
||||
};
|
||||
SqlOperation.ExecuteStoredProcedure("称重曲线_开始段", sqlParameter, out DataTable dt, out string err);
|
||||
SqlOperation.ExecuteStoredProcedure("称重曲线记录_开始", sqlParameter, out DataTable dt, out string err);
|
||||
if (dt != null && dt.Rows.Count > 0 && dt.Rows[0]["result"].ToString() == "1")
|
||||
{
|
||||
return Convert.ToInt64(dt.Rows[0]["ID"]);
|
||||
@@ -450,46 +449,43 @@ namespace MesWork
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 批量写入曲线采样点(采集线程每攒够N条调用一次)
|
||||
/// 保存紧凑曲线点位字符串,并关联最终称重记录。
|
||||
/// </summary>
|
||||
/// <param name="segmentId">段ID</param>
|
||||
/// <param name="points">采样点列表</param>
|
||||
/// <returns>写入条数,失败返回0</returns>
|
||||
public static int Curve_WritePoints(long segmentId, List<CurveSamplePoint> points)
|
||||
public static bool CurveRecord_Save(long curveId, long weighingRecordId, int sampleCount, string pointValues,
|
||||
decimal? finalWeight, int? finalStartSeq, int? finalEndSeq)
|
||||
{
|
||||
if (points == null || points.Count == 0) return 0;
|
||||
|
||||
// 用 JSON 序列化避免小数区域格式和字符串拼接转义问题。
|
||||
var json = JsonConvert.SerializeObject(points.Select(p => new
|
||||
{
|
||||
seq = p.SeqNo,
|
||||
time = p.SampleTime.ToString("yyyy-MM-ddTHH:mm:ss.fff"),
|
||||
weight = p.Weight
|
||||
}));
|
||||
|
||||
var sqlParameter = new SqlParameter[] {
|
||||
new SqlParameter("@段ID", segmentId),
|
||||
new SqlParameter("@采样数据", json)
|
||||
new SqlParameter("@ID", curveId),
|
||||
new SqlParameter("@称重记录ID", weighingRecordId > 0 ? (object)weighingRecordId : DBNull.Value),
|
||||
new SqlParameter("@采样点数", sampleCount),
|
||||
new SqlParameter("@点位值", string.IsNullOrEmpty(pointValues) ? (object)DBNull.Value : pointValues),
|
||||
new SqlParameter("@最终重量", finalWeight.HasValue ? (object)finalWeight.Value : DBNull.Value),
|
||||
new SqlParameter("@最终取点开始序号", finalStartSeq.HasValue ? (object)finalStartSeq.Value : DBNull.Value),
|
||||
new SqlParameter("@最终取点结束序号", finalEndSeq.HasValue ? (object)finalEndSeq.Value : DBNull.Value)
|
||||
};
|
||||
SqlOperation.ExecuteStoredProcedure("称重曲线_批量写入", sqlParameter, out DataTable dt, out string err);
|
||||
if (dt != null && dt.Rows.Count > 0 && dt.Rows[0]["result"].ToString() == "1")
|
||||
{
|
||||
return Convert.ToInt32(dt.Rows[0]["count"]);
|
||||
}
|
||||
return 0;
|
||||
SqlOperation.ExecuteStoredProcedure("称重曲线记录_保存", sqlParameter, out DataTable dt, out string err);
|
||||
return dt != null && dt.Rows.Count > 0 && dt.Rows[0]["result"].ToString() == "1";
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 结束曲线段(请求保存时调用,关联称重记录ID)
|
||||
/// 查询指定产品最新紧凑曲线记录。
|
||||
/// </summary>
|
||||
public static bool Curve_EndSegment(long segmentId, long weighingRecordId)
|
||||
public static bool CurveRecord_QueryLatest(string opName, string productNo, out string pointValues, out decimal finalWeight)
|
||||
{
|
||||
pointValues = "";
|
||||
finalWeight = 0;
|
||||
var sqlParameter = new SqlParameter[] {
|
||||
new SqlParameter("@段ID", segmentId),
|
||||
new SqlParameter("@称重记录ID", weighingRecordId > 0 ? (object)weighingRecordId : DBNull.Value)
|
||||
new SqlParameter("@工位号", opName),
|
||||
new SqlParameter("@产品编号", productNo)
|
||||
};
|
||||
SqlOperation.ExecuteStoredProcedure("称重曲线_结束段", sqlParameter, out DataTable dt, out string err);
|
||||
return dt != null && dt.Rows.Count > 0 && dt.Rows[0]["result"].ToString() == "1";
|
||||
SqlOperation.ExecuteStoredProcedure("称重曲线记录_查询最新", sqlParameter, out DataTable dt, out string err);
|
||||
if (dt != null && dt.Rows.Count > 0 && dt.Rows[0]["result"].ToString() == "1")
|
||||
{
|
||||
pointValues = dt.Rows[0]["点位值"]?.ToString() ?? "";
|
||||
decimal.TryParse(dt.Rows[0]["最终重量"]?.ToString(), out finalWeight);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user