Sfoglia il codice sorgente

新增测试记录

ltwork 1 anno fa
parent
commit
2394454988

+ 2 - 2
BlankApp1/BizService/BizTestRecordDtlService.cs

@@ -9,9 +9,9 @@ namespace BizService
 {
     public class BizTestRecordDtlService : BaseService<biz_test_record_dtl>, IBizTestRecordDtlService
     {
-        public biz_test_record_dtl FindRecordDetailBySchDtlID(long schDtlID)
+        public List<biz_test_record_dtl> FindRecordDetailBySchDtlID(long schDtlID)
         {
-            return base.GetFirst(x => x.scheme_dtl_id == schDtlID);
+            return base.GetList(x => x.scheme_dtl_id == schDtlID);
         }
 
         public List<biz_test_record_dtl> FindRecordDetailByRecordID(long recordId)

+ 1 - 1
BlankApp1/BizService/IBizTestRecordDtlService.cs

@@ -13,7 +13,7 @@ namespace BizService
      /// </summary>
      /// <param name="schemeId"></param>
      /// <returns></returns>
-        public biz_test_record_dtl FindRecordDetailBySchDtlID(long schDtlID);
+        public List<biz_test_record_dtl> FindRecordDetailBySchDtlID(long schDtlID);
 
 
         public List<biz_test_record_dtl> FindRecordDetailByRecordID(long recordId);

+ 2 - 1
BlankApp1/BlankApp1/App.xaml.cs

@@ -54,7 +54,7 @@ namespace BlankApp1
             containerRegistry.RegisterForNavigation<BaseConfigView, BaseConfigViewModel>();
        
             containerRegistry.RegisterForNavigation<TestOperView, TestOperViewModel>();
-            containerRegistry.RegisterForNavigation<QueryView, QueryViewModel>();
+       
             containerRegistry.RegisterForNavigation<TreeMenuView, TreeMenuViewModel>();
             containerRegistry.RegisterForNavigation<StatisticsView, StatisticsViewModel>();
             containerRegistry.RegisterForNavigation<LogView, LogViewModel>();
@@ -68,6 +68,7 @@ namespace BlankApp1
             containerRegistry.RegisterForNavigation<ProjectView, ProjectViewModel>();
             containerRegistry.RegisterForNavigation<DeviceTestView, DeviceTestViewModel>();
             containerRegistry.RegisterForNavigation<ResultQueryView, ResultQueryViewModel>();
+            containerRegistry.RegisterForNavigation<RetryTestView, RetryTestViewModel>();
             containerRegistry.RegisterDialog<AddOrEditSchView, AddOrEditSchViewModel>();
             containerRegistry.RegisterDialog<AddDetailView, AddDetailViewModel>();
             containerRegistry.RegisterDialog<AutoTestView, AutoTestViewModel>();

+ 0 - 616
BlankApp1/BlankApp1/ViewModels/BusinessManageViewModel/QueryViewModel.cs

@@ -1,616 +0,0 @@
-using AutoMapper;
-using BizService;
-using Microsoft.Extensions.Logging;
-using MiniExcelLibs;
-using Model.Dto;
-using Model.Entities;
-using NetTaste;
-using Newtonsoft.Json;
-using PLCTool.Pdf;
-using Prism.Commands;
-using Prism.Mvvm;
-using Prism.Services.Dialogs;
-using QuestPDF;
-using QuestPDF.Fluent;
-using QuestPDF.Helpers;
-using QuestPDF.Infrastructure;
-using QuestPDF.Previewer;
-using SqlSugar;
-using System;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.Linq;
-using System.Reflection.Metadata;
-using System.Text;
-using System.Threading.Tasks;
-using System.Windows;
-using WPFDevelopers.Controls.Runtimes.Shell32;
-using static System.Windows.Forms.VisualStyles.VisualStyleElement.ListView;
-
-namespace PLCTool.ViewModels.BusinessManageViewModel
-{
-    internal class QueryViewModel : BindableBase
-    {
-        private readonly IDialogService _dialog;
-        private readonly IOptionConfigService _optionConfigService;
-        private readonly IBasicPlcTestSchemeService _basicPlcTestSchemeService;
-        private readonly IBasicPlcTestSchemeDtlService _basicPlcTestSchemeDtlService;
-        private readonly IBizTestRecordDtlService _iBizTestRecordDtlService;
-        private readonly IBasicDeviceService _iBasicDeviceService;
-        private readonly ILogger _logger;
-        private readonly IMapper _mapper;
-        private readonly IMenuService _menuService;
-
-        private List<SchDtlWithResultModel> allConfigList = new List<SchDtlWithResultModel>();//所有方案
-        private List<SchDtlWithResultModel> conditionConfig = new List<SchDtlWithResultModel>();//符合条件的方案
-
-        private const int PageCount = 1; //每一页显示个数
-        public QueryViewModel(IDialogService dialog, IMenuService menuService, IOptionConfigService optionConfigService, IBasicPlcTestSchemeService basicPlcTestSchemeService, IBasicPlcTestSchemeDtlService basicPlcTestSchemeDtlService, IBizTestRecordDtlService iBizTestRecordDtlService, IBasicDeviceService iBasicDeviceService,IMapper mapper, ILogger logger)
-        {
-            _dialog = dialog;
-            _optionConfigService = optionConfigService;
-            _basicPlcTestSchemeService = basicPlcTestSchemeService;
-            _basicPlcTestSchemeDtlService = basicPlcTestSchemeDtlService;
-            _iBizTestRecordDtlService = iBizTestRecordDtlService;
-            _iBasicDeviceService = iBasicDeviceService;
-            _logger = logger;
-            _mapper = mapper;
-            _menuService = menuService;
-            QueryCommand = new DelegateCommand<object>(Query);
-            ResetCommand = new DelegateCommand<object>(Reset);
-            ExportCommand = new DelegateCommand<string>(Export);
-            OnLoadCommand = new DelegateCommand(OnLoad);
-            CheckDetailCommand = new DelegateCommand<object>(CheckDetail);
-            PdfReportCommand = new DelegateCommand<object>(CreatePdf);
-            GetConfigOption();
-          
-        }
-
-
-
-
-
-        #region 私有方法
-        /// <summary>
-        /// pdf报告相关信息
-        /// </summary>
-        /// <param name="schDtlId"></param>
-        /// <returns></returns>
-        private InvoiceModel GetReportPLCInfo(int schDtlId)
-        {
-            //测试方案明细主键ID
-        
-            InvoiceModel invoiceModel = new InvoiceModel();
-        
-            invoiceModel.ReportPLCModels = new List<ReportPLCModel>();
-
-            //根据 测试方案明细主键ID 查找测试方案id 及方案名和设备名
-            var findEntity = _basicPlcTestSchemeDtlService.Find(schDtlId);
-            var findresult = _mapper.Map<bas_plc_test_scheme_dtl, BasicPlcTestSchemeDtlDto>(findEntity);
-            if (findresult != null)
-            {
-                //根据方案id 在方案表中查找方案名 设备名
-                int schID = Convert.ToInt32(findresult.SchemeId);
-                var findSch = _basicPlcTestSchemeService.Find(schID);
-                if (findSch != null)
-                {
-                    invoiceModel.SchemeName = findSch.scheme_name;
-                    invoiceModel.DeviceName = findSch.devicekind_name;
-
-                }
-                //此测试方案下的所有测试项
-                var allResult = allConfigList.FindAll(X => X.SchemeName == findSch.scheme_name);
-                foreach (var each in allResult)
-                {
-                    long schDetailId = each.SchemeId;
-             
-                    //根据测试方案明细id查找结果
-                    var recordDetail = _iBizTestRecordDtlService.FindRecordDetailBySchDtlID(schDetailId);
-                    if (recordDetail != null)
-                    {       //前置项结果解析
-                        string preconStr = recordDetail.precondition_final?.ToString();
-                        if (!string.IsNullOrEmpty(preconStr))
-                        {
-                            JsonModel preconditionModel = JsonConvert.DeserializeObject<JsonModel>(preconStr);
-
-                            foreach (var detail in preconditionModel.DetailInfo)
-                            {
-
-                                invoiceModel.ReportPLCModels.Add(new ReportPLCModel()
-                                {
-                                    ItemName = each.ItemName,
-                                    ItemType = each.ItemType,
-                                    Type = "前置项",
-                                    JudgeType = preconditionModel.ItemType,
-                                    SelectLogic = preconditionModel.ItemLogical,
-                                    Detail = preconditionModel.Description,
-                                    Id = detail.Id,
-                                    PlcAddress = detail.PlcAddress,
-                                    PlcItem = detail.PlcItem,
-                                    PlcValue = detail.PlcValue,
-                                    Remark = detail.Remark,
-                                    TestTime = detail.TestTime,
-                                    RealValue = detail.RealValue,
-                                    TestResult = detail.TestResult,
-
-                                });
-                            }
-                        }
-
-                        //输入项解析
-                        string inStr = recordDetail.action_final?.ToString();
-                        if (!string.IsNullOrEmpty(inStr))
-                        {
-                            JsonModel inModel = JsonConvert.DeserializeObject<JsonModel>(inStr);
-
-                            foreach (var detail in inModel.DetailInfo)
-                            {
-                                invoiceModel.ReportPLCModels.Add(new ReportPLCModel()
-                                {
-                                    ItemName = each.ItemName,
-                                    ItemType = each.ItemType,
-                                    Type = "输入项",
-                                    JudgeType = inModel.ItemType,
-                                    SelectLogic = inModel.ItemLogical,
-                                    Detail = inModel.Description,
-                                    Id = detail.Id,
-                                    PlcAddress = detail.PlcAddress,
-                                    PlcItem = detail.PlcItem,
-                                    PlcValue = detail.PlcValue,
-                                    Remark = detail.Remark,
-                                    TestTime = detail.TestTime,
-                                    RealValue = detail.RealValue,
-                                    TestResult = detail.TestResult,
-
-                                });
-                            }
-                        }
-
-                        //输出项解析
-                        string outStr = recordDetail.judgement_result_final?.ToString();
-                        if (!string.IsNullOrEmpty(outStr))
-                        {
-                            JsonModel outModel = JsonConvert.DeserializeObject<JsonModel>(outStr);
-
-                            foreach (var detail in outModel.DetailInfo)
-                            {
-                                invoiceModel.ReportPLCModels.Add(new ReportPLCModel()
-                                {
-                                    ItemName = each.ItemName,
-                                    ItemType = each.ItemType,
-                                    Type = "结果项",
-                                    JudgeType = outModel.ItemType,
-                                    SelectLogic = outModel.ItemLogical,
-                                    Detail = outModel.Description,
-                                    Id = detail.Id,
-                                    PlcAddress = detail.PlcAddress,
-                                    PlcItem = detail.PlcItem,
-                                    PlcValue = detail.PlcValue,
-                                    Remark = detail.Remark,
-                                    TestTime = detail.TestTime,
-                                    RealValue = detail.RealValue,
-                                    TestResult = detail.TestResult,
-
-                                });
-                            }
-                        }
-                    }
-                }
-                //判断方案结果是否通过
-                var testCount = allConfigList.FindAll(X => X.SchemeName == findSch.scheme_name&&X.TestResult=="通过")?.Count;
-                if(testCount== allResult.Count)
-                {
-                    invoiceModel.FinalReuslt = "通过";
-                }
-                else
-                {
-                    invoiceModel.FinalReuslt = "不通过";
-                }
-
-            }
-            return invoiceModel;
-        }
-
-        /// <summary>
-        /// 生成pdf
-        /// </summary>
-        /// <param name="obj"></param>
-        public  void CreatePdf(object obj)
-        {
-            int id = Convert.ToInt32(obj);
-            try
-            {
-                Settings.License = LicenseType.Community;
-                var model = GetReportPLCInfo(id);
-                var document = new InvoiceDocument(model);
-                //pdf名称为轴编号+时间
-
-                //输出文件
-                using (System.Windows.Forms.SaveFileDialog saveFileDialog = new System.Windows.Forms.SaveFileDialog()
-                {
-                    //设置文件类型
-                    //书写规则例如:txt files(*.txt)|*.txt
-                    Filter = "pdf文件|*.pdf",
-                    //设置默认文件名(可以不设置)
-                    FileName = "报表" + string.Format("{0:yyyyMMddHHmm}", DateTime.Now),
-
-                    //获取或设置一个值,该值指示如果用户省略扩展名,文件对话框是否自动在文件名中添加扩展名。(可以不设置)
-                    AddExtension = true,
-
-                    //保存对话框是否记忆上次打开的目录
-                    RestoreDirectory = true
-                })
-                {
-
-
-                    //点了保存按钮进入
-                    if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
-                    {
-                            //获得文件路径
-                            string localFilePath = saveFileDialog.FileName.ToString();
-                            document.GeneratePdf(localFilePath);
-
-                    }
-
-                }
-              
-               
-            }
-            catch(Exception ex)
-            {
-                _logger.LogError(ex.ToString());
-            }
-
-
-
-          
-
-        }
-
-        private void CheckDetail(object obj)
-        {
-            //测试方案明细主键ID
-            long id = Convert.ToInt64(obj);
-            DialogParameters parm = new DialogParameters();
-            parm.Add("Key", id);
-            //弹出详情对话框
-            //弹出详情对话框
-            _dialog.ShowDialog("TestResultDetailView", parm, async callback =>
-            {
-                if (callback.Result == ButtonResult.OK)
-                {
-                    //更新表格,重新获取
-                    GetContent();
-                }
-
-            });
-        }
-
-
-
-
-        /// <summary>
-        /// 每次进入页面加载
-        /// </summary>
-        private void OnLoad()
-        {
-            GetContent();
-        }
-        private void Reset(object obj)
-        {
-            ScheduleName = string.Empty;
-            DeviceKindName = string.Empty;
-            TestName = string.Empty;
-            SelectTest = string.Empty;
-            StartTime = DateTime.MinValue;
-            EndTime = DateTime.MinValue;
-        }
-
-        private void Query(object obj)
-        {
-            if (StartTime > EndTime)
-            {
-                MessageBox.Show("起始时间大于结束时间,请重新输入", "确认", MessageBoxButton.OK, MessageBoxImage.Warning);
-                return;
-            }
-
-            conditionConfig = (from a in allConfigList
-                               where (EndTime == DateTime.MinValue ? true : (a.CreateTime < Convert.ToDateTime(EndTime)) && (Convert.ToDateTime(StartTime) < a.CreateTime))
-                                && (string.IsNullOrEmpty(ScheduleName) ? true : (a.SchemeName == ScheduleName))
-                                 && (string.IsNullOrEmpty(TestName) ? true : (a.ItemName == TestName))
-                                  && (string.IsNullOrEmpty(DeviceKindName) ? true : (a.DeviceKindName == DeviceKindName))
-                                    && (string.IsNullOrEmpty(SelectTest) ? true : (a.ItemType == SelectTest))
-                               select a).ToList();
-            //默认显示的第一页
-            conditionConfig = conditionConfig.OrderBy(x => x.SchemeName).ThenBy(x => x.SchemeId).ToList();
-            Getpage();
-            //BaseConfigList = new ObservableCollection<BasicPlcTestSchemeDto>(conditionConfig);
-        }
-        /// <summary>
-        /// 获取配置
-        /// </summary>
-        private void GetConfigOption()
-        {
-            var configList = _optionConfigService.QueryList();
-            var _optionConfigs = _mapper.Map<List<OptionConfig>, List<OptionConfigDto>>(configList);
-            var tests = _optionConfigs.FindAll(x => x.TypeID == 1);
-            TestKinds = new List<string>();
-            foreach (var test in tests)
-            {
-                TestKinds.Add(test.ContentOption);
-            }
-        }
-
-  
-  
-        /// <summary>
-        /// excel导出
-        /// </summary>
-        /// <param name="obj"></param>
-        private void Export(object obj)
-        {
-
-
-            using (System.Windows.Forms.SaveFileDialog saveFileDialog = new System.Windows.Forms.SaveFileDialog()
-            {
-                //设置文件类型
-                //书写规则例如:txt files(*.txt)|*.txt
-                Filter = "Excel files(*.xlsx)|*.xlsx|All files(*.*)|*.*",
-                //设置默认文件名(可以不设置)
-                FileName = "测试记录" + string.Format("{0:yyyyMMddHHmm}", DateTime.Now),
-
-                //获取或设置一个值,该值指示如果用户省略扩展名,文件对话框是否自动在文件名中添加扩展名。(可以不设置)
-                AddExtension = true,
-
-                //保存对话框是否记忆上次打开的目录
-                RestoreDirectory = true
-            })
-            {
-                // Show save file dialog box
-
-                //点了保存按钮进入
-                if (saveFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
-                {
-                    try
-                    {
-                        //获得文件路径
-                        string localFilePath = saveFileDialog.FileName.ToString();
-
-                        //string filePathWithName = localFilePath + ".xlsx";
-
-                        //获取文件内容
-                        MiniExcel.SaveAs(localFilePath, BaseConfigList);
-                    }
-                    catch (Exception ex)
-                    {
-                        _logger.LogError(ex.ToString());
-                    }
-
-
-                }
-
-            }
-        }
-        /// <summary>
-        /// 获取解决方案
-        /// </summary>
-        private void GetContent()
-        {
-            //所有测试方案
-            var schlist = _basicPlcTestSchemeService.QueryList();
-            var configList = _mapper.Map<List<bas_plc_test_scheme>, List<BasicPlcTestSchemeDto>>(schlist);
-            //清空集合
-            BaseConfigList.Clear();
-            allConfigList.Clear();
-            conditionConfig.Clear();
-            //查找测试项名称
-            foreach (var sch in configList)
-            {
-                long schId = sch.SchemeId;
-                //在解决方案详细表中查找所有的测试项
-                var items = _basicPlcTestSchemeDtlService.FindAllBySchId(schId);
-                foreach (var item in items)
-                {
-                    //上面是测试方案明细
-                    SchDtlWithResultModel basicPlcTestSchemeDto = new SchDtlWithResultModel();
-                    basicPlcTestSchemeDto.SchemeId = item.scheme_dtl_id;
-                    basicPlcTestSchemeDto.SchemeName = sch.SchemeName;
-                    basicPlcTestSchemeDto.DeviceKindName = sch.DeviceKindName;
-                    switch (item.item_type)
-                    {
-                        case 0:
-                            basicPlcTestSchemeDto.ItemType = "前置项";
-                            break;
-                        case 1:
-                            basicPlcTestSchemeDto.ItemType = "PLC点位测试项";
-                            break;
-                        case 2:
-                            basicPlcTestSchemeDto.ItemType = "Robot动作测试";
-                            break;
-                    }
-
-                    basicPlcTestSchemeDto.ItemName = item.item_name;
-                    basicPlcTestSchemeDto.CreateBy = sch.CreateBy;
-                    basicPlcTestSchemeDto.CreateTime = sch.CreateTime;
-                    //这里是测试项 结果和 测试记录明细状态
-                    var recordDetail=_iBizTestRecordDtlService.FindRecordDetailBySchDtlID(item.scheme_dtl_id);
-                    if(recordDetail != null)
-                    {
-                        basicPlcTestSchemeDto.StartTestTime = recordDetail.start_test_time.Value;
-                        basicPlcTestSchemeDto.FinishTestTime = recordDetail.finish_test_time.Value;
-                        basicPlcTestSchemeDto.TestMode= recordDetail.test_mode;
-                        switch (recordDetail.test_result)
-                        {
-                            case 0:
-                                basicPlcTestSchemeDto.TestResult = "不通过";
-                                break;
-                            case 1:
-                                basicPlcTestSchemeDto.TestResult = "通过";
-                                break;
-                        }
-
-                        switch (recordDetail.status)
-                        {
-                            case 0:
-                                basicPlcTestSchemeDto.TestStatus = "未测试";
-                                break;
-                            case 99:
-                                basicPlcTestSchemeDto.TestStatus = "已测试";
-                                break;
-                        }
-                        //只显示已测试的项
-                        allConfigList.Add(basicPlcTestSchemeDto);
-                        conditionConfig.Add(basicPlcTestSchemeDto);
-                    }
-                   
-
-                }
-                conditionConfig = conditionConfig.OrderBy(x => x.SchemeName).ThenBy(x => x.SchemeId).ToList();
-                //默认显示的第一页
-                Getpage();
-            }
-
-        }
-
-        /// <summary>
-        /// 获取页面
-        /// </summary>
-        private void Getpage()
-        {
-            CurrentPage = 1;
-            TotalCount = conditionConfig.Count;
-            CurrentPageChanged();
-
-
-        }
-        /// <summary>
-        /// 页面变化
-        /// </summary>
-        private void CurrentPageChanged()
-        {
-
-            BaseConfigList.Clear();
-
-            foreach (var i in conditionConfig.Skip((CurrentPage - 1) * CountPerPage).Take(CountPerPage))
-            {
-                BaseConfigList.Add(i);
-            }
-        }
-
-        #endregion
-        #region 命令绑定
-
-
-        public DelegateCommand<object> QueryCommand { set; get; }
-        public DelegateCommand<object> ResetCommand { set; get; }
-    
-        public DelegateCommand<string> ExportCommand { set; get; }
-
-        public DelegateCommand OnLoadCommand { set; get; }
-        
-        public DelegateCommand<object> PdfReportCommand { set; get; }
-        public DelegateCommand<object> CheckDetailCommand { set; get; }
-        #endregion
-        #region 数据绑定
-        /// <summary>
-        /// 测试方案编码
-        /// </summary>
-        private string scheduleName;
-        public string ScheduleName
-        {
-            get { return scheduleName; }
-            set { scheduleName = value; RaisePropertyChanged(); }
-        }
-        /// <summary>
-        /// 设备名称
-        /// </summary>
-        private string deviceKindName;
-        public string DeviceKindName
-        {
-            get { return deviceKindName; }
-            set { deviceKindName = value; RaisePropertyChanged(); }
-        }
-        /// <summary>
-        /// 测试项名称
-        /// </summary>
-        private string testName;
-        public string TestName
-        {
-            get { return testName; }
-            set { testName = value; RaisePropertyChanged(); }
-        }
-        /// <summary>
-        /// 测试项类型
-        /// </summary>
-
-
-        private List<string> testKinds = new List<string>();
-        public List<string> TestKinds
-        {
-            get { return testKinds; }
-            set { testKinds = value; RaisePropertyChanged(); }
-        }
-        /// <summary>
-        /// 
-        /// </summary>
-        private string selectTest;
-        public string SelectTest
-        {
-            get { return selectTest; }
-            set { selectTest = value; RaisePropertyChanged(); }
-        }
-
-        private DateTime startTime = DateTime.Now;
-        public DateTime StartTime
-        {
-            get { return startTime; }
-            set { startTime = value; RaisePropertyChanged(); }
-        }
-        private DateTime endTime = DateTime.Now;
-        public DateTime EndTime
-        {
-            get { return endTime; }
-            set { endTime = value; RaisePropertyChanged(); }
-        }
-
-
-        /// <summary>
-        /// 总条数
-        /// </summary>
-        private int totalCount;
-        public int TotalCount
-        {
-            get { return totalCount; }
-            set { totalCount = value; RaisePropertyChanged(); CurrentPageChanged(); }
-        }
-        /// <summary>
-        /// 每页数量
-        /// </summary>
-        private int countPerPage = 15;
-        public int CountPerPage
-        {
-            get { return countPerPage; }
-            set { countPerPage = value; RaisePropertyChanged(); CurrentPageChanged(); }
-        }
-        /// <summary>
-        /// 单前页
-        /// </summary>
-        private int currentPage = 1;
-        public int CurrentPage
-        {
-            get { return currentPage; }
-            set { currentPage = value; RaisePropertyChanged(); CurrentPageChanged(); }
-        }
-
-        private ObservableCollection<SchDtlWithResultModel> baseConfigList = new ObservableCollection<SchDtlWithResultModel>();
-        public ObservableCollection<SchDtlWithResultModel> BaseConfigList
-        {
-            get { return baseConfigList; }
-            set { SetProperty(ref baseConfigList, value); }
-        }
-
-        #endregion
-
-    }
-}
-

+ 131 - 96
BlankApp1/BlankApp1/ViewModels/BusinessManageViewModel/ResultQueryViewModel.cs

@@ -79,7 +79,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
             parm.Add("Key2", deviceId);
             //弹出详情对话框
             //弹出详情对话框
-            _dialog.ShowDialog("ManualTestView", parm, async callback =>
+            _dialog.ShowDialog("RetryTestView", parm, async callback =>
             {
                 if (callback.Result == ButtonResult.OK)
                 {
@@ -200,7 +200,6 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
             var schDtoList = _mapper.Map<List<bas_plc_test_scheme>, List<BasicPlcTestSchemeDto>>(schlist);
             //测试记录中的所有设备
             var deviceIds=_iBizTestRecordService.QueryList().Select(X => X.device_id).Distinct();
-
             foreach (var deviceId in deviceIds)
             {
                 var deviceMsg = _iBasicDeviceService.Find(((int)deviceId));
@@ -214,6 +213,39 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                         string deviceKindName = _iBasicDeviceKindService.Find((int)deviceMsg.device_kind_id)?.devicekind_name;
                         string projectName = _iBasicProjectService.Find((int)deviceMsg.project_id)?.project_name;
                         long schId=(long)_basicPlcTestSchemeService.FindByNameAndType(sch.scheme_name, deviceKindName)?.scheme_id;
+                        //计算测试结果
+                        string testResult = string.Empty;
+                        int countResult = 0;
+                        var records = _iBizTestRecordDtlService.FindRecordDetailByRecordID(sch.record_id);
+                        //
+                        var schDtls=_iBasicPlcTestSchemeDtlService.FindAllBySchId(schId);
+                        //循环所有测试项,有一个不合格,则整个测试方案不合格
+                        foreach(var dtl in schDtls)
+                        {
+                            //选取开始时间最大的一个数据,查看测试结果
+                            long schDtId = dtl.scheme_dtl_id;
+                            var findRecords=records.FindAll(x => x.scheme_dtl_id == schDtId).OrderByDescending(x=>x.start_test_time).ToArray();
+                            if(findRecords.Length>0)
+                            {
+                                int result = (int)findRecords[0]?.test_result.Value;
+                                if(result==0)
+                                {
+                                    testResult = "不通过";
+                                    break;
+                                }
+                                else
+                                {
+                                    countResult++;
+                                }
+                            }
+                        }
+                        //测试结果
+                        if(countResult== schDtls.Count)
+                        {
+                            testResult = "通过";
+                        }
+
+                        
                         allDeviceList.Add(new DeviceDtlWithResultModel()
                         {
                             RecordId = sch.record_id,
@@ -225,7 +257,8 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                             SchemeName = sch.scheme_name,
                             SchemeId= schId,
                             StartTestTime = sch.start_test_time.Value,
-                        }); ; ;
+                            TestResult=testResult
+                        }); 
                         conditionDevices.Add(new DeviceDtlWithResultModel()
                         {
                             RecordId = sch.record_id,
@@ -237,13 +270,11 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                             SchemeName = sch.scheme_name,
                             SchemeId = schId,
                             StartTestTime = sch.start_test_time.Value,
+                            TestResult = testResult
                         });
                     }
                   
                 }
-              
-    
-               
 
             }
             conditionDevices = conditionDevices.OrderBy(x => x.DeviceId).ToList();
@@ -356,112 +387,116 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
             {
                 long recordId = each.record_id.Value;
                 long schDtlid = each.scheme_dtl_id;
-                
-                string schItemName = _iBasicPlcTestSchemeDtlService.Find((int)schDtlid)?.item_name;
-                string schItemType = string.Empty;
-                int typeNo=(int) _iBasicPlcTestSchemeDtlService.Find((int)schDtlid)?.item_type;
-                switch (typeNo)
+                var schDtlRelt = _iBasicPlcTestSchemeDtlService.Find((int)schDtlid);
+                if(schDtlRelt != null)
                 {
-                    case 0:
-                        schItemType = "前置项";
-                        break;
-                    case 1:
-                        schItemType = "PLC点位测试项";
-                        break;
-                    case 2:
-                        schItemType = "Robot动作测试";
-                        break;
-                }
-                //根据测试结果明细
-                if (each != null)
-                {       //前置项结果解析
-                    string preconStr = each.precondition_final?.ToString();
-                    if (!string.IsNullOrEmpty(preconStr))
+                    string schItemName = schDtlRelt.item_name;
+                    string schItemType = string.Empty;
+                    int typeNo = schDtlRelt.item_type.Value;
+                    switch (typeNo)
                     {
-                        JsonModel preconditionModel = JsonConvert.DeserializeObject<JsonModel>(preconStr);
-
-                        foreach (var detail in preconditionModel.DetailInfo)
+                        case 0:
+                            schItemType = "前置项";
+                            break;
+                        case 1:
+                            schItemType = "PLC点位测试项";
+                            break;
+                        case 2:
+                            schItemType = "Robot动作测试";
+                            break;
+                    }
+                    //根据测试结果明细
+                    if (each != null)
+                    {       //前置项结果解析
+                        string preconStr = each.precondition_final?.ToString();
+                        if (!string.IsNullOrEmpty(preconStr))
                         {
+                            JsonModel preconditionModel = JsonConvert.DeserializeObject<JsonModel>(preconStr);
 
-                            invoiceModel.ReportPLCModels.Add(new ReportPLCModel()
+                            foreach (var detail in preconditionModel.DetailInfo)
                             {
-                                ItemName =schItemName,
-                                ItemType = schItemType,
-                                Type = "前置项",
-                                JudgeType = preconditionModel.ItemType,
-                                SelectLogic = preconditionModel.ItemLogical,
-                                Detail = preconditionModel.Description,
-                                Id = detail.Id,
-                                PlcAddress = detail.PlcAddress,
-                                PlcItem = detail.PlcItem,
-                                PlcValue = detail.PlcValue,
-                                Remark = detail.Remark,
-                                TestTime = detail.TestTime,
-                                RealValue = detail.RealValue,
-                                TestResult = detail.TestResult,
-
-                            });
-                        }
-                    }
 
-                    //输入项解析
-                    string inStr = each.action_final?.ToString();
-                    if (!string.IsNullOrEmpty(inStr))
-                    {
-                        JsonModel inModel = JsonConvert.DeserializeObject<JsonModel>(inStr);
+                                invoiceModel.ReportPLCModels.Add(new ReportPLCModel()
+                                {
+                                    ItemName = schItemName,
+                                    ItemType = schItemType,
+                                    Type = "前置项",
+                                    JudgeType = preconditionModel.ItemType,
+                                    SelectLogic = preconditionModel.ItemLogical,
+                                    Detail = preconditionModel.Description,
+                                    Id = detail.Id,
+                                    PlcAddress = detail.PlcAddress,
+                                    PlcItem = detail.PlcItem,
+                                    PlcValue = detail.PlcValue,
+                                    Remark = detail.Remark,
+                                    TestTime = detail.TestTime,
+                                    RealValue = detail.RealValue,
+                                    TestResult = detail.TestResult,
+
+                                });
+                            }
+                        }
 
-                        foreach (var detail in inModel.DetailInfo)
+                        //输入项解析
+                        string inStr = each.action_final?.ToString();
+                        if (!string.IsNullOrEmpty(inStr))
                         {
-                            invoiceModel.ReportPLCModels.Add(new ReportPLCModel()
+                            JsonModel inModel = JsonConvert.DeserializeObject<JsonModel>(inStr);
+
+                            foreach (var detail in inModel.DetailInfo)
                             {
-                                ItemName = schItemName,
-                                ItemType = schItemType,
-                                Type = "输入项",
-                                JudgeType = inModel.ItemType,
-                                SelectLogic = inModel.ItemLogical,
-                                Detail = inModel.Description,
-                                Id = detail.Id,
-                                PlcAddress = detail.PlcAddress,
-                                PlcItem = detail.PlcItem,
-                                PlcValue = detail.PlcValue,
-                                Remark = detail.Remark,
-                                TestTime = detail.TestTime,
-                                RealValue = detail.RealValue,
-                                TestResult = detail.TestResult,
-
-                            });
+                                invoiceModel.ReportPLCModels.Add(new ReportPLCModel()
+                                {
+                                    ItemName = schItemName,
+                                    ItemType = schItemType,
+                                    Type = "输入项",
+                                    JudgeType = inModel.ItemType,
+                                    SelectLogic = inModel.ItemLogical,
+                                    Detail = inModel.Description,
+                                    Id = detail.Id,
+                                    PlcAddress = detail.PlcAddress,
+                                    PlcItem = detail.PlcItem,
+                                    PlcValue = detail.PlcValue,
+                                    Remark = detail.Remark,
+                                    TestTime = detail.TestTime,
+                                    RealValue = detail.RealValue,
+                                    TestResult = detail.TestResult,
+
+                                });
+                            }
                         }
-                    }
-
-                    //输出项解析
-                    string outStr = each.judgement_result_final?.ToString();
-                    if (!string.IsNullOrEmpty(outStr))
-                    {
-                        JsonModel outModel = JsonConvert.DeserializeObject<JsonModel>(outStr);
 
-                        foreach (var detail in outModel.DetailInfo)
+                        //输出项解析
+                        string outStr = each.judgement_result_final?.ToString();
+                        if (!string.IsNullOrEmpty(outStr))
                         {
-                            invoiceModel.ReportPLCModels.Add(new ReportPLCModel()
+                            JsonModel outModel = JsonConvert.DeserializeObject<JsonModel>(outStr);
+
+                            foreach (var detail in outModel.DetailInfo)
                             {
-                                ItemName = schItemName,
-                                ItemType = schItemType,
-                                Type = "结果项",
-                                JudgeType = outModel.ItemType,
-                                SelectLogic = outModel.ItemLogical,
-                                Detail = outModel.Description,
-                                Id = detail.Id,
-                                PlcAddress = detail.PlcAddress,
-                                PlcItem = detail.PlcItem,
-                                PlcValue = detail.PlcValue,
-                                Remark = detail.Remark,
-                                TestTime = detail.TestTime,
-                                RealValue = detail.RealValue,
-                                TestResult = detail.TestResult,
-
-                            });
+                                invoiceModel.ReportPLCModels.Add(new ReportPLCModel()
+                                {
+                                    ItemName = schItemName,
+                                    ItemType = schItemType,
+                                    Type = "结果项",
+                                    JudgeType = outModel.ItemType,
+                                    SelectLogic = outModel.ItemLogical,
+                                    Detail = outModel.Description,
+                                    Id = detail.Id,
+                                    PlcAddress = detail.PlcAddress,
+                                    PlcItem = detail.PlcItem,
+                                    PlcValue = detail.PlcValue,
+                                    Remark = detail.Remark,
+                                    TestTime = detail.TestTime,
+                                    RealValue = detail.RealValue,
+                                    TestResult = detail.TestResult,
+
+                                });
+                            }
                         }
                     }
                 }
