user_lt 1 rok pred
rodič
commit
12cfff66e5

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

@@ -14,6 +14,7 @@ using PLCTool.ViewModels.BusinessManageViewModel;
 using PLCTool.ViewModels.MonitorManageViewModel;
 using PLCTool.Views;
 using PLCTool.Views.BasicConfigView;
+using PLCTool.Views.BusinessManageView;
 using PLCTool.Views.MonitorManageView;
 using Prism.DryIoc;
 using Prism.Ioc;
@@ -52,6 +53,7 @@ namespace BlankApp1
             containerRegistry.Register(typeof(IMapper), GetMapper);
             containerRegistry.RegisterForNavigation<BaseConfigView, BaseConfigViewModel>();
             containerRegistry.RegisterForNavigation<TestTwoView, TestTwoViewModel>();
+            containerRegistry.RegisterForNavigation<TestOperView, TestOperViewModel>();
             containerRegistry.RegisterForNavigation<QueryView, QueryViewModel>();
             containerRegistry.RegisterForNavigation<TreeMenuView, TreeMenuViewModel>();
             containerRegistry.RegisterForNavigation<StatisticsView, StatisticsViewModel>();
@@ -61,9 +63,8 @@ namespace BlankApp1
             containerRegistry.RegisterForNavigation<PLCWriteView, PLCWriteViewModel>();
             containerRegistry.RegisterDialog<PopView, PopViewModel>();
             containerRegistry.RegisterDialog<AddOrEditSchView, AddOrEditSchViewModel>();
-           
             containerRegistry.RegisterDialog<AddDetailView, AddDetailViewModel>();
-            
+            containerRegistry.RegisterDialog<AutoTestView, AutoTestViewModel>();
         }
 
         private IMapper GetMapper(IContainerProvider container)

+ 526 - 0
BlankApp1/BlankApp1/ViewModels/BusinessManageViewModel/AutoTestViewModel.cs

