Browse Source

批量识别增加站点

djs 5 months ago
parent
commit
4eb293a765

+ 37 - 12
MeterVision/Patch/UCPatchGrid.xaml.cs

@@ -67,10 +67,10 @@ namespace MeterVision.Patch
         }
 
         private PatchItem _curPatchItem;
-        public PatchItem CurPatchItem
+        private PatchItem CurPatchItem
         {
             get => _curPatchItem;
-            private set
+            set
             {
                 if (_curPatchItem != value)
                 {
@@ -82,11 +82,27 @@ namespace MeterVision.Patch
             }
         }
 
+        //此属性只在函数内部调用
+        private VPatchStation _curStationItem;
+        private VPatchStation CurStationItem
+        {
+            get => _curStationItem;
+            set
+            {
+                if (_curStationItem != value)
+                {
+                    _curStationItem = value;
+                    //PatchDetailPage.InitDefaulValue(mConfigItem.StandPageSize);
+                    //LoadStandDetailItemList();
+                }
+            }
+        }
+
         private PatchFindType _selectedPatchFindType;
-        public PatchFindType SelectedPatchFindType
+        private PatchFindType SelectedPatchFindType
         {
             get => _selectedPatchFindType;
-            private set
+            set
             {
                 if (_selectedPatchFindType != value)
                 {
@@ -98,10 +114,11 @@ namespace MeterVision.Patch
         }
 
         //改变PatchItem或PatchFinType
-        public void ChangePatchItemOrFinType(PatchItem curPatchItem,PatchFindType patchFindType)
+        public void ChangePatchItemOrFinType(PatchItem curPatchItem,VPatchStation curStationItem,PatchFindType patchFindType)
         {
             bool blPatchItemChanged = false;
             bool blPatchFindTypeChanged = false;
+            bool blStationChanged = false;
 
             //判断是否数据发生变化            
             if(curPatchItem != _curPatchItem)
@@ -110,13 +127,19 @@ namespace MeterVision.Patch
                 blPatchItemChanged = true;
             }
             
+            if(curStationItem != _curStationItem)
+            {
+                CurStationItem = curStationItem;
+                blStationChanged = true;
+            }
+
             if(patchFindType != _selectedPatchFindType)
             {
                 SelectedPatchFindType = patchFindType;
                 blPatchFindTypeChanged = true;
             }
-            
-            if(blPatchItemChanged || blPatchFindTypeChanged)
+                      
+            if(blPatchItemChanged || blPatchFindTypeChanged || blStationChanged)
             {
                 PatchDetailPage.InitDefaulValue();
                 LoadPatchDetailItemList(true);
@@ -184,11 +207,13 @@ namespace MeterVision.Patch
                 {
                     //var result = await Task.Run(() =>
                     //{
-                        //数据库查询
-                        //return DBPatch.GetPagedPatchDetails(
-                        //    PatchDetailPage.PageNumber, PatchDetailPage.PageSize, CurPatchItem.PatchId);
-                        PatchFindModel findModel = new PatchFindModel(PatchDetailPage.PageNumber, PatchDetailPage.PageSize,
-                            CurPatchItem.PatchId, SelectedPatchFindType);
+                    //数据库查询
+                    //return DBPatch.GetPagedPatchDetails(
+                    //    PatchDetailPage.PageNumber, PatchDetailPage.PageSize, CurPatchItem.PatchId);
+                    string stationId = CurStationItem == null ? "" : CurStationItem.StationId;
+
+                    PatchFindModel findModel = new PatchFindModel(PatchDetailPage.PageNumber, PatchDetailPage.PageSize,
+                            CurPatchItem.PatchId,stationId ,SelectedPatchFindType);
 
                      //   return DBPatch.GetPagedPatchDetails(findModel);
                     //});

+ 122 - 3
MeterVision/Patch/UCPatchMain.xaml

@@ -7,6 +7,7 @@
              xmlns:local2="clr-namespace:MeterVision"
              xmlns:zdfflatui="clr-namespace:ZdfFlatUI;assembly=WPF.UI"
              xmlns:img="clr-namespace:MeterVision.UC"
+             xmlns:station="clr-namespace:MeterVision.Station"
              mc:Ignorable="d"
              Padding="5 2 5 5"
              Background="WhiteSmoke"
@@ -30,6 +31,7 @@
     <Grid>
         <Grid.ColumnDefinitions>
             <ColumnDefinition Width="220" x:Name="colLeft" />
+            <ColumnDefinition Width="300" x:Name="colStation" />
             <ColumnDefinition Width="*" />
             <ColumnDefinition Width="400" x:Name="colRight" />
         </Grid.ColumnDefinitions>
@@ -391,7 +393,124 @@
             </Grid>
         </Border>
 
-        <Border Grid.Column="1" BorderBrush="#D3D3D3" BorderThickness="0 0 1 0" Padding="0 0 5 0">
+
+        <Grid Grid.Column="1" Background="WhiteSmoke">
+            <Grid.ColumnDefinitions>
+                <ColumnDefinition Width="*" />
+                <ColumnDefinition Width="0"/>
+            </Grid.ColumnDefinitions>
+
+            <!--右侧上左站点明细-->
+            <Border Grid.Column="0" BorderBrush="#D3D3D3" BorderThickness="0 0 1 0" Padding="0 0 5 0">
+                <Grid>
+                    <Grid.RowDefinitions>
+                        <RowDefinition Height="40" />
+                        <RowDefinition Height="*" />
+                        <RowDefinition Height="40" />
+                        <RowDefinition Height="40" />
+                    </Grid.RowDefinitions>
+
+                    <!--右上空间的上方状态栏-->
+                    <Border Grid.Row="0" BorderBrush="#D3D3D3" BorderThickness="0 0 0 0" Padding="0 2 0 2" Margin="2 0 2 0">
+                        <Grid>
+                            <Grid.ColumnDefinitions>
+                                <ColumnDefinition Width="Auto" />
+                                <ColumnDefinition Width="*" />
+                            </Grid.ColumnDefinitions>
+                            <!--<TextBlock Grid.Column="0" Text="站点列表-管理水表识别时所需的参数" 
+                                   TextWrapping="Wrap" FontWeight="Bold" FontSize="14px" VerticalAlignment="Center" />-->
+                            <StackPanel Grid.Column="0" Orientation="Horizontal" HorizontalAlignment="Left" Margin="5 0 2 0">
+                                <Button Content="◀️" x:Name="btnLeftCtl" FontSize="20px" Width="28" Height="28" Visibility="Visible"
+                                        Click="BtnLeftCtl_Click" Foreground="White" Background="#333333" Margin="0 0 5 0" />
+                                <TextBlock x:Name="txtStandName" Text="1."  Visibility="Visible"
+                                               FontSize="14px" FontWeight="Bold" VerticalAlignment="Center" />
+                            </StackPanel>
+
+                            <StackPanel Grid.Column="1" VerticalAlignment="Center" HorizontalAlignment="Right" Orientation="Horizontal">
+                                <!--<Button Content="◀️" x:Name="btnLeftCtl" FontSize="20px" Width="28" Height="28" Visibility="Visible"
+                                        Click="BtnLeftCtl_Click" Foreground="White" Background="#333333" Margin="5 0 5 0" />-->
+
+                                <TextBlock Text="站点:" VerticalAlignment="Center" Margin="5 0 5 0"
+                                        Foreground="Black" FontSize="14px" />
+                                <TextBox x:Name="txtFindStationId" FontSize="14px" Width="110" Text="12345678901" VerticalAlignment="Center" 
+                                        Padding="2" Margin="0 0 10 0" PreviewTextInput="TextBox_PreviewTextInput" />
+                                <zdfflatui:FlatButton Grid.Column="1" x:Name="btnQuery" HorizontalAlignment="Center"
+                                              Background="#2196F3" Content="查询"
+                                                Click="BtnQuery_Click" Foreground="White"
+                                              Width="60" Height="28" FontSize="14" Margin="0 0 5 0" />
+
+                                <zdfflatui:FlatButton Grid.Column="2" x:Name="btnRefreshStation" HorizontalAlignment="Center"
+                                              Background="#2196F3" Foreground="White" Content="🔄"
+                                          ToolTip="刷新数据列表" Visibility="Collapsed"
+                                          Click="BtnRefreshStation_Click" Margin="10 0 10 0"
+                                              Width="30" Height="28" FontSize="20px"  />
+                            </StackPanel>
+
+                        </Grid>
+                    </Border>
+
+                    <Border Grid.Row="1">
+                        <station:UCVpsGrid x:Name="ucStationGrid" Padding="5 5 5 5" />
+                    </Border>
+                    <!-- 底部分页控件 -->
+                    <StackPanel Grid.Row="2" Height="35" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0">
+                        <TextBlock Text="{Binding ElementName=ucStationGrid,Path=TotalRecords,StringFormat='共 {0} 条数据'}" Margin="5" VerticalAlignment="Center" FontSize="13px"/>
+                        <ComboBox Width="55" Margin="5" FontSize="13px" 
+                              ItemsSource="{x:Static local2:ThisApp.PageSizeOptions}"
+                              SelectedValue="{Binding ElementName=ucStationGrid,Path=mConfigItem.PatchPageSize}"/>
+                        <!--<Button x:Name="btnStationFirstPage" Content="首页" Width="55" Margin="5" FontSize="13px" Click="BtnStationFirstPage_Click"/>
+                            <Button x:Name="btnStationPrePage" Content="上一页" Width="55" Margin="5" FontSize="13px" Click="BtnStationPrePage_Click"/>
+                            <TextBlock  Margin="5" FontSize="13px" VerticalAlignment="Center">
+                                <TextBlock.Text>
+                                    -->
+                        <!--<MultiBinding StringFormat="第 {0} 页 / 共 {1} 页">-->
+                        <!--
+                                    <MultiBinding StringFormat="{}{0}/{1}">
+                                        <Binding ElementName="ucStationGrid" Path="StationPage.PageNumber"/>
+                                        <Binding ElementName="ucStationGrid" Path="StationPage.PageCount"/>
+                                    </MultiBinding>
+                                </TextBlock.Text>
+                            </TextBlock>
+
+                            <Button x:Name="btnStationNextPage" Content="下一页" Width="55" Margin="5" FontSize="13px" Click="BtnStationNextPage_Click"/>
+                            <Button x:Name="btnStationLastPage" Content="尾页" Width="55" Margin="5" FontSize="13px" Click="BtnStationLastPage_Click"/>-->
+                        <TextBox x:Name="txtStationPageNumber" Width="40" Margin="5" TextAlignment="Center" FontSize="13px"
+                                 Text="{Binding ElementName=ucStationGrid,Path=StationPage.PageNumber,Mode=OneWay}" Visibility="Visible"
+                                 MaxLength="3" PreviewTextInput="TextBox_PreviewTextInput" VerticalContentAlignment="Center"/>
+                        <Button x:Name="btnStationSpeciPage" Content="跳转" Width="50" Margin="5" FontSize="13px" 
+                                    Visibility="Visible" Click="BtnStationSpeciPage_Click"/>
+                    </StackPanel>
+
+                    <StackPanel Grid.Row="3" Height="35" Orientation="Horizontal" HorizontalAlignment="Center" VerticalAlignment="Center" Margin="0">
+                        <!--<TextBlock Text="{Binding ElementName=ucStationGrid,Path=TotalRecords,StringFormat='共 {0} 条数据'}" Margin="5" VerticalAlignment="Center" FontSize="13px"/>
+                            <ComboBox Width="55" Margin="5" FontSize="13px" 
+                              ItemsSource="{x:Static local2:ThisApp.PageSizeOptions}"
+                              SelectedValue="{Binding ElementName=ucStationGrid,Path=mConfigItem.PatchPageSize}"/>-->
+                        <Button x:Name="btnStationFirstPage" Content="首页" Width="50" Margin="5" FontSize="13px" Click="BtnStationFirstPage_Click"/>
+                        <Button x:Name="btnStationPrePage" Content="上一页" Width="50" Margin="5" FontSize="13px" Click="BtnStationPrePage_Click"/>
+                        <TextBlock  Margin="5" FontSize="13px" VerticalAlignment="Center">
+                            <TextBlock.Text>
+                                <!--<MultiBinding StringFormat="第 {0} 页 / 共 {1} 页">-->
+                                <MultiBinding StringFormat="{}{0}/{1}">
+                                    <Binding ElementName="ucStationGrid" Path="StationPage.PageNumber"/>
+                                    <Binding ElementName="ucStationGrid" Path="StationPage.PageCount"/>
+                                </MultiBinding>
+                            </TextBlock.Text>
+                        </TextBlock>
+
+                        <Button x:Name="btnStationNextPage" Content="下一页" Width="50" Margin="5" FontSize="13px" Click="BtnStationNextPage_Click"/>
+                        <Button x:Name="btnStationLastPage" Content="尾页" Width="50" Margin="5" FontSize="13px" Click="BtnStationLastPage_Click"/>
+                        <!--<TextBox x:Name="txtStationPageNumber" Width="40" Margin="5" TextAlignment="Center" FontSize="13px"
+                                 Text="{Binding ElementName=ucStationGrid,Path=StationPage.PageNumber,Mode=OneWay}"
+                                 MaxLength="3" PreviewTextInput="TextBox_PreviewTextInput" VerticalContentAlignment="Center"/>
+                            <Button x:Name="btnStationSpeciPage" Content="跳转" Width="55" Margin="5" FontSize="13px" Click="BtnStationSpeciPage_Click"/>-->
+                    </StackPanel>
+                </Grid>
+            </Border>
+            <!--右侧上左站点明细结束-->
+        </Grid>
+
+        <Border Grid.Column="2" BorderBrush="#D3D3D3" BorderThickness="0 0 1 0" Padding="0 0 5 0">
             <Grid>
                 <Grid.RowDefinitions>
                     <RowDefinition Height="40" />
@@ -401,7 +520,7 @@
 
                 <Grid Grid.Row="0">
                     <StackPanel Orientation="Horizontal" HorizontalAlignment="Left" Margin="5 0 2 0">
-                        <Button Content="◀️" x:Name="btnLeftCtl" FontSize="20px" Width="28" Height="28" Visibility="Visible"
+                        <Button Content="◀️" x:Name="btnLeftCtl1" FontSize="20px" Width="28" Height="28" Visibility="Visible"
                                 Click="BtnLeftCtl_Click"
                                Foreground="White" Background="#333333" Margin="0 0 5 0" />
 
@@ -467,7 +586,7 @@
             </Grid>                
         </Border>
 
-        <Border Grid.Column="2" Background="White">
+        <Border Grid.Column="3" Background="White">
             <Grid>
                 <Grid.RowDefinitions>
                     <RowDefinition Height="35" />

+ 82 - 5
MeterVision/Patch/UCPatchMain.xaml.cs

@@ -40,6 +40,8 @@ namespace MeterVision.Patch
 
         public event PropertyChangedEventHandler PropertyChanged;
 
+        private string FindStationId = "";
+
         protected void OnPropertyChanged(string propertyName)
         {
             PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(propertyName));
@@ -58,7 +60,7 @@ namespace MeterVision.Patch
                 {
                     _selectedPatchFindType = value;
                     OnPropertyChanged(nameof(SelectedPatchFindType));
-                    ucPatchGird.ChangePatchItemOrFinType(SelectedPatchItem, SelectedPatchFindType);
+                    ucPatchGird.ChangePatchItemOrFinType(SelectedPatchItem,SelectedStationItem ,SelectedPatchFindType);
                 }
             }
         }
@@ -79,12 +81,33 @@ namespace MeterVision.Patch
             {
                 _selectedPatchItem = value;
                 OnPropertyChanged(nameof(SelectedPatchItem));
-                //ucPatchGird.CurPatchItem = value;                
-                ucPatchGird.ChangePatchItemOrFinType(SelectedPatchItem, SelectedPatchFindType);
+                //ucPatchGird.ChangePatchItemOrFinType(SelectedPatchItem, SelectedPatchFindType);
+                
+                if(_selectedPatchItem != null)
+                {
+                    ucStationGrid.ChangeFind(FindStationId, _selectedPatchItem.PatchId);
+                }
+                else
+                {
+                    ucStationGrid.ChangeFind(FindStationId, "");
+                }
                 Apply_UCPatchDetail_Title(value);
             }
         }
 
+        private VPatchStation _selectedStationItem;
+        public VPatchStation SelectedStationItem
+        {
+            get => _selectedStationItem;
+            set
+            {
+                _selectedStationItem = value;
+                OnPropertyChanged(nameof(SelectedStationItem));
+                //ucPatchGird.CurStationItem = SelectedStationItem;
+                ucPatchGird.ChangePatchItemOrFinType(SelectedPatchItem, SelectedStationItem,SelectedPatchFindType);
+            }
+        }
+
         //总共的Patch数量
         private int _totalPatchRecords;
         public int TotalPatchRecords
@@ -189,6 +212,13 @@ namespace MeterVision.Patch
             ChangeLeftVisiable(LeftVisiable);
             RightVisiable = true;
             ChangeRightVisiable(RightVisiable);
+
+            ucStationGrid.OnItemChanged += UcStationGrid_OnItemChanged;
+        }
+
+        private void UcStationGrid_OnItemChanged(VPatchStation item)
+        {
+            SelectedStationItem = item;
         }
 
         private async void MConfigItem_OnPatchCatalogPageSizeChnaged(int pageSize)
@@ -600,8 +630,8 @@ namespace MeterVision.Patch
         {
             //ucPatchGird.CurPatchItem = null;
             //ucPatchGird.CurPatchItem = SelectedPatchItem;
-            ucPatchGird.ChangePatchItemOrFinType(null, SelectedPatchFindType);
-            ucPatchGird.ChangePatchItemOrFinType(SelectedPatchItem, SelectedPatchFindType);
+            ucPatchGird.ChangePatchItemOrFinType(null,null ,SelectedPatchFindType);
+            ucPatchGird.ChangePatchItemOrFinType(SelectedPatchItem, SelectedStationItem,SelectedPatchFindType);
         }
 
         private void AiLogSave_Click(object sender, RoutedEventArgs e)
@@ -647,6 +677,53 @@ namespace MeterVision.Patch
             btnRightCtl.Content = visiable ? "▶️" : "◀️" ;
             btnRightCtl.ToolTip = visiable ? "点击隐藏右侧栏" : "点击显示右侧栏";
         }
