Sfoglia il codice sorgente

修改自动测试的bug

user_lt 1 anno fa
parent
commit
97cebe9e24

+ 1 - 1
BlankApp1/BlankApp1/App.config

@@ -3,7 +3,7 @@
 	<appSettings>
 		<!--连接字符串 SQL Server-->
 		<add key="MySql" value="Data Source=localhost;Database=plc_point_db;User Id='root';Password='Lt,100186';port=3306;charset=utf8mb4;"/>
-		<add key="PLCIp" value="192.168.0.20"/>
+		<add key="PLCIp" value="192.168.250.1"/>
 		<add key="PLCPort" value="9600"/>
 
 	</appSettings>

+ 15 - 7
BlankApp1/BlankApp1/Common/PLCCom.cs

@@ -41,18 +41,26 @@ namespace PLCTool.Common
 
         private bool ConnectPLC()
         {
-            ENT = new EtherNetPLC();
-            short re = ENT.Link(plcIp, short.Parse(plcPort), 500);
-            if (re == 0)
+            try
             {
-                isConnect = true;
-                return true;
+                ENT = new EtherNetPLC();
+                short re = ENT.Link(plcIp, short.Parse(plcPort), 500);
+                if (re == 0)
+                {
+                    isConnect = true;
+                    return true;
+                }
+                else
+                {
+                    isConnect = false;
+                    return false;
+                }
             }
-            else
+            catch (Exception e)
             {
-                isConnect = false;
                 return false;
             }
+          
 
         }
         public string ReadPlcObject(string address, VarType valueType)

+ 7 - 4
BlankApp1/BlankApp1/ViewModels/BasicConfigViewModel/AddOrEditSchViewModel.cs

@@ -31,6 +31,7 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
         private readonly ILogger _logger;
         private List<OptionConfigDto> _optionConfigs;
         private bas_plc_test_scheme bas_Plc_Test_Scheme;//测试方案
+        private int schDtlMainId = 0;//测试方案明细主键id
         public AddOrEditSchViewModel(IDialogService dialog, IEventAggregator aggregator, IOptionConfigService optionConfigService, IBasicPlcTestSchemeService basicPlcTestSchemeService, IBasicPlcTestSchemeDtlService basicPlcTestSchemeDtlService, IMapper mapper,ILogger logger)
         {
             _dialog = dialog;
@@ -82,6 +83,7 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
                 {
                     Title = "编辑方案";
                     int id = Convert.ToInt32(item);
+                    schDtlMainId = id;//全局变量赋值,测试方案明细id
                     //根据 测试方案明细主键ID 查找测试方案id 及方案名和设备名
                     var findEntity = _basicPlcTestSchemeDtlService.Find(id);
                     var findresult = _mapper.Map<bas_plc_test_scheme_dtl, BasicPlcTestSchemeDtlDto>(findEntity);
@@ -453,6 +455,7 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
                     if(bas_Plc_Test_Scheme!=null)
                     {
                         bas_Plc_Test_Scheme.scheme_name = ScheduleName;
+                        bas_Plc_Test_Scheme.device_name = DeviceName;
                         _basicPlcTestSchemeService.Edit(bas_Plc_Test_Scheme);
                     }
                     
@@ -462,7 +465,7 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
 
             //查找测试方案id
             var finsScheHave = _basicPlcTestSchemeService.FindByName(ScheduleName);
-            if (bas_Plc_Test_Scheme != null)
+            if (finsScheHave != null)
             {
                 long id = finsScheHave.scheme_id;
                 //增加或修改方案明细表
@@ -522,10 +525,10 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
                 if (Title == "编辑方案")
                 {
                     //修改 必须给主键SchemeDtlId值
-                    var schDtl = _basicPlcTestSchemeDtlService.FindSchDtlIdBySchIdAndItem(scheduleId, TestName);
-                    if (schDtl != null)
+                    //var schDtl = _basicPlcTestSchemeDtlService.FindSchDtlIdBySchIdAndItem(scheduleId, TestName);
+                   // if (schDtl != null)
                     {
-                        schDtlDto.SchemeDtlId = schDtl.scheme_dtl_id;
+                        schDtlDto.SchemeDtlId = schDtlMainId;
                         bas_plc_test_scheme_dtl schDtlEntityEdit = _mapper.Map<BasicPlcTestSchemeDtlDto, bas_plc_test_scheme_dtl>(schDtlDto);
                         //ItemType 转化
                         schDtlEntityEdit.item_type = StrToItemType(schDtlDto.ItemType);

+ 62 - 111
BlankApp1/BlankApp1/ViewModels/BusinessManageViewModel/AutoTestViewModel.cs

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

+ 22 - 11
BlankApp1/BlankApp1/ViewModels/BusinessManageViewModel/ManualTestViewModel.cs

@@ -289,12 +289,16 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
         /// <returns></returns>
         private int GetTestResult()
         {
+            //前置项
+            int beforeResult = 0;
+            int inResult= 0;
+            int outResult = 0;
             if (SelectLogic == "OR")
             {
                 var find = BeforeConList.FirstOrDefault(x => x.TestResult == "合格");
                 if (find != null)
                 {
-                    return 1;
+                    beforeResult= 1;
                 }
             }
             else
@@ -304,7 +308,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                     var find = BeforeConList.FirstOrDefault(x => x.TestResult == "不合格");
                     if (find != null)
                     {
-                        return 0;
+                        beforeResult= 0;
                     }
                 }
                 else
@@ -312,7 +316,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                     if (SelectLogic == "NULL")
                     {
 
-                        return 1;
+                        beforeResult= 1;
 
                     }
                 }
@@ -324,7 +328,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                 var find = InConList.FirstOrDefault(x => x.TestResult == "合格");
                 if (find != null)
                 {
-                    return 1;
+                    inResult= 1;
                 }
             }
             else
@@ -334,7 +338,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                     var find = InConList.FirstOrDefault(x => x.TestResult == "不合格");
                     if (find != null)
                     {
-                        return 0;
+                        inResult= 0;
                     }
                 }
                 else
@@ -342,7 +346,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                     if (InSelectLogic == "NULL")
                     {
 
-                        return 1;
+                        inResult= 1;
 
                     }
                 }
@@ -354,7 +358,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                 var find = OutConList.FirstOrDefault(x => x.TestResult == "合格");
                 if (find != null)
                 {
-                    return 1;
+                    outResult= 1;
                 }
             }
             else