+         
             }
             //判断方案结果是否通过
             //var testCount = allDeviceList.FindAll(X => X.SchemeName == findSch.scheme_name && X.TestResult == "通过")?.Count;

+ 1444 - 0
BlankApp1/BlankApp1/ViewModels/BusinessManageViewModel/RetryTestViewModel.cs

@@ -0,0 +1,1444 @@
+using AutoMapper;
+using BizService;
+using Microsoft.Extensions.Logging;
+using Model.Dto;
+using Model.Entities;
+using Newtonsoft.Json;
+using PLCTool.Common;
+using Prism.Commands;
+using Prism.Events;
+using Prism.Mvvm;
+using Prism.Services.Dialogs;
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+
+namespace PLCTool.ViewModels.BusinessManageViewModel
+{
+
+    public class RetryTestViewModel : BindableBase, IDialogAware
+    {
+        private readonly IDialogService _dialog;
+        private readonly IEventAggregator _aggregator;
+        private readonly IOptionConfigService _optionConfigService;
+        private readonly IBasicPlcTestSchemeService _basicPlcTestSchemeService;
+        private readonly IBasicPlcTestSchemeDtlService _basicPlcTestSchemeDtlService;
+        private readonly IBizTestRecordService _iBizTestRecordService;
+        private readonly IBizTestRecordDtlService _iBizTestRecordDtlService;
+        private readonly IMapper _mapper;
+        private readonly ILogger _logger;
+        private List<OptionConfigDto> _optionConfigs;
+
+        private DateTime startTime = DateTime.Now;
+        private DateTime endTime = DateTime.Now;
+        private int testStatus = 0;  //测试状态 
+        private int testResult = 0; //测试结果
+        private long schId = 0; //方案ID
+        private long globalSchDetailId = 0; //测试方案明细ID
+        private long globalDeviceId = 0; //设备ID
+        private BizTestRecordDtlDto bizTestRecordDtlDto = new BizTestRecordDtlDto(); //测试方案明细表
+        private const string TestMode = "重新测试";
+
+        private int delayTime = 20;
+        public RetryTestViewModel(IDialogService dialog, IEventAggregator aggregator, IOptionConfigService optionConfigService, IBasicPlcTestSchemeService basicPlcTestSchemeService, IBasicPlcTestSchemeDtlService basicPlcTestSchemeDtlService, IBizTestRecordService iBizTestRecordService, IBizTestRecordDtlService iBizTestRecordDtlService, IMapper mapper, ILogger logger)
+        {
+            _dialog = dialog;
+            _aggregator = aggregator;
+            _optionConfigService = optionConfigService;
+            _basicPlcTestSchemeService = basicPlcTestSchemeService;
+            _basicPlcTestSchemeDtlService = basicPlcTestSchemeDtlService;
+            _iBizTestRecordDtlService = iBizTestRecordDtlService;
+            _iBizTestRecordService = iBizTestRecordService;
+            _mapper = mapper;
+            _logger = logger;
+            CloseCommand = new DelegateCommand(Close);
+            StartCommand = new DelegateCommand<object>(Start);
+            PreviousCommand = new DelegateCommand<object>(Previous);
+            NextCommand = new DelegateCommand<object>(Next);
+            DoneCommand = new DelegateCommand<object>(Done);
+            ItemChangeCommand = new DelegateCommand(ItemChange);
+            BeforeConList = new ObservableCollection<BasPlcItemConfigDto>();
+            InConList = new ObservableCollection<BasPlcItemConfigDto>();
+            OutConList = new ObservableCollection<BasPlcItemConfigDto>();
+            GetConfigOption();
+
+        }
+        /// <summary>
+        /// 选中测试项
+        /// </summary>
+        private void ItemChange()
+        {
+            var findDtlMsg = _basicPlcTestSchemeDtlService.FindAllBySchId(schId)?.FirstOrDefault(X => X.item_name == SelectItem);
+            if (findDtlMsg != null)
+            {
+                int id = Convert.ToInt32(findDtlMsg.scheme_dtl_id);
+                // 根据 测试方案明细主键ID 查找测试方案id 及方案名和设备名
+                globalSchDetailId = id;
+                GetDetailInfo(id);
+            }
+        }
+
+
+
+
+        #region idialog接口实现
+        public string Title { set; get; } = "手动测试";
+
+        public event Action<IDialogResult> RequestClose;
+
+        public bool CanCloseDialog()
+        {
+            return true;
+        }
+
+        public void OnDialogClosed()
+        {
+
+        }
+
+        public void OnDialogOpened(IDialogParameters parameters)
+        {
+            //编辑
+            var getMsg = parameters.GetValues<long>("Key");
+            ///值不为空,表示修改
+            if (getMsg != null)
+            {
+                foreach (var item in getMsg)
+                {
+                    //测试方案号
+                    schId = item;
+                    var schDtls = _basicPlcTestSchemeDtlService.FindAllBySchId(schId).OrderBy(x => x.scheme_dtl_id).ToList(); ;
+                    //不合格项目集合
+                    List<bas_plc_test_scheme_dtl> reTrysList = new List<bas_plc_test_scheme_dtl>();
+                    //查找不合格项目
+                    foreach (var sch in schDtls)
+                    {
+                      
+                        long dtlId = sch.scheme_dtl_id;
+                        var dtlResult = _iBizTestRecordDtlService.FindRecordDetailBySchDtlID(dtlId)?.OrderByDescending(x => x.start_test_time)?.ToArray();
+                        if((dtlResult!=null)&&(dtlResult.Length!=0))
+                        {
+                            //时间最新的结果 ,不通过
+                            if (dtlResult[0].test_result==0)
+                            {
+                                SchItems.Add(sch.item_name);
+
+                                reTrysList.Add(sch);
+                            }
+
+
+                        }
+                       
+                    }
+                    //默认显示第一个测试项的信息
+                    if (reTrysList.Count != 0)
+                    {
+                        int id = Convert.ToInt32(reTrysList[0].scheme_dtl_id);
+                        globalSchDetailId = id;
+                        // 根据 测试方案明细主键ID 查找测试方案id 及方案名和设备名
+                        GetDetailInfo(id);
+                        SelectItemIndex = 0;
+                    }
+
+
+                }
+
+            }
+            //获取设备id
+            var getDes = parameters.GetValues<long>("Key2");
+            if (getDes != null)
+            {
+                foreach (var item in getDes)
+                {
+                    globalDeviceId = item;
+                }
+            }
+        }
+
+        /// <summary>
+        /// //根据 测试方案明细主键ID 查找测试方案id 及方案名和设备名
+        /// </summary>
+        /// <param name="id"></param>
+        private void GetDetailInfo(int schDetailId)
+        {
+            //根据 测试方案明细主键ID 查找测试方案id 及方案名和设备名
+            var findEntity = _basicPlcTestSchemeDtlService.Find(schDetailId);
+            var findresult = _mapper.Map<bas_plc_test_scheme_dtl, BasicPlcTestSchemeDtlDto>(findEntity);
+            if (findresult != null)
+            {
+                //根据方案id 在方案表中查找方案名 设备名
+                schId = findresult.SchemeId.Value; //方案id,方便下一步查找
+                int intSchId = Convert.ToInt32(findresult.SchemeId);
+
+                var findSch = _basicPlcTestSchemeService.Find(intSchId);
+                if (findSch != null)
+                {
+                    ScheduleName = findSch.scheme_name;
+                    DeviceKindName = findSch.devicekind_name;
+
+                }
+                TestName = findresult.ItemName;
+                SelectTest = findresult.ItemType;
+                //前置项解析
+                string preconStr = findresult.Precondition.ToString();
+                if (!string.IsNullOrEmpty(preconStr))
+                {
+                    JsonModel preconditionModel = JsonConvert.DeserializeObject<JsonModel>(preconStr);
+                    BeforeSelectJudge = preconditionModel.ItemType;
+                    SelectLogic = preconditionModel.ItemLogical;
+                    BeforeDetail = preconditionModel.Description;
+                    BeforeConList.Clear();
+                    foreach (var detail in preconditionModel.DetailInfo)
+                    {
+                        BasPlcItemConfigDto basPlcItemConfigDto = new BasPlcItemConfigDto();
+                        basPlcItemConfigDto.Id = detail.Id;
+                        basPlcItemConfigDto.PlcItem = detail.PlcItem;
+                        basPlcItemConfigDto.PlcAddress = detail.PlcAddress;
+                        basPlcItemConfigDto.PlcAddType = detail.PlcAddType;
+                        basPlcItemConfigDto.PlcValue = detail.PlcValue;
+                        basPlcItemConfigDto.Remark = detail.Remark;
+                        BeforeConList.Add(basPlcItemConfigDto);
+                    }
+                }
+
+                //输入项解析
+                string inStr = findresult.Action.ToString();
+                if (!string.IsNullOrEmpty(inStr))
+                {
+                    JsonModel inModel = JsonConvert.DeserializeObject<JsonModel>(inStr);
+                    SelectInJudge = inModel.ItemType;
+                    InSelectLogic = inModel.ItemLogical;
+                    InDetail = inModel.Description;
+                    InConList.Clear();
+                    foreach (var detail in inModel.DetailInfo)
+                    {
+                        BasPlcItemConfigDto basPlcItemConfigDto = new BasPlcItemConfigDto();
+                        basPlcItemConfigDto.Id = detail.Id;
+                        basPlcItemConfigDto.PlcItem = detail.PlcItem;
+                        basPlcItemConfigDto.PlcAddress = detail.PlcAddress;
+                        basPlcItemConfigDto.PlcAddType = detail.PlcAddType;
+                        basPlcItemConfigDto.PlcValue = detail.PlcValue;
+                        basPlcItemConfigDto.Remark = detail.Remark;
+                        InConList.Add(basPlcItemConfigDto);
+                    }
+                }
+
+                //输出项解析
+                string outStr = findresult.JudgementResult.ToString();
+                if (!string.IsNullOrEmpty(outStr))
+                {
+                    JsonModel outModel = JsonConvert.DeserializeObject<JsonModel>(outStr);
+                    SelectOutJudge = outModel.ItemType;
+                    OutSelectLogic = outModel.ItemLogical;
+                    OutDetail = outModel.Description;
+                    OutConList.Clear();
+                    foreach (var detail in outModel.DetailInfo)
+                    {
+                        BasPlcItemConfigDto basPlcItemConfigDto = new BasPlcItemConfigDto();
+                        basPlcItemConfigDto.Id = detail.Id;
+                        basPlcItemConfigDto.PlcItem = detail.PlcItem;
+                        basPlcItemConfigDto.PlcAddress = detail.PlcAddress;
+                        basPlcItemConfigDto.PlcAddType = detail.PlcAddType;
+                        basPlcItemConfigDto.PlcValue = detail.PlcValue;
+                        basPlcItemConfigDto.Remark = detail.Remark;
+                        OutConList.Add(basPlcItemConfigDto);
+                    }
+                }
+
+            }
+        }
+        #endregion
+
+        #region 私有发方法
+        /// <summary>
+        /// 增加或更新测试记录
+        /// </summary>
+        private void AddTestRecord()
+        {
+
+            //记录记录主表中是否有这个方案的记录,没有则添加
+            var findRecord = _iBizTestRecordService.FindRecorddByDeviceIdAndSchname(globalDeviceId, ScheduleName);
+            if (findRecord == null)
+            {
+                //状态status 没有赋值
+                BizTestRecordDto bizTestRecordDto = new BizTestRecordDto();
+                bizTestRecordDto.RecordName = ScheduleName + "_Record";
+                bizTestRecordDto.SchemeName = ScheduleName;
+                bizTestRecordDto.DeviceId = globalDeviceId;
+                bizTestRecordDto.Tester = Appsession.UserName;
+                bizTestRecordDto.StartTestTime = startTime;
+                bizTestRecordDto.FinishTestTime = endTime;
+                bizTestRecordDto.CreateBy = Appsession.UserName;
+                bizTestRecordDto.CreateTime = DateTime.Now;
+                bizTestRecordDto.UpdateBy = Appsession.UserName;
+                bizTestRecordDto.UpdateTime = DateTime.Now;
+                var testRecord = _mapper.Map<BizTestRecordDto, biz_test_record>(bizTestRecordDto);
+                _iBizTestRecordService.Add(testRecord);
+            }
+
+        }
+        /// <summary>
+        /// 获取记录明细
+        /// </summary>
+        private void AddDtltRecord(long schDetailId)
+        {
+            //查找record ID
+            long recordId = 0;
+            var findRecordID = _iBizTestRecordService.FindRecorddByDeviceIdAndSchname(globalDeviceId, ScheduleName);
+            if (findRecordID != null)
+            {
+                recordId = findRecordID.record_id;
+            }
+            testStatus = 99;//测试状态赋值为99
+                            //状态status 没有赋值
+
+            bizTestRecordDtlDto.RecordId = recordId;
+            bizTestRecordDtlDto.SchemeDtlId = schDetailId;
+            bizTestRecordDtlDto.StartTestTime = startTime;
+            bizTestRecordDtlDto.FinishTestTime = endTime;
+            bizTestRecordDtlDto.TestMode = TestMode;
+            bizTestRecordDtlDto.Status = testStatus;
+            bizTestRecordDtlDto.TestResult = GetTestResult();
+            bizTestRecordDtlDto.CreateBy = Appsession.UserName;
+            bizTestRecordDtlDto.CreateTime = startTime;
+            bizTestRecordDtlDto.UpdateBy = Appsession.UserName;
+            bizTestRecordDtlDto.UpdateTime = DateTime.Now;
+            //更新时间
+            bizTestRecordDtlDto.UpdateBy = Appsession.UserName;
+            bizTestRecordDtlDto.UpdateTime = DateTime.Now;
+
+            var testRecordDtl = _mapper.Map<BizTestRecordDtlDto, biz_test_record_dtl>(bizTestRecordDtlDto);
+            _iBizTestRecordDtlService.Add(testRecordDtl);
+
+
+        }
+        /// <summary>
+        /// 判定结果
+        /// </summary>
+        /// <returns></returns>
+        private int GetTestResult()
+        {
+            //前置项
+            int beforeResult = 0;
+            int inResult = 0;
+            int outResult = 0;
+            if (BeforeConList.Count == 0)
+            {
+                beforeResult = 1;
+            }
+            else
+            {
+                if (SelectLogic == "OR")
+                {
+                    var find = BeforeConList.FirstOrDefault(x => x.TestResult == "通过");
+                    if (find != null)
+                    {
+                        beforeResult = 1;
+                    }
+                    else
+                    {
+                        beforeResult = 0;
+                    }
+                }
+                else
+                {
+                    if (SelectLogic == "AND" || SelectLogic == "ONLY")
+                    {
+                        var find = BeforeConList.FirstOrDefault(x => x.TestResult == "不通过");
+                        if (find != null)
+                        {
+                            beforeResult = 0;
+                        }
+                    }
+                    else
+                    {
+                        if (SelectLogic == "NULL")
+                        {
+
+                            beforeResult = 1;
+
+                        }
+                    }
+                }
+            }
+
+
+            //输入项
+            if (InConList.Count == 0)
+            {
+                inResult = 1;
+            }
+            else
+            {
+                if (InSelectLogic == "OR")
+                {
+                    var find = InConList.FirstOrDefault(x => x.TestResult == "通过");
+                    if (find != null)
+                    {
+                        inResult = 1;
+                    }
+                    else
+                    {
+                        inResult = 0;
+                    }
+                }
+                else
+                {
+                    if (InSelectLogic == "AND" || InSelectLogic == "ONLY")
+                    {
+                        var find = InConList.FirstOrDefault(x => x.TestResult == "不通过");
+                        if (find != null)
+                        {
+                            inResult = 0;
+                        }
+                        else
+                        {
+                            inResult = 1;
+                        }
+                    }
+                    else
+                    {
+                        if (InSelectLogic == "NULL")
+                        {
+
+                            inResult = 1;
+
+                        }
+                    }
+                }
+
+            }
+
+
+            //输出项
+            if (OutConList.Count == 0)
+            {
+                outResult = 1;
+            }
+            else
+            {
+                if (OutSelectLogic == "OR")
+                {
+                    var find = OutConList.FirstOrDefault(x => x.TestResult == "通过");
+                    if (find != null)
+                    {
+                        outResult = 1;
+                    }
+                    else
+                    {
+                        outResult = 0;
+                    }
+                }
+                else
+                {
+                    if (OutSelectLogic == "AND" || OutSelectLogic == "ONLY")
+                    {
+                        var find = OutConList.FirstOrDefault(x => x.TestResult == "不通过");
+                        if (find != null)
+                        {
+                            outResult = 0;
+                        }
+                        else
+                        {
+                            outResult = 1;
+                        }
+                    }
+                    else
+                    {
+                        if (OutSelectLogic == "NULL")
+                        {
+
+                            outResult = 1;
+
+                        }
+                    }
+                }
+            }
+
+            if (beforeResult == 1 && inResult == 1 && outResult == 1)
+            {
+                return 1;
+            }
+            else
+            {
+                return 0;
+            }
+
+        }
+        /// <summary>
+        /// 更新测试记录
+        /// </summary>
+        private void UpdateTesDtltRecord()
+        {
+
+            var testRecordDtl = _mapper.Map<BizTestRecordDtlDto, biz_test_record_dtl>(bizTestRecordDtlDto);
+            _iBizTestRecordDtlService.Edit(testRecordDtl);
+        }
+        /// <summary>
+        /// 完成时间
+        /// </summary>
+        /// <param name="obj"></param>
+        private void Done(object obj)
+        {
+            endTime = DateTime.Now;
+            RequestClose?.Invoke(new DialogResult(ButtonResult.OK));
+
+        }
+
+        private void Next(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);
+                    SelectItemIndex++;
+                    //界面显示
+                    GetDetailInfo(id);
+                    //记录记录明细表中是否有这个方案明细ID的记录,没有则添加,有则更新记录状态
+
+                    break;
+                }
+                long maxDtlId = basicSchDtls.Select(x => x.scheme_dtl_id).Max();
+                if (globalSchDetailId == maxDtlId)
+                {
+                    MessageBox.Show("已是此测试方案最后一个测试项!", "确认", MessageBoxButton.OK, MessageBoxImage.Information);
+                    break;
+                }
+
+            }
+        }
+
+        private void Previous(object obj)
+        {
+            StepIndex = 0;
+            ///查找方案下的所有方案明细,并排序,
+            var basicSchDtls = _basicPlcTestSchemeDtlService.FindAllBySchId(schId)?.OrderByDescending(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);
+                    SelectItemIndex--;
+                    //界面显示
+                    GetDetailInfo(id);
+                    //记录记录明细表中是否有这个方案明细ID的记录,没有则添加,有则更新记录状态
+
+                    break;
+                }
+
+            }
+            long maxDtlId = basicSchDtls.Select(x => x.scheme_dtl_id).Min();
+            if (globalSchDetailId == maxDtlId)
+            {
+                SelectItemIndex = 0;
+                MessageBox.Show("已是此测试方案的第一个测试项!", "确认", MessageBoxButton.OK, MessageBoxImage.Information);
+
+            }
+        }
+        /// <summary>
+        /// 开始检测
+        /// </summary>
+        /// <param name="obj"></param>
+        private async void Start(object obj)
+        {
+
+
+            StartEnalbe = false;
+            _logger.LogInformation($"开始手动测试。方案名{ScheduleName},测试项{TestName}");
+            //开始时间
+            startTime = DateTime.Now;
+            //增加测试记录主表
+            AddTestRecord();
+
+            //前置项
+            bool preBool = TestPreceditionMethod();
+            if (!preBool)
+            {
+                StepIndex = 0;
+                StartEnalbe = true;
+                return;
+            }
+
+            //输入项
+            bool isAction = TestActionMethod();
+            if (!isAction)
+            {
+                StepIndex = 0;
+                StartEnalbe = true;
+                return;
+            }
+
+            //输出项
+            bool isJudgeResult = await TestJudgementMethod();
+            if (!isJudgeResult)
+            {
+                StepIndex = 0;
+                StartEnalbe = true;
+                return;
+            }
+            //将测试结果添加到数据库
+
+            AddDtltRecord(globalSchDetailId);
+
+            _logger.LogInformation($"手动测试完成。方案名{ScheduleName},测试项{TestName}");
+            StartEnalbe = true;
+        }
+        /// <summary>
+        /// 更新测试结果
+        /// </summary>
+        private void UpdateTestRecord()
+        {
+
+        }
+        /// <summary>
+        /// 测试前置项目
+        /// </summary>
+        private bool TestPreceditionMethod()
+        {
+            switch (BeforeSelectJudge)
+            {
+                case "人工判定":
+                    //弹出确认的对话框
+                    if (string.IsNullOrEmpty(BeforeDetail))
+                    {
+                        return true;
+                    }
+                    MessageBoxResult boxResult = MessageBox.Show(BeforeDetail, "确认", MessageBoxButton.OKCancel, MessageBoxImage.Information);
+                    if (boxResult == MessageBoxResult.OK)
+                    {
+                        //前置项测试结果json转化
+                        string prefixJsonStr = ModelToJsonToStr(BeforeSelectJudge, SelectLogic, BeforeDetail, BeforeConList);
+                        //json字符串
+                        bizTestRecordDtlDto.PreconditionFinal = prefixJsonStr;
+                        bizTestRecordDtlDto.PreconditionResult = "通过";
+                        StepIndex = 1;
+                    }
+                    else
+                    {
+                        return false;
+                    }
+
+                    break;
+                case "自动判定":
+                    //读取plc的值
+                    switch (SelectLogic)
+                    {
+                        case "NULL":
+                            //弹出确认的对话框
+                            if (string.IsNullOrEmpty(BeforeDetail))
+                            {
+                                return true;
+                            }
+                            MessageBoxResult boxResultAuto = MessageBox.Show(BeforeDetail, "确认", MessageBoxButton.OKCancel, MessageBoxImage.Information);
+                            if (boxResultAuto == MessageBoxResult.OK)
+                            {
+                                //前置项测试结果json转化
+                                string prefixJsonStr = ModelToJsonToStr(BeforeSelectJudge, SelectLogic, BeforeDetail, BeforeConList);
+                                //json字符串
+                                bizTestRecordDtlDto.PreconditionFinal = prefixJsonStr;
+                                bizTestRecordDtlDto.PreconditionResult = "通过";
+                                StepIndex = 1;
+                            }
+                            else
+                            {
+                                return false;
+                            }
+                            break;
+                        case "AND":
+                        case "ONLY":
+                        case "OR":
+                            ReadPredice(SelectLogic);
+                            break;
+
+                        case "ORDER":
+                            break;
+                    }
+                    break;
+            }
+
+            return true;
+        }
+
+        private void ReadPredice(string strLogic)
+        {
+            int countCond = 0;
+            foreach (var item in BeforeConList.OrderBy(x => x.Id))
+            {
+                string plcAddress = item.PlcAddress;
+                string plcAddType = item.PlcAddType;
+                string plcValue = item.PlcValue;
+
+                switch (plcAddType)
+                {
+                    case "bool":
+                        string readResult = PLCCom.GetInstance().ReadPlcObject(plcAddress, VarType.Bit);
+                        ///实时值记录
+
+                        item.RealValue = readResult;
+                        item.TestTime = DateTime.Now;
+                        if (readResult.Trim() == plcValue?.Trim())
+                        {
+                            item.TestResult = "通过";
+                            countCond++;
+                        }
+                        else
+                        {
+                            item.TestResult = "不通过";
+                        }
+                        break;
+                    case "word":
+                        break;
+
+                }
+
+            }
+            //测试记录存入数据库
+            //前置项测试结果json转化
+            string prefixJsonStr = ModelToJsonToStr(BeforeSelectJudge, SelectLogic, BeforeDetail, BeforeConList);
+            //json字符串
+            bizTestRecordDtlDto.PreconditionFinal = prefixJsonStr;
+            //条件满足
+            switch (strLogic)
+            {
+                case "AND":
+                case "ONLY":
+                    if ((countCond == BeforeConList.Count) && (countCond != 0))
+                    {
+                        bizTestRecordDtlDto.PreconditionResult = "通过";
+
+                    }
+                    else
+                    {
+                        bizTestRecordDtlDto.PreconditionResult = "不通过";
+                    }
+                    break;
+                case "OR":
+                    if ((countCond != 0))
+                    {
+                        bizTestRecordDtlDto.PreconditionResult = "通过";
+
+                    }
+                    else
+                    {
+                        bizTestRecordDtlDto.PreconditionResult = "不通过";
+                    }
+                    break;
+            }
+
+            StepIndex = 1;
+
+        }
+
+        /// <summary>
+        /// 输入项写入
+        /// </summary>
+        private bool TestActionMethod()
+        {
+            bool isActionResult = true;
+            switch (SelectInJudge)
+            {
+                case "人工判定":
+                    //弹出确认的对话框
+                    MessageBoxResult boxResult = MessageBox.Show(InDetail, "确认", MessageBoxButton.OKCancel, MessageBoxImage.Information);
+                    if (boxResult == MessageBoxResult.OK)
+                    {
+                        //前置项测试结果json转化
+                        string actionJsonStr = ModelToJsonToStr(SelectInJudge, InSelectLogic, InDetail, InConList);
+                        //json字符串
+                        bizTestRecordDtlDto.ActionFinal = actionJsonStr;
+                        bizTestRecordDtlDto.ActionResult = "通过";
+                        StepIndex = 2;
+                    }
+                    else
+                    {
+                        isActionResult = false;
+                    }
+
+                    break;
+                case "自动判定":
+                    //读取plc的值
+                    switch (InSelectLogic)
+                    {
+                        case "NULL":
+                            //弹出确认的对话框
+                            MessageBoxResult boxResultAction = MessageBox.Show(InDetail, "确认", MessageBoxButton.OKCancel, MessageBoxImage.Information);
+                            if (boxResultAction == MessageBoxResult.OK)
+                            {
+                                //前置项测试结果json转化
+                                string actionJsonStr = ModelToJsonToStr(SelectInJudge, InSelectLogic, InDetail, InConList);
+                                //json字符串
+                                bizTestRecordDtlDto.ActionFinal = actionJsonStr;
+                                bizTestRecordDtlDto.ActionResult = "通过";
+                                StepIndex = 2;
+                            }
+                            else
+                            {
+                                isActionResult = false;
+                            }
+
+                            break;
+                        case "AND":
+                        case "ONLY":
+                        case "OR":
+                            isActionResult = SendActionToPLC(InSelectLogic);
+                            break;
+
+                        case "ORDER":
+                            break;
+                    }
+                    break;
+            }
+
+            return isActionResult;
+        }
+        /// <summary>
+        /// 发送命令给PLC
+        /// </summary>
+        private bool SendActionToPLC(string strActionLogic)
+        {
+            bool isAction = true;
+            int countCond = 0;
+            foreach (var item in InConList.OrderBy(x => x.Id))
+            {
+                string plcAddress = item.PlcAddress;
+                string plcAddType = item.PlcAddType;
+                string plcValue = item.PlcValue;
+
+                switch (plcAddType)
+                {
+                    case "bool":
+
+                        DialogParameters parm = new DialogParameters();
+                        parm.Add("Key", plcAddress);
+                        parm.Add("Key2", plcValue);
+                        //弹出写入对话框
+                        _dialog.ShowDialog("WritePLCView", parm, async callback =>
+                        {
+                            if (callback.Result == ButtonResult.OK)
+                            {
+                                string plcRealValue = callback.Parameters.GetValue<string>("ReturnValue");
+                                bool writeResult = PLCCom.GetInstance().WritePlcObject(plcAddress, VarType.Bit, plcRealValue);
+                                ///实时值记录
+                                item.RealValue = plcRealValue;
+                                item.TestTime = DateTime.Now;
+                                if (writeResult)
+                                {
+                                    ///单个测试项通过
+                                    item.TestResult = "通过";
+                                    countCond++;
+                                }
+                                else
+                                {
+                                    item.TestResult = "不通过";
+                                }
+                            }
+                            else
+                            {
+                                isAction = false;
+                            }
+
+                        });
+                        break;
+                    case "word":
+                        DialogParameters parm2 = new DialogParameters();
+                        parm2.Add("Key", plcAddress);
+                        parm2.Add("Key2", plcValue);
+                        //弹出写入对话框
+                        _dialog.ShowDialog("WritePLCView", parm2, async callback =>
+                        {
+                            if (callback.Result == ButtonResult.OK)
+                            {
+                                string plcRealValue = callback.Parameters.GetValue<string>("ReturnValue");
+                                bool writeResult = PLCCom.GetInstance().WritePlcObject(plcAddress, VarType.Word, plcRealValue);
+                                ///实时值记录
+                                item.RealValue = plcRealValue;
+                                item.TestTime = DateTime.Now;
+                                if (writeResult)
+                                {
+                                    ///单个测试项通过
+                                    item.TestResult = "通过";
+                                    countCond++;
+                                }
+                                else
+                                {
+                                    item.TestResult = "不通过";
+                                }
+                            }
+                            else
+                            {
+                                isAction = false;
+                            }
+
+                        });
+                        break;
+
+                }
+
+            }
+            if (!isAction)
+            {
+                return isAction;
+            }
+            //测试记录存入数据库
+            //前置项测试结果json转化
+            string actionJsonStr = ModelToJsonToStr(SelectInJudge, InSelectLogic, InDetail, InConList);
+            //json字符串
+            bizTestRecordDtlDto.ActionFinal = actionJsonStr;
+            //条件满足
+
+            //条件满足
+            switch (strActionLogic)
+            {
+                case "AND":
+                case "ONLY":
+                    if ((countCond == BeforeConList.Count) && (countCond != 0))
+                    {
+                        bizTestRecordDtlDto.ActionResult = "通过";
+
+                    }
+                    else
+                    {
+                        bizTestRecordDtlDto.ActionResult = "不通过";
+                    }
+                    break;
+                case "OR":
+                    if ((countCond != 0))
+                    {
+                        bizTestRecordDtlDto.ActionResult = "通过";
+
+                    }
+                    else
+                    {
+                        bizTestRecordDtlDto.ActionResult = "不通过";
+                    }
+                    break;
+            }
+
+            StepIndex = 2;
+            return isAction;
+        }
+        /// <summary>
+        /// 结果项判定
+        /// </summary>
+        private async Task<bool> TestJudgementMethod()
+        {
+            bool isJudge = true;
+            switch (SelectOutJudge)
+            {
+                case "人工判定":
+                    //弹出确认的对话框
+                    MessageBoxResult boxResult = MessageBox.Show(OutDetail, "确认", MessageBoxButton.OKCancel, MessageBoxImage.Information);
+                    if (boxResult == MessageBoxResult.OK)
+                    {
+                        bizTestRecordDtlDto.JudgementResult = "通过";
+                        StepIndex = 3;
+                    }
+                    else
+                    {
+                        isJudge = false;
+                    }
+
+                    break;
+                case "自动判定":
+                    //读取plc的值
+                    switch (OutSelectLogic)
+                    {
+                        case "NULL":
+                            bizTestRecordDtlDto.JudgementResult = "通过";
+                            StepIndex = 3;
+                            break;
+                        case "AND":
+                        case "ONLY":
+                        case "OR":
+                            await ReadJudge(OutSelectLogic);
+                            break;
+                        case "ORDER":
+                            break;
+                    }
+                    break;
+            }
+            //更新测试记录
+            //更新测试记录
+            endTime = DateTime.Now;
+
+            return isJudge;
+        }
+        /// <summary>
+        /// 读取结果
+        /// </summary>
+        private async Task ReadJudge(String strLogic)
+        {
+            int countCond = 0;
+            DateTime entryTime = DateTime.Now;
+            foreach (var item in OutConList.OrderBy(x => x.Id))
+            {
+                string plcAddress = item.PlcAddress;
+                string plcAddType = item.PlcAddType;
+                string plcValue = item.PlcValue;
+
+                switch (plcAddType)
+                {
+
+                    case "bool":
+
+                        string readResult = string.Empty;
+                        //一直读
+                        await Task.Run(async () =>
+                        {
+                            while (entryTime.AddMilliseconds(delayTime * 1000) > DateTime.Now)
+                            {
+                                //显示进度条
+                                System.Windows.Application.Current.Dispatcher.Invoke((delegate
+                                {
+                                    ProVisibility = Visibility.Visible;
+                                }));
+
+                                readResult = PLCCom.GetInstance().ReadPlcObject(plcAddress, VarType.Bit);
+                                if (readResult == item.PlcValue)
+                                {
+                                    break;
+                                }
+                                await Task.Delay(1000);
+                            }
+                        });
+                        //可能有多个条件判定的,第二次时间到了直接跳出延时,直接读取,不用在延时20s
+                        readResult = PLCCom.GetInstance().ReadPlcObject(plcAddress, VarType.Bit);
+                        ProVisibility = Visibility.Hidden;
+                        ///实时值记录
+                        item.RealValue = readResult;
+                        item.TestTime = DateTime.Now;
+                        if (readResult.Trim() == plcValue?.Trim())
+                        {
+                            item.TestResult = "通过";
+                            countCond++;
+                        }
+                        else
+                        {
+                            item.TestResult = "不通过";
+                        }
+
+                        break;
+                    case "word":
+                        // DateTime entryTime2 = DateTime.Now;
+                        string readResult2 = string.Empty;
+                        //一直读
+                        await Task.Run(async () =>
+                        {
+                            while (entryTime.AddMilliseconds(delayTime * 1000) > DateTime.Now)
+                            {
+                                //显示进度条
+                                System.Windows.Application.Current.Dispatcher.Invoke((delegate
+                                {
+                                    ProVisibility = Visibility.Visible;
+                                }));
+
+                                readResult2 = PLCCom.GetInstance().ReadPlcObject(plcAddress, VarType.Word);
+                                if (readResult2 == item.PlcValue)
+                                {
+                                    break;
+                                }
+                                await Task.Delay(1000);
+                            }
+                        });
+                        //可能有多个条件判定的,第二次直接跳出延时,直接读取
+                        readResult2 = PLCCom.GetInstance().ReadPlcObject(plcAddress, VarType.Word);
+                        ProVisibility = Visibility.Hidden;
+                        ///实时值记录
+                        item.RealValue = readResult2;
+                        item.TestTime = DateTime.Now;
+                        if (readResult2.Trim() == plcValue?.Trim())
+                        {
+                            item.TestResult = "通过";
+                            countCond++;
+                        }
+                        else
+                        {
+                            item.TestResult = "不通过";
+                        }
+
+                        break;
+
+
+                }
+
+            }
+
+            //测试记录存入数据库
+            //输出项测试结果json转化
+            string prefixJsonStr = ModelToJsonToStr(SelectOutJudge, OutSelectLogic, OutDetail, OutConList);
+            //json字符串
+            bizTestRecordDtlDto.JudgementResultFinal = prefixJsonStr;
+            //条件满足
+            switch (strLogic)
+            {
+                case "AND":
+                case "ONLY":
+                    if ((countCond == OutConList.Count) && (countCond != 0))
+                    {
+                        bizTestRecordDtlDto.JudgementResult = "通过";
+
+                    }
+                    else
+                    {
+                        bizTestRecordDtlDto.JudgementResult = "不通过";
+                    }
+                    break;
+                case "OR":
+                    if (countCond != 0)
+                    {
+                        bizTestRecordDtlDto.JudgementResult = "通过";
+
+                    }
+                    else
+                    {
+                        bizTestRecordDtlDto.JudgementResult = "不通过";
+                    }
+                    break;
+            }
+
+            StepIndex = 3;
+        }
+        /// <summary>
+        /// 获取配置
+        /// </summary>
+        private void GetConfigOption()
+        {
+            var configList = _optionConfigService.QueryList();
+            _optionConfigs = _mapper.Map<List<OptionConfig>, List<OptionConfigDto>>(configList);
+            var tests = _optionConfigs.FindAll(x => x.TypeID == 1);
+            TestKinds = new List<string>();
+            foreach (var test in tests)
+            {
+                TestKinds.Add(test.ContentOption);
+            }
+
+            //测试项类型
+            var judges = _optionConfigs.FindAll(x => x.TypeID == 2);
+            foreach (var judge in judges)
+            {
+                BeforeJudgeKinds.Add(judge.ContentOption);
+                InJudgeKinds.Add(judge.ContentOption);
+                OutJudgeKinds.Add(judge.ContentOption);
+            }
+
+            //判定逻辑
+            var logics = _optionConfigs.FindAll(x => x.TypeID == 3);
+            foreach (var logic in logics)
+            {
+                JudgeLogicKinds.Add(logic.ContentOption);
+                InJudgeLogicKinds.Add(logic.ContentOption);
+                OutJudgeLogicKinds.Add(logic.ContentOption);
+
+            }
+
+        }
+
+
+
+
+
+
+        /// <summary>
+        /// 关闭按钮
+        /// </summary>
+        private void Close()
+        {
+            MessageBoxResult boxResult = MessageBox.Show("确认退出自动测试", "确认", MessageBoxButton.OKCancel, MessageBoxImage.Information);
+            if (boxResult == MessageBoxResult.OK)
+            {
+
+                RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
+            }
+
+        }
+
+
+
+
+
+        /// <summary>
+        /// mode转json
+        /// </summary>
+        /// <param name="itemType"></param>
+        /// <param name="itemLogical"></param>
+        /// <param name="description"></param>
+        /// <param name="conList"></param>
+        /// <returns></returns>
+
+        private string ModelToJsonToStr(string itemType, string itemLogical, string description, ObservableCollection<BasPlcItemConfigDto> conList)
+        {
+            JsonModel prefixJsonModel = new JsonModel();
+            prefixJsonModel.ItemType = itemType;
+            prefixJsonModel.ItemLogical = itemLogical;
+            prefixJsonModel.Description = description;
+            prefixJsonModel.DetailInfo = new List<DetailPLC>();
+            foreach (var item in conList)
+            {
+                DetailPLC plcItem = new DetailPLC();
+                plcItem.Id = item.Id;
+                plcItem.PlcItem = item.PlcItem;
+                plcItem.PlcAddress = item.PlcAddress;
+                plcItem.PlcAddType = item.PlcAddType;
+                plcItem.PlcValue = item.PlcValue;
+                plcItem.RealValue = item.RealValue;
+                plcItem.TestTime = item.TestTime;
+                plcItem.TestResult = item.TestResult;
+                plcItem.Remark = item.Remark;
+                prefixJsonModel.DetailInfo.Add(plcItem);
+
+            }
+            string prefixJsonStr = JsonConvert.SerializeObject(prefixJsonModel);
+            return prefixJsonStr;
+        }
+
+        #endregion
+
+
+        #region 命令绑定
+        public DelegateCommand CloseCommand { set; get; }
+
+        public DelegateCommand<object> StartCommand { set; get; }
+        public DelegateCommand<object> PreviousCommand { set; get; }
+
+        public DelegateCommand<object> NextCommand { set; get; }
+
+        public DelegateCommand<object> DoneCommand { set; get; }
+        public DelegateCommand ItemChangeCommand { set; get; }
+
+        #endregion
+        #region 变量绑定
+        /// <summary>
+        /// 测试方案编码
+        /// </summary>
+        private string scheduleName;
+        public string ScheduleName
+        {
+            get { return scheduleName; }
+            set { scheduleName = value; RaisePropertyChanged(); }
+        }
+        /// <summary>
+        /// 设备名称
+        /// </summary>
+        private string deviceKindName;
+        public string DeviceKindName
+        {
+            get { return deviceKindName; }
+            set { deviceKindName = value; RaisePropertyChanged(); }
+        }
+        /// <summary>
+        /// 测试项名称
+        /// </summary>
+        private string testName;
+        public string TestName
+        {
+            get { return testName; }
+            set { testName = value; RaisePropertyChanged(); }
+        }
+        /// <summary>
+        /// 测试项类型
+        /// </summary>
+        private List<string> testKinds = new List<string>();
+        public List<string> TestKinds
+        {
+            get { return testKinds; }
+            set { testKinds = value; RaisePropertyChanged(); }
+        }
+        /// <summary>
+        /// 
+        /// </summary>
+        private string selectTest;
+        public string SelectTest
+        {
+            get { return selectTest; }
+            set { selectTest = value; RaisePropertyChanged(); }
+        }
+        /// <summary>
+        /// 判定类型(前置项)
+        /// </summary>
+        private List<string> beforeJudgeKinds = new List<string>();
+        public List<string> BeforeJudgeKinds
+        {
+            get { return beforeJudgeKinds; }
+            set { beforeJudgeKinds = value; RaisePropertyChanged(); }
+        }
+        private string beforeSelectJudge;
+        public string BeforeSelectJudge
+        {
+            get { return beforeSelectJudge; }
+            set { beforeSelectJudge = value; RaisePropertyChanged(); }
+        }
+        /// <summary>
+        /// 逻辑判断
+        /// </summary>
+        private List<string> judgeLogicKinds = new List<string>();
+        public List<string> JudgeLogicKinds
+        {
+            get { return judgeLogicKinds; }
+            set { judgeLogicKinds = value; RaisePropertyChanged(); }
+        }
+        private string selectLogic;
+        public string SelectLogic
+        {
+            get { return selectLogic; }
+            set { selectLogic = value; RaisePropertyChanged(); }
+        }
+        private string beforeDetail;
+        public string BeforeDetail
+        {
+            get { return beforeDetail; }
+            set { beforeDetail = value; RaisePropertyChanged(); }
+        }
+
+        private ObservableCollection<BasPlcItemConfigDto> beforeConList;
+        public ObservableCollection<BasPlcItemConfigDto> BeforeConList
+        {
+            get { return beforeConList; }
+            set { beforeConList = value; RaisePropertyChanged(); }
+        }
+
+        /// <summary>
+        /// 判定类型(输入项)
+        /// </summary>
+        private List<string> inJudgeKinds = new List<string>();
+        public List<string> InJudgeKinds
+        {
+            get { return inJudgeKinds; }
+            set { inJudgeKinds = value; RaisePropertyChanged(); }
+        }
+        private string selectInJudge;
+        public string SelectInJudge
+        {
+            get { return selectInJudge; }
+            set { selectInJudge = value; RaisePropertyChanged(); }
+        }
+        /// <summary>
+        /// 逻辑判断
+        /// </summary>
+        private List<string> inJudgeLogicKinds = new List<string>();
+        public List<string> InJudgeLogicKinds
+        {
+            get { return inJudgeLogicKinds; }
+            set { inJudgeLogicKinds = value; RaisePropertyChanged(); }
+        }
+        private string inSelectLogic;
+        public string InSelectLogic
+        {
+            get { return inSelectLogic; }
+            set { inSelectLogic = value; RaisePropertyChanged(); }
+        }
+        private string inDetail;
+        public string InDetail
+        {
+            get { return inDetail; }
+            set { inDetail = value; RaisePropertyChanged(); }
+        }
+
+        private ObservableCollection<BasPlcItemConfigDto> inConList;
+        public ObservableCollection<BasPlcItemConfigDto> InConList
+        {
+            get { return inConList; }
+            set { inConList = value; RaisePropertyChanged(); }
+        }
+        /// <summary>
+        /// 判定类型(结果项)
+        /// </summary>
+        private List<string> outJudgeKinds = new List<string>();
+        public List<string> OutJudgeKinds
+        {
+            get { return outJudgeKinds; }
+            set { outJudgeKinds = value; RaisePropertyChanged(); }
+        }
+        private string selectOutJudge;
+        public string SelectOutJudge
+        {
+            get { return selectOutJudge; }
+            set { selectOutJudge = value; RaisePropertyChanged(); }
+        }
+        /// <summary>
+        /// 逻辑判断
+        /// </summary>
+        private List<string> outJudgeLogicKinds = new List<string>();
+        public List<string> OutJudgeLogicKinds
+        {
+            get { return outJudgeLogicKinds; }
+            set { outJudgeLogicKinds = value; RaisePropertyChanged(); }
+        }
+        private string outSelectLogic;
+        public string OutSelectLogic
+        {
+            get { return outSelectLogic; }
+            set { outSelectLogic = value; RaisePropertyChanged(); }
+        }
+
+        private string outDetail;
+        public string OutDetail
+        {
+            get { return outDetail; }
+            set { outDetail = value; RaisePropertyChanged(); }
+        }
+        private ObservableCollection<BasPlcItemConfigDto> outConList;
+        public ObservableCollection<BasPlcItemConfigDto> OutConList
+        {
+            get { return outConList; }
+            set { outConList = value; RaisePropertyChanged(); }
+        }
+
+        private int stepIndex = 0;
+        public int StepIndex
+        {
+            get { return stepIndex; }
+            set { stepIndex = value; RaisePropertyChanged(); }
+        }
+
+        private Visibility proVisibility = Visibility.Hidden;
+        public Visibility ProVisibility
+        {
+            get { return proVisibility; }
+            set { proVisibility = value; RaisePropertyChanged(); }
+        }
+        private bool startEnalbe = true;
+        public bool StartEnalbe
+        {
+            get { return startEnalbe; }
+            set { startEnalbe = value; RaisePropertyChanged(); }
+        }
+        //所有测试项列表
+        private List<string> schItems = new List<string>();
+        public List<string> SchItems
+        {
+            get { return schItems; }
+            set { schItems = value; RaisePropertyChanged(); }
+        }
+        //所选测试方案
+        private string selectItem;
+        public string SelectItem
+        {
+            get { return selectItem; }
+            set { selectItem = value; RaisePropertyChanged(); }
+        }
+
+        private int selectItemIndex;
+        public int SelectItemIndex
+        {
+            get { return selectItemIndex; }
+            set { selectItemIndex = value; RaisePropertyChanged(); }
+        }
+
+        #endregion
+
+    }
+}

