Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
W
weishida_DBbrower
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
潘栩锋
weishida_DBbrower
Commits
98260241
Commit
98260241
authored
Jul 27, 2020
by
潘栩锋
🚴
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改 查找界面,查找是通过储存过程获取结果。 可以只查找到异常数据
parent
e5609c92
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
555 additions
and
123 deletions
+555
-123
DBHelper.cs
WSDDBBrower/WSDDBBrower/Core/DBHelper.cs
+284
-20
PgSelect.xaml
WSDDBBrower/WSDDBBrower/PgSelect.xaml
+22
-5
PgSelect.xaml.cs
WSDDBBrower/WSDDBBrower/PgSelect.xaml.cs
+140
-98
TechInfoDialog.xaml
WSDDBBrower/WSDDBBrower/TechInfoDialog.xaml
+45
-0
TechInfoDialog.xaml.cs
WSDDBBrower/WSDDBBrower/TechInfoDialog.xaml.cs
+54
-0
WSDDBBrowser.csproj
WSDDBBrower/WSDDBBrower/WSDDBBrowser.csproj
+10
-0
No files found.
WSDDBBrower/WSDDBBrower/Core/DBHelper.cs
View file @
98260241
This diff is collapsed.
Click to expand it.
WSDDBBrower/WSDDBBrower/PgSelect.xaml
View file @
98260241
...
...
@@ -51,6 +51,12 @@
<TextBlock Style="{StaticResource TitleStyle}" Text="工序号"/>
<TextBox Style="{StaticResource ValueStyle}" Text="{Binding StepNo}"/>
</StackPanel>
<controls:ToggleSwitch Header="只查找超出标准工艺"
Margin="{StaticResource ControlMargin}"
IsChecked="{Binding IsJustSelectError}"
OffLabel="否"
OnLabel="是"
Style="{StaticResource MahApps.Metro.Styles.ToggleSwitch.Win10}" />
</StackPanel>
<StackPanel Orientation="Horizontal">
...
...
@@ -78,9 +84,10 @@
controls:TextBoxHelper.Watermark="输入订单号查找"
Text="{Binding OrderNoFilter}">
<TextBox.InputBindings>
<KeyBinding Key="Return"
Command="{Binding ButtonSearch, Mode=OneWay}"
CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=TextBox}, Path=Text, Mode=OneWay}" />
<!--<KeyBinding Key="Return"
Command="{Binding SearchCmd}"
CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType=TextBox}, Path=Text, Mode=OneWay}" />-->
<KeyBinding Key="Return" Command="{Binding SearchCmd}"/>
</TextBox.InputBindings>
<TextBox.Style>
<Style BasedOn="{StaticResource SearchMetroTextBox}" TargetType="{x:Type TextBox}">
...
...
@@ -94,7 +101,7 @@
</TextBox.Style>
</TextBox>
</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"
Kind="Magnify" />
</Button>
...
...
@@ -102,7 +109,7 @@
<StackPanel Grid.Column="1" Orientation="Horizontal" Margin="{StaticResource ControlMargin}" HorizontalAlignment="Right">
<Button Style="{StaticResource AccentCircleButtonStyle}" Margin="5,5,5,5" VerticalAlignment="Bottom" C
lick="ButtonOK_Click
">
<Button Style="{StaticResource AccentCircleButtonStyle}" Margin="5,5,5,5" VerticalAlignment="Bottom" C
ommand="{Binding OkCmd}
">
<iconPacks:PackIconFontAwesome Width="40" Height="40"
Kind="CheckCircleSolid" />
</Button>
...
...
@@ -126,6 +133,8 @@
</Style>
</DataGrid.Style>
<DataGrid.Columns>
<DataGridTextColumn Binding="{Binding MachineNo}" Header="机台号"/>
<DataGridTextColumn Binding="{Binding StepNo}" Header="工序号"/>
<DataGridTextColumn Binding="{Binding OrderNo}" Header="订单号"/>
<DataGridTextColumn Binding="{Binding ProjectNo}" Header="项目号"/>
<DataGridTextColumn Binding="{Binding TechnologyNo}" Header="工艺号"/>
...
...
@@ -134,6 +143,14 @@
<DataGridTextColumn Binding="{Binding TotalLen}" Header="检测长度"/>
<DataGridTextColumn Binding="{Binding HasSBData}" 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>
...
...
WSDDBBrower/WSDDBBrower/PgSelect.xaml.cs
View file @
98260241
using
MahApps.Metro.Controls.Dialogs
;
using
GalaSoft.MvvmLight.Command
;
using
MahApps.Metro.Controls.Dialogs
;
using
OfficeOpenXml.FormulaParsing.Excel.Functions.Information
;
using
System
;
using
System.Collections.Generic
;
using
System.Collections.ObjectModel
;
...
...
@@ -34,65 +36,10 @@ namespace WSDDBBrowser
public
void
Init
()
{
viewModel
=
new
PgSelectViewModel
();
viewModel
.
Init
();
this
.
DataContext
=
viewModel
;
}
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
;
}
viewModel
.
Init
(
DBViewerModel
.
Instance
,
DBHelper
.
Instance
,
dgridProcesses
,
NavigationService
);
await
controller
.
CloseAsync
();
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
();
this
.
DataContext
=
viewModel
;
}
private
void
ButtonBack_Click
(
object
sender
,
RoutedEventArgs
e
)
...
...
@@ -114,12 +61,12 @@ namespace WSDDBBrowser
/// <summary>
/// 机台号
/// </summary>
public
int
MachineNo
{
get
;
set
;
}
public
int
?
MachineNo
{
get
;
set
;
}
/// <summary>
/// 工序号
/// </summary>
public
int
StepNo
{
get
;
set
;
}
public
int
?
StepNo
{
get
;
set
;
}
/// <summary>
/// 开始日期
...
...
@@ -134,34 +81,62 @@ namespace WSDDBBrowser
/// </summary>
public
string
OrderNoFilter
{
get
;
set
;
}
/// <summary>
/// 只查找超出标准工艺
/// </summary>
public
bool
IsJustSelectError
{
get
;
set
;
}
/// <summary>
/// 生产列表
/// </summary>
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
()
{
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
);
EndDate
=
DateTime
.
Now
;
StepNo
=
DBViewerModel
.
Instance
.
StepNo
;
MachineNo
=
DBViewerModel
.
Instance
.
MachineNo
;
MachineNo
=
this
.
dbViewerModel
.
MachineNo
;
StepNo
=
this
.
dbViewerModel
.
StepNo
;
DBInit
();
}
void
DBInit
()
{
if
(!
DBHelper
.
Instance
.
Init
(
DBViewerModel
.
Instance
.
ServerIP
,
DBViewerModel
.
Instance
.
ServerUser
,
DBViewerModel
.
Instance
.
ServerPw
))
if
(!
dbHelper
.
Init
(
dbViewerModel
.
ServerIP
,
dbViewerModel
.
ServerUser
,
dbViewerModel
.
ServerPw
))
{
DBInitResult
=
DBHelper
.
Instance
.
ErrorMsg
;
DBInitResult
=
dbHelper
.
ErrorMsg
;
}
else
{
...
...
@@ -170,31 +145,37 @@ namespace WSDDBBrowser
}
private
ICommand
buttonSearch
;
public
ICommand
ButtonSearch
private
async
void
Search
()
{
get
{
return
this
.
buttonSearch
??
(
this
.
buttonSearch
=
new
ClickCommand
(
async
()=>
{
var
list
=
DBHelper
.
Instance
.
GetProcessList
(
StepNo
,
MachineNo
,
BeginDate
,
EndDate
,
OrderNoFilter
);
var
list
=
dbHelper
.
GetProcessList
(
StepNo
,
MachineNo
,
BeginDate
,
EndDate
,
OrderNoFilter
,
IsJustSelectError
);
//var list = dbHelper.GetProcessList_Debug(StepNo, MachineNo, BeginDate, EndDate, OrderNoFilter, IsJustSelectError);
Processes
.
Clear
();
foreach
(
var
p
in
list
)
{
Processes
.
Add
(
p
);
}
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
.
Instance
.
MachineNo
=
MachineNo
;
DBViewerModel
.
Instance
.
Save
();
dbViewerModel
.
StepNo
=
(
int
)
StepNo
;
isChanged
=
true
;
}
if
(
MachineNo
!=
null
)
{
dbViewerModel
.
MachineNo
=
(
int
)
MachineNo
;
isChanged
=
true
;
}
if
(
isChanged
)
dbViewerModel
.
Save
();
}
}
if
(
Processes
.
Count
>
0
)
...
...
@@ -206,8 +187,69 @@ namespace WSDDBBrowser
{
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
);
}
}
...
...
WSDDBBrower/WSDDBBrower/TechInfoDialog.xaml
0 → 100644
View file @
98260241
<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>
WSDDBBrower/WSDDBBrower/TechInfoDialog.xaml.cs
0 → 100644
View file @
98260241
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
();
}
}
}
WSDDBBrower/WSDDBBrower/WSDDBBrowser.csproj
View file @
98260241
...
...
@@ -121,6 +121,9 @@
<Compile
Include=
"PgChartView.xaml.cs"
>
<DependentUpon>
PgChartView.xaml
</DependentUpon>
</Compile>
<Compile
Include=
"TechInfoDialog.xaml.cs"
>
<DependentUpon>
TechInfoDialog.xaml
</DependentUpon>
</Compile>
<Compile
Include=
"Themes\Styles.cs"
/>
<Page
Include=
"Chart\ColumnRangeScanGraph.xaml"
>
<SubType>
Designer
</SubType>
...
...
@@ -182,6 +185,10 @@
<SubType>
Designer
</SubType>
<Generator>
MSBuild:Compile
</Generator>
</Page>
<Page
Include=
"TechInfoDialog.xaml"
>
<SubType>
Designer
</SubType>
<Generator>
MSBuild:Compile
</Generator>
</Page>
<Page
Include=
"Themes\CustomTabControl.xaml"
>
<SubType>
Designer
</SubType>
<Generator>
MSBuild:Compile
</Generator>
...
...
@@ -262,6 +269,9 @@
<PackageReference
Include=
"MahApps.Metro.IconPacks"
>
<Version>
3.0.0-alpha0146
</Version>
</PackageReference>
<PackageReference
Include=
"MvvmLight"
>
<Version>
5.4.1.1
</Version>
</PackageReference>
<PackageReference
Include=
"Newtonsoft.Json"
>
<Version>
12.0.2
</Version>
</PackageReference>
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment