djs 5 місяців тому
батько
коміт
14b8c4e01f

+ 4 - 2
MeterVision/Patch/UCPatchGrid.xaml.cs

@@ -487,8 +487,9 @@ namespace MeterVision.Patch
                 int runCount = 0;
                 await Task.Run(() =>
                 {
+                    string stationId = CurStationItem == null ? "" : CurStationItem.StationId;
                     //查询任务
-                    List<TPatchDetail> patchDetails = DBPatch.GetPatchDetailsWithRunFlagZero(CurPatchItem.PatchId);
+                    List<TPatchDetail> patchDetails = DBPatch.GetPatchDetailsWithRunFlagZero(CurPatchItem.PatchId,stationId);
                     for(int i = 0; i < patchDetails.Count; i++)
                     {
                         if (!IsProcessingTask)
@@ -605,7 +606,8 @@ namespace MeterVision.Patch
 
                 int taskCount = await Task.Run(() =>
                 {
-                    return DBPatch.GetPatchDetailsCountWithRunFlagZero(CurPatchItem.PatchId);
+                    string stationId = CurStationItem == null ? "" : CurStationItem.StationId;
+                    return DBPatch.GetPatchDetailsCountWithRunFlagZero(CurPatchItem.PatchId,stationId);
                 });
                 return taskCount;
             }

+ 2 - 0
MeterVision/Patch/UCPatchMain.xaml.cs

@@ -549,6 +549,8 @@ namespace MeterVision.Patch
                     }//foreach
                 }//if vpatch!=null
                 RefresUIPatchItem(SelectedPatchItem.PatchId);
+                //刷新站点的统计信息
+                ucStationGrid.RefreshItems();
             }//blTask
         }
 

+ 41 - 9
MeterVision/Station/UCVpsGrid.xaml

@@ -24,7 +24,7 @@
     </UserControl.Resources>
 
     <Grid>
-        <DataGrid Name="dgStation" GridLinesVisibility="All" HorizontalGridLinesBrush="#D3D3D3" VerticalGridLinesBrush="#D3D3D3" RowHeight="60" BorderBrush="#D3D3D3"
+        <DataGrid Name="dgStation" GridLinesVisibility="All" HorizontalGridLinesBrush="#D3D3D3" VerticalGridLinesBrush="#D3D3D3" RowHeight="80" BorderBrush="#D3D3D3"
                   HeadersVisibility="Column" SelectionMode="Single" SelectionUnit="FullRow" HorizontalScrollBarVisibility="Auto" CanUserResizeColumns="False"  
                   FrozenColumnCount="5"
                   SelectedItem="{Binding SelectedStationItem,Mode=TwoWay}"
@@ -90,32 +90,64 @@
                                 <Grid.RowDefinitions>
                                     <RowDefinition Height="*" />
                                     <RowDefinition Height="*" />
+                                    <RowDefinition Height="*" />
                                 </Grid.RowDefinitions>
                                 <Grid Grid.Row="0">
                                     <Grid.ColumnDefinitions>
                                         <ColumnDefinition Width="Auto" />
                                         <ColumnDefinition Width="*" />
+                                        <ColumnDefinition Width="*" />
                                     </Grid.ColumnDefinitions>
                                     <TextBlock Text="{Binding Index,StringFormat='{}{0}.'}" FontSize="14px" Foreground="#000000" HorizontalAlignment="Left" VerticalAlignment="Center"/>
-                                    <TextBlock Grid.Column="1" Text="{Binding StationIdName}" FontSize="14px" Foreground="#000000"
-                                               Margin="0 0 10 0" HorizontalAlignment="Right" VerticalAlignment="Center"/>
+                                    <TextBlock Grid.Column="1" Text="{Binding StationIdName}" FontSize="14px" Foreground="#000000" FontWeight="Bold"
+                                               Margin="20 0 0 0" HorizontalAlignment="Left" VerticalAlignment="Center"/>
+                                    <TextBlock Grid.Column="2" FontSize="14px" Foreground="{Binding TotalRunRateColor}"  Margin="0 0 10 0"
+                                               VerticalAlignment="Center" HorizontalAlignment="Right">
+                                        <TextBlock.Text>
+                                            <MultiBinding StringFormat="{}{0} / {1}">
+                                                <Binding Path="RunCount" />
+                                                <Binding Path="TotalCount"/>
+                                            </MultiBinding>
+                                        </TextBlock.Text>
+                                    </TextBlock>
                                 </Grid>
                                 <Grid Grid.Row="1">
                                     <Grid.ColumnDefinitions>
                                         <ColumnDefinition Width="*" />
                                         <ColumnDefinition Width="*" />
                                         <ColumnDefinition Width="*" />
