修正检测配置重复,动画结束还检测的问题。自动打开重复的历史记录报告

This commit is contained in:
tian 2026-02-20 00:13:15 +08:00
parent 3f0b42770d
commit 5ca793e093
10 changed files with 370 additions and 55 deletions

View File

@ -17,7 +17,20 @@ CheckExistingDetectionRecord
├── 是 → 提前返回,跳过动画生成和碰撞检测
└── 否 → 继续正常流程
用户生成动画 → 检测到相同配置的历史记录 → 弹出对话框询问
用户选择"使用历史记录"
1. 设置 IsUsingHistoryRecord = true
2. 在历史列表中选中该记录
3. 自动滚动到该记录
4. 自动打开碰撞报告对话框
用户播放动画 → 动画完成 → 检查 IsUsingHistoryRecord
├── true → 跳过 ClashDetective 测试,记录日志
└── false → 正常执行 ClashDetective 测试
生成动画
检查动画帧缓存

View File

@ -7,6 +7,7 @@
1. [x] (优化)实现完整的路径分析功能
2. [x] (功能)用物流分类属性筛选对应的物流元素
3. [x] (优化)实现完整的时间标签功能
4. [x] (优化)增加路径剖面盒开关
### [2026/2/8]
@ -76,7 +77,7 @@
1. [x] (功能)对路径上的各点进行坐标编辑
2. [ ] (功能)记录并查看路径文件操作的历史记录
3. [ ] (功能)自动隐藏或淡化非关键层,以便专注于物流路径相关的层级。
3. [x] (功能)自动隐藏或淡化非关键层,以便专注于物流路径相关的层级。
4. [x] (优化)优化路径时间标签功能
5. [ ] 测试路径规划文件能导入DELMIA
6. [x] (优化)优化路径规划分析和分析报告

View File