+
+        private void BtnStationFirstPage_Click(object sender, RoutedEventArgs e)
+        {
+            ucStationGrid.FirstPage();
+        }
+
+        private void BtnStationPrePage_Click(object sender, RoutedEventArgs e)
+        {
+            ucStationGrid.PrePage();
+        }
+
+        private void BtnStationNextPage_Click(object sender, RoutedEventArgs e)
+        {
+            ucStationGrid.NextPage();
+        }
+
+        private void BtnStationLastPage_Click(object sender, RoutedEventArgs e)
+        {
+            ucStationGrid.LastPage();
+        }
+
+        private void BtnStationSpeciPage_Click(object sender, RoutedEventArgs e)
+        {
+            try
+            {
+                int pageNumber = int.Parse(txtStationPageNumber.Text.ToString());
+                ucStationGrid.SpeciPage(pageNumber);
+            }
+            catch
+            {
+
+            }
+        }
+
+        private void BtnQuery_Click(object sender, RoutedEventArgs e)
+        {
+            FindStationId = txtFindStationId.Text.Trim();
+            ucStationGrid.ChangeFind(FindStationId,SelectedPatchItem.PatchId);
+            Apply_UCPatchDetail_Title(SelectedPatchItem);
+        }
+
+        private void BtnRefreshStation_Click(object sender, RoutedEventArgs e)
+        {
+            FindStationId = txtFindStationId.Text.Trim();
+            ucStationGrid.ChangeFind(FindStationId, SelectedPatchItem.PatchId);
+            Apply_UCPatchDetail_Title(SelectedPatchItem);
+        }
         //----------------------------------------------------------------
     }
 