@@ -0,0 +1,526 @@
+using AutoMapper;
+using BizService;
+using Model.Dto;
+using Model.Entities;
+using Newtonsoft.Json;
+using NLog;
+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 AutoTestViewModel : BindableBase, IDialogAware
+    {
+        private readonly IDialogService _dialog;
+        private readonly IEventAggregator _aggregator;
+        private readonly IOptionConfigService _optionConfigService;
+        private readonly IBasicPlcTestSchemeService _basicPlcTestSchemeService;
+        private readonly IBasicPlcTestSchemeDtlService _basicPlcTestSchemeDtlService;
+        private readonly IMapper _mapper;
+        private readonly ILogger _logger;
+        private List<OptionConfigDto> _optionConfigs;
+        public AutoTestViewModel(IDialogService dialog, IEventAggregator aggregator, IOptionConfigService optionConfigService, IBasicPlcTestSchemeService basicPlcTestSchemeService, IBasicPlcTestSchemeDtlService basicPlcTestSchemeDtlService, IMapper mapper)
+        {
+            _dialog = dialog;
+            _aggregator = aggregator;
+            _optionConfigService = optionConfigService;
+            _basicPlcTestSchemeService = basicPlcTestSchemeService;
+            _basicPlcTestSchemeDtlService = basicPlcTestSchemeDtlService;
+            _mapper = mapper;
+            //_logger = logger;
+            CloseCommand = new DelegateCommand(Close);
+            
+            ResetCommand = new DelegateCommand<string>(ResetMethod);
+            
+           
+            BeforeConList = new ObservableCollection<BasPlcItemConfigDto>();
+            InConList = new ObservableCollection<BasPlcItemConfigDto>();
+            OutConList = new ObservableCollection<BasPlcItemConfigDto>();
+            GetConfigOption();
+        }
+
+        #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)
+                {
+                   
+                    int id = Convert.ToInt32(item);
+                    //根据 测试方案明细主键ID 查找测试方案id 及方案名和设备名
+                    var findEntity = _basicPlcTestSchemeDtlService.Find(id);
+                    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)
+                        {
+                            ScheduleName = findSch.scheme_name;
+                            DeviceName = findSch.device_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.PlcItem = detail.PlcItem;
+                                basPlcItemConfigDto.PlcAddress = detail.PlcAddress;
+                                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.PlcItem = detail.PlcItem;
+                                basPlcItemConfigDto.PlcAddress = detail.PlcAddress;
+                                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.PlcItem = detail.PlcItem;
+                                basPlcItemConfigDto.PlcAddress = detail.PlcAddress;
+                                basPlcItemConfigDto.PlcValue = detail.PlcValue;
+                                basPlcItemConfigDto.Remark = detail.Remark;
+                                OutConList.Add(basPlcItemConfigDto);
+                            }
+                        }
+
+                    }
+
+                }
+
+            }
+        }
+
+        #endregion
+       
+
+      
+        
+
+        /// <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>
+
+        /// <summary>
+        /// 关闭按钮
+        /// </summary>
+        private void Close()
+        {
+            RequestClose?.Invoke(new DialogResult(ButtonResult.Cancel));
+        }
+      
+ 
+      
+        /// <summary>
+        /// 方案明细添加到数据库
+        /// </summary>
+        private void AddOrEditDetailsToDb(long scheduleId)
+        {
+            //前置项json转化
+            string prefixJsonStr = ModelToJsonToStr(BeforeSelectJudge, SelectLogic, BeforeDetail, BeforeConList);
+            //输入项json转化
+            string inJsonStr = ModelToJsonToStr(SelectInJudge, InSelectLogic, InDetail, InConList);
+            //输出项json转化
+            string outJsonStr = ModelToJsonToStr(SelectOutJudge, OutSelectLogic, OutDetail, OutConList);
+            //添加达到测试主表
+            //增加测试方案
+            BasicPlcTestSchemeDtlDto schDtlDto = new BasicPlcTestSchemeDtlDto();
+            schDtlDto.SchemeId = scheduleId;
+            schDtlDto.ItemName = TestName;
+
+            schDtlDto.ItemType = SelectTest;
+            schDtlDto.Precondition = prefixJsonStr;
+            schDtlDto.PreconditionDescribe = BeforeDetail;
+            schDtlDto.Action = inJsonStr;
+            schDtlDto.ActionDescribe = InDetail;
+            schDtlDto.JudgementResult = outJsonStr;
+            schDtlDto.JudgementResultDescribe = OutDetail;
+            schDtlDto.CreateBy = Appsession.UserName;
+            schDtlDto.CreateTime = DateTime.Now;
+            schDtlDto.UpdateTime = DateTime.Now;
+            schDtlDto.UpdateBy = Appsession.UserName;
+            bas_plc_test_scheme_dtl schDtlEntity = _mapper.Map<BasicPlcTestSchemeDtlDto, bas_plc_test_scheme_dtl>(schDtlDto);
+            if (Title == "新增方案")
+            {
+
+                bool isAddSucc = _basicPlcTestSchemeDtlService.Add(schDtlEntity);
+                if (isAddSucc)
+                {
+                    _logger.Info($"新增方案成功。方案名{ScheduleName},测试项{TestName}");
+                    MessageBoxResult boxResult = MessageBox.Show("更新成功", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
+                }
+                else
+                {
+                    MessageBoxResult boxResult = MessageBox.Show("更新失败", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+                    return;
+                }
+            }
+            else
+            {
+                if (Title == "编辑方案")
+                {
+                    //修改 必须给主键SchemeDtlId值
+                    var schDtl = _basicPlcTestSchemeDtlService.FindSchDtlIdBySchIdAndItem(scheduleId, TestName);
+                    if (schDtl != null)
+                    {
+                        schDtlDto.SchemeDtlId = schDtl.scheme_dtl_id;
+                        bas_plc_test_scheme_dtl schDtlEntityEdit = _mapper.Map<BasicPlcTestSchemeDtlDto, bas_plc_test_scheme_dtl>(schDtlDto);
+                        bool isSucc = _basicPlcTestSchemeDtlService.Edit(schDtlEntityEdit);
+                        if (isSucc)
+                        {
+                            _logger.Info($"更新方案成功。方案名{ScheduleName},测试项{TestName}");
+                            MessageBoxResult boxResult = MessageBox.Show("更新成功", "提示", MessageBoxButton.OK, MessageBoxImage.Information);
+                        }
+                        else
+                        {
+                            MessageBoxResult boxResult = MessageBox.Show("更新失败", "提示", MessageBoxButton.OK, MessageBoxImage.Warning);
+                            return;
+                        }
+
+                    }
+
+                }
+            }
+
+        }
+        /// <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.PlcItem = item.PlcItem;
+                plcItem.PlcAddress = item.PlcAddress;
+                plcItem.PlcValue = item.PlcValue;
+                plcItem.Remark = item.Remark;
+                prefixJsonModel.DetailInfo.Add(plcItem);
+
+            }
+            string prefixJsonStr = JsonConvert.SerializeObject(prefixJsonModel);
+            return prefixJsonStr;
+        }
+        /// <summary>
+        /// 重置
+        /// </summary>
+        /// <param name="obj"></param>
+        private void ResetMethod(string obj)
+        {
+
+        }
+       
+
+
+
+        #region 命令绑定
+        public DelegateCommand CloseCommand { set; get; }
+        
+        public DelegateCommand<string> ResetCommand { set; get; }
+  
+
+        #endregion
+        #region 变量绑定
+        /// <summary>
+        /// 测试方案编码
+        /// </summary>
+        private string scheduleName;
+        public string ScheduleName
+        {
+            get { return scheduleName; }
+            set { scheduleName = value; RaisePropertyChanged(); }
+        }
+        /// <summary>
+        /// 设备名称
+        /// </summary>
+        private string deviceName;
+        public string DeviceName
+        {
+            get { return deviceName; }
+            set { deviceName = 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(); }
+        }
+        #endregion
+
+    }
+}

