曲线回读+测试报告导出前期工作
This commit is contained in:
@@ -151,6 +151,7 @@ namespace ADP
|
|||||||
containerRegistry.RegisterScoped(typeof(SqlSugarRepository<>));
|
containerRegistry.RegisterScoped(typeof(SqlSugarRepository<>));
|
||||||
//注册服务
|
//注册服务
|
||||||
containerRegistry.Register<IMonitorValueService, MonitorValueService>();
|
containerRegistry.Register<IMonitorValueService, MonitorValueService>();
|
||||||
|
containerRegistry.Register<ITestReportService, TestReportService>();
|
||||||
}
|
}
|
||||||
//指定模块加载方式(需要手动将模块生成的dll放入Modules文件夹中)
|
//指定模块加载方式(需要手动将模块生成的dll放入Modules文件夹中)
|
||||||
protected override IModuleCatalog CreateModuleCatalog()
|
protected override IModuleCatalog CreateModuleCatalog()
|
||||||
|
|||||||
@@ -567,7 +567,7 @@ namespace ADP.ViewModels
|
|||||||
ScopedContext? targetContext = CurrentContext;
|
ScopedContext? targetContext = CurrentContext;
|
||||||
|
|
||||||
if (runningScope == "default" || string.IsNullOrEmpty(runningScope) || targetContext == null) return;
|
if (runningScope == "default" || string.IsNullOrEmpty(runningScope) || targetContext == null) return;
|
||||||
|
CurrentConfig.CurrentADPFile = "新建ADP文件";
|
||||||
// 💡 2. 严格对快照隔离的 Context 数据进行清理,不影响其他工位
|
// 💡 2. 严格对快照隔离的 Context 数据进行清理,不影响其他工位
|
||||||
targetContext.CurrentFilePath = null;
|
targetContext.CurrentFilePath = null;
|
||||||
targetContext.Program.Parameters.Clear();
|
targetContext.Program.Parameters.Clear();
|
||||||
@@ -631,7 +631,7 @@ namespace ADP.ViewModels
|
|||||||
LoggerHelper.WarnWithNotify(runningScope, $"文件格式不正确或为空: {filePath}");
|
LoggerHelper.WarnWithNotify(runningScope, $"文件格式不正确或为空: {filePath}");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
CurrentConfig.CurrentADPFile = filePath;
|
||||||
// 💡 2. 严格赋值给快照锁定下的当前工位上下文,实现数据完全隔离
|
// 💡 2. 严格赋值给快照锁定下的当前工位上下文,实现数据完全隔离
|
||||||
targetContext.Program.Parameters = program.Parameters;
|
targetContext.Program.Parameters = program.Parameters;
|
||||||
targetContext.Program.StepCollection = program.StepCollection;
|
targetContext.Program.StepCollection = program.StepCollection;
|
||||||
@@ -691,6 +691,7 @@ namespace ADP.ViewModels
|
|||||||
if (saveFileDialog.ShowDialog() == true)
|
if (saveFileDialog.ShowDialog() == true)
|
||||||
{
|
{
|
||||||
// 💡 2. 将新路径安全写入快照工位
|
// 💡 2. 将新路径安全写入快照工位
|
||||||
|
CurrentConfig.CurrentADPFile = saveFileDialog.FileName;
|
||||||
targetContext.CurrentFilePath = saveFileDialog.FileName;
|
targetContext.CurrentFilePath = saveFileDialog.FileName;
|
||||||
|
|
||||||
// 💡 3. 调用你的底层文件保存逻辑,传入快照工位的 Program 模型
|
// 💡 3. 调用你的底层文件保存逻辑,传入快照工位的 Program 模型
|
||||||
@@ -850,7 +851,7 @@ namespace ADP.ViewModels
|
|||||||
break;
|
break;
|
||||||
case "测试报告导出界面":
|
case "测试报告导出界面":
|
||||||
if (_globalInfo.CurrentScope != "default") return;
|
if (_globalInfo.CurrentScope != "default") return;
|
||||||
_regionManager.RequestNavigate("ShellViewManager", "CurveRecallView");
|
_regionManager.RequestNavigate("ShellViewManager", "ExportView");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,11 +16,14 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
|
|
||||||
using UIShare.GlobalVariable;
|
using UIShare.GlobalVariable;
|
||||||
using UIShare.UIViewModel;
|
using UIShare.UIViewModel;
|
||||||
using UIShare.ViewModelBase;
|
using UIShare.ViewModelBase;
|
||||||
|
|
||||||
namespace CurveModule.ViewModels
|
namespace CurveModule.ViewModels
|
||||||
|
|
||||||
|
|
||||||
{
|
{
|
||||||
public class CurveRecallViewModel : NavigateViewModelBase, IRegionMemberLifetime, IDisposable
|
public class CurveRecallViewModel : NavigateViewModelBase, IRegionMemberLifetime, IDisposable
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using Logger;
|
using Logger;
|
||||||
using MahApps.Metro.Controls;
|
using MahApps.Metro.Controls;
|
||||||
|
using Model;
|
||||||
using Model.Entity;
|
using Model.Entity;
|
||||||
using Model.Models;
|
using Model.Models;
|
||||||
using NLog.Targets;
|
using NLog.Targets;
|
||||||
@@ -26,24 +27,46 @@ namespace ExportModule.ViewModels
|
|||||||
{
|
{
|
||||||
#region 属性
|
#region 属性
|
||||||
public bool KeepAlive => true;
|
public bool KeepAlive => true;
|
||||||
|
|
||||||
|
private ObservableCollection<TestReportModel> _testReportModelList = new();
|
||||||
|
|
||||||
|
public ObservableCollection<TestReportModel> TestReportModelList
|
||||||
|
{
|
||||||
|
get { return _testReportModelList; }
|
||||||
|
set { SetProperty(ref _testReportModelList, value); }
|
||||||
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 命令
|
#region 命令
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
public ICommand LoadedCommand { get; set; }
|
||||||
#region 私有字段
|
#region 私有字段
|
||||||
|
ITestReportService _testReportService { get; set; }
|
||||||
#endregion
|
#endregion
|
||||||
public ExportViewModel(IContainerProvider containerProvider) : base(containerProvider)
|
public ExportViewModel(IContainerProvider containerProvider) : base(containerProvider)
|
||||||
{
|
{
|
||||||
|
_testReportService = containerProvider.Resolve<ITestReportService>();
|
||||||
|
LoadedCommand = new AsyncDelegateCommand(OnLoad);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#region 命令处理
|
#region 命令处理
|
||||||
|
private async Task OnLoad()
|
||||||
|
{
|
||||||
|
var result=await _testReportService.GetFilterList();
|
||||||
|
if (result.IsSuccess)
|
||||||
|
{
|
||||||
|
IList<TestReportModel> reportList = result.Data;
|
||||||
|
TestReportModelList = new ObservableCollection<TestReportModel>(reportList);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
TestReportModelList = new();
|
||||||
|
}
|
||||||
|
}
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
#region 辅助方法
|
#region 辅助方法
|
||||||
|
|||||||
@@ -3,11 +3,17 @@
|
|||||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||||
|
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
xmlns:prism="http://prismlibrary.com/"
|
xmlns:prism="http://prismlibrary.com/"
|
||||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||||
prism:ViewModelLocator.AutoWireViewModel="True"
|
prism:ViewModelLocator.AutoWireViewModel="True"
|
||||||
d:DesignHeight="1080" d:DesignWidth="1920">
|
d:DesignHeight="1080" d:DesignWidth="1920">
|
||||||
|
<i:Interaction.Triggers>
|
||||||
|
<i:EventTrigger EventName="Loaded">
|
||||||
|
<i:InvokeCommandAction Command="{Binding LoadedCommand}"/>
|
||||||
|
</i:EventTrigger>
|
||||||
|
</i:Interaction.Triggers>
|
||||||
<Grid>
|
<Grid>
|
||||||
|
|
||||||
</Grid>
|
</Grid>
|
||||||
|
|||||||
@@ -266,6 +266,7 @@ namespace MainModule.ViewModels
|
|||||||
if(_systemConfig.DefaultProgramFilePath != null&&File.Exists(_systemConfig.DefaultProgramFilePath))
|
if(_systemConfig.DefaultProgramFilePath != null&&File.Exists(_systemConfig.DefaultProgramFilePath))
|
||||||
{
|
{
|
||||||
var filePath = _systemConfig.DefaultProgramFilePath;
|
var filePath = _systemConfig.DefaultProgramFilePath;
|
||||||
|
_systemConfig.CurrentADPFile= _systemConfig.DefaultProgramFilePath;
|
||||||
// 读取 JSON 文件
|
// 读取 JSON 文件
|
||||||
string json = File.ReadAllText(filePath);
|
string json = File.ReadAllText(filePath);
|
||||||
|
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ namespace Model.Entity
|
|||||||
/// <summary>作用域/台架名称</summary>
|
/// <summary>作用域/台架名称</summary>
|
||||||
[SugarColumn(ColumnName = "Scope", ColumnDescription = "台架名称")]
|
[SugarColumn(ColumnName = "Scope", ColumnDescription = "台架名称")]
|
||||||
public string Scope { get; set; } = string.Empty;
|
public string Scope { get; set; } = string.Empty;
|
||||||
|
/// <summary>测试项名称(当前ADP文件路径)</summary>
|
||||||
|
[SugarColumn(ColumnName = "FileName", ColumnDescription = "测试项名称")]
|
||||||
|
public string FileName { get; set; } = string.Empty;
|
||||||
|
|
||||||
/// <summary>步骤序号</summary>
|
/// <summary>步骤序号</summary>
|
||||||
[SugarColumn(ColumnName = "StepIndex")]
|
[SugarColumn(ColumnName = "StepIndex")]
|
||||||
|
|||||||
17
Model/Models/TestReportModel.cs
Normal file
17
Model/Models/TestReportModel.cs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Model.Models
|
||||||
|
{
|
||||||
|
public class TestReportModel
|
||||||
|
{
|
||||||
|
public Guid TestRoundId { get; set; }
|
||||||
|
public string Scope { get; set; }
|
||||||
|
public DateTime StartTime { get; set; }
|
||||||
|
public DateTime EndTime { get; set; }
|
||||||
|
public string FileName { get; set; }
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -64,10 +64,15 @@ namespace MonitorModule.ViewModels
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>查询日期(null = 全部日期)</summary>
|
/// <summary>查询日期(null = 全部日期)</summary>
|
||||||
public DateTime? SelectedDate
|
public DateTime? SelectedStartDate
|
||||||
{
|
{
|
||||||
get => _selectedDate;
|
get => _selectedStartDate;
|
||||||
set => SetProperty(ref _selectedDate, value);
|
set => SetProperty(ref _selectedStartDate, value);
|
||||||
|
}
|
||||||
|
public DateTime? SelectedEndDate
|
||||||
|
{
|
||||||
|
get => _selectedEndDate;
|
||||||
|
set => SetProperty(ref _selectedEndDate, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataTable ResultTable
|
public DataTable ResultTable
|
||||||
@@ -142,7 +147,8 @@ namespace MonitorModule.ViewModels
|
|||||||
private string? _selectedMonitorName;
|
private string? _selectedMonitorName;
|
||||||
private ObservableCollection<string> _scopeNames = new(new[] { "全部", "TestCell1", "TestCell2", "TestCell3", "TestCell4", "TestCell5", "TestCell6", "TestCell7", "TestCell8" });
|
private ObservableCollection<string> _scopeNames = new(new[] { "全部", "TestCell1", "TestCell2", "TestCell3", "TestCell4", "TestCell5", "TestCell6", "TestCell7", "TestCell8" });
|
||||||
private string? _selectedScope = "全部";
|
private string? _selectedScope = "全部";
|
||||||
private DateTime? _selectedDate;
|
private DateTime? _selectedStartDate;
|
||||||
|
private DateTime? _selectedEndDate;
|
||||||
private DataTable _resultTable = new();
|
private DataTable _resultTable = new();
|
||||||
private string _statusMessage = "未连接";
|
private string _statusMessage = "未连接";
|
||||||
private int _pageIndex = 1;
|
private int _pageIndex = 1;
|
||||||
@@ -257,7 +263,8 @@ namespace MonitorModule.ViewModels
|
|||||||
{
|
{
|
||||||
SelectedMonitorName = null;
|
SelectedMonitorName = null;
|
||||||
SelectedScope = "全部";
|
SelectedScope = "全部";
|
||||||
SelectedDate = null;
|
SelectedStartDate = null;
|
||||||
|
SelectedEndDate = null;
|
||||||
PageIndex = 1;
|
PageIndex = 1;
|
||||||
Query();
|
Query();
|
||||||
}
|
}
|
||||||
@@ -274,8 +281,8 @@ namespace MonitorModule.ViewModels
|
|||||||
var db = SqlSugarContext.DbContext;
|
var db = SqlSugarContext.DbContext;
|
||||||
|
|
||||||
// 预计算日期范围,避免在表达式树中访问可空属性
|
// 预计算日期范围,避免在表达式树中访问可空属性
|
||||||
DateTime? dateStart = SelectedDate?.Date;
|
DateTime? dateStart = SelectedStartDate?.Date;
|
||||||
DateTime? dateEnd = dateStart?.AddDays(1);
|
DateTime? dateEnd = SelectedEndDate?.Date.AddDays(1);
|
||||||
|
|
||||||
var query = db.Queryable<MonitorValueEntity>()
|
var query = db.Queryable<MonitorValueEntity>()
|
||||||
.WhereIF(!string.IsNullOrEmpty(SelectedMonitorName), x => x.MonitorName == SelectedMonitorName)
|
.WhereIF(!string.IsNullOrEmpty(SelectedMonitorName), x => x.MonitorName == SelectedMonitorName)
|
||||||
@@ -317,8 +324,8 @@ namespace MonitorModule.ViewModels
|
|||||||
{
|
{
|
||||||
var db = SqlSugarContext.DbContext;
|
var db = SqlSugarContext.DbContext;
|
||||||
|
|
||||||
DateTime? dateStart = SelectedDate?.Date;
|
DateTime? dateStart = SelectedStartDate?.Date;
|
||||||
DateTime? dateEnd = dateStart?.AddDays(1);
|
DateTime? dateEnd = SelectedEndDate?.Date.AddDays(1);
|
||||||
|
|
||||||
var query = db.Queryable<MonitorValueEntity>()
|
var query = db.Queryable<MonitorValueEntity>()
|
||||||
.WhereIF(!string.IsNullOrEmpty(SelectedMonitorName), x => x.MonitorName == SelectedMonitorName)
|
.WhereIF(!string.IsNullOrEmpty(SelectedMonitorName), x => x.MonitorName == SelectedMonitorName)
|
||||||
|
|||||||
@@ -52,6 +52,7 @@
|
|||||||
<ColumnDefinition Width="150"/>
|
<ColumnDefinition Width="150"/>
|
||||||
<ColumnDefinition Width="Auto"/>
|
<ColumnDefinition Width="Auto"/>
|
||||||
<ColumnDefinition Width="150"/>
|
<ColumnDefinition Width="150"/>
|
||||||
|
<ColumnDefinition Width="150"/>
|
||||||
<ColumnDefinition Width="Auto"/>
|
<ColumnDefinition Width="Auto"/>
|
||||||
<ColumnDefinition Width="Auto"/>
|
<ColumnDefinition Width="Auto"/>
|
||||||
<ColumnDefinition Width="Auto"/>
|
<ColumnDefinition Width="Auto"/>
|
||||||
@@ -88,20 +89,25 @@
|
|||||||
VerticalAlignment="Center"
|
VerticalAlignment="Center"
|
||||||
Margin="12,0,4,0"/>
|
Margin="12,0,4,0"/>
|
||||||
<DatePicker Grid.Column="5"
|
<DatePicker Grid.Column="5"
|
||||||
SelectedDate="{Binding SelectedDate}"
|
SelectedDate="{Binding SelectedStartDate}"
|
||||||
materialDesign:HintAssist.Hint="全部"
|
materialDesign:HintAssist.Hint="开始时间"
|
||||||
|
VerticalAlignment="Center"/>
|
||||||
|
<DatePicker Grid.Column="6"
|
||||||
|
Margin=" 5 0 0 0"
|
||||||
|
SelectedDate="{Binding SelectedEndDate}"
|
||||||
|
materialDesign:HintAssist.Hint="结束时间"
|
||||||
VerticalAlignment="Center"/>
|
VerticalAlignment="Center"/>
|
||||||
|
|
||||||
<!-- 按钮 -->
|
<!-- 按钮 -->
|
||||||
<Button Grid.Column="6"
|
<Button Grid.Column="7"
|
||||||
Content="查询"
|
Content="查询"
|
||||||
Command="{Binding QueryCommand}"
|
Command="{Binding QueryCommand}"
|
||||||
Padding="12,4" Margin="12,0,0,0"/>
|
Padding="12,4" Margin="12,0,0,0"/>
|
||||||
<Button Grid.Column="7"
|
<Button Grid.Column="8"
|
||||||
Content="清除"
|
Content="清除"
|
||||||
Command="{Binding ClearFilterCommand}"
|
Command="{Binding ClearFilterCommand}"
|
||||||
Padding="12,4" Margin="6,0,0,0"/>
|
Padding="12,4" Margin="6,0,0,0"/>
|
||||||
<Button Grid.Column="8"
|
<Button Grid.Column="9"
|
||||||
Content="导出 CSV"
|
Content="导出 CSV"
|
||||||
Command="{Binding ExportCsvCommand}"
|
Command="{Binding ExportCsvCommand}"
|
||||||
Padding="12,4" Margin="6,0,0,0"/>
|
Padding="12,4" Margin="6,0,0,0"/>
|
||||||
|
|||||||
69
Service/Implement/TestReportService.cs
Normal file
69
Service/Implement/TestReportService.cs
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
using Model;
|
||||||
|
using Model.Entity;
|
||||||
|
using Model.Models;
|
||||||
|
using ORM;
|
||||||
|
using Service.Interface;
|
||||||
|
using SqlSugar;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using static System.Formats.Asn1.AsnWriter;
|
||||||
|
|
||||||
|
namespace Service.Implement
|
||||||
|
{
|
||||||
|
public class TestReportService : BaseService<TestReportEntity>, ITestReportService
|
||||||
|
{
|
||||||
|
public TestReportService(SqlSugarRepository<TestReportEntity> repository) : base(repository)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据 TestRoundId 获取符合条件的测试步骤
|
||||||
|
/// </summary>
|
||||||
|
public async Task<Result<List<TestReportEntity>>> GetByTestRoundIdAsync(Guid testRoundId)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
var list = await _repository.Entities
|
||||||
|
.Where(x => x.TestRoundId == testRoundId)
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
return Result<List<TestReportEntity>>.Success(list);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Result<List<TestReportEntity>>.Error("根据 TestRoundId 查询数据失败", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据 TestRoundId 分组,获取唯一记录并按分组统计最大与最小时间
|
||||||
|
/// </summary>
|
||||||
|
public async Task<Result<IList<TestReportModel>>> GetFilterList()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
// 使用 SqlSugar 的 GroupBy 查询,聚合最大/最小时间
|
||||||
|
// 推荐采用这种按组投影的方式,将分组计算交由数据库处理,性能最佳
|
||||||
|
var list = await _repository.Context.Queryable<TestReportEntity>()
|
||||||
|
.GroupBy(x => x.TestRoundId)
|
||||||
|
.Select(x => new TestReportModel
|
||||||
|
{
|
||||||
|
TestRoundId = x.TestRoundId,
|
||||||
|
StartTime = SqlFunc.AggregateMin(x.CreateTime),
|
||||||
|
EndTime = SqlFunc.AggregateMax(x.CreateTime),
|
||||||
|
Scope=x.Scope,
|
||||||
|
FileName = x.FileName,
|
||||||
|
})
|
||||||
|
.ToListAsync();
|
||||||
|
|
||||||
|
return Result<IList<TestReportModel>>.Success(list);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
return Result<IList<TestReportModel>>.Error("获取分组过滤列表失败", ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
26
Service/Interface/ITestReportService.cs
Normal file
26
Service/Interface/ITestReportService.cs
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
using Model;
|
||||||
|
using Model.Entity;
|
||||||
|
using Model.Models;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Service.Interface
|
||||||
|
{
|
||||||
|
public interface ITestReportService:IBaseService<TestReportEntity>
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 根据TestRoundId获符合的测试步骤
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="TestRoundId">TestRoundId</param>
|
||||||
|
/// <returns>返回符合的TestReportEntity列表</returns>
|
||||||
|
Task<Result<List<TestReportEntity>>> GetByTestRoundIdAsync(Guid TestRoundId);
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 根据 TestRoundId 分组,获取唯一记录并按分组统计最大与最小时间
|
||||||
|
/// </summary>
|
||||||
|
Task<Result<IList<TestReportModel>>> GetFilterList();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -402,11 +402,11 @@
|
|||||||
<Border Background="White"
|
<Border Background="White"
|
||||||
BorderBrush="#E0E0E0" BorderThickness="1"
|
BorderBrush="#E0E0E0" BorderThickness="1"
|
||||||
CornerRadius="4" Padding="14">
|
CornerRadius="4" Padding="14">
|
||||||
<StackPanel>
|
<!--<StackPanel>
|
||||||
<TextBlock Text="高级设置" FontWeight="Bold" FontSize="14" Margin="0,0,0,10"/>
|
<TextBlock Text="高级设置" FontWeight="Bold" FontSize="14" Margin="0,0,0,10"/>
|
||||||
<TextBlock Foreground="#888" FontSize="12" TextWrapping="Wrap"
|
<TextBlock Foreground="#888" FontSize="12" TextWrapping="Wrap"
|
||||||
Text="超时、重试、缓存策略等高级选项后续在此扩展。"/>
|
Text="超时、重试、缓存策略等高级选项后续在此扩展。"/>
|
||||||
</StackPanel>
|
</StackPanel>-->
|
||||||
</Border>
|
</Border>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
</ScrollViewer>
|
</ScrollViewer>
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ using Common.Tools;
|
|||||||
using Logger;
|
using Logger;
|
||||||
using MaterialDesignThemes.Wpf;
|
using MaterialDesignThemes.Wpf;
|
||||||
using Model.Entity;
|
using Model.Entity;
|
||||||
using ORM;
|
using Service.Interface;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections;
|
using System.Collections;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
@@ -28,6 +28,7 @@ namespace UIShare
|
|||||||
//private Devices _devices;
|
//private Devices _devices;
|
||||||
private IContainerProvider containerProvider;
|
private IContainerProvider containerProvider;
|
||||||
private IEventAggregator _eventAggregator;
|
private IEventAggregator _eventAggregator;
|
||||||
|
private ITestReportService _testReportService;
|
||||||
|
|
||||||
private readonly Dictionary<Guid, ParameterVM> tmpParameters = [];
|
private readonly Dictionary<Guid, ParameterVM> tmpParameters = [];
|
||||||
|
|
||||||
@@ -45,12 +46,13 @@ namespace UIShare
|
|||||||
private volatile bool _disposed = false;
|
private volatile bool _disposed = false;
|
||||||
|
|
||||||
public Guid TestRoundID;
|
public Guid TestRoundID;
|
||||||
public StepRunning(ScopedContext ScopedContext, SystemConfig systemConfig,IEventAggregator eventAggregator, DeviceManager deviceManager)
|
public StepRunning(ScopedContext ScopedContext, SystemConfig systemConfig,IEventAggregator eventAggregator, DeviceManager deviceManager, ITestReportService testReportService)
|
||||||
{
|
{
|
||||||
_scopedContext = ScopedContext;
|
_scopedContext = ScopedContext;
|
||||||
_systemConfig = systemConfig;
|
_systemConfig = systemConfig;
|
||||||
_eventAggregator = eventAggregator;
|
_eventAggregator = eventAggregator;
|
||||||
_deviceManager= deviceManager;
|
_deviceManager= deviceManager;
|
||||||
|
_testReportService = testReportService;
|
||||||
//_devices = containerProvider.Resolve<Devices>();
|
//_devices = containerProvider.Resolve<Devices>();
|
||||||
}
|
}
|
||||||
public async Task<bool> ExecuteErrorSteps(ProgramVM program, int depth = 0, CancellationToken cancellationToken = default)
|
public async Task<bool> ExecuteErrorSteps(ProgramVM program, int depth = 0, CancellationToken cancellationToken = default)
|
||||||
@@ -116,7 +118,7 @@ namespace UIShare
|
|||||||
step.CurrentLoopCount = context.LoopCount;
|
step.CurrentLoopCount = context.LoopCount;
|
||||||
LoggerHelper.InfoWithNotify(_systemConfig.Title, $"循环开始,共{context.LoopCount}次", depth);
|
LoggerHelper.InfoWithNotify(_systemConfig.Title, $"循环开始,共{context.LoopCount}次", depth);
|
||||||
index++;
|
index++;
|
||||||
SaveStepRecord(step, depth, true);
|
await SaveStepRecordAsync(step, depth, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理循环结束
|
// 处理循环结束
|
||||||
@@ -127,7 +129,7 @@ namespace UIShare
|
|||||||
LoggerHelper.ErrorWithNotify(_systemConfig.Title, "未匹配的循环结束指令", depth: depth);
|
LoggerHelper.ErrorWithNotify(_systemConfig.Title, "未匹配的循环结束指令", depth: depth);
|
||||||
step.Result = 2;
|
step.Result = 2;
|
||||||
index++;
|
index++;
|
||||||
SaveStepRecord(step, depth, true);
|
await SaveStepRecordAsync(step, depth, true);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -142,7 +144,7 @@ namespace UIShare
|
|||||||
// 继续循环:跳转到循环开始后的第一条指令
|
// 继续循环:跳转到循环开始后的第一条指令
|
||||||
index = context.StartIndex + 1;
|
index = context.StartIndex + 1;
|
||||||
LoggerHelper.InfoWithNotify(_systemConfig.Title, $"循环第{context.CurrentLoop}次结束,跳回开始,剩余{context.LoopCount - context.CurrentLoop}次", depth);
|
LoggerHelper.InfoWithNotify(_systemConfig.Title, $"循环第{context.CurrentLoop}次结束,跳回开始,剩余{context.LoopCount - context.CurrentLoop}次", depth);
|
||||||
SaveStepRecord(step, depth, true);
|
await SaveStepRecordAsync(step, depth, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -159,7 +161,7 @@ namespace UIShare
|
|||||||
program.ErrorStepCollection.First(x => x.ID == step.LoopStartStepId).Result = 1;
|
program.ErrorStepCollection.First(x => x.ID == step.LoopStartStepId).Result = 1;
|
||||||
loopStopwatchStack.Pop();
|
loopStopwatchStack.Pop();
|
||||||
}
|
}
|
||||||
SaveStepRecord(step, depth, true);
|
await SaveStepRecordAsync(step, depth, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -218,7 +220,7 @@ namespace UIShare
|
|||||||
stepStopwatch.Stop();
|
stepStopwatch.Stop();
|
||||||
step.RunTime = (int)stepStopwatch.ElapsedMilliseconds;
|
step.RunTime = (int)stepStopwatch.ElapsedMilliseconds;
|
||||||
}
|
}
|
||||||
SaveStepRecord(step, depth, true);
|
await SaveStepRecordAsync(step, depth, true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -291,7 +293,7 @@ namespace UIShare
|
|||||||
step.CurrentLoopCount = context.LoopCount;
|
step.CurrentLoopCount = context.LoopCount;
|
||||||
LoggerHelper.InfoWithNotify(_systemConfig.Title, $"循环开始({step.Name}),共{context.LoopCount}次", depth);
|
LoggerHelper.InfoWithNotify(_systemConfig.Title, $"循环开始({step.Name}),共{context.LoopCount}次", depth);
|
||||||
index++;
|
index++;
|
||||||
SaveStepRecord(step, depth, false);
|
await SaveStepRecordAsync(step, depth, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 处理循环结束
|
// 处理循环结束
|
||||||
@@ -302,7 +304,7 @@ namespace UIShare
|
|||||||
LoggerHelper.ErrorWithNotify(_systemConfig.Title, "未匹配的循环结束指令", depth:depth);
|
LoggerHelper.ErrorWithNotify(_systemConfig.Title, "未匹配的循环结束指令", depth:depth);
|
||||||
step.Result = 2;
|
step.Result = 2;
|
||||||
index++;
|
index++;
|
||||||
SaveStepRecord(step, depth, false);
|
await SaveStepRecordAsync(step, depth, false);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -317,7 +319,7 @@ namespace UIShare
|
|||||||
// 继续循环:跳转到循环开始后的第一条指令
|
// 继续循环:跳转到循环开始后的第一条指令
|
||||||
index = context.StartIndex + 1;
|
index = context.StartIndex + 1;
|
||||||
LoggerHelper.InfoWithNotify(_systemConfig.Title, $"循环第{context.CurrentLoop}次结束,跳回开始,剩余{context.LoopCount - context.CurrentLoop}次", depth);
|
LoggerHelper.InfoWithNotify(_systemConfig.Title, $"循环第{context.CurrentLoop}次结束,跳回开始,剩余{context.LoopCount - context.CurrentLoop}次", depth);
|
||||||
SaveStepRecord(step, depth, false);
|
await SaveStepRecordAsync(step, depth, false);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -334,7 +336,7 @@ namespace UIShare
|
|||||||
program.StepCollection.First(x => x.ID == step.LoopStartStepId).Result = 1;
|
program.StepCollection.First(x => x.ID == step.LoopStartStepId).Result = 1;
|
||||||
loopStopwatchStack.Pop();
|
loopStopwatchStack.Pop();
|
||||||
}
|
}
|
||||||
SaveStepRecord(step, depth, false);
|
await SaveStepRecordAsync(step, depth, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -400,7 +402,7 @@ namespace UIShare
|
|||||||
_scopedContext.SingleStep = false;
|
_scopedContext.SingleStep = false;
|
||||||
_eventAggregator.GetEvent<RunSingalCompletedEvent>().Publish("Play");
|
_eventAggregator.GetEvent<RunSingalCompletedEvent>().Publish("Play");
|
||||||
}
|
}
|
||||||
SaveStepRecord(step, depth, false);
|
await SaveStepRecordAsync(step, depth, false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -685,7 +687,7 @@ namespace UIShare
|
|||||||
/// 将单个步骤的执行结果保存到数据库(测试报告)。
|
/// 将单个步骤的执行结果保存到数据库(测试报告)。
|
||||||
/// 同一次运行的所有步骤共享 TestRoundID,导出时按此 Guid 查询。
|
/// 同一次运行的所有步骤共享 TestRoundID,导出时按此 Guid 查询。
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private void SaveStepRecord(StepVM step, int depth, bool isErrorStep)
|
private async Task SaveStepRecordAsync(StepVM step, int depth, bool isErrorStep)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -702,6 +704,7 @@ namespace UIShare
|
|||||||
{
|
{
|
||||||
TestRoundId = TestRoundID,
|
TestRoundId = TestRoundID,
|
||||||
Scope = _systemConfig.Title,
|
Scope = _systemConfig.Title,
|
||||||
|
FileName = _systemConfig.CurrentADPFile ?? "",
|
||||||
StepIndex = step.Index,
|
StepIndex = step.Index,
|
||||||
StepName = step.Name ?? "",
|
StepName = step.Name ?? "",
|
||||||
StepType = step.StepType ?? "普通步骤",
|
StepType = step.StepType ?? "普通步骤",
|
||||||
@@ -723,7 +726,11 @@ namespace UIShare
|
|||||||
CreateTime = DateTime.Now
|
CreateTime = DateTime.Now
|
||||||
};
|
};
|
||||||
|
|
||||||
SqlSugarContext.DbContext.Insertable(entity).ExecuteCommand();
|
var result = await _testReportService.InsertAsync(entity);
|
||||||
|
if (!result.IsSuccess)
|
||||||
|
{
|
||||||
|
LoggerHelper.Error($"保存步骤记录失败 [{step.Index}]: {result.Msg}");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ namespace UIShare.GlobalVariable
|
|||||||
public string TSMasterName { get; set; } = "ADP测试上位机";
|
public string TSMasterName { get; set; } = "ADP测试上位机";
|
||||||
public string SubProgramFilePath { get; set; } = @"D:\ADP\子程序\";
|
public string SubProgramFilePath { get; set; } = @"D:\ADP\子程序\";
|
||||||
public string Title { get; set; } = string.Empty;
|
public string Title { get; set; } = string.Empty;
|
||||||
|
public string CurrentADPFile { get; set; }
|
||||||
public int PerformanceLevel { get; set; } = 50;
|
public int PerformanceLevel { get; set; } = 50;
|
||||||
public string DefaultProgramFilePath { get; set; } = "";
|
public string DefaultProgramFilePath { get; set; } = "";
|
||||||
public string DefaultBLFFilePath { get; set; } = "";
|
public string DefaultBLFFilePath { get; set; } = "";
|
||||||
|
|||||||
@@ -22,6 +22,7 @@
|
|||||||
<ProjectReference Include="..\DeviceCommand\DeviceCommand.csproj" />
|
<ProjectReference Include="..\DeviceCommand\DeviceCommand.csproj" />
|
||||||
<ProjectReference Include="..\Logger\Logger.csproj" />
|
<ProjectReference Include="..\Logger\Logger.csproj" />
|
||||||
<ProjectReference Include="..\ORM\ORM.csproj" />
|
<ProjectReference Include="..\ORM\ORM.csproj" />
|
||||||
|
<ProjectReference Include="..\Service\Service.csproj" />
|
||||||
<ProjectReference Include="..\ZLGUSBCANFD\ZLGUSBCANFD.csproj" />
|
<ProjectReference Include="..\ZLGUSBCANFD\ZLGUSBCANFD.csproj" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
</Project>
|
</Project>
|
||||||
|
|||||||
Reference in New Issue
Block a user