+ 9 - 8
MeterVision/Station/UCVpsGrid.xaml.cs

@@ -36,17 +36,17 @@ namespace MeterVision.Station
 
         public event Action<VPatchStation> OnItemChanged;
 
-        private VPatchStation _selectedItem;
+        private VPatchStation _selectedStationItem;
 
-        public VPatchStation SelectedItem
+        public VPatchStation SelectedStationItem
         {
-            get => _selectedItem;
+            get => _selectedStationItem;
             set
             {
-                if(_selectedItem != value)
+                if(_selectedStationItem != value)
                 {
-                    _selectedItem = value;
-                    OnPropertyChanged(nameof(SelectedItem));
+                    _selectedStationItem = value;
+                    OnPropertyChanged(nameof(SelectedStationItem));
                     OnItemChanged?.Invoke(value);
                 }
             }
@@ -181,9 +181,10 @@ namespace MeterVision.Station
                         //item.Index = index + ((StationPage.PageNumber - 1) * StationPage.PageSize);
                         //StationItemList.Add(item);
                         station.Index = index + ((StationPage.PageNumber - 1) * StationPage.PageSize);
+                        StationItemList.Add(station);
                     }
 
-                    SelectedItem = null;
+                    SelectedStationItem = null;
                     if (StationItemList.Count > 0 && scrollTop)
                     {
                         dgStation.ScrollIntoView(dgStation.Items[0]);
@@ -196,7 +197,7 @@ namespace MeterVision.Station
                     $"加载数据是发生错误:{ex.Message}", "错误",
                     MessageBoxButton.OK, MessageBoxImage.Error);
             }