+ 206 - 34
BlankApp1/BlankApp1/ViewModels/BusinessManageViewModel/TestOperViewModel.cs

@@ -17,7 +17,7 @@ using System.Windows;
 
 namespace PLCTool.ViewModels.BusinessManageViewModel
 {
-    public class TestOperViewModel: BindableBase
+    public class TestOperViewModel : BindableBase
     {
         private readonly IDialogService _dialog;
         private readonly IOptionConfigService _optionConfigService;
@@ -26,26 +26,115 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
         private readonly ILogger _logger;
         private readonly IMapper _mapper;
         private readonly IMenuService _menuService;
-        public TestOperViewModel(IDialogService dialog, IMenuService menuService, IOptionConfigService optionConfigService, IBasicPlcTestSchemeService basicPlcTestSchemeService, IBasicPlcTestSchemeDtlService basicPlcTestSchemeDtlService, IMapper mapper, ILogger logger)
+
+        private List<BasicPlcTestSchemeDto> allConfigList = new List<BasicPlcTestSchemeDto>();//所有方案
+        private List<BasicPlcTestSchemeDto> conditionConfig = new List<BasicPlcTestSchemeDto>();//所有方案
+
+        private const int PageCount = 1; //每一页显示个数
+        public TestOperViewModel(IDialogService dialog, IMenuService menuService, IOptionConfigService optionConfigService, IBasicPlcTestSchemeService basicPlcTestSchemeService, IBasicPlcTestSchemeDtlService basicPlcTestSchemeDtlService, IMapper mapper)
         {
             _dialog = dialog;
             _optionConfigService = optionConfigService;
             _basicPlcTestSchemeService = basicPlcTestSchemeService;
             _basicPlcTestSchemeDtlService = basicPlcTestSchemeDtlService;
-            _logger = logger;
+            //_logger = logger;
             _mapper = mapper;
             _menuService = menuService;
+            QueryCommand = new DelegateCommand<object>(Query);
+            ResetCommand = new DelegateCommand<object>(Reset);
             ExportCommand = new DelegateCommand<string>(Export);
-            AddPlanCommand = new DelegateCommand<string>(AddPlan);
+       
             EditCommand = new DelegateCommand<object>(Edit);
             DeleteCommand = new DelegateCommand<object>(Delete);
+            //手动  自动测试
+            AutoTestCommand = new DelegateCommand<object>(AutoDest);
+            ManualTestCommand = new DelegateCommand<object>(ManualTest);
             GetConfigOption();
             GetContent();
-           
         }
+
+
+
+
         #region 私有方法
+        private void ManualTest(object obj)
+        {
+            //弹出详情对话框
+            _dialog.ShowDialog("AutoTestView", async callback =>
+            {
+                if (callback.Result == ButtonResult.OK)
+                {
+                    //更新表格,重新获取
+                    GetContent();
+                }
 
+            });
+        }
+        /// <summary>
+        /// 自动测试
+        /// </summary>
+        /// <param name="obj"></param>
+        private void AutoDest(object obj)
+        {
+            //测试方案明细主键ID
+            long id = Convert.ToInt64(obj);
+            DialogParameters parm = new DialogParameters();
+            parm.Add("Key", id);
+            //弹出详情对话框
+            //弹出详情对话框
+            _dialog.ShowDialog("AutoTestView",parm, async callback =>
+            {
+                if (callback.Result == ButtonResult.OK)
+                {
+                    //更新表格,重新获取
+                    GetContent();
+                }
+
+            });
+        }
+
+        /// <summary>
+        /// 重置
+        /// </summary>
+        /// <param name="obj"></param>
+        private void Reset(object obj)
+        {
+            ScheduleName = string.Empty;
+            DeviceName = string.Empty;
+            TestName = string.Empty;
+            SelectTest = string.Empty;
+        }
+        /// <summary>
+        /// 查询
+        /// </summary>
+        /// <param name="obj"></param>
+        private void Query(object obj)
+        {
+            if ((!string.IsNullOrEmpty(StartTime)) && (!string.IsNullOrEmpty(EndTime)))
+            {
+                if (Convert.ToDateTime(StartTime) > Convert.ToDateTime(EndTime))
+                {
+                    MessageBox.Show("起始时间大于结束时间,请重新输入", "确认", MessageBoxButton.OK, MessageBoxImage.Warning);
+                    return;
+                }
+                if (Convert.ToDateTime(StartTime).AddDays(2) < Convert.ToDateTime(EndTime))
+                {
+                    MessageBox.Show("起始时间和结束时间间隔不能大于2天,请重新输入", "确认", MessageBoxButton.OK, MessageBoxImage.Warning);
+                    return;
+                }
+            }
 
+            conditionConfig = (from a in allConfigList
+                               where (EndTime == string.Empty ? 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(DeviceName) ? true : (a.DeviceName == DeviceName))
+                                    && (string.IsNullOrEmpty(SelectTest) ? true : (a.ItemType == SelectTest))
+                               select a).ToList();
+            //默认显示的第一页
+            Getpage();
+            //BaseConfigList = new ObservableCollection<BasicPlcTestSchemeDto>(conditionConfig);
+        }
         /// <summary>
         /// 获取配置
         /// </summary>
@@ -71,7 +160,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
             DialogParameters parm = new DialogParameters();
             parm.Add("Key", id);
             //弹出详情对话框
-            _dialog.ShowDialog("AddPlanView", parm, async callback =>
+            _dialog.ShowDialog("AddOrEditSchView", parm, async callback =>
             {
                 if (callback.Result == ButtonResult.OK)
                 {
@@ -97,24 +186,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                 GetContent();
             }
         }
-        /// <summary>
-        /// 新增按钮
-        /// </summary>
-        /// <param name="obj"></param>
-        private void AddPlan(string obj)
-        {
-
-            //弹出详情对话框
-            _dialog.ShowDialog("AddPlanView", async callback =>
-            {
-                if (callback.Result == ButtonResult.OK)
-                {
-                    //更新表格,重新获取
-                    GetContent();
-                }
-
-            });
-        }
+      
         /// <summary>
         /// excel导出
         /// </summary>
@@ -173,6 +245,8 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
             var configList = _mapper.Map<List<bas_plc_test_scheme>, List<BasicPlcTestSchemeDto>>(schlist);
             //清空集合
             BaseConfigList.Clear();
+            allConfigList.Clear();
+            conditionConfig.Clear();
             //查找测试项名称
             foreach (var sch in configList)
             {
@@ -201,26 +275,90 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                     basicPlcTestSchemeDto.ItemName = item.item_name;
                     basicPlcTestSchemeDto.CreateBy = sch.CreateBy;
                     basicPlcTestSchemeDto.CreateTime = sch.CreateTime;
-                    BaseConfigList.Add(basicPlcTestSchemeDto);
-                }
 
+                    allConfigList.Add(basicPlcTestSchemeDto);
+                    conditionConfig.Add(basicPlcTestSchemeDto);
+
+                }
+                //默认显示的第一页
+                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<string> AddPlanCommand { set; get; }
-        public DelegateCommand<object> EditCommand { set; get; }
 
+        public DelegateCommand<object> EditCommand { set; get; }
+        public DelegateCommand<string> AddPlanCommand { set; get; }
+        public DelegateCommand<object> QueryCommand { set; get; }
+        public DelegateCommand<object> ResetCommand { set; get; }
         public DelegateCommand<object> DeleteCommand { set; get; }
         public DelegateCommand<string> ExportCommand { set; get; }
+
+        public DelegateCommand PageUpdatedCmd { set; get; }
+
+        public DelegateCommand<object> AutoTestCommand { set; get; }
+
+        public DelegateCommand<object> ManualTestCommand { set; get; }
         #endregion
         #region 数据绑定
-
         /// <summary>
-        /// 测试项
+        /// 测试方案编码
+        /// </summary>
+        private string scheduleName;
+        public string ScheduleName
+        {
+            get { return scheduleName; }
+            set { scheduleName = value; RaisePropertyChanged(); }
+        }
+        /// <summary>
+        /// 设备名称
         /// </summary>
+        private string deviceName;
+        public string DeviceName
+        {
+            get { return deviceName; }
+            set { deviceName = 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
         {
@@ -237,11 +375,45 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
             set { selectTest = value; RaisePropertyChanged(); }
         }
 
-        private string myContent = string.Empty;
-        public string MyContent
+        private string startTime = string.Empty;
+        public string StartTime
+        {
+            get { return startTime; }
+            set { startTime = value; RaisePropertyChanged(); }
+        }
+        private string endTime = string.Empty;
+        public string 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 = 1;
+        public int CountPerPage
+        {
+            get { return countPerPage; }
+            set { countPerPage = value; RaisePropertyChanged(); CurrentPageChanged(); }
+        }
+        /// <summary>
+        /// 单前页
+        /// </summary>
+        private int currentPage = 1;
+        public int CurrentPage
         {
-            get { return myContent; }
-            set { SetProperty(ref myContent, value); }
+            get { return currentPage; }
+            set { currentPage = value; RaisePropertyChanged(); CurrentPageChanged(); }
         }
 
         private ObservableCollection<BasicPlcTestSchemeDto> baseConfigList = new ObservableCollection<BasicPlcTestSchemeDto>();

+ 1 - 1
BlankApp1/BlankApp1/Views/BasicConfigView/AddOrEditSchView.xaml

@@ -4,7 +4,7 @@
              xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
              xmlns:local="clr-namespace:PLCTool.Views.BasicConfigView"
-                        xmlns:prism="http://prismlibrary.com/" 
+             xmlns:prism="http://prismlibrary.com/" 
              BorderBrush="#CBCBCB" BorderThickness="1"
              Height="600" Width="1000" >
     <!--<prism:Dialog.WindowStyle>

+ 1 - 1
BlankApp1/BlankApp1/Views/BasicConfigView/BaseConfigView.xaml

@@ -6,7 +6,7 @@
              xmlns:local="clr-namespace:BlankApp1.Views"
              xmlns:hc="https://handyorg.github.io/handycontrol"
              xmlns:myContr="clr-namespace:BlankApp1.Controls"
-               xmlns:wpfdev="https://github.com/WPFDevelopersOrg/WPFDevelopers"
+             xmlns:wpfdev="https://github.com/WPFDevelopersOrg/WPFDevelopers"
              mc:Ignorable="d" 
              d:DesignHeight="450" d:DesignWidth="800">
     <Grid >

+ 330 - 0
BlankApp1/BlankApp1/Views/BusinessManageView/AutoTestView.xaml

@@ -0,0 +1,330 @@
+<UserControl x:Class="PLCTool.Views.BusinessManageView.AutoTestView"
+             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/" 
+             BorderBrush="#CBCBCB" BorderThickness="1"
+             Height="600" Width="1000" >
+   
+    <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>
+    </UserControl.Resources>
+
+    <Grid>
+        <Grid.RowDefinitions>
+
+            <RowDefinition Height="50" />
+            <RowDefinition />
+            <RowDefinition />
+            <RowDefinition />
+            <RowDefinition Height="60" />
+        </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}" />
+            </StackPanel>
+            <StackPanel Orientation="Horizontal">
+                <TextBlock Text="设备名称:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0"/>
+                <TextBox  Height="28" Width="120" Text="{Binding DeviceName}"/>
+            </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="160"  Text="{Binding TestName}"/>
+            </StackPanel>
+            
+        </StackPanel>
+        <Border Grid.Row="0"  BorderBrush="#CBCBCB" BorderThickness="0,1" />
+        <Grid Grid.Row="1">
+            <Grid.ColumnDefinitions>
+                <ColumnDefinition Width="80"/>
+                <ColumnDefinition/>
+                <ColumnDefinition Width="1.3*"/>
+            </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}"/>
+                        <ComboBox  Height="28" Width="150" ItemsSource="{Binding BeforeJudgeKinds}" SelectedItem="{Binding BeforeSelectJudge}" />
+                    </StackPanel>
+                </Grid>
+                <Grid Grid.Row="1"  >
+                    <StackPanel Orientation="Horizontal" >
+                        <TextBlock Text="明细判定逻辑:"  Style="{StaticResource textBlockStyle}"/>
+                        <ComboBox  Height="28" Width="150" ItemsSource="{Binding JudgeLogicKinds}" SelectedItem="{Binding SelectLogic}"/>
+                    </StackPanel>
+                </Grid>
+                <Grid Grid.Row="2">
+                    <DockPanel LastChildFill="True" >
+                        <TextBlock Text="前置项描述:"   Style="{StaticResource textBlockStyle}" />
+                        <RichTextBox  Margin="0,5,5,5" >
+                            <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" >
+                    <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 RealValue}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                        <DataGridTemplateColumn Header="操作" Width="160"  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.EditBeforeCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" CommandParameter="{Binding Id}" Cursor="Hand" Margin="0,0,10,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.DeleteBeforeCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" CommandParameter="{Binding Id}"   Cursor="Hand" >
+
+                                            <StackPanel Orientation="Horizontal">
+                                                <TextBlock  Text="删除" VerticalAlignment="Center" Foreground="Blue"/>
+                                            </StackPanel>
+                                        </Button>
+
+                                    </UniformGrid>
+                                </DataTemplate>
+                            </DataGridTemplateColumn.CellTemplate>
+                        </DataGridTemplateColumn>
+
+                    </DataGrid.Columns>
+
+                </DataGrid>
+
+            </Grid>
+        </Grid>
+        <Grid Grid.Row="2">
+            <Grid.ColumnDefinitions>
+                <ColumnDefinition Width="80"/>
+                <ColumnDefinition/>
+                <ColumnDefinition Width="1.3*"/>
+            </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}"/>
+                        <ComboBox  Height="28" Width="150" ItemsSource="{Binding InJudgeKinds}" SelectedItem="{Binding SelectInJudge}" />
+                    </StackPanel>
+                </Grid>
+                <Grid Grid.Row="1"  >
+                    <StackPanel Orientation="Horizontal" >
+                        <TextBlock Text="明细判定逻辑:"  Style="{StaticResource textBlockStyle}"/>
+                        <ComboBox  Height="28" Width="150" ItemsSource="{Binding InJudgeLogicKinds}" SelectedItem="{Binding InSelectLogic}"/>
+                    </StackPanel>
+                </Grid>
+                <Grid Grid.Row="2">
+                    <DockPanel LastChildFill="True" >
+                        <TextBlock Text="输入项描述:"   Style="{StaticResource textBlockStyle}" />
+                        <RichTextBox  Margin="0,5,5,5" >
+                            <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" >
+                    <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 RealValue}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                        <DataGridTemplateColumn Header="操作" Width="160"  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.EditInCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" CommandParameter="{Binding Id}" Cursor="Hand" Margin="0,0,10,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.DeleteInCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" CommandParameter="{Binding Id}"   Cursor="Hand" >
+
+                                            <StackPanel Orientation="Horizontal">
+                                                <TextBlock  Text="删除" VerticalAlignment="Center" Foreground="Blue"/>
+                                            </StackPanel>
+                                        </Button>
+
+                                    </UniformGrid>
+                                </DataTemplate>
+                            </DataGridTemplateColumn.CellTemplate>
+                        </DataGridTemplateColumn>
+
+                    </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.3*"/>
+            </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}"/>
+                        <ComboBox  Height="28" Width="150" ItemsSource="{Binding OutJudgeKinds}" SelectedItem="{Binding SelectOutJudge}" />
+                    </StackPanel>
+                </Grid>
+                <Grid Grid.Row="1"  >
+                    <StackPanel Orientation="Horizontal" >
+                        <TextBlock Text="明细判定逻辑:"  Style="{StaticResource textBlockStyle}"/>
+                        <ComboBox  Height="28" Width="150" ItemsSource="{Binding OutJudgeLogicKinds}" SelectedItem="{Binding OutSelectLogic}"/>
+                    </StackPanel>
+                </Grid>
+                <Grid Grid.Row="2">
+                    <DockPanel LastChildFill="True" >
+                        <TextBlock Text="结果项描述:"   Style="{StaticResource textBlockStyle}" />
+                        <RichTextBox  Margin="0,5,5,5" >
+                            <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" >
+                    <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 RealValue}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                        <DataGridTemplateColumn Header="操作" Width="160"  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.EditOutCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" CommandParameter="{Binding Id}" Cursor="Hand" Margin="0,0,10,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.DeleteOutCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" CommandParameter="{Binding Id}"   Cursor="Hand" >
+
+                                            <StackPanel Orientation="Horizontal">
+                                                <TextBlock  Text="删除" VerticalAlignment="Center" Foreground="Blue"/>
+                                            </StackPanel>
+                                        </Button>
+
+                                    </UniformGrid>
+                                </DataTemplate>
+                            </DataGridTemplateColumn.CellTemplate>
+                        </DataGridTemplateColumn>
+
+                    </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:StepBar>
+        </Grid>
+    </Grid>
+</UserControl>