@@ -364,7 +368,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                     var find = OutConList.FirstOrDefault(x => x.TestResult == "不合格");
                     if (find != null)
                     {
-                        return 0;
+                        outResult= 0;
                     }
                 }
                 else
@@ -372,13 +376,20 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                     if (OutSelectLogic == "NULL")
                     {
 
-                        return 1;
+                        outResult= 1;
 
                     }
                 }
             }
-
-            return 1;
+            if(beforeResult==1&&inResult==1&&outResult==1)
+            {
+                return 1;
+            }
+            else
+            {
+                return 0;
+            }
+           
         }
         /// <summary>
         /// 更新测试记录

+ 37 - 22
BlankApp1/BlankApp1/ViewModels/StatisticsViewModel.cs

@@ -43,15 +43,16 @@ namespace BlankApp1.ViewModels
             PieSeriesCollectionEveryday = new SeriesCollection();
             PieSeriesCollectionPLC = new SeriesCollection();
             OnLoadCommand = new DelegateCommand(OnLoad);
-            GetPieSeriesDone();
-            GetPieSeriesPLC();
-            GetPieSeriesEveryDay();
-            GetPieSeriesFail();
+     
         }
 
         private void OnLoad()
         {
             GetContent();
+            GetPieSeriesDone();
+            GetPieSeriesPLC();
+            GetPieSeriesEveryDay();
+            GetPieSeriesFail();
         }
         /// <summary>
         /// 获取解决方案