@ -123,6 +123,7 @@ namespace NavisworksTransport.Core.Animation
// === 碰撞测试优化 ===
private string _currentAnimationHash; // 当前动画配置的哈希值
private int? _currentDetectionRecordId; // 当前检测记录ID关联CollisionDetectionRecords表
private bool _isUsingHistoryRecord; // 是否使用历史检测记录动画完成后跳过ClashDetective
// === 动画播放机制 ===
private double _frameInterval; // 帧间隔(毫秒)
@ -182,6 +183,15 @@ namespace NavisworksTransport.Core.Animation
set => _currentDetectionRecordId = value;
}
/// <summary>
/// 是否使用历史检测记录动画完成后跳过ClashDetective测试
/// </summary>
public bool IsUsingHistoryRecord
{
get => _isUsingHistoryRecord;
set => _isUsingHistoryRecord = value;
}
// --- 新增事件 ---
/// <summary>
/// 当动画状态发生改变时触发
@ -1611,45 +1621,53 @@ namespace NavisworksTransport.Core.Animation
_timeLinerManager.UpdateTaskProgress(_currentTaskId, 1.0, AnimationState.Finished);
}
// 🔥 执行碰撞检测(重复检查已在保存检测记录时完成,这里直接执行)
LogManager.Info($"开始创建碰撞测试汇总(基于 {_allCollisionResults.Count} 个预计算碰撞记录)...");
// 设置等待光标,避免进度条关闭后的无响应
var oldCursor = System.Windows.Input.Mouse.OverrideCursor;
System.Windows.Input.Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
bool testCompleted = false;
try
// 🔥 检查是否使用历史记录如果是则跳过ClashDetective测试
if (_isUsingHistoryRecord)
{
// 使用用户设置的检测容差(米)
testCompleted = ClashDetectiveIntegration.Instance.CreateAllAnimationCollisionTests(
_allCollisionResults,
_detectionTolerance,
_currentRouteId,
_animatedObject,
_isVirtualObject,
_animationFrameRate,
_animationDuration,
_virtualObjectLength,
_virtualObjectWidth,
_virtualObjectHeight,
_pathPoints,
_currentDetectionRecordId
);
}
finally
{
// 恢复光标
System.Windows.Input.Mouse.OverrideCursor = oldCursor;
}
if (testCompleted)
{
LogManager.Info($"碰撞测试汇总已创建完成");
LogManager.Info("[动画完成] 使用历史检测记录跳过ClashDetective测试");
}
else
{
LogManager.Info("碰撞检测被取消");
// 🔥 执行碰撞检测(重复检查已在保存检测记录时完成,这里直接执行)
LogManager.Info($"开始创建碰撞测试汇总(基于 {_allCollisionResults.Count} 个预计算碰撞记录)...");
// 设置等待光标,避免进度条关闭后的无响应
var oldCursor = System.Windows.Input.Mouse.OverrideCursor;
System.Windows.Input.Mouse.OverrideCursor = System.Windows.Input.Cursors.Wait;
bool testCompleted = false;
try
{
// 使用用户设置的检测容差(米)
testCompleted = ClashDetectiveIntegration.Instance.CreateAllAnimationCollisionTests(
_allCollisionResults,
_detectionTolerance,
_currentRouteId,
_animatedObject,
_isVirtualObject,
_animationFrameRate,
_animationDuration,
_virtualObjectLength,
_virtualObjectWidth,
_virtualObjectHeight,
_pathPoints,
_currentDetectionRecordId
);
}
finally
{
// 恢复光标
System.Windows.Input.Mouse.OverrideCursor = oldCursor;
}
if (testCompleted)
{
LogManager.Info($"碰撞测试汇总已创建完成");
}
else
{
LogManager.Info("碰撞检测被取消");
}
}
}
catch (Exception ex)
@ -2762,6 +2780,13 @@ namespace NavisworksTransport.Core.Animation
_currentDetectionRecordId = null;
}
// 🔥 清除历史记录标志,确保动画生成时状态正确
if (_isUsingHistoryRecord)
{
LogManager.Info("[CreateAnimation] 清除历史记录标志,将创建新检测");
_isUsingHistoryRecord = false;
}
_pathName = pathName;
_currentRouteId = routeId;
_isVirtualObject = isVirtualObject; // 设置是否使用虚拟物体

View File

@ -202,6 +202,22 @@ NavisworksTransport 共享样式资源字典 - Navisworks 2026风格
M12,2C6.48,2 2,6.48 2,12C2,17.52 6.48,22 12,22C17.52,22 22,17.52 22,12C22,6.48 17.52,2 12,2ZM12,20C7.59,20 4,16.41 4,12C4,7.59 7.59,4 12,4C16.41,4 20,7.59 20,12C20,16.41 16.41,20 12,20ZM12,6C8.69,6 6,8.69 6,12C6,15.31 8.69,18 12,18C15.31,18 18,15.31 18,12C18,8.69 15.31,6 12,6ZM12,16C9.79,16 8,14.21 8,12C8,9.79 9.79,8 12,8C14.21,8 16,9.79 16,12C16,14.21 14.21,16 12,16Z
</Geometry>
<!-- 检测记录标签样式(居中) -->
<Style x:Key="CenterLabelStyle" TargetType="TextBlock">
<Setter Property="FontWeight" Value="Normal"/>
<Setter Property="FontSize" Value="11"/>
<Setter Property="Foreground" Value="{StaticResource NavisworksSecondaryBrush}"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
</Style>
<!-- 检测记录数值样式(居中) -->
<Style x:Key="CenterValueStyle" TargetType="TextBlock">
<Setter Property="FontWeight" Value="Bold"/>
<Setter Property="FontSize" Value="12"/>
<Setter Property="Foreground" Value="{StaticResource NavisworksPrimaryBrush}"/>
<Setter Property="HorizontalAlignment" Value="Center"/>
</Style>
<!-- 正方形图标按钮基础样式 -->
<Style x:Key="IconButtonStyle" TargetType="Button">
<Setter Property="Width" Value="24"/>

