From 1d26cc279b05383c44b41603fba0f867f250a6d8 Mon Sep 17 00:00:00 2001 From: "zhengxuan.zhang" Date: Fri, 14 Aug 2026 09:41:36 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8DCNC=E5=A4=8D=E6=A0=B8?= =?UTF-8?q?=E6=A0=87=E8=AE=B0=E5=BD=92=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Services/InspectionArchiveServiceTests.cs | 2 +- .../Services/Cnc/Execution/CncExecutionService.cs | 5 +++++ .../Documentation/InspectionDocumentationService.cs | 13 +++++++++---- .../Documentation/InspectionMapViewModel.cs | 2 ++ 4 files changed, 17 insertions(+), 5 deletions(-) diff --git a/XplorePlane.Tests/Services/InspectionArchiveServiceTests.cs b/XplorePlane.Tests/Services/InspectionArchiveServiceTests.cs index 80aec383..fcb7812f 100644 --- a/XplorePlane.Tests/Services/InspectionArchiveServiceTests.cs +++ b/XplorePlane.Tests/Services/InspectionArchiveServiceTests.cs @@ -270,7 +270,7 @@ namespace XplorePlane.Tests.Services var opts = new JsonSerializerOptions { Converters = { new JsonStringEnumConverter() } }; var detail = JsonSerializer.Deserialize(json, opts); Assert.NotNull(detail); - Assert.Equal(2, detail.SchemaVersion); + Assert.Equal(3, detail.SchemaVersion); Assert.NotNull(detail.Map); Assert.Equal(map.MapId, detail.Map.MapId); Assert.Equal("marks/inspection-map.xpmap", detail.Map.DocumentPath); diff --git a/XplorePlane/Services/Cnc/Execution/CncExecutionService.cs b/XplorePlane/Services/Cnc/Execution/CncExecutionService.cs index b9e4dfc4..127ca523 100644 --- a/XplorePlane/Services/Cnc/Execution/CncExecutionService.cs +++ b/XplorePlane/Services/Cnc/Execution/CncExecutionService.cs @@ -841,6 +841,11 @@ namespace XplorePlane.Services.Cnc var markedOverviewImage = rawOverviewImage; if (_navigationFrameProvider?.TryCaptureCompositeBitmapSource(out var reviewedOverview) == true) markedOverviewImage = reviewedOverview; + + // 数据库是标记权威来源;绑定新建地图时恢复已归档标记,避免空地图覆盖 .xpmap。 + if (detail.Marks != null && detail.Marks.Count > 0) + map.Marks.AddRange(detail.Marks); + map.OverviewImageRelativePath = await _archive .SaveOverviewAsync(map, "overview.bmp", markedOverviewImage, ct) .ConfigureAwait(false); diff --git a/XplorePlane/Services/Inspection/Documentation/InspectionDocumentationService.cs b/XplorePlane/Services/Inspection/Documentation/InspectionDocumentationService.cs index 77c1d008..0987c347 100644 --- a/XplorePlane/Services/Inspection/Documentation/InspectionDocumentationService.cs +++ b/XplorePlane/Services/Inspection/Documentation/InspectionDocumentationService.cs @@ -18,7 +18,9 @@ namespace XplorePlane.Services.Inspection.Documentation { InspectionMapDocument CreateMap(string name); - Task AddMarkAsync(InspectionMapDocument map, InspectionMarkType type, Point imagePixelPoint, string comment, CancellationToken ct = default); + Task AddMarkAsync(InspectionMapDocument map, InspectionMarkType type, Point imagePixelPoint, string comment, CancellationToken ct = default); + + Task SaveMarkAsync(InspectionMapDocument map, InspectionMarkRecord mark, CancellationToken ct = default); void UpdateMark(InspectionMapDocument map, InspectionMarkRecord updatedMark); @@ -107,8 +109,11 @@ namespace XplorePlane.Services.Inspection.Documentation map.Marks.Add(mark); Touch(map); - return mark; - } + return mark; + } + + public Task SaveMarkAsync(InspectionMapDocument map, InspectionMarkRecord mark, CancellationToken ct = default) + => _archive.SaveMarkAsync(map, mark, ct); public void UpdateMark(InspectionMapDocument map, InspectionMarkRecord updatedMark) { @@ -222,4 +227,4 @@ namespace XplorePlane.Services.Inspection.Documentation _ => 5 }; } -} \ No newline at end of file +} diff --git a/XplorePlane/ViewModels/Inspection/Documentation/InspectionMapViewModel.cs b/XplorePlane/ViewModels/Inspection/Documentation/InspectionMapViewModel.cs index bde493ca..25bb8ba9 100644 --- a/XplorePlane/ViewModels/Inspection/Documentation/InspectionMapViewModel.cs +++ b/XplorePlane/ViewModels/Inspection/Documentation/InspectionMapViewModel.cs @@ -221,6 +221,7 @@ namespace XplorePlane.ViewModels.Inspection.Documentation // 用户选择的状态回写到标记类型,保证导航区标记图标(OK/NG/警告)显示正确 mark.Type = StatusToMarkType(mark.Status); _documentationService.UpdateMark(CurrentMap, mark); + await _documentationService.SaveMarkAsync(CurrentMap, mark); // 同步到导航区标记集合;同一位置节点只允许保留一个标记。 AddOrReplaceCncMark(mark); @@ -276,6 +277,7 @@ namespace XplorePlane.ViewModels.Inspection.Documentation : string.Empty; mark.ReviewedAtUtc = reviewedAtUtc ?? DateTime.UtcNow; _documentationService.UpdateMark(CurrentMap, mark); + await _documentationService.SaveMarkAsync(CurrentMap, mark); // 同一位置节点重复触发复核时更新原标记,不追加新的图标。 AddOrReplaceCncMark(mark);