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.
294 lines
11 KiB
C#
294 lines
11 KiB
C#
using Admin.Core.Common;
|
|
using Admin.Core.IService;
|
|
using Admin.Core.Model;
|
|
using Admin.Core.Service;
|
|
using CommunityToolkit.Mvvm.ComponentModel;
|
|
using CommunityToolkit.Mvvm.Input;
|
|
using LiveCharts;
|
|
using LiveCharts.Defaults;
|
|
using LiveCharts.Wpf;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Pipelines.Sockets.Unofficial;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using System.Windows;
|
|
using System.Windows.Media;
|
|
|
|
namespace Aucma.Core.SheetMetal.ViewModels
|
|
{
|
|
public partial class MaterialStatisticsViewModel : ObservableObject
|
|
{
|
|
private readonly IBaseSpaceInfoServices? _baseSpaceInfoServices;
|
|
private readonly ISysUserInfoServices? _sysUserInfoServices;
|
|
|
|
public MaterialStatisticsViewModel()
|
|
{
|
|
_baseSpaceInfoServices = App.ServiceProvider.GetService<IBaseSpaceInfoServices>();
|
|
_sysUserInfoServices = App.ServiceProvider.GetService<ISysUserInfoServices>();
|
|
//Refresh();
|
|
//RefreshTest();
|
|
}
|
|
[RelayCommand]
|
|
public void RefreshTest()
|
|
{
|
|
//箱壳
|
|
ShellMaterialStockDataGrid.Clear();
|
|
ShellMaterialStockDataGrid.Add(new BaseSpaceInfo() { MaterialType = "BCD-162CST", SpaceStock =7 });
|
|
ShellMaterialStockDataGrid.Add(new BaseSpaceInfo() { MaterialType = "BCD-212CHG", SpaceStock = 6 });
|
|
ShellMaterialStockDataGrid.Add(new BaseSpaceInfo() { MaterialType = "BCD-211CGN", SpaceStock = 9 });
|
|
ShellMaterialStockDataGrid.Add(new BaseSpaceInfo() { MaterialType = "BC/BD-310NF", SpaceStock = 10});
|
|
//内胆
|
|
LinerMaterialStockDataGrid.Clear();
|
|
LinerMaterialStockDataGrid.Add(new BaseSpaceInfo() { MaterialType = "BCD-162CST", SpaceStock = 6 });
|
|
LinerMaterialStockDataGrid.Add(new BaseSpaceInfo() { MaterialType = "BCD-212CHG", SpaceStock = 5 });
|
|
LinerMaterialStockDataGrid.Add(new BaseSpaceInfo() { MaterialType = "BCD-211CGN", SpaceStock = 4 });
|
|
LinerMaterialStockDataGrid.Add(new BaseSpaceInfo() { MaterialType = "BC/BD-310NF", SpaceStock = 11 });
|
|
|
|
//泡前库
|
|
FoamBeforeMaterialStockDataGrid.Clear();
|
|
FoamBeforeMaterialStockDataGrid.Add(new BaseSpaceInfo() { MaterialType = "BCD-162CST", SpaceStock =3 });
|
|
FoamBeforeMaterialStockDataGrid.Add(new BaseSpaceInfo() { MaterialType = "BCD-212CHG", SpaceStock = 3 });
|
|
FoamBeforeMaterialStockDataGrid.Add(new BaseSpaceInfo() { MaterialType = "BCD-211CGN", SpaceStock = 3});
|
|
FoamBeforeMaterialStockDataGrid.Add(new BaseSpaceInfo() { MaterialType = "BC/BD-310NF", SpaceStock = 2 });
|
|
RefreshModeStatusTest();
|
|
}
|
|
|
|
|
|
#region 刷新夹具统计测试
|
|
/// <summary>
|
|
/// 刷新夹具统计
|
|
/// </summary>
|
|
private void RefreshModeStatusTest()
|
|
{
|
|
App.Current.Dispatcher.Invoke((Action)(async () =>
|
|
{
|
|
var modeStatus = await _sysUserInfoServices.StatisticalModelStatus();
|
|
|
|
if (modeStatus != null)
|
|
{
|
|
if (Achievement.Count != 0) Achievement.Clear();
|
|
|
|
ModeTypeList = new List<string>()
|
|
{
|
|
"BCD-162CST",
|
|
"BCD-212CHG",
|
|
"BCD-211CGN",
|
|
"BC/BD-310NF",
|
|
};
|
|
ChartValues<double> achievement = new ChartValues<double>()
|
|
{
|
|
3,4,5,4
|
|
};
|
|
|
|
#region 按夹具状态统计
|
|
|
|
Achievement.Add(new ColumnSeries
|
|
{
|
|
DataLabels = true,
|
|
Title = "夹具状态",
|
|
ScalesYAt = 0,
|
|
Values = achievement,
|
|
Fill = new SolidColorBrush(Color.FromRgb(15, 209, 226)),
|
|
Foreground = Brushes.CadetBlue,
|
|
FontSize = 18
|
|
});
|
|
|
|
#endregion
|
|
}
|
|
}));
|
|
}
|
|
#endregion
|
|
|
|
|
|
|
|
#region 刷新
|
|
[RelayCommand]
|
|
private async void Refresh()
|
|
{
|
|
string shellStoreCode = Appsettings.app("StationInfo", "shellStoreCode");
|
|
string linerStoreCode = Appsettings.app("StationInfo", "linerStoreCode");
|
|
string foamBeforeStoreCode = Appsettings.app("StationInfo", "foamBeforeStoreCode");
|
|
//箱壳物料库存
|
|
ShellMaterialStockDataGrid = new ObservableCollection<BaseSpaceInfo>();
|
|
List<BaseSpaceInfo> shellList =await _baseSpaceInfoServices.GetSpaceInfosByStoreCode(shellStoreCode);
|
|
if (shellList == null) return;
|
|
|
|
shellList.OrderBy(x => x.ObjId);
|
|
var shellResult = from m in shellList
|
|
group m by m.MaterialType into g
|
|
select new BaseSpaceInfo()
|
|
{
|
|
MaterialType = g.Key,
|
|
SpaceStock = g.Sum(m => m.SpaceStock)
|
|
};
|
|
foreach (var item in shellResult)
|
|
{
|
|
if (string.IsNullOrEmpty(item.MaterialType)) continue;
|
|
ShellMaterialStockDataGrid.Add(new BaseSpaceInfo() { MaterialType = item.MaterialType, SpaceStock = item.SpaceStock });
|
|
}
|
|
|
|
//内胆物料库存
|
|
LinerMaterialStockDataGrid = new ObservableCollection<BaseSpaceInfo>();
|
|
List<BaseSpaceInfo> linerList =await _baseSpaceInfoServices.GetSpaceInfosByStoreCode(linerStoreCode);
|
|
var linerResult = from m in linerList
|
|
group m by m.MaterialType into g
|
|
select new BaseSpaceInfo()
|
|
{
|
|
MaterialType = g.Key,
|
|
SpaceStock = g.Sum(m => m.SpaceStock)
|
|
};
|
|
foreach (var item in linerResult)
|
|
{
|
|
if (string.IsNullOrEmpty(item.MaterialType)) continue;
|
|
LinerMaterialStockDataGrid.Add(new BaseSpaceInfo() { MaterialType = item.MaterialType, SpaceStock = item.SpaceStock });
|
|
}
|
|
|
|
//泡前库物料库存
|
|
FoamBeforeMaterialStockDataGrid = new ObservableCollection<BaseSpaceInfo>();
|
|
List<BaseSpaceInfo> foamBeforeList =await _baseSpaceInfoServices.GetSpaceInfosByStoreCode(foamBeforeStoreCode);
|
|
var foamBeforeResult = from m in foamBeforeList
|
|
group m by m.MaterialType into g
|
|
select new BaseSpaceInfo()
|
|
{
|
|
MaterialType = g.Key,
|
|
SpaceStock = g.Sum(m => m.SpaceStock)
|
|
};
|
|
foreach (var item in foamBeforeResult)
|
|
{
|
|
if (string.IsNullOrEmpty(item.MaterialType)) continue;
|
|
FoamBeforeMaterialStockDataGrid.Add(new BaseSpaceInfo() { MaterialType = item.MaterialType, SpaceStock = item.SpaceStock });
|
|
}
|
|
//夹具状态
|
|
RefreshModeStatus();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 关闭窗口
|
|
[RelayCommand]
|
|
private void CloseWindow(object parameter)
|
|
{
|
|
var window = parameter as Window;
|
|
if (window != null)
|
|
{
|
|
window.Close();
|
|
}
|
|
|
|
}
|
|
|
|
|
|
#endregion
|
|
|
|
#region 参数定义
|
|
/// <summary>
|
|
/// 箱壳物料库存DataGrid
|
|
/// </summary>
|
|
private ObservableCollection<BaseSpaceInfo> shellMaterialStockDataGrid=new ObservableCollection<BaseSpaceInfo>();
|
|
|
|
public ObservableCollection<BaseSpaceInfo> ShellMaterialStockDataGrid
|
|
{
|
|
get => shellMaterialStockDataGrid;
|
|
set => SetProperty(ref shellMaterialStockDataGrid, value);
|
|
|
|
}
|
|
|
|
/// <summary>
|
|
/// 内胆物料库存DataGrid
|
|
/// </summary>
|
|
private ObservableCollection<BaseSpaceInfo> linerMaterialStockDataGrid=new ObservableCollection<BaseSpaceInfo>();
|
|
|
|
public ObservableCollection<BaseSpaceInfo> LinerMaterialStockDataGrid
|
|
{
|
|
get => linerMaterialStockDataGrid;
|
|
set => SetProperty(ref linerMaterialStockDataGrid, value);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 泡前库物料库存DataGrid
|
|
/// </summary>
|
|
private ObservableCollection<BaseSpaceInfo> foamBeforeMaterialStockDataGrid = new ObservableCollection<BaseSpaceInfo>();
|
|
|
|
public ObservableCollection<BaseSpaceInfo> FoamBeforeMaterialStockDataGrid
|
|
{
|
|
get => foamBeforeMaterialStockDataGrid;
|
|
set => SetProperty(ref foamBeforeMaterialStockDataGrid, value);
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region 刷新夹具统计
|
|
/// <summary>
|
|
/// 刷新夹具统计
|
|
/// </summary>
|
|
private void RefreshModeStatus()
|
|
{
|
|
App.Current.Dispatcher.Invoke((Action)(async () =>
|
|
{
|
|
var modeStatus = await _sysUserInfoServices.StatisticalModelStatus();
|
|
|
|
if (modeStatus != null)
|
|
{
|
|
if (Achievement.Count != 0) Achievement.Clear();
|
|
|
|
ModeTypeList = new List<string>();
|
|
ChartValues<double> achievement = new ChartValues<double>();
|
|
int hour = 0;
|
|
foreach (var item in modeStatus)
|
|
{
|
|
achievement.Add(Convert.ToInt32(item.YValue));
|
|
ModeTypeList.Add(item.XValue);
|
|
hour++;
|
|
}
|
|
#region 按夹具状态统计
|
|
|
|
Achievement.Add(new ColumnSeries
|
|
{
|
|
DataLabels = true,
|
|
Title = "夹具状态",
|
|
ScalesYAt = 0,
|
|
Values = achievement,
|
|
Fill = new SolidColorBrush(Color.FromRgb(15, 209, 226)),
|
|
Foreground = Brushes.CadetBlue,
|
|
FontSize = 18
|
|
});
|
|
|
|
#endregion
|
|
}
|
|
}));
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region 夹具状态统计
|
|
|
|
#region 夹具状态统计
|
|
/// <summary>
|
|
/// 夹具状态统计
|
|
/// </summary>
|
|
private List<string> modeTypeList;
|
|
|
|
public List<string> ModeTypeList
|
|
{
|
|
get { return modeTypeList; }
|
|
set { modeTypeList = value; }
|
|
}
|
|
#endregion
|
|
|
|
/// <summary>
|
|
/// 夹具状态统计
|
|
/// </summary>
|
|
private SeriesCollection achievement = new SeriesCollection();
|
|
|
|
public SeriesCollection Achievement
|
|
{
|
|
get { return achievement; }
|
|
set { achievement = value; }
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
}
|