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));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public bool TimeChecked { get; set; }
|
|
|
|
|
public bool Unit { get; set; }
|
|
|
|
|
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-05-25 13:31:57 +08:00
|
|
|
|
public void QueryTime(string time)
|
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;
|
|
|
|
|
}
|
|
|
|
|
CoatingData = HistoryCoatingSqlHelp.QueryUpdateTime(StartDateTime.ToString(), EndDateTime.ToString());
|
|
|
|
|
Refresh();
|
|
|
|
|
}
|
|
|
|
|
public void QueryAll()
|
|
|
|
|
{
|
|
|
|
|
CoatingData = HistoryCoatingSqlHelp.QueryUpdateAll();
|
|
|
|
|
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 08:56:19 +08:00
|
|
|
|
string _starTimme = "";
|
|
|
|
|
string _endTimme = "";
|
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;
|
|
|
|
|
}
|
|
|
|
|
_starTimme = StartDateTime.ToString();
|
|
|
|
|
_endTimme = EndDateTime.ToString();
|
2023-05-25 13:31:57 +08:00
|
|
|
|
}
|
2023-05-26 08:56:19 +08:00
|
|
|
|
|
|
|
|
|
if (Unit)
|
|
|
|
|
CoatingData = HistoryCoatingSqlHelp.QueryUnitName(name, _starTimme, _endTimme,true);
|
|
|
|
|
else if (Entirety)
|
|
|
|
|
CoatingData = HistoryCoatingSqlHelp.QueryEntirety(name, _starTimme, _endTimme,true);
|
2023-05-25 13:31:57 +08:00
|
|
|
|
else
|
2023-05-26 08:56:19 +08:00
|
|
|
|
CoatingData = HistoryCoatingSqlHelp.QueryUnitName(name);
|
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
|
|
|
|
}
|