+ 28 - 0
BlankApp1/BlankApp1/Views/BusinessManageView/AutoTestView.xaml.cs

@@ -0,0 +1,28 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Windows;
+using System.Windows.Controls;
+using System.Windows.Data;
+using System.Windows.Documents;
+using System.Windows.Input;
+using System.Windows.Media;
+using System.Windows.Media.Imaging;
+using System.Windows.Navigation;
+using System.Windows.Shapes;
+
+namespace PLCTool.Views.BusinessManageView
+{
+    /// <summary>
+    /// AutoTestView.xaml 的交互逻辑
+    /// </summary>
+    public partial class AutoTestView : UserControl
+    {
+        public AutoTestView()
+        {
+            InitializeComponent();
+        }
+    }
+}

+ 22 - 27
BlankApp1/BlankApp1/Views/BusinessManageView/TestOperView.xaml

@@ -6,6 +6,7 @@
              xmlns:local="clr-namespace:PLCTool.Views.BusinessManageView"
              xmlns:hc="https://handyorg.github.io/handycontrol"
              xmlns:myContr="clr-namespace:BlankApp1.Controls"
+             xmlns:wpfdev="https://github.com/WPFDevelopersOrg/WPFDevelopers"
              mc:Ignorable="d" 
              d:DesignHeight="450" d:DesignWidth="800">
     <Grid >
