瀏覽代碼

添加不合格项测试

ltwork 1 年之前
父節點
當前提交
7baa2364b8

+ 41 - 5
BlankApp1/BlankApp1/ViewModels/BusinessManageViewModel/ResultQueryViewModel.cs

@@ -56,12 +56,41 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
             ResetCommand = new DelegateCommand<object>(Reset);
             OnLoadCommand = new DelegateCommand(OnLoad);
             PdfReportCommand = new DelegateCommand<object>(CreatePdf);
-
+            UnqualifiedCommand = new DelegateCommand<object>(RetryTest);
         }
 
 
+
+
         #region 私有方法
         /// <summary>
+        /// 重新测试不合格项
+        /// </summary>
+        /// <param name="obj"></param>
+        private void RetryTest(object obj)
+        {
+            object[] multiObj = obj as object[];
+
+            //测试方案明细主键ID
+            long id = (long)multiObj[0];
+            long deviceId = (long)multiObj[1];
+            DialogParameters parm = new DialogParameters();
+            parm.Add("Key", id);
+            parm.Add("Key2", deviceId);
+            //弹出详情对话框
+            //弹出详情对话框
+            _dialog.ShowDialog("ManualTestView", parm, async callback =>
+            {
+                if (callback.Result == ButtonResult.OK)
+                {
+                    //更新表格,重新获取
+
+                }
+
+            });
+
+        }
+        /// <summary>
         /// 加载页面
         /// </summary>
         private void OnLoad()
@@ -182,15 +211,19 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                     var recordMsgs=_iBizTestRecordService.FindRecordByDeviceId(deviceId);
                     foreach ( var sch in recordMsgs)
                     {
+                        string deviceKindName = _iBasicDeviceKindService.Find((int)deviceMsg.device_kind_id)?.devicekind_name;
+                        string projectName = _iBasicProjectService.Find((int)deviceMsg.project_id)?.project_name;
+                        long schId=(long)_basicPlcTestSchemeService.FindByNameAndType(sch.scheme_name, deviceKindName)?.scheme_id;
                         allDeviceList.Add(new DeviceDtlWithResultModel()
                         {
                             RecordId = sch.record_id,
                             DeviceId = deviceMsg.device_id,
                             DeviceNo = deviceMsg.device_no,
                             DeviceName = deviceMsg.device_name,
-                            DeviceKindName = _iBasicDeviceKindService.Find((int)deviceMsg.device_kind_id)?.devicekind_name,
-                            ProjectName = _iBasicProjectService.Find((int)deviceMsg.project_id)?.project_name,
+                            DeviceKindName = deviceKindName,
+                            ProjectName = projectName,
                             SchemeName = sch.scheme_name,
+                            SchemeId= schId,
                             StartTestTime = sch.start_test_time.Value,
                         }); ; ;
                         conditionDevices.Add(new DeviceDtlWithResultModel()
@@ -199,9 +232,10 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                             DeviceId = deviceMsg.device_id,
                             DeviceNo = deviceMsg.device_no,
                             DeviceName = deviceMsg.device_name,
-                            DeviceKindName =_iBasicDeviceKindService.Find((int) deviceMsg.device_kind_id)?.devicekind_name,
-                            ProjectName = _iBasicProjectService.Find((int)deviceMsg.project_id)?.project_name,
+                            DeviceKindName = deviceKindName,
+                            ProjectName = projectName,
                             SchemeName = sch.scheme_name,
+                            SchemeId = schId,
                             StartTestTime = sch.start_test_time.Value,
                         });
                     }
@@ -455,6 +489,8 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
 
         public DelegateCommand OnLoadCommand { set; get; }
         public DelegateCommand<object> CheckDetailCommand { set; get; }
+        public DelegateCommand<object> UnqualifiedCommand { set; get; }
+        
         public DelegateCommand<object> PdfReportCommand { set; get; }
         #endregion
 

+ 37 - 11
BlankApp1/BlankApp1/ViewModels/BusinessManageViewModel/TestResultDetailViewModel.cs