+                                    </Grid.ColumnDefinitions>
+                                    <TextBlock Grid.Column="0" Text="正确" HorizontalAlignment="Left" VerticalAlignment="Center"
+                                               FontSize="14px" Foreground="#28a745" />
+                                    <TextBlock Grid.Column="1" Text="错误" HorizontalAlignment="Left" VerticalAlignment="Center"
+                                               FontSize="14px" Foreground="#dc3545" />
+                                    <TextBlock Grid.Column="2" Text="无效" HorizontalAlignment="Left" VerticalAlignment="Center"
+                                               FontSize="14px" Foreground="#FFA500" />
+                                </Grid>
+
+                                <Grid Grid.Row="2">
+                                    <Grid.ColumnDefinitions>
+                                        <ColumnDefinition Width="*" />
+                                        <ColumnDefinition Width="*" />
                                         <ColumnDefinition Width="*" />
+                                        <!--<ColumnDefinition Width="*" />-->
                                     </Grid.ColumnDefinitions>
-                                    <TextBlock Grid.Column="0" Text="{Binding TotalCount,StringFormat='总数: {0}'}" HorizontalAlignment="Left" VerticalAlignment="Center"
-                                               FontSize="13px" Foreground="#000000" />
-                                    <TextBlock Grid.Column="1" Text="{Binding EqualCount,StringFormat='正确: {0}'}" HorizontalAlignment="Left" VerticalAlignment="Center"
+                                    <!--<TextBlock Grid.Column="0" Text="{Binding TotalCount,StringFormat='总数: {0}'}" HorizontalAlignment="Left" VerticalAlignment="Center"
+                                               FontSize="13px" Foreground="#000000" />-->
+                                    <!--<TextBlock Grid.Column="1" Text="{Binding EqualCountRate,StringFormat='正确: {0}'}" HorizontalAlignment="Left" VerticalAlignment="Center"
                                                FontSize="13px" Foreground="#28a745" />
-                                    <TextBlock Grid.Column="2" Text="{Binding ErrorCount,StringFormat='错误: {0}'}" HorizontalAlignment="Left" VerticalAlignment="Center"
+                                    <TextBlock Grid.Column="2" Text="{Binding ErrorCountRate,StringFormat='错误: {0}'}" HorizontalAlignment="Left" VerticalAlignment="Center"
                                                FontSize="13px" Foreground="#dc3545" />
-                                    <TextBlock Grid.Column="3" Text="{Binding InvalidCount,StringFormat='无效: {0}'}" HorizontalAlignment="Left" VerticalAlignment="Center"
-                                               FontSize="13px" Foreground="#FFA500" />
+                                    <TextBlock Grid.Column="3" Text="{Binding InvalidCountRate,StringFormat='无效: {0}'}" HorizontalAlignment="Left" VerticalAlignment="Center"
+                                               FontSize="13px" Foreground="#FFA500" />-->
+                                    <TextBlock Grid.Column="0" Text="{Binding EqualRateName}" HorizontalAlignment="Left" VerticalAlignment="Center"
+                                               FontSize="13px" Foreground="#000000" />
+                                    <TextBlock Grid.Column="1" Text="{Binding ErrorRateName}" HorizontalAlignment="Left" VerticalAlignment="Center"
+                                               FontSize="13px" Foreground="#000000" />
+                                    <TextBlock Grid.Column="2" Text="{Binding InvalidRateName}" HorizontalAlignment="Left" VerticalAlignment="Center"
+                                               FontSize="13px" Foreground="#000000" />
                                 </Grid>
+                                
                             </Grid>
                             
                         </DataTemplate>

+ 34 - 0
MeterVision/Station/UCVpsGrid.xaml.cs

@@ -1,6 +1,7 @@
 using MeterVision.Config;
 using MeterVision.db;
 using MeterVision.model;
+using MeterVision.Util;
 using System;
 using System.Collections.Generic;
 using System.Collections.ObjectModel;
@@ -264,6 +265,39 @@ namespace MeterVision.Station
             }
         }
 
+        public async void RefreshItems()
+        {
+            try
+            { 
+                var result = await Task.Run(() =>
+                {
+                    return DBPatch.GetPagedPatchStations(StationPage.PageNumber, StationPage.PageSize, FindStationId, PatchId);
+                });
+
+                //更新分页信息
+                //TotalRecords = result.Item1;
+                //StationPage.PageCount = result.Item2;
+                List<VPatchStation> stationList = result.Item3;
+
+                foreach(var stationItem in StationItemList)
+                {
+                    int index = stationItem.Index;
+                    var findItem = stationList.Find((a) => a.StationId == stationItem.StationId);
+                    if(findItem!= null)
+                    {
+                        ObjectHelper.CopyMatchingFields(findItem, stationItem);
+                        stationItem.Index = index;
+                    }
+                }
+            }
+            catch (Exception ex)
+            {
+                MessageBox.Show(Application.Current.MainWindow,
+                    $"加载数据是发生错误:{ex.Message}", "错误",
+                    MessageBoxButton.OK, MessageBoxImage.Error);
+            }
+        }
+
         //---------------------------------------------------------------------
     }
 }

+ 19 - 6
MeterVision/db/DBPatch.cs

@@ -850,7 +850,7 @@ namespace MeterVision.db
 
 
 