@@ -18,21 +19,21 @@
         </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" />
+                <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" />
-            </StackPanel>
-            <StackPanel Orientation="Horizontal">
-                <TextBlock Text="测试项名称:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0"/>
-                <TextBox  Height="28" Width="120" />
+                <TextBox  Height="28" Width="120" Text="{Binding DeviceName}"/>
             </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>
@@ -44,7 +45,7 @@
             <StackPanel Grid.Column="0" Orientation="Horizontal">
                 <StackPanel Orientation="Horizontal">
                     <TextBlock Text="创建时间:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0"/>
-                    <myContr:MyDateTimePicker ></myContr:MyDateTimePicker>
+                    <myContr:MyDateTimePicker  ></myContr:MyDateTimePicker>
                 </StackPanel>
                 <StackPanel Orientation="Horizontal">
                     <TextBlock Text="至:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0"/>
@@ -54,15 +55,12 @@
             <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 QueryCommand}" Style="{StaticResource NormalButtonStyle}" />
-                <Button  Content="手动测试" Width="80"  Margin="5,0"  Command="{Binding ManualCommand}" Style="{StaticResource NormalButtonStyle}"/>
-
-                <Button Content="自动测试" Width="80"  Margin="5,0"  Command="{Binding AutoCommand}" Style="{StaticResource NormalButtonStyle}" />
+                <Button  Content="重置" Width="80"  Margin="5,0"  Command="{Binding ResetCommand}" 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"  >
+                ColumnHeaderStyle="{StaticResource ColumnHeaderStyle}"  RowHeaderStyle="{StaticResource RowHeaderStyle}" RowStyle="{StaticResource DataGridRowtyle}"  AlternationCount="2"
+               ItemsSource="{Binding BaseConfigList}" IsReadOnly="True"  >
             <DataGrid.Columns >
                 <DataGridTextColumn Header="序号" Binding="{Binding SchemeId}" CellStyle="{StaticResource MyDataGridCellStyle}" />
                 <DataGridTextColumn Header="测试方案名称" Binding="{Binding SchemeName}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