@@ -157,18 +158,24 @@ namespace BlankApp1.ViewModels
         }
         private void GetPieSeriesDone()
         {
+            PieSeriesCollectionDone.Clear();
+            var findNoTest = allConfigList.FindAll(x => string.IsNullOrEmpty(x.TestStatus));
+            int tesDone = TotalCount - findNoTest.Count;
+           
             ChartValues<int> chartvalue = new ChartValues<int>();
-            chartvalue.Add(40);
-     
+            chartvalue.Add(tesDone);
+            ChartValues<int> noChartvalue = new ChartValues<int>();
+            noChartvalue.Add(findNoTest.Count);
+
             PieSeries series = new PieSeries();
             series.DataLabels = true;
-            series.Title = "合格率";
+            series.Title = "已测试";
             series.Values = chartvalue;
 
             PieSeries series2 = new PieSeries();
             series2.DataLabels = true;
-            series2.Title = "不合格率";
-            series2.Values = chartvalue;
+            series2.Title = "未测试";
+            series2.Values = noChartvalue;
             PieSeriesCollectionDone.Add(series);
             PieSeriesCollectionDone.Add(series2);
 
@@ -177,8 +184,14 @@ namespace BlankApp1.ViewModels
 
         private void GetPieSeriesPLC()
         {
+            PieSeriesCollectionPLC.Clear();
+            int succTest = allConfigList.FindAll(x => x.TestResult == "通过").Count;
+            int noSuccTest = allConfigList.FindAll(x => x.TestResult == "不通过").Count;
             ChartValues<int> chartvalue = new ChartValues<int>();
-            chartvalue.Add(40);
+            chartvalue.Add(succTest);
+
+            ChartValues<int> nochartvalue = new ChartValues<int>();
+            nochartvalue.Add(noSuccTest);
             PieSeries series = new PieSeries();
             series.DataLabels = true;
             series.Title = "合格率";
@@ -187,7 +200,7 @@ namespace BlankApp1.ViewModels
             PieSeries series2 = new PieSeries();
             series2.DataLabels = true;
             series2.Title = "不合格率";
-            series2.Values = chartvalue;
+            series2.Values = nochartvalue;
             PieSeriesCollectionPLC.Add(series);
             PieSeriesCollectionPLC.Add(series2);
 
@@ -196,16 +209,22 @@ namespace BlankApp1.ViewModels
 
         private void GetPieSeriesFail()
         {
+            PieSeriesCollectionFail.Clear();
+            int succTest = allConfigList.FindAll(x => x.TestResult == "通过").Count;
+            int noSuccTest = allConfigList.FindAll(x => x.TestResult == "不通过").Count;
             ChartValues<int> chartvalue = new ChartValues<int>();
-            chartvalue.Add(40);
+            chartvalue.Add(succTest);
+            ChartValues<int> noChartvalue = new ChartValues<int>();
+            noChartvalue.Add(noSuccTest);
+         
             PieSeries series = new PieSeries();
             series.DataLabels = true;
-            series.Title = "合格率";
+            series.Title = "通过";
             series.Values = chartvalue;
 
             PieSeries series2 = new PieSeries();
             series2.DataLabels = true;
-            series2.Title = "不合格率";
+            series2.Title = "不通过";
             series2.Values = chartvalue;
             PieSeriesCollectionFail.Add(series);
             PieSeriesCollectionFail.Add(series2);
@@ -215,20 +234,16 @@ namespace BlankApp1.ViewModels
 
         private void GetPieSeriesEveryDay()
         {
+            PieSeriesCollectionEveryday.Clear();
+            int dayTest = allConfigList.FindAll(x => x.StartTestTime.Date == DateTime.Now.Date).Count;
             ChartValues<int> chartvalue = new ChartValues<int>();
-            chartvalue.Add(40);
+            chartvalue.Add(dayTest);
             PieSeries series = new PieSeries();
             series.DataLabels = true;
-            series.Title = "合格率";
+            series.Title = "测试数量";
             series.Values = chartvalue;
 
-            PieSeries series2 = new PieSeries();
-            series2.DataLabels = true;
-            series2.Title = "不合格率";
-            series2.Values = chartvalue;
             PieSeriesCollectionEveryday.Add(series);
-            PieSeriesCollectionEveryday.Add(series2);
-
         }
         #region 数据绑定
 

+ 6 - 50
BlankApp1/BlankApp1/Views/BusinessManageView/AutoTestView.xaml

@@ -176,32 +176,10 @@
                         <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}"/>
                         <DataGridTextColumn Header="描述" Binding="{Binding Remark}" 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>
-
+                        <DataGridTextColumn Header="测试时间" 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>
@@ -266,32 +244,10 @@
                         <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}"/>
                         <DataGridTextColumn Header="描述" Binding="{Binding Remark}" 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>
-
+                        <DataGridTextColumn Header="测试时间" 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>

+ 2 - 2
BlankApp1/BlankApp1/Views/StatisticsView.xaml

@@ -62,8 +62,8 @@
             </UniformGrid>
             <UniformGrid Grid.Row="2" Columns="4">
                 <TextBlock FontSize="12"  Text="测试单完成率" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="5,0,0,0" />
-                <TextBlock FontSize="12"  Text="PLC点位测试率" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="5,0,0,0" />
-                <TextBlock FontSize="12"  Text="每日作业" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="5,0,0,0" />
+                <TextBlock FontSize="12"  Text="PLC点位测试率" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="5,0,0,0" />
+                <TextBlock FontSize="12"  Text="每日作业" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="5,0,0,0" />
                 <TextBlock FontSize="12"  Text="PLC点位测试失败率" VerticalAlignment="Center" HorizontalAlignment="Center" Margin="5,0,0,0" />
             </UniformGrid>
         </Grid>