重新截图信息更新至数据库,同时导出html

This commit is contained in:
tian 2026-02-02 22:25:26 +08:00
parent cb56910d68
commit a305ba31e1
4 changed files with 113 additions and 8 deletions

View File

@ -9,9 +9,9 @@
3、[x] (优化)修改吊装路径适应桁车空中路线(纵向+平移,有吊绳) 3、[x] (优化)修改吊装路径适应桁车空中路线(纵向+平移,有吊绳)
4、[x] (优化)对系统配置文件的修改即时起效 4、[x] (优化)对系统配置文件的修改即时起效
5、[ ] (优化)切换文档时重新加载数据库 5、[ ] (优化)切换文档时重新加载数据库
6、[ ] (优化)默认打开指定碰撞物体 6、[x] (优化)默认打开指定碰撞物体
7、[ ] (优化)动画运行视角优化设计,不能只用俯视图 7、[ ] (优化)动画运行视角优化设计,不能只用俯视图
8、[ ] BUG旧版配置文件要主动提示升级配置文件不能崩溃 8、[x] BUG旧版配置文件要主动提示升级配置文件不能崩溃
### [2026/1/26] ### [2026/1/26]

View File

@ -95,6 +95,7 @@ namespace NavisworksTransport.Commands
public int UniqueCollidedObjectsCount { get; set; } public int UniqueCollidedObjectsCount { get; set; }
// 新增:动画参数 // 新增:动画参数
public string RouteId { get; set; } // 路径ID用于数据库关联
public string PathName { get; set; } public string PathName { get; set; }
public int FrameRate { get; set; } public int FrameRate { get; set; }
public double Duration { get; set; } public double Duration { get; set; }
@ -179,8 +180,10 @@ namespace NavisworksTransport.Commands
result.DetectionTolerance = animationManager.DetectionTolerance; result.DetectionTolerance = animationManager.DetectionTolerance;
} }
// 从数据库获取路径名称(不依赖动画管理器的状态,使用同步方法避免死锁) // 从数据库获取路径名称和RouteId不依赖动画管理器的状态使用同步方法避免死锁
result.PathName = GetPathNameFromDatabase(targetTestName) ?? "未知路径"; var testInfo = GetTestInfoFromDatabase(targetTestName);
result.PathName = testInfo?.PathName ?? "未知路径";
result.RouteId = testInfo?.RouteId;
LogManager.Info($"碰撞报告计数 - 检查点: {result.AnimationCollisions}, Clash Detective: {result.TotalCollisions}"); LogManager.Info($"碰撞报告计数 - 检查点: {result.AnimationCollisions}, Clash Detective: {result.TotalCollisions}");
@ -513,6 +516,29 @@ namespace NavisworksTransport.Commands
} }
} }
/// <summary>
/// 从数据库获取测试信息包括路径名称和RouteId
/// </summary>
private ClashDetectiveResultRecord GetTestInfoFromDatabase(string testName)
{
var pathDatabase = PathPlanningManager.Instance?.GetPathDatabase();
if (pathDatabase == null)
{
LogManager.Warning("无法获取PathDatabase实例");
return null;
}
try
{
return pathDatabase.GetClashDetectiveResultByTestName(testName);
}
catch (Exception ex)
{
LogManager.Error($"从数据库获取测试信息失败: {ex.Message}");
return null;
}
}
/// <summary> /// <summary>
/// 生成报告内容 /// 生成报告内容
/// </summary> /// </summary>

View File

@ -391,6 +391,51 @@ namespace NavisworksTransport
} }
} }
/// <summary>
/// 更新碰撞报告的截图信息更新ClashDetectiveResults表
/// </summary>
public void UpdateCollisionReportScreenshot(string routeId, string screenshotPath,
string screenshotFormat, int screenshotWidth, int screenshotHeight)
{
try
{
// 更新 ClashDetectiveResults 表(该表包含 ScreenshotPath 列)
// 更新该 RouteId 的最新记录
var sql = @"
UPDATE ClashDetectiveResults
SET ScreenshotPath = @screenshotPath
WHERE RouteId = @routeId
AND Id = (
SELECT Id FROM ClashDetectiveResults
WHERE RouteId = @routeId
ORDER BY TestTime DESC
LIMIT 1
)
";
using (var cmd = new SQLiteCommand(sql, _connection))
{
cmd.Parameters.AddWithValue("@routeId", routeId ?? "");
cmd.Parameters.AddWithValue("@screenshotPath", screenshotPath ?? (object)DBNull.Value);
var rowsAffected = cmd.ExecuteNonQuery();
if (rowsAffected > 0)
{
LogManager.Info($"碰撞报告截图已更新: RouteId={routeId}, 截图={screenshotPath}");
}
else
{
LogManager.Warning($"未找到需要更新的碰撞记录: RouteId={routeId}");
}
}
}
catch (Exception ex)
{
LogManager.Error($"更新碰撞报告截图失败: {ex.Message}", ex);
throw;
}
}
/// <summary> /// <summary>
/// 更新路径名称(仅更新名称字段) /// 更新路径名称(仅更新名称字段)
/// </summary> /// </summary>

View File

@ -1014,19 +1014,53 @@ namespace NavisworksTransport.UI.WPF.ViewModels
CurrentReport.ScreenshotWidth = dialog.ImageWidth; CurrentReport.ScreenshotWidth = dialog.ImageWidth;
CurrentReport.ScreenshotHeight = dialog.ImageHeight; CurrentReport.ScreenshotHeight = dialog.ImageHeight;
// 保存到数据库
try
{
var pathDatabase = PathPlanningManager.Instance?.GetPathDatabase();
if (pathDatabase != null && !string.IsNullOrEmpty(CurrentReport.RouteId))
{
pathDatabase.UpdateCollisionReportScreenshot(
CurrentReport.RouteId,
screenshotPath,
CurrentReport.ScreenshotFormat,
dialog.ImageWidth,
dialog.ImageHeight
);
LogManager.Info($"碰撞报告截图已保存到数据库: RouteId={CurrentReport.RouteId}");
}
else
{
LogManager.Warning("无法保存截图到数据库PathDatabase不可用或RouteId为空");
}
}
catch (Exception dbEx)
{
LogManager.Error($"保存截图到数据库失败: {dbEx.Message}");
// 继续执行,不影响截图生成
}
// 通知UI更新 // 通知UI更新
OnPropertyChanged(nameof(CurrentReport)); OnPropertyChanged(nameof(CurrentReport));
OnPropertyChanged(nameof(ScreenshotPreviewSource)); OnPropertyChanged(nameof(ScreenshotPreviewSource));
// 提示用户
System.Windows.MessageBox.Show(
"截图已更新并保存到数据库。",
"截图更新成功",
System.Windows.MessageBoxButton.OK,
System.Windows.MessageBoxImage.Information);
LogManager.Info("碰撞场景截图已更新"); LogManager.Info("碰撞场景截图已更新");
} }
} }
} }
catch (Exception ex) catch (Exception ex)
{ {
LogManager.Error($"重新截图失败: {ex.Message}"); LogManager.Error($"重新截图失败: {ex.Message}");
System.Windows.MessageBox.Show($"重新截图失败: {ex.Message}", "错误", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error); System.Windows.MessageBox.Show($"重新截图失败: {ex.Message}", "错误", System.Windows.MessageBoxButton.OK, System.Windows.MessageBoxImage.Error);
} } }
}
/// <summary> /// <summary>
/// 检查是否可以执行重新截图 /// 检查是否可以执行重新截图