@@ -70,23 +68,23 @@
                 <DataGridTextColumn Header="测试项类型" Binding="{Binding ItemType}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
                 <DataGridTextColumn Header="测试项名称" Binding="{Binding ItemName}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
                 <DataGridTextColumn Header="创建者" Binding="{Binding CreateBy}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-                <DataGridTextColumn Header="创建时间" Binding="{Binding CreateTime}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                <DataGridTextColumn Header="创建时间" Binding="{Binding CreateTime,StringFormat={}{0:yyyy-MM-dd HH:mm:ss}}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
                 <DataGridTemplateColumn Header="操作"  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.EditCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" CommandParameter="{Binding SchemeId}" Cursor="Hand" Margin="0,0,10,0" >
+                                      Command="{Binding DataContext.ManualTestCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" CommandParameter="{Binding SchemeId}" Cursor="Hand" Margin="0,0,10,0" >
 
                                     <StackPanel Orientation="Horizontal">
-                                        <TextBlock  Text="编辑" VerticalAlignment="Center" Foreground="Blue"/>
+                                        <TextBlock  Text="手动测试" VerticalAlignment="Center" Foreground="Blue"/>
                                     </StackPanel>
                                 </Button>
                                 <Button  Width="auto" Background="Transparent" HorizontalContentAlignment ="Left" Foreground="Black" Height="25" BorderThickness="0"