View File

@ -308,6 +308,15 @@ namespace NavisworksTransport.UI.WPF.ViewModels
// 碰撞构件查看时保存的动画物体状态(用于恢复)
private ModelItem _savedAnimatedObjectForCollision;
#endregion
#region
/// <summary>
/// 请求滚动到指定碰撞历史记录的事件用于代码选中后UI自动滚动到该项
/// </summary>
public event EventHandler<ClashDetectiveResultViewModel> RequestScrollToClashDetectiveResult;
private ModelItemTransformHelper.ObjectStateSnapshot _savedAnimatedObjectStateForCollision;
// 动画参数相关字段(从配置初始化)
@ -866,6 +875,12 @@ namespace NavisworksTransport.UI.WPF.ViewModels
_selectedClashDetectiveResult = value;
OnPropertyChanged();
// 触发滚动事件让View滚动到选中的项
if (_selectedClashDetectiveResult != null)
{
RequestScrollToClashDetectiveResult?.Invoke(this, _selectedClashDetectiveResult);
}
}
}
}
@ -3089,6 +3104,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
// 用户选择使用历史记录
LogManager.Info($"[检测记录] 用户选择使用历史记录 (Id={existingId})");
_pathAnimationManager.CurrentDetectionRecordId = existingId;
_pathAnimationManager.IsUsingHistoryRecord = true; // 标记使用历史记录动画完成后跳过ClashDetective
// 在历史列表中选中该记录
SelectHistoryRecordById(existingId);
@ -3152,6 +3168,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
// 🔥 设置当前检测记录ID到PathAnimationManager供碰撞结果保存时关联使用
_pathAnimationManager.CurrentDetectionRecordId = recordId;
_pathAnimationManager.IsUsingHistoryRecord = false; // 新记录,不是历史记录
// 保存排除列表
var excludedObjects = _pathAnimationManager?.GetExcludedObjects();
@ -3665,7 +3682,7 @@ namespace NavisworksTransport.UI.WPF.ViewModels
}
/// <summary>
/// 在历史列表中选中指定ID的记录
/// 在历史列表中选中指定ID的记录,并打开碰撞报告
/// </summary>
private void SelectHistoryRecordById(int recordId)
{
@ -3678,10 +3695,11 @@ namespace NavisworksTransport.UI.WPF.ViewModels
var targetRecord = _clashDetectiveResults.FirstOrDefault(r => r.Record?.Id == recordId);
if (targetRecord != null)
{
// 先设置选中项确保UI更新
SelectedClashDetectiveResult = targetRecord;
LogManager.Info($"[SelectHistoryRecordById] 已在历史列表中选中记录 (Id={recordId})");
// 如果记录有碰撞,高亮显示
// 更新状态栏显示
if (targetRecord.Record?.CollisionCount > 0)
{
UpdateMainStatus($"已加载历史记录:{targetRecord.Record.TestName}{targetRecord.Record.CollisionCount} 个碰撞");
@ -3690,6 +3708,13 @@ namespace NavisworksTransport.UI.WPF.ViewModels
{
UpdateMainStatus($"已加载历史记录:{targetRecord.Record.TestName},无碰撞");
}
// 🔥 打开该历史记录的碰撞报告,让用户明确知道使用了哪条记录
if (!string.IsNullOrEmpty(targetRecord.Record?.TestName))
{
LogManager.Info($"[SelectHistoryRecordById] 正在打开历史记录报告: {targetRecord.Record.TestName}");
OpenHistoryReportAsync(recordId);
}
}
else
{
@ -3710,6 +3735,33 @@ namespace NavisworksTransport.UI.WPF.ViewModels
return _lastReusedRecordId.HasValue && _lastReusedRecordId.Value == recordId;
}
/// <summary>
/// 异步打开历史碰撞报告
/// </summary>
private async void OpenHistoryReportAsync(int recordId)
{
try
{
// 使用检测记录ID查询生成报告更可靠
var command = GenerateCollisionReportCommand.CreateComprehensive(hasHighlighted: true);
command.SetDetectionRecordId(recordId);
var result = await command.ExecuteAsync();
if (result.IsSuccess && result is PathPlanningResult<CollisionReportResult> reportResult)
{
NavisworksTransport.UI.WPF.Views.CollisionReportDialog.ShowReport(reportResult.Data);
}
else
{
LogManager.Warning($"[OpenHistoryReportAsync] 生成报告失败: {result.ErrorMessage}");
}
}
catch (Exception ex)
{
LogManager.Error($"[OpenHistoryReportAsync] 打开历史报告失败: {ex.Message}");
}
}
#endregion
/// <summary>

View File

@ -89,6 +89,8 @@ namespace NavisworksTransport.UI.WPF.ViewModels
private int _frameRate;
private double _duration;
private double _detectionTolerance;
private string _testName;
private DateTime? _testTime;
private CollisionReportResult _currentReport;
private ObservableCollection<ExcludedObjectRecord> _excludedObjects;
@ -241,6 +243,29 @@ namespace NavisworksTransport.UI.WPF.ViewModels
set => SetProperty(ref _pathName, value);
}
/// <summary>
/// 测试名称(来自检测记录)
/// </summary>
public string TestName
{
get => _testName;
set => SetProperty(ref _testName, value);
}
/// <summary>
/// 测试时间(来自检测记录)
/// </summary>
public DateTime? TestTime
{
get => _testTime;
set => SetProperty(ref _testTime, value);
}
/// <summary>
/// 测试时间显示字符串
/// </summary>
public string TestTimeDisplay => _testTime?.ToString("yyyy-MM-dd HH:mm:ss") ?? "未知时间";
/// <summary>
/// 动画帧率
/// </summary>
@ -574,6 +599,9 @@ namespace NavisworksTransport.UI.WPF.ViewModels
Duration = reportResult.Duration;
DetectionTolerance = reportResult.DetectionTolerance;
// 🔥 从数据库查询测试名称和时间
LoadTestInfoFromDatabase(reportResult.ResultId);
// 更新统计信息
UpdateStatistics(reportResult);
@ -621,6 +649,49 @@ namespace NavisworksTransport.UI.WPF.ViewModels
#region
/// <summary>
/// 从数据库加载测试信息(测试名称和时间)
/// </summary>
private void LoadTestInfoFromDatabase(int resultId)
{
try
{
if (resultId <= 0)
{
LogManager.Debug("[LoadTestInfoFromDatabase] ResultId无效跳过查询");
return;
}
var pathDatabase = PathPlanningManager.Instance?.GetPathDatabase();
if (pathDatabase == null)
{
LogManager.Warning("[LoadTestInfoFromDatabase] PathDatabase不可用");
return;
}
// 使用ResultId查询检测记录
var record = pathDatabase.GetDetectionResultById(resultId);
if (record != null)
{
TestName = record.TestName ?? "未命名测试";
TestTime = record.TestTime;
LogManager.Info($"[LoadTestInfoFromDatabase] 加载测试信息: Name={TestName}, Time={TestTimeDisplay}");
}
else
{
LogManager.Warning($"[LoadTestInfoFromDatabase] 未找到检测记录: ResultId={resultId}");
TestName = "未知测试";
TestTime = null;
}
}
catch (Exception ex)
{
LogManager.Error($"[LoadTestInfoFromDatabase] 加载测试信息失败: {ex.Message}");
TestName = "未知测试";
TestTime = null;
}
}
/// <summary>
/// 更新统计信息
/// </summary>
@ -926,7 +997,14 @@ namespace NavisworksTransport.UI.WPF.ViewModels
report.AppendLine("========================================");
report.AppendLine($"生成时间: {now:yyyy年MM月dd日 HH:mm:ss}");
report.AppendLine($"报告类型: {Statistics.ReportType}");
report.AppendLine();
// 检测记录信息
report.AppendLine("=== 检测记录 ===");
report.AppendLine($"测试名称: {TestName ?? ""}");
report.AppendLine($"检测时间: {TestTimeDisplay}");
report.AppendLine($"路径名称: {PathName}");
report.AppendLine();
// 总体统计
report.AppendLine("=== 总体统计 ===");

View File

@ -506,7 +506,8 @@ NavisworksTransport 检测动画页签视图 - 采用与类别设置和分层管
Visibility="{Binding HasClashDetectiveResults, Converter={StaticResource BoolToVisibilityConverter}, ConverterParameter=Inverse}"
Margin="0,5,0,0"/>
<ListView ItemsSource="{Binding ClashDetectiveResults}"
<ListView x:Name="ClashDetectiveResultsListView"
ItemsSource="{Binding ClashDetectiveResults}"
Margin="0,5,0,0"
Visibility="{Binding HasClashDetectiveResults, Converter={StaticResource BoolToVisibilityConverter}}"
MinHeight="120"

View File

@ -39,6 +39,7 @@ namespace NavisworksTransport.UI.WPF.Views
{
ViewModel = new AnimationControlViewModel();
DataContext = ViewModel;
SubscribeToViewModelEvents();
LogManager.Info("AnimationControlView ViewModel初始化完成");
}
catch (Exception ex)
@ -58,6 +59,7 @@ namespace NavisworksTransport.UI.WPF.Views
{
ViewModel = new AnimationControlViewModel(mainViewModel);
DataContext = ViewModel;
SubscribeToViewModelEvents();
LogManager.Info("AnimationControlView ViewModel初始化完成 - 支持统一状态栏");
}
catch (Exception ex)
@ -67,6 +69,58 @@ namespace NavisworksTransport.UI.WPF.Views
}
}
/// <summary>
/// 订阅ViewModel事件
/// </summary>
private void SubscribeToViewModelEvents()
{
if (ViewModel == null) return;
// 订阅滚动到历史记录事件
ViewModel.RequestScrollToClashDetectiveResult += OnRequestScrollToClashDetectiveResult;
}
/// <summary>
/// 处理滚动到碰撞历史记录请求
/// </summary>
private void OnRequestScrollToClashDetectiveResult(object sender, ClashDetectiveResultViewModel e)
{
try
{
// 查找历史记录列表的ListView通过可视化树查找
var listView = FindClashDetectiveResultsListView();
if (listView != null && e != null)
{
// 使用Dispatcher确保UI更新后再滚动
Dispatcher.BeginInvoke(new Action(() =>
{
listView.ScrollIntoView(e);
LogManager.Debug($"[AnimationControlView] 已滚动到历史记录: {e.Record?.TestName}");
}), System.Windows.Threading.DispatcherPriority.Background);
}
}
catch (Exception ex)
{
LogManager.Error($"[AnimationControlView] 滚动到历史记录失败: {ex.Message}");
}
}
/// <summary>
/// 查找碰撞历史记录ListView控件
/// </summary>
private System.Windows.Controls.ListView FindClashDetectiveResultsListView()
{
try
{
// 通过名称查找控件需要在XAML中设置x:Name
return this.FindName("ClashDetectiveResultsListView") as System.Windows.Controls.ListView;
}
catch
{
return null;
}
}
/// <summary>
/// 清理资源
/// </summary>

