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-06-09 17:20:52 +08:00
|
|
|
|
|
|
|
|
|
public bool IsQueryTray { get;set; }=true;
|
|
|
|
|
private bool _isQueryPM { get; set; }
|
|
|
|
|
public bool IsQueryPM
|
|
|
|
|
{
|
|
|
|
|
get => _isQueryPM;
|
|
|
|
|
set {
|
|
|
|
|
SelectPM = value ? Visibility.Collapsed: Visibility.Visible;
|
|
|
|
|
_isQueryPM = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private Visibility _selectPM { get; set; }
|
|
|
|
|
public Visibility SelectPM
|
|
|
|
|
{
|
|
|
|
|
get => _selectPM;
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
_selectPM = value;
|
|
|
|
|
NotifyOfPropertyChange(nameof(SelectPM));
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-05-25 13:31:57 +08:00
|
|
|
|
public bool TimeChecked { get; set; }
|
2023-05-31 09:41:56 +08:00
|
|
|
|
public bool Unit { get; set; } = true;
|
2023-05-25 13:31:57 +08:00
|
|
|
|
public bool Entirety { get; set; }
|
2023-05-26 08:56:19 +08:00
|
|
|
|
HistoryCoatingSqlHelp HistoryCoatingSqlHelp = new HistoryCoatingSqlHelp();
|
2023-05-25 13:31:57 +08:00
|
|
|
|
|
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-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)
|
|
|
|
|
CoatingData = HistoryCoatingSqlHelp.QueryUpdateTime_Tray(StartDateTime.ToString(), EndDateTime.ToString());
|
|
|
|
|
if (IsQueryPM)
|
|
|
|
|
CoatingData = 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)
|
|
|
|
|
CoatingData = HistoryCoatingSqlHelp.QueryUpdateAll_Tray();
|
|
|
|
|
if (IsQueryPM)
|
|
|
|
|
CoatingData = 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-05-26 18:15:17 +08:00
|
|
|
|
|
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)
|
|
|
|
|
CoatingData = HistoryCoatingSqlHelp.QueryEntiretyTray(name, StartDateTime.ToString(), EndDateTime.ToString());
|
|
|
|
|
else
|
|
|
|
|
CoatingData = HistoryCoatingSqlHelp.QueryUnitName_Tray(name, StartDateTime.ToString(), EndDateTime.ToString());
|
|
|
|
|
}
|
|
|
|
|
if (IsQueryPM)
|
|
|
|
|
CoatingData = 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-05-22 18:32:18 +08:00
|
|
|
|
}
|