-                                     Command="{Binding DataContext.DeleteCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" CommandParameter="{Binding SchemeId}" Cursor="Hand" >
+                                      Command="{Binding DataContext.AutoTestCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" CommandParameter="{Binding SchemeId}" Cursor="Hand" >
 
                                     <StackPanel Orientation="Horizontal">
-                                        <TextBlock  Text="删除" VerticalAlignment="Center" Foreground="Blue"/>
+                                        <TextBlock  Text="自动测试" VerticalAlignment="Center" Foreground="Blue"/>
                                     </StackPanel>
                                 </Button>
 
@@ -99,14 +97,11 @@
 
         </DataGrid>
         <Grid Grid.Row="3" HorizontalAlignment="Center" VerticalAlignment="Center">
-
-            <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>
+            <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>
 
 

+ 10 - 0
BlankApp1/Model/Dto/BasPlcItemConfigDto.cs

@@ -47,6 +47,16 @@ namespace Model.Dto
             get { return plcValue; }
             set { plcValue = value; OnPropertyChanged(); }
         }
+
+        /// <summary>
+        /// plc实时值(数据库中没有的字段,方便测试时绑定使用)
+        /// </summary>
+        private string realValue { get; set; }
+        public string RealValue
+        {
+            get { return realValue; }
+            set { realValue = value; OnPropertyChanged(); }
+        }
         /// <summary>
         /// Desc:
         /// Default: