Forráskód Böngészése

调试测试代码

user_lt 1 éve
szülő
commit
f9a58b4062

+ 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.250.1"/>
+		<add key="PLCIp" value="192.168.0.20"/>
 		<add key="PLCPort" value="9600"/>
 
 	</appSettings>

+ 1 - 1
BlankApp1/BlankApp1/ViewModels/BasicConfigViewModel/BaseConfigViewModel.cs

@@ -374,7 +374,7 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
         /// <summary>
         /// 每页数量
         /// </summary>
-        private int countPerPage = 1;
+        private int countPerPage = 10;
         public int CountPerPage
         {
             get { return countPerPage; }

+ 1 - 1
BlankApp1/BlankApp1/ViewModels/BasicConfigViewModel/PLCConfigViewModel.cs

@@ -174,7 +174,7 @@ namespace PLCTool.ViewModels.BasicConfigViewModel
         /// <summary>
         /// 每页数量
         /// </summary>
-        private int countPerPage = 1;
+        private int countPerPage = 10;
         public int CountPerPage
         {
             get { return countPerPage; }

+ 149 - 55
BlankApp1/BlankApp1/ViewModels/BusinessManageViewModel/AutoTestViewModel.cs

@@ -18,6 +18,7 @@ using System.Text;
 using System.Threading;
 using System.Threading.Tasks;
 using System.Windows;
+using System.Xaml;
 
 namespace PLCTool.ViewModels.BusinessManageViewModel
 {
@@ -255,29 +256,40 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
             }
             testStatus = 99;//测试状态赋值为99
                             //状态status 没有赋值
-
-            bizTestRecordDtlDto.RecordId = recordId;
-            bizTestRecordDtlDto.SchemeDtlId = schDetailId;
-            bizTestRecordDtlDto.StartTestTime = startTime;
-            bizTestRecordDtlDto.FinishTestTime = endTime;
-            bizTestRecordDtlDto.TestMode = TestMode;
-            bizTestRecordDtlDto.Status = testStatus;
-            bizTestRecordDtlDto.TestResult = GetTestResult();
-            bizTestRecordDtlDto.CreateBy = Appsession.UserName;
-            bizTestRecordDtlDto.CreateTime = startTime;
-            bizTestRecordDtlDto.UpdateBy = Appsession.UserName;
-            bizTestRecordDtlDto.UpdateTime = DateTime.Now;
+           
             //记录记录明细表中是否有这个方案明细ID的记录,没有则添加,有则更新记录状态
             var findRecordDetail = _iBizTestRecordDtlService.FindRecordDetailBySchDtlID(schDetailId);
             if (findRecordDetail == null)
             {
-
-                var testRecordDtl = _mapper.Map<BizTestRecordDtlDto, biz_test_record_dtl>(bizTestRecordDtlDto);
+                BizTestRecordDtlDto newBizTestEwDetail = new BizTestRecordDtlDto();
+                newBizTestEwDetail.RecordId = recordId;
+                newBizTestEwDetail.SchemeDtlId = schDetailId;
+                newBizTestEwDetail.StartTestTime = startTime;
+                newBizTestEwDetail.FinishTestTime = endTime;
+                newBizTestEwDetail.TestMode = TestMode;
+                newBizTestEwDetail.Status = testStatus;
+                newBizTestEwDetail.TestResult = GetTestResult();
+                newBizTestEwDetail.CreateBy = Appsession.UserName;
+                newBizTestEwDetail.CreateTime = startTime;
+                newBizTestEwDetail.UpdateBy = Appsession.UserName;
+                newBizTestEwDetail.UpdateTime = DateTime.Now;
+                var testRecordDtl = _mapper.Map<BizTestRecordDtlDto, biz_test_record_dtl>(newBizTestEwDetail);
                 _iBizTestRecordDtlService.Add(testRecordDtl);
             }
             else
             {
                 bizTestRecordDtlDto.RecordDtlId = findRecordDetail.record_dtl_id;
+                bizTestRecordDtlDto.RecordId = recordId;
+                bizTestRecordDtlDto.SchemeDtlId = schDetailId;
+                bizTestRecordDtlDto.StartTestTime = startTime;
+                bizTestRecordDtlDto.FinishTestTime = endTime;
+                bizTestRecordDtlDto.TestMode = TestMode;
+                bizTestRecordDtlDto.Status = testStatus;
+                bizTestRecordDtlDto.TestResult = GetTestResult();
+                bizTestRecordDtlDto.CreateBy = Appsession.UserName;
+                bizTestRecordDtlDto.CreateTime = startTime;
+                bizTestRecordDtlDto.UpdateBy = Appsession.UserName;
+                bizTestRecordDtlDto.UpdateTime = DateTime.Now;
                 //更新时间
                 bizTestRecordDtlDto.UpdateBy = Appsession.UserName;
                 bizTestRecordDtlDto.UpdateTime = DateTime.Now;
@@ -287,35 +299,101 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
 
 
         }
-
+        /// <summary>
+        /// 获取测试结果
+        /// </summary>
+        /// <returns></returns>
         private int GetTestResult()
         {
-
-            foreach (var item in BeforeConList)
+            if (SelectLogic == "OR")
             {
-                if (item.TestResult == "不合格" || string.IsNullOrEmpty(item.TestResult))
+                var find = BeforeConList.FirstOrDefault(x => x.TestResult == "合格");
+                if (find != null)
                 {
-
-                    return 0;
+                    return 1;
+                }
+            }
+            else
+            {
+                if (SelectLogic == "AND"|| SelectLogic == "ONLY")
+                {
+                    var find = BeforeConList.FirstOrDefault(x => x.TestResult == "不合格");
+                    if (find != null)
+                    {
+                        return 0;
+                    }
                 }
+                else
+                {
+                    if (SelectLogic == "NULL")
+                    {
+                       
+                            return 1;
+                       
+                    }
+                }
+            }
 
+            //输入项
+            if (InSelectLogic == "OR")
+            {
+                var find = InConList.FirstOrDefault(x => x.TestResult == "合格");
+                if (find != null)
+                {
+                    return 1;
+                }
             }
-            foreach (var item in InConList)
+            else
             {
-                if (item.TestResult == "不合格" || string.IsNullOrEmpty(item.TestResult))
+                if (InSelectLogic == "AND" || InSelectLogic == "ONLY")
+                {
+                    var find = InConList.FirstOrDefault(x => x.TestResult == "不合格");
+                    if (find != null)
+                    {
+                        return 0;
+                    }
+                }
+                else
                 {
+                    if (InSelectLogic == "NULL")
+                    {
+
+                        return 1;
 
-                    return 0;
+                    }
                 }
             }
-            foreach (var item in OutConList)
+
+            //输出项
+            if (OutSelectLogic == "OR")
             {
-                if (item.TestResult == "不合格" || string.IsNullOrEmpty(item.TestResult))
+                var find = OutConList.FirstOrDefault(x => x.TestResult == "合格");
+                if (find != null)
                 {
-                    return 0;
+                    return 1;
                 }
             }
+            else
+            {
+                if (OutSelectLogic == "AND" || OutSelectLogic == "ONLY")
+                {
+                    var find = OutConList.FirstOrDefault(x => x.TestResult == "不合格");
+                    if (find != null)
+                    {
+                        return 0;
+                    }
+                }
+                else
+                {
+                    if (OutSelectLogic == "NULL")
+                    {
 
+                        return 1;
+
+                    }
+                }
+            }
+  
             return 1;
         }
         /// <summary>
@@ -429,7 +507,11 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                         globalSchDetailId = schDetailId;
                         int id = Convert.ToInt32(schDetailId);
                         //界面显示
-                        GetDetailInfo(id);
+                        System.Windows.Application.Current.Dispatcher.Invoke((delegate
+                        {
+                            GetDetailInfo(id);
+                        }));
+                        
                         //递归调用
                         Start();
                     }
@@ -459,20 +541,26 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
             {
                 case "人工判定":
                     //弹出确认的对话框
-                    MessageBoxResult boxResult = MessageBox.Show(BeforeDetail, "确认", MessageBoxButton.OKCancel, MessageBoxImage.Information);
-                    if (boxResult == MessageBoxResult.OK)
-                    {
-                        //前置项测试结果json转化
-                        string prefixJsonStr = ModelToJsonToStr(BeforeSelectJudge, SelectLogic, BeforeDetail, BeforeConList);
-                        //json字符串
-                        bizTestRecordDtlDto.PreconditionFinal = prefixJsonStr;
-                        bizTestRecordDtlDto.PreconditionResult = "合格";
-                        StepIndex = 1;
-                    }
-                    else
-                    {
-                        return false;
-                    }
+                    //前置项测试结果json转化
+                    string prefixJsonStr = ModelToJsonToStr(BeforeSelectJudge, SelectLogic, BeforeDetail, BeforeConList);
+                    //json字符串
+                    bizTestRecordDtlDto.PreconditionFinal = prefixJsonStr;
+                    bizTestRecordDtlDto.PreconditionResult = "合格";
+                    StepIndex = 1;
+                    //MessageBoxResult boxResult = MessageBox.Show(BeforeDetail, "确认", MessageBoxButton.OKCancel, MessageBoxImage.Information);
+                    //if (boxResult == MessageBoxResult.OK)
+                    //{
+                    //    //前置项测试结果json转化
+                    //    string prefixJsonStr = ModelToJsonToStr(BeforeSelectJudge, SelectLogic, BeforeDetail, BeforeConList);
+                    //    //json字符串
+                    //    bizTestRecordDtlDto.PreconditionFinal = prefixJsonStr;
+                    //    bizTestRecordDtlDto.PreconditionResult = "合格";
+                    //    StepIndex = 1;
+                    //}
+                    //else
+                    //{
+                    //    return false;
+                    //}
 
                     break;
                 case "自动判定":
@@ -481,20 +569,26 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
                     {
                         case "NULL":
                             //弹出确认的对话框
-                            MessageBoxResult boxResultAuto = MessageBox.Show(BeforeDetail, "确认", MessageBoxButton.OKCancel, MessageBoxImage.Information);
-                            if (boxResultAuto == MessageBoxResult.OK)
-                            {
-                                //前置项测试结果json转化
-                                string prefixJsonStr = ModelToJsonToStr(BeforeSelectJudge, SelectLogic, BeforeDetail, BeforeConList);
-                                //json字符串
-                                bizTestRecordDtlDto.PreconditionFinal = prefixJsonStr;
-                                bizTestRecordDtlDto.PreconditionResult = "合格";
-                                StepIndex = 1;
-                            }
-                            else
-                            {
-                                return false;
-                            }
+                            //前置项测试结果json转化
+                            string prefixJsonStrAuto = ModelToJsonToStr(BeforeSelectJudge, SelectLogic, BeforeDetail, BeforeConList);
+                            //json字符串
+                            bizTestRecordDtlDto.PreconditionFinal = prefixJsonStrAuto;
+                            bizTestRecordDtlDto.PreconditionResult = "合格";
+                            StepIndex = 1;
+                            //MessageBoxResult boxResultAuto = MessageBox.Show(BeforeDetail, "确认", MessageBoxButton.OKCancel, MessageBoxImage.Information);
+                            //if (boxResultAuto == MessageBoxResult.OK)
+                            //{
+                            //    //前置项测试结果json转化
+                            //    string prefixJsonStr = ModelToJsonToStr(BeforeSelectJudge, SelectLogic, BeforeDetail, BeforeConList);
+                            //    //json字符串
+                            //    bizTestRecordDtlDto.PreconditionFinal = prefixJsonStr;
+                            //    bizTestRecordDtlDto.PreconditionResult = "合格";
+                            //    StepIndex = 1;
+                            //}
+                            //else
+                            //{
+                            //    return false;
+                            //}
                             break;
                         case "AND":
                         case "ONLY":

+ 104 - 26
BlankApp1/BlankApp1/ViewModels/BusinessManageViewModel/ManualTestViewModel.cs

@@ -240,28 +240,40 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
             testStatus = 99;//测试状态赋值为99
                             //状态status 没有赋值
 
-            bizTestRecordDtlDto.RecordId = recordId;
-            bizTestRecordDtlDto.SchemeDtlId = schDetailId;
-            bizTestRecordDtlDto.StartTestTime = startTime;
-            bizTestRecordDtlDto.FinishTestTime = endTime;
-            bizTestRecordDtlDto.TestMode = TestMode;
-            bizTestRecordDtlDto.Status = testStatus;
-            bizTestRecordDtlDto.TestResult = GetTestResult();
-            bizTestRecordDtlDto.CreateBy = Appsession.UserName;
-            bizTestRecordDtlDto.CreateTime = startTime;
-            bizTestRecordDtlDto.UpdateBy = Appsession.UserName;
-            bizTestRecordDtlDto.UpdateTime = DateTime.Now;
+            
             //记录记录明细表中是否有这个方案明细ID的记录,没有则添加,有则更新记录状态
             var findRecordDetail = _iBizTestRecordDtlService.FindRecordDetailBySchDtlID(schDetailId);
             if (findRecordDetail == null)
             {
-               
-                var testRecordDtl = _mapper.Map<BizTestRecordDtlDto, biz_test_record_dtl>(bizTestRecordDtlDto);
+                BizTestRecordDtlDto newBizTestEwDetail=new BizTestRecordDtlDto();
+                newBizTestEwDetail.RecordId = recordId;
+                newBizTestEwDetail.SchemeDtlId = schDetailId;
+                newBizTestEwDetail.StartTestTime = startTime;
+                newBizTestEwDetail.FinishTestTime = endTime;
+                newBizTestEwDetail.TestMode = TestMode;
+                newBizTestEwDetail.Status = testStatus;
+                newBizTestEwDetail.TestResult = GetTestResult();
+                newBizTestEwDetail.CreateBy = Appsession.UserName;
+                newBizTestEwDetail.CreateTime = startTime;
+                newBizTestEwDetail.UpdateBy = Appsession.UserName;
+                newBizTestEwDetail.UpdateTime = DateTime.Now;
+                var testRecordDtl = _mapper.Map<BizTestRecordDtlDto, biz_test_record_dtl>(newBizTestEwDetail);
                 _iBizTestRecordDtlService.Add(testRecordDtl);
             }
             else
             {
                 bizTestRecordDtlDto.RecordDtlId = findRecordDetail.record_dtl_id;
+                bizTestRecordDtlDto.RecordId = recordId;
+                bizTestRecordDtlDto.SchemeDtlId = schDetailId;
+                bizTestRecordDtlDto.StartTestTime = startTime;
+                bizTestRecordDtlDto.FinishTestTime = endTime;
+                bizTestRecordDtlDto.TestMode = TestMode;
+                bizTestRecordDtlDto.Status = testStatus;
+                bizTestRecordDtlDto.TestResult = GetTestResult();
+                bizTestRecordDtlDto.CreateBy = Appsession.UserName;
+                bizTestRecordDtlDto.CreateTime = startTime;
+                bizTestRecordDtlDto.UpdateBy = Appsession.UserName;
+                bizTestRecordDtlDto.UpdateTime = DateTime.Now;
                 //更新时间
                 bizTestRecordDtlDto.UpdateBy = Appsession.UserName;
                 bizTestRecordDtlDto.UpdateTime = DateTime.Now;
@@ -271,32 +283,98 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
 
 
         }
-
+        /// <summary>
+        /// 判定结果
+        /// </summary>
+        /// <returns></returns>
         private int GetTestResult()
         {
-         
-            foreach(var item in BeforeConList)
+            if (SelectLogic == "OR")
             {
-                if (item.TestResult == "不合格"||string.IsNullOrEmpty(item.TestResult))
+                var find = BeforeConList.FirstOrDefault(x => x.TestResult == "合格");
+                if (find != null)
                 {
-                   
-                    return 0;
+                    return 1;
                 }
+            }
+            else
+            {
+                if (SelectLogic == "AND" || SelectLogic == "ONLY")
+                {
+                    var find = BeforeConList.FirstOrDefault(x => x.TestResult == "不合格");
+                    if (find != null)
+                    {
+                        return 0;
+                    }
+                }
+                else
+                {
+                    if (SelectLogic == "NULL")
+                    {
+
+                        return 1;
 
+                    }
+                }
             }
-            foreach(var item in InConList)
+
+            //输入项
+            if (InSelectLogic == "OR")
             {
-                if(item.TestResult=="不合格" || string.IsNullOrEmpty(item.TestResult))
+                var find = InConList.FirstOrDefault(x => x.TestResult == "合格");
+                if (find != null)
                 {
-                   
-                    return 0;    
+                    return 1;
                 }
             }
-            foreach (var item in OutConList)
+            else
             {
-                if (item.TestResult == "不合格" || string.IsNullOrEmpty(item.TestResult))
+                if (InSelectLogic == "AND" || InSelectLogic == "ONLY")
                 {
-                    return 0;
+                    var find = InConList.FirstOrDefault(x => x.TestResult == "不合格");
+                    if (find != null)
+                    {
+                        return 0;
+                    }
+                }
+                else
+                {
+                    if (InSelectLogic == "NULL")
+                    {
+
+                        return 1;
+
+                    }
+                }
+            }
+
+            //输出项
+            if (OutSelectLogic == "OR")
+            {
+                var find = OutConList.FirstOrDefault(x => x.TestResult == "合格");
+                if (find != null)
+                {
+                    return 1;
+                }
+            }
+            else
+            {
+                if (OutSelectLogic == "AND" || OutSelectLogic == "ONLY")
+                {
+                    var find = OutConList.FirstOrDefault(x => x.TestResult == "不合格");
+                    if (find != null)
+                    {
+                        return 0;
+                    }
+                }
+                else
+                {
+                    if (OutSelectLogic == "NULL")
+                    {
+
+                        return 1;
+
+                    }
                 }
             }
 

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

@@ -376,7 +376,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
         /// <summary>
         /// 每页数量
         /// </summary>
-        private int countPerPage = 1;
+        private int countPerPage = 10;
         public int CountPerPage
         {
             get { return countPerPage; }

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

@@ -414,7 +414,7 @@ namespace PLCTool.ViewModels.BusinessManageViewModel
         /// <summary>
         /// 每页数量
         /// </summary>
-        private int countPerPage = 1;
+        private int countPerPage = 10;
         public int CountPerPage
         {
             get { return countPerPage; }

+ 12 - 1
BlankApp1/BlankApp1/ViewModels/MonitorManageViewModel/PLCPointViewModel.cs

@@ -1,4 +1,6 @@
-using Prism.Commands;
+using BlankApp1.Common;
+using PLCTool.Views.MonitorManageView;
+using Prism.Commands;
 using Prism.Regions;
 using System;
 using System.Collections.Generic;
@@ -15,6 +17,12 @@ namespace PLCTool.ViewModels.MonitorManageViewModel
         {
             _regionManager = regionManager; 
             ButtonNavigateCommand = new DelegateCommand<string>(NavigateMethod);
+            OnLoadCommand = new DelegateCommand(OnLoad);
+        }
+
+        private void OnLoad()
+        {
+            _regionManager.Regions["PLCRegion"].RequestNavigate("PLCReadView");
         }
 
         private void NavigateMethod(string strPar)
@@ -27,7 +35,10 @@ namespace PLCTool.ViewModels.MonitorManageViewModel
             _regionManager.Regions["PLCRegion"].RequestNavigate(strPar);
         }
 
+
+
         #region 命令绑定
+        public DelegateCommand OnLoadCommand { set; get; }
         public DelegateCommand<string> ButtonNavigateCommand { set; get; }
         #endregion
 

+ 1 - 1
BlankApp1/BlankApp1/ViewModels/StatisticsViewModel.cs

@@ -276,7 +276,7 @@ namespace BlankApp1.ViewModels
         /// <summary>
         /// 每页数量
         /// </summary>
-        private int countPerPage = 1;
+        private int countPerPage = 10;
         public int CountPerPage
         {
             get { return countPerPage; }

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

@@ -316,9 +316,13 @@
           
         </Grid>
         <Grid Grid.Row="2">
-            <hc:CircleProgressBar IsIndeterminate="True" Visibility="{Binding ProVisibility }" Value="50"  Margin="16,0,0,0" Width="100" Height="100" ArcThickness="10" Style="{StaticResource ProgressBarInfoCircle}">
+            <StackPanel Orientation="Vertical" HorizontalAlignment="Center">
+                <hc:CircleProgressBar IsIndeterminate="True" Visibility="{Binding ProVisibility }" Value="50"  Margin="16,0,0,0" Width="100" Height="100" ArcThickness="10" Style="{StaticResource ProgressBarInfoCircle}">
 
-            </hc:CircleProgressBar>
+                </hc:CircleProgressBar>
+                <TextBlock  Text="判定中..." Foreground="#409EFF" FontSize="30" Visibility="{Binding ProVisibility }"  Width="AUTO" Margin="0,5"/>
+            </StackPanel>
+         
         </Grid>
     </Grid>
 </UserControl>

+ 6 - 3
BlankApp1/BlankApp1/Views/BusinessManageView/ManualTestView.xaml

@@ -277,9 +277,12 @@
             <Button  Content="完成" Width="80"    Command="{Binding DoneCommand}" Style="{StaticResource NormalButtonStyle}" />
         </UniformGrid>
         <Grid Grid.Row="2">
-            <hc:CircleProgressBar IsIndeterminate="True" Visibility="{Binding ProVisibility }" Value="50"  Margin="16,0,0,0" Width="100" Height="100" ArcThickness="10" Style="{StaticResource ProgressBarInfoCircle}">
-               
-            </hc:CircleProgressBar>
+            <StackPanel Orientation="Vertical" HorizontalAlignment="Center">
+                <hc:CircleProgressBar IsIndeterminate="True" Visibility="{Binding ProVisibility }" Value="50"  Margin="16,0,0,0" Width="100" Height="100" ArcThickness="10" Style="{StaticResource ProgressBarInfoCircle}">
+
+                </hc:CircleProgressBar>
+                <TextBlock  Text="判定中..." Foreground="#409EFF" FontSize="30" Visibility="{Binding ProVisibility }"  Width="AUTO" Margin="0,5"/>
+            </StackPanel>
         </Grid>
     </Grid>
 </UserControl>

+ 7 - 0
BlankApp1/BlankApp1/Views/MonitorManageView/PLCPointView.xaml

@@ -5,9 +5,11 @@
              xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
              xmlns:local="clr-namespace:PLCTool.Views.MonitorManageView"
              xmlns:prism="http://prismlibrary.com/"
+              xmlns:b="http://schemas.microsoft.com/xaml/behaviors"
              mc:Ignorable="d" 
              d:DesignHeight="450" d:DesignWidth="800">
     <UserControl.Resources >
+       
         <Style TargetType="RadioButton" x:Key="NavTabButtonStyle">
             <Setter Property="FontSize" Value="15"/>
             <Setter Property="Foreground" Value="#DDD"/>
@@ -47,6 +49,11 @@
         </Style>
     </UserControl.Resources>
     <Grid>
+        <b:Interaction.Triggers>
+            <b:EventTrigger EventName="Loaded">
+                <b:InvokeCommandAction Command="{Binding OnLoadCommand}"/>
+            </b:EventTrigger>
+        </b:Interaction.Triggers>
         <Grid.RowDefinitions>
             <RowDefinition Height="60"/>
             <RowDefinition/>