Browse Source

更新测试状态

ltwork 1 year ago
parent
commit
cdafef69ef

+ 24 - 2
BlankApp1/BlankApp1/ViewModels/BusinessManageViewModel/DeviceTestViewModel.cs

@@ -29,6 +29,8 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
         private readonly IBasicDeviceKindService _iBasicDeviceKindService;
         private readonly IBasicProjectService _iBasicProjectService;
         private readonly IBasicPlcTestSchemeService _basicPlcTestSchemeService;
+        private readonly IBizTestRecordService _iBizTestRecordService;
+        private readonly IBizTestRecordDtlService _iBizTestRecordDtlService;
         private readonly IMapper _mapper;
         private readonly IDialogService _dialog;
         private readonly ILogger _logger;
@@ -36,13 +38,15 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
         private List<BasDeviceWithSchModel> allDeviceList = new List<BasDeviceWithSchModel>();//所有设备
         private List<BasDeviceWithSchModel> conditionDevices = new List<BasDeviceWithSchModel>();//符合条件的方案
         private string selectProjectName;
-        public DeviceTestViewModel(IRegionManager regionManager,IBasicDeviceService iBasicDeviceService, IBasicDeviceKindService iBasicDeviceKindService, IBasicProjectService iBasicProjectService, IBasicPlcTestSchemeService basicPlcTestSchemeService, IMapper mapper, IDialogService dialog, ILogger logger)
+        public DeviceTestViewModel(IRegionManager regionManager,IBasicDeviceService iBasicDeviceService, IBasicDeviceKindService iBasicDeviceKindService, IBasicProjectService iBasicProjectService, IBasicPlcTestSchemeService basicPlcTestSchemeService, IBizTestRecordService iBizTestRecordService, IBizTestRecordDtlService iBizTestRecordDtlService, IMapper mapper, IDialogService dialog, ILogger logger)
         {
             _regionManager = regionManager;
             _iBasicDeviceService = iBasicDeviceService;
             _iBasicDeviceKindService = iBasicDeviceKindService;
             _iBasicProjectService = iBasicProjectService;
             _basicPlcTestSchemeService = basicPlcTestSchemeService;
+            _iBizTestRecordService = iBizTestRecordService;
+            _iBizTestRecordDtlService=iBizTestRecordDtlService;
             _mapper = mapper;
             _dialog = dialog;
             _logger = logger;
@@ -295,6 +299,14 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                 //设备方案
                 foreach (var sch in schs)
                 {
+                    //测试方案是否测试
+                    string testStu = "未测试";
+                    var testStatusResult = _iBizTestRecordService.FindRecorddByDeviceIdAndSchname(item.DeviceId, sch.SchemeName);
+                    if (testStatusResult != null)
+                    {
+                        testStu = "已测试";
+                    }
+
                     allDeviceAndSchList.Add(new BasDeviceWithSchModel()
                     {
                         DeviceId = item.DeviceId,
@@ -304,11 +316,19 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                         ProjectName = projectName,
                         SchemeName = sch.SchemeName,
                         SchemeId = sch.SchemeId,
+                        TestStatus=testStu,
                         CreateBy=sch.CreateBy,
                         CreateTime = item.CreateTime,
                     });
                  
                 }
+                //查看测试记录中是否有测试
+                string totalTestStu = "未测试";
+                var resultTest=_iBizTestRecordService.FindRecordByDeviceId(item.DeviceId);
+                if(resultTest.Count!=0)
+                {
+                    totalTestStu = "已测试";
+                }
                 //只添加选择的项目
                 if (projectName == selectProjectName)
                 {
@@ -319,9 +339,10 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                         DeviceName = item.DeviceName,
                         DeviceKindName = deviceKindName,
                         ProjectName = projectName,
+                        TotalTestStatus = totalTestStu,
                         CreateBy = item.CreateBy,
                         CreateTime = item.CreateTime,
-
+                     
                     });
                     conditionDevices.Add(new BasDeviceWithSchModel()
                     {
@@ -330,6 +351,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                         DeviceName = item.DeviceName,
                         DeviceKindName = deviceKindName,
                         ProjectName = projectName,
+                        TotalTestStatus = totalTestStu,
                         CreateBy = item.CreateBy,
                         CreateTime = item.CreateTime,
 

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

@@ -95,7 +95,7 @@
                 <DataGridTextColumn Header="设备类型" Binding="{Binding DeviceKindName}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
                 <DataGridTextColumn Header="项目名称" Binding="{Binding ProjectName}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
                 <DataGridTextColumn Header="描述" Binding="{Binding Remark}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-                <DataGridTextColumn Header="测试状态" Binding="{Binding Remark}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                <DataGridTextColumn Header="测试状态" Binding="{Binding TotalTestStatus}" 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}"/>
                 
@@ -129,7 +129,7 @@
               
                 <DataGridTextColumn Header="设备类型" Binding="{Binding DeviceKindName}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
                 <DataGridTextColumn Header="测试方案名称" Binding="{Binding SchemeName}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
-                <DataGridTextColumn Header="测试状态" Binding="{Binding Remark}" CellStyle="{StaticResource MyDataGridCellStyle}"/>
+                <DataGridTextColumn Header="测试状态" Binding="{Binding TestStatus}" 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="200" CellStyle="{StaticResource MyDataGridCellStyle}">

+ 11 - 0
BlankApp1/Model/Dto/BasDeviceKindWithSchModel.cs

@@ -20,5 +20,16 @@ namespace Model.Dto
         /// 测试方案ID
         /// </summary>
         public long SchemeId { get; set; }
+
+
+        /// <summary>
+        /// 测试方案的测试状态 
+        /// </summary>
+        public string TestStatus { get; set; }
+        /// <summary>
+        /// 整个设备的测试状态 
+        /// </summary>
+        public string TotalTestStatus { get; set; }
+        
     }
 }