View File

@ -219,8 +219,8 @@ NavisworksTransport 碰撞检测报告对话框 - 采用与主界面一致的Nav
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="总碰撞数" Style="{StaticResource StatisticLabelStyle}"/>
<TextBlock Grid.Row="1" Text="{Binding Statistics.TotalCollisions}" Style="{StaticResource StatisticValueStyle}" FontSize="16"/>
<TextBlock Grid.Row="0" Text="总碰撞数" Style="{StaticResource CenterLabelStyle}"/>
<TextBlock Grid.Row="1" Text="{Binding Statistics.TotalCollisions}" Style="{StaticResource CenterValueStyle}"/>
</Grid>
</Border>
<Border Style="{StaticResource StatisticItemStyle}">
@ -229,8 +229,8 @@ NavisworksTransport 碰撞检测报告对话框 - 采用与主界面一致的Nav
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="碰撞构件" Style="{StaticResource StatisticLabelStyle}"/>
<TextBlock Grid.Row="1" Text="{Binding UniqueCollidedObjectsCount}" Style="{StaticResource StatisticValueStyle}"/>
<TextBlock Grid.Row="0" Text="碰撞构件" Style="{StaticResource CenterLabelStyle}"/>
<TextBlock Grid.Row="1" Text="{Binding UniqueCollidedObjectsCount}" Style="{StaticResource CenterValueStyle}"/>
</Grid>
</Border>
<Border Style="{StaticResource StatisticItemStyle}">
@ -239,8 +239,33 @@ NavisworksTransport 碰撞检测报告对话框 - 采用与主界面一致的Nav
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="检测点" Style="{StaticResource StatisticLabelStyle}"/>
<TextBlock Grid.Row="1" Text="{Binding Statistics.AnimationCollisions}" Style="{StaticResource StatisticValueStyle}"/>
<TextBlock Grid.Row="0" Text="检测点" Style="{StaticResource CenterLabelStyle}"/>
<TextBlock Grid.Row="1" Text="{Binding Statistics.AnimationCollisions}" Style="{StaticResource CenterValueStyle}"/>
</Grid>
</Border>
</UniformGrid>
<!-- 检测记录信息 -->
<Label Content="检测记录" Style="{StaticResource SectionHeaderStyle}"/>
<UniformGrid Columns="2" Margin="0,0,0,10">
<Border Style="{StaticResource StatisticItemStyle}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="测试名称" Style="{StaticResource CenterLabelStyle}"/>
<TextBlock Grid.Row="1" Text="{Binding TestName}" Style="{StaticResource CenterValueStyle}"/>
</Grid>
</Border>
<Border Style="{StaticResource StatisticItemStyle}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="检测时间" Style="{StaticResource CenterLabelStyle}"/>
<TextBlock Grid.Row="1" Text="{Binding TestTimeDisplay}" Style="{StaticResource CenterValueStyle}"/>
</Grid>
</Border>
</UniformGrid>
@ -254,8 +279,8 @@ NavisworksTransport 碰撞检测报告对话框 - 采用与主界面一致的Nav
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="路径名称" Style="{StaticResource StatisticLabelStyle}"/>
<TextBlock Grid.Row="1" Text="{Binding PathName}" Style="{StaticResource StatisticValueStyle}" FontSize="11"/>
<TextBlock Grid.Row="0" Text="路径名称" Style="{StaticResource CenterLabelStyle}"/>
<TextBlock Grid.Row="1" Text="{Binding PathName}" Style="{StaticResource CenterValueStyle}"/>
</Grid>
</Border>
<Border Style="{StaticResource StatisticItemStyle}">
@ -264,8 +289,8 @@ NavisworksTransport 碰撞检测报告对话框 - 采用与主界面一致的Nav
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="帧率(FPS)" Style="{StaticResource StatisticLabelStyle}"/>
<TextBlock Grid.Row="1" Text="{Binding FrameRate}" Style="{StaticResource StatisticValueStyle}"/>
<TextBlock Grid.Row="0" Text="帧率(FPS)" Style="{StaticResource CenterLabelStyle}"/>
<TextBlock Grid.Row="1" Text="{Binding FrameRate}" Style="{StaticResource CenterValueStyle}"/>
</Grid>
</Border>
<Border Style="{StaticResource StatisticItemStyle}">
@ -274,8 +299,8 @@ NavisworksTransport 碰撞检测报告对话框 - 采用与主界面一致的Nav
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="时长(秒)" Style="{StaticResource StatisticLabelStyle}"/>
<TextBlock Grid.Row="1" Text="{Binding Duration}" Style="{StaticResource StatisticValueStyle}"/>
<TextBlock Grid.Row="0" Text="时长(秒)" Style="{StaticResource CenterLabelStyle}"/>
<TextBlock Grid.Row="1" Text="{Binding Duration}" Style="{StaticResource CenterValueStyle}"/>
</Grid>
</Border>
<Border Style="{StaticResource StatisticItemStyle}">
@ -284,8 +309,8 @@ NavisworksTransport 碰撞检测报告对话框 - 采用与主界面一致的Nav
<RowDefinition Height="Auto"/>
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<TextBlock Grid.Row="0" Text="检测容差(米)" Style="{StaticResource StatisticLabelStyle}"/>
<TextBlock Grid.Row="1" Text="{Binding DetectionTolerance, StringFormat={}{0:F2}}" Style="{StaticResource StatisticValueStyle}"/>
<TextBlock Grid.Row="0" Text="检测容差(米)" Style="{StaticResource CenterLabelStyle}"/>
<TextBlock Grid.Row="1" Text="{Binding DetectionTolerance, StringFormat={}{0:F2}}" Style="{StaticResource CenterValueStyle}"/>
</Grid>
</Border>
</UniformGrid>