@@ -92,6 +92,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                     {
                         long recordId = item;
                         var records = _iBizTestRecordDtlService.FindRecordDetailByRecordID(recordId).OrderBy(x => x.record_dtl_id).ToList(); ;
+                        List<biz_test_record_dtl> recordNotNulls = new List<biz_test_record_dtl>(); //测试项名称不是空的集合
                         foreach (var record in records)
                         {
                             long dtlId = record.scheme_dtl_id;
@@ -99,21 +100,24 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                             if(!String.IsNullOrEmpty(itemName))
                             {
                                 SchItems.Add(itemName);
+                                recordNotNulls.Add(record);
+                                //在集合中添加满足条件的测试结果
+                                conditionRecordList.Add(new BizTestRecordDtlDto()
+                                {
+                                    RecordDtlId = record.record_dtl_id,
+                                    SchemeDtlId = record.scheme_dtl_id,
+                                });
+                                //默认显示第一个测试项
+                                int schDtlId = Convert.ToInt32((long)recordNotNulls?.First()?.scheme_dtl_id);
+                                int recordDtlId = Convert.ToInt32((long)recordNotNulls?.First()?.record_dtl_id);
+                                //显示
+                                DisplayDetail(schDtlId, recordDtlId);
                             }
                             
-                            //在集合中添加满足条件的测试结果
-                            conditionRecordList.Add(new BizTestRecordDtlDto()
-                            {
-                                RecordDtlId = record.record_dtl_id,
-                                SchemeDtlId=record.scheme_dtl_id,
-                            });
+                         
                         }
 
-                        //默认显示第一个测试项
-                        int schDtlId = Convert.ToInt32((long)records?.First().scheme_dtl_id);
-                        int recordDtlId = Convert.ToInt32((long)records?.First().record_dtl_id);
-                        //显示
-                        DisplayDetail(schDtlId, recordDtlId);
+              
                        
                     }
                 }
@@ -225,6 +229,18 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                             OutConList.Add(basPlcItemConfigDto);
                         }
                     }
+
+                    //结果
+                    switch (recordDetail.test_result)
+                    {
+                        case 0:
+                            TestDtlResult = "不通过";
+                            break;
+                        case 1:
+                            TestDtlResult = "通过";
+                            break;
+                    }
+                    
                 }
 
 
@@ -561,6 +577,16 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
             get { return selectIndex; }
             set { selectIndex = value; RaisePropertyChanged(); }
         }
+        /// <summary>
+        /// 测试项测试结果
+        /// </summary>
+        private string testDtlResult;
+        public string TestDtlResult
+        {
+            get { return testDtlResult; }
+            set { testDtlResult = value; RaisePropertyChanged(); }
+        }
+        
         #endregion
         #region 命令绑定
         public DelegateCommand ItemChangeCommand { set; get; }

+ 2 - 2
BlankApp1/BlankApp1/Views/BusinessManageView/ManualTestView.xaml

@@ -301,8 +301,8 @@
             </Grid>
             <UniformGrid  Grid.Row="5" Columns="4">
                 <Button  Content="开始检测" Width="80" IsEnabled="{Binding StartEnalbe}" Height="30" FontSize="12"   Command="{Binding StartCommand}" Style="{DynamicResource WD.PrimaryButton}" />
-                <Button  Content="上一" Width="80" IsEnabled="{Binding StartEnalbe}" Height="30" FontSize="12"   Command="{Binding PreviousCommand}" Style="{DynamicResource WD.PrimaryButton}" />
-                <Button  Content="下一" Width="80" IsEnabled="{Binding StartEnalbe}" Height="30" FontSize="12"   Command="{Binding NextCommand}" Style="{DynamicResource WD.PrimaryButton}" />
+                <Button  Content="上一" Width="80" IsEnabled="{Binding StartEnalbe}" Height="30" FontSize="12"   Command="{Binding PreviousCommand}" Style="{DynamicResource WD.PrimaryButton}" />
+                <Button  Content="下一" Width="80" IsEnabled="{Binding StartEnalbe}" Height="30" FontSize="12"   Command="{Binding NextCommand}" Style="{DynamicResource WD.PrimaryButton}" />
                 <Button  Content="完成" Width="80"  IsEnabled="{Binding StartEnalbe}" Height="30" FontSize="12"  Command="{Binding DoneCommand}" Style="{DynamicResource WD.PrimaryButton}" />
             </UniformGrid>
             <Grid Grid.Row="2">

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

