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.

198 lines
5.6 KiB
C#

using CommunityToolkit.Mvvm.ComponentModel;
using System;
using System.Collections.ObjectModel;
using log4net;
using Aucma.Core.DoorFoam.Common;
using LiveCharts;
using System.Collections.Generic;
using Admin.Core.Model;
using Admin.Core.Service;
using LiveCharts.Wpf;
1 year ago
using Admin.Core.IService;
using Microsoft.Extensions.DependencyInjection;
using System.Threading.Tasks;
1 year ago
using System.Windows.Media;
/*
1 year ago
*
*/
namespace Aucma.Core.DoorFoam.ViewModels
{
public partial class IndexPageViewModel : ObservableObject
{
private static readonly log4net.ILog log = LogManager.GetLogger(typeof(IndexPageViewModel));
private ObservableCollection<dynamic> listItems = new ObservableCollection<dynamic>();
1 year ago
private readonly IDoorFoamRecordServices? _doorFoamRecordServices;
public IndexPageViewModel()
{
1 year ago
_doorFoamRecordServices = App.ServiceProvider.GetService<IDoorFoamRecordServices>();
StationName = "门体发泡";
MaterialName = "SC-AUCMA-农夫山泉SC 门体";
OrderNo = "8512365486";
BeginTime = DateTime.Now.ToString("yyyy-mm-dd HH:mm:ss");
1 year ago
_=InitEveryDayMethodAsync();
}
1 year ago
/// <summary>
/// 获取今天的数据
/// </summary>
/// <returns></returns>
private async Task InitEveryDayMethodAsync()
{
1 year ago
DateTime startTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 00:00:00"));
DateTime endTime = Convert.ToDateTime(DateTime.Now.ToString("yyyy-MM-dd 23:59:59"));
//var list = await _doorFoamRecordServices.QueryAsync(d => d.BeginTime >= startTime && d.EndTime <= endTime);
ChartValues<double> achievement = new ChartValues<double>();
Random random = new Random();
for (int i = 0; i < 5; i++)
{
achievement.Add(random.Next(60, 100));
}
var column = new ColumnSeries();
column.DataLabels = true;
column.Title = "型号";
column.Values = achievement;
1 year ago
column.Foreground = Brushes.White;
ModelStatistics.Add(column);
ProductionHourList = new List<string>()
{
"12",
"13",
"14",
"15",
"16",
};
ChartValues<double> achievement2 = new ChartValues<double>();
Random random2 = new Random();
for (int i = 0; i < 5; i++)
{
achievement2.Add(random2.Next(60, 100));
}
var column2 = new ColumnSeries();
column2.DataLabels = true;
column2.Title = "产量";
column2.Values = achievement2;
1 year ago
column2.Foreground = Brushes.White;
Achievement.Add(column2);
}
#region 扫描信息
#region 物料条码
private string _stationName;
public string StationName
{
get { return _stationName; }
set
{
_stationName = value;
SetProperty(ref _stationName, value);
}
}
#endregion
#region 物料名称
private string _materialName;
public string MaterialName
{
get { return _materialName; }
set
{
_materialName = value;
SetProperty(ref _materialName, value);
}
}
#endregion
#region 订单信息
private string _orderNo;
public string OrderNo
{
get { return _orderNo; }
set
{
_orderNo = value;
SetProperty(ref _orderNo, value);
}
}
#endregion
#region 开始时间
private string _beginTime;
public string BeginTime
{
get { return _beginTime; }
set
{
_beginTime = value;
SetProperty(ref _beginTime, value);
}
}
#endregion
#endregion
#region 当日产量
#region 日产量柱状图X轴日期
/// <summary>
/// 日产量柱状图X轴日期
/// </summary>
private List<string> productionHourList;
public List<string> ProductionHourList
{
get { return productionHourList; }
set { productionHourList = value; }
}
#endregion
/// <summary>
/// 日产量柱状图
/// </summary>
private SeriesCollection achievement = new SeriesCollection();
public SeriesCollection Achievement
{
get { return achievement; }
set { achievement = value; }
}
#endregion
#region 型号统计
#region 型号统计柱状图x轴物料类型
/// <summary>
/// 型号统计柱状图x轴物料类型
/// </summary>
private List<string> materialNameList;
public List<string> MaterialNameList
{
get { return materialNameList; }
set { materialNameList = value; }
}
#endregion
#region 型号统计柱状图
/// <summary>
/// 型号统计柱状图
/// </summary>
private SeriesCollection modelStatistics = new SeriesCollection();
public SeriesCollection ModelStatistics
{
get { return modelStatistics; }
set { modelStatistics = value; }
}
#endregion
#endregion
}
}