-        public static List<TPatchDetail> GetPatchDetailsWithRunFlagZero(string patchId)
+        public static List<TPatchDetail> GetPatchDetailsWithRunFlagZero(string patchId,string stationId)
         {
             // 查询 SQL
             //string sql = @"
@@ -866,16 +866,22 @@ namespace MeterVision.db
             //    FROM t_patch_detail 
             //    WHERE patch_id = @PatchId AND run_flag = 0
             //    ORDER BY create_time ASC;"; // 可以根据需要修改排序字段
+            string whereStation = "";
+            if (!string.IsNullOrEmpty(stationId))
+            {
+                whereStation = " AND station_id = @StationId";
+            }
 
             string sql = $@"
                 SELECT * FROM t_patch_detail
-                WHERE patch_id = @PatchId AND run_flag = 0
+                WHERE patch_id = @PatchId AND run_flag = 0{whereStation}
                 ORDER BY station_id,sample_time ASC";
 
             // 定义参数
             SQLiteParameter[] parameters = new SQLiteParameter[]
             {
-                new SQLiteParameter("@PatchId", patchId)
+                new SQLiteParameter("@PatchId", patchId),
+                new SQLiteParameter("@StationId",stationId)
             };
 
             // 执行查询并读取数据
@@ -931,15 +937,22 @@ namespace MeterVision.db
         }
 
 
-        public static int GetPatchDetailsCountWithRunFlagZero(string patchId)
+        public static int GetPatchDetailsCountWithRunFlagZero(string patchId,string stationId)
         {
+            string whereStation = "";
+            if(!string.IsNullOrEmpty(stationId))
+            {
+                whereStation = " AND station_id = @StationId";
+            }
+
             // 查询数据数量的 SQL
-            string sql = "SELECT COUNT(*) FROM t_patch_detail WHERE patch_id = @PatchId AND run_flag = 0";
+            string sql = $@"SELECT COUNT(*) FROM t_patch_detail WHERE patch_id = @PatchId AND run_flag = 0{whereStation}";
 
             // 定义参数
             SQLiteParameter[] parameters = new SQLiteParameter[]
             {
-                new SQLiteParameter("@PatchId", patchId)
+                new SQLiteParameter("@PatchId", patchId),
+                new SQLiteParameter("@StationId",stationId)
             };
 
             // 执行查询并返回数据数量

+ 31 - 2
MeterVision/db/VPatchStation.cs

@@ -20,7 +20,7 @@ namespace MeterVision.db
         public string PatchId{ get; set;}
 
         public string StationId { get; set; }
-
+       
         public int TotalCount { get; set; }
 
         private int _errorCount;
@@ -33,6 +33,11 @@ namespace MeterVision.db
                 {
                     _errorCount = value;
                     OnPropertyChanged(nameof(ErrorCount));
+                    OnPropertyChanged(nameof(RunCount));
+                    OnPropertyChanged(nameof(TotalRunRateColor));
+                    OnPropertyChanged(nameof(InvalidRateName));
+                    OnPropertyChanged(nameof(EqualRateName));
+                    OnPropertyChanged(nameof(ErrorRateName));
                 }
             }
         }
@@ -47,6 +52,11 @@ namespace MeterVision.db
                 {
                     _equalCount = value;
                     OnPropertyChanged(nameof(EqualCount));
+                    OnPropertyChanged(nameof(RunCount));
+                    OnPropertyChanged(nameof(TotalRunRateColor));
+                    OnPropertyChanged(nameof(InvalidRateName));
+                    OnPropertyChanged(nameof(EqualRateName));
+                    OnPropertyChanged(nameof(ErrorRateName));
                 }
             }
         }
@@ -62,13 +72,32 @@ namespace MeterVision.db
                 {
                     _invalidCount = value;
                     OnPropertyChanged(nameof(InvalidCount));
+                    OnPropertyChanged(nameof(RunCount));
+                    OnPropertyChanged(nameof(TotalRunRateColor));
+                    OnPropertyChanged(nameof(InvalidRateName));
+                    OnPropertyChanged(nameof(EqualRateName));
+                    OnPropertyChanged(nameof(ErrorRateName));
                 }
             }
         }
 
         public int Index { get; set; }
 
-        
+        //总数
+        public int RunCount => (EqualCount + InvalidCount + ErrorCount);
+
+        private float EqualRate => RunCount > 0 ? (float)EqualCount / RunCount : 0.0f;
+        public string EqualRateName => $"{EqualCount} ({EqualRate.ToString("P1")})";
+
+        private float ErrorRate => RunCount > 0 ? (float)ErrorCount / RunCount : 0.0f;
+        public string ErrorRateName => $"{ErrorCount} ({ErrorRate.ToString("P1")})";
+
+        private float InvalidRate => RunCount > 0 ? (float)InvalidCount / RunCount : 0.0f;
+        public string InvalidRateName => $"{InvalidCount} ({InvalidRate.ToString("P1")})";
+
+        public string TotalRunRateColor => (TotalCount == RunCount) ? "#1E90FF" : "#000000";
+
+
         public string StationIdName
         {            
             get