@@ -86,10 +86,10 @@
                 <DataGridTextColumn Header="测试结果" Binding="{Binding TestResult}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
                 <!--<DataGridTextColumn Header="创建者" Binding="{Binding CreateBy}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
      <DataGridTextColumn Header="创建时间" Binding="{Binding CreateTime,StringFormat={}{0:yyyy-MM-dd HH:mm:ss}}" CellStyle="{StaticResource MyDataGridCellStyle}"/>-->
-                <DataGridTemplateColumn Header="操作" Width="180"  CellStyle="{StaticResource MyDataGridCellStyle}">
+                <DataGridTemplateColumn Header="操作" Width="240"  CellStyle="{StaticResource MyDataGridCellStyle}">
                     <DataGridTemplateColumn.CellTemplate>
                         <DataTemplate>
-                            <UniformGrid Columns="2">
+                            <UniformGrid Columns="3">
                                 <Button  Width="auto" Background="Transparent" HorizontalContentAlignment ="Left" Foreground="Black" Height="25" BorderThickness="0"
                        Command="{Binding DataContext.CheckDetailCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" CommandParameter="{Binding RecordId}"  Cursor="Hand" Margin="0,0,5,0" >
                                     
@@ -98,7 +98,19 @@
                                     </StackPanel>
                                 </Button>
                                 <Button  Width="auto" Background="Transparent" HorizontalContentAlignment ="Left" Foreground="Black" Height="25" BorderThickness="0"
-Command="{Binding DataContext.PdfReportCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" Cursor="Hand" >
+                                    Command="{Binding DataContext.UnqualifiedCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" Cursor="Hand" >
+                                    <Button.CommandParameter>
+                                        <MultiBinding Converter="{ StaticResource ResourceKey=TwoParConverter}">
+                                                <Binding Path="SchemeId"  ></Binding>
+                                                <Binding Path="DeviceId"></Binding>
+                                            </MultiBinding>
+                                       </Button.CommandParameter>
+                                    <StackPanel Orientation="Horizontal">
+                                        <TextBlock  Text="测试不合格项" VerticalAlignment="Center" Foreground="Blue"/>
+                                    </StackPanel>
+                                </Button>
+                                <Button  Width="auto" Background="Transparent" HorizontalContentAlignment ="Left" Foreground="Black" Height="25" BorderThickness="0"
+                                Command="{Binding DataContext.PdfReportCommand, RelativeSource={RelativeSource Mode=FindAncestor,AncestorType=DataGrid}}" Cursor="Hand" >
                                     <Button.CommandParameter>
                                         <MultiBinding Converter="{ StaticResource ResourceKey=TwoParConverter}">
                                             <Binding Path="SchemeName"  ></Binding>
@@ -109,7 +121,6 @@ Command="{Binding DataContext.PdfReportCommand, RelativeSource={RelativeSource M
                                         <TextBlock  Text="生成pdf报表" VerticalAlignment="Center" Foreground="Blue"/>
                                     </StackPanel>
                                 </Button>
-
                             </UniformGrid>
                         </DataTemplate>
                     </DataGridTemplateColumn.CellTemplate>

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

@@ -65,7 +65,10 @@
                     <TextBlock Text="测试项名称:"  Style="{StaticResource NormalTextBlockStyle}" Margin="10,0,5,0"/>
                     <TextBox  Height="28" Width="160"  Text="{Binding TestName}" IsReadOnly="True"/>
                 </StackPanel>
-
+                <StackPanel Orientation="Horizontal">
+                    <TextBlock Text="{Binding TestDtlResult}"  Style="{StaticResource NormalTextBlockStyle}" FontSize="25" Margin="10,0,5,0" />
+                    
+                </StackPanel>
             </StackPanel>
             <Border Grid.Row="0"  BorderBrush="#CBCBCB" BorderThickness="0,1" />
             <Grid Grid.Row="1">

+ 4 - 1
BlankApp1/Model/Dto/DeviceDtlWithResultModel.cs

@@ -14,7 +14,10 @@ namespace Model.Dto
         public DateTime FinishTestTime { get; set; }
 
         public string SchemeName { get; set; }
-        
+        /// <summary>
+        /// 测试方案ID
+        /// </summary>
+        public long SchemeId { get; set; }
         /// <summary>
         /// 测试模式
         /// </summary>