首次上传

This commit is contained in:
hanqiangqiang
2026-06-15 10:56:30 +08:00
commit b0213b94d6
4160 changed files with 736101 additions and 0 deletions
@@ -0,0 +1,90 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace MECF.Framework.UI.Client.TrayThickness
{
public class CoatingData : ICloneable
{
/// <summary>
/// 存储Tray的ID
/// </summary>
public string GUID { get; set; } = "0";
/// <summary>
/// 界面上标签显示
/// </summary>
public string Caption { get; set; }
/// <summary>
/// Tray环名称
/// </summary>
public string SerialNumber { get; set; }
/// <summary>
/// 设置或返回当前托盘组件所属的PM腔名称。
/// </summary>
public string PmOwned { get; set; }
/// <summary>
/// 厚度最大值
/// </summary>
public string MAX { get; set; }
/// <summary>
/// 当前厚度
/// </summary>
public string Current { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public string CreatTime { get; set; }
public string Index { get; set; } = "0";
public CoatingData()
{
CreatTime = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
}
public CoatingData(string caption, string uid) : this()
{
Caption = caption;
GUID = uid;
}
public bool Validate(out string reason)
{
reason = string.Empty;
if (string.IsNullOrEmpty(SerialNumber))
reason = "Serial SerialNumber can not be empty";
if(string.IsNullOrEmpty(PmOwned))
reason = "PM name can not be empty";
// reformat reason
if (!string.IsNullOrEmpty(reason))
reason = $"{Caption} {reason}";
return string.IsNullOrEmpty(reason);
}
public object Clone()
{
return new CoatingData()
{
SerialNumber = SerialNumber,
PmOwned = PmOwned,
MAX = MAX,
Current = Current
};
}
public void Update(CoatingData newData)
{
SerialNumber = newData.SerialNumber;
PmOwned = newData.PmOwned;
MAX = newData.MAX;
Current = newData.Current;
}
}
}
@@ -0,0 +1,105 @@
using Aitex.Core.RT.Event;
using Aitex.Core.RT.OperationCenter;
using Aitex.Core.Util;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Threading;
using System.Windows;
using DocumentFormat.OpenXml.Office2010.Excel;
namespace MECF.Framework.UI.Client.TrayThickness.HistoryData
{
public class HistoryCoatingManager:Singleton<HistoryCoatingManager>
{
public List<CoatingData> CoatingData { get; set; } = new List<CoatingData>();
HistoryCoatingSqlHelp historyCoatingSqlHelp { get; set; }=new HistoryCoatingSqlHelp();
public HistoryCoatingManager()
{
}
public void Initialize()
{
InitData();
}
private void InitData()
{
OP.Subscribe("HistoryCoatingManager.Grow", (string cmd, object[] args) => Grow(args));
OP.Subscribe("HistoryCoatingManager.GrowCheck", (string cmd, object[] args) => GrowCheck(args));
}
/// <summary>
/// 更新Tray和腔体的厚度,arg0 TrayInnerID arg1生长速率 arg2生长时间 arg3PM腔
/// </summary>
/// <param name="args"></param>
/// <returns></returns>
public bool Grow(object[] args)//Process完成后更新生长厚度,操作对象Tray PM
{
try
{
double GrowthRate = Convert.ToDouble(args[1]);
double Seconds = Convert.ToDouble(args[2]);
if (GrowthRate* Seconds==0)
{
return true;
}
historyCoatingSqlHelp.GrowTray(args[0].ToString(), GrowthRate, Seconds);
historyCoatingSqlHelp.GrowPM(args[3].ToString(), GrowthRate, Seconds);
historyCoatingSqlHelp.GrowPMForMaintenance(args[3].ToString(), GrowthRate, Seconds);
return true;
}
catch (Exception ex)
{
EV.PostInfoLog("System", $"CoatingManager.Grow_Error {ex.ToString()}");
return false;
}
}
public bool GrowCheck(object[] args)
{
string lab = "";
if (historyCoatingSqlHelp.CheckExceedTray(args[0].ToString(), args[1].ToString(), out lab))
CheckIsClear(lab);
if (historyCoatingSqlHelp.CheckExceedPM(args[1].ToString(), out lab))
CheckIsClear(lab);
return true;
}
InspectCleanView inspectCleanView = new InspectCleanView();
private void CheckIsClear(string lab) //检查当前厚度是否大于设定厚度,操作对象Tray PM,需要清理时弹窗提示
{
//在异步中弹窗
Application.Current.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() =>
{
inspectCleanView.AddToolTip(lab);
//弹窗提示,不关闭时,文本内容递增,关闭后重新提示
var wins = Application.Current.Windows.OfType<InspectCleanView>().ToArray();
if (wins.Any())
{
foreach (InspectCleanView w in wins)
{
if (w.WindowState == WindowState.Minimized)
w.WindowState = WindowState.Normal;
w.Show();
w.Activate();
}
}
else
{
if (!inspectCleanView.IsActive)
{
inspectCleanView = new InspectCleanView();
inspectCleanView.AddToolTip(lab);
inspectCleanView.Show();
}
}
}));
}
}
}
@@ -0,0 +1,430 @@
using Aitex.Core.RT.DBCore;
using Aitex.Core.RT.Log;
using Aitex.Core.RT.OperationCenter;
using Aitex.Core.RT.Routine;
using DocumentFormat.OpenXml.Drawing.Charts;
using DocumentFormat.OpenXml.Math;
using DocumentFormat.OpenXml.Office.Word;
using DocumentFormat.OpenXml.Wordprocessing;
using MECF.Framework.Common.DataCenter;
using MECF.Framework.Common.OperationCenter;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Xml.Linq;
namespace MECF.Framework.UI.Client.TrayThickness.HistoryData
{
public class HistoryCoatingSqlHelp
{
private List<string> TrayTabList = new List<string>()
{
"tray_number",
"tray_inner_number",
"ring_inner_number",
"ring_outer_number"
};
public List<TrayCoatingThickness> QueryUpdateAll_Tray()
{
string cmd = $"select * from tray_thickness_main order by create_time desc ";
return QueryTrayCoatingList(cmd);
}
public List<TrayCoatingThickness> QueryUpdateTime_Tray(string starTime, string endTime)
{
string cmd = $"select * from tray_thickness_main where create_time between '{starTime}' and '{endTime}' order by create_time desc";
return QueryTrayCoatingList(cmd);
}
public List<CoatingData> QueryUnitName_Tray(string name, string starTime="", string endTime="")
{
string time = $"and create_time between '{starTime}' and '{endTime}'";
string cmd = $"select * from tray_thickness_main where tray_number = '{name}' {time} order by create_time desc";
return QueryTrayBase(cmd, true);
}
/// <summary>
/// Tray环交叉使用记录
/// </summary>
/// <param name="name"></param>
/// <param name="starTime"></param>
/// <param name="endTime"></param>
/// <returns></returns>
public List<TrayCoatingThickness> QueryEntiretyTray(string name, string starTime = "", string endTime = "")
{
//根据TrayID获取对应内外编号
List<TrayCoatingThickness> trayCoatingList = new List<TrayCoatingThickness>();
List<string> rowName = new List<string>();
string cmdAllName = "select * from tray_thickness_data where " +
$"tray_number='{name}' " +
$"or tray_inner_number = '{name}' " +
$"or ring_inner_number = '{name}' " +
$"or ring_outer_number = '{name}'";
var dtAll = QueryDataClient.Instance.Service.QueryData(cmdAllName);
if (dtAll !=null && dtAll.Rows.Count != 0)
{
for (int i = 0; i < dtAll.Rows.Count; i++)
{
for (int j = 0; j < TrayTabList.Count; j++)
{
string value = dtAll.Rows[i][TrayTabList[j]].ToString();
if (!rowName.Contains(value))
rowName.Add(value);
}
}
}
string cmdName1 = "";
for (int i = 0; i < rowName.Count; i++)
{
if (i == rowName.Count - 1)
cmdName1 += $"tray_number = '{rowName[i]}' ";
else
cmdName1 += $"tray_number = '{rowName[i]}' or ";
}
string time = $"and create_time between '{starTime}' and '{endTime}'";
string cmdName = $"select * from tray_thickness_main where {cmdName1} {time} order by create_time desc";
trayCoatingList = QueryTrayCoatingList(cmdName);
return trayCoatingList;
}
public List<PMCoatingThickness> QueryUpdateAll_PM()
{
string cmd = $"select * from pm_thickness_main order by create_time desc ";
return QueryPMCoatingList(cmd);
}
public List<PMCoatingThickness> QueryUpdateTime_PM(string starTime, string endTime)
{
string cmd = $"select * from pm_thickness_main where create_time between '{starTime}' and '{endTime}' order by create_time desc";
return QueryPMCoatingList(cmd);
}
public List<PMCoatingThickness> QueryUnitName_PM(string name, string starTime = "", string endTime = "")
{
string time = $"and create_time between '{starTime}' and '{endTime}'";
string cmd = $"select * from pm_thickness_main where pm_cycle = '{name}' {time} order by create_time desc";
return QueryPMCoatingList(cmd);
}
private List<CoatingData> QueryTrayBase(string cmd, bool isNum = false)
{
List<CoatingData> coatingDataList = new List<CoatingData>();
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++)
{
if (dt.Rows[i].ItemArray.Length != 0)
{
CoatingData coatingData = new CoatingData()
{
SerialNumber = dt.Rows[i]["tray_number"].ToString(),
MAX = dt.Rows[i]["tray_max_thickness"].ToString(),
PmOwned = dt.Rows[i]["pm_number"].ToString(),
Current = dt.Rows[i]["tray_coating_thickness"].ToString(),
CreatTime = dt.Rows[i]["create_time"].ToString(),
Caption = dt.Rows[i]["tray_label"].ToString(),
Index = $"Tray {i / 4 + 1}"
};
if (isNum)
{
coatingData.Index = (i + 1).ToString();
}
coatingDataList.Add(coatingData);
}
else
coatingDataList.Add(new CoatingData());
}
}
catch (Exception)
{
return null;
}
return coatingDataList;
}
private List<TrayCoatingThickness> QueryTrayCoatingList(string cmd)
{
List<TrayCoatingThickness> trayCoatingList = new List<TrayCoatingThickness>();
try
{
TrayCoatingThickness trayCoatingThickness = new TrayCoatingThickness();
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++)
{
CoatingData coatingData = new CoatingData()
{
SerialNumber = dt.Rows[i]["tray_number"].ToString(),
MAX = dt.Rows[i]["tray_max_thickness"].ToString(),
PmOwned = dt.Rows[i]["pm_number"].ToString(),
Current = dt.Rows[i]["tray_coating_thickness"].ToString(),
CreatTime = dt.Rows[i]["create_time"].ToString(),
Caption = dt.Rows[i]["tray_label"].ToString(),
Index = $"Tray {i / 4 + 1}"
};
switch (coatingData.Caption)
{
case "石墨托盘":
trayCoatingThickness.Tray = coatingData;
break;
case "内部托架":
trayCoatingThickness.TrayInner = coatingData;
break;
case "中间托架":
trayCoatingThickness.RingInner = coatingData;
break;
case "外部托架":
trayCoatingThickness.RingOuter = coatingData;
break;
default:
break;
}
if ((i % 4) == 3)//Tray是4个数据为一个循环
{
trayCoatingList.Add(trayCoatingThickness);
trayCoatingThickness = new TrayCoatingThickness();
}
}
}
catch (Exception)
{
return null;
}
return trayCoatingList;
}
private List<PMCoatingThickness> QueryPMCoatingList(string cmd)
{
List<PMCoatingThickness> pmCoatingList = new List<PMCoatingThickness>();
try
{
PMCoatingThickness pmCoatingThickness = new PMCoatingThickness();
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++)
{
CoatingData coatingData = new CoatingData()
{
SerialNumber = dt.Rows[i]["pm_cycle"].ToString(),
MAX = dt.Rows[i]["pm_max_thickness"].ToString(),
PmOwned = dt.Rows[i]["pm_number"].ToString(),
Current = dt.Rows[i]["pm_coating_thickness"].ToString(),
CreatTime = dt.Rows[i]["create_time"].ToString(),
Caption = dt.Rows[i]["pm_label"].ToString(),
Index = $"{i + 1}"
};
if (coatingData.Caption.Contains("小周期"))
pmCoatingThickness.MinorCycle = coatingData;
else
pmCoatingThickness.MajorCycle = coatingData;
if ((i % 2) == 1)//MP是2个数据为一个循环
{
pmCoatingList.Add(pmCoatingThickness);
pmCoatingThickness = new PMCoatingThickness();
}
}
}
catch (Exception)
{
return null;
}
return pmCoatingList;
}
public bool GrowTray(string tray_guid, double GrowthRate, double Seconds)//Tray更新增长厚度
{
//
try
{
string tray_numbers = "";
string sSql = $"select * from tray_thickness_data where tray_guid like '{tray_guid}'";
DataSet ds = DB.ExecuteDataSet(sSql);
if (ds == null || ds.Tables[0].Rows.Count == 0)
return false;
tray_numbers = "'" + ds.Tables[0].Rows[0]["tray_number"].ToString() + "','" + ds.Tables[0].Rows[0]["tray_inner_number"].ToString() + "','" +
ds.Tables[0].Rows[0]["ring_inner_number"].ToString() + "','" + ds.Tables[0].Rows[0]["ring_outer_number"].ToString() + "'";
string growthValue = (GrowthRate * Seconds / 3600).ToString("0.000"); //μm
string[] gCmd = { $"update tray_thickness_main set tray_coating_thickness = tray_coating_thickness + {growthValue} " +
$"where create_time = (select create_time FROM tray_thickness_main where tray_number in ({tray_numbers}) " +
$"ORDER BY create_time DESC LIMIT 1 ) " };
List<string> coatingNameList = new List<string>();
coatingNameList.Add(ds.Tables[0].Rows[0]["tray_number"].ToString());
coatingNameList.Add(ds.Tables[0].Rows[0]["tray_inner_number"].ToString());
coatingNameList.Add(ds.Tables[0].Rows[0]["ring_inner_number"].ToString());
coatingNameList.Add(ds.Tables[0].Rows[0]["ring_outer_number"].ToString());
foreach (string name in coatingNameList)
{
OP.DoOperation("GEM_GrowCoating",
name, growthValue);
}
return DB.ExcuteTransAction(gCmd.ToList());
}
catch (Exception ex)
{
LOG.Write($"GrowTray { ex}");
return false;
}
}
public bool GrowPM(string pmName, double GrowthRate, double Seconds)//PM更新增长厚度
{
try
{
string pm_Cmd = "";
string sSql = $"select * from pm_thickness_data where pm_guid like '{pmName}' ";
DataSet ds = DB.ExecuteDataSet(sSql);
if (ds == null || ds.Tables[0].Rows.Count == 0)
return false;
pm_Cmd = $"'{ds.Tables[0].Rows[0]["pm_minor_cycle"].ToString()}','{ds.Tables[0].Rows[0]["pm_major_cycle"].ToString()}'";
//
string growthValue = (GrowthRate * Seconds / 3600).ToString("0.00"); //μm
string[] gCmd = { $"update pm_thickness_main set pm_coating_thickness = pm_coating_thickness + {growthValue} " +
$"where create_time = (select create_time FROM pm_thickness_main where pm_cycle in ({pm_Cmd}) " +
$"ORDER BY create_time DESC LIMIT 1 ) " };
return DB.ExcuteTransAction(gCmd.ToList());
}
catch (Exception ex)
{
LOG.Write($"GrowPM {ex}");
return false;
}
}
public bool GrowPMForMaintenance(string pmName, double GrowthRate, double Seconds)//PM更新增长厚度
{
try
{
string growthValue = (GrowthRate * Seconds / 3600).ToString("0.00"); //μm
string gCmd = $"update pm_thickness_data2 set thickness = thickness + {growthValue} " +
$"where pm_name = '{pmName}';";
return DB.ExecuteNonQuery(gCmd) == 1;
}
catch (Exception ex)
{
LOG.Write($"GrowPM {ex}");
return false;
}
}
public bool CheckExceedTray(string tray_guid,string pmName, out string infor)
{
infor = "";
try
{
string sSql = $"select * from tray_thickness_data where tray_guid like '{tray_guid}'";
DataSet ds = DB.ExecuteDataSet(sSql);
if (ds == null || ds.Tables[0].Rows.Count == 0)
return false;
string cmd = "select tray_coating_thickness , tray_max_thickness,tray_label from tray_thickness_main where ";
cmd += $"tray_number='{ds.Tables[0].Rows[0]["tray_number"].ToString()}' " +
$"or tray_number = '{ds.Tables[0].Rows[0]["tray_inner_number"].ToString()}' " +
$"OR tray_number = '{ds.Tables[0].Rows[0]["ring_inner_number"].ToString()}' " +
$"or tray_number = '{ds.Tables[0].Rows[0]["ring_outer_number"].ToString()}'";
string timeCmd = $" ORDER BY create_time DESC LIMIT 4";
ds = DB.ExecuteDataSet(cmd+ timeCmd);
if (ds == null || ds.Tables[0].Rows.Count == 0)
return false;
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
double coating = double.Parse( ds.Tables[0].Rows[i]["tray_coating_thickness"].ToString());
double max =double.Parse(ds.Tables[0].Rows[i]["tray_max_thickness"].ToString());
if (coating>max)
{
string lab = ds.Tables[0].Rows[i]["tray_label"].ToString();
infor = $"{pmName}腔体 Tray {lab} MAX={max} Coating={coating}";
return true;
}
}
}
catch (Exception ex)
{
LOG.Write($"HistoryCoatingSqlHelp.CheckExceedTray error {ex}");
return false;
}
return false;
}
public bool CheckExceedPM(string pmId, out string infor)
{
infor = "";
try
{
string sSql = $"select * from pm_thickness_data where pm_guid like '{pmId}'";
DataSet ds = DB.ExecuteDataSet(sSql);
if (ds == null || ds.Tables[0].Rows.Count == 0)
return false;
string cmd = "select pm_coating_thickness , pm_max_thickness,pm_label from pm_thickness_main where ";
cmd += $"pm_cycle='{ds.Tables[0].Rows[0]["pm_minor_cycle"].ToString()}' " +
$"or pm_cycle = '{ds.Tables[0].Rows[0]["pm_major_cycle"].ToString()}'";
string timeCmd = $" ORDER BY create_time DESC LIMIT 2";
ds = DB.ExecuteDataSet(cmd + timeCmd);
if (ds == null || ds.Tables[0].Rows.Count == 0)
return false;
for (int i = 0; i < ds.Tables[0].Rows.Count; i++)
{
double coating = double.Parse(ds.Tables[0].Rows[i]["pm_coating_thickness"].ToString());
double max = double.Parse(ds.Tables[0].Rows[i]["pm_max_thickness"].ToString());
if (coating > max)
{
string lab = ds.Tables[0].Rows[i]["pm_label"].ToString();
infor = $"{lab} MAX={max} Coating={coating}";
return true;
}
}
}
catch (Exception ex)
{
LOG.Write($"HistoryCoatingSqlHelp.CheckExceedPM error {ex}");
return false;
}
return false;
}
}
}
@@ -0,0 +1,679 @@
<UserControl
x:Class="MECF.Framework.UI.Client.TrayThickness.HistoryData.HistoryDataView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:OpenSEMI.Ctrlib.Controls"
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:lex="http://wpflocalizeextension.codeplex.com"
xmlns:local="clr-namespace:MECF.Framework.UI.Client.TrayThickness.HistoryData"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:micro="clr-namespace:Caliburn.Micro"
xmlns:toolkit="http://schemas.xceed.com/wpf/xaml/toolkit"
xmlns:xctk="http://schemas.xceed.com/wpf/xaml/toolkit"
d:DesignHeight="450"
d:DesignWidth="1200"
lex:LocalizeDictionary.DesignCulture="zh"
lex:ResxLocalizationProvider.DefaultAssembly="Sicentury.Localization"
lex:ResxLocalizationProvider.DefaultDictionary="lang_overview"
mc:Ignorable="d">
<UserControl.Resources>
<local:ColorConverter x:Key="ColorConverter_Current" />
<local:BoolToVisibilityConverter x:Key="BoolToVisibility_Converter" />
</UserControl.Resources>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="300" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<!-- 右侧操作面板 -->
<StackPanel
Height="340"
Margin="10"
VerticalAlignment="Top"
Background="#FFDBE5F1"
Orientation="Vertical">
<StackPanel
Width="260"
Margin="10"
lex:ResxLocalizationProvider.DefaultDictionary="lang_common">
<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="3,0" Orientation="Horizontal">
<TextBlock
Width="70"
VerticalAlignment="Center"
FontFamily="Arial"
FontSize="14"
Text="{lex:Loc ID_TXT_StartTime}" />
<WindowsFormsHost
Width="170"
Height="22"
Margin="5,0,0,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>
</StackPanel>
<StackPanel Margin="3,0" Orientation="Horizontal">
<TextBlock
Width="70"
VerticalAlignment="Center"
FontFamily="Arial"
FontSize="14"
Text="{lex:Loc ID_TXT_EndTime}" />
<WindowsFormsHost
Width="170"
Height="22"
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>
</StackPanel>
</StackPanel>
<StackPanel
Margin="5"
HorizontalAlignment="Right"
Orientation="Horizontal">
<RadioButton
Margin="5"
VerticalAlignment="Center"
Content="{lex:Loc ID_TXT_Tray}"
IsChecked="{Binding IsQueryTray}" />
<RadioButton
Margin="5"
VerticalAlignment="Center"
Content="PM"
IsChecked="{Binding IsQueryPM}"
ToolTip="选中时间段内查询" />
</StackPanel>
<StackPanel lex:ResxLocalizationProvider.DefaultDictionary="lang_common">
<Button
Width="100"
Height="30"
Margin="10"
HorizontalAlignment="Left"
Content="Query All"
ToolTip="查询所有记录"
Visibility="Collapsed">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<micro:ActionMessage MethodName="QueryAll" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
<Button
x:Name="ID_BTN_Query_Content"
Width="100"
Height="30"
Margin="10"
HorizontalAlignment="Right"
Content="{lex:Loc}"
ToolTip="{lex:Loc}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<micro:ActionMessage MethodName="QueryTime" />
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</StackPanel>
<StackPanel Visibility="{Binding IsQueryTray, Converter={StaticResource BoolToVisibility_Converter}}">
<StackPanel
Margin="10,30,0,0"
lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
Orientation="Horizontal">
<TextBlock
Width="50"
VerticalAlignment="Center"
FontFamily="Arial"
FontSize="14"
Text="{lex:Loc ID_TXT_Name}" />
<TextBox
Name="txt_TrayName"
Width="170"
Height="22"
Margin="5,0,0,0"
VerticalAlignment="Center"
FontFamily="Arial"
FontSize="14" />
</StackPanel>
<StackPanel
Margin="10"
HorizontalAlignment="Right"
Orientation="Horizontal">
<RadioButton
x:Name="ID_RAD_Monocycle_Content"
Margin="5"
VerticalAlignment="Center"
Content="{lex:Loc}"
IsChecked="{Binding Unit}"
ToolTip="{lex:Loc}" />
<RadioButton
x:Name="ID_RAD_Entirety_Content"
Margin="5"
VerticalAlignment="Center"
Content="{lex:Loc}"
IsChecked="{Binding Entirety}"
ToolTip="{lex:Loc}" />
</StackPanel>
<Button
Width="100"
Height="30"
Margin="10"
HorizontalAlignment="Right"
lex:ResxLocalizationProvider.DefaultDictionary="lang_common"
Content="{lex:Loc ID_BTN_Query_Content}"
ToolTip="{lex:Loc ID_BTN_Query_Content}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<micro:ActionMessage MethodName="QueryName">
<micro:ActionMessage.Parameters>
<micro:Parameter Value="{Binding Path=Text, ElementName=txt_TrayName}" />
</micro:ActionMessage.Parameters>
</micro:ActionMessage>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</StackPanel>
</StackPanel>
<ScrollViewer
Grid.Column="1"
Width="900"
Margin="10"
HorizontalAlignment="Left"
lex:ResxLocalizationProvider.DefaultDictionary="lang_overview">
<StackPanel>
<!-- Tray信息展示控件包含整体Tray和单环信息两种控件 -->
<StackPanel Visibility="{Binding IsQueryTray, Converter={StaticResource BoolToVisibility_Converter}}">
<!-- 单行信息展示 -->
<ListView
VerticalAlignment="Top"
AlternationCount="2"
ItemsSource="{Binding CoatingData}"
Visibility="{Binding Unit, Converter={StaticResource BoolToVisibility_Converter}}">
<ListView.View>
<GridView>
<GridViewColumn Width="80" Header="{lex:Loc ID_TXT_Index}">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Index}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Width="120" Header="{lex:Loc ID_TXT_Caption}">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Caption}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Width="200" Header="{lex:Loc ID_TXT_Name}">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding SerialNumber}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Width="100" Header="{lex:Loc ID_TXT_Max}">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding MAX}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Width="100" Header="{lex:Loc ID_TXT_Current}">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Current, StringFormat=N2}">
<TextBlock.Foreground>
<MultiBinding Converter="{StaticResource ColorConverter_Current}" StringFormat="{}{0}:{1}">
<Binding Path="Current" />
<Binding Path="MAX" />
</MultiBinding>
</TextBlock.Foreground>
</TextBlock>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Width="80" Header="{lex:Loc ID_TXT_PM_ID}">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding PmOwned}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
<GridViewColumn Width="220" Header="{lex:Loc ID_TXT_Creat_Time}">
<GridViewColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding CreatTime}" />
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
<!-- Tray整体信息展示 -->
<ListView
HorizontalAlignment="Left"
Background="White"
FontSize="12"
ItemsSource="{Binding TrayCoatingList}"
Visibility="{Binding IsNotUnit, Converter={StaticResource BoolToVisibility_Converter}}">
<ListView.Resources>
<Style TargetType="ListViewItem">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="White" />
</Trigger>
<Trigger Property="IsMouseOver" Value="False">
<Setter Property="Background" Value="White" />
</Trigger>
</Style.Triggers>
</Style>
<Style TargetType="Label">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="LightSkyBlue" />
</Trigger>
<Trigger Property="IsMouseOver" Value="False">
<Setter Property="Background" Value="White" />
</Trigger>
</Style.Triggers>
</Style>
</ListView.Resources>
<ListView.View>
<GridView>
<GridViewColumn
Width="900"
lex:ResxLocalizationProvider.DefaultDictionary="lang_overview"
Header="{lex:Loc ID_TXT_Tray_Coating_History_Data}">
<GridViewColumn.CellTemplate>
<DataTemplate>
<Grid Width="850">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Border BorderBrush="Gray" BorderThickness="1,1,0,1">
<Label
HorizontalAlignment="Center"
VerticalAlignment="Center"
Content="{Binding Tray.PmOwned}"
FontFamily="Bold"
FontSize="18" />
</Border>
<StackPanel Grid.Column="1">
<Border BorderBrush="Gray" BorderThickness="1">
<StackPanel Orientation="Horizontal">
<Label>Caption:</Label>
<Label
Width="60"
Margin="0,0,5,0"
HorizontalAlignment="Left"
Content="{Binding Tray.Caption}" />
<Label>Name:</Label>
<Label
Width="150"
Margin="0,0,5,0"
HorizontalAlignment="Left"
Content="{Binding Tray.SerialNumber}" />
<Label>Max:</Label>
<Label
Width="60"
Margin="0,0,5,0"
HorizontalAlignment="Left"
Content="{Binding Tray.MAX}" />
<Label>Thickness:</Label>
<Label
Width="60"
Margin="0,0,5,0"
HorizontalAlignment="Left"
Content="{Binding Tray.Current}">
<Label.Foreground>
<MultiBinding Converter="{StaticResource ColorConverter_Current}" StringFormat="{}{0}:{1}">
<Binding Path="Tray.Current" />
<Binding Path="Tray.MAX" />
</MultiBinding>
</Label.Foreground>
</Label>
<Label>Time:</Label>
<Label
Width="160"
HorizontalAlignment="Left"
Content="{Binding Tray.CreatTime}" />
</StackPanel>
</Border>
<Border BorderBrush="Gray" BorderThickness="1,0,1,1">
<StackPanel Orientation="Horizontal">
<Label>Caption:</Label>
<Label
Width="60"
Margin="0,0,5,0"
HorizontalAlignment="Left"
Content="{Binding TrayInner.Caption}" />
<Label>Name:</Label>
<Label
Width="150"
Margin="0,0,5,0"
HorizontalAlignment="Left"
Content="{Binding TrayInner.SerialNumber}" />
<Label>Max:</Label>
<Label
Width="60"
Margin="0,0,5,0"
HorizontalAlignment="Left"
Content="{Binding TrayInner.MAX}" />
<Label>Thickness:</Label>
<Label
Width="60"
Margin="0,0,5,0"
HorizontalAlignment="Left"
Content="{Binding TrayInner.Current}">
<Label.Foreground>
<MultiBinding Converter="{StaticResource ColorConverter_Current}" StringFormat="{}{0}:{1}">
<Binding Path="TrayInner.Current" />
<Binding Path="TrayInner.MAX" />
</MultiBinding>
</Label.Foreground>
</Label>
<Label>Time:</Label>
<Label
Width="160"
HorizontalAlignment="Left"
Content="{Binding TrayInner.CreatTime}" />
</StackPanel>
</Border>
<Border BorderBrush="Gray" BorderThickness="1,0,1,1">
<StackPanel Orientation="Horizontal">
<Label>Caption:</Label>
<Label
Width="60"
Margin="0,0,5,0"
HorizontalAlignment="Left"
Content="{Binding RingInner.Caption}" />
<Label>Name:</Label>
<Label
Width="150"
Margin="0,0,5,0"
HorizontalAlignment="Left"
Content="{Binding RingInner.SerialNumber}" />
<Label>Max:</Label>
<Label
Width="60"
Margin="0,0,5,0"
HorizontalAlignment="Left"
Content="{Binding RingInner.MAX}" />
<Label>Thickness:</Label>
<Label
Width="60"
Margin="0,0,5,0"
HorizontalAlignment="Left"
Content="{Binding RingInner.Current}">
<Label.Foreground>
<MultiBinding Converter="{StaticResource ColorConverter_Current}" StringFormat="{}{0}:{1}">
<Binding Path="RingInner.Current" />
<Binding Path="RingInner.MAX" />
</MultiBinding>
</Label.Foreground>
</Label>
<Label>Time:</Label>
<Label
Width="160"
HorizontalAlignment="Left"
Content="{Binding RingInner.CreatTime}" />
</StackPanel>
</Border>
<Border BorderBrush="Gray" BorderThickness="1,0,1,1">
<StackPanel Orientation="Horizontal">
<Label>Caption:</Label>
<Label
Width="60"
Margin="0,0,5,0"
HorizontalAlignment="Left"
Content="{Binding RingOuter.Caption}" />
<Label>Name:</Label>
<Label
Width="150"
Margin="0,0,5,0"
HorizontalAlignment="Left"
Content="{Binding RingOuter.SerialNumber}" />
<Label>Max:</Label>
<Label
Width="60"
Margin="0,0,5,0"
HorizontalAlignment="Left"
Content="{Binding RingOuter.MAX}" />
<Label>Thickness:</Label>
<Label
Width="60"
Margin="0,0,5,0"
HorizontalAlignment="Left"
Content="{Binding RingOuter.Current}">
<Label.Foreground>
<MultiBinding Converter="{StaticResource ColorConverter_Current}" StringFormat="{}{0}:{1}">
<Binding Path="RingOuter.Current" />
<Binding Path="RingOuter.MAX" />
</MultiBinding>
</Label.Foreground>
</Label>
<Label>Time:</Label>
<Label
Width="160"
HorizontalAlignment="Left"
Content="{Binding RingOuter.CreatTime}" />
</StackPanel>
</Border>
</StackPanel>
</Grid>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
</StackPanel>
<!-- PM信息展示控件 -->
<ListView
HorizontalAlignment="Left"
Background="White"
FontSize="12"
ItemsSource="{Binding PMCoatingList}"
Visibility="{Binding IsQueryPM, Converter={StaticResource BoolToVisibility_Converter}}">
<ListView.Resources>
<Style TargetType="ListViewItem">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="White" />
</Trigger>
<Trigger Property="IsMouseOver" Value="False">
<Setter Property="Background" Value="White" />
</Trigger>
</Style.Triggers>
</Style>
<Style TargetType="Label">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="LightSkyBlue" />
</Trigger>
<Trigger Property="IsMouseOver" Value="False">
<Setter Property="Background" Value="White" />
</Trigger>
</Style.Triggers>
</Style>
</ListView.Resources>
<ListView.View>
<GridView>
<GridViewColumn Width="920" Header="{lex:Loc ID_TXT_PM_Coating_History_Data}">
<GridViewColumn.CellTemplate>
<DataTemplate>
<Grid Width="920">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="50" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<Border BorderBrush="Gray" BorderThickness="1,1,0,1">
<Label
HorizontalAlignment="Center"
VerticalAlignment="Center"
Content="{Binding MinorCycle.PmOwned}"
FontFamily="Bold"
FontSize="18" />
</Border>
<StackPanel Grid.Column="1">
<Border BorderBrush="Gray" BorderThickness="1">
<StackPanel Orientation="Horizontal">
<Label>Caption:</Label>
<Label
Width="80"
Margin="0,0,5,0"
HorizontalAlignment="Left"
Content="{Binding MinorCycle.Caption}" />
<Label>Name:</Label>
<Label
Width="150"
Margin="0,0,5,0"
HorizontalAlignment="Left"
Content="{Binding MinorCycle.SerialNumber}" />
<Label>Max:</Label>
<Label
Width="60"
Margin="0,0,5,0"
HorizontalAlignment="Left"
Content="{Binding MinorCycle.MAX}" />
<Label>Thickness:</Label>
<Label
Width="60"
Margin="0,0,5,0"
HorizontalAlignment="Left"
Content="{Binding MinorCycle.Current}" />
<Label>Time:</Label>
<Label
Width="160"
HorizontalAlignment="Left"
Content="{Binding MinorCycle.CreatTime}" />
</StackPanel>
</Border>
<Border BorderBrush="Gray" BorderThickness="1,0,1,1">
<StackPanel Orientation="Horizontal">
<Label>Caption:</Label>
<Label
Width="80"
Margin="0,0,5,0"
HorizontalAlignment="Left"
Content="{Binding MajorCycle.Caption}" />
<Label>Name:</Label>
<Label
Width="150"
Margin="0,0,5,0"
HorizontalAlignment="Left"
Content="{Binding MajorCycle.SerialNumber}" />
<Label>Max:</Label>
<Label
Width="60"
Margin="0,0,5,0"
HorizontalAlignment="Left"
Content="{Binding MajorCycle.MAX}" />
<Label>Thickness:</Label>
<Label
Width="60"
Margin="0,0,5,0"
HorizontalAlignment="Left"
Content="{Binding MajorCycle.Current}" />
<Label>Time:</Label>
<Label
Width="160"
HorizontalAlignment="Left"
Content="{Binding MajorCycle.CreatTime}" />
</StackPanel>
</Border>
</StackPanel>
</Grid>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
</StackPanel>
</ScrollViewer>
</Grid>
</UserControl>
@@ -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.TrayThickness.HistoryData
{
/// <summary>
/// HistoryDataView.xaml 的交互逻辑
/// </summary>
public partial class HistoryDataView : UserControl
{
public HistoryDataView()
{
InitializeComponent();
}
}
}
@@ -0,0 +1,217 @@
using Aitex.Core.RT.OperationCenter;
using MECF.Framework.UI.Client.ClientBase;
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
namespace MECF.Framework.UI.Client.TrayThickness.HistoryData
{
public class HistoryDataViewModel : UiViewModelBase, ISupportMultipleSystem
{
/// <summary>
/// 返回ViewModel绑定的视图对象。
/// </summary>
public UserControl View { get; private set; }
public DateTime StartDateTime
{
get => ((HistoryDataView)View).wfTimeFrom.Value;
set
{
((HistoryDataView)View).wfTimeFrom.Value = value;
NotifyOfPropertyChange(nameof(StartDateTime));
}
}
public DateTime EndDateTime
{
get => ((HistoryDataView)View).wfTimeTo.Value;
set
{
((HistoryDataView)View).wfTimeTo.Value = value;
NotifyOfPropertyChange(nameof(EndDateTime));
}
}
private bool isQueryTray = true;
//勾选查询Tray
public bool IsQueryTray
{
get => isQueryTray;
set
{
isQueryTray = value;
Refresh();
}
}
private bool isQueryPM;
//勾选查询PM
public bool IsQueryPM
{
get => isQueryPM;
set
{
isQueryPM = value;
Refresh();
}
}
public bool TimeChecked { get; set; }
public bool Unit { get; set; } = false;
public bool IsNotUnit => !Unit;
public bool Entirety { get; set; } = true;
//数据库查询对象实例
private HistoryCoatingSqlHelp HistoryCoatingSqlHelp = new HistoryCoatingSqlHelp();
//表示单行数据集合,Tray专用
public List<CoatingData> CoatingData { get; set; } = new List<CoatingData>();
//整个Tray对象数据集合,内含4个环
public List<TrayCoatingThickness> TrayCoatingList { get; set; } = new List<TrayCoatingThickness>();
//PM对象数据集合,内含大小周期
public List<PMCoatingThickness> PMCoatingList { get; set; } = new List<PMCoatingThickness>();
protected override void OnViewLoaded(object _view)
{
base.OnViewLoaded(_view);
View = (UserControl)_view;
StartDateTime = DateTime.Now.Date;
EndDateTime = DateTime.Now.Date.AddDays(1).AddTicks(-1);
}
public void QueryTime()
{
if (StartDateTime > EndDateTime)
{
MessageBox.Show("time range invalid, start time should be early than end time.", "Error",
MessageBoxButton.OK,
MessageBoxImage.Error);
return;
}
if (IsQueryTray)
TrayCoatingList = HistoryCoatingSqlHelp.QueryUpdateTime_Tray(GetTime(StartDateTime), GetTime(EndDateTime));
if (IsQueryPM)
PMCoatingList = HistoryCoatingSqlHelp.QueryUpdateTime_PM(GetTime(StartDateTime), GetTime(EndDateTime));
Refresh();
}
public void QueryAll()
{
if (IsQueryTray)
TrayCoatingList = HistoryCoatingSqlHelp.QueryUpdateAll_Tray();
if (IsQueryPM)
PMCoatingList = HistoryCoatingSqlHelp.QueryUpdateAll_PM();
Refresh();
}
public void QueryName(string name)
{
if (name == null || name.Length == 0)
{
MessageBox.Show("输入名称为空");
return;
}
if (TimeChecked)
{
if (StartDateTime > EndDateTime)
{
MessageBox.Show("time range invalid, start time should be early than end time.", "Error",
MessageBoxButton.OK,
MessageBoxImage.Error);
return;
}
}
if (IsQueryTray)
{
if (Unit)
CoatingData = HistoryCoatingSqlHelp.QueryUnitName_Tray(name, GetTime(StartDateTime), GetTime(EndDateTime));
else if (Entirety)
TrayCoatingList = HistoryCoatingSqlHelp.QueryEntiretyTray(name, GetTime(StartDateTime), GetTime(EndDateTime));
else
CoatingData = HistoryCoatingSqlHelp.QueryUnitName_Tray(name, GetTime(StartDateTime), GetTime(EndDateTime));
}
if (IsQueryPM)
PMCoatingList = HistoryCoatingSqlHelp.QueryUnitName_PM(name, GetTime(StartDateTime), GetTime(EndDateTime));
Refresh();
}
private string GetTime(DateTime dt)
{
return dt.ToString("yyyy-MM-dd HH:mm:ss");
}
}
/// <summary>
/// 检测厚度是否大于最大值
/// </summary>
class ColorConverter : IMultiValueConverter
{
public object Convert(object[] value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
try
{
if (value[0] == null || value[1] == null)
{
return new SolidColorBrush(Colors.Black);
}
double _current;
if (!double.TryParse(value[0].ToString(), out _current))
return new SolidColorBrush(Colors.Red);
double _max;
if (!double.TryParse(value[1].ToString(), out _max))
return new SolidColorBrush(Colors.Black);
if (_current > _max)
{
return new SolidColorBrush(Colors.Red);
}
else
{
return new SolidColorBrush(Colors.Black);
}
}
catch (Exception)
{
return new SolidColorBrush(Colors.Red);
}
}
public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
{
return null;
}
}
class BoolToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if ((bool)value)
return Visibility.Visible;
return Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
@@ -0,0 +1,20 @@
<Window x:Class="MECF.Framework.UI.Client.TrayThickness.HistoryData.InspectCleanView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:MECF.Framework.UI.Client.TrayThickness.HistoryData"
mc:Ignorable="d"
WindowState="Normal" WindowStartupLocation="CenterScreen" ResizeMode="NoResize"
Window.SizeToContent="Height" Width="400" Topmost="True">
<Grid x:Name="Grid_Content" Margin="3,10,3,5" Height="Auto">
<StackPanel Orientation="Vertical">
<TextBlock Text="Needs Cleaning " HorizontalAlignment="Center" VerticalAlignment="Top" Foreground="Red" FontSize="18" FontWeight="Black" />
<TextBlock Name="txt_Coating" Text="" FontSize="12" Foreground="#666666" Margin="0,20,0,5" HorizontalAlignment="Center"
VerticalAlignment="Top" TextAlignment="Left"/>
</StackPanel>
</Grid>
</Window>
@@ -0,0 +1,32 @@
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.TrayThickness.HistoryData
{
/// <summary>
/// InspectCleanView.xaml 的交互逻辑
/// </summary>
public partial class InspectCleanView : Window
{
public InspectCleanView()
{
InitializeComponent();
}
public void AddToolTip(string str)
{
txt_Coating.Text += $"{str}\r\n";
}
}
}
@@ -0,0 +1,93 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MECF.Framework.UI.Client.TrayThickness
{
public class PMDataViewManager
{
PMCoatingThickness PMData;
PMDataViewSqlHelp pmDataHelp = new PMDataViewSqlHelp();
private string PMGuid;
public PMDataViewManager(PMCoatingThickness pmData, string pmGuid)
{
PMData = pmData;
PMGuid = pmGuid;
}
public void UpTrayCoatingThickness()
{
PMCoatingThickness _pmCoatingThickness = pmDataHelp.GetTrayCoatingThickness(PMGuid);
if (_pmCoatingThickness != null )
{
PMData.MinorCycle.Update(_pmCoatingThickness.MinorCycle);
PMData.MajorCycle.Update(_pmCoatingThickness.MajorCycle);
}
}
/// <summary>
/// 界面数据设置到数据库
/// </summary>
public bool SET(out string reason)
{
reason = "";
// 校验托盘组件数据
if (!PMData.Validate(out reason))
return false;
List<CoatingData> coatingDataList = new List<CoatingData>()
{
PMData.MinorCycle,
PMData.MajorCycle,
};
//检查单个环对象是否存在空数据
foreach (var item in coatingDataList)
{
if (item.GetType().GetProperties()
.Where(pi => pi.PropertyType == typeof(string))
.Select(pi => (string)pi.GetValue(item))
.Any(string.IsNullOrEmpty))
{
reason = $"Please check empty value";
return false;
}
}
var ret = pmDataHelp.UpTrayNumberData(PMData, PMGuid, coatingDataList);
if (!ret)
reason = "Failed to write tray Info. to database.";
return ret;
}
/// <summary>
/// 用户输入数据时,去数据库查询更新到界面
/// </summary>
/// <param name="part"></param>
public void LoadCoatingData(string part)
{
switch (part)
{
case "MinorCycle":
ForUpCoatingData(PMData.MinorCycle.SerialNumber, PMData.MinorCycle);
break;
case "MajorCycle":
ForUpCoatingData(PMData.MajorCycle.SerialNumber, PMData.MajorCycle);
break;
default:
break;
}
}
private void ForUpCoatingData(string number, CoatingData data)
{
var coatingData = pmDataHelp.GetCoatingData(number, out var isExistedInDb);
if (isExistedInDb)
{
data.Update(coatingData);
}
}
}
}
@@ -0,0 +1,159 @@
using MECF.Framework.Common.DataCenter;
using System;
using System.Collections.Generic;
using System.Data;
namespace MECF.Framework.UI.Client.TrayThickness
{
public class PMDataViewSqlHelp
{
private string minor_cycle, major_cycle, ring_inner_number, ring_outer_number;
/// <summary>
/// 获取Truy对象整体的数据
/// </summary>
/// <param name="_trayGuid"></param>
/// <returns></returns>
public PMCoatingThickness GetTrayCoatingThickness(string _trayGuid)
{
//这是一次查询一个对象
PMCoatingThickness trayCoatingThickness = null;
try
{
//根据TrayID获取对应内外编号
string cmdID = $"select * from pm_thickness_data where pm_guid = '{_trayGuid}'";
DataTable DataTable = QueryDataClient.Instance.Service.QueryData(cmdID);
if (DataTable != null && DataTable.Rows.Count > 0)
{
trayCoatingThickness = new PMCoatingThickness();
minor_cycle = DataTable.Rows[0]["pm_minor_cycle"].ToString();
major_cycle = DataTable.Rows[0]["pm_major_cycle"].ToString();
trayCoatingThickness.MinorCycle = GetCoatingData(minor_cycle, out _);
trayCoatingThickness.MajorCycle = GetCoatingData(major_cycle, out _);
}
return trayCoatingThickness;
}
catch (Exception)
{
return trayCoatingThickness;
}
}
/// <summary>
/// 获取单个的数据
/// </summary>
/// <param name="sn"></param>
/// <param name="isExistedInDb"></param>
/// <returns></returns>
public CoatingData GetCoatingData(string sn, out bool isExistedInDb)
{
var cmd = $"select * from pm_thickness_main where pm_cycle = '{sn}' ORDER BY create_time DESC LIMIT 1";
var dt = QueryDataClient.Instance.Service.QueryData(cmd);
if (dt is { Rows.Count: > 0 })
{
var coatingData = new CoatingData()
{
SerialNumber = dt.Rows[0]["pm_cycle"].ToString(),
MAX = dt.Rows[0]["pm_max_thickness"].ToString(),
PmOwned = dt.Rows[0]["pm_number"].ToString(),
Current = dt.Rows[0]["pm_coating_thickness"].ToString()
};
isExistedInDb = true;
return coatingData;
}
isExistedInDb = false;
return new CoatingData();
}
/// <summary>
/// 保存用户输入的数据到数据库
/// </summary>
/// <param name="trayCoatingThickness"></param>
/// <param name="trayUid"></param>
public bool UpTrayNumberData(PMCoatingThickness trayCoatingThickness, string trayUid, List<CoatingData> coatingData)
{
List<string> cmdList = new List<string>();
string cmdID = $"select * from pm_thickness_data where pm_guid = '{trayUid}'";
var dt = QueryDataClient.Instance.Service.QueryData(cmdID);
if (dt is { Rows.Count: > 0 })
cmdList.Add(Cmd_update(trayCoatingThickness, trayUid));
else
cmdList.Add(Cmd_data_insert(trayCoatingThickness, trayUid));
foreach (var item in coatingData)
{
cmdList.Add(Cmd_main_insert(item));
}
bool result = QueryDataClient.Instance.Service.ExcuteTransAction(cmdList);
return result;
}
public bool GetPartSnByTrayUid(string trayUid, out List<CoatingData> coatingData)
{
coatingData = new List<CoatingData>();
var sql =
$"select minor_cycle, major_cycle from pm_thickness_data WHERE pm_guid = '{trayUid}' limit 1";
var dt = QueryDataClient.Instance.Service.QueryData(sql);
if (dt is { Rows.Count: > 0 })
{
//partSnList.Add();
}
return false;
}
/// <summary>
/// PM中对象编号插入Sql语句拼接
/// </summary>
/// <param name="pmCoatingThickness"></param>
/// <param name="pmGuid"></param>
/// <returns></returns>
private string Cmd_data_insert(PMCoatingThickness pmCoatingThickness, string pmGuid)
{
string cmd_data_insert =
"insert into pm_thickness_data" +
"(pm_guid,pm_minor_cycle, pm_major_cycle)" +
$"values ('{pmGuid}'," +
$"'{pmCoatingThickness.MinorCycle.SerialNumber}'," +
$"'{pmCoatingThickness.MajorCycle.SerialNumber}')";
return cmd_data_insert;
}
/// <summary>
/// PM中对象编号更新Sql语句拼接
/// </summary>
/// <param name="PMCoatingThickness"></param>
/// <param name="pmGuid"></param>
/// <returns></returns>
private string Cmd_update(PMCoatingThickness PMCoatingThickness, string pmGuid)
{
string cmd_update =
$"update pm_thickness_data set " +
$"pm_minor_cycle = '{PMCoatingThickness.MinorCycle.SerialNumber}', " +
$"pm_major_cycle= '{PMCoatingThickness.MajorCycle.SerialNumber}'" +
$" where pm_guid = '{pmGuid}'";
return cmd_update;
}
/// <summary>
/// 每个环对应的数据插入Sql语句拼接
/// </summary>
/// <param name="coatingData"></param>
/// <returns></returns>
private string Cmd_main_insert(CoatingData coatingData)
{
return "insert into pm_thickness_main" +
"(pm_guid,pm_cycle,pm_number, pm_coating_thickness, pm_max_thickness,pm_label,create_time)" +
$"values ('{Guid.NewGuid()}'," +
$"'{coatingData.SerialNumber}'," +
$"'{coatingData.PmOwned}'," +
$"'{coatingData.Current}'," +
$"'{coatingData.MAX}'," +
$"'{coatingData.Caption}'," +
$"'{coatingData.CreatTime}')";
}
}
}
@@ -0,0 +1,117 @@
<Window x:Class="MECF.Framework.UI.Client.TrayThickness.WinPMThicknessDataView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:micro="clr-namespace:Caliburn.Micro"
xmlns:cal="http://www.caliburn.org"
mc:Ignorable="d"
Height="150" Width="700" >
<Window.Resources>
<Style TargetType="TextBlock" >
<Setter Property="FontSize" Value="13" />
<Setter Property="TextAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="Margin" Value="3"/>
<Setter Property="FontFamily" Value="Arial Black"/>
</Style>
<Style TargetType="Border">
<Setter Property="Background" Value="{DynamicResource Table_BG_Title}" />
<Setter Property="BorderBrush" Value="Gray"/>
<Setter Property="SnapsToDevicePixels" Value="True"/>
</Style>
</Window.Resources>
<Grid >
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition Height="3"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<!--界面标题-->
<Border CornerRadius="0,0,0,0" Grid.ColumnSpan="6" Background="#FF243664" >
<TextBlock Text="PM Coating Thickness" FontSize="15" Foreground="White" HorizontalAlignment="Center" Padding="8,0,0,0"/>
</Border >
<!--首行标签-->
<Border Grid.Row="1" Padding="5,1,0,1" BorderThickness="1,0,1,1" >
<TextBlock Text="Component" />
</Border>
<Border Grid.Row="1" Grid.Column="1" Padding="5,1,0,1" BorderThickness="0,0,1,1" >
<TextBlock Text="SN"/>
</Border>
<Border Grid.Row="1" Grid.Column="2" Padding="5,1,0,1" BorderThickness="0,0,1,1" >
<TextBlock Text="Coating"/>
</Border>
<Border Grid.Row="1" Grid.Column="3" Padding="5,1,0,1" BorderThickness="0,0,1,1" >
<TextBlock Text="MAX"/>
</Border>
<!--对象行-->
<Border Grid.Row="2" Padding="5,1,0,1" BorderThickness="1,0,1,1" >
<TextBlock Text="{Binding PMData.MinorCycle.Caption}"/>
</Border>
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding PMData.MinorCycle.SerialNumber}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="LostFocus">
<micro:ActionMessage MethodName="LoadCoatingData">
<micro:Parameter Value="MinorCycle" />
</micro:ActionMessage>
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBox>
<TextBox Grid.Row="2" Grid.Column="2" Text="{Binding PMData.MinorCycle.Current}" TextChanged="TextBox_TextChanged" />
<TextBox Grid.Row="2" Grid.Column="3" Text="{Binding PMData.MinorCycle.MAX}" TextChanged="TextBox_TextChanged"/>
<Border Grid.Row="3" Padding="5,1,0,1" BorderThickness="1,1,1,1" >
<TextBlock Text="{Binding PMData.MajorCycle.Caption}"/>
</Border>
<TextBox Grid.Row="3" Grid.Column="1" Text="{Binding PMData.MajorCycle.SerialNumber}" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="LostFocus">
<micro:ActionMessage MethodName="LoadCoatingData">
<micro:Parameter Value="MajorCycle" />
</micro:ActionMessage>
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBox>
<TextBox Grid.Row="3" Grid.Column="2" Text="{Binding PMData.MajorCycle.Current}" TextChanged="TextBox_TextChanged"/>
<TextBox Grid.Row="3" Grid.Column="3" Text="{Binding PMData.MajorCycle.MAX}" TextChanged="TextBox_TextChanged"/>
<Grid Grid.Row="1" Grid.Column="4" Grid.RowSpan="3">
<Button
Content="SET"
HorizontalAlignment="Center" VerticalAlignment="Center">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<micro:ActionMessage MethodName="SET">
</micro:ActionMessage>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</Grid>
</Grid>
<!--</Viewbox>-->
</Window>
@@ -0,0 +1,39 @@
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.TrayThickness
{
/// <summary>
/// WinPMThicknessDataView.xaml 的交互逻辑
/// </summary>
public partial class WinPMThicknessDataView : Window
{
public WinPMThicknessDataView()
{
InitializeComponent();
}
private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
{
TextBox textBox = sender as TextBox;
double input;
if (!double.TryParse(textBox.Text, out input))
textBox.Foreground = Brushes.Red;
else if (input < 0 || input > 9999999)
textBox.Foreground = Brushes.Red;
else
textBox.Foreground = Brushes.Black;
}
}
}
@@ -0,0 +1,46 @@
using MECF.Framework.Common.OperationCenter;
using MECF.Framework.UI.Client.ClientBase;
using OpenSEMI.ClientBase;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MECF.Framework.UI.Client.TrayThickness
{
public class WinPMThicknessDataViewModel : UiViewModelBase
{
PMDataViewManager pmDataViewManager;
string trayID;
public PMCoatingThickness PMData { get; set; }
public WinPMThicknessDataViewModel(string _pmGuid)
{
PMData = new PMCoatingThickness(_pmGuid);
pmDataViewManager = new PMDataViewManager(PMData, _pmGuid);
UpTrayCoatingThickness();
}
public void UpTrayCoatingThickness()//打开时,初始化界面数据
{
pmDataViewManager.UpTrayCoatingThickness();
}
public void SET()//设置到数据库
{
if (pmDataViewManager.SET(out var reason))
{
DialogBox.ShowInfo("MinorCycle Info. created successfully!");
TryClose();
}
else
{
DialogBox.ShowError(reason);
}
}
public void LoadCoatingData(string part)//人工输入名称后,查询数据
{
pmDataViewManager.LoadCoatingData(part);
Refresh();
}
}
}
@@ -0,0 +1,97 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace MECF.Framework.UI.Client.TrayThickness
{
public class PMCoatingThickness : ICloneable
{
private readonly List<CoatingData> _dataList;
#region Constructors
public PMCoatingThickness()
{
MinorCycle = new CoatingData();
MajorCycle = new CoatingData();
_dataList = new List<CoatingData>(
new[]
{
MinorCycle, MajorCycle
});
}
public PMCoatingThickness(string pmGuId)
{
PMGuid = pmGuId;//PM的默认数据库ID为MP
MinorCycle = new CoatingData($"{pmGuId}小周期", pmGuId);
MajorCycle = new CoatingData($"{pmGuId}大周期", pmGuId);
MinorCycle.PmOwned = pmGuId;
MajorCycle.PmOwned = pmGuId;
_dataList = new List<CoatingData>(
new[]
{
MinorCycle, MajorCycle
});
}
#endregion
#region Properties
public string PMGuid { get; set; }
/// <summary>
/// PM小周期厚度对象
/// </summary>
public CoatingData MinorCycle { get; set; }
/// <summary>
/// PM大周期厚度对象
/// </summary>
public CoatingData MajorCycle { get; set; }
#endregion
#region Methods
public bool Validate(out string reason)
{
if (!MinorCycle.Validate(out reason))
return false;
if (!MajorCycle.Validate(out reason))
return false;
//每个环Number数据是否存在相同,Linq语句检查
if (_dataList.GroupBy(i => i.SerialNumber).Any(g => g.Count() > 1))
{
reason = $"some of components have same SN, please check.";
return false;
}
return true;
}
public void Update(PMCoatingThickness newData)
{
MinorCycle.Update(newData.MinorCycle);
MajorCycle.Update(newData.MajorCycle);
}
public object Clone()
{
var newObj = new PMCoatingThickness(PMGuid);
newObj.MinorCycle = (CoatingData)MinorCycle.Clone();
newObj.MajorCycle = (CoatingData)MajorCycle.Clone();
return newObj;
}
#endregion
}
}
@@ -0,0 +1,122 @@
using MECF.Framework.Common.Equipment;
using MECF.Framework.Common.OperationCenter;
using MECF.Framework.UI.Client.ClientBase;
using OpenSEMI.ClientBase;
using OpenSEMI.Ctrlib.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
namespace MECF.Framework.UI.Client.TrayThickness
{
public class TrayDataViewManager
{
TrayCoatingThickness TrayData;
TrayDataViewSqlHelp trayDataHelp = new TrayDataViewSqlHelp();
private string TrayID;
public TrayDataViewManager(TrayCoatingThickness trayData, string trayID)
{
TrayData = trayData;
TrayID = trayID;
}
public void UpTrayCoatingThickness()
{
TrayCoatingThickness _trayCoatingThickness = trayDataHelp.GetTrayCoatingThickness(TrayID);
TrayData.Tray.Update(_trayCoatingThickness.Tray);
TrayData.TrayInner.Update(_trayCoatingThickness.TrayInner);
TrayData.RingInner.Update(_trayCoatingThickness.RingInner);
TrayData.RingOuter.Update(_trayCoatingThickness.RingOuter);
}
/// <summary>
/// 界面数据设置到数据库
/// </summary>
public bool SET(out string reason)
{
reason = "";
// 校验托盘组件数据
if (!TrayData.Validate(out reason))
return false;
List<CoatingData> coatingDataList = new List<CoatingData>()
{
TrayData.Tray,
TrayData.TrayInner,
TrayData.RingInner,
TrayData.RingOuter
};
//检查单个环对象是否存在空数据
foreach (var item in coatingDataList)
{
if (item.GetType().GetProperties()
.Where(pi => pi.PropertyType == typeof(string))
.Select(pi => (string)pi.GetValue(item))
.Any(string.IsNullOrEmpty))
{
reason = $"Please check empty value";
return false;
}
}
var ret = trayDataHelp.UpTrayNumberData(TrayData, TrayID, coatingDataList);
if (!ret)
reason = "Failed to write tray Info. to database.";
if(ret)
{
foreach (CoatingData coatingData in coatingDataList)
{
string name = coatingData.SerialNumber;
string coating = coatingData.Current;
string coatingMax = coatingData.MAX;
InvokeClient.Instance.Service.DoOperation("GEM_UpdateCoating",
name,coating, coatingMax);
}
}
return ret;
}
/// <summary>
/// 用户输入数据时,去数据库查询更新到界面
/// </summary>
/// <param name="part"></param>
public void LoadCoatingData(string part)
{
switch (part)
{
case "Tray":
ForUpCoatingData(TrayData.Tray.SerialNumber, TrayData.Tray);
break;
case "TrayInner":
ForUpCoatingData(TrayData.TrayInner.SerialNumber, TrayData.TrayInner);
break;
case "RingInner":
ForUpCoatingData(TrayData.RingInner.SerialNumber, TrayData.RingInner);
break;
case "RingOuter":
ForUpCoatingData(TrayData.RingOuter.SerialNumber, TrayData.RingOuter);
break;
default:
break;
}
}
private void ForUpCoatingData(string number, CoatingData data)
{
var coatingData = trayDataHelp.GetCoatingData(number, out var isExistedInDb);
if (isExistedInDb)
{
data.Update(coatingData);
}
}
}
}
@@ -0,0 +1,173 @@
using MECF.Framework.Common.DataCenter;
using System;
using System.Collections.Generic;
using System.Data;
namespace MECF.Framework.UI.Client.TrayThickness
{
/// <summary>
/// TrayDataViewSqlHelp
/// 1:查询整个Tray对象数据
/// 2:插入或者更新整个Tray对象数据
/// </summary>
public class TrayDataViewSqlHelp
{
private string tray_number, tray_inner_number, ring_inner_number, ring_outer_number;
/// <summary>
/// 获取Truy对象整体的数据
/// </summary>
/// <param name="_trayGuid"></param>
/// <returns></returns>
public TrayCoatingThickness GetTrayCoatingThickness(string _trayGuid)
{
//这是一次查询一个对象
TrayCoatingThickness trayCoatingThickness = new TrayCoatingThickness();
try
{
//根据TrayID获取对应内外编号
string cmdID = $"select * from tray_thickness_data where tray_guid = '{_trayGuid}'";
DataTable DataTable = QueryDataClient.Instance.Service.QueryData(cmdID);
if (DataTable != null && DataTable.Rows.Count > 0)
{
tray_number = DataTable.Rows[0]["tray_number"].ToString();
tray_inner_number = DataTable.Rows[0]["tray_inner_number"].ToString();
ring_inner_number = DataTable.Rows[0]["ring_inner_number"].ToString();
ring_outer_number = DataTable.Rows[0]["ring_outer_number"].ToString();
trayCoatingThickness.Tray = GetCoatingData(tray_number, out _);
trayCoatingThickness.TrayInner = GetCoatingData(tray_inner_number, out _);
trayCoatingThickness.RingInner = GetCoatingData(ring_inner_number, out _);
trayCoatingThickness.RingOuter = GetCoatingData(ring_outer_number, out _);
}
return trayCoatingThickness;
}
catch (Exception)
{
return trayCoatingThickness;
}
}
/// <summary>
/// 获取单个环的数据
/// </summary>
/// <param name="sn"></param>
/// <param name="isExistedInDb"></param>
/// <returns></returns>
public CoatingData GetCoatingData(string sn, out bool isExistedInDb)
{
var cmd = $"select * from tray_thickness_main where tray_number = '{sn}' ORDER BY create_time DESC LIMIT 1";
var dt = QueryDataClient.Instance.Service.QueryData(cmd);
if (dt is { Rows.Count: > 0 })
{
var coatingData = new CoatingData()
{
SerialNumber = dt.Rows[0]["tray_number"].ToString(),
MAX = dt.Rows[0]["tray_max_thickness"].ToString(),
PmOwned = dt.Rows[0]["pm_number"].ToString(),
Current = dt.Rows[0]["tray_coating_thickness"].ToString()
};
isExistedInDb = true;
return coatingData;
}
isExistedInDb = false;
return new CoatingData();
}
/// <summary>
/// 保存用户输入的数据到数据库
/// </summary>
/// <param name="trayCoatingThickness"></param>
/// <param name="trayUid"></param>
public bool UpTrayNumberData(TrayCoatingThickness trayCoatingThickness, string trayUid, List<CoatingData> coatingData)
{
List<string> cmdList = new List<string>();
string cmdID = $"select * from tray_thickness_data where tray_guid = '{trayUid}'";
var dt = QueryDataClient.Instance.Service.QueryData(cmdID);
if (dt is { Rows.Count: > 0 })
cmdList.Add(Cmd_update(trayCoatingThickness, trayUid));
else
cmdList.Add(Cmd_data_insert(trayCoatingThickness, trayUid));
foreach (var item in coatingData)
{
cmdList.Add(Cmd_main_insert(item));
}
bool result= QueryDataClient.Instance.Service.ExcuteTransAction(cmdList);
return result;
}
public bool GetPartSnByTrayUid(string trayUid, out List<CoatingData> coatingData)
{
coatingData = new List<CoatingData>();
var sql =
$"select tray_number, tray_inner_number, ring_inner_number, ring_outer_number from tray_thickness_data WHERE tray_guid = '{trayUid}' limit 1";
var dt = QueryDataClient.Instance.Service.QueryData(sql);
if (dt is { Rows.Count: > 0 })
{
//partSnList.Add();
}
return false;
}
/// <summary>
/// Tray中对象编号插入Sql语句拼接
/// </summary>
/// <param name="trayCoatingThickness"></param>
/// <param name="trayID"></param>
/// <returns></returns>
private string Cmd_data_insert(TrayCoatingThickness trayCoatingThickness,string trayID)
{
string cmd_data_insert =
"insert into tray_thickness_data" +
"(tray_guid,tray_number, tray_inner_number, ring_inner_number, ring_outer_number)" +
$"values ('{trayID}'," +
$"'{trayCoatingThickness.Tray.SerialNumber}'," +
$"'{trayCoatingThickness.TrayInner.SerialNumber}'," +
$"'{trayCoatingThickness.RingInner.SerialNumber}'," +
$"'{trayCoatingThickness.RingOuter.SerialNumber}')";
return cmd_data_insert;
}
/// <summary>
/// Tray中对象编号更新Sql语句拼接
/// </summary>
/// <param name="trayCoatingThickness"></param>
/// <param name="trayID"></param>
/// <returns></returns>
private string Cmd_update(TrayCoatingThickness trayCoatingThickness, string trayID)
{
string cmd_update =
$"update tray_thickness_data set " +
$"tray_number = '{trayCoatingThickness.Tray.SerialNumber}', " +
$"tray_inner_number= '{trayCoatingThickness.TrayInner.SerialNumber}'," +
$"ring_inner_number= '{trayCoatingThickness.RingInner.SerialNumber}'," +
$"ring_outer_number= '{trayCoatingThickness.RingOuter.SerialNumber}'" +
$"where tray_guid = '{trayID}'";
return cmd_update;
}
/// <summary>
/// 每个环对应的数据插入Sql语句拼接
/// </summary>
/// <param name="coatingData"></param>
/// <returns></returns>
private string Cmd_main_insert(CoatingData coatingData)
{
return "insert into tray_thickness_main" +
"(tray_guid,tray_number,pm_number, tray_coating_thickness, tray_max_thickness,tray_label,create_time)" +
$"values ('{Guid.NewGuid()}'," +
$"'{coatingData.SerialNumber}'," +
$"'{coatingData.PmOwned}'," +
$"'{coatingData.Current}'," +
$"'{coatingData.MAX}'," +
$"'{coatingData.Caption}'," +
$"'{coatingData.CreatTime}')";
}
}
}
@@ -0,0 +1,163 @@
<Window x:Class="MECF.Framework.UI.Client.TrayThickness.WinTrayThicknessDataView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
xmlns:micro="clr-namespace:Caliburn.Micro"
xmlns:cal="http://www.caliburn.org"
xmlns:local="clr-namespace:MECF.Framework.UI.Client.TrayThickness"
mc:Ignorable="d"
Height="220" Width="800" >
<Window.Resources>
<Style TargetType="TextBlock" >
<Setter Property="FontSize" Value="13" />
<Setter Property="TextAlignment" Value="Center" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="TextWrapping" Value="Wrap" />
<Setter Property="Margin" Value="3"/>
<Setter Property="FontFamily" Value="Arial Black"/>
</Style>
<Style TargetType="Border">
<Setter Property="Background" Value="{DynamicResource Table_BG_Title}" />
<Setter Property="BorderBrush" Value="Gray"/>
<Setter Property="SnapsToDevicePixels" Value="True"/>
</Style>
</Window.Resources>
<Grid >
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
<RowDefinition/>
<RowDefinition Height="0"/>
<RowDefinition/>
<RowDefinition Height="0"/>
<RowDefinition/>
<RowDefinition Height="0"/>
<RowDefinition/>
<RowDefinition Height="3"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<!--界面标题-->
<Border CornerRadius="0,0,0,0" Grid.ColumnSpan="6" Background="#FF243664" >
<TextBlock Text="Tray Coating Thickness" FontSize="15" Foreground="White" HorizontalAlignment="Center" Padding="8,0,0,0"/>
</Border >
<!--首行标签-->
<Border Grid.Row="1" Padding="5,1,0,1" BorderThickness="1,0,1,1" >
<TextBlock Text="Component" />
</Border>
<Border Grid.Row="1" Grid.Column="1" Padding="5,1,0,1" BorderThickness="0,0,1,1" >
<TextBlock Text="SN"/>
</Border>
<Border Grid.Row="1" Grid.Column="2" Padding="5,1,0,1" BorderThickness="0,0,1,1" >
<TextBlock Text="Coating"/>
</Border>
<Border Grid.Row="1" Grid.Column="3" Padding="5,1,0,1" BorderThickness="0,0,1,1" >
<TextBlock Text="MAX"/>
</Border>
<Border Grid.Row="1" Grid.Column="4" Padding="5,1,0,1" BorderThickness="0,0,1,1" >
<TextBlock Text="PM"/>
</Border>
<!--对象行-->
<Border Grid.Row="2" Padding="5,1,0,1" BorderThickness="1,0,1,1" >
<TextBlock Text="{Binding TrayData.Tray.Caption}"/>
</Border>
<TextBox Grid.Row="2" Grid.Column="1" Text="{Binding TrayData.Tray.SerialNumber}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="LostFocus">
<micro:ActionMessage MethodName="LoadCoatingData">
<micro:Parameter Value="Tray" />
</micro:ActionMessage>
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBox>
<TextBox Grid.Row="2" Grid.Column="2" Text="{Binding TrayData.Tray.Current}" TextChanged="TextBox_TextChanged" />
<TextBox Grid.Row="2" Grid.Column="3" Text="{Binding TrayData.Tray.MAX}" TextChanged="TextBox_TextChanged"/>
<ComboBox SelectedItem="{Binding PmOwned}" Grid.Row="2" Grid.Column="4" ItemsSource="{Binding PmsList}" />
<Border Grid.Row="4" Padding="5,1,0,1" BorderThickness="1,1,1,1" >
<TextBlock Text="{Binding TrayData.TrayInner.Caption}"/>
</Border>
<TextBox Grid.Row="4" Grid.Column="1" Text="{Binding TrayData.TrayInner.SerialNumber}" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="LostFocus">
<micro:ActionMessage MethodName="LoadCoatingData">
<micro:Parameter Value="TrayInner" />
</micro:ActionMessage>
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBox>
<TextBox Grid.Row="4" Grid.Column="2" Text="{Binding TrayData.TrayInner.Current}" TextChanged="TextBox_TextChanged"/>
<TextBox Grid.Row="4" Grid.Column="3" Text="{Binding TrayData.TrayInner.MAX}" TextChanged="TextBox_TextChanged"/>
<TextBox Grid.Row="4" Grid.Column="4" Text="{Binding PmOwned}" IsReadOnly="True" Background="LightGray"/>
<Border Grid.Row="6" Padding="5,1,0,1" BorderThickness="1,1,1,1" >
<TextBlock Text="{Binding TrayData.RingInner.Caption}"/>
</Border>
<TextBox Grid.Row="6" Grid.Column="1" Text="{Binding TrayData.RingInner.SerialNumber}" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="LostFocus">
<micro:ActionMessage MethodName="LoadCoatingData">
<micro:Parameter Value="RingInner" />
</micro:ActionMessage>
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBox>
<TextBox Grid.Row="6" Grid.Column="2" Text="{Binding TrayData.RingInner.Current}" TextChanged="TextBox_TextChanged"/>
<TextBox Grid.Row="6" Grid.Column="3" Text="{Binding TrayData.RingInner.MAX}" TextChanged="TextBox_TextChanged"/>
<TextBox Grid.Row="6" Grid.Column="4" Text="{Binding PmOwned}" IsReadOnly="True" Background="LightGray"/>
<Border Grid.Row="8" Padding="5,1,0,1" BorderThickness="1,1,1,1" >
<TextBlock Text="{Binding TrayData.RingOuter.Caption}"/>
</Border>
<TextBox Grid.Row="8" Grid.Column="1" Text="{Binding TrayData.RingOuter.SerialNumber}" >
<i:Interaction.Triggers>
<i:EventTrigger EventName="LostFocus">
<micro:ActionMessage MethodName="LoadCoatingData">
<micro:Parameter Value="RingOuter" />
</micro:ActionMessage>
</i:EventTrigger>
</i:Interaction.Triggers>
</TextBox>
<TextBox Grid.Row="8" Grid.Column="2" Text="{Binding TrayData.RingOuter.Current}" TextChanged="TextBox_TextChanged"/>
<TextBox Grid.Row="8" Grid.Column="3" Text="{Binding TrayData.RingOuter.MAX}" TextChanged="TextBox_TextChanged"/>
<TextBox Grid.Row="8" Grid.Column="4" Text="{Binding PmOwned}" IsReadOnly="True" Background="LightGray"/>
<Grid Grid.Row="1" Grid.Column="5" Grid.RowSpan="8">
<Button
Content="SET"
HorizontalAlignment="Center" VerticalAlignment="Center">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<micro:ActionMessage MethodName="SET">
</micro:ActionMessage>
</i:EventTrigger>
</i:Interaction.Triggers>
</Button>
</Grid>
</Grid>
<!--</Viewbox>-->
</Window>
@@ -0,0 +1,29 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Media;
namespace MECF.Framework.UI.Client.TrayThickness
{
/// <summary>
/// WinTrayThicknessDataView.xaml 的交互逻辑
/// </summary>
public partial class WinTrayThicknessDataView : Window
{
public WinTrayThicknessDataView()
{
InitializeComponent();
}
private void TextBox_TextChanged(object sender, TextChangedEventArgs e)
{
TextBox textBox = sender as TextBox;
double input;
if (!double.TryParse(textBox.Text, out input))
textBox.Foreground= Brushes.Red;
else if (input < 0 || input > 9999999)
textBox.Foreground = Brushes.Red;
else
textBox.Foreground = Brushes.Black;
}
}
}
@@ -0,0 +1,83 @@
using MECF.Framework.Common.Equipment;
using MECF.Framework.Common.OperationCenter;
using MECF.Framework.Common.SubstrateTrackings;
using MECF.Framework.UI.Client.ClientBase;
using OpenSEMI.ClientBase;
using OpenSEMI.Ctrlib.Controls;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Windows;
using System.Windows.Forms.VisualStyles;
using System.Windows.Threading;
namespace MECF.Framework.UI.Client.TrayThickness
{
public class WinTrayThicknessDataViewModel : UiViewModelBase
{
TrayDataViewManager trayDataViewManager;
private ModuleName MoudleName;
private int Sloat;
public TrayCoatingThickness TrayData { get; set; }
public List<string> PmsList { get; set; } = new List<string>() { "PM1", "PM2" };
private string pmOwned;
public string PmOwned
{
get { return pmOwned; }
set
{
pmOwned = value;
Refresh();
}
}
public WinTrayThicknessDataViewModel(string _trayGuid, ModuleName moudleName, int sloat)
{
MoudleName = moudleName;
Sloat = sloat;
TrayData = new TrayCoatingThickness(_trayGuid);
trayDataViewManager = new TrayDataViewManager(TrayData, _trayGuid);
UpTrayCoatingThickness();
}
public void UpTrayCoatingThickness()//打开时,初始化界面数据
{
trayDataViewManager.UpTrayCoatingThickness();
PmOwned = TrayData.Tray.PmOwned;
}
public void SET()//设置到数据库
{
if (PmOwned is not null && PmOwned.Contains("PM"))
{
TrayData.Tray.PmOwned = PmOwned;
TrayData.TrayInner.PmOwned = PmOwned;
TrayData.RingInner.PmOwned = PmOwned;
TrayData.RingOuter.PmOwned = PmOwned;
}
if (trayDataViewManager.SET(out var reason))
{
InvokeClient.Instance.Service.DoOperation("UpdatTrayBelongTo", MoudleName, Sloat, TrayData.Tray.PmOwned);
DialogBox.ShowInfo("MinorCycle Info. created successfully!");
TryClose();
}
else
{
DialogBox.ShowError(reason);
}
}
public void LoadCoatingData(string part)//人工输入名称后,查询数据
{
trayDataViewManager.LoadCoatingData(part);
PmOwned = TrayData.Tray.PmOwned;
Refresh();
}
}
}
@@ -0,0 +1,124 @@
using System;
using System.Collections.Generic;
using System.Linq;
namespace MECF.Framework.UI.Client.TrayThickness
{
public class TrayCoatingThickness : ICloneable
{
private readonly List<CoatingData> _dataList;
#region Constructors
public TrayCoatingThickness()
{
Tray = new CoatingData();
TrayInner = new CoatingData();
RingInner = new CoatingData();
RingOuter = new CoatingData();
_dataList = new List<CoatingData>(
new []
{
Tray, TrayInner, RingInner, RingOuter
});
}
public TrayCoatingThickness(string trayGuId)
{
TrayGuid = trayGuId; //Tary的默认数据库ID为自身编号1~8
Tray = new CoatingData($"石墨托盘", trayGuId);
TrayInner = new CoatingData($"内部托架", trayGuId);
RingInner = new CoatingData($"中间托架", trayGuId);
RingOuter = new CoatingData($"外部托架", trayGuId);
_dataList = new List<CoatingData>(
new[]
{
Tray, TrayInner, RingInner, RingOuter
});
}
//public TrayCoatingThickness(int slot) : this(slot.ToString())
//{
//}
#endregion
#region Properties
public string TrayGuid { get; set; }
/// <summary>
/// Tray厚度对象
/// </summary>
public CoatingData Tray { get; set; }
/// <summary>
/// Tray内环厚度对象
/// </summary>
public CoatingData TrayInner { get; set; }
/// <summary>
/// Ring内环厚度对象
/// </summary>
public CoatingData RingInner { get; set; }
/// <summary>
/// Ring外环厚度对象
/// </summary>
public CoatingData RingOuter { get; set; }
#endregion
#region Methods
public bool Validate(out string reason)
{
if (!Tray.Validate(out reason))
return false;
if(!TrayInner.Validate(out reason))
return false;
if(!RingInner.Validate(out reason))
return false;
if (!RingOuter.Validate(out reason))
return false;
//每个环Number数据是否存在相同,Linq语句检查
if (_dataList.GroupBy(i => i.SerialNumber).Any(g => g.Count() > 1))
{
reason = $"some of components have same SN, please check.";
return false;
}
return true;
}
public void Update(TrayCoatingThickness newData)
{
Tray.Update(newData.Tray);
TrayInner.Update(newData.TrayInner);
RingInner.Update(newData.RingInner);
RingOuter.Update(newData.RingOuter);
}
public object Clone()
{
var newObj = new TrayCoatingThickness(TrayGuid);
newObj.Tray = (CoatingData)Tray.Clone();
newObj.TrayInner = (CoatingData)TrayInner.Clone();
newObj.RingInner = (CoatingData)RingInner.Clone();
newObj.RingOuter = (CoatingData)RingOuter.Clone();
return newObj;
}
#endregion
}
}