|
@@ -43,6 +43,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
private int testResult = 0; //测试结果
|
|
|
private long schId = 0; //方案ID
|
|
|
private long globalSchDetailId = 0; //测试方案明细ID
|
|
|
+ private long selctStartDetailId = 0; //当前选择的第一个方案明细id
|
|
|
private BizTestRecordDtlDto bizTestRecordDtlDto = new BizTestRecordDtlDto(); //测试方案明细表
|
|
|
private const string TestMode = "自动测试";
|
|
|
ManualResetEvent m = new ManualResetEvent(true); //实例化阻塞事件
|
|
@@ -114,7 +115,8 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
{
|
|
|
foreach (var item in getMsg)
|
|
|
{
|
|
|
- globalSchDetailId = item; //测试方案明细ID
|
|
|
+
|
|
|
+ selctStartDetailId= item;//测试方案明细ID
|
|
|
int id = Convert.ToInt32(item);
|
|
|
// 根据 测试方案明细主键ID 查找测试方案id 及方案名和设备名
|
|
|
GetDetailInfo(id);
|
|
@@ -256,7 +258,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
}
|
|
|
testStatus = 99;//测试状态赋值为99
|
|
|
//状态status 没有赋值
|
|
|
-
|
|
|
+
|
|
|
//记录记录明细表中是否有这个方案明细ID的记录,没有则添加,有则更新记录状态
|
|
|
var findRecordDetail = _iBizTestRecordDtlService.FindRecordDetailBySchDtlID(schDetailId);
|
|
|
if (findRecordDetail == null)
|
|
@@ -305,31 +307,35 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
/// <returns></returns>
|
|
|
private int GetTestResult()
|
|
|
{
|
|
|
+ //前置项
|
|
|
+ int beforeResult = 0;
|
|
|
+ int inResult = 0;
|
|
|
+ int outResult = 0;
|
|
|
if (SelectLogic == "OR")
|
|
|
{
|
|
|
var find = BeforeConList.FirstOrDefault(x => x.TestResult == "合格");
|
|
|
if (find != null)
|
|
|
{
|
|
|
- return 1;
|
|
|
+ beforeResult = 1;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
- if (SelectLogic == "AND"|| SelectLogic == "ONLY")
|
|
|
+ if (SelectLogic == "AND" || SelectLogic == "ONLY")
|
|
|
{
|
|
|
var find = BeforeConList.FirstOrDefault(x => x.TestResult == "不合格");
|
|
|
if (find != null)
|
|
|
{
|
|
|
- return 0;
|
|
|
+ beforeResult = 0;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
|
{
|
|
|
if (SelectLogic == "NULL")
|
|
|
{
|
|
|
-
|
|
|
- return 1;
|
|
|
-
|
|
|
+
|
|
|
+ beforeResult = 1;
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -340,7 +346,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
var find = InConList.FirstOrDefault(x => x.TestResult == "合格");
|
|
|
if (find != null)
|
|
|
{
|
|
|
- return 1;
|
|
|
+ inResult = 1;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
@@ -350,7 +356,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
var find = InConList.FirstOrDefault(x => x.TestResult == "不合格");
|
|
|
if (find != null)
|
|
|
{
|
|
|
- return 0;
|
|
|
+ inResult = 0;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
@@ -358,7 +364,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
if (InSelectLogic == "NULL")
|
|
|
{
|
|
|
|
|
|
- return 1;
|
|
|
+ inResult = 1;
|
|
|
|
|
|
}
|
|
|
}
|
|
@@ -370,7 +376,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
var find = OutConList.FirstOrDefault(x => x.TestResult == "合格");
|
|
|
if (find != null)
|
|
|
{
|
|
|
- return 1;
|
|
|
+ outResult = 1;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
@@ -380,7 +386,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
var find = OutConList.FirstOrDefault(x => x.TestResult == "不合格");
|
|
|
if (find != null)
|
|
|
{
|
|
|
- return 0;
|
|
|
+ outResult = 0;
|
|
|
}
|
|
|
}
|
|
|
else
|
|
@@ -388,13 +394,20 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
if (OutSelectLogic == "NULL")
|
|
|
{
|
|
|
|
|
|
- return 1;
|
|
|
+ outResult = 1;
|
|
|
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
-
|
|
|
- return 1;
|
|
|
+ if (beforeResult == 1 && inResult == 1 && outResult == 1)
|
|
|
+ {
|
|
|
+ return 1;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ return 0;
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
/// <summary>
|
|
|
/// 更新测试记录
|
|
@@ -406,123 +419,61 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
|
|
|
_iBizTestRecordDtlService.Edit(testRecordDtl);
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+
|
|
|
/// <summary>
|
|
|
- /// 下一步
|
|
|
+ /// 开始检测
|
|
|
/// </summary>
|
|
|
- private void Next( )
|
|
|
+ /// <param name="obj"></param>
|
|
|
+ private async void Start()
|
|
|
{
|
|
|
- StepIndex = 0;
|
|
|
+
|
|
|
///查找方案下的所有方案明细,并排序,
|
|
|
var basicSchDtls = _basicPlcTestSchemeDtlService.FindAllBySchId(schId)?.OrderBy(x => x.scheme_dtl_id);
|
|
|
foreach (var item in basicSchDtls)
|
|
|
{
|
|
|
- //在测试结果明细中查看
|
|
|
long schDetailId = item.scheme_dtl_id;
|
|
|
- if (schDetailId > globalSchDetailId)
|
|
|
+ //编号小于当前选择的就不测试了,
|
|
|
+ if(schDetailId < selctStartDetailId)
|
|
|
{
|
|
|
- globalSchDetailId = schDetailId;
|
|
|
- int id = Convert.ToInt32(schDetailId);
|
|
|
- //界面显示
|
|
|
- GetDetailInfo(id);
|
|
|
- //记录记录明细表中是否有这个方案明细ID的记录,没有则添加,有则更新记录状态
|
|
|
- break;
|
|
|
+ continue;
|
|
|
}
|
|
|
-
|
|
|
- }
|
|
|
- long maxDtlId = basicSchDtls.Select(x => x.scheme_dtl_id).Max();
|
|
|
- if (globalSchDetailId== maxDtlId)
|
|
|
- {
|
|
|
- MessageBox.Show("已是此测试方案最后一个测试项!", "确认", MessageBoxButton.OK, MessageBoxImage.Information);
|
|
|
- }
|
|
|
- }
|
|
|
|
|
|
- private void Previous(object obj)
|
|
|
- {
|
|
|
- StepIndex = 0;
|
|
|
- ///查找方案下的所有方案明细,并排序,
|
|
|
- var basicSchDtls = _basicPlcTestSchemeDtlService.FindAllBySchId(schId)?.OrderBy(x => x.scheme_dtl_id);
|
|
|
- foreach (var item in basicSchDtls)
|
|
|
- {
|
|
|
- //在测试结果明细中查看
|
|
|
- long schDetailId = item.scheme_dtl_id;
|
|
|
- if (schDetailId < globalSchDetailId)
|
|
|
- {
|
|
|
- globalSchDetailId = schDetailId;
|
|
|
- int id = Convert.ToInt32(schDetailId);
|
|
|
+ globalSchDetailId = schDetailId;
|
|
|
+ await ExecTest();
|
|
|
+ //更新下一个界面显示
|
|
|
+ int id = Convert.ToInt32(globalSchDetailId);
|
|
|
//界面显示
|
|
|
- GetDetailInfo(id);
|
|
|
- //记录记录明细表中是否有这个方案明细ID的记录,没有则添加,有则更新记录状态
|
|
|
-
|
|
|
- break;
|
|
|
- }
|
|
|
- else
|
|
|
+ System.Windows.Application.Current.Dispatcher.Invoke((delegate
|
|
|
+ {
|
|
|
+ GetDetailInfo(id);
|
|
|
+ }));
|
|
|
+ //最后一项必须要测试
|
|
|
+ if (globalSchDetailId == basicSchDtls.Max(x => x.scheme_dtl_id))
|
|
|
{
|
|
|
- MessageBox.Show("已是此测试方案第一个测试项!", "确认", MessageBoxButton.OK, MessageBoxImage.Information);
|
|
|
+ ExecTest();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
}
|
|
|
- }
|
|
|
- /// <summary>
|
|
|
- /// 开始检测
|
|
|
- /// </summary>
|
|
|
- /// <param name="obj"></param>
|
|
|
- private async void Start()
|
|
|
- {
|
|
|
- CancellationToken cancellationToken = tokensource.Token;
|
|
|
- await Task.Run(async() => //模拟耗时任务
|
|
|
- {
|
|
|
- if (cancellationToken.IsCancellationRequested)
|
|
|
- {
|
|
|
- return;
|
|
|
- }
|
|
|
- m.WaitOne(); //当m等于true,才会往下执行,否则一直在此等待
|
|
|
-
|
|
|
- //开始时间
|
|
|
- startTime = DateTime.Now;
|
|
|
- //增加测试记录主表
|
|
|
- AddTestRecord();
|
|
|
-
|
|
|
- //前置项
|
|
|
- bool preBool = TestPreceditionMethod();
|
|
|
-
|
|
|
-
|
|
|
- //输入项
|
|
|
- bool isAction = TestActionMethod();
|
|
|
|
|
|
+ }
|
|
|
+ private async Task ExecTest()
|
|
|
+ { //开始时间
|
|
|
+ startTime = DateTime.Now;
|
|
|
+ //增加测试记录主表
|
|
|
+ AddTestRecord();
|
|
|
|
|
|
- //输出项
|
|
|
- bool isJudgeResult = await TestJudgementMethod();
|
|
|
- //下一项
|
|
|
- StepIndex = 0;
|
|
|
- ///查找方案下的所有方案明细,并排序,
|
|
|
- var basicSchDtls = _basicPlcTestSchemeDtlService.FindAllBySchId(schId)?.OrderBy(x => x.scheme_dtl_id);
|
|
|
- foreach (var item in basicSchDtls)
|
|
|
- {
|
|
|
- //在测试结果明细中查看
|
|
|
- long schDetailId = item.scheme_dtl_id;
|
|
|
- if (schDetailId > globalSchDetailId)
|
|
|
- {
|
|
|
- globalSchDetailId = schDetailId;
|
|
|
- int id = Convert.ToInt32(schDetailId);
|
|
|
- //界面显示
|
|
|
- System.Windows.Application.Current.Dispatcher.Invoke((delegate
|
|
|
- {
|
|
|
- GetDetailInfo(id);
|
|
|
- }));
|
|
|
-
|
|
|
- //递归调用
|
|
|
- Start();
|
|
|
- }
|
|
|
+ //前置项
|
|
|
+ bool preBool = TestPreceditionMethod();
|
|
|
|
|
|
- }
|
|
|
- }, cancellationToken);//绑定令牌到多线程
|
|
|
|
|
|
+ //输入项
|
|
|
+ bool isAction = TestActionMethod();
|
|
|
|
|
|
|
|
|
-
|
|
|
-
|
|
|
+ //输出项
|
|
|
+ bool isJudgeResult = await TestJudgementMethod();
|
|
|
+ //下一项
|
|
|
+ StepIndex = 0;
|
|
|
|
|
|
}
|
|
|
/// <summary>
|