-            SelectedItem = null;
+            SelectedStationItem = null;
         }
 
 

+ 6 - 0
MeterVision/db/DBPatch.cs

@@ -546,6 +546,12 @@ namespace MeterVision.db
                 parameters.Add(new SQLiteParameter("@EqualFlag", findModel.EqualFlag));
             }
 
+            if (!string.IsNullOrEmpty(findModel.StationId))
+            {
+                whereClause.Append(" AND station_id = @StationId");
+                parameters.Add(new SQLiteParameter("StationId", findModel.StationId));
+            }
+
             if(findModel.PatchFindType == Patch.PatchFindType.HAVE_MEMO)
             {
                 whereClause.Append(" AND memo != ''");

+ 4 - 1
MeterVision/model/PatchFindModel.cs

@@ -16,6 +16,8 @@ namespace MeterVision.model
 
         public string PatchId { get; set; }
 
+        public string StationId { get; set; }
+
         //以上三个为必要条件
         //以下为相应Flag=1时,才作为SQL语句的条件
 
@@ -28,12 +30,13 @@ namespace MeterVision.model
         ////StandValueFlag>=0时,stand_value='',
         //public int StandValueFlag { get; set; }
 
-        public PatchFindModel(int pageNumber,int pageSize, string patchId,PatchFindType patchFindType)
+        public PatchFindModel(int pageNumber,int pageSize, string patchId, string stationId, PatchFindType patchFindType)
         {
             PatchFindType = patchFindType;
             PageNumber = pageNumber;
             PageSize = pageSize;
             PatchId = patchId;
+            StationId = stationId;
 
             if(patchFindType == PatchFindType.ALL)
             {