|
@@ -210,6 +210,82 @@ namespace MeterVision.db
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ public static bool UpdatePatchDetails(List<TPatchDetail> patchDetails)
|
|
|
+ {
|
|
|
+ // 更新 SQL 语句
|
|
|
+ string sql = @"
|
|
|
+ UPDATE t_patch_detail
|
|
|
+ SET
|
|
|
+ run_flag = @RunFlag,
|
|
|
+ run_time = @RunTime,
|
|
|
+ dst_image = @DstImage,
|
|
|
+ result_meter = @ResultMeter,
|
|
|
+ result_type = @ResultType,
|
|
|
+ raw_value = @RawValue,
|
|
|
+ final_value = @FinalValue,
|
|
|
+ complete_value = @CompleteValue,
|
|
|
+ value_changed = @ValueChanged,
|
|
|
+ equal_flag = @EqualFlag,
|
|
|
+ ai_ver = @AiVer,
|
|
|
+ debug_info = @DebugInfo,
|
|
|
+ log_path = @LogPath,
|
|
|
+ memo = @Memo,
|
|
|
+ latest_complete = @LatestComplete,
|
|
|
+ last_compress = @LastCompress,
|
|
|
+ latest_value = @LatestValue,
|
|
|
+ latest_time = @LatestTime
|
|
|
+ WHERE patch_detail_id = @PatchDetailId;";
|
|
|
+
|
|
|
+ try
|
|
|
+ {
|
|
|
+ using (SQLiteConnection connection = SQLiteHelper.GetConnection())
|
|
|
+ {
|
|
|
+ connection.Open();
|
|
|
+ using (SQLiteTransaction transaction = connection.BeginTransaction())
|
|
|
+ {
|
|
|
+ foreach (var patchDetail in patchDetails)
|
|
|
+ {
|
|
|
+ SQLiteParameter[] parameters = new SQLiteParameter[]
|
|
|
+ {
|
|
|
+ new SQLiteParameter("@RunFlag", patchDetail.RunFlag),
|
|
|
+ new SQLiteParameter("@RunTime", patchDetail.RunTime),
|
|
|
+ new SQLiteParameter("@DstImage", patchDetail.DstImage),
|
|
|
+ new SQLiteParameter("@ResultMeter", patchDetail.ResultMeter),
|
|
|
+ new SQLiteParameter("@ResultType", patchDetail.ResultType),
|
|
|
+ new SQLiteParameter("@RawValue", patchDetail.RawValue),
|
|
|
+ new SQLiteParameter("@FinalValue", patchDetail.FinalValue),
|
|
|
+ new SQLiteParameter("@CompleteValue", patchDetail.CompleteValue),
|
|
|
+ new SQLiteParameter("@ValueChanged", patchDetail.ValueChanged),
|
|
|
+ new SQLiteParameter("@EqualFlag", patchDetail.EqualFlag),
|
|
|
+ new SQLiteParameter("@AiVer", patchDetail.AiVer),
|
|
|
+ new SQLiteParameter("@DebugInfo", patchDetail.DebugInfo),
|
|
|
+ new SQLiteParameter("@LogPath", patchDetail.LogPath),
|
|
|
+ new SQLiteParameter("@Memo", patchDetail.Memo),
|
|
|
+ new SQLiteParameter("@LatestComplete", patchDetail.LatestComplete),
|
|
|
+ new SQLiteParameter("@LastCompress", patchDetail.LastCompress),
|
|
|
+ new SQLiteParameter("@LatestValue", patchDetail.LatestValue),
|
|
|
+ new SQLiteParameter("@LatestTime", patchDetail.LatestTime),
|
|
|
+ new SQLiteParameter("@PatchDetailId", patchDetail.PatchDetailId) // 条件字段
|
|
|
+ };
|
|
|
+
|
|
|
+ SQLiteHelper.ExecuteNonQuery(sql, parameters, transaction);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 提交事务
|
|
|
+ transaction.Commit();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ catch (Exception ex)
|
|
|
+ {
|
|
|
+ Console.WriteLine("更新数据时出错: " + ex.Message);
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
//根据识别结果修改表内容
|
|
|
public static bool UpdatePatchDetailWithResult(TPatchDetail detail)
|
|
|
{
|
|
@@ -223,6 +299,7 @@ namespace MeterVision.db
|
|
|
raw_value = @RawValue,
|
|
|
final_value = @FinalValue,
|
|
|
complete_value = @CompleteValue,
|
|
|
+ value_changed = @ValueChanged,
|
|
|
equal_flag = @EqualFlag,
|
|
|
ai_ver = @AiVer,
|
|
|
debug_info = @DebugInfo,
|
|
@@ -241,6 +318,7 @@ namespace MeterVision.db
|
|
|
new SQLiteParameter("@RawValue", detail.RawValue),
|
|
|
new SQLiteParameter("@FinalValue", detail.FinalValue),
|
|
|
new SQLiteParameter("@CompleteValue",detail.CompleteValue),
|
|
|
+ new SQLiteParameter("@ValueChanged",detail.ValueChanged),
|
|
|
new SQLiteParameter("@EqualFlag", detail.EqualFlag),
|
|
|
new SQLiteParameter("@AiVer", detail.AiVer),
|
|
|
new SQLiteParameter("@DebugInfo", detail.DebugInfo),
|
|
@@ -850,7 +928,7 @@ namespace MeterVision.db
|
|
|
|
|
|
|
|
|
|
|
|
- public static List<TPatchDetail> GetPatchDetailsWithRunFlagZero(string patchId,string stationId)
|
|
|
+ public static List<TPatchDetail> GetPatchDetailsWithRunFlag(string patchId,string stationId,int runFlag)
|
|
|
{
|
|
|
// 查询 SQL
|
|
|
//string sql = @"
|
|
@@ -869,19 +947,26 @@ namespace MeterVision.db
|
|
|
string whereStation = "";
|
|
|
if (!string.IsNullOrEmpty(stationId))
|
|
|
{
|
|
|
- whereStation = " AND station_id = @StationId";
|
|
|
+ whereStation = " AND run_flag = @RunFlag AND station_id = @StationId";
|
|
|
}
|
|
|
|
|
|
+ //string sql = $@"
|
|
|
+ // SELECT * FROM t_patch_detail
|
|
|
+ // WHERE patch_id = @PatchId AND run_flag = 0{whereStation}
|
|
|
+ // ORDER BY station_id,sample_time ASC";
|
|
|
+
|
|
|
string sql = $@"
|
|
|
SELECT * FROM t_patch_detail
|
|
|
- WHERE patch_id = @PatchId AND run_flag = 0{whereStation}
|
|
|
+ WHERE patch_id = @PatchId{whereStation}
|
|
|
ORDER BY station_id,sample_time ASC";
|
|
|
|
|
|
+
|
|
|
// 定义参数
|
|
|
SQLiteParameter[] parameters = new SQLiteParameter[]
|
|
|
{
|
|
|
new SQLiteParameter("@PatchId", patchId),
|
|
|
- new SQLiteParameter("@StationId",stationId)
|
|
|
+ new SQLiteParameter("@StationId",stationId),
|
|
|
+ new SQLiteParameter("@RunFlag",runFlag)
|
|
|
};
|
|
|
|
|
|
// 执行查询并读取数据
|