Commit 98260241 authored by 潘栩锋's avatar 潘栩锋 🚴

修改 查找界面,查找是通过储存过程获取结果。 可以只查找到异常数据

parent e5609c92
This diff is collapsed.
...@@ -51,6 +51,12 @@ ...@@ -51,6 +51,12 @@
<TextBlock Style="{StaticResource TitleStyle}" Text="工序号"/> <TextBlock Style="{StaticResource TitleStyle}" Text="工序号"/>
<TextBox Style="{StaticResource ValueStyle}" Text="{Binding StepNo}"/> <TextBox Style="{StaticResource ValueStyle}" Text="{Binding StepNo}"/>
</StackPanel> </StackPanel>
<controls:ToggleSwitch Header="只查找超出标准工艺"
Margin="{StaticResource ControlMargin}"
IsChecked="{Binding IsJustSelectError}"
OffLabel="否"
OnLabel="是"
Style="{StaticResource MahApps.Metro.Styles.ToggleSwitch.Win10}" />
</StackPanel> </StackPanel>
<StackPanel Orientation="Horizontal"> <StackPanel Orientation="Horizontal">
...@@ -78,9 +84,10 @@ ...@@ -78,9 +84,10 @@
controls:TextBoxHelper.Watermark="输入订单号查找" controls:TextBoxHelper.Watermark="输入订单号查找"
Text="{Binding OrderNoFilter}"> Text="{Binding OrderNoFilter}">
<TextBox.InputBindings> <TextBox.InputBindings>
<KeyBinding Key="Return" <!--<KeyBinding Key="Return"
Command="{Binding ButtonSearch, Mode=OneWay}" Command="{Binding SearchCmd}"
CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=TextBox}, Path=Text, Mode=OneWay}" /> CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=TextBox}, Path=Text, Mode=OneWay}" />-->
<KeyBinding Key="Return" Command="{Binding SearchCmd}"/>
</TextBox.InputBindings> </TextBox.InputBindings>
<TextBox.Style> <TextBox.Style>
<Style BasedOn="{StaticResource SearchMetroTextBox}" TargetType="{x:Type TextBox}"> <Style BasedOn="{StaticResource SearchMetroTextBox}" TargetType="{x:Type TextBox}">
...@@ -94,7 +101,7 @@ ...@@ -94,7 +101,7 @@
</TextBox.Style> </TextBox.Style>
</TextBox> </TextBox>
</StackPanel> </StackPanel>
<Button Style="{StaticResource AccentCircleButtonStyle}" Margin="5,5,5,5" Grid.Column="1" VerticalAlignment="Bottom" Command="{Binding ButtonSearch, Mode=OneWay}"> <Button Style="{StaticResource AccentCircleButtonStyle}" Margin="5,5,5,5" Grid.Column="1" VerticalAlignment="Bottom" Command="{Binding SearchCmd}">
<iconPacks:Material Width="25" Height="25" <iconPacks:Material Width="25" Height="25"
Kind="Magnify" /> Kind="Magnify" />
</Button> </Button>
...@@ -102,7 +109,7 @@ ...@@ -102,7 +109,7 @@
<StackPanel Grid.Column="1" Orientation="Horizontal" Margin="{StaticResource ControlMargin}" HorizontalAlignment="Right"> <StackPanel Grid.Column="1" Orientation="Horizontal" Margin="{StaticResource ControlMargin}" HorizontalAlignment="Right">
<Button Style="{StaticResource AccentCircleButtonStyle}" Margin="5,5,5,5" VerticalAlignment="Bottom" Click="ButtonOK_Click"> <Button Style="{StaticResource AccentCircleButtonStyle}" Margin="5,5,5,5" VerticalAlignment="Bottom" Command="{Binding OkCmd}">
<iconPacks:PackIconFontAwesome Width="40" Height="40" <iconPacks:PackIconFontAwesome Width="40" Height="40"
Kind="CheckCircleSolid" /> Kind="CheckCircleSolid" />
</Button> </Button>
...@@ -126,6 +133,8 @@ ...@@ -126,6 +133,8 @@
</Style> </Style>
</DataGrid.Style> </DataGrid.Style>
<DataGrid.Columns> <DataGrid.Columns>
<DataGridTextColumn Binding="{Binding MachineNo}" Header="机台号"/>
<DataGridTextColumn Binding="{Binding StepNo}" Header="工序号"/>
<DataGridTextColumn Binding="{Binding OrderNo}" Header="订单号"/> <DataGridTextColumn Binding="{Binding OrderNo}" Header="订单号"/>
<DataGridTextColumn Binding="{Binding ProjectNo}" Header="项目号"/> <DataGridTextColumn Binding="{Binding ProjectNo}" Header="项目号"/>
<DataGridTextColumn Binding="{Binding TechnologyNo}" Header="工艺号"/> <DataGridTextColumn Binding="{Binding TechnologyNo}" Header="工艺号"/>
...@@ -134,6 +143,14 @@ ...@@ -134,6 +143,14 @@
<DataGridTextColumn Binding="{Binding TotalLen}" Header="检测长度"/> <DataGridTextColumn Binding="{Binding TotalLen}" Header="检测长度"/>
<DataGridTextColumn Binding="{Binding HasSBData}" Header="温度数据"/> <DataGridTextColumn Binding="{Binding HasSBData}" Header="温度数据"/>
<DataGridTextColumn Binding="{Binding HasTGData}" Header="厚度数据"/> <DataGridTextColumn Binding="{Binding HasTGData}" Header="厚度数据"/>
<DataGridTemplateColumn Header="温度异常" >
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Button Content="{Binding TechInfos.Count}" Command="{Binding ElementName=dgridProcesses,Path=DataContext.ShowTechInfosCmd}" CommandParameter="{Binding TechInfos}"/>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
</DataGridTemplateColumn>
</DataGrid.Columns> </DataGrid.Columns>
</DataGrid> </DataGrid>
......
using MahApps.Metro.Controls.Dialogs; using GalaSoft.MvvmLight.Command;
using MahApps.Metro.Controls.Dialogs;
using OfficeOpenXml.FormulaParsing.Excel.Functions.Information;
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Collections.ObjectModel; using System.Collections.ObjectModel;
...@@ -34,65 +36,10 @@ namespace WSDDBBrowser ...@@ -34,65 +36,10 @@ namespace WSDDBBrowser
public void Init() public void Init()
{ {
viewModel = new PgSelectViewModel(); viewModel = new PgSelectViewModel();
viewModel.Init(); viewModel.Init(DBViewerModel.Instance, DBHelper.Instance,
this.DataContext = viewModel; dgridProcesses, NavigationService);
}
private async void ButtonOK_Click(object sender, RoutedEventArgs e)
{
if (dgridProcesses.SelectedItems.Count == 0)
{
await App.MetroWindow.ShowMessageAsync("加载异常",
$"没有选择任何一个记录,也许忘记按 【搜索】 了!!");
return;
}
//开始加载
var controller = await App.MetroWindow.ShowProgressAsync("请等待...", "开始加载数据",
settings: new MetroDialogSettings()
{
NegativeButtonText = "停止",
AnimateShow = false,
AnimateHide = false,
});
//controller.SetCancelable(true);
controller.SetIndeterminate();
DBViewerModel.Instance.CurrProcess = null;
DBViewerModel.Instance.CurrProcess = dgridProcesses.SelectedItem as Process;
bool ret = DBViewerModel.Instance.GetProcessPacks();
if (!ret)
{
//获取出错
await controller.CloseAsync();
await App.MetroWindow.ShowMessageAsync("加载出错", "数据异常,请检测数据库");
return;
}
await controller.CloseAsync(); this.DataContext = viewModel;
string msg = "";
if (DBViewerModel.Instance.CurrProcess.HasTGData)
{
int cnt = DBViewerModel.Instance.ScanDataItems.Sum(item => item.MixValues.Count());
msg += $"厚度数据 {cnt}幅";
}
if (DBViewerModel.Instance.CurrProcess.HasSBData)
{
int cnt = DBViewerModel.Instance.SBProcessPack.Records.Count();
msg += $"温控数据 {cnt}个点";
}
//加载成功
await App.MetroWindow.ShowMessageAsync("加载成功", msg);
this.NavigationService.GoBack();
this.NavigationService.RemoveBackEntry();
} }
private void ButtonBack_Click(object sender, RoutedEventArgs e) private void ButtonBack_Click(object sender, RoutedEventArgs e)
...@@ -114,12 +61,12 @@ namespace WSDDBBrowser ...@@ -114,12 +61,12 @@ namespace WSDDBBrowser
/// <summary> /// <summary>
/// 机台号 /// 机台号
/// </summary> /// </summary>
public int MachineNo { get; set; } public int? MachineNo { get; set; }
/// <summary> /// <summary>
/// 工序号 /// 工序号
/// </summary> /// </summary>
public int StepNo { get; set; } public int? StepNo { get; set; }
/// <summary> /// <summary>
/// 开始日期 /// 开始日期
...@@ -134,34 +81,62 @@ namespace WSDDBBrowser ...@@ -134,34 +81,62 @@ namespace WSDDBBrowser
/// </summary> /// </summary>
public string OrderNoFilter { get; set; } public string OrderNoFilter { get; set; }
/// <summary>
/// 只查找超出标准工艺
/// </summary>
public bool IsJustSelectError { get; set; }
/// <summary> /// <summary>
/// 生产列表 /// 生产列表
/// </summary> /// </summary>
public ObservableCollection<Process> Processes { get; } = new ObservableCollection<Process>(); public ObservableCollection<Process> Processes { get; } = new ObservableCollection<Process>();
#region Command
public RelayCommand SearchCmd { get; }
public RelayCommand OkCmd { get; }
public RelayCommand<List<TechInfo>> ShowTechInfosCmd { get; }
#endregion
DBViewerModel dbViewerModel;
DBHelper dbHelper;
DataGrid dataGrid;
NavigationService navigationService;
public PgSelectViewModel() public PgSelectViewModel()
{ {
SearchCmd = new RelayCommand(Search);
OkCmd = new RelayCommand(Ok);
ShowTechInfosCmd = new RelayCommand<List<TechInfo>>(ShowTechInfos);
} }
public void Init()
public void Init(DBViewerModel dbVm, DBHelper dbHelper,
DataGrid dataGrid, NavigationService navigationService)
{ {
this.dbViewerModel = dbVm;
this.dbHelper = dbHelper;
this.dataGrid = dataGrid;
this.navigationService = navigationService;
BeginDate = DateTime.Now.AddDays(-1); BeginDate = DateTime.Now.AddDays(-1);
EndDate = DateTime.Now; EndDate = DateTime.Now;
StepNo = DBViewerModel.Instance.StepNo; MachineNo = this.dbViewerModel.MachineNo;
MachineNo = DBViewerModel.Instance.MachineNo; StepNo = this.dbViewerModel.StepNo;
DBInit(); DBInit();
} }
void DBInit() void DBInit()
{ {
if (!DBHelper.Instance.Init( if (!dbHelper.Init(
DBViewerModel.Instance.ServerIP, dbViewerModel.ServerIP,
DBViewerModel.Instance.ServerUser, dbViewerModel.ServerUser,
DBViewerModel.Instance.ServerPw)) dbViewerModel.ServerPw))
{ {
DBInitResult = DBHelper.Instance.ErrorMsg; DBInitResult = dbHelper.ErrorMsg;
} }
else else
{ {
...@@ -170,31 +145,37 @@ namespace WSDDBBrowser ...@@ -170,31 +145,37 @@ namespace WSDDBBrowser
} }
private async void Search()
private ICommand buttonSearch;
public ICommand ButtonSearch
{ {
get var list = dbHelper.GetProcessList(StepNo, MachineNo, BeginDate, EndDate, OrderNoFilter, IsJustSelectError);
{
return this.buttonSearch ?? (this.buttonSearch = new ClickCommand( async ()=> {
var list = DBHelper.Instance.GetProcessList(StepNo, MachineNo, BeginDate, EndDate, OrderNoFilter);
//var list = dbHelper.GetProcessList_Debug(StepNo, MachineNo, BeginDate, EndDate, OrderNoFilter, IsJustSelectError);
Processes.Clear(); Processes.Clear();
foreach (var p in list) foreach (var p in list)
{ {
Processes.Add(p); Processes.Add(p);
} }
if (list.Count() > 0) if (list.Count() > 0)
{ {
if (StepNo != DBViewerModel.Instance.StepNo || MachineNo != DBViewerModel.Instance.MachineNo) if (StepNo != dbViewerModel.StepNo ||
MachineNo != dbViewerModel.MachineNo )
{
bool isChanged = false;
if (StepNo!=null)
{ {
DBViewerModel.Instance.StepNo = StepNo; dbViewerModel.StepNo = (int)StepNo;
DBViewerModel.Instance.MachineNo = MachineNo; isChanged = true;
DBViewerModel.Instance.Save(); }
if (MachineNo!=null)
{
dbViewerModel.MachineNo = (int)MachineNo;
isChanged = true;
}
if(isChanged)
dbViewerModel.Save();
} }
} }
if (Processes.Count > 0) if (Processes.Count > 0)
...@@ -206,8 +187,69 @@ namespace WSDDBBrowser ...@@ -206,8 +187,69 @@ namespace WSDDBBrowser
{ {
await App.MetroWindow.ShowMessageAsync("加载失败", $"不能找到任何记录"); await App.MetroWindow.ShowMessageAsync("加载失败", $"不能找到任何记录");
} }
}));
} }
private async void Ok()
{
if (dataGrid.SelectedItems.Count == 0)
{
await App.MetroWindow.ShowMessageAsync("加载异常",
$"没有选择任何一个记录,也许忘记按 【搜索】 了!!");
return;
}
//开始加载
var controller = await App.MetroWindow.ShowProgressAsync("请等待...", "开始加载数据",
settings: new MetroDialogSettings()
{
NegativeButtonText = "停止",
AnimateShow = false,
AnimateHide = false,
});
//controller.SetCancelable(true);
controller.SetIndeterminate();
dbViewerModel.CurrProcess = null;
dbViewerModel.CurrProcess = dataGrid.SelectedItem as Process;
bool ret = dbViewerModel.GetProcessPacks();
if (!ret)
{
//获取出错
await controller.CloseAsync();
await App.MetroWindow.ShowMessageAsync("加载出错", "数据异常,请检测数据库");
return;
}
await controller.CloseAsync();
string msg = "";
if (dbViewerModel.CurrProcess.HasTGData)
{
int cnt = dbViewerModel.ScanDataItems.Sum(item => item.MixValues.Count());
msg += $"厚度数据 {cnt}幅";
}
if (dbViewerModel.CurrProcess.HasSBData)
{
int cnt = DBViewerModel.Instance.SBProcessPack.Records.Count();
msg += $"温控数据 {cnt}个点";
}
//加载成功
await App.MetroWindow.ShowMessageAsync("加载成功", msg);
navigationService.GoBack();
navigationService.RemoveBackEntry();
}
private async void ShowTechInfos(List<TechInfo> techInfos)
{
TechInfoDialog techInfoDialog = new TechInfoDialog();
await techInfoDialog.Show(techInfos);
} }
} }
......
<dialog:CustomDialog x:Class="WSDDBBrowser.TechInfoDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:local="clr-namespace:WSDDBBrowser"
mc:Ignorable="d"
xmlns:controls="http://metro.mahapps.com/winfx/xaml/controls"
xmlns:dialog="clr-namespace:MahApps.Metro.Controls.Dialogs;assembly=MahApps.Metro"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
d:DesignHeight="450" d:DesignWidth="800">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<DataGrid x:Name="dataGrid" AutoGenerateColumns="False" IsReadOnly="True" ItemsSource="{Binding TechInfos}"
RowStyle="{StaticResource MetroDataGridRow}"
>
<DataGrid.Style>
<Style BasedOn="{StaticResource MetroDataGrid}" TargetType="{x:Type DataGrid}">
<Setter Property="AlternatingRowBackground" Value="{DynamicResource GrayBrush10}" />
</Style>
</DataGrid.Style>
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding DeviceId}" Header="设备编号"/>
<DataGridTextColumn Binding="{Binding DeviceName}" Header="设备名称"/>
<DataGridTextColumn Binding="{Binding TechnologyNo}" Header="工艺号"/>
<DataGridTextColumn Binding="{Binding Target,StringFormat={}{0:F1}}" Header="目标值"/>
<DataGridTextColumn Binding="{Binding Tolerance,StringFormat={}{0:F1}}" Header="公差"/>
<DataGridTextColumn Binding="{Binding Avg,StringFormat={}{0:F1}}" Header="平均值"/>
</DataGrid.Columns>
</DataGrid>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Right" Margin="0,20" Grid.Row="1">
<StackPanel.Resources>
<Style TargetType="Button" BasedOn="{StaticResource AccentedSquareButtonStyle}">
<Setter Property="FontSize" Value="15"/>
<Setter Property="Width" Value="100"/>
<Setter Property="Margin" Value="5"/>
</Style>
</StackPanel.Resources>
<Button Content="确定" Click="ButtonOK_Click" />
</StackPanel>
</Grid>
</dialog:CustomDialog>
using MahApps.Metro.Controls.Dialogs;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using WSDDBBrowser.Core;
namespace WSDDBBrowser
{
/// <summary>
/// TechInfoDialog.xaml 的交互逻辑
/// </summary>
public partial class TechInfoDialog : CustomDialog
{
System.Threading.CancellationTokenSource cancellationTokenSource;
public TechInfoDialog()
{
InitializeComponent();
}
public async Task Show(List<TechInfo> techInfos)
{
dataGrid.ItemsSource = techInfos;
cancellationTokenSource = new System.Threading.CancellationTokenSource();
await App.MetroWindow.ShowMetroDialogAsync(this, settings: new MetroDialogSettings() { AnimateHide = true });
try
{
await Task.Delay(-1, cancellationTokenSource.Token);
}
catch (Exception e)
{
}
}
private async void ButtonOK_Click(object sender, RoutedEventArgs e)
{
await App.MetroWindow.HideMetroDialogAsync(this, settings: new MetroDialogSettings() { AnimateHide = true });
cancellationTokenSource.Cancel();
}
}
}
...@@ -121,6 +121,9 @@ ...@@ -121,6 +121,9 @@
<Compile Include="PgChartView.xaml.cs"> <Compile Include="PgChartView.xaml.cs">
<DependentUpon>PgChartView.xaml</DependentUpon> <DependentUpon>PgChartView.xaml</DependentUpon>
</Compile> </Compile>
<Compile Include="TechInfoDialog.xaml.cs">
<DependentUpon>TechInfoDialog.xaml</DependentUpon>
</Compile>
<Compile Include="Themes\Styles.cs" /> <Compile Include="Themes\Styles.cs" />
<Page Include="Chart\ColumnRangeScanGraph.xaml"> <Page Include="Chart\ColumnRangeScanGraph.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
...@@ -182,6 +185,10 @@ ...@@ -182,6 +185,10 @@
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
</Page> </Page>
<Page Include="TechInfoDialog.xaml">
<SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator>
</Page>
<Page Include="Themes\CustomTabControl.xaml"> <Page Include="Themes\CustomTabControl.xaml">
<SubType>Designer</SubType> <SubType>Designer</SubType>
<Generator>MSBuild:Compile</Generator> <Generator>MSBuild:Compile</Generator>
...@@ -262,6 +269,9 @@ ...@@ -262,6 +269,9 @@
<PackageReference Include="MahApps.Metro.IconPacks"> <PackageReference Include="MahApps.Metro.IconPacks">
<Version>3.0.0-alpha0146</Version> <Version>3.0.0-alpha0146</Version>
</PackageReference> </PackageReference>
<PackageReference Include="MvvmLight">
<Version>5.4.1.1</Version>
</PackageReference>
<PackageReference Include="Newtonsoft.Json"> <PackageReference Include="Newtonsoft.Json">
<Version>12.0.2</Version> <Version>12.0.2</Version>
</PackageReference> </PackageReference>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment