refactor: 将Framework库和RT、UI放在同一个解决方案中。
This commit is contained in:
+95
@@ -0,0 +1,95 @@
|
||||
<UserControl
|
||||
x:Class="MECF.Framework.UI.Client.CenterViews.DataLogs.ProcessHistory.ProcessHistoryInfMessageBoxView"
|
||||
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:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
|
||||
xmlns:local="clr-namespace:MECF.Framework.UI.Client.CenterViews.DataLogs.ProcessHistory"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:micro="clr-namespace:Caliburn.Micro"
|
||||
d:DesignHeight="650"
|
||||
d:DesignWidth="800"
|
||||
mc:Ignorable="d">
|
||||
<Grid Margin="5">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition />
|
||||
<RowDefinition Height="50" />
|
||||
</Grid.RowDefinitions>
|
||||
<DataGrid
|
||||
HorizontalAlignment="Left"
|
||||
AlternationCount="2"
|
||||
AutoGenerateColumns="False"
|
||||
CanUserAddRows="False"
|
||||
FontSize="14"
|
||||
IsReadOnly="True"
|
||||
ItemsSource="{Binding RecipeProcessHistoryDataList}"
|
||||
SelectedItem="{Binding RecipeProcessHistoryData}">
|
||||
<DataGrid.CellStyle>
|
||||
<Style TargetType="DataGridCell">
|
||||
<Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content.Text}" />
|
||||
</Style>
|
||||
</DataGrid.CellStyle>
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="MouseDoubleClick">
|
||||
<micro:ActionMessage MethodName="DoubleClickItem" />
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn
|
||||
Width="160"
|
||||
Binding="{Binding BeginTime}"
|
||||
Header="Start Time" />
|
||||
<DataGridTextColumn
|
||||
Width="80"
|
||||
Binding="{Binding EndTime}"
|
||||
Header="End Time" />
|
||||
<DataGridTextColumn
|
||||
Width="80"
|
||||
Binding="{Binding Status}"
|
||||
Header="Status" />
|
||||
<DataGridTextColumn
|
||||
Width="Auto"
|
||||
Binding="{Binding Name}"
|
||||
Header="Recipe Name" />
|
||||
</DataGrid.Columns>
|
||||
|
||||
</DataGrid>
|
||||
<StackPanel
|
||||
Grid.Row="1"
|
||||
Margin="0,10,0,0"
|
||||
HorizontalAlignment="Center"
|
||||
Orientation="Horizontal">
|
||||
<Button
|
||||
Width="90"
|
||||
Height="30"
|
||||
Content="OK">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="Click">
|
||||
<micro:ActionMessage MethodName="OK" />
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</Button>
|
||||
<Button
|
||||
Width="90"
|
||||
Height="30"
|
||||
Margin="10,0,0,0"
|
||||
Content="Cancel">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="Click">
|
||||
<micro:ActionMessage MethodName="Cancel" />
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</Button>
|
||||
<ComboBox
|
||||
Width="80"
|
||||
Height="30"
|
||||
Margin="20,0"
|
||||
ItemsSource="{Binding StepModelList}"
|
||||
SelectedItem="{Binding StepModel,UpdateSourceTrigger=PropertyChanged}"
|
||||
ToolTip="选择需要显示的Step,All表示:显示全部,*表示:筛选出Step名称中含有*" />
|
||||
|
||||
|
||||
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
</UserControl>
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
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.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace MECF.Framework.UI.Client.CenterViews.DataLogs.ProcessHistory
|
||||
{
|
||||
/// <summary>
|
||||
/// ProcessHistoryInfMessageBoxView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class ProcessHistoryInfMessageBoxView : UserControl
|
||||
{
|
||||
public ProcessHistoryInfMessageBoxView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
+41
@@ -0,0 +1,41 @@
|
||||
using MECF.Framework.Common.Aitex.Core.Common.DeviceData;
|
||||
using OpenSEMI.ClientBase;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MECF.Framework.UI.Client.CenterViews.DataLogs.ProcessHistory
|
||||
{
|
||||
public class ProcessHistoryInfMessageBoxViewModel : DialogViewModel<string>
|
||||
{
|
||||
public List<RecipeProcessHistoryData> RecipeProcessHistoryDataList { get; set; }
|
||||
|
||||
public RecipeProcessHistoryData RecipeProcessHistoryData { get; set; }
|
||||
|
||||
public List<string> StepModelList { get; set; } = new List<string>() { "All", "*" };
|
||||
|
||||
public string StepModel { get; set; } = "All";
|
||||
|
||||
public ProcessHistoryInfMessageBoxViewModel(string startDateTime,string endDateTime,string pm)
|
||||
{
|
||||
RecipeProcessHistoryDataList = ProcessHistorySqlHelp.QueryRecipeProcessHistoryData(startDateTime, endDateTime,pm);
|
||||
Refresh();
|
||||
}
|
||||
|
||||
public void DoubleClickItem()
|
||||
{
|
||||
IsCancel = false;
|
||||
TryClose(true);
|
||||
}
|
||||
|
||||
public void OK()
|
||||
{
|
||||
IsCancel = false;
|
||||
TryClose(true);
|
||||
}
|
||||
|
||||
public void Cancel()
|
||||
{
|
||||
IsCancel = true;
|
||||
TryClose(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
+262
@@ -0,0 +1,262 @@
|
||||
using Aitex.Core.RT.Log;
|
||||
using DocumentFormat.OpenXml.InkML;
|
||||
using MECF.Framework.Common.Aitex.Core.Common.DeviceData;
|
||||
using MECF.Framework.Common.DataCenter;
|
||||
using MECF.Framework.Common.Equipment;
|
||||
using Sicentury.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Data;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace MECF.Framework.UI.Client.CenterViews.DataLogs.ProcessHistory
|
||||
{
|
||||
public class ProcessHistorySqlHelp
|
||||
{
|
||||
public static List<RecipeProcessHistoryData> QueryRecipeProcessHistoryData(string starTime, string endTime, string pm)
|
||||
{
|
||||
string cmd = $"select * from process_data where process_in='{pm}' and process_status='Succeed' and process_begin_time between '{starTime}' and '{endTime}' order by process_begin_time desc";
|
||||
return GetPMCoatingList(cmd);
|
||||
}
|
||||
|
||||
|
||||
//**********************************************时间区间内Recipe运行记录查询*************************************************************
|
||||
private static List<RecipeProcessHistoryData> GetPMCoatingList(string cmd)
|
||||
{
|
||||
List<RecipeProcessHistoryData> recipeProcessHistoryDataList = new List<RecipeProcessHistoryData>();
|
||||
try
|
||||
{
|
||||
var dt = QueryDataClient.Instance.Service.QueryData(cmd);//只能界面用
|
||||
if (dt == null || dt.Rows.Count == 0)
|
||||
return null;
|
||||
|
||||
for (int i = 0; i < dt.Rows.Count; i++)
|
||||
{
|
||||
RecipeProcessHistoryData recipeProcessHistoryData = new RecipeProcessHistoryData()
|
||||
{
|
||||
PmModel = dt.Rows[i]["process_in"].ToString(),
|
||||
XPath = dt.Rows[i]["recipe_name"].ToString(),
|
||||
Status = dt.Rows[i]["process_status"].ToString(),
|
||||
ProcessGuid = dt.Rows[i]["guid"].ToString(),
|
||||
BeginTime = dt.Rows[i]["process_begin_time"].ToString(),
|
||||
EndTime = dt.Rows[i]["process_end_time"].ToString(),
|
||||
WaferDataGuid = dt.Rows[i]["wafer_data_guid"].ToString()
|
||||
};
|
||||
GetWaferInf(recipeProcessHistoryData);
|
||||
recipeProcessHistoryDataList.Add(recipeProcessHistoryData);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return recipeProcessHistoryDataList;
|
||||
}
|
||||
|
||||
private static void GetWaferInf(RecipeProcessHistoryData recipeProcessHistoryData)
|
||||
{
|
||||
string cmd = $"select * from wafer_data where wafer_id='{recipeProcessHistoryData.WaferDataGuid}' ";
|
||||
var dt = QueryDataClient.Instance.Service.QueryData(cmd);
|
||||
if (dt == null || dt.Rows.Count == 0)
|
||||
return;
|
||||
recipeProcessHistoryData.WaferInf = $"{dt.Rows[0]["create_station"]}_{dt.Rows[0]["create_slot"]}";
|
||||
recipeProcessHistoryData.TrayInf = $"{dt.Rows[0]["create_station"]}_{dt.Rows[0]["create_slot"]}";
|
||||
}
|
||||
|
||||
//**********************************************选中Recipe时,查询当时记录的总的步骤流程*************************************************
|
||||
public static ObservableCollection<ProcessHistoryData> QueryProcessHistoryData(string processGuid, string recipeName,string stepModel)
|
||||
{
|
||||
string cmd = $"select * from recipe_step_data where process_data_guid='{processGuid}' order by step_begin_time asc ";
|
||||
return GetProcessHistoryDataList(cmd, recipeName, stepModel);
|
||||
}
|
||||
|
||||
private static ObservableCollection<ProcessHistoryData> GetProcessHistoryDataList(string cmd, string recipeName, string stepModel)
|
||||
{
|
||||
ObservableCollection<ProcessHistoryData> processHistoryDataList = new ObservableCollection<ProcessHistoryData>();
|
||||
try
|
||||
{
|
||||
var dt = QueryDataClient.Instance.Service.QueryData(cmd);
|
||||
if (dt == null || dt.Rows.Count == 0)
|
||||
return null;
|
||||
|
||||
for (int i = 0; i < dt.Rows.Count; i++)
|
||||
{
|
||||
ProcessHistoryData recipeProcessHistoryData = new ProcessHistoryData()
|
||||
{
|
||||
StepBeginTime = dt.Rows[i]["step_begin_time"].ToString(),
|
||||
StepEndTime = dt.Rows[i]["step_end_time"].ToString(),
|
||||
RecipeName = recipeName,
|
||||
StepName = dt.Rows[i]["step_name"].ToString(),
|
||||
StepTime = dt.Rows[i]["step_time"].ToString(),
|
||||
StepNumber = dt.Rows[i]["step_number"].ToString()
|
||||
};
|
||||
|
||||
if (stepModel=="All")//All返回所有,*筛选出步骤名称中带有*
|
||||
processHistoryDataList.Add(recipeProcessHistoryData);
|
||||
else if (stepModel=="*")
|
||||
if (recipeProcessHistoryData.StepName.Contains("*"))
|
||||
processHistoryDataList.Add(recipeProcessHistoryData);
|
||||
}
|
||||
}
|
||||
catch (Exception)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return processHistoryDataList;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
//************************************************单步时硬件数据结果查询*******************************************************************
|
||||
|
||||
/// <summary>
|
||||
/// 拆分的天循查询数据
|
||||
/// </summary>
|
||||
/// <param name="daySlices">拆分的天</param>
|
||||
/// <param name="moduleName">PM名称</param>
|
||||
/// <param name="gasFlowSumList">显示列表对象</param>
|
||||
/// <returns></returns>
|
||||
public static ObservableCollection<ProcessHistoryDeviceData> GetProcessHistoryDeviceData(IEnumerable<DateRangeHelper> daySlices, string moduleName, List<ProcessDeviceItem> processHistoryItemList)
|
||||
{
|
||||
List<DataTable> dataTableList =new List<DataTable>();
|
||||
|
||||
foreach (var daySlice in daySlices)//拆分天
|
||||
{
|
||||
var dt = GetProcessHistoryDeviceDataListDaySlices(daySlice, moduleName, processHistoryItemList);
|
||||
if (dt != null)
|
||||
dataTableList.Add(dt);//拆分后,每次查询结果放入集合中
|
||||
}
|
||||
|
||||
|
||||
ObservableCollection<ProcessHistoryDeviceData> processHistoryDeviceDataList = new ObservableCollection<ProcessHistoryDeviceData>();
|
||||
|
||||
foreach (var item in processHistoryItemList)
|
||||
{
|
||||
var phd = new ProcessHistoryDeviceData();
|
||||
phd.DeviceName = item.Display;
|
||||
phd.DATASubscribeName = item.Property;
|
||||
phd.Unit = item.Unit;
|
||||
phd.IsPropertyExists = item.IsPropertyExists;
|
||||
foreach (DataTable ds in dataTableList)
|
||||
{
|
||||
for (int i = 0; i < ds.Rows.Count; i++)
|
||||
{
|
||||
if (!item.IsPropertyExists)
|
||||
continue;
|
||||
string value = ds.Rows[i][$"{moduleName}.{item.Property}"].ToString();
|
||||
if (value is not null && value.Length == 0)
|
||||
continue;
|
||||
float cache;
|
||||
if (float.TryParse(value, out cache))//防止非数据类型混入进来
|
||||
{
|
||||
phd.DeviceValue.Add(cache);//历史数据点
|
||||
phd.TimeStamp.Add(ds.Rows[i]["time"].ToString());//时间戳
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (phd.IsPropertyExists)
|
||||
{
|
||||
phd.CalculateData();
|
||||
processHistoryDeviceDataList.Add(phd);
|
||||
}
|
||||
|
||||
}
|
||||
return processHistoryDeviceDataList;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据拆分的天循查询数据
|
||||
/// </summary>
|
||||
/// <param name="daySlices">拆分的天</param>
|
||||
/// <param name="moduleName">PM名称</param>
|
||||
/// <param name="gasFlowSumList">显示集合列表</param>
|
||||
/// <returns></returns>
|
||||
private static DataTable GetProcessHistoryDeviceDataListDaySlices(DateRangeHelper daySlices, string moduleName, List<ProcessDeviceItem> processHistoryItemList)
|
||||
{
|
||||
DataTable dataTable = null;
|
||||
var ts = daySlices.Diff;
|
||||
for (var day = 0; day <= ts.Days; day++)
|
||||
{
|
||||
var tblName = $"{daySlices.Start.AddDays(day):yyyyMMdd}.{moduleName}";
|
||||
var sql = new StringBuilder();
|
||||
// 检查表名是否存在,否则SQL执行出错。
|
||||
if (CheckTableExists(tblName))
|
||||
{
|
||||
sql.Append("select time AS InternalTimeStamp");
|
||||
|
||||
// 添加待查询的列
|
||||
foreach (var item in processHistoryItemList)
|
||||
{
|
||||
// 检查表中是否存在对应属性,否则SQL执行出错。
|
||||
if (CheckPropertyExists(tblName, $"{moduleName}.{item.Property}"))
|
||||
{
|
||||
item.IsPropertyExists = true;
|
||||
sql.Append("," + $"\"{moduleName}.{item.Property}\"");
|
||||
}
|
||||
else//不查询状态标记
|
||||
item.IsPropertyExists = false;
|
||||
|
||||
}
|
||||
|
||||
sql.Append($", \"time\"");
|
||||
sql.Append($" from \"{tblName}\"");
|
||||
|
||||
if (day < ts.Days)
|
||||
sql.Append(" UNION ");
|
||||
sql.Append(
|
||||
$" where time between {daySlices.Start.Ticks} and {daySlices.End.Ticks} order by InternalTimeStamp asc");
|
||||
try
|
||||
{
|
||||
var _dataTable = QueryDataClient.Instance.Service.QueryData(sql.ToString());
|
||||
if (_dataTable is not null && _dataTable.Rows.Count > 0)
|
||||
dataTable = _dataTable;
|
||||
}
|
||||
catch (Exception ex)//查询较早日期时,可能不存在属性会报错
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dataTable;
|
||||
}
|
||||
|
||||
private static bool CheckTableExists(string tableName)
|
||||
{
|
||||
var sql =
|
||||
$"SELECT EXISTS ( SELECT FROM pg_tables WHERE schemaname = 'public' AND tablename = '{tableName}' )";
|
||||
var table = QueryDataClient.Instance.Service.QueryData(sql);
|
||||
if (table == null)
|
||||
return false;
|
||||
|
||||
if (table.Rows.Count <= 0)
|
||||
return false;
|
||||
|
||||
var value = table.Rows[0]["exists"].ToString();
|
||||
if (value.ToLower() == "true")
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private static bool CheckPropertyExists(string tableName, string property)
|
||||
{
|
||||
var sql =
|
||||
$"select count(1) from information_schema.columns WHERE table_name = '{tableName}' and column_name = '{property}'";
|
||||
var table = QueryDataClient.Instance.Service.QueryData(sql);
|
||||
if (table == null)
|
||||
return false;
|
||||
|
||||
if (table.Rows.Count <= 0)
|
||||
return false;
|
||||
|
||||
var value =int.Parse(table.Rows[0]["count"].ToString());
|
||||
if (value == 0)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
+321
@@ -0,0 +1,321 @@
|
||||
<UserControl
|
||||
x:Class="MECF.Framework.UI.Client.CenterViews.DataLogs.ProcessHistory.ProcessHistoryTestView"
|
||||
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:cv="clr-namespace:MECF.Framework.UI.Core.Converters;assembly=MECF.Framework.UI.Core"
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:forms="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
|
||||
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
|
||||
xmlns:local="clr-namespace:MECF.Framework.UI.Client.CenterViews.DataLogs.ProcessHistory"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
xmlns:micro="clr-namespace:Caliburn.Micro"
|
||||
xmlns:userControls="clr-namespace:MECF.Framework.UI.Client.CenterViews.Core.UserControls"
|
||||
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
|
||||
xmlns:lex="http://wpflocalizeextension.codeplex.com"
|
||||
d:DesignHeight="800"
|
||||
d:DesignWidth="1900"
|
||||
FontSize="14"
|
||||
mc:Ignorable="d"
|
||||
lex:LocalizeDictionary.DesignCulture="en"
|
||||
lex:ResxLocalizationProvider.DefaultAssembly="Sicentury.Localization"
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_common">
|
||||
|
||||
<UserControl.Resources>
|
||||
<cv:BoolVisibilityConverter x:Key="BoolVisibilityConverter" />
|
||||
</UserControl.Resources>
|
||||
|
||||
<Grid Margin="10">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="50" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="610" />
|
||||
<ColumnDefinition />
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<Border
|
||||
Grid.ColumnSpan="2"
|
||||
Margin="0,6"
|
||||
Padding="1"
|
||||
HorizontalAlignment="Stretch"
|
||||
Background="{StaticResource Tab_BG}"
|
||||
BorderBrush="{StaticResource Tab_BD}"
|
||||
BorderThickness="1,1,1,1">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<StackPanel.Resources>
|
||||
<Style TargetType="xctk:DateTimeUpDown">
|
||||
<Setter Property="Width" Value="180" />
|
||||
<Setter Property="Format" Value="Custom" />
|
||||
<Setter Property="FormatString" Value="yyyy/MM/dd HH:mm:ss" />
|
||||
</Style>
|
||||
</StackPanel.Resources>
|
||||
<StackPanel Margin="15,0" Orientation="Horizontal">
|
||||
<TextBlock
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="Arial"
|
||||
FontSize="14"
|
||||
Text="{lex:Loc ID_TXT_StartTime}" />
|
||||
<WindowsFormsHost
|
||||
Width="170"
|
||||
Height="25"
|
||||
Margin="5,0,15,0"
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="Arial"
|
||||
FontSize="14">
|
||||
<forms:DateTimePicker
|
||||
x:Name="wfTimeFrom"
|
||||
CustomFormat="yyyy/MM/dd HH:mm:ss"
|
||||
Format="Custom"
|
||||
Value="2011-8-1" />
|
||||
</WindowsFormsHost>
|
||||
<TextBlock
|
||||
Margin="0"
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="Arial"
|
||||
FontSize="14"
|
||||
Text="{lex:Loc ID_TXT_EndTime}" />
|
||||
<WindowsFormsHost
|
||||
Width="170"
|
||||
Height="25"
|
||||
Margin="5,0,0,0"
|
||||
VerticalAlignment="Center"
|
||||
FontFamily="Arial"
|
||||
FontSize="14">
|
||||
<forms:DateTimePicker
|
||||
x:Name="wfTimeTo"
|
||||
CustomFormat="yyyy/MM/dd HH:mm:ss"
|
||||
Format="Custom"
|
||||
Value="2011-8-1" />
|
||||
</WindowsFormsHost>
|
||||
<ComboBox
|
||||
Width="80"
|
||||
Height="30"
|
||||
Margin="20,0"
|
||||
ItemsSource="{Binding PmList}"
|
||||
SelectedItem="{Binding CbSelectPM}" />
|
||||
<Button
|
||||
Width="85"
|
||||
Height="30"
|
||||
HorizontalAlignment="Right"
|
||||
Content="{lex:Loc ID_BTN_Query_Content}">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="Click">
|
||||
<micro:ActionMessage MethodName="QueryRecipeProcessHistory" />
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</Button>
|
||||
<Button
|
||||
Width="85"
|
||||
Height="30"
|
||||
Margin="15,0"
|
||||
HorizontalAlignment="Right"
|
||||
Content="{Binding ExportTXt}"
|
||||
IsEnabled="{Binding IsExportNotBusy}">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="Click">
|
||||
<micro:ActionMessage MethodName="ExportRecipeProcessHistory" />
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</Button>
|
||||
<Button
|
||||
Width="100"
|
||||
Height="30"
|
||||
Margin="0,0,15,0"
|
||||
HorizontalAlignment="Right"
|
||||
Content="HandExport">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="Click">
|
||||
<micro:ActionMessage MethodName="HandExport" />
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</Button>
|
||||
<Button
|
||||
Width="100"
|
||||
Height="30"
|
||||
Margin="0,0,15,0"
|
||||
HorizontalAlignment="Right"
|
||||
Content="AutoExport">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="Click">
|
||||
<micro:ActionMessage MethodName="AutoExport" />
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</Button>
|
||||
<Label Margin="3,0" VerticalAlignment="Center">Select Recipe Name</Label>
|
||||
<Label
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_datalogviews"
|
||||
Margin="3,0" VerticalAlignment="Center" Content="{lex:Loc ID_TXT_SelectRecipeName}"/>
|
||||
<Label
|
||||
Margin="3,0"
|
||||
VerticalAlignment="Center"
|
||||
Content="{Binding RecipeProcessHistoryData.Name}"
|
||||
FontWeight="Black" />
|
||||
<Label
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_datalogviews"
|
||||
Margin="3,0" VerticalAlignment="Center" Content="{lex:Loc ID_TXT_SelectStepName}"/>
|
||||
<Label
|
||||
Margin="3,0"
|
||||
VerticalAlignment="Center"
|
||||
Content="{Binding SelectProcessHistoryData.StepName}"
|
||||
FontWeight="Black" />
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Border>
|
||||
|
||||
|
||||
|
||||
<Grid Grid.Row="1">
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto" />
|
||||
<RowDefinition />
|
||||
</Grid.RowDefinitions>
|
||||
|
||||
<DataGrid
|
||||
MaxHeight="350"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Top"
|
||||
AlternationCount="2"
|
||||
AutoGenerateColumns="False"
|
||||
CanUserAddRows="False"
|
||||
FontSize="14"
|
||||
IsReadOnly="True"
|
||||
Visibility="{Binding SelectRecipeIsNull, Converter={StaticResource BoolVisibilityConverter}}"
|
||||
ItemsSource="{Binding ProcessHistoryDataList}"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Visible"
|
||||
SelectedItem="{Binding SelectProcessHistoryData}">
|
||||
<DataGrid.CellStyle>
|
||||
<Style TargetType="DataGridCell">
|
||||
<Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content.Text}" />
|
||||
</Style>
|
||||
</DataGrid.CellStyle>
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="MouseDoubleClick">
|
||||
<micro:ActionMessage MethodName="GetProcessHistory" />
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
|
||||
<DataGrid.Columns>
|
||||
<DataGridTemplateColumn Width="60">
|
||||
<DataGridTemplateColumn.Header>
|
||||
<StackPanel Orientation="Horizontal">
|
||||
<CheckBox
|
||||
x:Name="cb_Select"
|
||||
VerticalContentAlignment="Center"
|
||||
Content="Exp">
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="Click">
|
||||
<micro:ActionMessage MethodName="SetExportAll">
|
||||
<micro:Parameter Value="{Binding Path=IsChecked, RelativeSource={RelativeSource AncestorType={x:Type CheckBox}}}" />
|
||||
</micro:ActionMessage>
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
</CheckBox>
|
||||
<!--<TextBlock Margin="3">全选</TextBlock>-->
|
||||
</StackPanel>
|
||||
</DataGridTemplateColumn.Header>
|
||||
<DataGridTemplateColumn.CellTemplate>
|
||||
<DataTemplate>
|
||||
<CheckBox
|
||||
Margin="10,0"
|
||||
VerticalContentAlignment="Center"
|
||||
IsChecked="{Binding IsExport, UpdateSourceTrigger=PropertyChanged}" />
|
||||
</DataTemplate>
|
||||
</DataGridTemplateColumn.CellTemplate>
|
||||
</DataGridTemplateColumn>
|
||||
<DataGridTextColumn
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_datalogviews"
|
||||
Width="155"
|
||||
Binding="{Binding StepBeginTime}"
|
||||
Header="{lex:Loc ID_TXT_StepStartTime}" />
|
||||
<DataGridTextColumn
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
|
||||
Width="90"
|
||||
Binding="{Binding StepEndTimeDisp}"
|
||||
Header="{lex:Loc ID_TXT_EndTime}" />
|
||||
<DataGridTextColumn
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_datalogviews"
|
||||
Width="80"
|
||||
Binding="{Binding StepTime}"
|
||||
Header="{lex:Loc ID_TXT_StepTime}" />
|
||||
<DataGridTextColumn
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_datalogviews"
|
||||
Width="80"
|
||||
Binding="{Binding StepNumber}"
|
||||
Header="{lex:Loc ID_TXT_StepNum}" />
|
||||
<DataGridTextColumn
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_datalogviews"
|
||||
Width="116"
|
||||
Binding="{Binding StepName}"
|
||||
Header="{lex:Loc ID_TXT_StepName}" />
|
||||
</DataGrid.Columns>
|
||||
|
||||
</DataGrid>
|
||||
|
||||
<DataGrid
|
||||
Grid.Row="1"
|
||||
Margin="0,8,0,0"
|
||||
HorizontalAlignment="Left"
|
||||
VerticalAlignment="Top"
|
||||
AlternationCount="2"
|
||||
AutoGenerateColumns="False"
|
||||
CanUserAddRows="False"
|
||||
FontSize="14"
|
||||
IsReadOnly="True"
|
||||
Visibility="{Binding SelectRecipeIsNull, Converter={StaticResource BoolVisibilityConverter}}"
|
||||
ItemsSource="{Binding StepDeviceDataList}"
|
||||
ScrollViewer.VerticalScrollBarVisibility="Visible"
|
||||
SelectedItem="{Binding StepSelectDeviceData}">
|
||||
<DataGrid.CellStyle>
|
||||
<Style TargetType="DataGridCell">
|
||||
<Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Mode=Self}, Path=Content.Text}" />
|
||||
</Style>
|
||||
</DataGrid.CellStyle>
|
||||
<i:Interaction.Triggers>
|
||||
<i:EventTrigger EventName="MouseDoubleClick">
|
||||
<micro:ActionMessage MethodName="DeviceCharting" />
|
||||
</i:EventTrigger>
|
||||
</i:Interaction.Triggers>
|
||||
<DataGrid.Columns>
|
||||
<DataGridTextColumn
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_datalogviews"
|
||||
Width="170"
|
||||
Binding="{Binding DeviceName}"
|
||||
Header="{lex:Loc ID_TXT_DeviceName}" />
|
||||
<DataGridTextColumn
|
||||
Width="80"
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_datalogviews"
|
||||
Binding="{Binding Unit}"
|
||||
Header="{lex:Loc ID_TXT_Unit}" />
|
||||
<DataGridTextColumn
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_datalogviews"
|
||||
Width="110"
|
||||
Binding="{Binding Min, StringFormat=F1}"
|
||||
Header="{lex:Loc ID_TXT_Min}" />
|
||||
<DataGridTextColumn
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_datalogviews"
|
||||
Width="110"
|
||||
Binding="{Binding Max, StringFormat=F1}"
|
||||
Header="{lex:Loc ID_TXT_Max}" />
|
||||
<DataGridTextColumn
|
||||
lex:ResxLocalizationProvider.DefaultDictionary="lang_datalogviews"
|
||||
Width="110"
|
||||
Binding="{Binding Average, StringFormat=F1}"
|
||||
Header="{lex:Loc ID_TXT_Average}" />
|
||||
</DataGrid.Columns>
|
||||
|
||||
</DataGrid>
|
||||
</Grid>
|
||||
<userControls:DataViewChart
|
||||
x:Name="chart"
|
||||
Grid.Row="1"
|
||||
Grid.Column="2"
|
||||
Margin="3,0"
|
||||
Visibility="{Binding SelectRecipeIsNull, Converter={StaticResource BoolVisibilityConverter}}"
|
||||
AutoRange="{Binding ChartAutoRange}"
|
||||
RenderableSeries="{Binding AppendedSeries}"
|
||||
VisibleRangeTime="{Binding VisibleRangeTime}"
|
||||
VisibleRangeValue="{Binding VisibleRangeValue}" />
|
||||
</Grid>
|
||||
</UserControl>
|
||||
+28
@@ -0,0 +1,28 @@
|
||||
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.Navigation;
|
||||
using System.Windows.Shapes;
|
||||
|
||||
namespace MECF.Framework.UI.Client.CenterViews.DataLogs.ProcessHistory
|
||||
{
|
||||
/// <summary>
|
||||
/// ProcessHistoryTestView.xaml 的交互逻辑
|
||||
/// </summary>
|
||||
public partial class ProcessHistoryTestView : UserControl
|
||||
{
|
||||
public ProcessHistoryTestView()
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
}
|
||||
}
|
||||
+599
@@ -0,0 +1,599 @@
|
||||
using Aitex.Common.Util;
|
||||
using Aitex.Core.RT.DataCenter;
|
||||
using Aitex.Core.RT.SCCore;
|
||||
using Aitex.Core.Util;
|
||||
using Caliburn.Micro;
|
||||
using DocumentFormat.OpenXml.Bibliography;
|
||||
using DocumentFormat.OpenXml.Drawing.Charts;
|
||||
using DocumentFormat.OpenXml.InkML;
|
||||
using DocumentFormat.OpenXml.Office2016.Drawing.ChartDrawing;
|
||||
using DocumentFormat.OpenXml.Spreadsheet;
|
||||
using MECF.Framework.Common.Aitex.Core.Common.DeviceData;
|
||||
using MECF.Framework.Common.DataCenter;
|
||||
using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.PMs;
|
||||
using MECF.Framework.UI.Client.CenterViews.Core;
|
||||
using MECF.Framework.UI.Client.ClientBase;
|
||||
using Microsoft.VisualBasic;
|
||||
using OfficeOpenXml;
|
||||
using OfficeOpenXml.FormulaParsing.Excel.Functions.Math;
|
||||
using OfficeOpenXml.FormulaParsing.Excel.Functions.RefAndLookup;
|
||||
using OfficeOpenXml.Style;
|
||||
using SciChart.Charting.Model.DataSeries;
|
||||
using SciChart.Charting.Visuals.Axes;
|
||||
using SciChart.Charting.Visuals.RenderableSeries;
|
||||
using SciChart.Data.Model;
|
||||
using Sicentury.Core;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Diagnostics;
|
||||
using System.Dynamic;
|
||||
using System.IO;
|
||||
using System.IO.Packaging;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Windows;
|
||||
using System.Windows.Controls;
|
||||
|
||||
namespace MECF.Framework.UI.Client.CenterViews.DataLogs.ProcessHistory
|
||||
{
|
||||
public class ProcessHistoryTestViewModel : UiViewModelBase
|
||||
{
|
||||
#region Variables
|
||||
|
||||
private IRange _timeRange;
|
||||
private IRange _visibleRangeValue;
|
||||
private AutoRange _autoRange;
|
||||
private List<ProcessDeviceItem> PMItemList { get; set; }
|
||||
|
||||
private string _path = PathManager.GetAppDir() + "\\Export";
|
||||
|
||||
/// <summary>
|
||||
/// 返回ViewModel绑定的视图对象。
|
||||
/// </summary>
|
||||
public UserControl View { get; private set; }
|
||||
|
||||
public DateTime StartDateTime
|
||||
{
|
||||
get => ((ProcessHistoryTestView)View).wfTimeFrom.Value;
|
||||
set
|
||||
{
|
||||
((ProcessHistoryTestView)View).wfTimeFrom.Value = value;
|
||||
NotifyOfPropertyChange(nameof(StartDateTime));
|
||||
}
|
||||
}
|
||||
|
||||
public DateTime EndDateTime
|
||||
{
|
||||
get => ((ProcessHistoryTestView)View).wfTimeTo.Value;
|
||||
set
|
||||
{
|
||||
((ProcessHistoryTestView)View).wfTimeTo.Value = value;
|
||||
NotifyOfPropertyChange(nameof(EndDateTime));
|
||||
}
|
||||
}
|
||||
|
||||
public List<string> PmList { get; set; }
|
||||
|
||||
private string cbSelectPM;
|
||||
|
||||
public string CbSelectPM
|
||||
{
|
||||
get => cbSelectPM;
|
||||
set
|
||||
{
|
||||
cbSelectPM = value;
|
||||
PMItemList = (List<ProcessDeviceItem>)QueryDataClient.Instance.Service.GetData($"{cbSelectPM}.ProcessHistoryItemsDefault");//选择的PM变化时,重新加载模板
|
||||
}
|
||||
}
|
||||
|
||||
private string _exportText;
|
||||
|
||||
public string ExportText
|
||||
{
|
||||
get => _exportText;
|
||||
set
|
||||
{
|
||||
if (ProcessHistoryDataList == null)
|
||||
{
|
||||
_exportText = "Export";
|
||||
}
|
||||
else
|
||||
{
|
||||
int count = ProcessHistoryDataList.Count(item => item.IsExport);
|
||||
_exportText = $"Export{count}";
|
||||
}
|
||||
NotifyOfPropertyChange(nameof(ExportText));
|
||||
}
|
||||
}
|
||||
|
||||
private bool _selectRecipeIsNull;
|
||||
|
||||
public bool SelectRecipeIsNull
|
||||
{
|
||||
get => _selectRecipeIsNull;
|
||||
set
|
||||
{
|
||||
_selectRecipeIsNull = value;
|
||||
NotifyOfPropertyChange(nameof(SelectRecipeIsNull));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 选择的Recipe
|
||||
/// </summary>
|
||||
public RecipeProcessHistoryData RecipeProcessHistoryData { get; set; }
|
||||
|
||||
private ObservableCollection<ProcessHistoryData> processHistoryDataList;
|
||||
|
||||
/// <summary>
|
||||
/// 单个Recipe对应的Step数据集合
|
||||
/// </summary>
|
||||
public ObservableCollection<ProcessHistoryData> ProcessHistoryDataList
|
||||
{
|
||||
get => processHistoryDataList;
|
||||
set
|
||||
{
|
||||
processHistoryDataList = value;
|
||||
NotifyOfPropertyChange(nameof(ProcessHistoryDataList));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 选中Step
|
||||
/// </summary>
|
||||
public ProcessHistoryData SelectProcessHistoryData { get; set; }
|
||||
|
||||
private ObservableCollection<ProcessHistoryDeviceData> stepDeviceDataList;
|
||||
|
||||
/// <summary>
|
||||
/// Step单步时对应的硬件数据集合
|
||||
/// </summary>
|
||||
public ObservableCollection<ProcessHistoryDeviceData> StepDeviceDataList
|
||||
{
|
||||
get => stepDeviceDataList;
|
||||
set
|
||||
{
|
||||
stepDeviceDataList = value;
|
||||
NotifyOfPropertyChange(nameof(StepDeviceDataList));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Step中选中硬件的数据
|
||||
/// </summary>
|
||||
public ProcessHistoryDeviceData StepSelectDeviceData { get; set; }
|
||||
|
||||
private ObservableCollection<IRenderableSeries> appendedSeries;
|
||||
|
||||
public ObservableCollection<IRenderableSeries> AppendedSeries
|
||||
{
|
||||
get => appendedSeries;
|
||||
set
|
||||
{
|
||||
appendedSeries = value;
|
||||
NotifyOfPropertyChange(nameof(AppendedSeries));
|
||||
}
|
||||
}
|
||||
|
||||
public IRange VisibleRangeTime
|
||||
{
|
||||
get => _timeRange;
|
||||
set
|
||||
{
|
||||
_timeRange = value;
|
||||
NotifyOfPropertyChange(nameof(VisibleRangeTime));
|
||||
}
|
||||
}
|
||||
|
||||
public IRange VisibleRangeValue
|
||||
{
|
||||
get => _visibleRangeValue;
|
||||
set
|
||||
{
|
||||
_visibleRangeValue = value;
|
||||
NotifyOfPropertyChange(nameof(VisibleRangeValue));
|
||||
}
|
||||
}
|
||||
|
||||
public AutoRange ChartAutoRange
|
||||
{
|
||||
get => _autoRange;
|
||||
set
|
||||
{
|
||||
_autoRange = value;
|
||||
NotifyOfPropertyChange(nameof(ChartAutoRange));
|
||||
}
|
||||
}
|
||||
|
||||
private bool _isExportNotBusy = true;
|
||||
|
||||
public bool IsExportNotBusy
|
||||
{
|
||||
get => _isExportNotBusy;
|
||||
set
|
||||
{
|
||||
_isExportNotBusy = value;
|
||||
NotifyOfPropertyChange();
|
||||
}
|
||||
}
|
||||
|
||||
private string _exportTXt = "Export";
|
||||
|
||||
public string ExportTXt
|
||||
{
|
||||
get => _exportTXt;
|
||||
set
|
||||
{
|
||||
_exportTXt = value;
|
||||
NotifyOfPropertyChange();
|
||||
}
|
||||
}
|
||||
|
||||
#endregion Variables
|
||||
|
||||
protected override void OnViewLoaded(object _view)
|
||||
{
|
||||
base.OnViewLoaded(_view);
|
||||
View = (ProcessHistoryTestView)_view;
|
||||
IniUIData();
|
||||
}
|
||||
|
||||
private void IniUIData()
|
||||
{
|
||||
PmList = new List<string>();
|
||||
for (int i = 1; i <= 2; i++)
|
||||
{
|
||||
if ((bool)QueryDataClient.Instance.Service.GetConfig($"System.SetUp.IsPM{i}Installed"))
|
||||
PmList.Add($"PM{i}");
|
||||
}
|
||||
if (PmList.Count > 0)
|
||||
CbSelectPM = PmList[0];
|
||||
StartDateTime = DateTime.Now.Date;
|
||||
EndDateTime = DateTime.Now.Date.AddDays(1).AddTicks(-1);
|
||||
|
||||
VisibleRangeTime = new DateRange(DateTime.Now.AddMinutes(-60), DateTime.Now.AddMinutes(60));
|
||||
VisibleRangeValue = new DoubleRange(0, 10);
|
||||
|
||||
Refresh();
|
||||
}
|
||||
|
||||
protected override void OnDeactivate(bool close)
|
||||
{
|
||||
ActiveUpdateData = true;
|
||||
base.OnDeactivate(close);
|
||||
}
|
||||
|
||||
protected override void OnActivate()
|
||||
{
|
||||
base.OnActivate();
|
||||
|
||||
EnableTimer(true);
|
||||
}
|
||||
|
||||
public void SetExportAll(bool b)
|
||||
{
|
||||
if (ProcessHistoryDataList == null)
|
||||
return;
|
||||
|
||||
foreach (var item in ProcessHistoryDataList)
|
||||
item.IsExport = b;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据选择的Recipe导出数据
|
||||
/// </summary>
|
||||
public void ExportRecipeProcessHistory()
|
||||
{
|
||||
if (ProcessHistoryDataList == null)
|
||||
{
|
||||
MessageBox.Show("没有选择的Recipe", "警告", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
SetBtn(false);
|
||||
MessageBoxResult result = MessageBox.Show("你确定要导出数据吗?", "提示", MessageBoxButton.YesNo, MessageBoxImage.Question);
|
||||
|
||||
Task.Run(() =>
|
||||
{
|
||||
if (result == MessageBoxResult.Yes)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<ObservableCollection<ProcessHistoryDeviceData>> exportRecipeProcessHistoryData = new();
|
||||
|
||||
for (int i = 0; i < ProcessHistoryDataList.Count; i++)
|
||||
{
|
||||
if (ProcessHistoryDataList[i].IsExport)
|
||||
{
|
||||
var qeph = QueryExportProcessHistory(ProcessHistoryDataList[i]);
|
||||
if (qeph == null)
|
||||
continue;
|
||||
foreach (var data in qeph)
|
||||
{
|
||||
data.StepNumber = ProcessHistoryDataList[i].StepNumber;
|
||||
data.StepName = ProcessHistoryDataList[i].StepName;
|
||||
}
|
||||
|
||||
exportRecipeProcessHistoryData.Add(qeph);
|
||||
}
|
||||
}
|
||||
|
||||
if (exportRecipeProcessHistoryData.Count > 0)
|
||||
{
|
||||
SaveCsv(exportRecipeProcessHistoryData);
|
||||
//SaveExcel(exportRecipeProcessHistoryData);
|
||||
MessageBox.Show("数据导出完成", "成功", MessageBoxButton.OK, MessageBoxImage.Information);
|
||||
}
|
||||
else
|
||||
MessageBox.Show("未选择导出的Step", "警告", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
MessageBox.Show(e.ToString(), "警告", MessageBoxButton.OK, MessageBoxImage.Warning);
|
||||
}
|
||||
}
|
||||
SetBtn(true);
|
||||
});
|
||||
}
|
||||
|
||||
private void SetBtn(bool b)
|
||||
{
|
||||
ExportTXt = b ? "Export" : "AwaitExport";
|
||||
IsExportNotBusy = b;
|
||||
}
|
||||
|
||||
private void SaveCsv(List<ObservableCollection<ProcessHistoryDeviceData>> phdd)
|
||||
{
|
||||
StringBuilder csvContent = new StringBuilder();
|
||||
|
||||
csvContent.Append("Date,Time,Wafer,Step,StepName,");
|
||||
for (int i = 0; i < phdd[0].Count; i++)
|
||||
{
|
||||
// 设置单元格的值为表头名
|
||||
csvContent.Append($"{phdd[0][i].DeviceName}[{phdd[0][i].Unit}],");
|
||||
}
|
||||
|
||||
csvContent.AppendLine(); // 换行
|
||||
|
||||
foreach (var processDataList in phdd)//所有Step循环
|
||||
{
|
||||
var stepDeviceData = processDataList
|
||||
.Where(item => item.DeviceValue != null && item.DeviceValue.Count > 0)
|
||||
.Select(item => item)
|
||||
.FirstOrDefault(); // 如果没有找到,返回0
|
||||
|
||||
if (stepDeviceData == null)
|
||||
continue;
|
||||
|
||||
// 遍历数组并写入 CSV 文件
|
||||
for (int i = 0; i < stepDeviceData.DeviceValue.Count; i++)
|
||||
{
|
||||
var dateTime = new DateTime(long.Parse(stepDeviceData.TimeStamp[i]));
|
||||
csvContent.Append(dateTime.ToString("yyyy-MM-dd") + ",");
|
||||
csvContent.Append(dateTime.ToString("HH:mm:ss") + ",");
|
||||
csvContent.Append(RecipeProcessHistoryData.WaferInf + ",");
|
||||
csvContent.Append(processDataList[0].StepNumber + ",");
|
||||
csvContent.Append(processDataList[0].StepName + ",");
|
||||
|
||||
for (int j = 0; j < processDataList.Count; j++)
|
||||
{
|
||||
if (i < processDataList[j].DeviceValue.Count)
|
||||
|
||||
csvContent.Append(processDataList[j].DeviceValue[i].ToString("F3") + ",");
|
||||
else
|
||||
csvContent.Append("0,");
|
||||
}
|
||||
csvContent.AppendLine(); // 换行
|
||||
}
|
||||
}
|
||||
|
||||
// 保存Excel文件
|
||||
|
||||
if (!Directory.Exists(_path))
|
||||
Directory.CreateDirectory(_path);
|
||||
|
||||
var filePath = $"{_path}\\{DateTime.Now:yyyy-MM-dd HH-mm-ss} - {RecipeProcessHistoryData.Name}.csv";
|
||||
|
||||
File.WriteAllText(filePath, csvContent.ToString());
|
||||
}
|
||||
|
||||
private void SaveExcel(List<ObservableCollection<ProcessHistoryDeviceData>> phdd)
|
||||
{
|
||||
// 创建一个新的ExcelPackage实例
|
||||
using (ExcelPackage excelPackage = new ExcelPackage())
|
||||
{
|
||||
// 添加一个工作表
|
||||
ExcelWorksheet worksheet = excelPackage.Workbook.Worksheets.Add(RecipeProcessHistoryData.Name);
|
||||
|
||||
// 将数据写入Excel工作表
|
||||
worksheet.Cells[1, 1].Value = "Date";
|
||||
worksheet.Cells[1, 2].Value = "Time";
|
||||
worksheet.Cells[1, 3].Value = "Wafer";
|
||||
//worksheet.Cells[1, 4].Value = "Tray";
|
||||
worksheet.Cells[1, 4].Value = "Step";
|
||||
worksheet.Cells[1, 5].Value = "StepName";
|
||||
|
||||
for (int i = 0; i < phdd[0].Count; i++)
|
||||
{
|
||||
// 设置单元格的值为表头名
|
||||
worksheet.Cells[1, i + 6].Value = $"{phdd[0][i].DeviceName}[{phdd[0][i].Unit}]";
|
||||
}
|
||||
|
||||
int k = 1;//拼接Step换行用
|
||||
foreach (var processDataList in phdd)//所有Step循环
|
||||
{
|
||||
for (int i = 0; i < processDataList.Count; i++)//单步Step循环
|
||||
{
|
||||
for (int j = 0; j < processDataList[i].DeviceValue.Count; j++)//当前Step,一个硬件产生的所有数据循环
|
||||
{
|
||||
if (i == 0)//i==0意味着数据属于同一个Step
|
||||
{
|
||||
//单步数据的共同数据,采集时间、Step序号和Step名称
|
||||
var dateTime = new DateTime(long.Parse(processDataList[i].TimeStamp[j]));
|
||||
worksheet.Cells[k + j + 1, 1].Value = dateTime.ToString("yyyy-MM-dd");
|
||||
worksheet.Cells[k + j + 1, 2].Value = dateTime.ToString("HH:mm:ss");
|
||||
worksheet.Cells[k + j + 1, 3].Value = RecipeProcessHistoryData.WaferInf;
|
||||
worksheet.Cells[k + j + 1, 4].Value = processDataList[i].StepNumber;
|
||||
worksheet.Cells[k + j + 1, 5].Value = processDataList[i].StepName;
|
||||
}
|
||||
|
||||
//获取数据值
|
||||
worksheet.Cells[k + j + 1, i + 6].Value = processDataList[i].DeviceValue[j];
|
||||
worksheet.Cells[k + j + 1, i + 6].Style.Numberformat.Format = "0.000";
|
||||
}
|
||||
}
|
||||
|
||||
k += processDataList[0].DeviceValue.Count;
|
||||
}
|
||||
|
||||
// 保存Excel文件
|
||||
|
||||
if (!Directory.Exists(_path))
|
||||
Directory.CreateDirectory(_path);
|
||||
|
||||
string xlsxFilePath = $"{_path}\\{DateTime.Now:yyyy-MM-dd HH-mm-ss} - {RecipeProcessHistoryData.Name}.xlsx";
|
||||
FileInfo fileInfo = new FileInfo(xlsxFilePath);
|
||||
|
||||
// 设置所有单元格的水平和垂直对齐方式为居中
|
||||
worksheet.Cells.Style.HorizontalAlignment = ExcelHorizontalAlignment.Center;
|
||||
worksheet.Cells.Style.VerticalAlignment = ExcelVerticalAlignment.Center;
|
||||
|
||||
// 自适应所有列的宽度
|
||||
worksheet.Cells.AutoFitColumns();
|
||||
excelPackage.SaveAs(fileInfo);
|
||||
}
|
||||
}
|
||||
|
||||
private ObservableCollection<ProcessHistoryDeviceData> QueryExportProcessHistory(ProcessHistoryData processHistoryData)
|
||||
{
|
||||
if (string.IsNullOrEmpty(processHistoryData.StepBeginTime) || string.IsNullOrEmpty(processHistoryData.StepEndTime))
|
||||
{
|
||||
MessageBox.Show("Not complete time", "Error",
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Error);
|
||||
return null;
|
||||
}
|
||||
var daySlices = DateRangeHelper.SplitInToHours(new DateRangeHelper(Convert.ToDateTime(processHistoryData.StepBeginTime), Convert.ToDateTime(processHistoryData.StepEndTime)), 12);
|
||||
return ProcessHistorySqlHelp.GetProcessHistoryDeviceData(daySlices, CbSelectPM, PMItemList);
|
||||
}
|
||||
|
||||
public void HandExport()
|
||||
{
|
||||
if (!Directory.Exists(_path))
|
||||
Directory.CreateDirectory(_path);
|
||||
Process.Start("explorer.exe", _path);
|
||||
}
|
||||
|
||||
public void AutoExport()
|
||||
{
|
||||
string path = (string)QueryDataClient.Instance.Service.GetData($"RT.AutoExpProcessHistory.Path");
|
||||
if (!Directory.Exists(path))
|
||||
Directory.CreateDirectory(path);
|
||||
Process.Start("explorer.exe", path);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据时间段查询Recipe生产的历史记录
|
||||
/// </summary>
|
||||
public void QueryRecipeProcessHistory()
|
||||
{
|
||||
if (StartDateTime > EndDateTime)
|
||||
{
|
||||
MessageBox.Show("time range invalid, start time should be early than end time.", "Error",
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Error);
|
||||
return;
|
||||
}
|
||||
|
||||
var dialog = new ProcessHistoryInfMessageBoxViewModel(StartDateTime.ToString("yyyy-MM-dd HH:mm:ss"), EndDateTime.ToString("yyyy-MM-dd HH:mm:ss"), CbSelectPM);
|
||||
var wm = new WindowManager();
|
||||
|
||||
dynamic settings = new ExpandoObject();
|
||||
settings.WindowStartupLocation = WindowStartupLocation.CenterOwner;
|
||||
settings.Title = "Recipe历史生产数据选择";
|
||||
settings.ResizeMode = ResizeMode.NoResize;
|
||||
settings.ShowInTaskbar = false;
|
||||
|
||||
var bret = wm.ShowDialog(dialog, null, settings);
|
||||
if ((bool)bret)
|
||||
{
|
||||
if (dialog.RecipeProcessHistoryData == null)
|
||||
return;
|
||||
|
||||
RecipeProcessHistoryData = dialog.RecipeProcessHistoryData;
|
||||
SelectRecipeIsNull = true;
|
||||
ProcessHistoryDataList = ProcessHistorySqlHelp.QueryProcessHistoryData(dialog.RecipeProcessHistoryData.ProcessGuid, dialog.RecipeProcessHistoryData.Name, dialog.StepModel);
|
||||
StepDeviceDataList?.Clear();
|
||||
AppendedSeries?.Clear();
|
||||
Refresh();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 选择Recipe后,自动查询当时记录的Step详情
|
||||
/// </summary>
|
||||
public void GetProcessHistory()
|
||||
{
|
||||
if (SelectProcessHistoryData == null)
|
||||
return;
|
||||
QueryProcessHistory(SelectProcessHistoryData);
|
||||
|
||||
Refresh();
|
||||
}
|
||||
|
||||
public void QueryProcessHistory(ProcessHistoryData processHistoryData)
|
||||
{
|
||||
if (string.IsNullOrEmpty(processHistoryData.StepBeginTime) || string.IsNullOrEmpty(processHistoryData.StepEndTime))
|
||||
{
|
||||
MessageBox.Show("Not complete time", "Error",
|
||||
MessageBoxButton.OK,
|
||||
MessageBoxImage.Error);
|
||||
return;
|
||||
}
|
||||
var daySlices = DateRangeHelper.SplitInToHours(new DateRangeHelper(Convert.ToDateTime(processHistoryData.StepBeginTime), Convert.ToDateTime(processHistoryData.StepEndTime)), 12);
|
||||
List<List<GasFlowSum>> gasFlowRunVent = new List<List<GasFlowSum>>();
|
||||
|
||||
StepDeviceDataList = ProcessHistorySqlHelp.GetProcessHistoryDeviceData(daySlices, CbSelectPM, PMItemList);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 显示Charting历史数据记录
|
||||
/// </summary>
|
||||
public void DeviceCharting()
|
||||
{
|
||||
if (StepSelectDeviceData == null)
|
||||
return;
|
||||
GetDeviceCharting();
|
||||
}
|
||||
|
||||
private void GetDeviceCharting()
|
||||
{
|
||||
RenderableSeriesProvide renderableSeries = new RenderableSeriesProvide();
|
||||
AppendedSeries = new ObservableCollection<IRenderableSeries> { renderableSeries.GetLineSeries(StepSelectDeviceData.DeviceName) };
|
||||
|
||||
var dataSeries = AppendedSeries[0].DataSeries as XyDataSeries<DateTime, double>;
|
||||
var dateList = new List<DateTime>();
|
||||
var valueList = new List<double>();
|
||||
var metaList = new List<ParameterNodePoint>();
|
||||
|
||||
// 数据记录点
|
||||
for (int i = 0; i < StepSelectDeviceData.DeviceValue.Count; i++)
|
||||
{
|
||||
var date = new DateTime(long.Parse(StepSelectDeviceData.TimeStamp[i]));
|
||||
var cellValue = StepSelectDeviceData.DeviceValue[i];
|
||||
|
||||
dateList.Add(date);
|
||||
valueList.Add(cellValue);
|
||||
metaList.Add(new ParameterNodePoint(date, cellValue));
|
||||
}
|
||||
dataSeries.Append(dateList, valueList, metaList);
|
||||
|
||||
Thread.Sleep(10);
|
||||
ChartAutoRange = AutoRange.Never;
|
||||
((ProcessHistoryTestView)View).chart.ZoomExtents();
|
||||
}
|
||||
}
|
||||
}
|
||||
+42
@@ -0,0 +1,42 @@
|
||||
using MECF.Framework.UI.Client.CenterViews.Core.Charting;
|
||||
using SciChart.Charting.Visuals.RenderableSeries;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.Linq;
|
||||
using System.Windows.Media;
|
||||
using SciChart.Data.Numerics;
|
||||
|
||||
namespace MECF.Framework.UI.Client.CenterViews.DataLogs.ProcessHistory
|
||||
{
|
||||
public class RenderableSeriesProvide : ObservableCollection<IRenderableSeries>
|
||||
{
|
||||
|
||||
public RenderableSeriesProvide() { }
|
||||
|
||||
/// <summary>
|
||||
/// 返回Chatring曲线对象
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public IRenderableSeries GetLineSeries(string lineName)
|
||||
{
|
||||
Clear();
|
||||
SicFastLineSeries sicFastLineSeries = new SicFastLineSeries(lineName)
|
||||
{
|
||||
Stroke = Colors.Red,
|
||||
AntiAliasing = true,
|
||||
ResamplingMode = ResamplingMode.MinMax,
|
||||
};
|
||||
|
||||
Add(sicFastLineSeries);
|
||||
|
||||
this.ToList().ForEach(x =>
|
||||
{
|
||||
x.DataSeries.Clear();
|
||||
((SicFastLineSeries)x)?.BackendParameterNode?.ClearStatistic();
|
||||
});
|
||||
|
||||
return sicFastLineSeries;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user