浏览代码

导出PDF/CSV时增加设备信息(线别/站别/机台号)

本次提交在导出PDF和CSV测试结果时,新增了设备信息(线别、站别、机台号)的导出功能,便于数据追溯和管理。同时对部分代码格式进行了优化,不涉及业务逻辑变更。
孝锋 徐 7 月之前
父节点
当前提交
569746c96b
共有 1 个文件被更改,包括 25 次插入6 次删除
  1. 25 6
      TeamAAS-VM/ViewModels/Product/VisionDynamicAccuracyAnalyzerViewModel.cs

+ 25 - 6
TeamAAS-VM/ViewModels/Product/VisionDynamicAccuracyAnalyzerViewModel.cs

@@ -212,7 +212,7 @@ namespace TeamAAS_VP.ViewModels.Product
             set { SetProperty(ref _ProcedureModels, value); }
         }
 
-        private int _MoveSpeed=100;
+        private int _MoveSpeed = 100;
         /// <summary>
         /// 移动速度
         /// </summary>
@@ -376,7 +376,7 @@ namespace TeamAAS_VP.ViewModels.Product
             {
                 DateTime startTime = DateTime.Now;
                 //为机器人设置移动速度
-                await Robot.CalibParameAsync(new PickInfo(), MoveSpeed,0,false,0,0);
+                await Robot.CalibParameAsync(new PickInfo(), MoveSpeed, 0, false, 0, 0);
 
                 //移动机器人至A点
                 bool isSuccess1 = await Robot.CalibMotionAsync(PointA, null);
@@ -487,7 +487,7 @@ namespace TeamAAS_VP.ViewModels.Product
                     {
                         FailCount++;
                     }
-                    TestResults.Add(new DynamicTestResult(CurrentProgress,isSuccess,PointB,CycleTime,pixelX,pixelY,angleU,transformX,transformY));
+                    TestResults.Add(new DynamicTestResult(CurrentProgress, isSuccess, PointB, CycleTime, pixelX, pixelY, angleU, transformX, transformY));
                     OnTestResultAdded();
 
                     CurrentProgress++;
@@ -654,6 +654,15 @@ namespace TeamAAS_VP.ViewModels.Product
                         metaTable.AddCell(cellVal);
                     }
 
+                    // include device info (line, station, fixture id) but exclude MES flags/urls
+                    var device = _configService?.GetDeviceInfo();
+                    if (device != null)
+                    {
+                        AddMeta("线别", device.Line ?? string.Empty);
+                        AddMeta("站别", device.Station ?? string.Empty);
+                        AddMeta("机台号", device.FixtureId ?? string.Empty);
+                    }
+
                     AddMeta("导出时间", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"));
                     AddMeta("测试次数(目标)", RepeatCount.ToString(System.Globalization.CultureInfo.InvariantCulture));
                     AddMeta("当前进度", $"{CurrentProgress} / {RepeatCount}");
@@ -820,7 +829,7 @@ namespace TeamAAS_VP.ViewModels.Product
                 string path = dlg.FileName;
                 var sb = new System.Text.StringBuilder();
 
-                // CSV 字段转义
+                // 辅助:CSV 字段转义
                 Func<string, string> EscapeCsv = (s) =>
                 {
                     if (s == null) return "";
@@ -828,6 +837,16 @@ namespace TeamAAS_VP.ViewModels.Product
                     string esc = s.Replace("\"", "\"\"");
                     return mustQuote ? $"\"{esc}\"" : esc;
                 };
+                // include device info at top of CSV
+                var device = _configService?.GetDeviceInfo() ?? _configService?.GetDeviceInfo();
+                if (device != null)
+                {
+                    sb.AppendLine("设备信息");
+                    sb.AppendLine($"线别,{EscapeCsv(device.Line)}");
+                    sb.AppendLine($"站别,{EscapeCsv(device.Station)}");
+                    sb.AppendLine($"机台号,{EscapeCsv(device.FixtureId)}");
+                    sb.AppendLine();
+                }
 
                 // 写入表头
                 var headers = new[]
@@ -1107,7 +1126,7 @@ namespace TeamAAS_VP.ViewModels.Product
                         //SendTaskMessage(Lang.拍照OK, MessageLevel.Debug);
 
                         // 3. 获取视觉输出结果
-                        
+
                         string points = (string)(outputCollection["Point"].Value);
                         string[] strpoints = points.Split(';');
                         //先将pos按照逗号进行分隔,拿到数组
@@ -1467,7 +1486,7 @@ namespace TeamAAS_VP.ViewModels.Product
                 var configDir = System.IO.Path.GetDirectoryName(configPath);
                 if (!Directory.Exists(configDir))
                 {
-                     Directory.CreateDirectory(configDir);
+                    Directory.CreateDirectory(configDir);
                 }
 
                 string json = JsonConvert.SerializeObject(ConfigModel, Formatting.Indented);