View File

@ -61,11 +61,28 @@ namespace NavisworksTransport.Utils
html.AppendLine("</style>");
html.AppendLine("</head><body>");
// 从数据库获取检测记录信息
var (testName, testTime) = GetDetectionRecordInfo(report.ResultId);
// 报告标题
html.AppendLine($"<h1>NavisworksTransport 碰撞检测报告</h1>");
html.AppendLine($"<p style='text-align: center; color: #666;'>生成时间: {now:yyyy年MM月dd日 HH:mm:ss}</p>");
html.AppendLine($"<p style='text-align: center; color: #666;'>报告类型: 综合报告</p>");
html.AppendLine($"<p style='text-align: center; color: #666;'>路径名称: {report.PathName ?? ""}</p>");
// 检测记录信息
html.AppendLine("<div class='summary'>");
html.AppendLine("<h2>检测记录</h2>");
html.AppendLine("<div class='stats-grid' style='grid-template-columns: repeat(2, 1fr);'>");
html.AppendLine("<div class='stat-item'>");
html.AppendLine("<div class='stat-label'>测试名称</div>");
html.AppendLine($"<div class='stat-value'>{testName ?? ""}</div>");
html.AppendLine("</div>");
html.AppendLine("<div class='stat-item'>");
html.AppendLine("<div class='stat-label'>检测时间</div>");
html.AppendLine($"<div class='stat-value'>{testTime}</div>");
html.AppendLine("</div>");
html.AppendLine("</div>");
html.AppendLine("</div>");
// 总体统计
html.AppendLine("<div class='summary'>");
@ -426,5 +443,38 @@ namespace NavisworksTransport.Utils
return null;
}
}
/// <summary>
/// 从数据库获取检测记录信息
/// </summary>
private static (string testName, string testTime) GetDetectionRecordInfo(int resultId)
{
try
{
if (resultId <= 0)
{
return (null, "未知时间");
}
var pathDatabase = PathPlanningManager.Instance?.GetPathDatabase();
if (pathDatabase == null)
{
return (null, "未知时间");
}
var record = pathDatabase.GetDetectionResultById(resultId);
if (record != null)
{
string timeStr = record.TestTime?.ToString("yyyy-MM-dd HH:mm:ss") ?? "未知时间";
return (record.TestName, timeStr);
}
}
catch (Exception ex)
{
LogManager.Error($"[CollisionReportHtmlGenerator] 获取检测记录信息失败: {ex.Message}");
}
return (null, "未知时间");
}
}
}