+ 1 - 1
BlankApp1/BlankApp1/ViewModels/BusinessManageViewModel/TestResultDetailViewModel.cs

@@ -91,7 +91,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                     foreach (var item in getMsg)
                     {
                         long recordId = item;
-                        var records = _iBizTestRecordDtlService.FindRecordDetailByRecordID(recordId).OrderBy(x => x.record_dtl_id).ToList(); ;
+                        var records = _iBizTestRecordDtlService.FindRecordDetailByRecordID(recordId).OrderBy(x => x.record_dtl_id).ToList() ;
                         List<biz_test_record_dtl> recordNotNulls = new List<biz_test_record_dtl>(); //测试项名称不是空的集合
                         foreach (var record in records)
                         {

+ 104 - 81
BlankApp1/BlankApp1/ViewModels/StatisticsViewModel.cs

@@ -25,18 +25,30 @@ namespace BlankApp1.ViewModels
         private readonly IBasicPlcTestSchemeService _basicPlcTestSchemeService;
         private readonly IBasicPlcTestSchemeDtlService _basicPlcTestSchemeDtlService;
         private readonly IBizTestRecordDtlService _iBizTestRecordDtlService;
+        private readonly IBasicDeviceService _iBasicDeviceService;
+        private readonly IBasicDeviceKindService _iBasicDeviceKindService;
+        private readonly IBasicProjectService _iBasicProjectService;
+        private readonly IBizTestRecordService _iBizTestRecordService;
+        private readonly IBasicPlcTestSchemeDtlService _iBasicPlcTestSchemeDtlService;
         private readonly ILogger _logger;
         private readonly IMapper _mapper;
-        private List<SchDtlWithResultModel> allConfigList = new List<SchDtlWithResultModel>();//所有方案
-        private List<SchDtlWithResultModel> conditionConfig = new List<SchDtlWithResultModel>();//符合条件的方案
+
+        private List<DeviceDtlWithResultModel> allDeviceList = new List<DeviceDtlWithResultModel>();//所有方案
+        private List<DeviceDtlWithResultModel> conditionDevices = new List<DeviceDtlWithResultModel>();//符合条件的方案
         private int allSchCount = 0; //所有测试项
-        public StatisticsViewModel(IDialogService dialog, IMenuService menuService, IOptionConfigService optionConfigService, IBasicPlcTestSchemeService basicPlcTestSchemeService, IBasicPlcTestSchemeDtlService basicPlcTestSchemeDtlService, IBizTestRecordDtlService iBizTestRecordDtlService, IMapper mapper, ILogger logger)
+        public StatisticsViewModel(IDialogService dialog, IMenuService menuService, IOptionConfigService optionConfigService, IBasicPlcTestSchemeService basicPlcTestSchemeService, IBasicPlcTestSchemeDtlService basicPlcTestSchemeDtlService, IBizTestRecordDtlService iBizTestRecordDtlService, IBasicDeviceKindService iBasicDeviceKindService, IBasicProjectService iBasicProjectService, IBizTestRecordService iBizTestRecordService, IBasicPlcTestSchemeDtlService iBasicPlcTestSchemeDtlService, IBasicDeviceService iBasicDeviceService,IMapper mapper, ILogger logger)
         {
             _dialog = dialog;
             _optionConfigService = optionConfigService;
             _basicPlcTestSchemeService = basicPlcTestSchemeService;
             _basicPlcTestSchemeDtlService = basicPlcTestSchemeDtlService;
             _iBizTestRecordDtlService = iBizTestRecordDtlService;
+
+             _iBasicDeviceKindService= iBasicDeviceKindService;
+            _iBasicProjectService = iBasicProjectService;
+            _iBizTestRecordService = iBizTestRecordService;
+            _iBasicPlcTestSchemeDtlService = iBasicPlcTestSchemeDtlService;
+            _iBasicDeviceService = iBasicDeviceService;
             _logger = logger;
             _mapper = mapper;
             PieSeriesCollectionDone = new SeriesCollection();
@@ -49,101 +61,112 @@ namespace BlankApp1.ViewModels
 
         private void OnLoad()
         {
-            GetContent();
+            GetProjectConfig();
             GetPieSeriesDone();
             GetPieSeriesPLC();
             GetPieSeriesEveryDay();
             GetPieSeriesFail();
         }
+ 
         /// <summary>
-        /// 获取解决方案
+        /// 获取所有项目
         /// </summary>
-        private void GetContent()
+        private void GetProjectConfig()
         {
-            allSchCount = 0;
+            allDeviceList.Clear();
+            conditionDevices.Clear();
             //所有测试方案
             var schlist = _basicPlcTestSchemeService.QueryList();
-            var configList = _mapper.Map<List<bas_plc_test_scheme>, List<BasicPlcTestSchemeDto>>(schlist);
-            //清空集合
-            BaseConfigList.Clear();
-            allConfigList.Clear();
-            conditionConfig.Clear();
-            //查找测试项名称
-            foreach (var sch in configList)
+            var schDtoList = _mapper.Map<List<bas_plc_test_scheme>, List<BasicPlcTestSchemeDto>>(schlist);
+            //测试记录中的所有设备
+            var deviceIds = _iBizTestRecordService.QueryList().Select(X => X.device_id).Distinct();
+            foreach (var deviceId in deviceIds)
             {
-                long schId = sch.SchemeId;
-                //在解决方案详细表中查找所有的测试项
-                var items = _basicPlcTestSchemeDtlService.FindAllBySchId(schId);
-                foreach (var item in items)
+                var deviceMsg = _iBasicDeviceService.Find(((int)deviceId));
+                if (deviceMsg != null)
                 {
-                    //上面是测试方案明细
-                    SchDtlWithResultModel basicPlcTestSchemeDto = new SchDtlWithResultModel();
-                    basicPlcTestSchemeDto.SchemeId = item.scheme_dtl_id;
-                    basicPlcTestSchemeDto.SchemeName = sch.SchemeName;
-                    basicPlcTestSchemeDto.DeviceKindName = sch.DeviceKindName;
-                    switch (item.item_type)
-                    {
-                        case 0:
-                            basicPlcTestSchemeDto.ItemType = "前置项";
-                            break;
-                        case 1:
-                            basicPlcTestSchemeDto.ItemType = "PLC点位测试项";
-                            break;
-                        case 2:
-                            basicPlcTestSchemeDto.ItemType = "Robot动作测试";
-                            break;
-                    }
+                    //查找哦记录有的方案
 
-                    basicPlcTestSchemeDto.ItemName = item.item_name;
-                    basicPlcTestSchemeDto.CreateBy = sch.CreateBy;
-                    basicPlcTestSchemeDto.CreateTime = sch.CreateTime;
-                    //这里是测试项 结果和 测试记录明细状态
-                    var recordDetail = _iBizTestRecordDtlService.FindRecordDetailBySchDtlID(item.scheme_dtl_id);
-                    if (recordDetail != null)
+                    var recordMsgs = _iBizTestRecordService.FindRecordByDeviceId(deviceId);
+                    foreach (var sch in recordMsgs)
                     {
-                        basicPlcTestSchemeDto.StartTestTime = recordDetail.start_test_time.Value;
-                        basicPlcTestSchemeDto.FinishTestTime = recordDetail.finish_test_time.Value;
-                        basicPlcTestSchemeDto.TestMode = recordDetail.test_mode;
-                        switch (recordDetail.test_result)
+                        string deviceKindName = _iBasicDeviceKindService.Find((int)deviceMsg.device_kind_id)?.devicekind_name;
+                        string projectName = _iBasicProjectService.Find((int)deviceMsg.project_id)?.project_name;
+                        long schId = (long)_basicPlcTestSchemeService.FindByNameAndType(sch.scheme_name, deviceKindName)?.scheme_id;
+                        //计算测试结果
+                        string testResult = string.Empty;
+                        int countResult = 0;
+                        var records = _iBizTestRecordDtlService.FindRecordDetailByRecordID(sch.record_id);
+                        //
+                        var schDtls = _iBasicPlcTestSchemeDtlService.FindAllBySchId(schId);
+                        //循环所有测试项,有一个不合格,则整个测试方案不合格
+                        foreach (var dtl in schDtls)
                         {
-                            case 0:
-                                basicPlcTestSchemeDto.TestResult = "不通过";
-                                break;
-                            case 1:
-                                basicPlcTestSchemeDto.TestResult = "通过";
-                                break;
+                            //选取开始时间最大的一个数据,查看测试结果
+                            long schDtId = dtl.scheme_dtl_id;
+                            var findRecords = records.FindAll(x => x.scheme_dtl_id == schDtId).OrderByDescending(x => x.start_test_time).ToArray();
+                            if (findRecords.Length > 0)
+                            {
+                                int result = (int)findRecords[0]?.test_result.Value;
+                                if (result == 0)
+                                {
+                                    testResult = "不通过";
+                                    break;
+                                }
+                                else
+                                {
+                                    countResult++;
+                                }
+                            }
                         }
-
-                        switch (recordDetail.status)
+                        //测试结果
+                        if (countResult == schDtls.Count)
                         {
-                            case 0:
-                                basicPlcTestSchemeDto.TestStatus = "未测试";
-                                break;
-                            case 99:
-                                basicPlcTestSchemeDto.TestStatus = "已测试";
-                                break;
+                            testResult = "通过";
                         }
-                        allConfigList.Add(basicPlcTestSchemeDto);
-                        conditionConfig.Add(basicPlcTestSchemeDto);
 
+
+                        allDeviceList.Add(new DeviceDtlWithResultModel()
+                        {
+                            RecordId = sch.record_id,
+                            DeviceId = deviceMsg.device_id,
+                            DeviceNo = deviceMsg.device_no,
+                            DeviceName = deviceMsg.device_name,
+                            DeviceKindName = deviceKindName,
+                            ProjectName = projectName,
+                            SchemeName = sch.scheme_name,
+                            SchemeId = schId,
+                            StartTestTime = sch.start_test_time.Value,
+                            TestResult = testResult
+                        });
+                        conditionDevices.Add(new DeviceDtlWithResultModel()
+                        {
+                            RecordId = sch.record_id,
+                            DeviceId = deviceMsg.device_id,
+                            DeviceNo = deviceMsg.device_no,
+                            DeviceName = deviceMsg.device_name,
+                            DeviceKindName = deviceKindName,
+                            ProjectName = projectName,
+                            SchemeName = sch.scheme_name,
+                            SchemeId = schId,
+                            StartTestTime = sch.start_test_time.Value,
+                            TestResult = testResult
+                        });
                     }
-                    //统计所有测试项个数
-                    allSchCount++;
+
                 }
-                conditionConfig = conditionConfig.OrderBy(x => x.SchemeName).ThenBy(x=>x.SchemeId).ToList();
-                //默认显示的第一页
-                Getpage();
-            }
 
+            }
+            conditionDevices = conditionDevices.OrderBy(x => x.DeviceId).ToList();
+            Getpage();
         }
-
         /// <summary>
         /// 获取页面
         /// </summary>
         private void Getpage()
         {
             CurrentPage = 1;
-            TotalCount = conditionConfig.Count;
+            TotalCount = conditionDevices.Count;
             CurrentPageChanged();
 
 
@@ -154,11 +177,11 @@ namespace BlankApp1.ViewModels
         private void CurrentPageChanged()
         {
 
-            BaseConfigList.Clear();
+            DeviceResultItemList.Clear();
 
-            foreach (var i in conditionConfig.Skip((CurrentPage - 1) * CountPerPage).Take(CountPerPage))
+            foreach (var i in conditionDevices.Skip((CurrentPage - 1) * CountPerPage).Take(CountPerPage))
             {
-                BaseConfigList.Add(i);
+                DeviceResultItemList.Add(i);
             }
         }
         private void GetPieSeriesDone()
@@ -190,8 +213,8 @@ namespace BlankApp1.ViewModels
         private void GetPieSeriesPLC()
         {
             PieSeriesCollectionPLC.Clear();
-            int succTest = allConfigList.FindAll(x => x.TestResult == "通过").Count;
-            int noSuccTest = allConfigList.FindAll(x => x.TestResult == "不通过").Count;
+            int succTest = allDeviceList.FindAll(x => x.TestResult == "通过").Count;
+            int noSuccTest = allDeviceList.FindAll(x => x.TestResult == "不通过").Count;
             ChartValues<int> chartvalue = new ChartValues<int>();
             chartvalue.Add(succTest);
 
@@ -215,8 +238,8 @@ namespace BlankApp1.ViewModels
         private void GetPieSeriesFail()
         {
             PieSeriesCollectionFail.Clear();
-            int succTest = allConfigList.FindAll(x => x.TestResult == "通过").Count;
-            int noSuccTest = allConfigList.FindAll(x => x.TestResult == "不通过").Count;
+            int succTest = allDeviceList.FindAll(x => x.TestResult == "通过").Count;
+            int noSuccTest = allDeviceList.FindAll(x => x.TestResult == "不通过").Count;
             ChartValues<int> chartvalue = new ChartValues<int>();
             chartvalue.Add(succTest);
             ChartValues<int> noChartvalue = new ChartValues<int>();
@@ -240,7 +263,7 @@ namespace BlankApp1.ViewModels
         private void GetPieSeriesEveryDay()
         {
             PieSeriesCollectionEveryday.Clear();
-            int dayTest = allConfigList.FindAll(x => x.StartTestTime.Date == DateTime.Now.Date).Count;
+            int dayTest = allDeviceList.FindAll(x => x.StartTestTime.Date == DateTime.Now.Date).Count;
             ChartValues<int> chartvalue = new ChartValues<int>();
             chartvalue.Add(dayTest);
             PieSeries series = new PieSeries();
@@ -312,11 +335,11 @@ namespace BlankApp1.ViewModels
             set { currentPage = value; RaisePropertyChanged(); CurrentPageChanged(); }
         }
 
-        private ObservableCollection<SchDtlWithResultModel> baseConfigList = new ObservableCollection<SchDtlWithResultModel>();
-        public ObservableCollection<SchDtlWithResultModel> BaseConfigList
+        private ObservableCollection<DeviceDtlWithResultModel> deviceResultItemList = new ObservableCollection<DeviceDtlWithResultModel>();
+        public ObservableCollection<DeviceDtlWithResultModel> DeviceResultItemList
         {
-            get { return baseConfigList; }
-            set { SetProperty(ref baseConfigList, value); }
+            get { return deviceResultItemList; }
+            set { deviceResultItemList = value; RaisePropertyChanged(); }
         }
         #endregion
         #region 命令绑定

+ 0 - 170
BlankApp1/BlankApp1/Views/BusinessManageView/QueryView.xaml

@@ -1,170 +0,0 @@
-<UserControl x:Class="BlankApp1.Views.QueryView"
-             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
-             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
-             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
-             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
-             xmlns:local="clr-namespace:BlankApp1.Views"
-             xmlns:myContr="clr-namespace:BlankApp1.Controls"
-             xmlns:hc="https://handyorg.github.io/handycontrol"
-             xmlns:wpfdev="https://github.com/WPFDevelopersOrg/WPFDevelopers"
-             xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
-             mc:Ignorable="d" 
-             d:DesignHeight="450" d:DesignWidth="800">
-    <Grid >
-        <b:Interaction.Triggers>
-            <b:EventTrigger EventName="Loaded">
-                <b:InvokeCommandAction Command="{Binding OnLoadCommand}"/>
-            </b:EventTrigger>
-        </b:Interaction.Triggers>
-        <Grid.RowDefinitions>
-            <RowDefinition Height="40"/>
-            <RowDefinition Height="40"/>
-            <RowDefinition/>
-            <RowDefinition Height="40"/>
-            <RowDefinition/>
-            <RowDefinition Height="40"/>
-        </Grid.RowDefinitions>
-        <UniformGrid Grid.Row="0" Columns="4">
-            <StackPanel Orientation="Horizontal">
-                <TextBlock Text="测试方案名称:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0"/>
-                <TextBox  Height="28" Width="120" Text="{Binding ScheduleName}" />
-            </StackPanel>
-            <StackPanel Orientation="Horizontal">
-                <TextBlock Text="设备类型:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0"/>
-                <TextBox  Height="28" Width="120" Text="{Binding DeviceKindName}"/>
-            </StackPanel>
-            <StackPanel Orientation="Horizontal" >
-                <TextBlock Text="测试项类型:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0"/>
-                <ComboBox  Height="28" Width="120" ItemsSource="{Binding TestKinds}" SelectedItem="{Binding SelectTest}" />
-            </StackPanel>
-            <StackPanel Orientation="Horizontal">
-                <TextBlock Text="测试项名称:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0"/>
-                <TextBox  Height="28" Width="120"  Text="{Binding TestName}"/>
-            </StackPanel>
-
-
-        </UniformGrid>
-        <Grid Grid.Row="1">
-            <Grid.ColumnDefinitions>
-                <ColumnDefinition/>
-                <ColumnDefinition/>
-            </Grid.ColumnDefinitions>
-            <StackPanel Grid.Column="0" Orientation="Horizontal">
-                <StackPanel Orientation="Horizontal">
-                    <TextBlock Text="创建时间:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0"/>
-                    <hc:DateTimePicker ShowClearButton="True" Style="{StaticResource DateTimePickerExtend}" Height="25" Width="160" SelectedDateTime="{Binding StartTime}" />
-                </StackPanel>
-                <StackPanel Orientation="Horizontal">
-                    <TextBlock Text="至:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0"/>
-                    <hc:DateTimePicker ShowClearButton="True" Style="{StaticResource DateTimePickerExtend}" Height="25" Width="160" SelectedDateTime="{Binding EndTime}"/>
-                </StackPanel>
-            </StackPanel>
-            <StackPanel Grid.Column="1" Orientation="Horizontal">
-
-                <Button  Content="查询" Width="80"  Margin="5,0"  Command="{Binding QueryCommand}" Style="{StaticResource NormalButtonStyle}" />
-                <Button  Content="重置" Width="80"  Margin="5,0"  Command="{Binding ResetCommand}" Style="{StaticResource NormalButtonStyle}" />
-                <Button  Content="导出Excel" Width="80"  Margin="5,0"  Command="{Binding ExportCommand}" Style="{StaticResource NormalButtonStyle}" />
-            </StackPanel>
-        </Grid>
-        <DataGrid  Grid.Row="2"  ColumnWidth="*" AutoGenerateColumns="False" HeadersVisibility="All" CanUserAddRows="False"  SelectionUnit="FullRow" SelectionMode="Single"   RowHeaderWidth="0"
-                ColumnHeaderStyle="{StaticResource ColumnHeaderStyle}"  RowHeaderStyle="{StaticResource RowHeaderStyle}" RowStyle="{StaticResource DataGridRowtyle}"  AlternationCount="2"
-               ItemsSource="{Binding BaseConfigList}" IsReadOnly="True" Padding="0" >
-            <DataGrid.Columns >
-                <DataGridTextColumn Header="序号" Binding="{Binding SchemeId}" CellStyle="{StaticResource MyDataGridCellStyle}" />
-                <DataGridTextColumn Header="测试方案名称" Binding="{Binding SchemeName}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-                <DataGridTextColumn Header="设备类型" Binding="{Binding DeviceKindName}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-                <DataGridTextColumn Header="测试项类型" Binding="{Binding ItemType}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-                <DataGridTextColumn Header="测试项名称" Binding="{Binding ItemName}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-                <DataGridTextColumn Header="测试时间" Binding="{Binding StartTestTime,StringFormat={}{0:yyyy-MM-dd HH:mm:ss}}" Width="150" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-                <DataGridTextColumn Header="测试结果" Binding="{Binding TestResult}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-                <DataGridTextColumn Header="状态" Binding="{Binding TestStatus}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-                <DataGridTextColumn Header="创建者" Binding="{Binding CreateBy}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-                <DataGridTemplateColumn Header="操作" Width="180"  CellStyle="{StaticResource MyDataGridCellStyle}">
-                    <DataGridTemplateColumn.CellTemplate>
-                        <DataTemplate>
-                            <UniformGrid Columns="2">
-                                <Button  Width="auto" Background="Transparent" HorizontalContentAlignment ="Left" Foreground="Black" Height="25" BorderThickness="0"
-                                        Command="{Binding DataContext.CheckDetailCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" CommandParameter="{Binding SchemeId}" Cursor="Hand" Margin="0,0,5,0" >
-
-                                    <StackPanel Orientation="Horizontal">
-                                        <TextBlock  Text="查看详情" VerticalAlignment="Center" Foreground="Blue"/>
-                                    </StackPanel>
-                                </Button>
-                                <Button  Width="auto" Background="Transparent" HorizontalContentAlignment ="Left" Foreground="Black" Height="25" BorderThickness="0"
-                 Command="{Binding DataContext.PdfReportCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" CommandParameter="{Binding SchemeId}" Cursor="Hand" >
-
-                                    <StackPanel Orientation="Horizontal">
-                                        <TextBlock  Text="生成pdf报表" VerticalAlignment="Center" Foreground="Blue"/>
-                                    </StackPanel>
-                                </Button>
-
-                            </UniformGrid>
-                        </DataTemplate>
-                    </DataGridTemplateColumn.CellTemplate>
-                </DataGridTemplateColumn>
-            </DataGrid.Columns>
-
-        </DataGrid>
-        <Grid Grid.Row="3" HorizontalAlignment="Center" VerticalAlignment="Center">
-            <wpfdev:Pagination IsLite="False"    Margin="0"  Width="auto" Height="30" HorizontalAlignment="Center"  
-                     Count="{Binding TotalCount,Mode=TwoWay}" 
-                     CountPerPage="{Binding CountPerPage,Mode=TwoWay}"
-                     Current="{Binding CurrentPage,Mode=TwoWay}"/>
-
-        </Grid>
-
-        <DataGrid  Grid.Row="4"  ColumnWidth="*" AutoGenerateColumns="False" HeadersVisibility="All" CanUserAddRows="False"  SelectionUnit="FullRow" SelectionMode="Single"   RowHeaderWidth="0"
-            ColumnHeaderStyle="{StaticResource ColumnHeaderStyle}"  RowHeaderStyle="{StaticResource RowHeaderStyle}" RowStyle="{StaticResource DataGridRowtyle}"  AlternationCount="2"
-           ItemsSource="{Binding DeviceItemList}" IsReadOnly="True" Padding="0"  >
-            <DataGrid.Columns >
-                <DataGridTextColumn Header="序号" Width="50" Binding="{Binding DeviceId}" CellStyle="{StaticResource MyDataGridCellStyle}" />
-                <DataGridTextColumn Header="设备编号" Binding="{Binding DeviceNo}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-                <DataGridTextColumn Header="设备名称" Binding="{Binding DeviceName}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-                <DataGridTextColumn Header="项目名称" Binding="{Binding ProjectName}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-                <DataGridTextColumn Header="设备类型" Binding="{Binding DeviceKindName}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-                <DataGridTextColumn Header="测试方案名称" Binding="{Binding SchemeName}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-                <DataGridTextColumn Header="测试时间" Binding="{Binding StartTestTime}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-                <DataGridTextColumn Header="测试结果" Binding="{Binding TestResult}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-                <!--<DataGridTextColumn Header="创建者" Binding="{Binding CreateBy}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-          <DataGridTextColumn Header="创建时间" Binding="{Binding CreateTime,StringFormat={}{0:yyyy-MM-dd HH:mm:ss}}" CellStyle="{StaticResource MyDataGridCellStyle}"/>-->
-                <DataGridTemplateColumn Header="操作" Width="180"  CellStyle="{StaticResource MyDataGridCellStyle}">
-                    <DataGridTemplateColumn.CellTemplate>
-                        <DataTemplate>
-                            <UniformGrid Columns="2">
-                                <Button  Width="auto" Background="Transparent" HorizontalContentAlignment ="Left" Foreground="Black" Height="25" BorderThickness="0"
-                            Command="{Binding DataContext.CheckDetailCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" CommandParameter="{Binding SchemeId}" Cursor="Hand" Margin="0,0,5,0" >
-
-                                    <StackPanel Orientation="Horizontal">
-                                        <TextBlock  Text="查看详情" VerticalAlignment="Center" Foreground="Blue"/>
-                                    </StackPanel>
-                                </Button>
-                                <Button  Width="auto" Background="Transparent" HorizontalContentAlignment ="Left" Foreground="Black" Height="25" BorderThickness="0"
-     Command="{Binding DataContext.PdfReportCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" CommandParameter="{Binding SchemeId}" Cursor="Hand" >
-
-                                    <StackPanel Orientation="Horizontal">
-                                        <TextBlock  Text="生成pdf报表" VerticalAlignment="Center" Foreground="Blue"/>
-                                    </StackPanel>
-                                </Button>
-
-                            </UniformGrid>
-                        </DataTemplate>
-                    </DataGridTemplateColumn.CellTemplate>
-                </DataGridTemplateColumn>
-            </DataGrid.Columns>
-
-        </DataGrid>
-        <Grid Grid.Row="5" HorizontalAlignment="Center" VerticalAlignment="Center">
-            <wpfdev:Pagination IsLite="False"    Margin="0"  Width="auto" Height="30" HorizontalAlignment="Center"  
-                 Count="{Binding TotalCount,Mode=TwoWay}" 
-                 CountPerPage="{Binding CountPerPage,Mode=TwoWay}"
-                 Current="{Binding CurrentPage,Mode=TwoWay}"/>
-            <!--<hc:Pagination MaxPageCount="10" PageIndex="{Binding PageIndex}" IsJumpEnabled="True">
-          <hc:Interaction.Triggers>
-              <hc:EventTrigger EventName="PageUpdated">
-                  <hc:EventToCommand Command="{Binding PageUpdatedCmd}" PassEventArgsToCommand="True" />
-              </hc:EventTrigger>
-          </hc:Interaction.Triggers>
-      </hc:Pagination>-->
-        </Grid>
-    </Grid>
-</UserControl>

+ 3 - 4
BlankApp1/BlankApp1/Views/BusinessManageView/ResultQueryView.xaml

@@ -82,11 +82,10 @@
                 <DataGridTextColumn Header="项目名称" Binding="{Binding ProjectName}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
                 <DataGridTextColumn Header="设备类型" Binding="{Binding DeviceKindName}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
                 <DataGridTextColumn Header="测试方案名称" Binding="{Binding SchemeName}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-                <DataGridTextColumn Header="测试时间" Binding="{Binding StartTestTime}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+               
+                <DataGridTextColumn Header="测试时间" Width="150" Binding="{Binding StartTestTime,StringFormat={}{0:yyyy-MM-dd HH:mm:ss}}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
                 <DataGridTextColumn Header="测试结果" Binding="{Binding TestResult}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-                <!--<DataGridTextColumn Header="创建者" Binding="{Binding CreateBy}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-     <DataGridTextColumn Header="创建时间" Binding="{Binding CreateTime,StringFormat={}{0:yyyy-MM-dd HH:mm:ss}}" CellStyle="{StaticResource MyDataGridCellStyle}"/>-->
-                <DataGridTemplateColumn Header="操作" Width="240"  CellStyle="{StaticResource MyDataGridCellStyle}">
+                <DataGridTemplateColumn Header="操作" Width="260"  CellStyle="{StaticResource MyDataGridCellStyle}">
                     <DataGridTemplateColumn.CellTemplate>
                         <DataTemplate>
                             <UniformGrid Columns="3">

+ 319 - 0
BlankApp1/BlankApp1/Views/BusinessManageView/RetryTestView.xaml

@@ -0,0 +1,319 @@
+<UserControl x:Class="PLCTool.Views.BusinessManageView.RetryTestView"
+             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
+             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
+             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
+             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
+             xmlns:local="clr-namespace:PLCTool.Views.BusinessManageView"
+                        xmlns:hc="https://handyorg.github.io/handycontrol"
+             xmlns:prism="http://prismlibrary.com/" 
+             xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
+             xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
+             BorderBrush="#CBCBCB" BorderThickness="1"
+             Height="600" Width="1100" >
+
+    <UserControl.Resources>
+        <Style TargetType="TextBlock" x:Key="textBlockStyle">
+            <Setter Property="Width" Value="80"/>
+            <Setter Property="FontSize" Value="12"/>
+            <Setter Property="VerticalAlignment" Value="Center"/>
+            <Setter Property="TextAlignment" Value="Right"/>
+            <Setter Property="Margin" Value="0,0,5,0"/>
+        </Style>
+        <Style TargetType="ListBoxItem">
+            <Style.Triggers>
+                <Trigger Property="ListBoxItem.IsSelected" Value="True">
+                    <Setter Property="ListBoxItem.Background" Value="red"/>
+                </Trigger>
+
+            </Style.Triggers>
+        </Style>
+
+
+    </UserControl.Resources>
+
+    <Grid>
+        <Grid.ColumnDefinitions>
+            <ColumnDefinition Width="90"/>
+            <ColumnDefinition/>
+        </Grid.ColumnDefinitions>
+        <DockPanel Grid.Column="0" LastChildFill="True">
+            <TextBlock Text="测试项列表:"  Style="{StaticResource NormalTextBlockStyle}" Margin="5,0,5,0" DockPanel.Dock="Top"/>
+            <ListBox ItemsSource="{Binding SchItems}" SelectedValue="{Binding SelectItem}" SelectedIndex="{Binding SelectItemIndex}" >
+
+                <b:Interaction.Triggers>
+                    <b:EventTrigger EventName="SelectionChanged">
+                        <b:InvokeCommandAction Command="{Binding ItemChangeCommand}"/>
+                    </b:EventTrigger>
+                </b:Interaction.Triggers>
+            </ListBox>
+
+        </DockPanel>
+        <Border Grid.Column="0"  BorderBrush="#CBCBCB" BorderThickness="1,0" />
+        <Grid Grid.Column="1">
+            <Grid.RowDefinitions>
+
+                <RowDefinition Height="50" />
+                <RowDefinition />
+                <RowDefinition />
+                <RowDefinition />
+                <RowDefinition Height="50" />
+                <RowDefinition Height="50" />
+            </Grid.RowDefinitions>
+
+            <StackPanel Orientation="Horizontal" Grid.Row="0" Margin="10">
+                <StackPanel Orientation="Horizontal">
+                    <TextBlock Text="测试方案名称:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0"/>
+                    <TextBox  Height="28" Width="120" Text="{Binding ScheduleName}" IsReadOnly="True" />
+                </StackPanel>
+                <StackPanel Orientation="Horizontal">
+                    <TextBlock Text="设备类型:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0"/>
+                    <TextBox  Height="28" Width="120" Text="{Binding DeviceKindName}" IsReadOnly="True" />
+                </StackPanel>
+                <StackPanel Orientation="Horizontal" >
+                    <TextBlock Text="测试项类型:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0"/>
+                    <TextBox  Height="28" Width="120"  Text="{Binding SelectTest}" IsReadOnly="True"  />
+                </StackPanel>
+                <StackPanel Orientation="Horizontal">
+                    <TextBlock Text="测试项名称:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0"/>
+                    <TextBox  Height="28" Width="160"  Text="{Binding TestName}" IsReadOnly="True" />
+                </StackPanel>
+
+            </StackPanel>
+            <Border Grid.Row="0"  BorderBrush="#CBCBCB" BorderThickness="0,1" />
+            <Grid Grid.Row="1">
+                <Grid.ColumnDefinitions>
+                    <ColumnDefinition Width="80"/>
+                    <ColumnDefinition/>
+                    <ColumnDefinition Width="1.6*"/>
+                </Grid.ColumnDefinitions>
+                <TextBlock Grid.Column="0" Text="前置项" Style="{StaticResource NormalTextBlockStyle}" TextAlignment="Center">
+                </TextBlock>
+                <Border Grid.Column="1"  BorderBrush="#CBCBCB" BorderThickness="1,0" />
+                <Grid Grid.Column="1">
+                    <Grid.RowDefinitions>
+                        <RowDefinition/>
+                        <RowDefinition/>
+                        <RowDefinition Height="2*"/>
+                    </Grid.RowDefinitions>
+                    <Grid Grid.Row="0">
+                        <StackPanel Orientation="Horizontal" >
+                            <TextBlock Text="测试项类型:"  Style="{StaticResource textBlockStyle}"/>
+                            <TextBox  Height="28" Width="150"  Text="{Binding BeforeSelectJudge}" IsReadOnly="True"  />
+                        </StackPanel>
+                    </Grid>
+                    <Grid Grid.Row="1"  >
+                        <StackPanel Orientation="Horizontal" >
+                            <TextBlock Text="明细判定逻辑:"  Style="{StaticResource textBlockStyle}"/>
+                            <TextBox  Height="28" Width="150" Text="{Binding SelectLogic}" IsReadOnly="True" />
+                        </StackPanel>
+                    </Grid>
+                    <Grid Grid.Row="2">
+                        <DockPanel LastChildFill="True" >
+                            <TextBlock Text="前置项描述:"   Style="{StaticResource textBlockStyle}" />
+                            <RichTextBox  Margin="0,5,5,5" IsReadOnly="True" >
+                                <FlowDocument>
+                                    <Paragraph>
+                                        <Run Text="{Binding BeforeDetail,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
+                                    </Paragraph>
+                                </FlowDocument>
+
+                            </RichTextBox>
+                        </DockPanel>
+                    </Grid>
+                </Grid>
+                <Grid Grid.Column="2" >
+                    <Grid.RowDefinitions>
+                        <RowDefinition Height="30"/>
+                        <RowDefinition/>
+                    </Grid.RowDefinitions>
+                    <DockPanel LastChildFill="False">
+                        <TextBlock Text="前置项明细:"   Style="{StaticResource textBlockStyle}" />
+
+                    </DockPanel>
+                    <DataGrid Grid.Row="1"  ColumnWidth="*" AutoGenerateColumns="False" HeadersVisibility="All" CanUserAddRows="False"  SelectionUnit="FullRow" SelectionMode="Single"   RowHeaderWidth="0" HorizontalScrollBarVisibility="Disabled"
+            ColumnHeaderStyle="{StaticResource ColumnHeaderStyle}" x:Name="DeviceDataGrid" RowHeaderStyle="{StaticResource RowHeaderStyle}" RowStyle="{StaticResource DataGridRowtyle}"  AlternationCount="2"
+              ItemsSource="{Binding BeforeConList}"  IsReadOnly="True" Padding="0" >
+                        <DataGrid.Columns >
+                            <DataGridTextColumn Header="序号" Width="40" Binding="{Binding Id}" CellStyle="{StaticResource MyDataGridCellStyle}" />
+                            <DataGridTextColumn Header="PLC地址" Binding="{Binding PlcAddress}" CellStyle="{StaticResource MyDataGridCellStyle}" />
+                            <DataGridTextColumn Header="PLC变量名" Binding="{Binding PlcItem}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                            <DataGridTextColumn Header="判定值" Binding="{Binding PlcValue}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                            <DataGridTextColumn Header="描述" Binding="{Binding Remark}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                            <DataGridTextColumn Header="测试时间" Width="160" Binding="{Binding TestTime,StringFormat={}{0:yyyy-MM-dd HH:mm:ss}}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                            <DataGridTextColumn Header="实际值" Binding="{Binding RealValue}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                            <DataGridTextColumn Header="结果" Binding="{Binding TestResult}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+
+                        </DataGrid.Columns>
+
+                    </DataGrid>
+
+                </Grid>
+            </Grid>
+            <Grid Grid.Row="2">
+                <Grid.ColumnDefinitions>
+                    <ColumnDefinition Width="80"/>
+                    <ColumnDefinition/>
+                    <ColumnDefinition Width="1.6*"/>
+                </Grid.ColumnDefinitions>
+                <TextBlock Grid.Column="0" Text="输入项" Style="{StaticResource NormalTextBlockStyle}" TextAlignment="Center">
+                </TextBlock>
+                <Border Grid.Column="1"  BorderBrush="#CBCBCB" BorderThickness="1,0" />
+                <Grid Grid.Column="1">
+                    <Grid.RowDefinitions>
+                        <RowDefinition/>
+                        <RowDefinition/>
+                        <RowDefinition Height="2*"/>
+                    </Grid.RowDefinitions>
+                    <Grid Grid.Row="0">
+                        <StackPanel Orientation="Horizontal" >
+                            <TextBlock Text="测试项类型:"  Style="{StaticResource textBlockStyle}"/>
+                            <TextBox  Height="28" Width="150"  Text="{Binding SelectInJudge}" IsReadOnly="True" />
+                        </StackPanel>
+                    </Grid>
+                    <Grid Grid.Row="1"  >
+                        <StackPanel Orientation="Horizontal" >
+                            <TextBlock Text="明细判定逻辑:"  Style="{StaticResource textBlockStyle}"/>
+                            <TextBox  Height="28" Width="150"  Text="{Binding InSelectLogic}" IsReadOnly="True" />
+                        </StackPanel>
+                    </Grid>
+                    <Grid Grid.Row="2">
+                        <DockPanel LastChildFill="True" >
+                            <TextBlock Text="输入项描述:"   Style="{StaticResource textBlockStyle}" />
+                            <RichTextBox  Margin="0,5,5,5" IsReadOnly="True"  >
+                                <FlowDocument>
+                                    <Paragraph>
+                                        <Run Text="{Binding InDetail,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
+                                    </Paragraph>
+                                </FlowDocument>
+
+                            </RichTextBox>
+                        </DockPanel>
+                    </Grid>
+                </Grid>
+                <Grid Grid.Column="2" >
+                    <Grid.RowDefinitions>
+                        <RowDefinition Height="30"/>
+                        <RowDefinition/>
+                    </Grid.RowDefinitions>
+                    <DockPanel LastChildFill="False">
+                        <TextBlock Text="输入项明细:"   Style="{StaticResource textBlockStyle}" />
+
+                    </DockPanel>
+                    <DataGrid Grid.Row="1"  ColumnWidth="*" AutoGenerateColumns="False" HeadersVisibility="All" CanUserAddRows="False"  SelectionUnit="FullRow" SelectionMode="Single"   RowHeaderWidth="0" HorizontalScrollBarVisibility="Disabled"
+ ColumnHeaderStyle="{StaticResource ColumnHeaderStyle}" RowHeaderStyle="{StaticResource RowHeaderStyle}" RowStyle="{StaticResource DataGridRowtyle}"  AlternationCount="2"
+   ItemsSource="{Binding InConList}"  IsReadOnly="True" Padding="0">
+                        <DataGrid.Columns >
+                            <DataGridTextColumn Header="序号" Width="40" Binding="{Binding Id}" CellStyle="{StaticResource MyDataGridCellStyle}" />
+                            <DataGridTextColumn Header="PLC地址" Binding="{Binding PlcAddress}" CellStyle="{StaticResource MyDataGridCellStyle}" />
+                            <DataGridTextColumn Header="PLC变量名" Binding="{Binding PlcItem}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                            <DataGridTextColumn Header="判定值" Binding="{Binding PlcValue}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                            <DataGridTextColumn Header="描述" Binding="{Binding Remark}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                            <DataGridTextColumn Header="测试时间" Width="160" Binding="{Binding TestTime,StringFormat={}{0:yyyy-MM-dd HH:mm:ss}}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                            <DataGridTextColumn Header="实际值" Binding="{Binding RealValue}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                            <DataGridTextColumn Header="结果" Binding="{Binding TestResult}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+
+                        </DataGrid.Columns>
+
+                    </DataGrid>
+
+                </Grid>
+            </Grid>
+            <Border Grid.Row="2"  BorderBrush="#CBCBCB" BorderThickness="0,1,0,0" />
+            <Grid Grid.Row="3">
+                <Grid.ColumnDefinitions>
+                    <ColumnDefinition Width="80"/>
+                    <ColumnDefinition/>
+                    <ColumnDefinition Width="1.6*"/>
+                </Grid.ColumnDefinitions>
+                <TextBlock Grid.Column="0" Text="结果项" Style="{StaticResource NormalTextBlockStyle}" TextAlignment="Center">
+                </TextBlock>
+                <Border Grid.Column="1"  BorderBrush="#CBCBCB" BorderThickness="1,0" />
+                <Grid Grid.Column="1">
+                    <Grid.RowDefinitions>
+                        <RowDefinition/>
+                        <RowDefinition/>
+                        <RowDefinition Height="2*"/>
+                    </Grid.RowDefinitions>
+                    <Grid Grid.Row="0">
+                        <StackPanel Orientation="Horizontal" >
+                            <TextBlock Text="测试项类型:"  Style="{StaticResource textBlockStyle}"/>
+                            <TextBox  Height="28" Width="150"  Text="{Binding SelectOutJudge}" IsReadOnly="True" />
+                        </StackPanel>
+                    </Grid>
+                    <Grid Grid.Row="1"  >
+                        <StackPanel Orientation="Horizontal" >
+                            <TextBlock Text="明细判定逻辑:"  Style="{StaticResource textBlockStyle}"/>
+                            <TextBox  Height="28" Width="150"  Text="{Binding OutSelectLogic}" IsReadOnly="True" />
+                        </StackPanel>
+                    </Grid>
+                    <Grid Grid.Row="2">
+                        <DockPanel LastChildFill="True" >
+                            <TextBlock Text="结果项描述:"   Style="{StaticResource textBlockStyle}" />
+                            <RichTextBox  Margin="0,5,5,5" IsReadOnly="True" >
+                                <FlowDocument>
+                                    <Paragraph>
+                                        <Run Text="{Binding OutDetail,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"/>
+                                    </Paragraph>
+                                </FlowDocument>
+
+                            </RichTextBox>
+                        </DockPanel>
+                    </Grid>
+                </Grid>
+                <Grid Grid.Column="2" >
+                    <Grid.RowDefinitions>
+                        <RowDefinition Height="30"/>
+                        <RowDefinition/>
+                    </Grid.RowDefinitions>
+                    <DockPanel LastChildFill="False">
+                        <TextBlock Text="输出项明细:"   Style="{StaticResource textBlockStyle}" />
+                    </DockPanel>
+                    <DataGrid Grid.Row="1"  ColumnWidth="*" AutoGenerateColumns="False" HeadersVisibility="All" CanUserAddRows="False"  SelectionUnit="FullRow" SelectionMode="Single"   RowHeaderWidth="0" HorizontalScrollBarVisibility="Disabled"
+ ColumnHeaderStyle="{StaticResource ColumnHeaderStyle}"  RowHeaderStyle="{StaticResource RowHeaderStyle}" RowStyle="{StaticResource DataGridRowtyle}"  AlternationCount="2"
+   ItemsSource="{Binding OutConList}"  IsReadOnly="True" Padding="0">
+                        <DataGrid.Columns >
+
+                            <DataGridTextColumn Header="序号" Width="40" Binding="{Binding Id}" CellStyle="{StaticResource MyDataGridCellStyle}" />
+                            <DataGridTextColumn Header="PLC地址" Binding="{Binding PlcAddress}" CellStyle="{StaticResource MyDataGridCellStyle}" />
+                            <DataGridTextColumn Header="PLC变量名" Binding="{Binding PlcItem}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                            <DataGridTextColumn Header="判定值" Binding="{Binding PlcValue}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                            <DataGridTextColumn Header="描述" Binding="{Binding Remark}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                            <DataGridTextColumn Header="测试时间" Width="160" Binding="{Binding TestTime,StringFormat={}{0:yyyy-MM-dd HH:mm:ss}}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                            <DataGridTextColumn Header="实际值" Binding="{Binding RealValue}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                            <DataGridTextColumn Header="结果" Binding="{Binding TestResult}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+
+                        </DataGrid.Columns>
+
+                    </DataGrid>
+
+                </Grid>
+            </Grid>
+            <Border Grid.Row="3"  BorderBrush="#CBCBCB" BorderThickness="0,1,0,0" />
+            <Grid Grid.Row="4">
+                <hc:StepBar  StepIndex="{Binding StepIndex}" VerticalAlignment="Center" x:Name="ProSetpBar"  >
+                    <hc:StepBarItem Content="开始"/>
+                    <hc:StepBarItem Content="前置条件满足"/>
+                    <hc:StepBarItem Content="输入明细完成"/>
+                    <hc:StepBarItem Content="结果判定完成"/>
+
+
+                </hc:StepBar>
+            </Grid>
+            <UniformGrid  Grid.Row="5" Columns="4">
+                <Button  Content="开始检测" Width="80" IsEnabled="{Binding StartEnalbe}" Height="30" FontSize="12"   Command="{Binding StartCommand}" Style="{DynamicResource WD.PrimaryButton}" />
+                <Button  Content="上一项" Width="80" IsEnabled="{Binding StartEnalbe}" Height="30" FontSize="12"   Command="{Binding PreviousCommand}" Style="{DynamicResource WD.PrimaryButton}" />
+                <Button  Content="下一项" Width="80" IsEnabled="{Binding StartEnalbe}" Height="30" FontSize="12"   Command="{Binding NextCommand}" Style="{DynamicResource WD.PrimaryButton}" />
+                <Button  Content="完成" Width="80"  IsEnabled="{Binding StartEnalbe}" Height="30" FontSize="12"  Command="{Binding DoneCommand}" Style="{DynamicResource WD.PrimaryButton}" />
+            </UniformGrid>
+            <Grid Grid.Row="2">
+                <StackPanel Orientation="Vertical" HorizontalAlignment="Center">
+                    <hc:CircleProgressBar IsIndeterminate="True" Visibility="{Binding ProVisibility }" Value="50"  Margin="16,0,0,0" Width="100" Height="100" ArcThickness="10" Style="{StaticResource ProgressBarInfoCircle}">
+
+                    </hc:CircleProgressBar>
+                    <TextBlock  Text="判定中..." Foreground="#409EFF" FontSize="30" Visibility="{Binding ProVisibility }"  Width="AUTO" Margin="0,5"/>
+                </StackPanel>
+            </Grid>
+        </Grid>
+
+    </Grid>
+</UserControl>

+ 4 - 5
BlankApp1/BlankApp1/Views/BusinessManageView/QueryView.xaml.cs → BlankApp1/BlankApp1/Views/BusinessManageView/RetryTestView.xaml.cs

@@ -13,17 +13,16 @@ using System.Windows.Media.Imaging;
 using System.Windows.Navigation;
 using System.Windows.Shapes;
 
-namespace BlankApp1.Views
+namespace PLCTool.Views.BusinessManageView
 {
     /// <summary>
-    /// QueryView.xaml 的交互逻辑
+    /// RetryTestView.xaml 的交互逻辑
     /// </summary>
-    public partial class QueryView : UserControl
+    public partial class RetryTestView : UserControl
     {
-        public QueryView()
+        public RetryTestView()
         {
             InitializeComponent();
-            
         }
     }
 }

+ 1 - 1
BlankApp1/BlankApp1/Views/BusinessManageView/TestResultDetailView.xaml

@@ -7,7 +7,7 @@
              xmlns:prism="http://prismlibrary.com/" 
              xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
              BorderBrush="#CBCBCB" BorderThickness="1"
-             Height="600" Width="1000" >
+             Height="600" Width="1050" >
 
     <UserControl.Resources>
         <Style TargetType="TextBlock" x:Key="textBlockStyle">

+ 11 - 12
BlankApp1/BlankApp1/Views/StatisticsView.xaml

@@ -68,24 +68,23 @@
             </UniformGrid>
         </Grid>
         <Grid Grid.Row="1" Margin="5">
-            <DataGrid  Grid.Row="2"  ColumnWidth="*" AutoGenerateColumns="False" HeadersVisibility="All" CanUserAddRows="False"  SelectionUnit="FullRow" SelectionMode="Single"   RowHeaderWidth="0"
-        ColumnHeaderStyle="{StaticResource ColumnHeaderStyle}"  RowHeaderStyle="{StaticResource RowHeaderStyle}" RowStyle="{StaticResource DataGridRowtyle}"  AlternationCount="2"
-       ItemsSource="{Binding BaseConfigList}" IsReadOnly="True"  Padding="0">
+            <DataGrid   ColumnWidth="*" AutoGenerateColumns="False" HeadersVisibility="All" CanUserAddRows="False"  SelectionUnit="FullRow" SelectionMode="Single"   RowHeaderWidth="0"
+            ColumnHeaderStyle="{StaticResource ColumnHeaderStyle}"  RowHeaderStyle="{StaticResource RowHeaderStyle}" RowStyle="{StaticResource DataGridRowtyle}"  AlternationCount="2"
+            ItemsSource="{Binding DeviceResultItemList}" IsReadOnly="True" Padding="0"  >
                 <DataGrid.Columns >
-                    <DataGridTextColumn Header="测试时间" Binding="{Binding StartTestTime,StringFormat={}{0:yyyy-MM-dd HH:mm:ss}}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-                    <DataGridTextColumn Header="测试人" Binding="{Binding CreateBy}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                    <DataGridTextColumn Header="序号" Width="50" Binding="{Binding DeviceId}" CellStyle="{StaticResource MyDataGridCellStyle}" />
+                    <DataGridTextColumn Header="设备编号" Binding="{Binding DeviceNo}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                    <DataGridTextColumn Header="设备名称" Binding="{Binding DeviceName}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                    <DataGridTextColumn Header="项目名称" Binding="{Binding ProjectName}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                    <DataGridTextColumn Header="设备类型" Binding="{Binding DeviceKindName}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
                     <DataGridTextColumn Header="测试方案名称" Binding="{Binding SchemeName}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-                    <DataGridTextColumn Header="测试项类型" Binding="{Binding ItemType}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-                    <DataGridTextColumn Header="测试项名称" Binding="{Binding ItemName}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-                    <DataGridTextColumn Header="测试方式" Binding="{Binding TestMode}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-                    <DataGridTextColumn Header="测试结果" Binding="{Binding TestResult}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-                 
-                   
 
+                    <DataGridTextColumn Header="测试时间" Width="150" Binding="{Binding StartTestTime,StringFormat={}{0:yyyy-MM-dd HH:mm:ss}}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                    <DataGridTextColumn Header="测试结果" Binding="{Binding TestResult}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+            
                 </DataGrid.Columns>
 
             </DataGrid>
-
         </Grid>
         <Grid Grid.Row="2">
             <wpfdev:Pagination IsLite="False"    Margin="0"  Width="auto" Height="30" HorizontalAlignment="Center"