You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
AUCMA_SCADA/Aucma.Core.OldBoxFoam/ViewModels/OldBoxFoamPageViewModel.cs

205 lines
7.2 KiB
C#

using Admin.Core.IService;
using Admin.Core.Model;
1 year ago
using Admin.Core.Model.Model_New;
using Admin.Core.Model.ViewModels;
using Admin.Core.Service;
using Admin.Core.Tasks;
using Aucma.Core.OldBoxFoam.Models;
using CommunityToolkit.Mvvm.ComponentModel;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
/**
* 线
* */
namespace Aucma.Core.OldBoxFoam.ViewModels
{
public partial class OldBoxFoamPageViewModel : ObservableObject
{
1 year ago
IBoxFoamDataServices? _oldBoxFoamDataServices;
IOldBoxFoamTypeServices _oldBoxFoamTypeServices;
1 year ago
public OldBoxFoamPageViewModel() {
1 year ago
_oldBoxFoamDataServices = App.ServiceProvider.GetService<IBoxFoamDataServices>();
_oldBoxFoamTypeServices = App.ServiceProvider.GetService<IOldBoxFoamTypeServices>();
1 year ago
Job_OldBoxFoam_Quartz.RefreshOldBoxFoamTypeDataDelegateEvent += OldBoxFoamTypeOnLoad3;
Job_OldBoxFoam_Quartz.RefreshOldBoxFoamDataDelegateEvent += OldBoxFoamOnLoad3;
1 year ago
Task.WaitAll(OldBoxFoamOnLoad(), OldBoxFoamTypeOnLoad());
}
#region 初始化加载数据
public async Task OldBoxFoamOnLoad()
{
1 year ago
List<BoxFoamData> list = await _oldBoxFoamDataServices.QueryAsync();
if (list == null) return;
1 year ago
int i = 0;
foreach (var item in list)
{
OldBoxFoamDataModel model = new OldBoxFoamDataModel();
model.ObjId = item.ObjId;
model.Fixtureboxtype = item.Fixtureboxtype;
model.Fixturestatus = item.Fixturestatus;
model.Production = item.Production;
model.CuringTimeSettingValue = item.CuringTimeSettingValue;
1 year ago
if (item.Fixturestatus == 1)//停止
{
_statusColor.Add("green");
}
else
{
_statusColor.Add("red");
}
_fixtureName.Add(item.Fixtureboxtype);
_production.Add(item.Production);
_beat.Add(item.BoxBeat);
i =+ item.Production;
}
1 year ago
_totle = list.Sum(d=>d.Production);
}
1 year ago
public Task OldBoxFoamOnLoad3(List<BoxFoamData> list)
1 year ago
{
if (list == null) return Task.CompletedTask;
System.Windows.Application.Current.Dispatcher.Invoke((Action)( () =>
{
OldBoxFoamDataGrid.Clear();
1 year ago
int i = 0;
1 year ago
foreach (var item in list)
{
OldBoxFoamDataModel model = new OldBoxFoamDataModel();
model.ObjId = item.ObjId;
model.Fixtureboxtype = item.Fixtureboxtype;
model.Fixturestatus = item.Fixturestatus;
model.Production = item.Production;
model.CuringTimeSettingValue = item.CuringTimeSettingValue;
1 year ago
if (item.Fixturestatus == 1)//停止
{
_statusColor.Add("green");
1 year ago
1 year ago
}
else
{
_statusColor.Add("red");
}
_fixtureName.Add(item.Fixtureboxtype);
_production.Add(item.Production);
_beat.Add(item.BoxBeat);
i = +item.Production;
1 year ago
}
}));
return Task.CompletedTask;
}
public async Task OldBoxFoamTypeOnLoad()
{
var list =await _oldBoxFoamTypeServices.QueryAsync();
if (list == null) return;
foreach (var item in list)
{
OldBoxFoamTypeModel model = new OldBoxFoamTypeModel();
model.ObjId = item.ObjId;
model.Local = item.Local;
model.Boxtype = item.Boxtype;
model.Storeamount = item.Storeamount;
1 year ago
_oldBoxFoamTypeDataGrid.Add(model);
}
}
1 year ago
public Task OldBoxFoamTypeOnLoad3(List<OldBoxFoamType> list)
{
if (list == null) return Task.CompletedTask;
System.Windows.Application.Current.Dispatcher.Invoke((Action)(() =>
{
OldBoxFoamTypeDataGrid.Clear();
foreach (var item in list)
{
OldBoxFoamTypeModel model = new OldBoxFoamTypeModel();
model.ObjId = item.ObjId;
model.Local = item.Local;
model.Boxtype = item.Boxtype;
model.Storeamount = item.Storeamount;
OldBoxFoamTypeDataGrid.Add(model);
}
}));
return Task.CompletedTask;
}
#endregion
#region 初始化发泡线 datagrid
1 year ago
private ObservableCollection<OldBoxFoamDataModel> _oldBoxFoamDataGrid = new ObservableCollection<OldBoxFoamDataModel>();
public ObservableCollection<OldBoxFoamDataModel> OldBoxFoamDataGrid
{
1 year ago
get => _oldBoxFoamDataGrid;
set => SetProperty(ref _oldBoxFoamDataGrid, value);
}
#endregion
#region 初始化泡前库 datagrid
1 year ago
private ObservableCollection<OldBoxFoamTypeModel> _oldBoxFoamTypeDataGrid = new ObservableCollection<OldBoxFoamTypeModel>();
public ObservableCollection<OldBoxFoamTypeModel> OldBoxFoamTypeDataGrid
{
1 year ago
get => _oldBoxFoamTypeDataGrid;
set => SetProperty(ref _oldBoxFoamTypeDataGrid, value);
}
#endregion
1 year ago
#region 夹具状态
private ObservableCollection<string> _statusColor = new ObservableCollection<string>();
public ObservableCollection<string> StatusColor
{
get => _statusColor;
set => SetProperty(ref _statusColor, value);
}
#endregion
#region 夹具名称
private ObservableCollection<string> _fixtureName = new ObservableCollection<string>();
public ObservableCollection<string> FixtureName
{
get => _fixtureName;
set => SetProperty(ref _fixtureName, value);
}
#endregion
#region 夹具产量
/// <summary>
///夹具产量
/// </summary>
private ObservableCollection<int> _production = new ObservableCollection<int>();
public ObservableCollection<int> Production
{
get => _production;
set => SetProperty(ref _production, value);
}
#endregion
#region 节拍
/// <summary>
///夹具产量
/// </summary>
private ObservableCollection<int> _beat = new ObservableCollection<int>();
public ObservableCollection<int> Beat
{
get => _beat;
set => SetProperty(ref _beat, value);
}
#endregion
#region 总计
private int _totle = 0;
public int Totle
{
get => _totle;
set => SetProperty(ref _totle, value);
}
#endregion
}
}