2023-05-22 18:32:18 +08:00
|
|
|
|
using Aitex.Core.RT.OperationCenter;
|
2023-05-25 13:31:57 +08:00
|
|
|
|
|
2023-05-22 18:32:18 +08:00
|
|
|
|
using MECF.Framework.UI.Client.ClientBase;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2023-05-24 13:17:09 +08:00
|
|
|
|
using System.Globalization;
|
2023-05-22 18:32:18 +08:00
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
2023-05-25 13:31:57 +08:00
|
|
|
|
using System.Windows;
|
|
|
|
|
using System.Windows.Controls;
|
2023-05-24 13:17:09 +08:00
|
|
|
|
using System.Windows.Data;
|
|
|
|
|
using System.Windows.Media;
|
2023-05-22 18:32:18 +08:00
|
|
|
|
|
|
|
|
|
namespace MECF.Framework.UI.Client.TrayThickness.HistoryData
|
|
|
|
|
{
|
|
|
|
|
public class HistoryDataViewModel : UiViewModelBase, ISupportMultipleSystem
|
|
|
|
|
{
|
2023-05-25 13:31:57 +08:00
|
|
|
|
/// <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));
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-05-22 18:32:18 +08:00
|
|
|
|
|
2023-05-25 13:31:57 +08:00
|
|
|
|
public DateTime EndDateTime
|
|
|
|
|
{
|
|
|
|
|
get => ((HistoryDataView)View).wfTimeTo.Value;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
((HistoryDataView)View).wfTimeTo.Value = value;
|
|
|
|
|
NotifyOfPropertyChange(nameof(EndDateTime));
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-07-10 16:48:49 +08:00
|
|
|
|
|
|
|
|
|
private bool isQueryTray = true;
|
|
|
|
|
//勾选查询Tray
|
|
|
|
|
public bool IsQueryTray
|
2023-06-09 17:20:52 +08:00
|
|
|
|
{
|
2023-07-10 16:48:49 +08:00
|
|
|
|
get => isQueryTray;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
isQueryTray = value;
|
|
|
|
|
Refresh();
|
|
|
|
|
}
|
2023-06-09 17:20:52 +08:00
|
|
|
|
}
|
2023-07-10 16:48:49 +08:00
|
|
|
|
|
|
|
|
|
private bool isQueryPM;
|
|
|
|
|
//勾选查询PM
|
|
|
|
|
public bool IsQueryPM
|
2023-06-09 17:20:52 +08:00
|
|
|
|
{
|
2023-07-10 16:48:49 +08:00
|
|
|
|
get => isQueryPM;
|
2023-06-09 17:20:52 +08:00
|
|
|
|
set
|
|
|
|
|
{
|
2023-07-10 16:48:49 +08:00
|
|
|
|
isQueryPM = value;
|
|
|
|
|
Refresh();
|
2023-06-09 17:20:52 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
2023-07-10 16:48:49 +08:00
|
|
|
|
|
2023-05-25 13:31:57 +08:00
|
|
|
|
public bool TimeChecked { get; set; }
|
|
|
|
|
|
2023-07-10 16:48:49 +08:00
|
|
|
|
public bool Unit { get; set; } = false;
|
|
|
|
|
|
|
|
|
|
public bool IsNotUnit => !Unit;
|
|
|
|
|
|
|
|
|
|
public bool Entirety { get; set; } = true;
|
|
|
|
|
|
|
|
|
|
//数据库查询对象实例
|
|
|
|
|
private HistoryCoatingSqlHelp HistoryCoatingSqlHelp = new HistoryCoatingSqlHelp();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//表示单行数据集合,Tray专用
|
2023-05-22 18:32:18 +08:00
|
|
|
|
public List<CoatingData> CoatingData { get; set; } = new List<CoatingData>();
|
2023-05-26 08:56:19 +08:00
|
|
|
|
|
2023-07-10 16:48:49 +08:00
|
|
|
|
//整个Tray对象数据集合,内含4个环
|
|
|
|
|
public List<TrayCoatingThickness> TrayCoatingList { get; set; } = new List<TrayCoatingThickness>();
|
|
|
|
|
|
|
|
|
|
//PM对象数据集合,内含大小周期
|
|
|
|
|
public List<PMCoatingThickness> PMCoatingList { get; set; } = new List<PMCoatingThickness>();
|
|
|
|
|
|
2023-05-25 13:31:57 +08:00
|
|
|
|
protected override void OnViewLoaded(object _view)
|
2023-05-22 18:32:18 +08:00
|
|
|
|
{
|
2023-05-25 13:31:57 +08:00
|
|
|
|
base.OnViewLoaded(_view);
|
|
|
|
|
View = (UserControl)_view;
|
|
|
|
|
StartDateTime = DateTime.Now.Date;
|
|
|
|
|
EndDateTime = DateTime.Now.Date.AddDays(1).AddTicks(-1);
|
|
|
|
|
|
2023-05-22 18:32:18 +08:00
|
|
|
|
}
|
2023-06-01 11:53:07 +08:00
|
|
|
|
public void QueryTime()
|
2023-05-22 18:32:18 +08:00
|
|
|
|
{
|
2023-05-25 13:31:57 +08:00
|
|
|
|
if (StartDateTime > EndDateTime)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("time range invalid, start time should be early than end time.", "Error",
|
|
|
|
|
MessageBoxButton.OK,
|
|
|
|
|
MessageBoxImage.Error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-06-09 17:20:52 +08:00
|
|
|
|
if (IsQueryTray)
|
2023-07-10 16:48:49 +08:00
|
|
|
|
TrayCoatingList = HistoryCoatingSqlHelp.QueryUpdateTime_Tray(StartDateTime.ToString(), EndDateTime.ToString());
|
2023-06-09 17:20:52 +08:00
|
|
|
|
if (IsQueryPM)
|
2023-07-10 16:48:49 +08:00
|
|
|
|
PMCoatingList = HistoryCoatingSqlHelp.QueryUpdateTime_PM(StartDateTime.ToString(), EndDateTime.ToString());
|
2023-05-25 13:31:57 +08:00
|
|
|
|
Refresh();
|
|
|
|
|
}
|
|
|
|
|
public void QueryAll()
|
|
|
|
|
{
|
2023-06-09 17:20:52 +08:00
|
|
|
|
if (IsQueryTray)
|
2023-07-10 16:48:49 +08:00
|
|
|
|
TrayCoatingList = HistoryCoatingSqlHelp.QueryUpdateAll_Tray();
|
2023-06-09 17:20:52 +08:00
|
|
|
|
if (IsQueryPM)
|
2023-07-10 16:48:49 +08:00
|
|
|
|
PMCoatingList = HistoryCoatingSqlHelp.QueryUpdateAll_PM();
|
2023-05-25 13:31:57 +08:00
|
|
|
|
Refresh();
|
2023-05-22 18:32:18 +08:00
|
|
|
|
}
|
2023-05-26 08:56:19 +08:00
|
|
|
|
|
2023-05-25 13:31:57 +08:00
|
|
|
|
public void QueryName(string name)
|
2023-05-22 18:32:18 +08:00
|
|
|
|
{
|
2023-07-10 16:48:49 +08:00
|
|
|
|
if (name == null || name.Length == 0)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("输入名称为空");
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-05-25 13:31:57 +08:00
|
|
|
|
if (TimeChecked)
|
|
|
|
|
{
|
2023-05-26 08:56:19 +08:00
|
|
|
|
if (StartDateTime > EndDateTime)
|
|
|
|
|
{
|
|
|
|
|
MessageBox.Show("time range invalid, start time should be early than end time.", "Error",
|
|
|
|
|
MessageBoxButton.OK,
|
|
|
|
|
MessageBoxImage.Error);
|
|
|
|
|
return;
|
|
|
|
|
}
|
2023-05-25 13:31:57 +08:00
|
|
|
|
}
|
2023-06-09 17:20:52 +08:00
|
|
|
|
if (IsQueryTray)
|
|
|
|
|
{
|
|
|
|
|
if (Unit)
|
|
|
|
|
CoatingData = HistoryCoatingSqlHelp.QueryUnitName_Tray(name, StartDateTime.ToString(), EndDateTime.ToString());
|
|
|
|
|
else if (Entirety)
|
2023-07-10 16:48:49 +08:00
|
|
|
|
TrayCoatingList = HistoryCoatingSqlHelp.QueryEntiretyTray(name, StartDateTime.ToString(), EndDateTime.ToString());
|
2023-06-09 17:20:52 +08:00
|
|
|
|
else
|
|
|
|
|
CoatingData = HistoryCoatingSqlHelp.QueryUnitName_Tray(name, StartDateTime.ToString(), EndDateTime.ToString());
|
|
|
|
|
}
|
|
|
|
|
if (IsQueryPM)
|
2023-07-10 16:48:49 +08:00
|
|
|
|
PMCoatingList = HistoryCoatingSqlHelp.QueryUnitName_PM(name, StartDateTime.ToString(), EndDateTime.ToString());
|
2023-05-26 08:56:19 +08:00
|
|
|
|
|
2023-05-22 18:32:18 +08:00
|
|
|
|
Refresh();
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-05-25 13:31:57 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2023-05-24 13:17:09 +08:00
|
|
|
|
/// <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;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-07-10 16:48:49 +08:00
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-05-22 18:32:18 +08:00
|
|
|
|
}
|