Sic.Framework-Nanjing-Baishi/MECF.Framework.UI.Client/CenterViews/DataLogs/ProcessHistory/ProcessHistoryTestViewModel.cs

163 lines
5.5 KiB
C#
Raw Normal View History

2023-11-30 13:42:06 +08:00
using MECF.Framework.UI.Client.ClientBase;
using System.Windows.Controls;
2023-11-30 13:42:06 +08:00
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using MECF.Framework.UI.Client.TrayThickness.HistoryData;
using Caliburn.Micro;
using MECF.Framework.UI.Client.CenterViews.Editors.Recipe;
using System.Dynamic;
using System.Windows;
using MECF.Framework.Common.DataCenter;
using System.Reflection;
using MECF.Framework.Common.Aitex.Core.Common.DeviceData;
using MECF.Framework.RT.EquipmentLibrary.HardwareUnits.GasFlow;
using Sicentury.Core.EventArgs;
using Sicentury.Core;
2023-11-30 13:42:06 +08:00
namespace MECF.Framework.UI.Client.CenterViews.DataLogs.ProcessHistory
{
public class ProcessHistoryTestViewModel : UiViewModelBase
{
/// <summary>
/// 返回ViewModel绑定的视图对象。
/// </summary>
public UserControl View { get; private set; }
public DateTime StartDateTime
{
get => ((ProcessHistoryTestView)View).wfTimeFrom.Value;
set
{
((ProcessHistoryTestView)View).wfTimeFrom.Value = value;
NotifyOfPropertyChange(nameof(StartDateTime));
}
}
public DateTime EndDateTime
{
get => ((ProcessHistoryTestView)View).wfTimeTo.Value;
set
{
((ProcessHistoryTestView)View).wfTimeTo.Value = value;
NotifyOfPropertyChange(nameof(EndDateTime));
}
}
public List<string> PmList { get; set; }
public string CbSelect { get;set; }
public RecipeProcessHistoryData RecipeProcessHistoryData { get; set; }
public List<ProcessHistoryData> ProcessHistoryDataList { get;set; }
public ProcessHistoryData SelectProcessHistoryData { get;set; }
public List<ProcessHistoryDeviceData> ProcessHistoryDeviceDataList { get; set; }
public ProcessHistoryDeviceData SelectProcessHistoryDeviceData { get; set; }
private ProcessHistoryItemsDefault ProcessHistoryItemsDefault = new ProcessHistoryItemsDefault();
protected override void OnViewLoaded(object _view)
{
base.OnViewLoaded(_view);
View = (UserControl)_view;
IniUIData();
}
private void IniUIData()
{
PmList = new List<string>();
for (int i = 1; i <= 2; i++)
{
if ((bool)QueryDataClient.Instance.Service.GetConfig($"PM.PM{i}.TMAEnable"))
PmList.Add($"PM{i}");
}
if (PmList.Count > 0)
CbSelect = PmList[0];
StartDateTime = DateTime.Now.Date;
EndDateTime = DateTime.Now.Date.AddDays(1).AddTicks(-1);
Refresh();
}
public void QueryRecipeProcessHistory()
{
if (StartDateTime > EndDateTime)
{
MessageBox.Show("time range invalid, start time should be early than end time.", "Error",
MessageBoxButton.OK,
MessageBoxImage.Error);
return;
}
var dialog = new ProcessHistoryInfMessageBoxViewModel(StartDateTime.ToString(), EndDateTime.ToString(), CbSelect);
var wm = new WindowManager();
dynamic settings = new ExpandoObject();
settings.WindowStartupLocation = WindowStartupLocation.CenterOwner;
settings.Title = "Recipe历史生产数据选择";
settings.ResizeMode = ResizeMode.NoResize;
settings.ShowInTaskbar = false;
var bret = wm.ShowDialog(dialog, null, settings);
if ((bool)bret)
{
if (dialog.RecipeProcessHistoryData == null)
return;
RecipeProcessHistoryData = dialog.RecipeProcessHistoryData;
ProcessHistoryDataList = ProcessHistorySqlHelp.QueryProcessHistoryData(dialog.RecipeProcessHistoryData.ProcessGuid, dialog.RecipeProcessHistoryData.Name);
Refresh();
}
}
public void DoubleClickItem()
{
Query(SelectProcessHistoryData);
Refresh();
}
public void QuerDeviceData()
{
}
public void Query( ProcessHistoryData processHistoryData)
{
var daySlices = DateRangeHelper.SplitInToHours(new DateRangeHelper( Convert.ToDateTime( processHistoryData.StepBeginTime), Convert.ToDateTime(processHistoryData.StepEndTime)), 12);
List<List<GasFlowSum>> gasFlowRunVent = new List<List<GasFlowSum>>();
//按天查询数据库单天返回数据类型为List<GasFlowSum>
ProcessHistoryDeviceDataList = ProcessHistorySqlHelp.GetProcessHistoryDeviceData(daySlices, CbSelect, ProcessHistoryItemsDefault.ItemList);
////解析数据库返回的数据
//foreach (var items in gasFlowRunVent)
//{
// foreach (var item in items)
// {
// var gasFlowSum = dayGasFlowList.Where(obj => item.Name.Contains(obj.Name)).First();
// if (item.Name.Contains("Run"))
// gasFlowSum.RunVolume += item.Volume;
// else
// gasFlowSum.VentVolume += item.Volume;
// }
//}
//使用公式转换单位
//_busyIndicatorContentExport.Report(new ProgressUpdatingEventArgs(100, 100, ""));
}
2023-11-30 13:42:06 +08:00
}
}